Cranelift: division/remainder CLIF ops are scalar-only. (#4141)
In #4104 we discussed whether it makes sense for the division and remainder ops to support vector types. We concluded that because most hardware doesn't support it directly, it probably is not ideal to force all backends to polyfill it. In the future we can always reverse this decision, perhaps with a platform-independent legalization. This PR restricts the allowed types on the CLIF ops to integer types only.
This commit is contained in:
@@ -1913,68 +1913,77 @@ pub(crate) fn define(
|
|||||||
.operands_out(vec![qa]),
|
.operands_out(vec![qa]),
|
||||||
);
|
);
|
||||||
|
|
||||||
ig.push(
|
{
|
||||||
Inst::new(
|
// Integer division and remainder are scalar-only; most
|
||||||
"udiv",
|
// hardware does not directly support vector integer division.
|
||||||
r#"
|
|
||||||
Unsigned integer division: `a := \lfloor {x \over y} \rfloor`.
|
|
||||||
|
|
||||||
This operation traps if the divisor is zero.
|
let x = &Operand::new("x", iB);
|
||||||
"#,
|
let y = &Operand::new("y", iB);
|
||||||
&formats.binary,
|
let a = &Operand::new("a", iB);
|
||||||
)
|
|
||||||
.operands_in(vec![x, y])
|
|
||||||
.operands_out(vec![a])
|
|
||||||
.can_trap(true),
|
|
||||||
);
|
|
||||||
|
|
||||||
ig.push(
|
ig.push(
|
||||||
Inst::new(
|
Inst::new(
|
||||||
"sdiv",
|
"udiv",
|
||||||
r#"
|
r#"
|
||||||
Signed integer division rounded toward zero: `a := sign(xy)
|
Unsigned integer division: `a := \lfloor {x \over y} \rfloor`.
|
||||||
\lfloor {|x| \over |y|}\rfloor`.
|
|
||||||
|
|
||||||
This operation traps if the divisor is zero, or if the result is not
|
This operation traps if the divisor is zero.
|
||||||
representable in `B` bits two's complement. This only happens
|
"#,
|
||||||
when `x = -2^{B-1}, y = -1`.
|
&formats.binary,
|
||||||
"#,
|
)
|
||||||
&formats.binary,
|
.operands_in(vec![x, y])
|
||||||
)
|
.operands_out(vec![a])
|
||||||
.operands_in(vec![x, y])
|
.can_trap(true),
|
||||||
.operands_out(vec![a])
|
);
|
||||||
.can_trap(true),
|
|
||||||
);
|
|
||||||
|
|
||||||
ig.push(
|
ig.push(
|
||||||
Inst::new(
|
Inst::new(
|
||||||
"urem",
|
"sdiv",
|
||||||
r#"
|
r#"
|
||||||
Unsigned integer remainder.
|
Signed integer division rounded toward zero: `a := sign(xy)
|
||||||
|
\lfloor {|x| \over |y|}\rfloor`.
|
||||||
|
|
||||||
This operation traps if the divisor is zero.
|
This operation traps if the divisor is zero, or if the result is not
|
||||||
"#,
|
representable in `B` bits two's complement. This only happens
|
||||||
&formats.binary,
|
when `x = -2^{B-1}, y = -1`.
|
||||||
)
|
"#,
|
||||||
.operands_in(vec![x, y])
|
&formats.binary,
|
||||||
.operands_out(vec![a])
|
)
|
||||||
.can_trap(true),
|
.operands_in(vec![x, y])
|
||||||
);
|
.operands_out(vec![a])
|
||||||
|
.can_trap(true),
|
||||||
|
);
|
||||||
|
|
||||||
ig.push(
|
ig.push(
|
||||||
Inst::new(
|
Inst::new(
|
||||||
"srem",
|
"urem",
|
||||||
r#"
|
r#"
|
||||||
Signed integer remainder. The result has the sign of the dividend.
|
Unsigned integer remainder.
|
||||||
|
|
||||||
This operation traps if the divisor is zero.
|
This operation traps if the divisor is zero.
|
||||||
"#,
|
"#,
|
||||||
&formats.binary,
|
&formats.binary,
|
||||||
)
|
)
|
||||||
.operands_in(vec![x, y])
|
.operands_in(vec![x, y])
|
||||||
.operands_out(vec![a])
|
.operands_out(vec![a])
|
||||||
.can_trap(true),
|
.can_trap(true),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
ig.push(
|
||||||
|
Inst::new(
|
||||||
|
"srem",
|
||||||
|
r#"
|
||||||
|
Signed integer remainder. The result has the sign of the dividend.
|
||||||
|
|
||||||
|
This operation traps if the divisor is zero.
|
||||||
|
"#,
|
||||||
|
&formats.binary,
|
||||||
|
)
|
||||||
|
.operands_in(vec![x, y])
|
||||||
|
.operands_out(vec![a])
|
||||||
|
.can_trap(true),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let a = &Operand::new("a", iB);
|
let a = &Operand::new("a", iB);
|
||||||
let x = &Operand::new("x", iB);
|
let x = &Operand::new("x", iB);
|
||||||
|
|||||||
Reference in New Issue
Block a user