MachineFunctionPass.h revision ea61c358720aa6c7a159d51658b34276316aa841
12a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner//===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===//
2ea61c358720aa6c7a159d51658b34276316aa841Misha Brukman//
36fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//                     The LLVM Compiler Infrastructure
46fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell//
56fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// This file was developed by the LLVM research group and is distributed under
66fbcc26f1460eaee4e0eb8b426fc1ff0c7af11beJohn Criswell// the University of Illinois Open Source 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
292a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  /// runOnMachineFunction - This method must be overloaded to perform the
302a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  /// desired machine code transformation or analysis.
312a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  ///
322a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
332a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
342a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  // FIXME: This pass should declare that the pass does not invalidate any LLVM
352a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  // passes.
362a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
372a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  virtual bool runOnFunction(Function &F) {
382a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner    return runOnMachineFunction(MachineFunction::get(&F));
392a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner  }
402a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner};
412a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner
42d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke} // End llvm namespace
43d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke
442a4a095e5788be7967c0ac311efc269bc87e80b3Chris Lattner#endif
45