P4C
The P4 Compiler
Loading...
Searching...
No Matches
check_parser_multi_write.h
1
18
19#ifndef BF_P4C_PARDE_CHECK_PARSER_MULTI_WRITE_H_
20#define BF_P4C_PARDE_CHECK_PARSER_MULTI_WRITE_H_
21
22#include <ir/ir.h>
23
24#include "backends/tofino/bf-p4c/parde/parde_visitor.h"
25#include "backends/tofino/bf-p4c/parde/parser_info.h"
26#include "backends/tofino/bf-p4c/parde/parser_query.h"
27#include "ir/pass_manager.h"
28
29using namespace P4;
30
35
36class CheckParserMultiWrite : public PassManager {
37 const PhvInfo &phv;
38
39 public:
40 explicit CheckParserMultiWrite(const PhvInfo &phv);
41};
42
43class PhvInfo;
45
48struct CheckWriteModeConsistency : public ParserTransform {
49 protected:
50 const PhvInfo &phv;
51 const MapFieldToParserStates &field_to_states;
52 const ParserQuery pq;
53
54 std::map<const IR::BFN::ParserPrimitive *, IR::BFN::ParserWriteMode> extract_to_write_mode;
55 std::map<std::pair<PHV::FieldSlice, PHV::FieldSlice>, bool> compatability;
56
60 bool check(const std::vector<const IR::BFN::Extract *> extracts) const;
61
68 void check_and_adjust(const std::vector<const IR::BFN::Extract *> extracts);
69
90
97 void check_post_alloc();
98
99 profile_t init_apply(const IR::Node *root) override;
100 IR::Node *preorder(IR::BFN::Extract *extract) override;
101 IR::Node *preorder(IR::BFN::ParserChecksumWritePrimitive *pcw) override;
102
103 template <typename T>
104 IR::Node *set_write_mode(T *write);
105
106 public:
107 CheckWriteModeConsistency(const PhvInfo &p, const MapFieldToParserStates &fs,
108 const CollectParserInfo &pi)
109 : phv(p), field_to_states(fs), pq(pi, fs) {}
110
114 bool check_compatability(const PHV::FieldSlice &slice_a, const PHV::FieldSlice &slice_b);
115};
116
117#endif /*BF_P4C_PARDE_CHECK_PARSER_MULTI_WRITE_H_*/
Map field to the parser states in which they are extracted or assigned from checksums.
Definition phv_fields.h:1755
Definition node.h:94
Definition ordered_set.h:32
Definition phv_fields.h:898
Definition phv_fields.h:1095
Definition parde_visitor.h:90
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
bool check_compatability(const PHV::FieldSlice &slice_a, const PHV::FieldSlice &slice_b)
Definition check_parser_multi_write.cpp:897
bool check(const std::vector< const IR::BFN::Extract * > extracts) const
Check that the write modes of all extracts are consistent.
Definition check_parser_multi_write.cpp:601
void check_pre_alloc(const ordered_set< const IR::BFN::ParserPrimitive * > &state_writes)
Definition check_parser_multi_write.cpp:791
void check_and_adjust(const std::vector< const IR::BFN::Extract * > extracts)
Check and adjust the write modes of all extracts to be consistent.
Definition check_parser_multi_write.cpp:673
void check_post_alloc()
Verify/unify parser write mode consistency post PHV allocation.
Definition check_parser_multi_write.cpp:820
Collection of functions to check parser information.
Definition parser_query.h:35