P4C
The P4 Compiler
Loading...
Searching...
No Matches
pa_byte_pack.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PHV_PRAGMA_PA_BYTE_PACK_H_
20#define BACKENDS_TOFINO_BF_P4C_PHV_PRAGMA_PA_BYTE_PACK_H_
21
22#include "backends/tofino/bf-p4c/phv/phv_fields.h"
23#include "backends/tofino/bf-p4c/phv/utils/utils.h"
24#include "ir/ir.h"
25#include "lib/safe_vector.h"
26
27using namespace P4;
28
39class PragmaBytePack : public Inspector {
40 public:
44 bool compiler_added;
45 std::optional<Util::SourceInfo> src_info;
46 PHV::PackingLayout packing;
47 };
48
52 std::optional<cstring> error;
53 bool ok() const { return !error; }
54 };
55
56 private:
57 PhvInfo &phv_i;
58 safe_vector<PackConstraint> packing_layouts_i;
59
63 AddConstraintResult add_packing_constraint(const PackConstraint &packing);
64
66 profile_t init_apply(const IR::Node *root) override {
67 profile_t rv = Inspector::init_apply(root);
68 packing_layouts_i.clear();
69 return rv;
70 }
71
73 bool preorder(const IR::BFN::Pipe *pipe) override;
74
75 public:
76 explicit PragmaBytePack(PhvInfo &phv) : phv_i(phv) {}
77
79 const safe_vector<PackConstraint> &packings() const { return packing_layouts_i; }
80
87 AddConstraintResult add_compiler_added_packing(const PHV::PackingLayout &packing);
88
90 static const char *name;
91 static const char *description;
92 static const char *help;
93};
94
95#endif /* BACKENDS_TOFINO_BF_P4C_PHV_PRAGMA_PA_BYTE_PACK_H_ */
Definition node.h:94
Definition visitor.h:400
Definition ordered_set.h:32
Definition safe_vector.h:27
Definition phv_fields.h:1095
Definition pa_byte_pack.h:39
static const char * name
BFN::Pragma interface.
Definition pa_byte_pack.h:90
AddConstraintResult add_compiler_added_packing(const PHV::PackingLayout &packing)
Definition phv/pragma/pa_byte_pack.cpp:195
const safe_vector< PackConstraint > & packings() const
Definition pa_byte_pack.h:79
Definition pa_byte_pack.h:43
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
void error(const char *format, Args &&...args)
Report an error with the given message.
Definition lib/error.h:51
Definition phv_fields.h:1034
Definition pa_byte_pack.h:49
ordered_set< const PHV::Field * > alignment_added
the set of fields which new alignment constraints were added on.
Definition pa_byte_pack.h:51