@@ -6,6 +6,11 @@ use crate::codegen_cx::CodegenCx;
66use crate :: spirv_type:: SpirvType ;
77use itertools:: Itertools ;
88use rspirv:: spirv:: { Dim , ImageFormat , StorageClass , Word } ;
9+ use rustc_abi:: ExternAbi ;
10+ use rustc_abi:: {
11+ Align , BackendRepr , FieldsShape , LayoutData , Primitive , ReprFlags , ReprOptions , Scalar , Size ,
12+ TagEncoding , VariantIdx , Variants ,
13+ } ;
914use rustc_data_structures:: fx:: FxHashMap ;
1015use rustc_errors:: ErrorGuaranteed ;
1116use rustc_index:: Idx ;
@@ -20,12 +25,7 @@ use rustc_middle::{bug, span_bug};
2025use rustc_span:: DUMMY_SP ;
2126use rustc_span:: def_id:: DefId ;
2227use rustc_span:: { Span , Symbol } ;
23- use rustc_target:: abi:: call:: { ArgAbi , ArgAttributes , FnAbi , PassMode } ;
24- use rustc_target:: abi:: {
25- Align , BackendRepr , FieldsShape , LayoutData , Primitive , ReprFlags , ReprOptions , Scalar , Size ,
26- TagEncoding , VariantIdx , Variants ,
27- } ;
28- use rustc_target:: spec:: abi:: Abi ;
28+ use rustc_target:: callconv:: { ArgAbi , ArgAttributes , FnAbi , PassMode } ;
2929use std:: cell:: RefCell ;
3030use std:: collections:: hash_map:: Entry ;
3131use std:: fmt;
@@ -46,8 +46,8 @@ pub(crate) fn provide(providers: &mut Providers) {
4646 let result = ( rustc_interface:: DEFAULT_QUERY_PROVIDERS . fn_sig ) ( tcx, def_id) ;
4747 result. map_bound ( |outer| {
4848 outer. map_bound ( |mut inner| {
49- if let Abi :: C { .. } = inner. abi {
50- inner. abi = Abi :: Unadjusted ;
49+ if let ExternAbi :: C { .. } = inner. abi {
50+ inner. abi = ExternAbi :: Unadjusted ;
5151 }
5252 inner
5353 } )
@@ -110,6 +110,8 @@ pub(crate) fn provide(providers: &mut Providers) {
110110 size,
111111 max_repr_align,
112112 unadjusted_abi_align,
113+ uninhabited,
114+ randomization_seed,
113115 } = * layout;
114116 LayoutData {
115117 fields : match * fields {
@@ -125,6 +127,7 @@ pub(crate) fn provide(providers: &mut Providers) {
125127 } ,
126128 } ,
127129 variants : match * variants {
130+ Variants :: Empty => Variants :: Empty ,
128131 Variants :: Single { index } => Variants :: Single { index } ,
129132 Variants :: Multiple {
130133 tag,
@@ -155,6 +158,8 @@ pub(crate) fn provide(providers: &mut Providers) {
155158 size,
156159 max_repr_align,
157160 unadjusted_abi_align,
161+ uninhabited,
162+ randomization_seed,
158163 }
159164 }
160165
@@ -198,6 +203,7 @@ pub(crate) fn provide(providers: &mut Providers) {
198203 let trivial_struct = match tcx. hir_node_by_def_id ( def_id) {
199204 rustc_hir:: Node :: Item ( item) => match item. kind {
200205 rustc_hir:: ItemKind :: Struct (
206+ _,
201207 _,
202208 & rustc_hir:: Generics {
203209 params :
@@ -462,7 +468,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
462468 // `ScalarPair`.
463469 // There's a few layers that we go through here. First we inspect layout.backend_repr, then if relevant, layout.fields, etc.
464470 match self . backend_repr {
465- BackendRepr :: Uninhabited => SpirvType :: Adt {
471+ x @ _ if x . is_unsized ( ) => SpirvType :: Adt {
466472 def_id : def_id_for_spirv_type_adt ( * self ) ,
467473 size : Some ( Size :: ZERO ) ,
468474 align : Align :: from_bytes ( 0 ) . unwrap ( ) ,
@@ -523,7 +529,9 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
523529 if let TyKind :: Adt ( adt, _) = self . ty . kind ( ) {
524530 if let Variants :: Single { index } = self . variants {
525531 for i in self . fields . index_by_increasing_offset ( ) {
526- let field = & adt. variants ( ) [ index] . fields [ i. into ( ) ] ;
532+ let field_index = rustc_abi:: FieldIdx :: from_usize ( i) ;
533+ let field: & rustc_middle:: ty:: FieldDef =
534+ & adt. variants ( ) [ index] . fields [ field_index] ;
527535 field_names. push ( field. name ) ;
528536 }
529537 }
@@ -542,7 +550,7 @@ impl<'tcx> ConvSpirvType<'tcx> for TyAndLayout<'tcx> {
542550 }
543551 . def_with_name ( cx, span, TyLayoutNameKey :: from ( * self ) )
544552 }
545- BackendRepr :: Vector { element, count } => {
553+ BackendRepr :: SimdVector { element, count } => {
546554 let elem_spirv = trans_scalar ( cx, span, * self , element, Size :: ZERO ) ;
547555 SpirvType :: Vector {
548556 element : elem_spirv,
@@ -653,6 +661,7 @@ fn dig_scalar_pointee<'tcx>(
653661
654662 let all_fields = ( match & layout. variants {
655663 Variants :: Multiple { variants, .. } => 0 ..variants. len ( ) ,
664+ Variants :: Empty => 0 ..0 ,
656665 Variants :: Single { index } => {
657666 let i = index. as_usize ( ) ;
658667 i..i + 1
@@ -811,7 +820,8 @@ fn trans_struct<'tcx>(cx: &CodegenCx<'tcx>, span: Span, ty: TyAndLayout<'tcx>) -
811820 field_offsets. push ( offset) ;
812821 if let Variants :: Single { index } = ty. variants {
813822 if let TyKind :: Adt ( adt, _) = ty. ty . kind ( ) {
814- let field = & adt. variants ( ) [ index] . fields [ i. into ( ) ] ;
823+ let field_index = rustc_abi:: FieldIdx :: from_usize ( i) ;
824+ let field: & rustc_middle:: ty:: FieldDef = & adt. variants ( ) [ index] . fields [ field_index] ;
815825 field_names. push ( field. name ) ;
816826 } else {
817827 // FIXME(eddyb) this looks like something that should exist in rustc.
@@ -868,6 +878,7 @@ impl<'tcx> From<TyAndLayout<'tcx>> for TyLayoutNameKey<'tcx> {
868878 variant : match layout. variants {
869879 Variants :: Single { index } => Some ( index) ,
870880 Variants :: Multiple { .. } => None ,
881+ Variants :: Empty => None ,
871882 } ,
872883 }
873884 }
@@ -984,11 +995,11 @@ fn trans_intrinsic_type<'tcx>(
984995 cx : & CodegenCx < ' tcx > ,
985996 const_ : Const < ' tcx > ,
986997 ) -> Result < P , ErrorGuaranteed > {
987- let ( const_val, const_ty) = const_
988- . try_to_valtree ( )
989- . expect ( "expected monomorphic const in codegen" ) ;
998+ let const_val = const_. to_value ( ) ;
999+ let const_ty = const_val. ty ;
9901000 assert ! ( const_ty. is_integral( ) ) ;
9911001 const_val
1002+ . valtree
9921003 . try_to_scalar_int ( )
9931004 . and_then ( P :: from_scalar_int)
9941005 . ok_or_else ( || {
0 commit comments