1 //===-- X86AsmPrinter.cpp - Convert X86 LLVM code to AT&T assembly --------===//
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 // This file contains a printer that converts from our internal representation
11 // of machine-dependent LLVM code to X86 machine code.
13 //===----------------------------------------------------------------------===//
15 #include "X86AsmPrinter.h"
16 #include "InstPrinter/X86ATTInstPrinter.h"
17 #include "MCTargetDesc/X86BaseInfo.h"
18 #include "MCTargetDesc/X86TargetStreamer.h"
19 #include "X86InstrInfo.h"
20 #include "X86MachineFunctionInfo.h"
21 #include "llvm/BinaryFormat/COFF.h"
22 #include "llvm/CodeGen/MachineConstantPool.h"
23 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
24 #include "llvm/CodeGen/MachineValueType.h"
25 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
26 #include "llvm/IR/DerivedTypes.h"
27 #include "llvm/IR/Mangler.h"
28 #include "llvm/IR/Module.h"
29 #include "llvm/IR/Type.h"
30 #include "llvm/MC/MCCodeEmitter.h"
31 #include "llvm/MC/MCContext.h"
32 #include "llvm/MC/MCExpr.h"
33 #include "llvm/MC/MCSectionCOFF.h"
34 #include "llvm/MC/MCSectionMachO.h"
35 #include "llvm/MC/MCStreamer.h"
36 #include "llvm/MC/MCSymbol.h"
37 #include "llvm/Support/Debug.h"
38 #include "llvm/Support/ErrorHandling.h"
39 #include "llvm/Support/TargetRegistry.h"
42 X86AsmPrinter::X86AsmPrinter(TargetMachine &TM,
43 std::unique_ptr<MCStreamer> Streamer)
44 : AsmPrinter(TM, std::move(Streamer)), SM(*this), FM(*this) {}
46 //===----------------------------------------------------------------------===//
47 // Primitive Helper Functions.
48 //===----------------------------------------------------------------------===//
50 /// runOnMachineFunction - Emit the function body.
52 bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
53 Subtarget = &MF.getSubtarget<X86Subtarget>();
55 SMShadowTracker.startFunction(MF);
56 CodeEmitter.reset(TM.getTarget().createMCCodeEmitter(
57 *Subtarget->getInstrInfo(), *Subtarget->getRegisterInfo(),
61 Subtarget->isTargetWin32() && MF.getMMI().getModule()->getCodeViewFlag();
63 SetupMachineFunction(MF);
65 if (Subtarget->isTargetCOFF()) {
66 bool Local = MF.getFunction().hasLocalLinkage();
67 OutStreamer->BeginCOFFSymbolDef(CurrentFnSym);
68 OutStreamer->EmitCOFFSymbolStorageClass(
69 Local ? COFF::IMAGE_SYM_CLASS_STATIC : COFF::IMAGE_SYM_CLASS_EXTERNAL);
70 OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION
71 << COFF::SCT_COMPLEX_TYPE_SHIFT);
72 OutStreamer->EndCOFFSymbolDef();
75 // Emit the rest of the function body.
78 // Emit the XRay table for this function.
83 // We didn't modify anything.
87 void X86AsmPrinter::EmitFunctionBodyStart() {
89 X86TargetStreamer *XTS =
90 static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer());
92 MF->getInfo<X86MachineFunctionInfo>()->getArgumentStackSize();
93 XTS->emitFPOProc(CurrentFnSym, ParamsSize);
97 void X86AsmPrinter::EmitFunctionBodyEnd() {
99 X86TargetStreamer *XTS =
100 static_cast<X86TargetStreamer *>(OutStreamer->getTargetStreamer());
101 XTS->emitFPOEndProc();
105 /// printSymbolOperand - Print a raw symbol reference operand. This handles
106 /// jump tables, constant pools, global address and external symbols, all of
107 /// which print to a label with various suffixes for relocation types etc.
108 static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
110 switch (MO.getType()) {
111 default: llvm_unreachable("unknown symbol type!");
112 case MachineOperand::MO_ConstantPoolIndex:
113 P.GetCPISymbol(MO.getIndex())->print(O, P.MAI);
114 P.printOffset(MO.getOffset(), O);
116 case MachineOperand::MO_GlobalAddress: {
117 const GlobalValue *GV = MO.getGlobal();
120 if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
121 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE)
122 GVSym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
124 GVSym = P.getSymbol(GV);
126 // Handle dllimport linkage.
127 if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
129 P.OutContext.getOrCreateSymbol(Twine("__imp_") + GVSym->getName());
131 if (MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY ||
132 MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE) {
133 MCSymbol *Sym = P.getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
134 MachineModuleInfoImpl::StubValueTy &StubSym =
135 P.MMI->getObjFileInfo<MachineModuleInfoMachO>().getGVStubEntry(Sym);
136 if (!StubSym.getPointer())
137 StubSym = MachineModuleInfoImpl::
138 StubValueTy(P.getSymbol(GV), !GV->hasInternalLinkage());
141 // If the name begins with a dollar-sign, enclose it in parens. We do this
142 // to avoid having it look like an integer immediate to the assembler.
143 if (GVSym->getName()[0] != '$')
144 GVSym->print(O, P.MAI);
147 GVSym->print(O, P.MAI);
150 P.printOffset(MO.getOffset(), O);
155 switch (MO.getTargetFlags()) {
157 llvm_unreachable("Unknown target flag on GV operand");
158 case X86II::MO_NO_FLAG: // No flag.
160 case X86II::MO_DARWIN_NONLAZY:
161 case X86II::MO_DLLIMPORT:
162 // These affect the name of the symbol, not any suffix.
164 case X86II::MO_GOT_ABSOLUTE_ADDRESS:
166 P.MF->getPICBaseSymbol()->print(O, P.MAI);
169 case X86II::MO_PIC_BASE_OFFSET:
170 case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
172 P.MF->getPICBaseSymbol()->print(O, P.MAI);
174 case X86II::MO_TLSGD: O << "@TLSGD"; break;
175 case X86II::MO_TLSLD: O << "@TLSLD"; break;
176 case X86II::MO_TLSLDM: O << "@TLSLDM"; break;
177 case X86II::MO_GOTTPOFF: O << "@GOTTPOFF"; break;
178 case X86II::MO_INDNTPOFF: O << "@INDNTPOFF"; break;
179 case X86II::MO_TPOFF: O << "@TPOFF"; break;
180 case X86II::MO_DTPOFF: O << "@DTPOFF"; break;
181 case X86II::MO_NTPOFF: O << "@NTPOFF"; break;
182 case X86II::MO_GOTNTPOFF: O << "@GOTNTPOFF"; break;
183 case X86II::MO_GOTPCREL: O << "@GOTPCREL"; break;
184 case X86II::MO_GOT: O << "@GOT"; break;
185 case X86II::MO_GOTOFF: O << "@GOTOFF"; break;
186 case X86II::MO_PLT: O << "@PLT"; break;
187 case X86II::MO_TLVP: O << "@TLVP"; break;
188 case X86II::MO_TLVP_PIC_BASE:
190 P.MF->getPICBaseSymbol()->print(O, P.MAI);
192 case X86II::MO_SECREL: O << "@SECREL32"; break;
196 static void printOperand(X86AsmPrinter &P, const MachineInstr *MI,
197 unsigned OpNo, raw_ostream &O,
198 const char *Modifier = nullptr, unsigned AsmVariant = 0);
200 /// printPCRelImm - This is used to print an immediate value that ends up
201 /// being encoded as a pc-relative value. These print slightly differently, for
202 /// example, a $ is not emitted.
203 static void printPCRelImm(X86AsmPrinter &P, const MachineInstr *MI,
204 unsigned OpNo, raw_ostream &O) {
205 const MachineOperand &MO = MI->getOperand(OpNo);
206 switch (MO.getType()) {
207 default: llvm_unreachable("Unknown pcrel immediate operand");
208 case MachineOperand::MO_Register:
209 // pc-relativeness was handled when computing the value in the reg.
210 printOperand(P, MI, OpNo, O);
212 case MachineOperand::MO_Immediate:
215 case MachineOperand::MO_GlobalAddress:
216 printSymbolOperand(P, MO, O);
221 static void printOperand(X86AsmPrinter &P, const MachineInstr *MI,
222 unsigned OpNo, raw_ostream &O, const char *Modifier,
223 unsigned AsmVariant) {
224 const MachineOperand &MO = MI->getOperand(OpNo);
225 switch (MO.getType()) {
226 default: llvm_unreachable("unknown operand type!");
227 case MachineOperand::MO_Register: {
228 // FIXME: Enumerating AsmVariant, so we can remove magic number.
229 if (AsmVariant == 0) O << '%';
230 unsigned Reg = MO.getReg();
231 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
232 unsigned Size = (strcmp(Modifier+6,"64") == 0) ? 64 :
233 (strcmp(Modifier+6,"32") == 0) ? 32 :
234 (strcmp(Modifier+6,"16") == 0) ? 16 : 8;
235 Reg = getX86SubSuperRegister(Reg, Size);
237 O << X86ATTInstPrinter::getRegisterName(Reg);
241 case MachineOperand::MO_Immediate:
242 if (AsmVariant == 0) O << '$';
246 case MachineOperand::MO_GlobalAddress: {
247 if (AsmVariant == 0) O << '$';
248 printSymbolOperand(P, MO, O);
254 static void printLeaMemReference(X86AsmPrinter &P, const MachineInstr *MI,
255 unsigned Op, raw_ostream &O,
256 const char *Modifier = nullptr) {
257 const MachineOperand &BaseReg = MI->getOperand(Op+X86::AddrBaseReg);
258 const MachineOperand &IndexReg = MI->getOperand(Op+X86::AddrIndexReg);
259 const MachineOperand &DispSpec = MI->getOperand(Op+X86::AddrDisp);
261 // If we really don't want to print out (rip), don't.
262 bool HasBaseReg = BaseReg.getReg() != 0;
263 if (HasBaseReg && Modifier && !strcmp(Modifier, "no-rip") &&
264 BaseReg.getReg() == X86::RIP)
267 // HasParenPart - True if we will print out the () part of the mem ref.
268 bool HasParenPart = IndexReg.getReg() || HasBaseReg;
270 switch (DispSpec.getType()) {
272 llvm_unreachable("unknown operand type!");
273 case MachineOperand::MO_Immediate: {
274 int DispVal = DispSpec.getImm();
275 if (DispVal || !HasParenPart)
279 case MachineOperand::MO_GlobalAddress:
280 case MachineOperand::MO_ConstantPoolIndex:
281 printSymbolOperand(P, DispSpec, O);
284 if (Modifier && strcmp(Modifier, "H") == 0)
288 assert(IndexReg.getReg() != X86::ESP &&
289 "X86 doesn't allow scaling by ESP");
293 printOperand(P, MI, Op+X86::AddrBaseReg, O, Modifier);
295 if (IndexReg.getReg()) {
297 printOperand(P, MI, Op+X86::AddrIndexReg, O, Modifier);
298 unsigned ScaleVal = MI->getOperand(Op+X86::AddrScaleAmt).getImm();
300 O << ',' << ScaleVal;
306 static void printMemReference(X86AsmPrinter &P, const MachineInstr *MI,
307 unsigned Op, raw_ostream &O,
308 const char *Modifier = nullptr) {
309 assert(isMem(*MI, Op) && "Invalid memory reference!");
310 const MachineOperand &Segment = MI->getOperand(Op+X86::AddrSegmentReg);
311 if (Segment.getReg()) {
312 printOperand(P, MI, Op+X86::AddrSegmentReg, O, Modifier);
315 printLeaMemReference(P, MI, Op, O, Modifier);
318 static void printIntelMemReference(X86AsmPrinter &P, const MachineInstr *MI,
319 unsigned Op, raw_ostream &O,
320 const char *Modifier = nullptr,
321 unsigned AsmVariant = 1) {
322 const MachineOperand &BaseReg = MI->getOperand(Op+X86::AddrBaseReg);
323 unsigned ScaleVal = MI->getOperand(Op+X86::AddrScaleAmt).getImm();
324 const MachineOperand &IndexReg = MI->getOperand(Op+X86::AddrIndexReg);
325 const MachineOperand &DispSpec = MI->getOperand(Op+X86::AddrDisp);
326 const MachineOperand &SegReg = MI->getOperand(Op+X86::AddrSegmentReg);
328 // If this has a segment register, print it.
329 if (SegReg.getReg()) {
330 printOperand(P, MI, Op+X86::AddrSegmentReg, O, Modifier, AsmVariant);
336 bool NeedPlus = false;
337 if (BaseReg.getReg()) {
338 printOperand(P, MI, Op+X86::AddrBaseReg, O, Modifier, AsmVariant);
342 if (IndexReg.getReg()) {
343 if (NeedPlus) O << " + ";
345 O << ScaleVal << '*';
346 printOperand(P, MI, Op+X86::AddrIndexReg, O, Modifier, AsmVariant);
350 if (!DispSpec.isImm()) {
351 if (NeedPlus) O << " + ";
352 printOperand(P, MI, Op+X86::AddrDisp, O, Modifier, AsmVariant);
354 int64_t DispVal = DispSpec.getImm();
355 if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
370 static bool printAsmMRegister(X86AsmPrinter &P, const MachineOperand &MO,
371 char Mode, raw_ostream &O) {
372 unsigned Reg = MO.getReg();
373 bool EmitPercent = true;
376 default: return true; // Unknown mode.
377 case 'b': // Print QImode register
378 Reg = getX86SubSuperRegister(Reg, 8);
380 case 'h': // Print QImode high register
381 Reg = getX86SubSuperRegister(Reg, 8, true);
383 case 'w': // Print HImode register
384 Reg = getX86SubSuperRegister(Reg, 16);
386 case 'k': // Print SImode register
387 Reg = getX86SubSuperRegister(Reg, 32);
393 // Print 64-bit register names if 64-bit integer registers are available.
394 // Otherwise, print 32-bit register names.
395 Reg = getX86SubSuperRegister(Reg, P.getSubtarget().is64Bit() ? 64 : 32);
402 O << X86ATTInstPrinter::getRegisterName(Reg);
406 /// PrintAsmOperand - Print out an operand for an inline asm expression.
408 bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
410 const char *ExtraCode, raw_ostream &O) {
411 // Does this asm operand have a single letter operand modifier?
412 if (ExtraCode && ExtraCode[0]) {
413 if (ExtraCode[1] != 0) return true; // Unknown modifier.
415 const MachineOperand &MO = MI->getOperand(OpNo);
417 switch (ExtraCode[0]) {
419 // See if this is a generic print operand
420 return AsmPrinter::PrintAsmOperand(MI, OpNo, AsmVariant, ExtraCode, O);
421 case 'a': // This is an address. Currently only 'i' and 'r' are expected.
422 switch (MO.getType()) {
425 case MachineOperand::MO_Immediate:
428 case MachineOperand::MO_ConstantPoolIndex:
429 case MachineOperand::MO_JumpTableIndex:
430 case MachineOperand::MO_ExternalSymbol:
431 llvm_unreachable("unexpected operand type!");
432 case MachineOperand::MO_GlobalAddress:
433 printSymbolOperand(*this, MO, O);
434 if (Subtarget->isPICStyleRIPRel())
437 case MachineOperand::MO_Register:
439 printOperand(*this, MI, OpNo, O);
444 case 'c': // Don't print "$" before a global var name or constant.
445 switch (MO.getType()) {
447 printOperand(*this, MI, OpNo, O);
449 case MachineOperand::MO_Immediate:
452 case MachineOperand::MO_ConstantPoolIndex:
453 case MachineOperand::MO_JumpTableIndex:
454 case MachineOperand::MO_ExternalSymbol:
455 llvm_unreachable("unexpected operand type!");
456 case MachineOperand::MO_GlobalAddress:
457 printSymbolOperand(*this, MO, O);
462 case 'A': // Print '*' before a register (it must be a register)
465 printOperand(*this, MI, OpNo, O);
470 case 'b': // Print QImode register
471 case 'h': // Print QImode high register
472 case 'w': // Print HImode register
473 case 'k': // Print SImode register
474 case 'q': // Print DImode register
475 case 'V': // Print native register without '%'
477 return printAsmMRegister(*this, MO, ExtraCode[0], O);
478 printOperand(*this, MI, OpNo, O);
481 case 'P': // This is the operand of a call, treat specially.
482 printPCRelImm(*this, MI, OpNo, O);
485 case 'n': // Negate the immediate or print a '-' before the operand.
486 // Note: this is a temporary solution. It should be handled target
487 // independently as part of the 'MC' work.
496 printOperand(*this, MI, OpNo, O, /*Modifier*/ nullptr, AsmVariant);
500 bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
501 unsigned OpNo, unsigned AsmVariant,
502 const char *ExtraCode,
505 printIntelMemReference(*this, MI, OpNo, O);
509 if (ExtraCode && ExtraCode[0]) {
510 if (ExtraCode[1] != 0) return true; // Unknown modifier.
512 switch (ExtraCode[0]) {
513 default: return true; // Unknown modifier.
514 case 'b': // Print QImode register
515 case 'h': // Print QImode high register
516 case 'w': // Print HImode register
517 case 'k': // Print SImode register
518 case 'q': // Print SImode register
519 // These only apply to registers, ignore on mem.
522 printMemReference(*this, MI, OpNo, O, "H");
524 case 'P': // Don't print @PLT, but do print as memory.
525 printMemReference(*this, MI, OpNo, O, "no-rip");
529 printMemReference(*this, MI, OpNo, O);
533 void X86AsmPrinter::EmitStartOfAsmFile(Module &M) {
534 const Triple &TT = TM.getTargetTriple();
536 if (TT.isOSBinFormatMachO())
537 OutStreamer->SwitchSection(getObjFileLowering().getTextSection());
539 if (TT.isOSBinFormatCOFF()) {
540 // Emit an absolute @feat.00 symbol. This appears to be some kind of
541 // compiler features bitfield read by link.exe.
542 if (TT.getArch() == Triple::x86) {
543 MCSymbol *S = MMI->getContext().getOrCreateSymbol(StringRef("@feat.00"));
544 OutStreamer->BeginCOFFSymbolDef(S);
545 OutStreamer->EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_STATIC);
546 OutStreamer->EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_NULL);
547 OutStreamer->EndCOFFSymbolDef();
548 // According to the PE-COFF spec, the LSB of this value marks the object
549 // for "registered SEH". This means that all SEH handler entry points
550 // must be registered in .sxdata. Use of any unregistered handlers will
551 // cause the process to terminate immediately. LLVM does not know how to
552 // register any SEH handlers, so its object files should be safe.
553 OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
554 OutStreamer->EmitAssignment(
555 S, MCConstantExpr::create(int64_t(1), MMI->getContext()));
558 OutStreamer->EmitSyntaxDirective();
560 // If this is not inline asm and we're in 16-bit
561 // mode prefix assembly with .code16.
562 bool is16 = TT.getEnvironment() == Triple::CODE16;
563 if (M.getModuleInlineAsm().empty() && is16)
564 OutStreamer->EmitAssemblerFlag(MCAF_Code16);
568 emitNonLazySymbolPointer(MCStreamer &OutStreamer, MCSymbol *StubLabel,
569 MachineModuleInfoImpl::StubValueTy &MCSym) {
571 OutStreamer.EmitLabel(StubLabel);
572 // .indirect_symbol _foo
573 OutStreamer.EmitSymbolAttribute(MCSym.getPointer(), MCSA_IndirectSymbol);
576 // External to current translation unit.
577 OutStreamer.EmitIntValue(0, 4/*size*/);
579 // Internal to current translation unit.
581 // When we place the LSDA into the TEXT section, the type info
582 // pointers need to be indirect and pc-rel. We accomplish this by
583 // using NLPs; however, sometimes the types are local to the file.
584 // We need to fill in the value for the NLP in those cases.
585 OutStreamer.EmitValue(
586 MCSymbolRefExpr::create(MCSym.getPointer(), OutStreamer.getContext()),
590 MCSymbol *X86AsmPrinter::GetCPISymbol(unsigned CPID) const {
591 if (Subtarget->isTargetKnownWindowsMSVC()) {
592 const MachineConstantPoolEntry &CPE =
593 MF->getConstantPool()->getConstants()[CPID];
594 if (!CPE.isMachineConstantPoolEntry()) {
595 const DataLayout &DL = MF->getDataLayout();
596 SectionKind Kind = CPE.getSectionKind(&DL);
597 const Constant *C = CPE.Val.ConstVal;
598 unsigned Align = CPE.Alignment;
599 if (const MCSectionCOFF *S = dyn_cast<MCSectionCOFF>(
600 getObjFileLowering().getSectionForConstant(DL, Kind, C, Align))) {
601 if (MCSymbol *Sym = S->getCOMDATSymbol()) {
602 if (Sym->isUndefined())
603 OutStreamer->EmitSymbolAttribute(Sym, MCSA_Global);
610 return AsmPrinter::GetCPISymbol(CPID);
613 void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
614 const Triple &TT = TM.getTargetTriple();
616 if (TT.isOSBinFormatMachO()) {
617 // All darwin targets use mach-o.
618 MachineModuleInfoMachO &MMIMacho =
619 MMI->getObjFileInfo<MachineModuleInfoMachO>();
621 // Output stubs for dynamically-linked functions.
622 MachineModuleInfoMachO::SymbolListTy Stubs;
624 // Output stubs for external and common global variables.
625 Stubs = MMIMacho.GetGVStubList();
626 if (!Stubs.empty()) {
627 MCSection *TheSection = OutContext.getMachOSection(
628 "__IMPORT", "__pointers", MachO::S_NON_LAZY_SYMBOL_POINTERS,
629 SectionKind::getMetadata());
630 OutStreamer->SwitchSection(TheSection);
632 for (auto &Stub : Stubs)
633 emitNonLazySymbolPointer(*OutStreamer, Stub.first, Stub.second);
636 OutStreamer->AddBlankLine();
639 SM.serializeToStackMapSection();
640 FM.serializeToFaultMapSection();
642 // Funny Darwin hack: This flag tells the linker that no global symbols
643 // contain code that falls through to other global symbols (e.g. the obvious
644 // implementation of multiple entry points). If this doesn't occur, the
645 // linker can safely perform dead code stripping. Since LLVM never
646 // generates code that does this, it is always safe to set.
647 OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
650 if (TT.isKnownWindowsMSVCEnvironment() && MMI->usesVAFloatArgument()) {
651 StringRef SymbolName =
652 (TT.getArch() == Triple::x86_64) ? "_fltused" : "__fltused";
653 MCSymbol *S = MMI->getContext().getOrCreateSymbol(SymbolName);
654 OutStreamer->EmitSymbolAttribute(S, MCSA_Global);
657 if (TT.isOSBinFormatCOFF()) {
658 const TargetLoweringObjectFileCOFF &TLOFCOFF =
659 static_cast<const TargetLoweringObjectFileCOFF&>(getObjFileLowering());
662 raw_string_ostream FlagsOS(Flags);
664 for (const auto &Function : M)
665 TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Function);
666 for (const auto &Global : M.globals())
667 TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Global);
668 for (const auto &Alias : M.aliases())
669 TLOFCOFF.emitLinkerFlagsForGlobal(FlagsOS, &Alias);
673 // Output collected flags.
674 if (!Flags.empty()) {
675 OutStreamer->SwitchSection(TLOFCOFF.getDrectveSection());
676 OutStreamer->EmitBytes(Flags);
679 SM.serializeToStackMapSection();
682 if (TT.isOSBinFormatELF()) {
683 SM.serializeToStackMapSection();
684 FM.serializeToFaultMapSection();
688 //===----------------------------------------------------------------------===//
689 // Target Registry Stuff
690 //===----------------------------------------------------------------------===//
692 // Force static initialization.
693 extern "C" void LLVMInitializeX86AsmPrinter() {
694 RegisterAsmPrinter<X86AsmPrinter> X(getTheX86_32Target());
695 RegisterAsmPrinter<X86AsmPrinter> Y(getTheX86_64Target());