1193323Sed//===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- C++ -*-===// 2193323Sed// 3193323Sed// The LLVM Compiler Infrastructure 4193323Sed// 5193323Sed// This file is distributed under the University of Illinois Open Source 6193323Sed// License. See LICENSE.TXT for details. 7193323Sed// 8193323Sed//===----------------------------------------------------------------------===// 9193323Sed// 10193323Sed// This pass is used to seek out all of the types in use by the program. 11193323Sed// 12193323Sed//===----------------------------------------------------------------------===// 13193323Sed 14193323Sed#ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H 15193323Sed#define LLVM_ANALYSIS_FINDUSEDTYPES_H 16193323Sed 17223017Sdim#include "llvm/ADT/SetVector.h" 18193323Sed#include "llvm/Pass.h" 19193323Sed 20193323Sednamespace llvm { 21193323Sed 22193323Sedclass Type; 23193323Sedclass Value; 24193323Sed 25193323Sedclass FindUsedTypes : public ModulePass { 26226890Sdim SetVector<Type *> UsedTypes; 27193323Sedpublic: 28193323Sed static char ID; // Pass identification, replacement for typeid 29218893Sdim FindUsedTypes() : ModulePass(ID) { 30218893Sdim initializeFindUsedTypesPass(*PassRegistry::getPassRegistry()); 31218893Sdim } 32193323Sed 33193323Sed /// getTypes - After the pass has been run, return the set containing all of 34193323Sed /// the types used in the module. 35193323Sed /// 36226890Sdim const SetVector<Type *> &getTypes() const { return UsedTypes; } 37193323Sed 38193323Sed /// Print the types found in the module. If the optional Module parameter is 39193323Sed /// passed in, then the types are printed symbolically if possible, using the 40193323Sed /// symbol table from the module. 41193323Sed /// 42198090Srdivacky void print(raw_ostream &o, const Module *M) const; 43193323Sed 44193323Sedprivate: 45193323Sed /// IncorporateType - Incorporate one type and all of its subtypes into the 46193323Sed /// collection of used types. 47193323Sed /// 48226890Sdim void IncorporateType(Type *Ty); 49193323Sed 50193323Sed /// IncorporateValue - Incorporate all of the types used by this value. 51193323Sed /// 52193323Sed void IncorporateValue(const Value *V); 53193323Sed 54193323Sedpublic: 55193323Sed /// run - This incorporates all types used by the specified module 56193323Sed bool runOnModule(Module &M); 57193323Sed 58193323Sed /// getAnalysisUsage - We do not modify anything. 59193323Sed virtual void getAnalysisUsage(AnalysisUsage &AU) const { 60193323Sed AU.setPreservesAll(); 61193323Sed } 62193323Sed}; 63193323Sed 64193323Sed} // End llvm namespace 65193323Sed 66193323Sed#endif 67