Lines Matching defs:ctx

33 static inline bool bpf_is_seen_register(struct codegen_context *ctx, int i)
35 return (ctx->seen & (1 << (31 - b2p[i])));
38 static inline void bpf_set_seen_register(struct codegen_context *ctx, int i)
40 ctx->seen |= (1 << (31 - b2p[i]));
43 static inline bool bpf_has_stack_frame(struct codegen_context *ctx)
51 return ctx->seen & SEEN_FUNC || bpf_is_seen_register(ctx, BPF_REG_FP);
65 static int bpf_jit_stack_local(struct codegen_context *ctx)
67 if (bpf_has_stack_frame(ctx))
68 return STACK_FRAME_MIN_SIZE + ctx->stack_size;
73 static int bpf_jit_stack_tailcallcnt(struct codegen_context *ctx)
75 return bpf_jit_stack_local(ctx) + 16;
78 static int bpf_jit_stack_offsetof(struct codegen_context *ctx, int reg)
81 return (bpf_has_stack_frame(ctx) ?
82 (BPF_PPC_STACKFRAME + ctx->stack_size) : 0)
89 static void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)
98 if (ctx->seen & SEEN_TAILCALL) {
109 if (bpf_has_stack_frame(ctx)) {
114 if (ctx->seen & SEEN_FUNC) {
119 PPC_BPF_STLU(1, 1, -(BPF_PPC_STACKFRAME + ctx->stack_size));
128 if (bpf_is_seen_register(ctx, i))
129 PPC_BPF_STL(b2p[i], 1, bpf_jit_stack_offsetof(ctx, b2p[i]));
132 if (bpf_is_seen_register(ctx, BPF_REG_FP))
134 STACK_FRAME_MIN_SIZE + ctx->stack_size));
137 static void bpf_jit_emit_common_epilogue(u32 *image, struct codegen_context *ctx)
143 if (bpf_is_seen_register(ctx, i))
144 PPC_BPF_LL(b2p[i], 1, bpf_jit_stack_offsetof(ctx, b2p[i]));
147 if (bpf_has_stack_frame(ctx)) {
148 EMIT(PPC_RAW_ADDI(1, 1, BPF_PPC_STACKFRAME + ctx->stack_size));
149 if (ctx->seen & SEEN_FUNC) {
156 static void bpf_jit_build_epilogue(u32 *image, struct codegen_context *ctx)
158 bpf_jit_emit_common_epilogue(image, ctx);
166 static void bpf_jit_emit_func_call_hlp(u32 *image, struct codegen_context *ctx,
191 static void bpf_jit_emit_func_call_rel(u32 *image, struct codegen_context *ctx,
194 unsigned int i, ctx_idx = ctx->idx;
209 for (i = ctx->idx - ctx_idx; i < 5; i++)
228 static int bpf_jit_emit_tail_call(u32 *image, struct codegen_context *ctx, u32 out)
232 * r3/BPF_REG_1 - pointer to ctx -- passed as is to the next bpf program
252 PPC_BPF_LL(b2p[TMP_REG_1], 1, bpf_jit_stack_tailcallcnt(ctx));
260 PPC_BPF_STL(b2p[TMP_REG_1], 1, bpf_jit_stack_tailcallcnt(ctx));
286 bpf_jit_emit_common_epilogue(image, ctx);
318 struct codegen_context *ctx,
345 addrs[i] = ctx->idx * 4;
359 bpf_set_seen_register(ctx, insn[i].dst_reg);
361 bpf_set_seen_register(ctx, insn[i].src_reg);
546 addrs[++i] = ctx->idx * 4;
555 addrs[++i] = ctx->idx * 4;
564 addrs[++i] = ctx->idx * 4;
572 addrs[++i] = ctx->idx * 4;
610 addrs[++i] = ctx->idx * 4;
655 PPC_BPF_STL(dst_reg, 1, bpf_jit_stack_local(ctx));
656 EMIT(PPC_RAW_ADDI(b2p[TMP_REG_1], 1, bpf_jit_stack_local(ctx)));
679 addrs[++i] = ctx->idx * 4;
765 tmp_idx = ctx->idx * 4;
778 tmp_idx = ctx->idx * 4;
792 addrs[++i] = ctx->idx * 4;
798 addrs[++i] = ctx->idx * 4;
804 addrs[++i] = ctx->idx * 4;
819 addrs[++i] = ctx->idx * 4;
841 ctx->seen |= SEEN_FUNC;
849 bpf_jit_emit_func_call_hlp(image, ctx, func_addr);
851 bpf_jit_emit_func_call_rel(image, ctx, func_addr);
1066 ctx->seen |= SEEN_TAILCALL;
1067 ret = bpf_jit_emit_tail_call(image, ctx, addrs[i + 1]);
1085 addrs[i] = ctx->idx * 4;
1092 struct codegen_context *ctx, u32 *addrs)
1119 * Save ctx->idx as this would currently point to the
1124 tmp_idx = ctx->idx;
1125 ctx->idx = addrs[i] / 4;
1126 bpf_jit_emit_func_call_rel(image, ctx, func_addr);
1129 * Restore ctx->idx here. This is safe as the length
1132 ctx->idx = tmp_idx;
1144 struct codegen_context ctx;
1194 cgctx = jit_data->ctx;
1224 * from bpf_jit_emit_tail_call() with a not yet stable ctx->seen.
1311 jit_data->ctx = cgctx;