2003-09-30 20:37:50 +02:00
|
|
|
//===- llvm/PassManager.h - Container for Passes ----------------*- C++ -*-===//
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:19:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-04-28 22:46:05 +02:00
|
|
|
//
|
|
|
|
// This file defines the PassManager class. This class is used to hold,
|
2003-05-20 20:39:06 +02:00
|
|
|
// maintain, and optimize execution of Passes. The PassManager class ensures
|
2002-04-28 22:46:05 +02:00
|
|
|
// that analysis results are available before a pass runs, and that Pass's are
|
|
|
|
// destroyed when the PassManager is destroyed.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_PASSMANAGER_H
|
|
|
|
#define LLVM_PASSMANAGER_H
|
|
|
|
|
2009-11-01 17:42:53 +01:00
|
|
|
#include "llvm/Pass.h"
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-04-28 22:46:05 +02:00
|
|
|
class Pass;
|
|
|
|
class Module;
|
2006-12-13 03:36:01 +01:00
|
|
|
|
2006-12-19 20:46:59 +01:00
|
|
|
class PassManagerImpl;
|
|
|
|
class FunctionPassManagerImpl;
|
2006-11-08 11:05:38 +01:00
|
|
|
|
2008-03-11 17:41:42 +01:00
|
|
|
/// PassManagerBase - An abstract interface to allow code to add passes to
|
|
|
|
/// a pass manager without having to hard-code what kind of pass manager
|
|
|
|
/// it is.
|
|
|
|
class PassManagerBase {
|
|
|
|
public:
|
|
|
|
virtual ~PassManagerBase();
|
|
|
|
|
|
|
|
/// add - Add a pass to the queue of passes to run. This passes ownership of
|
|
|
|
/// the Pass to the PassManager. When the PassManager is destroyed, the pass
|
|
|
|
/// will be destroyed as well, so there is no need to delete the pass. This
|
|
|
|
/// implies that all passes MUST be allocated with 'new'.
|
|
|
|
virtual void add(Pass *P) = 0;
|
|
|
|
};
|
|
|
|
|
2006-12-13 03:36:01 +01:00
|
|
|
/// PassManager manages ModulePassManagers
|
2008-03-11 17:41:42 +01:00
|
|
|
class PassManager : public PassManagerBase {
|
2006-11-07 23:23:34 +01:00
|
|
|
public:
|
|
|
|
|
2006-12-13 03:36:01 +01:00
|
|
|
PassManager();
|
|
|
|
~PassManager();
|
2006-11-08 11:29:57 +01:00
|
|
|
|
2006-11-07 23:23:34 +01:00
|
|
|
/// add - Add a pass to the queue of passes to run. This passes ownership of
|
|
|
|
/// the Pass to the PassManager. When the PassManager is destroyed, the pass
|
|
|
|
/// will be destroyed as well, so there is no need to delete the pass. This
|
|
|
|
/// implies that all passes MUST be allocated with 'new'.
|
|
|
|
void add(Pass *P);
|
|
|
|
|
|
|
|
/// run - Execute all of the passes scheduled for execution. Keep track of
|
|
|
|
/// whether any of the passes modifies the module, and if so, return true.
|
|
|
|
bool run(Module &M);
|
|
|
|
|
|
|
|
private:
|
2010-05-10 22:24:27 +02:00
|
|
|
/// addImpl - Add a pass to the queue of passes to run, without
|
|
|
|
/// checking whether to add a printer pass.
|
|
|
|
void addImpl(Pass *P);
|
2006-11-07 23:23:34 +01:00
|
|
|
|
2006-12-13 03:36:01 +01:00
|
|
|
/// PassManagerImpl_New is the actual class. PassManager is just the
|
2006-11-08 11:29:57 +01:00
|
|
|
/// wraper to publish simple pass manager interface
|
2006-12-19 20:46:59 +01:00
|
|
|
PassManagerImpl *PM;
|
2006-11-07 23:23:34 +01:00
|
|
|
};
|
|
|
|
|
2006-12-13 03:36:01 +01:00
|
|
|
/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers.
|
2008-03-11 17:41:42 +01:00
|
|
|
class FunctionPassManager : public PassManagerBase {
|
2006-11-08 11:44:40 +01:00
|
|
|
public:
|
2007-10-25 07:19:24 +02:00
|
|
|
/// FunctionPassManager ctor - This initializes the pass manager. It needs,
|
2010-01-27 21:34:15 +01:00
|
|
|
/// but does not take ownership of, the specified Module.
|
|
|
|
explicit FunctionPassManager(Module *M);
|
2006-12-13 03:36:01 +01:00
|
|
|
~FunctionPassManager();
|
2006-11-08 11:44:40 +01:00
|
|
|
|
|
|
|
/// add - Add a pass to the queue of passes to run. This passes
|
|
|
|
/// ownership of the Pass to the PassManager. When the
|
|
|
|
/// PassManager_X is destroyed, the pass will be destroyed as well, so
|
|
|
|
/// there is no need to delete the pass. (TODO delete passes.)
|
|
|
|
/// This implies that all passes MUST be allocated with 'new'.
|
|
|
|
void add(Pass *P);
|
|
|
|
|
2006-11-15 20:39:54 +01:00
|
|
|
/// run - Execute all of the passes scheduled for execution. Keep
|
|
|
|
/// track of whether any of the passes modifies the function, and if
|
|
|
|
/// so, return true.
|
|
|
|
///
|
|
|
|
bool run(Function &F);
|
|
|
|
|
2006-11-15 03:07:25 +01:00
|
|
|
/// doInitialization - Run all of the initializers for the function passes.
|
|
|
|
///
|
|
|
|
bool doInitialization();
|
|
|
|
|
2007-07-30 16:51:13 +02:00
|
|
|
/// doFinalization - Run all of the finalizers for the function passes.
|
2006-11-15 03:07:25 +01:00
|
|
|
///
|
|
|
|
bool doFinalization();
|
2008-06-27 00:26:45 +02:00
|
|
|
|
2006-11-08 11:44:40 +01:00
|
|
|
private:
|
2010-05-10 22:24:27 +02:00
|
|
|
/// addImpl - Add a pass to the queue of passes to run, without
|
|
|
|
/// checking whether to add a printer pass.
|
|
|
|
void addImpl(Pass *P);
|
|
|
|
|
2006-12-19 20:46:59 +01:00
|
|
|
FunctionPassManagerImpl *FPM;
|
2010-01-27 21:34:15 +01:00
|
|
|
Module *M;
|
2006-11-08 11:44:40 +01:00
|
|
|
};
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-04-28 22:46:05 +02:00
|
|
|
#endif
|