LLVM: lib/Target/X86/X86AsmPrinter.h Source File (original) (raw)

28public:

29 static char ID;

30

31private:

34 std::unique_ptr CodeEmitter;

35 bool EmitFPOData = false;

36 bool ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags = false;

37 bool IndCSPrefix = false;

38 bool EnableImportCallOptimization = false;

39

40 enum ImportCallKind : unsigned {

41 IMAGE_RETPOLINE_AMD64_IMPORT_BR = 0x02,

42 IMAGE_RETPOLINE_AMD64_IMPORT_CALL = 0x03,

43 IMAGE_RETPOLINE_AMD64_INDIR_BR = 0x04,

44 IMAGE_RETPOLINE_AMD64_INDIR_CALL = 0x05,

45 IMAGE_RETPOLINE_AMD64_INDIR_BR_REX = 0x06,

46 IMAGE_RETPOLINE_AMD64_CFG_BR = 0x08,

47 IMAGE_RETPOLINE_AMD64_CFG_CALL = 0x09,

48 IMAGE_RETPOLINE_AMD64_CFG_BR_REX = 0x0A,

49 IMAGE_RETPOLINE_AMD64_SWITCHTABLE_FIRST = 0x010,

50 IMAGE_RETPOLINE_AMD64_SWITCHTABLE_LAST = 0x01F,

51 };

52 struct ImportCallInfo {

54 ImportCallKind Kind;

55 };

56 DenseMap<MCSection *, std::vector>

57 SectionToImportedFunctionCalls;

58

59

60

61

62

63

64

65

66

67 class StackMapShadowTracker {

68 public:

69 void startFunction(MachineFunction &MF) {

70 this->MF = &MF;

71 }

72 void count(const MCInst &Inst, const MCSubtargetInfo &STI,

73 MCCodeEmitter *CodeEmitter);

74

75

76 void reset(unsigned RequiredSize) {

77 RequiredShadowSize = RequiredSize;

78 CurrentShadowSize = 0;

79 InShadow = true;

80 }

81

82

83

84 void emitShadowPadding(MCStreamer &OutStreamer, const MCSubtargetInfo &STI);

85 private:

86 const MachineFunction *MF = nullptr;

87 bool InShadow = false;

88

89

90

91

92

93

94 unsigned RequiredShadowSize = 0, CurrentShadowSize = 0;

95 };

96

97 StackMapShadowTracker SMShadowTracker;

98

99

100

101

102

103

104

105 void EmitAndCountInstruction(MCInst &Inst);

106 void LowerSTACKMAP(const MachineInstr &MI);

107 void LowerPATCHPOINT(const MachineInstr &MI, X86MCInstLower &MCIL);

108 void LowerSTATEPOINT(const MachineInstr &MI, X86MCInstLower &MCIL);

109 void LowerFAULTING_OP(const MachineInstr &MI, X86MCInstLower &MCIL);

110 void LowerPATCHABLE_OP(const MachineInstr &MI, X86MCInstLower &MCIL);

111

112 void LowerTlsAddr(X86MCInstLower &MCInstLowering, const MachineInstr &MI);

113

114

115 void LowerPATCHABLE_FUNCTION_ENTER(const MachineInstr &MI,

116 X86MCInstLower &MCIL);

117 void LowerPATCHABLE_RET(const MachineInstr &MI, X86MCInstLower &MCIL);

118 void LowerPATCHABLE_TAIL_CALL(const MachineInstr &MI, X86MCInstLower &MCIL);

119 void LowerPATCHABLE_EVENT_CALL(const MachineInstr &MI, X86MCInstLower &MCIL);

120 void LowerPATCHABLE_TYPED_EVENT_CALL(const MachineInstr &MI,

121 X86MCInstLower &MCIL);

122

123 void LowerFENTRY_CALL(const MachineInstr &MI, X86MCInstLower &MCIL);

124

125

126 uint32_t MaskKCFIType(uint32_t Value);

127 void EmitKCFITypePadding(const MachineFunction &MF, bool HasType = true);

128 void LowerKCFI_CHECK(const MachineInstr &MI);

129

130

131 void LowerASAN_CHECK_MEMACCESS(const MachineInstr &MI);

132

133

134 void EmitSEHInstruction(const MachineInstr *MI);

135

136 void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &O) override;

137 void PrintOperand(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);

138 void PrintModifiedOperand(const MachineInstr *MI, unsigned OpNo,

139 raw_ostream &O, StringRef Modifier = {});

140 void PrintPCRelImm(const MachineInstr *MI, unsigned OpNo, raw_ostream &O);

141 void PrintLeaMemReference(const MachineInstr *MI, unsigned OpNo,

142 raw_ostream &O, StringRef Modifier = {});

143 void PrintMemReference(const MachineInstr *MI, unsigned OpNo, raw_ostream &O,

144 StringRef Modifier = {});

145 void PrintIntelMemReference(const MachineInstr *MI, unsigned OpNo,

146 raw_ostream &O, StringRef Modifier = {});

147 const MCSubtargetInfo *getIFuncMCSubtargetInfo() const override;

148 void emitMachOIFuncStubBody(Module &M, const GlobalIFunc &GI,

149 MCSymbol *LazyPointer) override;

150 void emitMachOIFuncStubHelperBody(Module &M, const GlobalIFunc &GI,

151 MCSymbol *LazyPointer) override;

152

153 void emitCallInstruction(const llvm::MCInst &MCI);

154 void maybeEmitNopAfterCallForWindowsEH(const MachineInstr *MI);

155

156

157

158 void emitLabelAndRecordForImportCallOptimization(ImportCallKind Kind);

159

160public:

161 X86AsmPrinter(TargetMachine &TM, std::unique_ptr Streamer);

162

164 return "X86 Assembly Printer";

165 }

166

168

169 void emitStartOfAsmFile(Module &M) override;

170

171 void emitEndOfAsmFile(Module &M) override;

172

173 void emitInstruction(const MachineInstr *MI) override;

174

176

177 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,

178 const char *ExtraCode, raw_ostream &O) override;

179 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,

180 const char *ExtraCode, raw_ostream &O) override;

181

183 SMShadowTracker.reset(0);

184 SM.reset();

185 FM.reset();

187 }

188

190 void emitFunctionBodyStart() override;

191 void emitFunctionBodyEnd() override;

193

195 return ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags;

196 }

197};