LLVM 22.0.0git
ARMAsmPrinter.h
Go to the documentation of this file.
1//===-- ARMAsmPrinter.h - ARM implementation of AsmPrinter ------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
10#define LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
11
14
15namespace llvm {
16
17class ARMFunctionInfo;
19class MCOperand;
21class MachineOperand;
22class MCSymbol;
23
24namespace ARM {
29}
30
32public:
33 static char ID;
34
35private:
36 /// AFI - Keep a pointer to ARMFunctionInfo for the current
37 /// MachineFunction.
38 ARMFunctionInfo *AFI;
39
40 /// MCP - Keep a pointer to constantpool entries of the current
41 /// MachineFunction.
42 const MachineConstantPool *MCP;
43
44 /// InConstantPool - Maintain state when emitting a sequence of constant
45 /// pool entries so we can properly mark them as data regions.
46 bool InConstantPool;
47
48 /// ThumbIndirectPads - These maintain a per-function list of jump pad
49 /// labels used for ARMv4t thumb code to make register indirect calls.
51
52 /// OptimizationGoals - Maintain a combined optimization goal for all
53 /// functions in a module: one of Tag_ABI_optimization_goals values,
54 /// -1 if uninitialized, 0 if conflicting goals
55 int OptimizationGoals;
56
57 /// List of globals that have had their storage promoted to a constant
58 /// pool. This lives between calls to runOnMachineFunction and collects
59 /// data from every MachineFunction. It is used during doFinalization
60 /// when all non-function globals are emitted.
62 /// Set of globals in PromotedGlobals that we've emitted labels for.
63 /// We need to emit labels even for promoted globals so that DWARF
64 /// debug info can link properly.
65 SmallPtrSet<const GlobalVariable*,2> EmittedPromotedGlobalLabels;
66
67public:
69 std::unique_ptr<MCStreamer> Streamer);
70
71 StringRef getPassName() const override {
72 return "ARM Assembly Printer";
73 }
74
75 const ARMBaseTargetMachine &getTM() const;
76
77 void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
78
79 void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &O) override;
80 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
81 const char *ExtraCode, raw_ostream &O) override;
82 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
83 const char *ExtraCode, raw_ostream &O) override;
84
85 void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
86 const MCSubtargetInfo *EndInfo) const override;
87
88 void emitJumpTableAddrs(const MachineInstr *MI);
89 void emitJumpTableInsts(const MachineInstr *MI);
90 void emitJumpTableTBInst(const MachineInstr *MI, unsigned OffsetWidth);
91 void emitInstruction(const MachineInstr *MI) override;
92 bool runOnMachineFunction(MachineFunction &F) override;
93 std::tuple<const MCSymbol *, uint64_t, const MCSymbol *,
95 getCodeViewJumpTableInfo(int JTI, const MachineInstr *BranchInstr,
96 const MCSymbol *BranchLabel) const override;
97
98 void emitConstantPool() override {
99 // we emit constant pools customly!
100 }
101 void emitFunctionBodyEnd() override;
102 void emitFunctionEntryLabel() override;
103 void emitStartOfAsmFile(Module &M) override;
104 void emitEndOfAsmFile(Module &M) override;
105 void emitXXStructor(const DataLayout &DL, const Constant *CV) override;
106 void emitGlobalVariable(const GlobalVariable *GV) override;
107
108 MCSymbol *GetCPISymbol(unsigned CPID) const override;
109
110 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
111 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
112
113 //===------------------------------------------------------------------===//
114 // XRay implementation
115 //===------------------------------------------------------------------===//
116public:
117 // XRay-specific lowering for ARM.
118 void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);
119 void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);
120 void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);
121
122 // KCFI check lowering
123 void LowerKCFI_CHECK(const MachineInstr &MI);
124
125private:
126 void EmitSled(const MachineInstr &MI, SledKind Kind);
127
128 // KCFI check emission helpers
129 void EmitKCFI_CHECK_ARM32(Register AddrReg, int64_t Type,
130 const MachineInstr &Call, int64_t PrefixNops);
131 void EmitKCFI_CHECK_Thumb2(Register AddrReg, int64_t Type,
132 const MachineInstr &Call, int64_t PrefixNops);
133 void EmitKCFI_CHECK_Thumb1(Register AddrReg, int64_t Type,
134 const MachineInstr &Call, int64_t PrefixNops);
135
136 // Helpers for emitStartOfAsmFile() and emitEndOfAsmFile()
137 void emitAttributes();
138
139 void EmitUnwindingInstruction(const MachineInstr *MI);
140
141 // tblgen'erated.
142 bool lowerPseudoInstExpansion(const MachineInstr *MI, MCInst &Inst);
143
144public:
145 unsigned getISAEncoding() override {
146 // ARM/Darwin adds ISA to the DWARF info for each function.
147 const Triple &TT = TM.getTargetTriple();
148 if (!TT.isOSBinFormatMachO())
149 return 0;
150 bool isThumb = TT.isThumb() ||
151 TT.getSubArch() == Triple::ARMSubArch_v7m ||
152 TT.getSubArch() == Triple::ARMSubArch_v6m;
154 }
155
156private:
157 MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
158 MCSymbol *GetARMJTIPICJumpTableLabel(unsigned uid) const;
159
160 MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
161
162public:
163 /// EmitMachineConstantPoolValue - Print a machine constantpool value to
164 /// the .s file.
165 void emitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
166};
167
168} // end namespace llvm
169
170#endif
static bool isThumb(const MCSubtargetInfo &STI)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_LIBRARY_VISIBILITY
Definition Compiler.h:137
static MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol, HexagonAsmPrinter &Printer, bool MustExtend)
IRTranslator LLVM IR MI
#define F(x, y, z)
Definition MD5.cpp:54
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
void emitConstantPool() override
Print to the current output stream assembly representations of the constants in the constant pool MCP...
unsigned getISAEncoding() override
Get the value for DW_AT_APPLE_isa. Zero if no isa encoding specified.
ARMAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer)
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
ARMFunctionInfo - This class is derived from MachineFunctionInfo and contains private ARM-specific in...
TargetMachine & TM
Target machine description.
Definition AsmPrinter.h:99
AsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > Streamer, char &ID=AsmPrinter::ID)
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:63
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
Instances of this class represent operands of the MCInst class.
Definition MCInst.h:40
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Abstract base class for all machine specific constantpool value subclasses.
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Wrapper class representing virtual and physical registers.
Definition Register.h:20
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Primary interface to the complete machine description for the target machine.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
@ ARMSubArch_v7m
Definition Triple.h:142
@ ARMSubArch_v6m
Definition Triple.h:147
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
CallInst * Call
Define some predicates that are used for node matching.
Definition ARMEHABI.h:25
This is an optimization pass for GlobalISel generic memory operations.