libjit
[Top][All Lists]
Advanced

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

[Libjit] Basic float32 issue


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

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

Thanks,
Matt

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

    context = jit_context_create();
    jit_context_build_start(context);

    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_compile(function);
    jit_context_build_end(context);
    jit_function_apply(function, NULL, &result);
    printf("const(13) = %f\n", (float)result);

    jit_context_destroy(context);
}




reply via email to

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