FindUsedTypes.h revision 226890
1109905Smarkm//===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- C++ -*-===// 234198Sjdp// 334198Sjdp// The LLVM Compiler Infrastructure 434198Sjdp// 534198Sjdp// This file is distributed under the University of Illinois Open Source 634198Sjdp// License. See LICENSE.TXT for details. 734198Sjdp// 834198Sjdp//===----------------------------------------------------------------------===// 934198Sjdp// 1034198Sjdp// This pass is used to seek out all of the types in use by the program. 1134198Sjdp// 1234198Sjdp//===----------------------------------------------------------------------===// 1334198Sjdp 1434198Sjdp#ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H 1534198Sjdp#define LLVM_ANALYSIS_FINDUSEDTYPES_H 1634198Sjdp 1734198Sjdp#include "llvm/ADT/SetVector.h" 1834198Sjdp#include "llvm/Pass.h" 1934198Sjdp 2034198Sjdpnamespace llvm { 2134198Sjdp 2234198Sjdpclass Type; 2334198Sjdpclass Value; 2434198Sjdp 2534198Sjdpclass FindUsedTypes : public ModulePass { 2634198Sjdp SetVector<Type *> UsedTypes; 27216338Sdimpublic: 28216338Sdim static char ID; // Pass identification, replacement for typeid 29216338Sdim FindUsedTypes() : ModulePass(ID) { 30100167Smarkm initializeFindUsedTypesPass(*PassRegistry::getPassRegistry()); 3134198Sjdp } 3234198Sjdp 3334198Sjdp /// getTypes - After the pass has been run, return the set containing all of 34100167Smarkm /// the types used in the module. 3534198Sjdp /// 3634198Sjdp const SetVector<Type *> &getTypes() const { return UsedTypes; } 3799354Smarkm 3893399Smarkm /// Print the types found in the module. If the optional Module parameter is 3967811Sobrien /// passed in, then the types are printed symbolically if possible, using the 40232832Skib /// symbol table from the module. 4134198Sjdp /// 4234198Sjdp void print(raw_ostream &o, const Module *M) const; 4334198Sjdp 4438928Sjdpprivate: 4538928Sjdp /// IncorporateType - Incorporate one type and all of its subtypes into the 4638928Sjdp /// collection of used types. 4738928Sjdp /// 4838928Sjdp void IncorporateType(Type *Ty); 4938928Sjdp 5038928Sjdp /// IncorporateValue - Incorporate all of the types used by this value. 51204756Suqs /// 52204756Suqs void IncorporateValue(const Value *V); 53100167Smarkm 5434198Sjdppublic: 55114319Speter /// run - This incorporates all types used by the specified module 5634198Sjdp bool runOnModule(Module &M); 5799354Smarkm 5899354Smarkm /// getAnalysisUsage - We do not modify anything. 5999354Smarkm virtual void getAnalysisUsage(AnalysisUsage &AU) const { 6034198Sjdp AU.setPreservesAll(); 61114319Speter } 62114319Speter}; 63114319Speter 6499354Smarkm} // End llvm namespace 65232832Skib 66232832Skib#endif 6734198Sjdp