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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/inline-assembly.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following ABNF specifies the general syntax:
```text
format_string := STRING_LITERAL / RAW_STRING_LITERAL
dir_spec := "in" / "out" / "lateout" / "inout" / "inlateout"
reg_spec := <register class> / "<explicit register>"
reg_spec := <register class> / "\"" <explicit register> "\""
operand_expr := expr / "_" / expr "=>" expr / expr "=>" "_"
reg_operand := dir_spec "(" reg_spec ")" operand_expr
operand := reg_operand
Expand Down Expand Up @@ -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.

> - Some register classes are marked as "Only clobbers" which means that registers in these classes cannot be used for inputs or outputs, only clobbers of the form `out(<explicit register>) _` or `lateout(<explicit register>) _`.

Each register class has constraints on which value types they can be used with.
This is necessary because the way a value is loaded into a register depends on its type.
Expand Down Expand Up @@ -356,7 +356,7 @@ If all references to an operand already have modifiers then the warning is suppr
## ABI clobbers

The `clobber_abi` keyword can be used to apply a default set of clobbers to an `asm!` block.
This will automatically insert the necessary clobber constraints as needed for calling a function with a particular calling convention: if the calling convention does not fully preserve the value of a register across a call then a `lateout("reg") _` is implicitly added to the operands list.
This will automatically insert the necessary clobber constraints as needed for calling a function with a particular calling convention: if the calling convention does not fully preserve the value of a register across a call then `lateout("...") _` is implicitly added to the operands list (where the `...` is replaced by the register's name).

`clobber_abi` may be specified any number of times. It will insert a clobber for all unique registers in the union of all specified calling conventions.

Expand Down