Lines Matching refs:dst

191 /* dst = imm (register width) */
192 void emit_mov_i(struct jit_context *ctx, u8 dst, s32 imm)
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));
200 clobber_reg(ctx, dst);
203 /* dst = src (register width) */
204 void emit_mov_r(struct jit_context *ctx, u8 dst, u8 src)
206 emit(ctx, ori, dst, src, 0);
207 clobber_reg(ctx, dst);
264 /* dst * 1 is a no-op */
267 /* dst * 0 is dst & 0 */
270 /* dst * (1 << n) is dst << n */
277 /* dst / 1 is a no-op */
280 /* dst / (1 << n) is dst >> n */
286 /* dst % (1 << n) is dst & ((1 << n) - 1) */
298 void emit_alu_i(struct jit_context *ctx, u8 dst, s32 imm, u8 op)
301 /* dst = -dst */
303 emit(ctx, subu, dst, MIPS_R_ZERO, dst);
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);
338 clobber_reg(ctx, dst);
342 void emit_alu_r(struct jit_context *ctx, u8 dst, u8 src, u8 op)
345 /* dst = dst & src */
347 emit(ctx, and, dst, dst, src);
349 /* dst = dst | src */
351 emit(ctx, or, dst, dst, src);
353 /* dst = dst ^ src */
355 emit(ctx, xor, dst, dst, src);
357 /* dst = dst << src */
359 emit(ctx, sllv, dst, dst, src);
361 /* dst = dst >> src */
363 emit(ctx, srlv, dst, dst, src);
365 /* dst = dst >> src (arithmetic) */
367 emit(ctx, srav, dst, dst, src);
369 /* dst = dst + src */
371 emit(ctx, addu, dst, dst, src);
373 /* dst = dst - src */
375 emit(ctx, subu, dst, dst, src);
377 /* dst = dst * src */
380 emit(ctx, mul, dst, dst, src);
382 emit(ctx, multu, dst, src);
383 emit(ctx, mflo, dst);
386 /* dst = dst / src */
389 emit(ctx, divu_r6, dst, dst, src);
391 emit(ctx, divu, dst, src);
392 emit(ctx, mflo, dst);
395 /* dst = dst % src */
398 emit(ctx, modu, dst, dst, src);
400 emit(ctx, divu, dst, src);
401 emit(ctx, mfhi, dst);
405 clobber_reg(ctx, dst);
409 void emit_atomic_r(struct jit_context *ctx, u8 dst, u8 src, s16 off, u8 code)
412 emit(ctx, ll, MIPS_R_T9, off, dst);
434 emit(ctx, sc, MIPS_R_T8, off, dst);
445 void emit_cmpxchg_r(struct jit_context *ctx, u8 dst, u8 src, u8 res, s16 off)
448 emit(ctx, ll, MIPS_R_T9, off, dst);
451 emit(ctx, sc, MIPS_R_T8, off, dst);
458 void emit_bswap_r(struct jit_context *ctx, u8 dst, u32 width)
467 emit(ctx, wsbh, dst, dst);
468 emit(ctx, rotr, dst, dst, 16);
470 emit(ctx, sll, tmp, dst, 16); /* tmp = dst << 16 */
471 emit(ctx, srl, dst, dst, 16); /* dst = dst >> 16 */
472 emit(ctx, or, dst, dst, tmp); /* dst = dst | tmp */
477 emit(ctx, and, tmp, dst, msk); /* tmp = dst & msk */
479 emit(ctx, srl, dst, dst, 8); /* dst = dst >> 8 */
480 emit(ctx, and, dst, dst, msk); /* dst = dst & msk */
481 emit(ctx, or, dst, dst, tmp); /* reg = dst | tmp */
487 emit(ctx, wsbh, dst, dst);
488 emit(ctx, andi, dst, dst, 0xffff);
490 emit(ctx, andi, tmp, dst, 0xff00); /* t = d & 0xff00 */
492 emit(ctx, andi, dst, dst, 0x00ff); /* d = d & 0x00ff */
493 emit(ctx, sll, dst, dst, 8); /* d = d << 8 */
494 emit(ctx, or, dst, dst, tmp); /* d = d | t */
498 clobber_reg(ctx, dst);
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);
758 void emit_jmp_r(struct jit_context *ctx, u8 dst, u8 src, s32 off, u8 op)
764 /* PC += off if dst == src */
766 emit(ctx, beq, dst, src, off);
768 /* PC += off if dst != src */
770 emit(ctx, bne, dst, src, off);
772 /* PC += off if dst & src */
774 emit(ctx, and, MIPS_R_T9, dst, src);
777 /* PC += off if (dst & imm) == 0 (not in BPF, used for long jumps) */
779 emit(ctx, and, MIPS_R_T9, dst, src);
782 /* PC += off if dst > src */
784 emit(ctx, sltu, MIPS_R_T9, src, dst);
787 /* PC += off if dst >= src */
789 emit(ctx, sltu, MIPS_R_T9, dst, src);
792 /* PC += off if dst < src */
794 emit(ctx, sltu, MIPS_R_T9, dst, src);
797 /* PC += off if dst <= src */
799 emit(ctx, sltu, MIPS_R_T9, src, dst);
802 /* PC += off if dst > src (signed) */
804 emit(ctx, slt, MIPS_R_T9, src, dst);
807 /* PC += off if dst >= src (signed) */
809 emit(ctx, slt, MIPS_R_T9, dst, src);
812 /* PC += off if dst < src (signed) */
814 emit(ctx, slt, MIPS_R_T9, dst, src);
817 /* PC += off if dst <= src (signed) */
819 emit(ctx, slt, MIPS_R_T9, src, dst);