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 LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
11 #define LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
13 #include "ARMSubtarget.h"
14 #include "llvm/CodeGen/AsmPrinter.h"
15 #include "llvm/Target/TargetMachine.h"
19 class ARMFunctionInfo;
21 class MachineConstantPool;
32 class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter {
34 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
35 /// make the right decision when printing asm code for different targets.
36 const ARMSubtarget *Subtarget;
38 /// AFI - Keep a pointer to ARMFunctionInfo for the current
42 /// MCP - Keep a pointer to constantpool entries of the current
44 const MachineConstantPool *MCP;
46 /// InConstantPool - Maintain state when emitting a sequence of constant
47 /// pool entries so we can properly mark them as data regions.
50 /// ThumbIndirectPads - These maintain a per-function list of jump pad
51 /// labels used for ARMv4t thumb code to make register indirect calls.
52 SmallVector<std::pair<unsigned, MCSymbol*>, 4> ThumbIndirectPads;
55 explicit ARMAsmPrinter(TargetMachine &TM, MCStreamer &Streamer)
56 : AsmPrinter(TM, Streamer), AFI(nullptr), MCP(nullptr),
57 InConstantPool(false) {
58 Subtarget = &TM.getSubtarget<ARMSubtarget>();
61 const char *getPassName() const override {
62 return "ARM Assembly / Object Emitter";
65 void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O,
66 const char *Modifier = nullptr);
68 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
69 unsigned AsmVariant, const char *ExtraCode,
70 raw_ostream &O) override;
71 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
72 unsigned AsmVariant, const char *ExtraCode,
73 raw_ostream &O) override;
75 void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
76 const MCSubtargetInfo *EndInfo) const override;
78 void EmitJumpTable(const MachineInstr *MI);
79 void EmitJump2Table(const MachineInstr *MI);
80 void EmitInstruction(const MachineInstr *MI) override;
81 bool runOnMachineFunction(MachineFunction &F) override;
83 void EmitConstantPool() override {
84 // we emit constant pools customly!
86 void EmitFunctionBodyEnd() override;
87 void EmitFunctionEntryLabel() override;
88 void EmitStartOfAsmFile(Module &M) override;
89 void EmitEndOfAsmFile(Module &M) override;
90 void EmitXXStructor(const Constant *CV) override;
92 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
93 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
96 // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
97 void emitAttributes();
99 // Generic helper used to emit e.g. ARMv5 mul pseudos
100 void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
102 void EmitUnwindingInstruction(const MachineInstr *MI);
104 // emitPseudoExpansionLowering - tblgen'erated.
105 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
106 const MachineInstr *MI);
109 unsigned getISAEncoding() override {
110 // ARM/Darwin adds ISA to the DWARF info for each function.
111 if (!Subtarget->isTargetMachO())
113 return Subtarget->isThumb() ?
114 ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
118 MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
119 MCSymbol *GetARMJTIPICJumpTableLabel2(unsigned uid, unsigned uid2) const;
121 MCSymbol *GetARMSJLJEHLabel() const;
123 MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
126 /// EmitMachineConstantPoolValue - Print a machine constantpool value to
128 void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
130 } // end namespace llvm