Lines Matching refs:rd

140 static int emit_addr(u8 rd, u64 addr, bool extra_pass, struct rv_jit_context *ctx)  in emit_addr()  argument
152 emit(rv_auipc(rd, upper), ctx); in emit_addr()
153 emit(rv_addi(rd, rd, lower), ctx); in emit_addr()
158 static void emit_imm(u8 rd, s64 val, struct rv_jit_context *ctx) in emit_imm() argument
179 emit_lui(rd, upper, ctx); in emit_imm()
182 emit_li(rd, lower, ctx); in emit_imm()
186 emit_addiw(rd, rd, lower, ctx); in emit_imm()
194 emit_imm(rd, upper, ctx); in emit_imm()
196 emit_slli(rd, rd, shift, ctx); in emit_imm()
198 emit_addi(rd, rd, lower, ctx); in emit_imm()
245 static void emit_bcc(u8 cond, u8 rd, u8 rs, int rvoff, in emit_bcc() argument
250 emit(rv_beq(rd, rs, rvoff >> 1), ctx); in emit_bcc()
253 emit(rv_bltu(rs, rd, rvoff >> 1), ctx); in emit_bcc()
256 emit(rv_bltu(rd, rs, rvoff >> 1), ctx); in emit_bcc()
259 emit(rv_bgeu(rd, rs, rvoff >> 1), ctx); in emit_bcc()
262 emit(rv_bgeu(rs, rd, rvoff >> 1), ctx); in emit_bcc()
265 emit(rv_bne(rd, rs, rvoff >> 1), ctx); in emit_bcc()
268 emit(rv_blt(rs, rd, rvoff >> 1), ctx); in emit_bcc()
271 emit(rv_blt(rd, rs, rvoff >> 1), ctx); in emit_bcc()
274 emit(rv_bge(rd, rs, rvoff >> 1), ctx); in emit_bcc()
277 emit(rv_bge(rs, rd, rvoff >> 1), ctx); in emit_bcc()
281 static void emit_branch(u8 cond, u8 rd, u8 rs, int rvoff, in emit_branch() argument
287 emit_bcc(cond, rd, rs, rvoff, ctx); in emit_branch()
304 emit_bcc(cond, rd, rs, 8, ctx); in emit_branch()
315 emit_bcc(cond, rd, rs, 12, ctx); in emit_branch()
378 static void init_regs(u8 *rd, u8 *rs, const struct bpf_insn *insn, in init_regs() argument
390 *rd = bpf_to_rv_reg(insn->dst_reg, ctx); in init_regs()
399 static void emit_zext_32_rd_rs(u8 *rd, u8 *rs, struct rv_jit_context *ctx) in emit_zext_32_rd_rs() argument
401 emit_mv(RV_REG_T2, *rd, ctx); in emit_zext_32_rd_rs()
405 *rd = RV_REG_T2; in emit_zext_32_rd_rs()
409 static void emit_sext_32_rd_rs(u8 *rd, u8 *rs, struct rv_jit_context *ctx) in emit_sext_32_rd_rs() argument
411 emit_addiw(RV_REG_T2, *rd, 0, ctx); in emit_sext_32_rd_rs()
413 *rd = RV_REG_T2; in emit_sext_32_rd_rs()
417 static void emit_zext_32_rd_t1(u8 *rd, struct rv_jit_context *ctx) in emit_zext_32_rd_t1() argument
419 emit_mv(RV_REG_T2, *rd, ctx); in emit_zext_32_rd_t1()
422 *rd = RV_REG_T2; in emit_zext_32_rd_t1()
425 static void emit_sext_32_rd(u8 *rd, struct rv_jit_context *ctx) in emit_sext_32_rd() argument
427 emit_addiw(RV_REG_T2, *rd, 0, ctx); in emit_sext_32_rd()
428 *rd = RV_REG_T2; in emit_sext_32_rd()
431 static int emit_jump_and_link(u8 rd, s64 rvoff, bool force_jalr, in emit_jump_and_link() argument
437 emit(rv_jal(rd, rvoff >> 1), ctx); in emit_jump_and_link()
443 emit(rv_jalr(rd, RV_REG_T1, lower), ctx); in emit_jump_and_link()
461 u8 rd; in emit_call() local
472 rd = bpf_to_rv_reg(BPF_REG_0, ctx); in emit_call()
473 emit_mv(rd, RV_REG_A0, ctx); in emit_call()
477 static void emit_atomic(u8 rd, u8 rs, s16 off, s32 imm, bool is64, in emit_atomic() argument
485 emit_addi(RV_REG_T1, rd, off, ctx); in emit_atomic()
488 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in emit_atomic()
490 rd = RV_REG_T1; in emit_atomic()
496 emit(is64 ? rv_amoadd_d(RV_REG_ZERO, rs, rd, 0, 0) : in emit_atomic()
497 rv_amoadd_w(RV_REG_ZERO, rs, rd, 0, 0), ctx); in emit_atomic()
500 emit(is64 ? rv_amoand_d(RV_REG_ZERO, rs, rd, 0, 0) : in emit_atomic()
501 rv_amoand_w(RV_REG_ZERO, rs, rd, 0, 0), ctx); in emit_atomic()
504 emit(is64 ? rv_amoor_d(RV_REG_ZERO, rs, rd, 0, 0) : in emit_atomic()
505 rv_amoor_w(RV_REG_ZERO, rs, rd, 0, 0), ctx); in emit_atomic()
508 emit(is64 ? rv_amoxor_d(RV_REG_ZERO, rs, rd, 0, 0) : in emit_atomic()
509 rv_amoxor_w(RV_REG_ZERO, rs, rd, 0, 0), ctx); in emit_atomic()
513 emit(is64 ? rv_amoadd_d(rs, rs, rd, 0, 0) : in emit_atomic()
514 rv_amoadd_w(rs, rs, rd, 0, 0), ctx); in emit_atomic()
519 emit(is64 ? rv_amoand_d(rs, rs, rd, 0, 0) : in emit_atomic()
520 rv_amoand_w(rs, rs, rd, 0, 0), ctx); in emit_atomic()
525 emit(is64 ? rv_amoor_d(rs, rs, rd, 0, 0) : in emit_atomic()
526 rv_amoor_w(rs, rs, rd, 0, 0), ctx); in emit_atomic()
531 emit(is64 ? rv_amoxor_d(rs, rs, rd, 0, 0) : in emit_atomic()
532 rv_amoxor_w(rs, rs, rd, 0, 0), ctx); in emit_atomic()
538 emit(is64 ? rv_amoswap_d(rs, rs, rd, 0, 0) : in emit_atomic()
539 rv_amoswap_w(rs, rs, rd, 0, 0), ctx); in emit_atomic()
548 emit(is64 ? rv_lr_d(r0, 0, rd, 0, 0) : in emit_atomic()
549 rv_lr_w(r0, 0, rd, 0, 0), ctx); in emit_atomic()
552 emit(is64 ? rv_sc_d(RV_REG_T3, rs, rd, 0, 0) : in emit_atomic()
553 rv_sc_w(RV_REG_T3, rs, rd, 0, 0), ctx); in emit_atomic()
632 u8 rd = -1, rs = -1, code = insn->code; in bpf_jit_emit_insn() local
636 init_regs(&rd, &rs, insn, ctx); in bpf_jit_emit_insn()
644 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
647 emit_mv(rd, rs, ctx); in bpf_jit_emit_insn()
649 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
655 emit_add(rd, rd, rs, ctx); in bpf_jit_emit_insn()
657 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
662 emit_sub(rd, rd, rs, ctx); in bpf_jit_emit_insn()
664 emit_subw(rd, rd, rs, ctx); in bpf_jit_emit_insn()
667 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
671 emit_and(rd, rd, rs, ctx); in bpf_jit_emit_insn()
673 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
677 emit_or(rd, rd, rs, ctx); in bpf_jit_emit_insn()
679 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
683 emit_xor(rd, rd, rs, ctx); in bpf_jit_emit_insn()
685 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
689 emit(is64 ? rv_mul(rd, rd, rs) : rv_mulw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
691 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
695 emit(is64 ? rv_divu(rd, rd, rs) : rv_divuw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
697 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
701 emit(is64 ? rv_remu(rd, rd, rs) : rv_remuw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
703 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
707 emit(is64 ? rv_sll(rd, rd, rs) : rv_sllw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
709 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
713 emit(is64 ? rv_srl(rd, rd, rs) : rv_srlw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
715 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
719 emit(is64 ? rv_sra(rd, rd, rs) : rv_sraw(rd, rd, rs), ctx); in bpf_jit_emit_insn()
721 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
727 emit_sub(rd, RV_REG_ZERO, rd, ctx); in bpf_jit_emit_insn()
729 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
736 emit_slli(rd, rd, 48, ctx); in bpf_jit_emit_insn()
737 emit_srli(rd, rd, 48, ctx); in bpf_jit_emit_insn()
741 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
752 emit_andi(RV_REG_T1, rd, 0xff, ctx); in bpf_jit_emit_insn()
755 emit_srli(rd, rd, 8, ctx); in bpf_jit_emit_insn()
759 emit_andi(RV_REG_T1, rd, 0xff, ctx); in bpf_jit_emit_insn()
762 emit_srli(rd, rd, 8, ctx); in bpf_jit_emit_insn()
764 emit_andi(RV_REG_T1, rd, 0xff, ctx); in bpf_jit_emit_insn()
767 emit_srli(rd, rd, 8, ctx); in bpf_jit_emit_insn()
771 emit_andi(RV_REG_T1, rd, 0xff, ctx); in bpf_jit_emit_insn()
774 emit_srli(rd, rd, 8, ctx); in bpf_jit_emit_insn()
776 emit_andi(RV_REG_T1, rd, 0xff, ctx); in bpf_jit_emit_insn()
779 emit_srli(rd, rd, 8, ctx); in bpf_jit_emit_insn()
781 emit_andi(RV_REG_T1, rd, 0xff, ctx); in bpf_jit_emit_insn()
784 emit_srli(rd, rd, 8, ctx); in bpf_jit_emit_insn()
786 emit_andi(RV_REG_T1, rd, 0xff, ctx); in bpf_jit_emit_insn()
789 emit_srli(rd, rd, 8, ctx); in bpf_jit_emit_insn()
791 emit_andi(RV_REG_T1, rd, 0xff, ctx); in bpf_jit_emit_insn()
794 emit_mv(rd, RV_REG_T2, ctx); in bpf_jit_emit_insn()
800 emit_imm(rd, imm, ctx); in bpf_jit_emit_insn()
802 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
809 emit_addi(rd, rd, imm, ctx); in bpf_jit_emit_insn()
812 emit_add(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
815 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
820 emit_addi(rd, rd, -imm, ctx); in bpf_jit_emit_insn()
823 emit_sub(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
826 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
831 emit_andi(rd, rd, imm, ctx); in bpf_jit_emit_insn()
834 emit_and(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
837 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
842 emit(rv_ori(rd, rd, imm), ctx); in bpf_jit_emit_insn()
845 emit_or(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
848 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
853 emit(rv_xori(rd, rd, imm), ctx); in bpf_jit_emit_insn()
856 emit_xor(rd, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
859 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
864 emit(is64 ? rv_mul(rd, rd, RV_REG_T1) : in bpf_jit_emit_insn()
865 rv_mulw(rd, rd, RV_REG_T1), ctx); in bpf_jit_emit_insn()
867 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
872 emit(is64 ? rv_divu(rd, rd, RV_REG_T1) : in bpf_jit_emit_insn()
873 rv_divuw(rd, rd, RV_REG_T1), ctx); in bpf_jit_emit_insn()
875 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
880 emit(is64 ? rv_remu(rd, rd, RV_REG_T1) : in bpf_jit_emit_insn()
881 rv_remuw(rd, rd, RV_REG_T1), ctx); in bpf_jit_emit_insn()
883 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
887 emit_slli(rd, rd, imm, ctx); in bpf_jit_emit_insn()
890 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
895 emit_srli(rd, rd, imm, ctx); in bpf_jit_emit_insn()
897 emit(rv_srliw(rd, rd, imm), ctx); in bpf_jit_emit_insn()
900 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
905 emit_srai(rd, rd, imm, ctx); in bpf_jit_emit_insn()
907 emit(rv_sraiw(rd, rd, imm), ctx); in bpf_jit_emit_insn()
910 emit_zext_32(rd, ctx); in bpf_jit_emit_insn()
948 emit_sext_32_rd_rs(&rd, &rs, ctx); in bpf_jit_emit_insn()
950 emit_zext_32_rd_rs(&rd, &rs, ctx); in bpf_jit_emit_insn()
960 emit_and(RV_REG_T1, rd, rs, ctx); in bpf_jit_emit_insn()
964 emit_branch(BPF_OP(code), rd, rs, rvoff, ctx); in bpf_jit_emit_insn()
1000 emit_sext_32_rd(&rd, ctx); in bpf_jit_emit_insn()
1002 emit_zext_32_rd_t1(&rd, ctx); in bpf_jit_emit_insn()
1008 emit_branch(BPF_OP(code), rd, rs, rvoff, ctx); in bpf_jit_emit_insn()
1016 emit_andi(RV_REG_T1, rd, imm, ctx); in bpf_jit_emit_insn()
1019 emit_and(RV_REG_T1, rd, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1074 ret = emit_addr(rd, imm64, extra_pass, ctx); in bpf_jit_emit_insn()
1078 emit_imm(rd, imm64, ctx); in bpf_jit_emit_insn()
1100 emit(rv_lbu(rd, off, rs), ctx); in bpf_jit_emit_insn()
1108 emit(rv_lbu(rd, 0, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1116 emit(rv_lhu(rd, off, rs), ctx); in bpf_jit_emit_insn()
1124 emit(rv_lhu(rd, 0, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1132 emit(rv_lwu(rd, off, rs), ctx); in bpf_jit_emit_insn()
1140 emit(rv_lwu(rd, 0, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1148 emit_ld(rd, off, rs, ctx); in bpf_jit_emit_insn()
1156 emit_ld(rd, 0, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1161 ret = add_exception_handler(insn, ctx, rd, insn_len); in bpf_jit_emit_insn()
1174 emit(rv_sb(rd, off, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1179 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1186 emit(rv_sh(rd, off, RV_REG_T1), ctx); in bpf_jit_emit_insn()
1191 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1197 emit_sw(rd, off, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1202 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1208 emit_sd(rd, off, RV_REG_T1, ctx); in bpf_jit_emit_insn()
1213 emit_add(RV_REG_T2, RV_REG_T2, rd, ctx); in bpf_jit_emit_insn()
1220 emit(rv_sb(rd, off, rs), ctx); in bpf_jit_emit_insn()
1225 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1230 emit(rv_sh(rd, off, rs), ctx); in bpf_jit_emit_insn()
1235 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1240 emit_sw(rd, off, rs, ctx); in bpf_jit_emit_insn()
1245 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1250 emit_sd(rd, off, rs, ctx); in bpf_jit_emit_insn()
1255 emit_add(RV_REG_T1, RV_REG_T1, rd, ctx); in bpf_jit_emit_insn()
1260 emit_atomic(rd, rs, off, imm, in bpf_jit_emit_insn()