Lines Matching refs:rd

153 static void emit_sextw_alt(u8 *rd, u8 ra, struct rv_jit_context *ctx)  in emit_sextw_alt()  argument
155 emit_sextw(ra, *rd, ctx); in emit_sextw_alt()
156 *rd = ra; in emit_sextw_alt()
159 static void emit_zextw_alt(u8 *rd, u8 ra, struct rv_jit_context *ctx) in emit_zextw_alt() argument
161 emit_zextw(ra, *rd, ctx); in emit_zextw_alt()
162 *rd = ra; in emit_zextw_alt()
166 static int emit_addr(u8 rd, u64 addr, bool extra_pass, struct rv_jit_context *ctx) in emit_addr() argument
182 emit(rv_auipc(rd, upper), ctx); in emit_addr()
183 emit(rv_addi(rd, rd, lower), ctx); in emit_addr()
188 static void emit_imm(u8 rd, s64 val, struct rv_jit_context *ctx) in emit_imm() argument
209 emit_lui(rd, upper, ctx); in emit_imm()
212 emit_li(rd, lower, ctx); in emit_imm()
216 emit_addiw(rd, rd, lower, ctx); in emit_imm()
224 emit_imm(rd, upper, ctx); in emit_imm()
226 emit_slli(rd, rd, shift, ctx); in emit_imm()
228 emit_addi(rd, rd, lower, ctx); in emit_imm()
280 static void emit_bcc(u8 cond, u8 rd, u8 rs, int rvoff, in emit_bcc() argument
285 emit(rv_beq(rd, rs, rvoff >> 1), ctx); in emit_bcc()
288 emit(rv_bltu(rs, rd, rvoff >> 1), ctx); in emit_bcc()
291 emit(rv_bltu(rd, rs, rvoff >> 1), ctx); in emit_bcc()
294 emit(rv_bgeu(rd, rs, rvoff >> 1), ctx); in emit_bcc()
297 emit(rv_bgeu(rs, rd, rvoff >> 1), ctx); in emit_bcc()
300 emit(rv_bne(rd, rs, rvoff >> 1), ctx); in emit_bcc()
303 emit(rv_blt(rs, rd, rvoff >> 1), ctx); in emit_bcc()
306 emit(rv_blt(rd, rs, rvoff >> 1), ctx); in emit_bcc()
309 emit(rv_bge(rd, rs, rvoff >> 1), ctx); in emit_bcc()
312 emit(rv_bge(rs, rd, rvoff >> 1), ctx); in emit_bcc()
316 static void emit_branch(u8 cond, u8 rd, u8 rs, int rvoff, in emit_branch() argument
322 emit_bcc(cond, rd, rs, rvoff, ctx); in emit_branch()
339 emit_bcc(cond, rd, rs, 8, ctx); in emit_branch()
350 emit_bcc(cond, rd, rs, 12, ctx); in emit_branch()
406 static void init_regs(u8 *rd, u8 *rs, const struct bpf_insn *insn, in init_regs() argument
418 *rd = bpf_to_rv_reg(insn->dst_reg, ctx); in init_regs()
427 static int emit_jump_and_link(u8 rd, s64 rvoff, bool fixed_addr, in emit_jump_and_link() argument
433 emit(rv_jal(rd, rvoff >> 1), ctx); in emit_jump_and_link()
439 emit(rv_jalr(rd, RV_REG_T1, lower), ctx); in emit_jump_and_link()
476 static void emit_atomic(u8 rd, u8 rs, s16 off, s32 imm, bool is64, in emit_atomic() argument
484 emit_addi(RV_REG_T1, rd, off, ctx); in emit_atomic()
487 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in emit_atomic()
489 rd = RV_REG_T1; in emit_atomic()
495 emit(is64 ? rv_amoadd_d(RV_REG_ZERO, rs, rd, 0, 0) : in emit_atomic()
496 rv_amoadd_w(RV_REG_ZERO, rs, rd, 0, 0), ctx); in emit_atomic()
499 emit(is64 ? rv_amoand_d(RV_REG_ZERO, rs, rd, 0, 0) : in emit_atomic()
500 rv_amoand_w(RV_REG_ZERO, rs, rd, 0, 0), ctx); in emit_atomic()
503 emit(is64 ? rv_amoor_d(RV_REG_ZERO, rs, rd, 0, 0) : in emit_atomic()
504 rv_amoor_w(RV_REG_ZERO, rs, rd, 0, 0), ctx); in emit_atomic()
507 emit(is64 ? rv_amoxor_d(RV_REG_ZERO, rs, rd, 0, 0) : in emit_atomic()
508 rv_amoxor_w(RV_REG_ZERO, rs, rd, 0, 0), ctx); in emit_atomic()
512 emit(is64 ? rv_amoadd_d(rs, rs, rd, 1, 1) : in emit_atomic()
513 rv_amoadd_w(rs, rs, rd, 1, 1), ctx); in emit_atomic()
518 emit(is64 ? rv_amoand_d(rs, rs, rd, 1, 1) : in emit_atomic()
519 rv_amoand_w(rs, rs, rd, 1, 1), ctx); in emit_atomic()
524 emit(is64 ? rv_amoor_d(rs, rs, rd, 1, 1) : in emit_atomic()
525 rv_amoor_w(rs, rs, rd, 1, 1), ctx); in emit_atomic()
530 emit(is64 ? rv_amoxor_d(rs, rs, rd, 1, 1) : in emit_atomic()
531 rv_amoxor_w(rs, rs, rd, 1, 1), ctx); in emit_atomic()
537 emit(is64 ? rv_amoswap_d(rs, rs, rd, 1, 1) : in emit_atomic()
538 rv_amoswap_w(rs, rs, rd, 1, 1), ctx); in emit_atomic()
549 emit(is64 ? rv_lr_d(r0, 0, rd, 0, 0) : in emit_atomic()
550 rv_lr_w(r0, 0, rd, 0, 0), ctx); in emit_atomic()
553 emit(is64 ? rv_sc_d(RV_REG_T3, rs, rd, 0, 1) : in emit_atomic()
554 rv_sc_w(RV_REG_T3, rs, rd, 0, 1), ctx); in emit_atomic()
1130 u8 rd = -1, rs = -1, code = insn->code; in bpf_jit_emit_insn() local
1134 init_regs(&rd, &rs, insn, ctx); in bpf_jit_emit_insn()
1143 emit_imm(rd, (ctx->user_vm_start >> 32) << 32, ctx); in bpf_jit_emit_insn()
1145 emit_or(RV_REG_T1, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1146 emit_mv(rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1149 if (rd != rs) in bpf_jit_emit_insn()
1150 emit_mv(rd, rs, ctx); in bpf_jit_emit_insn()
1162 emit_add(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1167 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1172 emit_mv(rd, rs, ctx); in bpf_jit_emit_insn()
1175 emit_sextb(rd, rs, ctx); in bpf_jit_emit_insn()
1178 emit_sexth(rd, rs, ctx); in bpf_jit_emit_insn()
1181 emit_sextw(rd, rs, ctx); in bpf_jit_emit_insn()
1185 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1191 emit_add(rd, rd, rs, ctx); in bpf_jit_emit_insn()
1193 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1198 emit_sub(rd, rd, rs, ctx); in bpf_jit_emit_insn()
1200 emit_subw(rd, rd, rs, ctx); in bpf_jit_emit_insn()
1203 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1207 emit_and(rd, rd, rs, ctx); in bpf_jit_emit_insn()
1209 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1213 emit_or(rd, rd, rs, ctx); in bpf_jit_emit_insn()
1215 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1219 emit_xor(rd, rd, rs, ctx); in bpf_jit_emit_insn()
1221 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1225 emit(is64 ? rv_mul(rd, rd, rs) : rv_mulw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
1227 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1232 emit(is64 ? rv_div(rd, rd, rs) : rv_divw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
1234 emit(is64 ? rv_divu(rd, rd, rs) : rv_divuw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
1236 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1241 emit(is64 ? rv_rem(rd, rd, rs) : rv_remw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
1243 emit(is64 ? rv_remu(rd, rd, rs) : rv_remuw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
1245 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1249 emit(is64 ? rv_sll(rd, rd, rs) : rv_sllw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
1251 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1255 emit(is64 ? rv_srl(rd, rd, rs) : rv_srlw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
1257 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1261 emit(is64 ? rv_sra(rd, rd, rs) : rv_sraw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
1263 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1269 emit_sub(rd, RV_REG_ZERO, rd, ctx); in bpf_jit_emit_insn()
1271 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1278 emit_zexth(rd, rd, ctx); in bpf_jit_emit_insn()
1282 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1291 emit_bswap(rd, imm, ctx); in bpf_jit_emit_insn()
1297 emit_imm(rd, imm, ctx); in bpf_jit_emit_insn()
1299 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1306 emit_addi(rd, rd, imm, ctx); in bpf_jit_emit_insn()
1309 emit_add(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1312 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1317 emit_addi(rd, rd, -imm, ctx); in bpf_jit_emit_insn()
1320 emit_sub(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1323 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1328 emit_andi(rd, rd, imm, ctx); in bpf_jit_emit_insn()
1331 emit_and(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1334 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1339 emit(rv_ori(rd, rd, imm), ctx); in bpf_jit_emit_insn()
1342 emit_or(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1345 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1350 emit(rv_xori(rd, rd, imm), ctx); in bpf_jit_emit_insn()
1353 emit_xor(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1356 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1361 emit(is64 ? rv_mul(rd, rd, RV_REG_T1) : in bpf_jit_emit_insn()
1362 rv_mulw(rd, rd, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1364 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1370 emit(is64 ? rv_div(rd, rd, RV_REG_T1) : in bpf_jit_emit_insn()
1371 rv_divw(rd, rd, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1373 emit(is64 ? rv_divu(rd, rd, RV_REG_T1) : in bpf_jit_emit_insn()
1374 rv_divuw(rd, rd, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1376 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1382 emit(is64 ? rv_rem(rd, rd, RV_REG_T1) : in bpf_jit_emit_insn()
1383 rv_remw(rd, rd, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1385 emit(is64 ? rv_remu(rd, rd, RV_REG_T1) : in bpf_jit_emit_insn()
1386 rv_remuw(rd, rd, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1388 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1392 emit_slli(rd, rd, imm, ctx); in bpf_jit_emit_insn()
1395 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1400 emit_srli(rd, rd, imm, ctx); in bpf_jit_emit_insn()
1402 emit(rv_srliw(rd, rd, imm), ctx); in bpf_jit_emit_insn()
1405 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1410 emit_srai(rd, rd, imm, ctx); in bpf_jit_emit_insn()
1412 emit(rv_sraiw(rd, rd, imm), ctx); in bpf_jit_emit_insn()
1415 emit_zextw(rd, rd, ctx); in bpf_jit_emit_insn()
1458 emit_sextw_alt(&rd, RV_REG_T2, ctx); in bpf_jit_emit_insn()
1461 emit_zextw_alt(&rd, RV_REG_T2, ctx); in bpf_jit_emit_insn()
1472 emit_and(RV_REG_T1, rd, rs, ctx); in bpf_jit_emit_insn()
1475 emit_branch(BPF_OP(code), rd, rs, rvoff, ctx); in bpf_jit_emit_insn()
1507 emit_sextw_alt(&rd, RV_REG_T2, ctx); in bpf_jit_emit_insn()
1510 emit_zextw_alt(&rd, RV_REG_T2, ctx); in bpf_jit_emit_insn()
1519 emit_branch(BPF_OP(code), rd, rs, rvoff, ctx); in bpf_jit_emit_insn()
1527 emit_andi(RV_REG_T1, rd, imm, ctx); in bpf_jit_emit_insn()
1530 emit_and(RV_REG_T1, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1621 ret = emit_addr(rd, imm64, extra_pass, ctx); in bpf_jit_emit_insn()
1625 emit_imm(rd, imm64, ctx); in bpf_jit_emit_insn()
1669 emit(rv_lb(rd, off, rs), ctx); in bpf_jit_emit_insn()
1671 emit(rv_lbu(rd, off, rs), ctx); in bpf_jit_emit_insn()
1680 emit(rv_lb(rd, 0, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1682 emit(rv_lbu(rd, 0, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1689 emit(rv_lh(rd, off, rs), ctx); in bpf_jit_emit_insn()
1691 emit(rv_lhu(rd, off, rs), ctx); in bpf_jit_emit_insn()
1700 emit(rv_lh(rd, 0, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1702 emit(rv_lhu(rd, 0, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1709 emit(rv_lw(rd, off, rs), ctx); in bpf_jit_emit_insn()
1711 emit(rv_lwu(rd, off, rs), ctx); in bpf_jit_emit_insn()
1720 emit(rv_lw(rd, 0, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1722 emit(rv_lwu(rd, 0, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1728 emit_ld(rd, off, rs, ctx); in bpf_jit_emit_insn()
1736 emit_ld(rd, 0, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1741 ret = add_exception_handler(insn, ctx, rd, insn_len); in bpf_jit_emit_insn()
1757 emit(rv_sb(rd, off, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1762 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1769 emit(rv_sh(rd, off, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1774 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1780 emit_sw(rd, off, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1785 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1791 emit_sd(rd, off, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1796 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1807 emit_add(RV_REG_T3, rd, RV_REG_ARENA, ctx); in bpf_jit_emit_insn()
1808 rd = RV_REG_T3; in bpf_jit_emit_insn()
1817 emit(rv_sb(rd, off, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1823 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1831 emit(rv_sh(rd, off, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1837 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1845 emit_sw(rd, off, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1851 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1859 emit_sd(rd, off, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1865 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1883 emit(rv_sb(rd, off, rs), ctx); in bpf_jit_emit_insn()
1888 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1893 emit(rv_sh(rd, off, rs), ctx); in bpf_jit_emit_insn()
1898 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1903 emit_sw(rd, off, rs, ctx); in bpf_jit_emit_insn()
1908 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1913 emit_sd(rd, off, rs, ctx); in bpf_jit_emit_insn()
1918 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1923 emit_atomic(rd, rs, off, imm, in bpf_jit_emit_insn()
1934 emit_add(RV_REG_T2, rd, RV_REG_ARENA, ctx); in bpf_jit_emit_insn()
1935 rd = RV_REG_T2; in bpf_jit_emit_insn()
1941 emit(rv_sb(rd, off, rs), ctx); in bpf_jit_emit_insn()
1947 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1955 emit(rv_sh(rd, off, rs), ctx); in bpf_jit_emit_insn()
1961 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1969 emit_sw(rd, off, rs, ctx); in bpf_jit_emit_insn()
1975 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1983 emit_sd(rd, off, rs, ctx); in bpf_jit_emit_insn()
1989 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()