Skip to content

Commit ab9a65c

Browse files
committed
add Zclsd instructions
1 parent abc4553 commit ab9a65c

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed

arch/inst/Zclsd/c.ld.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# yaml-language-server: $schema=../../../schemas/inst_schema.json
2+
3+
$schema: "inst_schema.json#"
4+
kind: instruction
5+
name: c.ld
6+
long_name: Load doubleword to even/odd register pair, 16-bit encoding
7+
description: |
8+
Loads a 64-bit value into registers rd' and rd'+1. It computes an effective address by adding the
9+
zero-extended offset, scaled by 8, to the base address in register rs1'.
10+
definedBy:
11+
anyOf: [Zclsd]
12+
assembly: c.ld rd, offset(rs1)
13+
encoding:
14+
match: 011-----------00
15+
variables:
16+
- name: rd
17+
location: 4-2
18+
- name: imm
19+
location: 9-7
20+
- name: rs1
21+
location: 12-10|6-5
22+
access:
23+
s: always
24+
u: always
25+
vs: always
26+
vu: always
27+
operation(): |
28+
29+
Bits<XLEN> base = X[rs1];
30+
Bits<XLEN> offset = imm << 3;
31+
Bits<XLEN> eff_addr = base + offset;
32+
33+
Bits<64> data = read_memory<64>(eff_addr, $encoding);
34+
35+
if ((rd & 0x1) == 0) {
36+
X[rd] = data[31:0];
37+
X[rd+1] = data[63:32];
38+
}
39+
sail(): "" #not implemented in the sail model yet

arch/inst/Zclsd/c.ldsp.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# yaml-language-server: $schema=../../../schemas/inst_schema.json
2+
3+
$schema: "inst_schema.json#"
4+
kind: instruction
5+
name: c.ldsp
6+
long_name: Stack-pointer based load doubleword to even/odd register pair
7+
description: |
8+
Loads stack-pointer relative 64-bit value into registers rd' and rd'+1. It computes its effective
9+
address by adding the zero-extended offset, scaled by 8, to the stack pointer, x2. It expands to ld
10+
rd, offset(x2). C.LDSP is only valid when rd≠x0; the code points with rd=x0 are reserved.
11+
definedBy:
12+
anyOf: [Zclsd]
13+
assembly: ld rd, offset(rs1)
14+
encoding:
15+
match: 011-----------01
16+
variables:
17+
- name: rd
18+
location: 11-7
19+
- name: imm
20+
location: 12|6-2
21+
access:
22+
s: always
23+
u: always
24+
vs: always
25+
vu: always
26+
operation(): |
27+
28+
Bits<XLEN> base = X[2];
29+
Bits<XLEN> offset = imm << 3;
30+
Bits<XLEN> eff_addr = base + offset;
31+
32+
Bits<64> data = read_memory<64>(eff_addr, $encoding);
33+
34+
if ((rd & 0x1) == 0) {
35+
X[rd] = data[31:0];
36+
X[rd+1] = data[63:32];
37+
38+
}
39+
sail(): "" #not implemented in the sail model yet

arch/inst/Zclsd/c.sd.yaml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# yaml-language-server: $schema=../../../schemas/inst_schema.json
2+
3+
$schema: "inst_schema.json#"
4+
kind: instruction
5+
name: c.sd
6+
long_name: Store doubleword from even/odd register pair
7+
description: |
8+
Stores a 64-bit value from registers rs2' and rs2'+1. It computes an effective address by adding
9+
the zero-extended offset, scaled by 8, to the base address in register rs1'. It expands to sd rs2',
10+
offset(rs1').
11+
definedBy:
12+
anyOf: [Zclsd]
13+
assembly: c.sd rs2, offset(rs1)
14+
encoding:
15+
match: 111-----------00
16+
variables:
17+
- name: rs2
18+
location: 4-2
19+
- name: rs1
20+
location: 9-7
21+
- name: imm
22+
location: 12-10|6-5
23+
access:
24+
s: always
25+
u: always
26+
vs: always
27+
vu: always
28+
operation(): |
29+
30+
Bits<XLEN> base = X[rs1];
31+
Bits<XLEN> offset = imm << 3;
32+
Bits<XLEN> eff_addr = base + offset;
33+
34+
Bits<64> data = {X[rs2+1], X[rs2]};
35+
36+
write_memory<64>(eff_addr, data, $encoding);
37+
sail(): "" #not implemented in the sail model yet

arch/inst/Zclsd/c.sdsp.yaml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# yaml-language-server: $schema=../../../schemas/inst_schema.json
2+
3+
$schema: "inst_schema.json#"
4+
kind: instruction
5+
name: c.sdsp
6+
long_name: Stack-pointer based store doubleword from even/odd register pair
7+
description: |
8+
Stores a stack-pointer relative 64-bit value from registers rs2' and rs2'+1. It computes an effective
9+
address by adding the zero-extended offset, scaled by 8, to the stack pointer, x2. It expands to sd
10+
rs2, offset(x2).
11+
definedBy:
12+
anyOf: [Zclsd]
13+
assembly: c.sdsp rs2, offset(sp)
14+
encoding:
15+
match: 111-----------10
16+
variables:
17+
- name: rs2
18+
location: 6-2
19+
- name: imm
20+
location: 12-7
21+
access:
22+
s: always
23+
u: always
24+
vs: always
25+
vu: always
26+
operation(): |
27+
28+
Bits<XLEN> base = X[2];
29+
Bits<XLEN> offset = imm << 3;
30+
Bits<XLEN> eff_addr = base + offset;
31+
32+
Bits<64> data = {X[rs2+1], X[rs2]};
33+
34+
write_memory<64>(eff_addr, data, $encoding);
35+
sail(): "" #not implemented in the sail model yet

0 commit comments

Comments
 (0)