From 4068e1af9ff68b6b5fdb3233f1304e53f1bf179a Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 7 Jan 2013 15:43:51 +0000 Subject: Move TypeFinder.h into the IR tree, it clearly belongs with the IR library. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171749 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/TypeFinder.h | 78 ++++++++++++++++++++++++++++++++++++ include/llvm/TypeFinder.h | 78 ------------------------------------ lib/IR/AsmWriter.cpp | 2 +- lib/IR/TypeFinder.cpp | 2 +- lib/Linker/LinkModules.cpp | 2 +- lib/Transforms/IPO/StripSymbols.cpp | 2 +- lib/Transforms/Utils/MetaRenamer.cpp | 2 +- 7 files changed, 83 insertions(+), 83 deletions(-) create mode 100644 include/llvm/IR/TypeFinder.h delete mode 100644 include/llvm/TypeFinder.h diff --git a/include/llvm/IR/TypeFinder.h b/include/llvm/IR/TypeFinder.h new file mode 100644 index 0000000000..cea66a4ab0 --- /dev/null +++ b/include/llvm/IR/TypeFinder.h @@ -0,0 +1,78 @@ +//===-- llvm/IR/TypeFinder.h - Class to find used struct types --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains the declaration of the TypeFinder class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_IR_TYPEFINDER_H +#define LLVM_IR_TYPEFINDER_H + +#include "llvm/ADT/DenseSet.h" +#include + +namespace llvm { + +class MDNode; +class Module; +class StructType; +class Type; +class Value; + +/// TypeFinder - Walk over a module, identifying all of the types that are +/// used by the module. +class TypeFinder { + // To avoid walking constant expressions multiple times and other IR + // objects, we keep several helper maps. + DenseSet VisitedConstants; + DenseSet VisitedTypes; + + std::vector StructTypes; + bool OnlyNamed; + +public: + TypeFinder() : OnlyNamed(false) {} + + void run(const Module &M, bool onlyNamed); + void clear(); + + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; + + iterator begin() { return StructTypes.begin(); } + iterator end() { return StructTypes.end(); } + + const_iterator begin() const { return StructTypes.begin(); } + const_iterator end() const { return StructTypes.end(); } + + bool empty() const { return StructTypes.empty(); } + size_t size() const { return StructTypes.size(); } + iterator erase(iterator I, iterator E) { return StructTypes.erase(I, E); } + + StructType *&operator[](unsigned Idx) { return StructTypes[Idx]; } + +private: + /// incorporateType - This method adds the type to the list of used + /// structures if it's not in there already. + void incorporateType(Type *Ty); + + /// incorporateValue - This method is used to walk operand lists finding types + /// hiding in constant expressions and other operands that won't be walked in + /// other ways. GlobalValues, basic blocks, instructions, and inst operands + /// are all explicitly enumerated. + void incorporateValue(const Value *V); + + /// incorporateMDNode - This method is used to walk the operands of an MDNode + /// to find types hiding within. + void incorporateMDNode(const MDNode *V); +}; + +} // end llvm namespace + +#endif diff --git a/include/llvm/TypeFinder.h b/include/llvm/TypeFinder.h deleted file mode 100644 index 5d807057a3..0000000000 --- a/include/llvm/TypeFinder.h +++ /dev/null @@ -1,78 +0,0 @@ -//===-- llvm/TypeFinder.h - Class for finding used struct types -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains the declaration of the TypeFinder class. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TYPEFINDER_H -#define LLVM_TYPEFINDER_H - -#include "llvm/ADT/DenseSet.h" -#include - -namespace llvm { - -class MDNode; -class Module; -class StructType; -class Type; -class Value; - -/// TypeFinder - Walk over a module, identifying all of the types that are -/// used by the module. -class TypeFinder { - // To avoid walking constant expressions multiple times and other IR - // objects, we keep several helper maps. - DenseSet VisitedConstants; - DenseSet VisitedTypes; - - std::vector StructTypes; - bool OnlyNamed; - -public: - TypeFinder() : OnlyNamed(false) {} - - void run(const Module &M, bool onlyNamed); - void clear(); - - typedef std::vector::iterator iterator; - typedef std::vector::const_iterator const_iterator; - - iterator begin() { return StructTypes.begin(); } - iterator end() { return StructTypes.end(); } - - const_iterator begin() const { return StructTypes.begin(); } - const_iterator end() const { return StructTypes.end(); } - - bool empty() const { return StructTypes.empty(); } - size_t size() const { return StructTypes.size(); } - iterator erase(iterator I, iterator E) { return StructTypes.erase(I, E); } - - StructType *&operator[](unsigned Idx) { return StructTypes[Idx]; } - -private: - /// incorporateType - This method adds the type to the list of used - /// structures if it's not in there already. - void incorporateType(Type *Ty); - - /// incorporateValue - This method is used to walk operand lists finding types - /// hiding in constant expressions and other operands that won't be walked in - /// other ways. GlobalValues, basic blocks, instructions, and inst operands - /// are all explicitly enumerated. - void incorporateValue(const Value *V); - - /// incorporateMDNode - This method is used to walk the operands of an MDNode - /// to find types hiding within. - void incorporateMDNode(const MDNode *V); -}; - -} // end llvm namespace - -#endif diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index 4d2affcad0..1c46a9414a 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -30,6 +30,7 @@ #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" #include "llvm/IR/Operator.h" +#include "llvm/IR/TypeFinder.h" #include "llvm/IR/ValueSymbolTable.h" #include "llvm/Support/CFG.h" #include "llvm/Support/Debug.h" @@ -37,7 +38,6 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Support/MathExtras.h" -#include "llvm/TypeFinder.h" #include #include using namespace llvm; diff --git a/lib/IR/TypeFinder.cpp b/lib/IR/TypeFinder.cpp index f2e4f11b24..d5e6203507 100644 --- a/lib/IR/TypeFinder.cpp +++ b/lib/IR/TypeFinder.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/TypeFinder.h" +#include "llvm/IR/TypeFinder.h" #include "llvm/ADT/SmallVector.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/DerivedTypes.h" diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index bc512b46bc..e973919de3 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -21,12 +21,12 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" +#include "llvm/IR/TypeFinder.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/ValueMapper.h" -#include "llvm/TypeFinder.h" #include using namespace llvm; diff --git a/lib/Transforms/IPO/StripSymbols.cpp b/lib/Transforms/IPO/StripSymbols.cpp index 707fc6c331..5f8681ff45 100644 --- a/lib/Transforms/IPO/StripSymbols.cpp +++ b/lib/Transforms/IPO/StripSymbols.cpp @@ -28,10 +28,10 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Module.h" +#include "llvm/IR/TypeFinder.h" #include "llvm/IR/ValueSymbolTable.h" #include "llvm/Pass.h" #include "llvm/Transforms/Utils/Local.h" -#include "llvm/TypeFinder.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Utils/MetaRenamer.cpp b/lib/Transforms/Utils/MetaRenamer.cpp index 2715aa08bc..d519fb7548 100644 --- a/lib/Transforms/Utils/MetaRenamer.cpp +++ b/lib/Transforms/Utils/MetaRenamer.cpp @@ -20,8 +20,8 @@ #include "llvm/IR/Function.h" #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" +#include "llvm/IR/TypeFinder.h" #include "llvm/Pass.h" -#include "llvm/TypeFinder.h" using namespace llvm; namespace { -- cgit v1.2.3