FindUsedTypes.h revision 6fbcc26f1460eaee4e0eb8b426fc1ff0c7af11be
148486893f46d2e12e926682a3ecb908716bc66c4Chris Lattner//===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- C++ -*-===// 26fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// 36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// The LLVM Compiler Infrastructure 46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// 56fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// This file was developed by the LLVM research group and is distributed under 66fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// the University of Illinois Open Source License. See LICENSE.TXT for details. 76fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// 86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===// 9f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner// 10f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner// This pass is used to seek out all of the types in use by the program. 11f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner// 12f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner//===----------------------------------------------------------------------===// 13f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner 14f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner#ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H 15f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner#define LLVM_ANALYSIS_FINDUSEDTYPES_H 16f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner 17f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner#include "llvm/Pass.h" 18f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner#include <set> 19f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattnerclass SymbolTable; 20facd752d3afaeca7dee46648f2a2ae209a94e5e9Chris Lattnerclass Type; 21f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner 22facd752d3afaeca7dee46648f2a2ae209a94e5e9Chris Lattnerclass FindUsedTypes : public Pass { 23697954c15da58bd8b186dbafdedd8b06db770201Chris Lattner std::set<const Type *> UsedTypes; 24f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattnerpublic: 2547b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// getTypes - After the pass has been run, return the set containing all of 2647b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// the types used in the module. 2747b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// 285d549083e2dc55cc1aa035f1069480d052717061Chris Lattner const std::set<const Type *> &getTypes() const { return UsedTypes; } 29f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner 3047b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// Print the types found in the module. If the optional Module parameter is 3147b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// passed in, then the types are printed symbolically if possible, using the 3247b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// symbol table from the module. 3347b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// 3497f51a3024a72ef8500e95b90e6361e6783160fdChris Lattner void print(std::ostream &o, const Module *M) const; 35f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner 36f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattnerprivate: 3747b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// IncorporateType - Incorporate one type and all of its subtypes into the 3847b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// collection of used types. 3947b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// 40f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner void IncorporateType(const Type *Ty); 41f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner 42fe700e7e4240fa88b8d5f44d1e7d6dcc51495c26Chris Lattnerpublic: 4347b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// run - This incorporates all types used by the specified module 447e70829632f82de15db187845666aaca6e04b792Chris Lattner bool run(Module &M); 45f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner 4647b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner /// getAnalysisUsage - We do not modify anything. 47f57b845547302d24ecb6a9e79d7bc386f761a6c9Chris Lattner virtual void getAnalysisUsage(AnalysisUsage &AU) const { 48f57b845547302d24ecb6a9e79d7bc386f761a6c9Chris Lattner AU.setPreservesAll(); 49f57b845547302d24ecb6a9e79d7bc386f761a6c9Chris Lattner } 5047b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner 5147b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner // stub - dummy function, just ignore it 5247b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner static void stub(); 53f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner}; 54f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner 5547b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner// Make sure that any clients of this file link in PostDominators.cpp 5647b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattnerstatic IncludeFile 5747b6f84736197b5ece84860e6cb6052ebc60c646Chris LattnerFIND_USED_TYPES_INCLUDE_FILE((void*)&FindUsedTypes::stub); 5847b6f84736197b5ece84860e6cb6052ebc60c646Chris Lattner 59f26e28711bcc10536036e0c10c931a8ca28b778cChris Lattner#endif 60