Address review comments

This commit is contained in:
Amanieu d'Antras 2021-03-14 23:19:16 +00:00
parent fa3694fada
commit ba00ddc39a
5 changed files with 69 additions and 10 deletions

View File

@ -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"),
}
}
@ -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"),
}
}
}
@ -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"),
}
}
@ -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"),
}
}
@ -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"),
}
}
@ -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"),
}
}
@ -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"),
}
}
}

View File

@ -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") {
|| {};
@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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