P4C
The P4 Compiler
Loading...
Searching...
No Matches
declarations.h
1#ifndef BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_DECLARATIONS_H_
2#define BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_DECLARATIONS_H_
3
4#include <cstddef>
5
6#include "backends/p4tools/modules/smith/common/generator.h"
7#include "ir/indexed_vector.h"
8#include "ir/ir.h"
9#include "lib/cstring.h"
10
11namespace P4::P4Tools::P4Smith {
12
14 public:
15 explicit DeclarationGenerator(const SmithTarget &target) : Generator(target) {}
16
17 virtual ~DeclarationGenerator() = default;
18
19 virtual IR::StatOrDecl *generateRandomStatementOrDeclaration(bool is_in_func);
20
21 virtual IR::Vector<IR::Annotation> genAnnotation();
22
23 virtual IR::P4Action *genActionDeclaration();
24
25 virtual IR::Declaration_Constant *genConstantDeclaration();
26
27 virtual IR::IndexedVector<IR::Declaration> genLocalControlDecls();
28
29 virtual IR::P4Control *genControlDeclaration();
30
31 virtual IR::Declaration_Instance *genControlDeclarationInstance();
32
33 virtual IR::Type *genDerivedTypeDeclaration();
34
35 virtual IR::IndexedVector<IR::Declaration_ID> genIdentifierList(size_t len);
36
37 virtual IR::IndexedVector<IR::SerEnumMember> genSpecifiedIdentifier(size_t len);
38
39 virtual IR::IndexedVector<IR::SerEnumMember> genSpecifiedIdentifierList(size_t len);
40
41 virtual IR::Type_Enum *genEnumDeclaration(cstring name);
42
43 virtual IR::Type_SerEnum *genSerEnumDeclaration(cstring name);
44
45 virtual IR::Type *genEnumTypeDeclaration(int type);
46
47 virtual IR::Method *genExternDeclaration();
48
49 virtual IR::Function *genFunctionDeclaration();
50
51 static IR::Type_Header *genEthernetHeaderType();
52
53 virtual IR::Type_Header *genHeaderTypeDeclaration();
54
55 virtual IR::Type_HeaderUnion *genHeaderUnionDeclaration();
56
57 static constexpr size_t MAX_HEADER_STACK_SIZE = 10;
58
59 virtual IR::Type *genHeaderStackType();
60
61 virtual IR::Type_Struct *genStructTypeDeclaration();
62
63 virtual IR::Type_Struct *genHeaderStruct();
64
65 virtual IR::Type_Declaration *genTypeDeclaration();
66
67 virtual const IR::Type *genType();
68
69 virtual IR::Type_Typedef *genTypeDef();
70
71 virtual IR::Type_Newtype *genNewtype();
72
73 virtual IR::Type *genTypeDefOrNewType();
74
75 virtual IR::Declaration_Variable *genVariableDeclaration();
76
77 virtual IR::Parameter *genTypedParameter(bool if_none_dir);
78
79 virtual IR::Parameter *genParameter(IR::Direction dir, cstring p_name, cstring t_name);
80
81 virtual IR::ParameterList *genParameterList();
82};
83
84} // namespace P4::P4Tools::P4Smith
85
86#endif /* BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_DECLARATIONS_H_ */
Definition node.h:52
Definition vector.h:59
Definition declarations.h:13
Definition generator.h:10
Definition p4tools/modules/smith/core/target.h:17
Definition cstring.h:85