P4C
The P4 Compiler
Loading...
Searching...
No Matches
pass_utils.h
1/*
2 * Copyright 2024 Intel Corp.
3 * SPDX-FileCopyrightText: 2024 Intel Corp.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef IR_PASS_UTILS_H_
9#define IR_PASS_UTILS_H_
10
11#include "ir/pass_manager.h"
12#include "lib/compile_context.h"
13
16
17namespace P4 {
18
19inline const char *DIAGNOSTIC_COUNT_IN_PASS_TAG = "diagnosticCountInPass";
20
39
40struct DiagnosticCountInfoState; // forward declaration
41
46
49
50 friend struct DiagnosticCountInfo;
51
52 private:
53 DiagnosticCountInfoGuard(std::string_view componentInfo,
54 std::shared_ptr<DiagnosticCountInfoState> state)
55 : componentInfo(componentInfo), state(state) {}
56 std::string_view componentInfo;
57 std::shared_ptr<DiagnosticCountInfoState> state;
58};
59
70
75
79 void emitInfo(std::string_view componentInfo);
80
83 DiagnosticCountInfoGuard getInfoGuard(std::string_view componentInfo);
84
85 private:
86 std::shared_ptr<DiagnosticCountInfoState> state;
87};
88
89} // namespace P4
90
91#endif // IR_PASS_UTILS_H_
Definition compile_context.h:76
static BaseCompileContext & get()
Definition compile_context.cpp:50
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:13
DebugHook getDiagnosticCountInPassHook(BaseCompileContext &ctxt)
This creates a debug hook that prints information about the number of diagnostics of different levels...
Definition pass_utils.cpp:78
std::function< void(const char *manager, unsigned seqNo, const char *pass, const IR::Node *node)> DebugHook
Definition ir/pass_manager.h:38
Definition pass_utils.h:44
DiagnosticCountInfoGuard(DiagnosticCountInfoGuard &&)=delete
avoid creating moved-from object and copies that could emit spurious logs.
void emitInfo(std::string_view componentInfo)
Definition pass_utils.cpp:89
DebugHook getPassManagerHook()
Definition pass_utils.cpp:87
DiagnosticCountInfoGuard getInfoGuard(std::string_view componentInfo)
Definition pass_utils.cpp:91
DiagnosticCountInfo(BaseCompileContext &ctxt=BaseCompileContext::get())
Definition pass_utils.cpp:84
Definition pass_utils.cpp:21