Skip to content

Commit 3c47807

Browse files
authored
Merge pull request #1323 from Amanieu/asm-order
Relax ordering rules for `asm!` operands
2 parents 76f771b + 7b6a860 commit 3c47807

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/inline-assembly.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ format_string := STRING_LITERAL / RAW_STRING_LITERAL
4343
dir_spec := "in" / "out" / "lateout" / "inout" / "inlateout"
4444
reg_spec := <register class> / "\"" <explicit register> "\""
4545
operand_expr := expr / "_" / expr "=>" expr / expr "=>" "_"
46-
reg_operand := dir_spec "(" reg_spec ")" operand_expr
47-
operand := reg_operand
46+
reg_operand := [ident "="] dir_spec "(" reg_spec ")" operand_expr
4847
clobber_abi := "clobber_abi(" <abi> *("," <abi>) [","] ")"
4948
option := "pure" / "nomem" / "readonly" / "preserves_flags" / "noreturn" / "nostack" / "att_syntax" / "raw"
5049
options := "options(" option *("," option) [","] ")"
51-
asm := "asm!(" format_string *("," format_string) *("," [ident "="] operand) *("," clobber_abi) *("," options) [","] ")"
52-
global_asm := "global_asm!(" format_string *("," format_string) *("," [ident "="] operand) *("," options) [","] ")"
50+
operand := reg_operand / clobber_abi / options
51+
asm := "asm!(" format_string *("," format_string) *("," operand) [","] ")"
52+
global_asm := "global_asm!(" format_string *("," format_string) *("," operand) [","] ")"
5353
```
5454

5555

@@ -74,8 +74,7 @@ An `asm!` invocation may have one or more template string arguments; an `asm!` w
7474
The expected usage is for each template string argument to correspond to a line of assembly code.
7575
All template string arguments must appear before any other arguments.
7676

77-
As with format strings, named arguments must appear after positional arguments.
78-
Explicit [register operands](#register-operands) must appear at the end of the operand list, after named arguments if any.
77+
As with format strings, positional arguments must appear before named arguments and explicit [register operands](#register-operands).
7978

8079
Explicit register operands cannot be used by placeholders in the template string.
8180
All other named and positional operands must appear at least once in the template string, otherwise a compiler error is generated.

0 commit comments

Comments
 (0)