[LLVMdev] Question about MachineFunction Pass

Chris Lattner sabre at nondot.org
Tue Oct 19 08:34:44 PDT 2004


On Tue, 19 Oct 2004, Zhang Qiuyu wrote:
> I wrote a machinefunction pass to try to see what's going on. Does it
> mean that it is target machine dependent pass, like x86? However, after
> compile it, I found there wasnot command option I registered. I used
> regular way to do it like RegisterOpt <...> X("... ", "... "), but I
> cannot see the optimized option when I use opt -load
> ../../lib/Debug/libxxx.so --help. And from LLVM source code, I saw some
> passes use runOnMachineFunction(MachineFunction &MF), but there is no
> API like registerOpt. what does it mean? Thanks

MachineFunctionPass instances are part of the code generator.  As such,
they are not supposed to modify the LLVM code and their output does not go
to bytecode.

You *can* write target specific (e.g. the X86 floating point stackifier
pass) or target independent passes (e.g. the register allocators) with
MachineFunctionPass's, but I don't think this is what you really want to
do.

> For MachineFunction pass, the doc says it is not allowed to do any of the following:

MachineFunctionPass's are even more restricted than FunctionPass's.

> It seems I cannot insert some instructions, right?

Correct.

> For MachineInstr.h and MachineInstrBuilder.h and X86InstrBuilder.h, I am
> just wondering if we can construct some X86 assemble instruction? if so,

Yes.

> can we insert the X86 assemble instruction to bytecode( bytecode is IR
> code which should be conflicted with X86 asm) if I used
> runOnMachineFunction pass ?

No you can't do this yet, and when you can, it won't be with a
MachineFunctionPass.  What you are really trying to do is use a form of
inline assembly in the LLVM bytecode.  Unfortunately, we do not support
this feature yet, but it is on the mid-range "todo list".  I don't know of
anyone who is planning on tackling the job yet though.

Why do you want to insert assembly language?

-Chris

-- 
http://llvm.org/
http://nondot.org/sabre/




More information about the llvm-dev mailing list