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

Update to nightly-2023-08-29 #1091

Merged
merged 8 commits into from
Nov 21, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Changed 🛠
- [PR#1091](https://github.com/EmbarkStudios/rust-gpu/pull/1091) updated toolchain to `nightly-2023-08-29`
- [PR#1085](https://github.com/EmbarkStudios/rust-gpu/pull/1085) updated toolchain to `nightly-2023-07-08`

## [0.9.0]
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions crates/rustc_codegen_spirv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode};
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2023-07-08"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = cb80ff132a0e9aa71529b701427e4e6c243b58df"#;
channel = "nightly-2023-08-29"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = 4e78abb437a0478d1f42115198ee45888e5330fd"#;

fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));
Expand Down
46 changes: 25 additions & 21 deletions crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use rustc_errors::ErrorGuaranteed;
use rustc_index::Idx;
use rustc_middle::query::{ExternProviders, Providers};
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
use rustc_middle::ty::subst::SubstsRef;
use rustc_middle::ty::GenericArgsRef;
use rustc_middle::ty::{
self, Const, FloatTy, GeneratorSubsts, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind,
self, Const, FloatTy, GeneratorArgs, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind,
TypeAndMut, UintTy,
};
use rustc_middle::{bug, span_bug};
Expand Down Expand Up @@ -104,6 +104,8 @@ pub(crate) fn provide(providers: &mut Providers) {
largest_niche,
align,
size,
max_repr_align,
unadjusted_abi_align,
} = *layout;
LayoutS {
fields: match *fields {
Expand Down Expand Up @@ -147,6 +149,8 @@ pub(crate) fn provide(providers: &mut Providers) {
largest_niche,
align,
size,
max_repr_align,
unadjusted_abi_align,
}
}
providers.layout_of = |tcx, key| {
Expand Down Expand Up @@ -343,7 +347,7 @@ impl<'tcx> ConvSpirvType<'tcx> for FnAbi<'tcx, Ty<'tcx>> {

impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
fn spirv_type(&self, mut span: Span, cx: &CodegenCx<'tcx>) -> Word {
if let TyKind::Adt(adt, substs) = *self.ty.kind() {
if let TyKind::Adt(adt, args) = *self.ty.kind() {
if span == DUMMY_SP {
span = cx.tcx.def_span(adt.did());
}
Expand All @@ -352,7 +356,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {

if let Some(intrinsic_type_attr) = attrs.intrinsic_type.map(|attr| attr.value) {
if let Ok(spirv_type) =
trans_intrinsic_type(cx, span, *self, substs, intrinsic_type_attr)
trans_intrinsic_type(cx, span, *self, args, intrinsic_type_attr)
{
return spirv_type;
}
Expand Down Expand Up @@ -782,7 +786,7 @@ impl fmt::Display for TyLayoutNameKey<'_> {
}
}
if let (TyKind::Generator(_, _, _), Some(index)) = (self.ty.kind(), self.variant) {
write!(f, "::{}", GeneratorSubsts::variant_name(index))?;
write!(f, "::{}", GeneratorArgs::variant_name(index))?;
}
Ok(())
}
Expand All @@ -792,7 +796,7 @@ fn trans_intrinsic_type<'tcx>(
cx: &CodegenCx<'tcx>,
span: Span,
ty: TyAndLayout<'tcx>,
substs: SubstsRef<'tcx>,
args: GenericArgsRef<'tcx>,
intrinsic_type_attr: IntrinsicType,
) -> Result<Word, ErrorGuaranteed> {
match intrinsic_type_attr {
Expand All @@ -817,7 +821,7 @@ fn trans_intrinsic_type<'tcx>(
// <_>::from_u64(value).unwrap()
// }

let sampled_type = match substs.type_at(0).kind() {
let sampled_type = match args.type_at(0).kind() {
TyKind::Int(int) => match int {
IntTy::Isize => {
SpirvType::Integer(cx.tcx.data_layout.pointer_size.bits() as u32, true)
Expand Down Expand Up @@ -850,13 +854,13 @@ fn trans_intrinsic_type<'tcx>(
}
};

// let dim: spirv::Dim = type_from_variant_discriminant(cx, substs.const_at(1));
// let depth: u32 = type_from_variant_discriminant(cx, substs.const_at(2));
// let arrayed: u32 = type_from_variant_discriminant(cx, substs.const_at(3));
// let multisampled: u32 = type_from_variant_discriminant(cx, substs.const_at(4));
// let sampled: u32 = type_from_variant_discriminant(cx, substs.const_at(5));
// let dim: spirv::Dim = type_from_variant_discriminant(cx, args.const_at(1));
// let depth: u32 = type_from_variant_discriminant(cx, args.const_at(2));
// let arrayed: u32 = type_from_variant_discriminant(cx, args.const_at(3));
// let multisampled: u32 = type_from_variant_discriminant(cx, args.const_at(4));
// let sampled: u32 = type_from_variant_discriminant(cx, args.const_at(5));
// let image_format: spirv::ImageFormat =
// type_from_variant_discriminant(cx, substs.const_at(6));
// type_from_variant_discriminant(cx, args.const_at(6));

fn const_int_value<'tcx, P: FromPrimitive>(
cx: &CodegenCx<'tcx>,
Expand All @@ -873,12 +877,12 @@ fn trans_intrinsic_type<'tcx>(
}
}

let dim = const_int_value(cx, substs.const_at(1))?;
let depth = const_int_value(cx, substs.const_at(2))?;
let arrayed = const_int_value(cx, substs.const_at(3))?;
let multisampled = const_int_value(cx, substs.const_at(4))?;
let sampled = const_int_value(cx, substs.const_at(5))?;
let image_format = const_int_value(cx, substs.const_at(6))?;
let dim = const_int_value(cx, args.const_at(1))?;
let depth = const_int_value(cx, args.const_at(2))?;
let arrayed = const_int_value(cx, args.const_at(3))?;
let multisampled = const_int_value(cx, args.const_at(4))?;
let sampled = const_int_value(cx, args.const_at(5))?;
let image_format = const_int_value(cx, args.const_at(6))?;

let ty = SpirvType::Image {
sampled_type,
Expand Down Expand Up @@ -913,7 +917,7 @@ fn trans_intrinsic_type<'tcx>(

// We use a generic to indicate the underlying image type of the sampled image.
// The spirv type of it will be generated by querying the type of the first generic.
if let Some(image_ty) = substs.types().next() {
if let Some(image_ty) = args.types().next() {
// TODO: enforce that the generic param is an image type?
let image_type = cx.layout_of(image_ty).spirv_type(span, cx);
Ok(SpirvType::SampledImage { image_type }.def(span, cx))
Expand All @@ -934,7 +938,7 @@ fn trans_intrinsic_type<'tcx>(

// We use a generic to indicate the underlying element type.
// The spirv type of it will be generated by querying the type of the first generic.
if let Some(elem_ty) = substs.types().next() {
if let Some(elem_ty) = args.types().next() {
let element = cx.layout_of(elem_ty).spirv_type(span, cx);
Ok(SpirvType::RuntimeArray { element }.def(span, cx))
} else {
Expand Down
10 changes: 5 additions & 5 deletions crates/rustc_codegen_spirv/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::symbols::Symbols;
use rspirv::spirv::{BuiltIn, ExecutionMode, ExecutionModel, StorageClass};
use rustc_ast::Attribute;
use rustc_hir as hir;
use rustc_hir::def_id::LocalDefId;
use rustc_hir::def_id::LocalModDefId;
use rustc_hir::intravisit::{self, Visitor};
use rustc_hir::{HirId, MethodKind, Target, CRATE_HIR_ID};
use rustc_middle::hir::nested_filter;
Expand Down Expand Up @@ -484,7 +484,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
}

// FIXME(eddyb) DRY this somehow and make it reusable from somewhere in `rustc`.
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalModDefId) {
let check_spirv_attr_visitor = &mut CheckSpirvAttrVisitor {
tcx,
sym: Symbols::get(),
Expand All @@ -498,10 +498,10 @@ fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {

pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers {
check_mod_attrs: |tcx, def_id| {
check_mod_attrs: |tcx, module_def_id| {
// Run both the default checks, and our `#[spirv(...)]` ones.
(rustc_interface::DEFAULT_QUERY_PROVIDERS.check_mod_attrs)(tcx, def_id);
check_mod_attrs(tcx, def_id);
(rustc_interface::DEFAULT_QUERY_PROVIDERS.check_mod_attrs)(tcx, module_def_id);
check_mod_attrs(tcx, module_def_id);
},
..*providers
};
Expand Down
Loading
Loading