2003-09-30 18:37:50 +00:00
|
|
|
//===-- llvm/SymbolTableListTraits.h - Traits for iplist --------*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-06-25 16:12:52 +00:00
|
|
|
//
|
|
|
|
// This file defines a generic class that is used to implement the automatic
|
|
|
|
// symbol table manipulation that occurs when you put (for example) a named
|
|
|
|
// instruction into a basic block.
|
|
|
|
//
|
|
|
|
// The way that this is implemented is by using a special traits class with the
|
|
|
|
// intrusive list that makes up the list of instructions in a basic block. When
|
|
|
|
// a new element is added to the list of instructions, the traits class is
|
|
|
|
// notified, allowing the symbol table to be updated.
|
|
|
|
//
|
|
|
|
// This generic class implements the traits class. It must be generic so that
|
|
|
|
// it can work for all uses it, which include lists of instructions, basic
|
|
|
|
// blocks, arguments, functions, global variables, etc...
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_SYMBOLTABLELISTTRAITS_H
|
|
|
|
#define LLVM_SYMBOLTABLELISTTRAITS_H
|
|
|
|
|
2008-07-28 21:51:04 +00:00
|
|
|
#include "llvm/ADT/ilist.h"
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-06-25 16:12:52 +00:00
|
|
|
template<typename NodeTy> class ilist_iterator;
|
|
|
|
template<typename NodeTy, typename Traits> class iplist;
|
|
|
|
template<typename Ty> struct ilist_traits;
|
|
|
|
|
2009-02-27 09:33:37 +00:00
|
|
|
// ValueSubClass - The type of objects that I hold, e.g. Instruction.
|
|
|
|
// ItemParentClass - The type of object that owns the list, e.g. BasicBlock.
|
2002-06-25 16:12:52 +00:00
|
|
|
//
|
2007-04-17 03:26:42 +00:00
|
|
|
template<typename ValueSubClass, typename ItemParentClass>
|
2008-07-28 21:51:04 +00:00
|
|
|
class SymbolTableListTraits : public ilist_default_traits<ValueSubClass> {
|
2007-04-17 03:26:42 +00:00
|
|
|
typedef ilist_traits<ValueSubClass> TraitsClass;
|
2002-06-25 16:12:52 +00:00
|
|
|
public:
|
2007-04-17 04:04:14 +00:00
|
|
|
SymbolTableListTraits() {}
|
2002-06-25 16:12:52 +00:00
|
|
|
|
2007-04-17 04:04:14 +00:00
|
|
|
/// getListOwner - Return the object that owns this list. If this is a list
|
|
|
|
/// of instructions, it returns the BasicBlock that owns them.
|
|
|
|
ItemParentClass *getListOwner() {
|
2007-08-12 08:12:35 +00:00
|
|
|
return reinterpret_cast<ItemParentClass*>(reinterpret_cast<char*>(this)-
|
2007-04-17 04:04:14 +00:00
|
|
|
TraitsClass::getListOffset());
|
|
|
|
}
|
2002-06-25 16:12:52 +00:00
|
|
|
|
|
|
|
void addNodeToList(ValueSubClass *V);
|
|
|
|
void removeNodeFromList(ValueSubClass *V);
|
2008-07-28 21:51:04 +00:00
|
|
|
void transferNodesFromList(ilist_traits<ValueSubClass> &L2,
|
2002-06-25 16:12:52 +00:00
|
|
|
ilist_iterator<ValueSubClass> first,
|
|
|
|
ilist_iterator<ValueSubClass> last);
|
|
|
|
//private:
|
2007-04-17 03:26:42 +00:00
|
|
|
template<typename TPtr>
|
|
|
|
void setSymTabObject(TPtr *, TPtr);
|
2002-06-25 16:12:52 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-06-25 16:12:52 +00:00
|
|
|
#endif
|