This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Expand file tree Collapse file tree 1 file changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -506,10 +506,34 @@ impl<'tcx> InlineAssemblyGenerator<'_, 'tcx> {
506506 if self . options . contains ( InlineAsmOptions :: ATT_SYNTAX ) {
507507 generated_asm. push ( '%' ) ;
508508 }
509- self . registers [ * operand_idx]
510- . unwrap ( )
511- . emit ( & mut generated_asm, self . arch , * modifier)
512- . unwrap ( ) ;
509+
510+ let reg = self . registers [ * operand_idx] . unwrap ( ) ;
511+ match self . arch {
512+ InlineAsmArch :: X86_64 => match reg {
513+ InlineAsmReg :: X86 ( reg)
514+ if reg as u32 >= X86InlineAsmReg :: xmm0 as u32
515+ && reg as u32 <= X86InlineAsmReg :: xmm15 as u32 =>
516+ {
517+ // rustc emits x0 rather than xmm0
518+ let class = match * modifier {
519+ None | Some ( 'x' ) => "xmm" ,
520+ Some ( 'y' ) => "ymm" ,
521+ Some ( 'z' ) => "zmm" ,
522+ _ => unreachable ! ( ) ,
523+ } ;
524+ write ! (
525+ generated_asm,
526+ "{class}{}" ,
527+ reg as u32 - X86InlineAsmReg :: xmm0 as u32
528+ )
529+ . unwrap ( ) ;
530+ }
531+ _ => reg
532+ . emit ( & mut generated_asm, InlineAsmArch :: X86_64 , * modifier)
533+ . unwrap ( ) ,
534+ } ,
535+ _ => reg. emit ( & mut generated_asm, self . arch , * modifier) . unwrap ( ) ,
536+ }
513537 }
514538 CInlineAsmOperand :: Const { ref value } => {
515539 generated_asm. push_str ( value) ;
You can’t perform that action at this time.
0 commit comments