Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Mar 14, 2021
1 parent fa3694f commit ba00ddc
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 10 deletions.
14 changes: 7 additions & 7 deletions compiler/rustc_target/src/asm/mod.rs
Expand Up @@ -313,7 +313,7 @@ impl InlineAsmReg {
Self::RiscV(r) => r.emit(out, arch, modifier),
Self::Hexagon(r) => r.emit(out, arch, modifier),
Self::Mips(r) => r.emit(out, arch, modifier),
Self::Err => unreachable!(),
Self::Err => unreachable!("Use of InlineAsmReg::Err"),
}
}

Expand All @@ -325,7 +325,7 @@ impl InlineAsmReg {
Self::RiscV(_) => cb(self),
Self::Hexagon(r) => r.overlapping_regs(|r| cb(Self::Hexagon(r))),
Self::Mips(_) => cb(self),
Self::Err => unreachable!(),
Self::Err => unreachable!("Use of InlineAsmReg::Err"),
}
}
}
Expand Down Expand Up @@ -386,7 +386,7 @@ impl InlineAsmRegClass {
Self::Mips(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Mips),
Self::SpirV(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::SpirV),
Self::Wasm(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Wasm),
Self::Err => unreachable!(),
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
}
}

Expand All @@ -411,7 +411,7 @@ impl InlineAsmRegClass {
Self::Mips(r) => r.suggest_modifier(arch, ty),
Self::SpirV(r) => r.suggest_modifier(arch, ty),
Self::Wasm(r) => r.suggest_modifier(arch, ty),
Self::Err => unreachable!(),
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
}
}

Expand All @@ -432,7 +432,7 @@ impl InlineAsmRegClass {
Self::Mips(r) => r.default_modifier(arch),
Self::SpirV(r) => r.default_modifier(arch),
Self::Wasm(r) => r.default_modifier(arch),
Self::Err => unreachable!(),
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
}
}

Expand All @@ -452,7 +452,7 @@ impl InlineAsmRegClass {
Self::Mips(r) => r.supported_types(arch),
Self::SpirV(r) => r.supported_types(arch),
Self::Wasm(r) => r.supported_types(arch),
Self::Err => unreachable!(),
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
}
}

Expand Down Expand Up @@ -489,7 +489,7 @@ impl InlineAsmRegClass {
Self::Mips(r) => r.valid_modifiers(arch),
Self::SpirV(r) => r.valid_modifiers(arch),
Self::Wasm(r) => r.valid_modifiers(arch),
Self::Err => unreachable!(),
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
}
}
}
Expand Down
@@ -1,9 +1,9 @@
// check-pass
// Make sure rustdoc accepts asm! for a foreign architecture.

#![feature(asm)]

pub unsafe fn aarch64(a: f64, b: f64) {
// @has asm_foreign/fn.aarch64.html
pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
let c;
asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
|| {};
Expand All @@ -12,7 +12,8 @@ pub unsafe fn aarch64(a: f64, b: f64) {
c
}

pub unsafe fn x86(a: f64, b: f64) {
// @has asm_foreign/fn.x86.html
pub unsafe fn x86(a: f64, b: f64) -> f64 {
let c;
asm!("addsd {}, {}, xmm0", out(xmm_reg) c, in(xmm_reg) a, in("xmm0") b);
c
Expand Down
11 changes: 11 additions & 0 deletions src/test/rustdoc/asm-foreign2.rs
@@ -0,0 +1,11 @@
// only-aarch64
// Make sure rustdoc accepts options(att_syntax) asm! on non-x86 targets.

#![feature(asm)]

// @has asm_foreign2/fn.x86.html
pub unsafe fn x86(x: i64) -> i64 {
let y;
asm!("movq {}, {}", in(reg) x, out(reg) y, options(att_syntax));
y
}
23 changes: 23 additions & 0 deletions src/test/ui/issues/issue-82869.rs
@@ -0,0 +1,23 @@
// only-x86_64
// Make sure rustc doesn't ICE on asm! for a foreign architecture.

#![feature(asm)]
#![crate_type = "rlib"]

pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
let c;
asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
|| {};
b
});
//~^^^^ invalid register class
//~^^^^^ invalid register class
//~^^^^^^ invalid register
c
}

pub unsafe fn x86(a: f64, b: f64) -> f64 {
let c;
asm!("addsd {}, {}, xmm0", out(xmm_reg) c, in(xmm_reg) a, in("xmm0") b);
c
}
24 changes: 24 additions & 0 deletions src/test/ui/issues/issue-82869.stderr
@@ -0,0 +1,24 @@
error: invalid register class `vreg`: unknown register class
--> $DIR/issue-82869.rs:9:32
|
LL | asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
| ^^^^^^^^^^^

error: invalid register class `vreg`: unknown register class
--> $DIR/issue-82869.rs:9:45
|
LL | asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
| ^^^^^^^^^^

error: invalid register `d0`: unknown register
--> $DIR/issue-82869.rs:9:57
|
LL | asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
| _________________________________________________________^
LL | | || {};
LL | | b
LL | | });
| |_____^

error: aborting due to 3 previous errors

0 comments on commit ba00ddc

Please sign in to comment.