[LLVMdev] Help with Values sign

Santos Merino santitox at hotmail.es
Sun May 27 08:59:26 PDT 2012


I show you the trace of calls to llvm that my compiler makes to generate the
code above. bloques.back().last is of type Value* and bloques.back().bl is
BasicBlock* (the current Block)

bloques.back().last = 
               
dyn_cast<Value>(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), $1,
true)); // $1 is an int
    AllocaInst *alloc = 
                new AllocaInst(
                  Type::getInt32Ty(getGlobalContext()), izq.c_str(),
bloques.back().bl);
    Value *derecha = bloques.back().last;
    StoreInst *s = new StoreInst(derecha, alloc, false, bloques.back().bl);
    bloques.back().last = alloc;
    LoadInst* v1 = 
                new LoadInst(bloques.back().last, "r", false, bloques.back().bl);
    bloques.back().last = v1;
    BasicBlock* blockReturn = 
                BasicBlock::Create(getGlobalContext(), "Return", Main);
    Value* last = bloques.back().last;
    BranchInst::Create(blockReturn, bloques.back().bl);
    ReturnInst::Create(getGlobalContext(), last, blockReturn);
 
The source code corresponding to the IR representation would be:

    a = 1
    return a





More information about the llvm-dev mailing list