Parse a data value; e.g. `42`, `4.2`, `true`. data-value-list ::= [data-value {"," data-value-list}]
(&mut self, ty: Type)
| 2629 | /// |
| 2630 | /// data-value-list ::= [data-value {"," data-value-list}] |
| 2631 | fn parse_data_value(&mut self, ty: Type) -> ParseResult<DataValue> { |
| 2632 | let dv = match ty { |
| 2633 | I8 => DataValue::from(self.match_imm8("expected a i8")?), |
| 2634 | I16 => DataValue::from(self.match_imm16("expected an i16")?), |
| 2635 | I32 => DataValue::from(self.match_imm32("expected an i32")?), |
| 2636 | I64 => DataValue::from(Into::<i64>::into(self.match_imm64("expected an i64")?)), |
| 2637 | I128 => DataValue::from(self.match_imm128("expected an i128")?), |
| 2638 | F16 => DataValue::from(self.match_ieee16("expected an f16")?), |
| 2639 | F32 => DataValue::from(self.match_ieee32("expected an f32")?), |
| 2640 | F64 => DataValue::from(self.match_ieee64("expected an f64")?), |
| 2641 | F128 => DataValue::from(self.match_ieee128("expected an f128")?), |
| 2642 | _ if (ty.is_vector() || ty.is_dynamic_vector()) => { |
| 2643 | let as_vec = self.match_uimm128(ty)?.into_vec(); |
| 2644 | let slice = as_vec.as_slice(); |
| 2645 | match slice.len() { |
| 2646 | 16 => DataValue::V128(slice.try_into().unwrap()), |
| 2647 | 8 => DataValue::V64(slice.try_into().unwrap()), |
| 2648 | 4 => DataValue::V32(slice.try_into().unwrap()), |
| 2649 | 2 => DataValue::V16(slice.try_into().unwrap()), |
| 2650 | _ => { |
| 2651 | return Err( |
| 2652 | self.error("vectors larger than 128 bits are not currently supported") |
| 2653 | ); |
| 2654 | } |
| 2655 | } |
| 2656 | } |
| 2657 | _ => return Err(self.error(&format!("don't know how to parse data values of: {ty}"))), |
| 2658 | }; |
| 2659 | Ok(dv) |
| 2660 | } |
| 2661 | |
| 2662 | // Parse the operands following the instruction opcode. |
| 2663 | // This depends on the format of the opcode. |
no test coverage detected