@@ -548,22 +548,21 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
548548 match self . arch {
549549 InlineAsmArch :: X86_64 => match reg {
550550 InlineAsmReg :: X86 ( reg)
551- if reg as u32 >= X86InlineAsmReg :: xmm0 as u32
552- && reg as u32 <= X86InlineAsmReg :: xmm15 as u32 =>
551+ if matches ! (
552+ reg. reg_class( ) ,
553+ X86InlineAsmRegClass :: xmm_reg
554+ | X86InlineAsmRegClass :: ymm_reg
555+ | X86InlineAsmRegClass :: zmm_reg
556+ ) =>
553557 {
554- // rustc emits x0 rather than xmm0
555- let class = match * modifier {
556- None | Some ( 'x' ) => "xmm" ,
557- Some ( 'y' ) => "ymm" ,
558- Some ( 'z' ) => "zmm" ,
559- _ => unreachable ! ( ) ,
560- } ;
561- write ! (
562- generated_asm,
563- "{class}{}" ,
564- reg as u32 - X86InlineAsmReg :: xmm0 as u32
565- )
566- . unwrap ( ) ;
558+ // rustc emits x0/y0/z0 rather than xmm0/ymm0/zmm0
559+ let name = reg. name ( ) ;
560+ if let Some ( prefix) = modifier {
561+ let index = & name[ 3 ..] ;
562+ write ! ( generated_asm, "{prefix}mm{index}" ) . unwrap ( ) ;
563+ } else {
564+ write ! ( generated_asm, "{name}" ) . unwrap ( ) ;
565+ }
567566 }
568567 _ => reg
569568 . emit ( & mut generated_asm, InlineAsmArch :: X86_64 , * modifier)
@@ -716,12 +715,17 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
716715 InlineAsmArch :: X86_64 => {
717716 match reg {
718717 InlineAsmReg :: X86 ( reg)
719- if reg as u32 >= X86InlineAsmReg :: xmm0 as u32
720- && reg as u32 <= X86InlineAsmReg :: xmm15 as u32 =>
718+ if matches ! (
719+ reg. reg_class( ) ,
720+ X86InlineAsmRegClass :: xmm_reg
721+ | X86InlineAsmRegClass :: ymm_reg
722+ | X86InlineAsmRegClass :: zmm_reg
723+ ) =>
721724 {
722- // rustc emits x0 rather than xmm0
723- write ! ( generated_asm, " movups [rbx+0x{:x}], " , offset. bytes( ) ) . unwrap ( ) ;
724- write ! ( generated_asm, "xmm{}" , reg as u32 - X86InlineAsmReg :: xmm0 as u32 )
725+ // rustc emits x0/y0/z0 rather than xmm0/ymm0/zmm0
726+ let name = reg. name ( ) ;
727+ let mov = if name. starts_with ( "xmm" ) { "movups" } else { "vmovups" } ;
728+ write ! ( generated_asm, " {mov} [rbx+0x{:x}], {name}" , offset. bytes( ) )
725729 . unwrap ( ) ;
726730 }
727731 _ => {
@@ -761,16 +765,17 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
761765 InlineAsmArch :: X86_64 => {
762766 match reg {
763767 InlineAsmReg :: X86 ( reg)
764- if reg as u32 >= X86InlineAsmReg :: xmm0 as u32
765- && reg as u32 <= X86InlineAsmReg :: xmm15 as u32 =>
768+ if matches ! (
769+ reg. reg_class( ) ,
770+ X86InlineAsmRegClass :: xmm_reg
771+ | X86InlineAsmRegClass :: ymm_reg
772+ | X86InlineAsmRegClass :: zmm_reg
773+ ) =>
766774 {
767- // rustc emits x0 rather than xmm0
768- write ! (
769- generated_asm,
770- " movups xmm{}" ,
771- reg as u32 - X86InlineAsmReg :: xmm0 as u32
772- )
773- . unwrap ( ) ;
775+ // rustc emits x0/y0/z0 rather than xmm0/ymm0/zmm0
776+ let name = reg. name ( ) ;
777+ let mov = if name. starts_with ( "xmm" ) { "movups" } else { "vmovups" } ;
778+ write ! ( generated_asm, " {mov} {name}" ) . unwrap ( ) ;
774779 }
775780 _ => {
776781 generated_asm. push_str ( " mov " ) ;
0 commit comments