Skip to content

update rspirv 0.11 to 0.12 #43

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

Merged
merged 9 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 5 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ license.workspace = true
repository.workspace = true

[dependencies]
rspirv = "0.11"
rspirv = "0.12"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ regex = { version = "1", features = ["perf"] }
ar = "0.9.0"
either = "1.8.0"
indexmap = "1.6.0"
rspirv = "0.11"
rspirv = "0.12"
rustc_codegen_spirv-types.workspace = true
rustc-demangle = "0.1.21"
sanitize-filename = "0.4"
Expand Down
28 changes: 25 additions & 3 deletions crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::attr::{AggregatedSpirvAttributes, IntrinsicType};
use crate::codegen_cx::CodegenCx;
use crate::spirv_type::SpirvType;
use rspirv::spirv::{StorageClass, Word};
use rspirv::spirv::{Dim, ImageFormat, StorageClass, Word};
use rustc_data_structures::fx::FxHashMap;
use rustc_errors::ErrorGuaranteed;
use rustc_index::Idx;
Expand Down Expand Up @@ -862,13 +862,35 @@ fn trans_intrinsic_type<'tcx>(
// let image_format: spirv::ImageFormat =
// type_from_variant_discriminant(cx, args.const_at(6));

fn const_int_value<'tcx, P: FromPrimitive>(
trait FromU128Const: Sized {
fn from_u128_const(n: u128) -> Option<Self>;
}

impl FromU128Const for u32 {
fn from_u128_const(n: u128) -> Option<Self> {
u32::from_u128(n)
}
}

impl FromU128Const for Dim {
fn from_u128_const(n: u128) -> Option<Self> {
Dim::from_u32(u32::from_u128(n)?)
}
}

impl FromU128Const for ImageFormat {
fn from_u128_const(n: u128) -> Option<Self> {
ImageFormat::from_u32(u32::from_u128(n)?)
}
}

fn const_int_value<'tcx, P: FromU128Const>(
cx: &CodegenCx<'tcx>,
const_: Const<'tcx>,
) -> Result<P, ErrorGuaranteed> {
assert!(const_.ty().is_integral());
let value = const_.eval_bits(cx.tcx, ParamEnv::reveal_all());
match P::from_u128(value) {
match P::from_u128_const(value) {
Some(v) => Ok(v),
None => Err(cx
.tcx
Expand Down
14 changes: 7 additions & 7 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,9 +1106,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
))
} else if signed {
// this cast chain can probably be collapsed, but, whatever, be safe
Operand::LiteralInt32(v as u8 as i8 as i32 as u32)
Operand::LiteralBit32(v as u8 as i8 as i32 as u32)
} else {
Operand::LiteralInt32(v as u8 as u32)
Operand::LiteralBit32(v as u8 as u32)
}
}
fn construct_16(self_: &Builder<'_, '_>, signed: bool, v: u128) -> Operand {
Expand All @@ -1117,9 +1117,9 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
"Switches to values above u16::MAX not supported: {v:?}"
))
} else if signed {
Operand::LiteralInt32(v as u16 as i16 as i32 as u32)
Operand::LiteralBit32(v as u16 as i16 as i32 as u32)
} else {
Operand::LiteralInt32(v as u16 as u32)
Operand::LiteralBit32(v as u16 as u32)
}
}
fn construct_32(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand {
Expand All @@ -1128,7 +1128,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
"Switches to values above u32::MAX not supported: {v:?}"
))
} else {
Operand::LiteralInt32(v as u32)
Operand::LiteralBit32(v as u32)
}
}
fn construct_64(self_: &Builder<'_, '_>, _signed: bool, v: u128) -> Operand {
Expand All @@ -1137,7 +1137,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
"Switches to values above u64::MAX not supported: {v:?}"
))
} else {
Operand::LiteralInt64(v as u64)
Operand::LiteralBit64(v as u64)
}
}
// pass in signed into the closure to be able to unify closure types
Expand Down Expand Up @@ -2915,7 +2915,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {

// HACK(eddyb) avoid the logic below that assumes only ID operands
if inst.class.opcode == Op::CompositeExtract {
if let (Some(r), &[Operand::IdRef(x), Operand::LiteralInt32(i)]) =
if let (Some(r), &[Operand::IdRef(x), Operand::LiteralBit32(i)]) =
(inst.result_id, &inst.operands[..])
{
return Some(Inst::CompositeExtract(r, x, i));
Expand Down
Loading