You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `pure` option must be combined with either the `nomem` or `readonly` options, otherwise a compile-time error is emitted.
537
539
538
540
r[asm.options.supported-options.nomem]
539
-
-`nomem`: The `asm!` block does not read from or write to any memory accessible outside of the `asm!` block.
541
+
542
+
-`nomem`: The `asm!` blocks does not read or write to any memory.
543
+
540
544
This allows the compiler to cache the values of modified global variables in registers across the `asm!` block since it knows that they are not read or written to by the `asm!`.
541
545
The compiler also assumes that this `asm!` block does not perform any kind of synchronization with other threads, e.g. via fences.
542
546
543
547
r[asm.options.supported-options.readonly]
544
-
-`readonly`: The `asm!` block does not write to any memory accessible outside of the `asm!` block.
548
+
549
+
-`readonly`: The `asm!` block does not write to any memory.
550
+
545
551
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!`.
546
552
The compiler also assumes that this `asm!` block does not perform any kind of synchronization with other threads, e.g. via fences.
- On x86, the direction flag (DF in `EFLAGS`) is clear on entry to an asm block and must be clear on exit.
@@ -666,8 +672,6 @@ r[asm.rules.x86-x87]
666
672
- On x86, the x87 floating-point register stack must remain unchanged unless all of the `st([0-7])` registers have been marked as clobbered with `out("st(0)") _, out("st(1)") _, ...`.
667
673
- If all x87 registers are clobbered then the x87 register stack is guaranteed to be empty upon entering an `asm` block. Assembly code must ensure that the x87 register stack is also empty when exiting the asm block.
668
674
669
-
r[asm.rules.arm64ec]
670
-
- On arm64ec, [call checkers with appropriate thunks](https://learn.microsoft.com/en-us/windows/arm/arm64ec-abi#authoring-arm64ec-in-assembly) are mandatory when calling functions.
671
675
672
676
r[asm.rules.only-on-exit]
673
677
- The requirement of restoring the stack pointer and non-output registers to their original value only applies when exiting an `asm!` block.
Copy file name to clipboardExpand all lines: src/tokens.md
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -243,6 +243,16 @@ the characters `U+0022` (double-quote) (except when followed by at least as
243
243
many `U+0023` (`#`) characters as were used to start the raw string literal) or
244
244
`U+005C` (`\`) do not have any special meaning.
245
245
246
+
**Note that this is a _context-sensitive_ grammar, as opposed to _context-free_.**
247
+
This is because strings like `r###"I contain only 2 "##s so I'm ok"###` require
248
+
a parser to properly count the number of opening #'s and compare that count to two
249
+
different values. In practical terms this is very easy for a parser to do, but
250
+
a context-free language can't because the only way to express "counting" is
251
+
as a destructive operation which forces you to forget the count. This allows
252
+
for the "comparison" of two counts (such (as (balanced) (parens))) but not 3+.
253
+
254
+
See [the proof for more formal details](https://github.com/rust-lang/rust/blob/5187be620c76a313a19b9b596e1bce3a80a345dd/src/grammar/raw-string-literal-ambiguity.md).
0 commit comments