[LLVMdev] Runtime Array-Length

William Moses moses.williamsteven at gmail.com
Sat Oct 12 11:13:05 PDT 2013


All,

I am building my own language with llvm as the base.

I was working on string concatenation (where a string is just an array of
characters cast to a pointer to a character (i8*) ). Given two strings, it
is possible to determine the length of new string by summing the number of
characters until the null terminator and adding one.

Unfortunately, I have no idea how to use the c-api to store this. As the
length of the new string is not a compile-time constant (e.g. stored in a
Value*), I cannot determine at compile-time what length the llvm array-type
will be? Therefore, I cannot create the GlobalVariable since I do not know
the type.

One possible solution I thought of was linking to the malloc function and
calling that, but I'm sure there's a better way. If any of you have
implemented a similar sort of string concatenation, I would much appreciate
any advice that you could give.

Thanks,
Billy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131012/0fea868d/attachment.html>


More information about the llvm-dev mailing list