Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenXiangShan
NEMU
提交
298bc25c
N
NEMU
项目概览
OpenXiangShan
/
NEMU
大约 1 年 前同步成功
通知
7
Star
171
Fork
67
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NEMU
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
298bc25c
编写于
9月 09, 2019
作者:
Z
Zihao Yu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rtl: remove unnecessary basic rtl instructions
上级
85ef00c7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
32 addition
and
42 deletion
+32
-42
include/rtl/c_op.h
include/rtl/c_op.h
+13
-12
include/rtl/rtl-wrapper.h
include/rtl/rtl-wrapper.h
+0
-6
include/rtl/rtl.h
include/rtl/rtl.h
+1
-10
src/isa/riscv64/exec/compute.c
src/isa/riscv64/exec/compute.c
+3
-3
src/isa/riscv64/exec/muldiv.c
src/isa/riscv64/exec/muldiv.c
+15
-11
未找到文件。
include/rtl/c_op.h
浏览文件 @
298bc25c
...
@@ -8,20 +8,21 @@
...
@@ -8,20 +8,21 @@
#define c_xor(a, b) ((a) ^ (b))
#define c_xor(a, b) ((a) ^ (b))
#define c_shl(a, b) ((a) << (b))
#define c_shl(a, b) ((a) << (b))
#define c_shr(a, b) ((a) >> (b))
#define c_shr(a, b) ((a) >> (b))
#define c_shr64(a, b) ((uint32_t)(a) >> (b))
#define c_sar(a, b) ((sword_t)(a) >> (b))
#define c_sar(a, b) ((int32_t)(a) >> (b))
#define c_sar64(a, b) ((int64_t)(a) >> (b))
#define c_mul_lo(a, b) ((a) * (b))
#define c_mul_lo(a, b) ((a) * (b))
#define c_mul_hi(a, b) (((uint64_t)(a) * (uint64_t)(b)) >> 32)
#define c_imul_lo(a, b) ((sword_t)(a) * (sword_t)(b))
#define c_imul_lo(a, b) ((int32_t)(a) * (int32_t)(b))
#ifdef ISA64
#define c_imul_hi(a, b) (((int64_t)(int32_t)(a) * (int64_t)(int32_t)(b)) >> 32)
# define c_mul_hi(a, b) (((__uint128_t)(a) * (__uint128_t)(b)) >> 64)
# define c_imul_hi(a, b) (((__int128_t)(sword_t)(a) * (__int128_t)(sword_t)(b)) >> 64)
#else
# define c_mul_hi(a, b) (((uint64_t)(a) * (uint64_t)(b)) >> 32)
# define c_imul_hi(a, b) (((int64_t)(sword_t)(a) * (int64_t)(sword_t)(b)) >> 32)
#endif
#define c_div_q(a, b) ((a) / (b))
#define c_div_q(a, b) ((a) / (b))
#define c_div_q64(a, b) (((a) & 0xffffffff) / ((b) & 0xffffffff))
#define c_div_r(a, b) ((a) % (b))
#define c_div_r(a, b) ((a) % (b))
#define c_div_r64(a, b) (((a) & 0xffffffff) % ((b) & 0xffffffff))
#define c_idiv_q(a, b) ((sword_t)(a) / (sword_t)(b))
#define c_idiv_q(a, b) ((int32_t)(a) / (int32_t)(b))
#define c_idiv_r(a, b) ((sword_t)(a) % (sword_t)(b))
#define c_idiv_q64(a, b) ((int32_t)((uint32_t)((a) & 0xffffffff)) / (int32_t)((uint32_t)((b) & 0xffffffff)))
#define c_idiv_r(a, b) ((int32_t)(a) % (int32_t)(b))
#define c_idiv_r64(a, b) ((int32_t)((uint32_t)((a) & 0xffffffff)) % (int32_t)((uint32_t)((b) & 0xffffffff)))
#endif
#endif
include/rtl/rtl-wrapper.h
浏览文件 @
298bc25c
...
@@ -14,21 +14,15 @@
...
@@ -14,21 +14,15 @@
#define rtl_xor concat(RTL_PREFIX, _rtl_xor )
#define rtl_xor concat(RTL_PREFIX, _rtl_xor )
#define rtl_shl concat(RTL_PREFIX, _rtl_shl )
#define rtl_shl concat(RTL_PREFIX, _rtl_shl )
#define rtl_shr concat(RTL_PREFIX, _rtl_shr )
#define rtl_shr concat(RTL_PREFIX, _rtl_shr )
#define rtl_shr64 concat(RTL_PREFIX, _rtl_shr64 )
#define rtl_sar concat(RTL_PREFIX, _rtl_sar )
#define rtl_sar concat(RTL_PREFIX, _rtl_sar )
#define rtl_sar64 concat(RTL_PREFIX, _rtl_sar64 )
#define rtl_mul_lo concat(RTL_PREFIX, _rtl_mul_lo )
#define rtl_mul_lo concat(RTL_PREFIX, _rtl_mul_lo )
#define rtl_mul_hi concat(RTL_PREFIX, _rtl_mul_hi )
#define rtl_mul_hi concat(RTL_PREFIX, _rtl_mul_hi )
#define rtl_imul_lo concat(RTL_PREFIX, _rtl_imul_lo )
#define rtl_imul_lo concat(RTL_PREFIX, _rtl_imul_lo )
#define rtl_imul_hi concat(RTL_PREFIX, _rtl_imul_hi )
#define rtl_imul_hi concat(RTL_PREFIX, _rtl_imul_hi )
#define rtl_div_q concat(RTL_PREFIX, _rtl_div_q )
#define rtl_div_q concat(RTL_PREFIX, _rtl_div_q )
#define rtl_div_q64 concat(RTL_PREFIX, _rtl_div_q64 )
#define rtl_div_r concat(RTL_PREFIX, _rtl_div_r )
#define rtl_div_r concat(RTL_PREFIX, _rtl_div_r )
#define rtl_div_r64 concat(RTL_PREFIX, _rtl_div_r64 )
#define rtl_idiv_q concat(RTL_PREFIX, _rtl_idiv_q )
#define rtl_idiv_q concat(RTL_PREFIX, _rtl_idiv_q )
#define rtl_idiv_q64 concat(RTL_PREFIX, _rtl_idiv_q64)
#define rtl_idiv_r concat(RTL_PREFIX, _rtl_idiv_r )
#define rtl_idiv_r concat(RTL_PREFIX, _rtl_idiv_r )
#define rtl_idiv_r64 concat(RTL_PREFIX, _rtl_idiv_r64)
#define rtl_div64_q concat(RTL_PREFIX, _rtl_div64_q )
#define rtl_div64_q concat(RTL_PREFIX, _rtl_div64_q )
#define rtl_div64_r concat(RTL_PREFIX, _rtl_div64_r )
#define rtl_div64_r concat(RTL_PREFIX, _rtl_div64_r )
#define rtl_idiv64_q concat(RTL_PREFIX, _rtl_idiv64_q)
#define rtl_idiv64_q concat(RTL_PREFIX, _rtl_idiv64_q)
...
...
include/rtl/rtl.h
浏览文件 @
298bc25c
...
@@ -49,15 +49,6 @@ make_rtl_arith_logic(div_r)
...
@@ -49,15 +49,6 @@ make_rtl_arith_logic(div_r)
make_rtl_arith_logic
(
idiv_q
)
make_rtl_arith_logic
(
idiv_q
)
make_rtl_arith_logic
(
idiv_r
)
make_rtl_arith_logic
(
idiv_r
)
#ifdef ISA64
make_rtl_arith_logic
(
shr64
)
make_rtl_arith_logic
(
sar64
)
make_rtl_arith_logic
(
div_q64
)
make_rtl_arith_logic
(
div_r64
)
make_rtl_arith_logic
(
idiv_q64
)
make_rtl_arith_logic
(
idiv_r64
)
#endif
static
inline
void
interpret_rtl_div64_q
(
rtlreg_t
*
dest
,
static
inline
void
interpret_rtl_div64_q
(
rtlreg_t
*
dest
,
const
rtlreg_t
*
src1_hi
,
const
rtlreg_t
*
src1_lo
,
const
rtlreg_t
*
src2
)
{
const
rtlreg_t
*
src1_hi
,
const
rtlreg_t
*
src1_lo
,
const
rtlreg_t
*
src2
)
{
uint64_t
dividend
=
((
uint64_t
)(
*
src1_hi
)
<<
32
)
|
(
*
src1_lo
);
uint64_t
dividend
=
((
uint64_t
)(
*
src1_hi
)
<<
32
)
|
(
*
src1_lo
);
...
@@ -155,7 +146,7 @@ static inline void rtl_sext(rtlreg_t* dest, const rtlreg_t* src1, int width) {
...
@@ -155,7 +146,7 @@ static inline void rtl_sext(rtlreg_t* dest, const rtlreg_t* src1, int width) {
}
else
{
}
else
{
assert
(
width
==
1
||
width
==
2
||
width
==
4
);
assert
(
width
==
1
||
width
==
2
||
width
==
4
);
rtl_shli
(
dest
,
src1
,
(
8
-
width
)
*
8
);
rtl_shli
(
dest
,
src1
,
(
8
-
width
)
*
8
);
rtl_sar
64
i
(
dest
,
dest
,
(
8
-
width
)
*
8
);
rtl_sari
(
dest
,
dest
,
(
8
-
width
)
*
8
);
}
}
#else
#else
if
(
width
==
4
)
{
if
(
width
==
4
)
{
...
...
src/isa/riscv64/exec/compute.c
浏览文件 @
298bc25c
...
@@ -117,6 +117,7 @@ make_EHelper(sllw) {
...
@@ -117,6 +117,7 @@ make_EHelper(sllw) {
}
}
make_EHelper
(
srlw
)
{
make_EHelper
(
srlw
)
{
rtl_andi
(
&
id_src2
->
val
,
&
id_src2
->
val
,
0x1f
);
if
(
decinfo
.
isa
.
instr
.
funct7
==
32
)
{
if
(
decinfo
.
isa
.
instr
.
funct7
==
32
)
{
// sraw
// sraw
rtl_sar
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_sar
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
...
@@ -125,9 +126,8 @@ make_EHelper(srlw) {
...
@@ -125,9 +126,8 @@ make_EHelper(srlw) {
}
}
else
{
else
{
// srlw
// srlw
rtl_andi
(
&
id_src2
->
val
,
&
id_src2
->
val
,
0x1f
);
rtl_andi
(
&
id_src
->
val
,
&
id_src
->
val
,
0xffffffffu
);
rtl_shr
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_shr64
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
print_asm_template3
(
srlw
);
print_asm_template3
(
srlw
);
}
}
...
...
src/isa/riscv64/exec/muldiv.c
浏览文件 @
298bc25c
#include "cpu/exec.h"
#include "cpu/exec.h"
make_EHelper
(
mul
)
{
make_EHelper
(
mul
)
{
#ifdef ISA64
rtl_mul_lo
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_mul_lo
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
#else
rtl_imul_lo
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
#endif
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
print_asm_template3
(
mul
);
print_asm_template3
(
mul
);
...
@@ -54,7 +50,7 @@ make_EHelper(remu) {
...
@@ -54,7 +50,7 @@ make_EHelper(remu) {
}
}
make_EHelper
(
mulw
)
{
make_EHelper
(
mulw
)
{
rtl_
i
mul_lo
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_mul_lo
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
...
@@ -62,15 +58,19 @@ make_EHelper(mulw) {
...
@@ -62,15 +58,19 @@ make_EHelper(mulw) {
}
}
make_EHelper
(
divw
)
{
make_EHelper
(
divw
)
{
rtl_idiv_q64
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_sext
(
&
s0
,
&
id_src
->
val
,
4
);
rtl_sext
(
&
s1
,
&
id_src2
->
val
,
4
);
rtl_idiv_q
(
&
s0
,
&
s0
,
&
s1
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
print_asm_template3
(
div
);
print_asm_template3
(
div
w
);
}
}
make_EHelper
(
remw
)
{
make_EHelper
(
remw
)
{
rtl_idiv_r64
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_sext
(
&
s0
,
&
id_src
->
val
,
4
);
rtl_sext
(
&
s1
,
&
id_src2
->
val
,
4
);
rtl_idiv_r
(
&
s0
,
&
s0
,
&
s1
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
...
@@ -78,7 +78,9 @@ make_EHelper(remw) {
...
@@ -78,7 +78,9 @@ make_EHelper(remw) {
}
}
make_EHelper
(
divuw
)
{
make_EHelper
(
divuw
)
{
rtl_div_q64
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_andi
(
&
s0
,
&
id_src
->
val
,
0xffffffffu
);
rtl_andi
(
&
s1
,
&
id_src2
->
val
,
0xffffffffu
);
rtl_div_q
(
&
s0
,
&
s0
,
&
s1
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
...
@@ -86,9 +88,11 @@ make_EHelper(divuw) {
...
@@ -86,9 +88,11 @@ make_EHelper(divuw) {
}
}
make_EHelper
(
remuw
)
{
make_EHelper
(
remuw
)
{
rtl_idiv_r64
(
&
s0
,
&
id_src
->
val
,
&
id_src2
->
val
);
rtl_andi
(
&
s0
,
&
id_src
->
val
,
0xffffffffu
);
rtl_andi
(
&
s1
,
&
id_src2
->
val
,
0xffffffffu
);
rtl_div_r
(
&
s0
,
&
s0
,
&
s1
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sext
(
&
s0
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
rtl_sr
(
id_dest
->
reg
,
&
s0
,
4
);
print_asm_template3
(
remuw
);
print_asm_template3
(
remuw
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录