Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions cranelift/codegen/meta/src/shared/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,8 @@ pub(crate) fn define(
.operands_in(vec![Operand::new("x", iB), Operand::new("y", iB)])
.operands_out(vec![Operand::new("a", iB)])
.can_trap()
.side_effects_idempotent(),
.side_effects_idempotent()
.inst_builder_imm_method(true),
);

ig.push(
Expand Down Expand Up @@ -1981,22 +1982,6 @@ pub(crate) fn define(
.side_effects_idempotent(),
);

ig.push(
Inst::new(
"udiv_imm",
r#"
Unsigned integer division by an immediate constant.

Same as `udiv`, but one operand is a zero extended 64 bit immediate constant.

This operation traps if the divisor is zero.
"#,
&formats.binary_imm64,
)
.operands_in(vec![Operand::new("x", iB), Operand::new("Y", &imm.imm64)])
.operands_out(vec![Operand::new("a", iB)]),
);

ig.push(
Inst::new(
"sdiv_imm",
Expand Down
3 changes: 0 additions & 3 deletions cranelift/codegen/src/legalizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,6 @@ fn expand_binary_imm64(
ir::Opcode::SremImm => {
replace.srem(arg, imm);
}
ir::Opcode::UdivImm => {
replace.udiv(arg, imm);
}
ir::Opcode::UremImm => {
replace.urem(arg, imm);
}
Expand Down
12 changes: 0 additions & 12 deletions cranelift/codegen/src/souper_harvest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ fn harvest_candidate_lhs(
| ir::Opcode::IrsubImm
| ir::Opcode::Imul
| ir::Opcode::Udiv
| ir::Opcode::UdivImm
| ir::Opcode::Sdiv
| ir::Opcode::SdivImm
| ir::Opcode::Urem
Expand Down Expand Up @@ -204,17 +203,6 @@ fn harvest_candidate_lhs(
let b = arg(allocs, 1);
ast::Instruction::Udiv { a, b }.into()
}
(ir::Opcode::UdivImm, ir::InstructionData::BinaryImm64 { imm, .. }) => {
let a = arg(allocs, 0);
let value: i64 = (*imm).into();
let value: i128 = value.into();
let b = ast::Constant {
value,
r#type: souper_type_of(&func.dfg, val),
}
.into();
ast::Instruction::Udiv { a, b }.into()
}
(ir::Opcode::Sdiv, _) => {
let a = arg(allocs, 0);
let b = arg(allocs, 1);
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/src/verifier/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
//! Ad hoc checking
//!
//! - Stack slot loads and stores must be in-bounds.
//! - Immediate constraints for certain opcodes, like `udiv_imm v3, 0`.
//! - Immediate constraints for certain opcodes, like `iconst.i8 1234`.
//! - `Insertlane` and `extractlane` instructions have immediate lane numbers that must be in
//! range for their polymorphic type.
//! - Swizzle and shuffle instructions take a variable number of lane arguments. The number
Expand Down
1 change: 0 additions & 1 deletion cranelift/fuzzgen/src/function_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,6 @@ static OPCODE_SIGNATURES: LazyLock<Vec<OpcodeSignature>> = LazyLock::new(|| {
(Opcode::GetReturnAddress),
(Opcode::Blendv),
(Opcode::X86Pmulhrsw),
(Opcode::UdivImm),
(Opcode::SdivImm),
(Opcode::UremImm),
(Opcode::SremImm),
Expand Down
3 changes: 2 additions & 1 deletion cranelift/interpreter/src/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ mod tests {
let code = "function %test() -> i32 {
block0:
v0 = iconst.i32 1
v1 = udiv_imm.i32 v0, 0
v2 = iconst.i32 0
v1 = udiv v0, v2
return v1
}";

Expand Down
1 change: 0 additions & 1 deletion cranelift/interpreter/src/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,6 @@ where
Opcode::Sdiv => binary_can_trap(DataValueExt::sdiv, arg(0), arg(1))?,
Opcode::Urem => binary_can_trap(DataValueExt::urem, arg(0), arg(1))?,
Opcode::Srem => binary_can_trap(DataValueExt::srem, arg(0), arg(1))?,
Opcode::UdivImm => binary_can_trap(DataValueExt::udiv, arg(0), imm_as_ctrl_ty()?)?,
Opcode::SdivImm => binary_can_trap(DataValueExt::sdiv, arg(0), imm_as_ctrl_ty()?)?,
Opcode::UremImm => binary_can_trap(DataValueExt::urem, arg(0), imm_as_ctrl_ty()?)?,
Opcode::SremImm => binary_can_trap(DataValueExt::srem, arg(0), imm_as_ctrl_ty()?)?,
Expand Down
Loading