P4C
The P4 Compiler
Loading...
Searching...
No Matches
ebpfPsaRegister.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_EXTERNS_EBPFPSAREGISTER_H_
18#define BACKENDS_EBPF_PSA_EXTERNS_EBPFPSAREGISTER_H_
19
20#include "backends/ebpf/ebpfTable.h"
21#include "backends/ebpf/ebpfType.h"
22
23namespace P4::EBPF {
24
25class ControlBodyTranslatorPSA;
26
28 protected:
29 size_t size;
32 const IR::Constant *initialValue = nullptr;
33 const IR::Type *keyArg;
34 const IR::Type *valueArg;
35 EBPFType *keyType;
36 EBPFType *valueType;
37
38 bool shouldUseArrayMap();
39
40 public:
41 EBPFRegisterPSA(const EBPFProgram *program, cstring instanceName,
42 const IR::Declaration_Instance *di, CodeGenInspector *codeGen);
43
44 void emitTypes(CodeBuilder *builder);
45 void emitKeyType(CodeBuilder *builder);
46 void emitValueType(CodeBuilder *builder);
47
48 void emitInitializer(CodeBuilder *builder);
49 void emitInstance(CodeBuilder *builder);
50 void emitRegisterRead(CodeBuilder *builder, const P4::ExternMethod *method,
51 ControlBodyTranslatorPSA *translator,
52 const IR::Expression *leftExpression);
53 void emitRegisterWrite(CodeBuilder *builder, const P4::ExternMethod *method,
54 ControlBodyTranslatorPSA *translator);
55};
56
57} // namespace P4::EBPF
58
59#endif // BACKENDS_EBPF_PSA_EXTERNS_EBPFPSAREGISTER_H_
Definition ebpf/codeGen.h:33
Definition ebpf/codeGen.h:41
Definition ebpfPsaControl.h:30
Definition ebpfProgram.h:39
Definition ebpfPsaRegister.h:27
const IR::Constant * initialValue
Definition ebpfPsaRegister.h:32
Also used to represent counters.
Definition ebpfTable.h:49
Base class for EBPF types.
Definition ebpfType.h:29
Definition methodInstance.h:168
Definition cstring.h:85
Definition codeGen.cpp:25