Skip to content

Commit a630a91

Browse files
committed
feat: add Z{f,d,h}inx{min} extensions, modify check_f_ok for them
* Adds missing *inx* extension skeletons. * Updates the check_f_ok IDL function to look at mstateen0.FCSR instead of mstatus.FS when an *inx* extension is implemented
1 parent cf88b2b commit a630a91

File tree

6 files changed

+167
-16
lines changed

6 files changed

+167
-16
lines changed

arch/ext/Zdinx.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# yaml-language-server: $schema=../../schemas/ext_schema.json
2+
3+
$schema: "ext_schema.json#"
4+
kind: extension
5+
name: Zdinx
6+
long_name: Double-precision floating-point instructions using integer registers
7+
description:
8+
- id: ext-zdinx-instructions
9+
normative: true
10+
text: |
11+
The Zdinx extension adds all of the instructions that the D extension adds, except for the
12+
transfer instructions FLD, FSD, FMV.D.X, FMV.X.D, C.FLD[SP], and C.FSD[SP].
13+
14+
- id: ext-zdinx-semantics
15+
normative: true
16+
text: |
17+
The Zdinx variants of these D-extension instructions have the same semantics, except that whenever
18+
such an instruction would have accessed an f register, it instead accesses the x register with the
19+
same number.
20+
21+
- id: ext-zdinx-rv32regpair
22+
normative: true
23+
text: |
24+
Double-precision operands in RV32Zdinx are held in aligned x-register pairs, i.e., register
25+
numbers must be even. Use of misaligned (odd-numbered) registers for double-width
26+
floating-point operands is reserved.
27+
when(): return MXLEN == 32;
28+
29+
- id: ext-zdinx-rv32endianness
30+
normative: true
31+
text: |
32+
Regardless of endianness, the lower-numbered register holds the low-order bits, and the
33+
higher-numbered register holds the high-order bits: e.g., bits 31:0 of a double-precision
34+
operand in RV32Zdinx might be held in register x14, with bits 63:32 of that operand held
35+
in x15.
36+
when(): return MXLEN == 32;
37+
38+
- id: ext-zdinx-rv32x0
39+
normative: true
40+
text: |
41+
When a double-width floating-point result is written to x0, the entire write takes no effect:
42+
e.g., for RV32Zdinx, writing a double-precision result to x0 does not cause x1 to be written.
43+
when(): return MXLEN == 32;
44+
45+
- id: ext-zdinx-rv32x1
46+
normative: true
47+
text: |
48+
When x0 is used as a double-width floating-point operand, the entire operand is zero—i.e.,
49+
x1 is not accessed.
50+
when(): return MXLEN == 32;
51+
52+
- id: ext-zdinx-rv32mempair
53+
normative: false
54+
text: |
55+
Load-pair and store-pair instructions are not provided, so transferring double-precision
56+
operands in RV32Zdinx from or to memory requires two loads or stores.
57+
Register moves need only a single FSGNJ.D instruction, however.
58+
when(): return MXLEN == 32;
59+
60+
type: unprivileged
61+
versions:
62+
- version: "1.0.0"
63+
state: ratified
64+
ratification_date: 2021-11
65+
requires: Zfinx

arch/ext/Zfinx.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=../../schemas/ext_schema.json
2+
3+
$schema: "ext_schema.json#"
4+
kind: extension
5+
name: Zfinx
6+
long_name: Single-precision floating-point instructions using integer registers
7+
description:
8+
- id: ext-zfinx-instructions
9+
normative: true
10+
text: |
11+
The Zfinx extension adds all of the instructions that the F extension adds, except for the
12+
transfer instructions FLW, FSW, FMV.W.X, FMV.X.W, C.FLW[SP], and C.FSW[SP].
13+
14+
- id: ext-zfinx-semantics
15+
normative: true
16+
text: |
17+
The Zfinx variants of these F-extension instructions have the same semantics, except that
18+
whenever such an instruction would have accessed an f register, it instead accesses the
19+
x register with the same number.
20+
21+
type: unprivileged
22+
versions:
23+
- version: "1.0.0"
24+
state: ratified
25+
ratification_date: 2021-11
26+
requires: Zicsr
27+
conflicts: F

arch/ext/Zhinx.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@ $schema: "ext_schema.json#"
44
kind: extension
55
name: Zhinx
66
long_name: Half-precision floating-point instructions using integer registers
7-
description: |
8-
The Zhinx extension provides analogous half-precision floating-point instructions. The Zhinx extension
9-
depends upon the Zfinx extension.
10-
The Zhinx extension adds all of the instructions that the Zfh extension adds, except for the transfer
11-
instructions FLH, FSH, FMV.H.X, and FMV.X.H.
12-
The Zhinx variants of these Zfh-extension instructions have the same semantics, except that whenever
13-
such an instruction would have accessed an f register, it instead accesses the x register with the same
14-
number.
7+
description:
8+
- id: ext-zhinx-instructions
9+
normative: true
10+
text: |
11+
The Zhinx extension adds all of the instructions that the Zfh extension adds, except for the
12+
transfer instructions FLH, FSH, FMV.H.X, and FMV.X.H.
13+
14+
- id: ext-zhinx-semantics
15+
normative: true
16+
text: |
17+
The Zhinx variants of these Zfh-extension instructions have the same semantics, except that
18+
whenever such an instruction would have accessed an f register, it instead accesses the x
19+
register with the same number.
1520
1621
type: unprivileged
1722
versions:
1823
- version: "1.0.0"
1924
state: ratified
2025
ratification_date: 2021-11
26+
requires: Zfinx

arch/ext/Zhinxmin.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# yaml-language-server: $schema=../../schemas/ext_schema.json
2+
3+
$schema: "ext_schema.json#"
4+
kind: extension
5+
name: Zhinxmin
6+
long_name: Minimal support for half-precision floating-point instructions using integer registers
7+
description:
8+
- id: ext-zhinxmin-instructions
9+
normative: true
10+
text: |
11+
The Zhinxmin extension includes the following instructions from the Zhinx extension:
12+
FCVT.S.H and FCVT.H.S.
13+
when(): return !implemented?(Zdinx);
14+
15+
- id: ext-zhinxmin-instructions-with-zdinx
16+
normative: true
17+
text: |
18+
The Zhinxmin extension includes the following instructions from the Zhinx extension:
19+
FCVT.S.H, FCVT.H.S, FCVT.D.H, and FCVT.H.D.
20+
when(): return implemented?(Zdinx);
21+
22+
type: unprivileged
23+
versions:
24+
- version: "1.0.0"
25+
state: ratified
26+
ratification_date: 2021-11
27+
requires: Zfinx

arch/isa/fp.idl

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,42 @@ function check_f_ok {
125125
arguments
126126
Bits<INSTR_ENC_SIZE> encoding
127127
description {
128-
Checks if instructions from the `F` extension can be executed, and, if not,
128+
Checks if instructions from a floating point extension can be executed, and, if not,
129129
raise an exception.
130130
}
131131
body {
132-
if (MUTABLE_MISA_F && CSR[misa].F == 0) {
133-
raise(ExceptionCode::IllegalInstruction, mode(), encoding);
134-
}
132+
# All Z*inx extensions depend on Zfinx, so we only have to check if Zfinx is implemented
133+
if (implemented?(ExtensionName::Zfinx)) {
134+
# mstateen0.FCSR disables all modes
135+
if (implemented?(ExtensionName::Smstateen) && (CSR[mstateen0].FCSR == 0)) {
136+
raise(ExceptionCode::IllegalInstruction, mode(), enoding);
137+
}
135138

136-
if (CSR[mstatus].FS == 0) {
137-
raise(ExceptionCode::IllegalInstruction, mode(), encoding);
139+
# sstateen0.FCSR disables all modes except M
140+
if (implemented?(ExtensionName::Sstateen) &&
141+
(mode() != PrivilegeMode::M) &&
142+
(CSR[sstateen0].FCSR == 0)) {
143+
raise(ExceptionCode::IllegalInstruction, mode(), enoding);
144+
}
145+
146+
# hstateen0.FCSR disables VS and VU
147+
if (implemented?(ExtensionName::Sstateen) &&
148+
implemented?(ExtensionName::H) &&
149+
(CSR[misa].H == 1) &&
150+
virtual_mode?() &&
151+
(CSR[hstateen0].FCSR == 0)) {
152+
raise(ExceptionCode::IllegalInstruction, mode(), enoding);
153+
}
154+
} else if (implemented?(ExtensionName::F)) {
155+
if (MUTABLE_MISA_F && CSR[misa].F == 0) {
156+
raise(ExceptionCode::IllegalInstruction, mode(), encoding);
157+
}
158+
159+
if (CSR[mstatus].FS == 0) {
160+
raise(ExceptionCode::IllegalInstruction, mode(), encoding);
161+
}
162+
} else {
163+
assert(false, "check_f_ok called when no FP extension is implemented");
138164
}
139165
}
140166
}

schemas/ext_schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"required": ["description", "schema"],
3838
"properties": {
3939
"description": {
40-
"type": "string",
40+
"$ref": "schema_defs.json#/$defs/spec_text",
4141
"description": "Parameter description, including list of valid values"
4242
},
4343
"also_defined_in": {
@@ -97,7 +97,7 @@
9797
"pattern": ".*[^.!,]$"
9898
},
9999
"description": {
100-
"type": "string",
100+
"$ref": "schema_defs.json#/$defs/spec_text",
101101
"description": "Full documentation of the extension"
102102
},
103103
"rvi_jira_issue": {

0 commit comments

Comments
 (0)