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"
25#include "AMDGPUHazardLatency.h"
26#include "AMDGPUIGroupLP.h"
27#include "AMDGPUISelDAGToDAG.h"
29#include "AMDGPUMacroFusion.h"
37#include "AMDGPUSplitModule.h"
42#include "GCNDPPCombine.h"
44#include "GCNNSAReassign.h"
48#include "GCNSchedStrategy.h"
49#include "GCNVOPDUtils.h"
50#include "R600.h"
51#include "R600TargetMachine.h"
52#include "SIFixSGPRCopies.h"
53#include "SIFixVGPRCopies.h"
54#include "SIFoldOperands.h"
55#include "SIFormMemoryClauses.h"
57#include "SILowerControlFlow.h"
58#include "SILowerSGPRSpills.h"
59#include "SILowerWWMCopies.h"
61#include "SIMachineScheduler.h"
65#include "SIPeepholeSDWA.h"
66#include "SIPostRABundler.h"
69#include "SIWholeQuadMode.h"
90#include "llvm/CodeGen/Passes.h"
95#include "llvm/IR/IntrinsicsAMDGPU.h"
96#include "llvm/IR/Module.h"
97#include "llvm/IR/PassManager.h"
106#include "llvm/Transforms/IPO.h"
131#include <optional>
132
133using namespace llvm;
134using namespace llvm::PatternMatch;
135
136namespace {
137//===----------------------------------------------------------------------===//
138// AMDGPU CodeGen Pass Builder interface.
139//===----------------------------------------------------------------------===//
140
141class AMDGPUCodeGenPassBuilder
142 : public CodeGenPassBuilder<AMDGPUCodeGenPassBuilder, GCNTargetMachine> {
143 using Base = CodeGenPassBuilder<AMDGPUCodeGenPassBuilder, GCNTargetMachine>;
144
145public:
146 AMDGPUCodeGenPassBuilder(GCNTargetMachine &TM,
147 const CGPassBuilderOption &Opts,
148 PassInstrumentationCallbacks *PIC);
149
150 void addIRPasses(PassManagerWrapper &PMW) const;
151 void addCodeGenPrepare(PassManagerWrapper &PMW) const;
152 void addPreISel(PassManagerWrapper &PMW) const;
153 void addILPOpts(PassManagerWrapper &PMWM) const;
154 void addAsmPrinterBegin(PassManagerWrapper &PMW) const;
155 void addAsmPrinter(PassManagerWrapper &PMW) const;
156 void addAsmPrinterEnd(PassManagerWrapper &PMW) const;
157 Error addInstSelector(PassManagerWrapper &PMW) const;
158 void addPreRewrite(PassManagerWrapper &PMW) const;
159 void addMachineSSAOptimization(PassManagerWrapper &PMW) const;
160 void addPostRegAlloc(PassManagerWrapper &PMW) const;
161 void addPreEmitPass(PassManagerWrapper &PMWM) const;
162 void addPreEmitRegAlloc(PassManagerWrapper &PMW) const;
163 Error addRegAssignmentFast(PassManagerWrapper &PMW) const;
164 Error addRegAssignmentOptimized(PassManagerWrapper &PMW) const;
165 void addPreRegAlloc(PassManagerWrapper &PMW) const;
166 Error addFastRegAlloc(PassManagerWrapper &PMW) const;
167 Error addOptimizedRegAlloc(PassManagerWrapper &PMW) const;
168 void addPreSched2(PassManagerWrapper &PMW) const;
169 void addPostBBSections(PassManagerWrapper &PMW) const;
170
171private:
172 Error validateRegAllocOptions() const;
173
174public:
175 /// Check if a pass is enabled given \p Opt option. The option always
176 /// overrides defaults if explicitly used. Otherwise its default will be used
177 /// given that a pass shall work at an optimization \p Level minimum.
178 bool isPassEnabled(const cl::opt<bool> &Opt,
179 CodeGenOptLevel Level = CodeGenOptLevel::Default) const;
180 void addEarlyCSEOrGVNPass(PassManagerWrapper &PMW) const;
181 void addStraightLineScalarOptimizationPasses(PassManagerWrapper &PMW) const;
182};
183
184class SGPRRegisterRegAlloc : public RegisterRegAllocBase<SGPRRegisterRegAlloc> {
185public:
186 SGPRRegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
187 : RegisterRegAllocBase(N, D, C) {}
188};
189
190class VGPRRegisterRegAlloc : public RegisterRegAllocBase<VGPRRegisterRegAlloc> {
191public:
192 VGPRRegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
193 : RegisterRegAllocBase(N, D, C) {}
194};
195
196class WWMRegisterRegAlloc : public RegisterRegAllocBase<WWMRegisterRegAlloc> {
197public:
198 WWMRegisterRegAlloc(const char *N, const char *D, FunctionPassCtor C)
199 : RegisterRegAllocBase(N, D, C) {}
200};
201
202static bool onlyAllocateSGPRs(const TargetRegisterInfo &TRI,
203 const MachineRegisterInfo &MRI,
204 const Register Reg) {
205 const TargetRegisterClass *RC = MRI.getRegClass(Reg);
206 return static_cast<const SIRegisterInfo &>(TRI).isSGPRClass(RC);
207}
208
209static bool onlyAllocateVGPRs(const TargetRegisterInfo &TRI,
210 const MachineRegisterInfo &MRI,
211 const Register Reg) {
212 const TargetRegisterClass *RC = MRI.getRegClass(Reg);
213 return !static_cast<const SIRegisterInfo &>(TRI).isSGPRClass(RC);
214}
215
216static bool onlyAllocateWWMRegs(const TargetRegisterInfo &TRI,
217 const MachineRegisterInfo &MRI,
218 const Register Reg) {
219 const SIMachineFunctionInfo *MFI =
221 const TargetRegisterClass *RC = MRI.getRegClass(Reg);
222 return !static_cast<const SIRegisterInfo &>(TRI).isSGPRClass(RC) &&
224}
225
226/// -{sgpr|wwm|vgpr}-regalloc=... command line option.
227static FunctionPass *useDefaultRegisterAllocator() { return nullptr; }
228
229/// A dummy default pass factory indicates whether the register allocator is
230/// overridden on the command line.
231static llvm::once_flag InitializeDefaultSGPRRegisterAllocatorFlag;
232static llvm::once_flag InitializeDefaultVGPRRegisterAllocatorFlag;
233static llvm::once_flag InitializeDefaultWWMRegisterAllocatorFlag;
234
235static SGPRRegisterRegAlloc
236defaultSGPRRegAlloc("default",
237 "pick SGPR register allocator based on -O option",
239
240static cl::opt<SGPRRegisterRegAlloc::FunctionPassCtor, false,
242SGPRRegAlloc("sgpr-regalloc", cl::Hidden, cl::init(&useDefaultRegisterAllocator),
243 cl::desc("Register allocator to use for SGPRs"));
244
245static cl::opt<VGPRRegisterRegAlloc::FunctionPassCtor, false,
247VGPRRegAlloc("vgpr-regalloc", cl::Hidden, cl::init(&useDefaultRegisterAllocator),
248 cl::desc("Register allocator to use for VGPRs"));
249
250static cl::opt<WWMRegisterRegAlloc::FunctionPassCtor, false,
252 WWMRegAlloc("wwm-regalloc", cl::Hidden,
254 cl::desc("Register allocator to use for WWM registers"));
255
256// New pass manager register allocator options for AMDGPU
258 "sgpr-regalloc-npm", cl::Hidden, cl::init(RegAllocType::Default),
259 cl::desc("Register allocator for SGPRs (new pass manager)"));
260
262 "vgpr-regalloc-npm", cl::Hidden, cl::init(RegAllocType::Default),
263 cl::desc("Register allocator for VGPRs (new pass manager)"));
264
266 "wwm-regalloc-npm", cl::Hidden, cl::init(RegAllocType::Default),
267 cl::desc("Register allocator for WWM registers (new pass manager)"));
268
269/// Check if the given RegAllocType is supported for AMDGPU NPM register
270/// allocation. Only Fast and Greedy are supported; Basic and PBQP are not.
271static Error checkRegAllocSupported(RegAllocType RAType, StringRef RegName) {
272 if (RAType == RegAllocType::Basic || RAType == RegAllocType::PBQP) {
274 Twine("unsupported register allocator '") +
275 (RAType == RegAllocType::Basic ? "basic" : "pbqp") + "' for " +
276 RegName + " registers",
278 }
279 return Error::success();
280}
281
282Error AMDGPUCodeGenPassBuilder::validateRegAllocOptions() const {
283 // 1. Generic --regalloc-npm is not supported for AMDGPU.
284 if (Opt.RegAlloc != RegAllocType::Unset) {
286 "-regalloc-npm not supported for amdgcn. Use -sgpr-regalloc-npm, "
287 "-vgpr-regalloc-npm, and -wwm-regalloc-npm",
289 }
290
291 // 2. Legacy PM regalloc options are not compatible with NPM.
292 if (SGPRRegAlloc.getNumOccurrences() > 0 ||
293 VGPRRegAlloc.getNumOccurrences() > 0 ||
294 WWMRegAlloc.getNumOccurrences() > 0) {
296 "-sgpr-regalloc, -vgpr-regalloc, and -wwm-regalloc are legacy PM "
297 "options. Use -sgpr-regalloc-npm, -vgpr-regalloc-npm, and "
298 "-wwm-regalloc-npm with the new pass manager",
300 }
301
302 // 3. Only Fast and Greedy allocators are supported for AMDGPU.
303 if (auto Err = checkRegAllocSupported(SGPRRegAllocNPM, "SGPR"))
304 return Err;
305 if (auto Err = checkRegAllocSupported(WWMRegAllocNPM, "WWM"))
306 return Err;
307 if (auto Err = checkRegAllocSupported(VGPRRegAllocNPM, "VGPR"))
308 return Err;
309
310 return Error::success();
311}
312
313static void initializeDefaultSGPRRegisterAllocatorOnce() {
314 RegisterRegAlloc::FunctionPassCtor Ctor = SGPRRegisterRegAlloc::getDefault();
315
316 if (!Ctor) {
317 Ctor = SGPRRegAlloc;
318 SGPRRegisterRegAlloc::setDefault(SGPRRegAlloc);
319 }
320}
321
322static void initializeDefaultVGPRRegisterAllocatorOnce() {
323 RegisterRegAlloc::FunctionPassCtor Ctor = VGPRRegisterRegAlloc::getDefault();
324
325 if (!Ctor) {
326 Ctor = VGPRRegAlloc;
327 VGPRRegisterRegAlloc::setDefault(VGPRRegAlloc);
328 }
329}
330
331static void initializeDefaultWWMRegisterAllocatorOnce() {
332 RegisterRegAlloc::FunctionPassCtor Ctor = WWMRegisterRegAlloc::getDefault();
333
334 if (!Ctor) {
335 Ctor = WWMRegAlloc;
336 WWMRegisterRegAlloc::setDefault(WWMRegAlloc);
337 }
338}
339
340static FunctionPass *createBasicSGPRRegisterAllocator() {
341 return createBasicRegisterAllocator(onlyAllocateSGPRs);
342}
343
344static FunctionPass *createGreedySGPRRegisterAllocator() {
345 return createGreedyRegisterAllocator(onlyAllocateSGPRs);
346}
347
348static FunctionPass *createFastSGPRRegisterAllocator() {
349 return createFastRegisterAllocator(onlyAllocateSGPRs, false);
350}
351
352static FunctionPass *createBasicVGPRRegisterAllocator() {
353 return createBasicRegisterAllocator(onlyAllocateVGPRs);
354}
355
356static FunctionPass *createGreedyVGPRRegisterAllocator() {
357 return createGreedyRegisterAllocator(onlyAllocateVGPRs);
358}
359
360static FunctionPass *createFastVGPRRegisterAllocator() {
361 return createFastRegisterAllocator(onlyAllocateVGPRs, true);
362}
363
364static FunctionPass *createBasicWWMRegisterAllocator() {
365 return createBasicRegisterAllocator(onlyAllocateWWMRegs);
366}
367
368static FunctionPass *createGreedyWWMRegisterAllocator() {
369 return createGreedyRegisterAllocator(onlyAllocateWWMRegs);
370}
371
372static FunctionPass *createFastWWMRegisterAllocator() {
373 return createFastRegisterAllocator(onlyAllocateWWMRegs, false);
374}
375
376static SGPRRegisterRegAlloc basicRegAllocSGPR(
377 "basic", "basic register allocator", createBasicSGPRRegisterAllocator);
378static SGPRRegisterRegAlloc greedyRegAllocSGPR(
379 "greedy", "greedy register allocator", createGreedySGPRRegisterAllocator);
380
381static SGPRRegisterRegAlloc fastRegAllocSGPR(
382 "fast", "fast register allocator", createFastSGPRRegisterAllocator);
383
384
385static VGPRRegisterRegAlloc basicRegAllocVGPR(
386 "basic", "basic register allocator", createBasicVGPRRegisterAllocator);
387static VGPRRegisterRegAlloc greedyRegAllocVGPR(
388 "greedy", "greedy register allocator", createGreedyVGPRRegisterAllocator);
389
390static VGPRRegisterRegAlloc fastRegAllocVGPR(
391 "fast", "fast register allocator", createFastVGPRRegisterAllocator);
392static WWMRegisterRegAlloc basicRegAllocWWMReg("basic",
393 "basic register allocator",
394 createBasicWWMRegisterAllocator);
395static WWMRegisterRegAlloc
396 greedyRegAllocWWMReg("greedy", "greedy register allocator",
397 createGreedyWWMRegisterAllocator);
398static WWMRegisterRegAlloc fastRegAllocWWMReg("fast", "fast register allocator",
399 createFastWWMRegisterAllocator);
400
402 return Phase == ThinOrFullLTOPhase::FullLTOPreLink ||
403 Phase == ThinOrFullLTOPhase::ThinLTOPreLink;
404}
405} // anonymous namespace
406
407static cl::opt<bool>
409 cl::desc("Run early if-conversion"),
410 cl::init(false));
411
412static cl::opt<bool>
413OptExecMaskPreRA("amdgpu-opt-exec-mask-pre-ra", cl::Hidden,
414 cl::desc("Run pre-RA exec mask optimizations"),
415 cl::init(true));
416
417static cl::opt<bool>
418 LowerCtorDtor("amdgpu-lower-global-ctor-dtor",
419 cl::desc("Lower GPU ctor / dtors to globals on the device."),
420 cl::init(true), cl::Hidden);
421
422// Option to disable vectorizer for tests.
424 "amdgpu-load-store-vectorizer",
425 cl::desc("Enable load store vectorizer"),
426 cl::init(true),
427 cl::Hidden);
428
429// Option to control global loads scalarization
431 "amdgpu-scalarize-global-loads",
432 cl::desc("Enable global load scalarization"),
433 cl::init(true),
434 cl::Hidden);
435
436// Option to run internalize pass.
438 "amdgpu-internalize-symbols",
439 cl::desc("Enable elimination of non-kernel functions and unused globals"),
440 cl::init(false),
441 cl::Hidden);
442
443// Option to inline all early.
445 "amdgpu-early-inline-all",
446 cl::desc("Inline all functions early"),
447 cl::init(false),
448 cl::Hidden);
449
451 "amdgpu-enable-remove-incompatible-functions", cl::Hidden,
452 cl::desc("Enable removal of functions when they"
453 "use features not supported by the target GPU"),
454 cl::init(true));
455
457 "amdgpu-sdwa-peephole",
458 cl::desc("Enable SDWA peepholer"),
459 cl::init(true));
460
462 "amdgpu-dpp-combine",
463 cl::desc("Enable DPP combiner"),
464 cl::init(true));
465
466// Enable address space based alias analysis
468 cl::desc("Enable AMDGPU Alias Analysis"),
469 cl::init(true));
470
471// Enable lib calls simplifications
473 "amdgpu-simplify-libcall",
474 cl::desc("Enable amdgpu library simplifications"),
475 cl::init(true),
476 cl::Hidden);
477
479 "amdgpu-ir-lower-kernel-arguments",
480 cl::desc("Lower kernel argument loads in IR pass"),
481 cl::init(true),
482 cl::Hidden);
483
485 "amdgpu-reassign-regs",
486 cl::desc("Enable register reassign optimizations on gfx10+"),
487 cl::init(true),
488 cl::Hidden);
489
491 "amdgpu-opt-vgpr-liverange",
492 cl::desc("Enable VGPR liverange optimizations for if-else structure"),
493 cl::init(true), cl::Hidden);
494
496 "amdgpu-atomic-optimizer-strategy",
497 cl::desc("Select DPP or Iterative strategy for scan"),
500 clEnumValN(ScanOptions::DPP, "DPP", "Use DPP operations for scan"),
502 "Use Iterative approach for scan"),
503 clEnumValN(ScanOptions::None, "None", "Disable atomic optimizer")));
504
505// Enable Mode register optimization
507 "amdgpu-mode-register",
508 cl::desc("Enable mode register pass"),
509 cl::init(true),
510 cl::Hidden);
511
512// Enable GFX11+ s_delay_alu insertion
513static cl::opt<bool>
514 EnableInsertDelayAlu("amdgpu-enable-delay-alu",
515 cl::desc("Enable s_delay_alu insertion"),
516 cl::init(true), cl::Hidden);
517
518// Enable GFX11+ VOPD
519static cl::opt<bool>
520 EnableVOPD("amdgpu-enable-vopd",
521 cl::desc("Enable VOPD, dual issue of VALU in wave32"),
522 cl::init(true), cl::Hidden);
523
524// Option is used in lit tests to prevent deadcoding of patterns inspected.
525static cl::opt<bool>
526EnableDCEInRA("amdgpu-dce-in-ra",
527 cl::init(true), cl::Hidden,
528 cl::desc("Enable machine DCE inside regalloc"));
529
530static cl::opt<bool> EnableSetWavePriority("amdgpu-set-wave-priority",
531 cl::desc("Adjust wave priority"),
532 cl::init(false), cl::Hidden);
533
535 "amdgpu-scalar-ir-passes",
536 cl::desc("Enable scalar IR passes"),
537 cl::init(true),
538 cl::Hidden);
539
541 "amdgpu-enable-lower-exec-sync",
542 cl::desc("Enable lowering of execution synchronization."), cl::init(true),
543 cl::Hidden);
544
545static cl::opt<bool>
546 EnableSwLowerLDS("amdgpu-enable-sw-lower-lds",
547 cl::desc("Enable lowering of lds to global memory pass "
548 "and asan instrument resulting IR."),
549 cl::init(true), cl::Hidden);
550
552 "amdgpu-enable-object-linking",
553 cl::desc("Enable object linking for cross-TU LDS and ABI support"),
555 cl::Hidden);
556
558 "amdgpu-enable-lower-module-lds", cl::desc("Enable lower module lds pass"),
560 cl::Hidden);
561
563 "amdgpu-enable-pre-ra-optimizations",
564 cl::desc("Enable Pre-RA optimizations pass"), cl::init(true),
565 cl::Hidden);
566
568 "amdgpu-enable-promote-kernel-arguments",
569 cl::desc("Enable promotion of flat kernel pointer arguments to global"),
570 cl::Hidden, cl::init(true));
571
573 "amdgpu-enable-image-intrinsic-optimizer",
574 cl::desc("Enable image intrinsic optimizer pass"), cl::init(true),
575 cl::Hidden);
576
577static cl::opt<bool>
578 EnableLoopPrefetch("amdgpu-loop-prefetch",
579 cl::desc("Enable loop data prefetch on AMDGPU"),
580 cl::Hidden, cl::init(false));
581
583 AMDGPUSchedStrategy("amdgpu-sched-strategy",
584 cl::desc("Select custom AMDGPU scheduling strategy."),
585 cl::Hidden, cl::init(""));
586
587// Scheduler selection is consulted both when creating the scheduler and from
588// overrideSchedPolicy(), so keep the attribute and global command line handling
589// in one helper.
591 Attribute SchedStrategyAttr = F.getFnAttribute("amdgpu-sched-strategy");
592 if (SchedStrategyAttr.isValid())
593 return SchedStrategyAttr.getValueAsString();
594
595 if (!AMDGPUSchedStrategy.empty())
596 return AMDGPUSchedStrategy;
597
598 return "";
599}
600
601static void
603 const GCNSubtarget &ST) {
604 if (ST.hasGFX1250Insts())
605 return;
606
607 F.getContext().diagnose(DiagnosticInfoUnsupported(
608 F, "'amdgpu-sched-strategy'='coexec' is only supported for gfx1250",
610}
611
612static bool useNoopPostScheduler(const Function &F) {
613 Attribute PostSchedStrategyAttr =
614 F.getFnAttribute("amdgpu-post-sched-strategy");
615 return PostSchedStrategyAttr.isValid() &&
616 PostSchedStrategyAttr.getValueAsString() == "nop";
617}
618
620 "amdgpu-enable-rewrite-partial-reg-uses",
621 cl::desc("Enable rewrite partial reg uses pass"), cl::init(true),
622 cl::Hidden);
623
625 "amdgpu-enable-hipstdpar",
626 cl::desc("Enable HIP Standard Parallelism Offload support"), cl::init(false),
627 cl::Hidden);
628
629static cl::opt<bool>
630 EnableAMDGPUAttributor("amdgpu-attributor-enable",
631 cl::desc("Enable AMDGPUAttributorPass"),
632 cl::init(true), cl::Hidden);
633
635 "new-reg-bank-select",
636 cl::desc("Run amdgpu-regbankselect and amdgpu-regbanklegalize instead of "
637 "regbankselect"),
638 cl::init(false), cl::Hidden);
639
641 "amdgpu-link-time-closed-world",
642 cl::desc("Whether has closed-world assumption at link time"),
643 cl::init(false), cl::Hidden);
644
646 "amdgpu-enable-uniform-intrinsic-combine",
647 cl::desc("Enable/Disable the Uniform Intrinsic Combine Pass"),
648 cl::init(true), cl::Hidden);
649
651 // Register the target
654
740}
741
742static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
743 return std::make_unique<AMDGPUTargetObjectFile>();
744}
745
749
750static ScheduleDAGInstrs *
752 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
753 ScheduleDAGMILive *DAG =
754 new GCNScheduleDAGMILive(C, std::make_unique<GCNMaxOccupancySchedStrategy>(C));
755 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
756 if (ST.shouldClusterStores())
757 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
759 DAG->addMutation(createAMDGPUMacroFusionDAGMutation());
760 DAG->addMutation(createAMDGPUExportClusteringDAGMutation());
761 DAG->addMutation(createAMDGPUBarrierLatencyDAGMutation(C->MF));
762 DAG->addMutation(createAMDGPUHazardLatencyDAGMutation(C->MF));
763 return DAG;
764}
765
766static ScheduleDAGInstrs *
768 ScheduleDAGMILive *DAG =
769 new GCNScheduleDAGMILive(C, std::make_unique<GCNMaxILPSchedStrategy>(C));
771 return DAG;
772}
773
774static ScheduleDAGInstrs *
776 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
778 C, std::make_unique<GCNMaxMemoryClauseSchedStrategy>(C));
779 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
780 if (ST.shouldClusterStores())
781 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
782 DAG->addMutation(createAMDGPUExportClusteringDAGMutation());
783 DAG->addMutation(createAMDGPUBarrierLatencyDAGMutation(C->MF));
784 DAG->addMutation(createAMDGPUHazardLatencyDAGMutation(C->MF));
785 return DAG;
786}
787
788static ScheduleDAGInstrs *
790 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
791 auto *DAG = new GCNIterativeScheduler(
793 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
794 if (ST.shouldClusterStores())
795 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
797 return DAG;
798}
799
806
807static ScheduleDAGInstrs *
809 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
811 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
812 if (ST.shouldClusterStores())
813 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
814 DAG->addMutation(createAMDGPUMacroFusionDAGMutation());
816 return DAG;
817}
818
819static MachineSchedRegistry
820SISchedRegistry("si", "Run SI's custom scheduler",
822
825 "Run GCN scheduler to maximize occupancy",
827
829 GCNMaxILPSchedRegistry("gcn-max-ilp", "Run GCN scheduler to maximize ilp",
831
833 "gcn-max-memory-clause", "Run GCN scheduler to maximize memory clause",
835
837 "gcn-iterative-max-occupancy-experimental",
838 "Run GCN scheduler to maximize occupancy (experimental)",
840
842 "gcn-iterative-minreg",
843 "Run GCN iterative scheduler for minimal register usage (experimental)",
845
847 "gcn-iterative-ilp",
848 "Run GCN iterative scheduler for ILP scheduling (experimental)",
850
853 if (!GPU.empty())
854 return GPU;
855
856 // Need to default to a target with flat support for HSA.
857 if (TT.isAMDGCN())
858 return TT.getOS() == Triple::AMDHSA ? "generic-hsa" : "generic";
859
860 return "r600";
861}
862
864 // The AMDGPU toolchain only supports generating shared objects, so we
865 // must always use PIC.
866 return Reloc::PIC_;
867}
868
870 StringRef CPU, StringRef FS,
871 const TargetOptions &Options,
872 std::optional<Reloc::Model> RM,
873 std::optional<CodeModel::Model> CM,
876 T, TT.computeDataLayout(), TT, getGPUOrDefault(TT, CPU), FS, Options,
878 OptLevel),
880 initAsmInfo();
881 if (TT.isAMDGCN()) {
882 if (getMCSubtargetInfo().checkFeatures("+wavefrontsize64"))
884 else if (getMCSubtargetInfo().checkFeatures("+wavefrontsize32"))
886 }
887}
888
892
894
896 Attribute GPUAttr = F.getFnAttribute("target-cpu");
897 return GPUAttr.isValid() ? GPUAttr.getValueAsString() : getTargetCPU();
898}
899
901 Attribute FSAttr = F.getFnAttribute("target-features");
902
903 return FSAttr.isValid() ? FSAttr.getValueAsString()
905}
906
909 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
911 DAG->addMutation(createLoadClusterDAGMutation(DAG->TII, DAG->TRI));
912 if (ST.shouldClusterStores())
913 DAG->addMutation(createStoreClusterDAGMutation(DAG->TII, DAG->TRI));
914 return DAG;
915}
916
917/// Predicate for Internalize pass.
918static bool mustPreserveGV(const GlobalValue &GV) {
919 if (const Function *F = dyn_cast<Function>(&GV))
920 return F->isDeclaration() || F->getName().starts_with("__asan_") ||
921 F->getName().starts_with("__sanitizer_") ||
922 AMDGPU::isEntryFunctionCC(F->getCallingConv());
923
925 return !GV.use_empty();
926}
927
932
935 if (Params.empty())
937 Params.consume_front("strategy=");
938 auto Result = StringSwitch<std::optional<ScanOptions>>(Params)
939 .Case("dpp", ScanOptions::DPP)
940 .Cases({"iterative", ""}, ScanOptions::Iterative)
941 .Case("none", ScanOptions::None)
942 .Default(std::nullopt);
943 if (Result)
944 return *Result;
945 return make_error<StringError>("invalid parameter", inconvertibleErrorCode());
946}
947
951 while (!Params.empty()) {
952 StringRef ParamName;
953 std::tie(ParamName, Params) = Params.split(';');
954 if (ParamName == "closed-world") {
955 Result.IsClosedWorld = true;
956 } else {
958 formatv("invalid AMDGPUAttributor pass parameter '{0}' ", ParamName)
959 .str(),
961 }
962 }
963 return Result;
964}
965
967
968#define GET_PASS_REGISTRY "AMDGPUPassRegistry.def"
970
971 PB.registerPipelineParsingCallback(
972 [this](StringRef Name, CGSCCPassManager &PM,
974 if (Name == "amdgpu-attributor-cgscc" && getTargetTriple().isAMDGCN()) {
976 *static_cast<GCNTargetMachine *>(this)));
977 return true;
978 }
979 return false;
980 });
981
982 PB.registerScalarOptimizerLateEPCallback(
983 [](FunctionPassManager &FPM, OptimizationLevel Level) {
984 if (Level == OptimizationLevel::O0)
985 return;
986
988 });
989
990 PB.registerVectorizerEndEPCallback(
991 [](FunctionPassManager &FPM, OptimizationLevel Level) {
992 if (Level == OptimizationLevel::O0)
993 return;
994
996 });
997
998 PB.registerPipelineEarlySimplificationEPCallback(
999 [this](ModulePassManager &PM, OptimizationLevel Level,
1001 if (!isLTOPreLink(Phase) && getTargetTriple().isAMDGCN()) {
1002 // When we are not using -fgpu-rdc, we can run accelerator code
1003 // selection relatively early, but still after linking to prevent
1004 // eager removal of potentially reachable symbols.
1005 if (EnableHipStdPar) {
1008 }
1009
1011 }
1012
1013 if (Level == OptimizationLevel::O0)
1014 return;
1015
1016 // We don't want to run internalization at per-module stage.
1019 PM.addPass(GlobalDCEPass());
1020 }
1021
1024 });
1025
1026 PB.registerPeepholeEPCallback(
1027 [](FunctionPassManager &FPM, OptimizationLevel Level) {
1028 if (Level == OptimizationLevel::O0)
1029 return;
1030
1034
1037 });
1038
1039 PB.registerCGSCCOptimizerLateEPCallback(
1040 [this](CGSCCPassManager &PM, OptimizationLevel Level) {
1041 if (Level == OptimizationLevel::O0)
1042 return;
1043
1045
1046 // Add promote kernel arguments pass to the opt pipeline right before
1047 // infer address spaces which is needed to do actual address space
1048 // rewriting.
1049 if (Level.getSpeedupLevel() > OptimizationLevel::O1.getSpeedupLevel() &&
1052
1053 // Add infer address spaces pass to the opt pipeline after inlining
1054 // but before SROA to increase SROA opportunities.
1056
1057 // This should run after inlining to have any chance of doing
1058 // anything, and before other cleanup optimizations.
1060
1061 // Promote alloca to vector before SROA and loop unroll. If we
1062 // manage to eliminate allocas before unroll we may choose to unroll
1063 // less.
1065
1066 PM.addPass(createCGSCCToFunctionPassAdaptor(std::move(FPM)));
1067 });
1068
1069 // FIXME: Why is AMDGPUAttributor not in CGSCC?
1070 PB.registerOptimizerLastEPCallback([this](ModulePassManager &MPM,
1071 OptimizationLevel Level,
1073 if (Level != OptimizationLevel::O0) {
1074 if (!isLTOPreLink(Phase)) {
1075 if (EnableAMDGPUAttributor && getTargetTriple().isAMDGCN()) {
1077 MPM.addPass(AMDGPUAttributorPass(*this, Opts, Phase));
1078 }
1079 }
1080 }
1081 });
1082
1083 PB.registerFullLinkTimeOptimizationLastEPCallback(
1084 [this](ModulePassManager &PM, OptimizationLevel Level) {
1085 // When we are using -fgpu-rdc, we can only run accelerator code
1086 // selection after linking to prevent, otherwise we end up removing
1087 // potentially reachable symbols that were exported as external in other
1088 // modules.
1089 if (EnableHipStdPar) {
1092 }
1093 // We want to support the -lto-partitions=N option as "best effort".
1094 // For that, we need to lower LDS earlier in the pipeline before the
1095 // module is partitioned for codegen.
1098 if (EnableSwLowerLDS)
1099 PM.addPass(AMDGPUSwLowerLDSPass(*this));
1102 if (Level != OptimizationLevel::O0) {
1103 // We only want to run this with O2 or higher since inliner and SROA
1104 // don't run in O1.
1105 if (Level != OptimizationLevel::O1) {
1106 PM.addPass(
1108 }
1109 // Do we really need internalization in LTO?
1110 if (InternalizeSymbols) {
1112 PM.addPass(GlobalDCEPass());
1113 }
1114 if (EnableAMDGPUAttributor && getTargetTriple().isAMDGCN()) {
1117 Opt.IsClosedWorld = true;
1120 }
1121 }
1122 if (!NoKernelInfoEndLTO) {
1124 FPM.addPass(KernelInfoPrinter(this));
1125 PM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
1126 }
1127 });
1128
1129 PB.registerRegClassFilterParsingCallback(
1130 [](StringRef FilterName) -> RegAllocFilterFunc {
1131 if (FilterName == "sgpr")
1132 return onlyAllocateSGPRs;
1133 if (FilterName == "vgpr")
1134 return onlyAllocateVGPRs;
1135 if (FilterName == "wwm")
1136 return onlyAllocateWWMRegs;
1137 return nullptr;
1138 });
1139}
1140
1142 unsigned DestAS) const {
1143 return AMDGPU::isFlatGlobalAddrSpace(SrcAS) &&
1145}
1146
1148 if (auto *Arg = dyn_cast<Argument>(V);
1149 Arg &&
1150 AMDGPU::isModuleEntryFunctionCC(Arg->getParent()->getCallingConv()) &&
1151 !Arg->hasByRefAttr())
1153
1154 const auto *LD = dyn_cast<LoadInst>(V);
1155 if (!LD) // TODO: Handle invariant load like constant.
1157
1158 // It must be a generic pointer loaded.
1159 assert(V->getType()->getPointerAddressSpace() == AMDGPUAS::FLAT_ADDRESS);
1160
1161 const auto *Ptr = LD->getPointerOperand();
1162 if (Ptr->getType()->getPointerAddressSpace() != AMDGPUAS::CONSTANT_ADDRESS)
1164 // For a generic pointer loaded from the constant memory, it could be assumed
1165 // as a global pointer since the constant memory is only populated on the
1166 // host side. As implied by the offload programming model, only global
1167 // pointers could be referenced on the host side.
1169}
1170
1171std::pair<const Value *, unsigned>
1173 if (auto *II = dyn_cast<IntrinsicInst>(V)) {
1174 switch (II->getIntrinsicID()) {
1175 case Intrinsic::amdgcn_is_shared:
1176 return std::pair(II->getArgOperand(0), AMDGPUAS::LOCAL_ADDRESS);
1177 case Intrinsic::amdgcn_is_private:
1178 return std::pair(II->getArgOperand(0), AMDGPUAS::PRIVATE_ADDRESS);
1179 default:
1180 break;
1181 }
1182 return std::pair(nullptr, -1);
1183 }
1184 // Check the global pointer predication based on
1185 // (!is_share(p) && !is_private(p)). Note that logic 'and' is commutative and
1186 // the order of 'is_shared' and 'is_private' is not significant.
1187 Value *Ptr;
1188 if (match(
1189 const_cast<Value *>(V),
1192 m_Deferred(Ptr))))))
1193 return std::pair(Ptr, AMDGPUAS::GLOBAL_ADDRESS);
1194
1195 return std::pair(nullptr, -1);
1196}
1197
1198unsigned
1213
1215 Module &M, unsigned NumParts,
1216 function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback) {
1217 // FIXME(?): Would be better to use an already existing Analysis/PassManager,
1218 // but all current users of this API don't have one ready and would need to
1219 // create one anyway. Let's hide the boilerplate for now to keep it simple.
1220
1225
1226 PassBuilder PB(this);
1227 PB.registerModuleAnalyses(MAM);
1228 PB.registerFunctionAnalyses(FAM);
1229 PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
1230
1232 MPM.addPass(AMDGPUSplitModulePass(NumParts, ModuleCallback));
1233 MPM.run(M, MAM);
1234 return true;
1235}
1236
1237//===----------------------------------------------------------------------===//
1238// GCN Target Machine (SI+)
1239//===----------------------------------------------------------------------===//
1240
1242 StringRef CPU, StringRef FS,
1243 const TargetOptions &Options,
1244 std::optional<Reloc::Model> RM,
1245 std::optional<CodeModel::Model> CM,
1246 CodeGenOptLevel OL, bool JIT)
1247 : AMDGPUTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {}
1248
1249enum class OOBFlagValue {
1250 Any = 0,
1253};
1254
1255/// Returns the OOB mode encoded by a module flag.
1256/// An absent flag defaults to Any.
1257static OOBFlagValue getOOBFlagValue(const Module &M, StringRef FlagName) {
1258 const auto *Flag =
1259 mdconst::dyn_extract_or_null<ConstantInt>(M.getModuleFlag(FlagName));
1260 if (!Flag)
1261 return OOBFlagValue::Any;
1262 return static_cast<OOBFlagValue>(Flag->getZExtValue());
1263}
1264
1265const TargetSubtargetInfo *
1267 StringRef GPU = getGPUName(F);
1269
1270 const Module &M = *F.getParent();
1273 bool BufRelaxed = BufOOB == OOBFlagValue::Relaxed;
1274 bool TBufRelaxed = TBufOOB == OOBFlagValue::Relaxed;
1275 SmallString<128> SubtargetKey(GPU);
1276 SubtargetKey.append(FS);
1277 if (BufRelaxed)
1278 SubtargetKey.append(",buf-oob=1");
1279 if (TBufRelaxed)
1280 SubtargetKey.append(",tbuf-oob=1");
1281
1282 auto &I = SubtargetMap[SubtargetKey];
1283 if (!I) {
1284 // This needs to be done before we create a new subtarget since any
1285 // creation will depend on the TM and the code generation flags on the
1286 // function that reside in TargetOptions.
1288 I = std::make_unique<GCNSubtarget>(TargetTriple, GPU, FS, *this, BufRelaxed,
1289 TBufRelaxed);
1290 }
1291
1292 I->setScalarizeGlobalBehavior(ScalarizeGlobal);
1293
1294 return I.get();
1295}
1296
1299 return TargetTransformInfo(std::make_unique<GCNTTIImpl>(this, F));
1300}
1301
1304 raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
1305 const CGPassBuilderOption &Opts, MCContext &Ctx,
1307 AMDGPUCodeGenPassBuilder CGPB(*this, Opts, PIC);
1308 return CGPB.buildPipeline(MPM, MAM, Out, DwoOut, FileType, Ctx);
1309}
1310
1313 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
1314 if (ST.enableSIScheduler())
1316
1317 StringRef SchedStrategy = AMDGPU::getSchedStrategy(C->MF->getFunction());
1318
1319 if (SchedStrategy == "max-ilp")
1321
1322 if (SchedStrategy == "max-memory-clause")
1324
1325 if (SchedStrategy == "iterative-ilp")
1327
1328 if (SchedStrategy == "iterative-minreg")
1329 return createMinRegScheduler(C);
1330
1331 if (SchedStrategy == "iterative-maxocc")
1333
1334 if (SchedStrategy == "coexec") {
1335 diagnoseUnsupportedCoExecSchedulerSelection(C->MF->getFunction(), ST);
1337 }
1338
1340}
1341
1344 if (useNoopPostScheduler(C->MF->getFunction()))
1346
1347 ScheduleDAGMI *DAG =
1348 new GCNPostScheduleDAGMILive(C, std::make_unique<PostGenericScheduler>(C),
1349 /*RemoveKillFlags=*/true);
1350 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
1352 if (ST.shouldClusterStores())
1355 if ((EnableVOPD.getNumOccurrences() ||
1357 EnableVOPD)
1362 return DAG;
1363}
1364//===----------------------------------------------------------------------===//
1365// AMDGPU Legacy Pass Setup
1366//===----------------------------------------------------------------------===//
1367
1368std::unique_ptr<CSEConfigBase> llvm::AMDGPUPassConfig::getCSEConfig() const {
1369 return getStandardCSEConfigForOpt(TM->getOptLevel());
1370}
1371
1372namespace {
1373
1374class GCNPassConfig final : public AMDGPUPassConfig {
1375public:
1376 GCNPassConfig(TargetMachine &TM, PassManagerBase &PM)
1377 : AMDGPUPassConfig(TM, PM) {
1378 substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
1379 }
1380
1381 GCNTargetMachine &getGCNTargetMachine() const {
1382 return getTM<GCNTargetMachine>();
1383 }
1384
1385 bool addPreISel() override;
1386 void addMachineSSAOptimization() override;
1387 bool addILPOpts() override;
1388 bool addInstSelector() override;
1389 bool addIRTranslator() override;
1390 void addPreLegalizeMachineIR() override;
1391 bool addLegalizeMachineIR() override;
1392 void addPreRegBankSelect() override;
1393 bool addRegBankSelect() override;
1394 void addPreGlobalInstructionSelect() override;
1395 bool addGlobalInstructionSelect() override;
1396 void addPreRegAlloc() override;
1397 void addFastRegAlloc() override;
1398 void addOptimizedRegAlloc() override;
1399
1400 FunctionPass *createSGPRAllocPass(bool Optimized);
1401 FunctionPass *createVGPRAllocPass(bool Optimized);
1402 FunctionPass *createWWMRegAllocPass(bool Optimized);
1403 FunctionPass *createRegAllocPass(bool Optimized) override;
1404
1405 bool addRegAssignAndRewriteFast() override;
1406 bool addRegAssignAndRewriteOptimized() override;
1407
1408 bool addPreRewrite() override;
1409 void addPostRegAlloc() override;
1410 void addPreSched2() override;
1411 void addPreEmitPass() override;
1412 void addPostBBSections() override;
1413};
1414
1415} // end anonymous namespace
1416
1418 : TargetPassConfig(TM, PM) {
1419 // Exceptions and StackMaps are not supported, so these passes will never do
1420 // anything.
1423 // Garbage collection is not supported.
1426}
1427
1434
1439 // ReassociateGEPs exposes more opportunities for SLSR. See
1440 // the example in reassociate-geps-and-slsr.ll.
1442 // SeparateConstOffsetFromGEP and SLSR creates common expressions which GVN or
1443 // EarlyCSE can reuse.
1445 // Run NaryReassociate after EarlyCSE/GVN to be more effective.
1447 // NaryReassociate on GEPs creates redundant common expressions, so run
1448 // EarlyCSE after it.
1450}
1451
1454
1455 if (RemoveIncompatibleFunctions && TM.getTargetTriple().isAMDGCN())
1457
1458 // There is no reason to run these.
1462
1463 if (TM.getTargetTriple().isAMDGCN())
1465
1466 if (LowerCtorDtor)
1468
1469 if (TM.getTargetTriple().isAMDGCN() &&
1472
1475
1476 // This can be disabled by passing ::Disable here or on the command line
1477 // with --expand-variadics-override=disable.
1479
1480 // Function calls are not supported, so make sure we inline everything.
1483
1484 // Handle uses of OpenCL image2d_t, image3d_t and sampler_t arguments.
1485 if (TM.getTargetTriple().getArch() == Triple::r600)
1487
1488 // Make enqueued block runtime handles externally visible.
1490
1491 // Lower special LDS accesses.
1494
1495 // Lower LDS accesses to global memory pass if address sanitizer is enabled.
1496 if (EnableSwLowerLDS)
1498
1499 // Runs before PromoteAlloca so the latter can account for function uses
1502 }
1503
1504 // Run atomic optimizer before Atomic Expand
1505 if ((TM.getTargetTriple().isAMDGCN()) &&
1506 (TM.getOptLevel() >= CodeGenOptLevel::Less) &&
1509 }
1510
1512
1513 if (TM.getOptLevel() > CodeGenOptLevel::None) {
1515
1518
1522 AAResults &AAR) {
1523 if (auto *WrapperPass = P.getAnalysisIfAvailable<AMDGPUAAWrapperPass>())
1524 AAR.addAAResult(WrapperPass->getResult());
1525 }));
1526 }
1527
1528 if (TM.getTargetTriple().isAMDGCN()) {
1529 // TODO: May want to move later or split into an early and late one.
1531 }
1532
1533 // Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may
1534 // have expanded.
1535 if (TM.getOptLevel() > CodeGenOptLevel::Less)
1537 }
1538
1540
1541 // EarlyCSE is not always strong enough to clean up what LSR produces. For
1542 // example, GVN can combine
1543 //
1544 // %0 = add %a, %b
1545 // %1 = add %b, %a
1546 //
1547 // and
1548 //
1549 // %0 = shl nsw %a, 2
1550 // %1 = shl %a, 2
1551 //
1552 // but EarlyCSE can do neither of them.
1555}
1556
1558 if (TM->getTargetTriple().isAMDGCN() &&
1559 TM->getOptLevel() > CodeGenOptLevel::None)
1561
1562 if (TM->getTargetTriple().isAMDGCN() && EnableLowerKernelArguments)
1564
1566
1569
1570 if (TM->getTargetTriple().isAMDGCN()) {
1571 // This lowering has been placed after codegenprepare to take advantage of
1572 // address mode matching (which is why it isn't put with the LDS lowerings).
1573 // It could be placed anywhere before uniformity annotations (an analysis
1574 // that it changes by splitting up fat pointers into their components)
1575 // but has been put before switch lowering and CFG flattening so that those
1576 // passes can run on the more optimized control flow this pass creates in
1577 // many cases.
1580 }
1581
1582 // LowerSwitch pass may introduce unreachable blocks that can
1583 // cause unexpected behavior for subsequent passes. Placing it
1584 // here seems better that these blocks would get cleaned up by
1585 // UnreachableBlockElim inserted next in the pass flow.
1587}
1588
1590 if (TM->getOptLevel() > CodeGenOptLevel::None)
1592 return false;
1593}
1594
1599
1601 // Do nothing. GC is not supported.
1602 return false;
1603}
1604
1605//===----------------------------------------------------------------------===//
1606// GCN Legacy Pass Setup
1607//===----------------------------------------------------------------------===//
1608
1609bool GCNPassConfig::addPreISel() {
1611
1612 if (TM->getOptLevel() > CodeGenOptLevel::None) {
1613 addPass(createSinkingPass());
1615 }
1616
1617 // Merge divergent exit nodes. StructurizeCFG won't recognize the multi-exit
1618 // regions formed by them.
1620 addPass(createFixIrreduciblePass());
1621 addPass(createUnifyLoopExitsPass());
1622 addPass(createStructurizeCFGPass(false)); // true -> SkipUniformRegions
1623
1626 // TODO: Move this right after structurizeCFG to avoid extra divergence
1627 // analysis. This depends on stopping SIAnnotateControlFlow from making
1628 // control flow modifications.
1630
1631 // SDAG requires LCSSA, GlobalISel does not. Disable LCSSA for -global-isel
1632 // with -new-reg-bank-select and without any of the fallback options.
1634 !isGlobalISelAbortEnabled() || !NewRegBankSelect)
1635 addPass(createLCSSAPass());
1636
1637 if (TM->getOptLevel() > CodeGenOptLevel::Less)
1639
1640 return false;
1641}
1642
1643void GCNPassConfig::addMachineSSAOptimization() {
1645
1646 // We want to fold operands after PeepholeOptimizer has run (or as part of
1647 // it), because it will eliminate extra copies making it easier to fold the
1648 // real source operand. We want to eliminate dead instructions after, so that
1649 // we see fewer uses of the copies. We then need to clean up the dead
1650 // instructions leftover after the operands are folded as well.
1651 //
1652 // XXX - Can we get away without running DeadMachineInstructionElim again?
1653 addPass(&SIFoldOperandsLegacyID);
1654 if (EnableDPPCombine)
1655 addPass(&GCNDPPCombineLegacyID);
1657 if (isPassEnabled(EnableSDWAPeephole)) {
1658 addPass(&SIPeepholeSDWALegacyID);
1659 addPass(&EarlyMachineLICMID);
1660 addPass(&MachineCSELegacyID);
1661 addPass(&SIFoldOperandsLegacyID);
1662 }
1665}
1666
1667bool GCNPassConfig::addILPOpts() {
1669 addPass(&EarlyIfConverterLegacyID);
1670
1672 return false;
1673}
1674
1675bool GCNPassConfig::addInstSelector() {
1677 addPass(&SIFixSGPRCopiesLegacyID);
1679 return false;
1680}
1681
1682bool GCNPassConfig::addIRTranslator() {
1683 addPass(new IRTranslator(getOptLevel()));
1684 return false;
1685}
1686
1687void GCNPassConfig::addPreLegalizeMachineIR() {
1688 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1689 addPass(createAMDGPUPreLegalizeCombiner(IsOptNone));
1690 addPass(new Localizer());
1691}
1692
1693bool GCNPassConfig::addLegalizeMachineIR() {
1694 addPass(new Legalizer());
1695 return false;
1696}
1697
1698void GCNPassConfig::addPreRegBankSelect() {
1699 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1700 addPass(createAMDGPUPostLegalizeCombiner(IsOptNone));
1702}
1703
1704bool GCNPassConfig::addRegBankSelect() {
1705 if (NewRegBankSelect) {
1708 } else {
1709 addPass(new RegBankSelect());
1710 }
1711 return false;
1712}
1713
1714void GCNPassConfig::addPreGlobalInstructionSelect() {
1715 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1716 addPass(createAMDGPURegBankCombiner(IsOptNone));
1717}
1718
1719bool GCNPassConfig::addGlobalInstructionSelect() {
1720 addPass(new InstructionSelect(getOptLevel()));
1721 return false;
1722}
1723
1724void GCNPassConfig::addFastRegAlloc() {
1725 // FIXME: We have to disable the verifier here because of PHIElimination +
1726 // TwoAddressInstructions disabling it.
1727
1728 // This must be run immediately after phi elimination and before
1729 // TwoAddressInstructions, otherwise the processing of the tied operand of
1730 // SI_ELSE will introduce a copy of the tied operand source after the else.
1732
1734
1736}
1737
1738void GCNPassConfig::addPreRegAlloc() {
1739 if (getOptLevel() != CodeGenOptLevel::None)
1741}
1742
1743void GCNPassConfig::addOptimizedRegAlloc() {
1744 if (EnableDCEInRA)
1746
1747 // FIXME: when an instruction has a Killed operand, and the instruction is
1748 // inside a bundle, seems only the BUNDLE instruction appears as the Kills of
1749 // the register in LiveVariables, this would trigger a failure in verifier,
1750 // we should fix it and enable the verifier.
1751 if (OptVGPRLiveRange)
1753
1754 // This must be run immediately after phi elimination and before
1755 // TwoAddressInstructions, otherwise the processing of the tied operand of
1756 // SI_ELSE will introduce a copy of the tied operand source after the else.
1758
1761
1762 if (isPassEnabled(EnablePreRAOptimizations))
1764
1765 // Allow the scheduler to run before SIWholeQuadMode inserts exec manipulation
1766 // instructions that cause scheduling barriers.
1768
1769 if (OptExecMaskPreRA)
1771
1772 // This is not an essential optimization and it has a noticeable impact on
1773 // compilation time, so we only enable it from O2.
1774 if (TM->getOptLevel() > CodeGenOptLevel::Less)
1776
1778}
1779
1780bool GCNPassConfig::addPreRewrite() {
1782 addPass(&GCNNSAReassignID);
1783
1785 return true;
1786}
1787
1788FunctionPass *GCNPassConfig::createSGPRAllocPass(bool Optimized) {
1789 // Initialize the global default.
1790 llvm::call_once(InitializeDefaultSGPRRegisterAllocatorFlag,
1791 initializeDefaultSGPRRegisterAllocatorOnce);
1792
1793 RegisterRegAlloc::FunctionPassCtor Ctor = SGPRRegisterRegAlloc::getDefault();
1794 if (Ctor != useDefaultRegisterAllocator)
1795 return Ctor();
1796
1797 if (Optimized)
1798 return createGreedyRegisterAllocator(onlyAllocateSGPRs);
1799
1800 return createFastRegisterAllocator(onlyAllocateSGPRs, false);
1801}
1802
1803FunctionPass *GCNPassConfig::createVGPRAllocPass(bool Optimized) {
1804 // Initialize the global default.
1805 llvm::call_once(InitializeDefaultVGPRRegisterAllocatorFlag,
1806 initializeDefaultVGPRRegisterAllocatorOnce);
1807
1808 RegisterRegAlloc::FunctionPassCtor Ctor = VGPRRegisterRegAlloc::getDefault();
1809 if (Ctor != useDefaultRegisterAllocator)
1810 return Ctor();
1811
1812 if (Optimized)
1813 return createGreedyVGPRRegisterAllocator();
1814
1815 return createFastVGPRRegisterAllocator();
1816}
1817
1818FunctionPass *GCNPassConfig::createWWMRegAllocPass(bool Optimized) {
1819 // Initialize the global default.
1820 llvm::call_once(InitializeDefaultWWMRegisterAllocatorFlag,
1821 initializeDefaultWWMRegisterAllocatorOnce);
1822
1823 RegisterRegAlloc::FunctionPassCtor Ctor = WWMRegisterRegAlloc::getDefault();
1824 if (Ctor != useDefaultRegisterAllocator)
1825 return Ctor();
1826
1827 if (Optimized)
1828 return createGreedyWWMRegisterAllocator();
1829
1830 return createFastWWMRegisterAllocator();
1831}
1832
1833FunctionPass *GCNPassConfig::createRegAllocPass(bool Optimized) {
1834 llvm_unreachable("should not be used");
1835}
1836
1838 "-regalloc not supported with amdgcn. Use -sgpr-regalloc, -wwm-regalloc, "
1839 "and -vgpr-regalloc";
1840
1841bool GCNPassConfig::addRegAssignAndRewriteFast() {
1842 if (!usingDefaultRegAlloc())
1844
1845 addPass(&GCNPreRALongBranchRegID);
1846
1847 addPass(createSGPRAllocPass(false));
1848
1849 // Equivalent of PEI for SGPRs.
1850 addPass(&SILowerSGPRSpillsLegacyID);
1851
1852 // To Allocate wwm registers used in whole quad mode operations (for shaders).
1854
1855 // For allocating other wwm register operands.
1856 addPass(createWWMRegAllocPass(false));
1857
1858 addPass(&SILowerWWMCopiesLegacyID);
1860
1861 // For allocating per-thread VGPRs.
1862 addPass(createVGPRAllocPass(false));
1863
1864 return true;
1865}
1866
1867bool GCNPassConfig::addRegAssignAndRewriteOptimized() {
1868 if (!usingDefaultRegAlloc())
1870
1871 addPass(&GCNPreRALongBranchRegID);
1872
1873 addPass(createSGPRAllocPass(true));
1874
1875 // Commit allocated register changes. This is mostly necessary because too
1876 // many things rely on the use lists of the physical registers, such as the
1877 // verifier. This is only necessary with allocators which use LiveIntervals,
1878 // since FastRegAlloc does the replacements itself.
1879 addPass(createVirtRegRewriter(false));
1880
1881 // At this point, the sgpr-regalloc has been done and it is good to have the
1882 // stack slot coloring to try to optimize the SGPR spill stack indices before
1883 // attempting the custom SGPR spill lowering.
1884 addPass(&StackSlotColoringID);
1885
1886 // Equivalent of PEI for SGPRs.
1887 addPass(&SILowerSGPRSpillsLegacyID);
1888
1889 // To Allocate wwm registers used in whole quad mode operations (for shaders).
1891
1892 // For allocating other whole wave mode registers.
1893 addPass(createWWMRegAllocPass(true));
1894 addPass(&SILowerWWMCopiesLegacyID);
1895 addPass(createVirtRegRewriter(false));
1897
1898 // For allocating per-thread VGPRs.
1899 addPass(createVGPRAllocPass(true));
1900
1901 addPreRewrite();
1902 addPass(&VirtRegRewriterID);
1903
1905
1906 return true;
1907}
1908
1909void GCNPassConfig::addPostRegAlloc() {
1910 addPass(&SIFixVGPRCopiesID);
1911 if (getOptLevel() > CodeGenOptLevel::None)
1914}
1915
1916void GCNPassConfig::addPreSched2() {
1917 if (TM->getOptLevel() > CodeGenOptLevel::None)
1919 addPass(&SIPostRABundlerLegacyID);
1920}
1921
1922void GCNPassConfig::addPreEmitPass() {
1923 if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less))
1924 addPass(&GCNCreateVOPDID);
1925 addPass(createSIMemoryLegalizerPass());
1926 addPass(createSIInsertWaitcntsPass());
1927
1928 addPass(createSIModeRegisterPass());
1929
1930 if (getOptLevel() > CodeGenOptLevel::None)
1931 addPass(&SIInsertHardClausesID);
1932
1934 if (isPassEnabled(EnableSetWavePriority, CodeGenOptLevel::Less))
1936 if (getOptLevel() > CodeGenOptLevel::None)
1937 addPass(&SIPreEmitPeepholeID);
1938 // The hazard recognizer that runs as part of the post-ra scheduler does not
1939 // guarantee to be able handle all hazards correctly. This is because if there
1940 // are multiple scheduling regions in a basic block, the regions are scheduled
1941 // bottom up, so when we begin to schedule a region we don't know what
1942 // instructions were emitted directly before it.
1943 //
1944 // Here we add a stand-alone hazard recognizer pass which can handle all
1945 // cases.
1946 addPass(&PostRAHazardRecognizerID);
1947
1949
1951
1952 if (isPassEnabled(EnableInsertDelayAlu, CodeGenOptLevel::Less))
1953 addPass(&AMDGPUInsertDelayAluID);
1954
1955 addPass(&BranchRelaxationPassID);
1956}
1957
1958void GCNPassConfig::addPostBBSections() {
1959 // We run this later to avoid passes like livedebugvalues and BBSections
1960 // having to deal with the apparent multi-entry functions we may generate.
1962}
1963
1965 return new GCNPassConfig(*this, PM);
1966}
1967
1973
1980
1984
1991
1994 SMDiagnostic &Error, SMRange &SourceRange) const {
1995 const yaml::SIMachineFunctionInfo &YamlMFI =
1996 static_cast<const yaml::SIMachineFunctionInfo &>(MFI_);
1997 MachineFunction &MF = PFS.MF;
1999 const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
2000
2001 if (MFI->initializeBaseYamlFields(YamlMFI, MF, PFS, Error, SourceRange))
2002 return true;
2003
2004 if (MFI->Occupancy == 0) {
2005 // Fixup the subtarget dependent default value.
2006 MFI->Occupancy = ST.getOccupancyWithWorkGroupSizes(MF).second;
2007 }
2008
2009 auto parseRegister = [&](const yaml::StringValue &RegName, Register &RegVal) {
2010 Register TempReg;
2011 if (parseNamedRegisterReference(PFS, TempReg, RegName.Value, Error)) {
2012 SourceRange = RegName.SourceRange;
2013 return true;
2014 }
2015 RegVal = TempReg;
2016
2017 return false;
2018 };
2019
2020 auto parseOptionalRegister = [&](const yaml::StringValue &RegName,
2021 Register &RegVal) {
2022 return !RegName.Value.empty() && parseRegister(RegName, RegVal);
2023 };
2024
2025 if (parseOptionalRegister(YamlMFI.VGPRForAGPRCopy, MFI->VGPRForAGPRCopy))
2026 return true;
2027
2028 if (parseOptionalRegister(YamlMFI.SGPRForEXECCopy, MFI->SGPRForEXECCopy))
2029 return true;
2030
2031 if (parseOptionalRegister(YamlMFI.LongBranchReservedReg,
2032 MFI->LongBranchReservedReg))
2033 return true;
2034
2035 auto diagnoseRegisterClass = [&](const yaml::StringValue &RegName) {
2036 // Create a diagnostic for a the register string literal.
2037 const MemoryBuffer &Buffer =
2038 *PFS.SM->getMemoryBuffer(PFS.SM->getMainFileID());
2039 Error = SMDiagnostic(*PFS.SM, SMLoc(), Buffer.getBufferIdentifier(), 1,
2040 RegName.Value.size(), SourceMgr::DK_Error,
2041 "incorrect register class for field", RegName.Value,
2042 {}, {});
2043 SourceRange = RegName.SourceRange;
2044 return true;
2045 };
2046
2047 if (parseRegister(YamlMFI.ScratchRSrcReg, MFI->ScratchRSrcReg) ||
2048 parseRegister(YamlMFI.FrameOffsetReg, MFI->FrameOffsetReg) ||
2049 parseRegister(YamlMFI.StackPtrOffsetReg, MFI->StackPtrOffsetReg))
2050 return true;
2051
2052 if (MFI->ScratchRSrcReg != AMDGPU::PRIVATE_RSRC_REG &&
2053 !AMDGPU::SGPR_128RegClass.contains(MFI->ScratchRSrcReg)) {
2054 return diagnoseRegisterClass(YamlMFI.ScratchRSrcReg);
2055 }
2056
2057 if (MFI->FrameOffsetReg != AMDGPU::FP_REG &&
2058 !AMDGPU::SGPR_32RegClass.contains(MFI->FrameOffsetReg)) {
2059 return diagnoseRegisterClass(YamlMFI.FrameOffsetReg);
2060 }
2061
2062 if (MFI->StackPtrOffsetReg != AMDGPU::SP_REG &&
2063 !AMDGPU::SGPR_32RegClass.contains(MFI->StackPtrOffsetReg)) {
2064 return diagnoseRegisterClass(YamlMFI.StackPtrOffsetReg);
2065 }
2066
2067 for (const auto &YamlReg : YamlMFI.WWMReservedRegs) {
2068 Register ParsedReg;
2069 if (parseRegister(YamlReg, ParsedReg))
2070 return true;
2071
2072 MFI->reserveWWMRegister(ParsedReg);
2073 }
2074
2075 for (const auto &[_, Info] : PFS.VRegInfosNamed) {
2076 MFI->setFlag(Info->VReg, Info->Flags);
2077 }
2078 for (const auto &[_, Info] : PFS.VRegInfos) {
2079 MFI->setFlag(Info->VReg, Info->Flags);
2080 }
2081
2082 for (const auto &YamlRegStr : YamlMFI.SpillPhysVGPRS) {
2083 Register ParsedReg;
2084 if (parseRegister(YamlRegStr, ParsedReg))
2085 return true;
2086 MFI->SpillPhysVGPRs.push_back(ParsedReg);
2087 }
2088
2089 auto parseAndCheckArgument = [&](const std::optional<yaml::SIArgument> &A,
2090 const TargetRegisterClass &RC,
2091 ArgDescriptor &Arg, unsigned UserSGPRs,
2092 unsigned SystemSGPRs) {
2093 // Skip parsing if it's not present.
2094 if (!A)
2095 return false;
2096
2097 if (A->IsRegister) {
2098 Register Reg;
2099 if (parseNamedRegisterReference(PFS, Reg, A->RegisterName.Value, Error)) {
2100 SourceRange = A->RegisterName.SourceRange;
2101 return true;
2102 }
2103 if (!RC.contains(Reg))
2104 return diagnoseRegisterClass(A->RegisterName);
2106 } else
2107 Arg = ArgDescriptor::createStack(A->StackOffset);
2108 // Check and apply the optional mask.
2109 if (A->Mask)
2110 Arg = ArgDescriptor::createArg(Arg, *A->Mask);
2111
2112 MFI->NumUserSGPRs += UserSGPRs;
2113 MFI->NumSystemSGPRs += SystemSGPRs;
2114 return false;
2115 };
2116
2117 if (YamlMFI.ArgInfo &&
2118 (parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentBuffer,
2119 AMDGPU::SGPR_128RegClass,
2120 MFI->ArgInfo.PrivateSegmentBuffer, 4, 0) ||
2121 parseAndCheckArgument(YamlMFI.ArgInfo->DispatchPtr,
2122 AMDGPU::SReg_64RegClass, MFI->ArgInfo.DispatchPtr,
2123 2, 0) ||
2124 parseAndCheckArgument(YamlMFI.ArgInfo->QueuePtr, AMDGPU::SReg_64RegClass,
2125 MFI->ArgInfo.QueuePtr, 2, 0) ||
2126 parseAndCheckArgument(YamlMFI.ArgInfo->KernargSegmentPtr,
2127 AMDGPU::SReg_64RegClass,
2128 MFI->ArgInfo.KernargSegmentPtr, 2, 0) ||
2129 parseAndCheckArgument(YamlMFI.ArgInfo->DispatchID,
2130 AMDGPU::SReg_64RegClass, MFI->ArgInfo.DispatchID,
2131 2, 0) ||
2132 parseAndCheckArgument(YamlMFI.ArgInfo->FlatScratchInit,
2133 AMDGPU::SReg_64RegClass,
2134 MFI->ArgInfo.FlatScratchInit, 2, 0) ||
2135 parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentSize,
2136 AMDGPU::SGPR_32RegClass,
2137 MFI->ArgInfo.PrivateSegmentSize, 0, 0) ||
2138 parseAndCheckArgument(YamlMFI.ArgInfo->LDSKernelId,
2139 AMDGPU::SGPR_32RegClass,
2140 MFI->ArgInfo.LDSKernelId, 0, 1) ||
2141 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDX,
2142 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDX,
2143 0, 1) ||
2144 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDY,
2145 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDY,
2146 0, 1) ||
2147 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDZ,
2148 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDZ,
2149 0, 1) ||
2150 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupInfo,
2151 AMDGPU::SGPR_32RegClass,
2152 MFI->ArgInfo.WorkGroupInfo, 0, 1) ||
2153 parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentWaveByteOffset,
2154 AMDGPU::SGPR_32RegClass,
2155 MFI->ArgInfo.PrivateSegmentWaveByteOffset, 0, 1) ||
2156 parseAndCheckArgument(YamlMFI.ArgInfo->ImplicitArgPtr,
2157 AMDGPU::SReg_64RegClass,
2158 MFI->ArgInfo.ImplicitArgPtr, 0, 0) ||
2159 parseAndCheckArgument(YamlMFI.ArgInfo->ImplicitBufferPtr,
2160 AMDGPU::SReg_64RegClass,
2161 MFI->ArgInfo.ImplicitBufferPtr, 2, 0) ||
2162 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDX,
2163 AMDGPU::VGPR_32RegClass,
2164 MFI->ArgInfo.WorkItemIDX, 0, 0) ||
2165 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDY,
2166 AMDGPU::VGPR_32RegClass,
2167 MFI->ArgInfo.WorkItemIDY, 0, 0) ||
2168 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDZ,
2169 AMDGPU::VGPR_32RegClass,
2170 MFI->ArgInfo.WorkItemIDZ, 0, 0)))
2171 return true;
2172
2173 // Parse FirstKernArgPreloadReg separately, since it's a Register,
2174 // not ArgDescriptor.
2175 if (YamlMFI.ArgInfo && YamlMFI.ArgInfo->FirstKernArgPreloadReg) {
2176 const yaml::SIArgument &A = *YamlMFI.ArgInfo->FirstKernArgPreloadReg;
2177
2178 if (!A.IsRegister) {
2179 // For stack arguments, we don't have RegisterName.SourceRange,
2180 // but we should have some location info from the YAML parser
2181 const MemoryBuffer &Buffer =
2182 *PFS.SM->getMemoryBuffer(PFS.SM->getMainFileID());
2183 // Create a minimal valid source range
2185 SMRange Range(Loc, Loc);
2186
2188 *PFS.SM, Loc, Buffer.getBufferIdentifier(), 1, 0, SourceMgr::DK_Error,
2189 "firstKernArgPreloadReg must be a register, not a stack location", "",
2190 {}, {});
2191
2192 SourceRange = Range;
2193 return true;
2194 }
2195
2196 Register Reg;
2197 if (parseNamedRegisterReference(PFS, Reg, A.RegisterName.Value, Error)) {
2198 SourceRange = A.RegisterName.SourceRange;
2199 return true;
2200 }
2201
2202 if (!AMDGPU::SGPR_32RegClass.contains(Reg))
2203 return diagnoseRegisterClass(A.RegisterName);
2204
2205 MFI->ArgInfo.FirstKernArgPreloadReg = Reg;
2206 MFI->NumUserSGPRs += YamlMFI.NumKernargPreloadSGPRs;
2207 }
2208
2209 if (ST.hasFeature(AMDGPU::FeatureDX10ClampAndIEEEMode)) {
2210 MFI->Mode.IEEE = YamlMFI.Mode.IEEE;
2211 MFI->Mode.DX10Clamp = YamlMFI.Mode.DX10Clamp;
2212 }
2213
2214 // FIXME: Move proper support for denormal-fp-math into base MachineFunction
2215 MFI->Mode.FP32Denormals.Input = YamlMFI.Mode.FP32InputDenormals
2218 MFI->Mode.FP32Denormals.Output = YamlMFI.Mode.FP32OutputDenormals
2221
2228
2229 if (YamlMFI.HasInitWholeWave)
2230 MFI->setInitWholeWave();
2231
2232 return false;
2233}
2234
2235//===----------------------------------------------------------------------===//
2236// AMDGPU CodeGen Pass Builder interface.
2237//===----------------------------------------------------------------------===//
2238
2239AMDGPUCodeGenPassBuilder::AMDGPUCodeGenPassBuilder(
2240 GCNTargetMachine &TM, const CGPassBuilderOption &Opts,
2242 : CodeGenPassBuilder(TM, Opts, PIC) {
2243 Opt.MISchedPostRA = true;
2244 Opt.RequiresCodeGenSCCOrder = true;
2245 // Exceptions and StackMaps are not supported, so these passes will never do
2246 // anything.
2247 // Garbage collection is not supported.
2248 disablePass<StackMapLivenessPass, FuncletLayoutPass, PatchableFunctionPass,
2250}
2251
2252void AMDGPUCodeGenPassBuilder::addIRPasses(PassManagerWrapper &PMW) const {
2253 if (RemoveIncompatibleFunctions && TM.getTargetTriple().isAMDGCN()) {
2254 flushFPMsToMPM(PMW);
2255 addModulePass(AMDGPURemoveIncompatibleFunctionsPass(TM), PMW);
2256 }
2257
2258 flushFPMsToMPM(PMW);
2259
2260 if (TM.getTargetTriple().isAMDGCN())
2261 addModulePass(AMDGPUPrintfRuntimeBindingPass(), PMW);
2262
2263 if (LowerCtorDtor)
2264 addModulePass(AMDGPUCtorDtorLoweringPass(), PMW);
2265
2266 if (isPassEnabled(EnableImageIntrinsicOptimizer))
2267 addFunctionPass(AMDGPUImageIntrinsicOptimizerPass(TM), PMW);
2268
2270 addFunctionPass(AMDGPUUniformIntrinsicCombinePass(), PMW);
2271 // This can be disabled by passing ::Disable here or on the command line
2272 // with --expand-variadics-override=disable.
2273 flushFPMsToMPM(PMW);
2275
2276 addModulePass(AMDGPUAlwaysInlinePass(), PMW);
2277 addModulePass(AlwaysInlinerPass(), PMW);
2278
2279 addModulePass(AMDGPUExportKernelRuntimeHandlesPass(), PMW);
2280
2282 addModulePass(AMDGPULowerExecSyncPass(), PMW);
2283
2284 if (EnableSwLowerLDS)
2285 addModulePass(AMDGPUSwLowerLDSPass(TM), PMW);
2286
2287 // Runs before PromoteAlloca so the latter can account for function uses
2289 addModulePass(AMDGPULowerModuleLDSPass(TM), PMW);
2290
2291 // Run atomic optimizer before Atomic Expand
2292 if (TM.getOptLevel() >= CodeGenOptLevel::Less &&
2294 addFunctionPass(
2296
2297 addFunctionPass(AtomicExpandPass(TM), PMW);
2298
2299 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2300 addFunctionPass(AMDGPUPromoteAllocaPass(TM), PMW);
2301 if (isPassEnabled(EnableScalarIRPasses))
2302 addStraightLineScalarOptimizationPasses(PMW);
2303
2304 // TODO: Handle EnableAMDGPUAliasAnalysis
2305
2306 // TODO: May want to move later or split into an early and late one.
2307 addFunctionPass(AMDGPUCodeGenPreparePass(TM), PMW);
2308
2309 // Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may
2310 // have expanded.
2311 if (TM.getOptLevel() > CodeGenOptLevel::Less) {
2313 /*UseMemorySSA=*/true),
2314 PMW);
2315 }
2316 }
2317
2318 Base::addIRPasses(PMW);
2319
2320 // EarlyCSE is not always strong enough to clean up what LSR produces. For
2321 // example, GVN can combine
2322 //
2323 // %0 = add %a, %b
2324 // %1 = add %b, %a
2325 //
2326 // and
2327 //
2328 // %0 = shl nsw %a, 2
2329 // %1 = shl %a, 2
2330 //
2331 // but EarlyCSE can do neither of them.
2332 if (isPassEnabled(EnableScalarIRPasses))
2333 addEarlyCSEOrGVNPass(PMW);
2334}
2335
2336void AMDGPUCodeGenPassBuilder::addCodeGenPrepare(
2337 PassManagerWrapper &PMW) const {
2338 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2339 flushFPMsToMPM(PMW);
2340 addModulePass(AMDGPUPreloadKernelArgumentsPass(TM), PMW);
2341 }
2342
2344 addFunctionPass(AMDGPULowerKernelArgumentsPass(TM), PMW);
2345
2346 Base::addCodeGenPrepare(PMW);
2347
2348 if (isPassEnabled(EnableLoadStoreVectorizer))
2349 addFunctionPass(LoadStoreVectorizerPass(), PMW);
2350
2351 // This lowering has been placed after codegenprepare to take advantage of
2352 // address mode matching (which is why it isn't put with the LDS lowerings).
2353 // It could be placed anywhere before uniformity annotations (an analysis
2354 // that it changes by splitting up fat pointers into their components)
2355 // but has been put before switch lowering and CFG flattening so that those
2356 // passes can run on the more optimized control flow this pass creates in
2357 // many cases.
2358 flushFPMsToMPM(PMW);
2359 addModulePass(AMDGPULowerBufferFatPointersPass(TM), PMW);
2360 flushFPMsToMPM(PMW);
2361 requireCGSCCOrder(PMW);
2362
2363 addModulePass(AMDGPULowerIntrinsicsPass(TM), PMW);
2364
2365 // LowerSwitch pass may introduce unreachable blocks that can cause unexpected
2366 // behavior for subsequent passes. Placing it here seems better that these
2367 // blocks would get cleaned up by UnreachableBlockElim inserted next in the
2368 // pass flow.
2369 addFunctionPass(LowerSwitchPass(), PMW);
2370}
2371
2372void AMDGPUCodeGenPassBuilder::addPreISel(PassManagerWrapper &PMW) const {
2373
2374 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2375 addFunctionPass(FlattenCFGPass(), PMW);
2376 addFunctionPass(SinkingPass(), PMW);
2377 addFunctionPass(AMDGPULateCodeGenPreparePass(TM), PMW);
2378 }
2379
2380 // Merge divergent exit nodes. StructurizeCFG won't recognize the multi-exit
2381 // regions formed by them.
2382
2383 addFunctionPass(AMDGPUUnifyDivergentExitNodesPass(), PMW);
2384 addFunctionPass(FixIrreduciblePass(), PMW);
2385 addFunctionPass(UnifyLoopExitsPass(), PMW);
2386 addFunctionPass(StructurizeCFGPass(/*SkipUniformRegions=*/false), PMW);
2387
2388 addFunctionPass(AMDGPUAnnotateUniformValuesPass(), PMW);
2389
2390 addFunctionPass(SIAnnotateControlFlowPass(TM), PMW);
2391
2392 // TODO: Move this right after structurizeCFG to avoid extra divergence
2393 // analysis. This depends on stopping SIAnnotateControlFlow from making
2394 // control flow modifications.
2395 addFunctionPass(AMDGPURewriteUndefForPHIPass(), PMW);
2396
2398 !isGlobalISelAbortEnabled() || !NewRegBankSelect)
2399 addFunctionPass(LCSSAPass(), PMW);
2400
2401 if (TM.getOptLevel() > CodeGenOptLevel::Less) {
2402 flushFPMsToMPM(PMW);
2403 addModulePass(AMDGPUPerfHintAnalysisPass(TM), PMW);
2404 }
2405
2406 // FIXME: Why isn't this queried as required from AMDGPUISelDAGToDAG, and why
2407 // isn't this in addInstSelector?
2409 /*Force=*/true);
2410}
2411
2412void AMDGPUCodeGenPassBuilder::addILPOpts(PassManagerWrapper &PMW) const {
2414 addMachineFunctionPass(EarlyIfConverterPass(), PMW);
2415
2416 Base::addILPOpts(PMW);
2417}
2418
2419void AMDGPUCodeGenPassBuilder::addAsmPrinterBegin(
2420 PassManagerWrapper &PMW) const {
2421 // TODO: Add AsmPrinterBegin
2422}
2423
2424void AMDGPUCodeGenPassBuilder::addAsmPrinter(PassManagerWrapper &PMW) const {
2425 // TODO: Add AsmPrinter.
2426}
2427
2428void AMDGPUCodeGenPassBuilder::addAsmPrinterEnd(PassManagerWrapper &PMW) const {
2429 // TODO: Add AsmPrinterEnd
2430}
2431
2432Error AMDGPUCodeGenPassBuilder::addInstSelector(PassManagerWrapper &PMW) const {
2433 addMachineFunctionPass(AMDGPUISelDAGToDAGPass(TM), PMW);
2434 addMachineFunctionPass(SIFixSGPRCopiesPass(), PMW);
2435 addMachineFunctionPass(SILowerI1CopiesPass(), PMW);
2436 return Error::success();
2437}
2438
2439void AMDGPUCodeGenPassBuilder::addPreRewrite(PassManagerWrapper &PMW) const {
2440 if (EnableRegReassign) {
2441 addMachineFunctionPass(GCNNSAReassignPass(), PMW);
2442 }
2443
2444 addMachineFunctionPass(AMDGPURewriteAGPRCopyMFMAPass(), PMW);
2445}
2446
2447void AMDGPUCodeGenPassBuilder::addMachineSSAOptimization(
2448 PassManagerWrapper &PMW) const {
2449 Base::addMachineSSAOptimization(PMW);
2450
2451 addMachineFunctionPass(SIFoldOperandsPass(), PMW);
2452 if (EnableDPPCombine) {
2453 addMachineFunctionPass(GCNDPPCombinePass(), PMW);
2454 }
2455 addMachineFunctionPass(SILoadStoreOptimizerPass(), PMW);
2456 if (isPassEnabled(EnableSDWAPeephole)) {
2457 addMachineFunctionPass(SIPeepholeSDWAPass(), PMW);
2458 addMachineFunctionPass(EarlyMachineLICMPass(), PMW);
2459 addMachineFunctionPass(MachineCSEPass(), PMW);
2460 addMachineFunctionPass(SIFoldOperandsPass(), PMW);
2461 }
2462 addMachineFunctionPass(DeadMachineInstructionElimPass(), PMW);
2463 addMachineFunctionPass(SIShrinkInstructionsPass(), PMW);
2464}
2465
2466Error AMDGPUCodeGenPassBuilder::addFastRegAlloc(PassManagerWrapper &PMW) const {
2467 insertPass<PHIEliminationPass>(SILowerControlFlowPass());
2468
2469 insertPass<TwoAddressInstructionPass>(SIWholeQuadModePass());
2470
2471 return Base::addFastRegAlloc(PMW);
2472}
2473
2474Error AMDGPUCodeGenPassBuilder::addRegAssignmentFast(
2475 PassManagerWrapper &PMW) const {
2476 if (auto Err = validateRegAllocOptions())
2477 return Err;
2478
2479 addMachineFunctionPass(GCNPreRALongBranchRegPass(), PMW);
2480
2481 // SGPR allocation - default to fast at -O0.
2482 if (SGPRRegAllocNPM == RegAllocType::Greedy)
2483 addMachineFunctionPass(RAGreedyPass({onlyAllocateSGPRs, "sgpr"}), PMW);
2484 else
2485 addMachineFunctionPass(RegAllocFastPass({onlyAllocateSGPRs, "sgpr", false}),
2486 PMW);
2487
2488 // Equivalent of PEI for SGPRs.
2489 addMachineFunctionPass(SILowerSGPRSpillsPass(), PMW);
2490
2491 // To Allocate wwm registers used in whole quad mode operations (for shaders).
2492 addMachineFunctionPass(SIPreAllocateWWMRegsPass(), PMW);
2493
2494 // WWM allocation - default to fast at -O0.
2495 if (WWMRegAllocNPM == RegAllocType::Greedy)
2496 addMachineFunctionPass(RAGreedyPass({onlyAllocateWWMRegs, "wwm"}), PMW);
2497 else
2498 addMachineFunctionPass(
2499 RegAllocFastPass({onlyAllocateWWMRegs, "wwm", false}), PMW);
2500
2501 addMachineFunctionPass(SILowerWWMCopiesPass(), PMW);
2502 addMachineFunctionPass(AMDGPUReserveWWMRegsPass(), PMW);
2503
2504 // VGPR allocation - default to fast at -O0.
2505 if (VGPRRegAllocNPM == RegAllocType::Greedy)
2506 addMachineFunctionPass(RAGreedyPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2507 else
2508 addMachineFunctionPass(RegAllocFastPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2509
2510 return Error::success();
2511}
2512
2513Error AMDGPUCodeGenPassBuilder::addOptimizedRegAlloc(
2514 PassManagerWrapper &PMW) const {
2515 if (EnableDCEInRA)
2516 insertPass<DetectDeadLanesPass>(DeadMachineInstructionElimPass());
2517
2518 // FIXME: when an instruction has a Killed operand, and the instruction is
2519 // inside a bundle, seems only the BUNDLE instruction appears as the Kills of
2520 // the register in LiveVariables, this would trigger a failure in verifier,
2521 // we should fix it and enable the verifier.
2522 if (OptVGPRLiveRange)
2523 insertPass<RequireAnalysisPass<LiveVariablesAnalysis, MachineFunction>>(
2525
2526 // This must be run immediately after phi elimination and before
2527 // TwoAddressInstructions, otherwise the processing of the tied operand of
2528 // SI_ELSE will introduce a copy of the tied operand source after the else.
2529 insertPass<PHIEliminationPass>(SILowerControlFlowPass());
2530
2532 insertPass<RenameIndependentSubregsPass>(GCNRewritePartialRegUsesPass());
2533
2534 if (isPassEnabled(EnablePreRAOptimizations))
2535 insertPass<MachineSchedulerPass>(GCNPreRAOptimizationsPass());
2536
2537 // Allow the scheduler to run before SIWholeQuadMode inserts exec manipulation
2538 // instructions that cause scheduling barriers.
2539 insertPass<MachineSchedulerPass>(SIWholeQuadModePass());
2540
2541 if (OptExecMaskPreRA)
2542 insertPass<MachineSchedulerPass>(SIOptimizeExecMaskingPreRAPass());
2543
2544 // This is not an essential optimization and it has a noticeable impact on
2545 // compilation time, so we only enable it from O2.
2546 if (TM.getOptLevel() > CodeGenOptLevel::Less)
2547 insertPass<MachineSchedulerPass>(SIFormMemoryClausesPass());
2548
2549 return Base::addOptimizedRegAlloc(PMW);
2550}
2551
2552void AMDGPUCodeGenPassBuilder::addPreRegAlloc(PassManagerWrapper &PMW) const {
2553 if (getOptLevel() != CodeGenOptLevel::None)
2554 addMachineFunctionPass(AMDGPUPrepareAGPRAllocPass(), PMW);
2555}
2556
2557Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
2558 PassManagerWrapper &PMW) const {
2559 if (auto Err = validateRegAllocOptions())
2560 return Err;
2561
2562 addMachineFunctionPass(GCNPreRALongBranchRegPass(), PMW);
2563
2564 // SGPR allocation - default to greedy at -O1 and above.
2565 if (SGPRRegAllocNPM == RegAllocType::Fast)
2566 addMachineFunctionPass(RegAllocFastPass({onlyAllocateSGPRs, "sgpr", false}),
2567 PMW);
2568 else
2569 addMachineFunctionPass(RAGreedyPass({onlyAllocateSGPRs, "sgpr"}), PMW);
2570
2571 // Commit allocated register changes. This is mostly necessary because too
2572 // many things rely on the use lists of the physical registers, such as the
2573 // verifier. This is only necessary with allocators which use LiveIntervals,
2574 // since FastRegAlloc does the replacements itself.
2575 addMachineFunctionPass(VirtRegRewriterPass(false), PMW);
2576
2577 // At this point, the sgpr-regalloc has been done and it is good to have the
2578 // stack slot coloring to try to optimize the SGPR spill stack indices before
2579 // attempting the custom SGPR spill lowering.
2580 addMachineFunctionPass(StackSlotColoringPass(), PMW);
2581
2582 // Equivalent of PEI for SGPRs.
2583 addMachineFunctionPass(SILowerSGPRSpillsPass(), PMW);
2584
2585 // To Allocate wwm registers used in whole quad mode operations (for shaders).
2586 addMachineFunctionPass(SIPreAllocateWWMRegsPass(), PMW);
2587
2588 // WWM allocation - default to greedy at -O1 and above.
2589 if (WWMRegAllocNPM == RegAllocType::Fast)
2590 addMachineFunctionPass(
2591 RegAllocFastPass({onlyAllocateWWMRegs, "wwm", false}), PMW);
2592 else
2593 addMachineFunctionPass(RAGreedyPass({onlyAllocateWWMRegs, "wwm"}), PMW);
2594 addMachineFunctionPass(SILowerWWMCopiesPass(), PMW);
2595 addMachineFunctionPass(VirtRegRewriterPass(false), PMW);
2596 addMachineFunctionPass(AMDGPUReserveWWMRegsPass(), PMW);
2597
2598 // VGPR allocation - default to greedy at -O1 and above.
2599 if (VGPRRegAllocNPM == RegAllocType::Fast)
2600 addMachineFunctionPass(RegAllocFastPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2601 else
2602 addMachineFunctionPass(RAGreedyPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2603
2604 addPreRewrite(PMW);
2605 addMachineFunctionPass(VirtRegRewriterPass(true), PMW);
2606
2607 addMachineFunctionPass(AMDGPUMarkLastScratchLoadPass(), PMW);
2608 return Error::success();
2609}
2610
2611void AMDGPUCodeGenPassBuilder::addPostRegAlloc(PassManagerWrapper &PMW) const {
2612 addMachineFunctionPass(SIFixVGPRCopiesPass(), PMW);
2613 if (TM.getOptLevel() > CodeGenOptLevel::None)
2614 addMachineFunctionPass(SIOptimizeExecMaskingPass(), PMW);
2615 Base::addPostRegAlloc(PMW);
2616}
2617
2618void AMDGPUCodeGenPassBuilder::addPreSched2(PassManagerWrapper &PMW) const {
2619 if (TM.getOptLevel() > CodeGenOptLevel::None)
2620 addMachineFunctionPass(SIShrinkInstructionsPass(), PMW);
2621 addMachineFunctionPass(SIPostRABundlerPass(), PMW);
2622}
2623
2624void AMDGPUCodeGenPassBuilder::addPostBBSections(
2625 PassManagerWrapper &PMW) const {
2626 // We run this later to avoid passes like livedebugvalues and BBSections
2627 // having to deal with the apparent multi-entry functions we may generate.
2628 addMachineFunctionPass(AMDGPUPreloadKernArgPrologPass(), PMW);
2629}
2630
2631void AMDGPUCodeGenPassBuilder::addPreEmitPass(PassManagerWrapper &PMW) const {
2632 if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less)) {
2633 addMachineFunctionPass(GCNCreateVOPDPass(), PMW);
2634 }
2635
2636 addMachineFunctionPass(SIMemoryLegalizerPass(), PMW);
2637 addMachineFunctionPass(SIInsertWaitcntsPass(), PMW);
2638
2639 addMachineFunctionPass(SIModeRegisterPass(), PMW);
2640
2641 if (TM.getOptLevel() > CodeGenOptLevel::None)
2642 addMachineFunctionPass(SIInsertHardClausesPass(), PMW);
2643
2644 addMachineFunctionPass(SILateBranchLoweringPass(), PMW);
2645
2646 if (isPassEnabled(EnableSetWavePriority, CodeGenOptLevel::Less))
2647 addMachineFunctionPass(AMDGPUSetWavePriorityPass(), PMW);
2648
2649 if (TM.getOptLevel() > CodeGenOptLevel::None)
2650 addMachineFunctionPass(SIPreEmitPeepholePass(), PMW);
2651
2652 // The hazard recognizer that runs as part of the post-ra scheduler does not
2653 // guarantee to be able handle all hazards correctly. This is because if there
2654 // are multiple scheduling regions in a basic block, the regions are scheduled
2655 // bottom up, so when we begin to schedule a region we don't know what
2656 // instructions were emitted directly before it.
2657 //
2658 // Here we add a stand-alone hazard recognizer pass which can handle all
2659 // cases.
2660 addMachineFunctionPass(PostRAHazardRecognizerPass(), PMW);
2661 addMachineFunctionPass(AMDGPUWaitSGPRHazardsPass(), PMW);
2662 addMachineFunctionPass(AMDGPULowerVGPREncodingPass(), PMW);
2663
2664 if (isPassEnabled(EnableInsertDelayAlu, CodeGenOptLevel::Less)) {
2665 addMachineFunctionPass(AMDGPUInsertDelayAluPass(), PMW);
2666 }
2667
2668 addMachineFunctionPass(BranchRelaxationPass(), PMW);
2669}
2670
2671bool AMDGPUCodeGenPassBuilder::isPassEnabled(const cl::opt<bool> &Opt,
2672 CodeGenOptLevel Level) const {
2673 if (Opt.getNumOccurrences())
2674 return Opt;
2675 if (TM.getOptLevel() < Level)
2676 return false;
2677 return Opt;
2678}
2679
2680void AMDGPUCodeGenPassBuilder::addEarlyCSEOrGVNPass(
2681 PassManagerWrapper &PMW) const {
2682 if (TM.getOptLevel() == CodeGenOptLevel::Aggressive)
2683 addFunctionPass(GVNPass(), PMW);
2684 else
2685 addFunctionPass(EarlyCSEPass(), PMW);
2686}
2687
2688void AMDGPUCodeGenPassBuilder::addStraightLineScalarOptimizationPasses(
2689 PassManagerWrapper &PMW) const {
2691 addFunctionPass(LoopDataPrefetchPass(), PMW);
2692
2693 addFunctionPass(SeparateConstOffsetFromGEPPass(), PMW);
2694
2695 // ReassociateGEPs exposes more opportunities for SLSR. See
2696 // the example in reassociate-geps-and-slsr.ll.
2697 addFunctionPass(StraightLineStrengthReducePass(), PMW);
2698
2699 // SeparateConstOffsetFromGEP and SLSR creates common expressions which GVN or
2700 // EarlyCSE can reuse.
2701 addEarlyCSEOrGVNPass(PMW);
2702
2703 // Run NaryReassociate after EarlyCSE/GVN to be more effective.
2704 addFunctionPass(NaryReassociatePass(), PMW);
2705
2706 // NaryReassociate on GEPs creates redundant common expressions, so run
2707 // EarlyCSE after it.
2708 addFunctionPass(EarlyCSEPass(), PMW);
2709}
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.
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 > NewRegBankSelect("new-reg-bank-select", cl::desc("Run amdgpu-regbankselect and amdgpu-regbanklegalize instead of " "regbankselect"), cl::init(false), cl::Hidden)
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:853
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:315
#define LLVM_ABI
Definition Compiler.h:213
#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:483
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
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
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
RegisterPassParser class - Handle the addition of new machine passes.
RegisterRegAllocBase class - Track the registration of register allocators.
Wrapper class representing virtual and physical registers.
Definition Register.h:20
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:730
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:655
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
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
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)
bool isFlatGlobalAddrSpace(unsigned AS)
LLVM_READNONE constexpr bool isModuleEntryFunctionCC(CallingConv::ID CC)
LLVM_READNONE constexpr bool isEntryFunctionCC(CallingConv::ID CC)
@ 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()...
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
auto m_Value()
Match an arbitrary value and ignore it.
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()
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.
ModulePass * createAMDGPUSwLowerLDSLegacyPass(const AMDGPUTargetMachine *TM=nullptr)
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:4013
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 &)
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:383
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
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:179
DenseMap< Register, VRegInfo * > VRegInfos
Definition MIParser.h:178
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.