]> granicus.if.org Git - clang/commitdiff
ARM-Darwin: Use the *-*-darwin-eabi triple for v6m & v7m archs
authorTim Northover <tnorthover@apple.com>
Thu, 24 Oct 2013 10:48:50 +0000 (10:48 +0000)
committerTim Northover <tnorthover@apple.com>
Thu, 24 Oct 2013 10:48:50 +0000 (10:48 +0000)
These arch arguments are used for embedded targets (obviously) which need a
different calling convention to iOS.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193328 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/Targets.cpp
lib/Driver/ToolChains.cpp
test/Driver/darwin-eabi.c
test/Frontend/darwin-eabi.c [new file with mode: 0644]

index 843cc1bbf843329af0ff517a48601c8474643c4e..4deaa640f8a01b84e361a00213f867044245ec26 100644 (file)
@@ -149,7 +149,9 @@ static void getDarwinDefines(MacroBuilder &Builder, const LangOptions &Opts,
     Str[4] = '0' + (Rev % 10);
     Str[5] = '\0';
     Builder.defineMacro("__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__", Str);
-  } else {
+  } else if (Triple.getArchName() != "thumbv6m" &&
+             Triple.getArchName() != "thumbv7m" &&
+             Triple.getArchName() != "thumbv7em") {
     // Note that the Driver allows versions which aren't representable in the
     // define (because we only get a single digit for the minor and micro
     // revision numbers). So, we limit them to the maximum representable
index ec0d8f387cd450c0cce357e1b41914ac94362194..d45966c459f7191fe03a50ac3381fe8ed6fa2977 100644 (file)
@@ -167,10 +167,18 @@ std::string Darwin::ComputeEffectiveClangTriple(const ArgList &Args,
   if (!isTargetInitialized())
     return Triple.getTriple();
 
-  SmallString<16> Str;
-  Str += isTargetIPhoneOS() ? "ios" : "macosx";
-  Str += getTargetVersion().getAsString();
-  Triple.setOSName(Str);
+  if (Triple.getArchName() == "thumbv6m" ||
+      Triple.getArchName() == "thumbv7m" ||
+      Triple.getArchName() == "thumbv7em") {
+    // OS is ios or macosx unless it's the v6m or v7m.
+    Triple.setOS(llvm::Triple::Darwin);
+    Triple.setEnvironment(llvm::Triple::EABI);
+  } else {
+    SmallString<16> Str;
+    Str += isTargetIPhoneOS() ? "ios" : "macosx";
+    Str += getTargetVersion().getAsString();
+    Triple.setOSName(Str);
+  }
 
   return Triple.getTriple();
 }
index 744e536a13e26e9608689c4907049876b5f56bb7..1288fa40608cc44e477ef5fc2df2b94947760eda 100644 (file)
@@ -1,6 +1,12 @@
 // RUN: %clang -arch armv7 -target thumbv7-apple-darwin-eabi -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-AAPCS
 // RUN: %clang -arch armv7s -target thumbv7-apple-ios -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-APCS
 // RUN: %clang -arch armv7s -target thumbv7-apple-darwin -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-APCS
+// RUN: %clang -arch armv6m -target thumbv7-apple-darwin -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-DARWIN-EABI
+// RUN: %clang -arch armv7m -target thumbv7-apple-darwin -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-DARWIN-EABI
+// RUN: %clang -arch armv7em -target thumbv7-apple-darwin -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-DARWIN-EABI
+
+// CHECK-DARWIN-EABI: "-triple" "{{thumbv[67]e?m}}-apple-darwin-eabi"
+// CHECK-IOS: "-triple" "thumbv7" "thumbv7-apple-ios
 
 // CHECK-AAPCS: "-target-abi" "aapcs"
 // CHECK-APCS: "-target-abi" "apcs-gnu"
diff --git a/test/Frontend/darwin-eabi.c b/test/Frontend/darwin-eabi.c
new file mode 100644 (file)
index 0000000..dc0504b
--- /dev/null
@@ -0,0 +1,6 @@
+// RUN: %clang -target x86_64-apple-darwin -arch armv6m -dM -E %s | FileCheck %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7m -dM -E %s | FileCheck %s
+// RUN: %clang -target x86_64-apple-darwin -arch armv7em -dM -E %s | FileCheck %s
+
+// CHECK-NOT: __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__
+// CHECK-NOT: __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__