@@ -22,7 +22,6 @@ The compiler will emit an error if `asm!` is used on an unsupported target.
2222r[ asm.example]
2323## Example
2424
25-
2625``` rust
2726# #[cfg(target_arch = " x86_64" )] {
2827use std :: arch :: asm;
@@ -46,7 +45,6 @@ assert_eq!(x, 4 * 6);
4645r[ asm.syntax]
4746## Syntax
4847
49-
5048The following ABNF specifies the general syntax:
5149
5250``` text
@@ -106,7 +104,7 @@ The corresponding arguments are accessed in order, by index, or by name.
106104 let y : i64 ;
107105 let z : i64 ;
108106 // This
109- unsafe { core :: arch :: asm! (" mov {}, {}" , out (reg ) x , in (reg ) 5 );}
107+ unsafe { core :: arch :: asm! (" mov {}, {}" , out (reg ) x , in (reg ) 5 );}
110108 // ... this
111109 unsafe { core :: arch :: asm! (" mov {0}, {1}" , out (reg ) y , in (reg ) 5 );}
112110 /// ... and this
@@ -117,7 +115,6 @@ The corresponding arguments are accessed in order, by index, or by name.
117115# }
118116```
119117
120-
121118r[ asm.ts-args.no-implicit]
122119However, implicit named arguments (introduced by [ RFC #2795 ] [ rfc-2795 ] ) are not supported.
123120
@@ -339,7 +336,7 @@ r[asm.operand-type.supported-operands.sym]
339336# #[cfg(target_arch = " x86_64" )] {
340337 // swizzle [0, 1, 2, 3] => [3, 2, 0, 1]
341338 const SHUFFLE : u8 = 0b01_00_10_11 ;
342- let x : core :: arch :: x86_64 :: __m128 = unsafe { core :: mem :: transmute ([0u32 , 1u32 , 2u32 , 3u32 ]) };
339+ let x : core :: arch :: x86_64 :: __m128 = unsafe { core :: mem :: transmute ([0u32 , 1u32 , 2u32 , 3u32 ]) };
343340 let y : core :: arch :: x86_64 :: __m128 ;
344341 // Pass a constant value into an instruction that expects an immediate like `pshufd`
345342 unsafe { core :: arch :: asm! (" pshufd {xmm}, {xmm}, {shuffle}" , xmm = inlateout (xmm_reg ) x => y , shuffle = const SHUFFLE ); }
@@ -371,7 +368,7 @@ let x = 5;
371368
372369// register operands aren't allowed, since we aren't in a function
373370# #[cfg(target_arch = "x86_64")]
374- core::arch::global_asm!("", in(reg) 5);
371+ core::arch::global_asm!("", in(reg) 5);
375372
376373# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
377374```
@@ -423,7 +420,6 @@ It is a compile-time error to use the same explicit register for two input opera
423420# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
424421```
425422
426-
427423r[ asm.register-operands.error-overlapping]
428424Additionally, it is also a compile-time error to use overlapping registers (e.g. ARM VFP) in input operands or in output operands.
429425
@@ -771,7 +767,6 @@ Only one modifier is allowed per template placeholder.
771767# #[cfg(not(target_arch = "x86_64"))] core::compile_error!("Test not supported on this arch");
772768```
773769
774-
775770r[ asm.template-modifiers.supported-modifiers]
776771The 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.
777772
@@ -954,10 +949,10 @@ r[asm.options.supported-options.nomem]
954949 let z: i32;
955950 // Accessing memory from a nomem asm block is disallowed
956951 unsafe { core::arch::asm!("mov {val:e}, dword ptr [{ptr}]", ptr = in(reg) &mut x, val = lateout(reg) z, options(nomem))}
957-
952+
958953 // Writing to memory is also undefined behaviour
959954 unsafe { core::arch::asm!("mov dword ptr [{ptr}], {val:e}", ptr = in(reg) &mut x, val = in(reg) z, options(nomem))}
960- # }
955+ # }
961956```
962957
963958``` rust
@@ -971,7 +966,6 @@ r[asm.options.supported-options.nomem]
971966# }
972967```
973968
974-
975969r[ asm.options.supported-options.readonly]
976970- ` readonly ` : The ` asm! ` block does not write to any memory accessible outside of the ` asm! ` block.
977971 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! ` .
@@ -983,7 +977,7 @@ r[asm.options.supported-options.readonly]
983977 let mut x = 0;
984978 // We cannot modify memory in readonly
985979 unsafe { core::arch::asm!("mov dword ptr[{}], 1", in(reg) &mut x, options(readonly))}
986- # }
980+ # }
987981```
988982
989983``` rust
@@ -996,7 +990,6 @@ r[asm.options.supported-options.readonly]
996990# }
997991```
998992
999-
1000993``` rust
1001994# #[cfg(target_arch = " x86_64" )] {
1002995 let x : i64 = 0 ;
@@ -1205,19 +1198,19 @@ pub fn fadd(x: f64, y: f64) -> f64{
12051198 let mut top = 0u16 ;
12061199 // we can do complex stuff with x87 if we clobber the entire x87 stack
12071200 unsafe { core :: arch :: asm! (
1208- " fld qword ptr [{x}]" ,
1209- " fld qword ptr [{y}])" ,
1210- " faddp" ,
1211- " fstp qword ptr [{out}]" ,
1201+ " fld qword ptr [{x}]" ,
1202+ " fld qword ptr [{y}])" ,
1203+ " faddp" ,
1204+ " fstp qword ptr [{out}]" ,
12121205 " xor eax, eax" ,
12131206 " fstsw ax" ,
12141207 " shl eax, 11" ,
1215- x = in (reg ) & x ,
1216- y = in (reg ) & y ,
1208+ x = in (reg ) & x ,
1209+ y = in (reg ) & y ,
12171210 out = in (reg ) & mut out ,
1218- out (" st(0)" ) _ , out (" st(1)" ) _ , out (" st(2)" ) _ , out (" st(3)" ) _ ,
1211+ out (" st(0)" ) _ , out (" st(1)" ) _ , out (" st(2)" ) _ , out (" st(3)" ) _ ,
12191212 out (" st(4)" ) _ , out (" st(5)" ) _ , out (" st(6)" ) _ , out (" st(7)" ) _ ,
1220- out (" eax" ) top
1213+ out (" eax" ) top
12211214 );}
12221215
12231216 assert_eq! (top & 0x7 , 0 );
@@ -1367,7 +1360,6 @@ r[asm.target-specific-directives.dwarf-unwinding]
13671360
13681361The following directives are supported on ELF targets that support DWARF unwind info:
13691362
1370-
13711363- ` .cfi_adjust_cfa_offset `
13721364- ` .cfi_def_cfa `
13731365- ` .cfi_def_cfa_offset `
@@ -1390,7 +1382,6 @@ The following directives are supported on ELF targets that support DWARF unwind
13901382- ` .cfi_undefined `
13911383- ` .cfi_window_save `
13921384
1393-
13941385r[ asm.target-specific-directives.structured-exception-handling]
13951386##### Structured Exception Handling
13961387
@@ -1404,7 +1395,6 @@ On targets with structured exception Handling, the following additional directiv
14041395- ` .seh_setframe `
14051396- ` .seh_stackalloc `
14061397
1407-
14081398r[ asm.target-specific-directives.x86]
14091399##### x86 (32-bit and 64-bit)
14101400
@@ -1414,12 +1404,9 @@ On x86 targets, both 32-bit and 64-bit, the following additional directives are
14141404- ` .code32 `
14151405- ` .code64 `
14161406
1417-
14181407Use of ` .code16 ` , ` .code32 ` , and ` .code64 ` directives are only supported if the state is reset to the default before exiting the assembly block.
1419140832-bit x86 uses ` .code32 ` by default, and x86_64 uses ` .code64 ` by default.
14201409
1421-
1422-
14231410r[ asm.target-specific-directives.arm-32-bit]
14241411##### ARM (32-bit)
14251412
0 commit comments