MachineFunctionPass.h revision 8613b18a5aa80b13bb8c7f470528146f009bed74
12a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner//===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===//
2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//                     The LLVM Compiler Infrastructure
46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//
57ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// This file is distributed under the University of Illinois Open Source
67ed47a13356daed2a34cd2209a31f92552e3bdd8Chris Lattner// License. See LICENSE.TXT for details.
7ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
86fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//===----------------------------------------------------------------------===//
92a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner//
102a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner// This file defines the MachineFunctionPass class.  MachineFunctionPass's are
112a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner// just FunctionPass's, except they operate on machine code as part of a code
122a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner// generator.  Because they operate on machine code, not the LLVM
132a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner// representation, MachineFunctionPass's are not allowed to modify the LLVM
142a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner// representation.  Due to this limitation, the MachineFunctionPass class takes
152a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner// care of declaring that no LLVM passes are invalidated.
162a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner//
172a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner//===----------------------------------------------------------------------===//
182a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
192a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner#ifndef LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
202a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner#define LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
212a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
222a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner#include "llvm/Pass.h"
232a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
24d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm {
25d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
26f189004d3b172600bb5bedfe9158c1e2a3f45c34David Greeneclass MachineFunction;
27f189004d3b172600bb5bedfe9158c1e2a3f45c34David Greene
28ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman/// MachineFunctionPass - This class adapts the FunctionPass interface to
29ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman/// allow convenient creation of passes that operate on the MachineFunction
30ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman/// representation. Instead of overriding runOnFunction, subclasses
31ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman/// override runOnMachineFunction.
32ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohmanclass MachineFunctionPass : public FunctionPass {
33ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohmanprotected:
34a6900c7ad9752a27e2e3b1bd78b2af3b1381176dDan Gohman  explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {}
35ae73dc1448d25b02cabc7c64c86c64371453dda8Dan Gohman  explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {}
36794fd75c67a2cdc128d67342c6d88a504d186896Devang Patel
372a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  /// runOnMachineFunction - This method must be overloaded to perform the
382a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  /// desired machine code transformation or analysis.
392a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  ///
402a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
412a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
42ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman  /// getAnalysisUsage - Subclasses that override getAnalysisUsage
43ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman  /// must call this.
44d1ad72f54f4abf62a5f0b2c297edf5e4b1ab1024Dan Gohman  ///
45d1ad72f54f4abf62a5f0b2c297edf5e4b1ab1024Dan Gohman  /// For MachineFunctionPasses, calling AU.preservesCFG() indicates that
46d1ad72f54f4abf62a5f0b2c297edf5e4b1ab1024Dan Gohman  /// the pass does not modify the MachineBasicBlock CFG.
47d1ad72f54f4abf62a5f0b2c297edf5e4b1ab1024Dan Gohman  ///
48ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
49ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman
50ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohmanprivate:
518613b18a5aa80b13bb8c7f470528146f009bed74Dan Gohman  /// createPrinterPass - Get a machine function printer pass.
528613b18a5aa80b13bb8c7f470528146f009bed74Dan Gohman  virtual Pass *createPrinterPass(raw_ostream &O,
538613b18a5aa80b13bb8c7f470528146f009bed74Dan Gohman                                  const std::string &Banner) const;
548613b18a5aa80b13bb8c7f470528146f009bed74Dan Gohman
558613b18a5aa80b13bb8c7f470528146f009bed74Dan Gohman  virtual bool runOnFunction(Function &F);
562a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner};
572a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
58d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace
59d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
602a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner#endif
61