diff options
| author | bors <bors@rust-lang.org> | 2021-03-16 10:05:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-03-16 10:05:46 +0000 |
| commit | f24ce9b0140d9be5a336954e878d0c1522966bb8 (patch) | |
| tree | 652b4ddb515deb444280ee580bfe64dfeca2ee75 /src | |
| parent | 195ad4830e11a544391abe296b146450dea8411b (diff) | |
| parent | ba00ddc39a99ed70ba107902767db8d4837af921 (diff) | |
| download | rust-f24ce9b0140d9be5a336954e878d0c1522966bb8.tar.gz rust-f24ce9b0140d9be5a336954e878d0c1522966bb8.zip | |
Auto merge of #82838 - Amanieu:rustdoc_asm, r=nagisa
Allow rustdoc to handle asm! of foreign architectures This allows rustdoc to process code containing `asm!` for architectures other than the current one. Since this never reaches codegen, we just replace target-specific registers and register classes with a dummy one. Fixes #82869
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/rustdoc/asm-foreign.rs | 20 | ||||
| -rw-r--r-- | src/test/rustdoc/asm-foreign2.rs | 11 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-82869.rs | 23 | ||||
| -rw-r--r-- | src/test/ui/issues/issue-82869.stderr | 24 |
4 files changed, 78 insertions, 0 deletions
diff --git a/src/test/rustdoc/asm-foreign.rs b/src/test/rustdoc/asm-foreign.rs new file mode 100644 index 00000000000..570ed043dd9 --- /dev/null +++ b/src/test/rustdoc/asm-foreign.rs @@ -0,0 +1,20 @@ +// Make sure rustdoc accepts asm! for a foreign architecture. + +#![feature(asm)] + +// @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") { + || {}; + b + }); + c +} + +// @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 +} diff --git a/src/test/rustdoc/asm-foreign2.rs b/src/test/rustdoc/asm-foreign2.rs new file mode 100644 index 00000000000..34e313e7eac --- /dev/null +++ b/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 +} diff --git a/src/test/ui/issues/issue-82869.rs b/src/test/ui/issues/issue-82869.rs new file mode 100644 index 00000000000..a8e688cbe1f --- /dev/null +++ b/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 +} diff --git a/src/test/ui/issues/issue-82869.stderr b/src/test/ui/issues/issue-82869.stderr new file mode 100644 index 00000000000..d05714ea6f2 --- /dev/null +++ b/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 + |
