MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / match_uimm128

Method match_uimm128

cranelift/reader/src/parser.rs:720–741  ·  view source on GitHub ↗

Match and consume either a hexadecimal Uimm128 immediate (e.g. 0x000102...) or its literal list form (e.g. [0 1 2...]). For convenience, since uimm128 values are stored in the `ConstantPool`, this returns `ConstantData`.

(&mut self, controlling_type: Type)

Source from the content-addressed store, hash-verified

718 // list form (e.g. [0 1 2...]). For convenience, since uimm128 values are stored in the
719 // `ConstantPool`, this returns `ConstantData`.
720 fn match_uimm128(&mut self, controlling_type: Type) -> ParseResult<ConstantData> {
721 let expected_size = controlling_type.bytes() as usize;
722 let constant_data = if self.optional(Token::LBracket) {
723 // parse using a list of values, e.g. vconst.i32x4 [0 1 2 3]
724 let uimm128 = self.parse_literals_to_constant_data(controlling_type)?;
725 self.match_token(Token::RBracket, "expected a terminating right bracket")?;
726 uimm128
727 } else {
728 // parse using a hexadecimal value, e.g. 0x000102...
729 let uimm128 =
730 self.match_hexadecimal_constant("expected an immediate hexadecimal operand")?;
731 uimm128.expand_to(expected_size)
732 };
733
734 if constant_data.len() == expected_size {
735 Ok(constant_data)
736 } else {
737 Err(self.error(&format!(
738 "expected parsed constant to have {expected_size} bytes"
739 )))
740 }
741 }
742
743 // Match and consume a Uimm64 immediate.
744 fn match_uimm64(&mut self, err_msg: &str) -> ParseResult<Uimm64> {

Callers 3

parse_constant_declMethod · 0.80
parse_data_valueMethod · 0.80
parse_inst_operandsMethod · 0.80

Calls 9

OkFunction · 0.85
optionalMethod · 0.80
match_tokenMethod · 0.80
expand_toMethod · 0.80
bytesMethod · 0.45
lenMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected