Custom instruction directives
Syntax
.insnformat, {op2|op7},operands
Parameters
| The instruction format of the generated custom instruction. See the table Custom assembler instructions below. |
| An unsigned immediate value for either 2-bit or 7-bit operation code, depending on the instruction format. |
| Depending on the instruction format, these can be:
|
Description
These directives generate custom instructions not directly supported by the IAR Assembler for RISC-V. All RISC-V instruction formats are supported.
A custom instruction directive can be used with inline assembler in applications written in C or C++. In combination with an inline function, you can create an intrinsic-like function to use custom architecture extensions.
The bits for immediate values in compressed instructions (16-bit RVC) generally have an instruction-specific format that can differ even for instructions of the same type. All immediate values are copied directly into the bitfield—no rearrangements are performed, unless operators (like %hi) or relocations (see below) are used.
Some of the instructions allow relaxations to be performed by the linker. This can be disabled using the .option norelax directive.
These are the required operands for each instruction format:
Assembler instruction | Relaxed by linker | Resulting instruction format |
|---|---|---|
.insn b | — | Alias for |
.insn ca | — | CA |
.insn cb | — | CB |
.insn ci | — | CI |
.insn ciw | — | CIW |
.insn cj | — | CJ with |
.insn cr | — | CR |
.insn cs | — | CS |
.insn i | — | I, with relocations depending on |
.insn i | — | I, with relocations like |
.insn r | — | R |
.insn r | — | Alias for |
.insn r4 | — | R4 |
.insn s | If | S, with relocations like |
.insn sb | — | B, with |
.insn sb | — | Alias for |
.insn u | If | U, with relocations like |
.insn uj | — | J, with |
Refer to the RISC-V ISA specification, sections 2.3 and 12.2, for details on bit layout.
The operating code (op2/op7) can be supplied as an assembler constant expression, or as one of:
Operation code | Value |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|