Bladeren bron

Avoid inlining of real constant for m68k if type is not best precision

git-svn-id: trunk@48224 -
pierre 4 jaren geleden
bovenliggende
commit
4111e13017
1 gewijzigde bestanden met toevoegingen van 13 en 8 verwijderingen
  1. 13 8
      compiler/m68k/n68kadd.pas

+ 13 - 8
compiler/m68k/n68kadd.pas

@@ -26,7 +26,7 @@ unit n68kadd;
 interface
 interface
 
 
     uses
     uses
-       node,nadd,ncgadd,cpubase,cgbase;
+       symtype,node,nadd,ncgadd,cpubase,cgbase;
 
 
 
 
     type
     type
@@ -34,7 +34,7 @@ interface
        private
        private
           function getresflags(unsigned: boolean) : tresflags;
           function getresflags(unsigned: boolean) : tresflags;
           function getfloatresflags: tresflags;
           function getfloatresflags: tresflags;
-          function inlineable_realconstnode(const n: tnode): boolean;
+          function inlineable_realconstnode(const n: tnode; fpu_type : tdef): boolean;
           procedure second_mul64bit;
           procedure second_mul64bit;
        protected
        protected
           function use_generic_mul64bit: boolean; override;
           function use_generic_mul64bit: boolean; override;
@@ -55,7 +55,7 @@ implementation
     uses
     uses
       globtype,systems,
       globtype,systems,
       cutils,verbose,globals,
       cutils,verbose,globals,
-      symconst,symdef,paramgr,symtype,
+      symconst,symdef,paramgr,
       aasmbase,aasmtai,aasmdata,aasmcpu,defutil,htypechk,
       aasmbase,aasmtai,aasmdata,aasmcpu,defutil,htypechk,
       cpuinfo,pass_1,pass_2,
       cpuinfo,pass_1,pass_2,
       cpupara,cgutils,procinfo,
       cpupara,cgutils,procinfo,
@@ -146,9 +146,14 @@ implementation
       end;
       end;
 
 
 
 
-    function t68kaddnode.inlineable_realconstnode(const n: tnode): boolean;
+    function t68kaddnode.inlineable_realconstnode(const n: tnode; fpu_type : tdef): boolean;
       begin
       begin
-        result:=(n.nodetype = realconstn) and
+        if assigned(fpu_type) and
+	   ((FPUM68K_HAS_EXTENDED in fpu_capabilities[current_settings.fputype])
+            or (fpu_type.size < sizeof(bestreal))) then
+          result:=false
+        else
+          result:=(n.nodetype = realconstn) and
             not ((trealconstnode(n).value_real=MathInf.Value) or
             not ((trealconstnode(n).value_real=MathInf.Value) or
                  (trealconstnode(n).value_real=MathNegInf.Value) or
                  (trealconstnode(n).value_real=MathNegInf.Value) or
                  (trealconstnode(n).value_real=MathQNaN.value));
                  (trealconstnode(n).value_real=MathQNaN.value));
@@ -191,7 +196,7 @@ implementation
 
 
         { have left in the register, right can be a memory location }
         { have left in the register, right can be a memory location }
         if (FPUM68K_HAS_FLOATIMMEDIATE in fpu_capabilities[current_settings.fputype]) and
         if (FPUM68K_HAS_FLOATIMMEDIATE in fpu_capabilities[current_settings.fputype]) and
-           inlineable_realconstnode(left) then
+           inlineable_realconstnode(left,resultdef) then
           begin
           begin
             location.register := cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
             location.register := cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
             current_asmdata.CurrAsmList.concat(taicpu.op_realconst_reg(A_FMOVE,tcgsize2opsize[left.location.size],trealconstnode(left).value_real,location.register))
             current_asmdata.CurrAsmList.concat(taicpu.op_realconst_reg(A_FMOVE,tcgsize2opsize[left.location.size],trealconstnode(left).value_real,location.register))
@@ -211,7 +216,7 @@ implementation
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
               begin
               begin
                 if (FPUM68K_HAS_FLOATIMMEDIATE in fpu_capabilities[current_settings.fputype]) and
                 if (FPUM68K_HAS_FLOATIMMEDIATE in fpu_capabilities[current_settings.fputype]) and
-                   inlineable_realconstnode(right) then
+                   inlineable_realconstnode(right,resultdef) then
                   current_asmdata.CurrAsmList.concat(taicpu.op_realconst_reg(op,tcgsize2opsize[right.location.size],trealconstnode(right).value_real,location.register))
                   current_asmdata.CurrAsmList.concat(taicpu.op_realconst_reg(op,tcgsize2opsize[right.location.size],trealconstnode(right).value_real,location.register))
                 else
                 else
                   begin
                   begin
@@ -284,7 +289,7 @@ implementation
                   begin
                   begin
                     hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
                     hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
                     if not (current_settings.fputype = fpu_coldfire) and
                     if not (current_settings.fputype = fpu_coldfire) and
-                       inlineable_realconstnode(right) then
+                       inlineable_realconstnode(right,left.resultdef) then
                       current_asmdata.CurrAsmList.concat(taicpu.op_realconst_reg(A_FCMP,tcgsize2opsize[right.location.size],trealconstnode(right).value_real,left.location.register))
                       current_asmdata.CurrAsmList.concat(taicpu.op_realconst_reg(A_FCMP,tcgsize2opsize[right.location.size],trealconstnode(right).value_real,left.location.register))
                     else
                     else
                       begin
                       begin