[PATCH] D125419: [Arm64EC 7/?] clang side of Arm64EC varargs ABI.

Eli Friedman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 11 13:55:05 PDT 2022


efriedma created this revision.
Herald added subscribers: zzheng, kristof.beyls.
Herald added a project: All.
efriedma requested review of this revision.
Herald added a project: clang.

Part of initial Arm64EC patchset.

Don't try to duplicate the existing logic; instead, just call the actual code we use for native x64.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125419

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/arm64ec.c
  clang/test/CodeGenCXX/arm64ec.cpp


Index: clang/test/CodeGenCXX/arm64ec.cpp
===================================================================
--- clang/test/CodeGenCXX/arm64ec.cpp
+++ clang/test/CodeGenCXX/arm64ec.cpp
@@ -2,6 +2,8 @@
 
 // CHECK: @"?g@@YAXUA@@UB@@@Z" = alias void ([2 x float], [4 x float]), void ([2 x float], [4 x float])* @"?g@@$$hYAXUA@@UB@@@Z"
 // CHECK: define dso_local void @"?g@@$$hYAXUA@@UB@@@Z"
+// CHECK: call void (i64, ...) @"?f@@YAXUA@@ZZ"(i64 %{{.*}}, %struct.B* noundef %{{.*}})
 typedef struct { float x[2]; } A;
 typedef struct { float x[4]; } B;
-void g(A a, B b) { }
+void f(A a, ...);
+void g(A a, B b) { f(a, b); }
Index: clang/test/CodeGen/arm64ec.c
===================================================================
--- clang/test/CodeGen/arm64ec.c
+++ clang/test/CodeGen/arm64ec.c
@@ -2,6 +2,8 @@
 
 // CHECK: @g = alias void ([2 x float], [4 x float]), void ([2 x float], [4 x float])* @"#g"
 // CHECK: define dso_local void @"#g"
+// CHECK: call void (i64, ...) @f(i64 %{{.*}}, %struct.B* noundef %{{.*}})
 typedef struct { float x[2]; } A;
 typedef struct { float x[4]; } B;
-void g(A a, B b) { }
+void f(A a, ...);
+void g(A a, B b) { f(a, b); }
Index: clang/lib/CodeGen/TargetInfo.cpp
===================================================================
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2458,6 +2458,12 @@
     return true;
   }
 
+  ABIArgInfo classifyArgForArm64ECVarArg(QualType Ty) {
+    unsigned FreeSSERegs = 0;
+    return classify(Ty, FreeSSERegs, /*IsReturnType=*/false,
+                    /*IsVectorCall=*/false, /*IsRegCall=*/false);
+  }
+
 private:
   ABIArgInfo classify(QualType Ty, unsigned &FreeSSERegs, bool IsReturnType,
                       bool IsVectorCall, bool IsRegCall) const;
@@ -5743,6 +5749,13 @@
                                      unsigned CallingConvention) const {
   Ty = useFirstFieldIfTransparentUnion(Ty);
 
+  if (IsVariadic && getTarget().getTriple().isWindowsArm64EC()) {
+    // Arm64EC varargs functions use the x86_64 classification rules,
+    // not the AArch64 ABI rules.
+    WinX86_64ABIInfo Win64ABIInfo(CGT, X86AVXABILevel::None);
+    return Win64ABIInfo.classifyArgForArm64ECVarArg(Ty);
+  }
+
   // Handle illegal vector types here.
   if (isIllegalVectorType(Ty))
     return coerceIllegalVector(Ty);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125419.428768.patch
Type: text/x-patch
Size: 2322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220511/ddaf92ad/attachment-0001.bin>


More information about the cfe-commits mailing list