11use crate :: abi:: Size ;
2+ use crate :: spec:: Target ;
23use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
34use rustc_macros:: HashStable_Generic ;
45use rustc_span:: Symbol ;
@@ -83,12 +84,13 @@ macro_rules! def_regs {
8384 pub fn parse(
8485 _arch: super :: InlineAsmArch ,
8586 mut _has_feature: impl FnMut ( & str ) -> bool ,
87+ _target: & crate :: spec:: Target ,
8688 name: & str ,
8789 ) -> Result <Self , & ' static str > {
8890 match name {
8991 $(
9092 $( $alias) |* | $reg_name => {
91- $( $filter( _arch, & mut _has_feature, false ) ?; ) ?
93+ $( $filter( _arch, & mut _has_feature, _target , false ) ?; ) ?
9294 Ok ( Self :: $reg)
9395 }
9496 ) *
@@ -103,6 +105,7 @@ macro_rules! def_regs {
103105 pub ( super ) fn fill_reg_map(
104106 _arch: super :: InlineAsmArch ,
105107 mut _has_feature: impl FnMut ( & str ) -> bool ,
108+ _target: & crate :: spec:: Target ,
106109 _map: & mut rustc_data_structures:: fx:: FxHashMap <
107110 super :: InlineAsmRegClass ,
108111 rustc_data_structures:: fx:: FxHashSet <super :: InlineAsmReg >,
@@ -111,7 +114,7 @@ macro_rules! def_regs {
111114 #[ allow( unused_imports) ]
112115 use super :: { InlineAsmReg , InlineAsmRegClass } ;
113116 $(
114- if $( $filter( _arch, & mut _has_feature, true ) . is_ok( ) &&) ? true {
117+ if $( $filter( _arch, & mut _has_feature, _target , true ) . is_ok( ) &&) ? true {
115118 if let Some ( set) = _map. get_mut( & InlineAsmRegClass :: $arch( $arch_regclass:: $class) ) {
116119 set. insert( InlineAsmReg :: $arch( $arch_reg:: $reg) ) ;
117120 }
@@ -234,27 +237,30 @@ impl InlineAsmReg {
234237 pub fn parse (
235238 arch : InlineAsmArch ,
236239 has_feature : impl FnMut ( & str ) -> bool ,
240+ target : & Target ,
237241 name : Symbol ,
238242 ) -> Result < Self , & ' static str > {
239243 // FIXME: use direct symbol comparison for register names
240244 // Use `Symbol::as_str` instead of `Symbol::with` here because `has_feature` may access `Symbol`.
241245 let name = name. as_str ( ) ;
242246 Ok ( match arch {
243247 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) ?)
245252 }
246- InlineAsmArch :: Arm => Self :: Arm ( ArmInlineAsmReg :: parse ( arch, has_feature, & name) ?) ,
247253 InlineAsmArch :: AArch64 => {
248- Self :: AArch64 ( AArch64InlineAsmReg :: parse ( arch, has_feature, & name) ?)
254+ Self :: AArch64 ( AArch64InlineAsmReg :: parse ( arch, has_feature, target , & name) ?)
249255 }
250256 InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => {
251- Self :: RiscV ( RiscVInlineAsmReg :: parse ( arch, has_feature, & name) ?)
257+ Self :: RiscV ( RiscVInlineAsmReg :: parse ( arch, has_feature, target , & name) ?)
252258 }
253259 InlineAsmArch :: Nvptx64 => {
254- Self :: Nvptx ( NvptxInlineAsmReg :: parse ( arch, has_feature, & name) ?)
260+ Self :: Nvptx ( NvptxInlineAsmReg :: parse ( arch, has_feature, target , & name) ?)
255261 }
256262 InlineAsmArch :: Hexagon => {
257- Self :: Hexagon ( HexagonInlineAsmReg :: parse ( arch, has_feature, & name) ?)
263+ Self :: Hexagon ( HexagonInlineAsmReg :: parse ( arch, has_feature, target , & name) ?)
258264 }
259265 } )
260266 }
@@ -536,36 +542,37 @@ impl fmt::Display for InlineAsmType {
536542pub fn allocatable_registers (
537543 arch : InlineAsmArch ,
538544 has_feature : impl FnMut ( & str ) -> bool ,
545+ target : & crate :: spec:: Target ,
539546) -> FxHashMap < InlineAsmRegClass , FxHashSet < InlineAsmReg > > {
540547 match arch {
541548 InlineAsmArch :: X86 | InlineAsmArch :: X86_64 => {
542549 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) ;
544551 map
545552 }
546553 InlineAsmArch :: Arm => {
547554 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) ;
549556 map
550557 }
551558 InlineAsmArch :: AArch64 => {
552559 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) ;
554561 map
555562 }
556563 InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => {
557564 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) ;
559566 map
560567 }
561568 InlineAsmArch :: Nvptx64 => {
562569 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) ;
564571 map
565572 }
566573 InlineAsmArch :: Hexagon => {
567574 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) ;
569576 map
570577 }
571578 }
0 commit comments