25#define DEBUG_TYPE "amdgpu-pre-ra-long-branch-reg"
31 cl::desc(
"Factor to apply to what qualifies as a long branch "
32 "to reserve a pair of scalar registers. If this value "
33 "is 0 the long branch registers are never reserved. As this "
34 "value grows the greater chance the branch distance will fall "
35 "within the threshold and the registers will be marked to be "
36 "reserved. We lean towards always reserving a register for "
58 return "AMDGPU Pre-RA Long Branch Reg";
66char GCNPreRALongBranchReg::ID = 0;
69 "AMDGPU Pre-RA Long Branch Reg",
false,
false)
72void GCNPreRALongBranchReg::generateBlockInfo(
75 BlockInfo.resize(MF.getNumBlockIDs());
85 if (
MI.isMetaInstruction())
98 BlockInfo[Num].Offset = BlockInfo[PrevNum].Offset + BlockInfo[PrevNum].Size;
113 constexpr bool ReserveHighestRegister =
true;
114 Register LongBranchReservedReg =
TRI->findUnusedRegister(
115 MRI, &AMDGPU::SGPR_64RegClass, MF, ReserveHighestRegister);
116 if (!LongBranchReservedReg)
121 generateBlockInfo(MF, BlockInfo);
129 LongBranchFactor * BlockInfo[DestBB->
getNumber()].Offset);
132 if (!
TII->isBranchOffsetInRange(
Last->getOpcode(), BlockDistance)) {
unsigned const MachineRegisterInfo * MRI
AMD GCN specific subclass of TargetSubtarget.
const HexagonInstrInfo * TII
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
const SIInstrInfo * getInstrInfo() const override
const SIRegisterInfo * getRegisterInfo() const override
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
iterator getLastNonDebugInstr(bool SkipPseudoOp=true)
Returns an iterator to the last non-debug instruction in the basic block, or end().
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 bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
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...
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
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.
Wrapper class representing virtual and physical registers.
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
void setLongBranchReservedReg(Register Reg)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
const_iterator end(StringRef path)
Get end iterator over path.
This is an optimization pass for GlobalISel generic memory operations.
void initializeGCNPreRALongBranchRegPass(PassRegistry &)
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
char & GCNPreRALongBranchRegID
BasicBlockInfo - Information about the offset and size of a single basic block.