Lines Matching refs:dst
98 static void emit_sext(struct jit_context *ctx, u8 dst, u8 src)
100 emit(ctx, sll, dst, src, 0);
101 clobber_reg(ctx, dst);
105 static void emit_zext(struct jit_context *ctx, u8 dst)
108 emit(ctx, dinsu, dst, MIPS_R_ZERO, 32, 32);
110 emit(ctx, and, dst, dst, bpf2mips64[JIT_REG_ZX]);
113 clobber_reg(ctx, dst);
117 static void emit_zext_ver(struct jit_context *ctx, u8 dst)
120 emit_zext(ctx, dst);
123 /* dst = imm (64-bit) */
124 static void emit_mov_i64(struct jit_context *ctx, u8 dst, u64 imm64)
127 emit(ctx, daddiu, dst, MIPS_R_ZERO, (s16)imm64);
130 emit(ctx, lui, dst, (s16)(imm64 >> 16));
131 emit(ctx, ori, dst, dst, (u16)imm64 & 0xffff);
140 if (acc == dst)
145 emit(ctx, dsll_safe, dst, dst, shift);
146 emit(ctx, ori, dst, acc, half);
147 acc = dst;
152 emit(ctx, dsll_safe, dst, dst, shift);
154 clobber_reg(ctx, dst);
158 static void emit_alu_i64(struct jit_context *ctx, u8 dst, s32 imm, u8 op)
161 /* dst = dst | imm */
163 emit(ctx, ori, dst, dst, (u16)imm);
165 /* dst = dst ^ imm */
167 emit(ctx, xori, dst, dst, (u16)imm);
169 /* dst = -dst */
171 emit(ctx, dsubu, dst, MIPS_R_ZERO, dst);
173 /* dst = dst << imm */
175 emit(ctx, dsll_safe, dst, dst, imm);
177 /* dst = dst >> imm */
179 emit(ctx, dsrl_safe, dst, dst, imm);
181 /* dst = dst >> imm (arithmetic) */
183 emit(ctx, dsra_safe, dst, dst, imm);
185 /* dst = dst + imm */
187 emit(ctx, daddiu, dst, dst, imm);
189 /* dst = dst - imm */
191 emit(ctx, daddiu, dst, dst, -imm);
195 emit_alu_i(ctx, dst, imm, op);
197 clobber_reg(ctx, dst);
201 static void emit_alu_r64(struct jit_context *ctx, u8 dst, u8 src, u8 op)
204 /* dst = dst << src */
206 emit(ctx, dsllv, dst, dst, src);
208 /* dst = dst >> src */
210 emit(ctx, dsrlv, dst, dst, src);
212 /* dst = dst >> src (arithmetic) */
214 emit(ctx, dsrav, dst, dst, src);
216 /* dst = dst + src */
218 emit(ctx, daddu, dst, dst, src);
220 /* dst = dst - src */
222 emit(ctx, dsubu, dst, dst, src);
224 /* dst = dst * src */
227 emit(ctx, dmulu, dst, dst, src);
229 emit(ctx, dmultu, dst, src);
230 emit(ctx, mflo, dst);
236 /* dst = dst / src */
239 emit(ctx, ddivu_r6, dst, dst, src);
241 emit(ctx, ddivu, dst, src);
242 emit(ctx, mflo, dst);
245 /* dst = dst % src */
248 emit(ctx, dmodu, dst, dst, src);
250 emit(ctx, ddivu, dst, src);
251 emit(ctx, mfhi, dst);
256 emit_alu_r(ctx, dst, src, op);
258 clobber_reg(ctx, dst);
262 static void emit_swap_r64(struct jit_context *ctx, u8 dst, u8 mask, u32 bits)
266 emit(ctx, and, tmp, dst, mask); /* tmp = dst & mask */
268 emit(ctx, dsrl, dst, dst, bits); /* dst = dst >> bits */
269 emit(ctx, and, dst, dst, mask); /* dst = dst & mask */
270 emit(ctx, or, dst, dst, tmp); /* dst = dst | tmp */
274 static void emit_bswap_r64(struct jit_context *ctx, u8 dst, u32 width)
280 emit(ctx, dsbh, dst, dst);
281 emit(ctx, dshd, dst, dst);
286 emit(ctx, dsll32, t2, dst, 0); /* t2 = dst << 32 */
287 emit(ctx, dsrl32, dst, dst, 0); /* dst = dst >> 32 */
288 emit(ctx, or, dst, dst, t2); /* dst = dst | t2 */
293 emit_swap_r64(ctx, dst, t1, 16);/* dst = swap16(dst) */
299 emit_swap_r64(ctx, dst, t1, 8); /* dst = swap8(dst) */
306 emit_sext(ctx, dst, dst);
307 emit_bswap_r(ctx, dst, width);
309 emit_zext(ctx, dst);
312 clobber_reg(ctx, dst);
316 static void emit_trunc_r64(struct jit_context *ctx, u8 dst, u32 width)
323 emit_zext(ctx, dst);
327 emit(ctx, andi, dst, dst, 0xffff);
330 clobber_reg(ctx, dst);
333 /* Load operation: dst = *(size*)(src + off) */
334 static void emit_ldx(struct jit_context *ctx, u8 dst, u8 src, s16 off, u8 size)
339 emit(ctx, lbu, dst, off, src);
343 emit(ctx, lhu, dst, off, src);
347 emit(ctx, lwu, dst, off, src);
351 emit(ctx, ld, dst, off, src);
354 clobber_reg(ctx, dst);
357 /* Store operation: *(size *)(dst + off) = src */
358 static void emit_stx(struct jit_context *ctx, u8 dst, u8 src, s16 off, u8 size)
363 emit(ctx, sb, src, off, dst);
367 emit(ctx, sh, src, off, dst);
371 emit(ctx, sw, src, off, dst);
375 emit(ctx, sd, src, off, dst);
382 u8 dst, u8 src, s16 off, u8 code)
388 emit(ctx, lld, t1, off, dst);
410 emit(ctx, scd, t2, off, dst);
421 static void emit_cmpxchg_r64(struct jit_context *ctx, u8 dst, u8 src, s16 off)
428 emit(ctx, lld, t1, off, dst);
431 emit(ctx, scd, t2, off, dst);
637 u8 dst = bpf2mips64[insn->dst_reg];
648 /* dst = imm */
650 emit_mov_i(ctx, dst, imm);
651 emit_zext_ver(ctx, dst);
653 /* dst = src */
657 emit_zext(ctx, dst);
659 emit_mov_r(ctx, dst, src);
660 emit_zext_ver(ctx, dst);
663 /* dst = -dst */
665 emit_sext(ctx, dst, dst);
666 emit_alu_i(ctx, dst, 0, BPF_NEG);
667 emit_zext_ver(ctx, dst);
669 /* dst = dst & imm */
670 /* dst = dst | imm */
671 /* dst = dst ^ imm */
672 /* dst = dst << imm */
679 emit_alu_r(ctx, dst, MIPS_R_T4, BPF_OP(code));
681 emit_alu_i(ctx, dst, val, alu);
683 emit_zext_ver(ctx, dst);
685 /* dst = dst >> imm */
686 /* dst = dst >> imm (arithmetic) */
687 /* dst = dst + imm */
688 /* dst = dst - imm */
689 /* dst = dst * imm */
690 /* dst = dst / imm */
691 /* dst = dst % imm */
700 emit_sext(ctx, dst, dst);
702 emit_alu_r(ctx, dst, MIPS_R_T4, BPF_OP(code));
704 emit_sext(ctx, dst, dst);
705 emit_alu_i(ctx, dst, val, alu);
707 emit_zext_ver(ctx, dst);
709 /* dst = dst & src */
710 /* dst = dst | src */
711 /* dst = dst ^ src */
712 /* dst = dst << src */
717 emit_alu_r(ctx, dst, src, BPF_OP(code));
718 emit_zext_ver(ctx, dst);
720 /* dst = dst >> src */
721 /* dst = dst >> src (arithmetic) */
722 /* dst = dst + src */
723 /* dst = dst - src */
724 /* dst = dst * src */
725 /* dst = dst / src */
726 /* dst = dst % src */
734 emit_sext(ctx, dst, dst);
736 emit_alu_r(ctx, dst, MIPS_R_T4, BPF_OP(code));
737 emit_zext_ver(ctx, dst);
739 /* dst = imm (64-bit) */
741 emit_mov_i(ctx, dst, imm);
743 /* dst = src (64-bit) */
745 emit_mov_r(ctx, dst, src);
747 /* dst = -dst (64-bit) */
749 emit_alu_i64(ctx, dst, 0, BPF_NEG);
751 /* dst = dst & imm (64-bit) */
752 /* dst = dst | imm (64-bit) */
753 /* dst = dst ^ imm (64-bit) */
754 /* dst = dst << imm (64-bit) */
755 /* dst = dst >> imm (64-bit) */
756 /* dst = dst >> imm ((64-bit, arithmetic) */
757 /* dst = dst + imm (64-bit) */
758 /* dst = dst - imm (64-bit) */
759 /* dst = dst * imm (64-bit) */
760 /* dst = dst / imm (64-bit) */
761 /* dst = dst % imm (64-bit) */
775 emit_alu_r64(ctx, dst, MIPS_R_T4, BPF_OP(code));
777 emit_alu_i64(ctx, dst, val, alu);
780 /* dst = dst & src (64-bit) */
781 /* dst = dst | src (64-bit) */
782 /* dst = dst ^ src (64-bit) */
783 /* dst = dst << src (64-bit) */
784 /* dst = dst >> src (64-bit) */
785 /* dst = dst >> src (64-bit, arithmetic) */
786 /* dst = dst + src (64-bit) */
787 /* dst = dst - src (64-bit) */
788 /* dst = dst * src (64-bit) */
789 /* dst = dst / src (64-bit) */
790 /* dst = dst % src (64-bit) */
802 emit_alu_r64(ctx, dst, src, BPF_OP(code));
804 /* dst = htole(dst) */
805 /* dst = htobe(dst) */
815 emit_bswap_r64(ctx, dst, imm);
817 emit_trunc_r64(ctx, dst, imm);
819 /* dst = imm64 */
821 emit_mov_i64(ctx, dst, (u32)imm | ((u64)insn[1].imm << 32));
823 /* LDX: dst = *(size *)(src + off) */
828 emit_ldx(ctx, dst, src, off, BPF_SIZE(code));
830 /* ST: *(size *)(dst + off) = imm */
836 emit_stx(ctx, dst, MIPS_R_T4, off, BPF_SIZE(code));
838 /* STX: *(size *)(dst + off) = src */
843 emit_stx(ctx, dst, src, off, BPF_SIZE(code));
862 emit_atomic_r64(ctx, dst, src, off, imm);
864 u8 tmp = dst;
866 if (src == dst) { /* Don't overwrite dst */
867 emit_mov_r(ctx, MIPS_R_T4, dst);
875 emit_atomic_r(ctx, dst, MIPS_R_T4, off, imm);
880 emit_cmpxchg_r64(ctx, dst, src, off);
884 if (res == dst) /* Don't overwrite dst */
888 emit_cmpxchg_r(ctx, dst, MIPS_R_T5, tmp, off);
889 if (res == dst) /* Restore result */
898 /* PC += off if dst == src */
899 /* PC += off if dst != src */
900 /* PC += off if dst & src */
901 /* PC += off if dst > src */
902 /* PC += off if dst >= src */
903 /* PC += off if dst < src */
904 /* PC += off if dst <= src */
905 /* PC += off if dst > src (signed) */
906 /* PC += off if dst >= src (signed) */
907 /* PC += off if dst < src (signed) */
908 /* PC += off if dst <= src (signed) */
922 setup_jmp_r(ctx, dst == src, BPF_OP(code), off, &jmp, &rel);
923 emit_sext(ctx, MIPS_R_T4, dst); /* Sign-extended dst */
929 /* PC += off if dst == imm */
930 /* PC += off if dst != imm */
931 /* PC += off if dst & imm */
932 /* PC += off if dst > imm */
933 /* PC += off if dst >= imm */
934 /* PC += off if dst < imm */
935 /* PC += off if dst <= imm */
936 /* PC += off if dst > imm (signed) */
937 /* PC += off if dst >= imm (signed) */
938 /* PC += off if dst < imm (signed) */
939 /* PC += off if dst <= imm (signed) */
954 emit_sext(ctx, MIPS_R_T4, dst); /* Sign-extended dst */
965 /* PC += off if dst == src */
966 /* PC += off if dst != src */
967 /* PC += off if dst & src */
968 /* PC += off if dst > src */
969 /* PC += off if dst >= src */
970 /* PC += off if dst < src */
971 /* PC += off if dst <= src */
972 /* PC += off if dst > src (signed) */
973 /* PC += off if dst >= src (signed) */
974 /* PC += off if dst < src (signed) */
975 /* PC += off if dst <= src (signed) */
989 setup_jmp_r(ctx, dst == src, BPF_OP(code), off, &jmp, &rel);
990 emit_jmp_r(ctx, dst, src, rel, jmp);
994 /* PC += off if dst == imm */
995 /* PC += off if dst != imm */
996 /* PC += off if dst & imm */
997 /* PC += off if dst > imm */
998 /* PC += off if dst >= imm */
999 /* PC += off if dst < imm */
1000 /* PC += off if dst <= imm */
1001 /* PC += off if dst > imm (signed) */
1002 /* PC += off if dst >= imm (signed) */
1003 /* PC += off if dst < imm (signed) */
1004 /* PC += off if dst <= imm (signed) */
1020 emit_jmp_i(ctx, dst, imm, rel, jmp);
1024 emit_jmp_r(ctx, dst, MIPS_R_T4, rel, jmp);