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
19674be02d525d4e24bc6943ed9274958c580bcfbcJakub Staszak#ifndef LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
20674be02d525d4e24bc6943ed9274958c580bcfbcJakub Staszak#define LLVM_CODEGEN_MACHINEFUNCTIONPASS_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:
3490c579de5a383cee278acc3f7e7b9d0a656e6a35Owen Anderson  explicit MachineFunctionPass(char &ID) : FunctionPass(ID) {}
35794fd75c67a2cdc128d67342c6d88a504d186896Devang Patel
362a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  /// runOnMachineFunction - This method must be overloaded to perform the
372a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  /// desired machine code transformation or analysis.
382a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  ///
392a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
402a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
41ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman  /// getAnalysisUsage - Subclasses that override getAnalysisUsage
42ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman  /// must call this.
43d1ad72f54f4abf62a5f0b2c297edf5e4b1ab1024Dan Gohman  ///
44d1ad72f54f4abf62a5f0b2c297edf5e4b1ab1024Dan Gohman  /// For MachineFunctionPasses, calling AU.preservesCFG() indicates that
45d1ad72f54f4abf62a5f0b2c297edf5e4b1ab1024Dan Gohman  /// the pass does not modify the MachineBasicBlock CFG.
46d1ad72f54f4abf62a5f0b2c297edf5e4b1ab1024Dan Gohman  ///
4736b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  void getAnalysisUsage(AnalysisUsage &AU) const override;
48ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohman
49ad2afc2a421a0e41603d5eee412d4d8c77e9bc1cDan Gohmanprivate:
508613b18a5aa80b13bb8c7f470528146f009bed74Dan Gohman  /// createPrinterPass - Get a machine function printer pass.
5136b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  Pass *createPrinterPass(raw_ostream &O,
5236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines                          const std::string &Banner) const override;
538613b18a5aa80b13bb8c7f470528146f009bed74Dan Gohman
5436b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines  bool runOnFunction(Function &F) override;
552a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner};
562a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
57d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace
58d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
592a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner#endif
60