Add new Cranelift instructions for integer min/max
This includes legalizations to the previously-existing x86 SIMD integer min/max.
This commit is contained in:
@@ -481,6 +481,75 @@ fn define_control_flow(
|
||||
);
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
fn define_simd_arithmetic(
|
||||
ig: &mut InstructionGroupBuilder,
|
||||
formats: &Formats,
|
||||
_: &Immediates,
|
||||
_: &EntityRefs,
|
||||
) {
|
||||
let Int = &TypeVar::new(
|
||||
"Int",
|
||||
"A scalar or vector integer type",
|
||||
TypeSetBuilder::new()
|
||||
.ints(Interval::All)
|
||||
.simd_lanes(Interval::All)
|
||||
.build(),
|
||||
);
|
||||
|
||||
let a = &Operand::new("a", Int);
|
||||
let x = &Operand::new("x", Int);
|
||||
let y = &Operand::new("y", Int);
|
||||
|
||||
ig.push(
|
||||
Inst::new(
|
||||
"imin",
|
||||
r#"
|
||||
Signed integer minimum.
|
||||
"#,
|
||||
&formats.binary,
|
||||
)
|
||||
.operands_in(vec![x, y])
|
||||
.operands_out(vec![a]),
|
||||
);
|
||||
|
||||
ig.push(
|
||||
Inst::new(
|
||||
"umin",
|
||||
r#"
|
||||
Unsigned integer minimum.
|
||||
"#,
|
||||
&formats.binary,
|
||||
)
|
||||
.operands_in(vec![x, y])
|
||||
.operands_out(vec![a]),
|
||||
);
|
||||
|
||||
ig.push(
|
||||
Inst::new(
|
||||
"imax",
|
||||
r#"
|
||||
Signed integer maximum.
|
||||
"#,
|
||||
&formats.binary,
|
||||
)
|
||||
.operands_in(vec![x, y])
|
||||
.operands_out(vec![a]),
|
||||
);
|
||||
|
||||
ig.push(
|
||||
Inst::new(
|
||||
"umax",
|
||||
r#"
|
||||
Unsigned integer maximum.
|
||||
"#,
|
||||
&formats.binary,
|
||||
)
|
||||
.operands_in(vec![x, y])
|
||||
.operands_out(vec![a]),
|
||||
);
|
||||
}
|
||||
|
||||
#[allow(clippy::many_single_char_names)]
|
||||
pub(crate) fn define(
|
||||
all_instructions: &mut AllInstructions,
|
||||
@@ -491,6 +560,7 @@ pub(crate) fn define(
|
||||
let mut ig = InstructionGroupBuilder::new(all_instructions);
|
||||
|
||||
define_control_flow(&mut ig, formats, imm, entities);
|
||||
define_simd_arithmetic(&mut ig, formats, imm, entities);
|
||||
|
||||
// Operand kind shorthands.
|
||||
let iflags: &TypeVar = &ValueType::Special(types::Flag::IFlags.into()).into();
|
||||
|
||||
Reference in New Issue
Block a user