P4C
The P4 Compiler
Loading...
Searching...
No Matches
deparser.h
1/*
2Copyright 2013-present Barefoot Networks, Inc.
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 BACKENDS_BMV2_COMMON_DEPARSER_H_
18#define BACKENDS_BMV2_COMMON_DEPARSER_H_
19
20#include "backend.h"
21#include "expression.h"
22#include "frontends/common/resolveReferences/referenceMap.h"
23#include "frontends/p4/typeMap.h"
24#include "ir/ir.h"
25#include "lib/json.h"
26
27namespace P4::BMV2 {
28
31 cstring name;
32 P4::P4CoreLibrary &corelib;
33
34 protected:
35 Util::IJson *convertDeparser(const IR::P4Control *ctrl);
36 void convertDeparserBody(const IR::Vector<IR::StatOrDecl> *body, Util::JsonArray *order,
37 Util::JsonArray *primitives);
38
39 public:
40 bool preorder(const IR::P4Control *ctrl) override;
41
42 explicit DeparserConverter(ConversionContext *ctxt, cstring name = "deparser"_cs)
43 : ctxt(ctxt), name(name), corelib(P4::P4CoreLibrary::instance()) {
44 setName("DeparserConverter");
45 }
46};
47
48} // namespace P4::BMV2
49
50#endif /* BACKENDS_BMV2_COMMON_DEPARSER_H_ */
Definition deparser.h:29
Definition vector.h:58
Definition visitor.h:400
Definition coreLibrary.h:103
Definition json.h:40
Definition json.h:115
Definition cstring.h:85
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition action.cpp:21
Definition helpers.h:297