JIT'ing constant globals

It seems one can only put constant global statements
_before_ any functions are defined, not after.

I would like to produce eg. "hello world!" functions in a JIT.
So I was hoping to use global string constants.

Is there another way to do this kind of thing ?

thanks,

Simon.

It seems one can only put constant global statements
_before_ any functions are defined, not after.

This is true in .ll files, but not necessary in LLVM modules.

I would like to produce eg. "hello world!" functions in a JIT.
So I was hoping to use global string constants.
Is there another way to do this kind of thing ?

You should just be able to create the global. Can you be more specific what you are doing?

-Chris

> It seems one can only put constant global statements
> _before_ any functions are defined, not after.

This is true in .ll files, but not necessary in LLVM modules.

Yes, I'm generating .ll files.
I'm using a workaround: permanently malloc some memory
and just use that address directly in the .ll

Could I suggest that this fact about globals be added to
the LangRef documentation ?

thanks,

Simon.

This is true in .ll files, but not necessary in LLVM modules.

Yes, I'm generating .ll files.
I'm using a workaround: permanently malloc some memory
and just use that address directly in the .ll

Ok. Note that the .ll file format wasn't really intended to be a streaming format like this. One way to work around this would be to parse each LLVM chunk as an independent module, then use the llvm linker to combine it with the current module.

Could I suggest that this fact about globals be added to
the LangRef documentation ?

Here you go:
http://llvm.org/docs/LangRef.html#modulestructure

-chris

I would like to produce eg. "hello world!" functions in a JIT.
So I was hoping to use global string constants.
Is there another way to do this kind of thing ?

You should just be able to create the global. Can you be more specific
what you are doing?

-Chris

--
Chris Lattner's Homepage
http://llvm.org/
_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-Chris