19#ifndef BACKENDS_TOFINO_BF_P4C_PHV_FIELDSLICE_LIVE_RANGE_H_
20#define BACKENDS_TOFINO_BF_P4C_PHV_FIELDSLICE_LIVE_RANGE_H_
24#include "backends/tofino/bf-p4c/common/field_defuse.h"
25#include "backends/tofino/bf-p4c/common/map_tables_to_actions.h"
26#include "backends/tofino/bf-p4c/mau/action_analysis.h"
27#include "backends/tofino/bf-p4c/parde/clot/clot_info.h"
28#include "backends/tofino/bf-p4c/phv/phv.h"
29#include "backends/tofino/bf-p4c/phv/pragma/phv_pragmas.h"
30#include "lib/safe_vector.h"
31#include "mau_backtracker.h"
53 enum class OpInfo { DEAD, READ, WRITE, READ_WRITE, LIVE };
60 static int num_table_stages;
73 if (num_table_stages <= 0) num_table_stages = Device::numStages();
74 lives_i.resize(num_table_stages + 2, OpInfo::DEAD);
76 OpInfo &parser() {
return lives_i[0]; }
77 const OpInfo &parser()
const {
return lives_i[0]; }
78 OpInfo &deparser() {
return lives_i[num_table_stages + 1]; }
79 const OpInfo &deparser()
const {
return lives_i[num_table_stages + 1]; }
80 OpInfo &stage(
int i) {
return lives_i[i + 1]; }
81 const OpInfo &stage(
int i)
const {
return lives_i[i + 1]; }
87 num_table_stages = std::max(stage, Device::numStages());
134LiveRangeInfo::OpInfo operator|(
const LiveRangeInfo::OpInfo &,
const LiveRangeInfo::OpInfo &);
135LiveRangeInfo::OpInfo &operator|=(LiveRangeInfo::OpInfo &,
const LiveRangeInfo::OpInfo &);
137std::ostream &operator<<(std::ostream &out,
const LiveRangeInfo::OpInfo &opinfo);
138std::ostream &operator<<(std::ostream &out,
const LiveRangeInfo &lr);
153 class MapFieldSliceToAction :
public Inspector {
167 bool preorder(
const IR::MAU::Action *act)
override;
169 : phv(phv), red_info(ri) {}
174 enum unit { PARSER, TABLE, DEPARSER };
182 const MapFieldSliceToAction *fs_action_map;
192 std::optional<Location> to_location(
const PHV::Field *field,
199 std::pair<int, int> update_live_status(
LiveRangeInfo &liverange,
const Location &loc,
204 void update_live_range_info(
const PHV::FieldSlice &fs,
const Location &use_loc,
213 void end_apply()
override;
217 const FieldDefUse *defuse,
const MapFieldSliceToAction *fs_action_map,
221 backtracker(backtracker),
223 fs_action_map(fs_action_map),
229 MapFieldSliceToAction *fs_action_map;
242 fs_action_map =
new MapFieldSliceToAction(phv, red_info);
243 setter =
new DBSetter(phv, clot, backtracker, defuse, fs_action_map, *
this, pragmas);
244 addPasses({fs_action_map, setter});
Definition clot_info.h:41
Definition mau_backtracker.h:29
Definition ir/pass_manager.h:40
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition safe_vector.h:27
Definition phv_fields.h:154
Definition phv_fields.h:898
Definition fieldslice_live_range.h:152
const LiveRangeInfo * get_liverange(const PHV::FieldSlice &) const override
Definition phv/fieldslice_live_range.cpp:548
const LiveRangeInfo * default_liverange() const override
Definition phv/fieldslice_live_range.cpp:563
Definition fieldslice_live_range.h:140
virtual const LiveRangeInfo * get_liverange(const PHV::FieldSlice &) const =0
virtual const LiveRangeInfo * default_liverange() const =0
Definition fieldslice_live_range.h:35
bool can_overlay(const LiveRangeInfo &other) const
Definition phv/fieldslice_live_range.cpp:106
static void set_num_table_stages(int stage)
Definition fieldslice_live_range.h:86
static std::vector< LiveRange > merge_invalid_ranges(const std::vector< LiveRange > &ranges)
Definition phv/fieldslice_live_range.cpp:216
std::vector< LiveRange > disjoint_ranges() const
Definition phv/fieldslice_live_range.cpp:165
const safe_vector< OpInfo > & vec() const
Definition fieldslice_live_range.h:91
Definition phv_pragmas.h:46
Definition phv_fields.h:1095
const ordered_set< const PHV::Field * > & getFields() const
Definition pa_no_init.h:61
std::pair< const IR::BFN::Unit *, const IR::Expression * > locpair
Definition field_defuse.h:82
Definition field_defuse.h:77
The namespace encapsulating PHV-related stuff.
Definition gateway.h:32
Definition reduction_or.h:47