@@ -17,6 +17,7 @@ use rustc_target::callconv::{
17
17
} ;
18
18
use rustc_target:: spec:: SanitizerSet ;
19
19
use smallvec:: SmallVec ;
20
+ use tracing:: debug;
20
21
21
22
use crate :: attributes:: { self , llfn_attrs_from_instance} ;
22
23
use crate :: builder:: Builder ;
@@ -309,7 +310,7 @@ impl<'ll, 'tcx> ArgAbiBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
309
310
}
310
311
311
312
pub ( crate ) trait FnAbiLlvmExt < ' ll , ' tcx > {
312
- fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type ;
313
+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > , name : & str ) -> & ' ll Type ;
313
314
fn ptr_to_llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type ;
314
315
fn llvm_cconv ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> llvm:: CallConv ;
315
316
@@ -326,23 +327,21 @@ pub(crate) trait FnAbiLlvmExt<'ll, 'tcx> {
326
327
}
327
328
328
329
impl < ' ll , ' tcx > FnAbiLlvmExt < ' ll , ' tcx > for FnAbi < ' tcx , Ty < ' tcx > > {
329
- fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type {
330
+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > , name : & str ) -> & ' ll Type {
331
+ debug ! ( "Getting LLVM type for {}" , name) ;
330
332
// Ignore "extra" args from the call site for C variadic functions.
331
333
// Only the "fixed" args are part of the LLVM function signature.
332
334
let args =
333
335
if self . c_variadic { & self . args [ ..self . fixed_count as usize ] } else { & self . args } ;
334
336
335
337
let adjust_ty = |ty| {
336
- // todo: rectify this to be more selective (help wanted)
337
- let probably_unadjusted = self . conv == Conv :: C && !self . can_unwind && !self . c_variadic ;
338
- let probably_amx_intrinsic = probably_unadjusted && cx. tcx . sess . target . arch == "x86_64" ;
338
+ let amx_intrinsic = name. starts_with ( "llvm.x86." ) && name. ends_with ( ".internal" ) ;
339
339
// Change type to `x86amx` from `i32x256` for x86_64 AMX intrinsics
340
- if probably_amx_intrinsic
341
- && cx. type_kind ( ty) == TypeKind :: Vector
342
- && cx. vector_length ( ty) == 256
340
+ if amx_intrinsic && cx. type_kind ( ty) == TypeKind :: Vector && cx. vector_length ( ty) == 256
343
341
{
344
342
let element_ty = cx. element_type ( ty) ;
345
343
if cx. type_kind ( element_ty) == TypeKind :: Integer && cx. int_width ( element_ty) == 32 {
344
+ debug ! ( " Found an x86amx type!" ) ;
346
345
return cx. type_x86amx ( ) ;
347
346
}
348
347
}
0 commit comments