ARMAsmPrinter.h revision 239462
1234353Sdim//===-- ARMAsmPrinter.h - Print machine code to an ARM .s file --*- C++ -*-===// 2218885Sdim// 3218885Sdim// The LLVM Compiler Infrastructure 4218885Sdim// 5218885Sdim// This file is distributed under the University of Illinois Open Source 6218885Sdim// License. See LICENSE.TXT for details. 7218885Sdim// 8218885Sdim//===----------------------------------------------------------------------===// 9218885Sdim// 10218885Sdim// ARM Assembly printer class. 11218885Sdim// 12218885Sdim//===----------------------------------------------------------------------===// 13218885Sdim 14218885Sdim#ifndef ARMASMPRINTER_H 15218885Sdim#define ARMASMPRINTER_H 16218885Sdim 17218885Sdim#include "ARM.h" 18218885Sdim#include "ARMTargetMachine.h" 19218885Sdim#include "llvm/CodeGen/AsmPrinter.h" 20218885Sdim#include "llvm/Support/Compiler.h" 21218885Sdim 22218885Sdimnamespace llvm { 23218885Sdim 24224145Sdimclass MCOperand; 25224145Sdim 26218885Sdimnamespace ARM { 27218885Sdim enum DW_ISA { 28218885Sdim DW_ISA_ARM_thumb = 1, 29218885Sdim DW_ISA_ARM_arm = 2 30218885Sdim }; 31218885Sdim} 32218885Sdim 33218885Sdimclass LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter { 34218885Sdim 35218885Sdim /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can 36218885Sdim /// make the right decision when printing asm code for different targets. 37218885Sdim const ARMSubtarget *Subtarget; 38218885Sdim 39218885Sdim /// AFI - Keep a pointer to ARMFunctionInfo for the current 40218885Sdim /// MachineFunction. 41218885Sdim ARMFunctionInfo *AFI; 42218885Sdim 43218885Sdim /// MCP - Keep a pointer to constantpool entries of the current 44218885Sdim /// MachineFunction. 45218885Sdim const MachineConstantPool *MCP; 46218885Sdim 47239462Sdim /// InConstantPool - Maintain state when emitting a sequence of constant 48239462Sdim /// pool entries so we can properly mark them as data regions. 49239462Sdim bool InConstantPool; 50218885Sdimpublic: 51218885Sdim explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) 52239462Sdim : AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL), InConstantPool(false) { 53218885Sdim Subtarget = &TM.getSubtarget<ARMSubtarget>(); 54218885Sdim } 55218885Sdim 56218885Sdim virtual const char *getPassName() const { 57218885Sdim return "ARM Assembly Printer"; 58218885Sdim } 59218885Sdim 60218885Sdim void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O, 61218885Sdim const char *Modifier = 0); 62218885Sdim 63218885Sdim virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, 64218885Sdim unsigned AsmVariant, const char *ExtraCode, 65218885Sdim raw_ostream &O); 66218885Sdim virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, 67218885Sdim unsigned AsmVariant, 68218885Sdim const char *ExtraCode, raw_ostream &O); 69218885Sdim 70218885Sdim void EmitJumpTable(const MachineInstr *MI); 71218885Sdim void EmitJump2Table(const MachineInstr *MI); 72218885Sdim virtual void EmitInstruction(const MachineInstr *MI); 73218885Sdim bool runOnMachineFunction(MachineFunction &F); 74218885Sdim 75218885Sdim virtual void EmitConstantPool() {} // we emit constant pools customly! 76239462Sdim virtual void EmitFunctionBodyEnd(); 77218885Sdim virtual void EmitFunctionEntryLabel(); 78218885Sdim void EmitStartOfAsmFile(Module &M); 79218885Sdim void EmitEndOfAsmFile(Module &M); 80234353Sdim void EmitXXStructor(const Constant *CV); 81218885Sdim 82224145Sdim // lowerOperand - Convert a MachineOperand into the equivalent MCOperand. 83224145Sdim bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp); 84224145Sdim 85218885Sdimprivate: 86218885Sdim // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile() 87218885Sdim void emitAttributes(); 88218885Sdim 89218885Sdim // Helper for ELF .o only 90218885Sdim void emitARMAttributeSection(); 91218885Sdim 92218885Sdim // Generic helper used to emit e.g. ARMv5 mul pseudos 93218885Sdim void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc); 94218885Sdim 95221345Sdim void EmitUnwindingInstruction(const MachineInstr *MI); 96221345Sdim 97224145Sdim // emitPseudoExpansionLowering - tblgen'erated. 98224145Sdim bool emitPseudoExpansionLowering(MCStreamer &OutStreamer, 99224145Sdim const MachineInstr *MI); 100224145Sdim 101218885Sdimpublic: 102218885Sdim void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS); 103218885Sdim 104218885Sdim MachineLocation getDebugValueLocation(const MachineInstr *MI) const; 105218885Sdim 106221345Sdim /// EmitDwarfRegOp - Emit dwarf register operation. 107221345Sdim virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const; 108221345Sdim 109218885Sdim virtual unsigned getISAEncoding() { 110218885Sdim // ARM/Darwin adds ISA to the DWARF info for each function. 111218885Sdim if (!Subtarget->isTargetDarwin()) 112218885Sdim return 0; 113218885Sdim return Subtarget->isThumb() ? 114234353Sdim ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm; 115218885Sdim } 116218885Sdim 117224145Sdim MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol); 118218885Sdim MCSymbol *GetARMSetPICJumpTableLabel2(unsigned uid, unsigned uid2, 119218885Sdim const MachineBasicBlock *MBB) const; 120218885Sdim MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const; 121218885Sdim 122218885Sdim MCSymbol *GetARMSJLJEHLabel(void) const; 123218885Sdim 124218885Sdim MCSymbol *GetARMGVSymbol(const GlobalValue *GV); 125224145Sdim 126218885Sdim /// EmitMachineConstantPoolValue - Print a machine constantpool value to 127218885Sdim /// the .s file. 128218885Sdim virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV); 129218885Sdim}; 130218885Sdim} // end namespace llvm 131218885Sdim 132218885Sdim#endif 133