[llvm-branch-commits] [llvm-gcc-branch] r76145 - in /llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc: config/i386/i386.h llvm-convert.cpp

Bill Wendling isanbard at gmail.com
Thu Jul 16 19:20:46 PDT 2009


Author: void
Date: Thu Jul 16 21:20:44 2009
New Revision: 76145

URL: http://llvm.org/viewvc/llvm-project?rev=76145&view=rev
Log:
--- Merging r76128 into '.':
U    gcc/llvm-convert.cpp
U    gcc/config/i386/i386.h

Modified:
    llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/config/i386/i386.h
    llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/config/i386/i386.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/config/i386/i386.h?rev=76145&r1=76144&r2=76145&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/config/i386/i386.h (original)
+++ llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/config/i386/i386.h Thu Jul 16 21:20:44 2009
@@ -3915,6 +3915,13 @@
 #define LLVM_TARGET_INTRINSIC_LOWER(EXP, BUILTIN_CODE, DESTLOC, RESULT,       \
                                     DESTTY, OPS)                              \
         TargetIntrinsicLower(EXP, BUILTIN_CODE, DESTLOC, RESULT, DESTTY, OPS);
+
+/* When extracting a register name for a constraint, use the string extracted
+   from the magic symbol built for that register, rather than reg_names.
+   The latter maps both AH and AL to the same thing, which means we can't
+   distinguish them. */
+#define LLVM_DO_NOT_USE_REG_NAMES
+
 #endif /* ENABLE_LLVM */
 /* LLVM LOCAL end */
 

Modified: llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp?rev=76145&r1=76144&r2=76145&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Bender-SWB/gcc/llvm-convert.cpp Thu Jul 16 21:20:44 2009
@@ -4070,6 +4070,22 @@
     free((char *)ReplacementStrings[i]);
 }
 
+// When extracting a register name from a DECL_HARD_REGISTER variable,
+// we normally want to look up RegNum in reg_names.  This works on most
+// targets, where ADDITIONAL_REGISTER_NAMES are true synonyms.  It does not
+// work on x86, where ADDITIONAL_REGISTER_NAMES are overlapping subregisters;
+// in particular AH and AL can't be distinguished if we go through reg_names.
+static const char* getConstraintRegNameFromGccTables(const char *RegName,
+                                                     unsigned int RegNum) {
+#ifdef LLVM_DO_NOT_USE_REG_NAMES
+  if (*RegName == '%')
+    RegName++;
+  return RegName;
+#else
+  return reg_names[RegNum];
+#endif
+}
+
 Value *TreeToLLVM::EmitASM_EXPR(tree exp) {
   unsigned NumInputs = list_length(ASM_INPUTS(exp));
   unsigned NumOutputs = list_length(ASM_OUTPUTS(exp));
@@ -4188,9 +4204,7 @@
       const char* RegName = extractRegisterName(Operand);
       int RegNum = decode_reg_name(RegName);
       if (RegNum >= 0) {
-        // Constraints don't have the leading %, the variable names do
-        if (*RegName == '%')
-          RegName++;
+        RegName = getConstraintRegNameFromGccTables(RegName, RegNum);
         unsigned RegNameLen = strlen(RegName);
         char *NewConstraint = (char*)alloca(RegNameLen+4);
         NewConstraint[0] = '=';
@@ -4342,8 +4356,7 @@
       const char *RegName = extractRegisterName(Val);
       int RegNum = decode_reg_name(RegName);
       if (RegNum >= 0) {
-        if (*RegName == '%')      // Variables have leading %.
-          RegName++;              // Constraints don't.
+        RegName = getConstraintRegNameFromGccTables(RegName, RegNum);
         ConstraintStr += '{';
         ConstraintStr += RegName;
         ConstraintStr += '}';
@@ -4386,8 +4399,7 @@
       ConstraintStr += ",~{memory}";
       break;
     default:     // Normal register name.
-      if (*RegName == '%')
-        RegName++;
+      RegName = getConstraintRegNameFromGccTables(RegName, RegCode);
       ConstraintStr += ",~{";
       ConstraintStr += RegName;
       ConstraintStr += "}";





More information about the llvm-branch-commits mailing list