Skip to content

Commit 64807be

Browse files
committed
fix(data): use hints for Zicbop instructions
- Replace `pseudoinstructions` inline in `ori.yaml` with hint references - Fix IDL implementation for prefetch instructions to use the offset+reg value
1 parent 3d9129d commit 64807be

File tree

4 files changed

+100
-24
lines changed

4 files changed

+100
-24
lines changed

spec/std/isa/inst/I/ori.yaml

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,12 @@ access:
2525
vs: always
2626
vu: always
2727
data_independent_timing: true
28+
hints:
29+
- { $ref: inst/Zicbop/prefetch.r.yaml# }
30+
- { $ref: inst/Zicbop/prefetch.w.yaml# }
31+
- { $ref: inst/Zicbop/prefetch.i.yaml# }
2832
operation(): |
29-
if (implemented?(ExtensionName::Zicbop)) {
30-
if (xd == 0) {
31-
if (imm[4:0] == 0) {
32-
# prefetch.i instruction
33-
Bits<12> offset = {imm[11:5], xd};
34-
prefetch_instruction(offset);
35-
} else if (imm[4:0] == 1) {
36-
# prefetch.r instruction
37-
Bits<12> offset = {imm[11:5], xd};
38-
prefetch_read(offset);
39-
} else if (imm[4:0] == 3) {
40-
# prefetch.r instruction
41-
Bits<12> offset = {imm[11:5], xd};
42-
prefetch_write(offset);
43-
}
44-
}
45-
}
4633
X[xd] = X[xs1] | $signed(imm);
47-
pseudoinstructions:
48-
- when: (xd == 0) && (imm[4:0] == 0)
49-
to: prefetch.i offset
50-
- when: (xd == 0) && (imm[4:0] == 1)
51-
to: prefetch.r offset
52-
- when: (xd == 0) && (imm[4:0] == 3)
53-
to: prefetch.w offset
5434
5535
# SPDX-SnippetBegin
5636
# SPDX-FileCopyrightText: 2017-2025 Contributors to the RISCV Sail Model <https://github.com/riscv/sail-riscv/blob/master/LICENCE>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) Jordan Carlin
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# yaml-language-server: $schema=../../../../schemas/inst_schema.json
5+
6+
$schema: inst_schema.json#
7+
kind: instruction
8+
name: prefetch.i
9+
long_name: Cache block prefetch for instruction fetch
10+
description: |
11+
A prefetch.i instruction indicates to hardware that the cache block whose
12+
effective address is the sum of the base address specified in rs1 and the
13+
sign-extended offset encoded in imm[11:0], where imm[4:0] equals 0b00000,
14+
is likely to be accessed by an instruction fetch in the near future.
15+
definedBy: Zicbop
16+
assembly: prefetch.i imm(xs1)
17+
encoding:
18+
match: -------00001-----110000000010011
19+
variables:
20+
- name: imm
21+
location: 31-25
22+
- name: xs1
23+
location: 19-15
24+
access:
25+
s: always
26+
u: always
27+
vs: always
28+
vu: always
29+
data_independent_timing: false
30+
operation(): |
31+
XReg address = X[xs1] + $signed(imm << 5);
32+
prefetch_instruction(address);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) Jordan Carlin
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# yaml-language-server: $schema=../../../../schemas/inst_schema.json
5+
6+
$schema: inst_schema.json#
7+
kind: instruction
8+
name: prefetch.r
9+
long_name: Cache block prefetch for data read
10+
description: |
11+
A prefetch.r instruction indicates to hardware that the cache block whose
12+
effective address is the sum of the base address specified in rs1 and the
13+
sign-extended offset encoded in imm[11:0], where imm[4:0] equals 0b00000,
14+
is likely to be accessed by a data read (i.e. load) in the near future.
15+
definedBy: Zicbop
16+
assembly: prefetch.r imm(xs1)
17+
encoding:
18+
match: -------00001-----110000000010011
19+
variables:
20+
- name: imm
21+
location: 31-25
22+
- name: xs1
23+
location: 19-15
24+
access:
25+
s: always
26+
u: always
27+
vs: always
28+
vu: always
29+
data_independent_timing: false
30+
operation(): |
31+
XReg address = X[xs1] + $signed(imm << 5);
32+
prefetch_read(address);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Copyright (c) Jordan Carlin
2+
# SPDX-License-Identifier: BSD-3-Clause-Clear
3+
4+
# yaml-language-server: $schema=../../../../schemas/inst_schema.json
5+
6+
$schema: inst_schema.json#
7+
kind: instruction
8+
name: prefetch.w
9+
long_name: Cache block prefetch for data write
10+
description: |
11+
A prefetch.w instruction indicates to hardware that the cache block whose
12+
effective address is the sum of the base address specified in rs1 and the
13+
sign-extended offset encoded in imm[11:0], where imm[4:0] equals 0b00000,
14+
is likely to be accessed by a data write (i.e. store) in the near future.
15+
definedBy: Zicbop
16+
assembly: prefetch.w imm(xs1)
17+
encoding:
18+
match: -------00011-----110000000010011
19+
variables:
20+
- name: imm
21+
location: 31-25
22+
- name: xs1
23+
location: 19-15
24+
access:
25+
s: always
26+
u: always
27+
vs: always
28+
vu: always
29+
data_independent_timing: false
30+
operation(): |
31+
XReg address = X[xs1] + $signed(imm << 5);
32+
prefetch_write(address);

0 commit comments

Comments
 (0)