[LLVMdev] How to load a data from the address of unsiged long type

Michael.Kang blackfin.kang at gmail.com
Mon Mar 14 18:36:47 PDT 2011


On Mon, Mar 14, 2011 at 6:57 PM, Duncan Sands <baldrick at free.fr> wrote:
> Hi Michael,
>
>> Now I have an address that present in a unsigned long address like the
>> following format:
>> Value* addr = CONST(0xc0008000)
>
> what is the type of addr?  For that matter, what is CONST - what does it do?
>
> Ciao, Duncan.
I forget to interpret the CONST macro .It is defined as the following:

ConstantInt::get(getIntegerType(s), v)

It is used to transform a C language int type to llvm Integer type.

Thanks
MK

>
>>
>> But I do not know how to read the data from the above addr varaible. I
>> tried the following three kind of code:
>> 1. Code:
>>           Value* addr = CONST(0xc0008000);
>>           Value* data = new LoadInst(addr, "", false, bb);
>>     Error:
>>           Segmentation fault
>> 2. Code( use BotVastInst to vern):
>>         Value* addr = CONST(0xc0008000);
>>          a = new BitCastInst(a, PointerType::get(XgetType(Int32Ty), 0), "", bb);
>>          Value* data = new LoadInst(addr, "", false, bb);
>>      Error:
>>           Bitcast requires types of same width
>> 3. Code:
>>         Type const *intptr_type =
>> cpu->dyncom_engine->exec_engine->getTargetData()->getIntPtrType(_CTX());
>>          Value* ptr = new IntToPtrInst(a, intptr_type, "", bb);
>>          Value* data = new LoadInst(ptr, "", false, bb);
>>     Error:
>>          Segmentation fault
>>
>>
>> Any person can give me some hints for my case?
>>
>> Thanks
>> MK
>>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 
www.skyeye.org




More information about the llvm-dev mailing list