Lines Matching refs:imm

173 /* dst = imm (sign-extended) */
174 static void emit_mov_se_i64(struct jit_context *ctx, const u8 dst[], s32 imm)
176 emit_mov_i(ctx, lo(dst), imm);
177 if (imm < 0)
202 const u8 dst[], s32 imm, u8 op)
207 * ADD/SUB with all but the max negative imm can be handled by
208 * inverting the operation and the imm value, saving one insn.
210 if (imm > S32_MIN && imm < 0)
214 imm = -imm;
218 imm = -imm;
223 emit_mov_i(ctx, src, imm);
226 /* dst = dst + imm */
231 if (imm < 0)
234 /* dst = dst - imm */
239 if (imm < 0)
242 /* dst = dst | imm */
245 if (imm < 0)
248 /* dst = dst & imm */
251 if (imm >= 0)
254 /* dst = dst ^ imm */
257 if (imm < 0) {
322 const u8 dst[], u32 imm, u8 op)
325 /* dst = dst << imm */
327 if (imm < 32) {
328 emit(ctx, srl, MIPS_R_T9, lo(dst), 32 - imm);
329 emit(ctx, sll, lo(dst), lo(dst), imm);
330 emit(ctx, sll, hi(dst), hi(dst), imm);
333 emit(ctx, sll, hi(dst), lo(dst), imm - 32);
337 /* dst = dst >> imm */
339 if (imm < 32) {
340 emit(ctx, sll, MIPS_R_T9, hi(dst), 32 - imm);
341 emit(ctx, srl, lo(dst), lo(dst), imm);
342 emit(ctx, srl, hi(dst), hi(dst), imm);
345 emit(ctx, srl, lo(dst), hi(dst), imm - 32);
349 /* dst = dst >> imm (arithmetic) */
351 if (imm < 32) {
352 emit(ctx, sll, MIPS_R_T9, hi(dst), 32 - imm);
353 emit(ctx, srl, lo(dst), lo(dst), imm);
354 emit(ctx, sra, hi(dst), hi(dst), imm);
357 emit(ctx, sra, lo(dst), hi(dst), imm - 32);
423 static void emit_mul_i64(struct jit_context *ctx, const u8 dst[], s32 imm)
428 switch (imm) {
442 /* hi(dst) = hi(dst) * src(imm) */
443 emit_mov_i(ctx, src, imm);
452 if (imm < 0)
455 /* tmp = lo(dst) * src(imm) >> 32 */
456 /* lo(dst) = lo(dst) * src(imm) */
989 /* Emulation of 64-bit sltiu rd, rs, imm, where imm may be S32_MAX + 1 */
991 const u8 rs[], s64 imm)
995 if (imm < 0) {
996 emit_mov_i(ctx, rd, imm); /* rd = imm */
1000 } else { /* imm >= 0 */
1001 if (imm > 0x7fff) {
1002 emit_mov_i(ctx, rd, (s32)imm); /* rd = imm */
1005 emit(ctx, sltiu, rd, lo(rs), imm); /* rd = rsl < imm */
1024 /* Emulation of 64-bit slti rd, rs, imm, where imm may be S32_MAX + 1 */
1026 const u8 rs[], s64 imm)
1033 * if ((rs < 0) ^ (imm < 0)) t1 = imm >u rsl
1034 * else t1 = rsl <u imm
1036 emit_mov_i(ctx, rd, (s32)imm);
1037 emit(ctx, sltu, t1, lo(rs), rd); /* t1 = rsl <u imm */
1038 emit(ctx, sltu, t2, rd, lo(rs)); /* t2 = imm <u rsl */
1040 if (imm < 0)
1045 * if ((imm < 0 && rsh != 0xffffffff) ||
1046 * (imm >= 0 && rsh != 0))
1049 if (imm < 0) {
1052 } else { /* imm >= 0 */
1058 * if (imm < 0) rd = rsh < -1
1062 emit(ctx, slti, rd, hi(rs), imm < 0 ? -1 : 0); /* rd = rsh < hi(imm) */
1093 const u8 dst[], s32 imm, s32 off, u8 op)
1101 /* PC += off if dst == imm */
1102 /* PC += off if dst != imm */
1105 if (imm >= -0x7fff && imm <= 0x8000) {
1106 emit(ctx, addiu, tmp, lo(dst), -imm);
1107 } else if ((u32)imm <= 0xffff) {
1108 emit(ctx, xori, tmp, lo(dst), imm);
1110 emit_mov_i(ctx, tmp, imm);
1113 if (imm < 0) { /* Compare sign extension */
1124 /* PC += off if dst & imm */
1125 /* PC += off if (dst & imm) == 0 (not in BPF, used for long jumps) */
1128 if ((u32)imm <= 0xffff) {
1129 emit(ctx, andi, tmp, lo(dst), imm);
1131 emit_mov_i(ctx, tmp, imm);
1134 if (imm < 0) /* Sign-extension pulls in high word */
1141 /* PC += off if dst > imm */
1143 emit_sltiu_r64(ctx, tmp, dst, (s64)imm + 1);
1146 /* PC += off if dst >= imm */
1148 emit_sltiu_r64(ctx, tmp, dst, imm);
1151 /* PC += off if dst < imm */
1153 emit_sltiu_r64(ctx, tmp, dst, imm);
1156 /* PC += off if dst <= imm */
1158 emit_sltiu_r64(ctx, tmp, dst, (s64)imm + 1);
1161 /* PC += off if dst > imm (signed) */
1163 emit_slti_r64(ctx, tmp, dst, (s64)imm + 1);
1166 /* PC += off if dst >= imm (signed) */
1168 emit_slti_r64(ctx, tmp, dst, imm);
1171 /* PC += off if dst < imm (signed) */
1173 emit_slti_r64(ctx, tmp, dst, imm);
1176 /* PC += off if dst <= imm (signed) */
1178 emit_slti_r64(ctx, tmp, dst, (s64)imm + 1);
1208 /* PC += off if (dst & imm) == 0 (not in BPF, used for long jumps) */
1471 s32 imm = insn->imm;
1477 /* dst = imm */
1479 emit_mov_i(ctx, lo(dst), imm);
1484 if (imm == 1) {
1497 /* dst = dst & imm */
1498 /* dst = dst | imm */
1499 /* dst = dst ^ imm */
1500 /* dst = dst << imm */
1501 /* dst = dst >> imm */
1502 /* dst = dst >> imm (arithmetic) */
1503 /* dst = dst + imm */
1504 /* dst = dst - imm */
1505 /* dst = dst * imm */
1506 /* dst = dst / imm */
1507 /* dst = dst % imm */
1519 if (!valid_alu_i(BPF_OP(code), imm)) {
1520 emit_mov_i(ctx, MIPS_R_T6, imm);
1522 } else if (rewrite_alu_i(BPF_OP(code), imm, &alu, &val)) {
1552 /* dst = imm (64-bit) */
1554 emit_mov_se_i64(ctx, dst, imm);
1565 /* dst = dst & imm (64-bit) */
1567 emit_alu_i64(ctx, dst, imm, BPF_OP(code));
1569 /* dst = dst | imm (64-bit) */
1570 /* dst = dst ^ imm (64-bit) */
1571 /* dst = dst + imm (64-bit) */
1572 /* dst = dst - imm (64-bit) */
1577 if (imm)
1578 emit_alu_i64(ctx, dst, imm, BPF_OP(code));
1580 /* dst = dst << imm (64-bit) */
1581 /* dst = dst >> imm (64-bit) */
1582 /* dst = dst >> imm (64-bit, arithmetic) */
1586 if (imm)
1587 emit_shift_i64(ctx, dst, imm, BPF_OP(code));
1589 /* dst = dst * imm (64-bit) */
1591 emit_mul_i64(ctx, dst, imm);
1593 /* dst = dst / imm (64-bit) */
1594 /* dst = dst % imm (64-bit) */
1601 emit_mov_se_i64(ctx, tmp, imm);
1645 emit_bswap_r64(ctx, dst, imm);
1647 emit_trunc_r64(ctx, dst, imm);
1651 emit_mov_i(ctx, lo(dst), imm);
1652 emit_mov_i(ctx, hi(dst), insn[1].imm);
1661 /* ST: *(size *)(dst + off) = imm */
1669 emit_mov_se_i64(ctx, tmp, imm);
1674 emit_mov_i(ctx, lo(tmp), imm);
1691 switch (imm) {
1702 emit_atomic_r(ctx, lo(dst), lo(src), off, imm);
1705 off, imm);
1706 if (imm & BPF_FETCH)
1723 switch (imm) {
1733 emit_atomic_r64(ctx, lo(dst), src, off, imm);
1771 /* PC += off if dst == imm */
1772 /* PC += off if dst != imm */
1773 /* PC += off if dst & imm */
1774 /* PC += off if dst > imm */
1775 /* PC += off if dst >= imm */
1776 /* PC += off if dst < imm */
1777 /* PC += off if dst <= imm */
1778 /* PC += off if dst > imm (signed) */
1779 /* PC += off if dst >= imm (signed) */
1780 /* PC += off if dst < imm (signed) */
1781 /* PC += off if dst <= imm (signed) */
1795 setup_jmp_i(ctx, imm, 32, BPF_OP(code), off, &jmp, &rel);
1796 if (valid_jmp_i(jmp, imm)) {
1797 emit_jmp_i(ctx, lo(dst), imm, rel, jmp);
1800 emit_mov_i(ctx, MIPS_R_T6, imm);
1835 /* PC += off if dst == imm */
1836 /* PC += off if dst != imm */
1837 /* PC += off if dst & imm */
1838 /* PC += off if dst > imm */
1839 /* PC += off if dst >= imm */
1840 /* PC += off if dst < imm */
1841 /* PC += off if dst <= imm */
1842 /* PC += off if dst > imm (signed) */
1843 /* PC += off if dst >= imm (signed) */
1844 /* PC += off if dst < imm (signed) */
1845 /* PC += off if dst <= imm (signed) */
1859 setup_jmp_i(ctx, imm, 64, BPF_OP(code), off, &jmp, &rel);
1860 emit_jmp_i64(ctx, dst, imm, rel, jmp);