Lines Matching refs:ctx
25 struct jit_ctx ctx;
28 #define emit_insn(ctx, func, ...) \
30 if (ctx->image != NULL) { \
31 union loongarch_instruction *insn = &ctx->image[ctx->idx]; \
34 ctx->idx++; \
55 static inline int bpf2la_offset(int bpf_insn, int off, const struct jit_ctx *ctx)
64 return (ctx->offset[bpf_insn + off] - (ctx->offset[bpf_insn] - 1));
67 static inline int epilogue_offset(const struct jit_ctx *ctx)
69 int to = ctx->epilogue_offset;
70 int from = ctx->idx;
596 static inline void emit_zext_32(struct jit_ctx *ctx, enum loongarch_gpr reg, bool is32)
602 emit_insn(ctx, lu32id, reg, 0);
606 static inline void emit_sext_32(struct jit_ctx *ctx, enum loongarch_gpr reg)
608 emit_insn(ctx, addiw, reg, reg, 0);
611 static inline void move_imm32(struct jit_ctx *ctx, enum loongarch_gpr rd,
619 emit_insn(ctx, or, rd, LOONGARCH_GPR_ZERO, LOONGARCH_GPR_ZERO);
625 emit_insn(ctx, addiw, rd, LOONGARCH_GPR_ZERO, imm32);
631 emit_insn(ctx, ori, rd, LOONGARCH_GPR_ZERO, imm32);
637 emit_insn(ctx, lu12iw, rd, si20);
642 emit_insn(ctx, ori, rd, rd, ui12);
645 emit_zext_32(ctx, rd, is32);
648 static inline void move_imm64(struct jit_ctx *ctx, enum loongarch_gpr rd,
658 emit_insn(ctx, lu52id, rd, LOONGARCH_GPR_ZERO, si12);
663 move_imm32(ctx, rd, imm32, is32);
669 emit_insn(ctx, lu32id, rd, si20);
674 emit_insn(ctx, lu52id, rd, rd, si12);
678 static inline void move_reg(struct jit_ctx *ctx, enum loongarch_gpr rd,
681 emit_insn(ctx, or, rd, rj, LOONGARCH_GPR_ZERO);
712 static inline void cond_jump_offs16(struct jit_ctx *ctx, u8 cond, enum loongarch_gpr rj,
718 emit_insn(ctx, beq, rj, rd, jmp_offset);
723 emit_insn(ctx, bne, rj, rd, jmp_offset);
727 emit_insn(ctx, bltu, rd, rj, jmp_offset);
731 emit_insn(ctx, bltu, rj, rd, jmp_offset);
735 emit_insn(ctx, bgeu, rj, rd, jmp_offset);
739 emit_insn(ctx, bgeu, rd, rj, jmp_offset);
743 emit_insn(ctx, blt, rd, rj, jmp_offset);
747 emit_insn(ctx, blt, rj, rd, jmp_offset);
751 emit_insn(ctx, bge, rj, rd, jmp_offset);
755 emit_insn(ctx, bge, rd, rj, jmp_offset);
760 static inline void cond_jump_offs26(struct jit_ctx *ctx, u8 cond, enum loongarch_gpr rj,
764 cond_jump_offs16(ctx, cond, rj, rd, 2);
765 emit_insn(ctx, b, jmp_offset);
768 static inline void cond_jump_offs32(struct jit_ctx *ctx, u8 cond, enum loongarch_gpr rj,
777 cond_jump_offs16(ctx, cond, rj, rd, 3);
783 emit_insn(ctx, pcaddu18i, LOONGARCH_GPR_T2, upper << 2);
786 emit_insn(ctx, jirl, LOONGARCH_GPR_ZERO, LOONGARCH_GPR_T2, lower + 1);
789 static inline void uncond_jump_offs26(struct jit_ctx *ctx, int jmp_offset)
791 emit_insn(ctx, b, jmp_offset);
794 static inline void uncond_jump_offs32(struct jit_ctx *ctx, int jmp_offset, bool is_exit)
808 emit_insn(ctx, pcaddu18i, LOONGARCH_GPR_T1, upper << 2);
811 emit_insn(ctx, jirl, LOONGARCH_GPR_ZERO, LOONGARCH_GPR_T1, lower + 1);
814 static inline void emit_cond_jump(struct jit_ctx *ctx, u8 cond, enum loongarch_gpr rj,
818 cond_jump_offs16(ctx, cond, rj, rd, jmp_offset);
820 cond_jump_offs26(ctx, cond, rj, rd, jmp_offset);
822 cond_jump_offs32(ctx, cond, rj, rd, jmp_offset);
825 static inline void emit_uncond_jump(struct jit_ctx *ctx, int jmp_offset, bool is_exit)
828 uncond_jump_offs26(ctx, jmp_offset);
830 uncond_jump_offs32(ctx, jmp_offset, is_exit);
833 static inline void emit_tailcall_jump(struct jit_ctx *ctx, u8 cond, enum loongarch_gpr rj,
837 cond_jump_offs16(ctx, cond, rj, rd, jmp_offset);
839 cond_jump_offs26(ctx, cond, rj, rd, jmp_offset - 1);
841 cond_jump_offs32(ctx, cond, rj, rd, jmp_offset - 2);