LLVM 19.0.0git
PassInfo.h
Go to the documentation of this file.
1//===- llvm/PassInfo.h - Pass Info class ------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines and implements the PassInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_PASSINFO_H
14#define LLVM_PASSINFO_H
15
16#include "llvm/ADT/StringRef.h"
17#include <cassert>
18#include <vector>
19
20namespace llvm {
21
22class Pass;
23
24//===---------------------------------------------------------------------------
25/// PassInfo class - An instance of this class exists for every pass known by
26/// the system, and can be obtained from a live Pass by calling its
27/// getPassInfo() method. These objects are set up by the RegisterPass<>
28/// template.
29///
30class PassInfo {
31public:
32 using NormalCtor_t = Pass* (*)();
33
34private:
35 StringRef PassName; // Nice name for Pass
36 StringRef PassArgument; // Command Line argument to run this pass
37 const void *PassID;
38 const bool IsCFGOnlyPass = false; // Pass only looks at the CFG.
39 const bool IsAnalysis; // True if an analysis pass.
40 const bool IsAnalysisGroup; // True if an analysis group.
41 std::vector<const PassInfo *> ItfImpl; // Interfaces implemented by this pass
42 NormalCtor_t NormalCtor = nullptr;
43
44public:
45 /// PassInfo ctor - Do not call this directly, this should only be invoked
46 /// through RegisterPass.
47 PassInfo(StringRef name, StringRef arg, const void *pi, NormalCtor_t normal,
48 bool isCFGOnly, bool is_analysis)
49 : PassName(name), PassArgument(arg), PassID(pi), IsCFGOnlyPass(isCFGOnly),
50 IsAnalysis(is_analysis), IsAnalysisGroup(false), NormalCtor(normal) {}
51
52 /// PassInfo ctor - Do not call this directly, this should only be invoked
53 /// through RegisterPass. This version is for use by analysis groups; it
54 /// does not auto-register the pass.
55 PassInfo(StringRef name, const void *pi)
56 : PassName(name), PassID(pi), IsAnalysis(false), IsAnalysisGroup(true) {}
57
58 PassInfo(const PassInfo &) = delete;
59 PassInfo &operator=(const PassInfo &) = delete;
60
61 /// getPassName - Return the friendly name for the pass, never returns null
62 StringRef getPassName() const { return PassName; }
63
64 /// getPassArgument - Return the command line option that may be passed to
65 /// 'opt' that will cause this pass to be run. This will return null if there
66 /// is no argument.
67 StringRef getPassArgument() const { return PassArgument; }
68
69 /// getTypeInfo - Return the id object for the pass...
70 /// TODO : Rename
71 const void *getTypeInfo() const { return PassID; }
72
73 /// Return true if this PassID implements the specified ID pointer.
74 bool isPassID(const void *IDPtr) const { return PassID == IDPtr; }
75
76 /// isAnalysisGroup - Return true if this is an analysis group, not a normal
77 /// pass.
78 bool isAnalysisGroup() const { return IsAnalysisGroup; }
79 bool isAnalysis() const { return IsAnalysis; }
80
81 /// isCFGOnlyPass - return true if this pass only looks at the CFG for the
82 /// function.
83 bool isCFGOnlyPass() const { return IsCFGOnlyPass; }
84
85 /// getNormalCtor - Return a pointer to a function, that when called, creates
86 /// an instance of the pass and returns it. This pointer may be null if there
87 /// is no default constructor for the pass.
89 return NormalCtor;
90 }
92 NormalCtor = Ctor;
93 }
94
95 /// createPass() - Use this method to create an instance of this pass.
96 Pass *createPass() const {
97 assert((!isAnalysisGroup() || NormalCtor) &&
98 "No default implementation found for analysis group!");
99 assert(NormalCtor &&
100 "Cannot call createPass on PassInfo without default ctor!");
101 return NormalCtor();
102 }
103
104 /// addInterfaceImplemented - This method is called when this pass is
105 /// registered as a member of an analysis group with the RegisterAnalysisGroup
106 /// template.
108 ItfImpl.push_back(ItfPI);
109 }
110
111 /// getInterfacesImplemented - Return a list of all of the analysis group
112 /// interfaces implemented by this pass.
113 const std::vector<const PassInfo*> &getInterfacesImplemented() const {
114 return ItfImpl;
115 }
116};
117
118} // end namespace llvm
119
120#endif // LLVM_PASSINFO_H
aarch64 AArch64 CCMP Pass
basic Basic Alias true
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const char * name
Definition: SMEABIPass.cpp:49
PassInfo class - An instance of this class exists for every pass known by the system,...
Definition: PassInfo.h:30
PassInfo(StringRef name, const void *pi)
PassInfo ctor - Do not call this directly, this should only be invoked through RegisterPass.
Definition: PassInfo.h:55
bool isPassID(const void *IDPtr) const
Return true if this PassID implements the specified ID pointer.
Definition: PassInfo.h:74
PassInfo & operator=(const PassInfo &)=delete
Pass *(*)() NormalCtor_t
Definition: PassInfo.h:32
NormalCtor_t getNormalCtor() const
getNormalCtor - Return a pointer to a function, that when called, creates an instance of the pass and...
Definition: PassInfo.h:88
bool isAnalysis() const
Definition: PassInfo.h:79
bool isAnalysisGroup() const
isAnalysisGroup - Return true if this is an analysis group, not a normal pass.
Definition: PassInfo.h:78
PassInfo(const PassInfo &)=delete
void setNormalCtor(NormalCtor_t Ctor)
Definition: PassInfo.h:91
void addInterfaceImplemented(const PassInfo *ItfPI)
addInterfaceImplemented - This method is called when this pass is registered as a member of an analys...
Definition: PassInfo.h:107
const std::vector< const PassInfo * > & getInterfacesImplemented() const
getInterfacesImplemented - Return a list of all of the analysis group interfaces implemented by this ...
Definition: PassInfo.h:113
PassInfo(StringRef name, StringRef arg, const void *pi, NormalCtor_t normal, bool isCFGOnly, bool is_analysis)
PassInfo ctor - Do not call this directly, this should only be invoked through RegisterPass.
Definition: PassInfo.h:47
StringRef getPassArgument() const
getPassArgument - Return the command line option that may be passed to 'opt' that will cause this pas...
Definition: PassInfo.h:67
StringRef getPassName() const
getPassName - Return the friendly name for the pass, never returns null
Definition: PassInfo.h:62
bool isCFGOnlyPass() const
isCFGOnlyPass - return true if this pass only looks at the CFG for the function.
Definition: PassInfo.h:83
Pass * createPass() const
createPass() - Use this method to create an instance of this pass.
Definition: PassInfo.h:96
const void * getTypeInfo() const
getTypeInfo - Return the id object for the pass... TODO : Rename
Definition: PassInfo.h:71
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18