Frage

I found it so trouble when I try to insert some instruction in basicblock.

AllocaInst* pa = new AllocaInst(Type::getInt32Ty(getGlobalContext()), 0, 4, "dataKey");
Value* dataValue = ConstantInt::get(IntegerType::get(getGlobalContext(),6) , 100);

above are some code I used. Still now I don't understand the principle to insert all kinds of instructions in basicblock.(I just can insert a allocaInst). I wish someone could tell me some example that inset all kinds of instructions in basicblock.

War es hilfreich?

Lösung

First of all, the topic of inserting instructions is covered in the LLVM Programmer's Manual, I recommend taking a look. The Programmer's Manual is a great place to start for beginners.

Additionally, there are tons of examples in the LLVM source code itself. For instance:

Alternatively, if you want to add multiple new instructions, consider using an IRBuilder, which makes it slightly more convenient to add them; here's a tutorial on how to use an IRBuilder.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top