LLVM API Documentation

MachineFunctionPass.h

Go to the documentation of this file.
00001 //===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file defines the MachineFunctionPass class.  MachineFunctionPass's are
00011 // just FunctionPass's, except they operate on machine code as part of a code
00012 // generator.  Because they operate on machine code, not the LLVM
00013 // representation, MachineFunctionPass's are not allowed to modify the LLVM
00014 // representation.  Due to this limitation, the MachineFunctionPass class takes
00015 // care of declaring that no LLVM passes are invalidated.
00016 //
00017 //===----------------------------------------------------------------------===//
00018 
00019 #ifndef LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
00020 #define LLVM_CODEGEN_MACHINE_FUNCTION_PASS_H
00021 
00022 #include "llvm/Pass.h"
00023 #include "llvm/CodeGen/MachineFunction.h"
00024 
00025 namespace llvm {
00026 
00027 struct MachineFunctionPass : public FunctionPass {
00028 
00029   explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {}
00030   explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {}
00031 
00032 protected:
00033   /// runOnMachineFunction - This method must be overloaded to perform the
00034   /// desired machine code transformation or analysis.
00035   ///
00036   virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
00037 
00038 public:
00039   // FIXME: This pass should declare that the pass does not invalidate any LLVM
00040   // passes.
00041   bool runOnFunction(Function &F) {
00042     return runOnMachineFunction(MachineFunction::get(&F));
00043   }
00044   
00045 private:
00046   virtual void virtfn();  // out of line virtual fn to give class a home.
00047 };
00048 
00049 } // End llvm namespace
00050 
00051 #endif