Skip to content

Commit b41a30f

Browse files
committed
Fix whitespace formatting in inline-assembly.md
1 parent e7579c7 commit b41a30f

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

src/inline-assembly.md

+14-24
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ The corresponding arguments are accessed in order, by index, or by name.
108108
let y: i64;
109109
let z: i64;
110110
// This
111-
unsafe { core::arch::asm!("mov {}, {}", out(reg) x, in(reg) 5);}
111+
unsafe { core::arch::asm!("mov {}, {}", out(reg) x, in(reg) 5);}
112112
// ... this
113113
unsafe { core::arch::asm!("mov {0}, {1}", out(reg) y, in(reg) 5);}
114114
/// ... and this
@@ -119,7 +119,6 @@ The corresponding arguments are accessed in order, by index, or by name.
119119
# }
120120
```
121121

122-
123122
r[asm.ts-args.no-implicit]
124123
However, implicit named arguments (introduced by [RFC #2795][rfc-2795]) are not supported.
125124

@@ -342,7 +341,7 @@ r[asm.operand-type.supported-operands.sym]
342341
# #[cfg(target_arch = "x86_64")] {
343342
// swizzle [0, 1, 2, 3] => [3, 2, 0, 1]
344343
const SHUFFLE: u8 = 0b01_00_10_11;
345-
let x: core::arch::x86_64::__m128 = unsafe{ core::mem::transmute([0u32, 1u32, 2u32, 3u32]) };
344+
let x: core::arch::x86_64::__m128 = unsafe{ core::mem::transmute([0u32, 1u32, 2u32, 3u32]) };
346345
let y: core::arch::x86_64::__m128;
347346
// Pass a constant value into an instruction that expects an immediate like `pshufd`
348347
unsafe { core::arch::asm!("pshufd {xmm}, {xmm}, {shuffle}", xmm = inlateout(xmm_reg) x=>y, shuffle = const SHUFFLE); }
@@ -374,7 +373,7 @@ let x = 5;
374373
375374
// register operands aren't allowed, since we aren't in a function
376375
# #[cfg(target_arch = "x86_64")]
377-
core::arch::global_asm!("", in(reg) 5);
376+
core::arch::global_asm!("", in(reg) 5);
378377
379378
# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
380379
```
@@ -427,7 +426,6 @@ It is a compile-time error to use the same explicit register for two input opera
427426
# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
428427
```
429428

430-
431429
r[asm.register-operands.error-overlapping]
432430
Additionally, it is also a compile-time error to use overlapping registers (e.g. ARM VFP) in input operands or in output operands.
433431

@@ -751,7 +749,6 @@ Only one modifier is allowed per template placeholder.
751749
# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
752750
```
753751

754-
755752
r[asm.template-modifiers.supported-modifiers]
756753
The supported modifiers are a subset of LLVM's (and GCC's) [asm template argument modifiers][llvm-argmod], but do not use the same letter codes.
757754

@@ -930,10 +927,10 @@ r[asm.options.supported-options.nomem]
930927
let z: i32;
931928
// Accessing memory from a nomem asm block is disallowed
932929
unsafe { core::arch::asm!("mov {val:e}, dword ptr [{ptr}]", ptr = in(reg) &mut x, val = lateout(reg) z, options(nomem))}
933-
930+
934931
// Writing to memory is also undefined behaviour
935932
unsafe { core::arch::asm!("mov dword ptr [{ptr}], {val:e}", ptr = in(reg) &mut x, val = in(reg) z, options(nomem))}
936-
# }
933+
# }
937934
```
938935

939936
```rust
@@ -947,7 +944,6 @@ r[asm.options.supported-options.nomem]
947944
# }
948945
```
949946

950-
951947
r[asm.options.supported-options.readonly]
952948
- `readonly`: The `asm!` block does not write to any memory accessible outside of the `asm!` block.
953949
This allows the compiler to cache the values of unmodified global variables in registers across the `asm!` block since it knows that they are not written to by the `asm!`.
@@ -959,7 +955,7 @@ r[asm.options.supported-options.readonly]
959955
let mut x = 0;
960956
// We cannot modify memory in readonly
961957
unsafe { core::arch::asm!("mov dword ptr[{}], 1", in(reg) &mut x, options(readonly))}
962-
# }
958+
# }
963959
```
964960

965961
```rust
@@ -972,7 +968,6 @@ r[asm.options.supported-options.readonly]
972968
# }
973969
```
974970

975-
976971
```rust
977972
# #[cfg(target_arch = "x86_64")] {
978973
let x: i64 = 0;
@@ -1180,19 +1175,19 @@ pub fn fadd(x: f64, y: f64) -> f64{
11801175
let mut top = 0u16;
11811176
// we can do complex stuff with x87 if we clobber the entire x87 stack
11821177
unsafe{ core::arch::asm!(
1183-
"fld qword ptr [{x}]",
1184-
"fld qword ptr [{y}])",
1185-
"faddp",
1186-
"fstp qword ptr [{out}]",
1178+
"fld qword ptr [{x}]",
1179+
"fld qword ptr [{y}])",
1180+
"faddp",
1181+
"fstp qword ptr [{out}]",
11871182
"xor eax, eax",
11881183
"fstsw ax",
11891184
"shl eax, 11",
1190-
x = in(reg) &x,
1191-
y = in(reg) &y,
1185+
x = in(reg) &x,
1186+
y = in(reg) &y,
11921187
out = in(reg) &mut out,
1193-
out("st(0)") _, out("st(1)") _, out("st(2)") _, out("st(3)") _,
1188+
out("st(0)") _, out("st(1)") _, out("st(2)") _, out("st(3)") _,
11941189
out("st(4)") _, out("st(5)") _, out("st(6)") _, out("st(7)") _,
1195-
out("eax") top
1190+
out("eax") top
11961191
);}
11971192

11981193
assert_eq!(top & 0x7, 0);
@@ -1341,7 +1336,6 @@ r[asm.target-specific-directives]
13411336
r[asm.target-specific-directives.dwarf-unwinding]
13421337
The following directives are supported on ELF targets that support DWARF unwind info:
13431338

1344-
13451339
- `.cfi_adjust_cfa_offset`
13461340
- `.cfi_def_cfa`
13471341
- `.cfi_def_cfa_offset`
@@ -1364,7 +1358,6 @@ The following directives are supported on ELF targets that support DWARF unwind
13641358
- `.cfi_undefined`
13651359
- `.cfi_window_save`
13661360

1367-
13681361
##### Structured Exception Handling
13691362

13701363
r[asm.target-specific-directives.structured-exception-handling]
@@ -1378,7 +1371,6 @@ On targets with structured exception Handling, the following additional directiv
13781371
- `.seh_setframe`
13791372
- `.seh_stackalloc`
13801373

1381-
13821374
##### x86 (32-bit and 64-bit)
13831375

13841376
r[asm.target-specific-directives.x86]
@@ -1388,12 +1380,10 @@ On x86 targets, both 32-bit and 64-bit, the following additional directives are
13881380
- `.code32`
13891381
- `.code64`
13901382

1391-
13921383
Use of `.code16`, `.code32`, and `.code64` directives are only supported if the state is reset to the default before exiting the assembly block.
13931384
32-bit x86 uses `.code32` by default, and x86_64 uses `.code64` by default.
13941385

13951386

1396-
13971387
##### ARM (32-bit)
13981388

13991389
r[asm.target-specific-directives.arm-32-bit]

0 commit comments

Comments
 (0)