[LLVMdev] AsmPrinter vs. MCAsmStreamer

Jim Grosbach grosbach at apple.com
Wed Nov 9 08:55:55 PST 2011


On Nov 8, 2011, at 4:23 PM, Joe Matarazzo wrote:

> I'm writing a backend using a mid-October svn snapshot of LLVM. I'm having a hard time figuring out the relationship between my XXXAsmPrinter and MCAsmStreamer. Can someone explain what each is responsible for? Looking at the existing targets, the XXXAsmPrinter implementations seem to implement both the legacy "create a .s file" behavior, using printInstruction/printOperand/etc as well as the newer "lower to MCInst" behavior (EmitInstruction). Is this just a remnant of the v2.x -> v3.x transition?
> 
The old MachineInstr based AsmPrinter routines are legacy cruft. Not everything has been moved over to the new way of doing things yet.

> AFAICT, the MCAsmStreamer should be the interface to create the .s file going forward. Is that true? If true, how does it fit into registering the asmprinter as a pass? That is, if the AsmPrinter pass is used to lower to MCInst in the XXXAsmPrinter, then what? What's the target registration for MCInst -> .s file?
> 

Yes, MCAsmStreamer is the correct path. You shouldn't need to do anything special to register it. Just the usual LLVMInitializeXXXAsmPrinter() hook. See the ARM or X86 target for examples.

-Jim



More information about the llvm-dev mailing list