P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4test/midend.h
1/*
2 * SPDX-FileCopyrightText: 2013 Barefoot Networks, Inc.
3 * Copyright 2013-present Barefoot Networks, Inc.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef BACKENDS_P4TEST_MIDEND_H_
9#define BACKENDS_P4TEST_MIDEND_H_
10
11#include "frontends/common/options.h"
12#include "frontends/p4/evaluator/evaluator.h"
13#include "ir/ir.h"
14#include "p4test.h"
15
16namespace P4::P4Test {
17
18class MidEnd : public PassManager {
19 std::vector<DebugHook> hooks;
20
21 public:
22 P4::ReferenceMap refMap;
23 P4::TypeMap typeMap;
24 IR::ToplevelBlock *toplevel = nullptr;
25
26 void addDebugHook(DebugHook hook) { hooks.push_back(hook); }
27 explicit MidEnd(P4TestOptions &options, std::ostream *outStream = nullptr);
28 IR::ToplevelBlock *process(const IR::P4Program *&program) {
29 addDebugHooks(hooks, true);
30 program = program->apply(*this);
31 return toplevel;
32 }
33};
34
35} // namespace P4::P4Test
36
37#endif /* BACKENDS_P4TEST_MIDEND_H_ */
Class used to encode maps from paths to declarations.
Definition referenceMap.h:67
Definition typeMap.h:32
Definition p4test.h:15
std::function< void(const char *manager, unsigned seqNo, const char *pass, const IR::Node *node)> DebugHook
Definition ir/pass_manager.h:38