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:
74 if (LocalizedInstrs.
count(&MI) || !shouldLocalize(MI))
76 DEBUG(
dbgs() <<
"Should localize: " << MI);
78 "More than one definition not supported yet");
89 dbgs() <<
"Checking use: " << MIUse
91 if (isLocalUse(MOUse, MI, InsertMBB))
93 DEBUG(
dbgs() <<
"Fixing non-local use\n");
95 auto MBBAndReg = std::make_pair(InsertMBB, Reg);
96 auto NewVRegIt = MBBWithLocalDef.
find(MBBAndReg);
97 if (NewVRegIt == MBBWithLocalDef.
end()) {
100 LocalizedInstrs.
insert(LocalizedMI);
112 MBBWithLocalDef.
insert(std::make_pair(MBBAndReg, NewReg)).first;
113 DEBUG(
dbgs() <<
"Inserted: " << *LocalizedMI);
118 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...
INITIALIZE_PASS(Localizer, DEBUG_TYPE,"Move/duplicate certain instructions close to their use", false, false) Localizer
LLT getType(unsigned VReg) const
Get the low-level type of VReg or LLT{} if VReg is not a generic (target independent) virtual registe...
bool hasProperty(Property P) const
unsigned getNumDefs() const
Return the number of MachineOperands that are register definitions.
This pass implements the localization mechanism described at the top of this file.
unsigned getOperandNo(const_mop_iterator I) const
Returns the number of the operand iterator I points to.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
unsigned createGenericVirtualRegister(LLT Ty)
Create and return a new generic virtual register with low-level type Ty.
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...
void initializeLocalizerPass(PassRegistry &)
const MachineFunctionProperties & getProperties() const
Get the function properties.
Reg
All possible values of the reg field in the ModR/M byte.
bool runOnMachineFunction(MachineFunction &MF) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
iterator find(const_arg_type_t< KeyT > Val)
const MachineOperand & getOperand(unsigned i) const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
MachineOperand class - Representation of each machine instruction operand.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Representation of each machine instruction.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
use_iterator use_begin(unsigned RegNo) const
const RegClassOrRegBank & getRegClassOrRegBank(unsigned Reg) const
Return the register bank or register class of Reg.
void setReg(unsigned Reg)
Change the register this operand corresponds to.
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
void setRegClassOrRegBank(unsigned Reg, const RegClassOrRegBank &RCOrRB)