Lines Matching refs:rd
241 static inline u32 rv_r_insn(u8 funct7, u8 rs2, u8 rs1, u8 funct3, u8 rd, in rv_r_insn() argument
245 (rd << 7) | opcode; in rv_r_insn()
248 static inline u32 rv_i_insn(u16 imm11_0, u8 rs1, u8 funct3, u8 rd, u8 opcode) in rv_i_insn() argument
250 return (imm11_0 << 20) | (rs1 << 15) | (funct3 << 12) | (rd << 7) | in rv_i_insn()
271 static inline u32 rv_u_insn(u32 imm31_12, u8 rd, u8 opcode) in rv_u_insn() argument
273 return (imm31_12 << 12) | (rd << 7) | opcode; in rv_u_insn()
276 static inline u32 rv_j_insn(u32 imm20_1, u8 rd, u8 opcode) in rv_j_insn() argument
283 return (imm << 12) | (rd << 7) | opcode; in rv_j_insn()
287 u8 funct3, u8 rd, u8 opcode) in rv_amo_insn() argument
291 return rv_r_insn(funct7, rs2, rs1, funct3, rd, opcode); in rv_amo_insn()
296 static inline u16 rv_cr_insn(u8 funct4, u8 rd, u8 rs2, u8 op) in rv_cr_insn() argument
298 return (funct4 << 12) | (rd << 7) | (rs2 << 2) | op; in rv_cr_insn()
301 static inline u16 rv_ci_insn(u8 funct3, u32 imm6, u8 rd, u8 op) in rv_ci_insn() argument
306 return (funct3 << 13) | (rd << 7) | op | imm; in rv_ci_insn()
314 static inline u16 rv_ciw_insn(u8 funct3, u32 uimm, u8 rd, u8 op) in rv_ciw_insn() argument
316 return (funct3 << 13) | (uimm << 5) | ((rd & 0x7) << 2) | op; in rv_ciw_insn()
319 static inline u16 rv_cl_insn(u8 funct3, u32 imm_hi, u8 rs1, u32 imm_lo, u8 rd, in rv_cl_insn() argument
323 (imm_lo << 5) | ((rd & 0x7) << 2) | op; in rv_cl_insn()
333 static inline u16 rv_ca_insn(u8 funct6, u8 rd, u8 funct2, u8 rs2, u8 op) in rv_ca_insn() argument
335 return (funct6 << 10) | ((rd & 0x7) << 7) | (funct2 << 5) | in rv_ca_insn()
339 static inline u16 rv_cb_insn(u8 funct3, u32 imm6, u8 funct2, u8 rd, u8 op) in rv_cb_insn() argument
344 return (funct3 << 13) | (funct2 << 10) | ((rd & 0x7) << 7) | op | imm; in rv_cb_insn()
349 static inline u32 rv_addi(u8 rd, u8 rs1, u16 imm11_0) in rv_addi() argument
351 return rv_i_insn(imm11_0, rs1, 0, rd, 0x13); in rv_addi()
354 static inline u32 rv_andi(u8 rd, u8 rs1, u16 imm11_0) in rv_andi() argument
356 return rv_i_insn(imm11_0, rs1, 7, rd, 0x13); in rv_andi()
359 static inline u32 rv_ori(u8 rd, u8 rs1, u16 imm11_0) in rv_ori() argument
361 return rv_i_insn(imm11_0, rs1, 6, rd, 0x13); in rv_ori()
364 static inline u32 rv_xori(u8 rd, u8 rs1, u16 imm11_0) in rv_xori() argument
366 return rv_i_insn(imm11_0, rs1, 4, rd, 0x13); in rv_xori()
369 static inline u32 rv_slli(u8 rd, u8 rs1, u16 imm11_0) in rv_slli() argument
371 return rv_i_insn(imm11_0, rs1, 1, rd, 0x13); in rv_slli()
374 static inline u32 rv_srli(u8 rd, u8 rs1, u16 imm11_0) in rv_srli() argument
376 return rv_i_insn(imm11_0, rs1, 5, rd, 0x13); in rv_srli()
379 static inline u32 rv_srai(u8 rd, u8 rs1, u16 imm11_0) in rv_srai() argument
381 return rv_i_insn(0x400 | imm11_0, rs1, 5, rd, 0x13); in rv_srai()
384 static inline u32 rv_lui(u8 rd, u32 imm31_12) in rv_lui() argument
386 return rv_u_insn(imm31_12, rd, 0x37); in rv_lui()
389 static inline u32 rv_auipc(u8 rd, u32 imm31_12) in rv_auipc() argument
391 return rv_u_insn(imm31_12, rd, 0x17); in rv_auipc()
394 static inline u32 rv_add(u8 rd, u8 rs1, u8 rs2) in rv_add() argument
396 return rv_r_insn(0, rs2, rs1, 0, rd, 0x33); in rv_add()
399 static inline u32 rv_sub(u8 rd, u8 rs1, u8 rs2) in rv_sub() argument
401 return rv_r_insn(0x20, rs2, rs1, 0, rd, 0x33); in rv_sub()
404 static inline u32 rv_sltu(u8 rd, u8 rs1, u8 rs2) in rv_sltu() argument
406 return rv_r_insn(0, rs2, rs1, 3, rd, 0x33); in rv_sltu()
409 static inline u32 rv_and(u8 rd, u8 rs1, u8 rs2) in rv_and() argument
411 return rv_r_insn(0, rs2, rs1, 7, rd, 0x33); in rv_and()
414 static inline u32 rv_or(u8 rd, u8 rs1, u8 rs2) in rv_or() argument
416 return rv_r_insn(0, rs2, rs1, 6, rd, 0x33); in rv_or()
419 static inline u32 rv_xor(u8 rd, u8 rs1, u8 rs2) in rv_xor() argument
421 return rv_r_insn(0, rs2, rs1, 4, rd, 0x33); in rv_xor()
424 static inline u32 rv_sll(u8 rd, u8 rs1, u8 rs2) in rv_sll() argument
426 return rv_r_insn(0, rs2, rs1, 1, rd, 0x33); in rv_sll()
429 static inline u32 rv_srl(u8 rd, u8 rs1, u8 rs2) in rv_srl() argument
431 return rv_r_insn(0, rs2, rs1, 5, rd, 0x33); in rv_srl()
434 static inline u32 rv_sra(u8 rd, u8 rs1, u8 rs2) in rv_sra() argument
436 return rv_r_insn(0x20, rs2, rs1, 5, rd, 0x33); in rv_sra()
439 static inline u32 rv_mul(u8 rd, u8 rs1, u8 rs2) in rv_mul() argument
441 return rv_r_insn(1, rs2, rs1, 0, rd, 0x33); in rv_mul()
444 static inline u32 rv_mulhu(u8 rd, u8 rs1, u8 rs2) in rv_mulhu() argument
446 return rv_r_insn(1, rs2, rs1, 3, rd, 0x33); in rv_mulhu()
449 static inline u32 rv_div(u8 rd, u8 rs1, u8 rs2) in rv_div() argument
451 return rv_r_insn(1, rs2, rs1, 4, rd, 0x33); in rv_div()
454 static inline u32 rv_divu(u8 rd, u8 rs1, u8 rs2) in rv_divu() argument
456 return rv_r_insn(1, rs2, rs1, 5, rd, 0x33); in rv_divu()
459 static inline u32 rv_rem(u8 rd, u8 rs1, u8 rs2) in rv_rem() argument
461 return rv_r_insn(1, rs2, rs1, 6, rd, 0x33); in rv_rem()
464 static inline u32 rv_remu(u8 rd, u8 rs1, u8 rs2) in rv_remu() argument
466 return rv_r_insn(1, rs2, rs1, 7, rd, 0x33); in rv_remu()
469 static inline u32 rv_jal(u8 rd, u32 imm20_1) in rv_jal() argument
471 return rv_j_insn(imm20_1, rd, 0x6f); in rv_jal()
474 static inline u32 rv_jalr(u8 rd, u8 rs1, u16 imm11_0) in rv_jalr() argument
476 return rv_i_insn(imm11_0, rs1, 0, rd, 0x67); in rv_jalr()
529 static inline u32 rv_lb(u8 rd, u16 imm11_0, u8 rs1) in rv_lb() argument
531 return rv_i_insn(imm11_0, rs1, 0, rd, 0x03); in rv_lb()
534 static inline u32 rv_lh(u8 rd, u16 imm11_0, u8 rs1) in rv_lh() argument
536 return rv_i_insn(imm11_0, rs1, 1, rd, 0x03); in rv_lh()
539 static inline u32 rv_lw(u8 rd, u16 imm11_0, u8 rs1) in rv_lw() argument
541 return rv_i_insn(imm11_0, rs1, 2, rd, 0x03); in rv_lw()
544 static inline u32 rv_lbu(u8 rd, u16 imm11_0, u8 rs1) in rv_lbu() argument
546 return rv_i_insn(imm11_0, rs1, 4, rd, 0x03); in rv_lbu()
549 static inline u32 rv_lhu(u8 rd, u16 imm11_0, u8 rs1) in rv_lhu() argument
551 return rv_i_insn(imm11_0, rs1, 5, rd, 0x03); in rv_lhu()
569 static inline u32 rv_amoadd_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoadd_w() argument
571 return rv_amo_insn(0, aq, rl, rs2, rs1, 2, rd, 0x2f); in rv_amoadd_w()
574 static inline u32 rv_amoand_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoand_w() argument
576 return rv_amo_insn(0xc, aq, rl, rs2, rs1, 2, rd, 0x2f); in rv_amoand_w()
579 static inline u32 rv_amoor_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoor_w() argument
581 return rv_amo_insn(0x8, aq, rl, rs2, rs1, 2, rd, 0x2f); in rv_amoor_w()
584 static inline u32 rv_amoxor_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoxor_w() argument
586 return rv_amo_insn(0x4, aq, rl, rs2, rs1, 2, rd, 0x2f); in rv_amoxor_w()
589 static inline u32 rv_amoswap_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoswap_w() argument
591 return rv_amo_insn(0x1, aq, rl, rs2, rs1, 2, rd, 0x2f); in rv_amoswap_w()
594 static inline u32 rv_lr_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_lr_w() argument
596 return rv_amo_insn(0x2, aq, rl, rs2, rs1, 2, rd, 0x2f); in rv_lr_w()
599 static inline u32 rv_sc_w(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_sc_w() argument
601 return rv_amo_insn(0x3, aq, rl, rs2, rs1, 2, rd, 0x2f); in rv_sc_w()
618 static inline u16 rvc_addi4spn(u8 rd, u32 imm10) in rvc_addi4spn() argument
624 return rv_ciw_insn(0x0, imm, rd, 0x0); in rvc_addi4spn()
627 static inline u16 rvc_lw(u8 rd, u32 imm7, u8 rs1) in rvc_lw() argument
633 return rv_cl_insn(0x2, imm_hi, rs1, imm_lo, rd, 0x0); in rvc_lw()
645 static inline u16 rvc_addi(u8 rd, u32 imm6) in rvc_addi() argument
647 return rv_ci_insn(0, imm6, rd, 0x1); in rvc_addi()
650 static inline u16 rvc_li(u8 rd, u32 imm6) in rvc_li() argument
652 return rv_ci_insn(0x2, imm6, rd, 0x1); in rvc_li()
664 static inline u16 rvc_lui(u8 rd, u32 imm6) in rvc_lui() argument
666 return rv_ci_insn(0x3, imm6, rd, 0x1); in rvc_lui()
669 static inline u16 rvc_srli(u8 rd, u32 imm6) in rvc_srli() argument
671 return rv_cb_insn(0x4, imm6, 0, rd, 0x1); in rvc_srli()
674 static inline u16 rvc_srai(u8 rd, u32 imm6) in rvc_srai() argument
676 return rv_cb_insn(0x4, imm6, 0x1, rd, 0x1); in rvc_srai()
679 static inline u16 rvc_andi(u8 rd, u32 imm6) in rvc_andi() argument
681 return rv_cb_insn(0x4, imm6, 0x2, rd, 0x1); in rvc_andi()
684 static inline u16 rvc_sub(u8 rd, u8 rs) in rvc_sub() argument
686 return rv_ca_insn(0x23, rd, 0, rs, 0x1); in rvc_sub()
689 static inline u16 rvc_xor(u8 rd, u8 rs) in rvc_xor() argument
691 return rv_ca_insn(0x23, rd, 0x1, rs, 0x1); in rvc_xor()
694 static inline u16 rvc_or(u8 rd, u8 rs) in rvc_or() argument
696 return rv_ca_insn(0x23, rd, 0x2, rs, 0x1); in rvc_or()
699 static inline u16 rvc_and(u8 rd, u8 rs) in rvc_and() argument
701 return rv_ca_insn(0x23, rd, 0x3, rs, 0x1); in rvc_and()
704 static inline u16 rvc_slli(u8 rd, u32 imm6) in rvc_slli() argument
706 return rv_ci_insn(0, imm6, rd, 0x2); in rvc_slli()
709 static inline u16 rvc_lwsp(u8 rd, u32 imm8) in rvc_lwsp() argument
714 return rv_ci_insn(0x2, imm, rd, 0x2); in rvc_lwsp()
722 static inline u16 rvc_mv(u8 rd, u8 rs) in rvc_mv() argument
724 return rv_cr_insn(0x8, rd, rs, 0x2); in rvc_mv()
732 static inline u16 rvc_add(u8 rd, u8 rs) in rvc_add() argument
734 return rv_cr_insn(0x9, rd, rs, 0x2); in rvc_add()
746 static inline u32 rvzba_sh2add(u8 rd, u8 rs1, u8 rs2) in rvzba_sh2add() argument
748 return rv_r_insn(0x10, rs2, rs1, 0x4, rd, 0x33); in rvzba_sh2add()
751 static inline u32 rvzba_sh3add(u8 rd, u8 rs1, u8 rs2) in rvzba_sh3add() argument
753 return rv_r_insn(0x10, rs2, rs1, 0x6, rd, 0x33); in rvzba_sh3add()
757 static inline u32 rvzbb_sextb(u8 rd, u8 rs1) in rvzbb_sextb() argument
759 return rv_i_insn(0x604, rs1, 1, rd, 0x13); in rvzbb_sextb()
762 static inline u32 rvzbb_sexth(u8 rd, u8 rs1) in rvzbb_sexth() argument
764 return rv_i_insn(0x605, rs1, 1, rd, 0x13); in rvzbb_sexth()
767 static inline u32 rvzbb_zexth(u8 rd, u8 rs) in rvzbb_zexth() argument
770 return rv_i_insn(0x80, rs, 4, rd, 0x3b); in rvzbb_zexth()
772 return rv_i_insn(0x80, rs, 4, rd, 0x33); in rvzbb_zexth()
775 static inline u32 rvzbb_rev8(u8 rd, u8 rs) in rvzbb_rev8() argument
778 return rv_i_insn(0x6b8, rs, 5, rd, 0x13); in rvzbb_rev8()
780 return rv_i_insn(0x698, rs, 5, rd, 0x13); in rvzbb_rev8()
792 static inline u32 rv_addiw(u8 rd, u8 rs1, u16 imm11_0) in rv_addiw() argument
794 return rv_i_insn(imm11_0, rs1, 0, rd, 0x1b); in rv_addiw()
797 static inline u32 rv_slliw(u8 rd, u8 rs1, u16 imm11_0) in rv_slliw() argument
799 return rv_i_insn(imm11_0, rs1, 1, rd, 0x1b); in rv_slliw()
802 static inline u32 rv_srliw(u8 rd, u8 rs1, u16 imm11_0) in rv_srliw() argument
804 return rv_i_insn(imm11_0, rs1, 5, rd, 0x1b); in rv_srliw()
807 static inline u32 rv_sraiw(u8 rd, u8 rs1, u16 imm11_0) in rv_sraiw() argument
809 return rv_i_insn(0x400 | imm11_0, rs1, 5, rd, 0x1b); in rv_sraiw()
812 static inline u32 rv_addw(u8 rd, u8 rs1, u8 rs2) in rv_addw() argument
814 return rv_r_insn(0, rs2, rs1, 0, rd, 0x3b); in rv_addw()
817 static inline u32 rv_subw(u8 rd, u8 rs1, u8 rs2) in rv_subw() argument
819 return rv_r_insn(0x20, rs2, rs1, 0, rd, 0x3b); in rv_subw()
822 static inline u32 rv_sllw(u8 rd, u8 rs1, u8 rs2) in rv_sllw() argument
824 return rv_r_insn(0, rs2, rs1, 1, rd, 0x3b); in rv_sllw()
827 static inline u32 rv_srlw(u8 rd, u8 rs1, u8 rs2) in rv_srlw() argument
829 return rv_r_insn(0, rs2, rs1, 5, rd, 0x3b); in rv_srlw()
832 static inline u32 rv_sraw(u8 rd, u8 rs1, u8 rs2) in rv_sraw() argument
834 return rv_r_insn(0x20, rs2, rs1, 5, rd, 0x3b); in rv_sraw()
837 static inline u32 rv_mulw(u8 rd, u8 rs1, u8 rs2) in rv_mulw() argument
839 return rv_r_insn(1, rs2, rs1, 0, rd, 0x3b); in rv_mulw()
842 static inline u32 rv_divw(u8 rd, u8 rs1, u8 rs2) in rv_divw() argument
844 return rv_r_insn(1, rs2, rs1, 4, rd, 0x3b); in rv_divw()
847 static inline u32 rv_divuw(u8 rd, u8 rs1, u8 rs2) in rv_divuw() argument
849 return rv_r_insn(1, rs2, rs1, 5, rd, 0x3b); in rv_divuw()
852 static inline u32 rv_remw(u8 rd, u8 rs1, u8 rs2) in rv_remw() argument
854 return rv_r_insn(1, rs2, rs1, 6, rd, 0x3b); in rv_remw()
857 static inline u32 rv_remuw(u8 rd, u8 rs1, u8 rs2) in rv_remuw() argument
859 return rv_r_insn(1, rs2, rs1, 7, rd, 0x3b); in rv_remuw()
862 static inline u32 rv_ld(u8 rd, u16 imm11_0, u8 rs1) in rv_ld() argument
864 return rv_i_insn(imm11_0, rs1, 3, rd, 0x03); in rv_ld()
867 static inline u32 rv_lwu(u8 rd, u16 imm11_0, u8 rs1) in rv_lwu() argument
869 return rv_i_insn(imm11_0, rs1, 6, rd, 0x03); in rv_lwu()
877 static inline u32 rv_amoadd_d(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoadd_d() argument
879 return rv_amo_insn(0, aq, rl, rs2, rs1, 3, rd, 0x2f); in rv_amoadd_d()
882 static inline u32 rv_amoand_d(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoand_d() argument
884 return rv_amo_insn(0xc, aq, rl, rs2, rs1, 3, rd, 0x2f); in rv_amoand_d()
887 static inline u32 rv_amoor_d(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoor_d() argument
889 return rv_amo_insn(0x8, aq, rl, rs2, rs1, 3, rd, 0x2f); in rv_amoor_d()
892 static inline u32 rv_amoxor_d(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoxor_d() argument
894 return rv_amo_insn(0x4, aq, rl, rs2, rs1, 3, rd, 0x2f); in rv_amoxor_d()
897 static inline u32 rv_amoswap_d(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_amoswap_d() argument
899 return rv_amo_insn(0x1, aq, rl, rs2, rs1, 3, rd, 0x2f); in rv_amoswap_d()
902 static inline u32 rv_lr_d(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_lr_d() argument
904 return rv_amo_insn(0x2, aq, rl, rs2, rs1, 3, rd, 0x2f); in rv_lr_d()
907 static inline u32 rv_sc_d(u8 rd, u8 rs2, u8 rs1, u8 aq, u8 rl) in rv_sc_d() argument
909 return rv_amo_insn(0x3, aq, rl, rs2, rs1, 3, rd, 0x2f); in rv_sc_d()
914 static inline u16 rvc_ld(u8 rd, u32 imm8, u8 rs1) in rvc_ld() argument
920 return rv_cl_insn(0x3, imm_hi, rs1, imm_lo, rd, 0x0); in rvc_ld()
932 static inline u16 rvc_subw(u8 rd, u8 rs) in rvc_subw() argument
934 return rv_ca_insn(0x27, rd, 0, rs, 0x1); in rvc_subw()
937 static inline u16 rvc_addiw(u8 rd, u32 imm6) in rvc_addiw() argument
939 return rv_ci_insn(0x1, imm6, rd, 0x1); in rvc_addiw()
942 static inline u16 rvc_ldsp(u8 rd, u32 imm9) in rvc_ldsp() argument
947 return rv_ci_insn(0x3, imm, rd, 0x2); in rvc_ldsp()
960 static inline u32 rvzba_zextw(u8 rd, u8 rs1) in rvzba_zextw() argument
963 return rv_r_insn(0x04, RV_REG_ZERO, rs1, 0, rd, 0x3b); in rvzba_zextw()
970 static inline void emit_jalr(u8 rd, u8 rs, s32 imm, struct rv_jit_context *ctx) in emit_jalr() argument
972 if (rvc_enabled() && rd == RV_REG_RA && rs && !imm) in emit_jalr()
974 else if (rvc_enabled() && !rd && rs && !imm) in emit_jalr()
977 emit(rv_jalr(rd, rs, imm), ctx); in emit_jalr()
980 static inline void emit_mv(u8 rd, u8 rs, struct rv_jit_context *ctx) in emit_mv() argument
982 if (rvc_enabled() && rd && rs) in emit_mv()
983 emitc(rvc_mv(rd, rs), ctx); in emit_mv()
985 emit(rv_addi(rd, rs, 0), ctx); in emit_mv()
988 static inline void emit_add(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx) in emit_add() argument
990 if (rvc_enabled() && rd && rd == rs1 && rs2) in emit_add()
991 emitc(rvc_add(rd, rs2), ctx); in emit_add()
993 emit(rv_add(rd, rs1, rs2), ctx); in emit_add()
996 static inline void emit_addi(u8 rd, u8 rs, s32 imm, struct rv_jit_context *ctx) in emit_addi() argument
998 if (rvc_enabled() && rd == RV_REG_SP && rd == rs && is_10b_int(imm) && imm && !(imm & 0xf)) in emit_addi()
1000 else if (rvc_enabled() && is_creg(rd) && rs == RV_REG_SP && is_10b_uint(imm) && in emit_addi()
1002 emitc(rvc_addi4spn(rd, imm), ctx); in emit_addi()
1003 else if (rvc_enabled() && rd && rd == rs && imm && is_6b_int(imm)) in emit_addi()
1004 emitc(rvc_addi(rd, imm), ctx); in emit_addi()
1006 emit(rv_addi(rd, rs, imm), ctx); in emit_addi()
1009 static inline void emit_li(u8 rd, s32 imm, struct rv_jit_context *ctx) in emit_li() argument
1011 if (rvc_enabled() && rd && is_6b_int(imm)) in emit_li()
1012 emitc(rvc_li(rd, imm), ctx); in emit_li()
1014 emit(rv_addi(rd, RV_REG_ZERO, imm), ctx); in emit_li()
1017 static inline void emit_lui(u8 rd, s32 imm, struct rv_jit_context *ctx) in emit_lui() argument
1019 if (rvc_enabled() && rd && rd != RV_REG_SP && is_6b_int(imm) && imm) in emit_lui()
1020 emitc(rvc_lui(rd, imm), ctx); in emit_lui()
1022 emit(rv_lui(rd, imm), ctx); in emit_lui()
1025 static inline void emit_slli(u8 rd, u8 rs, s32 imm, struct rv_jit_context *ctx) in emit_slli() argument
1027 if (rvc_enabled() && rd && rd == rs && imm && (u32)imm < __riscv_xlen) in emit_slli()
1028 emitc(rvc_slli(rd, imm), ctx); in emit_slli()
1030 emit(rv_slli(rd, rs, imm), ctx); in emit_slli()
1033 static inline void emit_andi(u8 rd, u8 rs, s32 imm, struct rv_jit_context *ctx) in emit_andi() argument
1035 if (rvc_enabled() && is_creg(rd) && rd == rs && is_6b_int(imm)) in emit_andi()
1036 emitc(rvc_andi(rd, imm), ctx); in emit_andi()
1038 emit(rv_andi(rd, rs, imm), ctx); in emit_andi()
1041 static inline void emit_srli(u8 rd, u8 rs, s32 imm, struct rv_jit_context *ctx) in emit_srli() argument
1043 if (rvc_enabled() && is_creg(rd) && rd == rs && imm && (u32)imm < __riscv_xlen) in emit_srli()
1044 emitc(rvc_srli(rd, imm), ctx); in emit_srli()
1046 emit(rv_srli(rd, rs, imm), ctx); in emit_srli()
1049 static inline void emit_srai(u8 rd, u8 rs, s32 imm, struct rv_jit_context *ctx) in emit_srai() argument
1051 if (rvc_enabled() && is_creg(rd) && rd == rs && imm && (u32)imm < __riscv_xlen) in emit_srai()
1052 emitc(rvc_srai(rd, imm), ctx); in emit_srai()
1054 emit(rv_srai(rd, rs, imm), ctx); in emit_srai()
1057 static inline void emit_sub(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx) in emit_sub() argument
1059 if (rvc_enabled() && is_creg(rd) && rd == rs1 && is_creg(rs2)) in emit_sub()
1060 emitc(rvc_sub(rd, rs2), ctx); in emit_sub()
1062 emit(rv_sub(rd, rs1, rs2), ctx); in emit_sub()
1065 static inline void emit_or(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx) in emit_or() argument
1067 if (rvc_enabled() && is_creg(rd) && rd == rs1 && is_creg(rs2)) in emit_or()
1068 emitc(rvc_or(rd, rs2), ctx); in emit_or()
1070 emit(rv_or(rd, rs1, rs2), ctx); in emit_or()
1073 static inline void emit_and(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx) in emit_and() argument
1075 if (rvc_enabled() && is_creg(rd) && rd == rs1 && is_creg(rs2)) in emit_and()
1076 emitc(rvc_and(rd, rs2), ctx); in emit_and()
1078 emit(rv_and(rd, rs1, rs2), ctx); in emit_and()
1081 static inline void emit_xor(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx) in emit_xor() argument
1083 if (rvc_enabled() && is_creg(rd) && rd == rs1 && is_creg(rs2)) in emit_xor()
1084 emitc(rvc_xor(rd, rs2), ctx); in emit_xor()
1086 emit(rv_xor(rd, rs1, rs2), ctx); in emit_xor()
1089 static inline void emit_lw(u8 rd, s32 off, u8 rs1, struct rv_jit_context *ctx) in emit_lw() argument
1091 if (rvc_enabled() && rs1 == RV_REG_SP && rd && is_8b_uint(off) && !(off & 0x3)) in emit_lw()
1092 emitc(rvc_lwsp(rd, off), ctx); in emit_lw()
1093 else if (rvc_enabled() && is_creg(rd) && is_creg(rs1) && is_7b_uint(off) && !(off & 0x3)) in emit_lw()
1094 emitc(rvc_lw(rd, off, rs1), ctx); in emit_lw()
1096 emit(rv_lw(rd, off, rs1), ctx); in emit_lw()
1109 static inline void emit_sh2add(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx) in emit_sh2add() argument
1112 emit(rvzba_sh2add(rd, rs1, rs2), ctx); in emit_sh2add()
1116 emit_slli(rd, rs1, 2, ctx); in emit_sh2add()
1117 emit_add(rd, rd, rs2, ctx); in emit_sh2add()
1120 static inline void emit_sh3add(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx) in emit_sh3add() argument
1123 emit(rvzba_sh3add(rd, rs1, rs2), ctx); in emit_sh3add()
1127 emit_slli(rd, rs1, 3, ctx); in emit_sh3add()
1128 emit_add(rd, rd, rs2, ctx); in emit_sh3add()
1134 static inline void emit_addiw(u8 rd, u8 rs, s32 imm, struct rv_jit_context *ctx) in emit_addiw() argument
1136 if (rvc_enabled() && rd && rd == rs && is_6b_int(imm)) in emit_addiw()
1137 emitc(rvc_addiw(rd, imm), ctx); in emit_addiw()
1139 emit(rv_addiw(rd, rs, imm), ctx); in emit_addiw()
1142 static inline void emit_ld(u8 rd, s32 off, u8 rs1, struct rv_jit_context *ctx) in emit_ld() argument
1144 if (rvc_enabled() && rs1 == RV_REG_SP && rd && is_9b_uint(off) && !(off & 0x7)) in emit_ld()
1145 emitc(rvc_ldsp(rd, off), ctx); in emit_ld()
1146 else if (rvc_enabled() && is_creg(rd) && is_creg(rs1) && is_8b_uint(off) && !(off & 0x7)) in emit_ld()
1147 emitc(rvc_ld(rd, off, rs1), ctx); in emit_ld()
1149 emit(rv_ld(rd, off, rs1), ctx); in emit_ld()
1162 static inline void emit_subw(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx) in emit_subw() argument
1164 if (rvc_enabled() && is_creg(rd) && rd == rs1 && is_creg(rs2)) in emit_subw()
1165 emitc(rvc_subw(rd, rs2), ctx); in emit_subw()
1167 emit(rv_subw(rd, rs1, rs2), ctx); in emit_subw()
1170 static inline void emit_sextb(u8 rd, u8 rs, struct rv_jit_context *ctx) in emit_sextb() argument
1173 emit(rvzbb_sextb(rd, rs), ctx); in emit_sextb()
1177 emit_slli(rd, rs, 56, ctx); in emit_sextb()
1178 emit_srai(rd, rd, 56, ctx); in emit_sextb()
1181 static inline void emit_sexth(u8 rd, u8 rs, struct rv_jit_context *ctx) in emit_sexth() argument
1184 emit(rvzbb_sexth(rd, rs), ctx); in emit_sexth()
1188 emit_slli(rd, rs, 48, ctx); in emit_sexth()
1189 emit_srai(rd, rd, 48, ctx); in emit_sexth()
1192 static inline void emit_sextw(u8 rd, u8 rs, struct rv_jit_context *ctx) in emit_sextw() argument
1194 emit_addiw(rd, rs, 0, ctx); in emit_sextw()
1197 static inline void emit_zexth(u8 rd, u8 rs, struct rv_jit_context *ctx) in emit_zexth() argument
1200 emit(rvzbb_zexth(rd, rs), ctx); in emit_zexth()
1204 emit_slli(rd, rs, 48, ctx); in emit_zexth()
1205 emit_srli(rd, rd, 48, ctx); in emit_zexth()
1208 static inline void emit_zextw(u8 rd, u8 rs, struct rv_jit_context *ctx) in emit_zextw() argument
1211 emit(rvzba_zextw(rd, rs), ctx); in emit_zextw()
1215 emit_slli(rd, rs, 32, ctx); in emit_zextw()
1216 emit_srli(rd, rd, 32, ctx); in emit_zextw()
1219 static inline void emit_bswap(u8 rd, s32 imm, struct rv_jit_context *ctx) in emit_bswap() argument
1224 emit(rvzbb_rev8(rd, rd), ctx); in emit_bswap()
1226 emit_srli(rd, rd, bits, ctx); in emit_bswap()
1232 emit_andi(RV_REG_T1, rd, 0xff, ctx); in emit_bswap()
1235 emit_srli(rd, rd, 8, ctx); in emit_bswap()
1239 emit_andi(RV_REG_T1, rd, 0xff, ctx); in emit_bswap()
1242 emit_srli(rd, rd, 8, ctx); in emit_bswap()
1244 emit_andi(RV_REG_T1, rd, 0xff, ctx); in emit_bswap()
1247 emit_srli(rd, rd, 8, ctx); in emit_bswap()
1251 emit_andi(RV_REG_T1, rd, 0xff, ctx); in emit_bswap()
1254 emit_srli(rd, rd, 8, ctx); in emit_bswap()
1256 emit_andi(RV_REG_T1, rd, 0xff, ctx); in emit_bswap()
1259 emit_srli(rd, rd, 8, ctx); in emit_bswap()
1261 emit_andi(RV_REG_T1, rd, 0xff, ctx); in emit_bswap()
1264 emit_srli(rd, rd, 8, ctx); in emit_bswap()
1266 emit_andi(RV_REG_T1, rd, 0xff, ctx); in emit_bswap()
1269 emit_srli(rd, rd, 8, ctx); in emit_bswap()
1271 emit_andi(RV_REG_T1, rd, 0xff, ctx); in emit_bswap()
1274 emit_mv(rd, RV_REG_T2, ctx); in emit_bswap()