25 auto tbl =
dynamic_cast<StatefulTable *
>(tbl_);
26 BUG_CHECK(tbl,
"expected stateful table");
27 int logical_home_row = tbl->layout[0].row;
28 auto &meter_group = regs.rams.map_alu.meter_group[logical_home_row / 4U];
29 auto &salu = meter_group.stateful.salu_instr_state_alu[act->code][slot - ALU2LO];
30 auto &salu_instr_common = meter_group.stateful.salu_instr_common[act->code];
31 salu.salu_op = opc->opcode & 0xf;
32 salu.salu_arith = opc->opcode >> 4;
33 salu.salu_pred = predication_encode & Target::Tofino::STATEFUL_PRED_MASK;
34 const int alu_const_min = Target::STATEFUL_ALU_CONST_MIN();
35 const int alu_const_max = Target::STATEFUL_ALU_CONST_MAX();
38 salu.salu_asrc_memory = 1;
39 salu.salu_asrc_memory_index = m->field->bit(0) > 0;
41 salu.salu_asrc_memory = 0;
42 if (k->value >= alu_const_min && k->value <= alu_const_max) {
43 salu.salu_const_src = k->value & Target::STATEFUL_ALU_CONST_MASK();
44 salu.salu_regfile_const = 0;
46 salu.salu_const_src = tbl->get_const(k->lineno, k->value);
47 salu.salu_regfile_const = 1;
50 salu.salu_asrc_memory = 0;
51 salu.salu_const_src = r->index;
52 salu.salu_regfile_const = 1;
54 BUG(
"unknown operand");
59 salu.salu_bsrc_phv = 1;
60 salu.salu_bsrc_phv_index = f->phv_index(tbl);
62 salu_instr_common.salu_alu2_lo_bsrc_math = 1;
64 salu_instr_common.salu_alu2_lo_math_src = b->phv_index(tbl);
66 salu_instr_common.salu_alu2_lo_math_src = b->field->bit(0) > 0 ? 3 : 2;
68 BUG(
"unknown operand");
71 salu.salu_bsrc_phv = 0;
72 if (k->value >= alu_const_min && k->value <= alu_const_max) {
73 salu.salu_const_src = k->value & Target::STATEFUL_ALU_CONST_MASK();
74 salu.salu_regfile_const = 0;
76 salu.salu_const_src = tbl->get_const(k->lineno, k->value);
77 salu.salu_regfile_const = 1;
80 salu.salu_bsrc_phv = 0;
81 salu.salu_const_src = r->index;
82 salu.salu_regfile_const = 1;
84 BUG(
"unknown operand");
89 write_regs<Target::Tofino::mau_regs>(regs, tbl, act);
95 int logical_home_row = tbl->layout[0].row;
96 auto &meter_group = regs.rams.map_alu.meter_group[logical_home_row / 4U];
97 auto &salu = meter_group.stateful.salu_instr_state_alu[act->code][slot - ALU2LO];
98 salu.salu_op = opc->opcode & 0xf;
99 salu.salu_pred = predication_encode & Target::Tofino::STATEFUL_PRED_MASK;
101 salu.salu_asrc_memory = 1;
102 salu.salu_asrc_memory_index = 0;
105 write_regs<Target::Tofino::mau_regs>(regs, tbl, act);
111 auto tbl =
dynamic_cast<StatefulTable *
>(tbl_);
112 BUG_CHECK(tbl,
"expected stateful table");
113 int logical_home_row = tbl->layout[0].row;
114 auto &meter_group = regs.rams.map_alu.meter_group[logical_home_row / 4U];
115 auto &salu = meter_group.stateful.salu_instr_cmp_alu[act->code][slot];
117 salu.salu_cmp_asrc_input = srca->field->bit(0) > 0;
118 salu.salu_cmp_asrc_sign = srca_neg;
119 salu.salu_cmp_asrc_enable = 1;
122 salu.salu_cmp_bsrc_input = srcb->phv_index(tbl);
123 salu.salu_cmp_bsrc_sign = srcb_neg;
124 salu.salu_cmp_bsrc_enable = 1;
127 if (
auto k =
dynamic_cast<const operand::Const *
>(srcc)) {
128 const int cmp_const_min = Target::STATEFUL_CMP_CONST_MIN();
129 const int cmp_const_max = Target::STATEFUL_CMP_CONST_MAX();
130 if (k->value >= cmp_const_min && k->value <= cmp_const_max) {
131 salu.salu_cmp_const_src = k->value & Target::STATEFUL_CMP_CONST_MASK();
132 salu.salu_cmp_regfile_const = 0;
134 salu.salu_cmp_const_src = tbl->get_const(srcc->lineno, k->value);
135 salu.salu_cmp_regfile_const = 1;
137 }
else if (
auto r =
dynamic_cast<const operand::Regfile *
>(srcc)) {
138 salu.salu_cmp_const_src = r->index;
139 salu.salu_cmp_regfile_const = 1;
142 salu.salu_cmp_const_src = 0;
143 salu.salu_cmp_regfile_const = 0;
145 salu.salu_cmp_opcode = opc->opcode | (type << 2);
148 write_regs<Target::Tofino::mau_regs>(regs, tbl, act);
152 BUG(
"Unreachable state.");
155void OutOP::decode_output_mux(Target::Tofino,
Table *tbl,
value_t &op) {
156 static const std::map<std::string, int> ops_mux_lookup = {
157 {
"mem_hi", 0}, {
"mem_lo", 1}, {
"memory_hi", 0}, {
"memory_lo", 1},
158 {
"phv_hi", 2}, {
"phv_lo", 3}, {
"alu_hi", 4}, {
"alu_lo", 5},
159 {
"alu_hi_out", 4}, {
"alu_lo_out", 5}, {
"predicate", 6}};
160 if (op.type == tCMD && ops_mux_lookup.count(op[0].s))
161 output_mux = ops_mux_lookup.at(op[0].s);
162 else if (op.type == tSTR && ops_mux_lookup.count(op.s))
163 output_mux = ops_mux_lookup.at(op.s);
167 int tmp = output_mux;
168 if (
auto *phv = src.to<operand::Phv>())
169 output_mux = 3 - phv->phv_index(tbl->to<StatefulTable>());
170 else if (
auto *mem = src.to<operand::Memory>())
171 output_mux = mem->field->bit(0) > 0 ? 0 : 1;
172 BUG_CHECK(tmp < 0 || tmp == output_mux,
"inconsistent output mux decode");
175int OutOP::decode_output_option(Target::Tofino,
value_t &op) {
return -1; }
180 auto tbl =
dynamic_cast<StatefulTable *
>(tbl_);
181 BUG_CHECK(tbl,
"expected stateful table");
182 int logical_home_row = tbl->layout[0].row;
183 auto &meter_group = regs.rams.map_alu.meter_group[logical_home_row / 4U];
184 auto &salu = meter_group.stateful.salu_instr_output_alu[act->code];
185 if (predication_encode) {
186 salu.salu_output_cmpfn = predication_encode & Target::Tofino::STATEFUL_PRED_MASK;
188 salu.salu_output_cmpfn = STATEFUL_PREDICATION_ENCODE_UNCOND;
190 salu.salu_output_asrc = output_mux;
193 write_regs<Target::Tofino::mau_regs>(regs, tbl, act);
Definition salu_inst.cpp:45
Definition salu_inst.cpp:224
Definition salu_inst.cpp:164
Definition salu_inst.cpp:78
Definition salu_inst.cpp:60
Definition asm-types.h:114