2003-09-30 18:37:50 +00:00
|
|
|
//===- llvm/Analysis/FindUsedTypes.h - Find all Types in use ----*- 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
|
|
|
//===----------------------------------------------------------------------===//
|
2001-11-09 05:27:10 +00:00
|
|
|
//
|
|
|
|
// This pass is used to seek out all of the types in use by the program.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ANALYSIS_FINDUSEDTYPES_H
|
|
|
|
#define LLVM_ANALYSIS_FINDUSEDTYPES_H
|
|
|
|
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
#include <set>
|
2003-11-11 22:41:34 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2002-01-30 23:27:55 +00:00
|
|
|
class Type;
|
2009-01-05 17:59:02 +00:00
|
|
|
class Value;
|
2001-11-09 05:27:10 +00:00
|
|
|
|
2004-09-20 04:48:05 +00:00
|
|
|
class FindUsedTypes : public ModulePass {
|
2002-01-20 22:54:45 +00:00
|
|
|
std::set<const Type *> UsedTypes;
|
2001-11-09 05:27:10 +00:00
|
|
|
public:
|
2007-05-06 13:37:16 +00:00
|
|
|
static char ID; // Pass identification, replacement for typeid
|
2008-09-04 17:05:41 +00:00
|
|
|
FindUsedTypes() : ModulePass(&ID) {}
|
2007-05-01 21:15:47 +00:00
|
|
|
|
2002-09-24 00:07:17 +00:00
|
|
|
/// getTypes - After the pass has been run, return the set containing all of
|
|
|
|
/// the types used in the module.
|
|
|
|
///
|
2002-07-26 21:11:42 +00:00
|
|
|
const std::set<const Type *> &getTypes() const { return UsedTypes; }
|
2001-11-09 05:27:10 +00:00
|
|
|
|
2002-09-24 00:07:17 +00:00
|
|
|
/// Print the types found in the module. If the optional Module parameter is
|
|
|
|
/// passed in, then the types are printed symbolically if possible, using the
|
|
|
|
/// symbol table from the module.
|
|
|
|
///
|
2002-07-27 01:12:15 +00:00
|
|
|
void print(std::ostream &o, const Module *M) const;
|
2006-12-17 05:15:13 +00:00
|
|
|
void print(std::ostream *o, const Module *M) const { if (o) print(*o, M); }
|
2001-11-09 05:27:10 +00:00
|
|
|
|
|
|
|
private:
|
2002-09-24 00:07:17 +00:00
|
|
|
/// IncorporateType - Incorporate one type and all of its subtypes into the
|
|
|
|
/// collection of used types.
|
|
|
|
///
|
2001-11-09 05:27:10 +00:00
|
|
|
void IncorporateType(const Type *Ty);
|
|
|
|
|
2003-10-28 23:10:44 +00:00
|
|
|
/// IncorporateValue - Incorporate all of the types used by this value.
|
|
|
|
///
|
|
|
|
void IncorporateValue(const Value *V);
|
|
|
|
|
2001-11-15 15:24:31 +00:00
|
|
|
public:
|
2002-09-24 00:07:17 +00:00
|
|
|
/// run - This incorporates all types used by the specified module
|
2004-09-20 04:48:05 +00:00
|
|
|
bool runOnModule(Module &M);
|
2001-11-09 05:27:10 +00:00
|
|
|
|
2002-09-24 00:07:17 +00:00
|
|
|
/// getAnalysisUsage - We do not modify anything.
|
2002-04-27 06:56:12 +00:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
|
|
|
|
AU.setPreservesAll();
|
|
|
|
}
|
2001-11-09 05:27:10 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-11-09 05:27:10 +00:00
|
|
|
#endif
|