Skip to content

Commit 45f02d4

Browse files
committed
Inline Asm Constraints and Modifiers
We have customers with usecases that want more kinds of register constraints and modifiers. This change proposes support for these constraints and modifiers, and their names. Broadly, these are intended to make it easier for users who want to manually assemble instructions inside inline assembly blocks, either using the existing instruction formats, or using the raw form of the `.insn` directive. This makes it easier for hardware designers to experiment on new ISA extensions, and makes it easier to support the use of proprietary extensions with unmodified open-source toolchains. There are three groups of additions here: - Constraints for RVC-compatible registers. These use the `c` prefix on an existing register constraint, so `cr` gives a GPR between x8-x15, and `cf` does the same for an FPR between f8-f15. I'm not aware of compressed vector instructions, but we could add `cvr`, `cvd` and `cvm` in the future if the core architecture ends up having the concept of a vector register with an RVC encoding. - A modifier, `N`, to print the raw encoding of a register. This is used when using `.insn <length>, <encoding>`, where the user wants to pass a value to the instruction in a known register, but where the instruction doesn't follow the existing instruction formats, so the assembly parser is not expecting a register name, just a raw integer. - Constraints for even-odd pairs of registers. These use the `P` prefix on an existing register constraint. At the moment, this only defines `Pr` to mean an even-odd pair of GPRs. (We use `P` as a prefix as `p` already means "pointer" in GCC's target-independent constraints). I think this will print as the even register in the even-odd register pair, but I'm still working on the details around this. While the concept of even-odd register pairs is reasonably "new", there are places in the architecture where these already exist - the doubleword/quad CAS in Zacas, and they are also present in the Zilsd specification. Signed-off-by: Sam Elliott <quic_aelliott@quicinc.com>
1 parent 8b41934 commit 45f02d4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/c-api.adoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,13 +746,18 @@ statements, including both RISC-V specific and common operand constraints.
746746
|K |5-bit unsigned immediate integer operand |
747747
|J |Zero integer immediate operand |
748748
|s |symbol or label reference with a constant offset |
749+
|cr |RVC general purpose register (`x8`-`x15`) |
750+
|cf |RVC floating point register (`f8`-`f15`) |
751+
|Pr |Even-odd general purpose register pair |
749752
|vr |Vector register |
750753
|vd |Vector register, excluding v0 |
751754
|vm |Vector register, only v0 |
752755
|===
753756

754757
NOTE: Immediate value must be a compile-time constant.
755758

759+
NOTE: The `c*` and `P*` constraints are designed to be extensible to more kinds of registers in the future.
760+
756761
=== The Difference Between `m` and `A` Constraints
757762

758763
The difference between `m` and `A` is whether the operand can have an offset;
@@ -809,6 +814,7 @@ statements, including both RISC-V specific and common operand modifiers.
809814
|*Modifiers* |*Description* |*Note*
810815
|z |Print `zero` (`x0`) register for immediate 0, typically used with constraints `J` |
811816
|i |Print `i` if corresponding operand is immediate. |
817+
|N |Print register encoding as integer (0-31). |
812818
|===
813819

814820
[id=function-multi-version]

0 commit comments

Comments
 (0)