diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-10-07 20:05:10 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-10-07 20:05:10 +0000 |
commit | 37bf678a0d4645942c7c8335b067d5abe446768d (patch) | |
tree | 0df0268584bbcd9294cc53e9572bb1a3eb6735ca /llvm/lib/IR/SymbolTableListTraitsImpl.h | |
parent | edea2371f3789f4804000602671a6bc8ede4505c (diff) | |
download | bcm5719-llvm-37bf678a0d4645942c7c8335b067d5abe446768d.tar.gz bcm5719-llvm-37bf678a0d4645942c7c8335b067d5abe446768d.zip |
IR: Create SymbolTableList wrapper around iplist, NFC
Create `SymbolTableList`, a wrapper around `iplist` for lists that
automatically manage a symbol table. This commit reduces a ton of code
duplication between the six traits classes that were used previously.
As a drive by, reduce the number of template parameters from 2 to 1 by
using a SymbolTableListParentType metafunction (I originally had this as
a separate commit, but it touched most of the same lines so I squashed
them).
I'm in the process of trying to remove the UB in `createSentinel()` (see
the FIXMEs I added for `ilist_embedded_sentinel_traits` and
`ilist_half_embedded_sentinel_traits`). My eventual goal is to separate
the list logic into a base class layer that knows nothing about (and
isn't templated on) the downcasted nodes -- removing the need to invoke
UB -- but for now I'm just trying to get a handle on all the current use
cases (and cleaning things up as I see them).
Besides these six SymbolTable lists, there are two others that use the
addNode/removeNode/transferNodes() hooks: the `MachineInstruction` and
`MachineBasicBlock` lists. Ideally there'll be a way to factor these
hooks out of the low-level API entirely, but I'm not quite there yet.
llvm-svn: 249602
Diffstat (limited to 'llvm/lib/IR/SymbolTableListTraitsImpl.h')
-rw-r--r-- | llvm/lib/IR/SymbolTableListTraitsImpl.h | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/llvm/lib/IR/SymbolTableListTraitsImpl.h b/llvm/lib/IR/SymbolTableListTraitsImpl.h index 4d17d75859c..e7fa8ba58f4 100644 --- a/llvm/lib/IR/SymbolTableListTraitsImpl.h +++ b/llvm/lib/IR/SymbolTableListTraitsImpl.h @@ -24,10 +24,10 @@ namespace llvm { /// setSymTabObject - This is called when (f.e.) the parent of a basic block /// changes. This requires us to remove all the instruction symtab entries from /// the current function and reinsert them into the new function. -template<typename ValueSubClass, typename ItemParentClass> -template<typename TPtr> -void SymbolTableListTraits<ValueSubClass,ItemParentClass> -::setSymTabObject(TPtr *Dest, TPtr Src) { +template <typename ValueSubClass> +template <typename TPtr> +void SymbolTableListTraits<ValueSubClass>::setSymTabObject(TPtr *Dest, + TPtr Src) { // Get the old symtab and value list before doing the assignment. ValueSymbolTable *OldST = getSymTab(getListOwner()); @@ -41,7 +41,7 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass> if (OldST == NewST) return; // Move all the elements from the old symtab to the new one. - iplist<ValueSubClass> &ItemList = getList(getListOwner()); + ListTy &ItemList = getList(getListOwner()); if (ItemList.empty()) return; if (OldST) { @@ -60,9 +60,8 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass> } -template<typename ValueSubClass, typename ItemParentClass> -void SymbolTableListTraits<ValueSubClass,ItemParentClass> -::addNodeToList(ValueSubClass *V) { +template <typename ValueSubClass> +void SymbolTableListTraits<ValueSubClass>::addNodeToList(ValueSubClass *V) { assert(!V->getParent() && "Value already in a container!!"); ItemParentClass *Owner = getListOwner(); V->setParent(Owner); @@ -71,20 +70,19 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass> ST->reinsertValue(V); } -template<typename ValueSubClass, typename ItemParentClass> -void SymbolTableListTraits<ValueSubClass,ItemParentClass> -::removeNodeFromList(ValueSubClass *V) { +template <typename ValueSubClass> +void SymbolTableListTraits<ValueSubClass>::removeNodeFromList( + ValueSubClass *V) { V->setParent(nullptr); if (V->hasName()) if (ValueSymbolTable *ST = getSymTab(getListOwner())) ST->removeValueName(V->getValueName()); } -template<typename ValueSubClass, typename ItemParentClass> -void SymbolTableListTraits<ValueSubClass,ItemParentClass> -::transferNodesFromList(ilist_traits<ValueSubClass> &L2, - ilist_iterator<ValueSubClass> first, - ilist_iterator<ValueSubClass> last) { +template <typename ValueSubClass> +void SymbolTableListTraits<ValueSubClass>::transferNodesFromList( + SymbolTableListTraits &L2, ilist_iterator<ValueSubClass> first, + ilist_iterator<ValueSubClass> last) { // We only have to do work here if transferring instructions between BBs ItemParentClass *NewIP = getListOwner(), *OldIP = L2.getListOwner(); if (NewIP == OldIP) return; // No work to do at all... |