27#define DEBUG_TYPE "amdgpu-regbankselect"
30using namespace AMDGPU;
43 return "AMDGPU Register Bank Select";
63 "AMDGPU Register Bank Select",
false,
false)
70char AMDGPURegBankSelect::
ID = 0;
75 return new AMDGPURegBankSelect();
93 : B(B),
MRI(*B.getMRI()), ILMA(ILMA), MUI(MUI),
TRI(
TRI),
94 SgprRB(&RBI.getRegBank(AMDGPU::SGPRRegBankID)),
95 VgprRB(&RBI.getRegBank(AMDGPU::VGPRRegBankID)),
96 VccRB(&RBI.getRegBank(AMDGPU::VCCRegBankID)) {}
106 if (!
MI->isCopy() ||
MI->getNumImplicitOperands() != 1)
109 return MI->implicit_operands().begin()->getReg() ==
TRI.getExec();
136 LLT Ty =
MRI.getType(Reg);
137 Register NewReg =
MRI.createVirtualRegister({RB, Ty});
140 auto &
MBB = *
MI.getParent();
142 B.buildCopy(Reg, NewReg);
155 if (
UseMI.isPreISelOpcode()) {
157 if (
Op.isReg() &&
Op.getReg() == Reg)
172 LLT Ty =
MRI.getType(Reg);
173 Register NewReg =
MRI.createVirtualRegister({RB, Ty});
177 auto DefMI =
MRI.getVRegDef(Reg)->getIterator();
184 B.buildCopy(NewReg, Reg);
194 if (!Reg.isVirtual())
207 getAnalysis<GISelCSEAnalysisWrapperPass>().getCSEWrapper();
213 B.setCSEInfo(&CSEInfo);
214 B.setChangeObserver(Observer);
221 getAnalysis<MachineUniformityAnalysisPass>().getUniformityInfo();
225 *
ST.getRegBankInfo());
236 if (!DefReg.
isValid() ||
MRI.getRegClassOrNull(DefReg))
240 MRI.setRegBank(DefReg, *RBSHelper.getRegBankToAssign(DefReg));
244 if (!
MI.isPreISelOpcode())
262 const RegisterBank *RB = RBSHelper.getRegBankToAssign(DefReg);
263 if (
MRI.getRegClassOrNull(DefReg))
264 RBSHelper.reAssignRegBankOnDef(
MI, DefOP, RB);
267 MRI.setRegBank(DefReg, *RB);
280 MRI.getVRegDef(
UseReg)->isPreISelOpcode())
285 RBSHelper.constrainRegBankUse(
MI, UseOP, RB);
unsigned const MachineRegisterInfo * MRI
MachineInstrBuilder & UseMI
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
amdgpu aa AMDGPU Address space based Alias Analysis Wrapper
AMDGPU Register Bank Select
static Register getVReg(MachineOperand &Op)
#define DEBUG_TYPE
Assign register banks to all register operands of G_ instructions using machine uniformity analysis.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Provides analysis for continuously CSEing during GISel passes.
This file implements a version of MachineIRBuilder which CSEs insts within a MachineBasicBlock.
AMD GCN specific subclass of TargetSubtarget.
static Register UseReg(const MachineOperand &MO)
Register const TargetRegisterInfo * TRI
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Target-Independent Code Generator Pass Configuration Options pass.
const RegisterBank * getRegBankToAssign(Register Reg)
void reAssignRegBankOnDef(MachineInstr &MI, MachineOperand &DefOP, const RegisterBank *RB)
RegBankSelectHelper(MachineIRBuilder &B, AMDGPU::IntrinsicLaneMaskAnalyzer &ILMA, const MachineUniformityInfo &MUI, const SIRegisterInfo &TRI, const RegisterBankInfo &RBI)
bool isTemporalDivergenceCopy(Register Reg)
void constrainRegBankUse(MachineInstr &MI, MachineOperand &UseOP, const RegisterBank *RB)
bool isS32S64LaneMask(Register Reg) const
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
Defines a builder that does CSE of MachineInstructions using GISelCSEInfo.
This class represents an Operation in the Expression.
FunctionPass class - This class is used to implement most global optimizations.
The actual analysis pass wrapper.
Simple wrapper that does the following.
Simple wrapper observer that takes several observers, and calls each one for each event.
void addObserver(GISelChangeObserver *O)
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
LLVM_ABI iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual MachineFunctionProperties getSetProperties() const
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.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const MachineFunctionProperties & getProperties() const
Get the function properties.
Helper class to build MachineInstr.
Representation of each machine instruction.
const MachineBasicBlock * getParent() const
MachineOperand class - Representation of each machine instruction operand.
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
A simple RAII based Delegate installer.
A simple RAII based Observer installer.
Holds all the information related to register banks.
This class implements the register bank concept.
Wrapper class representing virtual and physical registers.
constexpr bool isValid() const
StringRef - Represent a constant reference to a string, i.e.
Target-Independent Code Generator Pass Configuration Options.
virtual std::unique_ptr< CSEConfigBase > getCSEConfig() const
Returns the CSEConfig object to use for the current optimization level.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
char & AMDGPURegBankSelectID
FunctionPass * createAMDGPURegBankSelectPass()