ARMAsmPrinter.h revision 224145
133965Sjdp//===-- ARMAsmPrinter.h - Print machine code to an ARM .s file ------------===// 233965Sjdp// 333965Sjdp// The LLVM Compiler Infrastructure 433965Sjdp// 533965Sjdp// This file is distributed under the University of Illinois Open Source 633965Sjdp// License. See LICENSE.TXT for details. 733965Sjdp// 833965Sjdp//===----------------------------------------------------------------------===// 933965Sjdp// 1033965Sjdp// ARM Assembly printer class. 1133965Sjdp// 1233965Sjdp//===----------------------------------------------------------------------===// 1333965Sjdp 1433965Sjdp#ifndef ARMASMPRINTER_H 1533965Sjdp#define ARMASMPRINTER_H 1633965Sjdp 1733965Sjdp#include "ARM.h" 1833965Sjdp#include "ARMTargetMachine.h" 1933965Sjdp#include "llvm/CodeGen/AsmPrinter.h" 2033965Sjdp#include "llvm/Support/Compiler.h" 2133965Sjdp 2233965Sjdpnamespace llvm { 2333965Sjdp 2433965Sjdpclass MCOperand; 2533965Sjdp 2633965Sjdpnamespace ARM { 2733965Sjdp enum DW_ISA { 2833965Sjdp DW_ISA_ARM_thumb = 1, 2933965Sjdp DW_ISA_ARM_arm = 2 3033965Sjdp }; 3133965Sjdp} 3233965Sjdp 3333965Sjdpclass LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter { 3433965Sjdp 3533965Sjdp /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can 3633965Sjdp /// make the right decision when printing asm code for different targets. 3733965Sjdp const ARMSubtarget *Subtarget; 3833965Sjdp 3933965Sjdp /// AFI - Keep a pointer to ARMFunctionInfo for the current 4033965Sjdp /// MachineFunction. 4133965Sjdp ARMFunctionInfo *AFI; 4233965Sjdp 4333965Sjdp /// MCP - Keep a pointer to constantpool entries of the current 4433965Sjdp /// MachineFunction. 4533965Sjdp const MachineConstantPool *MCP; 4633965Sjdp 4733965Sjdppublic: 4833965Sjdp explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) 4933965Sjdp : AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL) { 5033965Sjdp Subtarget = &TM.getSubtarget<ARMSubtarget>(); 5133965Sjdp } 5233965Sjdp 5333965Sjdp virtual const char *getPassName() const { 5433965Sjdp return "ARM Assembly Printer"; 5533965Sjdp } 5633965Sjdp 5733965Sjdp void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O, 5833965Sjdp const char *Modifier = 0); 5933965Sjdp 6033965Sjdp virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, 6133965Sjdp unsigned AsmVariant, const char *ExtraCode, 6233965Sjdp raw_ostream &O); 6333965Sjdp virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, 6433965Sjdp unsigned AsmVariant, 6533965Sjdp const char *ExtraCode, raw_ostream &O); 6633965Sjdp 6733965Sjdp void EmitJumpTable(const MachineInstr *MI); 6833965Sjdp void EmitJump2Table(const MachineInstr *MI); 6933965Sjdp virtual void EmitInstruction(const MachineInstr *MI); 7033965Sjdp bool runOnMachineFunction(MachineFunction &F); 7133965Sjdp 7233965Sjdp virtual void EmitConstantPool() {} // we emit constant pools customly! 7333965Sjdp virtual void EmitFunctionEntryLabel(); 7433965Sjdp void EmitStartOfAsmFile(Module &M); 7533965Sjdp void EmitEndOfAsmFile(Module &M); 7633965Sjdp 7733965Sjdp // lowerOperand - Convert a MachineOperand into the equivalent MCOperand. 7833965Sjdp bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp); 7933965Sjdp 8033965Sjdpprivate: 8133965Sjdp // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile() 8233965Sjdp void emitAttributes(); 8333965Sjdp 8433965Sjdp // Helper for ELF .o only 8533965Sjdp void emitARMAttributeSection(); 8633965Sjdp 8733965Sjdp // Generic helper used to emit e.g. ARMv5 mul pseudos 8833965Sjdp void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc); 8933965Sjdp 9033965Sjdp void EmitUnwindingInstruction(const MachineInstr *MI); 9133965Sjdp 9233965Sjdp // emitPseudoExpansionLowering - tblgen'erated. 9333965Sjdp bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, 9433965Sjdp const MachineInstr *MI); 9533965Sjdp 9633965Sjdppublic: 9733965Sjdp void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS); 9833965Sjdp 9933965Sjdp MachineLocation getDebugValueLocation(const MachineInstr *MI) const; 10033965Sjdp 10133965Sjdp /// EmitDwarfRegOp - Emit dwarf register operation. 10233965Sjdp virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const; 10333965Sjdp 10433965Sjdp virtual unsigned getISAEncoding() { 10533965Sjdp // ARM/Darwin adds ISA to the DWARF info for each function. 10633965Sjdp if (!Subtarget->isTargetDarwin()) 10733965Sjdp return 0; 10833965Sjdp return Subtarget->isThumb() ? 10933965Sjdp llvm::ARM::DW_ISA_ARM_thumb : llvm::ARM::DW_ISA_ARM_arm; 11033965Sjdp } 11133965Sjdp 11233965Sjdp MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol); 11333965Sjdp MCSymbol *GetARMSetPICJumpTableLabel2(unsigned uid, unsigned uid2, 11433965Sjdp const MachineBasicBlock *MBB) const; 11533965Sjdp MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const; 11633965Sjdp 11733965Sjdp MCSymbol *GetARMSJLJEHLabel(void) const; 11833965Sjdp 11933965Sjdp MCSymbol *GetARMGVSymbol(const GlobalValue *GV); 12033965Sjdp 12133965Sjdp /// EmitMachineConstantPoolValue - Print a machine constantpool value to 12233965Sjdp /// the .s file. 12333965Sjdp virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV); 12433965Sjdp}; 12533965Sjdp} // end namespace llvm 12633965Sjdp 12733965Sjdp#endif 12833965Sjdp