LLVM 24.0.0git
RISCVTargetMachine.cpp
Go to the documentation of this file.
1//===-- RISCVTargetMachine.cpp - Define TargetMachine for RISC-V ----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Implements the info about RISC-V target spec.
10//
11//===----------------------------------------------------------------------===//
12
13#include "RISCVTargetMachine.h"
14#include "RISCV.h"
30#include "llvm/CodeGen/Passes.h"
39#include "llvm/Transforms/IPO.h"
41#include <optional>
42using namespace llvm;
43
85}
86
88 std::optional<Reloc::Model> RM) {
89 if (TT.isOSBinFormatMachO())
90 return RM.value_or(Reloc::PIC_);
91
92 return RM.value_or(Reloc::Static);
93}
94
95static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
96 if (TT.isOSBinFormatMachO())
97 return std::make_unique<RISCVMachOTargetObjectFile>();
98 return std::make_unique<RISCVELFTargetObjectFile>();
99}
100
102 StringRef CPU, StringRef FS,
103 const TargetOptions &Options,
104 std::optional<Reloc::Model> RM,
105 std::optional<CodeModel::Model> CM,
106 CodeGenOptLevel OL, bool JIT)
107 : CodeGenTargetMachineImpl(T, TT, CPU, FS, Options,
109 getEffectiveCodeModel(CM, CodeModel::Small), OL),
110 CLOpts(cl::LibraryOptionsContext::get<RISCVOptions>(
111 Options.MCOptions.LibraryOptions)),
112 TLOF(createTLOF(TT)) {
113 initAsmInfo();
114
115 // RISC-V supports the MachineOutliner.
116 setMachineOutliner(true);
118
119 // RISC-V supports the debug entry values.
121
122 if (TT.isOSFuchsia() && !TT.isArch64Bit())
123 report_fatal_error("Fuchsia is only supported for 64-bit");
124
125 setCFIFixup(!CLOpts.enable_cfi_instr_inserter);
126}
127
128const RISCVSubtarget *
130 // Avoid rebuilding the subtarget key for repeated queries with the same
131 // function attributes.
132 AttributeSet FnAttrs = F.getAttributes().getFnAttrs();
133 if (LastSubtarget.first && LastSubtarget.second == FnAttrs)
134 return LastSubtarget.first;
135
136 Attribute CPUAttr = F.getFnAttribute("target-cpu");
137 Attribute TuneAttr = F.getFnAttribute("tune-cpu");
138 Attribute FSAttr = F.getFnAttribute("target-features");
139
140 StringRef CPU = CPUAttr.isValid() ? CPUAttr.getValueAsString() : TargetCPU;
141 StringRef TuneCPU = TuneAttr.isValid() ? TuneAttr.getValueAsString() : CPU;
142 StringRef FS = FSAttr.isValid() ? FSAttr.getValueAsString() : TargetFS;
143
144 unsigned RVVBitsMin = CLOpts.v_vector_bits_min.value_or(-1);
145 unsigned RVVBitsMax = CLOpts.v_vector_bits_max.value_or(0);
146
147 Attribute VScaleRangeAttr = F.getFnAttribute(Attribute::VScaleRange);
148 if (VScaleRangeAttr.isValid()) {
149 if (!CLOpts.v_vector_bits_min)
150 RVVBitsMin = VScaleRangeAttr.getVScaleRangeMin() * RISCV::RVVBitsPerBlock;
151 std::optional<unsigned> VScaleMax = VScaleRangeAttr.getVScaleRangeMax();
152 if (VScaleMax.has_value() && !CLOpts.v_vector_bits_max)
153 RVVBitsMax = *VScaleMax * RISCV::RVVBitsPerBlock;
154 }
155
156 if (RVVBitsMin != -1U) {
157 // FIXME: Change to >= 32 when VLEN = 32 is supported.
158 assert((RVVBitsMin == 0 || (RVVBitsMin >= 64 && RVVBitsMin <= 65536 &&
159 isPowerOf2_32(RVVBitsMin))) &&
160 "V or Zve* extension requires vector length to be in the range of "
161 "64 to 65536 and a power 2!");
162 assert((RVVBitsMax >= RVVBitsMin || RVVBitsMax == 0) &&
163 "Minimum V extension vector length should not be larger than its "
164 "maximum!");
165 }
166 assert((RVVBitsMax == 0 || (RVVBitsMax >= 64 && RVVBitsMax <= 65536 &&
167 isPowerOf2_32(RVVBitsMax))) &&
168 "V or Zve* extension requires vector length to be in the range of "
169 "64 to 65536 and a power 2!");
170
171 if (RVVBitsMin != -1U) {
172 if (RVVBitsMax != 0) {
173 RVVBitsMin = std::min(RVVBitsMin, RVVBitsMax);
174 RVVBitsMax = std::max(RVVBitsMin, RVVBitsMax);
175 }
176
177 RVVBitsMin = llvm::bit_floor(
178 (RVVBitsMin < 64 || RVVBitsMin > 65536) ? 0 : RVVBitsMin);
179 }
180 RVVBitsMax =
181 llvm::bit_floor((RVVBitsMax < 64 || RVVBitsMax > 65536) ? 0 : RVVBitsMax);
182
184 raw_svector_ostream(Key) << "RVVMin" << RVVBitsMin << "RVVMax" << RVVBitsMax
185 << CPU << TuneCPU << FS;
186 auto &I = SubtargetMap[Key];
187 if (!I) {
188 StringRef ABIName = getTargetABIName(*F.getParent());
189 I = std::make_unique<RISCVSubtarget>(
190 TargetTriple, CPU, TuneCPU, FS, ABIName, RVVBitsMin, RVVBitsMax, *this);
191 }
192 LastSubtarget = {I.get(), FnAttrs};
193 return LastSubtarget.first;
194}
195
202
205 return TargetTransformInfo(std::make_unique<RISCVTTIImpl>(this, F));
206}
207
208// A RISC-V hart has a single byte-addressable address space of 2^XLEN bytes
209// for all memory accesses, so it is reasonable to assume that an
210// implementation has no-op address space casts. If an implementation makes a
211// change to this, they can override it here.
213 unsigned SrcAS,
214 unsigned DstAS) const {
215 return true;
216}
217
220 const RISCVSubtarget &ST = C->MF->getSubtarget<RISCVSubtarget>();
222
223 // Add MacroFusion mutation first with a higher priority than later clustering
224 const auto &MacroFusions = ST.getMacroFusions();
225 if (!MacroFusions.empty())
226 DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
227
228 if (ST.enableMISchedLoadClustering())
229 DAG->addMutation(createLoadClusterDAGMutation(
230 DAG->TII, /*ReorderWhileClustering=*/true));
231
232 if (ST.enableMISchedStoreClustering())
233 DAG->addMutation(createStoreClusterDAGMutation(
234 DAG->TII, /*ReorderWhileClustering=*/true));
235
236 if (CLOpts.vector_mask_mutation && ST.hasVInstructions())
237 DAG->addMutation(createRISCVVectorMaskDAGMutation(DAG->TRI));
238
239 return DAG;
240}
241
244 const RISCVSubtarget &ST = C->MF->getSubtarget<RISCVSubtarget>();
246
247 // Add MacroFusion mutation first with a higher priority than later clustering
248 const auto &MacroFusions = ST.getMacroFusions();
249 if (!MacroFusions.empty())
250 DAG->addMutation(createMacroFusionDAGMutation(MacroFusions));
251
252 if (ST.enablePostMISchedLoadClustering())
253 DAG->addMutation(createLoadClusterDAGMutation(
254 DAG->TII, /*ReorderWhileClustering=*/true));
255
256 if (ST.enablePostMISchedStoreClustering())
257 DAG->addMutation(createStoreClusterDAGMutation(
258 DAG->TII, /*ReorderWhileClustering=*/true));
259
260 return DAG;
261}
262
263namespace {
264
265class RVVRegisterRegAlloc : public RegisterRegAllocBase<RVVRegisterRegAlloc> {
266public:
267 RVVRegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
268 : RegisterRegAllocBase(N, D, C) {}
269};
270
271static bool onlyAllocateRVVReg(const TargetRegisterInfo &TRI,
273 const Register Reg) {
276}
277
278static FunctionPass *useDefaultRegisterAllocator() { return nullptr; }
279
280static llvm::once_flag InitializeDefaultRVVRegisterAllocatorFlag;
281
282/// -riscv-rvv-regalloc=<fast|basic|greedy> command line option.
283/// This option could designate the rvv register allocator only.
284/// For example: -riscv-rvv-regalloc=basic
285static cl::opt<RVVRegisterRegAlloc::FunctionPassCtor, false,
287 RVVRegAlloc("riscv-rvv-regalloc", cl::Hidden,
289 cl::desc("Register allocator to use for RVV register."));
290
291static void initializeDefaultRVVRegisterAllocatorOnce() {
292 RegisterRegAlloc::FunctionPassCtor Ctor = RVVRegisterRegAlloc::getDefault();
293
294 if (!Ctor) {
295 Ctor = RVVRegAlloc;
296 RVVRegisterRegAlloc::setDefault(RVVRegAlloc);
297 }
298}
299
300static FunctionPass *createBasicRVVRegisterAllocator() {
301 return createBasicRegisterAllocator(onlyAllocateRVVReg);
302}
303
304static FunctionPass *createGreedyRVVRegisterAllocator() {
305 return createGreedyRegisterAllocator(onlyAllocateRVVReg);
306}
307
308static FunctionPass *createFastRVVRegisterAllocator() {
309 return createFastRegisterAllocator(onlyAllocateRVVReg, false);
310}
311
312static RVVRegisterRegAlloc basicRegAllocRVVReg("basic",
313 "basic register allocator",
314 createBasicRVVRegisterAllocator);
315static RVVRegisterRegAlloc
316 greedyRegAllocRVVReg("greedy", "greedy register allocator",
317 createGreedyRVVRegisterAllocator);
318
319static RVVRegisterRegAlloc fastRegAllocRVVReg("fast", "fast register allocator",
320 createFastRVVRegisterAllocator);
321
322class RISCVPassConfig : public TargetPassConfig {
323 const RISCVOptions &CLOpts;
324
325public:
326 RISCVPassConfig(RISCVTargetMachine &TM, PassManagerBase &PM)
327 : TargetPassConfig(TM, PM), CLOpts(TM.getCLOpts()) {
328 if (TM.getOptLevel() != CodeGenOptLevel::None)
329 substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
330 setEnableSinkAndFold(CLOpts.enable_sink_fold);
331 EnableLoopTermFold = true;
332 }
333
334 RISCVTargetMachine &getRISCVTargetMachine() const {
336 }
337
338 void addIRPasses() override;
339 bool addPreISel() override;
340 void addCodeGenPrepare() override;
341 bool addInstSelector() override;
342 bool addIRTranslator() override;
343 void addPreLegalizeMachineIR() override;
344 bool addLegalizeMachineIR() override;
345 void addPreRegBankSelect() override;
346 bool addRegBankSelect() override;
347 bool addGlobalInstructionSelect() override;
348 void addPreEmitPass() override;
349 void addPreEmitPass2() override;
350 void addPreSched2() override;
351 void addMachineSSAOptimization() override;
352 FunctionPass *createRVVRegAllocPass(bool Optimized);
353 bool addRegAssignAndRewriteFast() override;
354 bool addRegAssignAndRewriteOptimized() override;
355 void addPreRegAlloc() override;
356 void addPostRegAlloc() override;
357 void addFastRegAlloc() override;
358 bool addILPOpts() override;
359
360 std::unique_ptr<CSEConfigBase> getCSEConfig() const override;
361};
362} // namespace
363
365 return new RISCVPassConfig(*this, PM);
366}
367
368std::unique_ptr<CSEConfigBase> RISCVPassConfig::getCSEConfig() const {
369 return getStandardCSEConfigForOpt(TM->getOptLevel());
370}
371
372FunctionPass *RISCVPassConfig::createRVVRegAllocPass(bool Optimized) {
373 // Initialize the global default.
374 llvm::call_once(InitializeDefaultRVVRegisterAllocatorFlag,
375 initializeDefaultRVVRegisterAllocatorOnce);
376
377 RegisterRegAlloc::FunctionPassCtor Ctor = RVVRegisterRegAlloc::getDefault();
378 if (Ctor != useDefaultRegisterAllocator)
379 return Ctor();
380
381 if (Optimized)
382 return createGreedyRVVRegisterAllocator();
383
384 return createFastRVVRegisterAllocator();
385}
386
387bool RISCVPassConfig::addRegAssignAndRewriteFast() {
388 addPass(createRVVRegAllocPass(false));
390 if (TM->getOptLevel() != CodeGenOptLevel::None && CLOpts.enable_dead_defs)
393}
394
395bool RISCVPassConfig::addRegAssignAndRewriteOptimized() {
396 addPass(createRVVRegAllocPass(true));
397 addPass(createVirtRegRewriter(false));
399 if (TM->getOptLevel() != CodeGenOptLevel::None && CLOpts.enable_dead_defs)
402}
403
404void RISCVPassConfig::addIRPasses() {
407
408 if (getOptLevel() != CodeGenOptLevel::None) {
409 if (CLOpts.enable_loop_data_prefetch)
411
415 }
416
418
419 if (getOptLevel() == CodeGenOptLevel::Aggressive && CLOpts.select_opt)
420 addPass(createSelectOptimizePass());
421}
422
423bool RISCVPassConfig::addPreISel() {
424 if (TM->getOptLevel() != CodeGenOptLevel::None)
426 if (TM->getOptLevel() != CodeGenOptLevel::None) {
427 // Add a barrier before instruction selection so that we will not get
428 // deleted block address after enabling default outlining. See D99707 for
429 // more details.
430 addPass(createBarrierNoopPass());
431 }
432
433 if (valueOr(CLOpts.enable_global_merge,
434 TM->getOptLevel() != CodeGenOptLevel::None)) {
435 // FIXME: Like AArch64, we disable extern global merging by default due to
436 // concerns it might regress some workloads. Unlike AArch64, we don't
437 // currently support enabling the pass in an "OnlyOptimizeForSize" mode.
438 // Investigating and addressing both items are TODO.
439 addPass(createGlobalMergePass(TM, /* MaxOffset */ 2047,
440 /* OnlyOptimizeForSize */ false,
441 /* MergeExternalByDefault */ true));
442 }
443
444 return false;
445}
446
447void RISCVPassConfig::addCodeGenPrepare() {
448 if (getOptLevel() != CodeGenOptLevel::None)
451}
452
453bool RISCVPassConfig::addInstSelector() {
454 addPass(createRISCVISelDagLegacyPass(getRISCVTargetMachine(), getOptLevel()));
455
456 return false;
457}
458
459bool RISCVPassConfig::addIRTranslator() {
460 addPass(new IRTranslatorLegacy(getOptLevel()));
461 return false;
462}
463
464void RISCVPassConfig::addPreLegalizeMachineIR() {
465 if (getOptLevel() == CodeGenOptLevel::None) {
467 } else {
469 }
470}
471
472bool RISCVPassConfig::addLegalizeMachineIR() {
473 addPass(new LegalizerLegacy());
474 return false;
475}
476
477void RISCVPassConfig::addPreRegBankSelect() {
478 if (getOptLevel() != CodeGenOptLevel::None)
480}
481
482bool RISCVPassConfig::addRegBankSelect() {
483 addPass(new RegBankSelectLegacy());
484 return false;
485}
486
487bool RISCVPassConfig::addGlobalInstructionSelect() {
488 addPass(new InstructionSelectLegacy(getOptLevel()));
489 return false;
490}
491
492void RISCVPassConfig::addPreSched2() {
494
495 // Emit KCFI checks for indirect calls.
496 addPass(createKCFIPass());
497 if (TM->getOptLevel() != CodeGenOptLevel::None)
499}
500
501void RISCVPassConfig::addPreEmitPass() {
502 // TODO: It would potentially be better to schedule copy propagation after
503 // expanding pseudos (in addPreEmitPass2). However, performing copy
504 // propagation after the machine outliner (which runs after addPreEmitPass)
505 // currently leads to incorrect code-gen, where copies to registers within
506 // outlined functions are removed erroneously.
507 if (TM->getOptLevel() >= CodeGenOptLevel::Default &&
508 CLOpts.enable_copy_propagation)
510 if (TM->getOptLevel() >= CodeGenOptLevel::Default)
512 // The IndirectBranchTrackingPass inserts lpad and could have changed the
513 // basic block alignment. It must be done before Branch Relaxation to
514 // prevent the adjusted offset exceeding the branch range.
516 addPass(&BranchRelaxationPassID);
518}
519
520void RISCVPassConfig::addPreEmitPass2() {
521 if (TM->getOptLevel() != CodeGenOptLevel::None) {
523 // Schedule PushPop Optimization before expansion of Pseudo instruction,
524 // ensuring return instruction is detected correctly.
526 }
528
529 // Add QC Relaxation Markers as late as possible, and only for RV32
530 if (TM->getOptLevel() != CodeGenOptLevel::None &&
531 TM->getTargetTriple().isRISCV32())
533
534 // Schedule the expansion of AMOs at the last possible moment, avoiding the
535 // possibility for other passes to break the requirements for forward
536 // progress in the LR/SC block.
538
539 // KCFI indirect call checks are lowered to a bundle.
541 return MF.getFunction().getParent()->getModuleFlag("kcfi");
542 }));
543
544 if (CLOpts.enable_cfi_instr_inserter)
546}
547
548void RISCVPassConfig::addMachineSSAOptimization() {
549 // It's beneficial to reduce the VL to enable more
550 // Machine SSA optimizations.
551 if (TM->getOptLevel() != CodeGenOptLevel::None) {
552 // RISCVVLOptimizer can make loop invariant instructions like vmv.v.i
553 // loop variant by propagating a VL defined inside the loop. Run LICM and
554 // hoist them early. Don't do this at -O0 to avoid the compile-time
555 // overhead. Not reducing the VL of loop invariant pseudos results in more
556 // vsetvli toggles, and still requires the MachineLoopInfo analysis to be
557 // run.
558 addPass(&EarlyMachineLICMID);
560 }
561
564
566
567 if (TM->getTargetTriple().isRISCV64()) {
569 }
570}
571
572void RISCVPassConfig::addPreRegAlloc() {
574 if (TM->getOptLevel() != CodeGenOptLevel::None) {
577 }
578
583}
584
585void RISCVPassConfig::addFastRegAlloc() {
586 addPass(&InitUndefID);
588}
589
590
591void RISCVPassConfig::addPostRegAlloc() {
592 if (TM->getOptLevel() != CodeGenOptLevel::None && CLOpts.enable_copyelim)
594}
595
596bool RISCVPassConfig::addILPOpts() {
597 if (CLOpts.enable_machine_combiner)
598 addPass(&MachineCombinerID);
599
600 return true;
601}
602
607
613
616 SMDiagnostic &Error, SMRange &SourceRange) const {
617 const auto &YamlMFI =
618 static_cast<const yaml::RISCVMachineFunctionInfo &>(MFI);
619 PFS.MF.getInfo<RISCVMachineFunctionInfo>()->initializeBaseYamlFields(YamlMFI);
620 return false;
621}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static std::unique_ptr< TargetLoweringObjectFile > createTLOF(const Triple &TT)
static Reloc::Model getEffectiveRelocModel()
#define X(NUM, ENUM, NAME)
Definition ELF.h:665
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Provides analysis for continuously CSEing during GISel passes.
#define LLVM_ABI
Definition Compiler.h:211
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
This file declares the IRTranslator pass.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
Register const TargetRegisterInfo * TRI
#define T
MachineRegisterInfo & MRI
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTarget()
This file defines a TargetTransformInfoImplBase conforming object specific to the RISC-V target machi...
This file describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static FunctionPass * useDefaultRegisterAllocator()
-regalloc=... command line option.
Target-Independent Code Generator Pass Configuration Options pass.
This pass exposes codegen information to IR-level passes.
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
This class holds the attributes for a particular argument, parameter, function, or return value.
Definition Attributes.h:406
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:106
LLVM_ABI std::optional< unsigned > getVScaleRangeMax() const
Returns the maximum value for the vscale_range attribute or std::nullopt when unknown.
LLVM_ABI unsigned getVScaleRangeMin() const
Returns the minimum value for the vscale_range attribute.
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition Attributes.h:262
CodeGenTargetMachineImpl(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:312
Module * getParent()
Get the module that this global value is contained inside of...
This pass is responsible for selecting generic machine instructions to target-specific instructions.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
Definition Module.cpp:358
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
RISCVMachineFunctionInfo - This class is derived from MachineFunctionInfo and contains private RISCV-...
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
RISCVTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT)
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
bool isNoopAddrSpaceCast(const DataLayout &DL, unsigned SrcAS, unsigned DstAS) const override
Returns true if a cast between SrcAS and DestAS is a noop.
ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const override
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
ScheduleDAGInstrs * createPostMachineScheduler(MachineSchedContext *C) const override
Similar to createMachineScheduler but used when postRA machine scheduling is enabled.
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
const RISCVSubtarget * getSubtargetImpl() const =delete
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
RegisterPassParser class - Handle the addition of new machine passes.
RegisterRegAllocBase class - Track the registration of register allocators.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition SourceMgr.h:307
Represents a range in source code.
Definition SMLoc.h:47
A ScheduleDAG for scheduling lists of MachineInstr.
ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules machine instructions while...
ScheduleDAGMI is an implementation of ScheduleDAGInstrs that simply schedules machine instructions ac...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:28
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
void setSupportsDebugEntryValues(bool Enable)
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
void setMachineOutliner(bool Enable)
void setCFIFixup(bool Enable)
void setSupportsDefaultOutlining(bool Enable)
StringRef getTargetABIName(const Module &M) const
Returns the effective target ABI name: the "target-abi" module flag if present, otherwise the -target...
const DataLayout DL
DataLayout for the target: keep ABI type size and alignment.
std::unique_ptr< const MCSubtargetInfo > STI
TargetOptions Options
Target-Independent Code Generator Pass Configuration Options.
virtual void addCodeGenPrepare()
Add pass to prepare the LLVM IR for code generation.
virtual bool addRegAssignAndRewriteFast()
Add core register allocator passes which do the actual register assignment and rewriting.
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
virtual void addFastRegAlloc()
addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast registe...
virtual void addMachineSSAOptimization()
addMachineSSAOptimization - Add standard passes that optimize machine instructions in SSA form.
virtual bool addRegAssignAndRewriteOptimized()
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
TargetSubtargetInfo - Generic base class for all target subtargets.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:48
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Registers T::Global with cl::ParseCommandLineOptions.
A raw_ostream that writes to an SmallVector or SmallString.
const AArch64MCOptions & getCLOpts(const MCTargetOptions &Options)
static constexpr unsigned RVVBitsPerBlock
This namespace contains all of the command line option processing machinery.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
ScheduleDAGMILive * createSchedLive(MachineSchedContext *C)
Create the standard converging machine scheduler.
FunctionPass * createRISCVVectorPeepholeLegacyPass()
void initializeRISCVO0PreLegalizerCombinerLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createFastRegisterAllocator()
FastRegisterAllocation Pass - This pass register allocates as fast as possible.
void initializeRISCVFoldMemOffsetLegacyPass(PassRegistry &)
LLVM_ABI char & EarlyMachineLICMID
This pass performs loop invariant code motion on machine instructions.
LLVM_ABI char & InitUndefID
LLVM_ABI std::unique_ptr< ScheduleDAGMutation > createMacroFusionDAGMutation(ArrayRef< MacroFusionPredTy > Predicates, bool BranchOnly=false)
Create a DAG scheduling mutation to pair instructions back to back for instructions that benefit acco...
void initializeRISCVLateBranchOptLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createTypePromotionLegacyPass()
Create IR Type Promotion pass.
LLVM_ABI FunctionPass * createGreedyRegisterAllocator()
Greedy register allocation pass - This pass implements a global register allocator for optimized buil...
FunctionPass * createRISCVCodeGenPrepareLegacyPass()
FunctionPass * createRISCVISelDagLegacyPass(RISCVTargetMachine &TM, CodeGenOptLevel OptLevel)
FunctionPass * createRISCVOptWInstrsLegacyPass()
void initializeRISCVQCRelaxMarkingLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createSelectOptimizePass()
This pass converts conditional moves to conditional jumps when profitable.
LLVM_ABI Pass * createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset, bool OnlyOptimizeForSize=false, bool MergeExternalByDefault=false, bool MergeConstantByDefault=false, bool MergeConstAggressiveByDefault=false)
GlobalMerge - This pass merges internal (by default) globals into structs to enable reuse of a base p...
LLVM_ABI std::unique_ptr< ScheduleDAGMutation > createLoadClusterDAGMutation(const TargetInstrInfo *TII, bool ReorderWhileClustering=false)
If ReorderWhileClustering is set to true, no attempt will be made to reduce reordering due to store c...
Target & getTheRISCV32Target()
FunctionPass * createRISCVGatherScatterLoweringLegacyPass()
FunctionPass * createRISCVMoveMergeLegacyPass()
Returns an instance of the move merge pass.
FunctionPass * createRISCVLandingPadSetupLegacyPass()
void initializeRISCVPromoteConstantLegacyPass(PassRegistry &)
LLVM_ABI char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
void initializeRISCVExpandPseudoPreEmitLegacyPass(PassRegistry &)
FunctionPass * createRISCVExpandPseudoPostRALegacyPass()
FunctionPass * createRISCVExpandPseudoAtomicsLegacyPass()
Target & getTheRISCV64beTarget()
FunctionPass * createRISCVZacasABIFixLegacyPass()
LLVM_ABI std::unique_ptr< CSEConfigBase > getStandardCSEConfigForOpt(CodeGenOptLevel Level)
Definition CSEInfo.cpp:85
LLVM_ABI char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
LLVM_ABI std::unique_ptr< ScheduleDAGMutation > createStoreClusterDAGMutation(const TargetInstrInfo *TII, bool ReorderWhileClustering=false)
If ReorderWhileClustering is set to true, no attempt will be made to reduce reordering due to store c...
void initializeRISCVCodeGenPrepareLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createCFIInstrInserterLegacy()
Creates CFI Instruction Inserter pass.
void initializeRISCVRedundantCopyEliminationLegacyPass(PassRegistry &)
FunctionPass * createRISCVLateBranchOptLegacyPass()
ModulePass * createRISCVPromoteConstantLegacyPass()
FunctionPass * createRISCVIndirectBranchTrackingLegacyPass()
FunctionPass * createRISCVDeadRegisterDefinitionsLegacyPass()
void initializeRISCVPostLegalizerCombinerLegacyPass(PassRegistry &)
LLVM_ABI void initializeMachineKCFILegacyPass(PassRegistry &)
LLVM_ABI char & MachineCombinerID
This pass performs instruction combining using trace metrics to estimate critical-path and resource d...
FunctionPass * createRISCVMakeCompressibleLegacyPass()
Returns an instance of the Make Compressible Optimization pass.
LLVM_ABI FunctionPass * createUnpackMachineBundlesLegacy(std::function< bool(const MachineFunction &)> Ftor)
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
CodeModel::Model getEffectiveCodeModel(std::optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
FunctionPass * createRISCVPreLegalizerCombinerLegacyPass()
void initializeRISCVLoadStoreOptLegacyPass(PassRegistry &)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
Definition MathExtras.h:280
void initializeRISCVExpandPseudoAtomicsLegacyPass(PassRegistry &)
ScheduleDAGMI * createSchedPostRA(MachineSchedContext *C)
Create a generic scheduler with no vreg liveness or DAG mutation passes.
LLVM_ABI char & BranchRelaxationPassID
BranchRelaxation - This pass replaces branches that need to jump further than is supported by a branc...
FunctionPass * createRISCVExpandPseudoPreEmitLegacyPass()
void initializeRISCVDAGToDAGISelLegacyPass(PassRegistry &)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void initializeRISCVInsertVSETVLILegacyPass(PassRegistry &)
FunctionPass * createRISCVFoldMemOffsetLegacyPass()
LLVM_ABI FunctionPass * createKCFIPass()
Lowers KCFI operand bundles for indirect calls.
Definition KCFI.cpp:75
void initializeRISCVMakeCompressibleLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createLoopDataPrefetchPass()
FunctionPass * createRISCVMergeBaseOffsetLegacyPass()
Returns an instance of the Merge Base Offset Optimization pass.
void initializeRISCVPushPopOptLegacyPass(PassRegistry &)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Definition Error.cpp:163
FunctionPass * createRISCVPushPopOptLegacyPass()
createRISCVPushPopOptimizationPass - returns an instance of the Push/Pop optimization pass.
FunctionPass * createRISCVQCRelaxMarkingLegacyPass()
FunctionPass * createRISCVLoadStoreOptLegacyPass()
void initializeRISCVExpandPseudoPreRALegacyPass(PassRegistry &)
void initializeRISCVInsertWriteVXRMLegacyPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
@ Default
-O2, -Os, -Oz
Definition CodeGen.h:283
FunctionPass * createRISCVInsertWriteVXRMLegacyPass()
void initializeRISCVVLOptimizerLegacyPass(PassRegistry &)
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
FunctionPass * createRISCVPostLegalizerCombinerLegacyPass()
void initializeRISCVDeadRegisterDefinitionsLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createInterleavedAccessPass()
InterleavedAccess Pass - This pass identifies and matches interleaved memory accesses to target speci...
void initializeRISCVPreAllocZilsdOptLegacyPass(PassRegistry &)
std::unique_ptr< ScheduleDAGMutation > createRISCVVectorMaskDAGMutation(const TargetRegisterInfo *TRI)
LLVM_ABI FunctionPass * createBasicRegisterAllocator()
BasicRegisterAllocation Pass - This pass implements a degenerate global register allocator using the ...
LLVM_ABI void initializeGlobalISel(PassRegistry &)
Initialize all passes linked into the GlobalISel library.
FunctionPass * createRISCVRedundantCopyEliminationLegacyPass()
void initializeRISCVVectorPeepholeLegacyPass(PassRegistry &)
void initializeRISCVVMV0EliminationLegacyPass(PassRegistry &)
LLVM_ABI ModulePass * createBarrierNoopPass()
createBarrierNoopPass - This pass is purely a module pass barrier in a pass manager.
void initializeRISCVIndirectBranchTrackingLegacyPass(PassRegistry &)
Target & getTheRISCV64Target()
FunctionPass * createRISCVExpandPseudoPreRALegacyPass()
FunctionPass * createRISCVVMV0EliminationLegacyPass()
void call_once(once_flag &flag, Function &&F, Args &&... ArgList)
Execute the function specified as a parameter once.
Definition Threading.h:86
FunctionPass * createRISCVO0PreLegalizerCombinerLegacyPass()
void initializeRISCVMergeBaseOffsetLegacyPass(PassRegistry &)
void initializeRISCVAsmPrinterPass(PassRegistry &)
FunctionPass * createRISCVInsertReadWriteCSRLegacyPass()
void initializeRISCVOptWInstrsLegacyPass(PassRegistry &)
void initializeRISCVGatherScatterLoweringLegacyPass(PassRegistry &)
void initializeRISCVInsertReadWriteCSRLegacyPass(PassRegistry &)
void initializeRISCVZacasABIFixLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createVirtRegRewriter(bool ClearVirtRegs=true)
constexpr bool valueOr(BoolOrDefault X, bool Default)
LLVM_ABI FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
void initializeRISCVPreLegalizerCombinerLegacyPass(PassRegistry &)
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
Definition bit.h:347
LLVM_ABI MachineFunctionPass * createMachineCopyPropagationPass(bool UseCopyInstr)
FunctionPass * createRISCVVLOptimizerLegacyPass()
void initializeRISCVExpandPseudoPostRALegacyPass(PassRegistry &)
FunctionPass * createRISCVPreAllocZilsdOptLegacyPass()
FunctionPass * createRISCVInsertVSETVLILegacyPass()
Returns an instance of the Insert VSETVLI pass.
Target & getTheRISCV32beTarget()
void initializeRISCVMoveMergeLegacyPass(PassRegistry &)
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
#define N
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
static FuncInfoTy * create(BumpPtrAllocator &Allocator, const Function &F, const SubtargetTy *STI)
Factory function: default behavior is to call new using the supplied allocator.
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
static bool isRVVRegClass(const TargetRegisterClass *RC)
RegisterTargetMachine - Helper template for registering a target machine implementation,...
The llvm::once_flag structure.
Definition Threading.h:67
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.