P4C
The P4 Compiler
Loading...
Searching...
No Matches
constrained_fields.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_LOGGING_CONSTRAINED_FIELDS_H_
20#define BACKENDS_TOFINO_BF_P4C_LOGGING_CONSTRAINED_FIELDS_H_
21
22#include <map>
23
24#include "backends/tofino/bf-p4c/phv/phv_fields.h"
25#include "backends/tofino/bf-p4c/phv/utils/utils.h"
26#include "phv_schema.h"
27
32 public:
33 using Constraint = Logging::Phv_Schema_Logger::Constraint;
34
35 protected:
36 Constraint *logger = nullptr;
37
38 public:
39 Constraint *getLogger() { return logger; }
40
41 bool hasLoggedConstraints() const { return logger->get_base_constraint().size() > 0; }
42};
43
45
50class ConstrainedSlice : public LoggableEntity, public LiftCompare<ConstrainedSlice> {
51 private:
52 const ConstrainedField *parent;
53 le_bitrange range;
54
57
58 public:
59 ConstrainedSlice(const ConstrainedField &parent, le_bitrange range);
60 virtual ~ConstrainedSlice() = default;
61
62 const le_bitrange &getRange() const { return range; }
63 const ConstrainedField &getParent() const { return *parent; }
64
67 const Constraints::AlignmentConstraint &getAlignment() const { return alignment; }
68
69 void setContainerSize(const Constraints::ContainerSizeConstraint &containerSize);
70 const Constraints::ContainerSizeConstraint getContainerSize() const { return containerSize; }
71
73 bool operator<(const ConstrainedSlice &other) const override;
74 bool operator==(const ConstrainedSlice &other) const override;
75};
76
82 private:
83 cstring name;
84 std::vector<ConstrainedSlice> slices;
85
90
91 bool deparsedBottomBits = false;
92 bool noSplit = false;
93 bool noOverlay = false;
94 bool exactContainer = false;
95 bool noHoles = false;
96 bool sameContainerGroup = false;
97
98 public:
100 explicit ConstrainedField(const cstring &name);
101
102 const cstring &getName() const { return name; }
103
104 void addSlice(const ConstrainedSlice &slice);
105 std::vector<ConstrainedSlice> &getSlices() { return slices; }
106 const std::vector<ConstrainedSlice> &getSlices() const { return slices; }
107
109 void setSolitary(const Constraints::SolitaryConstraint &solitary);
110 const Constraints::SolitaryConstraint &getSolitary() const { return solitary; }
111
112 void setAlignment(const Constraints::AlignmentConstraint &alignment);
113 const Constraints::AlignmentConstraint &getAlignment() const { return alignment; }
114
115 void setDigest(const Constraints::DigestConstraint &digest);
116 const Constraints::DigestConstraint &getDigest() const { return digest; }
117
118 void setContainerSize(const Constraints::ContainerSizeConstraint &containerSize);
119 const Constraints::ContainerSizeConstraint getContainerSize() const { return containerSize; }
120
121 void setBottomBits(bool b);
122 bool hasBottomBits() const { return deparsedBottomBits; }
123
124 void setNoSplit(bool b);
125 bool hasNoSplit() const { return noSplit; }
126
127 void setNoOverlay(bool b);
128 bool hasNoOverlay() const { return noOverlay; }
129
130 void setExactContainer(bool b);
131 bool hasExactContainer() const { return exactContainer; }
132
133 void setNoHoles(bool b);
134 bool hasNoHoles() const { return noHoles; }
135
136 void setSameContainerGroup(bool b);
137 bool hasSameContainerGroup() { return sameContainerGroup; }
138};
139
140typedef std::map<cstring, ConstrainedField> ConstrainedFieldMap;
141
147 public:
148 static ConstrainedFieldMap buildMap(const PhvInfo &phv,
149 const std::list<PHV::SuperCluster *> &groups);
150};
151
152#endif /* BACKENDS_TOFINO_BF_P4C_LOGGING_CONSTRAINED_FIELDS_H_ */
Class representing PHV::Field with constraints and handle for constraint logging. Contains non-group ...
Definition constrained_fields.h:81
void setSolitary(const Constraints::SolitaryConstraint &solitary)
Constraints.
Definition constrained_fields.cpp:58
Initialize map of constrained fields by information present in PhvInfo and their slices based on slic...
Definition constrained_fields.h:146
Class representing FieldSlice with constraints, which has handle for constraint logging....
Definition constrained_fields.h:50
ConstrainedSlice(const ConstrainedField &parent, le_bitrange range)
Definition constrained_fields.cpp:23
void setAlignment(const Constraints::AlignmentConstraint &alignment)
Constraints.
Definition constrained_fields.cpp:32
bool operator<(const ConstrainedSlice &other) const override
Comparators implementation for LiftCompare.
Definition constrained_fields.cpp:40
Definition constraints.h:149
Definition constraints.h:203
Definition constraints.h:90
Definition constraints.h:56
Definition cmp.h:84
Class with handle for logging constraints.
Definition constrained_fields.h:31
Definition cstring.h:85
Definition phv_fields.h:1095