Lines Matching refs:rd

111 static void emit_imm(const s8 rd, s32 imm, struct rv_jit_context *ctx)  in emit_imm()  argument
117 emit(rv_lui(rd, upper), ctx); in emit_imm()
118 emit(rv_addi(rd, rd, lower), ctx); in emit_imm()
120 emit(rv_addi(rd, RV_REG_ZERO, lower), ctx); in emit_imm()
124 static void emit_imm32(const s8 *rd, s32 imm, struct rv_jit_context *ctx) in emit_imm32() argument
127 emit_imm(lo(rd), imm, ctx); in emit_imm32()
131 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in emit_imm32()
133 emit(rv_addi(hi(rd), RV_REG_ZERO, -1), ctx); in emit_imm32()
136 static void emit_imm64(const s8 *rd, s32 imm_hi, s32 imm_lo, in emit_imm64() argument
139 emit_imm(lo(rd), imm_lo, ctx); in emit_imm64()
140 emit_imm(hi(rd), imm_hi, ctx); in emit_imm64()
227 static void emit_jump_and_link(u8 rd, s32 rvoff, bool force_jalr, in emit_jump_and_link() argument
233 emit(rv_jal(rd, rvoff >> 1), ctx); in emit_jump_and_link()
240 emit(rv_jalr(rd, RV_REG_T1, lower), ctx); in emit_jump_and_link()
247 const s8 *rd = bpf_get_reg64(dst, tmp1, ctx); in emit_alu_i64() local
251 emit_imm32(rd, imm, ctx); in emit_alu_i64()
255 emit(rv_andi(lo(rd), lo(rd), imm), ctx); in emit_alu_i64()
258 emit(rv_and(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i64()
261 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in emit_alu_i64()
265 emit(rv_ori(lo(rd), lo(rd), imm), ctx); in emit_alu_i64()
268 emit(rv_or(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i64()
271 emit(rv_ori(hi(rd), RV_REG_ZERO, -1), ctx); in emit_alu_i64()
275 emit(rv_xori(lo(rd), lo(rd), imm), ctx); in emit_alu_i64()
278 emit(rv_xor(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i64()
281 emit(rv_xori(hi(rd), hi(rd), -1), ctx); in emit_alu_i64()
285 emit(rv_slli(hi(rd), lo(rd), imm - 32), ctx); in emit_alu_i64()
286 emit(rv_addi(lo(rd), RV_REG_ZERO, 0), ctx); in emit_alu_i64()
290 emit(rv_srli(RV_REG_T0, lo(rd), 32 - imm), ctx); in emit_alu_i64()
291 emit(rv_slli(hi(rd), hi(rd), imm), ctx); in emit_alu_i64()
292 emit(rv_or(hi(rd), RV_REG_T0, hi(rd)), ctx); in emit_alu_i64()
293 emit(rv_slli(lo(rd), lo(rd), imm), ctx); in emit_alu_i64()
298 emit(rv_srli(lo(rd), hi(rd), imm - 32), ctx); in emit_alu_i64()
299 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in emit_alu_i64()
303 emit(rv_slli(RV_REG_T0, hi(rd), 32 - imm), ctx); in emit_alu_i64()
304 emit(rv_srli(lo(rd), lo(rd), imm), ctx); in emit_alu_i64()
305 emit(rv_or(lo(rd), RV_REG_T0, lo(rd)), ctx); in emit_alu_i64()
306 emit(rv_srli(hi(rd), hi(rd), imm), ctx); in emit_alu_i64()
311 emit(rv_srai(lo(rd), hi(rd), imm - 32), ctx); in emit_alu_i64()
312 emit(rv_srai(hi(rd), hi(rd), 31), ctx); in emit_alu_i64()
316 emit(rv_slli(RV_REG_T0, hi(rd), 32 - imm), ctx); in emit_alu_i64()
317 emit(rv_srli(lo(rd), lo(rd), imm), ctx); in emit_alu_i64()
318 emit(rv_or(lo(rd), RV_REG_T0, lo(rd)), ctx); in emit_alu_i64()
319 emit(rv_srai(hi(rd), hi(rd), imm), ctx); in emit_alu_i64()
324 bpf_put_reg64(dst, rd, ctx); in emit_alu_i64()
331 const s8 *rd = bpf_get_reg32(dst, tmp1, ctx); in emit_alu_i32() local
335 emit_imm(lo(rd), imm, ctx); in emit_alu_i32()
339 emit(rv_addi(lo(rd), lo(rd), imm), ctx); in emit_alu_i32()
342 emit(rv_add(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i32()
347 emit(rv_addi(lo(rd), lo(rd), -imm), ctx); in emit_alu_i32()
350 emit(rv_sub(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i32()
355 emit(rv_andi(lo(rd), lo(rd), imm), ctx); in emit_alu_i32()
358 emit(rv_and(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i32()
363 emit(rv_ori(lo(rd), lo(rd), imm), ctx); in emit_alu_i32()
366 emit(rv_or(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i32()
371 emit(rv_xori(lo(rd), lo(rd), imm), ctx); in emit_alu_i32()
374 emit(rv_xor(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i32()
379 emit(rv_slli(lo(rd), lo(rd), imm), ctx); in emit_alu_i32()
382 emit(rv_sll(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i32()
387 emit(rv_srli(lo(rd), lo(rd), imm), ctx); in emit_alu_i32()
390 emit(rv_srl(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i32()
395 emit(rv_srai(lo(rd), lo(rd), imm), ctx); in emit_alu_i32()
398 emit(rv_sra(lo(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_i32()
403 bpf_put_reg32(dst, rd, ctx); in emit_alu_i32()
411 const s8 *rd = bpf_get_reg64(dst, tmp1, ctx); in emit_alu_r64() local
416 emit(rv_addi(lo(rd), lo(rs), 0), ctx); in emit_alu_r64()
417 emit(rv_addi(hi(rd), hi(rs), 0), ctx); in emit_alu_r64()
420 if (rd == rs) { in emit_alu_r64()
421 emit(rv_srli(RV_REG_T0, lo(rd), 31), ctx); in emit_alu_r64()
422 emit(rv_slli(hi(rd), hi(rd), 1), ctx); in emit_alu_r64()
423 emit(rv_or(hi(rd), RV_REG_T0, hi(rd)), ctx); in emit_alu_r64()
424 emit(rv_slli(lo(rd), lo(rd), 1), ctx); in emit_alu_r64()
426 emit(rv_add(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r64()
427 emit(rv_sltu(RV_REG_T0, lo(rd), lo(rs)), ctx); in emit_alu_r64()
428 emit(rv_add(hi(rd), hi(rd), hi(rs)), ctx); in emit_alu_r64()
429 emit(rv_add(hi(rd), hi(rd), RV_REG_T0), ctx); in emit_alu_r64()
433 emit(rv_sub(RV_REG_T1, hi(rd), hi(rs)), ctx); in emit_alu_r64()
434 emit(rv_sltu(RV_REG_T0, lo(rd), lo(rs)), ctx); in emit_alu_r64()
435 emit(rv_sub(hi(rd), RV_REG_T1, RV_REG_T0), ctx); in emit_alu_r64()
436 emit(rv_sub(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r64()
439 emit(rv_and(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r64()
440 emit(rv_and(hi(rd), hi(rd), hi(rs)), ctx); in emit_alu_r64()
443 emit(rv_or(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r64()
444 emit(rv_or(hi(rd), hi(rd), hi(rs)), ctx); in emit_alu_r64()
447 emit(rv_xor(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r64()
448 emit(rv_xor(hi(rd), hi(rd), hi(rs)), ctx); in emit_alu_r64()
451 emit(rv_mul(RV_REG_T0, hi(rs), lo(rd)), ctx); in emit_alu_r64()
452 emit(rv_mul(hi(rd), hi(rd), lo(rs)), ctx); in emit_alu_r64()
453 emit(rv_mulhu(RV_REG_T1, lo(rd), lo(rs)), ctx); in emit_alu_r64()
454 emit(rv_add(hi(rd), hi(rd), RV_REG_T0), ctx); in emit_alu_r64()
455 emit(rv_mul(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r64()
456 emit(rv_add(hi(rd), hi(rd), RV_REG_T1), ctx); in emit_alu_r64()
461 emit(rv_sll(hi(rd), lo(rd), RV_REG_T0), ctx); in emit_alu_r64()
462 emit(rv_addi(lo(rd), RV_REG_ZERO, 0), ctx); in emit_alu_r64()
465 emit(rv_srli(RV_REG_T0, lo(rd), 1), ctx); in emit_alu_r64()
468 emit(rv_sll(hi(rd), hi(rd), lo(rs)), ctx); in emit_alu_r64()
469 emit(rv_or(hi(rd), RV_REG_T0, hi(rd)), ctx); in emit_alu_r64()
470 emit(rv_sll(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r64()
475 emit(rv_srl(lo(rd), hi(rd), RV_REG_T0), ctx); in emit_alu_r64()
476 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in emit_alu_r64()
479 emit(rv_slli(RV_REG_T0, hi(rd), 1), ctx); in emit_alu_r64()
482 emit(rv_srl(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r64()
483 emit(rv_or(lo(rd), RV_REG_T0, lo(rd)), ctx); in emit_alu_r64()
484 emit(rv_srl(hi(rd), hi(rd), lo(rs)), ctx); in emit_alu_r64()
489 emit(rv_sra(lo(rd), hi(rd), RV_REG_T0), ctx); in emit_alu_r64()
490 emit(rv_srai(hi(rd), hi(rd), 31), ctx); in emit_alu_r64()
493 emit(rv_slli(RV_REG_T0, hi(rd), 1), ctx); in emit_alu_r64()
496 emit(rv_srl(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r64()
497 emit(rv_or(lo(rd), RV_REG_T0, lo(rd)), ctx); in emit_alu_r64()
498 emit(rv_sra(hi(rd), hi(rd), lo(rs)), ctx); in emit_alu_r64()
501 emit(rv_sub(lo(rd), RV_REG_ZERO, lo(rd)), ctx); in emit_alu_r64()
502 emit(rv_sltu(RV_REG_T0, RV_REG_ZERO, lo(rd)), ctx); in emit_alu_r64()
503 emit(rv_sub(hi(rd), RV_REG_ZERO, hi(rd)), ctx); in emit_alu_r64()
504 emit(rv_sub(hi(rd), hi(rd), RV_REG_T0), ctx); in emit_alu_r64()
508 bpf_put_reg64(dst, rd, ctx); in emit_alu_r64()
516 const s8 *rd = bpf_get_reg32(dst, tmp1, ctx); in emit_alu_r32() local
521 emit(rv_addi(lo(rd), lo(rs), 0), ctx); in emit_alu_r32()
524 emit(rv_add(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
527 emit(rv_sub(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
530 emit(rv_and(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
533 emit(rv_or(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
536 emit(rv_xor(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
539 emit(rv_mul(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
542 emit(rv_divu(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
545 emit(rv_remu(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
548 emit(rv_sll(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
551 emit(rv_srl(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
554 emit(rv_sra(lo(rd), lo(rd), lo(rs)), ctx); in emit_alu_r32()
557 emit(rv_sub(lo(rd), RV_REG_ZERO, lo(rd)), ctx); in emit_alu_r32()
561 bpf_put_reg32(dst, rd, ctx); in emit_alu_r32()
652 static int emit_bcc(u8 op, u8 rd, u8 rs, int rvoff, struct rv_jit_context *ctx) in emit_bcc() argument
678 emit(rv_beq(rd, rs, off), ctx); in emit_bcc()
681 emit(rv_bgtu(rd, rs, off), ctx); in emit_bcc()
684 emit(rv_bltu(rd, rs, off), ctx); in emit_bcc()
687 emit(rv_bgeu(rd, rs, off), ctx); in emit_bcc()
690 emit(rv_bleu(rd, rs, off), ctx); in emit_bcc()
693 emit(rv_bne(rd, rs, off), ctx); in emit_bcc()
696 emit(rv_bgt(rd, rs, off), ctx); in emit_bcc()
699 emit(rv_blt(rd, rs, off), ctx); in emit_bcc()
702 emit(rv_bge(rd, rs, off), ctx); in emit_bcc()
705 emit(rv_ble(rd, rs, off), ctx); in emit_bcc()
708 emit(rv_and(RV_REG_T0, rd, rs), ctx); in emit_bcc()
840 const s8 *rd = bpf_get_reg64(dst, tmp1, ctx); in emit_load_r64() local
848 emit(rv_lbu(lo(rd), 0, RV_REG_T0), ctx); in emit_load_r64()
850 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in emit_load_r64()
853 emit(rv_lhu(lo(rd), 0, RV_REG_T0), ctx); in emit_load_r64()
855 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in emit_load_r64()
858 emit(rv_lw(lo(rd), 0, RV_REG_T0), ctx); in emit_load_r64()
860 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in emit_load_r64()
863 emit(rv_lw(lo(rd), 0, RV_REG_T0), ctx); in emit_load_r64()
864 emit(rv_lw(hi(rd), 4, RV_REG_T0), ctx); in emit_load_r64()
868 bpf_put_reg64(dst, rd, ctx); in emit_load_r64()
878 const s8 *rd = bpf_get_reg64(dst, tmp1, ctx); in emit_store_r64() local
885 emit(rv_add(RV_REG_T0, RV_REG_T0, lo(rd)), ctx); in emit_store_r64()
914 static void emit_rev16(const s8 rd, struct rv_jit_context *ctx) in emit_rev16() argument
916 emit(rv_slli(rd, rd, 16), ctx); in emit_rev16()
917 emit(rv_slli(RV_REG_T1, rd, 8), ctx); in emit_rev16()
918 emit(rv_srli(rd, rd, 8), ctx); in emit_rev16()
919 emit(rv_add(RV_REG_T1, rd, RV_REG_T1), ctx); in emit_rev16()
920 emit(rv_srli(rd, RV_REG_T1, 16), ctx); in emit_rev16()
923 static void emit_rev32(const s8 rd, struct rv_jit_context *ctx) in emit_rev32() argument
926 emit(rv_andi(RV_REG_T0, rd, 255), ctx); in emit_rev32()
929 emit(rv_srli(rd, rd, 8), ctx); in emit_rev32()
930 emit(rv_andi(RV_REG_T0, rd, 255), ctx); in emit_rev32()
933 emit(rv_srli(rd, rd, 8), ctx); in emit_rev32()
934 emit(rv_andi(RV_REG_T0, rd, 255), ctx); in emit_rev32()
937 emit(rv_srli(rd, rd, 8), ctx); in emit_rev32()
938 emit(rv_andi(RV_REG_T0, rd, 255), ctx); in emit_rev32()
940 emit(rv_addi(rd, RV_REG_T1, 0), ctx); in emit_rev32()
945 const s8 *rd; in emit_zext64() local
948 rd = bpf_get_reg64(dst, tmp1, ctx); in emit_zext64()
949 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in emit_zext64()
950 bpf_put_reg64(dst, rd, ctx); in emit_zext64()
1073 const s8 *rd = bpf_get_reg64(dst, tmp1, ctx); in bpf_jit_emit_insn() local
1077 emit(rv_slli(lo(rd), lo(rd), 16), ctx); in bpf_jit_emit_insn()
1078 emit(rv_srli(lo(rd), lo(rd), 16), ctx); in bpf_jit_emit_insn()
1082 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in bpf_jit_emit_insn()
1092 bpf_put_reg64(dst, rd, ctx); in bpf_jit_emit_insn()
1098 const s8 *rd = bpf_get_reg64(dst, tmp1, ctx); in bpf_jit_emit_insn() local
1102 emit_rev16(lo(rd), ctx); in bpf_jit_emit_insn()
1104 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in bpf_jit_emit_insn()
1107 emit_rev32(lo(rd), ctx); in bpf_jit_emit_insn()
1109 emit(rv_addi(hi(rd), RV_REG_ZERO, 0), ctx); in bpf_jit_emit_insn()
1113 emit(rv_addi(RV_REG_T0, lo(rd), 0), ctx); in bpf_jit_emit_insn()
1114 emit(rv_addi(lo(rd), hi(rd), 0), ctx); in bpf_jit_emit_insn()
1115 emit(rv_addi(hi(rd), RV_REG_T0, 0), ctx); in bpf_jit_emit_insn()
1118 emit_rev32(lo(rd), ctx); in bpf_jit_emit_insn()
1119 emit_rev32(hi(rd), ctx); in bpf_jit_emit_insn()
1126 bpf_put_reg64(dst, rd, ctx); in bpf_jit_emit_insn()
1236 const s8 *rd = bpf_get_reg64(dst, tmp1, ctx); in bpf_jit_emit_insn() local
1238 emit_imm64(rd, imm_hi, imm_lo, ctx); in bpf_jit_emit_insn()
1239 bpf_put_reg64(dst, rd, ctx); in bpf_jit_emit_insn()