LLVM 20.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 NormalCtor_t NormalCtor = nullptr;
41
42public:
43 /// PassInfo ctor - Do not call this directly, this should only be invoked
44 /// through RegisterPass.
45 PassInfo(StringRef name, StringRef arg, const void *pi, NormalCtor_t normal,
46 bool isCFGOnly, bool is_analysis)
47 : PassName(name), PassArgument(arg), PassID(pi), IsCFGOnlyPass(isCFGOnly),
48 IsAnalysis(is_analysis), NormalCtor(normal) {}
49
50 PassInfo(const PassInfo &) = delete;
51 PassInfo &operator=(const PassInfo &) = delete;
52
53 /// getPassName - Return the friendly name for the pass, never returns null
54 StringRef getPassName() const { return PassName; }
55
56 /// getPassArgument - Return the command line option that may be passed to
57 /// 'opt' that will cause this pass to be run. This will return null if there
58 /// is no argument.
59 StringRef getPassArgument() const { return PassArgument; }
60
61 /// getTypeInfo - Return the id object for the pass...
62 /// TODO : Rename
63 const void *getTypeInfo() const { return PassID; }
64
65 /// Return true if this PassID implements the specified ID pointer.
66 bool isPassID(const void *IDPtr) const { return PassID == IDPtr; }
67
68 bool isAnalysis() const { return IsAnalysis; }
69
70 /// isCFGOnlyPass - return true if this pass only looks at the CFG for the
71 /// function.
72 bool isCFGOnlyPass() const { return IsCFGOnlyPass; }
73
74 /// getNormalCtor - Return a pointer to a function, that when called, creates
75 /// an instance of the pass and returns it. This pointer may be null if there
76 /// is no default constructor for the pass.
78 return NormalCtor;
79 }
81 NormalCtor = Ctor;
82 }
83
84 /// createPass() - Use this method to create an instance of this pass.
85 Pass *createPass() const {
86 assert(NormalCtor &&
87 "Cannot call createPass on PassInfo without default ctor!");
88 return NormalCtor();
89 }
90};
91
92} // end namespace llvm
93
94#endif // LLVM_PASSINFO_H
aarch64 AArch64 CCMP Pass
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static const char * name
Definition: SMEABIPass.cpp:50
PassInfo class - An instance of this class exists for every pass known by the system,...
Definition: PassInfo.h:30
bool isPassID(const void *IDPtr) const
Return true if this PassID implements the specified ID pointer.
Definition: PassInfo.h:66
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:77
bool isAnalysis() const
Definition: PassInfo.h:68
PassInfo(const PassInfo &)=delete
void setNormalCtor(NormalCtor_t Ctor)
Definition: PassInfo.h:80
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:45
StringRef getPassArgument() const
getPassArgument - Return the command line option that may be passed to 'opt' that will cause this pas...
Definition: PassInfo.h:59
StringRef getPassName() const
getPassName - Return the friendly name for the pass, never returns null
Definition: PassInfo.h:54
bool isCFGOnlyPass() const
isCFGOnlyPass - return true if this pass only looks at the CFG for the function.
Definition: PassInfo.h:72
Pass * createPass() const
createPass() - Use this method to create an instance of this pass.
Definition: PassInfo.h:85
const void * getTypeInfo() const
getTypeInfo - Return the id object for the pass... TODO : Rename
Definition: PassInfo.h:63
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