<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="font-family: Times; font-size: 16px; "><div>I don't think this is right. According to llvm documentation:</div><div><br></div>The index types specified for the '<tt>getelementptr</tt>' instruction depend on the pointer type that is being indexed into. <a href="http://llvm.org/docs/LangRef.html#t_pointer">Pointer</a> and <a href="http://llvm.org/docs/LangRef.html#t_array">array</a> types can use a 32-bit or 64-bit <a href="http://llvm.org/docs/LangRef.html#t_integer">integer</a> type but the value will always be sign extended to 64-bits. <a href="http://llvm.org/docs/LangRef.html#t_struct">Structure</a> and <a href="http://llvm.org/docs/LangRef.html#t_pstruct">packed structure</a> types require <tt>i32</tt> <b>constants</b>.</span><div><font class="Apple-style-span" face="Times" size="4"><span class="Apple-style-span" style="font-size: 16px;"><br></span></font></div><div><font class="Apple-style-span" face="Times" size="4"><span class="Apple-style-span" style="font-size: 16px;">Evan</span></font></div><div><font class="Apple-style-span" face="Times" size="4"><span class="Apple-style-span" style="font-size: 16px;"><br></span></font><div><div>On Jul 10, 2008, at 3:47 AM, Matthijs Kooijman wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi all,<br><br>any comments about this patch? I'd like to get it out of my working copy :-)<br><br>Gr.<br><br>Matthijs<br><br><blockquote type="cite">Index: lib/VMCore/Type.cpp<br></blockquote><blockquote type="cite">===================================================================<br></blockquote><blockquote type="cite">--- lib/VMCore/Type.cpp<span class="Apple-tab-span" style="white-space:pre">    </span>(revision 53136)<br></blockquote><blockquote type="cite">+++ lib/VMCore/Type.cpp<span class="Apple-tab-span" style="white-space:pre">        </span>(working copy)<br></blockquote><blockquote type="cite">@@ -394,9 +394,8 @@<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> bool StructType::indexValid(const Value *V) const {<br></blockquote><blockquote type="cite">   // Structure indexes require 32-bit integer constants.<br></blockquote><blockquote type="cite">-  if (V->getType() == Type::Int32Ty)<br></blockquote><blockquote type="cite">-    if (const ConstantInt *CU = dyn_cast<ConstantInt>(V))<br></blockquote><blockquote type="cite">-      return indexValid(CU->getZExtValue());<br></blockquote><blockquote type="cite">+  if (const ConstantInt *CU = dyn_cast<ConstantInt>(V))<br></blockquote><blockquote type="cite">+    return indexValid(CU->getZExtValue());<br></blockquote><blockquote type="cite">   return false;<br></blockquote><blockquote type="cite"> }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">@@ -1530,9 +1529,8 @@<br></blockquote><blockquote type="cite"> }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> bool SequentialType::indexValid(const Value *V) const {<br></blockquote><blockquote type="cite">-  if (const IntegerType *IT = dyn_cast<IntegerType>(V->getType())) <br></blockquote><blockquote type="cite">-    return IT->getBitWidth() == 32 || IT->getBitWidth() == 64;<br></blockquote><blockquote type="cite">-  return false;<br></blockquote><blockquote type="cite">+  // Any integer value is allowed<br></blockquote><blockquote type="cite">+  return V->getType()->isInteger();<br></blockquote><blockquote type="cite"> }<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite"> namespace llvm {<br></blockquote><blockquote type="cite">Index: lib/Target/TargetData.cpp<br></blockquote><blockquote type="cite">===================================================================<br></blockquote><blockquote type="cite">--- lib/Target/TargetData.cpp<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 53136)<br></blockquote><blockquote type="cite">+++ lib/Target/TargetData.cpp<span class="Apple-tab-span" style="white-space:pre">  </span>(working copy)<br></blockquote><blockquote type="cite">@@ -553,8 +553,7 @@<br></blockquote><blockquote type="cite">     TI = gep_type_begin(ptrTy, Indices, Indices+NumIndices);<br></blockquote><blockquote type="cite">   for (unsigned CurIDX = 0; CurIDX != NumIndices; ++CurIDX, ++TI) {<br></blockquote><blockquote type="cite">     if (const StructType *STy = dyn_cast<StructType>(*TI)) {<br></blockquote><blockquote type="cite">-      assert(Indices[CurIDX]->getType() == Type::Int32Ty &&<br></blockquote><blockquote type="cite">-             "Illegal struct idx");<br></blockquote><blockquote type="cite">+      assert(isa<ConstantInt>(Indices[CurIDX]) && "Illegal struct idx");<br></blockquote><blockquote type="cite">       unsigned FieldNo = cast<ConstantInt>(Indices[CurIDX])->getZExtValue();<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">       // Get structure layout information...<br></blockquote>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></blockquote></div><br></div></body></html>