P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpf/psa/backend.h
1/*
2Copyright 2022-present Orange
3Copyright 2022-present Open Networking Foundation
4
5Licensed under the Apache License, Version 2.0 (the "License");
6you may not use this file except in compliance with the License.
7You may obtain a copy of the License at
8
9 http://www.apache.org/licenses/LICENSE-2.0
10
11Unless required by applicable law or agreed to in writing, software
12distributed under the License is distributed on an "AS IS" BASIS,
13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14See the License for the specific language governing permissions and
15limitations under the License.
16*/
17#ifndef BACKENDS_EBPF_PSA_BACKEND_H_
18#define BACKENDS_EBPF_PSA_BACKEND_H_
19
20#include "ebpfPsaGen.h"
21
22namespace P4::EBPF {
23
25 public:
26 const EbpfOptions &options;
27 P4::ReferenceMap *refMap;
28 P4::TypeMap *typeMap;
29 P4::P4CoreLibrary &corelib;
30 const IR::ToplevelBlock *toplevel = nullptr;
31
32 Target *target;
33 const PSAEbpfGenerator *ebpf_program = nullptr;
34
35 PSASwitchBackend(const EbpfOptions &options, Target *target, P4::ReferenceMap *refMap,
36 P4::TypeMap *typeMap)
37 : options(options),
38 refMap(refMap),
39 typeMap(typeMap),
40 corelib(P4::P4CoreLibrary::instance()),
41 target(target) {
42 refMap->setIsV1(options.isv1());
43 }
44
45 void convert(const IR::ToplevelBlock *tlb);
46 void codegen(std::ostream &cstream) const {
47 CodeBuilder c(target);
48 // Instead of generating two files, put all the code in a single file.
49 ebpf_program->emit(&c);
50 cstream << c.toString();
51 }
52};
53
54} // namespace P4::EBPF
55
56#endif /* BACKENDS_EBPF_PSA_BACKEND_H_ */
Definition ebpf/codeGen.h:33
Definition ebpfPsaGen.h:47
Definition ebpf/psa/backend.h:24
Definition ebpf/target.h:44
Definition ebpfOptions.h:26
Definition coreLibrary.h:103
bool isv1() const
True if we are compiling a P4 v1.0 or v1.1 program.
Definition parser_options.cpp:473
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
void setIsV1(bool isv1)
Set boolean indicating whether map is for a P4_14 program to isV1.
Definition referenceMap.h:105
Definition typeMap.h:41
Definition codeGen.cpp:25