Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subgroup intrinsics #1151

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ target/
.vim/
tests/Cargo.lock
.github/install-spirv-tools/Cargo.lock
rustc-ice-*.txt
19 changes: 13 additions & 6 deletions crates/rustc_codegen_spirv/src/builder/spirv_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ use super::Builder;
use crate::builder_spirv::{BuilderCursor, SpirvValue};
use crate::codegen_cx::CodegenCx;
use crate::spirv_type::SpirvType;
use num_traits::FromPrimitive;
use rspirv::dr;
use rspirv::grammar::{reflect, LogicalOperand, OperandKind, OperandQuantifier};
use rspirv::spirv::{
FPFastMathMode, FragmentShadingRate, FunctionControl, ImageOperands, KernelProfilingInfo,
LoopControl, MemoryAccess, MemorySemantics, Op, RayFlags, SelectionControl, StorageClass, Word,
FPFastMathMode, FragmentShadingRate, FunctionControl, GroupOperation, ImageOperands,
KernelProfilingInfo, LoopControl, MemoryAccess, MemorySemantics, Op, RayFlags,
SelectionControl, StorageClass, Word,
};
use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_codegen_ssa::mir::place::PlaceRef;
Expand Down Expand Up @@ -1329,10 +1331,15 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
Ok(x) => inst.operands.push(dr::Operand::Scope(x)),
Err(()) => self.err(format!("unknown Scope {word}")),
},
(OperandKind::GroupOperation, Some(word)) => match word.parse() {
Ok(x) => inst.operands.push(dr::Operand::GroupOperation(x)),
Err(()) => self.err(format!("unknown GroupOperation {word}")),
},
(OperandKind::GroupOperation, Some(word)) => {
match word.parse::<u32>().ok().and_then(GroupOperation::from_u32) {
Some(id) => inst.operands.push(dr::Operand::GroupOperation(id)),
None => match word.parse() {
Ok(x) => inst.operands.push(dr::Operand::GroupOperation(x)),
Err(()) => self.err(format!("unknown GroupOperation {word}")),
},
}
}
(OperandKind::KernelEnqueueFlags, Some(word)) => match word.parse() {
Ok(x) => inst.operands.push(dr::Operand::KernelEnqueueFlags(x)),
Err(()) => self.err(format!("unknown KernelEnqueueFlags {word}")),
Expand Down
2 changes: 2 additions & 0 deletions crates/spirv-std/src/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ mod demote_to_helper_invocation_ext;
mod derivative;
mod primitive;
mod ray_tracing;
mod subgroup;

pub use atomics::*;
pub use barrier::*;
pub use demote_to_helper_invocation_ext::*;
pub use derivative::*;
pub use primitive::*;
pub use ray_tracing::*;
pub use subgroup::*;

/// Result is true if any component of `vector` is true, otherwise result is
/// false.
Expand Down
Loading