MachineFunctionPass.h revision f189004d3b172600bb5bedfe9158c1e2a3f45c34
16c38a79d770f3f0eaa11694ad84ca729b75272c4Chris Lattner//===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===//
2f976c856fcc5055f3fc7d9f070d72c2d027c1d9dMisha Brukman//
3b576c94c15af9a440f69d9d03c2afead7971118cJohn Criswell//                     The LLVM Compiler Infrastructure
4b576c94c15af9a440f69d9d03c2afead7971118cJohn Criswell//
54ee451de366474b9c228b4e5fa573795a715216dChris Lattner// This file is distributed under the University of Illinois Open Source
64ee451de366474b9c228b4e5fa573795a715216dChris Lattner// License. See LICENSE.TXT for details.
7f976c856fcc5055f3fc7d9f070d72c2d027c1d9dMisha Brukman//
8b576c94c15af9a440f69d9d03c2afead7971118cJohn Criswell//===----------------------------------------------------------------------===//
96c38a79d770f3f0eaa11694ad84ca729b75272c4Chris Lattner//
106c38a79d770f3f0eaa11694ad84ca729b75272c4Chris Lattner// This file defines the MachineFunctionPass class.  MachineFunctionPass's are
116c38a79d770f3f0eaa11694ad84ca729b75272c4Chris Lattner// just FunctionPass's, except they operate on machine code as part of a code
126c38a79d770f3f0eaa11694ad84ca729b75272c4Chris Lattner// generator.  Because they operate on machine code, not the LLVM
136c38a79d770f3f0eaa11694ad84ca729b75272c4Chris Lattner// representation, MachineFunctionPass's are not allowed to modify the LLVM
14551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer// representation.  Due to this limitation, the MachineFunctionPass class takes
15d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruth// care of declaring that no LLVM passes are invalidated.
16551ccae044b0ff658fe629dd67edd5ffe75d10e8Reid Spencer//
17fc86c3cfd6e81113722f17bebc54bc0b63389b58Chris Lattner//===----------------------------------------------------------------------===//
18dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines
19d9ea85ab01fb0f2929ed50223d3758dceea8bcbdChris Lattner#ifndef LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
20d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruth#define LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
211f6efa3996dd1929fbc129203ce5009b620e6969Michael J. Spencer
22cd81d94322a39503e4a3e87b6ee03d4fcb3465fbStephen Hines#include "llvm/Pass.h"
231f6efa3996dd1929fbc129203ce5009b620e6969Michael J. Spencer
24d04a8d4b33ff316ca4cf961e06c9e312eff8e64fChandler Carruthnamespace llvm {
25b6d465f8131f5fb0b8e565685fb3395ed9aecbdbChris Lattner
26f205fec78ae79707464d568bad297bc69fd1db78Chris Lattnerclass MachineFunction;
2749a2bb23d1391c8be45985518d4c5e99ff11b864Chris Lattner
2849a2bb23d1391c8be45985518d4c5e99ff11b864Chris Lattner/// MachineFunctionPass - This class adapts the FunctionPass interface to
29d0fde30ce850b78371fd1386338350591f9ff494Brian Gaeke/// allow convenient creation of passes that operate on the MachineFunction
3071336a9c14d2da7fd9ab094eed8c6f3695b864eeChris Lattner/// representation. Instead of overriding runOnFunction, subclasses
3171336a9c14d2da7fd9ab094eed8c6f3695b864eeChris Lattner/// override runOnMachineFunction.
32ac0b6ae358944ae8b2b5a11dc08f52c3ed89f2daChris Lattnerclass MachineFunctionPass : public FunctionPass {
3371336a9c14d2da7fd9ab094eed8c6f3695b864eeChris Lattnerprotected:
3471336a9c14d2da7fd9ab094eed8c6f3695b864eeChris Lattner  explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {}
35f6e5a25f3a57a225c8545e453045f3ae220e3286Reid Spencer  explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {}
36f6e5a25f3a57a225c8545e453045f3ae220e3286Reid Spencer
37f6e5a25f3a57a225c8545e453045f3ae220e3286Reid Spencer  /// runOnMachineFunction - This method must be overloaded to perform the
3890aa839c88776e3dd0b3a798a98ea30d85b6b53cChris Lattner  /// desired machine code transformation or analysis.
3971336a9c14d2da7fd9ab094eed8c6f3695b864eeChris Lattner  ///
40f6e5a25f3a57a225c8545e453045f3ae220e3286Reid Spencer  virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
4171336a9c14d2da7fd9ab094eed8c6f3695b864eeChris Lattner
426c38a79d770f3f0eaa11694ad84ca729b75272c4Chris Lattner  /// getAnalysisUsage - Subclasses that override getAnalysisUsage
4346d9a6494496d215e850f337b5a723c484212f80Owen Anderson  /// must call this.
4446d9a6494496d215e850f337b5a723c484212f80Owen Anderson  ///
453f39849003689a4d33aecdc744d4d27fd93a8f68Chris Lattner  /// For MachineFunctionPasses, calling AU.preservesCFG() indicates that
463c02aca2380bc95a3ce5799929354612c67cc105Dan Gohman  /// the pass does not modify the MachineBasicBlock CFG.
473f39849003689a4d33aecdc744d4d27fd93a8f68Chris Lattner  ///
483f39849003689a4d33aecdc744d4d27fd93a8f68Chris Lattner  virtual void getAnalysisUsage(AnalysisUsage &AU) const;
493f39849003689a4d33aecdc744d4d27fd93a8f68Chris Lattner
50f205fec78ae79707464d568bad297bc69fd1db78Chris Lattnerprivate:
513c02aca2380bc95a3ce5799929354612c67cc105Dan Gohman  bool runOnFunction(Function &F);
5296a54db5e763c19f556a1b54ad2956cc91b81cb8Chris Lattner};
53f205fec78ae79707464d568bad297bc69fd1db78Chris Lattner
5471336a9c14d2da7fd9ab094eed8c6f3695b864eeChris Lattner} // End llvm namespace
553f39849003689a4d33aecdc744d4d27fd93a8f68Chris Lattner
563f39849003689a4d33aecdc744d4d27fd93a8f68Chris Lattner#endif
5749a2bb23d1391c8be45985518d4c5e99ff11b864Chris Lattner