P4C
The P4 Compiler
Loading...
Searching...
No Matches
pass_utils.h
1/*
2Copyright 2024 Intel Corp.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17#ifndef IR_PASS_UTILS_H_
18#define IR_PASS_UTILS_H_
19
20#include "ir/pass_manager.h"
21#include "lib/compile_context.h"
22
25
26namespace P4 {
27
28inline const char *DIAGNOSTIC_COUNT_IN_PASS_TAG = "diagnosticCountInPass";
29
48
49struct DiagnosticCountInfoState; // forward declaration
50
55
58
59 friend struct DiagnosticCountInfo;
60
61 private:
62 DiagnosticCountInfoGuard(std::string_view componentInfo,
63 std::shared_ptr<DiagnosticCountInfoState> state)
64 : componentInfo(componentInfo), state(state) {}
65 std::string_view componentInfo;
66 std::shared_ptr<DiagnosticCountInfoState> state;
67};
68
79
84
88 void emitInfo(std::string_view componentInfo);
89
92 DiagnosticCountInfoGuard getInfoGuard(std::string_view componentInfo);
93
94 private:
95 std::shared_ptr<DiagnosticCountInfoState> state;
96};
97
98} // namespace P4
99
100#endif // IR_PASS_UTILS_H_
Definition compile_context.h:85
static BaseCompileContext & get()
Definition compile_context.cpp:61
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
DebugHook getDiagnosticCountInPassHook(BaseCompileContext &ctxt)
This creates a debug hook that prints information about the number of diagnostics of different levels...
Definition pass_utils.cpp:89
std::function< void(const char *manager, unsigned seqNo, const char *pass, const IR::Node *node)> DebugHook
Definition pass_manager.h:38
Definition pass_utils.h:53
DiagnosticCountInfoGuard(DiagnosticCountInfoGuard &&)=delete
avoid creating moved-from object and copies that could emit spurious logs.
Definition pass_utils.h:75
void emitInfo(std::string_view componentInfo)
Definition pass_utils.cpp:100
DebugHook getPassManagerHook()
Definition pass_utils.cpp:98
DiagnosticCountInfoGuard getInfoGuard(std::string_view componentInfo)
Definition pass_utils.cpp:102
DiagnosticCountInfo(BaseCompileContext &ctxt=BaseCompileContext::get())
Definition pass_utils.cpp:95