7#ifndef BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_SCOPE_H_
8#define BACKENDS_P4TOOLS_MODULES_SMITH_COMMON_SCOPE_H_
19#include "lib/cstring.h"
21namespace P4::P4Tools::P4Smith {
24 bool require_scalar{
false};
25 bool compile_time_known{
false};
26 bool no_methodcalls{
false};
28 bool not_negative{
false};
29 bool byte_align_headers{
false};
37 bool const_header_stack_index{
false};
38 bool const_lshift_count{
false};
39 bool single_stage_actions{
false};
40 int max_phv_container_width{0};
43 int max_bitwidth{128};
50 bool width_unknown{
false};
51 bool has_methodcall{
false};
52 bool in_action{
false};
56 const IR::Type *ret_type =
nullptr;
57 Properties() =
default;
63 static std::vector<IR::Vector<IR::Node> *>
scope;
69 static std::map<cstring, std::map<int, std::set<cstring>>>
lvalMap;
72 static std::map<cstring, std::map<int, std::set<cstring>>>
lvalMapRw;
95 static void addToScope(
const IR::Node *n);
96 static void startLocalScope();
97 static void endLocalScope();
99 static void addLval(
const IR::Type *tp,
cstring name,
bool read_only =
false);
100 static bool checkLval(
const IR::Type *tp,
bool must_write =
false);
101 static cstring pickLval(
const IR::Type *tp,
bool must_write =
false);
102 static void deleteLval(
const IR::Type *tp,
cstring name);
103 static std::set<cstring> getCandidateLvals(
const IR::Type *tp,
bool must_write =
true);
104 static bool hasWriteableLval(
cstring typeKey);
105 static std::optional<std::map<int, std::set<cstring>>> getWriteableLvalForTypeKey(
108 static const IR::Type_Bits *pickDeclaredBitType(
bool must_write =
false);
110 static const IR::Type_Declaration *getTypeByName(
cstring name);
114 template <
typename T>
115 static std::vector<const T *> getDecls() {
116 std::vector<const T *> ret;
118 for (
auto *subScope :
scope) {
119 for (
const auto *node : *subScope) {
120 if (
const T *tmpObj = node->to<T>()) {
121 ret.push_back(tmpObj);
128 static std::vector<const IR::Type_Declaration *> getFilteredDecls(std::set<cstring> filter);
129 static std::set<const IR::P4Table *> *getCallableTables();
Definition tofino/bf-p4c/phv/constraints/constraints.cpp:21