P4C
The P4 Compiler
Loading...
Searching...
No Matches
dpdkMetadata.h
1/*
2Copyright 2022 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 BACKENDS_DPDK_DPDKMETADATA_H_
18#define BACKENDS_DPDK_DPDKMETADATA_H_
19
20#include "dpdkUtils.h"
21#include "frontends/common/resolveReferences/referenceMap.h"
22#include "ir/ir.h"
23
24namespace P4::DPDK {
25
27 bool &is_direction_used;
28
29 public:
30 explicit IsDirectionMetadataUsed(bool &is_direction_used)
31 : is_direction_used(is_direction_used) {}
32 bool preorder(const IR::Member *m) override {
33 if (!is_direction_used && isDirection(m)) {
34 is_direction_used = true;
35 }
36 return false;
37 }
38};
39
44 ordered_map<cstring, cstring> dirToDirMapping;
45 ordered_map<cstring, cstring> inputToInputPortMapping;
46 ordered_set<cstring> usedNames;
47 cstring registerInstanceName;
48
49 public:
55 dirToDirMapping.insert(std::make_pair(cstring("pna_main_input_metadata_direction"),
56 cstring("pna_main_input_metadata_direction")));
57 dirToDirMapping.insert(std::make_pair(cstring("pna_pre_input_metadata_direction"),
58 cstring("pna_main_input_metadata_direction")));
59 dirToDirMapping.insert(std::make_pair(cstring("pna_main_parser_input_metadata_direction"),
60 cstring("pna_main_input_metadata_direction")));
61 inputToInputPortMapping.insert(
62 std::make_pair(cstring("pna_main_input_metadata_input_port"),
63 cstring("pna_main_input_metadata_input_port")));
64 inputToInputPortMapping.insert(
65 std::make_pair(cstring("pna_pre_input_metadata_direction"),
66 cstring("pna_main_input_metadata_input_port")));
67 inputToInputPortMapping.insert(
68 std::make_pair(cstring("pna_main_parser_input_metadata_direction"),
69 cstring("pna_main_input_metadata_input_port")));
70 }
71 const IR::Node *preorder(IR::DpdkAsmProgram *p) override;
72 const IR::Node *preorder(IR::Member *m) override;
73
74 void uniqueNames(IR::DpdkAsmProgram *p);
75 IR::DpdkExternDeclaration *addRegDeclInstance(cstring instanceName);
76 IR::DpdkListStatement *replaceDirection(IR::DpdkListStatement *l);
77 IR::IndexedVector<IR::DpdkAsmStatement> addRegReadStmtForDirection(
79};
80
86
87 public:
89 bool isPass(const IR::Member *m);
90 const IR::Node *postorder(IR::DpdkAction *a) override;
91 const IR::Node *postorder(IR::DpdkListStatement *l) override;
92 IR::IndexedVector<IR::DpdkAsmStatement> prependPassWithRecircid(
94};
95
96} // namespace P4::DPDK
97#endif // BACKENDS_DPDK_DPDKMETADATA_H_
Definition dpdkMetadata.h:43
DirectionToRegRead()
Definition dpdkMetadata.h:50
void uniqueNames(IR::DpdkAsmProgram *p)
Make sure new decls and fields name are unique.
Definition dpdkMetadata.cpp:26
IR::DpdkExternDeclaration * addRegDeclInstance(cstring instanceName)
Create and add register declaration instance to program.
Definition dpdkMetadata.cpp:56
Definition dpdkMetadata.h:26
Definition dpdkMetadata.h:84
bool isPass(const IR::Member *m)
Definition dpdkMetadata.cpp:99
Definition node.h:52
Definition node.h:95
Definition visitor.h:400
Definition visitor.h:424
Definition cstring.h:85
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition dpdk/backend.cpp:37