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

Duncan Sands baldrick at free.fr
Mon Mar 14 03:57:15 PDT 2011


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.

>
> 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
>




More information about the llvm-dev mailing list