-
Notifications
You must be signed in to change notification settings - Fork 5.1k
adapt to rv64ilp32 toolchain #9194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
#define REGTYPES_H__ | ||
#include <rtconfig.h> | ||
#if defined (RT_USING_RV64ILP32) | ||
typedef unsigned long long rt_uintreg_t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RTT 已经存在同样语义的类型 rt_ubase_t
。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这块是这样的虽然跑的64位机器但是指针 长整型等编出来都是32位的 所以需要这么做一下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rt_base_t
的语义就是机器字长。64 bits 核心肯定是 64 bits。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
跟随指针长度的变量在标准 C 里面是 intptr_t
。RTT 这个设计按我的理解就是和 ABI 做解耦的。
Lines 36 to 37 in d8d0af9
typedef signed long rt_base_t; /**< Nbit CPU related data type */ | |
typedef unsigned long rt_ubase_t; /**< Nbit unsigned CPU related data type */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rt_ubase_t
定义没考虑到不同 ABI 的问题。这个是单独 issue,建议是另外起一个 PR 修复。否则使用 rv64ilp32 的 ABI 时很多组件都跑不起来。单独加入一个新类型并不能从根源解决问题。
bsp/qemu-virt64-riscv/rtconfig.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不推荐这么处理。用户用得更多的还是常规配置。也包括那个 qemu.sh 脚本。这个特殊配置做成此 bsp 默认等于强迫原先的 bsp 用户使用时每次都要亲自修改一大堆功能。倒不如另外起一个目录来做。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里确实得考虑一下
libcpu/risc-v/virt64/cpuport.h
Outdated
#define STORE sw | ||
#define LOAD lw | ||
#define FSTORE fsw | ||
#define FLOAD flw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里关于浮点指令的设置不合理。RISC-V架构中,浮点寄存器的长度由ABI_FLEN决定,与指针长度无关。当ABI_FLEN == 32时,abi 为 ilp32f 或 lp64f,当 ABI_FLEN == 64 时,abi 为 ilp32d 或 lp64d。
区分 rv32 和 rv64应该使用 if __riscv_xlen == 64,区分 ptr 的长度应该使用 __SIZEOF_POINTER__
,区分浮点寄存器的长度应该使用 if __riscv_flen == 64 判断,示例如下
#if defined(__riscv_flen) && __riscv_flen == 64
# define FPR_L fld
# define FPR_S fsd
# define SZ_FPR 8
#elif defined(__riscv_flen) && __riscv_flen == 32
# define FPR_L flw
# define FPR_S fsw
# define SZ_FPR 4
#elif defined(__riscv_flen)
# error Q-extension unsupported
#else
# define SZ_FPR 0
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在构造线程栈时 代码这里为了统一 将浮点的宽度与整数的宽度做了统一 ;这里引入的宏去区别确实不太恰当;取消了这这里使用宏区别的方式,修改了构造栈函数中的数据类型来适配,相应调整在cpuport.c文件 @Liaoshihua
0682c5f
to
f0e1beb
Compare
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
qemu-virt64-riscv 适配 rv64ilp32新32位工具链
你的解决方案是什么 (what is your solution)
修改数据类型以支持rv64ilp32
请提供验证的bsp和config (provide the config and bsp)
bsp:qemu-virt64-riscv
rv64ilp32工具链地址
https://github.com/ruyisdk/riscv-gnu-toolchain-rv64ilp32/tags
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up