P4C
The P4 Compiler
Loading...
Searching...
No Matches
pa_alias.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PHV_PRAGMA_PA_ALIAS_H_
20#define BACKENDS_TOFINO_BF_P4C_PHV_PRAGMA_PA_ALIAS_H_
21
22#include <map>
23#include <optional>
24
25#include "bf-p4c/phv/phv_fields.h"
26#include "bf-p4c/phv/pragma/pa_no_overlay.h"
27#include "bf-p4c/phv/pragma/pretty_print.h"
28#include "bf-p4c/phv/utils/utils.h"
29#include "ir/ir.h"
30
31using namespace P4;
39 public:
40 enum CreatedBy { PRAGMA, COMPILER };
41
45
48 std::optional<le_bitrange> range;
49
51 CreatedBy who;
52 };
53
56
57 private:
58 const PhvInfo &phv_i;
59 AliasMap aliasMap;
60 PragmaNoOverlay &no_overlay;
61
64 bitvec fieldsWithExpressions;
66 bitvec fieldsWithAliasingSrc;
68 bitvec fieldsWithAliasingDst;
69
70 profile_t init_apply(const IR::Node *root) override;
71
73 bool preorder(const IR::Expression *expr) override;
74
76 void postorder(const IR::BFN::Pipe *pipe) override;
77
78 public:
79 explicit PragmaAlias(PhvInfo &phv, PragmaNoOverlay &no_ovrl)
80 : phv_i(phv), no_overlay(no_ovrl) {}
81 const AliasMap &getAliasMap() const { return aliasMap; }
82
84 static const char *name;
85 static const char *description;
86 static const char *help;
87
91 std::optional<std::pair<const PHV::Field *, const PHV::Field *>> mayAddAlias(
92 const PHV::Field *f1, const PHV::Field *f2, bool suppressWarning = false,
93 CreatedBy who = PRAGMA);
94
95 bool addAlias(const PHV::Field *f1, const PHV::Field *f2, bool suppressWarning = false,
96 CreatedBy who = PRAGMA);
97
98 std::string pretty_print() const override;
99};
100
101std::ostream &operator<<(std::ostream &out, const PragmaAlias &pa_a);
102std::ostream &operator<<(std::ostream &, const PragmaAlias::AliasDestination &dest);
103
104#endif /* BACKENDS_TOFINO_BF_P4C_PHV_PRAGMA_PA_ALIAS_H_ */
Definition node.h:95
Definition visitor.h:400
Definition visitor.h:78
Definition bitvec.h:120
Definition cstring.h:85
Definition phv_fields.h:154
Definition phv_fields.h:1095
Definition pretty_print.h:29
Definition pa_alias.h:38
static const char * name
BFN::Pragma interface.
Definition pa_alias.h:84
CreatedBy who
Who created the pragma?
Definition pa_alias.h:51
cstring field
The alias destination field.
Definition pa_alias.h:44
std::optional< le_bitrange > range
Definition pa_alias.h:48
ordered_map< cstring, AliasDestination > AliasMap
Map type from alias sources to destinations.
Definition pa_alias.h:55
std::optional< std::pair< const PHV::Field *, const PHV::Field * > > mayAddAlias(const PHV::Field *f1, const PHV::Field *f2, bool suppressWarning=false, CreatedBy who=PRAGMA)
Definition pa_alias.cpp:76
Definition pa_alias.h:42
Definition pa_no_overlay.h:33
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24