Add ABI information to ARM subtarget.
authorLauro Ramos Venancio <lauro.venancio@gmail.com>
Tue, 13 Feb 2007 19:52:28 +0000 (19:52 +0000)
committerLauro Ramos Venancio <lauro.venancio@gmail.com>
Tue, 13 Feb 2007 19:52:28 +0000 (19:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34245 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMSubtarget.cpp
lib/Target/ARM/ARMSubtarget.h
lib/Target/ARM/ARMTargetMachine.cpp
test/CodeGen/ARM/arguments.ll

index 27889c7818daad48e4b058d5ada8407f10871f46..4363697d3e37e9bff93d9f9420a163a5a9a3c49c 100644 (file)
@@ -26,8 +26,9 @@ ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS)
   , HasVFP2(false)
   , UseThumbBacktraces(false)
   , IsR9Reserved(false)
-  , stackAlignment(8)
-  , TargetType(isELF) { // Default to ELF unless otherwise specified.
+  , stackAlignment(4)
+  , TargetType(isELF) // Default to ELF unless otherwise specified.
+  , TargetABI(ARM_ABI_APCS) {
 
   // Determine default and user specified characteristics
   std::string CPU = "generic";
@@ -49,9 +50,14 @@ ARMSubtarget::ARMSubtarget(const Module &M, const std::string &FS)
 #endif
   }
 
+  if (TT.find("eabi") != std::string::npos)
+    TargetABI = ARM_ABI_AAPCS;
+
+  if (isAAPCS_ABI())
+    stackAlignment = 8;
+
   if (isTargetDarwin()) {
     UseThumbBacktraces = true;
     IsR9Reserved = true;
-    stackAlignment = 4;
-  } 
+  }
 }
index 33e440b0cf411b7b5c453c40c4400addf12bb788..88ceaef7b660a95178ee439da4dbad7ac2a6cc79 100644 (file)
@@ -42,7 +42,7 @@ protected:
 
   /// IsR9Reserved - True if R9 is a not available as general purpose register.
   bool IsR9Reserved;
-  
+
   /// stackAlignment - The minimum alignment known to hold of the stack frame on
   /// entry to the function and which must be maintained by every function.
   unsigned stackAlignment;
@@ -52,6 +52,11 @@ protected:
     isELF, isDarwin
   } TargetType;
 
+  enum {
+    ARM_ABI_APCS,
+    ARM_ABI_AAPCS // ARM EABI
+  } TargetABI;
+
   /// This constructor initializes the data members to match that
   /// of the specified module.
   ///
@@ -71,6 +76,9 @@ protected:
   bool isTargetDarwin() const { return TargetType == isDarwin; }
   bool isTargetELF() const { return TargetType == isELF; }
 
+  bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
+  bool isAAPCS_ABI() const { return TargetABI == ARM_ABI_AAPCS; }
+
   bool isThumb() const { return IsThumb; }
 
   bool useThumbBacktraces() const { return UseThumbBacktraces; }
index 442d25ecc2586d67bd551a2b8cb4d4ef700300eb..31884045225d7545d38f09df337feddaa28cac22 100644 (file)
@@ -34,13 +34,15 @@ namespace {
 ///
 ARMTargetMachine::ARMTargetMachine(const Module &M, const std::string &FS)
   : Subtarget(M, FS),
-    DataLayout(Subtarget.isTargetDarwin() ?
+    DataLayout(Subtarget.isAPCS_ABI() ?
+               //APCS ABI
           (Subtarget.isThumb() ?
            std::string("e-p:32:32-d:32:32-l:32:32-s:16:32-b:8:32-B:8:32-A:32") :
            std::string("e-p:32:32-d:32:32-l:32:32")) :
+               //AAPCS ABI
           (Subtarget.isThumb() ?
-           std::string("e-p:32:32-d:32:64-l:64:64-s:16:32-b:8:32-B:8:32-A:32") :
-           std::string("e-p:32:32-d:32:64-l:64:64"))),
+           std::string("e-p:32:32-d:64:64-l:64:64-s:16:32-b:8:32-B:8:32-A:32") :
+           std::string("e-p:32:32-d:64:64-l:64:64"))),
     InstrInfo(Subtarget),
     FrameInfo(Subtarget) {}
 
index 77cadd6fdfb16b6c7f376ec5315fd60225d12ef7..018be239e30ae663a8ccf9671761168c15c3357e 100644 (file)
@@ -1,5 +1,5 @@
 ; RUN: llvm-as < %s | llc -march=arm &&
-; RUN: llvm-as < %s | llc -mtriple=arm-linux | grep "mov r0, r2" | wc -l | grep 1 &&
+; RUN: llvm-as < %s | llc -mtriple=arm-linux-gnueabi | grep "mov r0, r2" | wc -l | grep 1 &&
 ; RUN: llvm-as < %s | llc -mtriple=arm-apple-darwin | grep "mov r0, r1" | wc -l | grep 1
 
 define i32 @f(i32 %a, i64 %b) {