19#ifndef BF_P4C_PHV_CONSTRAINTS_CONSTRAINTS_H_
20#define BF_P4C_PHV_CONSTRAINTS_CONSTRAINTS_H_
25#include "lib/cstring.h"
26#include "lib/ordered_set.h"
49 virtual bool hasConstraint()
const = 0;
50 virtual void addConstraint(uint32_t reason) = 0;
65 PRAGMA_SOLITARY = (1 << 4),
66 PRAGMA_CONTAINER_SIZE = (1 << 5),
67 CONFLICT_ALIGNMENT = (1 << 6),
69 CLEAR_ON_WRITE = (1 << 7)
73 bool hasConstraint()
const {
return (reason != 0); }
74 void addConstraint(uint32_t r) { reason |= r; }
76 bool isALU()
const {
return reason & ALU; }
77 bool isChecksum()
const {
return reason & CHECKSUM; }
78 bool isArch()
const {
return reason & ARCH; }
79 bool isDigest()
const {
return reason & DIGEST; }
80 bool isPragmaSolitary()
const {
return reason & PRAGMA_SOLITARY; }
81 bool isPragmaContainerSize()
const {
return reason & PRAGMA_CONTAINER_SIZE; }
82 bool isClearOnWrite()
const {
return reason & CLEAR_ON_WRITE; }
83 bool isOnlyClearOnWrite()
const {
return reason == CLEAR_ON_WRITE; }
101 bool hasConstraint()
const {
return (reason != 0); }
102 void addConstraint(uint32_t r) { reason |= r; }
104 bool isMirror()
const {
return reason & MIRROR; }
105 bool isLearning()
const {
return reason & LEARNING; }
106 bool isResubmit()
const {
return reason & RESUBMIT; }
107 bool isPktGen()
const {
return reason & PKTGEN; }
112 enum DeparsedToTMReason {
117 bool hasConstraint()
const {
return (reason != 0); }
118 void addConstraint(uint32_t r) { reason |= r; }
120 bool isDeparse()
const {
return reason & DEPARSE; }
130 bool hasConstraint()
const {
return (reason != 0); }
131 void addConstraint(uint32_t r) { reason |= r; }
133 bool isNoSplit()
const {
return reason & NO_SPLIT; }
143 virtual bool hasConstraint()
const = 0;
144 virtual void addConstraint(
unsigned r,
unsigned v) = 0;
154 unsigned container_size = 0;
158 enum AlignmentReason {
163 TERNARY_MATCH = (1 << 3),
165 INTRINSIC = (1 << 5),
166 PA_BYTE_PACK = (1 << 6),
170 bool hasConstraint()
const {
return (reason != 0); }
171 void addConstraint(
unsigned source,
unsigned v) {
176 void updateConstraint(
unsigned source) { reason |= source; }
177 void eraseConstraint() { reason = 0; }
178 unsigned getAlignment()
const {
return value; }
179 unsigned getReason()
const {
return reason; }
181 void setContainerSize(
unsigned size) { container_size = size; }
182 unsigned getContainerSize()
const {
return container_size; }
184 bool isBridged()
const {
return reason & BRIDGE; }
185 bool isParser()
const {
return reason & PARSER; }
186 bool isDeparser()
const {
return reason & DEPARSER; }
187 bool isTernaryMatch()
const {
return reason & TERNARY_MATCH; }
188 bool isDigest()
const {
return reason & DIGEST; }
189 bool isIntrinsic()
const {
return reason & INTRINSIC; }
192 return reason == a.reason && value == a.value;
197 else if (reason < a.reason)
205 enum ContainerSizeReason { NONE = 0, PRAGMA = 1 };
208 bool hasConstraint()
const {
return (reason != 0); }
209 void addConstraint(
unsigned source,
unsigned v) {
213 unsigned getContainerSize()
const {
return value; }
224 virtual bool hasConstraint()
const = 0;
225 virtual void addConstraint(uint32_t reason) = 0;
234 std::pair<cstring, cstring> fields;
247 fields.first = p.fields.first;
248 fields.second = p.fields.second;
251 virtual bool hasConstraint()
const = 0;
252 virtual void addConstraint(uint32_t reason) = 0;
254 return reason == a.reason && fields == a.fields;
257 if (reason < a.reason)
259 else if (fields < a.fields)
268 bool hasConstraint()
const {
return (reason != 0); }
269 void addConstraint(
unsigned r) { reason |= r; }
275 bool hasConstraint()
const {
return (reason != 0); }
276 void addConstraint(
unsigned r) { reason |= r; }
282 bool hasConstraint()
const {
return (reason != 0); }
283 void addConstraint(
unsigned r) { reason |= r; }
289 bool hasConstraint()
const {
return (reason != 0); }
290 void addConstraint(
unsigned r) { reason |= r; }
Definition constraints.h:149
Definition constraints.h:44
Definition constraints.h:203
Definition constraints.h:265
Definition constraints.h:110
Definition constraints.h:90
Definition constraints.h:216
Definition constraints.h:136
Definition constraints.h:286
Definition constraints.h:272
Definition constraints.h:279
Definition constraints.h:123
Definition constraints.h:228
Definition constraints.h:56
Definition ordered_set.h:32
Definition tofino/bf-p4c/phv/constraints/constraints.cpp:21
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32