@@ -785,6 +785,7 @@ pub enum InlineAsmClobberAbi {
785
785
X86_64SysV ,
786
786
Arm ,
787
787
AArch64 ,
788
+ AArch64NoX18 ,
788
789
RiscV ,
789
790
}
790
791
@@ -793,6 +794,7 @@ impl InlineAsmClobberAbi {
793
794
/// clobber ABIs for the target.
794
795
pub fn parse (
795
796
arch : InlineAsmArch ,
797
+ has_feature : impl FnMut ( & str ) -> bool ,
796
798
target : & Target ,
797
799
name : Symbol ,
798
800
) -> Result < Self , & ' static [ & ' static str ] > {
@@ -816,7 +818,13 @@ impl InlineAsmClobberAbi {
816
818
_ => Err ( & [ "C" , "system" , "efiapi" , "aapcs" ] ) ,
817
819
} ,
818
820
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
+ }
820
828
_ => Err ( & [ "C" , "system" , "efiapi" ] ) ,
821
829
} ,
822
830
InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => match name {
@@ -891,8 +899,25 @@ impl InlineAsmClobberAbi {
891
899
AArch64 AArch64InlineAsmReg {
892
900
x0, x1, x2, x3, x4, x5, x6, x7,
893
901
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,
896
921
x16, x17, x30,
897
922
898
923
// Technically the low 64 bits of v8-v15 are preserved, but
@@ -910,7 +935,8 @@ impl InlineAsmClobberAbi {
910
935
} ,
911
936
InlineAsmClobberAbi :: Arm => clobbered_regs ! {
912
937
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.
914
940
r0, r1, r2, r3, r12, r14,
915
941
916
942
// The finest-grained register variant is used here so that
0 commit comments