@@ -10,8 +10,9 @@ use crate::spirv_type::SpirvType;
1010use rspirv:: dr:: Operand ;
1111use rspirv:: spirv:: GLOp ;
1212use rustc_codegen_ssa:: RetagInfo ;
13+ use rustc_codegen_ssa:: mir:: IntrinsicResult ;
1314use rustc_codegen_ssa:: mir:: operand:: { OperandRef , OperandValue } ;
14- use rustc_codegen_ssa:: mir:: place:: PlaceRef ;
15+ use rustc_codegen_ssa:: mir:: place:: { PlaceRef , PlaceValue } ;
1516use rustc_codegen_ssa:: traits:: { BuilderMethods , IntrinsicCallBuilderMethods } ;
1617use rustc_middle:: ty:: layout:: LayoutOf ;
1718use rustc_middle:: ty:: { FnDef , Instance , Ty , TyKind , TypingEnv } ;
@@ -64,9 +65,14 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
6465 & mut self ,
6566 instance : Instance < ' tcx > ,
6667 args : & [ OperandRef < ' tcx , Self :: Value > ] ,
67- result : PlaceRef < ' tcx , Self :: Value > ,
68+ result_layout : ty:: layout:: TyAndLayout < ' tcx > ,
69+ result_place : Option < PlaceValue < Self :: Value > > ,
6870 _span : Span ,
69- ) -> Result < ( ) , ty:: Instance < ' tcx > > {
71+ ) -> IntrinsicResult < ' tcx , Self :: Value > {
72+ let result = PlaceRef {
73+ val : result_place. unwrap ( ) ,
74+ layout : result_layout,
75+ } ;
7076 let callee_ty = instance. ty ( self . tcx , TypingEnv :: fully_monomorphized ( ) ) ;
7177
7278 let ( def_id, fn_args) = match * callee_ty. kind ( ) {
@@ -95,7 +101,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
95101 sym:: breakpoint => {
96102 self . abort ( ) ;
97103 assert ! ( result. layout. ty. is_unit( ) ) ;
98- return Ok ( ( ) ) ;
104+ return IntrinsicResult :: WroteIntoPlace ;
99105 }
100106
101107 sym:: volatile_load | sym:: unaligned_volatile_load => {
@@ -105,7 +111,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
105111 if !result. layout . is_zst ( ) {
106112 self . store ( load, result. val . llval , result. val . align ) ;
107113 }
108- return Ok ( ( ) ) ;
114+ return IntrinsicResult :: WroteIntoPlace ;
109115 }
110116
111117 sym:: prefetch_read_data
@@ -114,7 +120,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
114120 | sym:: prefetch_write_instruction => {
115121 // ignore
116122 assert ! ( result. layout. ty. is_unit( ) ) ;
117- return Ok ( ( ) ) ;
123+ return IntrinsicResult :: WroteIntoPlace ;
118124 }
119125
120126 sym:: saturating_add => {
@@ -352,7 +358,10 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
352358
353359 _ => {
354360 // Call the fallback body instead of generating the intrinsic code
355- return Err ( ty:: Instance :: new_raw ( instance. def_id ( ) , instance. args ) ) ;
361+ return IntrinsicResult :: Fallback ( Instance :: new_raw (
362+ instance. def_id ( ) ,
363+ instance. args ,
364+ ) ) ;
356365 }
357366 } ;
358367
@@ -368,7 +377,7 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
368377 . val
369378 . store ( self , result) ;
370379 }
371- Ok ( ( ) )
380+ IntrinsicResult :: WroteIntoPlace
372381 }
373382
374383 fn codegen_llvm_intrinsic_call (
@@ -402,16 +411,9 @@ impl<'a, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'tcx> {
402411 todo ! ( )
403412 }
404413
405- fn va_start ( & mut self , val : Self :: Value ) -> Self :: Value {
406- // SPIR-V backend has no variadic ABI support; keep the placeholder
407- // operand unchanged so MIR lowering can proceed without crashing.
408- val
409- }
414+ fn va_start ( & mut self , _val : Self :: Value ) { }
410415
411- fn va_end ( & mut self , val : Self :: Value ) -> Self :: Value {
412- // See `va_start` above.
413- val
414- }
416+ fn va_end ( & mut self , _val : Self :: Value ) { }
415417
416418 fn retag_mem ( & mut self , _place : Self :: Value , _info : & RetagInfo < Self :: Value > ) {
417419 bug ! ( "retag not supported" )
0 commit comments