@@ -108,7 +108,7 @@ The corresponding arguments are accessed in order, by index, or by name.
108
108
let y : i64 ;
109
109
let z : i64 ;
110
110
// 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 );}
112
112
// ... this
113
113
unsafe { core :: arch :: asm! (" mov {0}, {1}" , out (reg ) y , in (reg ) 5 );}
114
114
/// ... and this
@@ -119,7 +119,6 @@ The corresponding arguments are accessed in order, by index, or by name.
119
119
# }
120
120
```
121
121
122
-
123
122
r[ asm.ts-args.no-implicit]
124
123
However, implicit named arguments (introduced by [ RFC #2795 ] [ rfc-2795 ] ) are not supported.
125
124
@@ -342,7 +341,7 @@ r[asm.operand-type.supported-operands.sym]
342
341
# #[cfg(target_arch = " x86_64" )] {
343
342
// swizzle [0, 1, 2, 3] => [3, 2, 0, 1]
344
343
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 ]) };
346
345
let y : core :: arch :: x86_64 :: __m128 ;
347
346
// Pass a constant value into an instruction that expects an immediate like `pshufd`
348
347
unsafe { core :: arch :: asm! (" pshufd {xmm}, {xmm}, {shuffle}" , xmm = inlateout (xmm_reg ) x => y , shuffle = const SHUFFLE ); }
@@ -374,7 +373,7 @@ let x = 5;
374
373
375
374
// register operands aren't allowed, since we aren't in a function
376
375
# #[cfg(target_arch = "x86_64")]
377
- core::arch::global_asm!("", in(reg) 5);
376
+ core::arch::global_asm!("", in(reg) 5);
378
377
379
378
# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
380
379
```
@@ -427,7 +426,6 @@ It is a compile-time error to use the same explicit register for two input opera
427
426
# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
428
427
```
429
428
430
-
431
429
r[ asm.register-operands.error-overlapping]
432
430
Additionally, it is also a compile-time error to use overlapping registers (e.g. ARM VFP) in input operands or in output operands.
433
431
@@ -751,7 +749,6 @@ Only one modifier is allowed per template placeholder.
751
749
# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
752
750
```
753
751
754
-
755
752
r[ asm.template-modifiers.supported-modifiers]
756
753
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.
757
754
@@ -930,10 +927,10 @@ r[asm.options.supported-options.nomem]
930
927
let z: i32;
931
928
// Accessing memory from a nomem asm block is disallowed
932
929
unsafe { core::arch::asm!("mov {val:e}, dword ptr [{ptr}]", ptr = in(reg) &mut x, val = lateout(reg) z, options(nomem))}
933
-
930
+
934
931
// Writing to memory is also undefined behaviour
935
932
unsafe { core::arch::asm!("mov dword ptr [{ptr}], {val:e}", ptr = in(reg) &mut x, val = in(reg) z, options(nomem))}
936
- # }
933
+ # }
937
934
```
938
935
939
936
``` rust
@@ -947,7 +944,6 @@ r[asm.options.supported-options.nomem]
947
944
# }
948
945
```
949
946
950
-
951
947
r[ asm.options.supported-options.readonly]
952
948
- ` readonly ` : The ` asm! ` block does not write to any memory accessible outside of the ` asm! ` block.
953
949
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]
959
955
let mut x = 0;
960
956
// We cannot modify memory in readonly
961
957
unsafe { core::arch::asm!("mov dword ptr[{}], 1", in(reg) &mut x, options(readonly))}
962
- # }
958
+ # }
963
959
```
964
960
965
961
``` rust
@@ -972,7 +968,6 @@ r[asm.options.supported-options.readonly]
972
968
# }
973
969
```
974
970
975
-
976
971
``` rust
977
972
# #[cfg(target_arch = " x86_64" )] {
978
973
let x : i64 = 0 ;
@@ -1180,19 +1175,19 @@ pub fn fadd(x: f64, y: f64) -> f64{
1180
1175
let mut top = 0u16 ;
1181
1176
// we can do complex stuff with x87 if we clobber the entire x87 stack
1182
1177
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}]" ,
1187
1182
" xor eax, eax" ,
1188
1183
" fstsw ax" ,
1189
1184
" shl eax, 11" ,
1190
- x = in (reg ) & x ,
1191
- y = in (reg ) & y ,
1185
+ x = in (reg ) & x ,
1186
+ y = in (reg ) & y ,
1192
1187
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)" ) _ ,
1194
1189
out (" st(4)" ) _ , out (" st(5)" ) _ , out (" st(6)" ) _ , out (" st(7)" ) _ ,
1195
- out (" eax" ) top
1190
+ out (" eax" ) top
1196
1191
);}
1197
1192
1198
1193
assert_eq! (top & 0x7 , 0 );
@@ -1341,7 +1336,6 @@ r[asm.target-specific-directives]
1341
1336
r[ asm.target-specific-directives.dwarf-unwinding]
1342
1337
The following directives are supported on ELF targets that support DWARF unwind info:
1343
1338
1344
-
1345
1339
- ` .cfi_adjust_cfa_offset `
1346
1340
- ` .cfi_def_cfa `
1347
1341
- ` .cfi_def_cfa_offset `
@@ -1364,7 +1358,6 @@ The following directives are supported on ELF targets that support DWARF unwind
1364
1358
- ` .cfi_undefined `
1365
1359
- ` .cfi_window_save `
1366
1360
1367
-
1368
1361
##### Structured Exception Handling
1369
1362
1370
1363
r[ asm.target-specific-directives.structured-exception-handling]
@@ -1378,7 +1371,6 @@ On targets with structured exception Handling, the following additional directiv
1378
1371
- ` .seh_setframe `
1379
1372
- ` .seh_stackalloc `
1380
1373
1381
-
1382
1374
##### x86 (32-bit and 64-bit)
1383
1375
1384
1376
r[ asm.target-specific-directives.x86]
@@ -1388,12 +1380,10 @@ On x86 targets, both 32-bit and 64-bit, the following additional directives are
1388
1380
- ` .code32 `
1389
1381
- ` .code64 `
1390
1382
1391
-
1392
1383
Use of ` .code16 ` , ` .code32 ` , and ` .code64 ` directives are only supported if the state is reset to the default before exiting the assembly block.
1393
1384
32-bit x86 uses ` .code32 ` by default, and x86_64 uses ` .code64 ` by default.
1394
1385
1395
1386
1396
-
1397
1387
##### ARM (32-bit)
1398
1388
1399
1389
r[ asm.target-specific-directives.arm-32-bit]
0 commit comments