From 74261ccd791e7f83382ca8b77149c7704c6d9cca Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 31 Oct 2021 18:47:13 +0100 Subject: [PATCH 1/7] Never use the first vararg as typevar operand If an instruction only takes varargs as values, it may have no arguments at all. --- cranelift/codegen/meta/src/cdsl/formats.rs | 4 +-- cranelift/codegen/meta/src/gen_inst.rs | 30 ++++++++++------------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/cranelift/codegen/meta/src/cdsl/formats.rs b/cranelift/codegen/meta/src/cdsl/formats.rs index d445a4ed7e..6cd20ecae6 100644 --- a/cranelift/codegen/meta/src/cdsl/formats.rs +++ b/cranelift/codegen/meta/src/cdsl/formats.rs @@ -133,7 +133,7 @@ impl InstructionFormatBuilder { pub fn typevar_operand(mut self, operand_index: usize) -> Self { assert!(self.typevar_operand.is_none()); - assert!(self.has_value_list || operand_index < self.num_value_operands); + assert!(operand_index < self.num_value_operands); self.typevar_operand = Some(operand_index); self } @@ -141,7 +141,7 @@ impl InstructionFormatBuilder { pub fn build(self) -> Rc { let typevar_operand = if self.typevar_operand.is_some() { self.typevar_operand - } else if self.has_value_list || self.num_value_operands > 0 { + } else if self.num_value_operands > 0 { // Default to the first value operand, if there's one. Some(0) } else { diff --git a/cranelift/codegen/meta/src/gen_inst.rs b/cranelift/codegen/meta/src/gen_inst.rs index f3c5f642a1..887ef878ad 100644 --- a/cranelift/codegen/meta/src/gen_inst.rs +++ b/cranelift/codegen/meta/src/gen_inst.rs @@ -75,14 +75,12 @@ fn gen_instruction_data(formats: &[&InstructionFormat], fmt: &mut Formatter) { fmtln!(fmt, "{} {{", format.name); fmt.indent(|fmt| { fmt.line("opcode: Opcode,"); - if format.typevar_operand.is_some() { - if format.has_value_list { - fmt.line("args: ValueList,"); - } else if format.num_value_operands == 1 { - fmt.line("arg: Value,"); - } else { - fmtln!(fmt, "args: [Value; {}],", format.num_value_operands); - } + if format.has_value_list { + fmt.line("args: ValueList,"); + } else if format.num_value_operands == 1 { + fmt.line("arg: Value,"); + } else if format.num_value_operands > 0 { + fmtln!(fmt, "args: [Value; {}],", format.num_value_operands); } for field in &format.imm_fields { fmtln!(fmt, "{}: {},", field.member, field.kind.rust_type); @@ -287,17 +285,17 @@ fn gen_instruction_data_impl(formats: &[&InstructionFormat], fmt: &mut Formatter let name = format!("&Self::{}", format.name); let mut members = vec!["opcode"]; - let args_eq = if format.typevar_operand.is_none() { - None - } else if format.has_value_list { + let args_eq = if format.has_value_list { members.push("args"); Some("args1.as_slice(pool) == args2.as_slice(pool)") } else if format.num_value_operands == 1 { members.push("arg"); Some("arg1 == arg2") - } else { + } else if format.num_value_operands > 0 { members.push("args"); Some("args1 == args2") + } else { + None }; for field in &format.imm_fields { @@ -339,17 +337,17 @@ fn gen_instruction_data_impl(formats: &[&InstructionFormat], fmt: &mut Formatter let name = format!("Self::{}", format.name); let mut members = vec!["opcode"]; - let args = if format.typevar_operand.is_none() { - "&()" - } else if format.has_value_list { + let args = if format.has_value_list { members.push("ref args"); "args.as_slice(pool)" } else if format.num_value_operands == 1 { members.push("ref arg"); "arg" - } else { + } else if format.num_value_operands > 0{ members.push("ref args"); "args" + } else { + "&()" }; for field in &format.imm_fields { From 2fbd57e9e21541abc2f1f724add3783a4b6f7d08 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 31 Oct 2021 18:48:07 +0100 Subject: [PATCH 2/7] Remove imm_with_name It is only used once to rename an imm field to mask --- cranelift/codegen/meta/src/cdsl/formats.rs | 9 --------- cranelift/codegen/meta/src/shared/formats.rs | 2 +- cranelift/codegen/src/ir/instructions.rs | 2 +- cranelift/codegen/src/machinst/lower.rs | 4 ++-- cranelift/codegen/src/write.rs | 4 ++-- 5 files changed, 6 insertions(+), 15 deletions(-) diff --git a/cranelift/codegen/meta/src/cdsl/formats.rs b/cranelift/codegen/meta/src/cdsl/formats.rs index 6cd20ecae6..299294f508 100644 --- a/cranelift/codegen/meta/src/cdsl/formats.rs +++ b/cranelift/codegen/meta/src/cdsl/formats.rs @@ -122,15 +122,6 @@ impl InstructionFormatBuilder { self } - pub fn imm_with_name(mut self, member: &'static str, operand_kind: &OperandKind) -> Self { - let field = FormatField { - kind: operand_kind.clone(), - member, - }; - self.imm_fields.push(field); - self - } - pub fn typevar_operand(mut self, operand_index: usize) -> Self { assert!(self.typevar_operand.is_none()); assert!(operand_index < self.num_value_operands); diff --git a/cranelift/codegen/meta/src/shared/formats.rs b/cranelift/codegen/meta/src/shared/formats.rs index d1fe6adaac..61f19e4d44 100644 --- a/cranelift/codegen/meta/src/shared/formats.rs +++ b/cranelift/codegen/meta/src/shared/formats.rs @@ -101,7 +101,7 @@ impl Formats { shuffle: Builder::new("Shuffle") .value() .value() - .imm_with_name("mask", &imm.uimm128) + .imm(&imm.uimm128) .build(), int_compare: Builder::new("IntCompare") diff --git a/cranelift/codegen/src/ir/instructions.rs b/cranelift/codegen/src/ir/instructions.rs index 92f7c34bec..63a17bf9ba 100644 --- a/cranelift/codegen/src/ir/instructions.rs +++ b/cranelift/codegen/src/ir/instructions.rs @@ -319,7 +319,7 @@ impl InstructionData { // included in the `InstructionData` for memory-size reasons. This case, returning // `None`, is left here to alert users of this method that they should retrieve the // value using the `DataFlowGraph`. - &InstructionData::Shuffle { mask: _, .. } => None, + &InstructionData::Shuffle { imm: _, .. } => None, _ => None, } } diff --git a/cranelift/codegen/src/machinst/lower.rs b/cranelift/codegen/src/machinst/lower.rs index 6cd6d970be..0a35ad3ae6 100644 --- a/cranelift/codegen/src/machinst/lower.rs +++ b/cranelift/codegen/src/machinst/lower.rs @@ -1264,8 +1264,8 @@ impl<'func, I: VCodeInst> LowerCtx for Lower<'func, I> { fn get_immediate(&self, ir_inst: Inst) -> Option { let inst_data = self.data(ir_inst); match inst_data { - InstructionData::Shuffle { mask, .. } => { - let buffer = self.f.dfg.immediates.get(mask.clone()).unwrap().as_slice(); + InstructionData::Shuffle { imm, .. } => { + let buffer = self.f.dfg.immediates.get(imm.clone()).unwrap().as_slice(); let value = DataValue::V128(buffer.try_into().expect("a 16-byte data buffer")); Some(value) } diff --git a/cranelift/codegen/src/write.rs b/cranelift/codegen/src/write.rs index 1883251b90..72496a3192 100644 --- a/cranelift/codegen/src/write.rs +++ b/cranelift/codegen/src/write.rs @@ -395,8 +395,8 @@ pub fn write_operands(w: &mut dyn Write, dfg: &DataFlowGraph, inst: Inst) -> fmt } NullAry { .. } => write!(w, " "), TernaryImm8 { imm, args, .. } => write!(w, " {}, {}, {}", args[0], args[1], imm), - Shuffle { mask, args, .. } => { - let data = dfg.immediates.get(mask).expect( + Shuffle { imm, args, .. } => { + let data = dfg.immediates.get(imm).expect( "Expected the shuffle mask to already be inserted into the immediates table", ); write!(w, " {}, {}, {}", args[0], args[1], data) From e8f3c0c6a9f6dcc27677e0cbf0d8d09c3a322131 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 31 Oct 2021 19:01:33 +0100 Subject: [PATCH 3/7] Use InstructionFormat inside InstructionFormatBuilder --- cranelift/codegen/meta/src/cdsl/formats.rs | 42 ++++++------------- .../codegen/meta/src/cdsl/instructions.rs | 2 +- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/cranelift/codegen/meta/src/cdsl/formats.rs b/cranelift/codegen/meta/src/cdsl/formats.rs index 299294f508..876fb7702f 100644 --- a/cranelift/codegen/meta/src/cdsl/formats.rs +++ b/cranelift/codegen/meta/src/cdsl/formats.rs @@ -84,32 +84,26 @@ impl InstructionFormat { } } -pub(crate) struct InstructionFormatBuilder { - name: &'static str, - num_value_operands: usize, - has_value_list: bool, - imm_fields: Vec, - typevar_operand: Option, -} +pub(crate) struct InstructionFormatBuilder(InstructionFormat); impl InstructionFormatBuilder { pub fn new(name: &'static str) -> Self { - Self { + Self(InstructionFormat { name, num_value_operands: 0, has_value_list: false, imm_fields: Vec::new(), typevar_operand: None, - } + }) } pub fn value(mut self) -> Self { - self.num_value_operands += 1; + self.0.num_value_operands += 1; self } pub fn varargs(mut self) -> Self { - self.has_value_list = true; + self.0.has_value_list = true; self } @@ -118,33 +112,23 @@ impl InstructionFormatBuilder { kind: operand_kind.clone(), member: operand_kind.rust_field_name, }; - self.imm_fields.push(field); + self.0.imm_fields.push(field); self } pub fn typevar_operand(mut self, operand_index: usize) -> Self { - assert!(self.typevar_operand.is_none()); - assert!(operand_index < self.num_value_operands); - self.typevar_operand = Some(operand_index); + assert!(self.0.typevar_operand.is_none()); + assert!(operand_index < self.0.num_value_operands); + self.0.typevar_operand = Some(operand_index); self } - pub fn build(self) -> Rc { - let typevar_operand = if self.typevar_operand.is_some() { - self.typevar_operand - } else if self.num_value_operands > 0 { + pub fn build(mut self) -> Rc { + if self.0.typevar_operand.is_none() && self.0.num_value_operands > 0 { // Default to the first value operand, if there's one. - Some(0) - } else { - None + self.0.typevar_operand = Some(0); }; - Rc::new(InstructionFormat { - name: self.name, - num_value_operands: self.num_value_operands, - has_value_list: self.has_value_list, - imm_fields: self.imm_fields, - typevar_operand, - }) + Rc::new(self.0) } } diff --git a/cranelift/codegen/meta/src/cdsl/instructions.rs b/cranelift/codegen/meta/src/cdsl/instructions.rs index 6c967cabcc..bb6af7f692 100644 --- a/cranelift/codegen/meta/src/cdsl/instructions.rs +++ b/cranelift/codegen/meta/src/cdsl/instructions.rs @@ -43,7 +43,7 @@ pub(crate) struct InstructionContent { /// Output operands. The output operands must be SSA values or `variable_args`. pub operands_out: Vec, - /// Instruction format, automatically derived from the input operands. + /// Instruction format. pub format: Rc, /// One of the input or output operands is a free type variable. None if the instruction is not From f84e1c16c74ffea46fe48f8d6583e66956cd0bdd Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 31 Oct 2021 19:27:12 +0100 Subject: [PATCH 4/7] Enforce all OperandKind have documentation --- cranelift/codegen/meta/src/cdsl/operands.rs | 21 ++-- cranelift/codegen/meta/src/shared/entities.rs | 12 +- .../codegen/meta/src/shared/immediates.rs | 105 +++++++++++++----- 3 files changed, 98 insertions(+), 40 deletions(-) diff --git a/cranelift/codegen/meta/src/cdsl/operands.rs b/cranelift/codegen/meta/src/cdsl/operands.rs index 605df24862..1d26ec3624 100644 --- a/cranelift/codegen/meta/src/cdsl/operands.rs +++ b/cranelift/codegen/meta/src/cdsl/operands.rs @@ -130,19 +130,15 @@ impl OperandKind { rust_field_name: &'static str, rust_type: &'static str, fields: OperandKindFields, + doc: &'static str, ) -> Self { Self { rust_field_name, rust_type, fields, - doc: None, + doc: Some(doc), } } - pub fn with_doc(mut self, doc: &'static str) -> Self { - assert!(self.doc.is_none()); - self.doc = Some(doc); - self - } fn doc(&self) -> Option<&str> { if let Some(doc) = &self.doc { return Some(doc); @@ -152,18 +148,19 @@ impl OperandKind { OperandKindFields::ImmEnum(_) | OperandKindFields::ImmValue | OperandKindFields::EntityRef - | OperandKindFields::VariableArgs => None, + | OperandKindFields::VariableArgs => unreachable!(), } } } impl Into for &TypeVar { fn into(self) -> OperandKind { - OperandKind::new( - "value", - "ir::Value", - OperandKindFields::TypeVar(self.into()), - ) + OperandKind { + rust_field_name: "value", + rust_type: "ir::Value", + fields: OperandKindFields::TypeVar(self.into()), + doc: None, + } } } impl Into for &OperandKind { diff --git a/cranelift/codegen/meta/src/shared/entities.rs b/cranelift/codegen/meta/src/shared/entities.rs index c3f2bc0387..dcf4ce2cf2 100644 --- a/cranelift/codegen/meta/src/shared/entities.rs +++ b/cranelift/codegen/meta/src/shared/entities.rs @@ -2,7 +2,12 @@ use crate::cdsl::operands::{OperandKind, OperandKindFields}; /// Small helper to initialize an OperandBuilder with the right kind, for a given name and doc. fn new(format_field_name: &'static str, rust_type: &'static str, doc: &'static str) -> OperandKind { - OperandKind::new(format_field_name, rust_type, OperandKindFields::EntityRef).with_doc(doc) + OperandKind::new( + format_field_name, + rust_type, + OperandKindFields::EntityRef, + doc, + ) } pub(crate) struct EntityRefs { @@ -59,7 +64,10 @@ impl EntityRefs { table: new("table", "ir::Table", "A table."), - varargs: OperandKind::new("", "&[Value]", OperandKindFields::VariableArgs).with_doc( + varargs: OperandKind::new( + "", + "&[Value]", + OperandKindFields::VariableArgs, r#" A variable size list of `value` operands. diff --git a/cranelift/codegen/meta/src/shared/immediates.rs b/cranelift/codegen/meta/src/shared/immediates.rs index 12a93d81e6..4808ce5593 100644 --- a/cranelift/codegen/meta/src/shared/immediates.rs +++ b/cranelift/codegen/meta/src/shared/immediates.rs @@ -73,40 +73,76 @@ pub(crate) struct Immediates { pub atomic_rmw_op: OperandKind, } -fn new_imm(format_field_name: &'static str, rust_type: &'static str) -> OperandKind { - OperandKind::new(format_field_name, rust_type, OperandKindFields::ImmValue) +fn new_imm( + format_field_name: &'static str, + rust_type: &'static str, + doc: &'static str, +) -> OperandKind { + OperandKind::new( + format_field_name, + rust_type, + OperandKindFields::ImmValue, + doc, + ) } fn new_enum( format_field_name: &'static str, rust_type: &'static str, values: EnumValues, + doc: &'static str, ) -> OperandKind { OperandKind::new( format_field_name, rust_type, OperandKindFields::ImmEnum(values), + doc, ) } impl Immediates { pub fn new() -> Self { Self { - imm64: new_imm("imm", "ir::immediates::Imm64").with_doc("A 64-bit immediate integer."), - uimm8: new_imm("imm", "ir::immediates::Uimm8") - .with_doc("An 8-bit immediate unsigned integer."), - uimm32: new_imm("imm", "ir::immediates::Uimm32") - .with_doc("A 32-bit immediate unsigned integer."), - uimm128: new_imm("imm", "ir::Immediate") - .with_doc("A 128-bit immediate unsigned integer."), - pool_constant: new_imm("constant_handle", "ir::Constant") - .with_doc("A constant stored in the constant pool."), - offset32: new_imm("offset", "ir::immediates::Offset32") - .with_doc("A 32-bit immediate signed offset."), - ieee32: new_imm("imm", "ir::immediates::Ieee32") - .with_doc("A 32-bit immediate floating point number."), - ieee64: new_imm("imm", "ir::immediates::Ieee64") - .with_doc("A 64-bit immediate floating point number."), - boolean: new_imm("imm", "bool").with_doc("An immediate boolean."), + imm64: new_imm( + "imm", + "ir::immediates::Imm64", + "A 64-bit immediate integer.", + ), + uimm8: new_imm( + "imm", + "ir::immediates::Uimm8", + "An 8-bit immediate unsigned integer.", + ), + uimm32: new_imm( + "imm", + "ir::immediates::Uimm32", + "A 32-bit immediate unsigned integer.", + ), + uimm128: new_imm( + "imm", + "ir::Immediate", + "A 128-bit immediate unsigned integer.", + ), + pool_constant: new_imm( + "constant_handle", + "ir::Constant", + "A constant stored in the constant pool.", + ), + offset32: new_imm( + "offset", + "ir::immediates::Offset32", + "A 32-bit immediate signed offset.", + ), + ieee32: new_imm( + "imm", + "ir::immediates::Ieee32", + "A 32-bit immediate floating point number.", + ), + ieee64: new_imm( + "imm", + "ir::immediates::Ieee64", + "A 64-bit immediate floating point number.", + ), + boolean: new_imm("imm", "bool", "An immediate boolean."), intcc: { let mut intcc_values = HashMap::new(); intcc_values.insert("eq", "Equal"); @@ -121,8 +157,12 @@ impl Immediates { intcc_values.insert("ult", "UnsignedLessThan"); intcc_values.insert("of", "Overflow"); intcc_values.insert("nof", "NotOverflow"); - new_enum("cond", "ir::condcodes::IntCC", intcc_values) - .with_doc("An integer comparison condition code.") + new_enum( + "cond", + "ir::condcodes::IntCC", + intcc_values, + "An integer comparison condition code.", + ) }, floatcc: { @@ -141,18 +181,27 @@ impl Immediates { floatcc_values.insert("ule", "UnorderedOrLessThanOrEqual"); floatcc_values.insert("ugt", "UnorderedOrGreaterThan"); floatcc_values.insert("uge", "UnorderedOrGreaterThanOrEqual"); - new_enum("cond", "ir::condcodes::FloatCC", floatcc_values) - .with_doc("A floating point comparison condition code") + new_enum( + "cond", + "ir::condcodes::FloatCC", + floatcc_values, + "A floating point comparison condition code", + ) }, - memflags: new_imm("flags", "ir::MemFlags").with_doc("Memory operation flags"), + memflags: new_imm("flags", "ir::MemFlags", "Memory operation flags"), trapcode: { let mut trapcode_values = HashMap::new(); trapcode_values.insert("stk_ovf", "StackOverflow"); trapcode_values.insert("heap_oob", "HeapOutOfBounds"); trapcode_values.insert("int_ovf", "IntegerOverflow"); trapcode_values.insert("int_divz", "IntegerDivisionByZero"); - new_enum("code", "ir::TrapCode", trapcode_values).with_doc("A trap reason code.") + new_enum( + "code", + "ir::TrapCode", + trapcode_values, + "A trap reason code.", + ) }, atomic_rmw_op: { let mut atomic_rmw_op_values = HashMap::new(); @@ -167,8 +216,12 @@ impl Immediates { atomic_rmw_op_values.insert("umax", "Umax"); atomic_rmw_op_values.insert("smin", "Smin"); atomic_rmw_op_values.insert("smax", "Smax"); - new_enum("op", "ir::AtomicRmwOp", atomic_rmw_op_values) - .with_doc("Atomic Read-Modify-Write Ops") + new_enum( + "op", + "ir::AtomicRmwOp", + atomic_rmw_op_values, + "Atomic Read-Modify-Write Ops", + ) }, } } From 55f8f8ce0559517ea4c62f9cdd1da38c6631c9f0 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 31 Oct 2021 19:56:46 +0100 Subject: [PATCH 5/7] Remove a bit of dead code --- cranelift/codegen/meta/src/cdsl/types.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/cranelift/codegen/meta/src/cdsl/types.rs b/cranelift/codegen/meta/src/cdsl/types.rs index 7d74d66724..3c8d8927ce 100644 --- a/cranelift/codegen/meta/src/cdsl/types.rs +++ b/cranelift/codegen/meta/src/cdsl/types.rs @@ -6,7 +6,7 @@ use crate::shared::types as shared_types; use cranelift_codegen_shared::constants; // Rust name prefix used for the `rust_name` method. -static _RUST_NAME_PREFIX: &str = "ir::types::"; +static RUST_NAME_PREFIX: &str = "ir::types::"; // ValueType variants (i8, i32, ...) are provided in `shared::types.rs`. @@ -82,14 +82,7 @@ impl ValueType { /// Return the name of this type for generated Rust source files. pub fn rust_name(&self) -> String { - format!("{}{}", _RUST_NAME_PREFIX, self.to_string().to_uppercase()) - } - - /// Return true iff: - /// 1. self and other have equal number of lanes - /// 2. each lane in self has at least as many bits as a lane in other - pub fn _wider_or_equal(&self, rhs: &ValueType) -> bool { - (self.lane_count() == rhs.lane_count()) && (self.lane_bits() >= rhs.lane_bits()) + format!("{}{}", RUST_NAME_PREFIX, self.to_string().to_uppercase()) } /// Return the total number of bits of an instance of this type. From 93e9bb02e44aca861cb8553f9468c530dc1d9a95 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 1 Nov 2021 18:17:57 +0100 Subject: [PATCH 6/7] Review comments --- cranelift/codegen/meta/src/cdsl/operands.rs | 14 ++++++++------ cranelift/codegen/meta/src/gen_inst.rs | 14 ++------------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/cranelift/codegen/meta/src/cdsl/operands.rs b/cranelift/codegen/meta/src/cdsl/operands.rs index 1d26ec3624..915b8b6380 100644 --- a/cranelift/codegen/meta/src/cdsl/operands.rs +++ b/cranelift/codegen/meta/src/cdsl/operands.rs @@ -39,12 +39,12 @@ impl Operand { self } - pub fn doc(&self) -> Option<&str> { + pub fn doc(&self) -> &str { if let Some(doc) = &self.doc { - return Some(doc); + return doc; } match &self.kind.fields { - OperandKindFields::TypeVar(tvar) => Some(&tvar.doc), + OperandKindFields::TypeVar(tvar) => &tvar.doc, _ => self.kind.doc(), } } @@ -139,12 +139,14 @@ impl OperandKind { doc: Some(doc), } } - fn doc(&self) -> Option<&str> { + fn doc(&self) -> &str { if let Some(doc) = &self.doc { - return Some(doc); + return doc; } match &self.fields { - OperandKindFields::TypeVar(type_var) => Some(&type_var.doc), + OperandKindFields::TypeVar(type_var) => &type_var.doc, + // The only method to create an OperandKind with `doc` set to None is using a TypeVar, + // so all other options are unreachable here. OperandKindFields::ImmEnum(_) | OperandKindFields::ImmValue | OperandKindFields::EntityRef diff --git a/cranelift/codegen/meta/src/gen_inst.rs b/cranelift/codegen/meta/src/gen_inst.rs index 887ef878ad..5e28e0b24b 100644 --- a/cranelift/codegen/meta/src/gen_inst.rs +++ b/cranelift/codegen/meta/src/gen_inst.rs @@ -946,21 +946,11 @@ fn gen_inst_builder(inst: &Instruction, format: &InstructionFormat, fmt: &mut Fo op.kind.rust_type.to_string() }; args.push(format!("{}: {}", op.name, t)); - args_doc.push(format!( - "- {}: {}", - op.name, - op.doc() - .expect("every instruction's input operand must be documented") - )); + args_doc.push(format!("- {}: {}", op.name, op.doc())); } for op in &inst.operands_out { - rets_doc.push(format!( - "- {}: {}", - op.name, - op.doc() - .expect("every instruction's output operand must be documented") - )); + rets_doc.push(format!("- {}: {}", op.name, op.doc())); } let rtype = match inst.value_results.len() { From 86d2ef8952f8c9ca8c7b1ea06a77f69d5985cee9 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Mon, 1 Nov 2021 18:19:59 +0100 Subject: [PATCH 7/7] Fix CI --- cranelift/interpreter/src/step.rs | 4 ++-- cranelift/reader/src/parser.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cranelift/interpreter/src/step.rs b/cranelift/interpreter/src/step.rs index 60ab37dc67..5764974bc1 100644 --- a/cranelift/interpreter/src/step.rs +++ b/cranelift/interpreter/src/step.rs @@ -76,12 +76,12 @@ where .as_slice(); DataValue::V128(buffer.try_into().expect("a 16-byte data buffer")) } - InstructionData::Shuffle { mask, .. } => { + InstructionData::Shuffle { imm, .. } => { let mask = state .get_current_function() .dfg .immediates - .get(mask) + .get(imm) .unwrap() .as_slice(); DataValue::V128(mask.try_into().expect("a 16-byte vector mask")) diff --git a/cranelift/reader/src/parser.rs b/cranelift/reader/src/parser.rs index d403d3534a..bc5089d37e 100644 --- a/cranelift/reader/src/parser.rs +++ b/cranelift/reader/src/parser.rs @@ -2694,10 +2694,10 @@ impl<'a> Parser<'a> { let b = self.match_value("expected SSA value second operand")?; self.match_token(Token::Comma, "expected ',' between operands")?; let uimm128 = self.match_uimm128(I8X16)?; - let mask = ctx.function.dfg.immediates.push(uimm128); + let imm = ctx.function.dfg.immediates.push(uimm128); InstructionData::Shuffle { opcode, - mask, + imm, args: [a, b], } }