1 //===-- ARMAsmPrinter.h - ARM implementation of AsmPrinter ------*- 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 #ifndef ARMASMPRINTER_H
11 #define ARMASMPRINTER_H
13 #include "ARMSubtarget.h"
14 #include "llvm/CodeGen/AsmPrinter.h"
15 #include "llvm/Target/TargetMachine.h"
19 class ARMFunctionInfo;
21 class MachineConstantPool;
31 class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter {
33 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
34 /// make the right decision when printing asm code for different targets.
35 const ARMSubtarget *Subtarget;
37 /// AFI - Keep a pointer to ARMFunctionInfo for the current
41 /// MCP - Keep a pointer to constantpool entries of the current
43 const MachineConstantPool *MCP;
45 /// InConstantPool - Maintain state when emitting a sequence of constant
46 /// pool entries so we can properly mark them as data regions.
49 explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
50 : AsmPrinter(TM, Streamer), AFI(NULL), MCP(NULL), InConstantPool(false) {
51 Subtarget = &TM.getSubtarget<ARMSubtarget>();
54 const char *getPassName() const override {
55 return "ARM Assembly / Object Emitter";
58 void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
59 const char *Modifier = 0);
61 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
62 unsigned AsmVariant, const char *ExtraCode,
63 raw_ostream &O) override;
64 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
65 unsigned AsmVariant, const char *ExtraCode,
66 raw_ostream &O) override;
68 void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
69 const MCSubtargetInfo *EndInfo) const override;
71 void EmitJumpTable(const MachineInstr *MI);
72 void EmitJump2Table(const MachineInstr *MI);
73 void EmitInstruction(const MachineInstr *MI) override;
74 bool runOnMachineFunction(MachineFunction &F) override;
76 void EmitConstantPool() override {
77 // we emit constant pools customly!
79 void EmitFunctionBodyEnd() override;
80 void EmitFunctionEntryLabel() override;
81 void EmitStartOfAsmFile(Module &M) override;
82 void EmitEndOfAsmFile(Module &M) override;
83 void EmitXXStructor(const Constant *CV) override;
85 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
86 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
89 // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
90 void emitAttributes();
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 unsigned getISAEncoding() override {
103 // ARM/Darwin adds ISA to the DWARF info for each function.
104 if (!Subtarget->isTargetMachO())
106 return Subtarget->isThumb() ?
107 ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
111 MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
112 MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const;
114 MCSymbol *GetARMSJLJEHLabel() const;
116 MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
119 /// EmitMachineConstantPoolValue - Print a machine constantpool value to
121 void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
123 } // end namespace llvm