P4C
The P4 Compiler
Loading...
Searching...
No Matches
selector_update.h
1
19#ifndef BF_P4C_MAU_SELECTOR_UPDATE_H_
20#define BF_P4C_MAU_SELECTOR_UPDATE_H_
21
22#include "ir/pass_manager.h"
23#include "lib/ordered_map.h"
24#include "mau_visitor.h"
25
26using namespace P4;
27
36 // map associating selectors with the stateful alu that updates them
38
39 class FindSelectorSalu : public MauInspector {
40 AddSelectorSalu &self;
41 bool preorder(const IR::MAU::StatefulAlu *salu) {
42 if (salu->selector) self.sel2salu[salu->selector] = salu;
43 return false;
44 }
45 bool preorder(const IR::Expression *) { return false; } // prune all expressions
46 public:
47 explicit FindSelectorSalu(AddSelectorSalu &self) : self(self) {}
48 };
49
50 class AddSaluIfNeeded : public MauModifier {
51 AddSelectorSalu &self;
52 bool preorder(IR::MAU::Table *);
53 bool preorder(IR::Expression *) { return false; } // prune all expressions
54 public:
55 explicit AddSaluIfNeeded(AddSelectorSalu &self) : self(self) {}
56 };
57
58 public:
59 AddSelectorSalu() : PassManager({new FindSelectorSalu(*this), new AddSaluIfNeeded(*this)}) {}
60};
61
62#endif /* BF_P4C_MAU_SELECTOR_UPDATE_H_ */
Definition selector_update.h:35
Definition mau_visitor.h:29
Definition mau_visitor.h:45
Definition ir/pass_manager.h:40
Definition ordered_map.h:32
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24