RISC-V数据模型,-mabi=ilp32, ilp32f, ilp32d, lp64, lp64f, lp64d

RISC-V GCC通过-mabi选项指定数据模型和浮点参数传递规则。有效的选项值包括ilp32、ilp32f、ilp32d、lp64、lp64f 和 lp64d。前半部分指定数据模型,后半部分指定浮点参数传递规则。

mingdu.zheng at gmail dot com
http://blog.csdn.net/zoomdy/article/details/79353313

iintllongppointer即指针,32/64指前面给出的类型是32/64位的;ffloat,指float型浮点数参数通过浮点数寄存器传递;ddouble,指float型和double型浮点数参数通过浮点数寄存器传递。

数据模型:

xint字长long字长指针字长
ilp32/ilp32f/ilp32d32bits32bits32bits
lp64/lp64f/lp64d32bits64bits64bits

浮点参数传递规则:

x需要浮点扩展指令?float参数double参数
ilp32/lp64不需要通过整数寄存器(a0-a1)传递通过整数寄存器(a0-a3)传递
ilp32f/lp64f需要F扩展通过浮点寄存器(fa0-fa1)传递通过整数寄存器(a0-a3)传递
ilp32d/lp64d需要F扩展和D扩展通过浮点寄存器(fa0-fa1)传递通过浮点寄存器(fa0-fa1)传递

浮点参数传递规则只跟-mabi选项有关,和-march选项没有直接关系,但是部分-mabi选项需要浮点寄存器,浮点寄存器是通过浮点扩展指令引入的,这就需要在-march选项中指定浮点扩展。

RISC-V GCC 使用手册对-mabi选项的说明:

-mabi=ABI-string
.
Specify integer and floating-point calling convention. ABI-string contains two parts: the size of integer types and the registers used for floating-point types. For example -march=rv64ifd -mabi=lp64d means that long and pointers are 64-bit (implicitly defining int to be 32-bit), and that floating-point values up to 64 bits wide are passed in F registers. Contrast this with -march=rv64ifd -mabi=lp64f, which still allows the compiler to generate code that uses the F and D extensions but only allows floating-point values up to 32 bits long to be passed in registers; or -march=rv64ifd -mabi=lp64, in which no floating-point arguments will be passed in registers.
.
The default for this argument is system dependent, users who want a specific calling convention should specify one explicitly. The valid calling conventions are: ilp32, ilp32f, ilp32d, lp64, lp64f, and lp64d. Some calling conventions are impossible to implement on some ISAs: for example, -march=rv32if -mabi=ilp32d is invalid because the ABI requires 64-bit values be passed in F registers, but F registers are only 32 bits wide.

  • 8
    点赞
  • 24
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值