P4C
The P4 Compiler
Loading...
Searching...
No Matches
resources_clot.h
1
18
19#ifndef _BACKENDS_TOFINO_BF_P4C_LOGGING_RESOURCES_CLOT_H_
20#define _BACKENDS_TOFINO_BF_P4C_LOGGING_RESOURCES_CLOT_H_
21
22#include <map>
23#include <vector>
24
25#include "backends/tofino/bf-p4c/logging/resources_schema.h"
26#include "ir/ir.h"
27
28using Logging::Resources_Schema_Logger;
29class ClotInfo; // Forward declaration
30
31namespace BFN {
32
33class ClotResourcesLogging : public ParserInspector {
34 public:
35 using ClotResourceUsage = Resources_Schema_Logger::ClotResourceUsage;
36 using ClotUsage = Resources_Schema_Logger::ClotUsage;
37 using ClotField = Resources_Schema_Logger::ClotField;
38
39 protected:
40 const ClotInfo &clotInfo;
41 ClotResourceUsage *clotLogger = nullptr;
42 std::vector<ClotResourceUsage *> clotUsages = std::vector<ClotResourceUsage *>(2);
43 bool collected = false;
44 std::map<unsigned, unsigned> clotTagToChecksumUnit;
45 std::vector<std::map<unsigned, std::vector<ClotUsage *>>> usageData;
46
47 bool usingClots() const;
48
49 std::vector<ClotUsage *> &getUsageData(gress_t gress, unsigned tag);
50
51 bool preorder(const IR::BFN::LoweredParserState *state) override;
52 void end_apply() override;
53
54 void collectClotUsages(const IR::BFN::LoweredParserMatch *match,
55 const IR::BFN::LoweredParserState *state, gress_t gress);
56
57 void collectExtractClotInfo(const IR::BFN::LoweredExtractClot *extract,
58 const IR::BFN::LoweredParserState *state, gress_t gress);
59
60 void logClotUsages();
61
62 ClotUsage *logExtractClotInfo(cstring parser_state, bool hasChecksum, int length, int offset,
63 unsigned tag, const Clot *clot);
64
65 public:
66 std::vector<ClotResourceUsage *> getLoggers();
67
68 explicit ClotResourcesLogging(const ClotInfo &clotInfo);
69};
70
71} // namespace BFN
72
73#endif /* _BACKENDS_TOFINO_BF_P4C_LOGGING_RESOURCES_CLOT_H_ */
Definition clot.h:57
Definition clot_info.h:41
Definition cstring.h:85
Definition parde_visitor.h:66
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21