Ver Fonte

m68k: support and use float TResFlags in the rest of the CG. ColdFire FPU now works, and FSxx is no longer generated which is software supported on '060, and doesn't exist on CF. if we still want to support it later, we can add it to cg.g_flags2reg

git-svn-id: trunk@33558 -
Károly Balogh há 9 anos atrás
pai
commit
4287f81b92
2 ficheiros alterados com 47 adições e 12 exclusões
  1. 16 1
      compiler/m68k/cgcpu.pas
  2. 31 11
      compiler/m68k/n68kadd.pas

+ 16 - 1
compiler/m68k/cgcpu.pas

@@ -1433,7 +1433,10 @@ unit cgcpu;
        var
        var
          ai : taicpu;
          ai : taicpu;
        begin
        begin
-         ai := Taicpu.op_sym(A_BXX,S_NO,l);
+         if not (f in FloatResFlags) then
+           ai := Taicpu.op_sym(A_BXX,S_NO,l)
+         else
+           ai := Taicpu.op_sym(A_FBXX,S_NO,l);
          ai.SetCondition(flags_to_cond(f));
          ai.SetCondition(flags_to_cond(f));
          ai.is_jmp := true;
          ai.is_jmp := true;
          list.concat(ai);
          list.concat(ai);
@@ -1444,7 +1447,19 @@ unit cgcpu;
          ai : taicpu;
          ai : taicpu;
          hreg : tregister;
          hreg : tregister;
          instr : taicpu;
          instr : taicpu;
+         htrue: tasmlabel;
        begin
        begin
+          if (f in FloatResFlags) then
+            begin
+              //list.concat(tai_comment.create(strpnew('flags2reg: float resflags')));
+              current_asmdata.getjumplabel(htrue);
+              a_load_const_reg(current_asmdata.CurrAsmList,OS_32,1,reg);
+              a_jmp_flags(list, f, htrue);
+              a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,reg);
+              a_label(current_asmdata.CurrAsmList,htrue);
+              exit;
+            end;
+
           { move to a Dx register? }
           { move to a Dx register? }
           if (isaddressregister(reg)) then
           if (isaddressregister(reg)) then
             hreg:=getintregister(list,OS_INT)
             hreg:=getintregister(list,OS_INT)

+ 31 - 11
compiler/m68k/n68kadd.pas

@@ -33,6 +33,7 @@ interface
        t68kaddnode = class(tcgaddnode)
        t68kaddnode = class(tcgaddnode)
        private
        private
           function getresflags(unsigned: boolean) : tresflags;
           function getresflags(unsigned: boolean) : tresflags;
+          function getfloatresflags: tresflags;
        protected
        protected
           procedure second_addfloat;override;
           procedure second_addfloat;override;
           procedure second_cmpfloat;override;
           procedure second_cmpfloat;override;
@@ -110,6 +111,34 @@ implementation
       end;
       end;
 
 
 
 
+    function t68kaddnode.getfloatresflags : tresflags;
+      begin
+        case nodetype of
+          equaln : getfloatresflags:=F_FE;
+          unequaln : getfloatresflags:=F_FNE;
+          else
+            if nf_swapped in flags then
+              case nodetype of
+                ltn : getfloatresflags:=F_FG;
+                lten : getfloatresflags:=F_FGE;
+                gtn : getfloatresflags:=F_FL;
+                gten : getfloatresflags:=F_FLE;
+                else
+                  internalerror(201604260);
+              end
+            else
+              case nodetype of
+                ltn : getfloatresflags:=F_FL;
+                lten : getfloatresflags:=F_FLE;
+                gtn : getfloatresflags:=F_FG;
+                gten : getfloatresflags:=F_FGE;
+                else
+                  internalerror(201604261);
+              end;
+        end;
+      end;
+
+
 {*****************************************************************************
 {*****************************************************************************
                                 AddFloat
                                 AddFloat
 *****************************************************************************}
 *****************************************************************************}
@@ -201,17 +230,8 @@ implementation
                   internalerror(2015021502);
                   internalerror(2015021502);
               end;
               end;
 
 
-              // temporary(?) hack, move condition result back to the CPU from the FPU.
-              // 6888x has its own FBcc branch instructions and FScc flags->reg instruction,
-              // which we don't support yet in the rest of the cg. (KB)
-              tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_8);
-              ai:=taicpu.op_reg(A_FSxx,S_B,tmpreg);
-              ai.SetCondition(flags_to_cond(getresflags(false)));
-              current_asmdata.CurrAsmList.concat(ai);
-              current_asmdata.CurrAsmList.concat(taicpu.op_reg(A_NEG,S_B,tmpreg));
-
-              location_reset(location,LOC_REGISTER,OS_8);
-              location.register:=tmpreg;
+              location_reset(location,LOC_FLAGS,OS_NO);
+              location.resflags:=getfloatresflags;
             end;
             end;
           else
           else
             // softfpu should be handled in pass1, others are not yet supported...
             // softfpu should be handled in pass1, others are not yet supported...