aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-06-11 15:04:06 +0000
committerChris Lattner <sabre@nondot.org>2001-06-11 15:04:06 +0000
commit143da691f066e24a9e5272e1cabea4c446ee8cc1 (patch)
tree022b7951ae07d807bb8b591d225c0055635d725d /include
parentdb0926260dae4ea1e6aa1dd90d604eb09bf865d6 (diff)
downloadexternal_llvm-143da691f066e24a9e5272e1cabea4c446ee8cc1.zip
external_llvm-143da691f066e24a9e5272e1cabea4c446ee8cc1.tar.gz
external_llvm-143da691f066e24a9e5272e1cabea4c446ee8cc1.tar.bz2
Updates to support
* Changes in PHI node structure * Fix to Predecessor iterator git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CFG.h11
-rw-r--r--include/llvm/Value.h2
-rw-r--r--include/llvm/iOther.h24
3 files changed, 17 insertions, 20 deletions
diff --git a/include/llvm/CFG.h b/include/llvm/CFG.h
index f574756..b460992 100644
--- a/include/llvm/CFG.h
+++ b/include/llvm/CFG.h
@@ -106,7 +106,7 @@ inline df_const_iterator df_end (const BasicBlock *BB);
template <class _Ptr, class _USE_iterator> // Predecessor Iterator
class PredIterator {
- const _Ptr ThisBB;
+ const _Ptr BB;
_USE_iterator It;
public:
typedef PredIterator<_Ptr,_USE_iterator> _Self;
@@ -116,15 +116,16 @@ public:
inline void advancePastConstPool() {
// Loop to ignore constant pool references
- while (It != ThisBB->use_end() &&
- ((*It)->getValueType() != Value::InstructionVal))
+ while (It != BB->use_end() &&
+ (((*It)->getValueType() != Value::InstructionVal) ||
+ !(((Instruction*)(*It))->isTerminator())))
++It;
}
- inline PredIterator(_Ptr BB) : ThisBB(BB), It(BB->use_begin()) {
+ inline PredIterator(_Ptr bb) : BB(bb), It(bb->use_begin()) {
advancePastConstPool();
}
- inline PredIterator(_Ptr BB, bool) : ThisBB(BB), It(BB->use_end()) {}
+ inline PredIterator(_Ptr bb, bool) : BB(bb), It(bb->use_end()) {}
inline bool operator==(const _Self& x) const { return It == x.It; }
inline bool operator!=(const _Self& x) const { return !operator==(x); }
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index b10ea95..b334d47 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -99,7 +99,7 @@ public:
inline UseTy<ValueSubclass>(const UseTy<ValueSubclass> &user) {
Val = 0;
U = user.U;
- operator=(user);
+ operator=(user.Val);
}
inline ValueSubclass *operator=(ValueSubclass *V) {
if (Val) Val->killUse(U);
diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h
index b66e4d4..118241f 100644
--- a/include/llvm/iOther.h
+++ b/include/llvm/iOther.h
@@ -20,16 +20,10 @@
// node, that can not exist in nature, but can be synthesized in a computer
// scientist's overactive imagination.
//
-// TODO: FIXME: This representation is not good enough. Consider the following
-// code:
-// BB0: %x = int %0
-// BB1: %y = int %1
-// BB2: %z = phi int %0, %1 - Can't tell where constants come from!
-//
-// TOFIX: Store pair<Use,BasicBlockUse> instead of just <Use>
-//
class PHINode : public Instruction {
- vector<Use> IncomingValues;
+ typedef pair<Use,BasicBlockUse> PairTy;
+ vector<PairTy> IncomingValues;
+
PHINode(const PHINode &PN);
public:
PHINode(const Type *Ty, const string &Name = "");
@@ -40,22 +34,24 @@ public:
// Implement all of the functionality required by User...
//
virtual void dropAllReferences();
- virtual const Value *getOperand(unsigned i) const {
- return (i < IncomingValues.size()) ? IncomingValues[i] : 0;
+ virtual const Value *getOperand(unsigned i) const {
+ if (i >= IncomingValues.size()*2) return 0;
+ if (i & 1) return IncomingValues[i/2].second;
+ else return IncomingValues[i/2].first;
}
inline Value *getOperand(unsigned i) {
return (Value*)((const PHINode*)this)->getOperand(i);
}
- virtual unsigned getNumOperands() const { return IncomingValues.size(); }
+ virtual unsigned getNumOperands() const { return IncomingValues.size()*2; }
virtual bool setOperand(unsigned i, Value *Val);
virtual string getOpcode() const { return "phi"; }
// addIncoming - Add an incoming value to the end of the PHI list
- void addIncoming(Value *D);
+ void addIncoming(Value *D, BasicBlock *BB);
// removeIncomingValue - Remove an incoming value. This is useful if a
// predecessor basic block is deleted. The value removed is returned.
- Value *removeIncomingValue(unsigned idx);
+ Value *removeIncomingValue(const BasicBlock *BB);
};