Yonghyun Hwang
2007-Apr-17 19:11 UTC
[LLVMdev] Instantiating the new Instructions from CallInst Class
Hello All, I'm developing timing analysis tool using LLVM. After several analysis phases, I want to instantiate several instructions in the basic block. Instructions that I try to instantiate are like below; call void (int)* %waitABC(int 10) %tmp = call int (int, int*)* %doABC(int %i, int* %total) I think I should use 'CallInst' class in 'Instructions.h' file. How I could make those instructions from 'CallInst' class? Thank you. - Yonghyun
Ferad Zyulkyarov
2007-Apr-18 08:45 UTC
[LLVMdev] Instantiating the new Instructions from CallInst Class
Hi, prior to call a function it should be declared in your Hi> After several analysis phases, I want to instantiate several > instructions in the basic block. > Instructions that I try to instantiate are like below; > > call void (int)* %waitABC(int 10) > %tmp = call int (int, int*)* %doABC(int %i, int* %total) > > I think I should use 'CallInst' class in 'Instructions.h' file. > How I could make those instructions from 'CallInst' class?To be able to call a function let's say "waitABC" that you have defined in somewhere else you have to declare it in your module. To declare a Function you have to create a Function object with empty basic block (see http://llvm.org/docs/ProgrammersManual.html#Function) The code should be something like this: Function *f = new Function(TheTypeOfYourFunction, GlobalValue::ExternalLinkage, "FunctionName", ModuleToPutYourFunction); CallInst callInst = new CallInst(f, args, "valueName", InstructionToInsertBefore); -- Ferad Zyulkyarov Barcelona Supercomputing Center
Apparently Analagous Threads
- Instantiating multiple child objects
- Instantiating Controller Object on Rails3 for unit testing
- instantiating a reference class with an initialize() method from .onLoad fails
- [LLVMdev] Instantiating a JIT on win64
- Any way to avoid instantiating a class twice?