Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline assembly: Clarify references to quoted regs #1191

Merged
merged 2 commits into from
May 20, 2022
Merged

Inline assembly: Clarify references to quoted regs #1191

merged 2 commits into from
May 20, 2022

Conversation

fw-immunant
Copy link
Contributor

For lateout and similar operand direction specifiers, a quoted argument must be an explicit register name, per the EBNF grammar we give. As such, we should not use quotes when describing syntax used with register classes.

Further, correct the EBNF: in EBNF, quoted strings are always terminals, but "<explicit register>" is intended to be a nonterminal surrounded by literal (terminal) quotation marks. Moving the quotes to their own terminal symbols does require escaping, but makes the terminal/nonterminal distinction clearer. The only other place double-quotes are present in the grammar is inside STRING_LITERAL/RAW_STRING_LITERAL, so calling attention to this case is worthwhile for clarity.

For `lateout` and similar operand direction specifiers, a quoted argument must be an explicit register name, per the EBNF grammar we give. As such, we should not use quotes when describing syntax used with register classes.

Further, correct the EBNF: in EBNF, quoted strings are always terminals, but `"<explicit register>"` is intended to be a nonterminal surrounded by literal (terminal) quotation marks. Moving the quotes to their own terminal symbols does require escaping, but makes the terminal/nonterminal distinction clearer. The only other place double-quotes are present in the grammar is inside `STRING_LITERAL`/`RAW_STRING_LITERAL`, so calling attention to this case is worthwhile for clarity.
@ehuss
Copy link
Contributor

ehuss commented May 20, 2022

This looks good to me. @Amanieu do you perhaps have any comments?

@ehuss ehuss added the A-asm Area: inline assembly label May 20, 2022
@@ -184,7 +184,7 @@ Here is the list of currently supported register classes:
>
> - On x86-64 the high byte registers (e.g. `ah`) are not available in the `reg_byte` register class.
>
> - Some register classes are marked as "Only clobbers" which means that they cannot be used for inputs or outputs, only clobbers of the form `out("reg") _` or `lateout("reg") _`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is incorrect: clobber-only registers can only be used with explicit registers, not register classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was misled by the usage of 'reg' here, because 'reg' itself is the name of a register class, so I took this to be naming one register class in a place where any register class was valid. If this is an explicit register name, we should say:

`out(<explicit register>) _` or `lateout(<explicit register>) _`, (for example, `lateout("rax") _`).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Committed a change that hopefully clarifies this.

src/inline-assembly.md Outdated Show resolved Hide resolved
Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ehuss ehuss merged commit b74825d into rust-lang:master May 20, 2022
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 25, 2022
Update books

## reference

6 commits in 8e36971959ff238b5aa2575fbc7a2e09e1313e82..b74825d8f88b685e239ade00f00de68ba4cd63d4
2022-05-09 17:20:59 -0700 to 2022-05-20 14:30:30 -0700
- Inline assembly: Clarify references to quoted regs (rust-lang/reference#1191)
- Add tile registers to inline-assembly documentation (rust-lang/reference#1220)
- Upper bound on hashes in raw string literals (rust-lang/reference#1180)
- Remove footnote on warning about lifetime shadowing labels.
- Makes explanation for Spans in "Procedural Macros" clearer (rust-lang/reference#1219)
- Update "Match Expressions" to remove 'cold' (rust-lang/reference#1216)

## book

18 commits in d9415b7cbfcb4b24062683f429bd0ff535396362..b4dd5f00b87190ad5ef42cbc2a88a783c6ae57ef
2022-05-09 09:10:44 -0400 to 2022-05-24 21:37:06 -0400
- Snapshot of appendices for nostarch
- Update rust-analyzer URLs and make links less repetitive
- Correct byte string literal type. Fixes rust-lang/book#2631.
- Fix verb agreement. Fixes rust-lang/book#3176
- Propagate ch19 edits to src
- Edits to chapter 19 from nostarch
- Propagate ch18 edits to src
- Edits to ch18 from nostarch
- Propagate tech review edits to src ch5
- Responses to chapter 5 tech review
- Ch5 after tech review
- Merge branch 'ch7-edits'
- fix: mdBook authors
- Propagating ch17 edits to src
- Edits from nostarch for ch17
- Fix rust-lang/book#3152 - Wrong character used
- & is not valid inside image alt text
- Merge branch 'ch20'

## rust-by-example

2 commits in e9f93cfcf410bc092c9107b8a41a82f144c761f2..2ed26865e8c29ef939dc913a97bd321cadd72a9a
2022-05-08 18:24:06 -0300 to 2022-05-18 17:23:47 -0300
- Rework cpuid asm example. (rust-lang/rust-by-example#1542)
- chore: better description for eprint macro (rust-lang/rust-by-example#1541)

## rustc-dev-guide

11 commits in 0c02acdb6f48f03907a02ea8e537c3272b4fde9f..554c00e4805df7f7bffac7db408437d62d6dfb9a
2022-05-10 09:45:31 -0300 to 2022-05-24 17:15:35 -0700
- Cleanup rustdoc-internals
- Fix some wording on the "Incremental Compilation In Detail" page
- Exclude `tomlee.co` from link-checking (rust-lang/rustc-dev-guide#1356)
- Add note about patching dependencies and warnings. (rust-lang/rustc-dev-guide#1354)
- make sentence more simple (rust-lang/rustc-dev-guide#1353)
- Update some links and docs (rust-lang/rustc-dev-guide#1340)
- Replace a broken YouTube link (rust-lang/rustc-dev-guide#1295)
- Edit the "Compiler Source Code" chapter (rust-lang/rustc-dev-guide#1307)
- Add docs for logging of queries. (rust-lang/rustc-dev-guide#1350)
- Fix configuration names for vscode/r-a (rust-lang/rustc-dev-guide#1352)
- Update docs for deprecated attribute (rust-lang/rustc-dev-guide#1338)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-asm Area: inline assembly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants