[llvm] r224489 - Model ARM backend ABI selection after the front end code doing the

Eric Christopher echristo at gmail.com
Wed Dec 17 18:08:45 PST 2014


Author: echristo
Date: Wed Dec 17 20:08:45 2014
New Revision: 224489

URL: http://llvm.org/viewvc/llvm-project?rev=224489&view=rev
Log:
Model ARM backend ABI selection after the front end code doing the
same. This will change the "bare metal" ABI from APCS to AAPCS.

The only difference between the front and back end code is that
the code for Triple::GNU was added for environment. That will migrate
to the front end shortly.

Tests updated with the ABI they were originally testing in the case
of bare metal (e.g. -mtriple armv7) or with a -gnu for arm-linux
triples.

Modified:
    llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
    llvm/trunk/test/CodeGen/ARM/arm-abi-attr.ll
    llvm/trunk/test/CodeGen/ARM/atomic-64bit.ll
    llvm/trunk/test/CodeGen/ARM/dagcombine-concatvector.ll
    llvm/trunk/test/CodeGen/ARM/emit-big-cst.ll
    llvm/trunk/test/CodeGen/ARM/tail-call.ll

Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=224489&r1=224488&r2=224489&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Wed Dec 17 20:08:45 2014
@@ -225,8 +225,8 @@ void ARMSubtarget::initSubtargetFeatures
   // Insert the architecture feature derived from the target triple into the
   // feature string. This is important for setting features that are implied
   // based on the architecture version.
