diff --git a/src/changelog.rst b/src/changelog.rst index 87ebd213..3c86710d 100644 --- a/src/changelog.rst +++ b/src/changelog.rst @@ -35,6 +35,16 @@ Language changes in Rust 1.93.0 - No change: this bug was not documented in FLS - `Stabilize asm_cfg `_ + + - Changed syntax: :s:`AssemblyCodeBlock`, :s:`AsmArguments`, :s:`GlobalAsmArguments` + - New syntax: :s:`AssemblyTemplate`, :s:`AssemblyAttributeRegisterArgument`, :s:`AssemblyAttributeAbiClobber`, :s:`AssemblyAttributeAssemblyOption` + + - New paragraphs: + + - :p:`fls_nLBhw2w6uznH` + - :p:`fls_xzDPz2zfRfoI` + - :p:`fls_cTEiqjf6haEg` + - `During const-evaluation, support copying pointers byte-by-byte `_ * No change: Already covered by the classification of :t:`[constant expression]s`. diff --git a/src/inline-assembly.rst b/src/inline-assembly.rst index b54cb9c0..878d3c16 100644 --- a/src/inline-assembly.rst +++ b/src/inline-assembly.rst @@ -963,7 +963,10 @@ Assembly Instructions .. syntax:: AssemblyCodeBlock ::= - AssemblyInstruction ($$,$$ AssemblyInstruction)* + AssemblyTemplate ($$,$$ AssemblyTemplate)* + + AssemblyTemplate ::= + OuterAttribute* AssemblyInstruction AssemblyInstruction ::= StringLiteral @@ -1625,10 +1628,19 @@ Macros: asm, global_asm, and naked_asm .. syntax:: AsmArguments ::= - $$($$ AssemblyCodeBlock ($$,$$ LabelBlock)? ($$,$$ RegisterArgument)* ($$,$$ AbiClobber)* ($$,$$ AssemblyOption)* $$,$$? $$)$$ + $$($$ AssemblyCodeBlock ($$,$$ LabelBlock)? ($$,$$ AssemblyAttributeRegisterArgument)* ($$,$$ AssemblyAttributeAbiClobber)* ($$,$$ AssemblyAttributeAssemblyOption)* $$,$$? $$)$$ GlobalAsmArguments ::= - $$($$ AssemblyCodeBlock ($$,$$ RegisterArgument)* ($$,$$ AssemblyOption)* $$,$$? $$)$$ + $$($$ AssemblyCodeBlock ($$,$$ AssemblyAttributeRegisterArgument)* ($$,$$ AssemblyAttributeAssemblyOption)* $$,$$? $$)$$ + + AssemblyAttributeRegisterArgument ::= + OuterAttribute* RegisterArgument + + AssemblyAttributeAbiClobber ::= + OuterAttribute* AbiClobber + + AssemblyAttributeAssemblyOption ::= + OuterAttribute* AssemblyOption LabelBlock ::= $$block$$ $${$$ StatementList $$}$$ @@ -1641,6 +1653,15 @@ Macros: asm, global_asm, and naked_asm :std:`core::arch::global_asm`, and :std:`core::arch::naked_asm`. +:dp:`fls_nLBhw2w6uznH` +Only :t:`attribute` :c:`cfg` and :t:`attribute` :c:`cfg_attr` shall decorate :t:`[assembly instruction]s`, :t:`[register argument]s`, :t:`[ABI clobber]s`, and :t:`[assembly option]s` in :s:`AsmArguments` and :s:`GlobalAsmArguments`; all other :t:`[attribute]s` shall be rejected. + +:dp:`fls_xzDPz2zfRfoI` +If a :t:`assembly instruction`, :t:`register argument`, :t:`ABI clobber`, or :t:`assembly option` in :s:`AsmArguments` or :s:`GlobalAsmArguments` is subject to :t:`attribute` :c:`cfg` or :t:`attribute` :c:`cfg_attr` where the related :t:`configuration predicate` evaluates to ``false``, then that construct is not considered part of the related :s:`AsmArguments` or :s:`GlobalAsmArguments`, consistent with :t:`conditional compilation`. + +:dp:`fls_cTEiqjf6haEg` +It is a static error for a :t:`register argument`, :t:`ABI clobber`, or :t:`assembly option` to appear before the first :t:`assembly instruction`, including when that construct is subject to :t:`attribute` :c:`cfg` or :t:`attribute` :c:`cfg_attr` where the related :t:`configuration predicate` evaluates to ``false``. + :dp:`fls_1ikzov7cxic1` When invoking :t:`macro` :std:`core::arch::asm`, the :s:`DelimitedTokenTree` of the related :t:`macro invocation` shall follow the syntax of :s:`AsmArguments`. @@ -1698,6 +1719,20 @@ The :t:`execution` of an :t:`assembly code block` produced by .. rubric:: Examples +.. code-block:: rust + + unsafe { + core::arch::asm!( + "nop", + #[cfg(target_feature = "sse2")] + "nop", + #[cfg(target_feature = "sse2")] + in(reg) 0_u32, + #[cfg(target_feature = "sse2")] + options(nomem, nostack), + ); + } + .. code-block:: rust fn asm_example() -> u32 {