1193323Sed//===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===//
2193323Sed//
3193323Sed//                     The LLVM Compiler Infrastructure
4193323Sed//
5193323Sed// This file is distributed under the University of Illinois Open Source
6193323Sed// License. See LICENSE.TXT for details.
7193323Sed//
8193323Sed//===----------------------------------------------------------------------===//
9193323Sed//
10193323Sed// This file defines the MachineFunctionPass class.  MachineFunctionPass's are
11193323Sed// just FunctionPass's, except they operate on machine code as part of a code
12193323Sed// generator.  Because they operate on machine code, not the LLVM
13193323Sed// representation, MachineFunctionPass's are not allowed to modify the LLVM
14193323Sed// representation.  Due to this limitation, the MachineFunctionPass class takes
15193323Sed// care of declaring that no LLVM passes are invalidated.
16193323Sed//
17193323Sed//===----------------------------------------------------------------------===//
18193323Sed
19249423Sdim#ifndef LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
20249423Sdim#define LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
21193323Sed
22193323Sed#include "llvm/Pass.h"
23193323Sed
24193323Sednamespace llvm {
25193323Sed
26198090Srdivackyclass MachineFunction;
27198090Srdivacky
28198090Srdivacky/// MachineFunctionPass - This class adapts the FunctionPass interface to
29198090Srdivacky/// allow convenient creation of passes that operate on the MachineFunction
30198090Srdivacky/// representation. Instead of overriding runOnFunction, subclasses
31198090Srdivacky/// override runOnMachineFunction.
32198090Srdivackyclass MachineFunctionPass : public FunctionPass {
33198090Srdivackyprotected:
34212904Sdim  explicit MachineFunctionPass(char &ID) : FunctionPass(ID) {}
35193323Sed
36193323Sed  /// runOnMachineFunction - This method must be overloaded to perform the
37193323Sed  /// desired machine code transformation or analysis.
38193323Sed  ///
39193323Sed  virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
40193323Sed
41198090Srdivacky  /// getAnalysisUsage - Subclasses that override getAnalysisUsage
42198090Srdivacky  /// must call this.
43198090Srdivacky  ///
44198090Srdivacky  /// For MachineFunctionPasses, calling AU.preservesCFG() indicates that
45198090Srdivacky  /// the pass does not modify the MachineBasicBlock CFG.
46198090Srdivacky  ///
47198090Srdivacky  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
48198090Srdivacky
49198090Srdivackyprivate:
50210299Sed  /// createPrinterPass - Get a machine function printer pass.
51210299Sed  virtual Pass *createPrinterPass(raw_ostream &O,
52210299Sed                                  const std::string &Banner) const;
53210299Sed
54210299Sed  virtual bool runOnFunction(Function &F);
55193323Sed};
56193323Sed
57193323Sed} // End llvm namespace
58193323Sed
59193323Sed#endif
60