19#ifndef BF_P4C_MAU_ACTION_DATA_BUS_H_
20#define BF_P4C_MAU_ACTION_DATA_BUS_H_
22#include "backends/tofino/bf-p4c/mau/action_format.h"
23#include "backends/tofino/bf-p4c/mau/table_layout.h"
24#include "lib/safe_vector.h"
63 ActionData::SlotType_t type;
64 Loc(
int b, ActionData::SlotType_t t) : byte(b), type(t) {}
65 void dbprint(std::ostream &out)
const {
66 int slot_size = (8 << type);
67 out <<
"ADB[" <<
byte <<
":" << ((
byte + slot_size / 8) - 1) <<
"]";
69 bool operator==(
const Loc &loc)
const {
70 if (
byte != loc.byte)
return false;
71 if (type != loc.type)
return false;
74 bool operator!=(
const Loc &loc)
const {
return !(*
this == loc); }
80 bool full_in_use =
false;
81 unsigned shared_status = 0;
82 int shared_byte[2] = {-1, -1};
83 bool full_bitmasked_set =
false;
84 int full_bitmasked_index = -1;
85 void init_full_bitmask(
int fbi) {
86 full_bitmasked_set =
true;
87 full_bitmasked_index = fbi;
99 ActionData::Location_t
source = ActionData::ALL_LOCATIONS;
101 : location(l), byte_offset(bo),
bytes_used(bu) {}
104 void dbprint(std::ostream &out)
const {
105 out <<
"Source:Offset " <<
source <<
":" << byte_offset <<
" : " << location;
108 if (location != rs.location)
return false;
109 if (byte_offset != rs.byte_offset)
return false;
110 if (
bytes_used != rs.bytes_used)
return false;
111 if (
source != rs.source)
return false;
114 bool operator!=(
const ReservedSpace &rs)
const {
return !(*
this == rs); }
121 virtual void clear() {
122 action_data_locs.clear();
123 clobber_locs.clear();
125 virtual Use *clone()
const = 0;
126 virtual bool emit_adb_asm(std::ostream &,
const IR::MAU::Table *,
bitvec source)
const = 0;
127 virtual bool empty()
const {
return action_data_locs.empty() && clobber_locs.empty(); }
128 virtual int rng_unit()
const = 0;
129 bool operator==(
const Use &use)
const {
130 if (action_data_locs != use.action_data_locs)
return false;
131 if (clobber_locs != use.clobber_locs)
return false;
134 bool operator!=(
const Use &use)
const {
return !(*
this == use); }
135 friend std::ostream &operator<<(std::ostream &out,
const Use &u);
148 virtual void clear();
159 virtual bool alloc_action_data_bus(
const IR::MAU::Table *tbl,
165 virtual void update(
cstring name,
const Use::ReservedSpace &rs) = 0;
166 virtual void update(
const IR::MAU::Table *tbl);
169 const IR::MAU::Table *tbl);
171 const IR::MAU::Table *tbl);
174 static int getAdbSize();
175 friend std::ostream &operator<<(std::ostream &out,
const ActionDataBus &adb);
Definition stringify.h:33
Definition ordered_map.h:32
Definition safe_vector.h:27
TODO: this is not really specific to BMV2, it should reside somewhere else.
Definition applyOptionsPragmas.cpp:24
Definition action_data_bus.h:79
Definition action_data_bus.h:61
Definition action_data_bus.h:94
ReservedSpace(Loc l, int bo, bitvec bu)
Definition action_data_bus.h:100
bitvec bytes_used
Definition action_data_bus.h:97
ActionData::Location_t source
Definition action_data_bus.h:99
Definition action_data_bus.h:92
Definition action_data_bus.h:59
loc_alg_t
Definition action_data_bus.h:139
virtual void clear()
Definition action_data_bus.cpp:24
virtual void update(cstring name, const Use &alloc)
Definition action_data_bus.cpp:32