LLVM API Documentation
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 00024 namespace llvm { 00025 00026 class MachineFunction; 00027 00028 /// MachineFunctionPass - This class adapts the FunctionPass interface to 00029 /// allow convenient creation of passes that operate on the MachineFunction 00030 /// representation. Instead of overriding runOnFunction, subclasses 00031 /// override runOnMachineFunction. 00032 class MachineFunctionPass : public FunctionPass { 00033 protected: 00034 explicit MachineFunctionPass(intptr_t ID) : FunctionPass(ID) {} 00035 explicit MachineFunctionPass(void *ID) : FunctionPass(ID) {} 00036 00037 /// runOnMachineFunction - This method must be overloaded to perform the 00038 /// desired machine code transformation or analysis. 00039 /// 00040 virtual bool runOnMachineFunction(MachineFunction &MF) = 0; 00041 00042 /// getAnalysisUsage - Subclasses that override getAnalysisUsage 00043 /// must call this. 00044 /// 00045 /// For MachineFunctionPasses, calling AU.preservesCFG() indicates that 00046 /// the pass does not modify the MachineBasicBlock CFG. 00047 /// 00048 virtual void getAnalysisUsage(AnalysisUsage &AU) const; 00049 00050 private: 00051 bool runOnFunction(Function &F); 00052 }; 00053 00054 } // End llvm namespace 00055 00056 #endif