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