2010/1/11 Garrison Venn <span dir="ltr"><<a href="mailto:gvenn.cfe.dev@gmail.com">gvenn.cfe.dev@gmail.com</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="word-wrap: break-word;">I have not tried this, but a linkage type of PrivateLinkage would not add to the symbol table according<div>to the doc. <div><br></div><div>LLVMSetLinkage(g, LLVMPrivateLinkage);</div></div>
</div></blockquote><div><br>Thanks - I hadn't thought of that.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="word-wrap: break-word;">
<div><div><br></div><font color="#888888"><div>Garrison</div><div><br></div></font><div><div><div><div></div><div class="h5"><div>On Jan 11, 2010, at 14:03, James Williams wrote:</div><br></div></div><blockquote type="cite">
<div><div></div><div class="h5">2010/1/11 Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com" target="_blank">eli.friedman@gmail.com</a>></span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div>On Mon, Jan 11, 2010 at 7:07 AM, James Williams <<a href="mailto:junk@giantblob.com" target="_blank">junk@giantblob.com</a>> wrote:<br>
> Hi,<br>
><br>
> I've read <a href="http://llvm.org/docs/LangRef.html#t_array" target="_blank">http://llvm.org/docs/LangRef.html#t_array</a> and<br>
> <a href="http://llvm.org/docs/GetElementPtr.html" target="_blank">http://llvm.org/docs/GetElementPtr.html</a> and if I've understood right there<br>
> are no operations that act directly on arrays - instead I need to use<br>
> getelementptr on a pointer to an array to get a pointer to an array element.<br>
> I also understand that there is no 'address of' operation.<br>
><br>
> As a result I can't figure out how to use constant derived types without<br>
> assigning them to a global. Say I want to use the C bindings function<br>
> LLVMValueRef LLVMConstString(char *, int, int) to get an int8* pointer to a<br>
> C string constant - there doesn't seem to be any way to directly use the<br>
> resulting [N x i8] value directly and there's no operator that gives me its<br>
> address.<br>
><br>
> The only way I can see to get a pointer to the string constant array is to<br>
> go through a global variable, for example:<br>
><br>
> g = LLVMAddGlobal(module, LLVMTypeOf(v), "__string_" +<br>
> string_literal_number);<br>
> string_literal_number = string_literal_number + 1;<br>
> v = LLVMConstString(string_literal, string_literal.Length, 0);<br>
> LLVMSetInitializer(g, v);<br>
> elements = { LLVMConstInt(LLVMInt32Type(), 0L, 0),<br>
> LLVMConstInt(LLVMInt32Type(), 0L, 0) };<br>
> return LLVMConstInBoundsGEP(g, elements, 2);<br>
><br>
> Is it possible to get the address of an element of a constant array or<br>
> struct without first initializing a global variable to the constant?<br>
<br>
</div></div>No.<br></blockquote><div><br>OK. I'd have preferred to have to avoid bloating the module symbol table with global symbols that will never be referenced but it's no big deal.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<font color="#888888"><br>
-Eli<br>
<br>
</font></blockquote></div><br></div></div><div class="im">
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></div></blockquote></div><br></div></div></div></blockquote></div><br>