0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 //===-- X86AsmPrinter.cpp - Convert X86 LLVM code to AT&T assembly --------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // The LLVM Compiler Infrastructure
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is distributed under the University of Illinois Open Source
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // License. See LICENSE.TXT for details.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 // This file contains a printer that converts from our internal representation
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 // of machine-dependent LLVM code to X86 machine code.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 #include "X86AsmPrinter.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 #include "InstPrinter/X86ATTInstPrinter.h"
|
77
|
17 #include "MCTargetDesc/X86BaseInfo.h"
|
121
|
18 #include "MCTargetDesc/X86TargetStreamer.h"
|
77
|
19 #include "X86InstrInfo.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 #include "X86MachineFunctionInfo.h"
|
121
|
21 #include "llvm/BinaryFormat/COFF.h"
|
77
|
22 #include "llvm/CodeGen/MachineConstantPool.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
|
77
|
24 #include "llvm/CodeGen/MachineValueType.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
|
77
|
26 #include "llvm/IR/DebugInfo.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 #include "llvm/IR/DerivedTypes.h"
|
77
|
28 #include "llvm/IR/Mangler.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 #include "llvm/IR/Module.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 #include "llvm/IR/Type.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 #include "llvm/MC/MCAsmInfo.h"
|
120
|
32 #include "llvm/MC/MCCodeEmitter.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 #include "llvm/MC/MCContext.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 #include "llvm/MC/MCExpr.h"
|
77
|
35 #include "llvm/MC/MCSectionCOFF.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36 #include "llvm/MC/MCSectionMachO.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 #include "llvm/MC/MCStreamer.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 #include "llvm/MC/MCSymbol.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 #include "llvm/Support/Debug.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 #include "llvm/Support/ErrorHandling.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 #include "llvm/Support/TargetRegistry.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 using namespace llvm;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43
|
121
|
44 X86AsmPrinter::X86AsmPrinter(TargetMachine &TM,
|
|
45 std::unique_ptr<MCStreamer> Streamer)
|
|
46 : AsmPrinter(TM, std::move(Streamer)), SM(*this), FM(*this) {}
|
|
47
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 // Primitive Helper Functions.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 /// runOnMachineFunction - Emit the function body.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 ///
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
54 bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
83
|
55 Subtarget = &MF.getSubtarget<X86Subtarget>();
|
|
56
|
77
|
57 SMShadowTracker.startFunction(MF);
|
120
|
58 CodeEmitter.reset(TM.getTarget().createMCCodeEmitter(
|
121
|
59 *Subtarget->getInstrInfo(), *Subtarget->getRegisterInfo(),
|
120
|
60 MF.getContext()));
|
77
|
61
|
121
|
62 EmitFPOData =
|
|
63 Subtarget->isTargetWin32() && MF.getMMI().getModule()->getCodeViewFlag();
|
|
64
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 SetupMachineFunction(MF);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66
|
33
|
67 if (Subtarget->isTargetCOFF()) {
|
120
|
68 bool Local = MF.getFunction()->hasLocalLinkage();
|
95
|
69 OutStreamer->BeginCOFFSymbolDef(CurrentFnSym);
|
120
|
70 OutStreamer->EmitCOFFSymbolStorageClass(
|
|
71 Local ? COFF::IMAGE_SYM_CLASS_STATIC : COFF::IMAGE_SYM_CLASS_EXTERNAL);
|
95
|
72 OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 << COFF::SCT_COMPLEX_TYPE_SHIFT);
|
95
|
74 OutStreamer->EndCOFFSymbolDef();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 // Emit the rest of the function body.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78 EmitFunctionBody();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
79
|
120
|
80 // Emit the XRay table for this function.
|
121
|
81 emitXRayTable();
|
|
82
|
|
83 EmitFPOData = false;
|
120
|
84
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 // We didn't modify anything.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
87 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
88
|
121
|
89 void X86AsmPrinter::EmitFunctionBodyStart() {
|
|
90 if (EmitFPOData) {
|
|
91 X86TargetStreamer *XTS =
|
|
92 static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer());
|
|
93 unsigned ParamsSize =
|
|
94 MF->getInfo<X86MachineFunctionInfo>()->getArgumentStackSize();
|
|
95 XTS->emitFPOProc(CurrentFnSym, ParamsSize);
|
|
96 }
|
|
97 }
|
|
98
|
|
99 void X86AsmPrinter::EmitFunctionBodyEnd() {
|
|
100 if (EmitFPOData) {
|
|
101 X86TargetStreamer *XTS =
|
|
102 static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer());
|
|
103 XTS->emitFPOEndProc();
|
|
104 }
|
|
105 }
|
|
106
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
107 /// printSymbolOperand - Print a raw symbol reference operand. This handles
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108 /// jump tables, constant pools, global address and external symbols, all of
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
109 /// which print to a label with various suffixes for relocation types etc.
|
33
|
110 static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
|
|
111 raw_ostream &O) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112 switch (MO.getType()) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 default: llvm_unreachable("unknown symbol type!");
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 case MachineOperand::MO_ConstantPoolIndex:
|
95
|
115 P.GetCPISymbol(MO.getIndex())->print(O, P.MAI);
|
33
|
116 P.printOffset(MO.getOffset(), O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
117 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 case MachineOperand::MO_GlobalAddress: {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119 const GlobalValue *GV = MO.getGlobal();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
120
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
121 MCSymbol *GVSym;
|
120
|
122 if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
|
123 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE)
|
33
|
124 GVSym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125 else
|
33
|
126 GVSym = P.getSymbol(GV);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
127
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 // Handle dllimport linkage.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
|
33
|
130 GVSym =
|
95
|
131 P.OutContext.getOrCreateSymbol(Twine("__imp_") + GVSym->getName());
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
|
33
|
135 MCSymbol *Sym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 MachineModuleInfoImpl::StubValueTy &StubSym =
|
33
|
137 P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
|
77
|
138 if (!StubSym.getPointer())
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 StubSym = MachineModuleInfoImpl::
|
33
|
140 StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage());
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
143 // If the name begins with a dollar-sign, enclose it in parens. We do this
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144 // to avoid having it look like an integer immediate to the assembler.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 if (GVSym->getName()[0] != '$')
|
95
|
146 GVSym->print(O, P.MAI);
|
|
147 else {
|
|
148 O << '(';
|
|
149 GVSym->print(O, P.MAI);
|
|
150 O << ')';
|
|
151 }
|
33
|
152 P.printOffset(MO.getOffset(), O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
153 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
154 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
156
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
157 switch (MO.getTargetFlags()) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158 default:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 llvm_unreachable("Unknown target flag on GV operand");
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 case X86II::MO_NO_FLAG: // No flag.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
161 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162 case X86II::MO_DARWIN_NONLAZY:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
163 case X86II::MO_DLLIMPORT:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 // These affect the name of the symbol, not any suffix.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166 case X86II::MO_GOT_ABSOLUTE_ADDRESS:
|
95
|
167 O << " + [.-";
|
|
168 P.MF->getPICBaseSymbol()->print(O, P.MAI);
|
|
169 O << ']';
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
170 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
171 case X86II::MO_PIC_BASE_OFFSET:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
172 case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
|
95
|
173 O << '-';
|
|
174 P.MF->getPICBaseSymbol()->print(O, P.MAI);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 case X86II::MO_TLSGD: O << "@TLSGD"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
177 case X86II::MO_TLSLD: O << "@TLSLD"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
178 case X86II::MO_TLSLDM: O << "@TLSLDM"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
179 case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
181 case X86II::MO_TPOFF: O << "@TPOFF"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
182 case X86II::MO_DTPOFF: O << "@DTPOFF"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
183 case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
184 case X86II::MO_GOTNTPOFF: O << "@GOTNTPOFF"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
185 case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
186 case X86II::MO_GOT: O << "@GOT"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
187 case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
188 case X86II::MO_PLT: O << "@PLT"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
189 case X86II::MO_TLVP: O << "@TLVP"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
190 case X86II::MO_TLVP_PIC_BASE:
|
95
|
191 O << "@TLVP" << '-';
|
|
192 P.MF->getPICBaseSymbol()->print(O, P.MAI);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
193 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
194 case X86II::MO_SECREL: O << "@SECREL32"; break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
195 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
196 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
197
|
33
|
198 static void printOperand(X86AsmPrinter &P, const MachineInstr *MI,
|
|
199 unsigned OpNo, raw_ostream &O,
|
77
|
200 const char *Modifier = nullptr, unsigned AsmVariant = 0);
|
33
|
201
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
202 /// printPCRelImm - This is used to print an immediate value that ends up
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
203 /// being encoded as a pc-relative value. These print slightly differently, for
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
204 /// example, a $ is not emitted.
|
33
|
205 static void printPCRelImm(X86AsmPrinter &P, const MachineInstr *MI,
|
|
206 unsigned OpNo, raw_ostream &O) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
207 const MachineOperand &MO = MI->getOperand(OpNo);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
208 switch (MO.getType()) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
209 default: llvm_unreachable("Unknown pcrel immediate operand");
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
210 case MachineOperand::MO_Register:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
211 // pc-relativeness was handled when computing the value in the reg.
|
33
|
212 printOperand(P, MI, OpNo, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
213 return;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
214 case MachineOperand::MO_Immediate:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
215 O << MO.getImm();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
216 return;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
217 case MachineOperand::MO_GlobalAddress:
|
33
|
218 printSymbolOperand(P, MO, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
219 return;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
220 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
221 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
222
|
33
|
223 static void printOperand(X86AsmPrinter &P, const MachineInstr *MI,
|
|
224 unsigned OpNo, raw_ostream &O, const char *Modifier,
|
|
225 unsigned AsmVariant) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
226 const MachineOperand &MO = MI->getOperand(OpNo);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
227 switch (MO.getType()) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
228 default: llvm_unreachable("unknown operand type!");
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
229 case MachineOperand::MO_Register: {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
230 // FIXME: Enumerating AsmVariant, so we can remove magic number.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
231 if (AsmVariant == 0) O << '%';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
232 unsigned Reg = MO.getReg();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
233 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
|
100
|
234 unsigned Size = (strcmp(Modifier+6,"64") == 0) ? 64 :
|
|
235 (strcmp(Modifier+6,"32") == 0) ? 32 :
|
|
236 (strcmp(Modifier+6,"16") == 0) ? 16 : 8;
|
|
237 Reg = getX86SubSuperRegister(Reg, Size);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
238 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
239 O << X86ATTInstPrinter::getRegisterName(Reg);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
240 return;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
241 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
242
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
243 case MachineOperand::MO_Immediate:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
244 if (AsmVariant == 0) O << '$';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
245 O << MO.getImm();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
246 return;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
247
|
33
|
248 case MachineOperand::MO_GlobalAddress: {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
249 if (AsmVariant == 0) O << '$';
|
33
|
250 printSymbolOperand(P, MO, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
251 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
252 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
253 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
254 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
255
|
33
|
256 static void printLeaMemReference(X86AsmPrinter &P, const MachineInstr *MI,
|
|
257 unsigned Op, raw_ostream &O,
|
77
|
258 const char *Modifier = nullptr) {
|
|
259 const MachineOperand &BaseReg = MI->getOperand(Op+X86::AddrBaseReg);
|
|
260 const MachineOperand &IndexReg = MI->getOperand(Op+X86::AddrIndexReg);
|
|
261 const MachineOperand &DispSpec = MI->getOperand(Op+X86::AddrDisp);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
262
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
263 // If we really don't want to print out (rip), don't.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
264 bool HasBaseReg = BaseReg.getReg() != 0;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
265 if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
266 BaseReg.getReg() == X86::RIP)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
267 HasBaseReg = false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
268
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
269 // HasParenPart - True if we will print out the () part of the mem ref.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
270 bool HasParenPart = IndexReg.getReg() || HasBaseReg;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
271
|
33
|
272 switch (DispSpec.getType()) {
|
|
273 default:
|
|
274 llvm_unreachable("unknown operand type!");
|
|
275 case MachineOperand::MO_Immediate: {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
276 int DispVal = DispSpec.getImm();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
277 if (DispVal || !HasParenPart)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
278 O << DispVal;
|
33
|
279 break;
|
|
280 }
|
|
281 case MachineOperand::MO_GlobalAddress:
|
|
282 case MachineOperand::MO_ConstantPoolIndex:
|
77
|
283 printSymbolOperand(P, DispSpec, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
284 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
285
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
286 if (Modifier && strcmp(Modifier, "H") == 0)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
287 O << "+8";
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
288
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
289 if (HasParenPart) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
290 assert(IndexReg.getReg() != X86::ESP &&
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
291 "X86 doesn't allow scaling by ESP");
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
292
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
293 O << '(';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
294 if (HasBaseReg)
|
77
|
295 printOperand(P, MI, Op+X86::AddrBaseReg, O, Modifier);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
296
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
297 if (IndexReg.getReg()) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
298 O << ',';
|
77
|
299 printOperand(P, MI, Op+X86::AddrIndexReg, O, Modifier);
|
|
300 unsigned ScaleVal = MI->getOperand(Op+X86::AddrScaleAmt).getImm();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
301 if (ScaleVal != 1)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
302 O << ',' << ScaleVal;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
303 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
304 O << ')';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
305 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
306 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
307
|
33
|
308 static void printMemReference(X86AsmPrinter &P, const MachineInstr *MI,
|
|
309 unsigned Op, raw_ostream &O,
|
77
|
310 const char *Modifier = nullptr) {
|
120
|
311 assert(isMem(*MI, Op) && "Invalid memory reference!");
|
77
|
312 const MachineOperand &Segment = MI->getOperand(Op+X86::AddrSegmentReg);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
313 if (Segment.getReg()) {
|
77
|
314 printOperand(P, MI, Op+X86::AddrSegmentReg, O, Modifier);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
315 O << ':';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
316 }
|
33
|
317 printLeaMemReference(P, MI, Op, O, Modifier);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
318 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
319
|
33
|
320 static void printIntelMemReference(X86AsmPrinter &P, const MachineInstr *MI,
|
|
321 unsigned Op, raw_ostream &O,
|
77
|
322 const char *Modifier = nullptr,
|
33
|
323 unsigned AsmVariant = 1) {
|
77
|
324 const MachineOperand &BaseReg = MI->getOperand(Op+X86::AddrBaseReg);
|
|
325 unsigned ScaleVal = MI->getOperand(Op+X86::AddrScaleAmt).getImm();
|
|
326 const MachineOperand &IndexReg = MI->getOperand(Op+X86::AddrIndexReg);
|
|
327 const MachineOperand &DispSpec = MI->getOperand(Op+X86::AddrDisp);
|
|
328 const MachineOperand &SegReg = MI->getOperand(Op+X86::AddrSegmentReg);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
329
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
330 // If this has a segment register, print it.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
331 if (SegReg.getReg()) {
|
77
|
332 printOperand(P, MI, Op+X86::AddrSegmentReg, O, Modifier, AsmVariant);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
333 O << ':';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
334 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
335
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
336 O << '[';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
337
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
338 bool NeedPlus = false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
339 if (BaseReg.getReg()) {
|
77
|
340 printOperand(P, MI, Op+X86::AddrBaseReg, O, Modifier, AsmVariant);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
341 NeedPlus = true;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
342 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
343
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
344 if (IndexReg.getReg()) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
345 if (NeedPlus) O << " + ";
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
346 if (ScaleVal != 1)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
347 O << ScaleVal << '*';
|
77
|
348 printOperand(P, MI, Op+X86::AddrIndexReg, O, Modifier, AsmVariant);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
349 NeedPlus = true;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
350 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
351
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
352 if (!DispSpec.isImm()) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
353 if (NeedPlus) O << " + ";
|
77
|
354 printOperand(P, MI, Op+X86::AddrDisp, O, Modifier, AsmVariant);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
355 } else {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
356 int64_t DispVal = DispSpec.getImm();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
357 if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
358 if (NeedPlus) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
359 if (DispVal > 0)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
360 O << " + ";
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
361 else {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
362 O << " - ";
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
363 DispVal = -DispVal;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
364 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
365 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
366 O << DispVal;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
367 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
368 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
369 O << ']';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
370 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
371
|
33
|
372 static bool printAsmMRegister(X86AsmPrinter &P, const MachineOperand &MO,
|
|
373 char Mode, raw_ostream &O) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
374 unsigned Reg = MO.getReg();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
375 switch (Mode) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
376 default: return true; // Unknown mode.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
377 case 'b': // Print QImode register
|
100
|
378 Reg = getX86SubSuperRegister(Reg, 8);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
379 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
380 case 'h': // Print QImode high register
|
100
|
381 Reg = getX86SubSuperRegister(Reg, 8, true);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
382 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
383 case 'w': // Print HImode register
|
100
|
384 Reg = getX86SubSuperRegister(Reg, 16);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
385 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
386 case 'k': // Print SImode register
|
100
|
387 Reg = getX86SubSuperRegister(Reg, 32);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
388 break;
|
77
|
389 case 'q':
|
|
390 // Print 64-bit register names if 64-bit integer registers are available.
|
|
391 // Otherwise, print 32-bit register names.
|
100
|
392 Reg = getX86SubSuperRegister(Reg, P.getSubtarget().is64Bit() ? 64 : 32);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
393 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
394 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
395
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
396 O << '%' << X86ATTInstPrinter::getRegisterName(Reg);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
397 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
398 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
399
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
400 /// PrintAsmOperand - Print out an operand for an inline asm expression.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
401 ///
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
402 bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
403 unsigned AsmVariant,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
404 const char *ExtraCode, raw_ostream &O) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
405 // Does this asm operand have a single letter operand modifier?
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
406 if (ExtraCode && ExtraCode[0]) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
407 if (ExtraCode[1] != 0) return true; // Unknown modifier.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
408
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
409 const MachineOperand &MO = MI->getOperand(OpNo);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
410
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
411 switch (ExtraCode[0]) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
412 default:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
413 // See if this is a generic print operand
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
414 return AsmPrinter::PrintAsmOperand(MI, OpNo, AsmVariant, ExtraCode, O);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
415 case 'a': // This is an address. Currently only 'i' and 'r' are expected.
|
33
|
416 switch (MO.getType()) {
|
|
417 default:
|
|
418 return true;
|
|
419 case MachineOperand::MO_Immediate:
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
420 O << MO.getImm();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
421 return false;
|
33
|
422 case MachineOperand::MO_ConstantPoolIndex:
|
|
423 case MachineOperand::MO_JumpTableIndex:
|
|
424 case MachineOperand::MO_ExternalSymbol:
|
|
425 llvm_unreachable("unexpected operand type!");
|
|
426 case MachineOperand::MO_GlobalAddress:
|
|
427 printSymbolOperand(*this, MO, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
428 if (Subtarget->isPICStyleRIPRel())
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
429 O << "(%rip)";
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
430 return false;
|
33
|
431 case MachineOperand::MO_Register:
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
432 O << '(';
|
33
|
433 printOperand(*this, MI, OpNo, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
434 O << ')';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
435 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
436 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
437
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
438 case 'c': // Don't print "$" before a global var name or constant.
|
33
|
439 switch (MO.getType()) {
|
|
440 default:
|
|
441 printOperand(*this, MI, OpNo, O);
|
|
442 break;
|
|
443 case MachineOperand::MO_Immediate:
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
444 O << MO.getImm();
|
33
|
445 break;
|
|
446 case MachineOperand::MO_ConstantPoolIndex:
|
|
447 case MachineOperand::MO_JumpTableIndex:
|
|
448 case MachineOperand::MO_ExternalSymbol:
|
|
449 llvm_unreachable("unexpected operand type!");
|
|
450 case MachineOperand::MO_GlobalAddress:
|
|
451 printSymbolOperand(*this, MO, O);
|
|
452 break;
|
|
453 }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
454 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
455
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
456 case 'A': // Print '*' before a register (it must be a register)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
457 if (MO.isReg()) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
458 O << '*';
|
33
|
459 printOperand(*this, MI, OpNo, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
460 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
461 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
462 return true;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
463
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
464 case 'b': // Print QImode register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
465 case 'h': // Print QImode high register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
466 case 'w': // Print HImode register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
467 case 'k': // Print SImode register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
468 case 'q': // Print DImode register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
469 if (MO.isReg())
|
33
|
470 return printAsmMRegister(*this, MO, ExtraCode[0], O);
|
|
471 printOperand(*this, MI, OpNo, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
472 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
473
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
474 case 'P': // This is the operand of a call, treat specially.
|
33
|
475 printPCRelImm(*this, MI, OpNo, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
476 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
477
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
478 case 'n': // Negate the immediate or print a '-' before the operand.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
479 // Note: this is a temporary solution. It should be handled target
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
480 // independently as part of the 'MC' work.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
481 if (MO.isImm()) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
482 O << -MO.getImm();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
483 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
484 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
485 O << '-';
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
486 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
487 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
488
|
77
|
489 printOperand(*this, MI, OpNo, O, /*Modifier*/ nullptr, AsmVariant);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
490 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
491 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
492
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
493 bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
494 unsigned OpNo, unsigned AsmVariant,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
495 const char *ExtraCode,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
496 raw_ostream &O) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
497 if (AsmVariant) {
|
33
|
498 printIntelMemReference(*this, MI, OpNo, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
499 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
500 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
501
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
502 if (ExtraCode && ExtraCode[0]) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
503 if (ExtraCode[1] != 0) return true; // Unknown modifier.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
504
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
505 switch (ExtraCode[0]) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
506 default: return true; // Unknown modifier.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
507 case 'b': // Print QImode register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
508 case 'h': // Print QImode high register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
509 case 'w': // Print HImode register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
510 case 'k': // Print SImode register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
511 case 'q': // Print SImode register
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
512 // These only apply to registers, ignore on mem.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
513 break;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
514 case 'H':
|
33
|
515 printMemReference(*this, MI, OpNo, O, "H");
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
516 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
517 case 'P': // Don't print @PLT, but do print as memory.
|
33
|
518 printMemReference(*this, MI, OpNo, O, "no-rip");
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
519 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
520 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
521 }
|
33
|
522 printMemReference(*this, MI, OpNo, O);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
523 return false;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
524 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
525
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
526 void X86AsmPrinter::EmitStartOfAsmFile(Module &M) {
|
95
|
527 const Triple &TT = TM.getTargetTriple();
|
83
|
528
|
|
529 if (TT.isOSBinFormatMachO())
|
95
|
530 OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
531
|
83
|
532 if (TT.isOSBinFormatCOFF()) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
533 // Emit an absolute @feat.00 symbol. This appears to be some kind of
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
534 // compiler features bitfield read by link.exe.
|
83
|
535 if (TT.getArch() == Triple::x86) {
|
95
|
536 MCSymbol *S = MMI->getContext().getOrCreateSymbol(StringRef("@feat.00"));
|
|
537 OutStreamer->BeginCOFFSymbolDef(S);
|
|
538 OutStreamer->EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
|
|
539 OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL);
|
|
540 OutStreamer->EndCOFFSymbolDef();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
541 // According to the PE-COFF spec, the LSB of this value marks the object
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
542 // for "registered SEH". This means that all SEH handler entry points
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
543 // must be registered in .sxdata. Use of any unregistered handlers will
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
544 // cause the process to terminate immediately. LLVM does not know how to
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
545 // register any SEH handlers, so its object files should be safe.
|
95
|
546 OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
|
|
547 OutStreamer->EmitAssignment(
|
|
548 S, MCConstantExpr::create(int64_t(1), MMI->getContext()));
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
549 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
550 }
|
95
|
551 OutStreamer->EmitSyntaxDirective();
|
120
|
552
|
|
553 // If this is not inline asm and we're in 16-bit
|
|
554 // mode prefix assembly with .code16.
|
|
555 bool is16 = TT.getEnvironment() == Triple::CODE16;
|
|
556 if (M.getModuleInlineAsm().empty() && is16)
|
|
557 OutStreamer->EmitAssemblerFlag(MCAF_Code16);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
558 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
559
|
77
|
560 static void
|
|
561 emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel,
|
|
562 MachineModuleInfoImpl::StubValueTy &MCSym) {
|
|
563 // L_foo$stub:
|
|
564 OutStreamer.EmitLabel(StubLabel);
|
|
565 // .indirect_symbol _foo
|
|
566 OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
|
|
567
|
|
568 if (MCSym.getInt())
|
|
569 // External to current translation unit.
|
|
570 OutStreamer.EmitIntValue(0, 4/*size*/);
|
|
571 else
|
|
572 // Internal to current translation unit.
|
|
573 //
|
|
574 // When we place the LSDA into the TEXT section, the type info
|
|
575 // pointers need to be indirect and pc-rel. We accomplish this by
|
|
576 // using NLPs; however, sometimes the types are local to the file.
|
|
577 // We need to fill in the value for the NLP in those cases.
|
|
578 OutStreamer.EmitValue(
|
95
|
579 MCSymbolRefExpr::create(MCSym.getPointer(), OutStreamer.getContext()),
|
77
|
580 4 /*size*/);
|
|
581 }
|
|
582
|
|
583 MCSymbol *X86AsmPrinter::GetCPISymbol(unsigned CPID) const {
|
|
584 if (Subtarget->isTargetKnownWindowsMSVC()) {
|
|
585 const MachineConstantPoolEntry &CPE =
|
|
586 MF->getConstantPool()->getConstants()[CPID];
|
|
587 if (!CPE.isMachineConstantPoolEntry()) {
|
95
|
588 const DataLayout &DL = MF->getDataLayout();
|
|
589 SectionKind Kind = CPE.getSectionKind(&DL);
|
77
|
590 const Constant *C = CPE.Val.ConstVal;
|
120
|
591 unsigned Align = CPE.Alignment;
|
77
|
592 if (const MCSectionCOFF *S = dyn_cast<MCSectionCOFF>(
|
120
|
593 getObjFileLowering().getSectionForConstant(DL, Kind, C, Align))) {
|
77
|
594 if (MCSymbol *Sym = S->getCOMDATSymbol()) {
|
|
595 if (Sym->isUndefined())
|
95
|
596 OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global);
|
77
|
597 return Sym;
|
|
598 }
|
|
599 }
|
|
600 }
|
|
601 }
|
|
602
|
|
603 return AsmPrinter::GetCPISymbol(CPID);
|
|
604 }
|
|
605
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
606 void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
|
95
|
607 const Triple &TT = TM.getTargetTriple();
|
83
|
608
|
|
609 if (TT.isOSBinFormatMachO()) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
610 // All darwin targets use mach-o.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
611 MachineModuleInfoMachO &MMIMacho =
|
83
|
612 MMI->getObjFileInfo<MachineModuleInfoMachO>();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
613
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
614 // Output stubs for dynamically-linked functions.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
615 MachineModuleInfoMachO::SymbolListTy Stubs;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
616
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
617 // Output stubs for external and common global variables.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
618 Stubs = MMIMacho.GetGVStubList();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
619 if (!Stubs.empty()) {
|
95
|
620 MCSection *TheSection = OutContext.getMachOSection(
|
|
621 "__IMPORT", "__pointers", MachO::S_NON_LAZY_SYMBOL_POINTERS,
|
|
622 SectionKind::getMetadata());
|
|
623 OutStreamer->SwitchSection(TheSection);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
624
|
77
|
625 for (auto &Stub : Stubs)
|
95
|
626 emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
|
77
|
627
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
628 Stubs.clear();
|
95
|
629 OutStreamer->AddBlankLine();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
630 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
631
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
632 SM.serializeToStackMapSection();
|
95
|
633 FM.serializeToFaultMapSection();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
634
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
635 // Funny Darwin hack: This flag tells the linker that no global symbols
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
636 // contain code that falls through to other global symbols (e.g. the obvious
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
637 // implementation of multiple entry points). If this doesn't occur, the
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
638 // linker can safely perform dead code stripping. Since LLVM never
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
639 // generates code that does this, it is always safe to set.
|
95
|
640 OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
641 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
642
|
83
|
643 if (TT.isKnownWindowsMSVCEnvironment() && MMI->usesVAFloatArgument()) {
|
|
644 StringRef SymbolName =
|
|
645 (TT.getArch() == Triple::x86_64) ? "_fltused" : "__fltused";
|
95
|
646 MCSymbol *S = MMI->getContext().getOrCreateSymbol(SymbolName);
|
|
647 OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
648 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
649
|
83
|
650 if (TT.isOSBinFormatCOFF()) {
|
95
|
651 const TargetLoweringObjectFileCOFF &TLOFCOFF =
|
|
652 static_cast<const TargetLoweringObjectFileCOFF&>(getObjFileLowering());
|
|
653
|
|
654 std::string Flags;
|
|
655 raw_string_ostream FlagsOS(Flags);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
656
|
77
|
657 for (const auto &Function : M)
|
120
|
658 TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Function);
|
77
|
659 for (const auto &Global : M.globals())
|
120
|
660 TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Global);
|
95
|
661 for (const auto &Alias : M.aliases())
|
120
|
662 TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Alias);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
663
|
95
|
664 FlagsOS.flush();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
665
|
95
|
666 // Output collected flags.
|
|
667 if (!Flags.empty()) {
|
|
668 OutStreamer->SwitchSection(TLOFCOFF.getDrectveSection());
|
|
669 OutStreamer->EmitBytes(Flags);
|
77
|
670 }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
671
|
95
|
672 SM.serializeToStackMapSection();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
673 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
674
|
83
|
675 if (TT.isOSBinFormatELF()) {
|
77
|
676 SM.serializeToStackMapSection();
|
95
|
677 FM.serializeToFaultMapSection();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
678 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
679 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
680
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
681 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
682 // Target Registry Stuff
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
683 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
684
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
685 // Force static initialization.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
686 extern "C" void LLVMInitializeX86AsmPrinter() {
|
120
|
687 RegisterAsmPrinter<X86AsmPrinter> X(getTheX86_32Target());
|
|
688 RegisterAsmPrinter<X86AsmPrinter> Y(getTheX86_64Target());
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
689 }
|