38 using ElementUsage = Resources_Schema_Logger::ElementUsage;
39 using ParserResources = Resources_Schema_Logger::ParserResources;
40 using ParserResourceUsage = Resources_Schema_Logger::ParserResourceUsage;
41 using Phase0ResourceUsage = Resources_Schema_Logger::Phase0ResourceUsage;
43 using ParserStateTransition = Resources_Schema_Logger::ParserStateTransitionResourceUsage;
45 using ClotExtracts = ParserStateTransition::Clot_Extracts;
46 using StateExtracts = ParserStateTransition::Extracts;
47 using StateMatchesOn = ParserStateTransition::MatchesOn;
48 using StateSavesTo = ParserStateTransition::SavesTo;
51 struct ParserLogData {
52 ParserResourceUsage *usage =
nullptr;
53 Phase0ResourceUsage *phase0 =
nullptr;
56 bool collected =
false;
57 ParserResources *parserLogger =
nullptr;
59 std::map<cstring, ParserLogData> parsers;
61 std::map<cstring, int> stateIds;
62 std::map<const IR::BFN::LoweredParserMatch *, int> tcamIds[2];
63 int nextTcamId[2] = {0};
66 bool preorder(
const IR::BFN::LoweredParserState *state)
override;
67 bool preorder(
const IR::BFN::LoweredParser *parser)
override;
68 void end_apply()
override { collected =
true; }
70 std::vector<ParserStateTransition *> logStateTransitionsByMatch(
71 const std::string &nextStateName,
const IR::BFN::LoweredParserState *prevState,
72 const IR::BFN::LoweredParserMatch *match);
74 int getTcamId(
const IR::BFN::LoweredParserMatch *match, gress_t gress);
76 int getStateId(
const std::string &state);
78 void logStateExtracts(
const IR::BFN::LoweredParserMatch *match,
79 std::vector<StateExtracts *> &result);
81 void logStateMatches(
const IR::BFN::LoweredParserState *prevState,
82 const IR::BFN::LoweredParserMatch *match,
83 std::vector<StateMatchesOn *> &result);
85 void logStateSaves(
const IR::BFN::LoweredParserMatch *match,
86 std::vector<StateSavesTo *> &result);
90 const int tcamRowsInit = Device::pardeSpec().
numTcamRows() - 1;
91 nextTcamId[0] = tcamRowsInit;
92 nextTcamId[1] = tcamRowsInit;
95 const ParserResources *getLogger();