Sorry, I sent this patch to the llvm-commit list... See the first part
of the patch in llvm-commit list.

The attached patch adds support for EABI triples in Clang (from today's
r123755) regarding bug #8957

http://llvm.org/bugs/show_bug.cgi?id=8957

Rationale:

Clang was not parsing target triples involving EABI and was generating
wrong IR (wrong PCS) and passing the wrong information down llc via
the target-triple printed in IR. I've fixed this by adding the parsing
of EABI into LLVM's Triple class and using it to choose the correct
PCS in Clang's Tools.

There's still some edges to cover, such as the decisions of which PCS
to use based on Darwin's defaults (v6/v7). We should add support for
architecture definitions (TargetData?) to Clang, to be able to
correctly pass the options to llc AND re-generate the correct target
triple in the final IR.

This patch (2/2):

This are Clang's modifications to use the EABI triple recognition and
set the according float-abi and procedure call standards.

The patch doesn't change Darwin's default on "soft" for architectures
older than v6 (a bit odd), but it doesn't add this rule to EABI
triples, since the old APCS was deprecated in the current EABI.
However, functions with ellipsis and other special features (?) can
still use the "C" calling convention available in LLVM.

The Environment check was added on the OS's default label, which
although not perfect, it's the best place now to avoid regressions.



-- 
cheers,
--renato
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp	(revision 123755)
+++ lib/Driver/Tools.cpp	(working copy)
@@ -428,13 +428,16 @@
     ABIName = A->getValue(Args);
   } else {
     // Select the default based on the platform.
-    llvm::StringRef env = Triple.getEnvironmentName();
-    if (env == "gnueabi")
+    switch(Triple.getEnvironment()) {
+    case llvm::Triple::GNUEABI:
       ABIName = "aapcs-linux";
-    else if (env == "eabi")
+      break;
+    case llvm::Triple::EABI:
       ABIName = "aapcs";
-    else
+      break;
+    default:
       ABIName = "apcs-gnu";
+    }
   }
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName);
@@ -481,8 +484,7 @@
     }
 
     case llvm::Triple::Linux: {
-      llvm::StringRef Env = getToolChain().getTriple().getEnvironmentName();
-      if (Env == "gnueabi") {
+      if (getToolChain().getTriple().getEnvironment() == llvm::Triple::GNUEABI) {
         FloatABI = "softfp";
         break;
       }
@@ -490,10 +492,20 @@
     // fall through
 
     default:
-      // Assume "soft", but warn the user we are guessing.
-      FloatABI = "soft";
-      D.Diag(clang::diag::warn_drv_assuming_mfloat_abi_is) << "soft";
-      break;
+      switch(Triple.getEnvironment()) {
+      case llvm::Triple::GNUEABI:
+        FloatABI = "softfp";
+        break;
+      case llvm::Triple::EABI:
+        // EABI is always AAPCS, and if it was not marked 'hard', it's softfp
+        FloatABI = "softfp";
+        break;
+      default:
+        // Assume "soft", but warn the user we are guessing.
+        FloatABI = "soft";
+        D.Diag(clang::diag::warn_drv_assuming_mfloat_abi_is) << "soft";
+        break;
+      }
     }
   }
 
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to