@@ -83,12 +83,13 @@ macro_rules! def_regs {
83
83
_arch: super :: InlineAsmArch ,
84
84
_target_features: & rustc_data_structures:: fx:: FxHashSet <Symbol >,
85
85
_target: & crate :: spec:: Target ,
86
+ _is_clobber: bool ,
86
87
name: & str ,
87
88
) -> Result <Self , & ' static str > {
88
89
match name {
89
90
$(
90
91
$( $alias) |* | $reg_name => {
91
- $( $filter( _arch, _target_features, _target) ?; ) ?
92
+ $( $filter( _arch, _target_features, _target, _is_clobber ) ?; ) ?
92
93
Ok ( Self :: $reg)
93
94
}
94
95
) *
@@ -112,7 +113,7 @@ macro_rules! def_regs {
112
113
#[ allow( unused_imports) ]
113
114
use super :: { InlineAsmReg , InlineAsmRegClass } ;
114
115
$(
115
- if $( $filter( _arch, _target_features, _target) . is_ok( ) &&) ? true {
116
+ if $( $filter( _arch, _target_features, _target, false ) . is_ok( ) &&) ? true {
116
117
if let Some ( set) = _map. get_mut( & InlineAsmRegClass :: $arch( $arch_regclass:: $class) ) {
117
118
set. insert( InlineAsmReg :: $arch( $arch_reg:: $reg) ) ;
118
119
}
@@ -298,54 +299,87 @@ impl InlineAsmReg {
298
299
arch : InlineAsmArch ,
299
300
target_features : & FxHashSet < Symbol > ,
300
301
target : & Target ,
302
+ is_clobber : bool ,
301
303
name : Symbol ,
302
304
) -> Result < Self , & ' static str > {
303
305
// FIXME: use direct symbol comparison for register names
304
306
// Use `Symbol::as_str` instead of `Symbol::with` here because `has_feature` may access `Symbol`.
305
307
let name = name. as_str ( ) ;
306
308
Ok ( match arch {
307
309
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) ?)
309
311
}
310
312
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) ?)
339
314
}
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
+ ) ?) ,
340
370
InlineAsmArch :: Bpf => {
341
- Self :: Bpf ( BpfInlineAsmReg :: parse ( arch, target_features, target, name) ?)
371
+ Self :: Bpf ( BpfInlineAsmReg :: parse ( arch, target_features, target, is_clobber , name) ?)
342
372
}
343
373
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) ?)
348
375
}
376
+ InlineAsmArch :: Msp430 => Self :: Msp430 ( Msp430InlineAsmReg :: parse (
377
+ arch,
378
+ target_features,
379
+ target,
380
+ is_clobber,
381
+ name,
382
+ ) ?) ,
349
383
} )
350
384
}
351
385
@@ -844,7 +878,7 @@ impl InlineAsmClobberAbi {
844
878
} ,
845
879
InlineAsmArch :: AArch64 => match name {
846
880
"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 ( ) {
848
882
InlineAsmClobberAbi :: AArch64NoX18
849
883
} else {
850
884
InlineAsmClobberAbi :: AArch64
0 commit comments