2002-12-28 20:03:01 +00:00
|
|
|
//===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===//
|
2005-04-21 20:39:54 +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:39:54 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-12-28 20:03:01 +00:00
|
|
|
//
|
|
|
|
// This file defines the MachineFunctionPass class. MachineFunctionPass's are
|
|
|
|
// just FunctionPass's, except they operate on machine code as part of a code
|
|
|
|
// generator. Because they operate on machine code, not the LLVM
|
|
|
|
// representation, MachineFunctionPass's are not allowed to modify the LLVM
|
|
|
|
// representation. Due to this limitation, the MachineFunctionPass class takes
|
|
|
|
// care of declaring that no LLVM passes are invalidated.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
|
|
|
|
#define LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
|
|
|
|
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2009-08-19 23:00:07 +00:00
|
|
|
class MachineFunction;
|
|
|
|
|
2009-07-31 18:16:33 +00:00
|
|
|
/// MachineFunctionPass - This class adapts the FunctionPass interface to
|
|
|
|
/// allow convenient creation of passes that operate on the MachineFunction
|
|
|
|
/// representation. Instead of overriding runOnFunction, subclasses
|
|
|
|
/// override runOnMachineFunction.
|
|
|
|
class MachineFunctionPass : public FunctionPass {
|
|
|
|
protected:
|
2007-07-02 14:53:37 +00:00
|
|
|
explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {}
|
2008-09-04 17:05:41 +00:00
|
|
|
explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {}
|
2007-05-01 21:15:47 +00:00
|
|
|
|
2010-04-02 23:17:14 +00:00
|
|
|
/// createPrinterPass - Get a machine function printer pass.
|
|
|
|
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;
|
|
|
|
|
2002-12-28 20:03:01 +00:00
|
|
|
/// runOnMachineFunction - This method must be overloaded to perform the
|
|
|
|
/// desired machine code transformation or analysis.
|
|
|
|
///
|
|
|
|
virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
|
|
|
|
|
2009-07-31 18:16:33 +00:00
|
|
|
/// getAnalysisUsage - Subclasses that override getAnalysisUsage
|
|
|
|
/// must call this.
|
2009-08-11 15:50:56 +00:00
|
|
|
///
|
|
|
|
/// For MachineFunctionPasses, calling AU.preservesCFG() indicates that
|
|
|
|
/// the pass does not modify the MachineBasicBlock CFG.
|
|
|
|
///
|
2009-07-31 18:16:33 +00:00
|
|
|
virtual void getAnalysisUsage(AnalysisUsage &AU) const;
|
|
|
|
|
|
|
|
private:
|
2009-04-13 05:44:34 +00:00
|
|
|
bool runOnFunction(Function &F);
|
2002-12-28 20:03:01 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-12-28 20:03:01 +00:00
|
|
|
#endif
|