|
|
|||
File indexing completed on 2026-05-10 08:43:30
0001 //===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 // This file defines the MachineFunctionPass class. MachineFunctionPass's are 0010 // just FunctionPass's, except they operate on machine code as part of a code 0011 // generator. Because they operate on machine code, not the LLVM 0012 // representation, MachineFunctionPass's are not allowed to modify the LLVM 0013 // representation. Due to this limitation, the MachineFunctionPass class takes 0014 // care of declaring that no LLVM passes are invalidated. 0015 // 0016 //===----------------------------------------------------------------------===// 0017 0018 #ifndef LLVM_CODEGEN_MACHINEFUNCTIONPASS_H 0019 #define LLVM_CODEGEN_MACHINEFUNCTIONPASS_H 0020 0021 #include "llvm/CodeGen/MachineFunction.h" 0022 #include "llvm/Pass.h" 0023 0024 namespace llvm { 0025 0026 /// MachineFunctionPass - This class adapts the FunctionPass interface to 0027 /// allow convenient creation of passes that operate on the MachineFunction 0028 /// representation. Instead of overriding runOnFunction, subclasses 0029 /// override runOnMachineFunction. 0030 class MachineFunctionPass : public FunctionPass { 0031 public: 0032 bool doInitialization(Module&) override { 0033 // Cache the properties info at module-init time so we don't have to 0034 // construct them for every function. 0035 RequiredProperties = getRequiredProperties(); 0036 SetProperties = getSetProperties(); 0037 ClearedProperties = getClearedProperties(); 0038 return false; 0039 } 0040 protected: 0041 explicit MachineFunctionPass(char &ID) : FunctionPass(ID) {} 0042 0043 /// runOnMachineFunction - This method must be overloaded to perform the 0044 /// desired machine code transformation or analysis. 0045 /// 0046 virtual bool runOnMachineFunction(MachineFunction &MF) = 0; 0047 0048 /// getAnalysisUsage - Subclasses that override getAnalysisUsage 0049 /// must call this. 0050 /// 0051 /// For MachineFunctionPasses, calling AU.preservesCFG() indicates that 0052 /// the pass does not modify the MachineBasicBlock CFG. 0053 /// 0054 void getAnalysisUsage(AnalysisUsage &AU) const override; 0055 0056 virtual MachineFunctionProperties getRequiredProperties() const { 0057 return MachineFunctionProperties(); 0058 } 0059 virtual MachineFunctionProperties getSetProperties() const { 0060 return MachineFunctionProperties(); 0061 } 0062 virtual MachineFunctionProperties getClearedProperties() const { 0063 return MachineFunctionProperties(); 0064 } 0065 0066 private: 0067 MachineFunctionProperties RequiredProperties; 0068 MachineFunctionProperties SetProperties; 0069 MachineFunctionProperties ClearedProperties; 0070 0071 /// createPrinterPass - Get a machine function printer pass. 0072 Pass *createPrinterPass(raw_ostream &O, 0073 const std::string &Banner) const override; 0074 0075 bool runOnFunction(Function &F) override; 0076 }; 0077 0078 } // End llvm namespace 0079 0080 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|