[LLVMdev] Statically Initialized Arrays
Evan Jones
ejones at uwaterloo.ca
Wed Nov 2 12:58:01 PST 2005
I am trying to generate LLVM code that references a global array.
Unfortunately, while I am generating the code I do not know the final
length of the array, as I add elements to it as my compiler goes along.
What is the best way to do this in LLVM? Ideally, I would be able to
define the GlobalVariable array and change its length later on. I would
love for it to have the correct length so I can leverage some of LLVM's
static checking.
I've been thinking that one level of indirection would solve the
problem for me. What I could do is reference the global array via a
function call while generating the code. Then, at the end, I would
generate both the array and the function body:
int array[size] = { ... };
int* globalArray( int index )
{
return &array[index];
}
Ideally, LLVM could then inline the function. Is there a better way to
arrange for this to occur? Should I not care about array lengths and
just have my global variable be a pointer?
Thanks for the advice,
Evan Jones
--
Evan Jones
http://evanjones.ca/
More information about the llvm-dev
mailing list