[llvm-commits] [dragonegg] r132741 - /dragonegg/trunk/src/Convert.cpp

Duncan Sands baldrick at free.fr
Wed Jun 8 00:03:32 PDT 2011


Author: baldrick
Date: Wed Jun  8 02:03:32 2011
New Revision: 132741

URL: http://llvm.org/viewvc/llvm-project?rev=132741&view=rev
Log:
Support for constant vectors of pointers at the gimple level.

Modified:
    dragonegg/trunk/src/Convert.cpp

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=132741&r1=132740&r2=132741&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Wed Jun  8 02:03:32 2011
@@ -6240,13 +6240,20 @@
 
   // Convert the elements.
   SmallVector<Constant*, 8> Elts;
-  for (tree elt = TREE_VECTOR_CST_ELTS(reg); elt; elt = TREE_CHAIN(elt))
-    Elts.push_back(EmitRegisterConstant(TREE_VALUE(elt)));
+  const IntegerType *IntTy = getTargetData().getIntPtrType(Context);
+  for (tree elt = TREE_VECTOR_CST_ELTS(reg); elt; elt = TREE_CHAIN(elt)) {
+    Constant *Elt = EmitRegisterConstant(TREE_VALUE(elt));
+    // LLVM does not support vectors of pointers, so turn any pointers into
+    // integers.
+    if (isa<PointerType>(Elt->getType()))
+      Elt = Builder.getFolder().CreatePtrToInt(Elt, IntTy);
+    Elts.push_back(Elt);
+  }
 
   // If there weren't enough elements then set the rest of the vector to the
   // default value.
   if (Elts.size() < TYPE_VECTOR_SUBPARTS(TREE_TYPE(reg))) {
-    Constant *Default = getDefaultValue(getRegType(TREE_TYPE(TREE_TYPE(reg))));
+    Constant *Default = getDefaultValue(Elts[0]->getType());
     Elts.append(TYPE_VECTOR_SUBPARTS(TREE_TYPE(reg)) - Elts.size(), Default);
   }
 





More information about the llvm-commits mailing list