Skip to content

Commit 9b587c1

Browse files
LegNeatoeddyb
authored andcommitted
Update to nightly-2023-08-29
1 parent e87c324 commit 9b587c1

File tree

16 files changed

+138
-112
lines changed

16 files changed

+138
-112
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/rustc_codegen_spirv/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ spirt = "0.3.0"
6262
lazy_static = "1.4.0"
6363
itertools = "0.10.5"
6464

65+
# `termcolor` is needed because we cannot construct an Emitter after it was added in
66+
# https://github.com/rust-lang/rust/pull/114104. This can be removed when
67+
# https://github.com/rust-lang/rust/pull/115393 lands.
68+
# We need to construct an emitter as yet another workaround,
69+
# see https://github.com/rust-lang/rust/pull/102992.
70+
termcolor = "1.2"
71+
6572
[dev-dependencies]
6673
pipe = "0.4"
6774
pretty_assertions = "1.0"

crates/rustc_codegen_spirv/build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use std::process::{Command, ExitCode};
1010
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
1111
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
1212
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
13-
channel = "nightly-2023-07-08"
14-
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
15-
# commit_hash = cb80ff132a0e9aa71529b701427e4e6c243b58df"#;
13+
channel = "nightly-2023-08-29"
14+
components = ["rust-src", "rustc-dev", "llvm-tools"]
15+
# commit_hash = 4e78abb437a0478d1f42115198ee45888e5330fd"#;
1616

1717
fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
1818
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));

