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

Bob Wilson bob.wilson at apple.com
Tue Jul 20 16:11:13 PDT 2010


Author: bwilson
Date: Tue Jul 20 18:11:13 2010
New Revision: 108963

URL: http://llvm.org/viewvc/llvm-project?rev=108963&view=rev
Log:
Add a new target-specific macro to control how the inline assembly "p"
constraint is canonicalized.

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

Modified: llvm-gcc-4.2/trunk/gcc/config/i386/i386.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/i386.h?rev=108963&r1=108962&r2=108963&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/config/i386/i386.h (original)
+++ llvm-gcc-4.2/trunk/gcc/config/i386/i386.h Tue Jul 20 18:11:13 2010
@@ -3932,6 +3932,11 @@
      if (nm && (*nm == '%' || *nm == '#')) ++nm; \
      ((!nm || ISDIGIT (*nm)) ? reg_names[REG_NUM] : nm); })
 
+/* LLVM_CANONICAL_ADDRESS_CONSTRAINTS - Valid x86 memory addresses include
+   symbolic values and immediates.  Canonicalize GCC's "p" constraint for
+   memory addresses to allow both memory and immediate operands. */
+#define LLVM_CANONICAL_ADDRESS_CONSTRAINTS "im"
+
 /* Propagate code model setting to backend */
 #define LLVM_SET_MACHINE_OPTIONS(argvec)                \
   do {                                                  \

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=108963&r1=108962&r2=108963&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Jul 20 18:11:13 2010
@@ -4249,6 +4249,15 @@
 #define LLVM_GET_REG_NAME(REG_NAME, REG_NUM) reg_names[REG_NUM]
 #endif
 
+// LLVM_CANONICAL_ADDRESS_CONSTRAINTS - GCC defines the "p" constraint to
+// allow a valid memory address, but targets differ widely on what is allowed
+// as an address.  This macro is a string containing the canonical constraint
+// characters that are conservatively valid addresses.  Default to allowing an
+// address in a register, since that works for many targets.
+#ifndef LLVM_CANONICAL_ADDRESS_CONSTRAINTS
+#define LLVM_CANONICAL_ADDRESS_CONSTRAINTS "r"
+#endif
+
 /// Reads from register variables are handled by emitting an inline asm node
 /// that copies the value out of the specified register.
 Value *TreeToLLVM::EmitReadOfRegisterVariable(tree decl,
@@ -4430,11 +4439,14 @@
       continue;
     }
 
-    // Translate 'p' to 'm'.  This is supposed to check for a valid memory
-    // address, but for inline assembly there is no way to know the mode of
-    // the data being addressed.  Peculiarly, it also accepts a constant.
-    if (ConstraintChar == 'p')
-      Result += "im";
+    // Translate 'p' to a target-specific set of constraints that
+    // conservatively allow a valid memory address.  For inline assembly there
+    // is no way to know the mode of the data being addressed, so this is only
+    // a rough approximation of how GCC handles this constraint.
+    if (ConstraintChar == 'p') {
+      Result += LLVM_CANONICAL_ADDRESS_CONSTRAINTS;
+      continue;
+    }
 
     // See if this is a regclass constraint.
     unsigned RegClass;





More information about the llvm-commits mailing list