37 using ElementUsage = Resources_Schema_Logger::ElementUsage;
38 using ParserResources = Resources_Schema_Logger::ParserResources;
39 using ParserResourceUsage = Resources_Schema_Logger::ParserResourceUsage;
40 using Phase0ResourceUsage = Resources_Schema_Logger::Phase0ResourceUsage;
42 using ParserStateTransition = Resources_Schema_Logger::ParserStateTransitionResourceUsage;
44 using ClotExtracts = ParserStateTransition::Clot_Extracts;
45 using StateExtracts = ParserStateTransition::Extracts;
46 using StateMatchesOn = ParserStateTransition::MatchesOn;
47 using StateSavesTo = ParserStateTransition::SavesTo;
50 struct ParserLogData {
51 ParserResourceUsage *usage =
nullptr;
52 Phase0ResourceUsage *phase0 =
nullptr;
55 bool collected =
false;
56 ParserResources *parserLogger =
nullptr;
58 std::map<cstring, ParserLogData> parsers;
60 std::map<cstring, int> stateIds;
61 std::map<const IR::BFN::LoweredParserMatch *, int> tcamIds[2];
62 int nextTcamId[2] = {0};
65 bool preorder(
const IR::BFN::LoweredParserState *state)
override;
66 bool preorder(
const IR::BFN::LoweredParser *parser)
override;
67 void end_apply()
override { collected =
true; }
69 std::vector<ParserStateTransition *> logStateTransitionsByMatch(
70 const std::string &nextStateName,
const IR::BFN::LoweredParserState *prevState,
71 const IR::BFN::LoweredParserMatch *match);
73 int getTcamId(
const IR::BFN::LoweredParserMatch *match, gress_t gress);
75 int getStateId(
const std::string &state);
77 void logStateExtracts(
const IR::BFN::LoweredParserMatch *match,
78 std::vector<StateExtracts *> &result);
80 void logStateMatches(
const IR::BFN::LoweredParserState *prevState,
81 const IR::BFN::LoweredParserMatch *match,
82 std::vector<StateMatchesOn *> &result);
84 void logStateSaves(
const IR::BFN::LoweredParserMatch *match,
85 std::vector<StateSavesTo *> &result);
88 ParserResourcesLogging() {
89 const int tcamRowsInit = Device::pardeSpec().numTcamRows() - 1;
90 nextTcamId[0] = tcamRowsInit;
91 nextTcamId[1] = tcamRowsInit;
94 const ParserResources *getLogger();