adapt to rv64ilp32 toolchain#9194
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.
RTT 已经存在同样语义的类型 rt_ubase_t。
There was a problem hiding this comment.
这块是这样的虽然跑的64位机器但是指针 长整型等编出来都是32位的 所以需要这么做一下
There was a problem hiding this comment.
rt_base_t 的语义就是机器字长。64 bits 核心肯定是 64 bits。
There was a problem hiding this comment.
跟随指针长度的变量在标准 C 里面是 intptr_t。RTT 这个设计按我的理解就是和 ABI 做解耦的。
Lines 36 to 37 in d8d0af9
There was a problem hiding this comment.
rt_ubase_t 定义没考虑到不同 ABI 的问题。这个是单独 issue,建议是另外起一个 PR 修复。否则使用 rv64ilp32 的 ABI 时很多组件都跑不起来。单独加入一个新类型并不能从根源解决问题。
There was a problem hiding this comment.
不推荐这么处理。用户用得更多的还是常规配置。也包括那个 qemu.sh 脚本。这个特殊配置做成此 bsp 默认等于强迫原先的 bsp 用户使用时每次都要亲自修改一大堆功能。倒不如另外起一个目录来做。
| #define STORE sw | ||
| #define LOAD lw | ||
| #define FSTORE fsw | ||
| #define FLOAD flw |
There was a problem hiding this comment.
这里关于浮点指令的设置不合理。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.
在构造线程栈时 代码这里为了统一 将浮点的宽度与整数的宽度做了统一 ;这里引入的宏去区别确实不太恰当;取消了这这里使用宏区别的方式,修改了构造栈函数中的数据类型来适配,相应调整在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