mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-08 19:25:47 +00:00
simplify the way how traits get hold of the symbol table
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66336 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -45,8 +45,6 @@ template<> struct ilist_traits<Instruction>
|
|||||||
Instruction *provideInitialHead() const { return createSentinel(); }
|
Instruction *provideInitialHead() const { return createSentinel(); }
|
||||||
Instruction *ensureHead(Instruction*) const { return createSentinel(); }
|
Instruction *ensureHead(Instruction*) const { return createSentinel(); }
|
||||||
static void noteHead(Instruction*, Instruction*) {}
|
static void noteHead(Instruction*, Instruction*) {}
|
||||||
|
|
||||||
static ValueSymbolTable *getSymTab(BasicBlock *ItemParent);
|
|
||||||
private:
|
private:
|
||||||
mutable ilist_node<Instruction> Sentinel;
|
mutable ilist_node<Instruction> Sentinel;
|
||||||
};
|
};
|
||||||
@@ -184,10 +182,15 @@ public:
|
|||||||
///
|
///
|
||||||
const InstListType &getInstList() const { return InstList; }
|
const InstListType &getInstList() const { return InstList; }
|
||||||
InstListType &getInstList() { return InstList; }
|
InstListType &getInstList() { return InstList; }
|
||||||
|
|
||||||
|
/// getSublistAccess() - returns pointer to member of instruction list
|
||||||
static iplist<Instruction> BasicBlock::*getSublistAccess(Instruction*) {
|
static iplist<Instruction> BasicBlock::*getSublistAccess(Instruction*) {
|
||||||
return &BasicBlock::InstList;
|
return &BasicBlock::InstList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getValueSymbolTable() - returns pointer to symbol table (if any)
|
||||||
|
ValueSymbolTable *getValueSymbolTable();
|
||||||
|
|
||||||
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
/// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const BasicBlock *) { return true; }
|
static inline bool classof(const BasicBlock *) { return true; }
|
||||||
static inline bool classof(const Value *V) {
|
static inline bool classof(const Value *V) {
|
||||||
|
@@ -31,21 +31,18 @@ template<> struct ilist_traits<Function>
|
|||||||
// createSentinel is used to create a node that marks the end of the list.
|
// createSentinel is used to create a node that marks the end of the list.
|
||||||
static Function *createSentinel();
|
static Function *createSentinel();
|
||||||
static void destroySentinel(Function *F) { delete F; }
|
static void destroySentinel(Function *F) { delete F; }
|
||||||
static inline ValueSymbolTable *getSymTab(Module *M);
|
|
||||||
};
|
};
|
||||||
template<> struct ilist_traits<GlobalVariable>
|
template<> struct ilist_traits<GlobalVariable>
|
||||||
: public SymbolTableListTraits<GlobalVariable, Module> {
|
: public SymbolTableListTraits<GlobalVariable, Module> {
|
||||||
// createSentinel is used to create a node that marks the end of the list.
|
// createSentinel is used to create a node that marks the end of the list.
|
||||||
static GlobalVariable *createSentinel();
|
static GlobalVariable *createSentinel();
|
||||||
static void destroySentinel(GlobalVariable *GV) { delete GV; }
|
static void destroySentinel(GlobalVariable *GV) { delete GV; }
|
||||||
static inline ValueSymbolTable *getSymTab(Module *M);
|
|
||||||
};
|
};
|
||||||
template<> struct ilist_traits<GlobalAlias>
|
template<> struct ilist_traits<GlobalAlias>
|
||||||
: public SymbolTableListTraits<GlobalAlias, Module> {
|
: public SymbolTableListTraits<GlobalAlias, Module> {
|
||||||
// createSentinel is used to create a node that marks the end of the list.
|
// createSentinel is used to create a node that marks the end of the list.
|
||||||
static GlobalAlias *createSentinel();
|
static GlobalAlias *createSentinel();
|
||||||
static void destroySentinel(GlobalAlias *GA) { delete GA; }
|
static void destroySentinel(GlobalAlias *GA) { delete GA; }
|
||||||
static inline ValueSymbolTable *getSymTab(Module *M);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A Module instance is used to store all the information related to an
|
/// A Module instance is used to store all the information related to an
|
||||||
@@ -409,22 +406,6 @@ inline raw_ostream &operator<<(raw_ostream &O, const Module &M) {
|
|||||||
M.print(O, 0);
|
M.print(O, 0);
|
||||||
return O;
|
return O;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline ValueSymbolTable *
|
|
||||||
ilist_traits<Function>::getSymTab(Module *M) {
|
|
||||||
return M ? &M->getValueSymbolTable() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ValueSymbolTable *
|
|
||||||
ilist_traits<GlobalVariable>::getSymTab(Module *M) {
|
|
||||||
return M ? &M->getValueSymbolTable() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ValueSymbolTable *
|
|
||||||
ilist_traits<GlobalAlias>::getSymTab(Module *M) {
|
|
||||||
return M ? &M->getValueSymbolTable() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
|
@@ -55,8 +55,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static iplist<ValueSubClass> &getList(ItemParentClass *Par) {
|
static iplist<ValueSubClass> &getList(ItemParentClass *Par) {
|
||||||
return Par->*(Par->getSublistAccess((ValueSubClass*)0));
|
return Par->*(Par->getSublistAccess((ValueSubClass*)0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ValueSymbolTable *getSymTab(ItemParentClass *Par) {
|
||||||
|
return Par ? toPtr(Par->getValueSymbolTable()) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
void addNodeToList(ValueSubClass *V);
|
void addNodeToList(ValueSubClass *V);
|
||||||
void removeNodeFromList(ValueSubClass *V);
|
void removeNodeFromList(ValueSubClass *V);
|
||||||
@@ -66,6 +70,8 @@ public:
|
|||||||
//private:
|
//private:
|
||||||
template<typename TPtr>
|
template<typename TPtr>
|
||||||
void setSymTabObject(TPtr *, TPtr);
|
void setSymTabObject(TPtr *, TPtr);
|
||||||
|
static ValueSymbolTable *toPtr(ValueSymbolTable *P) { return P; }
|
||||||
|
static ValueSymbolTable *toPtr(ValueSymbolTable &R) { return &R; }
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
@@ -23,11 +23,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
inline ValueSymbolTable *
|
ValueSymbolTable *BasicBlock::getValueSymbolTable() {
|
||||||
ilist_traits<Instruction>::getSymTab(BasicBlock *BB) {
|
if (Function *F = getParent())
|
||||||
if (BB)
|
return &F->getValueSymbolTable();
|
||||||
if (Function *F = BB->getParent())
|
|
||||||
return &F->getValueSymbolTable();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user