Patchwork [Ada] Use subtraction to negate VAX float on Alpha VMS

login
register
mail settings
Submitter Arnaud Charlet
Date Aug. 29, 2011, 8:37 a.m.
Message ID <20110829083729.GA1449@adacore.com>
Download mbox | patch
Permalink /patch/111977/
State New
Headers show

Comments

Arnaud Charlet - Aug. 29, 2011, 8:37 a.m.
Using "cpysn" just flips the sign bit, but that will generate an
invalid VAX Float for an input value of 0.0, as VAX float formats
do not allow signed zeros.

The following should compile and execute successfully.

procedure test1 is
   XX, YY, ZZ : Long_Float;
begin
   XX := 0.0;
   YY := 1.1;
   ZZ := -XX * YY;

   if ZZ /= 0.0 then
      raise Program_Error;
   end if;
end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2011-08-29  Geert Bosch  <bosch@adacore.com>

	* s-vaflop-vms-alpha.adb (Neg_F): Use subtraction instead of negation
	instruction, as the latter may produce -0.0, which is not a valid VAX
	F float number.
	(Neg_G): Likewise for VAX F float.

Patch

Index: s-vaflop-vms-alpha.adb
===================================================================
--- s-vaflop-vms-alpha.adb	(revision 178160)
+++ s-vaflop-vms-alpha.adb	(working copy)
@@ -536,7 +536,7 @@ 
       C    : F;
    begin
       Asm ("ldf %0,%1", S'Asm_Output ("=f", A), F'Asm_Input ("m", X));
-      Asm ("cpysn %1,%1,%0", S'Asm_Output ("=f", B), S'Asm_Input ("f", A));
+      Asm ("subf $f31,%1,%0", S'Asm_Output ("=f", B), S'Asm_Input ("f", A));
       Asm ("stf %1,%0", F'Asm_Output ("=m", C), S'Asm_Input ("f", B));
       return C;
    end Neg_F;
@@ -550,7 +550,7 @@ 
       C    : G;
    begin
       Asm ("ldg %0,%1", T'Asm_Output ("=f", A), G'Asm_Input ("m", X));
-      Asm ("cpysn %1,%1,%0", T'Asm_Output ("=f", B), T'Asm_Input ("f", A));
+      Asm ("subg $f31,%1,%0", T'Asm_Output ("=f", B), T'Asm_Input ("f", A));
       Asm ("stg %1,%0", G'Asm_Output ("=m", C), T'Asm_Input ("f", B));
       return C;
    end Neg_G;