LLVM: lib/CodeGen/CodeGenTargetMachineImpl.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

36using namespace llvm;

37

40 cl::desc("Enable generating trap for unreachable"));

41

44 cl::desc("Do not emit a trap instruction for 'unreachable' IR instructions "

45 "after noreturn calls, even if --trap-unreachable is set."));

46

49 assert(MRI && "Unable to create reg info");

51 assert(MII && "Unable to create instruction info");

52

53

54

55

58 assert(STI && "Unable to create subtarget info");

59

62

63

64

65

66 assert(TmpAsmInfo && "MCAsmInfo not initialized. "

67 "Make sure you include the correct TargetSelect.h"

68 "and that InitializeAllTargetMCs() is being invoked!");

69

70 if (Options.BinutilsVersion.first > 0)

72

73 if (Options.DisableIntegratedAS) {

75

76

78 }

79

81

83

86 "MCAsmInfo and Triple disagree on default exception handling type");

87

90

91 AsmInfo.reset(TmpAsmInfo);

92}

93

99 this->RM = RM;

102

107}

108

113

114

117 bool DisableVerify,

119

120

122

124 PM.add(PassConfig);

125 PM.add(&MMIWP);

127

129 return nullptr;

132 return PassConfig;

133}

134

142 if (!MCStreamerOrErr) {

144 return true;

145 }

146

147

151 return true;

152

154 return false;

155}

156

166

167 std::unique_ptr AsmStreamer;

168

169 switch (FileType) {

176 if (!InstPrinter->applyTargetSpecificCLOption(Opt))

177 return createStringError("invalid InstPrinter option '" + Opt + "'");

178

179

180 std::unique_ptr MCE;

181 if (Options.MCOptions.ShowMCEncoding)

182 MCE.reset(getTarget().createMCCodeEmitter(MII, Context));

183

184 std::unique_ptr MAB(

186 auto FOut = std::make_unique<formatted_raw_ostream>(Out);

188 Context, std::move(FOut), std::move(InstPrinter), std::move(MCE),

189 std::move(MAB));

190 AsmStreamer.reset(S);

191 break;

192 }

194

195

197 if (!MCE)

202 if (!MAB)

205

207 AsmStreamer.reset(getTarget().createMCObjectStreamer(

208 T, Context, std::unique_ptr(MAB),

211 std::unique_ptr(MCE), STI));

212 break;

213 }

215

216

218 break;

219 }

220

221 return std::move(AsmStreamer);

222}

223

228

229 if (!MMIWP)

233 if (!PassConfig)

234 return true;

235

238 return true;

239 } else {

240

243 }

244

246 return false;

247}

248

249

250

251

252

253

257 bool DisableVerify) {

258

262 if (!PassConfig)

263 return true;

265 "Cannot emit MC with limited codegen pipeline");

266

268

269

271

272

273

276 std::unique_ptr MCE(

278 if (!MCE)

279 return true;

282 if (!MAB)

283 return true;

284

286 std::unique_ptr AsmStreamer(getTarget().createMCObjectStreamer(

287 T, *Ctx, std::unique_ptr(MAB), MAB->createObjectWriter(Out),

288 std::move(MCE), STI));

289

290

294 return true;

295

298

299 return false;

300}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file provides a helper that implements much of the TTI interface in terms of the target-independ...

static TargetPassConfig * addPassesToGenerateCode(CodeGenTargetMachineImpl &TM, PassManagerBase &PM, bool DisableVerify, MachineModuleInfoWrapperPass &MMIWP)

addPassesToX helper drives creation and initialization of TargetPassConfig.

Definition CodeGenTargetMachineImpl.cpp:116

static cl::opt< bool > EnableTrapUnreachable("trap-unreachable", cl::Hidden, cl::desc("Enable generating trap for unreachable"))

static cl::opt< bool > EnableNoTrapAfterNoreturn("no-trap-after-noreturn", cl::Hidden, cl::desc("Do not emit a trap instruction for 'unreachable' IR instructions " "after noreturn calls, even if --trap-unreachable is set."))

dxil pretty DXIL Metadata Pretty Printer

Target-Independent Code Generator Pass Configuration Options pass.

static MCInstPrinter * createMCInstPrinter(const Triple &, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)

implements a set of functionality in the TargetMachine class for targets that make use of the indepen...

Expected< std::unique_ptr< MCStreamer > > createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext &Ctx) override

Definition CodeGenTargetMachineImpl.cpp:158

bool addPassesToEmitFile(PassManagerBase &PM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, bool DisableVerify=true, MachineModuleInfoWrapperPass *MMIWP=nullptr) override

Add passes to the specified pass manager to get the specified file emitted.

Definition CodeGenTargetMachineImpl.cpp:224

CodeGenTargetMachineImpl(const Target &T, StringRef DataLayoutString, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)

Definition CodeGenTargetMachineImpl.cpp:94

bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx, raw_pwrite_stream &Out, bool DisableVerify=true) override

Add passes to the specified pass manager to get machine code emitted with the MCJIT.

Definition CodeGenTargetMachineImpl.cpp:254

TargetTransformInfo getTargetTransformInfo(const Function &F) const override

Get a TargetTransformInfo implementation for the target.

Definition CodeGenTargetMachineImpl.cpp:110

void initAsmInfo()

Definition CodeGenTargetMachineImpl.cpp:47

