什么是__float128,如果我在x86_64上使用gcc 4.9? [英] What exactly is a __float128 if I'm using gcc 4.9 on x86_64?

查看:1562
本文介绍了什么是__float128,如果我在x86_64上使用gcc 4.9?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  int main(){
double a,b,c;
scanf(%lf%lf%lf,& a,& b,& c);
__float128 foo = a;
foo + = b; foo + = c;
printf(%f\\\
,(double)foo);



$ b $ $ $ $ $ $主要
编译( -O3)到以下内容:

  400630:48 83 ec 38 sub $ 0x38,%rsp 
400634:bf 34 08 40 00 mov $ 0x400834,%edi
400639:31 c0 xor%eax,%eax
40063b:48 8d 4c 24 28 lea 0x28(%rsp),%rcx
400640: 48 8d 54 24 20 lea 0x20(%rsp),%rdx
400645:48 8d 74 24 18 lea 0x18(%rsp),%rsi
40064a:e8 c1 ff ff ff callq 400610< scanf @ PLT>
40064f:f2 0f 10 44 24 18 movsd 0x18(%rsp),%xmm0
400655:e8 a6 ff ff ff callq 400600< _ extenddftf2 @ plt>
40065a:0f 29 04 24 movaps%xmm0,(%rsp)
40065e:f2 0f 10 44 24 20 movsd 0x20(%rsp),%xmm0
400664:e8 97 ff ff ff callq 400600< __ extenddftf2 @ plt>
400669:66 0f 6f 0c 24 movdqa(%rsp),%xmm1
40066e:e8 5d ff ff ff callq 4005d0< __ addtf3 @ plt> (%rsp)
400677:f2 0f 10 44 24 28 movsd 0x28(%rsp),%xmm0
40067d:e8 7e ff ff callq 400600< __ extenddftf2 @ plt>
400682:66 0f 6f 0c 24 movdqa(%rsp),%xmm1
400687:e8 44 ff ff ff callq 4005d0< __ addtf3 @ plt>
40068c:e8 8f ff ff ff callq 400620< __ trunctfdf2 @ plt>
400691:bf 3a 08 40 00 mov $ 0x40083a,%edi
400696:b8 01 00 00 00 mov $ 0x1,%eax
40069b:e8 20 ff ff ff callq 4005c0< printf @ PLT>
4006a0:31 c0 xor%eax,%eax
4006a2:48 83 c4 38 add $ 0x38,%rsp
4006a6:c3 retq

通过在 __ addtf3 中设置断点并在 gdb ,我看到一个算术和条件的泥沼。我没有打算阅读它,但它确实不像 double double 加法的代码。



这些软件是四倍精度的浮点数吗?如果是这样的话,是什么格式?

__ float128 会有所不同,这取决于目标和ABI GCC正在使用。



文档说:


  • TFmode

    Tetra Floating模式代表一个十六个字节的浮点数所有的128位都是有意义的。一种常见的用途是IEEE四倍精度格式。



在x86_64上支持TFmode是由此修补程序 GCC 4.3发行说明确认对于x86_64,它是IEEE四种格式:


  • 支持(TFmode)IEEE四类型和相应的TCmode IEEE复合四类型可通过x86_64目标上的soft-fp库获得。

I wrote a simple program, thinking I could find out from the disassembly:

int main() {
  double a, b, c;
  scanf("%lf %lf %lf", &a, &b, &c);
  __float128 foo = a;
  foo += b; foo += c;
  printf("%f\n", (double)foo);
}

main compiles (-O3) to the following:

  400630:       48 83 ec 38             sub    $0x38,%rsp
  400634:       bf 34 08 40 00          mov    $0x400834,%edi
  400639:       31 c0                   xor    %eax,%eax
  40063b:       48 8d 4c 24 28          lea    0x28(%rsp),%rcx
  400640:       48 8d 54 24 20          lea    0x20(%rsp),%rdx
  400645:       48 8d 74 24 18          lea    0x18(%rsp),%rsi
  40064a:       e8 c1 ff ff ff          callq  400610 <scanf@plt>
  40064f:       f2 0f 10 44 24 18       movsd  0x18(%rsp),%xmm0
  400655:       e8 a6 ff ff ff          callq  400600 <__extenddftf2@plt>
  40065a:       0f 29 04 24             movaps %xmm0,(%rsp)
  40065e:       f2 0f 10 44 24 20       movsd  0x20(%rsp),%xmm0
  400664:       e8 97 ff ff ff          callq  400600 <__extenddftf2@plt>
  400669:       66 0f 6f 0c 24          movdqa (%rsp),%xmm1
  40066e:       e8 5d ff ff ff          callq  4005d0 <__addtf3@plt>
  400673:       0f 29 04 24             movaps %xmm0,(%rsp)
  400677:       f2 0f 10 44 24 28       movsd  0x28(%rsp),%xmm0
  40067d:       e8 7e ff ff ff          callq  400600 <__extenddftf2@plt>
  400682:       66 0f 6f 0c 24          movdqa (%rsp),%xmm1
  400687:       e8 44 ff ff ff          callq  4005d0 <__addtf3@plt>
  40068c:       e8 8f ff ff ff          callq  400620 <__trunctfdf2@plt>
  400691:       bf 3a 08 40 00          mov    $0x40083a,%edi
  400696:       b8 01 00 00 00          mov    $0x1,%eax
  40069b:       e8 20 ff ff ff          callq  4005c0 <printf@plt>
  4006a0:       31 c0                   xor    %eax,%eax
  4006a2:       48 83 c4 38             add    $0x38,%rsp
  4006a6:       c3                      retq

When I look at the disassembly of __addtf3 by setting a breakpoint there and running the program under gdb, I see a morass of arithmetic and conditionals. I didn't bother trying to read it, but it sure didn't look like the code for double double addition.

Are these software quad-precision floating-point numbers? If so, what format?

解决方案

GCC's __float128 coresponds to its internal "TFmode" format, which varies depending on the target and the ABI that GCC is using.

The documentation says:

  • TFmode
    "Tetra Floating" mode represents a sixteen byte floating point number all 128 of whose bits are meaningful. One common use is the IEEE quad-precision format.

Support for TFmode on x86_64 was added by this patch and the GCC 4.3 release notes confirm that for x86_64 it is IEEE quad format:

  • Support for __float128 (TFmode) IEEE quad type and corresponding TCmode IEEE complex quad type is available via the soft-fp library on x86_64 targets.

这篇关于什么是__float128,如果我在x86_64上使用gcc 4.9?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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