117 using Phv_Schema_Logger = Logging::Phv_Schema_Logger;
118 using Structure = Phv_Schema_Logger::Structure;
119 using Container = Phv_Schema_Logger::Container;
120 using FieldInfo = Phv_Schema_Logger::FieldInfo;
121 using FieldGroupItem = Phv_Schema_Logger::FieldGroupItem;
122 using Field = Phv_Schema_Logger::Field;
123 using Slice = Phv_Schema_Logger::Slice;
124 using FieldSlice = Phv_Schema_Logger::FieldSlice;
125 using SourceLocation = Phv_Schema_Logger::SourceLocation;
126 using BoolConstraint = Phv_Schema_Logger::BoolConstraint;
127 using IntConstraint = Phv_Schema_Logger::IntConstraint;
128 using ListConstraint = Phv_Schema_Logger::ListConstraint;
129 using Constraint = Phv_Schema_Logger::Constraint;
130 using ParserLocation = Phv_Schema_Logger::ParserLocation;
131 using DeparserLocation = Phv_Schema_Logger::DeparserLocation;
132 using MAULocation = Phv_Schema_Logger::MAULocation;
133 using ContainerSlice = Phv_Schema_Logger::ContainerSlice;
134 using Access = Phv_Schema_Logger::Access;
135 using Resources = Phv_Schema_Logger::Resources;
138 std::string parserState;
140 bool operator<(PardeInfo other)
const {
141 if (unit != other.unit)
return unit < other.unit;
142 return parserState < other.parserState;
145 bool operator==(PardeInfo other)
const {
146 return (unit == other.unit && parserState == other.parserState);
149 explicit PardeInfo(std::string u, std::string name =
"") : unit(u), parserState(name) {}
157 class CollectDefUseInfo :
public Visitor {
161 const IR::Node *apply_visitor(
const IR::Node *n,
const char *name = 0)
override;
164 void replace_parser_state_name(
cstring old_name,
cstring new_name);
174 explicit CollectDefUseInfo(
const FieldDefUse &du) : defuse(du) {}
177 enum class ConstraintReason : std::size_t {
183 SolitaryContainerSize,
185 SolitaryExceptSameDigest,
202 const ClotInfo &clot;
204 const CollectPhvLoggingInfo &info;
208 const ordered_map<cstring, ordered_set<int>> &tableAlloc;
210 const TableSummary &tableSummary;
213 ordered_set<PHV::FieldSlice> unallocatedSlices;
216 Phv_Schema_Logger logger;
218 profile_t init_apply(
const IR::Node *root)
override {
219 unallocatedSlices.clear();
220 return Inspector::init_apply(root);
223 void end_apply(
const IR::Node *root)
override;
226 void populateContainerGroups(cstring groupType);
231 const char *containerType(
const PHV::Container c)
const;
235 const char *getFieldType(
const PHV::Field *f)
const;
238 const char *getGress(
const PHV::Field *f)
const;
240 const char *getDeparserAccessType(
const PHV::Field *f)
const;
243 std::string stripDotPrefix(
const cstring name)
const;
245 void getAllParserDefs(
const PHV::Field *f, ordered_set<PardeInfo> &rv)
const;
246 void getAllDeparserUses(
const PHV::Field *f, ordered_set<PardeInfo> &rv)
const;
248 void addPardeReadsAndWrites(
const PHV::Field *f, ordered_set<PardeInfo> &rv,
249 ContainerSlice *cs)
const;
250 void addTableKeys(
const PHV::FieldSlice &sl, ContainerSlice *cs)
const;
251 void addVLIWReads(
const PHV::FieldSlice &sl, ContainerSlice *cs)
const;
252 void addVLIWWrites(
const PHV::FieldSlice &sl, ContainerSlice *cs)
const;
253 void addMutexFields(
const PHV::AllocSlice &sl, ContainerSlice *cs)
const;
255 PHV::Field::AllocState getAllocatedState(
const PHV::Field *f);
261 ordered_map<cstring, ordered_set<const PHV::Field *>> getFields();
265 ordered_map<const PHV::Field *, const PHV::Field *> getFieldAliases();
270 FieldInfo *getFieldInfo(
const PHV::Field *f)
const;
276 SourceLocation *getSourceLoc(
const PHV::Field *f)
const;
282 FieldSlice *logFieldSlice(
const PHV::Field *f,
bool use_alias);
288 FieldSlice *logFieldSlice(
const PHV::AllocSlice &sl,
bool use_alias);
295 ContainerSlice *logContainerSlice(
const PHV::AllocSlice &sl,
bool use_alias);
304 void logContainers();
307 void logConstraintReasons();
310 void logFieldConstraints(
const cstring &fieldName, Field *logger);
312 void logSolitaryConstraints(ConstrainedField &field,
const SourceLocation *srcLoc);
314 void logNoPackConstraint(ConstrainedField &field,
const FieldInfo *fieldInfo,
315 const SourceLocation *srcLoc);
317 void logGroupConstraint(ConstrainedField &field, ListConstraint *c,
318 std::vector<ConstrainedSlice> &group);
320 void logMauGroupConstraint(ConstrainedField &field,
const SourceLocation *srcLoc);
322 void logNoSplitConstraint(ConstrainedField &field,
const SourceLocation *srcLoc);
324 void logContainerSizeConstraint(ConstrainedField &field,
const SourceLocation *srcLoc);
326 void logAlignmentConstraint(ConstrainedField &field,
const SourceLocation *srcLoc);
328 void logNoOverlayConstraint(ConstrainedField &field,
const SourceLocation *srcLoc);
330 void logExactContainerConstraint(ConstrainedField &field,
const SourceLocation *srcLoc);
332 void logEquivalentAlignConstraint(ConstrainedField &field,
const SourceLocation *srcLoc);
334 void logNoHolesConstraint(ConstrainedField &field,
const SourceLocation *srcLoc);
336 void logSameContainerGroup(ConstrainedField &field,
const SourceLocation *srcLoc);
342 template <
typename T>
343 int getDatabaseIndex(std::vector<T> &db, T item);
346 explicit PhvLogging(
const char *filename,
const PhvInfo &p,
const ClotInfo &ci,
348 const ordered_map<cstring, ordered_set<int>> &t,
const TableSummary &ts);