Lines Matching refs:ctx

27 	struct jit_ctx ctx;
30 #define emit_insn(ctx, func, ...) \
32 if (ctx->image != NULL) { \
33 union loongarch_instruction *insn = &ctx->image[ctx->idx]; \
36 ctx->idx++; \
47 static inline int bpf2la_offset(int bpf_insn, int off, const struct jit_ctx *ctx)
56 return (ctx->offset[bpf_insn + off] - (ctx->offset[bpf_insn] - 1));
59 static inline int epilogue_offset(const struct jit_ctx *ctx)
61 int from = ctx->idx;
62 int to = ctx->epilogue_offset;
68 static inline void emit_zext_32(struct jit_ctx *ctx, enum loongarch_gpr reg, bool is32)
73 emit_insn(ctx, lu32id, reg, 0);
77 static inline void emit_sext_32(struct jit_ctx *ctx, enum loongarch_gpr reg, bool is32)
82 emit_insn(ctx, addiw, reg, reg, 0);
85 static inline void move_addr(struct jit_ctx *ctx, enum loongarch_gpr rd, u64 addr)
91 emit_insn(ctx, lu12iw, rd, imm_31_12);
95 emit_insn(ctx, ori, rd, rd, imm_11_0);
99 emit_insn(ctx, lu32id, rd, imm_51_32);
103 emit_insn(ctx, lu52id, rd, rd, imm_63_52);
106 static inline void move_imm(struct jit_ctx *ctx, enum loongarch_gpr rd, long imm, bool is32)
112 emit_insn(ctx, or, rd, LOONGARCH_GPR_ZERO, LOONGARCH_GPR_ZERO);
118 emit_insn(ctx, addiw, rd, LOONGARCH_GPR_ZERO, imm);
124 emit_insn(ctx, ori, rd, LOONGARCH_GPR_ZERO, imm);
132 emit_insn(ctx, lu52id, rd, LOONGARCH_GPR_ZERO, imm_63_52);
138 emit_insn(ctx, lu12iw, rd, imm_31_12);
143 emit_insn(ctx, ori, rd, rd, imm_11_0);
156 emit_insn(ctx, lu32id, rd, imm_51_32);
162 emit_insn(ctx, lu52id, rd, rd, imm_63_52);
166 emit_zext_32(ctx, rd, is32);
169 static inline void move_reg(struct jit_ctx *ctx, enum loongarch_gpr rd,
172 emit_insn(ctx, or, rd, rj, LOONGARCH_GPR_ZERO);
203 static inline void cond_jmp_offset(struct jit_ctx *ctx, u8 cond, enum loongarch_gpr rj,
209 emit_insn(ctx, beq, rj, rd, jmp_offset);
214 emit_insn(ctx, bne, rj, rd, jmp_offset);
218 emit_insn(ctx, bltu, rd, rj, jmp_offset);
222 emit_insn(ctx, bltu, rj, rd, jmp_offset);
226 emit_insn(ctx, bgeu, rj, rd, jmp_offset);
230 emit_insn(ctx, bgeu, rd, rj, jmp_offset);
234 emit_insn(ctx, blt, rd, rj, jmp_offset);
238 emit_insn(ctx, blt, rj, rd, jmp_offset);
242 emit_insn(ctx, bge, rj, rd, jmp_offset);
246 emit_insn(ctx, bge, rd, rj, jmp_offset);
251 static inline void cond_jmp_offs26(struct jit_ctx *ctx, u8 cond, enum loongarch_gpr rj,
255 cond_jmp_offset(ctx, cond, rj, rd, 2);
256 emit_insn(ctx, b, jmp_offset);
259 static inline void uncond_jmp_offs26(struct jit_ctx *ctx, int jmp_offset)
261 emit_insn(ctx, b, jmp_offset);
264 static inline int emit_cond_jmp(struct jit_ctx *ctx, u8 cond, enum loongarch_gpr rj,
279 cond_jmp_offs26(ctx, cond, rj, rd, jmp_offset);
286 static inline int emit_uncond_jmp(struct jit_ctx *ctx, int jmp_offset)
289 uncond_jmp_offs26(ctx, jmp_offset);
296 static inline int emit_tailcall_jmp(struct jit_ctx *ctx, u8 cond, enum loongarch_gpr rj,
300 cond_jmp_offset(ctx, cond, rj, rd, jmp_offset);