Lines Matching refs:imm
294 emit_immed(struct nfp_prog *nfp_prog, swreg dst, u16 imm, in emit_immed() argument
305 err = swreg_to_unrestricted(dst, dst, reg_imm(imm & 0xff), ®); in emit_immed()
314 reg.breg, imm >> 8, width, invert, shift, in emit_immed()
590 static bool pack_immed(u32 imm, u16 *val, enum immed_shift *shift) in pack_immed() argument
592 if (!(imm & 0xffff0000)) { in pack_immed()
593 *val = imm; in pack_immed()
595 } else if (!(imm & 0xff0000ff)) { in pack_immed()
596 *val = imm >> 8; in pack_immed()
598 } else if (!(imm & 0x0000ffff)) { in pack_immed()
599 *val = imm >> 16; in pack_immed()
608 static void wrp_immed(struct nfp_prog *nfp_prog, swreg dst, u32 imm) in wrp_immed() argument
613 if (pack_immed(imm, &val, &shift)) { in wrp_immed()
615 } else if (pack_immed(~imm, &val, &shift)) { in wrp_immed()
618 emit_immed(nfp_prog, dst, imm & 0xffff, IMMED_WIDTH_ALL, in wrp_immed()
620 emit_immed(nfp_prog, dst, imm >> 16, IMMED_WIDTH_WORD, in wrp_immed()
633 wrp_immed_relo(struct nfp_prog *nfp_prog, swreg dst, u32 imm, in wrp_immed_relo() argument
636 if (imm > 0xffff) { in wrp_immed_relo()
641 emit_immed(nfp_prog, dst, imm, IMMED_WIDTH_ALL, false, IMMED_SHIFT_0B); in wrp_immed_relo()
651 static swreg ur_load_imm_any(struct nfp_prog *nfp_prog, u32 imm, swreg tmp_reg) in ur_load_imm_any() argument
653 if (FIELD_FIT(UR_REG_IMM_MAX, imm)) in ur_load_imm_any()
654 return reg_imm(imm); in ur_load_imm_any()
656 wrp_immed(nfp_prog, tmp_reg, imm); in ur_load_imm_any()
664 static swreg re_load_imm_any(struct nfp_prog *nfp_prog, u32 imm, swreg tmp_reg) in re_load_imm_any() argument
666 if (FIELD_FIT(RE_REG_IMM_MAX, imm)) in re_load_imm_any()
667 return reg_imm(imm); in re_load_imm_any()
669 wrp_immed(nfp_prog, tmp_reg, imm); in re_load_imm_any()
1002 u64 imm, u8 size) in data_st_host_order() argument
1004 wrp_immed(nfp_prog, reg_xfer(0), imm); in data_st_host_order()
1006 wrp_immed(nfp_prog, reg_xfer(1), imm >> 32); in data_st_host_order()
1265 wrp_alu_imm(struct nfp_prog *nfp_prog, u8 dst, enum alu_op alu_op, u32 imm) in wrp_alu_imm() argument
1270 if (!imm) in wrp_alu_imm()
1272 if (!imm || !~imm) in wrp_alu_imm()
1276 if (!~imm) in wrp_alu_imm()
1278 if (!imm || !~imm) in wrp_alu_imm()
1282 if (!~imm) in wrp_alu_imm()
1285 if (!imm || !~imm) in wrp_alu_imm()
1289 tmp_reg = ur_load_imm_any(nfp_prog, imm, imm_b(nfp_prog)); in wrp_alu_imm()
1298 u64 imm = insn->imm; /* sign extend */ in wrp_alu64_imm() local
1305 wrp_alu_imm(nfp_prog, insn->dst_reg * 2, alu_op, imm & ~0U); in wrp_alu64_imm()
1306 wrp_alu_imm(nfp_prog, insn->dst_reg * 2 + 1, alu_op, imm >> 32); in wrp_alu64_imm()
1331 wrp_alu_imm(nfp_prog, dst, alu_op, insn->imm); in wrp_alu32_imm()
1403 u64 imm = insn->imm; /* sign extend */ in cmp_imm() local
1416 tmp_reg = ur_load_imm_any(nfp_prog, imm & ~0U, imm_b(nfp_prog)); in cmp_imm()
1423 tmp_reg = ur_load_imm_any(nfp_prog, imm >> 32, imm_b(nfp_prog)); in cmp_imm()
1518 u32 imm = insn->imm; in wrp_mul() local
1520 multiplier = ur_load_imm_any(nfp_prog, imm, imm_b(nfp_prog)); in wrp_mul()
1521 ropnd_max = imm; in wrp_mul()
1532 static int wrp_div_imm(struct nfp_prog *nfp_prog, u8 dst, u64 imm) in wrp_div_imm() argument
1539 if (imm > U32_MAX) { in wrp_div_imm()
1555 if (imm > 1U << 31) { in wrp_div_imm()
1556 swreg tmp_b = ur_load_imm_any(nfp_prog, imm, imm_b(nfp_prog)); in wrp_div_imm()
1565 rvalue = reciprocal_value_adv(imm, 32); in wrp_div_imm()
1567 if (rvalue.is_wide_m && !(imm & 1)) { in wrp_div_imm()
1568 pre_shift = fls(imm & -imm) - 1; in wrp_div_imm()
1569 rvalue = reciprocal_value_adv(imm >> pre_shift, 32 - pre_shift); in wrp_div_imm()
1574 if (imm == 1U << exp) { in wrp_div_imm()
1861 u64 imm = meta->insn.imm; /* sign extend */ in mov_imm64() local
1863 wrp_immed(nfp_prog, reg_both(meta->insn.dst_reg * 2), imm & ~0U); in mov_imm64()
1864 wrp_immed(nfp_prog, reg_both(meta->insn.dst_reg * 2 + 1), imm >> 32); in mov_imm64()
1876 return wrp_alu64_imm(nfp_prog, meta, ALU_OP_XOR, !meta->insn.imm); in xor_imm64()
1886 return wrp_alu64_imm(nfp_prog, meta, ALU_OP_AND, !~meta->insn.imm); in and_imm64()
1896 return wrp_alu64_imm(nfp_prog, meta, ALU_OP_OR, !meta->insn.imm); in or_imm64()
1916 u64 imm = insn->imm; /* sign extend */ in add_imm64() local
1918 wrp_alu_imm(nfp_prog, insn->dst_reg * 2, ALU_OP_ADD, imm & ~0U); in add_imm64()
1919 wrp_alu_imm(nfp_prog, insn->dst_reg * 2 + 1, ALU_OP_ADD_C, imm >> 32); in add_imm64()
1941 u64 imm = insn->imm; /* sign extend */ in sub_imm64() local
1943 wrp_alu_imm(nfp_prog, insn->dst_reg * 2, ALU_OP_SUB, imm & ~0U); in sub_imm64()
1944 wrp_alu_imm(nfp_prog, insn->dst_reg * 2 + 1, ALU_OP_SUB_C, imm >> 32); in sub_imm64()
1963 return wrp_div_imm(nfp_prog, insn->dst_reg * 2, insn->imm); in div_imm64()
2024 return __shl_imm64(nfp_prog, dst, insn->imm); in shl_imm64()
2138 return __shr_imm64(nfp_prog, dst, insn->imm); in shr_imm64()
2250 return __ashr_imm64(nfp_prog, dst, insn->imm); in ashr_imm64()
2340 wrp_immed(nfp_prog, reg_both(insn->dst_reg * 2), insn->imm); in mov_imm()
2471 return __ashr_imm(nfp_prog, meta, dst, insn->imm); in ashr_imm()
2490 return __shr_imm(nfp_prog, meta, dst, insn->imm); in shr_imm()
2529 return __shl_imm(nfp_prog, meta, dst, insn->imm); in shl_imm()
2555 switch (insn->imm) { in end_reg32()
2586 imm_lo = prev->insn.imm; in imm_ld8_part2()
2587 imm_hi = meta->insn.imm; in imm_ld8_part2()
2608 return construct_data_ld(nfp_prog, meta, meta->insn.imm, 1); in data_ld1()
2613 return construct_data_ld(nfp_prog, meta, meta->insn.imm, 2); in data_ld2()
2618 return construct_data_ld(nfp_prog, meta, meta->insn.imm, 4); in data_ld4()
2623 return construct_data_ind_ld(nfp_prog, meta, meta->insn.imm, in data_ind_ld1()
2629 return construct_data_ind_ld(nfp_prog, meta, meta->insn.imm, in data_ind_ld2()
2635 return construct_data_ind_ld(nfp_prog, meta, meta->insn.imm, in data_ind_ld4()
2910 u64 imm = meta->insn.imm; /* sign extend */ in mem_st_data() local
2916 imm, size); in mem_st_data()
3114 if (meta->insn.imm != BPF_ADD) in mem_atomic4()
3122 if (meta->insn.imm != BPF_ADD) in mem_atomic8()
3138 u64 imm = insn->imm; /* sign extend */ in jeq_imm() local
3144 if (imm & ~0U) { in jeq_imm()
3145 tmp_reg = ur_load_imm_any(nfp_prog, imm & ~0U, imm_b(nfp_prog)); in jeq_imm()
3151 if (imm >> 32) { in jeq_imm()
3152 tmp_reg = ur_load_imm_any(nfp_prog, imm >> 32, imm_b(nfp_prog)); in jeq_imm()
3169 tmp_reg = ur_load_imm_any(nfp_prog, insn->imm, imm_b(nfp_prog)); in jeq32_imm()
3180 u64 imm = insn->imm; /* sign extend */ in jset_imm() local
3184 tmp_reg = ur_load_imm_any(nfp_prog, imm & ~0U, imm_b(nfp_prog)); in jset_imm()
3190 if (is_mbpf_jmp64(meta) && imm >> 32) { in jset_imm()
3202 u64 imm = insn->imm; /* sign extend */ in jne_imm() local
3206 if (!imm) { in jne_imm()
3217 tmp_reg = ur_load_imm_any(nfp_prog, imm & ~0U, imm_b(nfp_prog)); in jne_imm()
3225 tmp_reg = ur_load_imm_any(nfp_prog, imm >> 32, imm_b(nfp_prog)); in jne_imm()
3323 emit_br(nfp_prog, BR_UNC, meta->insn.imm, 1); in bpf_to_bpf_call()
3349 switch (meta->insn.imm) { in helper_call()
3928 if (insn.imm >= 0) in nfp_bpf_opt_neg_add_sub()
3953 meta->insn.imm = -insn.imm; in nfp_bpf_opt_neg_add_sub()
3984 if (exp_mask[BPF_SIZE(insn.code)] != next.imm) in nfp_bpf_opt_ld_mask()
4026 if (next1.imm != 0x20 || next2.imm != 0x20) in nfp_bpf_opt_ld_shift()
4419 map = (void *)(unsigned long)((u32)meta1->insn.imm | in nfp_bpf_replace_map_ptrs()
4420 (u64)meta2->insn.imm << 32); in nfp_bpf_replace_map_ptrs()
4428 meta1->insn.imm = id; in nfp_bpf_replace_map_ptrs()
4429 meta2->insn.imm = 0; in nfp_bpf_replace_map_ptrs()
4515 dst_idx = meta->n + 1 + meta->insn.imm; in nfp_bpf_jit_prepare()