@@ -19,7 +19,7 @@ use rustc_middle::{bug, span_bug};
19
19
use rustc_span:: def_id:: DefId ;
20
20
use rustc_span:: Span ;
21
21
use rustc_span:: DUMMY_SP ;
22
- use rustc_target:: abi:: call:: { ArgAbi , ArgAttributes , CastTarget , FnAbi , PassMode , Reg , RegKind } ;
22
+ use rustc_target:: abi:: call:: { ArgAbi , ArgAttributes , FnAbi , PassMode } ;
23
23
use rustc_target:: abi:: { Abi , Align , FieldsShape , Primitive , Scalar , Size , VariantIdx , Variants } ;
24
24
use rustc_target:: spec:: abi:: Abi as SpecAbi ;
25
25
use std:: cell:: RefCell ;
@@ -236,87 +236,6 @@ impl<'tcx> ConvSpirvType<'tcx> for PointeeTy<'tcx> {
236
236
}
237
237
}
238
238
239
- impl < ' tcx > ConvSpirvType < ' tcx > for Reg {
240
- fn spirv_type ( & self , span : Span , cx : & CodegenCx < ' tcx > ) -> Word {
241
- match self . kind {
242
- RegKind :: Integer => SpirvType :: Integer ( self . size . bits ( ) as u32 , false ) . def ( span, cx) ,
243
- RegKind :: Float => SpirvType :: Float ( self . size . bits ( ) as u32 ) . def ( span, cx) ,
244
- RegKind :: Vector => SpirvType :: Vector {
245
- element : SpirvType :: Integer ( 8 , false ) . def ( span, cx) ,
246
- count : self . size . bytes ( ) as u32 ,
247
- }
248
- . def ( span, cx) ,
249
- }
250
- }
251
- }
252
-
253
- impl < ' tcx > ConvSpirvType < ' tcx > for CastTarget {
254
- fn spirv_type ( & self , span : Span , cx : & CodegenCx < ' tcx > ) -> Word {
255
- let rest_ll_unit = self . rest . unit . spirv_type ( span, cx) ;
256
- let ( rest_count, rem_bytes) = if self . rest . unit . size . bytes ( ) == 0 {
257
- ( 0 , 0 )
258
- } else {
259
- (
260
- self . rest . total . bytes ( ) / self . rest . unit . size . bytes ( ) ,
261
- self . rest . total . bytes ( ) % self . rest . unit . size . bytes ( ) ,
262
- )
263
- } ;
264
-
265
- if self . prefix . iter ( ) . all ( |x| x. is_none ( ) ) {
266
- // Simplify to a single unit when there is no prefix and size <= unit size
267
- if self . rest . total <= self . rest . unit . size {
268
- return rest_ll_unit;
269
- }
270
-
271
- // Simplify to array when all chunks are the same size and type
272
- if rem_bytes == 0 {
273
- return SpirvType :: Array {
274
- element : rest_ll_unit,
275
- count : cx. constant_u32 ( span, rest_count as u32 ) ,
276
- }
277
- . def ( span, cx) ;
278
- }
279
- }
280
-
281
- // Create list of fields in the main structure
282
- let mut args: Vec < _ > = self
283
- . prefix
284
- . iter ( )
285
- . flatten ( )
286
- . map ( |& kind| {
287
- Reg {
288
- kind,
289
- size : self . prefix_chunk_size ,
290
- }
291
- . spirv_type ( span, cx)
292
- } )
293
- . chain ( ( 0 ..rest_count) . map ( |_| rest_ll_unit) )
294
- . collect ( ) ;
295
-
296
- // Append final integer
297
- if rem_bytes != 0 {
298
- // Only integers can be really split further.
299
- assert_eq ! ( self . rest. unit. kind, RegKind :: Integer ) ;
300
- args. push ( SpirvType :: Integer ( rem_bytes as u32 * 8 , false ) . def ( span, cx) ) ;
301
- }
302
-
303
- let size = Some ( self . size ( cx) ) ;
304
- let align = self . align ( cx) ;
305
- let ( field_offsets, computed_size, computed_align) = auto_struct_layout ( cx, & args) ;
306
- assert_eq ! ( size, computed_size, "{:#?}" , self ) ;
307
- assert_eq ! ( align, computed_align, "{:#?}" , self ) ;
308
- SpirvType :: Adt {
309
- def_id : None ,
310
- size,
311
- align,
312
- field_types : args,
313
- field_offsets,
314
- field_names : None ,
315
- }
316
- . def ( span, cx)
317
- }
318
- }
319
-
320
239
impl < ' tcx > ConvSpirvType < ' tcx > for FnAbi < ' tcx , Ty < ' tcx > > {
321
240
fn spirv_type ( & self , span : Span , cx : & CodegenCx < ' tcx > ) -> Word {
322
241
let mut argument_types = Vec :: new ( ) ;
@@ -326,14 +245,11 @@ impl<'tcx> ConvSpirvType<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
326
245
PassMode :: Direct ( _) | PassMode :: Pair ( ..) => {
327
246
self . ret . layout . spirv_type_immediate ( span, cx)
328
247
}
329
- PassMode :: Cast ( cast_target) => cast_target. spirv_type ( span, cx) ,
330
- PassMode :: Indirect { .. } => {
331
- let pointee = self . ret . layout . spirv_type ( span, cx) ;
332
- let pointer = SpirvType :: Pointer { pointee } . def ( span, cx) ;
333
- // Important: the return pointer comes *first*, not last.
334
- argument_types. push ( pointer) ;
335
- SpirvType :: Void . def ( span, cx)
336
- }
248
+ PassMode :: Cast ( _) | PassMode :: Indirect { .. } => span_bug ! (
249
+ span,
250
+ "query hooks should've made this `PassMode` impossible: {:#?}" ,
251
+ self . ret
252
+ ) ,
337
253
} ;
338
254
339
255
for arg in & self . args {
@@ -349,27 +265,11 @@ impl<'tcx> ConvSpirvType<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
349
265
) ) ;
350
266
continue ;
351
267
}
352
- PassMode :: Cast ( cast_target) => cast_target. spirv_type ( span, cx) ,
353
- PassMode :: Indirect {
354
- extra_attrs : Some ( _) ,
355
- ..
356
- } => {
357
- let ptr_ty = cx. tcx . mk_mut_ptr ( arg. layout . ty ) ;
358
- let ptr_layout = cx. layout_of ( ptr_ty) ;
359
- argument_types. push ( scalar_pair_element_backend_type (
360
- cx, span, ptr_layout, 0 , true ,
361
- ) ) ;
362
- argument_types. push ( scalar_pair_element_backend_type (
363
- cx, span, ptr_layout, 1 , true ,
364
- ) ) ;
365
- continue ;
366
- }
367
- PassMode :: Indirect {
368
- extra_attrs : None , ..
369
- } => {
370
- let pointee = arg. layout . spirv_type ( span, cx) ;
371
- SpirvType :: Pointer { pointee } . def ( span, cx)
372
- }
268
+ PassMode :: Cast ( _) | PassMode :: Indirect { .. } => span_bug ! (
269
+ span,
270
+ "query hooks should've made this `PassMode` impossible: {:#?}" ,
271
+ arg
272
+ ) ,
373
273
} ;
374
274
argument_types. push ( arg_type) ;
375
275
}
0 commit comments