P4C
The P4 Compiler
Loading...
Searching...
No Matches
check_parser_multi_write.h
1
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 "bf-p4c/parde/parde_visitor.h"
25#include "bf-p4c/parde/parser_info.h"
26#include "bf-p4c/parde/parser_query.h"
27#include "ir/pass_manager.h"
28
29using namespace P4;
30
37 const PhvInfo &phv;
38
39 explicit CheckParserMultiWrite(const PhvInfo &phv);
40};
41
42class PhvInfo;
44
48 protected:
49 const PhvInfo &phv;
50 const MapFieldToParserStates &field_to_states;
51 const ParserQuery pq;
52
53 std::map<const IR::BFN::ParserPrimitive *, IR::BFN::ParserWriteMode> extract_to_write_mode;
54 std::map<std::pair<PHV::FieldSlice, PHV::FieldSlice>, bool> compatability;
55
59 bool check(const std::vector<const IR::BFN::Extract *> extracts) const;
60
67 void check_and_adjust(const std::vector<const IR::BFN::Extract *> extracts);
68
89
96 void check_post_alloc();
97
98 profile_t init_apply(const IR::Node *root) override;
99 IR::Node *preorder(IR::BFN::Extract *extract) override;
100 IR::Node *preorder(IR::BFN::ParserChecksumWritePrimitive *pcw) override;
101
102 template <typename T>
103 IR::Node *set_write_mode(T *write);
104
105 public:
107 const CollectParserInfo &pi)
108 : phv(p), field_to_states(fs), pq(pi, fs) {}
109
113 bool check_compatability(const PHV::FieldSlice &slice_a, const PHV::FieldSlice &slice_b);
114};
115
116#endif /*BF_P4C_PARDE_CHECK_PARSER_MULTI_WRITE_H_*/
Definition node.h:95
Definition ir/pass_manager.h:40
Definition ordered_set.h:32
Definition phv_fields.h:898
Definition phv_fields.h:1095
Definition parde_visitor.h:90
Checks multiple writes to the same field on non-mutually exclusive paths.
Definition check_parser_multi_write.h:36
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition check_parser_multi_write.h:47
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:599
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
Map field to the parser states in which they are extracted or assigned from checksums.
Definition phv_fields.h:1755
Collection of functions to check parser information.
Definition parser_query.h:35