[cfe-dev] Workaround for bug 16070 ?

Stephen Kelly steveire at gmail.com
Wed Jul 10 07:26:20 PDT 2013


Tim Northover wrote:

> Hi Stephen,
> 
> Ah, it appears there are two getARMTargetCPU functions; the one that
> makes the first decision is in ToolChain.cpp. This then gets used to
> determine the suffix added to the triple.
> 
> Sorry about that.
> 
> Tim.

Ah, ok.

This patch solves the problem for me, but I have no idea if it is correct:

diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index 8676f7f..51e06d8 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -201,7 +201,7 @@ static const char *getARMTargetCPU(const ArgList &Args,
     .Case("xscale", "xscale")
     // If all else failed, return the most base CPU with thumb interworking
     // supported by LLVM.
-    .Default("arm7tdmi");
+    .Default("cortex-a8");
 }


Is this better?

diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index 8676f7f..6dad2f1 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -174,7 +174,7 @@ static const char *getARMTargetCPU(const ArgList &Args,
     MArch = Triple.getArchName();
   }
 
-  return llvm::StringSwitch<const char *>(MArch)
+  const char *result = llvm::StringSwitch<const char *>(MArch)
     .Cases("armv2", "armv2a","arm2")
     .Case("armv3", "arm6")
     .Case("armv3m", "arm7m")
@@ -199,9 +199,14 @@ static const char *getARMTargetCPU(const ArgList &Args,
     .Case("ep9312", "ep9312")
     .Case("iwmmxt", "iwmmxt")
     .Case("xscale", "xscale")
-    // If all else failed, return the most base CPU with thumb interworking
-    // supported by LLVM.
-    .Default("arm7tdmi");
+    .Default(0);
+
+  if (result)
+    return result;
+
+  // If all else failed, return the most base CPU with thumb interworking
+  // supported by LLVM.
+  return Triple.HasHardwareFloat() ? "cortex-a8" : "arm7tdmi";
 }
 
Is there an implementation of something like Triple.HasHardwareFloat() ?

I see that this exists in Toolchains.cpp... :

  static const char *const ARMHFTriples[] = { "arm-linux-gnueabihf",
                                              "armv7hl-redhat-linux-gnueabi"   
  };

Thanks,

Steve.





More information about the cfe-dev mailing list