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 I = std::make_unique<GCNSubtarget>(TargetTriple, GPU, FS, *this, BufRelaxed,
1285 TBufRelaxed);
1286 }
1287
1288 I->setScalarizeGlobalBehavior(ScalarizeGlobal);
1289
1290 return I.get();
1291}
1292
1295 return TargetTransformInfo(std::make_unique<GCNTTIImpl>(this, F));
1296}
1297
1300 raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
1301 const CGPassBuilderOption &Opts, MCContext &Ctx,
1303 AMDGPUCodeGenPassBuilder CGPB(*this, Opts, PIC);
1304 return CGPB.buildPipeline(MPM, MAM, Out, DwoOut, FileType, Ctx);
1305}
1306
1309 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
1310 if (ST.enableSIScheduler())
1312
1313 StringRef SchedStrategy = AMDGPU::getSchedStrategy(C->MF->getFunction());
1314
1315 if (SchedStrategy == "max-ilp")
1317
1318 if (SchedStrategy == "max-memory-clause")
1320
1321 if (SchedStrategy == "iterative-ilp")
1323
1324 if (SchedStrategy == "iterative-minreg")
1325 return createMinRegScheduler(C);
1326
1327 if (SchedStrategy == "iterative-maxocc")
1329
1330 if (SchedStrategy == "coexec") {
1331 diagnoseUnsupportedCoExecSchedulerSelection(C->MF->getFunction(), ST);
1333 }
1334
1336}
1337
1340 if (useNoopPostScheduler(C->MF->getFunction()))
1342
1343 ScheduleDAGMI *DAG =
1344 new GCNPostScheduleDAGMILive(C, std::make_unique<PostGenericScheduler>(C),
1345 /*RemoveKillFlags=*/true);
1346 const GCNSubtarget &ST = C->MF->getSubtarget<GCNSubtarget>();
1348 if (ST.shouldClusterStores())
1351 if ((EnableVOPD.getNumOccurrences() ||
1353 EnableVOPD)
1358 return DAG;
1359}
1360//===----------------------------------------------------------------------===//
1361// AMDGPU Legacy Pass Setup
1362//===----------------------------------------------------------------------===//
1363
1364std::unique_ptr<CSEConfigBase> llvm::AMDGPUPassConfig::getCSEConfig() const {
1365 return getStandardCSEConfigForOpt(TM->getOptLevel());
1366}
1367
1368namespace {
1369
1370class GCNPassConfig final : public AMDGPUPassConfig {
1371public:
1372 GCNPassConfig(TargetMachine &TM, PassManagerBase &PM)
1373 : AMDGPUPassConfig(TM, PM) {
1374 substitutePass(&PostRASchedulerID, &PostMachineSchedulerID);
1375 }
1376
1377 GCNTargetMachine &getGCNTargetMachine() const {
1378 return getTM<GCNTargetMachine>();
1379 }
1380
1381 bool addPreISel() override;
1382 void addMachineSSAOptimization() override;
1383 bool addILPOpts() override;
1384 bool addInstSelector() override;
1385 bool addIRTranslator() override;
1386 void addPreLegalizeMachineIR() override;
1387 bool addLegalizeMachineIR() override;
1388 void addPreRegBankSelect() override;
1389 bool addRegBankSelect() override;
1390 void addPreGlobalInstructionSelect() override;
1391 bool addGlobalInstructionSelect() override;
1392 void addPreRegAlloc() override;
1393 void addFastRegAlloc() override;
1394 void addOptimizedRegAlloc() override;
1395
1396 FunctionPass *createSGPRAllocPass(bool Optimized);
1397 FunctionPass *createVGPRAllocPass(bool Optimized);
1398 FunctionPass *createWWMRegAllocPass(bool Optimized);
1399 FunctionPass *createRegAllocPass(bool Optimized) override;
1400
1401 bool addRegAssignAndRewriteFast() override;
1402 bool addRegAssignAndRewriteOptimized() override;
1403
1404 bool addPreRewrite() override;
1405 void addPostRegAlloc() override;
1406 void addPreSched2() override;
1407 void addPreEmitPass() override;
1408 void addPostBBSections() override;
1409};
1410
1411} // end anonymous namespace
1412
1414 : TargetPassConfig(TM, PM) {
1415 // Exceptions and StackMaps are not supported, so these passes will never do
1416 // anything.
1419 // Garbage collection is not supported.
1422}
1423
1430
1435 // ReassociateGEPs exposes more opportunities for SLSR. See
1436 // the example in reassociate-geps-and-slsr.ll.
1438 // SeparateConstOffsetFromGEP and SLSR creates common expressions which GVN or
1439 // EarlyCSE can reuse.
1441 // Run NaryReassociate after EarlyCSE/GVN to be more effective.
1443 // NaryReassociate on GEPs creates redundant common expressions, so run
1444 // EarlyCSE after it.
1446}
1447
1450
1451 if (RemoveIncompatibleFunctions && TM.getTargetTriple().isAMDGCN())
1453
1454 // There is no reason to run these.
1458
1459 if (TM.getTargetTriple().isAMDGCN())
1461
1462 if (LowerCtorDtor)
1464
1465 if (TM.getTargetTriple().isAMDGCN() &&
1468
1471
1472 // This can be disabled by passing ::Disable here or on the command line
1473 // with --expand-variadics-override=disable.
1475
1476 // Function calls are not supported, so make sure we inline everything.
1479
1480 // Handle uses of OpenCL image2d_t, image3d_t and sampler_t arguments.
1481 if (TM.getTargetTriple().getArch() == Triple::r600)
1483
1484 // Make enqueued block runtime handles externally visible.
1486
1487 // Lower special LDS accesses.
1490
1491 // Lower LDS accesses to global memory pass if address sanitizer is enabled.
1492 if (EnableSwLowerLDS)
1494
1495 // Runs before PromoteAlloca so the latter can account for function uses
1498 }
1499
1500 // Run atomic optimizer before Atomic Expand
1501 if ((TM.getTargetTriple().isAMDGCN()) &&
1502 (TM.getOptLevel() >= CodeGenOptLevel::Less) &&
1505 }
1506
1508
1509 if (TM.getOptLevel() > CodeGenOptLevel::None) {
1511
1514
1518 AAResults &AAR) {
1519 if (auto *WrapperPass = P.getAnalysisIfAvailable<AMDGPUAAWrapperPass>())
1520 AAR.addAAResult(WrapperPass->getResult());
1521 }));
1522 }
1523
1524 if (TM.getTargetTriple().isAMDGCN()) {
1525 // TODO: May want to move later or split into an early and late one.
1527 }
1528
1529 // Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may
1530 // have expanded.
1531 if (TM.getOptLevel() > CodeGenOptLevel::Less)
1533 }
1534
1536
1537 // EarlyCSE is not always strong enough to clean up what LSR produces. For
1538 // example, GVN can combine
1539 //
1540 // %0 = add %a, %b
1541 // %1 = add %b, %a
1542 //
1543 // and
1544 //
1545 // %0 = shl nsw %a, 2
1546 // %1 = shl %a, 2
1547 //
1548 // but EarlyCSE can do neither of them.
1551}
1552
1554 if (TM->getTargetTriple().isAMDGCN() &&
1555 TM->getOptLevel() > CodeGenOptLevel::None)
1557
1558 if (TM->getTargetTriple().isAMDGCN() && EnableLowerKernelArguments)
1560
1562
1565
1566 if (TM->getTargetTriple().isAMDGCN()) {
1567 // This lowering has been placed after codegenprepare to take advantage of
1568 // address mode matching (which is why it isn't put with the LDS lowerings).
1569 // It could be placed anywhere before uniformity annotations (an analysis
1570 // that it changes by splitting up fat pointers into their components)
1571 // but has been put before switch lowering and CFG flattening so that those
1572 // passes can run on the more optimized control flow this pass creates in
1573 // many cases.
1576 }
1577
1578 // LowerSwitch pass may introduce unreachable blocks that can
1579 // cause unexpected behavior for subsequent passes. Placing it
1580 // here seems better that these blocks would get cleaned up by
1581 // UnreachableBlockElim inserted next in the pass flow.
1583}
1584
1586 if (TM->getOptLevel() > CodeGenOptLevel::None)
1588 return false;
1589}
1590
1595
1597 // Do nothing. GC is not supported.
1598 return false;
1599}
1600
1601//===----------------------------------------------------------------------===//
1602// GCN Legacy Pass Setup
1603//===----------------------------------------------------------------------===//
1604
1605bool GCNPassConfig::addPreISel() {
1607
1608 if (TM->getOptLevel() > CodeGenOptLevel::None) {
1609 addPass(createSinkingPass());
1611 }
1612
1613 // Merge divergent exit nodes. StructurizeCFG won't recognize the multi-exit
1614 // regions formed by them.
1616 addPass(createFixIrreduciblePass());
1617 addPass(createUnifyLoopExitsPass());
1618 addPass(createStructurizeCFGPass(false)); // true -> SkipUniformRegions
1619
1622 // TODO: Move this right after structurizeCFG to avoid extra divergence
1623 // analysis. This depends on stopping SIAnnotateControlFlow from making
1624 // control flow modifications.
1626
1627 // SDAG requires LCSSA, GlobalISel does not. Disable LCSSA for -global-isel
1628 // with -new-reg-bank-select and without any of the fallback options.
1630 !isGlobalISelAbortEnabled() || !NewRegBankSelect)
1631 addPass(createLCSSAPass());
1632
1633 if (TM->getOptLevel() > CodeGenOptLevel::Less)
1635
1636 return false;
1637}
1638
1639void GCNPassConfig::addMachineSSAOptimization() {
1641
1642 // We want to fold operands after PeepholeOptimizer has run (or as part of
1643 // it), because it will eliminate extra copies making it easier to fold the
1644 // real source operand. We want to eliminate dead instructions after, so that
1645 // we see fewer uses of the copies. We then need to clean up the dead
1646 // instructions leftover after the operands are folded as well.
1647 //
1648 // XXX - Can we get away without running DeadMachineInstructionElim again?
1649 addPass(&SIFoldOperandsLegacyID);
1650 if (EnableDPPCombine)
1651 addPass(&GCNDPPCombineLegacyID);
1653 if (isPassEnabled(EnableSDWAPeephole)) {
1654 addPass(&SIPeepholeSDWALegacyID);
1655 addPass(&EarlyMachineLICMID);
1656 addPass(&MachineCSELegacyID);
1657 addPass(&SIFoldOperandsLegacyID);
1658 }
1661}
1662
1663bool GCNPassConfig::addILPOpts() {
1665 addPass(&EarlyIfConverterLegacyID);
1666
1668 return false;
1669}
1670
1671bool GCNPassConfig::addInstSelector() {
1673 addPass(&SIFixSGPRCopiesLegacyID);
1675 return false;
1676}
1677
1678bool GCNPassConfig::addIRTranslator() {
1679 addPass(new IRTranslator(getOptLevel()));
1680 return false;
1681}
1682
1683void GCNPassConfig::addPreLegalizeMachineIR() {
1684 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1685 addPass(createAMDGPUPreLegalizeCombiner(IsOptNone));
1686 addPass(new Localizer());
1687}
1688
1689bool GCNPassConfig::addLegalizeMachineIR() {
1690 addPass(new Legalizer());
1691 return false;
1692}
1693
1694void GCNPassConfig::addPreRegBankSelect() {
1695 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1696 addPass(createAMDGPUPostLegalizeCombiner(IsOptNone));
1698}
1699
1700bool GCNPassConfig::addRegBankSelect() {
1701 if (NewRegBankSelect) {
1704 } else {
1705 addPass(new RegBankSelect());
1706 }
1707 return false;
1708}
1709
1710void GCNPassConfig::addPreGlobalInstructionSelect() {
1711 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1712 addPass(createAMDGPURegBankCombiner(IsOptNone));
1713}
1714
1715bool GCNPassConfig::addGlobalInstructionSelect() {
1716 addPass(new InstructionSelect(getOptLevel()));
1717 return false;
1718}
1719
1720void GCNPassConfig::addFastRegAlloc() {
1721 // FIXME: We have to disable the verifier here because of PHIElimination +
1722 // TwoAddressInstructions disabling it.
1723
1724 // This must be run immediately after phi elimination and before
1725 // TwoAddressInstructions, otherwise the processing of the tied operand of
1726 // SI_ELSE will introduce a copy of the tied operand source after the else.
1728
1730
1732}
1733
1734void GCNPassConfig::addPreRegAlloc() {
1735 if (getOptLevel() != CodeGenOptLevel::None)
1737}
1738
1739void GCNPassConfig::addOptimizedRegAlloc() {
1740 if (EnableDCEInRA)
1742
1743 // FIXME: when an instruction has a Killed operand, and the instruction is
1744 // inside a bundle, seems only the BUNDLE instruction appears as the Kills of
1745 // the register in LiveVariables, this would trigger a failure in verifier,
1746 // we should fix it and enable the verifier.
1747 if (OptVGPRLiveRange)
1749
1750 // This must be run immediately after phi elimination and before
1751 // TwoAddressInstructions, otherwise the processing of the tied operand of
1752 // SI_ELSE will introduce a copy of the tied operand source after the else.
1754
1757
1758 if (isPassEnabled(EnablePreRAOptimizations))
1760
1761 // Allow the scheduler to run before SIWholeQuadMode inserts exec manipulation
1762 // instructions that cause scheduling barriers.
1764
1765 if (OptExecMaskPreRA)
1767
1768 // This is not an essential optimization and it has a noticeable impact on
1769 // compilation time, so we only enable it from O2.
1770 if (TM->getOptLevel() > CodeGenOptLevel::Less)
1772
1774}
1775
1776bool GCNPassConfig::addPreRewrite() {
1778 addPass(&GCNNSAReassignID);
1779
1781 return true;
1782}
1783
1784FunctionPass *GCNPassConfig::createSGPRAllocPass(bool Optimized) {
1785 // Initialize the global default.
1786 llvm::call_once(InitializeDefaultSGPRRegisterAllocatorFlag,
1787 initializeDefaultSGPRRegisterAllocatorOnce);
1788
1789 RegisterRegAlloc::FunctionPassCtor Ctor = SGPRRegisterRegAlloc::getDefault();
1790 if (Ctor != useDefaultRegisterAllocator)
1791 return Ctor();
1792
1793 if (Optimized)
1794 return createGreedyRegisterAllocator(onlyAllocateSGPRs);
1795
1796 return createFastRegisterAllocator(onlyAllocateSGPRs, false);
1797}
1798
1799FunctionPass *GCNPassConfig::createVGPRAllocPass(bool Optimized) {
1800 // Initialize the global default.
1801 llvm::call_once(InitializeDefaultVGPRRegisterAllocatorFlag,
1802 initializeDefaultVGPRRegisterAllocatorOnce);
1803
1804 RegisterRegAlloc::FunctionPassCtor Ctor = VGPRRegisterRegAlloc::getDefault();
1805 if (Ctor != useDefaultRegisterAllocator)
1806 return Ctor();
1807
1808 if (Optimized)
1809 return createGreedyVGPRRegisterAllocator();
1810
1811 return createFastVGPRRegisterAllocator();
1812}
1813
1814FunctionPass *GCNPassConfig::createWWMRegAllocPass(bool Optimized) {
1815 // Initialize the global default.
1816 llvm::call_once(InitializeDefaultWWMRegisterAllocatorFlag,
1817 initializeDefaultWWMRegisterAllocatorOnce);
1818
1819 RegisterRegAlloc::FunctionPassCtor Ctor = WWMRegisterRegAlloc::getDefault();
1820 if (Ctor != useDefaultRegisterAllocator)
1821 return Ctor();
1822
1823 if (Optimized)
1824 return createGreedyWWMRegisterAllocator();
1825
1826 return createFastWWMRegisterAllocator();
1827}
1828
1829FunctionPass *GCNPassConfig::createRegAllocPass(bool Optimized) {
1830 llvm_unreachable("should not be used");
1831}
1832
1834 "-regalloc not supported with amdgcn. Use -sgpr-regalloc, -wwm-regalloc, "
1835 "and -vgpr-regalloc";
1836
1837bool GCNPassConfig::addRegAssignAndRewriteFast() {
1838 if (!usingDefaultRegAlloc())
1840
1841 addPass(&GCNPreRALongBranchRegID);
1842
1843 addPass(createSGPRAllocPass(false));
1844
1845 // Equivalent of PEI for SGPRs.
1846 addPass(&SILowerSGPRSpillsLegacyID);
1847
1848 // To Allocate wwm registers used in whole quad mode operations (for shaders).
1850
1851 // For allocating other wwm register operands.
1852 addPass(createWWMRegAllocPass(false));
1853
1854 addPass(&SILowerWWMCopiesLegacyID);
1856
1857 // For allocating per-thread VGPRs.
1858 addPass(createVGPRAllocPass(false));
1859
1860 return true;
1861}
1862
1863bool GCNPassConfig::addRegAssignAndRewriteOptimized() {
1864 if (!usingDefaultRegAlloc())
1866
1867 addPass(&GCNPreRALongBranchRegID);
1868
1869 addPass(createSGPRAllocPass(true));
1870
1871 // Commit allocated register changes. This is mostly necessary because too
1872 // many things rely on the use lists of the physical registers, such as the
1873 // verifier. This is only necessary with allocators which use LiveIntervals,
1874 // since FastRegAlloc does the replacements itself.
1875 addPass(createVirtRegRewriter(false));
1876
1877 // At this point, the sgpr-regalloc has been done and it is good to have the
1878 // stack slot coloring to try to optimize the SGPR spill stack indices before
1879 // attempting the custom SGPR spill lowering.
1880 addPass(&StackSlotColoringID);
1881
1882 // Equivalent of PEI for SGPRs.
1883 addPass(&SILowerSGPRSpillsLegacyID);
1884
1885 // To Allocate wwm registers used in whole quad mode operations (for shaders).
1887
1888 // For allocating other whole wave mode registers.
1889 addPass(createWWMRegAllocPass(true));
1890 addPass(&SILowerWWMCopiesLegacyID);
1891 addPass(createVirtRegRewriter(false));
1893
1894 // For allocating per-thread VGPRs.
1895 addPass(createVGPRAllocPass(true));
1896
1897 addPreRewrite();
1898 addPass(&VirtRegRewriterID);
1899
1901
1902 return true;
1903}
1904
1905void GCNPassConfig::addPostRegAlloc() {
1906 addPass(&SIFixVGPRCopiesID);
1907 if (getOptLevel() > CodeGenOptLevel::None)
1910}
1911
1912void GCNPassConfig::addPreSched2() {
1913 if (TM->getOptLevel() > CodeGenOptLevel::None)
1915 addPass(&SIPostRABundlerLegacyID);
1916}
1917
1918void GCNPassConfig::addPreEmitPass() {
1919 if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less))
1920 addPass(&GCNCreateVOPDID);
1921 addPass(createSIMemoryLegalizerPass());
1922 addPass(createSIInsertWaitcntsPass());
1923
1924 addPass(createSIModeRegisterPass());
1925
1926 if (getOptLevel() > CodeGenOptLevel::None)
1927 addPass(&SIInsertHardClausesID);
1928
1930 if (isPassEnabled(EnableSetWavePriority, CodeGenOptLevel::Less))
1932 if (getOptLevel() > CodeGenOptLevel::None)
1933 addPass(&SIPreEmitPeepholeID);
1934 // The hazard recognizer that runs as part of the post-ra scheduler does not
1935 // guarantee to be able handle all hazards correctly. This is because if there
1936 // are multiple scheduling regions in a basic block, the regions are scheduled
1937 // bottom up, so when we begin to schedule a region we don't know what
1938 // instructions were emitted directly before it.
1939 //
1940 // Here we add a stand-alone hazard recognizer pass which can handle all
1941 // cases.
1942 addPass(&PostRAHazardRecognizerID);
1943
1945
1947
1948 if (isPassEnabled(EnableInsertDelayAlu, CodeGenOptLevel::Less))
1949 addPass(&AMDGPUInsertDelayAluID);
1950
1951 addPass(&BranchRelaxationPassID);
1952}
1953
1954void GCNPassConfig::addPostBBSections() {
1955 // We run this later to avoid passes like livedebugvalues and BBSections
1956 // having to deal with the apparent multi-entry functions we may generate.
1958}
1959
1961 return new GCNPassConfig(*this, PM);
1962}
1963
1969
1976
1980
1987
1990 SMDiagnostic &Error, SMRange &SourceRange) const {
1991 const yaml::SIMachineFunctionInfo &YamlMFI =
1992 static_cast<const yaml::SIMachineFunctionInfo &>(MFI_);
1993 MachineFunction &MF = PFS.MF;
1995 const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
1996
1997 if (MFI->initializeBaseYamlFields(YamlMFI, MF, PFS, Error, SourceRange))
1998 return true;
1999
2000 if (MFI->Occupancy == 0) {
2001 // Fixup the subtarget dependent default value.
2002 MFI->Occupancy = ST.getOccupancyWithWorkGroupSizes(MF).second;
2003 }
2004
2005 auto parseRegister = [&](const yaml::StringValue &RegName, Register &RegVal) {
2006 Register TempReg;
2007 if (parseNamedRegisterReference(PFS, TempReg, RegName.Value, Error)) {
2008 SourceRange = RegName.SourceRange;
2009 return true;
2010 }
2011 RegVal = TempReg;
2012
2013 return false;
2014 };
2015
2016 auto parseOptionalRegister = [&](const yaml::StringValue &RegName,
2017 Register &RegVal) {
2018 return !RegName.Value.empty() && parseRegister(RegName, RegVal);
2019 };
2020
2021 if (parseOptionalRegister(YamlMFI.VGPRForAGPRCopy, MFI->VGPRForAGPRCopy))
2022 return true;
2023
2024 if (parseOptionalRegister(YamlMFI.SGPRForEXECCopy, MFI->SGPRForEXECCopy))
2025 return true;
2026
2027 if (parseOptionalRegister(YamlMFI.LongBranchReservedReg,
2028 MFI->LongBranchReservedReg))
2029 return true;
2030
2031 auto diagnoseRegisterClass = [&](const yaml::StringValue &RegName) {
2032 // Create a diagnostic for a the register string literal.
2033 const MemoryBuffer &Buffer =
2034 *PFS.SM->getMemoryBuffer(PFS.SM->getMainFileID());
2035 Error = SMDiagnostic(*PFS.SM, SMLoc(), Buffer.getBufferIdentifier(), 1,
2036 RegName.Value.size(), SourceMgr::DK_Error,
2037 "incorrect register class for field", RegName.Value,
2038 {}, {});
2039 SourceRange = RegName.SourceRange;
2040 return true;
2041 };
2042
2043 if (parseRegister(YamlMFI.ScratchRSrcReg, MFI->ScratchRSrcReg) ||
2044 parseRegister(YamlMFI.FrameOffsetReg, MFI->FrameOffsetReg) ||
2045 parseRegister(YamlMFI.StackPtrOffsetReg, MFI->StackPtrOffsetReg))
2046 return true;
2047
2048 if (MFI->ScratchRSrcReg != AMDGPU::PRIVATE_RSRC_REG &&
2049 !AMDGPU::SGPR_128RegClass.contains(MFI->ScratchRSrcReg)) {
2050 return diagnoseRegisterClass(YamlMFI.ScratchRSrcReg);
2051 }
2052
2053 if (MFI->FrameOffsetReg != AMDGPU::FP_REG &&
2054 !AMDGPU::SGPR_32RegClass.contains(MFI->FrameOffsetReg)) {
2055 return diagnoseRegisterClass(YamlMFI.FrameOffsetReg);
2056 }
2057
2058 if (MFI->StackPtrOffsetReg != AMDGPU::SP_REG &&
2059 !AMDGPU::SGPR_32RegClass.contains(MFI->StackPtrOffsetReg)) {
2060 return diagnoseRegisterClass(YamlMFI.StackPtrOffsetReg);
2061 }
2062
2063 for (const auto &YamlReg : YamlMFI.WWMReservedRegs) {
2064 Register ParsedReg;
2065 if (parseRegister(YamlReg, ParsedReg))
2066 return true;
2067
2068 MFI->reserveWWMRegister(ParsedReg);
2069 }
2070
2071 for (const auto &[_, Info] : PFS.VRegInfosNamed) {
2072 MFI->setFlag(Info->VReg, Info->Flags);
2073 }
2074 for (const auto &[_, Info] : PFS.VRegInfos) {
2075 MFI->setFlag(Info->VReg, Info->Flags);
2076 }
2077
2078 for (const auto &YamlRegStr : YamlMFI.SpillPhysVGPRS) {
2079 Register ParsedReg;
2080 if (parseRegister(YamlRegStr, ParsedReg))
2081 return true;
2082 MFI->SpillPhysVGPRs.push_back(ParsedReg);
2083 }
2084
2085 auto parseAndCheckArgument = [&](const std::optional<yaml::SIArgument> &A,
2086 const TargetRegisterClass &RC,
2087 ArgDescriptor &Arg, unsigned UserSGPRs,
2088 unsigned SystemSGPRs) {
2089 // Skip parsing if it's not present.
2090 if (!A)
2091 return false;
2092
2093 if (A->IsRegister) {
2094 Register Reg;
2095 if (parseNamedRegisterReference(PFS, Reg, A->RegisterName.Value, Error)) {
2096 SourceRange = A->RegisterName.SourceRange;
2097 return true;
2098 }
2099 if (!RC.contains(Reg))
2100 return diagnoseRegisterClass(A->RegisterName);
2102 } else
2103 Arg = ArgDescriptor::createStack(A->StackOffset);
2104 // Check and apply the optional mask.
2105 if (A->Mask)
2106 Arg = ArgDescriptor::createArg(Arg, *A->Mask);
2107
2108 MFI->NumUserSGPRs += UserSGPRs;
2109 MFI->NumSystemSGPRs += SystemSGPRs;
2110 return false;
2111 };
2112
2113 if (YamlMFI.ArgInfo &&
2114 (parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentBuffer,
2115 AMDGPU::SGPR_128RegClass,
2116 MFI->ArgInfo.PrivateSegmentBuffer, 4, 0) ||
2117 parseAndCheckArgument(YamlMFI.ArgInfo->DispatchPtr,
2118 AMDGPU::SReg_64RegClass, MFI->ArgInfo.DispatchPtr,
2119 2, 0) ||
2120 parseAndCheckArgument(YamlMFI.ArgInfo->QueuePtr, AMDGPU::SReg_64RegClass,
2121 MFI->ArgInfo.QueuePtr, 2, 0) ||
2122 parseAndCheckArgument(YamlMFI.ArgInfo->KernargSegmentPtr,
2123 AMDGPU::SReg_64RegClass,
2124 MFI->ArgInfo.KernargSegmentPtr, 2, 0) ||
2125 parseAndCheckArgument(YamlMFI.ArgInfo->DispatchID,
2126 AMDGPU::SReg_64RegClass, MFI->ArgInfo.DispatchID,
2127 2, 0) ||
2128 parseAndCheckArgument(YamlMFI.ArgInfo->FlatScratchInit,
2129 AMDGPU::SReg_64RegClass,
2130 MFI->ArgInfo.FlatScratchInit, 2, 0) ||
2131 parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentSize,
2132 AMDGPU::SGPR_32RegClass,
2133 MFI->ArgInfo.PrivateSegmentSize, 0, 0) ||
2134 parseAndCheckArgument(YamlMFI.ArgInfo->LDSKernelId,
2135 AMDGPU::SGPR_32RegClass,
2136 MFI->ArgInfo.LDSKernelId, 0, 1) ||
2137 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDX,
2138 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDX,
2139 0, 1) ||
2140 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDY,
2141 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDY,
2142 0, 1) ||
2143 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDZ,
2144 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDZ,
2145 0, 1) ||
2146 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupInfo,
2147 AMDGPU::SGPR_32RegClass,
2148 MFI->ArgInfo.WorkGroupInfo, 0, 1) ||
2149 parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentWaveByteOffset,
2150 AMDGPU::SGPR_32RegClass,
2151 MFI->ArgInfo.PrivateSegmentWaveByteOffset, 0, 1) ||
2152 parseAndCheckArgument(YamlMFI.ArgInfo->ImplicitArgPtr,
2153 AMDGPU::SReg_64RegClass,
2154 MFI->ArgInfo.ImplicitArgPtr, 0, 0) ||
2155 parseAndCheckArgument(YamlMFI.ArgInfo->ImplicitBufferPtr,
2156 AMDGPU::SReg_64RegClass,
2157 MFI->ArgInfo.ImplicitBufferPtr, 2, 0) ||
2158 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDX,
2159 AMDGPU::VGPR_32RegClass,
2160 MFI->ArgInfo.WorkItemIDX, 0, 0) ||
2161 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDY,
2162 AMDGPU::VGPR_32RegClass,
2163 MFI->ArgInfo.WorkItemIDY, 0, 0) ||
2164 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDZ,
2165 AMDGPU::VGPR_32RegClass,
2166 MFI->ArgInfo.WorkItemIDZ, 0, 0)))
2167 return true;
2168
2169 // Parse FirstKernArgPreloadReg separately, since it's a Register,
2170 // not ArgDescriptor.
2171 if (YamlMFI.ArgInfo && YamlMFI.ArgInfo->FirstKernArgPreloadReg) {
2172 const yaml::SIArgument &A = *YamlMFI.ArgInfo->FirstKernArgPreloadReg;
2173
2174 if (!A.IsRegister) {
2175 // For stack arguments, we don't have RegisterName.SourceRange,
2176 // but we should have some location info from the YAML parser
2177 const MemoryBuffer &Buffer =
2178 *PFS.SM->getMemoryBuffer(PFS.SM->getMainFileID());
2179 // Create a minimal valid source range
2181 SMRange Range(Loc, Loc);
2182
2184 *PFS.SM, Loc, Buffer.getBufferIdentifier(), 1, 0, SourceMgr::DK_Error,
2185 "firstKernArgPreloadReg must be a register, not a stack location", "",
2186 {}, {});
2187
2188 SourceRange = Range;
2189 return true;
2190 }
2191
2192 Register Reg;
2193 if (parseNamedRegisterReference(PFS, Reg, A.RegisterName.Value, Error)) {
2194 SourceRange = A.RegisterName.SourceRange;
2195 return true;
2196 }
2197
2198 if (!AMDGPU::SGPR_32RegClass.contains(Reg))
2199 return diagnoseRegisterClass(A.RegisterName);
2200
2201 MFI->ArgInfo.FirstKernArgPreloadReg = Reg;
2202 MFI->NumUserSGPRs += YamlMFI.NumKernargPreloadSGPRs;
2203 }
2204
2205 if (ST.hasFeature(AMDGPU::FeatureDX10ClampAndIEEEMode)) {
2206 MFI->Mode.IEEE = YamlMFI.Mode.IEEE;
2207 MFI->Mode.DX10Clamp = YamlMFI.Mode.DX10Clamp;
2208 }
2209
2210 // FIXME: Move proper support for denormal-fp-math into base MachineFunction
2211 MFI->Mode.FP32Denormals.Input = YamlMFI.Mode.FP32InputDenormals
2214 MFI->Mode.FP32Denormals.Output = YamlMFI.Mode.FP32OutputDenormals
2217
2224
2225 if (YamlMFI.HasInitWholeWave)
2226 MFI->setInitWholeWave();
2227
2228 return false;
2229}
2230
2231//===----------------------------------------------------------------------===//
2232// AMDGPU CodeGen Pass Builder interface.
2233//===----------------------------------------------------------------------===//
2234
2235AMDGPUCodeGenPassBuilder::AMDGPUCodeGenPassBuilder(
2236 GCNTargetMachine &TM, const CGPassBuilderOption &Opts,
2238 : CodeGenPassBuilder(TM, Opts, PIC) {
2239 Opt.MISchedPostRA = true;
2240 Opt.RequiresCodeGenSCCOrder = true;
2241 // Exceptions and StackMaps are not supported, so these passes will never do
2242 // anything.
2243 // Garbage collection is not supported.
2244 disablePass<StackMapLivenessPass, FuncletLayoutPass, PatchableFunctionPass,
2246}
2247
2248void AMDGPUCodeGenPassBuilder::addIRPasses(PassManagerWrapper &PMW) const {
2249 if (RemoveIncompatibleFunctions && TM.getTargetTriple().isAMDGCN()) {
2250 flushFPMsToMPM(PMW);
2251 addModulePass(AMDGPURemoveIncompatibleFunctionsPass(TM), PMW);
2252 }
2253
2254 flushFPMsToMPM(PMW);
2255
2256 if (TM.getTargetTriple().isAMDGCN())
2257 addModulePass(AMDGPUPrintfRuntimeBindingPass(), PMW);
2258
2259 if (LowerCtorDtor)
2260 addModulePass(AMDGPUCtorDtorLoweringPass(), PMW);
2261
2262 if (isPassEnabled(EnableImageIntrinsicOptimizer))
2263 addFunctionPass(AMDGPUImageIntrinsicOptimizerPass(TM), PMW);
2264
2266 addFunctionPass(AMDGPUUniformIntrinsicCombinePass(), PMW);
2267 // This can be disabled by passing ::Disable here or on the command line
2268 // with --expand-variadics-override=disable.
2269 flushFPMsToMPM(PMW);
2271
2272 addModulePass(AMDGPUAlwaysInlinePass(), PMW);
2273 addModulePass(AlwaysInlinerPass(), PMW);
2274
2275 addModulePass(AMDGPUExportKernelRuntimeHandlesPass(), PMW);
2276
2278 addModulePass(AMDGPULowerExecSyncPass(), PMW);
2279
2280 if (EnableSwLowerLDS)
2281 addModulePass(AMDGPUSwLowerLDSPass(TM), PMW);
2282
2283 // Runs before PromoteAlloca so the latter can account for function uses
2285 addModulePass(AMDGPULowerModuleLDSPass(TM), PMW);
2286
2287 // Run atomic optimizer before Atomic Expand
2288 if (TM.getOptLevel() >= CodeGenOptLevel::Less &&
2290 addFunctionPass(
2292
2293 addFunctionPass(AtomicExpandPass(TM), PMW);
2294
2295 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2296 addFunctionPass(AMDGPUPromoteAllocaPass(TM), PMW);
2297 if (isPassEnabled(EnableScalarIRPasses))
2298 addStraightLineScalarOptimizationPasses(PMW);
2299
2300 // TODO: Handle EnableAMDGPUAliasAnalysis
2301
2302 // TODO: May want to move later or split into an early and late one.
2303 addFunctionPass(AMDGPUCodeGenPreparePass(TM), PMW);
2304
2305 // Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may
2306 // have expanded.
2307 if (TM.getOptLevel() > CodeGenOptLevel::Less) {
2309 /*UseMemorySSA=*/true),
2310 PMW);
2311 }
2312 }
2313
2314 Base::addIRPasses(PMW);
2315
2316 // EarlyCSE is not always strong enough to clean up what LSR produces. For
2317 // example, GVN can combine
2318 //
2319 // %0 = add %a, %b
2320 // %1 = add %b, %a
2321 //
2322 // and
2323 //
2324 // %0 = shl nsw %a, 2
2325 // %1 = shl %a, 2
2326 //
2327 // but EarlyCSE can do neither of them.
2328 if (isPassEnabled(EnableScalarIRPasses))
2329 addEarlyCSEOrGVNPass(PMW);
2330}
2331
2332void AMDGPUCodeGenPassBuilder::addCodeGenPrepare(
2333 PassManagerWrapper &PMW) const {
2334 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2335 flushFPMsToMPM(PMW);
2336 addModulePass(AMDGPUPreloadKernelArgumentsPass(TM), PMW);
2337 }
2338
2340 addFunctionPass(AMDGPULowerKernelArgumentsPass(TM), PMW);
2341
2342 Base::addCodeGenPrepare(PMW);
2343
2344 if (isPassEnabled(EnableLoadStoreVectorizer))
2345 addFunctionPass(LoadStoreVectorizerPass(), PMW);
2346
2347 // This lowering has been placed after codegenprepare to take advantage of
2348 // address mode matching (which is why it isn't put with the LDS lowerings).
2349 // It could be placed anywhere before uniformity annotations (an analysis
2350 // that it changes by splitting up fat pointers into their components)
2351 // but has been put before switch lowering and CFG flattening so that those
2352 // passes can run on the more optimized control flow this pass creates in
2353 // many cases.
2354 flushFPMsToMPM(PMW);
2355 addModulePass(AMDGPULowerBufferFatPointersPass(TM), PMW);
2356 flushFPMsToMPM(PMW);
2357 requireCGSCCOrder(PMW);
2358
2359 addModulePass(AMDGPULowerIntrinsicsPass(TM), PMW);
2360
2361 // LowerSwitch pass may introduce unreachable blocks that can cause unexpected
2362 // behavior for subsequent passes. Placing it here seems better that these
2363 // blocks would get cleaned up by UnreachableBlockElim inserted next in the
2364 // pass flow.
2365 addFunctionPass(LowerSwitchPass(), PMW);
2366}
2367
2368void AMDGPUCodeGenPassBuilder::addPreISel(PassManagerWrapper &PMW) const {
2369
2370 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2371 addFunctionPass(FlattenCFGPass(), PMW);
2372 addFunctionPass(SinkingPass(), PMW);
2373 addFunctionPass(AMDGPULateCodeGenPreparePass(TM), PMW);
2374 }
2375
2376 // Merge divergent exit nodes. StructurizeCFG won't recognize the multi-exit
2377 // regions formed by them.
2378
2379 addFunctionPass(AMDGPUUnifyDivergentExitNodesPass(), PMW);
2380 addFunctionPass(FixIrreduciblePass(), PMW);
2381 addFunctionPass(UnifyLoopExitsPass(), PMW);
2382 addFunctionPass(StructurizeCFGPass(/*SkipUniformRegions=*/false), PMW);
2383
2384 addFunctionPass(AMDGPUAnnotateUniformValuesPass(), PMW);
2385
2386 addFunctionPass(SIAnnotateControlFlowPass(TM), PMW);
2387
2388 // TODO: Move this right after structurizeCFG to avoid extra divergence
2389 // analysis. This depends on stopping SIAnnotateControlFlow from making
2390 // control flow modifications.
2391 addFunctionPass(AMDGPURewriteUndefForPHIPass(), PMW);
2392
2394 !isGlobalISelAbortEnabled() || !NewRegBankSelect)
2395 addFunctionPass(LCSSAPass(), PMW);
2396
2397 if (TM.getOptLevel() > CodeGenOptLevel::Less) {
2398 flushFPMsToMPM(PMW);
2399 addModulePass(AMDGPUPerfHintAnalysisPass(TM), PMW);
2400 }
2401
2402 // FIXME: Why isn't this queried as required from AMDGPUISelDAGToDAG, and why
2403 // isn't this in addInstSelector?
2405 /*Force=*/true);
2406}
2407
2408void AMDGPUCodeGenPassBuilder::addILPOpts(PassManagerWrapper &PMW) const {
2410 addMachineFunctionPass(EarlyIfConverterPass(), PMW);
2411
2412 Base::addILPOpts(PMW);
2413}
2414
2415void AMDGPUCodeGenPassBuilder::addAsmPrinterBegin(
2416 PassManagerWrapper &PMW) const {
2417 // TODO: Add AsmPrinterBegin
2418}
2419
2420void AMDGPUCodeGenPassBuilder::addAsmPrinter(PassManagerWrapper &PMW) const {
2421 // TODO: Add AsmPrinter.
2422}
2423
2424void AMDGPUCodeGenPassBuilder::addAsmPrinterEnd(PassManagerWrapper &PMW) const {
2425 // TODO: Add AsmPrinterEnd
2426}
2427
2428Error AMDGPUCodeGenPassBuilder::addInstSelector(PassManagerWrapper &PMW) const {
2429 addMachineFunctionPass(AMDGPUISelDAGToDAGPass(TM), PMW);
2430 addMachineFunctionPass(SIFixSGPRCopiesPass(), PMW);
2431 addMachineFunctionPass(SILowerI1CopiesPass(), PMW);
2432 return Error::success();
2433}
2434
2435void AMDGPUCodeGenPassBuilder::addPreRewrite(PassManagerWrapper &PMW) const {
2436 if (EnableRegReassign) {
2437 addMachineFunctionPass(GCNNSAReassignPass(), PMW);
2438 }
2439
2440 addMachineFunctionPass(AMDGPURewriteAGPRCopyMFMAPass(), PMW);
2441}
2442
2443void AMDGPUCodeGenPassBuilder::addMachineSSAOptimization(
2444 PassManagerWrapper &PMW) const {
2445 Base::addMachineSSAOptimization(PMW);
2446
2447 addMachineFunctionPass(SIFoldOperandsPass(), PMW);
2448 if (EnableDPPCombine) {
2449 addMachineFunctionPass(GCNDPPCombinePass(), PMW);
2450 }
2451 addMachineFunctionPass(SILoadStoreOptimizerPass(), PMW);
2452 if (isPassEnabled(EnableSDWAPeephole)) {
2453 addMachineFunctionPass(SIPeepholeSDWAPass(), PMW);
2454 addMachineFunctionPass(EarlyMachineLICMPass(), PMW);
2455 addMachineFunctionPass(MachineCSEPass(), PMW);
2456 addMachineFunctionPass(SIFoldOperandsPass(), PMW);
2457 }
2458 addMachineFunctionPass(DeadMachineInstructionElimPass(), PMW);
2459 addMachineFunctionPass(SIShrinkInstructionsPass(), PMW);
2460}
2461
2462Error AMDGPUCodeGenPassBuilder::addFastRegAlloc(PassManagerWrapper &PMW) const {
2463 insertPass<PHIEliminationPass>(SILowerControlFlowPass());
2464
2465 insertPass<TwoAddressInstructionPass>(SIWholeQuadModePass());
2466
2467 return Base::addFastRegAlloc(PMW);
2468}
2469
2470Error AMDGPUCodeGenPassBuilder::addRegAssignmentFast(
2471 PassManagerWrapper &PMW) const {
2472 if (auto Err = validateRegAllocOptions())
2473 return Err;
2474
2475 addMachineFunctionPass(GCNPreRALongBranchRegPass(), PMW);
2476
2477 // SGPR allocation - default to fast at -O0.
2478 if (SGPRRegAllocNPM == RegAllocType::Greedy)
2479 addMachineFunctionPass(RAGreedyPass({onlyAllocateSGPRs, "sgpr"}), PMW);
2480 else
2481 addMachineFunctionPass(RegAllocFastPass({onlyAllocateSGPRs, "sgpr", false}),
2482 PMW);
2483
2484 // Equivalent of PEI for SGPRs.
2485 addMachineFunctionPass(SILowerSGPRSpillsPass(), PMW);
2486
2487 // To Allocate wwm registers used in whole quad mode operations (for shaders).
2488 addMachineFunctionPass(SIPreAllocateWWMRegsPass(), PMW);
2489
2490 // WWM allocation - default to fast at -O0.
2491 if (WWMRegAllocNPM == RegAllocType::Greedy)
2492 addMachineFunctionPass(RAGreedyPass({onlyAllocateWWMRegs, "wwm"}), PMW);
2493 else
2494 addMachineFunctionPass(
2495 RegAllocFastPass({onlyAllocateWWMRegs, "wwm", false}), PMW);
2496
2497 addMachineFunctionPass(SILowerWWMCopiesPass(), PMW);
2498 addMachineFunctionPass(AMDGPUReserveWWMRegsPass(), PMW);
2499
2500 // VGPR allocation - default to fast at -O0.
2501 if (VGPRRegAllocNPM == RegAllocType::Greedy)
2502 addMachineFunctionPass(RAGreedyPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2503 else
2504 addMachineFunctionPass(RegAllocFastPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2505
2506 return Error::success();
2507}
2508
2509Error AMDGPUCodeGenPassBuilder::addOptimizedRegAlloc(
2510 PassManagerWrapper &PMW) const {
2511 if (EnableDCEInRA)
2512 insertPass<DetectDeadLanesPass>(DeadMachineInstructionElimPass());
2513
2514 // FIXME: when an instruction has a Killed operand, and the instruction is
2515 // inside a bundle, seems only the BUNDLE instruction appears as the Kills of
2516 // the register in LiveVariables, this would trigger a failure in verifier,
2517 // we should fix it and enable the verifier.
2518 if (OptVGPRLiveRange)
2519 insertPass<RequireAnalysisPass<LiveVariablesAnalysis, MachineFunction>>(
2521
2522 // This must be run immediately after phi elimination and before
2523 // TwoAddressInstructions, otherwise the processing of the tied operand of
2524 // SI_ELSE will introduce a copy of the tied operand source after the else.
2525 insertPass<PHIEliminationPass>(SILowerControlFlowPass());
2526
2528 insertPass<RenameIndependentSubregsPass>(GCNRewritePartialRegUsesPass());
2529
2530 if (isPassEnabled(EnablePreRAOptimizations))
2531 insertPass<MachineSchedulerPass>(GCNPreRAOptimizationsPass());
2532
2533 // Allow the scheduler to run before SIWholeQuadMode inserts exec manipulation
2534 // instructions that cause scheduling barriers.
2535 insertPass<MachineSchedulerPass>(SIWholeQuadModePass());
2536
2537 if (OptExecMaskPreRA)
2538 insertPass<MachineSchedulerPass>(SIOptimizeExecMaskingPreRAPass());
2539
2540 // This is not an essential optimization and it has a noticeable impact on
2541 // compilation time, so we only enable it from O2.
2542 if (TM.getOptLevel() > CodeGenOptLevel::Less)
2543 insertPass<MachineSchedulerPass>(SIFormMemoryClausesPass());
2544
2545 return Base::addOptimizedRegAlloc(PMW);
2546}
2547
2548void AMDGPUCodeGenPassBuilder::addPreRegAlloc(PassManagerWrapper &PMW) const {
2549 if (getOptLevel() != CodeGenOptLevel::None)
2550 addMachineFunctionPass(AMDGPUPrepareAGPRAllocPass(), PMW);
2551}
2552
2553Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
2554 PassManagerWrapper &PMW) const {
2555 if (auto Err = validateRegAllocOptions())
2556 return Err;
2557
2558 addMachineFunctionPass(GCNPreRALongBranchRegPass(), PMW);
2559
2560 // SGPR allocation - default to greedy at -O1 and above.
2561 if (SGPRRegAllocNPM == RegAllocType::Fast)
2562 addMachineFunctionPass(RegAllocFastPass({onlyAllocateSGPRs, "sgpr", false}),
2563 PMW);
2564 else
2565 addMachineFunctionPass(RAGreedyPass({onlyAllocateSGPRs, "sgpr"}), PMW);
2566
2567 // Commit allocated register changes. This is mostly necessary because too
2568 // many things rely on the use lists of the physical registers, such as the
2569 // verifier. This is only necessary with allocators which use LiveIntervals,
2570 // since FastRegAlloc does the replacements itself.
2571 addMachineFunctionPass(VirtRegRewriterPass(false), PMW);
2572
2573 // At this point, the sgpr-regalloc has been done and it is good to have the
2574 // stack slot coloring to try to optimize the SGPR spill stack indices before
2575 // attempting the custom SGPR spill lowering.
2576 addMachineFunctionPass(StackSlotColoringPass(), PMW);
2577
2578 // Equivalent of PEI for SGPRs.
2579 addMachineFunctionPass(SILowerSGPRSpillsPass(), PMW);
2580
2581 // To Allocate wwm registers used in whole quad mode operations (for shaders).
2582 addMachineFunctionPass(SIPreAllocateWWMRegsPass(), PMW);
2583
2584 // WWM allocation - default to greedy at -O1 and above.
2585 if (WWMRegAllocNPM == RegAllocType::Fast)
2586 addMachineFunctionPass(
2587 RegAllocFastPass({onlyAllocateWWMRegs, "wwm", false}), PMW);
2588 else
2589 addMachineFunctionPass(RAGreedyPass({onlyAllocateWWMRegs, "wwm"}), PMW);
2590 addMachineFunctionPass(SILowerWWMCopiesPass(), PMW);
2591 addMachineFunctionPass(VirtRegRewriterPass(false), PMW);
2592 addMachineFunctionPass(AMDGPUReserveWWMRegsPass(), PMW);
2593
2594 // VGPR allocation - default to greedy at -O1 and above.
2595 if (VGPRRegAllocNPM == RegAllocType::Fast)
2596 addMachineFunctionPass(RegAllocFastPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2597 else
2598 addMachineFunctionPass(RAGreedyPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2599
2600 addPreRewrite(PMW);
2601 addMachineFunctionPass(VirtRegRewriterPass(true), PMW);
2602
2603 addMachineFunctionPass(AMDGPUMarkLastScratchLoadPass(), PMW);
2604 return Error::success();
2605}
2606
2607void AMDGPUCodeGenPassBuilder::addPostRegAlloc(PassManagerWrapper &PMW) const {
2608 addMachineFunctionPass(SIFixVGPRCopiesPass(), PMW);
2609 if (TM.getOptLevel() > CodeGenOptLevel::None)
2610 addMachineFunctionPass(SIOptimizeExecMaskingPass(), PMW);
2611 Base::addPostRegAlloc(PMW);
2612}
2613
2614void AMDGPUCodeGenPassBuilder::addPreSched2(PassManagerWrapper &PMW) const {
2615 if (TM.getOptLevel() > CodeGenOptLevel::None)
2616 addMachineFunctionPass(SIShrinkInstructionsPass(), PMW);
2617 addMachineFunctionPass(SIPostRABundlerPass(), PMW);
2618}
2619
2620void AMDGPUCodeGenPassBuilder::addPostBBSections(
2621 PassManagerWrapper &PMW) const {
2622 // We run this later to avoid passes like livedebugvalues and BBSections
2623 // having to deal with the apparent multi-entry functions we may generate.
2624 addMachineFunctionPass(AMDGPUPreloadKernArgPrologPass(), PMW);
2625}
2626
2627void AMDGPUCodeGenPassBuilder::addPreEmitPass(PassManagerWrapper &PMW) const {
2628 if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less)) {
2629 addMachineFunctionPass(GCNCreateVOPDPass(), PMW);
2630 }
2631
2632 addMachineFunctionPass(SIMemoryLegalizerPass(), PMW);
2633 addMachineFunctionPass(SIInsertWaitcntsPass(), PMW);
2634
2635 addMachineFunctionPass(SIModeRegisterPass(), PMW);
2636
2637 if (TM.getOptLevel() > CodeGenOptLevel::None)
2638 addMachineFunctionPass(SIInsertHardClausesPass(), PMW);
2639
2640 addMachineFunctionPass(SILateBranchLoweringPass(), PMW);
2641
2642 if (isPassEnabled(EnableSetWavePriority, CodeGenOptLevel::Less))
2643 addMachineFunctionPass(AMDGPUSetWavePriorityPass(), PMW);
2644
2645 if (TM.getOptLevel() > CodeGenOptLevel::None)
2646 addMachineFunctionPass(SIPreEmitPeepholePass(), PMW);
2647
2648 // The hazard recognizer that runs as part of the post-ra scheduler does not
2649 // guarantee to be able handle all hazards correctly. This is because if there
2650 // are multiple scheduling regions in a basic block, the regions are scheduled
2651 // bottom up, so when we begin to schedule a region we don't know what
2652 // instructions were emitted directly before it.
2653 //
2654 // Here we add a stand-alone hazard recognizer pass which can handle all
2655 // cases.
2656 addMachineFunctionPass(PostRAHazardRecognizerPass(), PMW);
2657 addMachineFunctionPass(AMDGPUWaitSGPRHazardsPass(), PMW);
2658 addMachineFunctionPass(AMDGPULowerVGPREncodingPass(), PMW);
2659
2660 if (isPassEnabled(EnableInsertDelayAlu, CodeGenOptLevel::Less)) {
2661 addMachineFunctionPass(AMDGPUInsertDelayAluPass(), PMW);
2662 }
2663
2664 addMachineFunctionPass(BranchRelaxationPass(), PMW);
2665}
2666
2667bool AMDGPUCodeGenPassBuilder::isPassEnabled(const cl::opt<bool> &Opt,
2668 CodeGenOptLevel Level) const {
2669 if (Opt.getNumOccurrences())
2670 return Opt;
2671 if (TM.getOptLevel() < Level)
2672 return false;
2673 return Opt;
2674}
2675
2676void AMDGPUCodeGenPassBuilder::addEarlyCSEOrGVNPass(
2677 PassManagerWrapper &PMW) const {
2678 if (TM.getOptLevel() == CodeGenOptLevel::Aggressive)
2679 addFunctionPass(GVNPass(), PMW);
2680 else
2681 addFunctionPass(EarlyCSEPass(), PMW);
2682}
2683
2684void AMDGPUCodeGenPassBuilder::addStraightLineScalarOptimizationPasses(
2685 PassManagerWrapper &PMW) const {
2687 addFunctionPass(LoopDataPrefetchPass(), PMW);
2688
2689 addFunctionPass(SeparateConstOffsetFromGEPPass(), PMW);
2690
2691 // ReassociateGEPs exposes more opportunities for SLSR. See
2692 // the example in reassociate-geps-and-slsr.ll.
2693 addFunctionPass(StraightLineStrengthReducePass(), PMW);
2694
2695 // SeparateConstOffsetFromGEP and SLSR creates common expressions which GVN or
2696 // EarlyCSE can reuse.
2697 addEarlyCSEOrGVNPass(PMW);
2698
2699 // Run NaryReassociate after EarlyCSE/GVN to be more effective.
2700 addFunctionPass(NaryReassociatePass(), PMW);
2701
2702 // NaryReassociate on GEPs creates redundant common expressions, so run
2703 // EarlyCSE after it.
2704 addFunctionPass(EarlyCSEPass(), PMW);
2705}
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
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:4011
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.