This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Soft float support and casting


Hello!

I'm working on adding floating point support to Cibyl, my MIPS to Java
bytecode binary translator. After having studied the MIPS FPU and
NestedVM, I've decided that it's easier to rely on GCC's -msoft-float
option and implementing efficient versions of the library routines
(normally found in libgcc).

I believe I will be able to fairly easily construct efficient
implementations by invoking Java code which works on "native" floats,
i.e., something like


   /* C implementation */
   float __addsf3(float a, float b)
   {
     /* This is actually a call to the Java method below */
     return __addsf3_helper(a,b);
   }

   /* Java method */
   public static int __addsf3_helper(int _a, int _b)
   {
     float a = Float.intBitsToFloat(_a);
     float b = Float.intBitsToFloat(_b);

     return Float.floatToIntBits(a + b);
   }


I've looked in libgcc2.c and am unfortunately a bit unsure about how
to get GCC to directly cast an integer value to a float type. For
example, I would like to do something like this:

   float __floatsisf(long i)
   {
       return (float)0x40c00000; /* float value 6.0 */
   }

but the cast will of course turn this into some completely different
number. Can someone quickly explain how to do this?

// Simon


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]