cranelift: Restrict br_table to i32 indices (#4510)
* cranelift: Restrict `br_table` to `i32` indices In #4498 it was proposed that we should only accept `i32` indices to `br_table`. The rationale for this is that larger types lead the users to a false sense of flexibility (since we don't support jump tables larger than u32's), and narrower types are not well tested paths that would be safer if we removed them. * cranelift: Reduce directly from i128 to i32 in Switch
This commit is contained in:
@@ -157,7 +157,12 @@ fn define_control_flow(
|
||||
}
|
||||
|
||||
{
|
||||
let x = &Operand::new("x", iB).with_doc("index into jump table");
|
||||
let _i32 = &TypeVar::new(
|
||||
"i32",
|
||||
"A 32 bit scalar integer type",
|
||||
TypeSetBuilder::new().ints(32..32).build(),
|
||||
);
|
||||
let x = &Operand::new("x", _i32).with_doc("i32 index into jump table");
|
||||
let JT = &Operand::new("JT", &entities.jump_table);
|
||||
|
||||
ig.push(
|
||||
|
||||
@@ -3244,19 +3244,13 @@ impl LowerBackend for X64Backend {
|
||||
let jt_size = jt_size as u32;
|
||||
|
||||
let ty = ctx.input_ty(branches[0], 0);
|
||||
let ext_spec = match ty {
|
||||
types::I128 => panic!("BrTable unimplemented for I128"),
|
||||
types::I64 => ExtSpec::ZeroExtendTo64,
|
||||
_ => ExtSpec::ZeroExtendTo32,
|
||||
};
|
||||
|
||||
let idx = extend_input_to_reg(
|
||||
ctx,
|
||||
InsnInput {
|
||||
insn: branches[0],
|
||||
input: 0,
|
||||
},
|
||||
ext_spec,
|
||||
ExtSpec::ZeroExtendTo32,
|
||||
);
|
||||
|
||||
// Emit the compound instruction that does:
|
||||
|
||||
Reference in New Issue
Block a user