From 9bea24f540b04c8523b752734f96eb420732b9fc Mon Sep 17 00:00:00 2001 From: Firestar99 <4696087-firestar99@users.noreply.gitlab.com> Date: Fri, 2 Feb 2024 10:33:18 +0100 Subject: [PATCH] update rspirv: handle LiteralFloat just like other numbers --- crates/rustc_codegen_spirv/src/builder/spirv_asm.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs index 835b7ecc9b..5141cf2ede 100644 --- a/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs +++ b/crates/rustc_codegen_spirv/src/builder/spirv_asm.rs @@ -1081,6 +1081,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Ok(v) => inst.operands.push(dr::Operand::LiteralBit32(v)), Err(e) => self.err(format!("invalid integer: {e}")), }, + (OperandKind::LiteralFloat, Some(word)) => match word.parse() { + Ok(v) => inst + .operands + .push(dr::Operand::LiteralBit32(f32::to_bits(v))), + Err(e) => self.err(format!("invalid float: {e}")), + }, (OperandKind::LiteralString, _) => { if let Token::String(value) = token { inst.operands.push(dr::Operand::LiteralString(value)); @@ -1412,7 +1418,6 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> { Ok(x) => inst.operands.push(dr::Operand::StoreCacheControl(x)), Err(()) => self.err(format!("unknown StoreCacheControl {word}")), }, - (OperandKind::LiteralFloat, Some(_word)) => todo!(), (kind, None) => match token { Token::Word(_) => bug!(), Token::String(_) => {