34 std::unique_ptr<MCCodeEmitter> CodeEmitter;
35 bool EmitFPOData =
false;
36 bool ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags =
false;
37 bool IndCSPrefix =
false;
38 bool EnableImportCallOptimization =
false;
39 bool SplitChainedAtEndOfBlock =
false;
41 enum ImportCallKind :
unsigned {
42 IMAGE_RETPOLINE_AMD64_IMPORT_BR = 0x02,
43 IMAGE_RETPOLINE_AMD64_IMPORT_CALL = 0x03,
44 IMAGE_RETPOLINE_AMD64_INDIR_BR = 0x04,
45 IMAGE_RETPOLINE_AMD64_INDIR_CALL = 0x05,
46 IMAGE_RETPOLINE_AMD64_INDIR_BR_REX = 0x06,
47 IMAGE_RETPOLINE_AMD64_CFG_BR = 0x08,
48 IMAGE_RETPOLINE_AMD64_CFG_CALL = 0x09,
49 IMAGE_RETPOLINE_AMD64_CFG_BR_REX = 0x0A,
50 IMAGE_RETPOLINE_AMD64_SWITCHTABLE_FIRST = 0x010,
51 IMAGE_RETPOLINE_AMD64_SWITCHTABLE_LAST = 0x01F,
53 struct ImportCallInfo {
57 DenseMap<MCSection *, std::vector<ImportCallInfo>>
58 SectionToImportedFunctionCalls;
68 class StackMapShadowTracker {
70 void startFunction(MachineFunction &MF) {
73 void count(
const MCInst &Inst,
const MCSubtargetInfo &STI,
74 MCCodeEmitter *CodeEmitter);
77 void reset(
unsigned RequiredSize) {
78 RequiredShadowSize = RequiredSize;
79 CurrentShadowSize = 0;
85 void emitShadowPadding(MCStreamer &OutStreamer,
const MCSubtargetInfo &STI);
87 const MachineFunction *MF =
nullptr;
88 bool InShadow =
false;
95 unsigned RequiredShadowSize = 0, CurrentShadowSize = 0;
98 StackMapShadowTracker SMShadowTracker;
106 void EmitAndCountInstruction(MCInst &Inst);
107 void LowerSTACKMAP(
const MachineInstr &
MI);
108 void LowerPATCHPOINT(
const MachineInstr &
MI, X86MCInstLower &MCIL);
109 void LowerSTATEPOINT(
const MachineInstr &
MI, X86MCInstLower &MCIL);
110 void LowerFAULTING_OP(
const MachineInstr &
MI, X86MCInstLower &MCIL);
111 void LowerPATCHABLE_OP(
const MachineInstr &
MI, X86MCInstLower &MCIL);
113 void LowerTlsAddr(X86MCInstLower &MCInstLowering,
const MachineInstr &
MI);
116 void LowerPATCHABLE_FUNCTION_ENTER(
const MachineInstr &
MI,
117 X86MCInstLower &MCIL);
118 void LowerPATCHABLE_RET(
const MachineInstr &
MI, X86MCInstLower &MCIL);
119 void LowerPATCHABLE_TAIL_CALL(
const MachineInstr &
MI, X86MCInstLower &MCIL);
120 void LowerPATCHABLE_EVENT_CALL(
const MachineInstr &
MI, X86MCInstLower &MCIL);
121 void LowerPATCHABLE_TYPED_EVENT_CALL(
const MachineInstr &
MI,
122 X86MCInstLower &MCIL);
124 void LowerFENTRY_CALL(
const MachineInstr &
MI, X86MCInstLower &MCIL);
127 uint32_t MaskKCFIType(uint32_t
Value);
128 void EmitKCFITypePadding(
const MachineFunction &MF,
bool HasType =
true);
129 void LowerKCFI_CHECK(
const MachineInstr &
MI);
132 void LowerASAN_CHECK_MEMACCESS(
const MachineInstr &
MI);
135 void EmitSEHInstruction(
const MachineInstr *
MI);
137 void PrintSymbolOperand(
const MachineOperand &MO, raw_ostream &O)
override;
138 void PrintOperand(
const MachineInstr *
MI,
unsigned OpNo, raw_ostream &O);
139 void PrintModifiedOperand(
const MachineInstr *
MI,
unsigned OpNo,
140 raw_ostream &O, StringRef Modifier = {});
141 void PrintPCRelImm(
const MachineInstr *
MI,
unsigned OpNo, raw_ostream &O);
142 void PrintLeaMemReference(
const MachineInstr *
MI,
unsigned OpNo,
143 raw_ostream &O, StringRef Modifier = {});
144 void PrintMemReference(
const MachineInstr *
MI,
unsigned OpNo, raw_ostream &O,
145 StringRef Modifier = {});
146 void PrintIntelMemReference(
const MachineInstr *
MI,
unsigned OpNo,
147 raw_ostream &O, StringRef Modifier = {});
148 const MCSubtargetInfo *getIFuncMCSubtargetInfo()
const override;
149 void emitMachOIFuncStubBody(
Module &M,
const GlobalIFunc &GI,
150 MCSymbol *LazyPointer)
override;
151 void emitMachOIFuncStubHelperBody(
Module &M,
const GlobalIFunc &GI,
152 MCSymbol *LazyPointer)
override;
154 void emitCallInstruction(
const llvm::MCInst &MCI);
155 void maybeEmitNopAfterCallForWindowsEH(
const MachineInstr *
MI);
159 void emitLabelAndRecordForImportCallOptimization(ImportCallKind Kind);
162 X86AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer);
165 return "X86 Assembly Printer";
170 void emitStartOfAsmFile(
Module &M)
override;
172 void emitEndOfAsmFile(
Module &M)
override;
188 SMShadowTracker.reset(0);
195 void emitFunctionBodyStart()
override;
196 void emitFunctionBodyEnd()
override;
200 return ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags;