Skip to content

Commit

Permalink
Modifies fcvt_to_sint and fcvt_to_unit clif to make scalar only (byte…
Browse files Browse the repository at this point in the history
  • Loading branch information
jlb6740 authored Aug 29, 2022
1 parent 573ae0c commit 6368c6b
Showing 1 changed file with 28 additions and 22 deletions.
50 changes: 28 additions & 22 deletions cranelift/codegen/meta/src/shared/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2159,7 +2159,7 @@ pub(crate) fn define(
"irsub_imm",
r#"
Immediate reverse wrapping subtraction: `a := Y - x \pmod{2^B}`.
The immediate operand is a sign extended 64 bit constant.
Also works as integer negation when `Y = 0`. Use `iadd_imm`
Expand Down Expand Up @@ -3845,20 +3845,24 @@ pub(crate) fn define(
.operands_out(vec![x]),
);

let x = &Operand::new("x", Float);
let FloatScalar = &TypeVar::new(
"FloatScalar",
"A scalar only floating point number",
TypeSetBuilder::new().floats(Interval::All).build(),
);
let x = &Operand::new("x", FloatScalar);
let a = &Operand::new("a", IntTo);

ig.push(
Inst::new(
"fcvt_to_uint",
r#"
Convert floating point to unsigned integer.
Converts floating point scalars to unsigned integer.
Each lane in `x` is converted to an unsigned integer by rounding
towards zero. If `x` is NaN or if the unsigned integral value cannot be
represented in the result type, this instruction traps.
Only operates on `x` if it is a scalar. If `x` is NaN or if
the unsigned integral value cannot be represented in the result
type, this instruction traps.
The result type must have the same number of vector lanes as the input.
"#,
&formats.unary,
)
Expand All @@ -3869,35 +3873,37 @@ pub(crate) fn define(

ig.push(
Inst::new(
"fcvt_to_uint_sat",
"fcvt_to_sint",
r#"
Convert floating point to unsigned integer as fcvt_to_uint does, but
saturates the input instead of trapping. NaN and negative values are
converted to 0.
Converts floating point scalars to signed integer.
Only operates on `x` if it is a scalar. If `x` is NaN or if
the unsigned integral value cannot be represented in the result
type, this instruction traps.
"#,
&formats.unary,
)
.operands_in(vec![x])
.operands_out(vec![a]),
.operands_out(vec![a])
.can_trap(true),
);

let x = &Operand::new("x", Float);
let a = &Operand::new("a", IntTo);

ig.push(
Inst::new(
"fcvt_to_sint",
"fcvt_to_uint_sat",
r#"
Convert floating point to signed integer.
Each lane in `x` is converted to a signed integer by rounding towards
zero. If `x` is NaN or if the signed integral value cannot be
represented in the result type, this instruction traps.
The result type must have the same number of vector lanes as the input.
Convert floating point to unsigned integer as fcvt_to_uint does, but
saturates the input instead of trapping. NaN and negative values are
converted to 0.
"#,
&formats.unary,
)
.operands_in(vec![x])
.operands_out(vec![a])
.can_trap(true),
.operands_out(vec![a]),
);

ig.push(
Expand Down

0 comments on commit 6368c6b

Please sign in to comment.