Skip to content

Commit a5b23db

Browse files
Merge branch 'Gankra-patch-1' into master
2 parents ad51135 + af118ad commit a5b23db

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/inline-assembly.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ After the `asm!` has executed, outputs are written to in left to right order.
186186
This is significant if two outputs point to the same place: that place will contain the value of the rightmost output.
187187

188188
r[asm.operand-type.global_asm-restriction]
189-
Since `global_asm!` exists outside a function, it can only use `sym` and `const` operands.
189+
190+
Since `global_asm!` exists outside a function, it can only use `sym` operands.
191+
190192

191193
## Register operands
192194

@@ -536,12 +538,16 @@ r[asm.options.supported-options.pure]
536538
The `pure` option must be combined with either the `nomem` or `readonly` options, otherwise a compile-time error is emitted.
537539

538540
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+
540544
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!`.
541545
The compiler also assumes that this `asm!` block does not perform any kind of synchronization with other threads, e.g. via fences.
542546

543547
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+
545551
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!`.
546552
The compiler also assumes that this `asm!` block does not perform any kind of synchronization with other threads, e.g. via fences.
547553

@@ -655,8 +661,8 @@ r[asm.rules.preserved-registers]
655661
- Vector extension state (`vtype`, `vl`, `vcsr`).
656662
- LoongArch
657663
- Floating-point condition flags in `$fcc[0-7]`.
658-
- s390x
659-
- The condition code register `cc`.
664+
665+
660666

661667
r[asm.rules.x86-df]
662668
- 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]
666672
- 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)") _, ...`.
667673
- 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.
668674

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.
671675

672676
r[asm.rules.only-on-exit]
673677
- The requirement of restoring the stack pointer and non-output registers to their original value only applies when exiting an `asm!` block.

src/tokens.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ the characters `U+0022` (double-quote) (except when followed by at least as
243243
many `U+0023` (`#`) characters as were used to start the raw string literal) or
244244
`U+005C` (`\`) do not have any special meaning.
245245

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).
255+
246256
Examples for string literals:
247257

248258
```rust

0 commit comments

Comments
 (0)