Skip to content

Commit 54ac0a2

Browse files
committed
Add Tag_RISCV_mop_and_hint_encoding for instruction reinterpretation
Various RISC-V extensions reuse existing instruction encoding spaces for specialized behaviors. CFI extensions use NOP or MOP (Maybe Operation) instructions to ensure correct program execution even when hardware doesn't implement CFI. Similarly, hint extensions redefine specific encodings for performance optimization purposes. However, this design conflicts with current toolchain conventions, where X extension instructions are only usable when the X extension is enabled: assemblers accept corresponding mnemonics and disassemblers decode instructions only when the extension is active. The affected use cases require different behavior: - Zicfiss instructions should be available when Zimop extension is present - Zicfilp instructions should be usable even without explicit enabling (since auipc is in baseline ISA) - Hint extensions should reinterpret specific encodings regardless of extension enablement Following conventional toolchain behavior would force compilers to generate generic instructions ('mop', 'fence w,0', 'auipc x0, <value>') instead of extension-specific mnemonics ('sspush/sspop', 'pause', 'lpad <value>'), causing user confusion and reducing code clarity. While this could be addressed at the ISA specification level, such changes involve complex and time-consuming procedures. Therefore, this psABI defines Tag_RISCV_mop_and_hint_encoding to provide toolchain implementations with clear guidance. This tag uses a bitmap format where each bit indicates whether specific instruction encodings should be reinterpreted: - Bit 0: auipc x0, <value> as lpad <value> (Zicfilp) - Bit 1: Zimop encodings as Zicfiss instructions - Bit 2: fence w,0 as pause hints (Zihintpause) - Bit 3: specific encodings as non-temporal locality hints (Zihintntl) The tag uses bitwise OR merge policy to allow combining multiple reinterpretation requirements, with toolchain warnings recommended when encoding space conflicts occur.
1 parent 712449f commit 54ac0a2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

riscv-elf.adoc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,7 @@ non-standard ABI extensions.
12721272
| Tag_RISCV_priv_spec_revision | 12 | uleb128 | *Deprecated*, indicates the revision version of the privileged specification.
12731273
| Tag_RISCV_atomic_abi | 14 | uleb128 | Indicates which version of the atomics ABI is being used.
12741274
| Tag_RISCV_x3_reg_usage | 16 | uleb128 | Indicates the usage definition of the X3 register.
1275+
| Tag_RISCV_mop_and_hint_encoding | 18 | uleb128 | Indicates the reinterpretation of MOP and hint instruction encodings.
12751276
| Reserved for non-standard attribute | >= 32768 | - | -
12761277
|===
12771278

@@ -1437,6 +1438,34 @@ value. After the merge, the resulting value will be the non-zero one.
14371438

14381439
--
14391440

1441+
===== Tag_RISCV_mop_and_hint_encoding, 18, uleb128=value
1442+
1443+
Tag_RISCV_mop_and_hint_encoding indicates the reinterpretation of MOP (Maybe Operation)
1444+
and hint instruction encodings within this object. The value is a bitmap where each bit
1445+
indicates whether specific instruction encodings should be reinterpreted:
1446+
1447+
[horizontal]
1448+
Bit 0 (Zicfilp):: When set, `auipc x0, <value>` instructions are interpreted as `lpad <value>`.
1449+
Bit 1 (Zicfiss):: When set, Zimop encoding space instructions are interpreted as Zicfiss instructions.
1450+
Bit 2 (Zihintpause):: When set, `fence w,0` instructions are interpreted as `pause` hints.
1451+
Bit 3 (Zihintntl):: When set, specific instruction encodings are interpreted as non-temporal locality hints.
1452+
1453+
--
1454+
1455+
Merge policy:::
1456+
Values are merged using bitwise OR operation.
1457+
1458+
NOTE: The bitwise OR merge policy may cause disassembler confusion when the same encoding
1459+
space is redefined by multiple bits. Toolchains may report warnings to alert users
1460+
when such conflicts occur.
1461+
1462+
--
1463+
1464+
NOTE: When specific bits are set, toolchains must disassemble instructions according to
1465+
the corresponding extensions regardless of whether these extensions are enabled. For example,
1466+
if bit 0 is set, `auipc x0, <value>` must be disassembled as `lpad <value>`; if bit 1 is
1467+
set, Zimop encodings must be disassembled as Zicfiss instructions.
1468+
14401469
=== Program Property
14411470

14421471
Program properties are used to record information about an object file or binary

0 commit comments

Comments
 (0)