Lines Matching refs:rs2

241 static inline u32 rv_r_insn(u8 funct7, u8 rs2, u8 rs1, u8 funct3, u8 rd,  in rv_r_insn()  argument
244 return (funct7 << 25) | (rs2 << 20) | (rs1 << 15) | (funct3 << 12) | in rv_r_insn()
254 static inline u32 rv_s_insn(u16 imm11_0, u8 rs2, u8 rs1, u8 funct3, u8 opcode) in rv_s_insn() argument
258 return (imm11_5 << 25) | (rs2 << 20) | (rs1 << 15) | (funct3 << 12) | in rv_s_insn()
262 static inline u32 rv_b_insn(u16 imm12_1, u8 rs2, u8 rs1, u8 funct3, u8 opcode) in rv_b_insn() argument
267 return (imm12 << 25) | (rs2 << 20) | (rs1 << 15) | (funct3 << 12) | in rv_b_insn()
286 static inline u32 rv_amo_insn(u8 funct5, u8 aq, u8 rl, u8 rs2, u8 rs1, 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()
309 static inline u16 rv_css_insn(u8 funct3, u32 uimm, u8 rs2, u8 op) in rv_css_insn() argument
311 return (funct3 << 13) | (uimm << 7) | (rs2 << 2) | op; in rv_css_insn()
326 static inline u16 rv_cs_insn(u8 funct3, u32 imm_hi, u8 rs1, u32 imm_lo, u8 rs2, in rv_cs_insn() argument
330 (imm_lo << 5) | ((rs2 & 0x7) << 2) | op; in rv_cs_insn()
333 static inline u16 rv_ca_insn(u8 funct6, u8 rd, u8 funct2, u8 rs2, u8 op) in rv_ca_insn() argument
336 ((rs2 & 0x7) << 2) | op; in rv_ca_insn()
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()
479 static inline u32 rv_beq(u8 rs1, u8 rs2, u16 imm12_1) in rv_beq() argument
481 return rv_b_insn(imm12_1, rs2, rs1, 0, 0x63); in rv_beq()
484 static inline u32 rv_bne(u8 rs1, u8 rs2, u16 imm12_1) in rv_bne() argument
486 return rv_b_insn(imm12_1, rs2, rs1, 1, 0x63); in rv_bne()
489 static inline u32 rv_bltu(u8 rs1, u8 rs2, u16 imm12_1) in rv_bltu() argument
491 return rv_b_insn(imm12_1, rs2, rs1, 6, 0x63); in rv_bltu()
494 static inline u32 rv_bgtu(u8 rs1, u8 rs2, u16 imm12_1) in rv_bgtu() argument
496 return rv_bltu(rs2, rs1, imm12_1); in rv_bgtu()
499 static inline u32 rv_bgeu(u8 rs1, u8 rs2, u16 imm12_1) in rv_bgeu() argument
501 return rv_b_insn(imm12_1, rs2, rs1, 7, 0x63); in rv_bgeu()
504 static inline u32 rv_bleu(u8 rs1, u8 rs2, u16 imm12_1) in rv_bleu() argument
506 return rv_bgeu(rs2, rs1, imm12_1); in rv_bleu()
509 static inline u32 rv_blt(u8 rs1, u8 rs2, u16 imm12_1) in rv_blt() argument
511 return rv_b_insn(imm12_1, rs2, rs1, 4, 0x63); in rv_blt()
514 static inline u32 rv_bgt(u8 rs1, u8 rs2, u16 imm12_1) in rv_bgt() argument
516 return rv_blt(rs2, rs1, imm12_1); in rv_bgt()
519 static inline u32 rv_bge(u8 rs1, u8 rs2, u16 imm12_1) in rv_bge() argument
521 return rv_b_insn(imm12_1, rs2, rs1, 5, 0x63); in rv_bge()
524 static inline u32 rv_ble(u8 rs1, u8 rs2, u16 imm12_1) in rv_ble() argument
526 return rv_bge(rs2, rs1, imm12_1); in rv_ble()
554 static inline u32 rv_sb(u8 rs1, u16 imm11_0, u8 rs2) in rv_sb() argument
556 return rv_s_insn(imm11_0, rs2, rs1, 0, 0x23); in rv_sb()
559 static inline u32 rv_sh(u8 rs1, u16 imm11_0, u8 rs2) in rv_sh() argument
561 return rv_s_insn(imm11_0, rs2, rs1, 1, 0x23); in rv_sh()
564 static inline u32 rv_sw(u8 rs1, u16 imm11_0, u8 rs2) in rv_sw() argument
566 return rv_s_insn(imm11_0, rs2, rs1, 2, 0x23); in rv_sw()
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()
636 static inline u16 rvc_sw(u8 rs1, u32 imm7, u8 rs2) in rvc_sw() argument
642 return rv_cs_insn(0x6, imm_hi, rs1, imm_lo, rs2, 0x0); in rvc_sw()
737 static inline u16 rvc_swsp(u32 imm8, u8 rs2) in rvc_swsp() argument
742 return rv_css_insn(0x6, imm, rs2, 0x2); in rvc_swsp()
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()
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()
872 static inline u32 rv_sd(u8 rs1, u16 imm11_0, u8 rs2) in rv_sd() argument
874 return rv_s_insn(imm11_0, rs2, rs1, 3, 0x23); in rv_sd()
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()
923 static inline u16 rvc_sd(u8 rs1, u32 imm8, u8 rs2) in rvc_sd() argument
929 return rv_cs_insn(0x7, imm_hi, rs1, imm_lo, rs2, 0x0); in rvc_sd()
950 static inline u16 rvc_sdsp(u32 imm9, u8 rs2) in rvc_sdsp() argument
955 return rv_css_insn(0x7, imm, rs2, 0x2); in rvc_sdsp()
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()
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()
1099 static inline void emit_sw(u8 rs1, s32 off, u8 rs2, struct rv_jit_context *ctx) in emit_sw() argument
1102 emitc(rvc_swsp(off, rs2), ctx); in emit_sw()
1103 else if (rvc_enabled() && is_creg(rs1) && is_creg(rs2) && is_7b_uint(off) && !(off & 0x3)) in emit_sw()
1104 emitc(rvc_sw(rs1, off, rs2), ctx); in emit_sw()
1106 emit(rv_sw(rs1, off, rs2), ctx); in emit_sw()
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()
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()
1128 emit_add(rd, rd, rs2, ctx); in emit_sh3add()
1152 static inline void emit_sd(u8 rs1, s32 off, u8 rs2, struct rv_jit_context *ctx) in emit_sd() argument
1155 emitc(rvc_sdsp(off, rs2), ctx); in emit_sd()
1156 else if (rvc_enabled() && is_creg(rs1) && is_creg(rs2) && is_8b_uint(off) && !(off & 0x7)) in emit_sd()
1157 emitc(rvc_sd(rs1, off, rs2), ctx); in emit_sd()
1159 emit(rv_sd(rs1, off, rs2), ctx); in emit_sd()
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()