P4C
The P4 Compiler
Loading...
Searching...
No Matches
splitter.h
1/*
2Copyright 2025-present Altera Corporation.
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_SPLITTER_H_
18#define IR_SPLITTER_H_
19
20#include "ir/ir.h"
21#include "ir/visitor.h"
22
23namespace P4 {
24
25class NameGenerator;
26class TypeMap;
27
28template <typename Node>
30 const Node *before = nullptr;
31 const Node *after = nullptr;
32 std::vector<const IR::Declaration *> hoistedDeclarations;
33
35 explicit operator bool() const { return after; }
36 void clear() {
37 before = after = nullptr;
38 hoistedDeclarations.clear();
39 }
40};
41
121 const IR::Statement *stat,
122 std::function<bool(const IR::Statement *, const P4::Visitor_Context *)> predicate,
123 P4::NameGenerator &nameGen, P4::TypeMap *typeMap = nullptr);
124
125} // namespace P4
126
127#endif // IR_SPLITTER_H_
Definition referenceMap.h:29
Definition typeMap.h:41
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
SplitResult< IR::Statement > splitStatementBefore(const IR::Statement *stat, std::function< bool(const IR::Statement *, const P4::Visitor_Context *)> predicate, P4::NameGenerator &nameGen, P4::TypeMap *typeMap)
Split stat so that on every control-flow path all the statements up to the first one matching predica...
Definition splitter.cpp:269
Definition splitter.h:29