[LLVMdev] adding a codegen pass into llvm

Qingan Li ww345ww at gmail.com
Mon Jan 17 20:44:05 PST 2011


Thanks for your last reply.
Could I understand the way to adding a pass (built into the llvm rather than
dynamic loadable) includes:
1. Declaring a creator function for this pass
2. Implementing the creator function for this pass
3. Instantiating this pass and get a object of it
3. Register this pass into the PassRegistry

Then, for a built-into bytecode pass,
        task 1(declaration of the creator) should be done in Scalar.h;
        task 2(implementation of the creator) should be done the related
mypass.cpp file;
        task 3(instantiation of the pass class) should be done in
LinkAllPasses.h;
        task 4(registration of the pass into the PassRegistry) should be
done by INITIALIZE_PASS
class LiveVariables : public MachineFunctionPass is a case of point.

For a built-into codegen/MachineCode pass,
        task 1 should be done in Passes.h;
        task 2 should be done in the related mypass.cpp file;
        task 3 should be done in LLVMTargetMachine.cpp
        task 4 should be done by INITIALIZE_PASS
 class IntervalAnalylsis: public MachineFunctionPass is a case in point.

I have implemented a new mypass (just for analysis, rather than
transformation) as a subclass of MchineFunctionPass, and finished task 1, 2,
4. But I don't know how to finish task 3, since I failed to make clear how
the class IntervalAnalysis did task 3. So I need your help.

-- 
Best regards,

Li Qingan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110118/a65fa139/attachment.html>


More information about the llvm-dev mailing list