19 #define DEBUG_TYPE "localizer" 25 "Move/duplicate certain instructions close to their use",
false,
40 case TargetOpcode::G_CONSTANT:
41 case TargetOpcode::G_FCONSTANT:
42 case TargetOpcode::G_FRAME_INDEX:
79 if (LocalizedInstrs.
count(&MI) || !shouldLocalize(MI))
83 "More than one definition not supported yet");
94 dbgs() <<
"Checking use: " << MIUse
95 <<
" #Opd: " << MIUse.getOperandNo(&MOUse) <<
'\n');
96 if (isLocalUse(MOUse, MI, InsertMBB))
100 auto MBBAndReg = std::make_pair(InsertMBB, Reg);
101 auto NewVRegIt = MBBWithLocalDef.
find(MBBAndReg);
102 if (NewVRegIt == MBBWithLocalDef.
end()) {
105 LocalizedInstrs.
insert(LocalizedMI);
118 MBBWithLocalDef.
insert(std::make_pair(MBBAndReg, NewReg)).first;
124 MOUse.
setReg(NewVRegIt->second);
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
This class represents lattice values for constants.
void getSelectionDAGFallbackAnalysisUsage(AnalysisUsage &AU)
Modify analysis usage so it preserves passes required for the SelectionDAG fallback.
const MachineFunctionProperties & getProperties() const
Get the function properties.
This pass implements the localization mechanism described at the top of this file.
unsigned getReg() const
getReg - Returns the register number.
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
LLT getType(unsigned Reg) const
Get the low-level type of Reg or LLT{} if Reg is not a generic (target independent) virtual register...
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
static use_iterator use_end()
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
void initializeLocalizerPass(PassRegistry &)
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
const RegClassOrRegBank & getRegClassOrRegBank(unsigned Reg) const
Return the register bank or register class of Reg.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
iterator find(const_arg_type_t< KeyT > Val)
INITIALIZE_PASS(Localizer, DEBUG_TYPE, "Move/duplicate certain instructions close to their use", false, false) Localizer
iterator SkipPHIsAndLabels(iterator I)
Return the first instruction in MBB after I that is not a PHI or a label.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Represent the analysis usage information of a pass.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
unsigned createGenericVirtualRegister(LLT Ty, StringRef Name="")
Create and return a new generic virtual register with low-level type Ty.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
MachineOperand class - Representation of each machine instruction operand.
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const MachineBasicBlock * getParent() const
Representation of each machine instruction.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
use_iterator use_begin(unsigned RegNo) const
void setReg(unsigned Reg)
Change the register this operand corresponds to.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasProperty(Property P) const
void setRegClassOrRegBank(unsigned Reg, const RegClassOrRegBank &RCOrRB)
const MachineOperand & getOperand(unsigned i) const