Skip to content

Commit bd07233

Browse files
committed
Removed unnecessary blank lines and VLEN checks
Removed unnecessary blank lines in `src/decode.c`. Removed redundant `VLEN` checks in `src/riscv.h` and `src/rv32_template.c` since they are already handled in the Makefile. Moved and reordered `#include` statements in `decode.c`, replaced `log2` with `ilog2` in `common.h`.
1 parent a871e8c commit bd07233

File tree

3 files changed

+11
-31
lines changed

3 files changed

+11
-31
lines changed

src/decode.c

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
* "LICENSE" for information on usage and redistribution of this file.
44
*/
55

6-
#include "decode.h"
76
#include <assert.h>
8-
#include <math.h>
97
#include <stdlib.h>
8+
9+
#include "decode.h"
1010
#include "riscv_private.h"
1111

1212
/* decode rd field
@@ -362,7 +362,6 @@ static inline void decode_jtype(rv_insn_t *ir, const uint32_t insn)
362362

363363

364364
#if RV32_HAS(EXT_F)
365-
366365
/* decode R4-type rs3 field
367366
* rs3 = inst[31:27]
368367
*/
@@ -1193,8 +1192,6 @@ static inline bool op_amo(rv_insn_t *ir, const uint32_t insn)
11931192
#endif /* RV32_HAS(EXT_A) */
11941193

11951194
#if RV32_HAS(EXT_F)
1196-
1197-
11981195
/* OP-FP: R-type
11991196
* 31 27 26 25 24 20 19 15 14 12 11 7 6 0
12001197
* | funct5 | fmt | rs2 | rs1 | rm | rd | opcode |
@@ -1937,15 +1934,11 @@ static inline bool op_cfsw(rv_insn_t *ir, const uint32_t insn)
19371934
#define op_cflwsp OP_UNIMP
19381935
#endif /* RV32_HAS(EXT_C) && RV32_HAS(EXT_F) */
19391936

1940-
1941-
#if RV32_HAS(EXT_V) /* (RV32_HAS(EXT_V) */
1942-
1943-
/*
1944-
* Sign extened vector immediate
1945-
*/
1937+
#if RV32_HAS(EXT_V)
1938+
/* Sign-extened vector immediate */
19461939
static inline int32_t decode_v_imm(const uint32_t insn)
19471940
{
1948-
return ((int32_t)((insn << 12) & FR4_RS3)) >> 27;
1941+
return ((int32_t) ((insn << 12) & FR4_RS3)) >> 27;
19491942
}
19501943

19511944
/* decode vsetvli zimm[10:0] field
@@ -3975,9 +3968,7 @@ static inline bool op_111111(rv_insn_t *ir, const uint32_t insn)
39753968
}
39763969
return true;
39773970
}
3978-
3979-
#endif /* (RV32_HAS(EXT_V) */
3980-
3971+
#endif
39813972

39823973
/* Fixme:Temproary move op_load/store_fp out of EXT_F */
39833974
/* LOAD-FP: I-type
@@ -3987,9 +3978,6 @@ static inline bool op_111111(rv_insn_t *ir, const uint32_t insn)
39873978
static inline bool op_load_fp(rv_insn_t *ir, const uint32_t insn)
39883979
{
39893980
#if RV32_HAS(EXT_V)
3990-
/* Fixme: The implementation now is just using switch statement, since there
3991-
* are multiple duplicate elements in vectore load/store instruction. I'm
3992-
* hoping to build clean and efficient code. */
39933981
/* inst nf mew mop vm rs2/vs1 rs1 width vd opcode
39943982
* ----+---+---+---+--+---------+-----+-----+---+--------
39953983
* VL* nf mew mop vm lumop rs1 width vd 0000111
@@ -4013,7 +4001,7 @@ static inline bool op_load_fp(rv_insn_t *ir, const uint32_t insn)
40134001
}
40144002
break;
40154003
case 0b01000:
4016-
ir->opcode = rv_insn_vl1re8_v + 4 * eew + log2(nf + 1);
4004+
ir->opcode = rv_insn_vl1re8_v + 4 * eew + ilog2(nf + 1);
40174005
break;
40184006
case 0b01011:
40194007
ir->opcode = rv_insn_vlm_v;
@@ -4058,7 +4046,6 @@ static inline bool op_load_fp(rv_insn_t *ir, const uint32_t insn)
40584046
}
40594047
return true;
40604048
}
4061-
40624049
#endif
40634050

40644051
/* inst imm[11:0] rs1 width rd opcode
@@ -4073,7 +4060,6 @@ static inline bool op_load_fp(rv_insn_t *ir, const uint32_t insn)
40734060
return true;
40744061
}
40754062

4076-
40774063
/* STORE-FP: S-type
40784064
* 31 25 24 20 19 15 14 12 11 7 6 0
40794065
* | imm[11:5] | rs2 | rs1 | width | imm[4:0] | opcode |
@@ -4107,7 +4093,7 @@ static inline bool op_store_fp(rv_insn_t *ir, const uint32_t insn)
41074093
}
41084094
break;
41094095
case 0b01000:
4110-
ir->opcode = rv_insn_vs1r_v + log2(nf + 1);
4096+
ir->opcode = rv_insn_vs1r_v + ilog2(nf + 1);
41114097
break;
41124098
case 0b01011:
41134099
ir->opcode = rv_insn_vsm_v;
@@ -4145,8 +4131,8 @@ static inline bool op_store_fp(rv_insn_t *ir, const uint32_t insn)
41454131
}
41464132
return true;
41474133
}
4148-
41494134
#endif
4135+
41504136
/* inst imm[11:5] rs2 rs1 width imm[4:0] opcode
41514137
* ----+---------+---+---+-----+--------+-------
41524138
* FSW imm[11:5] rs2 rs1 010 imm[4:0] 0100111
@@ -4203,9 +4189,9 @@ bool rv_decode(rv_insn_t *ir, uint32_t insn)
42034189
#endif
42044190

42054191
#if RV32_HAS(EXT_V)
4206-
/* RVV vector opcode map */
4192+
/* RVV vector function6 map */
42074193
static const decode_t rvv_jump_table[] = {
4208-
/* Acording to https://github.com/riscvarchive/riscv-v-spec/blob/master/inst-table.adoc this table is for function6. */
4194+
/* Acording to https://github.com/riscvarchive/riscv-v-spec/blob/master/inst-table.adoc */
42094195
// 000 001 010 011 100 101 110 111
42104196
OP(000000), OP(000001), OP(000010), OP(000011), OP(000100), OP(000101), OP(000110), OP(000111), // 000
42114197
OP(001000), OP(001001), OP(001010), OP(001011), OP(001100), OP(unimp), OP(001110), OP(001111), // 001

src/riscv.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ typedef uint32_t riscv_exception_t;
290290
typedef softfloat_float32_t riscv_float_t;
291291
#endif
292292
#if RV32_HAS(EXT_V)
293-
#ifndef VLEN
294-
#define VLEN 128
295-
#endif
296293
typedef uint32_t vreg_t[VLEN / 32];
297294
#endif
298295

src/rv32_template.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2990,9 +2990,6 @@ RVOP(
29902990

29912991

29922992
#if RV32_HAS(EXT_V)
2993-
#ifndef VLEN
2994-
#define VLEN 128
2995-
#endif
29962993

29972994
#define LEN ((VLEN) >> (5))
29982995

0 commit comments

Comments
 (0)