ARMAsmPrinter.h revision 221345
1218885Sdim//===-- ARMAsmPrinter.h - Print machine code to an ARM .s file ------------===// 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 24218885Sdimnamespace ARM { 25218885Sdim enum DW_ISA { 26218885Sdim DW_ISA_ARM_thumb = 1, 27218885Sdim DW_ISA_ARM_arm = 2 28218885Sdim }; 29218885Sdim} 30218885Sdim 31218885Sdimclass LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter { 32218885Sdim 33218885Sdim /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can 34218885Sdim /// make the right decision when printing asm code for different targets. 35218885Sdim const ARMSubtarget *Subtarget; 36218885Sdim 37218885Sdim /// AFI - Keep a pointer to ARMFunctionInfo for the current 38218885Sdim /// MachineFunction. 39218885Sdim ARMFunctionInfo *AFI; 40218885Sdim 41218885Sdim /// MCP - Keep a pointer to constantpool entries of the current 42218885Sdim /// MachineFunction. 43218885Sdim const MachineConstantPool *MCP; 44218885Sdim 45218885Sdimpublic: 46218885Sdim explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer) 47218885Sdim : AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL) { 48218885Sdim Subtarget = &TM.getSubtarget<ARMSubtarget>(); 49218885Sdim } 50218885Sdim 51218885Sdim virtual const char *getPassName() const { 52218885Sdim return "ARM Assembly Printer"; 53218885Sdim } 54218885Sdim 55218885Sdim void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O, 56218885Sdim const char *Modifier = 0); 57218885Sdim 58218885Sdim virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, 59218885Sdim unsigned AsmVariant, const char *ExtraCode, 60218885Sdim raw_ostream &O); 61218885Sdim virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, 62218885Sdim unsigned AsmVariant, 63218885Sdim const char *ExtraCode, raw_ostream &O); 64218885Sdim 65218885Sdim void EmitJumpTable(const MachineInstr *MI); 66218885Sdim void EmitJump2Table(const MachineInstr *MI); 67218885Sdim virtual void EmitInstruction(const MachineInstr *MI); 68218885Sdim bool runOnMachineFunction(MachineFunction &F); 69218885Sdim 70218885Sdim virtual void EmitConstantPool() {} // we emit constant pools customly! 71218885Sdim virtual void EmitFunctionEntryLabel(); 72218885Sdim void EmitStartOfAsmFile(Module &M); 73218885Sdim void EmitEndOfAsmFile(Module &M); 74218885Sdim 75218885Sdimprivate: 76218885Sdim // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile() 77218885Sdim void emitAttributes(); 78218885Sdim 79218885Sdim // Helper for ELF .o only 80218885Sdim void emitARMAttributeSection(); 81218885Sdim 82218885Sdim // Generic helper used to emit e.g. ARMv5 mul pseudos 83218885Sdim void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc); 84218885Sdim 85221345Sdim void EmitUnwindingInstruction(const MachineInstr *MI); 86221345Sdim 87218885Sdimpublic: 88218885Sdim void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS); 89218885Sdim 90218885Sdim MachineLocation getDebugValueLocation(const MachineInstr *MI) const; 91218885Sdim 92221345Sdim /// getDwarfRegOpSize - get size required to emit given machine location 93221345Sdim /// using dwarf encoding. 94221345Sdim virtual unsigned getDwarfRegOpSize(const MachineLocation &MLoc) const; 95221345Sdim 96221345Sdim /// EmitDwarfRegOp - Emit dwarf register operation. 97221345Sdim virtual void EmitDwarfRegOp(const MachineLocation &MLoc) const; 98221345Sdim 99218885Sdim virtual unsigned getISAEncoding() { 100218885Sdim // ARM/Darwin adds ISA to the DWARF info for each function. 101218885Sdim if (!Subtarget->isTargetDarwin()) 102218885Sdim return 0; 103218885Sdim return Subtarget->isThumb() ? 104218885Sdim llvm::ARM::DW_ISA_ARM_thumb : llvm::ARM::DW_ISA_ARM_arm; 105218885Sdim } 106218885Sdim 107218885Sdim MCSymbol *GetARMSetPICJumpTableLabel2(unsigned uid, unsigned uid2, 108218885Sdim const MachineBasicBlock *MBB) const; 109218885Sdim MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const; 110218885Sdim 111218885Sdim MCSymbol *GetARMSJLJEHLabel(void) const; 112218885Sdim 113218885Sdim MCSymbol *GetARMGVSymbol(const GlobalValue *GV); 114218885Sdim 115218885Sdim /// EmitMachineConstantPoolValue - Print a machine constantpool value to 116218885Sdim /// the .s file. 117218885Sdim virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV); 118218885Sdim}; 119218885Sdim} // end namespace llvm 120218885Sdim 121218885Sdim#endif 122