@@ -785,6 +785,7 @@ pub enum InlineAsmClobberAbi {
785785 X86_64SysV ,
786786 Arm ,
787787 AArch64 ,
788+ AArch64NoX18 ,
788789 RiscV ,
789790}
790791
@@ -793,6 +794,7 @@ impl InlineAsmClobberAbi {
793794 /// clobber ABIs for the target.
794795 pub fn parse (
795796 arch : InlineAsmArch ,
797+ has_feature : impl FnMut ( & str ) -> bool ,
796798 target : & Target ,
797799 name : Symbol ,
798800 ) -> Result < Self , & ' static [ & ' static str ] > {
@@ -816,7 +818,13 @@ impl InlineAsmClobberAbi {
816818 _ => Err ( & [ "C" , "system" , "efiapi" , "aapcs" ] ) ,
817819 } ,
818820 InlineAsmArch :: AArch64 => match name {
819- "C" | "system" | "efiapi" => Ok ( InlineAsmClobberAbi :: AArch64 ) ,
821+ "C" | "system" | "efiapi" => {
822+ Ok ( if aarch64:: reserved_x18 ( arch, has_feature, target) . is_err ( ) {
823+ InlineAsmClobberAbi :: AArch64NoX18
824+ } else {
825+ InlineAsmClobberAbi :: AArch64
826+ } )
827+ }
820828 _ => Err ( & [ "C" , "system" , "efiapi" ] ) ,
821829 } ,
822830 InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => match name {
@@ -891,8 +899,25 @@ impl InlineAsmClobberAbi {
891899 AArch64 AArch64InlineAsmReg {
892900 x0, x1, x2, x3, x4, x5, x6, x7,
893901 x8, x9, x10, x11, x12, x13, x14, x15,
894- // x18 is platform-reserved or temporary, but we exclude it
895- // here since it is a reserved register.
902+ x16, x17, x18, x30,
903+
904+ // Technically the low 64 bits of v8-v15 are preserved, but
905+ // we have no way of expressing this using clobbers.
906+ v0, v1, v2, v3, v4, v5, v6, v7,
907+ v8, v9, v10, v11, v12, v13, v14, v15,
908+ v16, v17, v18, v19, v20, v21, v22, v23,
909+ v24, v25, v26, v27, v28, v29, v30, v31,
910+
911+ p0, p1, p2, p3, p4, p5, p6, p7,
912+ p8, p9, p10, p11, p12, p13, p14, p15,
913+ ffr,
914+
915+ }
916+ } ,
917+ InlineAsmClobberAbi :: AArch64NoX18 => clobbered_regs ! {
918+ AArch64 AArch64InlineAsmReg {
919+ x0, x1, x2, x3, x4, x5, x6, x7,
920+ x8, x9, x10, x11, x12, x13, x14, x15,
896921 x16, x17, x30,
897922
898923 // Technically the low 64 bits of v8-v15 are preserved, but
@@ -910,7 +935,8 @@ impl InlineAsmClobberAbi {
910935 } ,
911936 InlineAsmClobberAbi :: Arm => clobbered_regs ! {
912937 Arm ArmInlineAsmReg {
913- // r9 is platform-reserved and is treated as callee-saved.
938+ // r9 is either platform-reserved or callee-saved. Either
939+ // way we don't need to clobber it.
914940 r0, r1, r2, r3, r12, r14,
915941
916942 // The finest-grained register variant is used here so that
0 commit comments