1 //===-- ARMAsmPrinter.h - Print machine code to an ARM .s file --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // ARM Assembly printer class.
12 //===----------------------------------------------------------------------===//
14 #ifndef ARMASMPRINTER_H
15 #define ARMASMPRINTER_H
18 #include "ARMTargetMachine.h"
19 #include "llvm/CodeGen/AsmPrinter.h"
20 #include "llvm/Support/Compiler.h"
33 class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter
: public AsmPrinter
{
35 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
36 /// make the right decision when printing asm code for different targets.
37 const ARMSubtarget
*Subtarget
;
39 /// AFI - Keep a pointer to ARMFunctionInfo for the current
43 /// MCP - Keep a pointer to constantpool entries of the current
45 const MachineConstantPool
*MCP
;
47 /// InConstantPool - Maintain state when emitting a sequence of constant
48 /// pool entries so we can properly mark them as data regions.
51 explicit ARMAsmPrinter(TargetMachine
&TM
, MCStreamer
&Streamer
)
52 : AsmPrinter(TM
, Streamer
), AFI(NULL
), MCP(NULL
), InConstantPool(false) {
53 Subtarget
= &TM
.getSubtarget
<ARMSubtarget
>();
56 virtual const char *getPassName() const {
57 return "ARM Assembly Printer";
60 void printOperand(const MachineInstr
*MI
, int OpNum
, raw_ostream
&O
,
61 const char *Modifier
= 0);
63 virtual bool PrintAsmOperand(const MachineInstr
*MI
, unsigned OpNum
,
64 unsigned AsmVariant
, const char *ExtraCode
,
66 virtual bool PrintAsmMemoryOperand(const MachineInstr
*MI
, unsigned OpNum
,
68 const char *ExtraCode
, raw_ostream
&O
);
70 void EmitJumpTable(const MachineInstr
*MI
);
71 void EmitJump2Table(const MachineInstr
*MI
);
72 virtual void EmitInstruction(const MachineInstr
*MI
);
73 bool runOnMachineFunction(MachineFunction
&F
);
75 virtual void EmitConstantPool() {} // we emit constant pools customly!
76 virtual void EmitFunctionBodyEnd();
77 virtual void EmitFunctionEntryLabel();
78 void EmitStartOfAsmFile(Module
&M
);
79 void EmitEndOfAsmFile(Module
&M
);
80 void EmitXXStructor(const Constant
*CV
);
82 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
83 bool lowerOperand(const MachineOperand
&MO
, MCOperand
&MCOp
);
86 // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
87 void emitAttributes();
89 // Helper for ELF .o only
90 void emitARMAttributeSection();
92 // Generic helper used to emit e.g. ARMv5 mul pseudos
93 void EmitPatchedInstruction(const MachineInstr
*MI
, unsigned TargetOpc
);
95 void EmitUnwindingInstruction(const MachineInstr
*MI
);
97 // emitPseudoExpansionLowering - tblgen'erated.
98 bool emitPseudoExpansionLowering(MCStreamer
&OutStreamer
,
99 const MachineInstr
*MI
);
102 void PrintDebugValueComment(const MachineInstr
*MI
, raw_ostream
&OS
);
104 MachineLocation
getDebugValueLocation(const MachineInstr
*MI
) const;
106 /// EmitDwarfRegOp - Emit dwarf register operation.
107 virtual void EmitDwarfRegOp(const MachineLocation
&MLoc
) const;
109 virtual unsigned getISAEncoding() {
110 // ARM/Darwin adds ISA to the DWARF info for each function.
111 if (!Subtarget
->isTargetDarwin())
113 return Subtarget
->isThumb() ?
114 ARM::DW_ISA_ARM_thumb
: ARM::DW_ISA_ARM_arm
;
117 MCOperand
GetSymbolRef(const MachineOperand
&MO
, const MCSymbol
*Symbol
);
118 MCSymbol
*GetARMSetPICJumpTableLabel2(unsigned uid
, unsigned uid2
,
119 const MachineBasicBlock
*MBB
) const;
120 MCSymbol
*GetARMJTIPICJumpTableLabel2(unsigned uid
, unsigned uid2
) const;
122 MCSymbol
*GetARMSJLJEHLabel(void) const;
124 MCSymbol
*GetARMGVSymbol(const GlobalValue
*GV
);
126 /// EmitMachineConstantPoolValue - Print a machine constantpool value to
128 virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue
*MCPV
);
130 } // end namespace llvm