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 "bf-p4c/phv/phv_fields.h"
25#include "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
61 const le_bitrange &getRange() const { return range; }
62 const ConstrainedField &getParent() const { return *parent; }
63
66 const Constraints::AlignmentConstraint &getAlignment() const { return alignment; }
67
68 void setContainerSize(const Constraints::ContainerSizeConstraint &containerSize);
69 const Constraints::ContainerSizeConstraint getContainerSize() const { return containerSize; }
70
72 bool operator<(const ConstrainedSlice &other) const override;
73 bool operator==(const ConstrainedSlice &other) const override;
74};
75
81 private:
82 cstring name;
83 std::vector<ConstrainedSlice> slices;
84
89
90 bool deparsedBottomBits = false;
91 bool noSplit = false;
92 bool noOverlay = false;
93 bool exactContainer = false;
94 bool noHoles = false;
95 bool sameContainerGroup = false;
96
97 public:
99 explicit ConstrainedField(const cstring &name);
100
101 const cstring &getName() const { return name; }
102
103 void addSlice(const ConstrainedSlice &slice);
104 std::vector<ConstrainedSlice> &getSlices() { return slices; }
105 const std::vector<ConstrainedSlice> &getSlices() const { return slices; }
106
108 void setSolitary(const Constraints::SolitaryConstraint &solitary);
109 const Constraints::SolitaryConstraint &getSolitary() const { return solitary; }
110
111 void setAlignment(const Constraints::AlignmentConstraint &alignment);
112 const Constraints::AlignmentConstraint &getAlignment() const { return alignment; }
113
114 void setDigest(const Constraints::DigestConstraint &digest);
115 const Constraints::DigestConstraint &getDigest() const { return digest; }
116
117 void setContainerSize(const Constraints::ContainerSizeConstraint &containerSize);
118 const Constraints::ContainerSizeConstraint getContainerSize() const { return containerSize; }
119
120 void setBottomBits(bool b);
121 bool hasBottomBits() const { return deparsedBottomBits; }
122
123 void setNoSplit(bool b);
124 bool hasNoSplit() const { return noSplit; }
125
126 void setNoOverlay(bool b);
127 bool hasNoOverlay() const { return noOverlay; }
128
129 void setExactContainer(bool b);
130 bool hasExactContainer() const { return exactContainer; }
131
132 void setNoHoles(bool b);
133 bool hasNoHoles() const { return noHoles; }
134
135 void setSameContainerGroup(bool b);
136 bool hasSameContainerGroup() { return sameContainerGroup; }
137};
138
139typedef std::map<cstring, ConstrainedField> ConstrainedFieldMap;
140
146 public:
147 static ConstrainedFieldMap buildMap(const PhvInfo &phv,
148 const std::list<PHV::SuperCluster *> &groups);
149};
150
151#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:80
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:145
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