Skip to content

Commit ba00ddc

Browse files
committed
Address review comments
1 parent fa3694f commit ba00ddc

File tree

5 files changed

+69
-10
lines changed

5 files changed

+69
-10
lines changed

compiler/rustc_target/src/asm/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl InlineAsmReg {
313313
Self::RiscV(r) => r.emit(out, arch, modifier),
314314
Self::Hexagon(r) => r.emit(out, arch, modifier),
315315
Self::Mips(r) => r.emit(out, arch, modifier),
316-
Self::Err => unreachable!(),
316+
Self::Err => unreachable!("Use of InlineAsmReg::Err"),
317317
}
318318
}
319319

@@ -325,7 +325,7 @@ impl InlineAsmReg {
325325
Self::RiscV(_) => cb(self),
326326
Self::Hexagon(r) => r.overlapping_regs(|r| cb(Self::Hexagon(r))),
327327
Self::Mips(_) => cb(self),
328-
Self::Err => unreachable!(),
328+
Self::Err => unreachable!("Use of InlineAsmReg::Err"),
329329
}
330330
}
331331
}
@@ -386,7 +386,7 @@ impl InlineAsmRegClass {
386386
Self::Mips(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Mips),
387387
Self::SpirV(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::SpirV),
388388
Self::Wasm(r) => r.suggest_class(arch, ty).map(InlineAsmRegClass::Wasm),
389-
Self::Err => unreachable!(),
389+
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
390390
}
391391
}
392392

@@ -411,7 +411,7 @@ impl InlineAsmRegClass {
411411
Self::Mips(r) => r.suggest_modifier(arch, ty),
412412
Self::SpirV(r) => r.suggest_modifier(arch, ty),
413413
Self::Wasm(r) => r.suggest_modifier(arch, ty),
414-
Self::Err => unreachable!(),
414+
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
415415
}
416416
}
417417

@@ -432,7 +432,7 @@ impl InlineAsmRegClass {
432432
Self::Mips(r) => r.default_modifier(arch),
433433
Self::SpirV(r) => r.default_modifier(arch),
434434
Self::Wasm(r) => r.default_modifier(arch),
435-
Self::Err => unreachable!(),
435+
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
436436
}
437437
}
438438

@@ -452,7 +452,7 @@ impl InlineAsmRegClass {
452452
Self::Mips(r) => r.supported_types(arch),
453453
Self::SpirV(r) => r.supported_types(arch),
454454
Self::Wasm(r) => r.supported_types(arch),
455-
Self::Err => unreachable!(),
455+
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
456456
}
457457
}
458458

@@ -489,7 +489,7 @@ impl InlineAsmRegClass {
489489
Self::Mips(r) => r.valid_modifiers(arch),
490490
Self::SpirV(r) => r.valid_modifiers(arch),
491491
Self::Wasm(r) => r.valid_modifiers(arch),
492-
Self::Err => unreachable!(),
492+
Self::Err => unreachable!("Use of InlineAsmRegClass::Err"),
493493
}
494494
}
495495
}

src/test/rustdoc-ui/asm-foreign.rs src/test/rustdoc/asm-foreign.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// check-pass
21
// Make sure rustdoc accepts asm! for a foreign architecture.
32

43
#![feature(asm)]
54

6-
pub unsafe fn aarch64(a: f64, b: f64) {
5+
// @has asm_foreign/fn.aarch64.html
6+
pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
77
let c;
88
asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
99
|| {};
@@ -12,7 +12,8 @@ pub unsafe fn aarch64(a: f64, b: f64) {
1212
c
1313
}
1414

15-
pub unsafe fn x86(a: f64, b: f64) {
15+
// @has asm_foreign/fn.x86.html
16+
pub unsafe fn x86(a: f64, b: f64) -> f64 {
1617
let c;
1718
asm!("addsd {}, {}, xmm0", out(xmm_reg) c, in(xmm_reg) a, in("xmm0") b);
1819
c

src/test/rustdoc/asm-foreign2.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// only-aarch64
2+
// Make sure rustdoc accepts options(att_syntax) asm! on non-x86 targets.
3+
4+
#![feature(asm)]
5+
6+
// @has asm_foreign2/fn.x86.html
7+
pub unsafe fn x86(x: i64) -> i64 {
8+
let y;
9+
asm!("movq {}, {}", in(reg) x, out(reg) y, options(att_syntax));
10+
y
11+
}

src/test/ui/issues/issue-82869.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// only-x86_64
2+
// Make sure rustc doesn't ICE on asm! for a foreign architecture.
3+
4+
#![feature(asm)]
5+
#![crate_type = "rlib"]
6+
7+
pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
8+
let c;
9+
asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
10+
|| {};
11+
b
12+
});
13+
//~^^^^ invalid register class
14+
//~^^^^^ invalid register class
15+
//~^^^^^^ invalid register
16+
c
17+
}
18+
19+
pub unsafe fn x86(a: f64, b: f64) -> f64 {
20+
let c;
21+
asm!("addsd {}, {}, xmm0", out(xmm_reg) c, in(xmm_reg) a, in("xmm0") b);
22+
c
23+
}

src/test/ui/issues/issue-82869.stderr

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error: invalid register class `vreg`: unknown register class
2+
--> $DIR/issue-82869.rs:9:32
3+
|
4+
LL | asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
5+
| ^^^^^^^^^^^
6+
7+
error: invalid register class `vreg`: unknown register class
8+
--> $DIR/issue-82869.rs:9:45
9+
|
10+
LL | asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
11+
| ^^^^^^^^^^
12+
13+
error: invalid register `d0`: unknown register
14+
--> $DIR/issue-82869.rs:9:57
15+
|
16+
LL | asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
17+
| _________________________________________________________^
18+
LL | | || {};
19+
LL | | b
20+
LL | | });
21+
| |_____^
22+
23+
error: aborting due to 3 previous errors
24+

0 commit comments

Comments
 (0)