LLVM 20.0.0git
AMDGPURegBankLegalize.cpp
Go to the documentation of this file.
1//===-- AMDGPURegBankLegalize.cpp -----------------------------------------===//
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/// Lower G_ instructions that can't be inst-selected with register bank
10/// assignment from AMDGPURegBankSelect based on machine uniformity info.
11/// Given types on all operands, some register bank assignments require lowering
12/// while others do not.
13/// Note: cases where all register bank assignments would require lowering are
14/// lowered in legalizer.
15/// For example vgpr S64 G_AND requires lowering to S32 while sgpr S64 does not.
16/// Eliminate sgpr S1 by lowering to sgpr S32.
17//
18//===----------------------------------------------------------------------===//
19
20#include "AMDGPU.h"
23
24#define DEBUG_TYPE "amdgpu-regbanklegalize"
25
26using namespace llvm;
27
28namespace {
29
30class AMDGPURegBankLegalize : public MachineFunctionPass {
31public:
32 static char ID;
33
34public:
35 AMDGPURegBankLegalize() : MachineFunctionPass(ID) {
37 }
38
39 bool runOnMachineFunction(MachineFunction &MF) override;
40
41 StringRef getPassName() const override {
42 return "AMDGPU Register Bank Legalize";
43 }
44
45 void getAnalysisUsage(AnalysisUsage &AU) const override {
47 }
48
49 // If there were no phis and we do waterfall expansion machine verifier would
50 // fail.
53 MachineFunctionProperties::Property::NoPHIs);
54 }
55};
56
57} // End anonymous namespace.
58
59INITIALIZE_PASS_BEGIN(AMDGPURegBankLegalize, DEBUG_TYPE,
60 "AMDGPU Register Bank Legalize", false, false)
61INITIALIZE_PASS_END(AMDGPURegBankLegalize, DEBUG_TYPE,
62 "AMDGPU Register Bank Legalize", false, false)
63
64char AMDGPURegBankLegalize::ID = 0;
65
66char &llvm::AMDGPURegBankLegalizeID = AMDGPURegBankLegalize::ID;
67
69 return new AMDGPURegBankLegalize();
70}
71
72using namespace AMDGPU;
73
74bool AMDGPURegBankLegalize::runOnMachineFunction(MachineFunction &MF) {
76 MachineFunctionProperties::Property::FailedISel))
77 return false;
78 return true;
79}
AMDGPU Register Bank Legalize
#define DEBUG_TYPE
Lower G_ instructions that can't be inst-selected with register bank assignment from AMDGPURegBankSel...
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:57
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:52
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:310
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual MachineFunctionProperties getClearedProperties() const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
bool hasProperty(Property P) const
const MachineFunctionProperties & getProperties() const
Get the function properties.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Definition: Pass.cpp:81
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
FunctionPass * createAMDGPURegBankLegalizePass()
char & AMDGPURegBankLegalizeID
void initializeAMDGPURegBankLegalizePass(PassRegistry &)