Skip to content

Commit 51d691c

Browse files
committed
subgroup: fixed asm for instructions taking GROUP_OP generic
1 parent 956231c commit 51d691c

File tree

2 files changed

+46
-72
lines changed

2 files changed

+46
-72
lines changed

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ use super::Builder;
22
use crate::builder_spirv::{BuilderCursor, SpirvValue};
33
use crate::codegen_cx::CodegenCx;
44
use crate::spirv_type::SpirvType;
5+
use num_traits::FromPrimitive;
56
use rspirv::dr;
67
use rspirv::grammar::{reflect, LogicalOperand, OperandKind, OperandQuantifier};
78
use rspirv::spirv::{
8-
FPFastMathMode, FragmentShadingRate, FunctionControl, ImageOperands, KernelProfilingInfo,
9-
LoopControl, MemoryAccess, MemorySemantics, Op, RayFlags, SelectionControl, StorageClass, Word,
9+
FPFastMathMode, FragmentShadingRate, FunctionControl, GroupOperation, ImageOperands,
10+
KernelProfilingInfo, LoopControl, MemoryAccess, MemorySemantics, Op, RayFlags,
11+
SelectionControl, StorageClass, Word,
1012
};
1113
use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
1214
use rustc_codegen_ssa::mir::place::PlaceRef;
@@ -1347,10 +1349,15 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
13471349
Ok(x) => inst.operands.push(dr::Operand::Scope(x)),
13481350
Err(()) => self.err(format!("unknown Scope {word}")),
13491351
},
1350-
(OperandKind::GroupOperation, Some(word)) => match word.parse() {
1351-
Ok(x) => inst.operands.push(dr::Operand::GroupOperation(x)),
1352-
Err(()) => self.err(format!("unknown GroupOperation {word}")),
1353-
},
1352+
(OperandKind::GroupOperation, Some(word)) => {
1353+
match word.parse::<u32>().ok().and_then(GroupOperation::from_u32) {
1354+
Some(id) => inst.operands.push(dr::Operand::GroupOperation(id)),
1355+
None => match word.parse() {
1356+
Ok(x) => inst.operands.push(dr::Operand::GroupOperation(x)),
1357+
Err(()) => self.err(format!("unknown GroupOperation {word}")),
1358+
},
1359+
}
1360+
}
13541361
(OperandKind::KernelEnqueueFlags, Some(word)) => match word.parse() {
13551362
Ok(x) => inst.operands.push(dr::Operand::KernelEnqueueFlags(x)),
13561363
Err(()) => self.err(format!("unknown KernelEnqueueFlags {word}")),

0 commit comments

Comments
 (0)