[llvm-commits] [llvm] r54127 - in /llvm/trunk: include/llvm/CodeGen/SelectionDAGNodes.h include/llvm/Use.h lib/CodeGen/SelectionDAG/DAGCombiner.cpp lib/CodeGen/SelectionDAG/LegalizeDAG.cpp lib/CodeGen/SelectionDAG/LegalizeTypes.cpp lib/CodeGen/SelectionDAG/ScheduleDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/PowerPC/PPCISelLowering.cpp lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86ISelLowering.cpp
Dan Gohman
gohman at apple.com
Sun Jul 27 13:43:26 PDT 2008
Author: djg
Date: Sun Jul 27 15:43:25 2008
New Revision: 54127
URL: http://llvm.org/viewvc/llvm-project?rev=54127&view=rev
Log:
Tidy SDNode::use_iterator, and complete the transition to have it
parallel its analogue, Value::value_use_iterator. The operator* method
now returns the user, rather than the use.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/trunk/include/llvm/Use.h
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Sun Jul 27 15:43:25 2008
@@ -932,7 +932,7 @@
return *this;
}
- SDUse * getNext() { return Next; }
+ SDUse *getNext() { return Next; }
SDNode *getUser() { return User; }
@@ -942,7 +942,7 @@
const SDOperand& getSDOperand() const { return Operand; }
- SDNode* &getVal () { return Operand.Val; }
+ SDNode *&getVal() { return Operand.Val; }
bool operator==(const SDOperand &O) const {
return Operand == O;
@@ -1156,33 +1156,27 @@
use_iterator tmp = *this; ++*this; return tmp;
}
-
- /// getOperandNum - Retrive a number of a current operand.
- unsigned getOperandNum() const {
+ /// Retrieve a pointer to the current user node.
+ SDNode *operator*() const {
assert(Op && "Cannot dereference end iterator!");
- return (unsigned)(Op - Op->getUser()->OperandList);
+ return Op->getUser();
}
- /// Retrieve a reference to the current operand.
- SDUse &operator*() const {
- assert(Op && "Cannot dereference end iterator!");
- return *Op;
- }
+ SDNode *operator->() const { return operator*(); }
- /// Retrieve a pointer to the current operand.
- SDUse *operator->() const {
+ SDUse &getUse() const { return *Op; }
+
+ /// getOperandNo - Retrive the operand # of this use in its user.
+ ///
+ unsigned getOperandNo() const {
assert(Op && "Cannot dereference end iterator!");
- return Op;
+ return (unsigned)(Op - Op->getUser()->OperandList);
}
};
/// use_begin/use_end - Provide iteration support to walk over all uses
/// of an SDNode.
- use_iterator use_begin(SDNode *node) const {
- return use_iterator(node->Uses);
- }
-
use_iterator use_begin() const {
return use_iterator(Uses);
}
Modified: llvm/trunk/include/llvm/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Use.h?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Use.h (original)
+++ llvm/trunk/include/llvm/Use.h Sun Jul 27 15:43:25 2008
@@ -190,7 +190,7 @@
_Self tmp = *this; ++*this; return tmp;
}
- // Retrieve a reference to the current User
+ // Retrieve a pointer to the current User.
UserTy *operator*() const {
assert(U && "Cannot dereference end iterator!");
return U->getUser();
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sun Jul 27 15:43:25 2008
@@ -65,7 +65,7 @@
void AddUsersToWorkList(SDNode *N) {
for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end();
UI != UE; ++UI)
- AddToWorkList(UI->getUser());
+ AddToWorkList(*UI);
}
/// visit - call the node-specific routine that knows how to fold each
@@ -2686,7 +2686,7 @@
bool isTruncFree = TLI.isTruncateFree(N->getValueType(0), N0.getValueType());
for (SDNode::use_iterator UI = N0.Val->use_begin(), UE = N0.Val->use_end();
UI != UE; ++UI) {
- SDNode *User = UI->getUser();
+ SDNode *User = *UI;
if (User == N)
continue;
// FIXME: Only extend SETCC N, N and SETCC N, c for now.
@@ -2725,7 +2725,7 @@
bool BothLiveOut = false;
for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end();
UI != UE; ++UI) {
- SDNode *User = UI->getUser();
+ SDNode *User = *UI;
for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) {
SDOperand UseOp = User->getOperand(i);
if (UseOp.Val == N && UseOp.ResNo == 0) {
@@ -3948,7 +3948,7 @@
// If this is fp_round(fpextend), don't fold it, allow ourselves to be folded.
if (N->hasOneUse() &&
- N->use_begin()->getSDOperand().getOpcode() == ISD::FP_ROUND)
+ N->use_begin().getUse().getSDOperand().getOpcode() == ISD::FP_ROUND)
return SDOperand();
// fold (fp_extend c1fp) -> c1fp
@@ -4169,7 +4169,7 @@
bool RealUse = false;
for (SDNode::use_iterator I = Ptr.Val->use_begin(),
E = Ptr.Val->use_end(); I != E; ++I) {
- SDNode *Use = I->getUser();
+ SDNode *Use = *I;
if (Use == N)
continue;
if (Use->isPredecessorOf(N))
@@ -4254,7 +4254,7 @@
for (SDNode::use_iterator I = Ptr.Val->use_begin(),
E = Ptr.Val->use_end(); I != E; ++I) {
- SDNode *Op = I->getUser();
+ SDNode *Op = *I;
if (Op == N ||
(Op->getOpcode() != ISD::ADD && Op->getOpcode() != ISD::SUB))
continue;
@@ -4282,7 +4282,7 @@
bool TryNext = false;
for (SDNode::use_iterator II = BasePtr.Val->use_begin(),
EE = BasePtr.Val->use_end(); II != EE; ++II) {
- SDNode *Use = II->getUser();
+ SDNode *Use = *II;
if (Use == Ptr.Val)
continue;
@@ -4292,7 +4292,7 @@
bool RealUse = false;
for (SDNode::use_iterator III = Use->use_begin(),
EEE = Use->use_end(); III != EEE; ++III) {
- SDNode *UseUse = III->getUser();
+ SDNode *UseUse = *III;
if (!((UseUse->getOpcode() == ISD::LOAD &&
cast<LoadSDNode>(UseUse)->getBasePtr().Val == Use) ||
(UseUse->getOpcode() == ISD::STORE &&
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sun Jul 27 15:43:25 2008
@@ -299,9 +299,7 @@
// Now that we have N in, add anything that uses it if all of their operands
// are now done.
- for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end();
- UI != E; ++UI)
- Worklist.push_back(UI->getUser());
+ Worklist.insert(Worklist.end(), N->use_begin(), N->use_end());
}
assert(Order.size() == Visited.size() &&
@@ -373,7 +371,7 @@
E = Node->use_end(); UI != E; ++UI) {
// Make sure to only follow users of our token chain.
- SDNode *User = UI->getUser();
+ SDNode *User = *UI;
for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i)
if (User->getOperand(i) == TheChain)
if (SDNode *Result = FindCallEndFromCallStart(User))
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp Sun Jul 27 15:43:25 2008
@@ -138,7 +138,7 @@
for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end();
UI != E; ++UI) {
- SDNode *User = UI->getUser();
+ SDNode *User = *UI;
int NodeID = User->getNodeId();
assert(NodeID != ReadyToProcess && NodeID != Processed &&
"Invalid node id for user of unprocessed node!");
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Sun Jul 27 15:43:25 2008
@@ -51,18 +51,18 @@
/// CheckForPhysRegDependency - Check if the dependency between def and use of
/// a specified operand is a physical register dependency. If so, returns the
/// register and the cost of copying the register.
-static void CheckForPhysRegDependency(SDNode *Def, SDNode *Use, unsigned Op,
+static void CheckForPhysRegDependency(SDNode *Def, SDNode *User, unsigned Op,
const TargetRegisterInfo *TRI,
const TargetInstrInfo *TII,
unsigned &PhysReg, int &Cost) {
- if (Op != 2 || Use->getOpcode() != ISD::CopyToReg)
+ if (Op != 2 || User->getOpcode() != ISD::CopyToReg)
return;
- unsigned Reg = cast<RegisterSDNode>(Use->getOperand(1))->getReg();
+ unsigned Reg = cast<RegisterSDNode>(User->getOperand(1))->getReg();
if (TargetRegisterInfo::isVirtualRegister(Reg))
return;
- unsigned ResNo = Use->getOperand(2).ResNo;
+ unsigned ResNo = User->getOperand(2).ResNo;
if (Def->isMachineOpcode()) {
const TargetInstrDesc &II = TII->get(Def->getMachineOpcode());
if (ResNo >= II.getNumDefs() &&
@@ -142,12 +142,12 @@
bool HasFlagUse = false;
for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end();
UI != E; ++UI)
- if (FlagVal.isOperandOf(UI->getUser())) {
+ if (FlagVal.isOperandOf(*UI)) {
HasFlagUse = true;
NodeSUnit->FlaggedNodes.push_back(N);
assert(N->getNodeId() == -1 && "Node already inserted!");
N->setNodeId(NodeSUnit->NodeNum);
- N = UI->getUser();
+ N = *UI;
break;
}
if (!HasFlagUse) break;
@@ -426,20 +426,20 @@
bool MatchReg = true;
for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end();
UI != E; ++UI) {
- SDNode *Use = UI->getUser();
+ SDNode *User = *UI;
bool Match = true;
- if (Use->getOpcode() == ISD::CopyToReg &&
- Use->getOperand(2).Val == Node &&
- Use->getOperand(2).ResNo == ResNo) {
- unsigned DestReg = cast<RegisterSDNode>(Use->getOperand(1))->getReg();
+ if (User->getOpcode() == ISD::CopyToReg &&
+ User->getOperand(2).Val == Node &&
+ User->getOperand(2).ResNo == ResNo) {
+ unsigned DestReg = cast<RegisterSDNode>(User->getOperand(1))->getReg();
if (TargetRegisterInfo::isVirtualRegister(DestReg)) {
VRBase = DestReg;
Match = false;
} else if (DestReg != SrcReg)
Match = false;
} else {
- for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {
- SDOperand Op = Use->getOperand(i);
+ for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) {
+ SDOperand Op = User->getOperand(i);
if (Op.Val != Node || Op.ResNo != ResNo)
continue;
MVT VT = Node->getValueType(Op.ResNo);
@@ -487,11 +487,11 @@
if (!Node->hasOneUse())
return 0;
- SDNode *Use = Node->use_begin()->getUser();
- if (Use->getOpcode() == ISD::CopyToReg &&
- Use->getOperand(2).Val == Node &&
- Use->getOperand(2).ResNo == ResNo) {
- unsigned Reg = cast<RegisterSDNode>(Use->getOperand(1))->getReg();
+ SDNode *User = *Node->use_begin();
+ if (User->getOpcode() == ISD::CopyToReg &&
+ User->getOperand(2).Val == Node &&
+ User->getOperand(2).ResNo == ResNo) {
+ unsigned Reg = cast<RegisterSDNode>(User->getOperand(1))->getReg();
if (TargetRegisterInfo::isVirtualRegister(Reg))
return Reg;
}
@@ -511,11 +511,11 @@
unsigned VRBase = 0;
for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end();
UI != E; ++UI) {
- SDNode *Use = UI->getUser();
- if (Use->getOpcode() == ISD::CopyToReg &&
- Use->getOperand(2).Val == Node &&
- Use->getOperand(2).ResNo == i) {
- unsigned Reg = cast<RegisterSDNode>(Use->getOperand(1))->getReg();
+ SDNode *User = *UI;
+ if (User->getOpcode() == ISD::CopyToReg &&
+ User->getOperand(2).Val == Node &&
+ User->getOperand(2).ResNo == i) {
+ unsigned Reg = cast<RegisterSDNode>(User->getOperand(1))->getReg();
if (TargetRegisterInfo::isVirtualRegister(Reg)) {
VRBase = Reg;
MI->addOperand(MachineOperand::CreateReg(Reg, true));
@@ -710,10 +710,10 @@
// the CopyToReg'd destination register instead of creating a new vreg.
for (SDNode::use_iterator UI = Node->use_begin(), E = Node->use_end();
UI != E; ++UI) {
- SDNode *Use = UI->getUser();
- if (Use->getOpcode() == ISD::CopyToReg &&
- Use->getOperand(2).Val == Node) {
- unsigned DestReg = cast<RegisterSDNode>(Use->getOperand(1))->getReg();
+ SDNode *User = *UI;
+ if (User->getOpcode() == ISD::CopyToReg &&
+ User->getOperand(2).Val == Node) {
+ unsigned DestReg = cast<RegisterSDNode>(User->getOperand(1))->getReg();
if (TargetRegisterInfo::isVirtualRegister(DestReg)) {
VRBase = DestReg;
break;
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sun Jul 27 15:43:25 2008
@@ -4138,7 +4138,7 @@
while (!From->use_empty()) {
SDNode::use_iterator UI = From->use_begin();
- SDNode *U = UI->getUser();
+ SDNode *U = *UI;
// This node is about to morph, remove its old self from the CSE maps.
RemoveNodeFromCSEMaps(U);
@@ -4187,7 +4187,7 @@
while (!From->use_empty()) {
SDNode::use_iterator UI = From->use_begin();
- SDNode *U = UI->getUser();
+ SDNode *U = *UI;
// This node is about to morph, remove its old self from the CSE maps.
RemoveNodeFromCSEMaps(U);
@@ -4230,7 +4230,7 @@
while (!From->use_empty()) {
SDNode::use_iterator UI = From->use_begin();
- SDNode *U = UI->getUser();
+ SDNode *U = *UI;
// This node is about to morph, remove its old self from the CSE maps.
RemoveNodeFromCSEMaps(U);
@@ -4276,16 +4276,9 @@
return;
}
- if (From.use_empty()) return;
-
// Get all of the users of From.Val. We want these in a nice,
// deterministically ordered and uniqued set, so we use a SmallSetVector.
- SmallSetVector<SDNode*, 16> Users;
- for (SDNode::use_iterator UI = From.Val->use_begin(),
- E = From.Val->use_end(); UI != E; ++UI) {
- SDNode *User = UI->getUser();
- Users.insert(User);
- }
+ SmallSetVector<SDNode*, 16> Users(From.Val->use_begin(), From.Val->use_end());
while (!Users.empty()) {
// We know that this user uses some value of From. If it is the right
@@ -4350,7 +4343,7 @@
for (unsigned i = 0; i != Num; ++i)
for (SDNode::use_iterator UI = From[i].Val->use_begin(),
E = From[i].Val->use_end(); UI != E; ++UI)
- Users.push_back(std::make_pair(UI->getUser(), i));
+ Users.push_back(std::make_pair(*UI, i));
while (!Users.empty()) {
// We know that this user uses some value of From. If it is the right
@@ -4556,7 +4549,7 @@
// TODO: Only iterate over uses of a given value of the node
for (SDNode::use_iterator UI = use_begin(), E = use_end(); UI != E; ++UI) {
- if (UI->getSDOperand().ResNo == Value) {
+ if (UI.getUse().getSDOperand().ResNo == Value) {
if (NUses == 0)
return false;
--NUses;
@@ -4574,7 +4567,7 @@
assert(Value < getNumValues() && "Bad value!");
for (SDNode::use_iterator UI = use_begin(), E = use_end(); UI != E; ++UI)
- if (UI->getSDOperand().ResNo == Value)
+ if (UI.getUse().getSDOperand().ResNo == Value)
return true;
return false;
@@ -4586,7 +4579,7 @@
bool SDNode::isOnlyUserOf(SDNode *N) const {
bool Seen = false;
for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E; ++I) {
- SDNode *User = I->getUser();
+ SDNode *User = *I;
if (User == this)
Seen = true;
else
Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Sun Jul 27 15:43:25 2008
@@ -4273,11 +4273,11 @@
SDNode *LHSN = N->getOperand(0).Val;
for (SDNode::use_iterator UI = LHSN->use_begin(), E = LHSN->use_end();
UI != E; ++UI)
- if ((*UI).getUser()->getOpcode() == PPCISD::VCMPo &&
- (*UI).getUser()->getOperand(1) == N->getOperand(1) &&
- (*UI).getUser()->getOperand(2) == N->getOperand(2) &&
- (*UI).getUser()->getOperand(0) == N->getOperand(0)) {
- VCMPoNode = UI->getUser();
+ if (UI->getOpcode() == PPCISD::VCMPo &&
+ UI->getOperand(1) == N->getOperand(1) &&
+ UI->getOperand(2) == N->getOperand(2) &&
+ UI->getOperand(0) == N->getOperand(0)) {
+ VCMPoNode = *UI;
break;
}
@@ -4293,7 +4293,7 @@
for (SDNode::use_iterator UI = VCMPoNode->use_begin();
FlagUser == 0; ++UI) {
assert(UI != VCMPoNode->use_end() && "Didn't find user!");
- SDNode *User = UI->getUser();
+ SDNode *User = *UI;
for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) {
if (User->getOperand(i) == SDOperand(VCMPoNode, 1)) {
FlagUser = User;
Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Sun Jul 27 15:43:25 2008
@@ -231,7 +231,7 @@
static SDNode *findFlagUse(SDNode *N) {
unsigned FlagResNo = N->getNumValues()-1;
for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E; ++I) {
- SDNode *User = I->getUser();
+ SDNode *User = *I;
for (unsigned i = 0, e = User->getNumOperands(); i != e; ++i) {
SDOperand Op = User->getOperand(i);
if (Op.Val == N && Op.ResNo == FlagResNo)
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=54127&r1=54126&r2=54127&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Jul 27 15:43:25 2008
@@ -4039,7 +4039,7 @@
// result has a single use which is a store or a bitcast to i32.
if (!Op.hasOneUse())
return SDOperand();
- SDNode *User = Op.Val->use_begin()->getUser();
+ SDNode *User = *Op.Val->use_begin();
if (User->getOpcode() != ISD::STORE &&
(User->getOpcode() != ISD::BIT_CONVERT ||
User->getValueType(0) != MVT::i32))
More information about the llvm-commits
mailing list