0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 //===-- ARMAsmPrinter.h - ARM implementation of AsmPrinter ------*- C++ -*-===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 //
|
147
|
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
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8
|
77
|
9 #ifndef LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
|
|
10 #define LLVM_LIB_TARGET_ARM_ARMASMPRINTER_H
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11
|
77
|
12 #include "ARMSubtarget.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 #include "llvm/CodeGen/AsmPrinter.h"
|
77
|
14 #include "llvm/Target/TargetMachine.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 namespace llvm {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17
|
77
|
18 class ARMFunctionInfo;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 class MCOperand;
|
77
|
20 class MachineConstantPool;
|
|
21 class MachineOperand;
|
83
|
22 class MCSymbol;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 namespace ARM {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 enum DW_ISA {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 DW_ISA_ARM_thumb = 1,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 DW_ISA_ARM_arm = 2
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 };
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 /// Subtarget - Keep a pointer to the ARMSubtarget around so that we can
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 /// make the right decision when printing asm code for different targets.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 const ARMSubtarget *Subtarget;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 /// AFI - Keep a pointer to ARMFunctionInfo for the current
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 /// MachineFunction.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 ARMFunctionInfo *AFI;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 /// MCP - Keep a pointer to constantpool entries of the current
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 /// MachineFunction.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 const MachineConstantPool *MCP;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
45 /// InConstantPool - Maintain state when emitting a sequence of constant
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
46 /// pool entries so we can properly mark them as data regions.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 bool InConstantPool;
|
83
|
48
|
|
49 /// ThumbIndirectPads - These maintain a per-function list of jump pad
|
|
50 /// labels used for ARMv4t thumb code to make register indirect calls.
|
|
51 SmallVector<std::pair<unsigned, MCSymbol*>, 4> ThumbIndirectPads;
|
|
52
|
100
|
53 /// OptimizationGoals - Maintain a combined optimization goal for all
|
|
54 /// functions in a module: one of Tag_ABI_optimization_goals values,
|
|
55 /// -1 if uninitialized, 0 if conflicting goals
|
|
56 int OptimizationGoals;
|
|
57
|
120
|
58 /// List of globals that have had their storage promoted to a constant
|
|
59 /// pool. This lives between calls to runOnMachineFunction and collects
|
|
60 /// data from every MachineFunction. It is used during doFinalization
|
|
61 /// when all non-function globals are emitted.
|
|
62 SmallPtrSet<const GlobalVariable*,2> PromotedGlobals;
|
|
63 /// Set of globals in PromotedGlobals that we've emitted labels for.
|
|
64 /// We need to emit labels even for promoted globals so that DWARF
|
|
65 /// debug info can link properly.
|
|
66 SmallPtrSet<const GlobalVariable*,2> EmittedPromotedGlobalLabels;
|
|
67
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
68 public:
|
83
|
69 explicit ARMAsmPrinter(TargetMachine &TM,
|
|
70 std::unique_ptr<MCStreamer> Streamer);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71
|
120
|
72 StringRef getPassName() const override {
|
|
73 return "ARM Assembly Printer";
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75
|
95
|
76 void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77
|
147
|
78 void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &O) override;
|
77
|
79 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNum,
|
147
|
80 const char *ExtraCode, raw_ostream &O) override;
|
77
|
81 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum,
|
147
|
82 const char *ExtraCode, raw_ostream &O) override;
|
77
|
83
|
|
84 void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
|
|
85 const MCSubtargetInfo *EndInfo) const override;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86
|
95
|
87 void EmitJumpTableAddrs(const MachineInstr *MI);
|
|
88 void EmitJumpTableInsts(const MachineInstr *MI);
|
|
89 void EmitJumpTableTBInst(const MachineInstr *MI, unsigned OffsetWidth);
|
77
|
90 void EmitInstruction(const MachineInstr *MI) override;
|
|
91 bool runOnMachineFunction(MachineFunction &F) override;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
92
|
77
|
93 void EmitConstantPool() override {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94 // we emit constant pools customly!
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
95 }
|
77
|
96 void EmitFunctionBodyEnd() override;
|
|
97 void EmitFunctionEntryLabel() override;
|
|
98 void EmitStartOfAsmFile(Module &M) override;
|
|
99 void EmitEndOfAsmFile(Module &M) override;
|
95
|
100 void EmitXXStructor(const DataLayout &DL, const Constant *CV) override;
|
120
|
101 void EmitGlobalVariable(const GlobalVariable *GV) override;
|
147
|
102
|
|
103 MCSymbol *GetCPISymbol(unsigned CPID) const override;
|
|
104
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
105 // lowerOperand - Convert a MachineOperand into the equivalent MCOperand.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
106 bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107
|
120
|
108 //===------------------------------------------------------------------===//
|
|
109 // XRay implementation
|
|
110 //===------------------------------------------------------------------===//
|
|
111 public:
|
|
112 // XRay-specific lowering for ARM.
|
|
113 void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI);
|
|
114 void LowerPATCHABLE_FUNCTION_EXIT(const MachineInstr &MI);
|
|
115 void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI);
|
|
116
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 private:
|
120
|
118 void EmitSled(const MachineInstr &MI, SledKind Kind);
|
|
119
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120 // Helpers for EmitStartOfAsmFile() and EmitEndOfAsmFile()
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
121 void emitAttributes();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
122
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
123 // Generic helper used to emit e.g. ARMv5 mul pseudos
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
124 void EmitPatchedInstruction(const MachineInstr *MI, unsigned TargetOpc);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 void EmitUnwindingInstruction(const MachineInstr *MI);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 // emitPseudoExpansionLowering - tblgen'erated.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 bool emitPseudoExpansionLowering(MCStreamer &OutStreamer,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 const MachineInstr *MI);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
131
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132 public:
|
95
|
133 unsigned getISAEncoding() override {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 // ARM/Darwin adds ISA to the DWARF info for each function.
|
95
|
135 const Triple &TT = TM.getTargetTriple();
|
83
|
136 if (!TT.isOSBinFormatMachO())
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 return 0;
|
121
|
138 bool isThumb = TT.isThumb() ||
|
95
|
139 TT.getSubArch() == Triple::ARMSubArch_v7m ||
|
|
140 TT.getSubArch() == Triple::ARMSubArch_v6m;
|
|
141 return isThumb ? ARM::DW_ISA_ARM_thumb : ARM::DW_ISA_ARM_arm;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 private:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 MCOperand GetSymbolRef(const MachineOperand &MO, const MCSymbol *Symbol);
|
95
|
146 MCSymbol *GetARMJTIPICJumpTableLabel(unsigned uid) const;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
147
|
33
|
148 MCSymbol *GetARMGVSymbol(const GlobalValue *GV, unsigned char TargetFlags);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
150 public:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151 /// EmitMachineConstantPoolValue - Print a machine constantpool value to
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
152 /// the .s file.
|
77
|
153 void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) override;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
154 };
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 } // end namespace llvm
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 #endif
|