Skip to content

Commit 92d6c3f

Browse files
committed
Merge branch 'NXP-zilsd'
2 parents 62d5c06 + 70d26d6 commit 92d6c3f

File tree

11 files changed

+83
-17
lines changed

11 files changed

+83
-17
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ Spike supports the following RISC-V ISA features:
6161
- Zvkt extension, v1.0
6262
- Zvkn, Zvknc, Zvkng extension, v1.0
6363
- Zvks, Zvksc, Zvksg extension, v1.0
64+
- Zilsd extension, v0.9.0
65+
- Zcmlsd extension, v0.9.0
6466

6567
Versioning and APIs
6668
-------------------

disasm/disasm.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,11 +1391,14 @@ void disassembler_t::add_instructions(const isa_parser_t* isa)
13911391
if (isa->get_max_xlen() == 32) {
13921392
DISASM_INSN("c.jal", c_jal, 0, {&rvc_jump_target});
13931393
} else {
1394+
DISASM_INSN("c.addiw", c_addiw, 0, {&xrd, &rvc_imm});
1395+
}
1396+
1397+
if (isa->get_max_xlen() == 64 || isa->extension_enabled(EXT_ZCMLSD)) {
13941398
DISASM_INSN("c.ld", c_ld, 0, {&rvc_rs2s, &rvc_ld_address});
13951399
DISASM_INSN("c.ldsp", c_ldsp, 0, {&xrd, &rvc_ldsp_address});
13961400
DISASM_INSN("c.sd", c_sd, 0, {&rvc_rs2s, &rvc_ld_address});
13971401
DISASM_INSN("c.sdsp", c_sdsp, 0, {&rvc_rs2, &rvc_sdsp_address});
1398-
DISASM_INSN("c.addiw", c_addiw, 0, {&xrd, &rvc_imm});
13991402
}
14001403
}
14011404

disasm/isa_parser.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
239239
extension_table[EXT_ZICOND] = true;
240240
} else if (ext_str == "zihpm") {
241241
extension_table[EXT_ZIHPM] = true;
242+
} else if (ext_str == "zilsd") {
243+
if (max_xlen != 32)
244+
bad_isa_string(str, "'Zilsd' requires RV32");
245+
extension_table[EXT_ZILSD] = true;
246+
} else if (ext_str == "zcmlsd") {
247+
extension_table[EXT_ZCMLSD] = true;
242248
} else if (ext_str == "zvbb") {
243249
extension_table[EXT_ZVBB] = true;
244250
} else if (ext_str == "zvbc") {
@@ -324,6 +330,14 @@ isa_parser_t::isa_parser_t(const char* str, const char *priv)
324330
bad_isa_string(str, ("can't parse: " + std::string(p)).c_str());
325331
}
326332

333+
if (extension_table[EXT_ZCMLSD] && extension_table[EXT_ZCF]) {
334+
bad_isa_string(str, "'Zcmlsd' extension conflicts with 'Zcf' extensions");
335+
}
336+
337+
if (extension_table[EXT_ZCMLSD] && (!extension_table[EXT_ZCA] || !extension_table[EXT_ZILSD])) {
338+
bad_isa_string(str, "'Zcmlsd' extension requires 'Zca' and 'Zilsd' extensions");
339+
}
340+
327341
if (extension_table[EXT_ZFBFMIN] && !extension_table['F']) {
328342
bad_isa_string(str, "'Zfbfmin' extension requires 'F' extension");
329343
}

riscv/decode_macros.h

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@
4242
})
4343
#define WRITE_VSTATUS STATE.log_reg_write[3] = {0, 0};
4444

45+
/* the value parameter needs to be evaluated before writing to the registers */
46+
#define WRITE_REG_PAIR(reg, value) \
47+
if (reg != 0) { \
48+
require((reg) % 2 == 0); \
49+
uint64_t val = (value); \
50+
WRITE_REG(reg, sext32(val)); \
51+
WRITE_REG((reg) + 1, (sreg_t(val)) >> 32); \
52+
}
53+
4554
// RVC macros
4655
#define WRITE_RVC_RS1S(value) WRITE_REG(insn.rvc_rs1s(), value)
4756
#define WRITE_RVC_RS2S(value) WRITE_REG(insn.rvc_rs2s(), value)
@@ -69,13 +78,15 @@
6978
#define RS1_PAIR READ_REG_PAIR(insn.rs1())
7079
#define RS2_PAIR READ_REG_PAIR(insn.rs2())
7180
#define RD_PAIR READ_REG_PAIR(insn.rd())
81+
#define WRITE_RD_PAIR(value) WRITE_REG_PAIR(insn.rd(), value)
7282

