@@ -20,16 +20,16 @@ macro_rules! def_reg_class {
20
20
}
21
21
22
22
impl $arch_regclass {
23
- pub fn name( self ) -> & ' static str {
23
+ pub fn name( self ) -> rustc_span :: Symbol {
24
24
match self {
25
- $( Self :: $class => stringify! ( $class) , ) *
25
+ $( Self :: $class => rustc_span :: symbol :: sym :: $class, ) *
26
26
}
27
27
}
28
28
29
- pub fn parse( _arch: super :: InlineAsmArch , name: & str ) -> Result <Self , & ' static str > {
29
+ pub fn parse( _arch: super :: InlineAsmArch , name: rustc_span :: Symbol ) -> Result <Self , & ' static str > {
30
30
match name {
31
31
$(
32
- stringify! ( $class) => Ok ( Self :: $class) ,
32
+ rustc_span :: sym :: $class => Ok ( Self :: $class) ,
33
33
) *
34
34
_ => Err ( "unknown register class" ) ,
35
35
}
@@ -327,7 +327,7 @@ pub enum InlineAsmRegClass {
327
327
}
328
328
329
329
impl InlineAsmRegClass {
330
- pub fn name ( self ) -> & ' static str {
330
+ pub fn name ( self ) -> Symbol {
331
331
match self {
332
332
Self :: X86 ( r) => r. name ( ) ,
333
333
Self :: Arm ( r) => r. name ( ) ,
@@ -422,29 +422,22 @@ impl InlineAsmRegClass {
422
422
}
423
423
424
424
pub fn parse ( arch : InlineAsmArch , name : Symbol ) -> Result < Self , & ' static str > {
425
- // FIXME: use direct symbol comparison for register class names
426
- name. with ( |name| {
427
- Ok ( match arch {
428
- InlineAsmArch :: X86 | InlineAsmArch :: X86_64 => {
429
- Self :: X86 ( X86InlineAsmRegClass :: parse ( arch, name) ?)
430
- }
431
- InlineAsmArch :: Arm => Self :: Arm ( ArmInlineAsmRegClass :: parse ( arch, name) ?) ,
432
- InlineAsmArch :: AArch64 => {
433
- Self :: AArch64 ( AArch64InlineAsmRegClass :: parse ( arch, name) ?)
434
- }
435
- InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => {
436
- Self :: RiscV ( RiscVInlineAsmRegClass :: parse ( arch, name) ?)
437
- }
438
- InlineAsmArch :: Nvptx64 => Self :: Nvptx ( NvptxInlineAsmRegClass :: parse ( arch, name) ?) ,
439
- InlineAsmArch :: Hexagon => {
440
- Self :: Hexagon ( HexagonInlineAsmRegClass :: parse ( arch, name) ?)
441
- }
442
- InlineAsmArch :: Mips | InlineAsmArch :: Mips64 => {
443
- Self :: Mips ( MipsInlineAsmRegClass :: parse ( arch, name) ?)
444
- }
445
- InlineAsmArch :: SpirV => Self :: SpirV ( SpirVInlineAsmRegClass :: parse ( arch, name) ?) ,
446
- InlineAsmArch :: Wasm32 => Self :: Wasm ( WasmInlineAsmRegClass :: parse ( arch, name) ?) ,
447
- } )
425
+ Ok ( match arch {
426
+ InlineAsmArch :: X86 | InlineAsmArch :: X86_64 => {
427
+ Self :: X86 ( X86InlineAsmRegClass :: parse ( arch, name) ?)
428
+ }
429
+ InlineAsmArch :: Arm => Self :: Arm ( ArmInlineAsmRegClass :: parse ( arch, name) ?) ,
430
+ InlineAsmArch :: AArch64 => Self :: AArch64 ( AArch64InlineAsmRegClass :: parse ( arch, name) ?) ,
431
+ InlineAsmArch :: RiscV32 | InlineAsmArch :: RiscV64 => {
432
+ Self :: RiscV ( RiscVInlineAsmRegClass :: parse ( arch, name) ?)
433
+ }
434
+ InlineAsmArch :: Nvptx64 => Self :: Nvptx ( NvptxInlineAsmRegClass :: parse ( arch, name) ?) ,
435
+ InlineAsmArch :: Hexagon => Self :: Hexagon ( HexagonInlineAsmRegClass :: parse ( arch, name) ?) ,
436
+ InlineAsmArch :: Mips | InlineAsmArch :: Mips64 => {
437
+ Self :: Mips ( MipsInlineAsmRegClass :: parse ( arch, name) ?)
438
+ }
439
+ InlineAsmArch :: SpirV => Self :: SpirV ( SpirVInlineAsmRegClass :: parse ( arch, name) ?) ,
440
+ InlineAsmArch :: Wasm32 => Self :: Wasm ( WasmInlineAsmRegClass :: parse ( arch, name) ?) ,
448
441
} )
449
442
}
450
443
@@ -484,7 +477,7 @@ impl fmt::Display for InlineAsmRegOrRegClass {
484
477
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
485
478
match self {
486
479
Self :: Reg ( r) => write ! ( f, "\" {}\" " , r. name( ) ) ,
487
- Self :: RegClass ( r) => f . write_str ( r. name ( ) ) ,
480
+ Self :: RegClass ( r) => write ! ( f , "{}" , r. name( ) ) ,
488
481
}
489
482
}
490
483
}
0 commit comments