[llvm-commits] [gcc-plugin] r81883 - /gcc-plugin/trunk/llvm-convert.cpp

Duncan Sands baldrick at free.fr
Tue Sep 15 11:23:36 PDT 2009


Author: baldrick
Date: Tue Sep 15 13:23:36 2009
New Revision: 81883

URL: http://llvm.org/viewvc/llvm-project?rev=81883&view=rev
Log:
Support ASM expressions that define ssa names.

Modified:
    gcc-plugin/trunk/llvm-convert.cpp

Modified: gcc-plugin/trunk/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/gcc-plugin/trunk/llvm-convert.cpp?rev=81883&r1=81882&r2=81883&view=diff

==============================================================================
--- gcc-plugin/trunk/llvm-convert.cpp (original)
+++ gcc-plugin/trunk/llvm-convert.cpp Tue Sep 15 13:23:36 2009
@@ -4329,6 +4329,8 @@
   SmallVector<Value *, 4> StoreCallResultAddrs;
   SmallVector<const Type *, 4> CallResultTypes;
   SmallVector<bool, 4> CallResultIsSigned;
+  SmallVector<tree, 4> CallResultSSANames;
+  SmallVector<Value *, 4> CallResultSSATemps;
 
   // Process outputs.
   ValNum = 0;
@@ -4384,9 +4386,19 @@
       SimplifiedConstraint = CanonicalizeConstraint(Constraint+1);
     }
 
-    LValue Dest = EmitLV(Operand);
-    const Type *DestValTy =
-      cast<PointerType>(Dest.Ptr->getType())->getElementType();
+    LValue Dest;
+    const Type *DestValTy;
+    if (TREE_CODE(Operand) == SSA_NAME) {
+      // The ASM is defining an ssa name.  Store the output to a temporary, then
+      // load it out again later as the ssa name.
+      DestValTy = ConvertType(TREE_TYPE(Operand));
+      Dest.Ptr = CreateTemporary(DestValTy);
+      CallResultSSANames.push_back(Operand);
+      CallResultSSATemps.push_back(Dest.Ptr);
+    } else {
+      Dest = EmitLV(Operand);
+      DestValTy = cast<PointerType>(Dest.Ptr->getType())->getElementType();
+    }
 
     assert(!Dest.isBitfield() && "Cannot assign into a bitfield!");
     if (!AllowsMem && DestValTy->isSingleValueType()) {// Reg dest -> asm return
@@ -4613,6 +4625,10 @@
     }
   }
 
+  // If the call defined any ssa names, associate them with their value.
+  for (unsigned i = 0, e = CallResultSSANames.size(); i != e; ++i)
+    SSANames[CallResultSSANames[i]] = Builder.CreateLoad(CallResultSSATemps[i]);
+
   // Give the backend a chance to upgrade the inline asm to LLVM code.  This
   // handles some common cases that LLVM has intrinsics for, e.g. x86 bswap ->
   // llvm.bswap.





More information about the llvm-commits mailing list