19#ifndef BACKENDS_TOFINO_BF_P4C_IR_UNIQUE_ID_H_
20#define BACKENDS_TOFINO_BF_P4C_IR_UNIQUE_ID_H_
24#include "lib/cstring.h"
25#include "lib/exceptions.h"
58 enum pre_placed_type_t { NO_PP, TIND_PP, ADATA_PP };
61 return name == uai.name && type == uai.type;
64 bool operator!=(
const UniqueAttachedId &uai)
const {
return !(*
this == uai); }
67 if (name != uai.name)
return name < uai.name;
68 if (type != uai.type)
return type < uai.type;
72 operator bool()
const {
return type != INVALID; }
73 bool name_valid()
const {
return !name.isNull(); }
78 if (!(type == IDLETIME || type == TERNARY_INDIRECT || (type == ACTION_DATA && direct))) {
84 BUG_CHECK(ppt != NO_PP,
"Attached ID not initialized correct");
85 if (ppt == TIND_PP) type = TERNARY_INDIRECT;
86 if (ppt == ADATA_PP) type = ACTION_DATA;
92 bool has_meter_type()
const {
93 return type == METER || type == STATEFUL_ALU || type == SELECTOR;
96 std::string build_name()
const;
99inline std::ostream &operator<<(std::ostream &out,
const UniqueAttachedId::type_t type) {
101 case UniqueAttachedId::TERNARY_INDIRECT:
102 out <<
"TERNARY_INDIRECT";
104 case UniqueAttachedId::IDLETIME:
107 case UniqueAttachedId::COUNTER:
110 case UniqueAttachedId::METER:
113 case UniqueAttachedId::SELECTOR:
116 case UniqueAttachedId::STATEFUL_ALU:
117 out <<
"STATEFUL_ALU";
119 case UniqueAttachedId::ACTION_DATA:
120 out <<
"ACTION_DATA";
129inline bool operator>>(cstring s, UniqueAttachedId::type_t &type) {
130 if (!s || s ==
"" || s ==
"INVALID")
131 type = UniqueAttachedId::INVALID;
132 else if (s ==
"TERNARY_INDIRECT")
133 type = UniqueAttachedId::TERNARY_INDIRECT;
134 else if (s ==
"IDLETIME")
135 type = UniqueAttachedId::IDLETIME;
136 else if (s ==
"COUNTER")
137 type = UniqueAttachedId::COUNTER;
138 else if (s ==
"METER")
139 type = UniqueAttachedId::METER;
140 else if (s ==
"SELECTOR")
141 type = UniqueAttachedId::SELECTOR;
142 else if (s ==
"STATEFUL_ALU")
143 type = UniqueAttachedId::STATEFUL_ALU;
144 else if (s ==
"ACTION_DATA")
145 type = UniqueAttachedId::ACTION_DATA;
151inline std::ostream &operator<<(std::ostream &out,
const UniqueAttachedId &uai) {
152 out << uai.name <<
" " << uai.type;
172 int stage_table = -1;
175 int logical_table = -1;
177 bool stage_table_used()
const {
return stage_table != -1; }
178 bool logical_table_used()
const {
return logical_table != -1; }
183 enum speciality_t { NONE, ATCAM, DLEFT } speciality = NONE;
185 bool operator==(
const UniqueId &ui)
const;
186 bool operator!=(
const UniqueId &ui)
const {
return !(*
this == ui); }
187 bool operator<(
const UniqueId &ui)
const;
189 bool equal_table(
const UniqueId &ui)
const;
191 std::string build_name()
const;
196 cstring toString()
const {
return build_name(); }
199std::ostream &operator<<(std::ostream &out,
const UniqueId &ui);
Definition json_generator.h:36
Definition json_loader.h:38
Definition unique_id.h:44
Definition unique_id.h:168
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24