Skip to content

Commit b8d2c58

Browse files
authored
Merge pull request #1270 from Amanieu/asm-sym
Add `sym` operands for inline assembly
2 parents 8104645 + b00444a commit b8d2c58

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/inline-assembly.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,17 @@ Several types of operands are supported:
123123
* `inlateout(<reg>) <expr>` / `inlateout(<reg>) <in expr> => <out expr>`
124124
- Identical to `inout` except that the register allocator can reuse a register allocated to an `in` (this can happen if the compiler knows the `in` has the same initial value as the `inlateout`).
125125
- You should only write to the register after all inputs are read, otherwise you may clobber an input.
126+
* `sym <path>`
127+
- `<path>` must refer to a `fn` or `static`.
128+
- A mangled symbol name referring to the item is substituted into the asm template string.
129+
- The substituted string does not include any modifiers (e.g. GOT, PLT, relocations, etc).
130+
- `<path>` is allowed to point to a `#[thread_local]` static, in which case the asm code can combine the symbol with relocations (e.g. `@plt`, `@TPOFF`) to read from thread-local data.
126131

127132
Operand expressions are evaluated from left to right, just like function call arguments.
128133
After the `asm!` has executed, outputs are written to in left to right order.
129134
This is significant if two outputs point to the same place: that place will contain the value of the rightmost output.
130135

131-
Since `global_asm!` exists outside a function, it cannot use input/output operands.
136+
Since `global_asm!` exists outside a function, it can only use `sym` operands.
132137

133138
## Register operands
134139

0 commit comments

Comments
 (0)