-  std::string ArchFS = ARM_MC::ParseARMTriple(TargetTriple.getTriple(),
-                                              CPUString);
+  std::string ArchFS =
+      ARM_MC::ParseARMTriple(TargetTriple.getTriple(), CPUString);
   if (!FS.empty()) {
     if (!ArchFS.empty())
       ArchFS = ArchFS + "," + FS.str();
@@ -246,29 +246,45 @@ void ARMSubtarget::initSubtargetFeatures
   InstrItins = getInstrItineraryForCPU(CPUString);
 
   if (TargetABI == ARM_ABI_UNKNOWN) {
-    switch (TargetTriple.getEnvironment()) {
-    case Triple::Android:
-    case Triple::EABI:
-    case Triple::EABIHF:
-    case Triple::GNUEABI:
-    case Triple::GNUEABIHF:
-      TargetABI = ARM_ABI_AAPCS;
-      break;
-    default:
-      if (TargetTriple.isOSBinFormatMachO() &&
-          TargetTriple.getOS() == Triple::UnknownOS)
+    // FIXME: This is duplicated code from the front end and should be unified.
+    if (TargetTriple.isOSBinFormatMachO()) {
+      if (TargetTriple.getEnvironment() == llvm::Triple::EABI ||
+          (TargetTriple.getOS() == llvm::Triple::UnknownOS &&
+           TargetTriple.getObjectFormat() == llvm::Triple::MachO) ||
+          CPU.startswith("cortex-m")) {
         TargetABI = ARM_ABI_AAPCS;
-      else
+      } else {
         TargetABI = ARM_ABI_APCS;
-      break;
+      }
+    } else if (TargetTriple.isOSWindows()) {
+      // FIXME: this is invalid for WindowsCE
+      TargetABI = ARM_ABI_AAPCS;
+    } else {
+      // Select the default based on the platform.
+      switch (TargetTriple.getEnvironment()) {
+      case llvm::Triple::Android:
+      case llvm::Triple::GNUEABI:
+      case llvm::Triple::GNUEABIHF:
+      case llvm::Triple::EABIHF:
+      case llvm::Triple::EABI:
+        TargetABI = ARM_ABI_AAPCS;
+        break;
+      case llvm::Triple::GNU:
+	TargetABI = ARM_ABI_APCS;
+	break;
+      default:
+        if (TargetTriple.getOS() == llvm::Triple::NetBSD)
+          TargetABI = ARM_ABI_APCS;
+        else
+          TargetABI = ARM_ABI_AAPCS;
+        break;
+      }
     }
   }
 
   // FIXME: this is invalid for WindowsCE
-  if (isTargetWindows()) {
-    TargetABI = ARM_ABI_AAPCS;
+  if (isTargetWindows())
     NoARM = true;
-  }
 
   if (isAAPCS_ABI())
     stackAlignment = 8;

Modified: llvm/trunk/test/CodeGen/ARM/arm-abi-attr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/arm-abi-attr.ll?rev=224489&r1=224488&r2=224489&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/arm-abi-attr.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/arm-abi-attr.ll Wed Dec 17 20:08:45 2014
@@ -1,5 +1,5 @@
-; RUN: llc -mtriple=arm-linux < %s | FileCheck %s --check-prefix=APCS
-; RUN: llc -mtriple=arm-linux -mattr=apcs < %s | \
+; RUN: llc -mtriple=arm-linux-gnu < %s | FileCheck %s --check-prefix=APCS
+; RUN: llc -mtriple=arm-linux-gnu -mattr=apcs < %s | \
 ; RUN: FileCheck %s --check-prefix=APCS
 ; RUN: llc -mtriple=arm-linux-gnueabi -mattr=apcs < %s | \
 ; RUN: FileCheck %s --check-prefix=APCS

Modified: llvm/trunk/test/CodeGen/ARM/atomic-64bit.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/atomic-64bit.ll?rev=224489&r1=224488&r2=224489&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/atomic-64bit.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/atomic-64bit.ll Wed Dec 17 20:08:45 2014
@@ -1,6 +1,6 @@
 ; RUN: llc < %s -mtriple=armv7-apple-ios | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LE
 ; RUN: llc < %s -mtriple=thumbv7-none-linux-gnueabihf | FileCheck %s --check-prefix=CHECK-THUMB --check-prefix=CHECK-THUMB-LE
-; RUN: llc < %s -mtriple=armebv7 | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BE
+; RUN: llc < %s -mtriple=armebv7 -mattr=apcs | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-BE
 ; RUN: llc < %s -mtriple=thumbebv7-none-linux-gnueabihf | FileCheck %s --check-prefix=CHECK-THUMB --check-prefix=CHECK-THUMB-BE
 
 define i64 @test1(i64* %ptr, i64 %val) {

Modified: llvm/trunk/test/CodeGen/ARM/dagcombine-concatvector.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/dagcombine-concatvector.ll?rev=224489&r1=224488&r2=224489&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/dagcombine-concatvector.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/dagcombine-concatvector.ll Wed Dec 17 20:08:45 2014
@@ -1,5 +1,5 @@
 ; RUN: llc < %s -mtriple=thumbv7s-apple-ios3.0.0 -mcpu=generic | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-LE
-; RUN: llc < %s -mtriple=thumbeb -mattr=v7,neon | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-BE
+; RUN: llc < %s -mtriple=thumbeb -mattr=apcs -mattr=v7,neon | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-BE
 
 ; PR15525
 ; CHECK-LABEL: test1:

Modified: llvm/trunk/test/CodeGen/ARM/emit-big-cst.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/emit-big-cst.ll?rev=224489&r1=224488&r2=224489&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/emit-big-cst.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/emit-big-cst.ll Wed Dec 17 20:08:45 2014
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=thumbv7-unknown-unknown < %s | FileCheck %s
+; RUN: llc -mtriple=thumbv7-unknown-unknown -mattr=apcs < %s | FileCheck %s
 ; Check assembly printing of odd constants.
 
 ; CHECK: bigCst:

Modified: llvm/trunk/test/CodeGen/ARM/tail-call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/tail-call.ll?rev=224489&r1=224488&r2=224489&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/tail-call.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/tail-call.ll Wed Dec 17 20:08:45 2014
@@ -1,5 +1,6 @@
-; RUN: llc -mtriple armv7 -O0 -o - < %s | FileCheck %s -check-prefix CHECK-TAIL
-; RUN: llc -mtriple armv7 -O0 -disable-tail-calls -o - < %s \
+; RUN: llc -mtriple armv7 -mattr=apcs -O0 -o - < %s \
+; RUN:   | FileCheck %s -check-prefix CHECK-TAIL
+; RUN: llc -mtriple armv7 -mattr=apcs -O0 -disable-tail-calls -o - < %s \
 ; RUN:   | FileCheck %s -check-prefix CHECK-NO-TAIL
 
 declare i32 @callee(i32 %i)





More information about the llvm-commits mailing list