[LLVMdev] All backends now use the MC asm printer

Venkatraman Govindaraju venkatra at cs.wisc.edu
Sun Jan 12 12:10:15 PST 2014

On Sat, Jan 11, 2014 at 11:20 PM, Sean Silva <chisophugis at gmail.com> wrote:
> On Sat, Jan 11, 2014 at 5:26 PM, Richard Pennington <rich at pennware.com>
> wrote:
>> On 01/10/2014 04:06 PM, Rafael EspĂ­ndola wrote:
>>> In r198030 the last in tree backend was converted to use MCInst for
>>> printing assembly. I removed support for the old printer in r198959.
>>> Out of tree targets have to lower MachineInstr to MCInst to use the new
>>> printer.
>>> Cheers,
>>> Rafael
>> Are there any guidelines as to how the lowering should be done? I'd like
>> to update the (defunct) Microblaze back end before I pull the latest TOT
>> this week.
> Venkatraman, I'm guessing you still have this fresh in your memory. Would
> you mind giving a hand? (bonus points for writing some documentation
> <http://llvm.org/docs/SphinxQuickstartTemplate.html> ;)

Here are the steps that I followed to implement the MCLowering in
SPARC backend.

1. Implement <Target>MCExpr.cpp
    Create a derived class of TargetMCExpr  to handle target specific
expressions such as %hi, %lo etc.  See examples in AArch64MCExpr.cpp,
SparcMCExpr.cpp etc.,

2. Implement <Target>MCStreamer.cpp if the target needs any special directives.
    See http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-October/066248.html
for further info.

3. Implement InstPrinter using TableGen-ed AsmWriter. (See examples in

4. Implement <Target>MCInstLower.cpp to lower MachineInstrs to MCInst.
   This is implemented by lowering MachineInstr operands to either
MCInst operands or MCExpr. Target specific expressions are lowered to
<Target>MCExpr objects.

5. Modify <Target>AsmPrinter to lower MachineInstrs to MCInst and emit
them using the MCStreamer.

6. Finally, register the InstPrinter and the MCStreamers in

 Hope that this helps.

  For MicroBlaze target, when it removed from the trunk, it is already
using the new MCInstPrinter. So, it may easier to update it.


> -- Sean Silva
>> -Rich
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

More information about the llvm-dev mailing list