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

Commit 19a0d14

Browse files
committed
Add notes about functions that are not currently used
1 parent 7dfa486 commit 19a0d14

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/librustc_target/asm/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ macro_rules! def_regs {
8787
match name {
8888
$(
8989
$($alias)|* | $reg_name => {
90-
$($filter(_arch, &mut _has_feature)?;)?
90+
$($filter(_arch, &mut _has_feature, false)?;)?
9191
Ok(Self::$reg)
9292
}
9393
)*
@@ -109,7 +109,7 @@ macro_rules! def_regs {
109109
) {
110110
use super::{InlineAsmReg, InlineAsmRegClass};
111111
$(
112-
if $($filter(_arch, &mut _has_feature).is_ok() &&)? true {
112+
if $($filter(_arch, &mut _has_feature, true).is_ok() &&)? true {
113113
if let Some(set) = map.get_mut(&InlineAsmRegClass::$arch($arch_regclass::$class)) {
114114
set.insert(InlineAsmReg::$arch($arch_reg::$reg));
115115
}
@@ -239,6 +239,8 @@ impl InlineAsmReg {
239239
})
240240
}
241241

242+
// NOTE: This function isn't used at the moment, but is needed to support
243+
// falling back to an external assembler.
242244
pub fn emit(
243245
self,
244246
out: &mut dyn fmt::Write,
@@ -542,6 +544,8 @@ impl fmt::Display for InlineAsmType {
542544
/// registers in each register class. A particular register may be allocatable
543545
/// from multiple register classes, in which case it will appear multiple times
544546
/// in the map.
547+
// NOTE: This function isn't used at the moment, but is needed to support
548+
// falling back to an external assembler.
545549
pub fn allocatable_registers(
546550
arch: InlineAsmArch,
547551
has_feature: impl FnMut(&str) -> bool,

src/librustc_target/asm/riscv.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ impl RiscVInlineAsmRegClass {
5050
fn not_e(
5151
_arch: InlineAsmArch,
5252
mut has_feature: impl FnMut(&str) -> bool,
53+
_allocating: bool,
5354
) -> Result<(), &'static str> {
5455
if has_feature("e") {
5556
Err("register can't be used with the `e` target feature")

src/librustc_target/asm/x86.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ impl X86InlineAsmRegClass {
131131
fn x86_64_only(
132132
arch: InlineAsmArch,
133133
_has_feature: impl FnMut(&str) -> bool,
134+
_allocating: bool,
134135
) -> Result<(), &'static str> {
135136
match arch {
136137
InlineAsmArch::X86 => Err("register is only available on x86_64"),
@@ -139,6 +140,20 @@ fn x86_64_only(
139140
}
140141
}
141142

143+
fn high_byte(
144+
arch: InlineAsmArch,
145+
_has_feature: impl FnMut(&str) -> bool,
146+
allocating: bool,
147+
) -> Result<(), &'static str> {
148+
match arch {
149+
InlineAsmArch::X86_64 if allocating => {
150+
// The error message isn't actually used...
151+
Err("high byte registers are not allocated by reg_byte")
152+
}
153+
_ => Ok(()),
154+
}
155+
}
156+
142157
def_regs! {
143158
X86 X86InlineAsmReg X86InlineAsmRegClass {
144159
ax: reg, reg_abcd = ["ax", "eax", "rax"],
@@ -156,13 +171,13 @@ def_regs! {
156171
r14: reg = ["r14", "r14w", "r14d"] % x86_64_only,
157172
r15: reg = ["r15", "r15w", "r15d"] % x86_64_only,
158173
al: reg_byte = ["al"],
159-
ah: reg_byte = ["ah"],
174+
ah: reg_byte = ["ah"] % high_byte,
160175
bl: reg_byte = ["bl"],
161-
bh: reg_byte = ["bh"],
176+
bh: reg_byte = ["bh"] % high_byte,
162177
cl: reg_byte = ["cl"],
163-
ch: reg_byte = ["ch"],
178+
ch: reg_byte = ["ch"] % high_byte,
164179
dl: reg_byte = ["dl"],
165-
dh: reg_byte = ["dh"],
180+
dh: reg_byte = ["dh"] % high_byte,
166181
sil: reg_byte = ["sil"] % x86_64_only,
167182
dil: reg_byte = ["dil"] % x86_64_only,
168183
r8b: reg_byte = ["r8b"] % x86_64_only,

0 commit comments

Comments
 (0)