@@ -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 ;
@@ -263,8 +264,7 @@ pub(crate) fn gen_define_handling<'ll, 'tcx>(
263264 tcx : TyCtxt < ' tcx > ,
264265 kernel : & ' ll llvm:: Value ,
265266 offload_entry_ty : & ' ll llvm:: Type ,
266- // TODO(Sa4dUs): Define a typetree once i have a better idea of what do we exactly need
267- tt : Vec < Ty < ' tcx > > ,
267+ metadata : Vec < OffloadMetadata > ,
268268 symbol : & str ,
269269) -> ( & ' ll llvm:: Value , & ' ll llvm:: Value ) {
270270 let types = cx. func_params_types ( cx. get_type_of_global ( kernel) ) ;
@@ -275,12 +275,11 @@ pub(crate) fn gen_define_handling<'ll, 'tcx>(
275275 . filter ( |& x| matches ! ( cx. type_kind( x) , rustc_codegen_ssa:: common:: TypeKind :: Pointer ) )
276276 . count ( ) ;
277277
278- // TODO(Sa4dUs): Add typetrees here
279278 let ptr_sizes = types
280279 . iter ( )
281- . zip ( tt )
282- . filter_map ( |( & x, ty ) | match cx. type_kind ( x) {
283- rustc_codegen_ssa:: common:: TypeKind :: Pointer => Some ( get_payload_size ( tcx , ty ) ) ,
280+ . zip ( metadata )
281+ . filter_map ( |( & x, meta ) | match cx. type_kind ( x) {
282+ rustc_codegen_ssa:: common:: TypeKind :: Pointer => Some ( meta . payload_size ) ,
284283 _ => None ,
285284 } )
286285 . collect :: < Vec < u64 > > ( ) ;
@@ -335,56 +334,6 @@ pub(crate) fn gen_define_handling<'ll, 'tcx>(
335334 ( memtransfer_types, region_id)
336335}
337336
338- // TODO(Sa4dUs): move this to a proper place
339- fn get_payload_size < ' tcx > ( tcx : TyCtxt < ' tcx > , ty : Ty < ' tcx > ) -> u64 {
340- match ty. kind ( ) {
341- /*
342- rustc_middle::infer::canonical::ir::TyKind::Bool => todo!(),
343- rustc_middle::infer::canonical::ir::TyKind::Char => todo!(),
344- rustc_middle::infer::canonical::ir::TyKind::Int(int_ty) => todo!(),
345- rustc_middle::infer::canonical::ir::TyKind::Uint(uint_ty) => todo!(),
346- rustc_middle::infer::canonical::ir::TyKind::Float(float_ty) => todo!(),
347- rustc_middle::infer::canonical::ir::TyKind::Adt(_, _) => todo!(),
348- rustc_middle::infer::canonical::ir::TyKind::Foreign(_) => todo!(),
349- rustc_middle::infer::canonical::ir::TyKind::Str => todo!(),
350- rustc_middle::infer::canonical::ir::TyKind::Array(_, _) => todo!(),
351- rustc_middle::infer::canonical::ir::TyKind::Pat(_, _) => todo!(),
352- rustc_middle::infer::canonical::ir::TyKind::Slice(_) => todo!(),
353- rustc_middle::infer::canonical::ir::TyKind::RawPtr(_, mutability) => todo!(),
354- */
355- ty:: Ref ( _, inner, _) => get_payload_size ( tcx, * inner) ,
356- /*
357- rustc_middle::infer::canonical::ir::TyKind::FnDef(_, _) => todo!(),
358- rustc_middle::infer::canonical::ir::TyKind::FnPtr(binder, fn_header) => todo!(),
359- rustc_middle::infer::canonical::ir::TyKind::UnsafeBinder(unsafe_binder_inner) => todo!(),
360- rustc_middle::infer::canonical::ir::TyKind::Dynamic(_, _) => todo!(),
361- rustc_middle::infer::canonical::ir::TyKind::Closure(_, _) => todo!(),
362- rustc_middle::infer::canonical::ir::TyKind::CoroutineClosure(_, _) => todo!(),
363- rustc_middle::infer::canonical::ir::TyKind::Coroutine(_, _) => todo!(),
364- rustc_middle::infer::canonical::ir::TyKind::CoroutineWitness(_, _) => todo!(),
365- rustc_middle::infer::canonical::ir::TyKind::Never => todo!(),
366- rustc_middle::infer::canonical::ir::TyKind::Tuple(_) => todo!(),
367- rustc_middle::infer::canonical::ir::TyKind::Alias(alias_ty_kind, alias_ty) => todo!(),
368- rustc_middle::infer::canonical::ir::TyKind::Param(_) => todo!(),
369- rustc_middle::infer::canonical::ir::TyKind::Bound(bound_var_index_kind, _) => todo!(),
370- rustc_middle::infer::canonical::ir::TyKind::Placeholder(_) => todo!(),
371- rustc_middle::infer::canonical::ir::TyKind::Infer(infer_ty) => todo!(),
372- rustc_middle::infer::canonical::ir::TyKind::Error(_) => todo!(),
373- */
374- _ => {
375- tcx
376- // TODO(Sa4dUs): Maybe `.as_query_input()`?
377- . layout_of ( PseudoCanonicalInput {
378- typing_env : TypingEnv :: fully_monomorphized ( ) ,
379- value : ty,
380- } )
381- . unwrap ( )
382- . size
383- . bytes ( )
384- }
385- }
386- }
387-
388337fn declare_offload_fn < ' ll > (
389338 cx : & ' ll SimpleCx < ' _ > ,
390339 name : & str ,
@@ -423,7 +372,7 @@ fn declare_offload_fn<'ll>(
423372pub ( crate ) fn gen_call_handling < ' ll > (
424373 cx : & SimpleCx < ' ll > ,
425374 bb : & BasicBlock ,
426- kernels : & [ & ' ll llvm:: Value ] ,
375+ kernel : & ' ll llvm:: Value ,
427376 memtransfer_types : & [ & ' ll llvm:: Value ] ,
428377 region_ids : & [ & ' ll llvm:: Value ] ,
429378 llfn : & ' ll Value ,
@@ -441,7 +390,7 @@ pub(crate) fn gen_call_handling<'ll>(
441390
442391 let mut builder = SBuilder :: build ( cx, bb) ;
443392
444- let types = cx. func_params_types ( cx. get_type_of_global ( kernels [ 0 ] ) ) ;
393+ let types = cx. func_params_types ( cx. get_type_of_global ( kernel ) ) ;
445394 let num_args = types. len ( ) as u64 ;
446395
447396 // Step 0)
0 commit comments