[cfe-commits] r81595 - in /cfe/trunk: lib/CodeGen/TargetABIInfo.cpp test/CodeGen/arm-apcs-arguments.c

Daniel Dunbar daniel at zuster.org
Fri Sep 11 18:00:39 PDT 2009


Author: ddunbar
Date: Fri Sep 11 20:00:39 2009
New Revision: 81595

URL: http://llvm.org/viewvc/llvm-project?rev=81595&view=rev
Log:
Stub out room for ARM APCS ABI implementation (and AAPCS_VFP, although you can't
hit this via command line options yet).

Added:
    cfe/trunk/test/CodeGen/arm-apcs-arguments.c
Modified:
    cfe/trunk/lib/CodeGen/TargetABIInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetABIInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetABIInfo.cpp?rev=81595&r1=81594&r2=81595&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/TargetABIInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetABIInfo.cpp Fri Sep 11 20:00:39 2009
@@ -1327,6 +1327,22 @@
 namespace {
 
 class ARMABIInfo : public ABIInfo {
+public:
+  enum ABIKind {
+    APCS = 0,
+    AAPCS = 1,
+    AAPCS_VFP
+  };
+
+private:
+  ABIKind Kind;
+
+public:
+  ARMABIInfo(ABIKind _Kind) : Kind(_Kind) {}
+
+private:
+  ABIKind getABIKind() const { return Kind; }
+
   ABIArgInfo classifyReturnType(QualType RetTy,
                                 ASTContext &Context,
                                 llvm::LLVMContext &VMCOntext) const;
@@ -1352,6 +1368,21 @@
        it != ie; ++it) {
     it->info = classifyArgumentType(it->type, Context, VMContext);
   }
+
+  // ARM always overrides the calling convention.
+  switch (getABIKind()) {
+  case APCS:
+    FI.setEffectiveCallingConvention(llvm::CallingConv::ARM_APCS);
+    break;
+
+  case AAPCS:
+    FI.setEffectiveCallingConvention(llvm::CallingConv::ARM_AAPCS);
+    break;
+
+  case AAPCS_VFP:
+    FI.setEffectiveCallingConvention(llvm::CallingConv::ARM_AAPCS_VFP);
+    break;
+  }
 }
 
 ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty,
@@ -1544,8 +1575,14 @@
 
   case llvm::Triple::arm:
   case llvm::Triple::thumb:
-    // FIXME: Support for OABI?
-    return *(TheABIInfo = new ARMABIInfo());
+    // FIXME: We should get this from the target, we also need a -target-abi
+    // because the user should have some control over this.
+    //
+    // FIXME: We want to know the float calling convention as well.
+    if (Triple.getOS() == llvm::Triple::Darwin)
+      return *(TheABIInfo = new ARMABIInfo(ARMABIInfo::APCS));
+
+    return *(TheABIInfo = new ARMABIInfo(ARMABIInfo::AAPCS));
 
   case llvm::Triple::pic16:
     return *(TheABIInfo = new PIC16ABIInfo());

Added: cfe/trunk/test/CodeGen/arm-apcs-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-apcs-arguments.c?rev=81595&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/arm-apcs-arguments.c (added)
+++ cfe/trunk/test/CodeGen/arm-apcs-arguments.c Fri Sep 11 20:00:39 2009
@@ -0,0 +1,6 @@
+// RUN: clang-cc -triple armv7-apple-darwin9 -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define arm_apcscc signext i8 @f0()
+char f0(void) {
+  return 0;
+}





More information about the cfe-commits mailing list