@@ -4,6 +4,7 @@ use llvm::Linkage::*;
44use rustc_abi:: Align ;
55use rustc_codegen_ssa:: back:: write:: CodegenContext ;
66use rustc_codegen_ssa:: traits:: BaseTypeCodegenMethods ;
7+ use rustc_middle:: ty:: offload_meta:: OffloadMetadata ;
78use rustc_middle:: ty:: { self , PseudoCanonicalInput , Ty , TyCtxt , TypingEnv } ;
89
910use crate :: builder:: SBuilder ;
@@ -260,8 +261,7 @@ pub(crate) fn gen_define_handling<'ll, 'tcx>(
260261 tcx : TyCtxt < ' tcx > ,
261262 kernel : & ' ll llvm:: Value ,
262263 offload_entry_ty : & ' ll llvm:: Type ,
263- // TODO(Sa4dUs): Define a typetree once i have a better idea of what do we exactly need
264- tt : Vec < Ty < ' tcx > > ,
264+ metadata : Vec < OffloadMetadata > ,
265265 symbol : & str ,
266266) -> ( & ' ll llvm:: Value , & ' ll llvm:: Value ) {
267267 let types = cx. func_params_types ( cx. get_type_of_global ( kernel) ) ;
@@ -272,12 +272,11 @@ pub(crate) fn gen_define_handling<'ll, 'tcx>(
272272 . filter ( |& x| matches ! ( cx. type_kind( x) , rustc_codegen_ssa:: common:: TypeKind :: Pointer ) )
273273 . count ( ) ;
274274
275- // TODO(Sa4dUs): Add typetrees here
276275 let ptr_sizes = types
277276 . iter ( )
278- . zip ( tt )
279- . filter_map ( |( & x, ty ) | match cx. type_kind ( x) {
280- rustc_codegen_ssa:: common:: TypeKind :: Pointer => Some ( get_payload_size ( tcx , ty ) ) ,
277+ . zip ( metadata )
278+ . filter_map ( |( & x, meta ) | match cx. type_kind ( x) {
279+ rustc_codegen_ssa:: common:: TypeKind :: Pointer => Some ( meta . payload_size ) ,
281280 _ => None ,
282281 } )
283282 . collect :: < Vec < u64 > > ( ) ;
@@ -332,56 +331,6 @@ pub(crate) fn gen_define_handling<'ll, 'tcx>(
332331 ( memtransfer_types, region_id)
333332}
334333
335- // TODO(Sa4dUs): move this to a proper place
336- fn get_payload_size < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> u64 {
337- match ty. kind ( ) {
338- /*
339- rustc_middle::infer::canonical::ir::TyKind::Bool => todo!(),
340- rustc_middle::infer::canonical::ir::TyKind::Char => todo!(),
341- rustc_middle::infer::canonical::ir::TyKind::Int(int_ty) => todo!(),
342- rustc_middle::infer::canonical::ir::TyKind::Uint(uint_ty) => todo!(),
343- rustc_middle::infer::canonical::ir::TyKind::Float(float_ty) => todo!(),
344- rustc_middle::infer::canonical::ir::TyKind::Adt(_, _) => todo!(),
345- rustc_middle::infer::canonical::ir::TyKind::Foreign(_) => todo!(),
346- rustc_middle::infer::canonical::ir::TyKind::Str => todo!(),
347- rustc_middle::infer::canonical::ir::TyKind::Array(_, _) => todo!(),
348- rustc_middle::infer::canonical::ir::TyKind::Pat(_, _) => todo!(),
349- rustc_middle::infer::canonical::ir::TyKind::Slice(_) => todo!(),
350- rustc_middle::infer::canonical::ir::TyKind::RawPtr(_, mutability) => todo!(),
351- */
352- ty:: Ref ( _, inner, _) => get_payload_size ( tcx, * inner) ,
353- /*
354- rustc_middle::infer::canonical::ir::TyKind::FnDef(_, _) => todo!(),
355- rustc_middle::infer::canonical::ir::TyKind::FnPtr(binder, fn_header) => todo!(),
356- rustc_middle::infer::canonical::ir::TyKind::UnsafeBinder(unsafe_binder_inner) => todo!(),
357- rustc_middle::infer::canonical::ir::TyKind::Dynamic(_, _) => todo!(),
358- rustc_middle::infer::canonical::ir::TyKind::Closure(_, _) => todo!(),
359- rustc_middle::infer::canonical::ir::TyKind::CoroutineClosure(_, _) => todo!(),
360- rustc_middle::infer::canonical::ir::TyKind::Coroutine(_, _) => todo!(),
361- rustc_middle::infer::canonical::ir::TyKind::CoroutineWitness(_, _) => todo!(),
362- rustc_middle::infer::canonical::ir::TyKind::Never => todo!(),
363- rustc_middle::infer::canonical::ir::TyKind::Tuple(_) => todo!(),
364- rustc_middle::infer::canonical::ir::TyKind::Alias(alias_ty_kind, alias_ty) => todo!(),
365- rustc_middle::infer::canonical::ir::TyKind::Param(_) => todo!(),
366- rustc_middle::infer::canonical::ir::TyKind::Bound(bound_var_index_kind, _) => todo!(),
367- rustc_middle::infer::canonical::ir::TyKind::Placeholder(_) => todo!(),
368- rustc_middle::infer::canonical::ir::TyKind::Infer(infer_ty) => todo!(),
369- rustc_middle::infer::canonical::ir::TyKind::Error(_) => todo!(),
370- */
371- _ => {
372- tcx
373- // TODO(Sa4dUs): Maybe `.as_query_input()`?
374- . layout_of ( PseudoCanonicalInput {
375- typing_env : TypingEnv :: fully_monomorphized ( ) ,
376- value : ty,
377- } )
378- . unwrap ( )
379- . size
380- . bytes ( )
381- }
382- }
383- }
384-
385334fn declare_offload_fn < ' ll > (
386335 cx : & ' ll SimpleCx < ' _ > ,
387336 name : & str ,
@@ -420,7 +369,7 @@ fn declare_offload_fn<'ll>(
420369pub ( crate ) fn gen_call_handling < ' ll > (
421370 cx : & SimpleCx < ' ll > ,
422371 bb : & BasicBlock ,
423- kernels : & [ & ' ll llvm:: Value ] ,
372+ kernel : & ' ll llvm:: Value ,
424373 memtransfer_types : & [ & ' ll llvm:: Value ] ,
425374 region_ids : & [ & ' ll llvm:: Value ] ,
426375 llfn : & ' ll Value ,
@@ -438,7 +387,7 @@ pub(crate) fn gen_call_handling<'ll>(
438387
439388 let mut builder = SBuilder :: build ( cx, bb) ;
440389
441- let types = cx. func_params_types ( cx. get_type_of_global ( kernels [ 0 ] ) ) ;
390+ let types = cx. func_params_types ( cx. get_type_of_global ( kernel ) ) ;
442391 let num_args = types. len ( ) as u64 ;
443392
444393 // Step 0)
0 commit comments