P4C
The P4 Compiler
Loading...
Searching...
No Matches
bridged_packing.h
1
18
19#ifndef BACKENDS_TOFINO_BF_P4C_COMMON_BRIDGED_PACKING_H_
20#define BACKENDS_TOFINO_BF_P4C_COMMON_BRIDGED_PACKING_H_
21
22#include <z3++.h>
23
24#include "backends/tofino/bf-p4c/bf-p4c-options.h"
25#include "backends/tofino/bf-p4c/common/extract_maupipe.h"
26#include "backends/tofino/bf-p4c/common/field_defuse.h"
27#include "backends/tofino/bf-p4c/common/pragma/collect_global_pragma.h"
28#include "backends/tofino/bf-p4c/logging/source_info_logging.h"
29#include "backends/tofino/bf-p4c/midend/blockmap.h"
30#include "backends/tofino/bf-p4c/midend/normalize_params.h"
31#include "backends/tofino/bf-p4c/midend/param_binding.h"
32#include "backends/tofino/bf-p4c/midend/simplify_references.h"
33#include "backends/tofino/bf-p4c/midend/type_checker.h"
34#include "backends/tofino/bf-p4c/phv/action_phv_constraints.h"
35#include "backends/tofino/bf-p4c/phv/constraints/constraints.h"
36#include "backends/tofino/bf-p4c/phv/phv.h"
37#include "backends/tofino/bf-p4c/phv/phv_fields.h"
38#include "frontends/common/resolveReferences/referenceMap.h"
39#include "frontends/common/resolveReferences/resolveReferences.h"
40#include "frontends/p4/methodInstance.h"
41#include "frontends/p4/typeMap.h"
42
43using namespace P4;
44
45// Collection of bridge metadata constraints across all pipelines
46// in the program.
57
58using FieldListEntry = std::pair<int, const IR::Type *>;
59using AlignmentConstraint = Constraints::AlignmentConstraint;
60using SolitaryConstraint = Constraints::SolitaryConstraint;
61using RepackedHeaders = std::vector<std::pair<const IR::HeaderOrMetadata *, std::string>>;
62using ExtractedTogether = ordered_map<cstring, ordered_set<cstring>>;
63using PackingCandidateFields = ordered_map<cstring, ordered_set<cstring>>;
65using PackingConstraints = ordered_map<cstring, std::vector<z3::expr>>;
66
72
85
105class CollectIngressBridgedFields : public Inspector {
106 private:
107 const PhvInfo &phv;
108
109 bool preorder(const IR::BFN::Unit *unit) override {
110 if (unit->thread() == EGRESS) return false;
111 return true;
112 }
113
114 profile_t init_apply(const IR::Node *root) override;
115 void postorder(const IR::BFN::AliasMember *mem) override;
116 void end_apply() override;
117
118 public:
119 explicit CollectIngressBridgedFields(const PhvInfo &phv) : phv(phv) {}
120
123};
124
146class CollectEgressBridgedFields : public Inspector {
147 const PhvInfo &phv;
149 ordered_map<const PHV::Field *,
151 candidateSourcesInParser;
152
153 public:
154 explicit CollectEgressBridgedFields(const PhvInfo &p) : phv(p) {}
155
158
159 Visitor::profile_t init_apply(const IR::Node *root) override;
160 bool preorder(const IR::BFN::Extract *extract) override;
161 void end_apply() override;
162};
163
179class GatherParserExtracts : public Inspector {
180 public:
182
183 private:
184 const PhvInfo &phv;
186 FieldToFieldSet parserAlignedFields;
188 FieldToFieldSet reverseParserAlignMap;
189
190 profile_t init_apply(const IR::Node *root) override {
191 parserAlignedFields.clear();
192 reverseParserAlignMap.clear();
193 return Inspector::init_apply(root);
194 }
195
196 bool preorder(const IR::BFN::Extract *e) override;
197
198 public:
199 explicit GatherParserExtracts(const PhvInfo &p) : phv(p) {}
200
201 bool count(const PHV::Field *f) const { return parserAlignedFields.count(f); }
202
203 const ordered_set<const PHV::Field *> &at(const PHV::Field *f) const {
204 static ordered_set<const PHV::Field *> emptySet;
205 if (!parserAlignedFields.count(f)) return emptySet;
206 return parserAlignedFields.at(f);
207 }
208
209 bool revCount(const PHV::Field *f) const { return reverseParserAlignMap.count(f); }
210
211 const ordered_set<const PHV::Field *> &revAt(const PHV::Field *f) const {
212 static ordered_set<const PHV::Field *> emptySet;
213 if (!reverseParserAlignMap.count(f)) return emptySet;
214 return reverseParserAlignMap.at(f);
215 }
216
217 const FieldToFieldSet &getAlignedMap() const { return parserAlignedFields; }
218 const FieldToFieldSet &getReverseMap() const { return reverseParserAlignMap; }
219};
220
221template <typename NodeType, typename Func, typename Func2>
222void forAllMatchingDoPreAndPostOrder(const IR::Node *root, Func &&function, Func2 &&function2) {
223 struct NodeVisitor : public Inspector {
224 explicit NodeVisitor(Func &&function, Func2 &&function2)
225 : function(function), function2(function2) {}
226 Func function;
227 Func2 function2;
228 bool preorder(const NodeType *node) override {
229 function(node);
230 return true;
231 }
232 void postorder(const NodeType *node) override { function2(node); }
233 };
234 root->apply(NodeVisitor(std::forward<Func>(function), std::forward<Func2>(function2)));
235}
236
237template <typename NodeType, typename Func>
238void forAllMatchingDoPostOrder(const IR::Node *root, Func &&function) {
239 struct NodeVisitor : public Inspector {
240 explicit NodeVisitor(Func &&function) : function(function) {}
241 Func function;
242 void postorder(const NodeType *node) override { function(node); }
243 };
244 root->apply(NodeVisitor(std::forward<Func>(function)));
245}
246
264class GatherDigestFields : public Inspector {
265 public:
267
268 private:
269 const PhvInfo &phv;
272 FieldToFieldSet digestFieldMap;
273 FieldToFieldSet reverseDigestFieldMap;
274
276 const FieldToFieldSet &getDigestMap() const { return digestFieldMap; }
278 const FieldToFieldSet &getReverseDigestMap() const { return reverseDigestFieldMap; }
279
280 public:
281 explicit GatherDigestFields(const PhvInfo &p) : phv(p) {}
282 bool preorder(const IR::BFN::DigestFieldList *fl) override;
283 bool preorder(const IR::HeaderOrMetadata *hdr) override;
284 void end_apply() override;
285};
286
303class CollectConstraints : public Inspector {
304 PhvInfo &phv;
305
306 struct Constraints {
307 // collected alignment constraints;
309 // two field must have the same constraint, exact value to be determined by solver.
311
314 };
315 Constraints constraints;
316
317 const CollectIngressBridgedFields &ingressBridgedFields;
318 const CollectEgressBridgedFields &egressBridgedFields;
319 const GatherParserExtracts &parserAlignedFields;
320 const GatherDigestFields &digestFields;
321 const ActionPhvConstraints &actionConstraints;
322
323 // determine alignment constraint on a single field.
324 cstring getOppositeGressFieldName(cstring);
325 cstring getEgressFieldName(cstring);
326
327 ordered_set<const PHV::Field *> findAllRelatedFields(const PHV::Field *f);
328 ordered_set<const PHV::Field *> findAllReachingFields(const PHV::Field *f);
329 ordered_set<const PHV::Field *> findAllSourcingFields(const PHV::Field *f);
330 ordered_set<const PHV::Field *> findAllRelatedFieldsOfCopackedFields(const PHV::Field *f);
331 void computeAlignmentConstraint(const ordered_set<const PHV::Field *> &, bool);
332
335 void computeMustPackConstraints(const ordered_set<const PHV::Field *> &, bool);
336
337 void computeNoPackIfIntrinsicMeta(const ordered_set<const PHV::Field *> &, bool);
338 void computeNoPackIfActionDataWrite(const ordered_set<const PHV::Field *> &, bool);
339 void computeNoPackIfSpecialityRead(const ordered_set<const PHV::Field *> &, bool);
340 void computeNoPackIfDigestUse(const ordered_set<const PHV::Field *> &, bool);
341 void computeNoSplitConstraints(const ordered_set<const PHV::Field *> &, bool);
342
343 bool preorder(const IR::HeaderOrMetadata *) override;
344 bool preorder(const IR::BFN::DigestFieldList *) override;
345 profile_t init_apply(const IR::Node *root) override;
346 void end_apply() override;
347
353 template <typename NodeType, typename Func, typename Func2>
354 void forAllMatching(const IR::Node *root, Func &&function, Func2 &&function2) {
355 struct NodeVisitor : public Inspector {
356 explicit NodeVisitor(Func &&function, Func2 &&function2)
357 : function(function), function2(function2) {}
358 Func function;
359 Func2 function2;
360 bool preorder(const NodeType *node) override {
361 function(node);
362 return true;
363 }
364 void postorder(const NodeType *node) override { function2(node); }
365 };
366 root->apply(NodeVisitor(std::forward<Func>(function), std::forward<Func2>(function2)));
367 }
368
369 public:
370 explicit CollectConstraints(PhvInfo &p, const CollectIngressBridgedFields &b,
372 const GatherDigestFields &d, const ActionPhvConstraints &a)
373 : phv(p),
374 ingressBridgedFields(b),
375 egressBridgedFields(e),
376 parserAlignedFields(g),
377 digestFields(d),
378 actionConstraints(a) {}
379};
380
384class GatherAlignmentConstraints : public PassManager {
385 private:
386 CollectIngressBridgedFields collectIngressBridgedFields;
387 CollectEgressBridgedFields collectEgressBridgedFields;
388 GatherParserExtracts collectParserAlignedFields;
389 GatherDigestFields collectDigestFields; // Outputs currently not used
390
391 public:
392 GatherAlignmentConstraints(PhvInfo &p, const ActionPhvConstraints &a)
393 : collectIngressBridgedFields(p),
394 collectEgressBridgedFields(p),
395 collectParserAlignedFields(p),
396 collectDigestFields(p) {
397 addPasses({
398 &collectIngressBridgedFields,
399 &collectEgressBridgedFields,
400 &collectParserAlignedFields,
401 &collectDigestFields,
402 new CollectConstraints(p, collectIngressBridgedFields, collectEgressBridgedFields,
403 collectParserAlignedFields, collectDigestFields, a),
404 });
405 }
406};
407
440class ConstraintSolver {
441 const PhvInfo &phv;
442 z3::context &context;
443 z3::optimize &solver;
444 PackingConstraints &packingConstraints;
445 AllConstraints &constraints;
448 DebugInfo &debug_info;
449
450 void add_field_alignment_constraints(cstring, const PHV::Field *, int);
451 void add_non_overlap_constraints(cstring, ordered_set<const PHV::Field *> &);
452 void add_extract_together_constraints(cstring, ordered_set<const PHV::Field *> &);
453 void add_solitary_constraints(cstring, ordered_set<const PHV::Field *> &);
454 void add_deparsed_to_tm_constraints(cstring, ordered_set<const PHV::Field *> &);
455 void add_no_pack_constraints(cstring, ordered_set<const PHV::Field *> &);
456 void add_no_split_constraints(cstring, ordered_set<const PHV::Field *> &);
457
458 const PHV::Field *create_padding(int size);
459 std::vector<const PHV::Field *> insert_padding(std::vector<std::pair<unsigned, std::string>> &);
460
461 void dump_unsat_core();
462
463 public:
464 explicit ConstraintSolver(const PhvInfo &p, z3::context &context, z3::optimize &solver,
465 PackingConstraints &pc, AllConstraints &constraints, DebugInfo &dbg)
466 : phv(p),
467 context(context),
468 solver(solver),
469 packingConstraints(pc),
470 constraints(constraints),
471 debug_info(dbg) {}
472
477
478 void print_assertions();
479};
480
524class PackWithConstraintSolver : public Inspector {
525 const PhvInfo &phv;
531 const ordered_set<cstring> &candidates;
532
535
544 // XXX: make this a ordered_map<cstring, IR::StructField>
546 phvFieldToStructFieldMap;
547
552
553 PackingCandidateFields &packingCandidateFields;
554 PackingConstraints &packingConstraints;
555
559
560 // Pipeline name for printing debug messages
561 cstring pipelineName;
562
563 public:
564 explicit PackWithConstraintSolver(const PhvInfo &p, ConstraintSolver &solver,
565 const ordered_set<cstring> &c,
567 PackingCandidateFields &pcf, PackingConstraints &pc)
568 : phv(p),
569 solver(solver),
570 candidates(c),
571 repackedTypes(r),
572 packingCandidateFields(pcf),
573 packingConstraints(pc) {}
574
575 Visitor::profile_t init_apply(const IR::Node *root) override;
576 bool preorder(const IR::HeaderOrMetadata *hdr) override;
577 bool preorder(const IR::BFN::DigestFieldList *dfl) override;
578 void end_apply() override;
579
580 void set_pipeline_name(cstring name) { pipelineName = name; }
581 void optimize();
582 void solve();
583};
584
590class PadFixedSizeHeaders : public Inspector {
592
593 public:
594 explicit PadFixedSizeHeaders(ordered_map<cstring, const IR::Type_StructLike *> &r)
595 : repackedTypes(r) {}
596
597 bool preorder(const IR::BFN::Type_FixedSizeHeader *h) override {
598 auto width = [&](const IR::Type_StructLike *s) -> int {
599 int rv = 0;
600 for (auto f : s->fields) rv += f->type->width_bits();
601 return rv;
602 };
603
604 auto countPadding = [&](const IR::IndexedVector<IR::StructField> &fields) -> int {
605 int count = 0;
606 for (auto f : fields)
607 if (f->hasAnnotation("padding"_cs)) count++;
608
609 return count;
610 };
611
612 auto genPadding = [&](int size, int id) {
613 cstring padFieldName = "__pad_" + cstring::to_cstring(id);
614 const IR::StructField *padField =
615 new IR::StructField(padFieldName,
616 {new IR::Annotation(IR::ID("padding"), {}),
617 new IR::Annotation(IR::ID("overlayable"), {})},
618 IR::Type::Bits::get(size));
619 return padField;
620 };
621
622 size_t bits = static_cast<size_t>(width(h));
623 ERROR_CHECK(bits <= Device::pardeSpec().bitResubmitSize(), "%1% digest limited to %2% bits",
624 h->name, Device::pardeSpec().bitResubmitSize());
625 auto pad_size = h->fixed_size - bits;
626
627 auto fields = new IR::IndexedVector<IR::StructField>();
628 fields->append(h->fields);
629 auto index = countPadding(h->fields);
630 if (pad_size != 0) {
631 auto padding = genPadding(pad_size, index++);
632 fields->push_back(padding);
633 }
634
635 auto newType = new IR::Type_Header(h->name, *fields);
636 repackedTypes.emplace(h->name, newType);
637 return false;
638 }
639};
640
648class ReplaceFlexibleType : public Transform {
649 const RepackedHeaderTypes &repackedTypes;
650
651 public:
652 explicit ReplaceFlexibleType(const RepackedHeaderTypes &m) : repackedTypes(m) {}
653
654 // if used in backend
655 const IR::Node *postorder(IR::HeaderOrMetadata *h) override;
656 const IR::Node *postorder(IR::BFN::DigestFieldList *d) override;
657 const IR::BFN::DigestFieldList *repackFieldList(
658 cstring digest, std::vector<FieldListEntry> repackedFieldIndices,
659 const IR::Type_StructLike *repackedHeaderType,
660 const IR::BFN::DigestFieldList *origFieldList) const;
661
662 // if used in midend
663 const IR::Node *postorder(IR::Type_StructLike *h) override;
664 const IR::Node *postorder(IR::StructExpression *h) override;
665};
666
667bool findFlexibleAnnotation(const IR::Type_StructLike *);
668
673class GatherDeparserParameters : public Inspector {
674 private:
675 const PhvInfo &phv;
678
679 profile_t init_apply(const IR::Node *root) override {
680 params.clear();
681 return Inspector::init_apply(root);
682 }
683
684 bool preorder(const IR::BFN::DeparserParameter *p) override;
685
686 public:
687 explicit GatherDeparserParameters(const PhvInfo &p, ordered_set<const PHV::Field *> &f)
688 : phv(p), params(f) {}
689};
690
694class GatherPhase0Fields : public Inspector {
695 private:
696 const PhvInfo &phv;
699 static constexpr char const *PHASE0_PARSER_STATE_NAME = "ingress::$phase0";
700
701 profile_t init_apply(const IR::Node *root) override {
702 noPackFields.clear();
703 return Inspector::init_apply(root);
704 }
705
706 bool preorder(const IR::BFN::ParserState *p) override;
707
708 bool preorder(const IR::BFN::DigestFieldList *d) override;
709
710 public:
711 explicit GatherPhase0Fields(const PhvInfo &p, ordered_set<const PHV::Field *> &f)
712 : phv(p), noPackFields(f) {}
713};
714
715// set of variables for bridged fields (pretty print)
716// set of constraints for bridged fields
717// helper function to convert between PHV::Field to z3::expr
718// constraints are objects on PHV fields
719// constraints can be pretty_printed, encoded to z3
720class LogRepackedHeaders : public Inspector {
721 private:
722 // Need this for field names
723 const PhvInfo &phv;
724 // Contains all of the (potentially) repacked headers
725 RepackedHeaders repacked;
726 // All headers we have seen before, but with "egress" or "ingress" removed (avoid duplication)
727 std::unordered_set<std::string> hdrs;
728
729 // Collects all headers/metadatas that may have been repacked (i.e. have a field that is
730 // flexible)
731 bool preorder(const IR::HeaderOrMetadata *h) override;
732
733 // Pretty print all of the flexible headers
734 void end_apply() override;
735
736 // Returns the full field name
737 std::string getFieldName(std::string hdr, const IR::StructField *field) const;
738
739 // Pretty prints a single header/metadata
740 std::string pretty_print(const IR::HeaderOrMetadata *h, std::string hdr) const;
741
742 // Strips the given prefix from the front of the cstring, returns as string
743 std::string strip_prefix(cstring str, std::string pre);
744
745 public:
746 explicit LogRepackedHeaders(const PhvInfo &p) : phv(p) {}
747
748 std::string asm_output() const;
749};
750
751class LogFlexiblePacking : public Logging::PassManager {
752 LogRepackedHeaders *flexibleLogging;
753
754 public:
755 explicit LogFlexiblePacking(const PhvInfo &phv)
756 : Logging::PassManager("flexible_packing"_cs, Logging::Mode::AUTO) {
757 flexibleLogging = new LogRepackedHeaders(phv);
758 addPasses({
759 flexibleLogging,
760 });
761 }
762
763 const LogRepackedHeaders *get_flexible_logging() const { return flexibleLogging; }
764};
765
766class GatherPackingConstraintFromSinglePipeline : public PassManager {
767 private:
768 const BFN_Options &options;
769 MauBacktracker table_alloc;
770 PragmaNoPack pa_no_pack;
771 PackConflicts packConflicts;
772 MapTablesToActions tableActionsMap;
773 ActionPhvConstraints actionConstraints;
774 SymBitMatrix doNotPack;
778 ordered_set<const PHV::Field *> deparserParams;
779
780 // used by solver-based packing
782 PackWithConstraintSolver &packWithConstraintSolver;
783
784 public:
785 explicit GatherPackingConstraintFromSinglePipeline(PhvInfo &p, const PhvUse &u,
786 DependencyGraph &dg, const BFN_Options &o,
788
789 // Return a Json representation of flexible headers to be saved in .bfa/context.json
790 // must be called after the pass is applied
791 std::string asm_output() const;
792};
793
794// PackFlexibleHeader manages the global context for packing bridge metadata
795// The global context includes:
796// - instance of z3 solver and its context
797//
798// We need to manage the global context at this level is because bridge
799// metadata can be used across multiple pipelines in folded pipeline. To
800// support folded pipeline, we first collect bridge metadata constraints across
801// each pair of ingress/egress, and run z3 solver over the global set of
802// constraints over all pairs of ingress&egress pipelines. Therefore, it
803// is necessary to maintain z3 context as this level.
804class PackFlexibleHeaders : public PassManager {
805 std::vector<const IR::BFN::Pipe *> pipe;
806 PhvInfo phv;
807 PhvUse uses;
808 FieldDefUse defuse;
809 DependencyGraph deps;
810
811 z3::context context;
812 z3::optimize solver;
813 ConstraintSolver constraint_solver;
814 PackWithConstraintSolver packWithConstraintSolver;
815 PackingCandidateFields packingCandidateFields;
816 PackingConstraints packingConstraints;
817 PackedFields packedFields;
818 AllConstraints constraints;
819
820 cstring pipelineName;
821 /* storage for debug log */
822 DebugInfo debug_info;
823
825
826 public:
827 explicit PackFlexibleHeaders(const BFN_Options &options, ordered_set<cstring> &,
828 RepackedHeaderTypes &repackedTypes);
829
830 void set_pipeline_name(cstring name) { pipelineName = name; }
831 // encode constraints to z3 expressions
832 void optimize() {
833 packWithConstraintSolver.set_pipeline_name(pipelineName);
834 packWithConstraintSolver.optimize();
835 }
836 // execute z3 solver to find a solution
837 void solve() { packWithConstraintSolver.solve(); }
838 // convert the solution to P4 header format
839 void end_apply() override;
840
841 void print_packing_candidate_fields() const {
842 for (auto &[hdr_type, fields] : packingCandidateFields) {
843 LOG3("Packing candidate fields for " << hdr_type << ":");
844 for (auto f : fields) {
845 LOG3(" " << f);
846 }
847 }
848 }
849 void check_conflicting_constraints();
850};
851
925
926using PipeAndGress = std::pair<std::pair<cstring, gress_t>, std::pair<cstring, gress_t>>;
927
928using BridgeLocs = ordered_map<std::pair<cstring, gress_t>, IR::HeaderRef *>;
929
930class CollectBridgedFieldsUse : public Inspector {
931 public:
932 P4::ReferenceMap *refMap;
933 P4::TypeMap *typeMap;
934
935 struct Use {
936 const IR::Type *type;
937 cstring name;
938 cstring method;
939 gress_t thread;
940
941 bool operator<(const Use &other) const {
942 return std::tie(type, name, method, thread) <
943 std::tie(other.type, other.name, other.method, other.thread);
944 }
945
946 bool operator==(const Use &other) const {
947 return std::tie(type, name, method, thread) ==
948 std::tie(other.type, other.name, other.method, other.thread);
949 }
950 };
951
952 ordered_set<Use> bridge_uses;
953
954 friend std::ostream &operator<<(std::ostream &, const Use &u);
955
956 public:
957 CollectBridgedFieldsUse(P4::ReferenceMap *refMap, P4::TypeMap *typeMap)
958 : refMap(refMap), typeMap(typeMap) {}
959
960 void postorder(const IR::MethodCallExpression *mc) override;
961};
962
964 int pipe_id;
966 IR::BFN::Pipe::thread_t thread;
967};
968
969class ExtractBridgeInfo : public Inspector {
970 const BFN_Options &options;
971 P4::ReferenceMap *refMap;
972 P4::TypeMap *typeMap;
974 ParamBinding *bindings;
976 CollectGlobalPragma collect_pragma;
977
978 public:
980
981 ExtractBridgeInfo(BFN_Options &options, P4::ReferenceMap *refMap, P4::TypeMap *typeMap,
983 : options(options),
984 refMap(refMap),
985 typeMap(typeMap),
986 conv(conv),
987 bindings(bindings),
988 map(ht) {}
989
990 std::vector<const IR::BFN::Pipe *> *generate_bridge_pairs(std::vector<BridgeContext> &);
991
992 bool preorder(const IR::P4Program *program) override;
993 void end_apply(const IR::Node *) override;
994};
995
1003class BridgedPacking : public PassManager {
1004 ParamBinding *bindings;
1005 BFN::ApplyEvaluator *evaluator;
1008 ExtractBridgeInfo *extractBridgeInfo;
1009
1010 public:
1011 P4::ReferenceMap refMap;
1012 P4::TypeMap typeMap;
1013
1014 public:
1015 BridgedPacking(BFN_Options &options, RepackedHeaderTypes &repackMap,
1016 CollectSourceInfoLogging &sourceInfoLogging);
1017
1020};
1021
1027class SubstitutePackedHeaders : public PassManager {
1028 ParamBinding *bindings;
1029 BFN::ApplyEvaluator *evaluator;
1031
1032 public:
1033 P4::ReferenceMap refMap;
1034 P4::TypeMap typeMap;
1037
1038 public:
1039 SubstitutePackedHeaders(BFN_Options &options, const RepackedHeaderTypes &repackedMap,
1040 CollectSourceInfoLogging &sourceInfoLogging);
1041 const BFN::ProgramPipelines &getPipelines() const { return conv->getPipelines(); }
1042 const IR::ToplevelBlock *getToplevelBlock() const { return evaluator->toplevel; }
1043};
1044
1045#endif /* BACKENDS_TOFINO_BF_P4C_COMMON_BRIDGED_PACKING_H_ */
Definition action_mutex.h:29
Definition action_phv_constraints.h:107
Definition extract_maupipe.h:212
Definition arch.h:293
Definition bf-p4c-options.h:28
Definition bridged_packing.h:303
Definition bridged_packing.h:146
ordered_map< cstring, cstring > bridged_to_orig
Map: bridged field name -> original field name.
Definition bridged_packing.h:157
Definition collect_global_pragma.h:28
Definition bridged_packing.h:105
ordered_map< cstring, cstring > bridged_to_orig
Key: bridged field name, value: original field name.
Definition bridged_packing.h:122
The class uses the Z3 solver to generate packing for a set of PHV fields given a set of constraints.
Definition bridged_packing.h:440
void add_constraints(cstring, ordered_set< const PHV::Field * > &)
Definition bridged_packing.cpp:1297
ordered_map< cstring, std::vector< const PHV::Field * > > solve(ordered_map< cstring, ordered_set< const PHV::Field * > > &)
Definition bridged_packing.cpp:1432
void add_mutually_aligned_constraints(ordered_set< const PHV::Field * > &)
Definition bridged_packing.cpp:1109
Definition constraints.h:149
Definition constraints.h:56
Definition bridged_packing.h:969
bool preorder(const IR::P4Program *program) override
Definition bridged_packing.cpp:2330
Definition bridged_packing.h:264
bool preorder(const IR::BFN::DigestFieldList *fl) override
Definition bridged_packing.cpp:169
Definition bridged_packing.h:766
Definition bridged_packing.h:179
Definition bridged_packing.h:720
Definition backends/tofino/bf-p4c/logging/pass_manager.h:36
Definition map_tables_to_actions.h:29
Definition mau_backtracker.h:29
Definition indexed_vector.h:40
Definition node.h:94
Definition vector.h:59
Definition visitor.h:413
Class used to encode maps from paths to declarations.
Definition referenceMap.h:66
Definition symbitmatrix.h:27
Definition visitor.h:437
Definition typeMap.h:41
Definition visitor.h:78
Definition cstring.h:85
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition phv_fields.h:154
Definition pack_conflicts.h:36
PackFlexibleHeaders(const BFN_Options &options, ordered_set< cstring > &, RepackedHeaderTypes &repackedTypes)
Definition bridged_packing.cpp:2182
Definition bridged_packing.h:524
bool preorder(const IR::HeaderOrMetadata *hdr) override
Definition bridged_packing.cpp:1488
void optimize()
Definition bridged_packing.cpp:1628
void solve()
Definition bridged_packing.cpp:1669
void end_apply() override
Definition bridged_packing.cpp:1651
Definition param_binding.h:32
Definition phv_fields.h:1095
Definition phv_parde_mau_use.h:154
Definition pa_no_pack.h:28
Definition mau/table_mutex.h:110
Definition arch.h:452
ordered_map< cstring, const IR::Type_StructLike * > RepackedHeaderTypes
Adjusted packing of bridged and fixed-size headers; output of BFN::BridgedPacking,...
Definition bridged_packing.h:84
Pass that collects source information.
Definition source_info_logging.h:39
Definition field_defuse.h:77
Definition tofino/bf-p4c/phv/constraints/constraints.cpp:21
@ AUTO
Creates if this is the first time writing to the log; otherwise, appends.
Definition filelog.h:43
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition phv/solver/action_constraint_solver.cpp:33
Definition bridged_packing.h:47
Definition bridged_packing.h:963
Definition bridged_packing.h:935
Definition table_dependency_graph.h:52
Definition id.h:28