Skip to content

Commit 6c42a1f

Browse files
authored
Merge pull request riscv-non-isa#92 from lenary/pr/inline-asm
Inline Asm Constraints and Modifiers - RVC, Raw Encodings, Pairs
2 parents 00cd189 + e693b8c commit 6c42a1f

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/c-api.adoc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,17 @@ Sign extension of 32-bit values on RV64 is not reflected in the interface.
732732

733733
This section lists operand constraints that can be used with inline assembly
734734
statements, including both RISC-V specific and common operand constraints.
735+
Operand constraints are case-sensitive.
736+
737+
"Floating-point register" in both the `f` and `cf` rows means "a register
738+
suitable for passing a floating-point value", so when using the `Zfinx`,
739+
`Zdinx`, or `Zhinxmin` extensions this will allocate an X register. This is done
740+
to aid portability of floating-point code.
735741

736742
.Constraints on Operands of Inline Assembly Statements
737743
[%autowidth]
738744
|===
739-
|*Constraint* | |*Note*
745+
|*Constraint* |*Description* |*Note*
740746
|m |An address that is held in a general-purpose register with offset. |
741747
|A |An address that is held in a general-purpose register. |
742748
|r |General purpose register |
@@ -746,13 +752,25 @@ statements, including both RISC-V specific and common operand constraints.
746752
|K |5-bit unsigned immediate integer operand |
747753
|J |Zero integer immediate operand |
748754
|s |symbol or label reference with a constant offset |
755+
|cr |RVC general purpose register (`x8`-`x15`) |
756+
|cf |RVC floating-point register (`f8`-`f15` or `x8-x15` with `Zfinx`) |
757+
|R |Even-odd general purpose register pair |
749758
|vr |Vector register |
750759
|vd |Vector register, excluding v0 |
751760
|vm |Vector register, only v0 |
752761
|===
753762

763+
The `R` constraint should print as the even register in the pair, as this
764+
matches how the `amocas.q` instruction (on RV64) or the `amocas.d` and `Zdinx`
765+
instructions (on RV32) expect to parse their pair register operands. However,
766+
both registers in the pair should be considered to be live or clobbered
767+
together.
768+
754769
NOTE: Immediate value must be a compile-time constant.
755770

771+
NOTE: The `c*` constraints are designed to be extensible to more kinds of
772+
RVC-compatible register constraints in the future.
773+
756774
=== The Difference Between `m` and `A` Constraints
757775

758776
The difference between `m` and `A` is whether the operand can have an offset;
@@ -809,6 +827,7 @@ statements, including both RISC-V specific and common operand modifiers.
809827
|*Modifiers* |*Description* |*Note*
810828
|z |Print `zero` (`x0`) register for immediate 0, typically used with constraints `J` |
811829
|i |Print `i` if corresponding operand is immediate. |
830+
|N |Print register encoding as integer (0-31). |
812831
|===
813832

814833
[id=function-multi-version]

0 commit comments

Comments
 (0)