cranelift: Add ireduce/iconcat/isplit to the clif fuzzer (#4703)

* cranelift: Add ireduce to fuzzer

* cranelift: Add iconcat/isplit to fuzzer
This commit is contained in:
Afonso Bordado
2022-08-15 17:18:08 +01:00
committed by GitHub
parent 7ddb90d990
commit c6d2a3f94e
2 changed files with 28 additions and 3 deletions

View File

@@ -1942,7 +1942,7 @@ fn lower_insn_to_regs(
assert_eq!( assert_eq!(
ty, ty,
types::I128, types::I128,
"Iconcat not expected to be used for non-128-bit type" "Isplit not expected to be used for non-128-bit type"
); );
assert_eq!(ctx.output_ty(insn, 0), types::I64); assert_eq!(ctx.output_ty(insn, 0), types::I64);
assert_eq!(ctx.output_ty(insn, 1), types::I64); assert_eq!(ctx.output_ty(insn, 1), types::I64);

View File

@@ -30,8 +30,18 @@ fn insert_opcode(
arg_vals.push(val, &mut builder.func.dfg.value_lists); arg_vals.push(val, &mut builder.func.dfg.value_lists);
} }
let typevar = rets.first().copied().unwrap_or(INVALID); // For pretty much every instruction the control type is the return type
let (inst, dfg) = builder.ins().MultiAry(opcode, typevar, arg_vals); // except for Iconcat and Isplit which are *special* and the control type
// is the input type.
let ctrl_type = if opcode == Opcode::Iconcat || opcode == Opcode::Isplit {
args.first()
} else {
rets.first()
}
.copied()
.unwrap_or(INVALID);
let (inst, dfg) = builder.ins().MultiAry(opcode, ctrl_type, arg_vals);
let results = dfg.inst_results(inst).to_vec(); let results = dfg.inst_results(inst).to_vec();
for (val, &ty) in results.into_iter().zip(rets) { for (val, &ty) in results.into_iter().zip(rets) {
@@ -315,6 +325,21 @@ const OPCODE_SIGNATURES: &'static [(
(Opcode::Sextend, &[I32], &[I64], insert_opcode), (Opcode::Sextend, &[I32], &[I64], insert_opcode),
(Opcode::Sextend, &[I32], &[I128], insert_opcode), (Opcode::Sextend, &[I32], &[I128], insert_opcode),
(Opcode::Sextend, &[I64], &[I128], insert_opcode), (Opcode::Sextend, &[I64], &[I128], insert_opcode),
// Ireduce
(Opcode::Ireduce, &[I16], &[I8], insert_opcode),
(Opcode::Ireduce, &[I32], &[I8], insert_opcode),
(Opcode::Ireduce, &[I32], &[I16], insert_opcode),
(Opcode::Ireduce, &[I64], &[I8], insert_opcode),
(Opcode::Ireduce, &[I64], &[I16], insert_opcode),
(Opcode::Ireduce, &[I64], &[I32], insert_opcode),
(Opcode::Ireduce, &[I128], &[I8], insert_opcode),
(Opcode::Ireduce, &[I128], &[I16], insert_opcode),
(Opcode::Ireduce, &[I128], &[I32], insert_opcode),
(Opcode::Ireduce, &[I128], &[I64], insert_opcode),
// Isplit
(Opcode::Isplit, &[I128], &[I64, I64], insert_opcode),
// Iconcat
(Opcode::Iconcat, &[I64, I64], &[I128], insert_opcode),
// Fadd // Fadd
(Opcode::Fadd, &[F32, F32], &[F32], insert_opcode), (Opcode::Fadd, &[F32, F32], &[F32], insert_opcode),
(Opcode::Fadd, &[F64, F64], &[F64], insert_opcode), (Opcode::Fadd, &[F64, F64], &[F64], insert_opcode),