[PATCH v2] fix compilation with -march=armv4 / no -mcpu and gas

Jeroen Hofstee jeroen at myspectrum.nl
Wed Jun 12 14:08:13 PDT 2013


Hello,

When clang is invoked with -march=armv4 and no -mcpu is
specified, the arm7tdmi cpu was selected as reference.
That causes clang to emit bx lr instructions since its
architecture is armv4t. When gas is used for assembling the
-march=armv4 is passed on and hence fails with:

     "selected processor does not support ARM mode `bx lr'"

Attached patch makes the strongarm the reference cpu for
armv4 to resolve the problem. Also the default is updated,
since the armv4 is more basic then armv4t.

changes for v2
--------------------
In v1 the default cpu was changed to become strongarm,
in accordance with the comment. As mentioned by Tim
Northover, this is a doubtful change and a topic of its own.
Ubuntu gcc arm uses arm5t e.g. as a default. Therefore
don't change the default, just update the comment instead.

--
For completeness sake, I don't have commit permissions and
would be appreciated if someone picks this up who does.

Regards,
Jeroen

-------------- next part --------------
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 183857)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -446,6 +446,7 @@
 // FIXME: tblgen this, or kill it!
 static const char *getLLVMArchSuffixForARM(StringRef CPU) {
   return llvm::StringSwitch<const char *>(CPU)
+    .Case("strongarm", "v4")
     .Cases("arm7tdmi", "arm7tdmi-s", "arm710t", "v4t")
     .Cases("arm720t", "arm9", "arm9tdmi", "v4t")
     .Cases("arm920", "arm920t", "arm922t", "v4t")
@@ -510,7 +511,8 @@
     .Cases("armv2", "armv2a","arm2")
     .Case("armv3", "arm6")
     .Case("armv3m", "arm7m")
-    .Cases("armv4", "armv4t", "arm7tdmi")
+    .Case("armv4", "strongarm")
+    .Case("armv4t", "arm7tdmi")
     .Cases("armv5", "armv5t", "arm10tdmi")
     .Cases("armv5e", "armv5te", "arm1022e")
     .Case("armv5tej", "arm926ej-s")
@@ -528,7 +530,8 @@
     .Case("ep9312", "ep9312")
     .Case("iwmmxt", "iwmmxt")
     .Case("xscale", "xscale")
-    // If all else failed, return the most base CPU LLVM supports.
+    // If all else failed, return the most base CPU with thumb interworking
+    // supported by LLVM.
     .Default("arm7tdmi");
 }
 
Index: lib/Driver/ToolChain.cpp
===================================================================
--- lib/Driver/ToolChain.cpp	(revision 183857)
+++ lib/Driver/ToolChain.cpp	(working copy)
@@ -177,7 +177,8 @@
     .Cases("armv2", "armv2a","arm2")
     .Case("armv3", "arm6")
     .Case("armv3m", "arm7m")
-    .Cases("armv4", "armv4t", "arm7tdmi")
+    .Case("armv4", "strongarm")
+    .Case("armv4t", "arm7tdmi")
     .Cases("armv5", "armv5t", "arm10tdmi")
     .Cases("armv5e", "armv5te", "arm1026ejs")
     .Case("armv5tej", "arm926ej-s")
@@ -196,7 +197,8 @@
     .Case("ep9312", "ep9312")
     .Case("iwmmxt", "iwmmxt")
     .Case("xscale", "xscale")
-    // If all else failed, return the most base CPU LLVM supports.
+    // If all else failed, return the most base CPU with thumb interworking
+    // supported by LLVM.
     .Default("arm7tdmi");
 }
 
@@ -207,6 +209,7 @@
 // FIXME: tblgen this, or kill it!
 static const char *getLLVMArchSuffixForARM(StringRef CPU) {
   return llvm::StringSwitch<const char *>(CPU)
+    .Case("strongarm", "v4")
     .Cases("arm7tdmi", "arm7tdmi-s", "arm710t", "v4t")
     .Cases("arm720t", "arm9", "arm9tdmi", "v4t")
     .Cases("arm920", "arm920t", "arm922t", "v4t")


More information about the cfe-commits mailing list