[LLVMdev] Adding variants of some instructions
Hans Vandierendonck
hvdieren at elis.ugent.be
Tue Mar 10 13:15:27 PDT 2009
Hi,
I need to have special variants of some instructions, e.g. a special
MallocInst that carries some additional information. Besides having
this additional information, I want all of LLVM to recognize this
instruction as a regular MallocInst. This special MallocInst need only
exist inside LLVM; it need not be written out to bytecode. How to best
implement this?
This is what I was thinking:
* Not to introduce a new instruction, but to represent special
MallocInst as a derived class from MallocInst
* Introduce the special MallocInst instructions during a pass that
decides to replace some original MallocInsts or some other code by
special MallocInst
* Apply LLVM analysis and transformations assuming that when new
MallocInsts are created, the proper clone() function is called
* Apply my own passes that use the special MallocInst. This requires
to recognize that some MallocInst are special MallocInst, but the
isa<> interface won't be usable for that
* Revert the special MallocInst instructions to whatever code was
there before
Is this a good approach or are there better alternatives?
Thanks for the help
Hans Vandierendonck.
More information about the llvm-dev
mailing list