Skip to content

Commit

Permalink
Mark asm unstable book doctests as allow_fail since they don't work w…
Browse files Browse the repository at this point in the history
…ith system LLVM
  • Loading branch information
Amanieu committed May 18, 2020
1 parent cecffdc commit 3233565
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/doc/unstable-book/src/library-features/asm.md
Expand Up @@ -24,7 +24,7 @@ cannot be otherwise achieved. Accessing low level hardware primitives, e.g. in k

Let us start with the simplest possible example:

```rust
```rust,allow_fail
# #![feature(asm)]
unsafe {
asm!("nop");
Expand All @@ -41,7 +41,7 @@ in the first argument of the `asm!` macro as a string literal.
Now inserting an instruction that does nothing is rather boring. Let us do something that
actually acts on data:

```rust
```rust,allow_fail
# #![feature(asm)]
let x: u64;
unsafe {
Expand All @@ -63,7 +63,7 @@ the template and will read the variable from there after the inline assembly fin

Let us see another example that also uses an input:

```rust
```rust,allow_fail
# #![feature(asm)]
let i: u64 = 3;
let o: u64;
Expand Down Expand Up @@ -95,7 +95,7 @@ readability, and allows reordering instructions without changing the argument or

We can further refine the above example to avoid the `mov` instruction:

```rust
```rust,allow_fail
# #![feature(asm)]
let mut x: u64 = 3;
unsafe {
Expand All @@ -109,7 +109,7 @@ This is different from specifying an input and output separately in that it is g

It is also possible to specify different variables for the input and output parts of an `inout` operand:

```rust
```rust,allow_fail
# #![feature(asm)]
let x: u64 = 3;
let y: u64;
Expand All @@ -131,7 +131,7 @@ There is also a `inlateout` variant of this specifier.

Here is an example where `inlateout` *cannot* be used:

```rust
```rust,allow_fail
# #![feature(asm)]
let mut a: u64 = 4;
let b: u64 = 4;
Expand All @@ -149,7 +149,7 @@ Here the compiler is free to allocate the same register for inputs `b` and `c` s

However the following example can use `inlateout` since the output is only modified after all input registers have been read:

```rust
```rust,allow_fail
# #![feature(asm)]
let mut a: u64 = 4;
let b: u64 = 4;
Expand All @@ -168,7 +168,7 @@ Therefore, Rust inline assembly provides some more specific constraint specifier
While `reg` is generally available on any architecture, these are highly architecture specific. E.g. for x86 the general purpose registers `eax`, `ebx`, `ecx`, `edx`, `ebp`, `esi`, and `edi`
among others can be addressed by their name.

```rust,no_run
```rust,allow_fail,no_run
# #![feature(asm)]
let cmd = 0xd1;
unsafe {
Expand All @@ -184,7 +184,7 @@ Note that unlike other operand types, explicit register operands cannot be used

Consider this example which uses the x86 `mul` instruction:

```rust
```rust,allow_fail
# #![feature(asm)]
fn mul(a: u64, b: u64) -> u128 {
let lo: u64;
Expand Down Expand Up @@ -220,7 +220,7 @@ This state is generally referred to as being "clobbered".
We need to tell the compiler about this since it may need to save and restore this state
around the inline assembly block.

```rust
```rust,allow_fail
# #![feature(asm)]
let ebx: u32;
let ecx: u32;
Expand Down Expand Up @@ -250,7 +250,7 @@ However we still need to tell the compiler that `eax` and `edx` have been modifi

This can also be used with a general register class (e.g. `reg`) to obtain a scratch register for use inside the asm code:

```rust
```rust,allow_fail
# #![feature(asm)]
// Multiply x by 6 using shifts and adds
let mut x: u64 = 4;
Expand All @@ -270,7 +270,7 @@ assert_eq!(x, 4 * 6);
A special operand type, `sym`, allows you to use the symbol name of a `fn` or `static` in inline assembly code.
This allows you to call a function or access a global variable without needing to keep its address in a register.

```rust
```rust,allow_fail
# #![feature(asm)]
extern "C" fn foo(arg: i32) {
println!("arg = {}", arg);
Expand Down Expand Up @@ -306,7 +306,7 @@ By default the compiler will always choose the name that refers to the full regi

This default can be overriden by using modifiers on the template string operands, just like you would with format strings:

```rust
```rust,allow_fail
# #![feature(asm)]
let mut x: u16 = 0xab;
Expand All @@ -330,7 +330,7 @@ By default, an inline assembly block is treated the same way as an external FFI

Let's take our previous example of an `add` instruction:

```rust
```rust,allow_fail
# #![feature(asm)]
let mut a: u64 = 4;
let b: u64 = 4;
Expand Down

0 comments on commit 3233565

Please sign in to comment.