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_MACHINEFUNCTIONPASS_H
00020 #define LLVM_CODEGEN_MACHINEFUNCTIONPASS_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(char &ID) : FunctionPass(ID) {}
00035 
00036   /// runOnMachineFunction - This method must be overloaded to perform the
00037   /// desired machine code transformation or analysis.
00038   ///
00039   virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
00040 
00041   /// getAnalysisUsage - Subclasses that override getAnalysisUsage
00042   /// must call this.
00043   ///
00044   /// For MachineFunctionPasses, calling AU.preservesCFG() indicates that
00045   /// the pass does not modify the MachineBasicBlock CFG.
00046   ///
00047   void getAnalysisUsage(AnalysisUsage &AU) const override;
00048 
00049 private:
00050   /// createPrinterPass - Get a machine function printer pass.
00051   Pass *createPrinterPass(raw_ostream &O,
00052                           const std::string &Banner) const override;
00053 
00054   bool runOnFunction(Function &F) override;
00055 };
00056 
00057 } // End llvm namespace
00058 
00059 #endif