@@ -83,12 +83,13 @@ macro_rules! def_regs {
8383 _arch: super :: InlineAsmArch ,
8484 _target_features: & rustc_data_structures:: fx:: FxHashSet <Symbol >,
8585 _target: & crate :: spec:: Target ,
86+ _is_clobber: bool ,
8687 name: & str ,
8788 ) -> Result <Self , & ' static str > {
8889 match name {
8990 $(
9091 $( $alias) |* | $reg_name => {
91- $( $filter( _arch, _target_features, _target) ?; ) ?
92+ $( $filter( _arch, _target_features, _target, _is_clobber ) ?; ) ?
9293 Ok ( Self :: $reg)
9394 }
9495 ) *
@@ -112,7 +113,7 @@ macro_rules! def_regs {
112113 #[ allow( unused_imports) ]
113114 use super :: { InlineAsmReg , InlineAsmRegClass } ;
114115 $(
115- if $( $filter( _arch, _target_features, _target) . is_ok( ) &&) ? true {
116+ if $( $filter( _arch, _target_features, _target, false ) . is_ok( ) &&) ? true {
116117 if let Some ( set) = _map. get_mut( & InlineAsmRegClass :: $arch( $arch_regclass:: $class) ) {
117118 set. insert( InlineAsmReg :: $arch( $arch_reg:: $reg) ) ;
118119 }
@@ -298,54 +299,87 @@ impl InlineAsmReg {
298299 arch : InlineAsmArch ,
299300 target_features : & FxHashSet < Symbol > ,
300301 target : & Target ,
302+ is_clobber : bool ,
301303 name : Symbol ,
302304 ) -> Result < Self , & ' static str > {
303305 // FIXME: use direct symbol comparison for register names
304306 // Use `Symbol::as_str` instead of `Symbol::with` here because `has_feature` may access `Symbol`.
305307 let name = name. as_str ( ) ;
306308 Ok ( match arch {
307309 InlineAsmArch :: X86 | InlineAsmArch :: X86_64 => {
308- Self :: X86 ( X86InlineAsmReg :: parse ( arch, target_features, target, name) ?)
310+ Self :: X86 ( X86InlineAsmReg :: parse ( arch, target_features, target, is_clobber , name) ?)
309311 }
310312 InlineAsmArch :: Arm => {
311- Self :: Arm ( ArmInlineAsmReg :: parse ( arch, target_features, target, name) ?)
312- }
313- InlineAsmArch :: AArch64 => {
314- Self :: AArch64 ( AArch64InlineAsmReg :: parse ( arch, target_features, target, name) ?)
315- }
316- InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => {
317- Self :: RiscV ( RiscVInlineAsmReg :: parse ( arch, target_features, target, name) ?)
318- }
319- InlineAsmArch :: Nvptx64 => {
320- Self :: Nvptx ( NvptxInlineAsmReg :: parse ( arch, target_features, target, name) ?)
321- }
322- InlineAsmArch :: PowerPC | InlineAsmArch :: PowerPC64 => {
323- Self :: PowerPC ( PowerPCInlineAsmReg :: parse ( arch, target_features, target, name) ?)
324- }
325- InlineAsmArch :: Hexagon => {
326- Self :: Hexagon ( HexagonInlineAsmReg :: parse ( arch, target_features, target, name) ?)
327- }
328- InlineAsmArch :: Mips | InlineAsmArch :: Mips64 => {
329- Self :: Mips ( MipsInlineAsmReg :: parse ( arch, target_features, target, name) ?)
330- }
331- InlineAsmArch :: S390x => {
332- Self :: S390x ( S390xInlineAsmReg :: parse ( arch, target_features, target, name) ?)
333- }
334- InlineAsmArch :: SpirV => {
335- Self :: SpirV ( SpirVInlineAsmReg :: parse ( arch, target_features, target, name) ?)
336- }
337- InlineAsmArch :: Wasm32 | InlineAsmArch :: Wasm64 => {
338- Self :: Wasm ( WasmInlineAsmReg :: parse ( arch, target_features, target, name) ?)
313+ Self :: Arm ( ArmInlineAsmReg :: parse ( arch, target_features, target, is_clobber, name) ?)
339314 }
315+ InlineAsmArch :: AArch64 => Self :: AArch64 ( AArch64InlineAsmReg :: parse (
316+ arch,
317+ target_features,
318+ target,
319+ is_clobber,
320+ name,
321+ ) ?) ,
322+ InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => Self :: RiscV (
323+ RiscVInlineAsmReg :: parse ( arch, target_features, target, is_clobber, name) ?,
324+ ) ,
325+ InlineAsmArch :: Nvptx64 => Self :: Nvptx ( NvptxInlineAsmReg :: parse (
326+ arch,
327+ target_features,
328+ target,
329+ is_clobber,
330+ name,
331+ ) ?) ,
332+ InlineAsmArch :: PowerPC | InlineAsmArch :: PowerPC64 => Self :: PowerPC (
333+ PowerPCInlineAsmReg :: parse ( arch, target_features, target, is_clobber, name) ?,
334+ ) ,
335+ InlineAsmArch :: Hexagon => Self :: Hexagon ( HexagonInlineAsmReg :: parse (
336+ arch,
337+ target_features,
338+ target,
339+ is_clobber,
340+ name,
341+ ) ?) ,
342+ InlineAsmArch :: Mips | InlineAsmArch :: Mips64 => Self :: Mips ( MipsInlineAsmReg :: parse (
343+ arch,
344+ target_features,
345+ target,
346+ is_clobber,
347+ name,
348+ ) ?) ,
349+ InlineAsmArch :: S390x => Self :: S390x ( S390xInlineAsmReg :: parse (
350+ arch,
351+ target_features,
352+ target,
353+ is_clobber,
354+ name,
355+ ) ?) ,
356+ InlineAsmArch :: SpirV => Self :: SpirV ( SpirVInlineAsmReg :: parse (
357+ arch,
358+ target_features,
359+ target,
360+ is_clobber,
361+ name,
362+ ) ?) ,
363+ InlineAsmArch :: Wasm32 | InlineAsmArch :: Wasm64 => Self :: Wasm ( WasmInlineAsmReg :: parse (
364+ arch,
365+ target_features,
366+ target,
367+ is_clobber,
368+ name,
369+ ) ?) ,
340370 InlineAsmArch :: Bpf => {
341- Self :: Bpf ( BpfInlineAsmReg :: parse ( arch, target_features, target, name) ?)
371+ Self :: Bpf ( BpfInlineAsmReg :: parse ( arch, target_features, target, is_clobber , name) ?)
342372 }
343373 InlineAsmArch :: Avr => {
344- Self :: Avr ( AvrInlineAsmReg :: parse ( arch, target_features, target, name) ?)
345- }
346- InlineAsmArch :: Msp430 => {
347- Self :: Msp430 ( Msp430InlineAsmReg :: parse ( arch, target_features, target, name) ?)
374+ Self :: Avr ( AvrInlineAsmReg :: parse ( arch, target_features, target, is_clobber, name) ?)
348375 }
376+ InlineAsmArch :: Msp430 => Self :: Msp430 ( Msp430InlineAsmReg :: parse (
377+ arch,
378+ target_features,
379+ target,
380+ is_clobber,
381+ name,
382+ ) ?) ,
349383 } )
350384 }
351385
@@ -844,7 +878,7 @@ impl InlineAsmClobberAbi {
844878 } ,
845879 InlineAsmArch :: AArch64 => match name {
846880 "C" | "system" | "efiapi" => {
847- Ok ( if aarch64:: reserved_x18 ( arch, target_features, target) . is_err ( ) {
881+ Ok ( if aarch64:: reserved_x18 ( arch, target_features, target, true ) . is_err ( ) {
848882 InlineAsmClobberAbi :: AArch64NoX18
849883 } else {
850884 InlineAsmClobberAbi :: AArch64
0 commit comments