bool addAsmPrinter(PassManagerBase &PM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext &Context) override

Adds an AsmPrinter pass to the pipeline that prints assembly or machine code from the MI representati...

Definition CodeGenTargetMachineImpl.cpp:135

TargetPassConfig * createPassConfig(PassManagerBase &PM) override

Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...

Tagged union holding either a T or a Error.

Error takeError()

Take ownership of the stored error.

FunctionPass class - This class is used to implement most global optimizations.

Generic interface to target specific assembler backends.

std::unique_ptr< MCObjectWriter > createObjectWriter(raw_pwrite_stream &OS) const

Create a new MCObjectWriter instance for use by the assembler backend to emit the final object file.

std::unique_ptr< MCObjectWriter > createDwoObjectWriter(raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS) const

Create an MCObjectWriter that writes two object files: a .o file which is linked into the final progr...

This class is intended to be used as a base class for asm properties and features specific to the tar...

unsigned getAssemblerDialect() const

virtual void setUseIntegratedAssembler(bool Value)

Set whether assembly (inline or otherwise) should be parsed.

virtual void setPreserveAsmComments(bool Value)

Set whether assembly (inline or otherwise) should be parsed.

virtual void setParseInlineAsmUsingAsmParser(bool Value)

Set whether target want to use AsmParser to parse inlineasm.

void setFullRegisterNames(bool V)

void setBinutilsVersion(std::pair< int, int > Value)

void setExceptionsType(ExceptionHandling EH)

ExceptionHandling getExceptionHandlingType() const

MCCodeEmitter - Generic instruction encoding interface.

Context object for machine code objects.

Interface to description of machine instruction set.

MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...

Streaming machine code generation interface.

virtual void reset()

State management.

Generic base class for all target subtargets.

MachineModuleInfo & getMMI()

const MCContext & getContext() const

Represents a location in source code.

StringRef - Represent a constant reference to a string, i.e.

std::unique_ptr< const MCAsmInfo > AsmInfo

Contains target specific asm information.

const Triple & getTargetTriple() const

const MCSubtargetInfo * getMCSubtargetInfo() const

std::unique_ptr< const MCInstrInfo > MII

StringRef getTargetFeatureString() const

StringRef getTargetCPU() const

const MCInstrInfo * getMCInstrInfo() const

std::unique_ptr< const MCSubtargetInfo > STI

const Target & getTarget() const

const Target & TheTarget

The Target that this machine was created for.

const MCRegisterInfo * getMCRegisterInfo() const

TargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TargetTriple, StringRef CPU, StringRef FS, const TargetOptions &Options)

std::unique_ptr< const MCRegisterInfo > MRI

const MCAsmInfo * getMCAsmInfo() const

Return target specific asm information.

unsigned NoTrapAfterNoreturn

Do not emit a trap instruction for 'unreachable' IR instructions behind noreturn calls,...

unsigned TrapUnreachable

Emit target-specific trap instruction for 'unreachable' IR instructions.

Target-Independent Code Generator Pass Configuration Options.

virtual void addMachinePasses()

Add the complete, standard set of LLVM CodeGen passes.

void setDisableVerify(bool Disable)

static bool willCompleteCodeGenPipeline()

Returns true if none of the -stop-before and -stop-after options is set.

bool addISelPasses()

High level function that adds all passes necessary to go from llvm IR representation to the MI repres...

This pass provides access to the codegen interfaces that are needed for IR-level transformations.

Target - Wrapper for Target specific information.

MCCodeEmitter * createMCCodeEmitter(const MCInstrInfo &II, MCContext &Ctx) const

createMCCodeEmitter - Create a target specific code emitter.

MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const

createMCAsmBackend - Create a target specific assembly parser.

LLVM_ABI MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, std::unique_ptr< MCInstPrinter > IP, std::unique_ptr< MCCodeEmitter > CE, std::unique_ptr< MCAsmBackend > TAB) const

AsmPrinter * createAsmPrinter(TargetMachine &TM, std::unique_ptr< MCStreamer > &&Streamer) const

createAsmPrinter - Create a target specific assembly printer pass.

Triple - Helper class for working with autoconf configuration names.

PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...

virtual void add(Pass *P)=0

Add a pass to the queue of passes to run.

An abstract base class for streams implementations that also support a pwrite operation.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI MachineFunctionPass * createPrintMIRPass(raw_ostream &OS)

MIRPrinting pass - this pass prints out the LLVM IR into the given stream using the MIR serialization...

LLVM_ABI std::error_code inconvertibleErrorCode()

The value returned by this function can be returned from convertToErrorCode for Error values where no...

@ None

No exception support.

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

LLVM_ABI MCStreamer * createNullStreamer(MCContext &Ctx)

Create a dummy machine code streamer, which does nothing.

CodeGenFileType

These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...

CodeGenOptLevel

Code generation optimization level.

Error make_error(ArgTs &&... Args)

Make a Error instance representing failure using the given error info type.

LLVM_ABI void invokeGlobalTargetPassConfigCallbacks(TargetMachine &TM, PassManagerBase &PM, TargetPassConfig *PassConfig)

std::string toString(const APInt &I, unsigned Radix, bool Signed, bool formatAsCLiteral=false, bool UpperCase=true, bool InsertSeparators=false)

LLVM_ABI FunctionPass * createFreeMachineFunctionPass()

This pass frees the memory occupied by the MachineFunction.