Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1070f08

Browse files
committed
Deduplicated macro code
1 parent baa801a commit 1070f08

File tree

1 file changed

+5
-27
lines changed

1 file changed

+5
-27
lines changed

src/librustc_target/asm/mod.rs

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,6 @@ macro_rules! def_reg_class {
5252

5353
#[macro_use]
5454
macro_rules! def_regs {
55-
($arch:ident $arch_reg:ident $arch_regclass:ident {}) => {
56-
#[allow(unreachable_code)]
57-
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, Eq, PartialEq, Hash, HashStable_Generic)]
58-
pub enum $arch_reg {}
59-
60-
impl $arch_reg {
61-
pub fn parse(
62-
_arch: super::InlineAsmArch,
63-
mut _has_feature: impl FnMut(&str) -> bool,
64-
_name: &str,
65-
) -> Result<Self, &'static str> {
66-
Err("unknown register")
67-
}
68-
}
69-
70-
pub(super) fn fill_reg_map(
71-
_arch: super::InlineAsmArch,
72-
mut _has_feature: impl FnMut(&str) -> bool,
73-
_map: &mut rustc_data_structures::fx::FxHashMap<
74-
super::InlineAsmRegClass,
75-
rustc_data_structures::fx::FxHashSet<super::InlineAsmReg>,
76-
>,
77-
) {}
78-
};
7955
($arch:ident $arch_reg:ident $arch_regclass:ident {
8056
$(
8157
$reg:ident: $class:ident $(, $extra_class:ident)* = [$reg_name:literal $(, $alias:literal)*] $(% $filter:ident)?,
@@ -84,6 +60,7 @@ macro_rules! def_regs {
8460
#error = [$($bad_reg:literal),+] => $error:literal,
8561
)*
8662
}) => {
63+
#[allow(unreachable_code)]
8764
#[derive(Copy, Clone, RustcEncodable, RustcDecodable, Debug, Eq, PartialEq, Hash, HashStable_Generic)]
8865
#[allow(non_camel_case_types)]
8966
pub enum $arch_reg {
@@ -126,19 +103,20 @@ macro_rules! def_regs {
126103
pub(super) fn fill_reg_map(
127104
_arch: super::InlineAsmArch,
128105
mut _has_feature: impl FnMut(&str) -> bool,
129-
map: &mut rustc_data_structures::fx::FxHashMap<
106+
_map: &mut rustc_data_structures::fx::FxHashMap<
130107
super::InlineAsmRegClass,
131108
rustc_data_structures::fx::FxHashSet<super::InlineAsmReg>,
132109
>,
133110
) {
111+
#[allow(unused_imports)]
134112
use super::{InlineAsmReg, InlineAsmRegClass};
135113
$(
136114
if $($filter(_arch, &mut _has_feature, true).is_ok() &&)? true {
137-
if let Some(set) = map.get_mut(&InlineAsmRegClass::$arch($arch_regclass::$class)) {
115+
if let Some(set) = _map.get_mut(&InlineAsmRegClass::$arch($arch_regclass::$class)) {
138116
set.insert(InlineAsmReg::$arch($arch_reg::$reg));
139117
}
140118
$(
141-
if let Some(set) = map.get_mut(&InlineAsmRegClass::$arch($arch_regclass::$extra_class)) {
119+
if let Some(set) = _map.get_mut(&InlineAsmRegClass::$arch($arch_regclass::$extra_class)) {
142120
set.insert(InlineAsmReg::$arch($arch_reg::$reg));
143121
}
144122
)*

0 commit comments

Comments
 (0)