LLVM: lib/CodeGen/CodeGenTargetMachineImpl.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
34using namespace llvm;
35
38 cl::desc("Enable generating trap for unreachable"));
39
42 cl::desc("Do not emit a trap instruction for 'unreachable' IR instructions "
43 "after noreturn calls, even if --trap-unreachable is set."));
44
47 assert(MRI && "Unable to create reg info");
49 assert(MII && "Unable to create instruction info");
50
51
52
53
56 assert(STI && "Unable to create subtarget info");
57
60
61
62
63
64 assert(TmpAsmInfo && "MCAsmInfo not initialized. "
65 "Make sure you include the correct TargetSelect.h"
66 "and that InitializeAllTargetMCs() is being invoked!");
67
70
73
74
76 }
77
79
81
84
85 AsmInfo.reset(TmpAsmInfo);
86}
87
93 this->RM = RM;
96
101}
102
106}
107
108
111 bool DisableVerify,
113
114
116
118 PM.add(PassConfig);
119 PM.add(&MMIWP);
120
122 return nullptr;
125 return PassConfig;
126}
127
135 if (auto Err = MCStreamerOrErr.takeError())
136 return true;
137
138
142 return true;
143
145 return false;
146}
147
157
158 std::unique_ptr AsmStreamer;
159
160 switch (FileType) {
166
167
168 std::unique_ptr MCE;
170 MCE.reset(getTarget().createMCCodeEmitter(MII, Context));
171
172 std::unique_ptr MAB(
174 auto FOut = std::make_unique<formatted_raw_ostream>(Out);
176 Context, std::move(FOut), InstPrinter, std::move(MCE), std::move(MAB));
177 AsmStreamer.reset(S);
178 break;
179 }
181
182
184 if (!MCE)
185 return make_error("createMCCodeEmitter failed",
189 if (!MAB)
190 return make_error("createMCAsmBackend failed",
192
194 AsmStreamer.reset(getTarget().createMCObjectStreamer(
195 T, Context, std::unique_ptr(MAB),
198 std::unique_ptr(MCE), STI));
199 break;
200 }
202
203
205 break;
206 }
207
208 return std::move(AsmStreamer);
209}
210
215
216 if (!MMIWP)
220 if (!PassConfig)
221 return true;
222
225 return true;
226 } else {
227
230 }
231
233 return false;
234}
235
236
237
238
239
240
244 bool DisableVerify) {
245
249 if (!PassConfig)
250 return true;
252 "Cannot emit MC with limited codegen pipeline");
253
255
256
258
259
260
263 std::unique_ptr MCE(
265 if (!MCE)
266 return true;
269 if (!MAB)
270 return true;
271
273 std::unique_ptr AsmStreamer(getTarget().createMCObjectStreamer(
274 T, *Ctx, std::unique_ptr(MAB), MAB->createObjectWriter(Out),
275 std::move(MCE), STI));
276
277
281 return true;
282
285
286 return false;
287}
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.
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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Target-Independent Code Generator Pass Configuration Options pass.
Concrete BasicTTIImpl that can be used if no further customization is needed.
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
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.
CodeGenTargetMachineImpl(const Target &T, StringRef DataLayoutString, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
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.
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
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...
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)
MCCodeEmitter - Generic instruction encoding interface.
Context object for machine code objects.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
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.
bool PreserveAsmComments
Preserve Comments in Assembly.
EmitDwarfUnwindType EmitDwarfUnwind
bool PPCUseFullRegisterNames
std::optional< unsigned > OutputAsmVariant
MachineModuleInfo & getMMI()
const MCContext & getContext() const
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
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
std::unique_ptr< const MCRegisterInfo > MRI
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
MCTargetOptions MCOptions
Machine level options.
std::pair< int, int > BinutilsVersion
If greater than 0, override the default value of MCAsmInfo::BinutilsVersion.
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.
unsigned DisableIntegratedAS
Disable the integrated assembler.
ExceptionHandling ExceptionModel
What exception model to use.
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.
MCSubtargetInfo * createMCSubtargetInfo(StringRef TheTriple, StringRef CPU, StringRef Features) const
createMCSubtargetInfo - Create a MCSubtargetInfo implementation.
MCAsmBackend * createMCAsmBackend(const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options) const
createMCAsmBackend - Create a target specific assembly parser.
MCRegisterInfo * createMCRegInfo(StringRef TT) const
createMCRegInfo - Create a MCRegisterInfo implementation.
MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &MRI, StringRef TheTriple, const MCTargetOptions &Options) const
createMCAsmInfo - Create a MCAsmInfo implementation for the specified target triple.
MCInstPrinter * createMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI) const
MCStreamer * createAsmStreamer(MCContext &Ctx, std::unique_ptr< formatted_raw_ostream > OS, 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.
MCInstrInfo * createMCInstrInfo() const
createMCInstrInfo - Create a MCInstrInfo implementation.
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.
MachineFunctionPass * createPrintMIRPass(raw_ostream &OS)
MIRPrinting pass - this pass prints out the LLVM IR into the given stream using the MIR serialization...
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
@ None
No exception support.
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.
FunctionPass * createFreeMachineFunctionPass()
This pass frees the memory occupied by the MachineFunction.