[llvm-commits] [llvm-gcc-4.2] r75681 - in /llvm-gcc-4.2/trunk/gcc: config/i386/i386.c llvm-convert.cpp

Dale Johannesen dalej at apple.com
Tue Jul 14 14:12:10 PDT 2009


Author: johannes
Date: Tue Jul 14 16:11:44 2009
New Revision: 75681

URL: http://llvm.org/viewvc/llvm-project?rev=75681&view=rev
Log:
Handle hard registers AH and friends in inline asm.
Before they were only shown in ASM_USES which we
didn't handle.  Also change references to AL to
actually generate AL instead of AX (we need to
distinguish AL from AH, after all).  This allows us
to disable ASM_USES altogether.
gcc.apple/asm-block-13.c
gcc.apple/asm-block-33.c


Modified:
    llvm-gcc-4.2/trunk/gcc/config/i386/i386.c
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.c?rev=75681&r1=75680&r2=75681&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/i386.c (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.c Tue Jul 14 16:11:44 2009
@@ -22060,9 +22060,18 @@
       enum machine_mode mode = VOIDmode;
       if (IDENTIFIER_POINTER (arg)[1] == 'e')
 	mode = SImode;
+/* LLVM LOCAL begin */
+/* Accept H registers for LLVM, this totally obviates need for ASM_USES. */
+#ifndef ENABLE_LLVM
       else if (/* IDENTIFIER_POINTER (arg)[2] == 'h'
 		  || */ IDENTIFIER_POINTER (arg)[2] == 'l')
 	mode = QImode;
+#else
+      else if (IDENTIFIER_POINTER (arg)[2] == 'h'
+               || IDENTIFIER_POINTER (arg)[2] == 'l')
+	mode = QImode;
+#endif
+/* LLVM LOCAL end */
       else if (IDENTIFIER_POINTER (arg)[2] == 'x')
 	mode = HImode;
       else if (IDENTIFIER_POINTER (arg)[1] == 'r')

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=75681&r1=75680&r2=75681&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Jul 14 16:11:44 2009
@@ -4288,13 +4288,17 @@
     // If this output register is pinned to a machine register, use that machine
     // register instead of the specified constraint.
     if (TREE_CODE(Operand) == VAR_DECL && DECL_HARD_REGISTER(Operand)) {
-      int RegNum = decode_reg_name(extractRegisterName(Operand));
+      const char* RegName = extractRegisterName(Operand);
+      int RegNum = decode_reg_name(RegName);
       if (RegNum >= 0) {
-        unsigned RegNameLen = strlen(reg_names[RegNum]);
+        // Constraints don't have the leading %, the variable names do
+        if (*RegName == '%')
+          RegName++;
+        unsigned RegNameLen = strlen(RegName);
         char *NewConstraint = (char*)alloca(RegNameLen+4);
         NewConstraint[0] = '=';
         NewConstraint[1] = '{';
-        memcpy(NewConstraint+2, reg_names[RegNum], RegNameLen);
+        memcpy(NewConstraint+2, RegName, RegNameLen);
         NewConstraint[RegNameLen+2] = '}';
         NewConstraint[RegNameLen+3] = 0;
         SimplifiedConstraint = NewConstraint;
@@ -4437,27 +4441,29 @@
     
     // If this output register is pinned to a machine register, use that machine
     // register instead of the specified constraint.
-    int RegNum;
-    if (TREE_CODE(Val) == VAR_DECL && DECL_HARD_REGISTER(Val) &&
-        (RegNum = decode_reg_name(extractRegisterName(Val))) >= 0) {
-      ConstraintStr += '{';
-      ConstraintStr += reg_names[RegNum];
-      ConstraintStr += '}';
-    } else {
-      // If there is a simpler form for the register constraint, use it.
-      std::string Simplified = CanonicalizeConstraint(Constraint);
-      ConstraintStr += Simplified;
+    if (TREE_CODE(Val) == VAR_DECL && DECL_HARD_REGISTER(Val)) {
+      const char *RegName = extractRegisterName(Val);
+      int RegNum = decode_reg_name(RegName);
+      if (RegNum >= 0) {
+        if (*RegName == '%')      // Variables have leading %.
+          RegName++;              // Constraints don't.
+        ConstraintStr += '{';
+        ConstraintStr += RegName;
+        ConstraintStr += '}';
+        continue;
+      }
     }
+
+    // If there is a simpler form for the register constraint, use it.
+    std::string Simplified = CanonicalizeConstraint(Constraint);
+    ConstraintStr += Simplified;
   }
   
-  if (ASM_USES(exp)) {
-    // FIXME: Figure out what ASM_USES means.
-    error("%Hcode warrior/ms asm not supported yet in %qs", &EXPR_LOCATION(exp),
-          TREE_STRING_POINTER(ASM_STRING(exp)));
-    if (NumChoices>1)
-      FreeConstTupleStrings(ReplacementStrings, NumInputs+NumOutputs);
-    return 0;
-  }
+  // ASM_USES contains info about certain hard regs which are used as inputs.
+  // gcc represents the xH registers on x86 this way because of deficiencies
+  // in the way gcc can represent registers internally.  llvm-gcc can represent
+  // these as normal inputs, so we aren't using ASM_USES.
+  assert(ASM_USES(exp)==0);
   
   // Process clobbers.
 
@@ -4483,8 +4489,10 @@
       ConstraintStr += ",~{memory}";
       break;
     default:     // Normal register name.
+      if (*RegName == '%')
+        RegName++;
       ConstraintStr += ",~{";
-      ConstraintStr += reg_names[RegCode];
+      ConstraintStr += RegName;
       ConstraintStr += "}";
       break;
     }





More information about the llvm-commits mailing list