[clang] [Clang][LoongArch] Add ABI implementation of passing vectors (PR #68954)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 12 21:49:17 PDT 2023


https://github.com/yjijd created https://github.com/llvm/llvm-project/pull/68954

None

>From 74d9ea74aea28db6f5a3a4c6dfccb132d87d1fa8 Mon Sep 17 00:00:00 2001
From: licongtian <licongtian at loongson.cn>
Date: Tue, 10 Oct 2023 15:51:58 +0800
Subject: [PATCH] [Clang][LoongArch] Add ABI implementation of passing vectors

---
 clang/lib/CodeGen/Targets/LoongArch.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/clang/lib/CodeGen/Targets/LoongArch.cpp b/clang/lib/CodeGen/Targets/LoongArch.cpp
index 7483bf6d6d1e8e2..26c68c3583b2a19 100644
--- a/clang/lib/CodeGen/Targets/LoongArch.cpp
+++ b/clang/lib/CodeGen/Targets/LoongArch.cpp
@@ -321,6 +321,13 @@ ABIArgInfo LoongArchABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
     return ABIArgInfo::getDirect();
   }
 
+  // Pass 128-bit/256-bit vector values via vector registers directly.
+  if (Ty->isVectorType() && (((getContext().getTypeSize(Ty) == 128) &&
+                              (getTarget().hasFeature("lsx"))) ||
+                             ((getContext().getTypeSize(Ty) == 256) &&
+                              getTarget().hasFeature("lasx"))))
+    return ABIArgInfo::getDirect();
+
   // Complex types for the *f or *d ABI must be passed directly rather than
   // using CoerceAndExpand.
   if (IsFixed && Ty->isComplexType() && FRLen && FARsLeft >= 2) {



More information about the cfe-commits mailing list