1
1
use super :: { InlineAsmArch , InlineAsmType } ;
2
2
use crate :: spec:: Target ;
3
+ use rustc_data_structures:: stable_set:: FxHashSet ;
3
4
use rustc_macros:: HashStable_Generic ;
5
+ use rustc_span:: { sym, Symbol } ;
4
6
use std:: fmt;
5
7
6
8
def_reg_class ! {
@@ -44,31 +46,31 @@ impl ArmInlineAsmRegClass {
44
46
pub fn supported_types (
45
47
self ,
46
48
_arch : InlineAsmArch ,
47
- ) -> & ' static [ ( InlineAsmType , Option < & ' static str > ) ] {
49
+ ) -> & ' static [ ( InlineAsmType , Option < Symbol > ) ] {
48
50
match self {
49
51
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 ; } ,
51
53
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 ) ;
53
55
} ,
54
56
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 ) ;
56
58
} ,
57
59
}
58
60
}
59
61
}
60
62
61
63
// 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 ) )
64
66
}
65
67
66
68
fn frame_pointer_r11 (
67
69
_arch : InlineAsmArch ,
68
- has_feature : impl FnMut ( & str ) -> bool ,
70
+ target_features : & FxHashSet < Symbol > ,
69
71
target : & Target ,
70
72
) -> Result < ( ) , & ' static str > {
71
- if !frame_pointer_is_r7 ( has_feature , target) {
73
+ if !frame_pointer_is_r7 ( target_features , target) {
72
74
Err ( "the frame pointer (r11) cannot be used as an operand for inline asm" )
73
75
} else {
74
76
Ok ( ( ) )
@@ -77,10 +79,10 @@ fn frame_pointer_r11(
77
79
78
80
fn frame_pointer_r7 (
79
81
_arch : InlineAsmArch ,
80
- has_feature : impl FnMut ( & str ) -> bool ,
82
+ target_features : & FxHashSet < Symbol > ,
81
83
target : & Target ,
82
84
) -> Result < ( ) , & ' static str > {
83
- if frame_pointer_is_r7 ( has_feature , target) {
85
+ if frame_pointer_is_r7 ( target_features , target) {
84
86
Err ( "the frame pointer (r7) cannot be used as an operand for inline asm" )
85
87
} else {
86
88
Ok ( ( ) )
@@ -89,10 +91,10 @@ fn frame_pointer_r7(
89
91
90
92
fn not_thumb1 (
91
93
_arch : InlineAsmArch ,
92
- mut has_feature : impl FnMut ( & str ) -> bool ,
94
+ target_features : & FxHashSet < Symbol > ,
93
95
_target : & Target ,
94
96
) -> 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) {
96
98
Err ( "high registers (r8+) cannot be used in Thumb-1 code" )
97
99
} else {
98
100
Ok ( ( ) )
@@ -101,14 +103,14 @@ fn not_thumb1(
101
103
102
104
fn reserved_r9 (
103
105
arch : InlineAsmArch ,
104
- mut has_feature : impl FnMut ( & str ) -> bool ,
106
+ target_features : & FxHashSet < Symbol > ,
105
107
target : & Target ,
106
108
) -> Result < ( ) , & ' static str > {
107
- not_thumb1 ( arch, & mut has_feature , target) ?;
109
+ not_thumb1 ( arch, target_features , target) ?;
108
110
109
111
// We detect this using the reserved-r9 feature instead of using the target
110
112
// because the relocation model can be changed with compiler options.
111
- if has_feature ( "reserved-r9" ) {
113
+ if target_features . contains ( & sym :: reserved_r9 ) {
112
114
Err ( "the RWPI static base register (r9) cannot be used as an operand for inline asm" )
113
115
} else {
114
116
Ok ( ( ) )
0 commit comments