[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libjit] Basic float32 issue

From: Matthew Keeter
Subject: Re: [Libjit] Basic float32 issue
Date: Sat, 16 Apr 2016 21:52:59 -0400

Digging a little deeper, the IR looks fine but the generated assembly is missing a data / bss section with float constants:

Before compiling:
function test() : float32

After compiling:
function test() : float32

/tmp/libjit-dump.o:     file format mach-o-x86-64

Disassembly of section .text:

000000010413914c <.text>:
   10413914c:   55                      push   %rbp
   10413914d:   48 8b ec                mov    %rsp,%rbp
   104139150:   f3 0f 10 05 78 fe 00    movss  0xfe78(%rip),%xmm0        # 0x104148fd0
   104139157:   00
   104139158:   48 8b e5                mov    %rbp,%rsp
   10413915b:   5d                      pop    %rbp
   10413915c:   c3                      retq


In particular, note that
    movss  0xfe78(%rip),%xmm0        # 0x104148fd0
is pointing off into space.

Does this ring any bells?


On Apr 16, 2016, at 9:09 PM, Matthew Keeter <address@hidden> wrote:

Hi all,

I’m having trouble with floating-point operations and have reduced to a very simple test case.
The code below creates a function with no arguments that just returns a float32 constant.

For some reason, instead of returning the constant’s value, it always gives zero.

Identical code with jit_type_int works fine, so I’m puzzled as to what’s going on.
Any ideas?  The code is pasted below


   jit_context_t context;
   jit_type_t signature;
   jit_function_t function;
   jit_value_t c;
   jit_float32 result;

   context = jit_context_create();

   signature = jit_type_create_signature
       (jit_abi_cdecl, jit_type_float32, NULL, 0, 1);

   function = jit_function_create(context, signature);

   c = jit_value_create_float32_constant(function, jit_type_float32, (jit_float32)13.0f);
   jit_insn_return(function, c);

   jit_function_apply(function, NULL, &result);
   printf("const(13) = %f\n", (float)result);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]