1
1
use crate :: abi:: Size ;
2
+ use crate :: spec:: Target ;
2
3
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
3
4
use rustc_macros:: HashStable_Generic ;
4
5
use rustc_span:: Symbol ;
@@ -83,12 +84,13 @@ macro_rules! def_regs {
83
84
pub fn parse(
84
85
_arch: super :: InlineAsmArch ,
85
86
mut _has_feature: impl FnMut ( & str ) -> bool ,
87
+ _target: & crate :: spec:: Target ,
86
88
name: & str ,
87
89
) -> Result <Self , & ' static str > {
88
90
match name {
89
91
$(
90
92
$( $alias) |* | $reg_name => {
91
- $( $filter( _arch, & mut _has_feature, false ) ?; ) ?
93
+ $( $filter( _arch, & mut _has_feature, _target , false ) ?; ) ?
92
94
Ok ( Self :: $reg)
93
95
}
94
96
) *
@@ -103,6 +105,7 @@ macro_rules! def_regs {
103
105
pub ( super ) fn fill_reg_map(
104
106
_arch: super :: InlineAsmArch ,
105
107
mut _has_feature: impl FnMut ( & str ) -> bool ,
108
+ _target: & crate :: spec:: Target ,
106
109
_map: & mut rustc_data_structures:: fx:: FxHashMap <
107
110
super :: InlineAsmRegClass ,
108
111
rustc_data_structures:: fx:: FxHashSet <super :: InlineAsmReg >,
@@ -111,7 +114,7 @@ macro_rules! def_regs {
111
114
#[ allow( unused_imports) ]
112
115
use super :: { InlineAsmReg , InlineAsmRegClass } ;
113
116
$(
114
- if $( $filter( _arch, & mut _has_feature, true ) . is_ok( ) &&) ? true {
117
+ if $( $filter( _arch, & mut _has_feature, _target , true ) . is_ok( ) &&) ? true {
115
118
if let Some ( set) = _map. get_mut( & InlineAsmRegClass :: $arch( $arch_regclass:: $class) ) {
116
119
set. insert( InlineAsmReg :: $arch( $arch_reg:: $reg) ) ;
117
120
}
@@ -234,27 +237,30 @@ impl InlineAsmReg {
234
237
pub fn parse (
235
238
arch : InlineAsmArch ,
236
239
has_feature : impl FnMut ( & str ) -> bool ,
240
+ target : & Target ,
237
241
name : Symbol ,
238
242
) -> Result < Self , & ' static str > {
239
243
// FIXME: use direct symbol comparison for register names
240
244
// Use `Symbol::as_str` instead of `Symbol::with` here because `has_feature` may access `Symbol`.
241
245
let name = name. as_str ( ) ;
242
246
Ok ( match arch {
243
247
InlineAsmArch :: X86 | InlineAsmArch :: X86_64 => {
244
- Self :: X86 ( X86InlineAsmReg :: parse ( arch, has_feature, & name) ?)
248
+ Self :: X86 ( X86InlineAsmReg :: parse ( arch, has_feature, target, & name) ?)
249
+ }
250
+ InlineAsmArch :: Arm => {
251
+ Self :: Arm ( ArmInlineAsmReg :: parse ( arch, has_feature, target, & name) ?)
245
252
}
246
- InlineAsmArch :: Arm => Self :: Arm ( ArmInlineAsmReg :: parse ( arch, has_feature, & name) ?) ,
247
253
InlineAsmArch :: AArch64 => {
248
- Self :: AArch64 ( AArch64InlineAsmReg :: parse ( arch, has_feature, & name) ?)
254
+ Self :: AArch64 ( AArch64InlineAsmReg :: parse ( arch, has_feature, target , & name) ?)
249
255
}
250
256
InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => {
251
- Self :: RiscV ( RiscVInlineAsmReg :: parse ( arch, has_feature, & name) ?)
257
+ Self :: RiscV ( RiscVInlineAsmReg :: parse ( arch, has_feature, target , & name) ?)
252
258
}
253
259
InlineAsmArch :: Nvptx64 => {
254
- Self :: Nvptx ( NvptxInlineAsmReg :: parse ( arch, has_feature, & name) ?)
260
+ Self :: Nvptx ( NvptxInlineAsmReg :: parse ( arch, has_feature, target , & name) ?)
255
261
}
256
262
InlineAsmArch :: Hexagon => {
257
- Self :: Hexagon ( HexagonInlineAsmReg :: parse ( arch, has_feature, & name) ?)
263
+ Self :: Hexagon ( HexagonInlineAsmReg :: parse ( arch, has_feature, target , & name) ?)
258
264
}
259
265
} )
260
266
}
@@ -536,36 +542,37 @@ impl fmt::Display for InlineAsmType {
536
542
pub fn allocatable_registers (
537
543
arch : InlineAsmArch ,
538
544
has_feature : impl FnMut ( & str ) -> bool ,
545
+ target : & crate :: spec:: Target ,
539
546
) -> FxHashMap < InlineAsmRegClass , FxHashSet < InlineAsmReg > > {
540
547
match arch {
541
548
InlineAsmArch :: X86 | InlineAsmArch :: X86_64 => {
542
549
let mut map = x86:: regclass_map ( ) ;
543
- x86:: fill_reg_map ( arch, has_feature, & mut map) ;
550
+ x86:: fill_reg_map ( arch, has_feature, target , & mut map) ;
544
551
map
545
552
}
546
553
InlineAsmArch :: Arm => {
547
554
let mut map = arm:: regclass_map ( ) ;
548
- arm:: fill_reg_map ( arch, has_feature, & mut map) ;
555
+ arm:: fill_reg_map ( arch, has_feature, target , & mut map) ;
549
556
map
550
557
}
551
558
InlineAsmArch :: AArch64 => {
552
559
let mut map = aarch64:: regclass_map ( ) ;
553
- aarch64:: fill_reg_map ( arch, has_feature, & mut map) ;
560
+ aarch64:: fill_reg_map ( arch, has_feature, target , & mut map) ;
554
561
map
555
562
}
556
563
InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => {
557
564
let mut map = riscv:: regclass_map ( ) ;
558
- riscv:: fill_reg_map ( arch, has_feature, & mut map) ;
565
+ riscv:: fill_reg_map ( arch, has_feature, target , & mut map) ;
559
566
map
560
567
}
561
568
InlineAsmArch :: Nvptx64 => {
562
569
let mut map = nvptx:: regclass_map ( ) ;
563
- nvptx:: fill_reg_map ( arch, has_feature, & mut map) ;
570
+ nvptx:: fill_reg_map ( arch, has_feature, target , & mut map) ;
564
571
map
565
572
}
566
573
InlineAsmArch :: Hexagon => {
567
574
let mut map = hexagon:: regclass_map ( ) ;
568
- hexagon:: fill_reg_map ( arch, has_feature, & mut map) ;
575
+ hexagon:: fill_reg_map ( arch, has_feature, target , & mut map) ;
569
576
map
570
577
}
571
578
}
0 commit comments