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.
1631 !isGlobalISelAbortEnabled() || !NewRegBankSelect)
1632 addPass(createLCSSAPass());
1633
1634 if (TM->getOptLevel() > CodeGenOptLevel::Less)
1636
1637 return false;
1638}
1639
1640void GCNPassConfig::addMachineSSAOptimization() {
1642
1643 // We want to fold operands after PeepholeOptimizer has run (or as part of
1644 // it), because it will eliminate extra copies making it easier to fold the
1645 // real source operand. We want to eliminate dead instructions after, so that
1646 // we see fewer uses of the copies. We then need to clean up the dead
1647 // instructions leftover after the operands are folded as well.
1648 //
1649 // XXX - Can we get away without running DeadMachineInstructionElim again?
1650 addPass(&SIFoldOperandsLegacyID);
1651 if (EnableDPPCombine)
1652 addPass(&GCNDPPCombineLegacyID);
1654 if (isPassEnabled(EnableSDWAPeephole)) {
1655 addPass(&SIPeepholeSDWALegacyID);
1656 addPass(&EarlyMachineLICMID);
1657 addPass(&MachineCSELegacyID);
1658 addPass(&SIFoldOperandsLegacyID);
1659 }
1662}
1663
1664bool GCNPassConfig::addILPOpts() {
1666 addPass(&EarlyIfConverterLegacyID);
1667
1669 return false;
1670}
1671
1672bool GCNPassConfig::addInstSelector() {
1674 addPass(&SIFixSGPRCopiesLegacyID);
1676 return false;
1677}
1678
1679bool GCNPassConfig::addIRTranslator() {
1680 addPass(new IRTranslator(getOptLevel()));
1681 return false;
1682}
1683
1684void GCNPassConfig::addPreLegalizeMachineIR() {
1685 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1686 addPass(createAMDGPUPreLegalizeCombiner(IsOptNone));
1687 addPass(new Localizer());
1688}
1689
1690bool GCNPassConfig::addLegalizeMachineIR() {
1691 addPass(new Legalizer());
1692 return false;
1693}
1694
1695void GCNPassConfig::addPreRegBankSelect() {
1696 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1697 addPass(createAMDGPUPostLegalizeCombiner(IsOptNone));
1699}
1700
1701bool GCNPassConfig::addRegBankSelect() {
1702 if (NewRegBankSelect) {
1705 } else {
1706 addPass(new RegBankSelect());
1707 }
1708 return false;
1709}
1710
1711void GCNPassConfig::addPreGlobalInstructionSelect() {
1712 bool IsOptNone = getOptLevel() == CodeGenOptLevel::None;
1713 addPass(createAMDGPURegBankCombiner(IsOptNone));
1714}
1715
1716bool GCNPassConfig::addGlobalInstructionSelect() {
1717 addPass(new InstructionSelect(getOptLevel()));
1718 return false;
1719}
1720
1721void GCNPassConfig::addFastRegAlloc() {
1722 // FIXME: We have to disable the verifier here because of PHIElimination +
1723 // TwoAddressInstructions disabling it.
1724
1725 // This must be run immediately after phi elimination and before
1726 // TwoAddressInstructions, otherwise the processing of the tied operand of
1727 // SI_ELSE will introduce a copy of the tied operand source after the else.
1729
1731
1733}
1734
1735void GCNPassConfig::addPreRegAlloc() {
1736 if (getOptLevel() != CodeGenOptLevel::None)
1738}
1739
1740void GCNPassConfig::addOptimizedRegAlloc() {
1741 if (EnableDCEInRA)
1743
1744 // FIXME: when an instruction has a Killed operand, and the instruction is
1745 // inside a bundle, seems only the BUNDLE instruction appears as the Kills of
1746 // the register in LiveVariables, this would trigger a failure in verifier,
1747 // we should fix it and enable the verifier.
1748 if (OptVGPRLiveRange)
1750
1751 // This must be run immediately after phi elimination and before
1752 // TwoAddressInstructions, otherwise the processing of the tied operand of
1753 // SI_ELSE will introduce a copy of the tied operand source after the else.
1755
1758
1759 if (isPassEnabled(EnablePreRAOptimizations))
1761
1762 // Allow the scheduler to run before SIWholeQuadMode inserts exec manipulation
1763 // instructions that cause scheduling barriers.
1765
1766 if (OptExecMaskPreRA)
1768
1769 // This is not an essential optimization and it has a noticeable impact on
1770 // compilation time, so we only enable it from O2.
1771 if (TM->getOptLevel() > CodeGenOptLevel::Less)
1773
1775}
1776
1777bool GCNPassConfig::addPreRewrite() {
1779 addPass(&GCNNSAReassignID);
1780
1782 return true;
1783}
1784
1785FunctionPass *GCNPassConfig::createSGPRAllocPass(bool Optimized) {
1786 // Initialize the global default.
1787 llvm::call_once(InitializeDefaultSGPRRegisterAllocatorFlag,
1788 initializeDefaultSGPRRegisterAllocatorOnce);
1789
1790 RegisterRegAlloc::FunctionPassCtor Ctor = SGPRRegisterRegAlloc::getDefault();
1791 if (Ctor != useDefaultRegisterAllocator)
1792 return Ctor();
1793
1794 if (Optimized)
1795 return createGreedyRegisterAllocator(onlyAllocateSGPRs);
1796
1797 return createFastRegisterAllocator(onlyAllocateSGPRs, false);
1798}
1799
1800FunctionPass *GCNPassConfig::createVGPRAllocPass(bool Optimized) {
1801 // Initialize the global default.
1802 llvm::call_once(InitializeDefaultVGPRRegisterAllocatorFlag,
1803 initializeDefaultVGPRRegisterAllocatorOnce);
1804
1805 RegisterRegAlloc::FunctionPassCtor Ctor = VGPRRegisterRegAlloc::getDefault();
1806 if (Ctor != useDefaultRegisterAllocator)
1807 return Ctor();
1808
1809 if (Optimized)
1810 return createGreedyVGPRRegisterAllocator();
1811
1812 return createFastVGPRRegisterAllocator();
1813}
1814
1815FunctionPass *GCNPassConfig::createWWMRegAllocPass(bool Optimized) {
1816 // Initialize the global default.
1817 llvm::call_once(InitializeDefaultWWMRegisterAllocatorFlag,
1818 initializeDefaultWWMRegisterAllocatorOnce);
1819
1820 RegisterRegAlloc::FunctionPassCtor Ctor = WWMRegisterRegAlloc::getDefault();
1821 if (Ctor != useDefaultRegisterAllocator)
1822 return Ctor();
1823
1824 if (Optimized)
1825 return createGreedyWWMRegisterAllocator();
1826
1827 return createFastWWMRegisterAllocator();
1828}
1829
1830FunctionPass *GCNPassConfig::createRegAllocPass(bool Optimized) {
1831 llvm_unreachable("should not be used");
1832}
1833
1835 "-regalloc not supported with amdgcn. Use -sgpr-regalloc, -wwm-regalloc, "
1836 "and -vgpr-regalloc";
1837
1838bool GCNPassConfig::addRegAssignAndRewriteFast() {
1839 if (!usingDefaultRegAlloc())
1841
1842 addPass(&GCNPreRALongBranchRegID);
1843
1844 addPass(createSGPRAllocPass(false));
1845
1846 // Equivalent of PEI for SGPRs.
1847 addPass(&SILowerSGPRSpillsLegacyID);
1848
1849 // To Allocate wwm registers used in whole quad mode operations (for shaders).
1851
1852 // For allocating other wwm register operands.
1853 addPass(createWWMRegAllocPass(false));
1854
1855 addPass(&SILowerWWMCopiesLegacyID);
1857
1858 // For allocating per-thread VGPRs.
1859 addPass(createVGPRAllocPass(false));
1860
1861 return true;
1862}
1863
1864bool GCNPassConfig::addRegAssignAndRewriteOptimized() {
1865 if (!usingDefaultRegAlloc())
1867
1868 addPass(&GCNPreRALongBranchRegID);
1869
1870 addPass(createSGPRAllocPass(true));
1871
1872 // Commit allocated register changes. This is mostly necessary because too
1873 // many things rely on the use lists of the physical registers, such as the
1874 // verifier. This is only necessary with allocators which use LiveIntervals,
1875 // since FastRegAlloc does the replacements itself.
1876 addPass(createVirtRegRewriter(false));
1877
1878 // At this point, the sgpr-regalloc has been done and it is good to have the
1879 // stack slot coloring to try to optimize the SGPR spill stack indices before
1880 // attempting the custom SGPR spill lowering.
1881 addPass(&StackSlotColoringID);
1882
1883 // Equivalent of PEI for SGPRs.
1884 addPass(&SILowerSGPRSpillsLegacyID);
1885
1886 // To Allocate wwm registers used in whole quad mode operations (for shaders).
1888
1889 // For allocating other whole wave mode registers.
1890 addPass(createWWMRegAllocPass(true));
1891 addPass(&SILowerWWMCopiesLegacyID);
1892 addPass(createVirtRegRewriter(false));
1894
1895 // For allocating per-thread VGPRs.
1896 addPass(createVGPRAllocPass(true));
1897
1898 addPreRewrite();
1899 addPass(&VirtRegRewriterID);
1900
1902
1903 return true;
1904}
1905
1906void GCNPassConfig::addPostRegAlloc() {
1907 addPass(&SIFixVGPRCopiesID);
1908 if (getOptLevel() > CodeGenOptLevel::None)
1911}
1912
1913void GCNPassConfig::addPreSched2() {
1914 if (TM->getOptLevel() > CodeGenOptLevel::None)
1916 addPass(&SIPostRABundlerLegacyID);
1917}
1918
1919void GCNPassConfig::addPreEmitPass() {
1920 if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less))
1921 addPass(&GCNCreateVOPDID);
1922 addPass(createSIMemoryLegalizerPass());
1923 addPass(createSIInsertWaitcntsPass());
1924
1925 addPass(createSIModeRegisterPass());
1926
1927 if (getOptLevel() > CodeGenOptLevel::None)
1928 addPass(&SIInsertHardClausesID);
1929
1931 if (isPassEnabled(EnableSetWavePriority, CodeGenOptLevel::Less))
1933 if (getOptLevel() > CodeGenOptLevel::None)
1934 addPass(&SIPreEmitPeepholeID);
1935 // The hazard recognizer that runs as part of the post-ra scheduler does not
1936 // guarantee to be able handle all hazards correctly. This is because if there
1937 // are multiple scheduling regions in a basic block, the regions are scheduled
1938 // bottom up, so when we begin to schedule a region we don't know what
1939 // instructions were emitted directly before it.
1940 //
1941 // Here we add a stand-alone hazard recognizer pass which can handle all
1942 // cases.
1943 addPass(&PostRAHazardRecognizerID);
1944
1946
1948
1949 if (isPassEnabled(EnableInsertDelayAlu, CodeGenOptLevel::Less))
1950 addPass(&AMDGPUInsertDelayAluID);
1951
1952 addPass(&BranchRelaxationPassID);
1953}
1954
1955void GCNPassConfig::addPostBBSections() {
1956 // We run this later to avoid passes like livedebugvalues and BBSections
1957 // having to deal with the apparent multi-entry functions we may generate.
1959}
1960
1962 return new GCNPassConfig(*this, PM);
1963}
1964
1970
1977
1981
1988
1991 SMDiagnostic &Error, SMRange &SourceRange) const {
1992 const yaml::SIMachineFunctionInfo &YamlMFI =
1993 static_cast<const yaml::SIMachineFunctionInfo &>(MFI_);
1994 MachineFunction &MF = PFS.MF;
1996 const GCNSubtarget &ST = MF.getSubtarget<GCNSubtarget>();
1997
1998 if (MFI->initializeBaseYamlFields(YamlMFI, MF, PFS, Error, SourceRange))
1999 return true;
2000
2001 if (MFI->Occupancy == 0) {
2002 // Fixup the subtarget dependent default value.
2003 MFI->Occupancy = ST.getOccupancyWithWorkGroupSizes(MF).second;
2004 }
2005
2006 auto parseRegister = [&](const yaml::StringValue &RegName, Register &RegVal) {
2007 Register TempReg;
2008 if (parseNamedRegisterReference(PFS, TempReg, RegName.Value, Error)) {
2009 SourceRange = RegName.SourceRange;
2010 return true;
2011 }
2012 RegVal = TempReg;
2013
2014 return false;
2015 };
2016
2017 auto parseOptionalRegister = [&](const yaml::StringValue &RegName,
2018 Register &RegVal) {
2019 return !RegName.Value.empty() && parseRegister(RegName, RegVal);
2020 };
2021
2022 if (parseOptionalRegister(YamlMFI.VGPRForAGPRCopy, MFI->VGPRForAGPRCopy))
2023 return true;
2024
2025 if (parseOptionalRegister(YamlMFI.SGPRForEXECCopy, MFI->SGPRForEXECCopy))
2026 return true;
2027
2028 if (parseOptionalRegister(YamlMFI.LongBranchReservedReg,
2029 MFI->LongBranchReservedReg))
2030 return true;
2031
2032 auto diagnoseRegisterClass = [&](const yaml::StringValue &RegName) {
2033 // Create a diagnostic for a the register string literal.
2034 const MemoryBuffer &Buffer =
2035 *PFS.SM->getMemoryBuffer(PFS.SM->getMainFileID());
2036 Error = SMDiagnostic(*PFS.SM, SMLoc(), Buffer.getBufferIdentifier(), 1,
2037 RegName.Value.size(), SourceMgr::DK_Error,
2038 "incorrect register class for field", RegName.Value,
2039 {}, {});
2040 SourceRange = RegName.SourceRange;
2041 return true;
2042 };
2043
2044 if (parseRegister(YamlMFI.ScratchRSrcReg, MFI->ScratchRSrcReg) ||
2045 parseRegister(YamlMFI.FrameOffsetReg, MFI->FrameOffsetReg) ||
2046 parseRegister(YamlMFI.StackPtrOffsetReg, MFI->StackPtrOffsetReg))
2047 return true;
2048
2049 if (MFI->ScratchRSrcReg != AMDGPU::PRIVATE_RSRC_REG &&
2050 !AMDGPU::SGPR_128RegClass.contains(MFI->ScratchRSrcReg)) {
2051 return diagnoseRegisterClass(YamlMFI.ScratchRSrcReg);
2052 }
2053
2054 if (MFI->FrameOffsetReg != AMDGPU::FP_REG &&
2055 !AMDGPU::SGPR_32RegClass.contains(MFI->FrameOffsetReg)) {
2056 return diagnoseRegisterClass(YamlMFI.FrameOffsetReg);
2057 }
2058
2059 if (MFI->StackPtrOffsetReg != AMDGPU::SP_REG &&
2060 !AMDGPU::SGPR_32RegClass.contains(MFI->StackPtrOffsetReg)) {
2061 return diagnoseRegisterClass(YamlMFI.StackPtrOffsetReg);
2062 }
2063
2064 for (const auto &YamlReg : YamlMFI.WWMReservedRegs) {
2065 Register ParsedReg;
2066 if (parseRegister(YamlReg, ParsedReg))
2067 return true;
2068
2069 MFI->reserveWWMRegister(ParsedReg);
2070 }
2071
2072 for (const auto &[_, Info] : PFS.VRegInfosNamed) {
2073 MFI->setFlag(Info->VReg, Info->Flags);
2074 }
2075 for (const auto &[_, Info] : PFS.VRegInfos) {
2076 MFI->setFlag(Info->VReg, Info->Flags);
2077 }
2078
2079 for (const auto &YamlRegStr : YamlMFI.SpillPhysVGPRS) {
2080 Register ParsedReg;
2081 if (parseRegister(YamlRegStr, ParsedReg))
2082 return true;
2083 MFI->SpillPhysVGPRs.push_back(ParsedReg);
2084 }
2085
2086 auto parseAndCheckArgument = [&](const std::optional<yaml::SIArgument> &A,
2087 const TargetRegisterClass &RC,
2088 ArgDescriptor &Arg, unsigned UserSGPRs,
2089 unsigned SystemSGPRs) {
2090 // Skip parsing if it's not present.
2091 if (!A)
2092 return false;
2093
2094 if (A->IsRegister) {
2095 Register Reg;
2096 if (parseNamedRegisterReference(PFS, Reg, A->RegisterName.Value, Error)) {
2097 SourceRange = A->RegisterName.SourceRange;
2098 return true;
2099 }
2100 if (!RC.contains(Reg))
2101 return diagnoseRegisterClass(A->RegisterName);
2103 } else
2104 Arg = ArgDescriptor::createStack(A->StackOffset);
2105 // Check and apply the optional mask.
2106 if (A->Mask)
2107 Arg = ArgDescriptor::createArg(Arg, *A->Mask);
2108
2109 MFI->NumUserSGPRs += UserSGPRs;
2110 MFI->NumSystemSGPRs += SystemSGPRs;
2111 return false;
2112 };
2113
2114 if (YamlMFI.ArgInfo &&
2115 (parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentBuffer,
2116 AMDGPU::SGPR_128RegClass,
2117 MFI->ArgInfo.PrivateSegmentBuffer, 4, 0) ||
2118 parseAndCheckArgument(YamlMFI.ArgInfo->DispatchPtr,
2119 AMDGPU::SReg_64RegClass, MFI->ArgInfo.DispatchPtr,
2120 2, 0) ||
2121 parseAndCheckArgument(YamlMFI.ArgInfo->QueuePtr, AMDGPU::SReg_64RegClass,
2122 MFI->ArgInfo.QueuePtr, 2, 0) ||
2123 parseAndCheckArgument(YamlMFI.ArgInfo->KernargSegmentPtr,
2124 AMDGPU::SReg_64RegClass,
2125 MFI->ArgInfo.KernargSegmentPtr, 2, 0) ||
2126 parseAndCheckArgument(YamlMFI.ArgInfo->DispatchID,
2127 AMDGPU::SReg_64RegClass, MFI->ArgInfo.DispatchID,
2128 2, 0) ||
2129 parseAndCheckArgument(YamlMFI.ArgInfo->FlatScratchInit,
2130 AMDGPU::SReg_64RegClass,
2131 MFI->ArgInfo.FlatScratchInit, 2, 0) ||
2132 parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentSize,
2133 AMDGPU::SGPR_32RegClass,
2134 MFI->ArgInfo.PrivateSegmentSize, 0, 0) ||
2135 parseAndCheckArgument(YamlMFI.ArgInfo->LDSKernelId,
2136 AMDGPU::SGPR_32RegClass,
2137 MFI->ArgInfo.LDSKernelId, 0, 1) ||
2138 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDX,
2139 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDX,
2140 0, 1) ||
2141 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDY,
2142 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDY,
2143 0, 1) ||
2144 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupIDZ,
2145 AMDGPU::SGPR_32RegClass, MFI->ArgInfo.WorkGroupIDZ,
2146 0, 1) ||
2147 parseAndCheckArgument(YamlMFI.ArgInfo->WorkGroupInfo,
2148 AMDGPU::SGPR_32RegClass,
2149 MFI->ArgInfo.WorkGroupInfo, 0, 1) ||
2150 parseAndCheckArgument(YamlMFI.ArgInfo->PrivateSegmentWaveByteOffset,
2151 AMDGPU::SGPR_32RegClass,
2152 MFI->ArgInfo.PrivateSegmentWaveByteOffset, 0, 1) ||
2153 parseAndCheckArgument(YamlMFI.ArgInfo->ImplicitArgPtr,
2154 AMDGPU::SReg_64RegClass,
2155 MFI->ArgInfo.ImplicitArgPtr, 0, 0) ||
2156 parseAndCheckArgument(YamlMFI.ArgInfo->ImplicitBufferPtr,
2157 AMDGPU::SReg_64RegClass,
2158 MFI->ArgInfo.ImplicitBufferPtr, 2, 0) ||
2159 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDX,
2160 AMDGPU::VGPR_32RegClass,
2161 MFI->ArgInfo.WorkItemIDX, 0, 0) ||
2162 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDY,
2163 AMDGPU::VGPR_32RegClass,
2164 MFI->ArgInfo.WorkItemIDY, 0, 0) ||
2165 parseAndCheckArgument(YamlMFI.ArgInfo->WorkItemIDZ,
2166 AMDGPU::VGPR_32RegClass,
2167 MFI->ArgInfo.WorkItemIDZ, 0, 0)))
2168 return true;
2169
2170 // Parse FirstKernArgPreloadReg separately, since it's a Register,
2171 // not ArgDescriptor.
2172 if (YamlMFI.ArgInfo && YamlMFI.ArgInfo->FirstKernArgPreloadReg) {
2173 const yaml::SIArgument &A = *YamlMFI.ArgInfo->FirstKernArgPreloadReg;
2174
2175 if (!A.IsRegister) {
2176 // For stack arguments, we don't have RegisterName.SourceRange,
2177 // but we should have some location info from the YAML parser
2178 const MemoryBuffer &Buffer =
2179 *PFS.SM->getMemoryBuffer(PFS.SM->getMainFileID());
2180 // Create a minimal valid source range
2182 SMRange Range(Loc, Loc);
2183
2185 *PFS.SM, Loc, Buffer.getBufferIdentifier(), 1, 0, SourceMgr::DK_Error,
2186 "firstKernArgPreloadReg must be a register, not a stack location", "",
2187 {}, {});
2188
2189 SourceRange = Range;
2190 return true;
2191 }
2192
2193 Register Reg;
2194 if (parseNamedRegisterReference(PFS, Reg, A.RegisterName.Value, Error)) {
2195 SourceRange = A.RegisterName.SourceRange;
2196 return true;
2197 }
2198
2199 if (!AMDGPU::SGPR_32RegClass.contains(Reg))
2200 return diagnoseRegisterClass(A.RegisterName);
2201
2202 MFI->ArgInfo.FirstKernArgPreloadReg = Reg;
2203 MFI->NumUserSGPRs += YamlMFI.NumKernargPreloadSGPRs;
2204 }
2205
2206 if (ST.hasFeature(AMDGPU::FeatureDX10ClampAndIEEEMode)) {
2207 MFI->Mode.IEEE = YamlMFI.Mode.IEEE;
2208 MFI->Mode.DX10Clamp = YamlMFI.Mode.DX10Clamp;
2209 }
2210
2211 // FIXME: Move proper support for denormal-fp-math into base MachineFunction
2212 MFI->Mode.FP32Denormals.Input = YamlMFI.Mode.FP32InputDenormals
2215 MFI->Mode.FP32Denormals.Output = YamlMFI.Mode.FP32OutputDenormals
2218
2225
2226 if (YamlMFI.HasInitWholeWave)
2227 MFI->setInitWholeWave();
2228
2229 return false;
2230}
2231
2232//===----------------------------------------------------------------------===//
2233// AMDGPU CodeGen Pass Builder interface.
2234//===----------------------------------------------------------------------===//
2235
2236AMDGPUCodeGenPassBuilder::AMDGPUCodeGenPassBuilder(
2237 GCNTargetMachine &TM, const CGPassBuilderOption &Opts,
2239 : CodeGenPassBuilder(TM, Opts, PIC) {
2240 Opt.MISchedPostRA = true;
2241 Opt.RequiresCodeGenSCCOrder = true;
2242 // Exceptions and StackMaps are not supported, so these passes will never do
2243 // anything.
2244 // Garbage collection is not supported.
2245 disablePass<StackMapLivenessPass, FuncletLayoutPass, PatchableFunctionPass,
2247}
2248
2249void AMDGPUCodeGenPassBuilder::addIRPasses(PassManagerWrapper &PMW) const {
2250 if (RemoveIncompatibleFunctions && TM.getTargetTriple().isAMDGCN()) {
2251 flushFPMsToMPM(PMW);
2252 addModulePass(AMDGPURemoveIncompatibleFunctionsPass(TM), PMW);
2253 }
2254
2255 flushFPMsToMPM(PMW);
2256
2257 if (TM.getTargetTriple().isAMDGCN())
2258 addModulePass(AMDGPUPrintfRuntimeBindingPass(), PMW);
2259
2260 if (LowerCtorDtor)
2261 addModulePass(AMDGPUCtorDtorLoweringPass(), PMW);
2262
2263 if (isPassEnabled(EnableImageIntrinsicOptimizer))
2264 addFunctionPass(AMDGPUImageIntrinsicOptimizerPass(TM), PMW);
2265
2267 addFunctionPass(AMDGPUUniformIntrinsicCombinePass(), PMW);
2268 // This can be disabled by passing ::Disable here or on the command line
2269 // with --expand-variadics-override=disable.
2270 flushFPMsToMPM(PMW);
2272
2273 addModulePass(AMDGPUAlwaysInlinePass(), PMW);
2274 addModulePass(AlwaysInlinerPass(), PMW);
2275
2276 addModulePass(AMDGPUExportKernelRuntimeHandlesPass(), PMW);
2277
2279 addModulePass(AMDGPULowerExecSyncPass(), PMW);
2280
2281 if (EnableSwLowerLDS)
2282 addModulePass(AMDGPUSwLowerLDSPass(TM), PMW);
2283
2284 // Runs before PromoteAlloca so the latter can account for function uses
2286 addModulePass(AMDGPULowerModuleLDSPass(TM), PMW);
2287
2288 // Run atomic optimizer before Atomic Expand
2289 if (TM.getOptLevel() >= CodeGenOptLevel::Less &&
2291 addFunctionPass(
2293
2294 addFunctionPass(AtomicExpandPass(TM), PMW);
2295
2296 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2297 addFunctionPass(AMDGPUPromoteAllocaPass(TM), PMW);
2298 if (isPassEnabled(EnableScalarIRPasses))
2299 addStraightLineScalarOptimizationPasses(PMW);
2300
2301 // TODO: Handle EnableAMDGPUAliasAnalysis
2302
2303 // TODO: May want to move later or split into an early and late one.
2304 addFunctionPass(AMDGPUCodeGenPreparePass(TM), PMW);
2305
2306 // Try to hoist loop invariant parts of divisions AMDGPUCodeGenPrepare may
2307 // have expanded.
2308 if (TM.getOptLevel() > CodeGenOptLevel::Less) {
2310 /*UseMemorySSA=*/true),
2311 PMW);
2312 }
2313 }
2314
2315 Base::addIRPasses(PMW);
2316
2317 // EarlyCSE is not always strong enough to clean up what LSR produces. For
2318 // example, GVN can combine
2319 //
2320 // %0 = add %a, %b
2321 // %1 = add %b, %a
2322 //
2323 // and
2324 //
2325 // %0 = shl nsw %a, 2
2326 // %1 = shl %a, 2
2327 //
2328 // but EarlyCSE can do neither of them.
2329 if (isPassEnabled(EnableScalarIRPasses))
2330 addEarlyCSEOrGVNPass(PMW);
2331}
2332
2333void AMDGPUCodeGenPassBuilder::addCodeGenPrepare(
2334 PassManagerWrapper &PMW) const {
2335 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2336 flushFPMsToMPM(PMW);
2337 addModulePass(AMDGPUPreloadKernelArgumentsPass(TM), PMW);
2338 }
2339
2341 addFunctionPass(AMDGPULowerKernelArgumentsPass(TM), PMW);
2342
2343 Base::addCodeGenPrepare(PMW);
2344
2345 if (isPassEnabled(EnableLoadStoreVectorizer))
2346 addFunctionPass(LoadStoreVectorizerPass(), PMW);
2347
2348 // This lowering has been placed after codegenprepare to take advantage of
2349 // address mode matching (which is why it isn't put with the LDS lowerings).
2350 // It could be placed anywhere before uniformity annotations (an analysis
2351 // that it changes by splitting up fat pointers into their components)
2352 // but has been put before switch lowering and CFG flattening so that those
2353 // passes can run on the more optimized control flow this pass creates in
2354 // many cases.
2355 flushFPMsToMPM(PMW);
2356 addModulePass(AMDGPULowerBufferFatPointersPass(TM), PMW);
2357 flushFPMsToMPM(PMW);
2358 requireCGSCCOrder(PMW);
2359
2360 addModulePass(AMDGPULowerIntrinsicsPass(TM), PMW);
2361
2362 // LowerSwitch pass may introduce unreachable blocks that can cause unexpected
2363 // behavior for subsequent passes. Placing it here seems better that these
2364 // blocks would get cleaned up by UnreachableBlockElim inserted next in the
2365 // pass flow.
2366 addFunctionPass(LowerSwitchPass(), PMW);
2367}
2368
2369void AMDGPUCodeGenPassBuilder::addPreISel(PassManagerWrapper &PMW) const {
2370
2371 if (TM.getOptLevel() > CodeGenOptLevel::None) {
2372 addFunctionPass(FlattenCFGPass(), PMW);
2373 addFunctionPass(SinkingPass(), PMW);
2374 addFunctionPass(AMDGPULateCodeGenPreparePass(TM), PMW);
2375 }
2376
2377 // Merge divergent exit nodes. StructurizeCFG won't recognize the multi-exit
2378 // regions formed by them.
2379
2380 addFunctionPass(AMDGPUUnifyDivergentExitNodesPass(), PMW);
2381 addFunctionPass(FixIrreduciblePass(), PMW);
2382 addFunctionPass(UnifyLoopExitsPass(), PMW);
2383 addFunctionPass(StructurizeCFGPass(/*SkipUniformRegions=*/false), PMW);
2384
2385 addFunctionPass(AMDGPUAnnotateUniformValuesPass(), PMW);
2386
2387 addFunctionPass(SIAnnotateControlFlowPass(TM), PMW);
2388
2389 // TODO: Move this right after structurizeCFG to avoid extra divergence
2390 // analysis. This depends on stopping SIAnnotateControlFlow from making
2391 // control flow modifications.
2392 addFunctionPass(AMDGPURewriteUndefForPHIPass(), PMW);
2393
2396 !isGlobalISelAbortEnabled() || !NewRegBankSelect)
2397 addFunctionPass(LCSSAPass(), PMW);
2398
2399 if (TM.getOptLevel() > CodeGenOptLevel::Less) {
2400 flushFPMsToMPM(PMW);
2401 addModulePass(AMDGPUPerfHintAnalysisPass(TM), PMW);
2402 }
2403
2404 // FIXME: Why isn't this queried as required from AMDGPUISelDAGToDAG, and why
2405 // isn't this in addInstSelector?
2407 /*Force=*/true);
2408}
2409
2410void AMDGPUCodeGenPassBuilder::addILPOpts(PassManagerWrapper &PMW) const {
2412 addMachineFunctionPass(EarlyIfConverterPass(), PMW);
2413
2414 Base::addILPOpts(PMW);
2415}
2416
2417void AMDGPUCodeGenPassBuilder::addAsmPrinterBegin(
2418 PassManagerWrapper &PMW) const {
2419 // TODO: Add AsmPrinterBegin
2420}
2421
2422void AMDGPUCodeGenPassBuilder::addAsmPrinter(PassManagerWrapper &PMW) const {
2423 // TODO: Add AsmPrinter.
2424}
2425
2426void AMDGPUCodeGenPassBuilder::addAsmPrinterEnd(PassManagerWrapper &PMW) const {
2427 // TODO: Add AsmPrinterEnd
2428}
2429
2430Error AMDGPUCodeGenPassBuilder::addInstSelector(PassManagerWrapper &PMW) const {
2431 addMachineFunctionPass(AMDGPUISelDAGToDAGPass(TM), PMW);
2432 addMachineFunctionPass(SIFixSGPRCopiesPass(), PMW);
2433 addMachineFunctionPass(SILowerI1CopiesPass(), PMW);
2434 return Error::success();
2435}
2436
2437void AMDGPUCodeGenPassBuilder::addPreRewrite(PassManagerWrapper &PMW) const {
2438 if (EnableRegReassign) {
2439 addMachineFunctionPass(GCNNSAReassignPass(), PMW);
2440 }
2441
2442 addMachineFunctionPass(AMDGPURewriteAGPRCopyMFMAPass(), PMW);
2443}
2444
2445void AMDGPUCodeGenPassBuilder::addMachineSSAOptimization(
2446 PassManagerWrapper &PMW) const {
2447 Base::addMachineSSAOptimization(PMW);
2448
2449 addMachineFunctionPass(SIFoldOperandsPass(), PMW);
2450 if (EnableDPPCombine) {
2451 addMachineFunctionPass(GCNDPPCombinePass(), PMW);
2452 }
2453 addMachineFunctionPass(SILoadStoreOptimizerPass(), PMW);
2454 if (isPassEnabled(EnableSDWAPeephole)) {
2455 addMachineFunctionPass(SIPeepholeSDWAPass(), PMW);
2456 addMachineFunctionPass(EarlyMachineLICMPass(), PMW);
2457 addMachineFunctionPass(MachineCSEPass(), PMW);
2458 addMachineFunctionPass(SIFoldOperandsPass(), PMW);
2459 }
2460 addMachineFunctionPass(DeadMachineInstructionElimPass(), PMW);
2461 addMachineFunctionPass(SIShrinkInstructionsPass(), PMW);
2462}
2463
2464Error AMDGPUCodeGenPassBuilder::addFastRegAlloc(PassManagerWrapper &PMW) const {
2465 insertPass<PHIEliminationPass>(SILowerControlFlowPass());
2466
2467 insertPass<TwoAddressInstructionPass>(SIWholeQuadModePass());
2468
2469 return Base::addFastRegAlloc(PMW);
2470}
2471
2472Error AMDGPUCodeGenPassBuilder::addRegAssignmentFast(
2473 PassManagerWrapper &PMW) const {
2474 if (auto Err = validateRegAllocOptions())
2475 return Err;
2476
2477 addMachineFunctionPass(GCNPreRALongBranchRegPass(), PMW);
2478
2479 // SGPR allocation - default to fast at -O0.
2480 if (SGPRRegAllocNPM == RegAllocType::Greedy)
2481 addMachineFunctionPass(RAGreedyPass({onlyAllocateSGPRs, "sgpr"}), PMW);
2482 else
2483 addMachineFunctionPass(RegAllocFastPass({onlyAllocateSGPRs, "sgpr", false}),
2484 PMW);
2485
2486 // Equivalent of PEI for SGPRs.
2487 addMachineFunctionPass(SILowerSGPRSpillsPass(), PMW);
2488
2489 // To Allocate wwm registers used in whole quad mode operations (for shaders).
2490 addMachineFunctionPass(SIPreAllocateWWMRegsPass(), PMW);
2491
2492 // WWM allocation - default to fast at -O0.
2493 if (WWMRegAllocNPM == RegAllocType::Greedy)
2494 addMachineFunctionPass(RAGreedyPass({onlyAllocateWWMRegs, "wwm"}), PMW);
2495 else
2496 addMachineFunctionPass(
2497 RegAllocFastPass({onlyAllocateWWMRegs, "wwm", false}), PMW);
2498
2499 addMachineFunctionPass(SILowerWWMCopiesPass(), PMW);
2500 addMachineFunctionPass(AMDGPUReserveWWMRegsPass(), PMW);
2501
2502 // VGPR allocation - default to fast at -O0.
2503 if (VGPRRegAllocNPM == RegAllocType::Greedy)
2504 addMachineFunctionPass(RAGreedyPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2505 else
2506 addMachineFunctionPass(RegAllocFastPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2507
2508 return Error::success();
2509}
2510
2511Error AMDGPUCodeGenPassBuilder::addOptimizedRegAlloc(
2512 PassManagerWrapper &PMW) const {
2513 if (EnableDCEInRA)
2514 insertPass<DetectDeadLanesPass>(DeadMachineInstructionElimPass());
2515
2516 // FIXME: when an instruction has a Killed operand, and the instruction is
2517 // inside a bundle, seems only the BUNDLE instruction appears as the Kills of
2518 // the register in LiveVariables, this would trigger a failure in verifier,
2519 // we should fix it and enable the verifier.
2520 if (OptVGPRLiveRange)
2521 insertPass<RequireAnalysisPass<LiveVariablesAnalysis, MachineFunction>>(
2523
2524 // This must be run immediately after phi elimination and before
2525 // TwoAddressInstructions, otherwise the processing of the tied operand of
2526 // SI_ELSE will introduce a copy of the tied operand source after the else.
2527 insertPass<PHIEliminationPass>(SILowerControlFlowPass());
2528
2530 insertPass<RenameIndependentSubregsPass>(GCNRewritePartialRegUsesPass());
2531
2532 if (isPassEnabled(EnablePreRAOptimizations))
2533 insertPass<MachineSchedulerPass>(GCNPreRAOptimizationsPass());
2534
2535 // Allow the scheduler to run before SIWholeQuadMode inserts exec manipulation
2536 // instructions that cause scheduling barriers.
2537 insertPass<MachineSchedulerPass>(SIWholeQuadModePass());
2538
2539 if (OptExecMaskPreRA)
2540 insertPass<MachineSchedulerPass>(SIOptimizeExecMaskingPreRAPass());
2541
2542 // This is not an essential optimization and it has a noticeable impact on
2543 // compilation time, so we only enable it from O2.
2544 if (TM.getOptLevel() > CodeGenOptLevel::Less)
2545 insertPass<MachineSchedulerPass>(SIFormMemoryClausesPass());
2546
2547 return Base::addOptimizedRegAlloc(PMW);
2548}
2549
2550void AMDGPUCodeGenPassBuilder::addPreRegAlloc(PassManagerWrapper &PMW) const {
2551 if (getOptLevel() != CodeGenOptLevel::None)
2552 addMachineFunctionPass(AMDGPUPrepareAGPRAllocPass(), PMW);
2553}
2554
2555Error AMDGPUCodeGenPassBuilder::addRegAssignmentOptimized(
2556 PassManagerWrapper &PMW) const {
2557 if (auto Err = validateRegAllocOptions())
2558 return Err;
2559
2560 addMachineFunctionPass(GCNPreRALongBranchRegPass(), PMW);
2561
2562 // SGPR allocation - default to greedy at -O1 and above.
2563 if (SGPRRegAllocNPM == RegAllocType::Fast)
2564 addMachineFunctionPass(RegAllocFastPass({onlyAllocateSGPRs, "sgpr", false}),
2565 PMW);
2566 else
2567 addMachineFunctionPass(RAGreedyPass({onlyAllocateSGPRs, "sgpr"}), PMW);
2568
2569 // Commit allocated register changes. This is mostly necessary because too
2570 // many things rely on the use lists of the physical registers, such as the
2571 // verifier. This is only necessary with allocators which use LiveIntervals,
2572 // since FastRegAlloc does the replacements itself.
2573 addMachineFunctionPass(VirtRegRewriterPass(false), PMW);
2574
2575 // At this point, the sgpr-regalloc has been done and it is good to have the
2576 // stack slot coloring to try to optimize the SGPR spill stack indices before
2577 // attempting the custom SGPR spill lowering.
2578 addMachineFunctionPass(StackSlotColoringPass(), PMW);
2579
2580 // Equivalent of PEI for SGPRs.
2581 addMachineFunctionPass(SILowerSGPRSpillsPass(), PMW);
2582
2583 // To Allocate wwm registers used in whole quad mode operations (for shaders).
2584 addMachineFunctionPass(SIPreAllocateWWMRegsPass(), PMW);
2585
2586 // WWM allocation - default to greedy at -O1 and above.
2587 if (WWMRegAllocNPM == RegAllocType::Fast)
2588 addMachineFunctionPass(
2589 RegAllocFastPass({onlyAllocateWWMRegs, "wwm", false}), PMW);
2590 else
2591 addMachineFunctionPass(RAGreedyPass({onlyAllocateWWMRegs, "wwm"}), PMW);
2592 addMachineFunctionPass(SILowerWWMCopiesPass(), PMW);
2593 addMachineFunctionPass(VirtRegRewriterPass(false), PMW);
2594 addMachineFunctionPass(AMDGPUReserveWWMRegsPass(), PMW);
2595
2596 // VGPR allocation - default to greedy at -O1 and above.
2597 if (VGPRRegAllocNPM == RegAllocType::Fast)
2598 addMachineFunctionPass(RegAllocFastPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2599 else
2600 addMachineFunctionPass(RAGreedyPass({onlyAllocateVGPRs, "vgpr"}), PMW);
2601
2602 addPreRewrite(PMW);
2603 addMachineFunctionPass(VirtRegRewriterPass(true), PMW);
2604
2605 addMachineFunctionPass(AMDGPUMarkLastScratchLoadPass(), PMW);
2606 return Error::success();
2607}
2608
2609void AMDGPUCodeGenPassBuilder::addPostRegAlloc(PassManagerWrapper &PMW) const {
2610 addMachineFunctionPass(SIFixVGPRCopiesPass(), PMW);
2611 if (TM.getOptLevel() > CodeGenOptLevel::None)
2612 addMachineFunctionPass(SIOptimizeExecMaskingPass(), PMW);
2613 Base::addPostRegAlloc(PMW);
2614}
2615
2616void AMDGPUCodeGenPassBuilder::addPreSched2(PassManagerWrapper &PMW) const {
2617 if (TM.getOptLevel() > CodeGenOptLevel::None)
2618 addMachineFunctionPass(SIShrinkInstructionsPass(), PMW);
2619 addMachineFunctionPass(SIPostRABundlerPass(), PMW);
2620}
2621
2622void AMDGPUCodeGenPassBuilder::addPostBBSections(
2623 PassManagerWrapper &PMW) const {
2624 // We run this later to avoid passes like livedebugvalues and BBSections
2625 // having to deal with the apparent multi-entry functions we may generate.
2626 addMachineFunctionPass(AMDGPUPreloadKernArgPrologPass(), PMW);
2627}
2628
2629void AMDGPUCodeGenPassBuilder::addPreEmitPass(PassManagerWrapper &PMW) const {
2630 if (isPassEnabled(EnableVOPD, CodeGenOptLevel::Less)) {
2631 addMachineFunctionPass(GCNCreateVOPDPass(), PMW);
2632 }
2633
2634 addMachineFunctionPass(SIMemoryLegalizerPass(), PMW);
2635 addMachineFunctionPass(SIInsertWaitcntsPass(), PMW);
2636
2637 addMachineFunctionPass(SIModeRegisterPass(), PMW);
2638
2639 if (TM.getOptLevel() > CodeGenOptLevel::None)
2640 addMachineFunctionPass(SIInsertHardClausesPass(), PMW);
2641
2642 addMachineFunctionPass(SILateBranchLoweringPass(), PMW);
2643
2644 if (isPassEnabled(EnableSetWavePriority, CodeGenOptLevel::Less))
2645 addMachineFunctionPass(AMDGPUSetWavePriorityPass(), PMW);
2646
2647 if (TM.getOptLevel() > CodeGenOptLevel::None)
2648 addMachineFunctionPass(SIPreEmitPeepholePass(), PMW);
2649
2650 // The hazard recognizer that runs as part of the post-ra scheduler does not
2651 // guarantee to be able handle all hazards correctly. This is because if there
2652 // are multiple scheduling regions in a basic block, the regions are scheduled
2653 // bottom up, so when we begin to schedule a region we don't know what
2654 // instructions were emitted directly before it.
2655 //
2656 // Here we add a stand-alone hazard recognizer pass which can handle all
2657 // cases.
2658 addMachineFunctionPass(PostRAHazardRecognizerPass(), PMW);
2659 addMachineFunctionPass(AMDGPUWaitSGPRHazardsPass(), PMW);
2660 addMachineFunctionPass(AMDGPULowerVGPREncodingPass(), PMW);
2661
2662 if (isPassEnabled(EnableInsertDelayAlu, CodeGenOptLevel::Less)) {
2663 addMachineFunctionPass(AMDGPUInsertDelayAluPass(), PMW);
2664 }
2665
2666 addMachineFunctionPass(BranchRelaxationPass(), PMW);
2667}
2668
2669bool AMDGPUCodeGenPassBuilder::isPassEnabled(const cl::opt<bool> &Opt,
2670 CodeGenOptLevel Level) const {
2671 if (Opt.getNumOccurrences())
2672 return Opt;
2673 if (TM.getOptLevel() < Level)
2674 return false;
2675 return Opt;
2676}
2677
2678void AMDGPUCodeGenPassBuilder::addEarlyCSEOrGVNPass(
2679 PassManagerWrapper &PMW) const {
2680 if (TM.getOptLevel() == CodeGenOptLevel::Aggressive)
2681 addFunctionPass(GVNPass(), PMW);
2682 else
2683 addFunctionPass(EarlyCSEPass(), PMW);
2684}
2685
2686void AMDGPUCodeGenPassBuilder::addStraightLineScalarOptimizationPasses(
2687 PassManagerWrapper &PMW) const {
2689 addFunctionPass(LoopDataPrefetchPass(), PMW);
2690
2691 addFunctionPass(SeparateConstOffsetFromGEPPass(), PMW);
2692
2693 // ReassociateGEPs exposes more opportunities for SLSR. See
2694 // the example in reassociate-geps-and-slsr.ll.
2695 addFunctionPass(StraightLineStrengthReducePass(), PMW);
2696
2697 // SeparateConstOffsetFromGEP and SLSR creates common expressions which GVN or
2698 // EarlyCSE can reuse.
2699 addEarlyCSEOrGVNPass(PMW);
2700
2701 // Run NaryReassociate after EarlyCSE/GVN to be more effective.
2702 addFunctionPass(NaryReassociatePass(), PMW);
2703
2704 // NaryReassociate on GEPs creates redundant common expressions, so run
2705 // EarlyCSE after it.
2706 addFunctionPass(EarlyCSEPass(), PMW);
2707}
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:317
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
DXIL Legalizer
This file provides the interface for a simple, fast CSE pass.
This file defines the class GCNIterativeScheduler, which uses an iterative approach to find a best sc...
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
#define _
AcceleratorCodeSelection - Identify all functions reachable from a kernel, removing those that are un...
This file declares the IRTranslator pass.
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
#define RegName(no)
This file provides the interface for LLVM's Loop Data Prefetching Pass.
This header provides classes for managing a pipeline of passes over loops in LLVM IR.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Register Reg
Register const TargetRegisterInfo * TRI
#define T
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
#define P(N)
CGSCCAnalysisManager CGAM
LoopAnalysisManager LAM
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
PassInstrumentationCallbacks PIC
PassBuilder PB(Machine, PassOpts->PTO, std::nullopt, &PIC)
static bool isLTOPreLink(ThinOrFullLTOPhase Phase)
The AMDGPU TargetMachine interface definition for hw codegen targets.
This file describes the interface of the MachineFunctionPass responsible for assigning the generic vi...
const GCNTargetMachine & getTM(const GCNSubtarget *STI)
SI Machine Scheduler interface.
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition Value.cpp:484
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static FunctionPass * useDefaultRegisterAllocator()
-regalloc=... command line option.
static cl::opt< cl::boolOrDefault > EnableGlobalISelOption("global-isel", cl::Hidden, cl::desc("Enable the \"global\" instruction selector"))
Target-Independent Code Generator Pass Configuration Options pass.
LLVM IR instance of the generic uniformity analysis.
static std::unique_ptr< TargetLoweringObjectFile > createTLOF()
A manager for alias analyses.
void registerFunctionAnalysis()
Register a specific AA result.
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
Legacy wrapper pass to provide the AMDGPUAAResult object.
Analysis pass providing a never-invalidated alias analysis result.
Lower llvm.global_ctors and llvm.global_dtors to special kernels.
AMDGPUTargetMachine & getAMDGPUTargetMachine() const
std::unique_ptr< CSEConfigBase > getCSEConfig() const override
Returns the CSEConfig object to use for the current optimization level.
bool isPassEnabled(const cl::opt< bool > &Opt, CodeGenOptLevel Level=CodeGenOptLevel::Default) const
Check if a pass is enabled given Opt option.
bool addPreISel() override
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where t...
bool addInstSelector() override
addInstSelector - This method should install an instruction selector pass, which converts from LLVM c...
bool addGCPasses() override
addGCPasses - Add late codegen passes that analyze code for garbage collection.
AMDGPUPassConfig(TargetMachine &TM, PassManagerBase &PM)
void addIRPasses() override
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
void addCodeGenPrepare() override
Add pass to prepare the LLVM IR for code generation.
Splits the module M into N linkable partitions.
std::unique_ptr< TargetLoweringObjectFile > TLOF
unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const override
getAddressSpaceForPseudoSourceKind - Given the kind of memory (e.g.
const TargetSubtargetInfo * getSubtargetImpl() const
void registerDefaultAliasAnalyses(AAManager &) override
Allow the target to register alias analyses with the AAManager for use with the new pass manager.
std::pair< const Value *, unsigned > getPredicatedAddrSpace(const Value *V) const override
If the specified predicate checks whether a generic pointer falls within a specified address space,...
StringRef getFeatureString(const Function &F) const
ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const override
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL)
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override
Returns true if a cast between SrcAS and DestAS is a noop.
void registerPassBuilderCallbacks(PassBuilder &PB) override
Allow the target to modify the pass pipeline.
StringRef getGPUName(const Function &F) const
unsigned getAssumedAddrSpace(const Value *V) const override
If the specified generic pointer could be assumed as a pointer to a specific address space,...
bool splitModule(Module &M, unsigned NumParts, function_ref< void(std::unique_ptr< Module > MPart)> ModuleCallback) override
Entry point for module splitting.
Inlines functions marked as "always_inline".
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Functions, function parameters, and return types can have attributes to indicate how they should be t...
Definition Attributes.h:105
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
bool isValid() const
Return true if the attribute is any kind of attribute.
Definition Attributes.h:261
This class provides access to building LLVM's passes.
CodeGenTargetMachineImpl(const Target &T, StringRef DataLayoutString, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOptLevel OL)
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
Diagnostic information for unsupported feature in backend.
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
static ErrorSuccess success()
Create a success value.
Definition Error.h:336
Tagged union holding either a T or a Error.
Definition Error.h:485
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
LowerIntrinsics - This pass rewrites calls to the llvm.gcread or llvm.gcwrite intrinsics,...
Definition GCMetadata.h:229
const SIRegisterInfo * getRegisterInfo() const override
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
ScheduleDAGInstrs * createPostMachineScheduler(MachineSchedContext *C) const override
Similar to createMachineScheduler but used when postRA machine scheduling is enabled.
ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const override
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
void registerMachineRegisterInfoCallback(MachineFunction &MF) const override
bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const override
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const override
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
Error buildCodeGenPipeline(ModulePassManager &MPM, ModuleAnalysisManager &MAM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, const CGPassBuilderOption &Opts, MCContext &Ctx, PassInstrumentationCallbacks *PIC) override
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, std::optional< Reloc::Model > RM, std::optional< CodeModel::Model > CM, CodeGenOptLevel OL, bool JIT)
MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const override
Create the target's instance of MachineFunctionInfo.
The core GVN pass object.
Definition GVN.h:131
Pass to remove unused function declarations.
Definition GlobalDCE.h:38
This pass is responsible for selecting generic machine instructions to target-specific instructions.
A pass that internalizes all functions and variables other than those that must be preserved accordin...
Definition Internalize.h:37
Converts loops into loop-closed SSA form.
Definition LCSSA.h:38
Performs Loop Invariant Code Motion Pass.
Definition LICM.h:66
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.