SSE 寄存器返回,SSE 禁用 [英] SSE register return with SSE disabled

查看:108
本文介绍了SSE 寄存器返回,SSE 禁用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况如下:

  • 我正在为不允许 SSE 指令的内核编写代码
  • 我需要做浮点运算
  • 我正在为 x86_64 平台进行编译

这是一个说明问题的代码示例:

Here is a code sample that illustrates the problem:

int
main(int argc, char** argv)
{
    double d = 0.0, dbase;
    uint64_t base_value = 300;

    d = (2200.0 - 1000.0)/(1000.0);
    dbase = d * base_value;
    printf("d = %f, dbase = %f
", d, dbase);
    base_value = dbase;
    printf("base_value = %llu
", (long long unsigned)base_value);
    return 0;
}

这里是 makefile 中的相关行:

And here is the relevant line from the makefile:

CFLAGS +=   -mcmodel=kernel -mno-red-zone -mfpmath=387 -mno-sse -mno-sse2 -mno-mmx -mno-3dnow 
            -msoft-float -fno-asynchronous-unwind-tables -fno-omit-frame-pointer

运行构建时出现此错误:

When I run a build I get this error:

SSE register return with SSE disabled

(错误指向d和base_value相乘的那一行)

(The error points to the line that multiplies d and base_value)

知道我能做些什么来解决这个问题吗?删除 -mno-sse 不是一种选择,但似乎编译器应该能够生成非 sse 代码来进行乘法运算.

Any idea what I can do to fix this? Removing -mno-sse is not an option, but it seems like the compiler should be able to generate non-sse code to do the multiply.

谢谢内森

推荐答案

听起来编译器正在调用库例程来为您执行浮点乘法(大概不使用 SSE),但正在尝试使用具有在 SSE 中传递的返回值的调用的 ABI.显然,这是行不通的.

It sounds like the compiler is emitting a call to a library routine to do the floating point multiply for you (presumably without using SSE), but is trying to use an ABI for the call that has the return value passed in SSE. Obviously, that doesn't work.

如果在你的内核中完全可以使用浮点,那么应该有一个特殊的运行时库来执行不使用通常的(用户态)参数传递和返回约定的软浮点操作.但是,据我所知,BSD 内核中不支持浮点.几年前肯定是这样.

If it is possible at all to use floating-point at all in your kernel, there should be a special runtime library to do soft-float operations that does not use the usual (userland) argument passing and return conventions. However, as far as I know, there is no support for floating-point in the BSD kernel. That was certainly the case a few years ago.

您可能应该只询问 BSD 内核开发电子邮件列表是否可以使用浮点;我怀疑它会给你一个比 SO 更快更明确的答案.

You should probably just ask the BSD kernel dev email list whether or not it is possible to use floating-point; I suspect it will give you a faster more definitive answer than SO.

这篇关于SSE 寄存器返回,SSE 禁用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