Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/rustc_target/src/asm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ macro_rules! def_reg_class {
macro_rules! def_regs {
($arch:ident $arch_reg:ident $arch_regclass:ident {
$(
$reg:ident: $class:ident $(, $extra_class:ident)* = [$reg_name:literal $(, $alias:literal)*] $(% $filter:ident)?,
$reg:ident: $class:ident $(, $extra_class:ident)* = [$reg_name:literal $(, $alias:literal)*] $(% $filter:ident)*,
)*
$(
#error = [$($bad_reg:literal),+] => $error:literal,
Expand Down Expand Up @@ -121,7 +121,7 @@ macro_rules! def_regs {
_target_features,
_target,
_is_clobber
)?;)?
)?;)*
Ok(())
}
)*
Expand All @@ -142,7 +142,7 @@ macro_rules! def_regs {
#[allow(unused_imports)]
use super::{InlineAsmReg, InlineAsmRegClass};
$(
if $($filter(_arch, _reloc_model, _target_features, _target, false).is_ok() &&)? true {
if $($filter(_arch, _reloc_model, _target_features, _target, false).is_ok() &&)* true {
if let Some(set) = _map.get_mut(&InlineAsmRegClass::$arch($arch_regclass::$class)) {
set.insert(InlineAsmReg::$arch($arch_reg::$reg));
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_target/src/asm/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ def_regs! {
r15: reg = ["r15", "r15w", "r15d"] % x86_64_only,
al: reg_byte = ["al"],
ah: reg_byte = ["ah"] % high_byte,
bl: reg_byte = ["bl"],
bh: reg_byte = ["bh"] % high_byte,
bl: reg_byte = ["bl"] % rbx_reserved,
bh: reg_byte = ["bh"] % rbx_reserved % high_byte,
cl: reg_byte = ["cl"],
ch: reg_byte = ["ch"] % high_byte,
dl: reg_byte = ["dl"],
Expand Down
56 changes: 34 additions & 22 deletions tests/ui/asm/x86_64/bad-reg.experimental_reg.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -67,154 +67,166 @@ LL | asm!("", in("ip") foo);
| ^^^^^^^^^^^^

error: register class `x87_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:39:18
--> $DIR/bad-reg.rs:43:18
|
LL | asm!("", in("st(2)") foo);
| ^^^^^^^^^^^^^^^

error: register class `mmx_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:42:18
--> $DIR/bad-reg.rs:46:18
|
LL | asm!("", in("mm0") foo);
| ^^^^^^^^^^^^^

error: register class `kreg0` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:45:18
--> $DIR/bad-reg.rs:49:18
|
LL | asm!("", in("k0") foo);
| ^^^^^^^^^^^^

error: register class `x87_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:50:20
--> $DIR/bad-reg.rs:54:20
|
LL | asm!("{}", in(x87_reg) foo);
| ^^^^^^^^^^^^^^^

error: register class `mmx_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:53:20
--> $DIR/bad-reg.rs:57:20
|
LL | asm!("{}", in(mmx_reg) foo);
| ^^^^^^^^^^^^^^^

error: register class `x87_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:56:20
--> $DIR/bad-reg.rs:60:20
|
LL | asm!("{}", out(x87_reg) _);
| ^^^^^^^^^^^^^^

error: register class `mmx_reg` can only be used as a clobber, not as an input or output
--> $DIR/bad-reg.rs:58:20
--> $DIR/bad-reg.rs:62:20
|
LL | asm!("{}", out(mmx_reg) _);
| ^^^^^^^^^^^^^^

error: register `al` conflicts with register `eax`
--> $DIR/bad-reg.rs:64:33
--> $DIR/bad-reg.rs:68:33
|
LL | asm!("", in("eax") foo, in("al") bar);
| ------------- ^^^^^^^^^^^^ register `al`
| |
| register `eax`

error: register `rax` conflicts with register `rax`
--> $DIR/bad-reg.rs:67:33
--> $DIR/bad-reg.rs:71:33
|
LL | asm!("", in("rax") foo, out("rax") bar);
| ------------- ^^^^^^^^^^^^^^ register `rax`
| |
| register `rax`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:67:18
--> $DIR/bad-reg.rs:71:18
|
LL | asm!("", in("rax") foo, out("rax") bar);
| ^^^^^^^^^^^^^

error: register `ymm0` conflicts with register `xmm0`
--> $DIR/bad-reg.rs:72:34
--> $DIR/bad-reg.rs:76:34
|
LL | asm!("", in("xmm0") foo, in("ymm0") bar);
| -------------- ^^^^^^^^^^^^^^ register `ymm0`
| |
| register `xmm0`

error: register `ymm0` conflicts with register `xmm0`
--> $DIR/bad-reg.rs:74:34
--> $DIR/bad-reg.rs:78:34
|
LL | asm!("", in("xmm0") foo, out("ymm0") bar);
| -------------- ^^^^^^^^^^^^^^^ register `ymm0`
| |
| register `xmm0`
|
help: use `lateout` instead of `out` to avoid conflict
--> $DIR/bad-reg.rs:74:18
--> $DIR/bad-reg.rs:78:18
|
LL | asm!("", in("xmm0") foo, out("ymm0") bar);
| ^^^^^^^^^^^^^^

error: cannot use register `bl`: rbx is used internally by LLVM and cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:38:18
|
LL | asm!("", in("bl") foo);
| ^^^^^^^^^^^^

error: cannot use register `bh`: rbx is used internally by LLVM and cannot be used as an operand for inline asm
--> $DIR/bad-reg.rs:40:18
|
LL | asm!("", in("bh") foo);
| ^^^^^^^^^^^^

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:39:30
--> $DIR/bad-reg.rs:43:30
|
LL | asm!("", in("st(2)") foo);
| ^^^
|
= note: register class `x87_reg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:42:28
--> $DIR/bad-reg.rs:46:28
|
LL | asm!("", in("mm0") foo);
| ^^^
|
= note: register class `mmx_reg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:45:27
--> $DIR/bad-reg.rs:49:27
|
LL | asm!("", in("k0") foo);
| ^^^
|
= note: register class `kreg0` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:50:32
--> $DIR/bad-reg.rs:54:32
|
LL | asm!("{}", in(x87_reg) foo);
| ^^^
|
= note: register class `x87_reg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:53:32
--> $DIR/bad-reg.rs:57:32
|
LL | asm!("{}", in(mmx_reg) foo);
| ^^^
|
= note: register class `mmx_reg` supports these types:

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:64:42
--> $DIR/bad-reg.rs:68:42
|
LL | asm!("", in("eax") foo, in("al") bar);
| ^^^
|
= note: register class `reg_byte` supports these types: i8

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:69:27
--> $DIR/bad-reg.rs:73:27
|
LL | asm!("", in("al") foo, lateout("al") bar);
| ^^^
|
= note: register class `reg_byte` supports these types: i8

error: type `i32` cannot be used with this register class
--> $DIR/bad-reg.rs:69:46
--> $DIR/bad-reg.rs:73:46
|
LL | asm!("", in("al") foo, lateout("al") bar);
| ^^^
|
= note: register class `reg_byte` supports these types: i8

error: aborting due to 28 previous errors
error: aborting due to 30 previous errors

4 changes: 4 additions & 0 deletions tests/ui/asm/x86_64/bad-reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ fn main() {
//~^ ERROR invalid register `rsp`: the stack pointer cannot be used as an operand
asm!("", in("ip") foo);
//~^ ERROR invalid register `ip`: the instruction pointer cannot be used as an operand
asm!("", in("bl") foo);
//~^ ERROR cannot use register `bl`: rbx is used internally by LLVM and cannot be used as an operand for inline asm
asm!("", in("bh") foo);
//~^ ERROR cannot use register `bh`: rbx is used internally by LLVM and cannot be used as an operand for inline asm

asm!("", in("st(2)") foo);
//~^ ERROR register class `x87_reg` can only be used as a clobber, not as an input or output
Expand Down
Loading
Loading