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(nullptr), MCP(nullptr),
51 InConstantPool(false) {
52 Subtarget = &TM.getSubtarget<ARMSubtarget>();
55 const char *getPassName() const override {
56 return "ARM Assembly / Object Emitter";
59 void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
60 const char *Modifier = nullptr);
62 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
63 unsigned AsmVariant, const char *ExtraCode,
64 raw_ostream &O) override;
65 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
66 unsigned AsmVariant, const char *ExtraCode,
67 raw_ostream &O) override;
69 void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
70 const MCSubtargetInfo *EndInfo) const override;
72 void EmitJumpTable(const MachineInstr *MI);
73 void EmitJump2Table(const MachineInstr *MI);
74 void EmitInstruction(const MachineInstr *MI) override;
75 bool runOnMachineFunction(MachineFunction &F) override;
77 void EmitConstantPool() override {
78 // we emit constant pools customly!
80 void EmitFunctionBodyEnd() override;
81 void EmitFunctionEntryLabel() override;
82 void EmitStartOfAsmFile(Module &M) override;
83 void EmitEndOfAsmFile(Module &M) override;
84 void EmitXXStructor(const Constant *CV) override;
86 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
87 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
90 // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
91 void emitAttributes();
93 // Generic helper used to emit e.g. ARMv5 mul pseudos
94 void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
96 void EmitUnwindingInstruction(const MachineInstr *MI);
98 // emitPseudoExpansionLowering - tblgen'erated.
99 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
100 const MachineInstr *MI);
103 unsigned getISAEncoding() override {
104 // ARM/Darwin adds ISA to the DWARF info for each function.
105 if (!Subtarget->isTargetMachO())
107 return Subtarget->isThumb() ?
108 ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
112 MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
113 MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const;
115 MCSymbol *GetARMSJLJEHLabel() const;
117 MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
120 /// EmitMachineConstantPoolValue - Print a machine constantpool value to
122 void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
124 } // end namespace llvm