SSE注册返回SSE禁用 [英] SSE register return with SSE disabled

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

问题描述

我在以下情况:


  • 我正在为不允许SSE指令的内核写代码

  • 我需要做浮点算法
  • 我正在为x86_64平台编译



下面是一个代码示例,说明了这个问题:

$ p $ 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 \ n,d,dbase);
base_value = dbase;
printf(base_value =%llu \ n,(long long unsigned)base_value);
返回0;





这里是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

当我运行一个构建时,我得到这个错误:

  SSE寄存器返回SSE禁用

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

任何想法我可以做什么来解决这个问题?删除-mno-sse不是一个选项,但是好像编译器应该能够生成非sse代码来完成乘法操作。



感谢
Nathan

解决方案

听起来好像编译器正在发出对库例程的调用,为您做浮点乘法(大概没有使用SSE),但正试图使用​​一个ABI的具有在SSE中传递的返回值的调用。显然,这是行不通的。

如果在你的内核中完全可以使用浮点,那么应该有一个特殊的运行时间库来做软浮动操作不使用通常的(userland)参数传递和返回约定。但据我所知,在BSD内核中不支持浮点。几年前的情况确实如此。

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

I am in the following situation:

  • I am writing code for a kernel that does not allow SSE instructions
  • I need to do floating-point arithmetic
  • I'm compiling for a x86_64 platform

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\n", d, dbase);
    base_value = dbase;
    printf("base_value = %llu\n", (long long unsigned)base_value);
    return 0;
}

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

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

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.

Thanks Nathan

解决方案

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.

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.

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天全站免登陆