33 case TargetOpcode::COPY: {
44 EM.insert(std::make_pair(DstR, SrcR));
47 case TargetOpcode::REG_SEQUENCE:
55 CopyMap.insert(std::make_pair(SA.
Id, EM));
56 Copies.push_back(SA.
Id);
75 Changed |= scanBlock(
I->getBlock());
99 dbgs() <<
"Copies:\n";
100 for (
auto I : Copies) {
103 for (
auto J : CopyMap[
I])
110 bool Changed =
false;
112 bool HasLimit =
CpLimit.getNumOccurrences() > 0;
115 auto MinPhysReg = [
this] (
RegisterRef RR) ->
unsigned {
122 return S.getSubReg();
127 for (
auto C : Copies) {
133 auto FS = CopyMap.find(SA.
Id);
134 if (FS == CopyMap.end())
140 auto FR = EM.find(DR);
147 NodeId AtCopy = getLocalReachingDef(SR, SA);
149 for (
NodeId N = DA.Addr->getReachedUse(), NextN;
N; N = NextN) {
152 uint16_t
F = UA.Addr->getFlags();
155 if (UA.Addr->getRegRef(DFG) != DR)
160 NodeId AtUse = getLocalReachingDef(SR, IA);
173 unsigned NewReg = MinPhysReg(SR);
178 UA.Addr->linkToDef(UA.Id, DFG.
addr<
DefNode*>(AtCopy));
180 UA.Addr->setReachingDef(0);
181 UA.Addr->setSibling(0);
191 auto FC = CopyMap.find(IA.
Id);
192 if (
FC != CopyMap.end()) {
194 auto &M =
FC->second;
NodeList members(const DataFlowGraph &G) const
MachineFunction & getMF() const
static cl::opt< unsigned > CpLimit("rdf-cp-limit", cl::init(0), cl::Hidden)
std::map< RegisterRef, RegisterRef > EqualityMap
bool isValid() const
Returns true if this iterator is not yet at the end.
LaneBitmask getSubRegIndexLaneMask(unsigned SubIdx) const
Return a bitmask representing the parts of a register that are covered by SubIdx. ...
void unlinkUse(NodeAddr< UseNode * > UA, bool RemoveFromOwner)
MachineDomTreeNode * getNode(MachineBasicBlock *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
const MachineBasicBlock & front() const
static bool IsDef(const NodeAddr< NodeBase * > BA)
Base class for the actual dominator tree node.
NodeAddr< RefNode * > getNearestAliasedRef(RegisterRef RefRR, NodeAddr< InstrNode * > IA)
Find the nearest ref node aliased to RefRR, going upwards in the data flow, starting from the instruc...
NodeAddr< NodeBase * > getOwner(const DataFlowGraph &G)
NodeList members_if(Predicate P, const DataFlowGraph &G) const
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const TargetRegisterInfo & getTRI() const
initializer< Ty > init(const Ty &Val)
Iterator that enumerates the sub-registers of a Reg and the associated sub-register indices...
const MachineOperand & getOperand(unsigned i) const
static bool IsCode(const NodeAddr< NodeBase * > BA)
unsigned getSubReg() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual bool interpretAsCopy(const MachineInstr *MI, EqualityMap &EM)
MachineOperand class - Representation of each machine instruction operand.
NodeId getSibling() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
llvm_unreachable("Unknown RegBank!")
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
RegisterRef makeRegRef(unsigned Reg, unsigned Sub) const
void setReg(unsigned Reg)
Change the register this operand corresponds to.
void setSubReg(unsigned subReg)
const LaneBitmask LaneMask
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MachineInstr * getCode() const
NodeAddr< T > addr(NodeId N) const
NodeId getReachingDef() const
NodeAddr< BlockNode * > findBlock(MachineBasicBlock *BB) const