11use super :: { InlineAsmArch , InlineAsmType } ;
22use crate :: spec:: Target ;
3+ use rustc_data_structures:: stable_set:: FxHashSet ;
34use rustc_macros:: HashStable_Generic ;
5+ use rustc_span:: { sym, Symbol } ;
46use std:: fmt;
57
68def_reg_class ! {
@@ -44,31 +46,31 @@ impl ArmInlineAsmRegClass {
4446 pub fn supported_types (
4547 self ,
4648 _arch : InlineAsmArch ,
47- ) -> & ' static [ ( InlineAsmType , Option < & ' static str > ) ] {
49+ ) -> & ' static [ ( InlineAsmType , Option < Symbol > ) ] {
4850 match self {
4951 Self :: reg => types ! { _: I8 , I16 , I32 , F32 ; } ,
50- Self :: sreg | Self :: sreg_low16 => types ! { " vfp2" : I32 , F32 ; } ,
52+ Self :: sreg | Self :: sreg_low16 => types ! { vfp2: I32 , F32 ; } ,
5153 Self :: dreg | Self :: dreg_low16 | Self :: dreg_low8 => types ! {
52- " vfp2" : I64 , F64 , VecI8 ( 8 ) , VecI16 ( 4 ) , VecI32 ( 2 ) , VecI64 ( 1 ) , VecF32 ( 2 ) ;
54+ vfp2: I64 , F64 , VecI8 ( 8 ) , VecI16 ( 4 ) , VecI32 ( 2 ) , VecI64 ( 1 ) , VecF32 ( 2 ) ;
5355 } ,
5456 Self :: qreg | Self :: qreg_low8 | Self :: qreg_low4 => types ! {
55- " neon" : VecI8 ( 16 ) , VecI16 ( 8 ) , VecI32 ( 4 ) , VecI64 ( 2 ) , VecF32 ( 4 ) ;
57+ neon: VecI8 ( 16 ) , VecI16 ( 8 ) , VecI32 ( 4 ) , VecI64 ( 2 ) , VecF32 ( 4 ) ;
5658 } ,
5759 }
5860 }
5961}
6062
6163// This uses the same logic as useR7AsFramePointer in LLVM
62- fn frame_pointer_is_r7 ( mut has_feature : impl FnMut ( & str ) -> bool , target : & Target ) -> bool {
63- target. is_like_osx || ( !target. is_like_windows && has_feature ( "thumb-mode" ) )
64+ fn frame_pointer_is_r7 ( target_features : & FxHashSet < Symbol > , target : & Target ) -> bool {
65+ target. is_like_osx || ( !target. is_like_windows && target_features . contains ( & sym :: thumb_mode ) )
6466}
6567
6668fn frame_pointer_r11 (
6769 _arch : InlineAsmArch ,
68- has_feature : impl FnMut ( & str ) -> bool ,
70+ target_features : & FxHashSet < Symbol > ,
6971 target : & Target ,
7072) -> Result < ( ) , & ' static str > {
71- if !frame_pointer_is_r7 ( has_feature , target) {
73+ if !frame_pointer_is_r7 ( target_features , target) {
7274 Err ( "the frame pointer (r11) cannot be used as an operand for inline asm" )
7375 } else {
7476 Ok ( ( ) )
@@ -77,10 +79,10 @@ fn frame_pointer_r11(
7779
7880fn frame_pointer_r7 (
7981 _arch : InlineAsmArch ,
80- has_feature : impl FnMut ( & str ) -> bool ,
82+ target_features : & FxHashSet < Symbol > ,
8183 target : & Target ,
8284) -> Result < ( ) , & ' static str > {
83- if frame_pointer_is_r7 ( has_feature , target) {
85+ if frame_pointer_is_r7 ( target_features , target) {
8486 Err ( "the frame pointer (r7) cannot be used as an operand for inline asm" )
8587 } else {
8688 Ok ( ( ) )
@@ -89,10 +91,10 @@ fn frame_pointer_r7(
8991
9092fn not_thumb1 (
9193 _arch : InlineAsmArch ,
92- mut has_feature : impl FnMut ( & str ) -> bool ,
94+ target_features : & FxHashSet < Symbol > ,
9395 _target : & Target ,
9496) -> Result < ( ) , & ' static str > {
95- if has_feature ( "thumb-mode" ) && !has_feature ( " thumb2" ) {
97+ if target_features . contains ( & sym :: thumb_mode ) && !target_features . contains ( & sym :: thumb2) {
9698 Err ( "high registers (r8+) cannot be used in Thumb-1 code" )
9799 } else {
98100 Ok ( ( ) )
@@ -101,14 +103,14 @@ fn not_thumb1(
101103
102104fn reserved_r9 (
103105 arch : InlineAsmArch ,
104- mut has_feature : impl FnMut ( & str ) -> bool ,
106+ target_features : & FxHashSet < Symbol > ,
105107 target : & Target ,
106108) -> Result < ( ) , & ' static str > {
107- not_thumb1 ( arch, & mut has_feature , target) ?;
109+ not_thumb1 ( arch, target_features , target) ?;
108110
109111 // We detect this using the reserved-r9 feature instead of using the target
110112 // because the relocation model can be changed with compiler options.
111- if has_feature ( "reserved-r9" ) {
113+ if target_features . contains ( & sym :: reserved_r9 ) {
112114 Err ( "the RWPI static base register (r9) cannot be used as an operand for inline asm" )
113115 } else {
114116 Ok ( ( ) )
0 commit comments