LLVM 23.0.0git
AMDGPUTargetMachine.cpp
Go to the documentation of this file.
1//===-- AMDGPUTargetMachine.cpp - TargetMachine for hw codegen targets-----===//
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/// \file
10/// This file contains both AMDGPU target machine and the CodeGen pass builder.
11/// The AMDGPU target machine contains all of the hardware specific information
12/// needed to emit code for SI+ GPUs in the legacy pass manager pipeline. The
13/// CodeGen pass builder handles the pass pipeline for new pass manager.
14//
15//===----------------------------------------------------------------------===//
16
17#include "AMDGPUTargetMachine.h"
18#include "AMDGPU.h"
19#include "AMDGPUAliasAnalysis.h"
20#include "AMDGPUAsmPrinter.h"
26#include "AMDGPUHazardLatency.h"
27#include "AMDGPUIGroupLP.h"
28#include "AMDGPUISelDAGToDAG.h"
30#include "AMDGPUMacroFusion.h"
38#include "AMDGPUSplitModule.h"
43#include "GCNDPPCombine.h"
45#include "GCNNSAReassign.h"
49#include "GCNSchedStrategy.h"
50#include "GCNVOPDUtils.h"
51#include "R600.h"
52#include "R600TargetMachine.h"
53#include "SIFixSGPRCopies.h"
54#include "SIFixVGPRCopies.h"
55#include "SIFoldOperands.h"
56#include "SIFormMemoryClauses.h"
58#include "SILowerControlFlow.h"
59#include "SILowerSGPRSpills.h"
60#include "SILowerWWMCopies.h"
62#include "SIMachineScheduler.h"
66#include "SIPeepholeSDWA.h"
67#include "SIPostRABundler.h"
70#include "SIWholeQuadMode.h"
91#include "llvm/CodeGen/Passes.h"
96#include "llvm/IR/IntrinsicsAMDGPU.h"
97#include "llvm/IR/Module.h"
98#include "llvm/IR/PassManager.h"
108#include "llvm/Transforms/IPO.h"
133#include <optional>
134
135using namespace llvm;
136using namespace llvm::PatternMatch;
137
138namespace {
139//===----------------------------------------------------------------------===//
140// AMDGPU CodeGen Pass Builder interface.
141//===----------------------------------------------------------------------===//
142
143class AMDGPUCodeGenPassBuilder
144 : public CodeGenPassBuilder<AMDGPUCodeGenPassBuilder, GCNTargetMachine> {
145 using Base = CodeGenPassBuilder<AMDGPUCodeGenPassBuilder, GCNTargetMachine>;
146
147public:
148 AMDGPUCodeGenPassBuilder(GCNTargetMachine &TM,
149 const CGPassBuilderOption &Opts,
150 PassInstrumentationCallbacks *PIC);
151
152 void addIRPasses(PassManagerWrapper &PMW) const;
153 void addCodeGenPrepare(PassManagerWrapper &PMW) const;
154 void addPreISel(PassManagerWrapper &PMW) const;
155 void addILPOpts(PassManagerWrapper &PMWM) const;
156 void addAsmPrinterBegin(PassManagerWrapper &PMW) const;
157 void addAsmPrinter(PassManagerWrapper &PMW) const;
158 void addAsmPrinterEnd(PassManagerWrapper &PMW) const;
159 Error addInstSelector(PassManagerWrapper &PMW) const;
160 void addPreRewrite(PassManagerWrapper &PMW) const;
161 void addMachineSSAOptimization(PassManagerWrapper &PMW) const;
162 void addPostRegAlloc(PassManagerWrapper &PMW) const;
163 void addPreEmitPass(PassManagerWrapper &PMWM) const;
164 void addPreEmitRegAlloc(PassManagerWrapper &PMW) const;
165 Error addRegAssignmentFast(PassManagerWrapper &PMW) const;
166 Error addRegAssignmentOptimized(PassManagerWrapper &PMW) const;
167 void addPreRegAlloc(PassManagerWrapper &PMW) const;
168 Error addFastRegAlloc(PassManagerWrapper &PMW) const;
169 Error addOptimizedRegAlloc(PassManagerWrapper &PMW) const;
170 void addPreSched2(PassManagerWrapper &PMW) const;
171 void addPostBBSections(PassManagerWrapper &PMW) const;
172
173private:
174 Error validateRegAllocOptions() const;
175
176public:
177 /// Check if a pass is enabled given \p Opt option. The option always
178 /// overrides defaults if explicitly used. Otherwise its default will be used
179 /// given that a pass shall work at an optimization \p Level minimum.
180 bool isPassEnabled(const cl::opt<bool> &Opt,
181 CodeGenOptLevel Level = CodeGenOptLevel::Default) const;
182 void addEarlyCSEOrGVNPass(PassManagerWrapper &PMW) const;
183 void addStraightLineScalarOptimizationPasses(PassManagerWrapper &PMW) const;
184};
185
186class SGPRRegisterRegAlloc : public RegisterRegAllocBase<SGPRRegisterRegAlloc> {
187public:
188 SGPRRegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
189 : RegisterRegAllocBase(N, D, C) {}
190};
191
192class VGPRRegisterRegAlloc : public RegisterRegAllocBase<VGPRRegisterRegAlloc> {
193public:
194 VGPRRegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
195 : RegisterRegAllocBase(N, D, C) {}
196};
197
198class WWMRegisterRegAlloc : public RegisterRegAllocBase<WWMRegisterRegAlloc> {
199public:
200 WWMRegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
201 : RegisterRegAllocBase(N, D, C) {}
202};
203
204static bool onlyAllocateSGPRs(const TargetRegisterInfo &TRI,
205 const MachineRegisterInfo &MRI,
206 const Register Reg) {
207 const TargetRegisterClass *RC = MRI.getRegClass(Reg);
208 return static_cast<const SIRegisterInfo &>(TRI).isSGPRClass(RC);
209}
210
211static bool onlyAllocateVGPRs(const TargetRegisterInfo &TRI,
212 const MachineRegisterInfo &MRI,
213 const Register Reg) {
214 const TargetRegisterClass *RC = MRI.getRegClass(Reg);
215 return !static_cast<const SIRegisterInfo &>(TRI).isSGPRClass(RC);
216}
217
218static bool onlyAllocateWWMRegs(const TargetRegisterInfo &TRI,
219 const MachineRegisterInfo &MRI,
220 const Register Reg) {
221 const SIMachineFunctionInfo *MFI =
223 const TargetRegisterClass *RC = MRI.getRegClass(Reg);
224 return !static_cast<const SIRegisterInfo &>(TRI).isSGPRClass(RC) &&
226}
227
228/// -{sgpr|wwm|vgpr}-regalloc=... command line option.
229static FunctionPass *useDefaultRegisterAllocator() { return nullptr; }
230
231/// A dummy default pass factory indicates whether the register allocator is
232/// overridden on the command line.
233static llvm::once_flag InitializeDefaultSGPRRegisterAllocatorFlag;
234static llvm::once_flag InitializeDefaultVGPRRegisterAllocatorFlag;
235static llvm::once_flag InitializeDefaultWWMRegisterAllocatorFlag;
236
237static SGPRRegisterRegAlloc
238defaultSGPRRegAlloc("default",
239 "pick SGPR register allocator based on -O option",
241
242static cl::opt<SGPRRegisterRegAlloc::FunctionPassCtor, false,
244SGPRRegAlloc("sgpr-regalloc", cl::Hidden, cl::init(&useDefaultRegisterAllocator),
245 cl::desc("Register allocator to use for SGPRs"));
246
247static cl::opt<VGPRRegisterRegAlloc::FunctionPassCtor, false,
249VGPRRegAlloc("vgpr-regalloc", cl::Hidden, cl::init(&useDefaultRegisterAllocator),
250 cl::desc("Register allocator to use for VGPRs"));
251
252static cl::opt<WWMRegisterRegAlloc::FunctionPassCtor, false,
254 WWMRegAlloc("wwm-regalloc", cl::Hidden,
256 cl::desc("Register allocator to use for WWM registers"));
257
258// New pass manager register allocator options for AMDGPU
260 "sgpr-regalloc-npm", cl::Hidden, cl::init(RegAllocType::Default),
261 cl::desc("Register allocator for SGPRs (new pass manager)"));
262
264 "vgpr-regalloc-npm", cl::Hidden, cl::init(RegAllocType::Default),
265 cl::desc("Register allocator for VGPRs (new pass manager)"));
266
268 "wwm-regalloc-npm", cl::Hidden, cl::init(RegAllocType::Default),
269 cl::desc("Register allocator for WWM registers (new pass manager)"));
270
271/// Check if the given RegAllocType is supported for AMDGPU NPM register
272/// allocation. Only Fast and Greedy are supported; Basic and PBQP are not.
273static Error checkRegAllocSupported(RegAllocType RAType, StringRef RegName) {
274 if (RAType == RegAllocType::Basic || RAType == RegAllocType::PBQP) {
276 Twine("unsupported register allocator '") +
277 (RAType == RegAllocType::Basic ? "basic" : "pbqp") + "' for " +
278 RegName + " registers",
280 }
281 return Error::success();
282}
283
284Error AMDGPUCodeGenPassBuilder::validateRegAllocOptions() const {
285 // 1. Generic --regalloc-npm is not supported for AMDGPU.
286 if (Opt.RegAlloc != RegAllocType::Unset) {
288 "-regalloc-npm not supported for amdgcn. Use -sgpr-regalloc-npm, "
289 "-vgpr-regalloc-npm, and -wwm-regalloc-npm",
291 }
292
293 // 2. Legacy PM regalloc options are not compatible with NPM.
294 if (SGPRRegAlloc.getNumOccurrences() > 0 ||
295 VGPRRegAlloc.getNumOccurrences() > 0 ||
296 WWMRegAlloc.getNumOccurrences() > 0) {
298 "-sgpr-regalloc, -vgpr-regalloc, and -wwm-regalloc are legacy PM "
299 "options. Use -sgpr-regalloc-npm, -vgpr-regalloc-npm, and "
300 "-wwm-regalloc-npm with the new pass manager",
302 }
303
304 // 3. Only Fast and Greedy allocators are supported for AMDGPU.
305 if (auto Err = checkRegAllocSupported(SGPRRegAllocNPM, "SGPR"))
306 return Err;
307 if (auto Err = checkRegAllocSupported(WWMRegAllocNPM, "WWM"))
308 return Err;
309 if (auto Err = checkRegAllocSupported(VGPRRegAllocNPM, "VGPR"))
310 return Err;
311
312 return Error::success();
313}
314
315static void initializeDefaultSGPRRegisterAllocatorOnce() {
316 RegisterRegAlloc::FunctionPassCtor Ctor = SGPRRegisterRegAlloc::getDefault();
317
318 if (!Ctor) {
319 Ctor = SGPRRegAlloc;
320 SGPRRegisterRegAlloc::setDefault(SGPRRegAlloc);
321 }
322}
323
324static void initializeDefaultVGPRRegisterAllocatorOnce() {
325 RegisterRegAlloc::FunctionPassCtor Ctor = VGPRRegisterRegAlloc::getDefault();
326
327 if (!Ctor) {
328 Ctor = VGPRRegAlloc;
329 VGPRRegisterRegAlloc::setDefault(VGPRRegAlloc);
330 }
331}
332
333static void initializeDefaultWWMRegisterAllocatorOnce() {
334 RegisterRegAlloc::FunctionPassCtor Ctor = WWMRegisterRegAlloc::getDefault();
335
336 if (!Ctor) {
337 Ctor = WWMRegAlloc;
338 WWMRegisterRegAlloc::setDefault(WWMRegAlloc);
339 }
340}
341
342static FunctionPass *createBasicSGPRRegisterAllocator() {
343 return createBasicRegisterAllocator(onlyAllocateSGPRs);
344}
345
346static FunctionPass *createGreedySGPRRegisterAllocator() {
347 return createGreedyRegisterAllocator(onlyAllocateSGPRs);
348}
349
350static FunctionPass *createFastSGPRRegisterAllocator() {
351 return createFastRegisterAllocator(onlyAllocateSGPRs, false);
352}
353
354static FunctionPass *createBasicVGPRRegisterAllocator() {
355 return createBasicRegisterAllocator(onlyAllocateVGPRs);
356}
357
358static FunctionPass *createGreedyVGPRRegisterAllocator() {
359 return createGreedyRegisterAllocator(onlyAllocateVGPRs);
360}
361
362static FunctionPass *createFastVGPRRegisterAllocator() {
363 return createFastRegisterAllocator(onlyAllocateVGPRs, true);
364}
365
366static FunctionPass *createBasicWWMRegisterAllocator() {
367 return createBasicRegisterAllocator(onlyAllocateWWMRegs);
368}
369
370static FunctionPass *createGreedyWWMRegisterAllocator() {
371 return createGreedyRegisterAllocator(onlyAllocateWWMRegs);
372}
373
374static FunctionPass *createFastWWMRegisterAllocator() {
375 return createFastRegisterAllocator(onlyAllocateWWMRegs, false);
376}
377
378static SGPRRegisterRegAlloc basicRegAllocSGPR(
379 "basic", "basic register allocator", createBasicSGPRRegisterAllocator);
380static SGPRRegisterRegAlloc greedyRegAllocSGPR(
381 "greedy", "greedy register allocator", createGreedySGPRRegisterAllocator);
382
383static SGPRRegisterRegAlloc fastRegAllocSGPR(
384 "fast", "fast register allocator", createFastSGPRRegisterAllocator);
385
386
387static VGPRRegisterRegAlloc basicRegAllocVGPR(
388 "basic", "basic register allocator", createBasicVGPRRegisterAllocator);
389static VGPRRegisterRegAlloc greedyRegAllocVGPR(
390 "greedy", "greedy register allocator", createGreedyVGPRRegisterAllocator);
391
392static VGPRRegisterRegAlloc fastRegAllocVGPR(
393 "fast", "fast register allocator", createFastVGPRRegisterAllocator);
394static WWMRegisterRegAlloc basicRegAllocWWMReg("basic",
395 "basic register allocator",
396 createBasicWWMRegisterAllocator);
397static WWMRegisterRegAlloc
398 greedyRegAllocWWMReg("greedy", "greedy register allocator",
399 createGreedyWWMRegisterAllocator);
400static WWMRegisterRegAlloc fastRegAllocWWMReg("fast", "fast register allocator",
401 createFastWWMRegisterAllocator);
402
404 return Phase == ThinOrFullLTOPhase::FullLTOPreLink ||
405 Phase == ThinOrFullLTOPhase::ThinLTOPreLink;
406}
407} // anonymous namespace
408
409static cl::opt<bool>
411 cl::desc("Run early if-conversion"),
412 cl::init(false));
413
414static cl::opt<bool>
415OptExecMaskPreRA("amdgpu-opt-exec-mask-pre-ra", cl::Hidden,
416 cl::desc("Run pre-RA exec mask optimizations"),
417 cl::init(true));
418
419static cl::opt<bool>
420 LowerCtorDtor("amdgpu-lower-global-ctor-dtor",
421 cl::desc("Lower GPU ctor / dtors to globals on the device."),
422 cl::init(true), cl::Hidden);
423
424// Option to disable vectorizer for tests.
426 "amdgpu-load-store-vectorizer",
427 cl::desc("Enable load store vectorizer"),
428 cl::init(true),
429 cl::Hidden);
430
431// Option to control global loads scalarization
433 "amdgpu-scalarize-global-loads",
434 cl::desc("Enable global load scalarization"),
435 cl::init(true),
436 cl::Hidden);
437
438// Option to run internalize pass.
440 "amdgpu-internalize-symbols",
441 cl::desc("Enable elimination of non-kernel functions and unused globals"),
442 cl::init(false),
443 cl::Hidden);
444
445// Option to inline all early.
447 "amdgpu-early-inline-all",
448 cl::desc("Inline all functions early"),
449 cl::init(false),
450 cl::Hidden);
451
453 "amdgpu-enable-remove-incompatible-functions", cl::Hidden,
454 cl::desc("Enable removal of functions when they"
455 "use features not supported by the target GPU"),
456 cl::init(true));
457
459 "amdgpu-sdwa-peephole",
460 cl::desc("Enable SDWA peepholer"),
461 cl::init(true));
462
464 "amdgpu-dpp-combine",
465 cl::desc("Enable DPP combiner"),
466 cl::init(true));
467
468// Enable address space based alias analysis
470 cl::desc("Enable AMDGPU Alias Analysis"),
471 cl::init(true));
472
473// Enable lib calls simplifications
475 "amdgpu-simplify-libcall",
476 cl::desc("Enable amdgpu library simplifications"),
477 cl::init(true),
478 cl::Hidden);
479
481 "amdgpu-ir-lower-kernel-arguments",
482 cl::desc("Lower kernel argument loads in IR pass"),
483 cl::init(true),
484 cl::Hidden);
485
487 "amdgpu-reassign-regs",
488 cl::desc("Enable register reassign optimizations on gfx10+"),
489 cl::init(true),
490 cl::Hidden);
491
493 "amdgpu-opt-vgpr-liverange",
494 cl::desc("Enable VGPR liverange optimizations for if-else structure"),
495 cl::init(true), cl::Hidden);
496
498 "amdgpu-atomic-optimizer-strategy",
499 cl::desc("Select DPP or Iterative strategy for scan"),
502 clEnumValN(ScanOptions::DPP, "DPP", "Use DPP operations for scan"),
504 "Use Iterative approach for scan"),
505 clEnumValN(ScanOptions::None, "None", "Disable atomic optimizer")));
506
507// Enable Mode register optimization
509 "amdgpu-mode-register",
510 cl::desc("Enable mode register pass"),
511 cl::init(true),
512 cl::Hidden);
513
514// Enable GFX11+ s_delay_alu insertion
515static cl::opt<bool>
516 EnableInsertDelayAlu("amdgpu-enable-delay-alu",
517 cl::desc("Enable s_delay_alu insertion"),
518 cl::init(true), cl::Hidden);
519
520// Enable GFX11+ VOPD
521static cl::opt<bool>
522 EnableVOPD("amdgpu-enable-vopd",
523 cl::desc("Enable VOPD, dual issue of VALU in wave32"),
524 cl::init(true), cl::Hidden);
525
526// Option is used in lit tests to prevent deadcoding of patterns inspected.
527static cl::opt<bool>
528EnableDCEInRA("amdgpu-dce-in-ra",
529 cl::init(true), cl::Hidden,
530 cl::desc("Enable machine DCE inside regalloc"));
531
532static cl::opt<bool> EnableSetWavePriority("amdgpu-set-wave-priority",
533 cl::desc("Adjust wave priority"),
534 cl::init(false), cl::Hidden);
535
537 "amdgpu-scalar-ir-passes",
538 cl::desc("Enable scalar IR passes"),
539 cl::init(true),
540 cl::Hidden);
541
543 "amdgpu-enable-lower-exec-sync",
544 cl::desc("Enable lowering of execution synchronization."), cl::init(true),
545 cl::Hidden);
546
547static cl::opt<bool>
548 EnableSwLowerLDS("amdgpu-enable-sw-lower-lds",
549 cl::desc("Enable lowering of lds to global memory pass "
550 "and asan instrument resulting IR."),
551 cl::init(true), cl::Hidden);
552
554 "amdgpu-enable-object-linking",
555 cl::desc("Enable object linking for cross-TU LDS and ABI support"),
557 cl::Hidden);
558
560 "amdgpu-enable-lower-module-lds", cl::desc("Enable lower module lds pass"),
562 cl::Hidden);
563
565 "amdgpu-enable-pre-ra-optimizations",
566 cl::desc("Enable Pre-RA optimizations pass"), cl::init(true),
567 cl::Hidden);
568
570 "amdgpu-enable-promote-kernel-arguments",
571 cl::desc("Enable promotion of flat kernel pointer arguments to global"),
572 cl::Hidden, cl::init(true));
573
575 "amdgpu-enable-image-intrinsic-optimizer",
576 cl::desc("Enable image intrinsic optimizer pass"), cl::init(true),
577 cl::Hidden);
578
579static cl::opt<bool>
580 EnableLoopPrefetch("amdgpu-loop-prefetch",
581 cl::desc("Enable loop data prefetch on AMDGPU"),
582 cl::Hidden, cl::init(false));
583
585 AMDGPUSchedStrategy("amdgpu-sched-strategy",
586 cl::desc("Select custom AMDGPU scheduling strategy."),
587 cl::Hidden, cl::init(""));
588
589// Scheduler selection is consulted both when creating the scheduler and from
590// overrideSchedPolicy(), so keep the attribute and global command line handling
591// in one helper.
593 Attribute SchedStrategyAttr = F.getFnAttribute("amdgpu-sched-strategy");
594 if (SchedStrategyAttr.isValid())
595 return SchedStrategyAttr.getValueAsString();
596
597 if (!AMDGPUSchedStrategy.empty())
598 return AMDGPUSchedStrategy;
599
600 return "";
601}
602
603static void
605 const GCNSubtarget &ST) {
606 if (ST.hasGFX1250Insts())
607 return;
608
609 F.getContext().diagnose(DiagnosticInfoUnsupported(
610 F, "'amdgpu-sched-strategy'='coexec' is only supported for gfx1250",
612}
613
614static bool useNoopPostScheduler(const Function &F) {
615 Attribute PostSchedStrategyAttr =
616 F.getFnAttribute("amdgpu-post-sched-strategy");
617 return PostSchedStrategyAttr.isValid() &&
618 PostSchedStrategyAttr.getValueAsString() == "nop";
619}
620
622 "amdgpu-enable-rewrite-partial-reg-uses",
623 cl::desc("Enable rewrite partial reg uses pass"), cl::init(true),
624 cl::Hidden);
625
627 "amdgpu-enable-hipstdpar",
628 cl::desc("Enable HIP Standard Parallelism Offload support"), cl::init(false),
629 cl::Hidden);
630
631static cl::opt<bool>
632 EnableAMDGPUAttributor("amdgpu-attributor-enable",
633 cl::desc("Enable AMDGPUAttributorPass"),
634 cl::init(true), cl::Hidden);
635
637 "amdgpu-link-time-closed-world",
638 cl::desc("Whether has closed-world assumption at link time"),
639 cl::init(false), cl::Hidden);
640
642 "amdgpu-enable-uniform-intrinsic-combine",
643 cl::desc("Enable/Disable the Uniform Intrinsic Combine Pass"),
644 cl::init(true), cl::Hidden);
645
647 // Register the target
651
737}
738
739static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
740 return std::make_unique<AMDGPUTargetObjectFile>();
741}
742
746
747static ScheduleDAGInstrs *
749 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
750 ScheduleDAGMILive *DAG =
751 new GCNScheduleDAGMILive(C, std::make_unique<GCNMaxOccupancySchedStrategy>(C));
752 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
753 if (ST.shouldClusterStores())
754 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
756 DAG->addMutation(createAMDGPUMacroFusionDAGMutation());
757 DAG->addMutation(createAMDGPUExportClusteringDAGMutation());
758 DAG->addMutation(createAMDGPUBarrierLatencyDAGMutation(C->MF));
759 DAG->addMutation(createAMDGPUHazardLatencyDAGMutation(C->MF));
760 return DAG;
761}
762
763static ScheduleDAGInstrs *
765 ScheduleDAGMILive *DAG =
766 new GCNScheduleDAGMILive(C, std::make_unique<GCNMaxILPSchedStrategy>(C));
768 return DAG;
769}
770
771static ScheduleDAGInstrs *
773 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
775 C, std::make_unique<GCNMaxMemoryClauseSchedStrategy>(C));
776 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
777 if (ST.shouldClusterStores())
778 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
779 DAG->addMutation(createAMDGPUExportClusteringDAGMutation());
780 DAG->addMutation(createAMDGPUBarrierLatencyDAGMutation(C->MF));
781 DAG->addMutation(createAMDGPUHazardLatencyDAGMutation(C->MF));
782 return DAG;
783}
784
785static ScheduleDAGInstrs *
787 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
788 auto *DAG = new GCNIterativeScheduler(
790 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
791 if (ST.shouldClusterStores())
792 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
794 return DAG;
795}
796
803
804static ScheduleDAGInstrs *
806 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
808 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
809 if (ST.shouldClusterStores())
810 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
811 DAG->addMutation(createAMDGPUMacroFusionDAGMutation());
813 return DAG;
814}
815
816static MachineSchedRegistry
817SISchedRegistry("si", "Run SI's custom scheduler",
819
822 "Run GCN scheduler to maximize occupancy",
824
826 GCNMaxILPSchedRegistry("gcn-max-ilp", "Run GCN scheduler to maximize ilp",
828
830 "gcn-max-memory-clause", "Run GCN scheduler to maximize memory clause",
832
834 "gcn-iterative-max-occupancy-experimental",
835 "Run GCN scheduler to maximize occupancy (experimental)",
837
839 "gcn-iterative-minreg",
840 "Run GCN iterative scheduler for minimal register usage (experimental)",
842
844 "gcn-iterative-ilp",
845 "Run GCN iterative scheduler for ILP scheduling (experimental)",
847
850 if (!GPU.empty())
851 return GPU;
852
853 if (StringRef Name = AMDGPU::getArchNameFromSubArch(TT.getSubArch());
854 !Name.empty())
855 return Name;
856
857 // Need to default to a target with flat support for HSA.
858 if (TT.isAMDGCN())
859 return TT.getOS() == Triple::AMDHSA ? "generic-hsa" : "generic";
860
861 return "r600";
862}
863
865 // The AMDGPU toolchain only supports generating shared objects, so we
866 // must always use PIC.
867 return Reloc::PIC_;
868}
869
871 StringRef CPU, StringRef FS,
872 const TargetOptions &Options,
873 std::optional<Reloc::Model> RM,
874 std::optional<CodeModel::Model> CM,
877 T, TT.computeDataLayout(), TT, getGPUOrDefault(TT, CPU), FS, Options,
879 OptLevel),
881 initAsmInfo();
882 if (TT.isAMDGCN()) {
883 // Triple is missing a representation for non-empty, but unrecognized
884 // subarches. Only permit no subarch for any subtarget if it was really
885 // empty.
886 bool IsUnknownSubArch =
887 TT.getSubArch() == Triple::NoSubArch && TT.getArchName().size() != 6;
888 if (IsUnknownSubArch)
889 reportFatalUsageError("unknown subarch " + TT.getArchName());
890
891 if (TT.getSubArch() != Triple::NoSubArch) {
893 Triple::SubArchType GPUSubArch = AMDGPU::getSubArch(Kind);
894 if (Kind != AMDGPU::GK_NONE && GPUSubArch != TT.getSubArch() &&
895 TT.getSubArch() != AMDGPU::getMajorSubArch(GPUSubArch)) {
896 reportFatalUsageError("invalid cpu '" + CPU + "' for subarch " +
897 TT.getArchName());
898 }
899 }
900
901 if (getMCSubtargetInfo().checkFeatures("+wavefrontsize64"))
903 else if (getMCSubtargetInfo().checkFeatures("+wavefrontsize32"))
905 }
907}
908
912
914
916 Attribute GPUAttr = F.getFnAttribute("target-cpu");
917 return GPUAttr.isValid() ? GPUAttr.getValueAsString() : getTargetCPU();
918}
919
921 Attribute FSAttr = F.getFnAttribute("target-features");
922
923 return FSAttr.isValid() ? FSAttr.getValueAsString()
925}
926
929 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
931 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
932 if (ST.shouldClusterStores())
933 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
934 return DAG;
935}
936
937/// Predicate for Internalize pass.
938static bool mustPreserveGV(const GlobalValue &GV) {
939 if (const Function *F = dyn_cast<Function>(&GV))
940 return F->isDeclaration() || F->getName().starts_with("__asan_") ||
941 F->getName().starts_with("__sanitizer_") ||
942 AMDGPU::isEntryFunctionCC(F->getCallingConv());
943
945 return !GV.use_empty();
946}
947
952
955 if (Params.empty())
957 Params.consume_front("strategy=");
958 auto Result = StringSwitch<std::optional<ScanOptions>>(Params)
959 .Case("dpp", ScanOptions::DPP)
960 .Cases({"iterative", ""}, ScanOptions::Iterative)
961 .Case("none", ScanOptions::None)
962 .Default(std::nullopt);
963 if (Result)
964 return *Result;
965 return make_error<StringError>("invalid parameter", inconvertibleErrorCode());
966}
967
971 while (!Params.empty()) {
972 StringRef ParamName;
973 std::tie(ParamName, Params) = Params.split(';');
974 if (ParamName == "closed-world") {
975 Result.IsClosedWorld = true;
976 } else {
978 formatv("invalid AMDGPUAttributor pass parameter '{0}' ", ParamName)
979 .str(),
981 }
982 }
983 return Result;
984}
985
987
988#define GET_PASS_REGISTRY "AMDGPUPassRegistry.def"
990
991 // TODO: Move this into the base CodeGenPassBuilder once all
992 // targets that currently implement it have a ported asm-printer pass.
993 if (PIC) {
994 PIC->addClassToPassName(AMDGPUAsmPrinterBeginPass::name(),
995 "amdgpu-asm-printer-begin");
996 PIC->addClassToPassName(AMDGPUAsmPrinterPass::name(), "amdgpu-asm-printer");
997 PIC->addClassToPassName(AMDGPUAsmPrinterEndPass::name(),
998 "amdgpu-asm-printer-end");
999 }
1000
1001 PB.registerPipelineParsingCallback(
1002 [this](StringRef Name, CGSCCPassManager &PM,
1004 if (Name == "amdgpu-attributor-cgscc" && getTargetTriple().isAMDGCN()) {
1006 *static_cast<GCNTargetMachine *>(this)));
1007 return true;
1008 }
1009 return false;
1010 });
1011
1012 PB.registerScalarOptimizerLateEPCallback(
1013 [](FunctionPassManager &FPM, OptimizationLevel Level) {
1014 if (Level == OptimizationLevel::O0)
1015 return;
1016
1018 });
1019
1020 PB.registerVectorizerEndEPCallback(
1021 [](FunctionPassManager &FPM, OptimizationLevel Level) {
1022 if (Level == OptimizationLevel::O0)
1023 return;
1024
1026 });
1027
1028 PB.registerPipelineEarlySimplificationEPCallback(
1029 [this](ModulePassManager &PM, OptimizationLevel Level,
1031 if (!isLTOPreLink(Phase) && getTargetTriple().isAMDGCN()) {
1032 // When we are not using -fgpu-rdc, we can run accelerator code
1033 // selection relatively early, but still after linking to prevent
1034 // eager removal of potentially reachable symbols.
1035 if (EnableHipStdPar) {
1038 }
1039
1041 }
1042
1043 if (Level == OptimizationLevel::O0)
1044 return;
1045
1046 // We don't want to run internalization at per-module stage.
1049 PM.addPass(GlobalDCEPass());
1050 }
1051
1054 });
1055
1056 PB.registerPeepholeEPCallback(
1057 [](FunctionPassManager &FPM, OptimizationLevel Level) {
1058 if (Level == OptimizationLevel::O0)
1059 return;
1060
1064
1067 });
1068
1069 PB.registerCGSCCOptimizerLateEPCallback(
1070 [this](CGSCCPassManager &PM, OptimizationLevel Level) {
1071 if (Level == OptimizationLevel::O0)
1072 return;
1073
1075
1076 // Add promote kernel arguments pass to the opt pipeline right before
1077 // infer address spaces which is needed to do actual address space
1078 // rewriting.
1079 if (Level.getSpeedupLevel() > OptimizationLevel::O1.getSpeedupLevel() &&
1082
1083 // Add infer address spaces pass to the opt pipeline after inlining
1084 // but before SROA to increase SROA opportunities.
1086
1087 // This should run after inlining to have any chance of doing
1088 // anything, and before other cleanup optimizations.
1090
1091 // Promote alloca to vector before SROA and loop unroll. If we
1092 // manage to eliminate allocas before unroll we may choose to unroll
1093 // less.
1095
1096 PM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
1097 });
1098
1099 // FIXME: Why is AMDGPUAttributor not in CGSCC?
1100 PB.registerOptimizerLastEPCallback([this](ModulePassManager &MPM,
1101 OptimizationLevel Level,
1103 if (Level != OptimizationLevel::O0) {
1104 if (!isLTOPreLink(Phase)) {
1105 if (EnableAMDGPUAttributor && getTargetTriple().isAMDGCN()) {
1107 MPM.addPass(AMDGPUAttributorPass(*this, Opts, Phase));
1108 }
1109 }
1110 }
1111 });
1112
1113 PB.registerFullLinkTimeOptimizationLastEPCallback(
1114 [this](ModulePassManager &PM, OptimizationLevel Level) {
1115 // When we are using -fgpu-rdc, we can only run accelerator code
1116 // selection after linking to prevent, otherwise we end up removing
1117 // potentially reachable symbols that were exported as external in other
1118 // modules.
1119 if (EnableHipStdPar) {
1122 }
1123 // We want to support the -lto-partitions=N option as "best effort".
1124 // For that, we need to lower LDS earlier in the pipeline before the
1125 // module is partitioned for codegen.
1128 if (EnableSwLowerLDS)
1132 if (Level != OptimizationLevel::O0) {
1133 // We only want to run this with O2 or higher since inliner and SROA
1134 // don't run in O1.
1135 if (Level != OptimizationLevel::O1) {
1136 PM.addPass(
1138 }
1139 // Do we really need internalization in LTO?
1140 if (InternalizeSymbols) {
1142 PM.addPass(GlobalDCEPass());
1143 }
1144 if (EnableAMDGPUAttributor && getTargetTriple().isAMDGCN()) {
1147 Opt.IsClosedWorld = true;
1150 }
1151 }
1152 if (!NoKernelInfoEndLTO) {
1154 FPM.addPass(KernelInfoPrinter(this));
1155 PM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
1156 }
1157 });
1158
1159 PB.registerRegClassFilterParsingCallback(
1160 [](StringRef FilterName) -> RegAllocFilterFunc {
1161 if (FilterName == "sgpr")
1162 return onlyAllocateSGPRs;
1163 if (FilterName == "vgpr")
1164 return onlyAllocateVGPRs;
1165 if (FilterName == "wwm")
1166 return onlyAllocateWWMRegs;
1167 return nullptr;
1168 });
1169}
1170
1172 unsigned DestAS) const {
1173 return AMDGPU::isFlatGlobalAddrSpace(SrcAS) &&
1175}
1176
1178 if (auto *Arg = dyn_cast<Argument>(V);
1179 Arg &&
1180 AMDGPU::isModuleEntryFunctionCC(Arg->getParent()->getCallingConv()) &&
1181 !Arg->hasByRefAttr())
1183
1184 const auto *LD = dyn_cast<LoadInst>(V);
1185 if (!LD) // TODO: Handle invariant load like constant.
1187
1188 // It must be a generic pointer loaded.
1189 assert(V->getType()->getPointerAddressSpace() == AMDGPUAS::FLAT_ADDRESS);
1190
1191 const auto *Ptr = LD->getPointerOperand();
1192 if (Ptr->getType()->getPointerAddressSpace() != AMDGPUAS::CONSTANT_ADDRESS)
1194 // For a generic pointer loaded from the constant memory, it could be assumed
1195 // as a global pointer since the constant memory is only populated on the
1196 // host side. As implied by the offload programming model, only global
1197 // pointers could be referenced on the host side.
1199}
1200
1201std::pair<const Value *, unsigned>
1203 if (auto *II = dyn_cast<IntrinsicInst>(V)) {
1204 switch (II->getIntrinsicID()) {
1205 case Intrinsic::amdgcn_is_shared:
1206 return std::pair(II->getArgOperand(0), AMDGPUAS::LOCAL_ADDRESS);
1207 case Intrinsic::amdgcn_is_private:
1208 return std::pair(II->getArgOperand(0), AMDGPUAS::PRIVATE_ADDRESS);
1209 default:
1210 break;
1211 }
1212 return std::pair(nullptr, -1);
1213 }
1214 // Check the global pointer predication based on
1215 // (!is_share(p) && !is_private(p)). Note that logic 'and' is commutative and
1216 // the order of 'is_shared' and 'is_private' is not significant.
1217 Value *Ptr;
1218 if (match(
1219 const_cast<Value *>(V),
1222 m_Deferred(Ptr))))))
1223 return std::pair(Ptr, AMDGPUAS::GLOBAL_ADDRESS);
1224
1225 return std::pair(nullptr, -1);
1226}
1227
1228unsigned
1243
1245 Module &M, unsigned NumParts,
1246 function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback) {
1247 // FIXME(?): Would be better to use an already existing Analysis/PassManager,
1248 // but all current users of this API don't have one ready and would need to
1249 // create one anyway. Let's hide the boilerplate for now to keep it simple.
1250
1255
1256 PassBuilder PB(this);
1257 PB.registerModuleAnalyses(MAM);
1258 PB.registerFunctionAnalyses(FAM);
1259 PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
1260
1262 MPM.addPass(AMDGPUSplitModulePass(NumParts, ModuleCallback));
1263 MPM.run(M, MAM);
1264 return true;
1265}
1266
1267//===----------------------------------------------------------------------===//
1268// GCN Target Machine (SI+)
1269//===----------------------------------------------------------------------===//
1270
1272 StringRef CPU, StringRef FS,
1273 const TargetOptions &Options,
1274 std::optional<Reloc::Model> RM,
1275 std::optional<CodeModel::Model> CM,
1276 CodeGenOptLevel OL, bool JIT)
1277 : AMDGPUTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
1278
1279enum class OOBFlagValue {
1280 Any = 0,
1283};
1284
1285/// Returns the OOB mode encoded by a module flag.
1286/// An absent flag defaults to Any.
1287static OOBFlagValue getOOBFlagValue(const Module &M, StringRef FlagName) {
1288 const auto *Flag =
1289 mdconst::dyn_extract_or_null<ConstantInt>(M.getModuleFlag(FlagName));
1290 if (!Flag)
1291 return OOBFlagValue::Any;
1292 return static_cast<OOBFlagValue>(Flag->getZExtValue());
1293}
1294
1295const TargetSubtargetInfo *
1297 StringRef GPU = getGPUName(F);
1299
1300 const Module &M = *F.getParent();
1303 bool BufRelaxed = BufOOB == OOBFlagValue::Relaxed;
1304 bool TBufRelaxed = TBufOOB == OOBFlagValue::Relaxed;
1305 SmallString<128> SubtargetKey(GPU);
1306 SubtargetKey.append(FS);
1307 if (BufRelaxed)
1308 SubtargetKey.append(",buf-oob=1");
1309 if (TBufRelaxed)
1310 SubtargetKey.append(",tbuf-oob=1");
1311
1312 auto &I = SubtargetMap[SubtargetKey];
1313 if (!I) {
1315 Triple::SubArchType GPUSubArch = AMDGPU::getSubArch(Kind);
1316
1317 // Enforce the subtarget is covered by the subarch. Tolerate no subarch for
1318 // legacy compatibility.
1319 const Triple &TT = M.getTargetTriple();
1320 if (GPUSubArch != TT.getSubArch() && Kind != AMDGPU::GK_NONE) {
1321 // Check if this is a generic subarch which has subtargets. Ignore
1322 // unknown subtargets with a known subarch, since for whatever reason
1323 // the convention is to just print a warning and ignore unrecognized
1324 // subtargets.
1325 bool IsLegacyEmptySubArch = TT.getSubArch() == Triple::NoSubArch;
1326 if (!IsLegacyEmptySubArch &&
1327 AMDGPU::getMajorSubArch(GPUSubArch) != TT.getSubArch()) {
1328 F.getContext().emitError("invalid subtarget '" + Twine(GPU) +
1329 "' for subarch " + TT.getArchName());
1330 }
1331 }
1332
1333 I = std::make_unique<GCNSubtarget>(TargetTriple, GPU, FS, *this, BufRelaxed,
1334 TBufRelaxed);
1335 }
1336
1337 I->setScalarizeGlobalBehavior(ScalarizeGlobal);
1338
1339 return I.get();
1340}
1341
1344 return TargetTransformInfo(std::make_unique<GCNTTIImpl>(this, F));
1345}
1346
1349 raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
1350 const CGPassBuilderOption &Opts, MCContext &Ctx,
1352 AMDGPUCodeGenPassBuilder CGPB(*this, Opts, PIC);
1353 return CGPB.buildPipeline(MPM, MAM, Out, DwoOut, FileType, Ctx);
1354}
1355
1358 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
1359 if (ST.enableSIScheduler())
1361
1362 StringRef SchedStrategy = AMDGPU::getSchedStrategy(C->MF->getFunction());
1363
1364 if (SchedStrategy == "max-ilp")
1366
1367 if (SchedStrategy == "max-memory-clause")
1369
1370 if (SchedStrategy == "iterative-ilp")
1372
1373 if (SchedStrategy == "iterative-minreg")
1374 return createMinRegScheduler(C);
1375
1376 if (SchedStrategy == "iterative-maxocc")
1378
1379 if (SchedStrategy == "coexec") {
1380 diagnoseUnsupportedCoExecSchedulerSelection(C->MF->getFunction(), ST);
1382 }
1383
1385}
1386
1389 if (useNoopPostScheduler(C->MF->getFunction()))
1391
1392 ScheduleDAGMI *DAG =
1393 new GCNPostScheduleDAGMILive(C, std::make_unique<PostGenericScheduler>(C),
1394 /*RemoveKillFlags=*/true);
1395 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
1397 if (ST.shouldClusterStores())
1400 if ((EnableVOPD.getNumOccurrences() ||
1402 EnableVOPD)
1407 return DAG;
1408}
1409//===----------------------------------------------------------------------===//
1410// AMDGPU Legacy Pass Setup
1411//===----------------------------------------------------------------------===//
1412
1413std::unique_ptr<CSEConfigBase> llvm::AMDGPUPassConfig::getCSEConfig() const {
1414 return getStandardCSEConfigForOpt(TM->getOptLevel());
1415}
1416
1417namespace {
1418
1419class GCNPassConfig final : public AMDGPUPassConfig {
1420public:
1421 GCNPassConfig(TargetMachine &TM, PassManagerBase &PM)
1422 : AMDGPUPassConfig(TM, PM) {
1423 substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
1424 }
1425
1426 GCNTargetMachine &getGCNTargetMachine() const {
1427 return getTM<GCNTargetMachine>();
1428 }
1429
1430 bool addPreISel() override;
1431 void addMachineSSAOptimization() override;
1432 bool addILPOpts() override;
1433 bool addInstSelector() override;
1434 bool addIRTranslator() override;
1435 void addPreLegalizeMachineIR() override;
1436 bool addLegalizeMachineIR() override;
1437 void addPreRegBankSelect() override;
1438 bool addRegBankSelect() override;
1439 void addPreGlobalInstructionSelect() override;
1440 bool addGlobalInstructionSelect() override;
1441 void addPreRegAlloc() override;
1442 void addFastRegAlloc() override;
1443 void addOptimizedRegAlloc() override;
1444
1445 FunctionPass *createSGPRAllocPass(bool Optimized);
1446 FunctionPass *createVGPRAllocPass(bool Optimized);
1447 FunctionPass *createWWMRegAllocPass(bool Optimized);
1448 FunctionPass *createRegAllocPass(bool Optimized) override;
1449
1450 bool addRegAssignAndRewriteFast() override;
1451 bool addRegAssignAndRewriteOptimized() override;
1452
1453 bool addPreRewrite() override;
1454 void addPostRegAlloc() override;
1455 void addPreSched2() override;
1456 void addPreEmitPass() override;
1457 void addPostBBSections() override;
1458};
1459
1460} // end anonymous namespace
1461
1463 : TargetPassConfig(TM, PM) {
1464 // Exceptions and StackMaps are not supported, so these passes will never do
1465 // anything.
1468 // Garbage collection is not supported.
1471}
1472
1479
1484 // ReassociateGEPs exposes more opportunities for SLSR. See
1485 // the example in reassociate-geps-and-slsr.ll.
1487 // SeparateConstOffsetFromGEP and SLSR creates common expressions which GVN or
1488 // EarlyCSE can reuse.
1490 // Run NaryReassociate after EarlyCSE/GVN to be more effective.
1492 // NaryReassociate on GEPs creates redundant common expressions, so run
1493 // EarlyCSE after it.
1495}
1496
1499
1500 if (RemoveIncompatibleFunctions && TM.getTargetTriple().isAMDGCN())
1502
1503 // There is no reason to run these.
1507
1508 if (TM.getTargetTriple().isAMDGCN())
1510
1511 if (LowerCtorDtor)
1513
1514 if (TM.getTargetTriple().isAMDGCN() &&
1517
1520
1521 // This can be disabled by passing ::Disable here or on the command line
1522 // with --expand-variadics-override=disable.
1524
1525 // Function calls are not supported, so make sure we inline everything.
1528
1529 // Handle uses of OpenCL image2d_t, image3d_t and sampler_t arguments.
1530 if (TM.getTargetTriple().getArch() == Triple::r600)
1532
1533 // Make enqueued block runtime handles externally visible.
1535
1536 // Lower special LDS accesses.
1539
1540 // Lower LDS accesses to global memory pass if address sanitizer is enabled.
1541 if (EnableSwLowerLDS)
1543
1544 // Runs before PromoteAlloca so the latter can account for function uses
1547 }
1548
1549 // Run atomic optimizer before Atomic Expand
1550 if ((TM.getTargetTriple().isAMDGCN()) &&
1551 (TM.getOptLevel() >= CodeGenOptLevel::Less) &&
1554 }
1555
1557
1558 if (TM.getOptLevel() > CodeGenOptLevel::None) {
1560
1563
1567 AAResults &AAR) {
1568 if (auto *WrapperPass = P.getAnalysisIfAvailable<AMDGPUAAWrapperPass>())
1569 AAR.addAAResult(WrapperPass->getResult());
1570 }));
1571 }
1572
1573 if (TM.getTargetTriple().isAMDGCN()) {
1574 // TODO: May want to move later or split into an early and late one.
1576 }
1577
1578 // Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may
1579 // have expanded.
1580 if (TM.getOptLevel() > CodeGenOptLevel::Less)
1582 }
1583
1585
1586 // EarlyCSE is not always strong enough to clean up what LSR produces. For
1587 // example, GVN can combine
1588 //
1589 // %0 = add %a, %b
1590 // %1 = add %b, %a
1591 //
1592 // and
1593 //
1594 // %0 = shl nsw %a, 2
1595 // %1 = shl %a, 2
1596 //
1597 // but EarlyCSE can do neither of them.
1600}
1601
1603 if (TM->getTargetTriple().isAMDGCN() &&
1604 TM->getOptLevel() > CodeGenOptLevel::None)
1606
1607 if (TM->getTargetTriple().isAMDGCN() && EnableLowerKernelArguments)
1609
1611
1614
1615 if (TM->getTargetTriple().isAMDGCN()) {
1616 // This lowering has been placed after codegenprepare to take advantage of
1617 // address mode matching (which is why it isn't put with the LDS lowerings).
1618 // It could be placed anywhere before uniformity annotations (an analysis
1619 // that it changes by splitting up fat pointers into their components)
1620 // but has been put before switch lowering and CFG flattening so that those
1621 // passes can run on the more optimized control flow this pass creates in
1622 // many cases.
1625 }
1626
1627 // LowerSwitch pass may introduce unreachable blocks that can
1628 // cause unexpected behavior for subsequent passes. Placing it
1629 // here seems better that these blocks would get cleaned up by
1630 // UnreachableBlockElim inserted next in the pass flow.
1632}
1633
1635 if (TM->getOptLevel() > CodeGenOptLevel::None)
1637 return false;
1638}
1639
1644
1646 // Do nothing. GC is not supported.
1647 return false;
1648}
1649
1650//===----------------------------------------------------------------------===//
1651// GCN Legacy Pass Setup
1652//===----------------------------------------------------------------------===//
1653
1654bool GCNPassConfig::addPreISel() {
1656
1657 if (TM->getOptLevel() > CodeGenOptLevel::None) {
1658 addPass(createSinkingPass());
1660 }
1661
1662 // Merge divergent exit nodes. StructurizeCFG won't recognize the multi-exit
1663 // regions formed by them.
1665 addPass(createFixIrreduciblePass());
1666 addPass(createUnifyLoopExitsPass());
1667 addPass(createStructurizeCFGPass(false)); // true -> SkipUniformRegions
1668
1671 // TODO: Move this right after structurizeCFG to avoid extra divergence
1672 // analysis. This depends on stopping SIAnnotateControlFlow from making
1673 // control flow modifications.
1675
1676 // SDAG requires LCSSA, GlobalISel does not. Disable LCSSA for -global-isel
1677 // without any of the fallback options.
1680 !isGlobalISelAbortEnabled())
1681 addPass(createLCSSAPass());
1682
1683 if (TM->getOptLevel() > CodeGenOptLevel::Less)
1685
1686 return false;
1687}
1688
1689void GCNPassConfig::addMachineSSAOptimization() {
1691
1692 // We want to fold operands after PeepholeOptimizer has run (or as part of
1693 // it), because it will eliminate extra copies making it easier to fold the
1694 // real source operand. We want to eliminate dead instructions after, so that
1695 // we see fewer uses of the copies. We then need to clean up the dead
1696 // instructions leftover after the operands are folded as well.
1697 //
1698 // XXX - Can we get away without running DeadMachineInstructionElim again?
1699 addPass(&SIFoldOperandsLegacyID);
1700 if (EnableDPPCombine)
1701 addPass(&GCNDPPCombineLegacyID);
1703 if (isPassEnabled(EnableSDWAPeephole)) {
1704 addPass(&SIPeepholeSDWALegacyID);
1705 addPass(&EarlyMachineLICMID);
1706 addPass(&MachineCSELegacyID);
1707 addPass(&SIFoldOperandsLegacyID);
1708 }
1711}
1712
1713bool GCNPassConfig::addILPOpts() {
1715 addPass(&EarlyIfConverterLegacyID);
1716
1718 return false;
1719}
1720
1721bool GCNPassConfig::addInstSelector() {
1723 addPass(&SIFixSGPRCopiesLegacyID);
1725 return false;
1726}
1727
1728bool GCNPassConfig::addIRTranslator() {
1729 addPass(new IRTranslator(getOptLevel()));
1730 return false;
1731}
1732
1733void GCNPassConfig::addPreLegalizeMachineIR() {
1734 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1735 addPass(createAMDGPUPreLegalizeCombiner(IsOptNone));
1736 addPass(new Localizer());
1737}
1738
1739bool GCNPassConfig::addLegalizeMachineIR() {
1740 addPass(new Legalizer());
1741 return false;
1742}
1743
1744void GCNPassConfig::addPreRegBankSelect() {
1745 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1746 addPass(createAMDGPUPostLegalizeCombiner(IsOptNone));
1748}
1749
1750bool GCNPassConfig::addRegBankSelect() {
1753 return false;
1754}
1755
1756void GCNPassConfig::addPreGlobalInstructionSelect() {
1757 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1758 addPass(createAMDGPURegBankCombiner(IsOptNone));
1759}
1760
1761bool GCNPassConfig::addGlobalInstructionSelect() {
1762 addPass(new InstructionSelect(getOptLevel()));
1763 return false;
1764}
1765
1766void GCNPassConfig::addFastRegAlloc() {
1767 // FIXME: We have to disable the verifier here because of PHIElimination +
1768 // TwoAddressInstructions disabling it.
1769
1770 // This must be run immediately after phi elimination and before
1771 // TwoAddressInstructions, otherwise the processing of the tied operand of
1772 // SI_ELSE will introduce a copy of the tied operand source after the else.
1774
1776
1778}
1779
1780void GCNPassConfig::addPreRegAlloc() {
1781 if (getOptLevel() != CodeGenOptLevel::None)
1783}
1784
1785void GCNPassConfig::addOptimizedRegAlloc() {
1786 if (EnableDCEInRA)
1788
1789 // FIXME: when an instruction has a Killed operand, and the instruction is
1790 // inside a bundle, seems only the BUNDLE instruction appears as the Kills of
1791 // the register in LiveVariables, this would trigger a failure in verifier,
1792 // we should fix it and enable the verifier.
1793 if (OptVGPRLiveRange)
1795
1796 // This must be run immediately after phi elimination and before
1797 // TwoAddressInstructions, otherwise the processing of the tied operand of
1798 // SI_ELSE will introduce a copy of the tied operand source after the else.
1800
1803
1804 if (isPassEnabled(EnablePreRAOptimizations))
1806
1807 // Allow the scheduler to run before SIWholeQuadMode inserts exec manipulation
1808 // instructions that cause scheduling barriers.
1810
1811 if (OptExecMaskPreRA)
1813
1814 // This is not an essential optimization and it has a noticeable impact on
1815 // compilation time, so we only enable it from O2.
1816 if (TM->getOptLevel() > CodeGenOptLevel::Less)
1818
1820}
1821
1822bool GCNPassConfig::addPreRewrite() {
1824 addPass(&GCNNSAReassignID);
1825
1827 return true;
1828}
1829
1830FunctionPass *GCNPassConfig::createSGPRAllocPass(bool Optimized) {
1831 // Initialize the global default.
1832 llvm::call_once(InitializeDefaultSGPRRegisterAllocatorFlag,
1833 initializeDefaultSGPRRegisterAllocatorOnce);
1834
1835 RegisterRegAlloc::FunctionPassCtor Ctor = SGPRRegisterRegAlloc::getDefault();
1836 if (Ctor != useDefaultRegisterAllocator)
1837 return Ctor();
1838
1839 if (Optimized)
1840 return createGreedyRegisterAllocator(onlyAllocateSGPRs);
1841
1842 return createFastRegisterAllocator(onlyAllocateSGPRs, false);
1843}
1844
1845FunctionPass *GCNPassConfig::createVGPRAllocPass(bool Optimized) {
1846 // Initialize the global default.
1847 llvm::call_once(InitializeDefaultVGPRRegisterAllocatorFlag,
1848 initializeDefaultVGPRRegisterAllocatorOnce);
1849
1850 RegisterRegAlloc::FunctionPassCtor Ctor = VGPRRegisterRegAlloc::getDefault();
1851 if (Ctor != useDefaultRegisterAllocator)
1852 return Ctor();
1853
1854 if (Optimized)
1855 return createGreedyVGPRRegisterAllocator();
1856
1857 return createFastVGPRRegisterAllocator();
1858}
1859
1860FunctionPass *GCNPassConfig::createWWMRegAllocPass(bool Optimized) {
1861 // Initialize the global default.
1862 llvm::call_once(InitializeDefaultWWMRegisterAllocatorFlag,
1863 initializeDefaultWWMRegisterAllocatorOnce);
1864
1865 RegisterRegAlloc::FunctionPassCtor Ctor = WWMRegisterRegAlloc::getDefault();
1866 if (Ctor != useDefaultRegisterAllocator)
1867 return Ctor();
1868
1869 if (Optimized)
1870 return createGreedyWWMRegisterAllocator();
1871
1872 return createFastWWMRegisterAllocator();
1873}
1874
1875FunctionPass *GCNPassConfig::createRegAllocPass(bool Optimized) {
1876 llvm_unreachable("should not be used");
1877}
1878
1880 "-regalloc not supported with amdgcn. Use -sgpr-regalloc, -wwm-regalloc, "
1881 "and -vgpr-regalloc";
1882
1883bool GCNPassConfig::addRegAssignAndRewriteFast() {
1884 if (!usingDefaultRegAlloc())
1886
1887 addPass(&GCNPreRALongBranchRegID);
1888
1889 addPass(createSGPRAllocPass(false));
1890
1891 // Equivalent of PEI for SGPRs.
1892 addPass(&SILowerSGPRSpillsLegacyID);
1893
1894 // To Allocate wwm registers used in whole quad mode operations (for shaders).
1896
1897 // For allocating other wwm register operands.
1898 addPass(createWWMRegAllocPass(false));
1899
1900 addPass(&SILowerWWMCopiesLegacyID);
1902
1903 // For allocating per-thread VGPRs.
1904 addPass(createVGPRAllocPass(false));
1905
1906 return true;
1907}
1908
1909bool GCNPassConfig::addRegAssignAndRewriteOptimized() {
1910 if (!usingDefaultRegAlloc())
1912
1913 addPass(&GCNPreRALongBranchRegID);
1914
1915 addPass(createSGPRAllocPass(true));
1916
1917 // Commit allocated register changes. This is mostly necessary because too
1918 // many things rely on the use lists of the physical registers, such as the
1919 // verifier. This is only necessary with allocators which use LiveIntervals,
1920 // since FastRegAlloc does the replacements itself.
1921 addPass(createVirtRegRewriter(false));
1922
1923 // At this point, the sgpr-regalloc has been done and it is good to have the
1924 // stack slot coloring to try to optimize the SGPR spill stack indices before
1925 // attempting the custom SGPR spill lowering.
1926 addPass(&StackSlotColoringID);
1927
1928 // Equivalent of PEI for SGPRs.
1929 addPass(&SILowerSGPRSpillsLegacyID);
1930
1931 // To Allocate wwm registers used in whole quad mode operations (for shaders).
1933
1934 // For allocating other whole wave mode registers.
1935 addPass(createWWMRegAllocPass(true));
1936 addPass(&SILowerWWMCopiesLegacyID);
1937 addPass(createVirtRegRewriter(false));
1939
1940 // For allocating per-thread VGPRs.
1941 addPass(createVGPRAllocPass(true));
1942
1943 addPreRewrite();
1944 addPass(&VirtRegRewriterID);
1945
1947
1948 return true;
1949}
1950
1951void GCNPassConfig::addPostRegAlloc() {
1952 addPass(&SIFixVGPRCopiesID);
1953 if (getOptLevel() > CodeGenOptLevel::None)
1956}
1957
1958void GCNPassConfig::addPreSched2() {
1959 if (TM->getOptLevel() > CodeGenOptLevel::None)
1961 addPass(&SIPostRABundlerLegacyID);
1962}
1963
1964void GCNPassConfig::addPreEmitPass() {
1965 if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less))
1966 addPass(&GCNCreateVOPDID);
1967 addPass(createSIMemoryLegalizerPass());
1968 addPass(createSIInsertWaitcntsPass());
1969
1970 addPass(createSIModeRegisterPass());
1971
1972 if (getOptLevel() > CodeGenOptLevel::None)
1973 addPass(&SIInsertHardClausesID);
1974
1976 if (isPassEnabled(EnableSetWavePriority, CodeGenOptLevel::Less))
1978 if (getOptLevel() > CodeGenOptLevel::None)
1979 addPass(&SIPreEmitPeepholeID);
1980 // The hazard recognizer that runs as part of the post-ra scheduler does not
1981 // guarantee to be able handle all hazards correctly. This is because if there
1982 // are multiple scheduling regions in a basic block, the regions are scheduled
1983 // bottom up, so when we begin to schedule a region we don't know what
1984 // instructions were emitted directly before it.
1985 //
1986 // Here we add a stand-alone hazard recognizer pass which can handle all
1987 // cases.
1988 addPass(&PostRAHazardRecognizerID);
1989
1991
1993
1994 if (isPassEnabled(EnableInsertDelayAlu, CodeGenOptLevel::Less))
1995 addPass(&AMDGPUInsertDelayAluID);
1996
1997 addPass(&BranchRelaxationPassID);
1998}
1999
2000void GCNPassConfig::addPostBBSections() {
2001 // We run this later to avoid passes like livedebugvalues and BBSections
2002 // having to deal with the apparent multi-entry functions we may generate.
2004}
2005
2007 return new GCNPassConfig(*this, PM);
2008}
2009
2015
2022
2026
2033
2036 SMDiagnostic &Error, SMRange &SourceRange) const {
2037 const yaml::SIMachineFunctionInfo &YamlMFI =
2038 static_cast<const yaml::SIMachineFunctionInfo &>(MFI_);
2039 MachineFunction &MF = PFS.MF;
2041 const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
2042
2043 if (MFI->initializeBaseYamlFields(YamlMFI, MF, PFS, Error, SourceRange))
2044 return true;
2045
2046 if (MFI->Occupancy == 0) {
2047 // Fixup the subtarget dependent default value.
2048 MFI->Occupancy = ST.getOccupancyWithWorkGroupSizes(MF).second;
2049 }
2050
2051 auto parseRegister = [&](const yaml::StringValue &RegName, Register &RegVal) {
2052 Register TempReg;
2053 if (parseNamedRegisterReference(PFS, TempReg, RegName.Value, Error)) {
2054 SourceRange = RegName.SourceRange;
2055 return true;
2056 }
2057 RegVal = TempReg;
2058
2059 return false;
2060 };
2061
2062 auto parseOptionalRegister = [&](const yaml::StringValue &RegName,
2063 Register &RegVal) {
2064 return !RegName.Value.empty() && parseRegister(RegName, RegVal);
2065 };
2066
2067 if (parseOptionalRegister(YamlMFI.VGPRForAGPRCopy, MFI->VGPRForAGPRCopy))
2068 return true;
2069
2070 if (parseOptionalRegister(YamlMFI.SGPRForEXECCopy, MFI->SGPRForEXECCopy))
2071 return true;
2072
2073 if (parseOptionalRegister(YamlMFI.LongBranchReservedReg,
2074 MFI->LongBranchReservedReg))
2075 return true;
2076
2077 auto diagnoseRegisterClass = [&](const yaml::StringValue &RegName) {
2078 // Create a diagnostic for a the register string literal.
2079 const MemoryBuffer &Buffer =
2080 *PFS.SM->getMemoryBuffer(PFS.SM->getMainFileID());
2081 Error = SMDiagnostic(*PFS.SM, SMLoc(), Buffer.getBufferIdentifier(), 1,
2082 RegName.Value.size(), SourceMgr::DK_Error,
2083 "incorrect register class for field", RegName.Value,
2084 {}, {});
2085 SourceRange = RegName.SourceRange;
2086 return true;
2087 };
2088
2089 if (parseRegister(YamlMFI.ScratchRSrcReg, MFI->ScratchRSrcReg) ||
2090 parseRegister(YamlMFI.FrameOffsetReg, MFI->FrameOffsetReg) ||
2091 parseRegister(YamlMFI.StackPtrOffsetReg, MFI->StackPtrOffsetReg))
2092 return true;
2093
2094 if (MFI->ScratchRSrcReg != AMDGPU::PRIVATE_RSRC_REG &&
2095 !AMDGPU::SGPR_128RegClass.contains(MFI->ScratchRSrcReg)) {
2096 return diagnoseRegisterClass(YamlMFI.ScratchRSrcReg);
2097 }
2098
2099 if (MFI->FrameOffsetReg != AMDGPU::FP_REG &&
2100 !AMDGPU::SGPR_32RegClass.contains(MFI->FrameOffsetReg)) {
2101 return diagnoseRegisterClass(YamlMFI.FrameOffsetReg);
2102 }
2103
2104 if (MFI->StackPtrOffsetReg != AMDGPU::SP_REG &&
2105 !AMDGPU::SGPR_32RegClass.contains(MFI->StackPtrOffsetReg)) {
2106 return diagnoseRegisterClass(YamlMFI.StackPtrOffsetReg);
2107 }
2108
2109 for (const auto &YamlReg : YamlMFI.WWMReservedRegs) {
2110 Register ParsedReg;
2111 if (parseRegister(YamlReg, ParsedReg))
2112 return true;
2113
2114 MFI->reserveWWMRegister(ParsedReg);
2115 }
2116
2117 for (const auto &[_, Info] : PFS.VRegInfosNamed) {
2118 MFI->setFlag(Info->VReg, Info->Flags);
2119 }
2120 for (const auto &[_, Info] : PFS.VRegInfos) {
2121 MFI->setFlag(Info->VReg, Info->Flags);
2122 }
2123
2124 for (const auto &YamlRegStr : YamlMFI.SpillPhysVGPRS) {
2125 Register ParsedReg;
2126 if (parseRegister(YamlRegStr, ParsedReg))
2127 return true;
2128 MFI->SpillPhysVGPRs.push_back(ParsedReg);
2129 }
2130
2131 auto parseAndCheckArgument = [&](const std::optional<yaml::SIArgument> &A,
2132 const TargetRegisterClass &RC,
2133 ArgDescriptor &Arg, unsigned UserSGPRs,
2134 unsigned SystemSGPRs) {
2135 // Skip parsing if it's not present.
2136 if (!A)
2137 return false;
2138
2139 if (A->IsRegister) {
2140 Register Reg;
2141 if (parseNamedRegisterReference(PFS, Reg, A->RegisterName.Value, Error)) {
2142 SourceRange = A->RegisterName.SourceRange;
2143 return true;
2144 }
2145 if (!RC.contains(Reg))
2146 return diagnoseRegisterClass(A->RegisterName);
2148 } else
2149 Arg = ArgDescriptor::createStack(A->StackOffset);
2150 // Check and apply the optional mask.
2151 if (A->Mask)
2152 Arg = ArgDescriptor::createArg(Arg, *A->Mask);
2153
2154 MFI->NumUserSGPRs += UserSGPRs;
2155 MFI->NumSystemSGPRs += SystemSGPRs;
2156 return false;
2157 };
2158
2159 if (YamlMFI.ArgInfo &&
2160 (parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentBuffer,
2161 AMDGPU::SGPR_128RegClass,
2162 MFI->ArgInfo.PrivateSegmentBuffer, 4, 0) ||
2163 parseAndCheckArgument(YamlMFI.ArgInfo->DispatchPtr,
2164 AMDGPU::SReg_64RegClass, MFI->ArgInfo.DispatchPtr,
2165 2, 0) ||
2166 parseAndCheckArgument(YamlMFI.ArgInfo->QueuePtr, AMDGPU::SReg_64RegClass,
2167 MFI->ArgInfo.QueuePtr, 2, 0) ||
2168 parseAndCheckArgument(YamlMFI.ArgInfo->KernargSegmentPtr,
2169 AMDGPU::SReg_64RegClass,
2170 MFI->ArgInfo.KernargSegmentPtr, 2, 0) ||
2171 parseAndCheckArgument(YamlMFI.ArgInfo->DispatchID,
2172 AMDGPU::SReg_64RegClass, MFI->ArgInfo.DispatchID,
2173 2, 0) ||
2174 parseAndCheckArgument(YamlMFI.ArgInfo->FlatScratchInit,
2175 AMDGPU::SReg_64RegClass,
2176 MFI->ArgInfo.FlatScratchInit, 2, 0) ||
2177 parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentSize,
2178 AMDGPU::SGPR_32RegClass,
2179 MFI->ArgInfo.PrivateSegmentSize, 0, 0) ||
2180 parseAndCheckArgument(YamlMFI.ArgInfo->LDSKernelId,
2181 AMDGPU::SGPR_32RegClass,
2182 MFI->ArgInfo.LDSKernelId, 0, 1) ||
2183 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDX,
2184 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDX,
2185 0, 1) ||
2186 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDY,
2187 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDY,
2188 0, 1) ||
2189 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDZ,
2190 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDZ,
2191 0, 1) ||
2192 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupInfo,
2193 AMDGPU::SGPR_32RegClass,
2194 MFI->ArgInfo.WorkGroupInfo, 0, 1) ||
2195 parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentWaveByteOffset,
2196 AMDGPU::SGPR_32RegClass,
2197 MFI->ArgInfo.PrivateSegmentWaveByteOffset, 0, 1) ||
2198 parseAndCheckArgument(YamlMFI.ArgInfo->ImplicitArgPtr,
2199 AMDGPU::SReg_64RegClass,
2200 MFI->ArgInfo.ImplicitArgPtr, 0, 0) ||
2201 parseAndCheckArgument(YamlMFI.ArgInfo->ImplicitBufferPtr,
2202 AMDGPU::SReg_64RegClass,
2203 MFI->ArgInfo.ImplicitBufferPtr, 2, 0) ||
2204 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDX,
2205 AMDGPU::VGPR_32RegClass,
2206 MFI->ArgInfo.WorkItemIDX, 0, 0) ||
2207 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDY,
2208 AMDGPU::VGPR_32RegClass,
2209 MFI->ArgInfo.WorkItemIDY, 0, 0) ||
2210 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDZ,
2211 AMDGPU::VGPR_32RegClass,
2212 MFI->ArgInfo.WorkItemIDZ, 0, 0)))
2213 return true;
2214
2215 // Parse FirstKernArgPreloadReg separately, since it's a Register,
2216 // not ArgDescriptor.
2217 if (YamlMFI.ArgInfo && YamlMFI.ArgInfo->FirstKernArgPreloadReg) {
2218 const yaml::SIArgument &A = *YamlMFI.ArgInfo->FirstKernArgPreloadReg;
2219
2220 if (!A.IsRegister) {
2221 // For stack arguments, we don't have RegisterName.SourceRange,
2222 // but we should have some location info from the YAML parser
2223 const MemoryBuffer &Buffer =
2224 *PFS.SM->getMemoryBuffer(PFS.SM->getMainFileID());
2225 // Create a minimal valid source range
2227 SMRange Range(Loc, Loc);
2228
2230 *PFS.SM, Loc, Buffer.getBufferIdentifier(), 1, 0, SourceMgr::DK_Error,
2231 "firstKernArgPreloadReg must be a register, not a stack location", "",
2232 {}, {});
2233
2234 SourceRange = Range;
2235 return true;
2236 }
2237
2238 Register Reg;
2239 if (parseNamedRegisterReference(PFS, Reg, A.RegisterName.Value, Error)) {
2240 SourceRange = A.RegisterName.SourceRange;
2241 return true;
2242 }
2243
2244 if (!AMDGPU::SGPR_32RegClass.contains(Reg))
2245 return diagnoseRegisterClass(A.RegisterName);
2246
2247 MFI->ArgInfo.FirstKernArgPreloadReg = Reg;
2248 MFI->NumUserSGPRs += YamlMFI.NumKernargPreloadSGPRs;
2249 }
2250
2251 if (ST.hasFeature(AMDGPU::FeatureDX10ClampAndIEEEMode)) {
2252 MFI->Mode.IEEE = YamlMFI.Mode.IEEE;
2253 MFI->Mode.DX10Clamp = YamlMFI.Mode.DX10Clamp;
2254 }
2255
2256 // FIXME: Move proper support for denormal-fp-math into base MachineFunction
2257 MFI->Mode.FP32Denormals.Input = YamlMFI.Mode.FP32InputDenormals
2260 MFI->Mode.FP32Denormals.Output = YamlMFI.Mode.FP32OutputDenormals
2263
2270
2271 if (YamlMFI.HasInitWholeWave)
2272 MFI->setInitWholeWave();
2273
2274 return false;
2275}
2276
2277//===----------------------------------------------------------------------===//
2278// AMDGPU CodeGen Pass Builder interface.
2279//===----------------------------------------------------------------------===//
2280
2281AMDGPUCodeGenPassBuilder::AMDGPUCodeGenPassBuilder(
2282 GCNTargetMachine &TM, const CGPassBuilderOption &Opts,
2284 : CodeGenPassBuilder(TM, Opts, PIC) {
2285 Opt.MISchedPostRA = true;
2286 Opt.RequiresCodeGenSCCOrder = true;
2287 // Exceptions and StackMaps are not supported, so these passes will never do
2288 // anything.
2289 // Garbage collection is not supported.
2290 disablePass<StackMapLivenessPass, FuncletLayoutPass, PatchableFunctionPass,
2292}
2293
2294void AMDGPUCodeGenPassBuilder::addIRPasses(PassManagerWrapper &PMW) const {
2295 if (RemoveIncompatibleFunctions && TM.getTargetTriple().isAMDGCN()) {
2296 flushFPMsToMPM(PMW);
2297 addModulePass(AMDGPURemoveIncompatibleFunctionsPass(TM), PMW);
2298 }
2299
2300 flushFPMsToMPM(PMW);
2301
2302 if (TM.getTargetTriple().isAMDGCN())
2303 addModulePass(AMDGPUPrintfRuntimeBindingPass(), PMW);
2304
2305 if (LowerCtorDtor)
2306 addModulePass(AMDGPUCtorDtorLoweringPass(), PMW);
2307
2308 if (isPassEnabled(EnableImageIntrinsicOptimizer))
2309 addFunctionPass(AMDGPUImageIntrinsicOptimizerPass(TM), PMW);
2310
2312 addFunctionPass(AMDGPUUniformIntrinsicCombinePass(), PMW);
2313 // This can be disabled by passing ::Disable here or on the command line
2314 // with --expand-variadics-override=disable.
2315 flushFPMsToMPM(PMW);
2317
2318 addModulePass(AMDGPUAlwaysInlinePass(), PMW);
2319 addModulePass(AlwaysInlinerPass(), PMW);
2320
2321 addModulePass(AMDGPUExportKernelRuntimeHandlesPass(), PMW);
2322
2324 addModulePass(AMDGPULowerExecSyncPass(), PMW);
2325
2326 if (EnableSwLowerLDS)
2327 addModulePass(AMDGPUSwLowerLDSPass(), PMW);
2328
2329 // Runs before PromoteAlloca so the latter can account for function uses
2331 addModulePass(AMDGPULowerModuleLDSPass(TM), PMW);
2332
2333 // Run atomic optimizer before Atomic Expand
2334 if (TM.getOptLevel() >= CodeGenOptLevel::Less &&
2336 addFunctionPass(
2338
2339 addFunctionPass(AtomicExpandPass(TM), PMW);
2340
2341 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2342 addFunctionPass(AMDGPUPromoteAllocaPass(TM), PMW);
2343 if (isPassEnabled(EnableScalarIRPasses))
2344 addStraightLineScalarOptimizationPasses(PMW);
2345
2346 // TODO: Handle EnableAMDGPUAliasAnalysis
2347
2348 // TODO: May want to move later or split into an early and late one.
2349 addFunctionPass(AMDGPUCodeGenPreparePass(TM), PMW);
2350
2351 // Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may
2352 // have expanded.
2353 if (TM.getOptLevel() > CodeGenOptLevel::Less) {
2355 /*UseMemorySSA=*/true),
2356 PMW);
2357 }
2358 }
2359
2360 Base::addIRPasses(PMW);
2361
2362 // EarlyCSE is not always strong enough to clean up what LSR produces. For
2363 // example, GVN can combine
2364 //
2365 // %0 = add %a, %b
2366 // %1 = add %b, %a
2367 //
2368 // and
2369 //
2370 // %0 = shl nsw %a, 2
2371 // %1 = shl %a, 2
2372 //
2373 // but EarlyCSE can do neither of them.
2374 if (isPassEnabled(EnableScalarIRPasses))
2375 addEarlyCSEOrGVNPass(PMW);
2376}
2377
2378void AMDGPUCodeGenPassBuilder::addCodeGenPrepare(
2379 PassManagerWrapper &PMW) const {
2380 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2381 flushFPMsToMPM(PMW);
2382 addModulePass(AMDGPUPreloadKernelArgumentsPass(TM), PMW);
2383 }
2384
2386 addFunctionPass(AMDGPULowerKernelArgumentsPass(TM), PMW);
2387
2388 Base::addCodeGenPrepare(PMW);
2389
2390 if (isPassEnabled(EnableLoadStoreVectorizer))
2391 addFunctionPass(LoadStoreVectorizerPass(), PMW);
2392
2393 // This lowering has been placed after codegenprepare to take advantage of
2394 // address mode matching (which is why it isn't put with the LDS lowerings).
2395 // It could be placed anywhere before uniformity annotations (an analysis
2396 // that it changes by splitting up fat pointers into their components)
2397 // but has been put before switch lowering and CFG flattening so that those
2398 // passes can run on the more optimized control flow this pass creates in
2399 // many cases.
2400 flushFPMsToMPM(PMW);
2401 addModulePass(AMDGPULowerBufferFatPointersPass(TM), PMW);
2402 flushFPMsToMPM(PMW);
2403 requireCGSCCOrder(PMW);
2404
2405 addModulePass(AMDGPULowerIntrinsicsPass(TM), PMW);
2406
2407 // LowerSwitch pass may introduce unreachable blocks that can cause unexpected
2408 // behavior for subsequent passes. Placing it here seems better that these
2409 // blocks would get cleaned up by UnreachableBlockElim inserted next in the
2410 // pass flow.
2411 addFunctionPass(LowerSwitchPass(), PMW);
2412}
2413
2414void AMDGPUCodeGenPassBuilder::addPreISel(PassManagerWrapper &PMW) const {
2415
2416 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2417 addFunctionPass(FlattenCFGPass(), PMW);
2418 addFunctionPass(SinkingPass(), PMW);
2419 addFunctionPass(AMDGPULateCodeGenPreparePass(TM), PMW);
2420 }
2421
2422 // Merge divergent exit nodes. StructurizeCFG won't recognize the multi-exit
2423 // regions formed by them.
2424
2425 addFunctionPass(AMDGPUUnifyDivergentExitNodesPass(), PMW);
2426 addFunctionPass(FixIrreduciblePass(), PMW);
2427 addFunctionPass(UnifyLoopExitsPass(), PMW);
2428 addFunctionPass(StructurizeCFGPass(/*SkipUniformRegions=*/false), PMW);
2429
2430 addFunctionPass(AMDGPUAnnotateUniformValuesPass(), PMW);
2431
2432 addFunctionPass(SIAnnotateControlFlowPass(TM), PMW);
2433
2434 // TODO: Move this right after structurizeCFG to avoid extra divergence
2435 // analysis. This depends on stopping SIAnnotateControlFlow from making
2436 // control flow modifications.
2437 addFunctionPass(AMDGPURewriteUndefForPHIPass(), PMW);
2438
2441 !isGlobalISelAbortEnabled())
2442 addFunctionPass(LCSSAPass(), PMW);
2443
2444 if (TM.getOptLevel() > CodeGenOptLevel::Less) {
2445 flushFPMsToMPM(PMW);
2446 addModulePass(AMDGPUPerfHintAnalysisPass(TM), PMW);
2447 }
2448
2449 // FIXME: Why isn't this queried as required from AMDGPUISelDAGToDAG, and why
2450 // isn't this in addInstSelector?
2452 /*Force=*/true);
2453}
2454
2455void AMDGPUCodeGenPassBuilder::addILPOpts(PassManagerWrapper &PMW) const {
2457 addMachineFunctionPass(EarlyIfConverterPass(), PMW);
2458
2459 Base::addILPOpts(PMW);
2460}
2461
2462void AMDGPUCodeGenPassBuilder::addAsmPrinterBegin(
2463 PassManagerWrapper &PMW) const {
2464 addModulePass(AMDGPUAsmPrinterBeginPass(), PMW,
2465 /*Force=*/true);
2466}
2467
2468void AMDGPUCodeGenPassBuilder::addAsmPrinter(PassManagerWrapper &PMW) const {
2469 addMachineFunctionPass(AMDGPUAsmPrinterPass(), PMW);
2470}
2471
2472void AMDGPUCodeGenPassBuilder::addAsmPrinterEnd(PassManagerWrapper &PMW) const {
2473 addModulePass(AMDGPUAsmPrinterEndPass(), PMW);
2474}
2475
2476Error AMDGPUCodeGenPassBuilder::addInstSelector(PassManagerWrapper &PMW) const {
2477 addMachineFunctionPass(AMDGPUISelDAGToDAGPass(TM), PMW);
2478 addMachineFunctionPass(SIFixSGPRCopiesPass(), PMW);
2479 addMachineFunctionPass(SILowerI1CopiesPass(), PMW);
2480 return Error::success();
2481}
2482
2483void AMDGPUCodeGenPassBuilder::addPreRewrite(PassManagerWrapper &PMW) const {
2484 if (EnableRegReassign) {
2485 addMachineFunctionPass(GCNNSAReassignPass(), PMW);
2486 }
2487
2488 addMachineFunctionPass(AMDGPURewriteAGPRCopyMFMAPass(), PMW);
2489}
2490
2491void AMDGPUCodeGenPassBuilder::addMachineSSAOptimization(
2492 PassManagerWrapper &PMW) const {
2493 Base::addMachineSSAOptimization(PMW);
2494
2495 addMachineFunctionPass(SIFoldOperandsPass(), PMW);
2496 if (EnableDPPCombine) {
2497 addMachineFunctionPass(GCNDPPCombinePass(), PMW);
2498 }
2499 addMachineFunctionPass(SILoadStoreOptimizerPass(), PMW);
2500 if (isPassEnabled(EnableSDWAPeephole)) {
2501 addMachineFunctionPass(SIPeepholeSDWAPass(), PMW);
2502 addMachineFunctionPass(EarlyMachineLICMPass(), PMW);
2503 addMachineFunctionPass(MachineCSEPass(), PMW);
2504 addMachineFunctionPass(SIFoldOperandsPass(), PMW);
2505 }
2506 addMachineFunctionPass(DeadMachineInstructionElimPass(), PMW);
2507 addMachineFunctionPass(SIShrinkInstructionsPass(), PMW);
2508}
2509
2510Error AMDGPUCodeGenPassBuilder::addFastRegAlloc(PassManagerWrapper &PMW) const {
2511 insertPass<PHIEliminationPass>(SILowerControlFlowPass());
2512
2513 insertPass<TwoAddressInstructionPass>(SIWholeQuadModePass());
2514
2515 return Base::addFastRegAlloc(PMW);
2516}
2517
2518Error AMDGPUCodeGenPassBuilder::addRegAssignmentFast(
2519 PassManagerWrapper &PMW) const {
2520 if (auto Err = validateRegAllocOptions())
2521 return Err;
2522
2523 addMachineFunctionPass(GCNPreRALongBranchRegPass(), PMW);
2524
2525 // SGPR allocation - default to fast at -O0.
2526 if (SGPRRegAllocNPM == RegAllocType::Greedy)
2527 addMachineFunctionPass(RAGreedyPass({onlyAllocateSGPRs, "sgpr"}), PMW);
2528 else
2529 addMachineFunctionPass(RegAllocFastPass({onlyAllocateSGPRs, "sgpr", false}),
2530 PMW);
2531
2532 // Equivalent of PEI for SGPRs.
2533 addMachineFunctionPass(SILowerSGPRSpillsPass(), PMW);
2534
2535 // To Allocate wwm registers used in whole quad mode operations (for shaders).
2536 addMachineFunctionPass(SIPreAllocateWWMRegsPass(), PMW);
2537
2538 // WWM allocation - default to fast at -O0.
2539 if (WWMRegAllocNPM == RegAllocType::Greedy)
2540 addMachineFunctionPass(RAGreedyPass({onlyAllocateWWMRegs, "wwm"}), PMW);
2541 else
2542 addMachineFunctionPass(
2543 RegAllocFastPass({onlyAllocateWWMRegs, "wwm", false}), PMW);
2544
2545 addMachineFunctionPass(SILowerWWMCopiesPass(), PMW);
2546 addMachineFunctionPass(AMDGPUReserveWWMRegsPass(), PMW);
2547
2548 // VGPR allocation - default to fast at -O0.
2549 if (VGPRRegAllocNPM == RegAllocType::Greedy)
2550 addMachineFunctionPass(RAGreedyPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2551 else
2552 addMachineFunctionPass(RegAllocFastPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2553
2554 return Error::success();
2555}
2556
2557Error AMDGPUCodeGenPassBuilder::addOptimizedRegAlloc(
2558 PassManagerWrapper &PMW) const {
2559 if (EnableDCEInRA)
2560 insertPass<DetectDeadLanesPass>(DeadMachineInstructionElimPass());
2561
2562 // FIXME: when an instruction has a Killed operand, and the instruction is
2563 // inside a bundle, seems only the BUNDLE instruction appears as the Kills of
2564 // the register in LiveVariables, this would trigger a failure in verifier,
2565 // we should fix it and enable the verifier.
2566 if (OptVGPRLiveRange)
2567 insertPass<RequireAnalysisPass<LiveVariablesAnalysis, MachineFunction>>(
2569
2570 // This must be run immediately after phi elimination and before
2571 // TwoAddressInstructions, otherwise the processing of the tied operand of
2572 // SI_ELSE will introduce a copy of the tied operand source after the else.
2573 insertPass<PHIEliminationPass>(SILowerControlFlowPass());
2574
2576 insertPass<RenameIndependentSubregsPass>(GCNRewritePartialRegUsesPass());
2577
2578 if (isPassEnabled(EnablePreRAOptimizations))
2579 insertPass<MachineSchedulerPass>(GCNPreRAOptimizationsPass());
2580
2581 // Allow the scheduler to run before SIWholeQuadMode inserts exec manipulation
2582 // instructions that cause scheduling barriers.
2583 insertPass<MachineSchedulerPass>(SIWholeQuadModePass());
2584
2585 if (OptExecMaskPreRA)
2586 insertPass<MachineSchedulerPass>(SIOptimizeExecMaskingPreRAPass());
2587
2588 // This is not an essential optimization and it has a noticeable impact on
2589 // compilation time, so we only enable it from O2.
2590 if (TM.getOptLevel() > CodeGenOptLevel::Less)
2591 insertPass<MachineSchedulerPass>(SIFormMemoryClausesPass());
2592
2593 return Base::addOptimizedRegAlloc(PMW);
2594}
2595
2596void AMDGPUCodeGenPassBuilder::addPreRegAlloc(PassManagerWrapper &PMW) const {
2597 if (getOptLevel() != CodeGenOptLevel::None)
2598 addMachineFunctionPass(AMDGPUPrepareAGPRAllocPass(), PMW);
2599}
2600
2601Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
2602 PassManagerWrapper &PMW) const {
2603 if (auto Err = validateRegAllocOptions())
2604 return Err;
2605
2606 addMachineFunctionPass(GCNPreRALongBranchRegPass(), PMW);
2607
2608 // SGPR allocation - default to greedy at -O1 and above.
2609 if (SGPRRegAllocNPM == RegAllocType::Fast)
2610 addMachineFunctionPass(RegAllocFastPass({onlyAllocateSGPRs, "sgpr", false}),
2611 PMW);
2612 else
2613 addMachineFunctionPass(RAGreedyPass({onlyAllocateSGPRs, "sgpr"}), PMW);
2614
2615 // Commit allocated register changes. This is mostly necessary because too
2616 // many things rely on the use lists of the physical registers, such as the
2617 // verifier. This is only necessary with allocators which use LiveIntervals,
2618 // since FastRegAlloc does the replacements itself.
2619 addMachineFunctionPass(VirtRegRewriterPass(false), PMW);
2620
2621 // At this point, the sgpr-regalloc has been done and it is good to have the
2622 // stack slot coloring to try to optimize the SGPR spill stack indices before
2623 // attempting the custom SGPR spill lowering.
2624 addMachineFunctionPass(StackSlotColoringPass(), PMW);
2625
2626 // Equivalent of PEI for SGPRs.
2627 addMachineFunctionPass(SILowerSGPRSpillsPass(), PMW);
2628
2629 // To Allocate wwm registers used in whole quad mode operations (for shaders).
2630 addMachineFunctionPass(SIPreAllocateWWMRegsPass(), PMW);
2631
2632 // WWM allocation - default to greedy at -O1 and above.
2633 if (WWMRegAllocNPM == RegAllocType::Fast)
2634 addMachineFunctionPass(
2635 RegAllocFastPass({onlyAllocateWWMRegs, "wwm", false}), PMW);
2636 else
2637 addMachineFunctionPass(RAGreedyPass({onlyAllocateWWMRegs, "wwm"}), PMW);
2638 addMachineFunctionPass(SILowerWWMCopiesPass(), PMW);
2639 addMachineFunctionPass(VirtRegRewriterPass(false), PMW);
2640 addMachineFunctionPass(AMDGPUReserveWWMRegsPass(), PMW);
2641
2642 // VGPR allocation - default to greedy at -O1 and above.
2643 if (VGPRRegAllocNPM == RegAllocType::Fast)
2644 addMachineFunctionPass(RegAllocFastPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2645 else
2646 addMachineFunctionPass(RAGreedyPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2647
2648 addPreRewrite(PMW);
2649 addMachineFunctionPass(VirtRegRewriterPass(true), PMW);
2650
2651 addMachineFunctionPass(AMDGPUMarkLastScratchLoadPass(), PMW);
2652 return Error::success();
2653}
2654
2655void AMDGPUCodeGenPassBuilder::addPostRegAlloc(PassManagerWrapper &PMW) const {
2656 addMachineFunctionPass(SIFixVGPRCopiesPass(), PMW);
2657 if (TM.getOptLevel() > CodeGenOptLevel::None)
2658 addMachineFunctionPass(SIOptimizeExecMaskingPass(), PMW);
2659 Base::addPostRegAlloc(PMW);
2660}
2661
2662void AMDGPUCodeGenPassBuilder::addPreSched2(PassManagerWrapper &PMW) const {
2663 if (TM.getOptLevel() > CodeGenOptLevel::None)
2664 addMachineFunctionPass(SIShrinkInstructionsPass(), PMW);
2665 addMachineFunctionPass(SIPostRABundlerPass(), PMW);
2666}
2667
2668void AMDGPUCodeGenPassBuilder::addPostBBSections(
2669 PassManagerWrapper &PMW) const {
2670 // We run this later to avoid passes like livedebugvalues and BBSections
2671 // having to deal with the apparent multi-entry functions we may generate.
2672 addMachineFunctionPass(AMDGPUPreloadKernArgPrologPass(), PMW);
2673}
2674
2675void AMDGPUCodeGenPassBuilder::addPreEmitPass(PassManagerWrapper &PMW) const {
2676 if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less)) {
2677 addMachineFunctionPass(GCNCreateVOPDPass(), PMW);
2678 }
2679
2680 addMachineFunctionPass(SIMemoryLegalizerPass(), PMW);
2681 addMachineFunctionPass(SIInsertWaitcntsPass(), PMW);
2682
2683 addMachineFunctionPass(SIModeRegisterPass(), PMW);
2684
2685 if (TM.getOptLevel() > CodeGenOptLevel::None)
2686 addMachineFunctionPass(SIInsertHardClausesPass(), PMW);
2687
2688 addMachineFunctionPass(SILateBranchLoweringPass(), PMW);
2689
2690 if (isPassEnabled(EnableSetWavePriority, CodeGenOptLevel::Less))
2691 addMachineFunctionPass(AMDGPUSetWavePriorityPass(), PMW);
2692
2693 if (TM.getOptLevel() > CodeGenOptLevel::None)
2694 addMachineFunctionPass(SIPreEmitPeepholePass(), PMW);
2695
2696 // The hazard recognizer that runs as part of the post-ra scheduler does not
2697 // guarantee to be able handle all hazards correctly. This is because if there
2698 // are multiple scheduling regions in a basic block, the regions are scheduled
2699 // bottom up, so when we begin to schedule a region we don't know what
2700 // instructions were emitted directly before it.
2701 //
2702 // Here we add a stand-alone hazard recognizer pass which can handle all
2703 // cases.
2704 addMachineFunctionPass(PostRAHazardRecognizerPass(), PMW);
2705 addMachineFunctionPass(AMDGPUWaitSGPRHazardsPass(), PMW);
2706 addMachineFunctionPass(AMDGPULowerVGPREncodingPass(), PMW);
2707
2708 if (isPassEnabled(EnableInsertDelayAlu, CodeGenOptLevel::Less)) {
2709 addMachineFunctionPass(AMDGPUInsertDelayAluPass(), PMW);
2710 }
2711
2712 addMachineFunctionPass(BranchRelaxationPass(), PMW);
2713}
2714
2715bool AMDGPUCodeGenPassBuilder::isPassEnabled(const cl::opt<bool> &Opt,
2716 CodeGenOptLevel Level) const {
2717 if (Opt.getNumOccurrences())
2718 return Opt;
2719 if (TM.getOptLevel() < Level)
2720 return false;
2721 return Opt;
2722}
2723
2724void AMDGPUCodeGenPassBuilder::addEarlyCSEOrGVNPass(
2725 PassManagerWrapper &PMW) const {
2726 if (TM.getOptLevel() == CodeGenOptLevel::Aggressive)
2727 addFunctionPass(GVNPass(), PMW);
2728 else
2729 addFunctionPass(EarlyCSEPass(), PMW);
2730}
2731
2732void AMDGPUCodeGenPassBuilder::addStraightLineScalarOptimizationPasses(
2733 PassManagerWrapper &PMW) const {
2735 addFunctionPass(LoopDataPrefetchPass(), PMW);
2736
2737 addFunctionPass(SeparateConstOffsetFromGEPPass(), PMW);
2738
2739 // ReassociateGEPs exposes more opportunities for SLSR. See
2740 // the example in reassociate-geps-and-slsr.ll.
2741 addFunctionPass(StraightLineStrengthReducePass(), PMW);
2742
2743 // SeparateConstOffsetFromGEP and SLSR creates common expressions which GVN or
2744 // EarlyCSE can reuse.
2745 addEarlyCSEOrGVNPass(PMW);
2746
2747 // Run NaryReassociate after EarlyCSE/GVN to be more effective.
2748 addFunctionPass(NaryReassociatePass(), PMW);
2749
2750 // NaryReassociate on GEPs creates redundant common expressions, so run
2751 // EarlyCSE after it.
2752 addFunctionPass(EarlyCSEPass(), PMW);
2753}
aarch64 falkor hwpf fix Falkor HW Prefetch Fix Late Phase
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static cl::opt< bool > EnableEarlyIfConversion("aarch64-enable-early-ifcvt", cl::Hidden, cl::desc("Run early if-conversion"), cl::init(true))
static std::unique_ptr< TargetLoweringObjectFile > createTLOF(const Triple &TT)
This is the AMGPU address space based alias analysis pass.
AMDGPU Assembly printer class.
Coexecution-focused scheduling strategy for AMDGPU.
Defines an instruction selector for the AMDGPU target.
Analyzes if a function potentially memory bound and if a kernel kernel may benefit from limiting numb...
Analyzes how many registers and other resources are used by functions.
static cl::opt< bool > EnableDCEInRA("amdgpu-dce-in-ra", cl::init(true), cl::Hidden, cl::desc("Enable machine DCE inside regalloc"))
static cl::opt< bool, true > EnableLowerModuleLDS("amdgpu-enable-lower-module-lds", cl::desc("Enable lower module lds pass"), cl::location(AMDGPUTargetMachine::EnableLowerModuleLDS), cl::init(true), cl::Hidden)
static MachineSchedRegistry GCNMaxMemoryClauseSchedRegistry("gcn-max-memory-clause", "Run GCN scheduler to maximize memory clause", createGCNMaxMemoryClauseMachineScheduler)
static Reloc::Model getEffectiveRelocModel()
static cl::opt< bool > EnableUniformIntrinsicCombine("amdgpu-enable-uniform-intrinsic-combine", cl::desc("Enable/Disable the Uniform Intrinsic Combine Pass"), cl::init(true), cl::Hidden)
static MachineSchedRegistry SISchedRegistry("si", "Run SI's custom scheduler", createSIMachineScheduler)
static ScheduleDAGInstrs * createIterativeILPMachineScheduler(MachineSchedContext *C)
static cl::opt< bool > EarlyInlineAll("amdgpu-early-inline-all", cl::desc("Inline all functions early"), cl::init(false), cl::Hidden)
static OOBFlagValue getOOBFlagValue(const Module &M, StringRef FlagName)
Returns the OOB mode encoded by a module flag.
static cl::opt< bool > EnableSwLowerLDS("amdgpu-enable-sw-lower-lds", cl::desc("Enable lowering of lds to global memory pass " "and asan instrument resulting IR."), cl::init(true), cl::Hidden)
static cl::opt< bool > EnableLowerKernelArguments("amdgpu-ir-lower-kernel-arguments", cl::desc("Lower kernel argument loads in IR pass"), cl::init(true), cl::Hidden)
static cl::opt< bool, true > EnableObjectLinking("amdgpu-enable-object-linking", cl::desc("Enable object linking for cross-TU LDS and ABI support"), cl::location(AMDGPUTargetMachine::EnableObjectLinking), cl::init(false), cl::Hidden)
static ScheduleDAGInstrs * createGCNMaxILPMachineScheduler(MachineSchedContext *C)
static cl::opt< bool > EnableSDWAPeephole("amdgpu-sdwa-peephole", cl::desc("Enable SDWA peepholer"), cl::init(true))
static MachineSchedRegistry GCNMinRegSchedRegistry("gcn-iterative-minreg", "Run GCN iterative scheduler for minimal register usage (experimental)", createMinRegScheduler)
static void diagnoseUnsupportedCoExecSchedulerSelection(const Function &F, const GCNSubtarget &ST)
static cl::opt< bool > EnableImageIntrinsicOptimizer("amdgpu-enable-image-intrinsic-optimizer", cl::desc("Enable image intrinsic optimizer pass"), cl::init(true), cl::Hidden)
static cl::opt< bool > HasClosedWorldAssumption("amdgpu-link-time-closed-world", cl::desc("Whether has closed-world assumption at link time"), cl::init(false), cl::Hidden)
static bool useNoopPostScheduler(const Function &F)
static ScheduleDAGInstrs * createGCNMaxMemoryClauseMachineScheduler(MachineSchedContext *C)
static cl::opt< bool > EnableSIModeRegisterPass("amdgpu-mode-register", cl::desc("Enable mode register pass"), cl::init(true), cl::Hidden)
static cl::opt< std::string > AMDGPUSchedStrategy("amdgpu-sched-strategy", cl::desc("Select custom AMDGPU scheduling strategy."), cl::Hidden, cl::init(""))
static cl::opt< bool > EnableDPPCombine("amdgpu-dpp-combine", cl::desc("Enable DPP combiner"), cl::init(true))
static MachineSchedRegistry IterativeGCNMaxOccupancySchedRegistry("gcn-iterative-max-occupancy-experimental", "Run GCN scheduler to maximize occupancy (experimental)", createIterativeGCNMaxOccupancyMachineScheduler)
static cl::opt< bool > EnableSetWavePriority("amdgpu-set-wave-priority", cl::desc("Adjust wave priority"), cl::init(false), cl::Hidden)
static cl::opt< bool > LowerCtorDtor("amdgpu-lower-global-ctor-dtor", cl::desc("Lower GPU ctor / dtors to globals on the device."), cl::init(true), cl::Hidden)
static cl::opt< bool > OptExecMaskPreRA("amdgpu-opt-exec-mask-pre-ra", cl::Hidden, cl::desc("Run pre-RA exec mask optimizations"), cl::init(true))
static cl::opt< bool > EnablePromoteKernelArguments("amdgpu-enable-promote-kernel-arguments", cl::desc("Enable promotion of flat kernel pointer arguments to global"), cl::Hidden, cl::init(true))
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget()
static cl::opt< bool > EnableRewritePartialRegUses("amdgpu-enable-rewrite-partial-reg-uses", cl::desc("Enable rewrite partial reg uses pass"), cl::init(true), cl::Hidden)
static cl::opt< bool > EnableLibCallSimplify("amdgpu-simplify-libcall", cl::desc("Enable amdgpu library simplifications"), cl::init(true), cl::Hidden)
static MachineSchedRegistry GCNMaxILPSchedRegistry("gcn-max-ilp", "Run GCN scheduler to maximize ilp", createGCNMaxILPMachineScheduler)
static cl::opt< bool > InternalizeSymbols("amdgpu-internalize-symbols", cl::desc("Enable elimination of non-kernel functions and unused globals"), cl::init(false), cl::Hidden)
static cl::opt< bool > EnableAMDGPUAttributor("amdgpu-attributor-enable", cl::desc("Enable AMDGPUAttributorPass"), cl::init(true), cl::Hidden)
static LLVM_READNONE StringRef getGPUOrDefault(const Triple &TT, StringRef GPU)
Expected< AMDGPUAttributorOptions > parseAMDGPUAttributorPassOptions(StringRef Params)
static cl::opt< bool > EnableAMDGPUAliasAnalysis("enable-amdgpu-aa", cl::Hidden, cl::desc("Enable AMDGPU Alias Analysis"), cl::init(true))
static Expected< ScanOptions > parseAMDGPUAtomicOptimizerStrategy(StringRef Params)
static ScheduleDAGInstrs * createMinRegScheduler(MachineSchedContext *C)
static cl::opt< bool > EnableHipStdPar("amdgpu-enable-hipstdpar", cl::desc("Enable HIP Standard Parallelism Offload support"), cl::init(false), cl::Hidden)
static cl::opt< bool > EnableInsertDelayAlu("amdgpu-enable-delay-alu", cl::desc("Enable s_delay_alu insertion"), cl::init(true), cl::Hidden)
static ScheduleDAGInstrs * createIterativeGCNMaxOccupancyMachineScheduler(MachineSchedContext *C)
static cl::opt< bool > EnableLoadStoreVectorizer("amdgpu-load-store-vectorizer", cl::desc("Enable load store vectorizer"), cl::init(true), cl::Hidden)
static bool mustPreserveGV(const GlobalValue &GV)
Predicate for Internalize pass.
static cl::opt< bool > EnableLoopPrefetch("amdgpu-loop-prefetch", cl::desc("Enable loop data prefetch on AMDGPU"), cl::Hidden, cl::init(false))
static cl::opt< bool > RemoveIncompatibleFunctions("amdgpu-enable-remove-incompatible-functions", cl::Hidden, cl::desc("Enable removal of functions when they" "use features not supported by the target GPU"), cl::init(true))
static cl::opt< bool > EnableScalarIRPasses("amdgpu-scalar-ir-passes", cl::desc("Enable scalar IR passes"), cl::init(true), cl::Hidden)
static cl::opt< bool > EnableRegReassign("amdgpu-reassign-regs", cl::desc("Enable register reassign optimizations on gfx10+"), cl::init(true), cl::Hidden)
static cl::opt< bool > OptVGPRLiveRange("amdgpu-opt-vgpr-liverange", cl::desc("Enable VGPR liverange optimizations for if-else structure"), cl::init(true), cl::Hidden)
static ScheduleDAGInstrs * createSIMachineScheduler(MachineSchedContext *C)
static cl::opt< bool > EnablePreRAOptimizations("amdgpu-enable-pre-ra-optimizations", cl::desc("Enable Pre-RA optimizations pass"), cl::init(true), cl::Hidden)
static cl::opt< ScanOptions > AMDGPUAtomicOptimizerStrategy("amdgpu-atomic-optimizer-strategy", cl::desc("Select DPP or Iterative strategy for scan"), cl::init(ScanOptions::Iterative), cl::values(clEnumValN(ScanOptions::DPP, "DPP", "Use DPP operations for scan"), clEnumValN(ScanOptions::Iterative, "Iterative", "Use Iterative approach for scan"), clEnumValN(ScanOptions::None, "None", "Disable atomic optimizer")))
static cl::opt< bool > EnableVOPD("amdgpu-enable-vopd", cl::desc("Enable VOPD, dual issue of VALU in wave32"), cl::init(true), cl::Hidden)
static ScheduleDAGInstrs * createGCNMaxOccupancyMachineScheduler(MachineSchedContext *C)
static cl::opt< bool > EnableLowerExecSync("amdgpu-enable-lower-exec-sync", cl::desc("Enable lowering of execution synchronization."), cl::init(true), cl::Hidden)
static MachineSchedRegistry GCNILPSchedRegistry("gcn-iterative-ilp", "Run GCN iterative scheduler for ILP scheduling (experimental)", createIterativeILPMachineScheduler)
static cl::opt< bool > ScalarizeGlobal("amdgpu-scalarize-global-loads", cl::desc("Enable global load scalarization"), cl::init(true), cl::Hidden)
static const char RegAllocOptNotSupportedMessage[]
static MachineSchedRegistry GCNMaxOccupancySchedRegistry("gcn-max-occupancy", "Run GCN scheduler to maximize occupancy", createGCNMaxOccupancyMachineScheduler)
The AMDGPU TargetMachine interface definition for hw codegen targets.
This file declares the AMDGPU-specific subclass of TargetLoweringObjectFile.
This file a TargetTransformInfoImplBase conforming object specific to the AMDGPU target machine.
Provides passes to inlining "always_inline" functions.
#define X(NUM, ENUM, NAME)
Definition ELF.h:856
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
This header provides classes for managing passes over SCCs of the call graph.
Provides analysis for continuously CSEing during GISel passes.
Interfaces for producing common pass manager configurations.
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
#define LLVM_READNONE
Definition Compiler.h:317
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
DXIL Legalizer
This file provides the interface for a simple, fast CSE pass.
This file defines the class GCNIterativeScheduler, which uses an iterative approach to find a best sc...
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
#define _
AcceleratorCodeSelection - Identify all functions reachable from a kernel, removing those that are un...
This file declares the IRTranslator pass.
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
#define RegName(no)
This file provides the interface for LLVM's Loop Data Prefetching Pass.
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
#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
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
#define P(N)
CGSCCAnalysisManager CGAM
LoopAnalysisManager LAM
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
PassInstrumentationCallbacks PIC
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
static bool isLTOPreLink(ThinOrFullLTOPhase Phase)
The AMDGPU TargetMachine interface definition for hw codegen targets.
This file describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
SI Machine Scheduler interface.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition Value.cpp:484
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static FunctionPass * useDefaultRegisterAllocator()
-regalloc=... command line option.
static cl::opt< cl::boolOrDefault > EnableGlobalISelOption("global-isel", cl::Hidden, cl::desc("Enable the \"global\" instruction selector"))
Target-Independent Code Generator Pass Configuration Options pass.
LLVM IR instance of the generic uniformity analysis.
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
A manager for alias analyses.
void registerFunctionAnalysis()
Register a specific AA result.
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
Legacy wrapper pass to provide the AMDGPUAAResult object.
Analysis pass providing a never-invalidated alias analysis result.
Lower llvm.global_ctors and llvm.global_dtors to special kernels.
AMDGPUTargetMachine & getAMDGPUTargetMachine() const
std::unique_ptr< CSEConfigBase > getCSEConfig() const override
Returns the CSEConfig object to use for the current optimization level.
bool isPassEnabled(const cl::opt< bool > &Opt, CodeGenOptLevel Level=CodeGenOptLevel::Default) const
Check if a pass is enabled given Opt option.
bool addPreISel() override
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
bool addInstSelector() override
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
bool addGCPasses() override
addGCPasses - Add late codegen passes that analyze code for garbage collection.
AMDGPUPassConfig(TargetMachine &TM, PassManagerBase &PM)
void addIRPasses() override
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
void addCodeGenPrepare() override
Add pass to prepare the LLVM IR for code generation.
Splits the module M into N linkable partitions.
std::unique_ptr< TargetLoweringObjectFile > TLOF
unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const override
getAddressSpaceForPseudoSourceKind - Given the kind of memory (e.g.
const TargetSubtargetInfo * getSubtargetImpl() const
void registerDefaultAliasAnalyses(AAManager &) override
Allow the target to register alias analyses with the AAManager for use with the new pass manager.
std::pair< const Value *, unsigned > getPredicatedAddrSpace(const Value *V) const override
If the specified predicate checks whether a generic pointer falls within a specified address space,...
StringRef getFeatureString(const Function &F) const
ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const override
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
AMDGPUTargetMachine(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 isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override
Returns true if a cast between SrcAS and DestAS is a noop.
void registerPassBuilderCallbacks(PassBuilder &PB) override
Allow the target to modify the pass pipeline.
StringRef getGPUName(const Function &F) const
unsigned getAssumedAddrSpace(const Value *V) const override
If the specified generic pointer could be assumed as a pointer to a specific address space,...
bool splitModule(Module &M, unsigned NumParts, function_ref< void(std::unique_ptr< Module > MPart)> ModuleCallback) override
Entry point for module splitting.
Inlines functions marked as "always_inline".
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:105
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:261
This class provides access to building LLVM's passes.
CodeGenTargetMachineImpl(const Target &T, StringRef DataLayoutString, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
Diagnostic information for unsupported feature in backend.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Tagged union holding either a T or a Error.
Definition Error.h:485
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
LowerIntrinsics - This pass rewrites calls to the llvm.gcread or llvm.gcwrite intrinsics,...
Definition GCMetadata.h:229
const SIRegisterInfo * getRegisterInfo() const override
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
ScheduleDAGInstrs * createPostMachineScheduler(MachineSchedContext *C) const override
Similar to createMachineScheduler but used when postRA machine scheduling is enabled.
ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const override
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
void registerMachineRegisterInfoCallback(MachineFunction &MF) const override
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
Error buildCodeGenPipeline(ModulePassManager &MPM, ModuleAnalysisManager &MAM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, const CGPassBuilderOption &Opts, MCContext &Ctx, PassInstrumentationCallbacks *PIC) override
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
GCNTargetMachine(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)
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
The core GVN pass object.
Definition GVN.h:131
Pass to remove unused function declarations.
Definition GlobalDCE.h:38
This pass is responsible for selecting generic machine instructions to target-specific instructions.
A pass that internalizes all functions and variables other than those that must be preserved accordin...
Definition Internalize.h:37
Converts loops into loop-closed SSA form.
Definition LCSSA.h:38
Performs Loop Invariant Code Motion Pass.
Definition LICM.h:66
static void setUseExtended(bool Enable)
This pass implements the localization mechanism described at the top of this file.
Definition Localizer.h:43
An optimization pass inserting data prefetches in loops.
Context object for machine code objects.
Definition MCContext.h:83
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
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.
void addDelegate(Delegate *delegate)
const MachineFunction & getMF() const
MachineSchedRegistry provides a selection of available machine instruction schedulers.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
virtual StringRef getBufferIdentifier() const
Return an identifier for this buffer, typically the filename it was read from.
const char * getBufferStart() const
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
static LLVM_ABI const OptimizationLevel O0
Disable as many optimizations as possible.
static LLVM_ABI const OptimizationLevel O1
Optimize quickly without destroying debuggability.
This class provides access to building LLVM's passes.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
LLVM_ATTRIBUTE_MINSIZE std::enable_if_t<!std::is_same_v< PassT, PassManager > > addPass(PassT &&Pass)
PreservedAnalyses run(IRUnitT &IR, AnalysisManagerT &AM, ExtraArgTs... ExtraArgs)
Run all of the passes in this manager over the given unit of IR.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Pass interface - Implemented by all 'passes'.
Definition Pass.h:99
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
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
bool initializeBaseYamlFields(const yaml::SIMachineFunctionInfo &YamlMFI, const MachineFunction &MF, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange)
void setFlag(Register Reg, uint8_t Flag)
bool checkFlag(Register Reg, uint8_t Flag) const
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition SourceMgr.h:303
Represents a location in source code.
Definition SMLoc.h:22
static SMLoc getFromPointer(const char *Ptr)
Definition SMLoc.h:35
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...
void addMutation(std::unique_ptr< ScheduleDAGMutation > Mutation)
Add a postprocessing step to the DAG builder.
const TargetInstrInfo * TII
Target instruction information.
const TargetRegisterInfo * TRI
Target processor register info.
Move instructions into successor blocks when possible.
Definition Sink.h:24
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition SmallString.h:26
void append(StringRef RHS)
Append from a StringRef.
Definition SmallString.h:68
unsigned getMainFileID() const
Definition SourceMgr.h:151
const MemoryBuffer * getMemoryBuffer(unsigned i) const
Definition SourceMgr.h:144
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition StringRef.h:736
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
bool consume_front(char Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
Definition StringRef.h:661
A switch()-like statement whose cases are string literals.
StringSwitch & Cases(std::initializer_list< StringLiteral > CaseStrings, T Value)
Primary interface to the complete machine description for the target machine.
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
const Triple & getTargetTriple() const
const MCSubtargetInfo & getMCSubtargetInfo() const
StringRef getTargetFeatureString() const
StringRef getTargetCPU() const
std::unique_ptr< const MCSubtargetInfo > STI
TargetOptions Options
std::unique_ptr< const MCRegisterInfo > MRI
CodeGenOptLevel OptLevel
Target-Independent Code Generator Pass Configuration Options.
virtual void addCodeGenPrepare()
Add pass to prepare the LLVM IR for code generation.
virtual bool addILPOpts()
Add passes that optimize instruction level parallelism for out-of-order targets.
virtual void addPostRegAlloc()
This method may be implemented by targets that want to run passes after register allocation pass pipe...
CodeGenOptLevel getOptLevel() const
virtual void addOptimizedRegAlloc()
addOptimizedRegAlloc - Add passes related to register allocation.
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.
void disablePass(AnalysisID PassID)
Allow the target to disable a specific standard pass by default.
AnalysisID addPass(AnalysisID PassID)
Utilities for targets to add passes to the pass manager.
TargetPassConfig(TargetMachine &TM, PassManagerBase &PM)
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:47
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
LLVM Value Representation.
Definition Value.h:75
bool use_empty() const
Definition Value.h:346
int getNumOccurrences() const
An efficient, type-erasing, non-owning reference to a callable.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
An abstract base class for streams implementations that also support a pwrite operation.
Interfaces for registering analysis passes, producing common pass manager configurations,...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ LOCAL_ADDRESS
Address space for local memory.
@ CONSTANT_ADDRESS
Address space for constant memory (VTX2).
@ FLAT_ADDRESS
Address space for flat memory.
@ GLOBAL_ADDRESS
Address space for global memory (RAT0, VTX0).
@ PRIVATE_ADDRESS
Address space for private memory.
constexpr StringLiteral BufferFlag("amdgpu.buffer.oob.mode")
constexpr StringLiteral TBufferFlag("amdgpu.tbuffer.oob.mode")
StringRef getSchedStrategy(const Function &F)
GPUKind
GPU kinds supported by the AMDGPU target.
bool isFlatGlobalAddrSpace(unsigned AS)
LLVM_READNONE constexpr bool isModuleEntryFunctionCC(CallingConv::ID CC)
LLVM_READNONE constexpr bool isEntryFunctionCC(CallingConv::ID CC)
LLVM_ABI Triple::SubArchType getSubArch(GPUKind AK)
LLVM_ABI StringRef getArchNameFromSubArch(Triple::SubArchType SubArch)
Returns the canonical GPU name for an AMDGPU subarch, e.g.
LLVM_ABI GPUKind parseArchAMDGCN(StringRef CPU)
LLVM_ABI Triple::SubArchType getMajorSubArch(Triple::SubArchType SubArch)
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
BinaryOp_match< SrcTy, SpecificConstantMatch, TargetOpcode::G_XOR, true > m_Not(const SrcTy &&Src)
Matches a register not-ed by a G_XOR.
BinaryOp_match< LHS, RHS, Instruction::And, true > m_c_And(const LHS &L, const RHS &R)
Matches an And with LHS and RHS in either order.
bool match(Val *V, const Pattern &P)
match_deferred< Value > m_Deferred(Value *const &V)
Like m_Specific(), but works if the specific value to match is determined as part of the same match()...
auto m_Value()
Match an arbitrary value and ignore it.
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
template class LLVM_TEMPLATE_ABI opt< bool >
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
LocationClass< Ty > location(Ty &L)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract_or_null(Y &&MD)
Extract a Value from Metadata, if any, allowing null.
Definition Metadata.h:709
This is an optimization pass for GlobalISel generic memory operations.
ScheduleDAGMILive * createSchedLive(MachineSchedContext *C)
Create the standard converging machine scheduler.
LLVM_ABI FunctionPass * createFlattenCFGPass()
ModulePass * createAMDGPUSwLowerLDSLegacyPass()
std::unique_ptr< ScheduleDAGMutation > createAMDGPUBarrierLatencyDAGMutation(MachineFunction *MF)
LLVM_ABI FunctionPass * createFastRegisterAllocator()
FastRegisterAllocation Pass - This pass register allocates as fast as possible.
LLVM_ABI char & EarlyMachineLICMID
This pass performs loop invariant code motion on machine instructions.
ImmutablePass * createAMDGPUAAWrapperPass()
LLVM_ABI char & PostRAHazardRecognizerID
PostRAHazardRecognizer - This pass runs the post-ra hazard recognizer.
std::function< bool(const TargetRegisterInfo &TRI, const MachineRegisterInfo &MRI, const Register Reg)> RegAllocFilterFunc
Filter function for register classes during regalloc.
FunctionPass * createAMDGPUSetWavePriorityPass()
LLVM_ABI Pass * createLCSSAPass()
Definition LCSSA.cpp:525
void initializeAMDGPUMarkLastScratchLoadLegacyPass(PassRegistry &)
void initializeAMDGPUInsertDelayAluLegacyPass(PassRegistry &)
void initializeSIOptimizeExecMaskingPreRALegacyPass(PassRegistry &)
char & GCNPreRAOptimizationsID
LLVM_ABI char & GCLoweringID
GCLowering Pass - Used by gc.root to perform its default lowering operations.
void initializeSIInsertHardClausesLegacyPass(PassRegistry &)
FunctionPass * createSIAnnotateControlFlowLegacyPass()
Create the annotation pass.
FunctionPass * createSIModeRegisterPass()
void initializeGCNPreRAOptimizationsLegacyPass(PassRegistry &)
void initializeSILowerWWMCopiesLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createGreedyRegisterAllocator()
Greedy register allocation pass - This pass implements a global register allocator for optimized buil...
void initializeAMDGPUAAWrapperPassPass(PassRegistry &)
void initializeSIShrinkInstructionsLegacyPass(PassRegistry &)
ModulePass * createAMDGPULowerBufferFatPointersPass()
void initializeR600ClauseMergePassPass(PassRegistry &)
ModulePass * createAMDGPUCtorDtorLoweringLegacyPass()
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
ModuleToFunctionPassAdaptor createModuleToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
void initializeGCNRewritePartialRegUsesLegacyPass(llvm::PassRegistry &)
void initializeAMDGPURewriteUndefForPHILegacyPass(PassRegistry &)
char & GCNRewritePartialRegUsesID
void initializeAMDGPUSwLowerLDSLegacyPass(PassRegistry &)
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
void initializeAMDGPULowerVGPREncodingLegacyPass(PassRegistry &)
char & AMDGPUWaitSGPRHazardsLegacyID
void initializeSILowerSGPRSpillsLegacyPass(PassRegistry &)
LLVM_ABI Pass * createLoadStoreVectorizerPass()
Create a legacy pass manager instance of the LoadStoreVectorizer pass.
std::unique_ptr< ScheduleDAGMutation > createIGroupLPDAGMutation(AMDGPU::SchedulingPhase Phase)
Phase specifes whether or not this is a reentry into the IGroupLPDAGMutation.
void initializeAMDGPUDAGToDAGISelLegacyPass(PassRegistry &)
FunctionPass * createAMDGPURegBankCombiner(bool IsOptNone)
LLVM_ABI FunctionPass * createNaryReassociatePass()
char & AMDGPUReserveWWMRegsLegacyID
void initializeAMDGPUWaitSGPRHazardsLegacyPass(PassRegistry &)
LLVM_ABI char & PatchableFunctionID
This pass implements the "patchable-function" attribute.
char & SIOptimizeExecMaskingLegacyID
LLVM_ABI char & PostRASchedulerID
PostRAScheduler - This pass performs post register allocation scheduling.
void initializeAMDGPUNextUseAnalysisLegacyPassPass(PassRegistry &)
void initializeR600ExpandSpecialInstrsPassPass(PassRegistry &)
void initializeR600PacketizerPass(PassRegistry &)
std::unique_ptr< ScheduleDAGMutation > createVOPDPairingMutation()
ModulePass * createAMDGPUExportKernelRuntimeHandlesLegacyPass()
ModulePass * createAMDGPUAlwaysInlinePass(bool GlobalOpt=true)
void initializeAMDGPUAsmPrinterPass(PassRegistry &)
void initializeSIFoldOperandsLegacyPass(PassRegistry &)
char & SILoadStoreOptimizerLegacyID
void initializeAMDGPUGlobalISelDivergenceLoweringPass(PassRegistry &)
PassManager< LazyCallGraph::SCC, CGSCCAnalysisManager, LazyCallGraph &, CGSCCUpdateResult & > CGSCCPassManager
The CGSCC pass manager.
LLVM_ABI std::unique_ptr< CSEConfigBase > getStandardCSEConfigForOpt(CodeGenOptLevel Level)
Definition CSEInfo.cpp:85
Target & getTheR600Target()
The target for R600 GPUs.
LLVM_ABI char & MachineSchedulerID
MachineScheduler - This pass schedules machine instructions.
LLVM_ABI Pass * createStructurizeCFGPass(bool SkipUniformRegions=false)
When SkipUniformRegions is true the structizer will not structurize regions that only contain uniform...
LLVM_ABI char & PostMachineSchedulerID
PostMachineScheduler - This pass schedules machine instructions postRA.
LLVM_ABI Pass * createLICMPass()
Definition LICM.cpp:386
char & SIFormMemoryClausesID
void initializeSILoadStoreOptimizerLegacyPass(PassRegistry &)
void initializeAMDGPULowerModuleLDSLegacyPass(PassRegistry &)
AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager
The CGSCC analysis manager.
void initializeAMDGPUCtorDtorLoweringLegacyPass(PassRegistry &)
LLVM_ABI char & EarlyIfConverterLegacyID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions.
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
FunctionPass * createAMDGPUUniformIntrinsicCombineLegacyPass()
void initializeAMDGPURegBankCombinerPass(PassRegistry &)
ThinOrFullLTOPhase
This enumerates the LLVM full LTO or ThinLTO optimization phases.
Definition Pass.h:77
@ FullLTOPostLink
Full LTO postlink (backend compile) phase.
Definition Pass.h:87
char & AMDGPUUnifyDivergentExitNodesID
void initializeAMDGPUPrepareAGPRAllocLegacyPass(PassRegistry &)
FunctionPass * createAMDGPUAtomicOptimizerPass(ScanOptions ScanStrategy)
FunctionPass * createAMDGPUPreloadKernArgPrologLegacyPass()
char & SIOptimizeVGPRLiveRangeLegacyID
LLVM_ABI char & ShadowStackGCLoweringID
ShadowStackGCLowering - Implements the custom lowering mechanism used by the shadow stack GC.
char & GCNNSAReassignID
void initializeAMDGPURewriteOutArgumentsPass(PassRegistry &)
static Reloc::Model getEffectiveRelocModel(std::optional< Reloc::Model > RM)
void initializeAMDGPUExternalAAWrapperPass(PassRegistry &)
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
void initializeAMDGPULowerKernelArgumentsPass(PassRegistry &)
void initializeSIModeRegisterLegacyPass(PassRegistry &)
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.
void initializeAMDGPUPreloadKernelArgumentsLegacyPass(PassRegistry &)
LLVM_ABI ModulePass * createExpandVariadicsPass(ExpandVariadicsMode)
char & SILateBranchLoweringPassID
FunctionToLoopPassAdaptor createFunctionToLoopPassAdaptor(LoopPassT &&Pass, bool UseMemorySSA=false)
A function to deduce a loop pass type and wrap it in the templated adaptor.
LLVM_ABI char & BranchRelaxationPassID
BranchRelaxation - This pass replaces branches that need to jump further than is supported by a branc...
LLVM_ABI FunctionPass * createSinkingPass()
Definition Sink.cpp:275
CGSCCToFunctionPassAdaptor createCGSCCToFunctionPassAdaptor(FunctionPassT &&Pass, bool EagerlyInvalidate=false, bool NoRerun=false)
A function to deduce a function pass type and wrap it in the templated adaptor.
void initializeSIMemoryLegalizerLegacyPass(PassRegistry &)
ModulePass * createAMDGPULowerIntrinsicsLegacyPass()
void initializeR600MachineCFGStructurizerPass(PassRegistry &)
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition CodeGen.h:111
char & GCNDPPCombineLegacyID
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
LLVM_ABI std::unique_ptr< ScheduleDAGMutation > createStoreClusterDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI, bool ReorderWhileClustering=false)
If ReorderWhileClustering is set to true, no attempt will be made to reduce reordering due to store c...
LLVM_ABI FunctionPass * createLoopDataPrefetchPass()
FunctionPass * createAMDGPULowerKernelArgumentsPass()
char & AMDGPUInsertDelayAluID
std::unique_ptr< ScheduleDAGMutation > createAMDGPUMacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createAMDGPUMacroFusionDAGMutation()); to AMDGPUTargetMach...
LLVM_ABI char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...
void initializeGCNPreRALongBranchRegLegacyPass(PassRegistry &)
char & SILowerWWMCopiesLegacyID
LLVM_ABI FunctionPass * createUnifyLoopExitsPass()
char & SIOptimizeExecMaskingPreRAID
LLVM_ABI FunctionPass * createFixIrreduciblePass()
void initializeR600EmitClauseMarkersPass(PassRegistry &)
LLVM_ABI char & FuncletLayoutID
This pass lays out funclets contiguously.
LLVM_ABI char & DetectDeadLanesID
This pass adds dead/undef flags after analyzing subregister lanes.
void initializeAMDGPULowerExecSyncLegacyPass(PassRegistry &)
void initializeAMDGPUPostLegalizerCombinerPass(PassRegistry &)
ScheduleDAGInstrs * createGCNNoopPostMachineScheduler(MachineSchedContext *C)
void initializeAMDGPUExportKernelRuntimeHandlesLegacyPass(PassRegistry &)
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
void initializeSIInsertWaitcntsLegacyPass(PassRegistry &)
ModulePass * createAMDGPUPreloadKernelArgumentsLegacyPass(const TargetMachine *)
ModulePass * createAMDGPUPrintfRuntimeBinding()
LLVM_ABI char & StackSlotColoringID
StackSlotColoring - This pass performs stack slot coloring.
LLVM_ABI Pass * createAlwaysInlinerLegacyPass(bool InsertLifetime=true)
Create a legacy pass manager instance of a pass to inline and remove functions marked as "always_inli...
void initializeR600ControlFlowFinalizerPass(PassRegistry &)
void initializeAMDGPUImageIntrinsicOptimizerPass(PassRegistry &)
void initializeSILateBranchLoweringLegacyPass(PassRegistry &)
void initializeSILowerControlFlowLegacyPass(PassRegistry &)
void initializeSIFormMemoryClausesLegacyPass(PassRegistry &)
char & SIPreAllocateWWMRegsLegacyID
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
ModulePass * createAMDGPULowerModuleLDSLegacyPass(const AMDGPUTargetMachine *TM=nullptr)
void initializeAMDGPUPreLegalizerCombinerPass(PassRegistry &)
FunctionPass * createAMDGPUPromoteAlloca()
LLVM_ABI FunctionPass * createSeparateConstOffsetFromGEPPass(bool LowerGEP=false)
void initializeAMDGPUReserveWWMRegsLegacyPass(PassRegistry &)
char & SIPreEmitPeepholeID
char & SIPostRABundlerLegacyID
ModulePass * createAMDGPURemoveIncompatibleFunctionsPass(const TargetMachine *)
void initializeGCNRegPressurePrinterPass(PassRegistry &)
void initializeSILowerI1CopiesLegacyPass(PassRegistry &)
char & SILowerSGPRSpillsLegacyID
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.
char & SILowerControlFlowLegacyID
ModulePass * createR600OpenCLImageTypeLoweringPass()
FunctionPass * createAMDGPUCodeGenPreparePass()
void initializeSIAnnotateControlFlowLegacyPass(PassRegistry &)
FunctionPass * createAMDGPUISelDag(TargetMachine &TM, CodeGenOptLevel OptLevel)
This pass converts a legalized DAG into a AMDGPU-specific.
void initializeGCNCreateVOPDLegacyPass(PassRegistry &)
void initializeAMDGPUUniformIntrinsicCombineLegacyPass(PassRegistry &)
ScheduleDAGInstrs * createGCNCoExecMachineScheduler(MachineSchedContext *C)
void initializeSIPreAllocateWWMRegsLegacyPass(PassRegistry &)
void initializeSIFixVGPRCopiesLegacyPass(PassRegistry &)
Target & getTheGCNTarget()
The target for GCN GPUs.
void initializeSIFixSGPRCopiesLegacyPass(PassRegistry &)
void initializeAMDGPUAtomicOptimizerPass(PassRegistry &)
void initializeAMDGPULowerIntrinsicsLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createGVNPass()
Definition GVN.cpp:4070
void initializeAMDGPURewriteAGPRCopyMFMALegacyPass(PassRegistry &)
void initializeAMDGPUNextUseAnalysisPrinterLegacyPassPass(PassRegistry &)
void initializeSIPostRABundlerLegacyPass(PassRegistry &)
FunctionPass * createAMDGPURegBankSelectPass()
FunctionPass * createAMDGPURegBankLegalizePass()
LLVM_ABI char & MachineCSELegacyID
MachineCSE - This pass performs global CSE on machine instructions.
char & SIWholeQuadModeID
LLVM_ABI std::unique_ptr< ScheduleDAGMutation > createLoadClusterDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI, bool ReorderWhileClustering=false)
If ReorderWhileClustering is set to true, no attempt will be made to reduce reordering due to store c...
PassManager< Function > FunctionPassManager
Convenience typedef for a pass manager over functions.
LLVM_ABI char & LiveVariablesID
LiveVariables pass - This pass computes the set of blocks in which each variable is life and sets mac...
void initializeAMDGPUCodeGenPreparePass(PassRegistry &)
FunctionPass * createAMDGPURewriteUndefForPHILegacyPass()
void initializeSIOptimizeExecMaskingLegacyPass(PassRegistry &)
void call_once(once_flag &flag, Function &&F, Args &&... ArgList)
Execute the function specified as a parameter once.
Definition Threading.h:86
FunctionPass * createSILowerI1CopiesLegacyPass()
FunctionPass * createAMDGPUPostLegalizeCombiner(bool IsOptNone)
void initializeAMDGPULowerKernelAttributesPass(PassRegistry &)
char & SIInsertHardClausesID
char & SIFixSGPRCopiesLegacyID
void initializeGCNDPPCombineLegacyPass(PassRegistry &)
char & GCNCreateVOPDID
char & SIPeepholeSDWALegacyID
LLVM_ABI char & VirtRegRewriterID
VirtRegRewriter pass.
char & SIFixVGPRCopiesID
char & SIFoldOperandsLegacyID
void initializeGCNNSAReassignLegacyPass(PassRegistry &)
LLVM_ABI FunctionPass * createLowerSwitchPass()
void initializeAMDGPUPreloadKernArgPrologLegacyPass(PassRegistry &)
Target & getTheGCNLegacyTarget()
The target for GCN GPUs, registered under the legacy "amdgcn" architecture name for use with -march.
LLVM_ABI FunctionPass * createVirtRegRewriter(bool ClearVirtRegs=true)
void initializeR600VectorRegMergerPass(PassRegistry &)
char & AMDGPURewriteAGPRCopyMFMALegacyID
ModulePass * createAMDGPULowerExecSyncLegacyPass()
char & AMDGPULowerVGPREncodingLegacyID
FunctionPass * createAMDGPUGlobalISelDivergenceLoweringPass()
FunctionPass * createSIMemoryLegalizerPass()
void initializeAMDGPULateCodeGenPrepareLegacyPass(PassRegistry &)
void initializeSIOptimizeVGPRLiveRangeLegacyPass(PassRegistry &)
void initializeSIPeepholeSDWALegacyPass(PassRegistry &)
void initializeAMDGPURegBankLegalizePass(PassRegistry &)
LLVM_ABI char & TwoAddressInstructionPassID
TwoAddressInstruction - This pass reduces two-address instructions to use two operands.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
FunctionPass * createAMDGPUPreLegalizeCombiner(bool IsOptNone)
void initializeAMDGPURegBankSelectPass(PassRegistry &)
FunctionPass * createAMDGPULateCodeGenPrepareLegacyPass()
LLVM_ABI FunctionPass * createAtomicExpandLegacyPass()
AtomicExpandPass - At IR level this pass replace atomic instructions with __atomic_* library calls,...
MCRegisterInfo * createGCNMCRegisterInfo(AMDGPUDwarfFlavour DwarfFlavour)
LLVM_ABI FunctionPass * createStraightLineStrengthReducePass()
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:390
FunctionPass * createAMDGPUImageIntrinsicOptimizerPass(const TargetMachine *)
void initializeAMDGPULowerBufferFatPointersPass(PassRegistry &)
void initializeAMDGPUUnifyDivergentExitNodesLegacyPass(PassRegistry &)
FunctionPass * createSIInsertWaitcntsPass()
FunctionPass * createAMDGPUAnnotateUniformValuesLegacy()
LLVM_ABI FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
void initializeSIWholeQuadModeLegacyPass(PassRegistry &)
LLVM_ABI char & PHIEliminationID
PHIElimination - This pass eliminates machine instruction PHI nodes by inserting copy instructions.
LLVM_ABI llvm::cl::opt< bool > NoKernelInfoEndLTO
LLVM_ABI bool parseNamedRegisterReference(PerFunctionMIParsingState &PFS, Register &Reg, StringRef Src, SMDiagnostic &Error)
void initializeAMDGPUResourceUsageAnalysisWrapperPassPass(PassRegistry &)
FunctionPass * createSIShrinkInstructionsLegacyPass()
char & AMDGPUPrepareAGPRAllocLegacyID
char & AMDGPUMarkLastScratchLoadID
LLVM_ABI char & RenameIndependentSubregsID
This pass detects subregister lanes in a virtual register that are used independently of other lanes ...
void initializeAMDGPUAnnotateUniformValuesLegacyPass(PassRegistry &)
std::unique_ptr< ScheduleDAGMutation > createAMDGPUExportClusteringDAGMutation()
void initializeAMDGPUPrintfRuntimeBindingPass(PassRegistry &)
void initializeAMDGPUPromoteAllocaPass(PassRegistry &)
void initializeAMDGPURemoveIncompatibleFunctionsLegacyPass(PassRegistry &)
std::unique_ptr< ScheduleDAGMutation > createAMDGPUHazardLatencyDAGMutation(MachineFunction *MF)
void initializeAMDGPUAlwaysInlinePass(PassRegistry &)
LLVM_ABI char & DeadMachineInstructionElimID
DeadMachineInstructionElim - This pass removes dead machine instructions.
void initializeSIPreEmitPeepholeLegacyPass(PassRegistry &)
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
char & AMDGPUPerfHintAnalysisLegacyID
LLVM_ABI ImmutablePass * createExternalAAWrapperPass(std::function< void(Pass &, Function &, AAResults &)> Callback)
A wrapper pass around a callback which can be used to populate the AAResults in the AAResultsWrapperP...
char & GCNPreRALongBranchRegID
MCRegisterClass TargetRegisterClass
Definition FastISel.h:58
LLVM_ABI CGPassBuilderOption getCGPassBuilderOption()
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
Definition Error.cpp:177
void initializeAMDGPUPromoteKernelArgumentsPass(PassRegistry &)
#define N
static ArgDescriptor createStack(unsigned Offset, unsigned Mask=~0u)
static ArgDescriptor createArg(const ArgDescriptor &Arg, unsigned Mask)
static ArgDescriptor createRegister(Register Reg, unsigned Mask=~0u)
DenormalModeKind Input
Denormal treatment kind for floating point instruction inputs in the default floating-point environme...
@ PreserveSign
The sign of a flushed-to-zero number is preserved in the sign of 0.
@ IEEE
IEEE-754 denormal numbers preserved.
DenormalModeKind Output
Denormal flushing mode for floating point instruction results in the default floating point environme...
A simple and fast domtree-based CSE pass.
Definition EarlyCSE.h:31
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...
StringMap< VRegInfo * > VRegInfosNamed
Definition MIParser.h:180
DenseMap< Register, VRegInfo * > VRegInfos
Definition MIParser.h:179
RegisterTargetMachine - Helper template for registering a target machine implementation,...
A utility pass template to force an analysis result to be available.
bool DX10Clamp
Used by the vector ALU to force DX10-style treatment of NaNs: when set, clamp NaN to zero; otherwise,...
DenormalMode FP64FP16Denormals
If this is set, neither input or output denormals are flushed for both f64 and f16/v2f16 instructions...
bool IEEE
Floating point opcodes that support exception flag gathering quiet and propagate signaling NaN inputs...
DenormalMode FP32Denormals
If this is set, neither input or output denormals are flushed for most f32 instructions.
The llvm::once_flag structure.
Definition Threading.h:67
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
SmallVector< StringValue > WWMReservedRegs
std::optional< SIArgumentInfo > ArgInfo
SmallVector< StringValue, 2 > SpillPhysVGPRS
A wrapper around std::string which contains a source range that's being set during parsing.