mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-25 03:30:37 +00:00
Add extra forwarding accessor methods so that getMethodList(), getBasicBlocks()
and getInstList() are obsolete... except for when modifying those lists. This makes code much more succinct and to the point. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0305cfd3cc
commit
1020b3982c
@ -43,6 +43,12 @@ private :
|
|||||||
void setParent(Method *parent);
|
void setParent(Method *parent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Instruction iterators...
|
||||||
|
typedef InstListType::iterator iterator;
|
||||||
|
typedef InstListType::const_iterator const_iterator;
|
||||||
|
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
typedef reverse_iterator<iterator> reverse_iterator;
|
||||||
|
|
||||||
typedef cfg::succ_iterator succ_iterator; // Include CFG.h to use these
|
typedef cfg::succ_iterator succ_iterator; // Include CFG.h to use these
|
||||||
typedef cfg::pred_iterator pred_iterator;
|
typedef cfg::pred_iterator pred_iterator;
|
||||||
typedef cfg::succ_const_iterator succ_const_iterator;
|
typedef cfg::succ_const_iterator succ_const_iterator;
|
||||||
@ -57,9 +63,6 @@ public:
|
|||||||
const Method *getParent() const { return (const Method*)InstList.getParent();}
|
const Method *getParent() const { return (const Method*)InstList.getParent();}
|
||||||
Method *getParent() { return (Method*)InstList.getParent(); }
|
Method *getParent() { return (Method*)InstList.getParent(); }
|
||||||
|
|
||||||
const InstListType &getInstList() const { return InstList; }
|
|
||||||
InstListType &getInstList() { return InstList; }
|
|
||||||
|
|
||||||
// getTerminator() - If this is a well formed basic block, then this returns
|
// getTerminator() - If this is a well formed basic block, then this returns
|
||||||
// a pointer to the terminator instruction. If it is not, then you get a null
|
// a pointer to the terminator instruction. If it is not, then you get a null
|
||||||
// pointer back.
|
// pointer back.
|
||||||
@ -67,6 +70,31 @@ public:
|
|||||||
TerminatorInst *getTerminator();
|
TerminatorInst *getTerminator();
|
||||||
const TerminatorInst *const getTerminator() const;
|
const TerminatorInst *const getTerminator() const;
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
// Instruction iterator methods
|
||||||
|
inline iterator begin() { return InstList.begin(); }
|
||||||
|
inline const_iterator begin() const { return InstList.begin(); }
|
||||||
|
inline iterator end () { return InstList.end(); }
|
||||||
|
inline const_iterator end () const { return InstList.end(); }
|
||||||
|
|
||||||
|
inline reverse_iterator rbegin() { return InstList.rbegin(); }
|
||||||
|
inline const_reverse_iterator rbegin() const { return InstList.rbegin(); }
|
||||||
|
inline reverse_iterator rend () { return InstList.rend(); }
|
||||||
|
inline const_reverse_iterator rend () const { return InstList.rend(); }
|
||||||
|
|
||||||
|
inline unsigned size() const { return InstList.size(); }
|
||||||
|
inline bool empty() const { return InstList.empty(); }
|
||||||
|
inline const Instruction *front() const { return InstList.front(); }
|
||||||
|
inline Instruction *front() { return InstList.front(); }
|
||||||
|
inline const Instruction *back() const { return InstList.back(); }
|
||||||
|
inline Instruction *back() { return InstList.back(); }
|
||||||
|
|
||||||
|
// getInstList() - Return the underlying instruction list container. You need
|
||||||
|
// to access it directly if you want to modify it currently.
|
||||||
|
//
|
||||||
|
const InstListType &getInstList() const { return InstList; }
|
||||||
|
InstListType &getInstList() { return InstList; }
|
||||||
|
|
||||||
// hasConstantPoolReferences() - This predicate is true if there is a
|
// hasConstantPoolReferences() - This predicate is true if there is a
|
||||||
// reference to this basic block in the constant pool for this method. For
|
// reference to this basic block in the constant pool for this method. For
|
||||||
// example, if a block is reached through a switch table, that table resides
|
// example, if a block is reached through a switch table, that table resides
|
||||||
@ -96,7 +124,7 @@ public:
|
|||||||
// cause a degenerate basic block to be formed, having a terminator inside of
|
// cause a degenerate basic block to be formed, having a terminator inside of
|
||||||
// the basic block).
|
// the basic block).
|
||||||
//
|
//
|
||||||
BasicBlock *splitBasicBlock(InstListType::iterator I);
|
BasicBlock *splitBasicBlock(iterator I);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,7 +28,13 @@ class Method : public SymTabValue {
|
|||||||
public:
|
public:
|
||||||
typedef ValueHolder<MethodArgument, Method> ArgumentListType;
|
typedef ValueHolder<MethodArgument, Method> ArgumentListType;
|
||||||
typedef ValueHolder<BasicBlock , Method> BasicBlocksType;
|
typedef ValueHolder<BasicBlock , Method> BasicBlocksType;
|
||||||
|
|
||||||
|
// BasicBlock iterators...
|
||||||
typedef BasicBlocksType::iterator iterator;
|
typedef BasicBlocksType::iterator iterator;
|
||||||
|
typedef BasicBlocksType::const_iterator const_iterator;
|
||||||
|
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
typedef reverse_iterator<iterator> reverse_iterator;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Important things that make up a method!
|
// Important things that make up a method!
|
||||||
@ -59,11 +65,34 @@ public:
|
|||||||
inline Module *getParent() { return Parent; }
|
inline Module *getParent() { return Parent; }
|
||||||
inline const Module *getParent() const { return Parent; }
|
inline const Module *getParent() const { return Parent; }
|
||||||
|
|
||||||
|
// Get the underlying elements of the Method...
|
||||||
|
inline const ArgumentListType &getArgumentList() const{ return ArgumentList; }
|
||||||
|
inline ArgumentListType &getArgumentList() { return ArgumentList; }
|
||||||
|
|
||||||
inline const BasicBlocksType &getBasicBlocks() const { return BasicBlocks; }
|
inline const BasicBlocksType &getBasicBlocks() const { return BasicBlocks; }
|
||||||
inline BasicBlocksType &getBasicBlocks() { return BasicBlocks; }
|
inline BasicBlocksType &getBasicBlocks() { return BasicBlocks; }
|
||||||
|
|
||||||
inline const ArgumentListType &getArgumentList() const{ return ArgumentList; }
|
|
||||||
inline ArgumentListType &getArgumentList() { return ArgumentList; }
|
//===--------------------------------------------------------------------===//
|
||||||
|
// BasicBlock iterator forwarding functions
|
||||||
|
//
|
||||||
|
inline iterator begin() { return BasicBlocks.begin(); }
|
||||||
|
inline const_iterator begin() const { return BasicBlocks.begin(); }
|
||||||
|
inline iterator end () { return BasicBlocks.end(); }
|
||||||
|
inline const_iterator end () const { return BasicBlocks.end(); }
|
||||||
|
|
||||||
|
inline reverse_iterator rbegin() { return BasicBlocks.rbegin(); }
|
||||||
|
inline const_reverse_iterator rbegin() const { return BasicBlocks.rbegin(); }
|
||||||
|
inline reverse_iterator rend () { return BasicBlocks.rend(); }
|
||||||
|
inline const_reverse_iterator rend () const { return BasicBlocks.rend(); }
|
||||||
|
|
||||||
|
inline unsigned size() const { return BasicBlocks.size(); }
|
||||||
|
inline bool empty() const { return BasicBlocks.empty(); }
|
||||||
|
inline const BasicBlock *front() const { return BasicBlocks.front(); }
|
||||||
|
inline BasicBlock *front() { return BasicBlocks.front(); }
|
||||||
|
inline const BasicBlock *back() const { return BasicBlocks.back(); }
|
||||||
|
inline BasicBlock *back() { return BasicBlocks.back(); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// dropAllReferences() - This function causes all the subinstructions to "let
|
// dropAllReferences() - This function causes all the subinstructions to "let
|
||||||
@ -82,11 +111,10 @@ public:
|
|||||||
//
|
//
|
||||||
template <class _BB_t, class _BB_i_t, class _BI_t, class _II_t>
|
template <class _BB_t, class _BB_i_t, class _BI_t, class _II_t>
|
||||||
class InstIterator;
|
class InstIterator;
|
||||||
typedef InstIterator<BasicBlocksType, BasicBlocksType::iterator,
|
typedef InstIterator<BasicBlocksType, iterator,
|
||||||
BasicBlock::InstListType::iterator,
|
BasicBlock::iterator, Instruction*> inst_iterator;
|
||||||
Instruction*> inst_iterator;
|
typedef InstIterator<const BasicBlocksType, const_iterator,
|
||||||
typedef InstIterator<const BasicBlocksType, BasicBlocksType::const_iterator,
|
BasicBlock::const_iterator,
|
||||||
BasicBlock::InstListType::const_iterator,
|
|
||||||
const Instruction*> inst_const_iterator;
|
const Instruction*> inst_const_iterator;
|
||||||
|
|
||||||
// This inner class is used to implement inst_begin() & inst_end() for
|
// This inner class is used to implement inst_begin() & inst_end() for
|
||||||
@ -100,14 +128,14 @@ public:
|
|||||||
typedef _II_t IIty;
|
typedef _II_t IIty;
|
||||||
_BB_t &BBs; // BasicBlocksType
|
_BB_t &BBs; // BasicBlocksType
|
||||||
_BB_i_t BB; // BasicBlocksType::iterator
|
_BB_i_t BB; // BasicBlocksType::iterator
|
||||||
_BI_t BI; // BasicBlock::InstListType::iterator
|
_BI_t BI; // BasicBlock::iterator
|
||||||
public:
|
public:
|
||||||
typedef bidirectional_iterator_tag iterator_category;
|
typedef bidirectional_iterator_tag iterator_category;
|
||||||
|
|
||||||
template<class M> InstIterator(M &m)
|
template<class M> InstIterator(M &m)
|
||||||
: BBs(m.getBasicBlocks()), BB(BBs.begin()) { // begin ctor
|
: BBs(m.getBasicBlocks()), BB(BBs.begin()) { // begin ctor
|
||||||
if (BB != BBs.end()) {
|
if (BB != BBs.end()) {
|
||||||
BI = (*BB)->getInstList().begin();
|
BI = (*BB)->begin();
|
||||||
resyncInstructionIterator();
|
resyncInstructionIterator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,10 +165,10 @@ public:
|
|||||||
inline void resyncInstructionIterator() {
|
inline void resyncInstructionIterator() {
|
||||||
// The only way that the II could be broken is if it is now pointing to
|
// The only way that the II could be broken is if it is now pointing to
|
||||||
// the end() of the current BasicBlock and there are successor BBs.
|
// the end() of the current BasicBlock and there are successor BBs.
|
||||||
while (BI == (*BB)->getInstList().end()) {
|
while (BI == (*BB)->end()) {
|
||||||
++BB;
|
++BB;
|
||||||
if (BB == BBs.end()) break;
|
if (BB == BBs.end()) break;
|
||||||
BI = (*BB)->getInstList().begin();
|
BI = (*BB)->begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,9 +182,9 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
InstIterator& operator--() {
|
InstIterator& operator--() {
|
||||||
while (BB == BBs.end() || BI == (*BB)->getInstList().begin()) {
|
while (BB == BBs.end() || BI == (*BB)->begin()) {
|
||||||
--BB;
|
--BB;
|
||||||
BI = (*BB)->getInstList().end();
|
BI = (*BB)->end();
|
||||||
}
|
}
|
||||||
--BI;
|
--BI;
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -14,6 +14,12 @@ class Method;
|
|||||||
class Module : public SymTabValue {
|
class Module : public SymTabValue {
|
||||||
public:
|
public:
|
||||||
typedef ValueHolder<Method, Module> MethodListType;
|
typedef ValueHolder<Method, Module> MethodListType;
|
||||||
|
|
||||||
|
// Method iterators...
|
||||||
|
typedef MethodListType::iterator iterator;
|
||||||
|
typedef MethodListType::const_iterator const_iterator;
|
||||||
|
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
typedef reverse_iterator<iterator> reverse_iterator;
|
||||||
private:
|
private:
|
||||||
MethodListType MethodList; // The Methods
|
MethodListType MethodList; // The Methods
|
||||||
|
|
||||||
@ -21,9 +27,31 @@ public:
|
|||||||
Module();
|
Module();
|
||||||
~Module();
|
~Module();
|
||||||
|
|
||||||
|
// Get the underlying elements of the Module...
|
||||||
inline const MethodListType &getMethodList() const { return MethodList; }
|
inline const MethodListType &getMethodList() const { return MethodList; }
|
||||||
inline MethodListType &getMethodList() { return MethodList; }
|
inline MethodListType &getMethodList() { return MethodList; }
|
||||||
|
|
||||||
|
//===--------------------------------------------------------------------===//
|
||||||
|
// Module iterator forwarding functions
|
||||||
|
//
|
||||||
|
inline iterator begin() { return MethodList.begin(); }
|
||||||
|
inline const_iterator begin() const { return MethodList.begin(); }
|
||||||
|
inline iterator end () { return MethodList.end(); }
|
||||||
|
inline const_iterator end () const { return MethodList.end(); }
|
||||||
|
|
||||||
|
inline reverse_iterator rbegin() { return MethodList.rbegin(); }
|
||||||
|
inline const_reverse_iterator rbegin() const { return MethodList.rbegin(); }
|
||||||
|
inline reverse_iterator rend () { return MethodList.rend(); }
|
||||||
|
inline const_reverse_iterator rend () const { return MethodList.rend(); }
|
||||||
|
|
||||||
|
inline unsigned size() const { return MethodList.size(); }
|
||||||
|
inline bool empty() const { return MethodList.empty(); }
|
||||||
|
inline const Method *front() const { return MethodList.front(); }
|
||||||
|
inline Method *front() { return MethodList.front(); }
|
||||||
|
inline const Method *back() const { return MethodList.back(); }
|
||||||
|
inline Method *back() { return MethodList.back(); }
|
||||||
|
|
||||||
|
|
||||||
// dropAllReferences() - This function causes all the subinstructions to "let
|
// dropAllReferences() - This function causes all the subinstructions to "let
|
||||||
// go" of all references that they are maintaining. This allows one to
|
// go" of all references that they are maintaining. This allows one to
|
||||||
// 'delete' a whole class at a time, even though there may be circular
|
// 'delete' a whole class at a time, even though there may be circular
|
||||||
|
Loading…
x
Reference in New Issue
Block a user