AsmPrinter vs. MCAsmStreamer

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?

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?

Thanks,
Joe

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