Skip to content

Commit 9bea24f

Browse files
committed
update rspirv: handle LiteralFloat just like other numbers
1 parent 76f251d commit 9bea24f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
10811081
Ok(v) => inst.operands.push(dr::Operand::LiteralBit32(v)),
10821082
Err(e) => self.err(format!("invalid integer: {e}")),
10831083
},
1084+
(OperandKind::LiteralFloat, Some(word)) => match word.parse() {
1085+
Ok(v) => inst
1086+
.operands
1087+
.push(dr::Operand::LiteralBit32(f32::to_bits(v))),
1088+
Err(e) => self.err(format!("invalid float: {e}")),
1089+
},
10841090
(OperandKind::LiteralString, _) => {
10851091
if let Token::String(value) = token {
10861092
inst.operands.push(dr::Operand::LiteralString(value));
@@ -1412,7 +1418,6 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
14121418
Ok(x) => inst.operands.push(dr::Operand::StoreCacheControl(x)),
14131419
Err(()) => self.err(format!("unknown StoreCacheControl {word}")),
14141420
},
1415-
(OperandKind::LiteralFloat, Some(_word)) => todo!(),
14161421
(kind, None) => match token {
14171422
Token::Word(_) => bug!(),
14181423
Token::String(_) => {

0 commit comments

Comments
 (0)