P4C
The P4 Compiler
Loading...
Searching...
No Matches
p4tools/common/lib/arch_spec.h
1/*
2 * SPDX-FileCopyrightText: 2023 The P4 Language Consortium
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef BACKENDS_P4TOOLS_COMMON_LIB_ARCH_SPEC_H_
8#define BACKENDS_P4TOOLS_COMMON_LIB_ARCH_SPEC_H_
9
10#include <cstddef>
11#include <map>
12#include <vector>
13
14#include "lib/cstring.h"
15
16namespace P4::P4Tools {
17
19class ArchSpec {
20 public:
22 struct ArchMember {
23 cstring blockName;
24 std::vector<cstring> blockParams;
25 };
26
27 private:
29 cstring packageName;
30
32 std::vector<ArchMember> archVector;
33
36 std::map<cstring, size_t> blockIndices;
37
38 public:
39 explicit ArchSpec(cstring packageName, const std::vector<ArchMember> &archVectorInput);
40
43 [[nodiscard]] size_t getBlockIndex(cstring blockName) const;
44
47 [[nodiscard]] const ArchMember *getArchMember(size_t blockIndex) const;
48
51 [[nodiscard]] cstring getParamName(size_t blockIndex, size_t paramIndex) const;
52
56 [[nodiscard]] cstring getParamName(cstring blockName, size_t paramIndex) const;
57
59 [[nodiscard]] size_t getArchVectorSize() const;
60
62 [[nodiscard]] cstring getPackageName() const;
63};
64
65} // namespace P4::P4Tools
66
67#endif /* BACKENDS_P4TOOLS_COMMON_LIB_ARCH_SPEC_H_ */
size_t getArchVectorSize() const
Definition p4tools/common/lib/arch_spec.cpp:54
cstring getParamName(size_t blockIndex, size_t paramIndex) const
Definition p4tools/common/lib/arch_spec.cpp:39
const ArchMember * getArchMember(size_t blockIndex) const
Definition p4tools/common/lib/arch_spec.cpp:48
cstring getPackageName() const
Definition p4tools/common/lib/arch_spec.cpp:56
size_t getBlockIndex(cstring blockName) const
Definition p4tools/common/lib/arch_spec.cpp:23
An ArchMember represents a construct in the pipe. It has a name and parameters.
Definition p4tools/common/lib/arch_spec.h:22
Definition cstring.h:85
Definition common/compiler/compiler_result.cpp:7