LoongArch: BPF: Support signed mod instructions
Add support for signed mod instructions. Signed-off-by: Hengqi Chen <hengqi.chen@gmail.com> Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
This commit is contained in:
parent
2425c9e002
commit
7b6b13d329
|
@ -588,20 +588,36 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
|
||||||
/* dst = dst % src */
|
/* dst = dst % src */
|
||||||
case BPF_ALU | BPF_MOD | BPF_X:
|
case BPF_ALU | BPF_MOD | BPF_X:
|
||||||
case BPF_ALU64 | BPF_MOD | BPF_X:
|
case BPF_ALU64 | BPF_MOD | BPF_X:
|
||||||
|
if (!off) {
|
||||||
emit_zext_32(ctx, dst, is32);
|
emit_zext_32(ctx, dst, is32);
|
||||||
move_reg(ctx, t1, src);
|
move_reg(ctx, t1, src);
|
||||||
emit_zext_32(ctx, t1, is32);
|
emit_zext_32(ctx, t1, is32);
|
||||||
emit_insn(ctx, moddu, dst, dst, t1);
|
emit_insn(ctx, moddu, dst, dst, t1);
|
||||||
emit_zext_32(ctx, dst, is32);
|
emit_zext_32(ctx, dst, is32);
|
||||||
|
} else {
|
||||||
|
emit_sext_32(ctx, dst, is32);
|
||||||
|
move_reg(ctx, t1, src);
|
||||||
|
emit_sext_32(ctx, t1, is32);
|
||||||
|
emit_insn(ctx, modd, dst, dst, t1);
|
||||||
|
emit_sext_32(ctx, dst, is32);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* dst = dst % imm */
|
/* dst = dst % imm */
|
||||||
case BPF_ALU | BPF_MOD | BPF_K:
|
case BPF_ALU | BPF_MOD | BPF_K:
|
||||||
case BPF_ALU64 | BPF_MOD | BPF_K:
|
case BPF_ALU64 | BPF_MOD | BPF_K:
|
||||||
|
if (!off) {
|
||||||
move_imm(ctx, t1, imm, is32);
|
move_imm(ctx, t1, imm, is32);
|
||||||
emit_zext_32(ctx, dst, is32);
|
emit_zext_32(ctx, dst, is32);
|
||||||
emit_insn(ctx, moddu, dst, dst, t1);
|
emit_insn(ctx, moddu, dst, dst, t1);
|
||||||
emit_zext_32(ctx, dst, is32);
|
emit_zext_32(ctx, dst, is32);
|
||||||
|
} else {
|
||||||
|
move_imm(ctx, t1, imm, false);
|
||||||
|
emit_sext_32(ctx, t1, is32);
|
||||||
|
emit_sext_32(ctx, dst, is32);
|
||||||
|
emit_insn(ctx, modd, dst, dst, t1);
|
||||||
|
emit_sext_32(ctx, dst, is32);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* dst = -dst */
|
/* dst = -dst */
|
||||||
|
|
Loading…
Reference in New Issue