|
|
|||
File indexing completed on 2026-05-10 08:44:46
0001 //===- llvm/PassInfo.h - Pass Info class ------------------------*- 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 and implements the PassInfo class. 0010 // 0011 //===----------------------------------------------------------------------===// 0012 0013 #ifndef LLVM_PASSINFO_H 0014 #define LLVM_PASSINFO_H 0015 0016 #include "llvm/ADT/StringRef.h" 0017 #include <cassert> 0018 #include <vector> 0019 0020 namespace llvm { 0021 0022 class Pass; 0023 0024 //===--------------------------------------------------------------------------- 0025 /// PassInfo class - An instance of this class exists for every pass known by 0026 /// the system, and can be obtained from a live Pass by calling its 0027 /// getPassInfo() method. These objects are set up by the RegisterPass<> 0028 /// template. 0029 /// 0030 class PassInfo { 0031 public: 0032 using NormalCtor_t = Pass* (*)(); 0033 0034 private: 0035 StringRef PassName; // Nice name for Pass 0036 StringRef PassArgument; // Command Line argument to run this pass 0037 const void *PassID; 0038 const bool IsCFGOnlyPass = false; // Pass only looks at the CFG. 0039 const bool IsAnalysis; // True if an analysis pass. 0040 NormalCtor_t NormalCtor = nullptr; 0041 0042 public: 0043 /// PassInfo ctor - Do not call this directly, this should only be invoked 0044 /// through RegisterPass. 0045 PassInfo(StringRef name, StringRef arg, const void *pi, NormalCtor_t normal, 0046 bool isCFGOnly, bool is_analysis) 0047 : PassName(name), PassArgument(arg), PassID(pi), IsCFGOnlyPass(isCFGOnly), 0048 IsAnalysis(is_analysis), NormalCtor(normal) {} 0049 0050 PassInfo(const PassInfo &) = delete; 0051 PassInfo &operator=(const PassInfo &) = delete; 0052 0053 /// getPassName - Return the friendly name for the pass, never returns null 0054 StringRef getPassName() const { return PassName; } 0055 0056 /// getPassArgument - Return the command line option that may be passed to 0057 /// 'opt' that will cause this pass to be run. This will return null if there 0058 /// is no argument. 0059 StringRef getPassArgument() const { return PassArgument; } 0060 0061 /// getTypeInfo - Return the id object for the pass... 0062 /// TODO : Rename 0063 const void *getTypeInfo() const { return PassID; } 0064 0065 /// Return true if this PassID implements the specified ID pointer. 0066 bool isPassID(const void *IDPtr) const { return PassID == IDPtr; } 0067 0068 bool isAnalysis() const { return IsAnalysis; } 0069 0070 /// isCFGOnlyPass - return true if this pass only looks at the CFG for the 0071 /// function. 0072 bool isCFGOnlyPass() const { return IsCFGOnlyPass; } 0073 0074 /// getNormalCtor - Return a pointer to a function, that when called, creates 0075 /// an instance of the pass and returns it. This pointer may be null if there 0076 /// is no default constructor for the pass. 0077 NormalCtor_t getNormalCtor() const { 0078 return NormalCtor; 0079 } 0080 void setNormalCtor(NormalCtor_t Ctor) { 0081 NormalCtor = Ctor; 0082 } 0083 0084 /// createPass() - Use this method to create an instance of this pass. 0085 Pass *createPass() const { 0086 assert(NormalCtor && 0087 "Cannot call createPass on PassInfo without default ctor!"); 0088 return NormalCtor(); 0089 } 0090 }; 0091 0092 } // end namespace llvm 0093 0094 #endif // LLVM_PASSINFO_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|