An explanation to ConstantInt

Hi,

I am new to LLVM mailing list! Am I right in adding [LLVMdev] to the subject? Or is it for some other purpose, I just saw that everyone does
that.

Here is my problem. I am running my program using JIT. Once the
program execution is complete, the control goes back to the program
which initiated the JIT. I want to know the value of one of the global
variables in my program.
Since the variable is a global variable, I can get the pointer to it using
the ExecutionEngine, and then obtain the value.

I see the hierarchy as:
GlobalVariable → GlobalValue → Constant
and
ConstantInt → Constant

I can actually get the value of a ConstantInt variable using getValue().
I am getting confused with the nomenclature of Constant. Any
explanation for why it is called Constant?

Thanks
Varun Agrawal

Hi Varun,

I can actually get the value of a ConstantInt variable using getValue().
I am getting confused with the nomenclature of Constant. Any
explanation for why it is called Constant?

It's a Constant because the value it represents is the address of the
global variable, which isn't expected to change during execution. I'm
not sure what calling getValue on a GlobalVariable will do, but it's
probably not what you want; I'd go via the execution engine.

It's all related to the fact that after you've declared
    @var = global i32 0
you use it as
    %value = load i32* @var

Hope this helps.

Tim.