crates/rustc_codegen_spirv/src/abi.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use rustc_errors::ErrorGuaranteed;
1010
use rustc_index::Idx;
1111
use rustc_middle::query::{ExternProviders, Providers};
1212
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
13-
use rustc_middle::ty::subst::SubstsRef;
13+
use rustc_middle::ty::GenericArgsRef;
1414
use rustc_middle::ty::{
15-
self, Const, FloatTy, GeneratorSubsts, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind,
15+
self, Const, FloatTy, GeneratorArgs, IntTy, ParamEnv, PolyFnSig, Ty, TyCtxt, TyKind,
1616
TypeAndMut, UintTy,
1717
};
1818
use rustc_middle::{bug, span_bug};
@@ -104,6 +104,8 @@ pub(crate) fn provide(providers: &mut Providers) {
104104
largest_niche,
105105
align,
106106
size,
107+
max_repr_align,
108+
unadjusted_abi_align,
107109
} = *layout;
108110
LayoutS {
109111
fields: match *fields {
@@ -147,6 +149,8 @@ pub(crate) fn provide(providers: &mut Providers) {
147149
largest_niche,
148150
align,
149151
size,
152+
max_repr_align,
153+
unadjusted_abi_align,
150154
}
151155
}
152156
providers.layout_of = |tcx, key| {
@@ -343,7 +347,7 @@ impl<'tcx> ConvSpirvType<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
343347

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

353357
if let Some(intrinsic_type_attr) = attrs.intrinsic_type.map(|attr| attr.value) {
354358
if let Ok(spirv_type) =
355-
trans_intrinsic_type(cx, span, *self, substs, intrinsic_type_attr)
359+
trans_intrinsic_type(cx, span, *self, args, intrinsic_type_attr)
356360
{
357361
return spirv_type;
358362
}
@@ -782,7 +786,7 @@ impl fmt::Display for TyLayoutNameKey<'_> {
782786
}
783787
}
784788
if let (TyKind::Generator(_, _, _), Some(index)) = (self.ty.kind(), self.variant) {
785-
write!(f, "::{}", GeneratorSubsts::variant_name(index))?;
789+
write!(f, "::{}", GeneratorArgs::variant_name(index))?;
786790
}
787791
Ok(())
788792
}
@@ -792,7 +796,7 @@ fn trans_intrinsic_type<'tcx>(
792796
cx: &CodegenCx<'tcx>,
793797
span: Span,
794798
ty: TyAndLayout<'tcx>,
795-
substs: SubstsRef<'tcx>,
799+
args: GenericArgsRef<'tcx>,
796800
intrinsic_type_attr: IntrinsicType,
797801
) -> Result<Word, ErrorGuaranteed> {
798802
match intrinsic_type_attr {
@@ -817,7 +821,7 @@ fn trans_intrinsic_type<'tcx>(
817821
// <_>::from_u64(value).unwrap()
818822
// }
819823

820-
let sampled_type = match substs.type_at(0).kind() {
824+
let sampled_type = match args.type_at(0).kind() {
821825
TyKind::Int(int) => match int {
822826
IntTy::Isize => {
823827
SpirvType::Integer(cx.tcx.data_layout.pointer_size.bits() as u32, true)
@@ -850,13 +854,13 @@ fn trans_intrinsic_type<'tcx>(
850854
}
851855
};
852856

853-
// let dim: spirv::Dim = type_from_variant_discriminant(cx, substs.const_at(1));
854-
// let depth: u32 = type_from_variant_discriminant(cx, substs.const_at(2));
855-
// let arrayed: u32 = type_from_variant_discriminant(cx, substs.const_at(3));
856-
// let multisampled: u32 = type_from_variant_discriminant(cx, substs.const_at(4));
857-
// let sampled: u32 = type_from_variant_discriminant(cx, substs.const_at(5));
857+
// let dim: spirv::Dim = type_from_variant_discriminant(cx, args.const_at(1));
858+
// let depth: u32 = type_from_variant_discriminant(cx, args.const_at(2));
859+
// let arrayed: u32 = type_from_variant_discriminant(cx, args.const_at(3));
860+
// let multisampled: u32 = type_from_variant_discriminant(cx, args.const_at(4));
861+
// let sampled: u32 = type_from_variant_discriminant(cx, args.const_at(5));
858862
// let image_format: spirv::ImageFormat =
859-
// type_from_variant_discriminant(cx, substs.const_at(6));
863+
// type_from_variant_discriminant(cx, args.const_at(6));
860864

861865
fn const_int_value<'tcx, P: FromPrimitive>(
862866
cx: &CodegenCx<'tcx>,
@@ -873,12 +877,12 @@ fn trans_intrinsic_type<'tcx>(
873877
}
874878
}
875879

876-
let dim = const_int_value(cx, substs.const_at(1))?;
877-
let depth = const_int_value(cx, substs.const_at(2))?;
878-
let arrayed = const_int_value(cx, substs.const_at(3))?;
879-
let multisampled = const_int_value(cx, substs.const_at(4))?;
880-
let sampled = const_int_value(cx, substs.const_at(5))?;
881-
let image_format = const_int_value(cx, substs.const_at(6))?;
880+
let dim = const_int_value(cx, args.const_at(1))?;
881+
let depth = const_int_value(cx, args.const_at(2))?;
882+
let arrayed = const_int_value(cx, args.const_at(3))?;
883+
let multisampled = const_int_value(cx, args.const_at(4))?;
884+
let sampled = const_int_value(cx, args.const_at(5))?;
885+
let image_format = const_int_value(cx, args.const_at(6))?;
882886

883887
let ty = SpirvType::Image {
884888
sampled_type,
@@ -913,7 +917,7 @@ fn trans_intrinsic_type<'tcx>(
913917

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

935939
// We use a generic to indicate the underlying element type.
936940
// The spirv type of it will be generated by querying the type of the first generic.
937-
if let Some(elem_ty) = substs.types().next() {
941+
if let Some(elem_ty) = args.types().next() {
938942
let element = cx.layout_of(elem_ty).spirv_type(span, cx);
939943
Ok(SpirvType::RuntimeArray { element }.def(span, cx))
940944
} else {

crates/rustc_codegen_spirv/src/attr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::symbols::Symbols;
77
use rspirv::spirv::{BuiltIn, ExecutionMode, ExecutionModel, StorageClass};
88
use rustc_ast::Attribute;
99
use rustc_hir as hir;
10-
use rustc_hir::def_id::LocalDefId;
10+
use rustc_hir::def_id::LocalModDefId;
1111
use rustc_hir::intravisit::{self, Visitor};
1212
use rustc_hir::{HirId, MethodKind, Target, CRATE_HIR_ID};
1313
use rustc_middle::hir::nested_filter;
@@ -484,7 +484,7 @@ impl<'tcx> Visitor<'tcx> for CheckSpirvAttrVisitor<'tcx> {
484484
}
485485

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

499499
pub(crate) fn provide(providers: &mut Providers) {
500500
*providers = Providers {
501-
check_mod_attrs: |tcx, def_id| {
501+
check_mod_attrs: |tcx, module_def_id| {
502502
// Run both the default checks, and our `#[spirv(...)]` ones.
503-
(rustc_interface::DEFAULT_QUERY_PROVIDERS.check_mod_attrs)(tcx, def_id);
504-
check_mod_attrs(tcx, def_id);
503+
(rustc_interface::DEFAULT_QUERY_PROVIDERS.check_mod_attrs)(tcx, module_def_id);
504+
check_mod_attrs(tcx, module_def_id);
505505
},
506506
..*providers
507507
};

crates/rustc_codegen_spirv/src/builder/byte_addressable_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use super::Builder;
22
use crate::builder_spirv::{SpirvValue, SpirvValueExt, SpirvValueKind};
33
use crate::spirv_type::SpirvType;
44
use rspirv::spirv::Word;
5-
use rustc_codegen_ssa::traits::{BaseTypeMethods, BuilderMethods};
5+
use rustc_codegen_ssa::traits::BuilderMethods;
66
use rustc_errors::ErrorGuaranteed;
77
use rustc_span::DUMMY_SP;
88
use rustc_target::abi::call::PassMode;

crates/rustc_codegen_spirv/src/builder/intrinsics.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
7474
) {
7575
let callee_ty = instance.ty(self.tcx, ParamEnv::reveal_all());
7676

77-
let (def_id, substs) = match *callee_ty.kind() {
78-
FnDef(def_id, substs) => (def_id, substs),
77+
let (def_id, fn_args) = match *callee_ty.kind() {
78+
FnDef(def_id, fn_args) => (def_id, fn_args),
7979
_ => bug!("expected fn item type, found {}", callee_ty),
8080
};
8181

@@ -103,7 +103,7 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
103103

104104
sym::volatile_load | sym::unaligned_volatile_load => {
105105
let ptr = args[0].immediate();
106-
let layout = self.layout_of(substs.type_at(0));
106+
let layout = self.layout_of(fn_args.type_at(0));
107107
let load = self.volatile_load(layout.spirv_type(self.span(), self), ptr);
108108
self.to_immediate(load, layout)
109109
}

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
660660
/// `leftover_operands` is used for `IndexComposite` patterns, if any exist.
661661
/// If the pattern isn't constraining enough to determine an unique type,
662662
/// `Err(Ambiguous)` is returned instead.
663-
fn subst_ty_pat(
663+
fn arg_ty_pat(
664664
cx: &CodegenCx<'_>,
665665
pat: &TyPat<'_>,
666666
ty_vars: &[Option<Word>],
@@ -673,23 +673,23 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
673673
},
674674

675675
TyPat::Pointer(_, pat) => SpirvType::Pointer {
676-
pointee: subst_ty_pat(cx, pat, ty_vars, leftover_operands)?,
676+
pointee: arg_ty_pat(cx, pat, ty_vars, leftover_operands)?,
677677
}
678678
.def(DUMMY_SP, cx),
679679

680680
TyPat::Vector4(pat) => SpirvType::Vector {
681-
element: subst_ty_pat(cx, pat, ty_vars, leftover_operands)?,
681+
element: arg_ty_pat(cx, pat, ty_vars, leftover_operands)?,
682682
count: 4,
683683
}
684684
.def(DUMMY_SP, cx),
685685

686686
TyPat::SampledImage(pat) => SpirvType::SampledImage {
687-
image_type: subst_ty_pat(cx, pat, ty_vars, leftover_operands)?,
687+
image_type: arg_ty_pat(cx, pat, ty_vars, leftover_operands)?,
688688
}
689689
.def(DUMMY_SP, cx),
690690

691691
TyPat::IndexComposite(pat) => {
692-
let mut ty = subst_ty_pat(cx, pat, ty_vars, leftover_operands)?;
692+
let mut ty =arg_ty_pat(cx, pat, ty_vars, leftover_operands)?;
693693
for index in leftover_operands {
694694
let index_to_usize = || match *index {
695695
// FIXME(eddyb) support more than just literals,
@@ -780,7 +780,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
780780
_ => return None,
781781
}
782782

783-
match subst_ty_pat(
783+
match arg_ty_pat(
784784
self,
785785
sig.output_type.unwrap(),
786786
&combined_ty_vars,

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::abi::ConvSpirvType;
33
use crate::builder_spirv::{SpirvConst, SpirvValue, SpirvValueExt, SpirvValueKind};
44
use crate::spirv_type::SpirvType;
55
use rspirv::spirv::Word;
6-
use rustc_codegen_ssa::traits::{BaseTypeMethods, ConstMethods, MiscMethods, StaticMethods};
6+
use rustc_codegen_ssa::traits::{ConstMethods, MiscMethods, StaticMethods};
77
use rustc_middle::bug;
88
use rustc_middle::mir::interpret::{alloc_range, ConstAllocation, GlobalAlloc, Scalar};
99
use rustc_middle::ty::layout::LayoutOf;
@@ -361,18 +361,6 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
361361
self.def_constant(void_type, SpirvConst::ConstDataFromAlloc(alloc))
362362
}
363363

364-
// FIXME(eddyb) is this just redundant with `const_bitcast`?!
365-
fn const_ptrcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value {
366-
if val.ty == ty {
367-
val
368-
} else {
369-
// FIXME(eddyb) implement via `OpSpecConstantOp`.
370-
// FIXME(eddyb) this zombies the original value without creating a new one.
371-
let result = val.def_cx(self).with_type(ty);
372-
self.zombie_no_span(result.def_cx(self), "const_ptrcast");
373-
result
374-
}
375-
}
376364
fn const_bitcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value {
377365
// HACK(eddyb) special-case `const_data_from_alloc` + `static_addr_of`
378366
// as the old `from_const_alloc` (now `OperandRef::from_const_alloc`).

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::spirv_type::SpirvType;
77
use itertools::Itertools;
88
use rspirv::spirv::{FunctionControl, LinkageType, StorageClass, Word};
99
use rustc_attr::InlineAttr;
10-
use rustc_codegen_ssa::traits::{BaseTypeMethods, PreDefineMethods, StaticMethods};
10+
use rustc_codegen_ssa::traits::{PreDefineMethods, StaticMethods};
1111
use rustc_hir::def::DefKind;
1212
use rustc_middle::bug;
1313
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
@@ -37,8 +37,8 @@ fn attrs_to_spirv(attrs: &CodegenFnAttrs) -> FunctionControl {
3737
impl<'tcx> CodegenCx<'tcx> {
3838
/// Returns a function if it already exists, or declares a header if it doesn't.
3939
pub fn get_fn_ext(&self, instance: Instance<'tcx>) -> SpirvValue {
40-
assert!(!instance.substs.has_infer());
41-
assert!(!instance.substs.has_escaping_bound_vars());
40+
assert!(!instance.args.has_infer());
41+
assert!(!instance.args.has_escaping_bound_vars());
4242

4343
if let Some(&func) = self.instances.borrow().get(&instance) {
4444
return func;
@@ -214,7 +214,7 @@ impl<'tcx> CodegenCx<'tcx> {
214214
})
215215
});
216216
if let Some(spec) = spec {
217-
if let Some((ty,)) = instance.substs.types().collect_tuple() {
217+
if let Some((ty,)) = instance.args.types().collect_tuple() {
218218
self.fmt_rt_arg_new_fn_ids_to_ty_and_spec
219219
.borrow_mut()
220220
.insert(fn_id, (ty, spec));

0 commit comments

Comments
 (0)