73-
#define WRITE_RD_PAIR(value) \
74-
if (insn.rd() != 0) { \
75-
require(insn.rd() % 2 == 0); \
76-
WRITE_REG(insn.rd(), sext32(value)); \
77-
WRITE_REG(insn.rd() + 1, (sreg_t(value)) >> 32); \
78-
}
83+
// Zilsd macros
84+
#define WRITE_RD_D(value) (xlen == 32 ? WRITE_RD_PAIR(value) : WRITE_RD(value))
85+
86+
// Zcmlsd macros
87+
#define WRITE_RVC_RS2S_PAIR(value) WRITE_REG_PAIR(insn.rvc_rs2s(), value)
88+
#define RVC_RS2S_PAIR READ_REG_PAIR(insn.rvc_rs2s())
89+
#define RVC_RS2_PAIR READ_REG_PAIR(insn.rvc_rs2())
7990

8091
// FPU macros
8192
#define READ_ZDINX_REG(reg) (xlen == 32 ? f64(READ_REG_PAIR(reg)) : f64(STATE.XPR[reg] & (uint64_t)-1))
@@ -122,8 +133,7 @@ do { \
122133
do { \
123134
if (p->extension_enabled(EXT_ZFINX)) { \
124135
if (xlen == 32) { \
125-
uint64_t val = (value).v; \
126-
WRITE_RD_PAIR(val); \
136+
WRITE_RD_PAIR((value).v); \
127137
} else { \
128138
WRITE_REG(insn.rd(), (value).v); \
129139
} \

riscv/insns/c_ld.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
require_extension(EXT_ZCA);
2-
WRITE_RVC_RS2S(MMU.load<int64_t>(RVC_RS1S + insn.rvc_ld_imm()));
2+
require((xlen == 64) || p->extension_enabled(EXT_ZCMLSD));
3+
4+
if (xlen == 32) {
5+
WRITE_RVC_RS2S_PAIR(MMU.load<int64_t>(RVC_RS1S + insn.rvc_ld_imm()));
6+
} else {
7+
WRITE_RVC_RS2S(MMU.load<int64_t>(RVC_RS1S + insn.rvc_ld_imm()));
8+
}

riscv/insns/c_ldsp.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
require_extension(EXT_ZCA);
2+
require((xlen == 64) || p->extension_enabled(EXT_ZCMLSD));
23
require(insn.rvc_rd() != 0);
3-
WRITE_RD(MMU.load<int64_t>(RVC_SP + insn.rvc_ldsp_imm()));
4+
5+
if (xlen == 32) {
6+
WRITE_RD_PAIR(MMU.load<int64_t>(RVC_SP + insn.rvc_ldsp_imm()));
7+
} else {
8+
WRITE_RD(MMU.load<int64_t>(RVC_SP + insn.rvc_ldsp_imm()));
9+
}

riscv/insns/c_sd.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
require_extension(EXT_ZCA);
2-
MMU.store<uint64_t>(RVC_RS1S + insn.rvc_ld_imm(), RVC_RS2S);
2+
require((xlen == 64) || p->extension_enabled(EXT_ZCMLSD));
3+
4+
if (xlen == 32) {
5+
MMU.store<uint64_t>(RVC_RS1S + insn.rvc_ld_imm(), RVC_RS2S_PAIR);
6+
} else {
7+
MMU.store<uint64_t>(RVC_RS1S + insn.rvc_ld_imm(), RVC_RS2S);
8+
}

riscv/insns/c_sdsp.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
require_extension(EXT_ZCA);
2-
MMU.store<uint64_t>(RVC_SP + insn.rvc_sdsp_imm(), RVC_RS2);
2+
require((xlen == 64) || p->extension_enabled(EXT_ZCMLSD));
3+
4+
if (xlen == 32) {
5+
MMU.store<uint64_t>(RVC_SP + insn.rvc_sdsp_imm(), RVC_RS2_PAIR);
6+
} else {
7+
MMU.store<uint64_t>(RVC_SP + insn.rvc_sdsp_imm(), RVC_RS2);
8+
}

riscv/insns/ld.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
require_rv64;
2-
WRITE_RD(MMU.load<int64_t>(RS1 + insn.i_imm()));
1+
require((xlen == 64) || p->extension_enabled(EXT_ZILSD));
2+
3+
if (xlen == 32) {
4+
WRITE_RD_PAIR(MMU.load<int64_t>(RS1 + insn.i_imm()));
5+
} else {
6+
WRITE_RD(MMU.load<int64_t>(RS1 + insn.i_imm()));
7+
}
8+

riscv/insns/sd.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
require_rv64;
2-
MMU.store<uint64_t>(RS1 + insn.s_imm(), RS2);
1+
require((xlen == 64) || p->extension_enabled(EXT_ZILSD));
2+
3+
if (xlen == 32) {
4+
MMU.store<uint64_t>(RS1 + insn.s_imm(), RS2_PAIR);
5+
} else {
6+
MMU.store<uint64_t>(RS1 + insn.s_imm(), RS2);
7+
}

0 commit comments

Comments
 (0)