MachineFunctionPass.h revision 7ed47a13356daed2a34cd2209a31f92552e3bdd8
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#include "llvm/CodeGen/MachineFunction.h"
242a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
25d0fde30ce850b78371fd1386338350591f9ff494Brian Gaekenamespace llvm {
26d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
272a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattnerstruct MachineFunctionPass : public FunctionPass {
282a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
29a6900c7ad9752a27e2e3b1bd78b2af3b1381176dDan Gohman  explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {}
30794fd75c67a2cdc128d67342c6d88a504d186896Devang Patel
31d27df628cc6fa29605fa221a2f0b03b4592caf03Dan Gohmanprotected:
322a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  /// runOnMachineFunction - This method must be overloaded to perform the
332a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  /// desired machine code transformation or analysis.
342a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  ///
352a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
362a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
37d27df628cc6fa29605fa221a2f0b03b4592caf03Dan Gohmanpublic:
382a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  // FIXME: This pass should declare that the pass does not invalidate any LLVM
392a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  // passes.
40d27df628cc6fa29605fa221a2f0b03b4592caf03Dan Gohman  bool runOnFunction(Function &F) {
412a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner    return runOnMachineFunction(MachineFunction::get(&F));
422a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  }
43efb9b813fa74d3134dd185df10f6577ceab72bcdChris Lattner
44d27df628cc6fa29605fa221a2f0b03b4592caf03Dan Gohmanprivate:
45efb9b813fa74d3134dd185df10f6577ceab72bcdChris Lattner  virtual void virtfn();  // out of line virtual fn to give class a home.
462a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner};
472a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
48d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace
49d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
502a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner#endif
51