0

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.

gre_gor
  • 6,669
  • 9
  • 47
  • 52
Kun Lee
  • 97
  • 1
  • 8
  • What exactly don't you understand after reading the relevant documentation? You have to be more precise in your question. – Eli Bendersky Dec 26 '12 at 19:09

1 Answers1

1

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.

Oak
  • 26,231
  • 8
  • 93
  • 152