Lines Matching refs:imm

191 /* dst = imm (register width) */
192 void emit_mov_i(struct jit_context *ctx, u8 dst, s32 imm)
194 if (imm >= -0x8000 && imm <= 0x7fff) {
195 emit(ctx, addiu, dst, MIPS_R_ZERO, imm);
197 emit(ctx, lui, dst, (s16)((u32)imm >> 16));
198 emit(ctx, ori, dst, dst, (u16)(imm & 0xffff));
211 bool valid_alu_i(u8 op, s32 imm)
223 /* imm must be 16 bits */
224 return imm >= -0x8000 && imm <= 0x7fff;
228 /* -imm must be 16 bits */
229 return imm >= -0x7fff && imm <= 0x8000;
233 /* imm must be 16 bits unsigned */
234 return imm >= 0 && imm <= 0xffff;
236 /* imm must be zero or a positive power of two */
237 return imm == 0 || (imm > 0 && is_power_of_2(imm));
240 /* imm must be an 17-bit power of two */
241 return (u32)imm <= 0x10000 && is_power_of_2((u32)imm);
247 bool rewrite_alu_i(u8 op, s32 imm, u8 *alu, s32 *val)
259 /* imm == 0 is a no-op */
260 act = imm != 0;
263 if (imm == 1) {
266 } else if (imm == 0) {
272 imm = ilog2(abs(imm));
276 if (imm == 1) {
282 imm = ilog2(imm);
288 imm--;
293 *val = imm;
298 void emit_alu_i(struct jit_context *ctx, u8 dst, s32 imm, u8 op)
305 /* dst = dst & imm */
307 emit(ctx, andi, dst, dst, (u16)imm);
309 /* dst = dst | imm */
311 emit(ctx, ori, dst, dst, (u16)imm);
313 /* dst = dst ^ imm */
315 emit(ctx, xori, dst, dst, (u16)imm);
317 /* dst = dst << imm */
319 emit(ctx, sll, dst, dst, imm);
321 /* dst = dst >> imm */
323 emit(ctx, srl, dst, dst, imm);
325 /* dst = dst >> imm (arithmetic) */
327 emit(ctx, sra, dst, dst, imm);
329 /* dst = dst + imm */
331 emit(ctx, addiu, dst, dst, imm);
333 /* dst = dst - imm */
335 emit(ctx, addiu, dst, dst, -imm);
502 bool valid_jmp_i(u8 op, s32 imm)
514 /* imm must be 16 bits unsigned */
515 return imm >= 0 && imm <= 0xffff;
520 /* imm must be 16 bits */
521 return imm >= -0x8000 && imm <= 0x7fff;
526 /* imm + 1 must be 16 bits */
527 return imm >= -0x8001 && imm <= 0x7ffe;
605 void setup_jmp_i(struct jit_context *ctx, s32 imm, u8 width,
617 never = imm == 0;
620 always = imm == 0;
623 never = (u32)imm == U32_MAX;
626 always = (u32)imm == U32_MAX;
629 never = imm == S32_MAX && width == 32;
632 always = imm == S32_MIN && width == 32;
635 never = imm == S32_MIN && width == 32;
638 always = imm == S32_MAX && width == 32;
698 void emit_jmp_i(struct jit_context *ctx, u8 dst, s32 imm, s32 off, u8 op)
704 /* PC += off if dst & imm */
706 emit(ctx, andi, MIPS_R_T9, dst, (u16)imm);
709 /* PC += off if (dst & imm) == 0 (not in BPF, used for long jumps) */
711 emit(ctx, andi, MIPS_R_T9, dst, (u16)imm);
714 /* PC += off if dst > imm */
716 emit(ctx, sltiu, MIPS_R_T9, dst, imm + 1);
719 /* PC += off if dst >= imm */
721 emit(ctx, sltiu, MIPS_R_T9, dst, imm);
724 /* PC += off if dst < imm */
726 emit(ctx, sltiu, MIPS_R_T9, dst, imm);
729 /* PC += off if dst <= imm */
731 emit(ctx, sltiu, MIPS_R_T9, dst, imm + 1);
734 /* PC += off if dst > imm (signed) */
736 emit(ctx, slti, MIPS_R_T9, dst, imm + 1);
739 /* PC += off if dst >= imm (signed) */
741 emit(ctx, slti, MIPS_R_T9, dst, imm);
744 /* PC += off if dst < imm (signed) */
746 emit(ctx, slti, MIPS_R_T9, dst, imm);
749 /* PC += off if dst <= imm (signed) */
751 emit(ctx, slti, MIPS_R_T9, dst, imm + 1);
777 /* PC += off if (dst & imm) == 0 (not in BPF, used for long jumps) */