Skip to content

Commit 750f008

Browse files
author
Weiwei Li
committed
add support for overlap instructions
* add DECLARE_OVERLAP_INSN to bind instructions with extension * add overlap_list.h to contain the declare of all overlapping instructions * make func function for overlapping instruction return NULL when the coresponding extension(s) is not supported.
1 parent c3c04a8 commit 750f008

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

customext/cflush.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ class cflush_t : public extension_t
2424

2525
std::vector<insn_desc_t> get_instructions() {
2626
std::vector<insn_desc_t> insns;
27-
insns.push_back((insn_desc_t){0xFC000073, 0xFFF07FFF, custom_cflush, custom_cflush, custom_cflush, custom_cflush});
28-
insns.push_back((insn_desc_t){0xFC200073, 0xFFF07FFF, custom_cflush, custom_cflush, custom_cflush, custom_cflush});
29-
insns.push_back((insn_desc_t){0xFC100073, 0xFFF07FFF, custom_cflush, custom_cflush, custom_cflush, custom_cflush});
27+
insns.push_back((insn_desc_t){true, 0xFC000073, 0xFFF07FFF, custom_cflush, custom_cflush, custom_cflush, custom_cflush});
28+
insns.push_back((insn_desc_t){true, 0xFC200073, 0xFFF07FFF, custom_cflush, custom_cflush, custom_cflush, custom_cflush});
29+
insns.push_back((insn_desc_t){true, 0xFC100073, 0xFFF07FFF, custom_cflush, custom_cflush, custom_cflush, custom_cflush});
3030
return insns;
3131
}
3232

riscv/overlap_list.h

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
DECLARE_OVERLAP_INSN(c_fsdsp, 'C')
2+
DECLARE_OVERLAP_INSN(c_fsdsp, 'D')
3+
DECLARE_OVERLAP_INSN(c_fld, 'C')
4+
DECLARE_OVERLAP_INSN(c_fld, 'D')
5+
DECLARE_OVERLAP_INSN(c_fldsp, 'C')
6+
DECLARE_OVERLAP_INSN(c_fldsp, 'D')
7+
DECLARE_OVERLAP_INSN(c_fsd, 'C')
8+
DECLARE_OVERLAP_INSN(c_fsd, 'D')

riscv/processor.cc

+8-1
Original file line numberDiff line numberDiff line change
@@ -942,16 +942,23 @@ void processor_t::register_extension(extension_t* x)
942942
void processor_t::register_base_instructions()
943943
{
944944
#define DECLARE_INSN(name, match, mask) \
945-
insn_bits_t name##_match = (match), name##_mask = (mask);
945+
insn_bits_t name##_match = (match), name##_mask = (mask); \
946+
bool name##_supported = true;
947+
946948
#include "encoding.h"
947949
#undef DECLARE_INSN
948950

951+
#define DECLARE_OVERLAP_INSN(name, ext) { name##_supported &= isa->extension_enabled(ext); }
952+
#include "overlap_list.h"
953+
#undef DECLARE_OVERLAP_INSN
954+
949955
#define DEFINE_INSN(name) \
950956
extern reg_t rv32i_##name(processor_t*, insn_t, reg_t); \
951957
extern reg_t rv64i_##name(processor_t*, insn_t, reg_t); \
952958
extern reg_t rv32e_##name(processor_t*, insn_t, reg_t); \
953959
extern reg_t rv64e_##name(processor_t*, insn_t, reg_t); \
954960
register_insn((insn_desc_t) { \
961+
name##_supported, \
955962
name##_match, \
956963
name##_mask, \
957964
rv32i_##name, \

riscv/processor.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ reg_t illegal_instruction(processor_t* p, insn_t insn, reg_t pc);
2929

3030
struct insn_desc_t
3131
{
32+
bool supported;
3233
insn_bits_t match;
3334
insn_bits_t mask;
3435
insn_func_t rv32i;
@@ -38,6 +39,9 @@ struct insn_desc_t
3839

3940
insn_func_t func(int xlen, bool rve)
4041
{
42+
if (!supported)
43+
return NULL;
44+
4145
if (rve)
4246
return xlen == 64 ? rv64e : rv32e;
4347
else
@@ -46,7 +50,7 @@ struct insn_desc_t
4650

4751
static insn_desc_t illegal()
4852
{
49-
return {0, 0, &illegal_instruction, &illegal_instruction, &illegal_instruction, &illegal_instruction};
53+
return {true, 0, 0, &illegal_instruction, &illegal_instruction, &illegal_instruction, &illegal_instruction};
5054
}
5155
};
5256

riscv/rocc.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ customX(3)
3232
std::vector<insn_desc_t> rocc_t::get_instructions()
3333
{
3434
std::vector<insn_desc_t> insns;
35-
insns.push_back((insn_desc_t){0x0b, 0x7f, &::illegal_instruction, c0, &::illegal_instruction, c0});
36-
insns.push_back((insn_desc_t){0x2b, 0x7f, &::illegal_instruction, c1, &::illegal_instruction, c1});
37-
insns.push_back((insn_desc_t){0x5b, 0x7f, &::illegal_instruction, c2, &::illegal_instruction, c2});
38-
insns.push_back((insn_desc_t){0x7b, 0x7f, &::illegal_instruction, c3, &::illegal_instruction, c3});
35+
insns.push_back((insn_desc_t){true, 0x0b, 0x7f, &::illegal_instruction, c0, &::illegal_instruction, c0});
36+
insns.push_back((insn_desc_t){true, 0x2b, 0x7f, &::illegal_instruction, c1, &::illegal_instruction, c1});
37+
insns.push_back((insn_desc_t){true, 0x5b, 0x7f, &::illegal_instruction, c2, &::illegal_instruction, c2});
38+
insns.push_back((insn_desc_t){true, 0x7b, 0x7f, &::illegal_instruction, c3, &::illegal_instruction, c3});
3939
return insns;
4040
}
4141

0 commit comments

Comments
 (0)