P4C
The P4 Compiler
Loading...
Searching...
No Matches
initialize_mirror_io_select.h
1
19#ifndef INITIALIZE_MIRROR_IO_SELECT_H_
20#define INITIALIZE_MIRROR_IO_SELECT_H_
21
22#include "backends/tofino/bf-p4c/arch/arch.h"
23#include "backends/tofino/bf-p4c/common/pragma/all_pragmas.h"
24#include "backends/tofino/bf-p4c/common/pragma/collect_global_pragma.h"
25#include "backends/tofino/bf-p4c/device.h"
26#include "ir/ir.h"
27#include "type_checker.h"
28
29namespace BFN {
30
31// Initialize eg_intr_md_for_dprsr.mirror_io_select
33 cstring egIntrMdForDprsrName;
34
35 public:
37
38 // disable this pass if the @disable_egress_mirror_io_select_initialization pragma is used
39 const IR::Node *preorder(IR::P4Program *p) override {
40 // collect and set global_pragmas
41 CollectGlobalPragma collect_pragma;
42 p->apply(collect_pragma);
43 // Workaround can be disabled by pragma
44 if (collect_pragma.exists(PragmaDisableEgressMirrorIOSelectInitialization::name)) {
45 prune();
46 }
47 return p;
48 }
49
50 // Add mirror_io_select initialization to egress parser
51 const IR::Node *preorder(IR::BFN::TnaParser *parser) override;
52 const IR::Node *preorder(IR::ParserState *state) override;
53
54 // Skip controls and deparsers
55 const IR::Node *preorder(IR::BFN::TnaControl *control) override {
56 prune();
57 return control;
58 };
59 const IR::Node *preorder(IR::BFN::TnaDeparser *deparser) override {
60 prune();
61 return deparser;
62 };
63};
64
71 public:
73 addPasses({new PassIf(
74 []() { return Device::hasMirrorIOSelect(); },
76 new P4::ResolveReferences(refMap),
77 new BFN::TypeInference(typeMap, false), /* extended P4::TypeInference */
78 new P4::ApplyTypesToExpressions(typeMap), new P4::ResolveReferences(refMap)})});
79 setName("InitializeMirrorIOSelect");
80 }
81};
82
83} // namespace BFN
84
85#endif // INITIALIZE_MIRROR_IO_SELECT_H_
Definition initialize_mirror_io_select.h:32
Definition collect_global_pragma.h:28
const IR::Annotation * exists(const char *pragma_name) const
Check if pragma exists.
Definition collect_global_pragma.cpp:120
Definition typeChecker.h:620
Definition typeChecker.h:32
Definition node.h:94
Definition ir/pass_manager.h:172
Definition ir/pass_manager.h:40
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition resolveReferences.h:123
Definition visitor.h:424
Definition typeChecker.h:483
Definition typeMap.h:41
Definition cstring.h:85
Initializes eg_intr_md_for_dprsr.mirror_io_select on devices except Tofino1.
Definition initialize_mirror_io_select.h:70
The namespace encapsulating Barefoot/Intel-specific stuff.
Definition add_t2na_meta.cpp:21