[llvm-commits] [dragonegg] r115784 - in /dragonegg/trunk: llvm-convert.cpp x86/llvm-target.h

Duncan Sands baldrick at free.fr
Wed Oct 6 05:41:43 PDT 2010


Author: baldrick
Date: Wed Oct  6 07:41:43 2010
New Revision: 115784

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

Modified:
    dragonegg/trunk/llvm-convert.cpp
    dragonegg/trunk/x86/llvm-target.h

Modified: dragonegg/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-convert.cpp?rev=115784&r1=115783&r2=115784&view=diff
==============================================================================
--- dragonegg/trunk/llvm-convert.cpp (original)
+++ dragonegg/trunk/llvm-convert.cpp Wed Oct  6 07:41:43 2010
@@ -2938,6 +2938,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) {
@@ -3123,11 +3132,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;

Modified: dragonegg/trunk/x86/llvm-target.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/x86/llvm-target.h?rev=115784&r1=115783&r2=115784&view=diff
==============================================================================
--- dragonegg/trunk/x86/llvm-target.h (original)
+++ dragonegg/trunk/x86/llvm-target.h Wed Oct  6 07:41:43 2010
@@ -363,6 +363,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 {                                                  \





More information about the llvm-commits mailing list