MachineFunctionPass.h revision 2a4a095e5788be7967c0ac311efc269bc87e80b3
1//===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===//
2//
3// This file defines the MachineFunctionPass class.  MachineFunctionPass's are
4// just FunctionPass's, except they operate on machine code as part of a code
5// generator.  Because they operate on machine code, not the LLVM
6// representation, MachineFunctionPass's are not allowed to modify the LLVM
7// representation.  Due to this limitation, the MachineFunctionPass class takes
8// care of declaring that no LLVM passes are invalidated.
9//
10//===----------------------------------------------------------------------===//
11
12#ifndef LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
13#define LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
14
15#include "llvm/Pass.h"
16#include "llvm/CodeGen/MachineFunction.h"
17
18struct MachineFunctionPass : public FunctionPass {
19
20  /// runOnMachineFunction - This method must be overloaded to perform the
21  /// desired machine code transformation or analysis.
22  ///
23  virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
24
25  // FIXME: This pass should declare that the pass does not invalidate any LLVM
26  // passes.
27
28  virtual bool runOnFunction(Function &F) {
29    return runOnMachineFunction(MachineFunction::get(&F));
30  }
31};
32
33#endif
34