瀏覽代碼

+ second_floataddsse implemented

florian 21 年之前
父節點
當前提交
d1116fb7f1
共有 4 個文件被更改,包括 99 次插入12 次删除
  1. 24 7
      compiler/cgobj.pas
  2. 6 1
      compiler/ncgadd.pas
  3. 22 1
      compiler/ncgutil.pas
  4. 47 3
      compiler/x86/nx86add.pas

+ 24 - 7
compiler/cgobj.pas

@@ -229,11 +229,12 @@ unit cgobj;
           procedure a_loadmm_loc_reg(list: taasmoutput; size: tcgsize; const loc: tlocation; const reg: tregister;shuffle : pmmshuffle);
           procedure a_loadmm_reg_loc(list: taasmoutput; size: tcgsize; const reg: tregister; const loc: tlocation;shuffle : pmmshuffle);
           procedure a_parammm_reg(list: taasmoutput; size: tcgsize; reg: tregister;const locpara : tparalocation;shuffle : pmmshuffle); virtual;
-          procedure a_parammm_ref(list: taasmoutput; size: tcgsize; ref: treference;const locpara : tparalocation;shuffle : pmmshuffle); virtual;
-          procedure a_parammm_loc(list: taasmoutput; loc: tlocation; const locpara : tparalocation;shuffle : pmmshuffle); virtual;
+          procedure a_parammm_ref(list: taasmoutput; size: tcgsize; const ref: treference;const locpara : tparalocation;shuffle : pmmshuffle); virtual;
+          procedure a_parammm_loc(list: taasmoutput; const loc: tlocation; const locpara : tparalocation;shuffle : pmmshuffle); virtual;
           procedure a_opmm_reg_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;src,dst: tregister;shuffle : pmmshuffle); virtual;abstract;
           procedure a_opmm_ref_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle); virtual;
-          procedure a_opmm_reg_ref(list: taasmoutput; Op: TOpCG; size : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle); virtual;
+          procedure a_opmm_loc_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;const loc: tlocation; reg: tregister;shuffle : pmmshuffle); virtual;
+          procedure a_opmm_reg_ref(list: taasmoutput; Op: TOpCG; size : tcgsize;reg: tregister;const ref: treference; shuffle : pmmshuffle); virtual;
 
           { basic arithmetic operations }
           { note: for operators which require only one argument (not, neg), use }
@@ -1366,7 +1367,7 @@ implementation
       end;
 
 
-    procedure tcg.a_parammm_ref(list: taasmoutput; size: tcgsize; ref: treference;const locpara : tparalocation;shuffle : pmmshuffle);
+    procedure tcg.a_parammm_ref(list: taasmoutput; size: tcgsize;const ref: treference;const locpara : tparalocation;shuffle : pmmshuffle);
       var
          hr : tregister;
          hs : tmmshuffle;
@@ -1385,7 +1386,7 @@ implementation
       end;
 
 
-    procedure tcg.a_parammm_loc(list: taasmoutput; loc: tlocation; const locpara : tparalocation;shuffle : pmmshuffle);
+    procedure tcg.a_parammm_loc(list: taasmoutput;const loc: tlocation; const locpara : tparalocation;shuffle : pmmshuffle);
       begin
         case loc.loc of
           LOC_MMREGISTER,LOC_CMMREGISTER:
@@ -1403,11 +1404,24 @@ implementation
       end;
 
 
-    procedure tcg.a_opmm_reg_ref(list: taasmoutput; Op: TOpCG; size : tcgsize;const ref: treference; reg: tregister;shuffle : pmmshuffle);
+    procedure tcg.a_opmm_reg_ref(list: taasmoutput; Op: TOpCG; size : tcgsize;reg: tregister; const ref: treference; shuffle : pmmshuffle);
       begin
       end;
 
 
+    procedure tcg.a_opmm_loc_reg(list: taasmoutput; Op: TOpCG; size : tcgsize;const loc: tlocation; reg: tregister;shuffle : pmmshuffle);
+      begin
+        case loc.loc of
+          LOC_CMMREGISTER,LOC_MMREGISTER:
+            a_opmm_reg_reg(list,op,size,loc.register,reg,shuffle);
+          LOC_CREFERENCE,LOC_REFERENCE:
+            a_opmm_ref_reg(list,op,size,loc.reference,reg,shuffle);
+          else
+            internalerror(200312232);
+        end;
+      end;
+
+
     class function tcg.reg_cgsize(const reg: tregister) : tcgsize;
       begin
         reg_cgsize := OS_INT;
@@ -1986,7 +2000,10 @@ finalization
 end.
 {
   $Log$
-  Revision 1.142  2003-12-22 19:00:17  florian
+  Revision 1.143  2003-12-23 14:38:07  florian
+    + second_floataddsse implemented
+
+  Revision 1.142  2003/12/22 19:00:17  florian
     * fixed some x86-64 issues
 
   Revision 1.141  2003/12/21 19:42:42  florian

+ 6 - 1
compiler/ncgadd.pas

@@ -716,10 +716,12 @@ interface
                should not be used.}
               if (tsetdef(left.resulttype.def).settype<>smallset) then
                 begin
+{$ifdef SUPPORT_MMX}
                 {$ifdef i386}
                   if cs_mmx in aktlocalswitches then
                     second_opmmxset
                   else
+{$endif SUPPORT_MMX}
                 {$endif}
                     internalerror(200109041);
                 end
@@ -747,7 +749,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.23  2003-12-21 11:28:41  daniel
+  Revision 1.24  2003-12-23 14:38:07  florian
+    + second_floataddsse implemented
+
+  Revision 1.23  2003/12/21 11:28:41  daniel
     * Some work to allow mmx instructions to be used for 32 byte sets
 
   Revision 1.22  2003/10/17 01:22:08  florian

+ 22 - 1
compiler/ncgutil.pas

@@ -47,6 +47,7 @@ interface
     procedure location_force_reg(list:TAAsmoutput;var l:tlocation;dst_size:TCGSize;maybeconst:boolean);
     procedure location_force_fpureg(list:TAAsmoutput;var l: tlocation;maybeconst:boolean);
     procedure location_force_mem(list:TAAsmoutput;var l:tlocation);
+    procedure location_force_mmregscalar(list:TAAsmoutput;var l: tlocation;maybeconst:boolean);
 
     function  maybe_pushfpu(list:taasmoutput;needed : byte;var l:tlocation) : boolean;
 
@@ -618,6 +619,23 @@ implementation
       end;
 
 
+    procedure location_force_mmregscalar(list:TAAsmoutput;var l: tlocation;maybeconst:boolean);
+      var
+        reg : tregister;
+      begin
+        if (l.loc<>LOC_MMREGISTER)  and
+           ((l.loc<>LOC_CMMREGISTER) or (not maybeconst)) then
+          begin
+            reg:=cg.getmmregister(list,l.size);
+            cg.a_loadmm_loc_reg(list,l.size,l,reg,mms_movescalar);
+            location_freetemp(list,l);
+            location_release(list,l);
+            location_reset(l,LOC_MMREGISTER,l.size);
+            l.register:=reg;
+          end;
+      end;
+
+
     procedure location_force_mem(list:TAAsmoutput;var l:tlocation);
       var
         r : treference;
@@ -2001,7 +2019,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.175  2003-12-22 19:00:17  florian
+  Revision 1.176  2003-12-23 14:38:07  florian
+    + second_floataddsse implemented
+
+  Revision 1.175  2003/12/22 19:00:17  florian
     * fixed some x86-64 issues
 
   Revision 1.174  2003/12/07 16:28:30  jonas

+ 47 - 3
compiler/x86/nx86add.pas

@@ -30,23 +30,67 @@ unit nx86add;
   interface
 
     uses
-       node,nadd,cpubase;
+       node,nadd,ncgadd,cpubase;
 
     type
-       tx86addnode = class(taddnode)
+       tx86addnode = class(tcgaddnode)
          procedure second_floataddsse;
        end;
 
 
   implementation
 
+    uses
+      verbose,
+      aasmtai,
+      cgbase,cgobj,
+      ncgutil,
+      defutil;
+
     procedure tx86addnode.second_floataddsse;
+      var
+        op : topcg;
       begin
+        pass_left_right;
+        if (nf_swaped in flags) then
+          swapleftright;
+
+        case nodetype of
+          addn :
+            op:=OP_ADD;
+          muln :
+            op:=OP_MUL;
+          subn :
+            op:=OP_SUB;
+          slashn :
+            op:=OP_DIV;
+          else
+            internalerror(200312231);
+        end;
+
+        location_reset(location,LOC_MMREGISTER,def_cgsize(resulttype.def));
+        { we can use only right as left operand if the operation is commutative }
+        if (right.location.loc=LOC_MMREGISTER) and (op in [OP_ADD,OP_MUL]) then
+          begin
+            location.register:=right.location.register;
+            cg.a_opmm_loc_reg(exprasmlist,op,location.size,left.location,location.register,mms_movescalar);
+            location_release(exprasmlist,left.location);
+          end
+        else
+          begin
+            location_force_mmregscalar(exprasmlist,left.location,false);
+            location.register:=left.location.register;
+            cg.a_opmm_loc_reg(exprasmlist,op,location.size,right.location,location.register,mms_movescalar);
+            location_release(exprasmlist,right.location);
+          end;
       end;
 
 end.
 {
   $Log$
-  Revision 1.1  2003-10-13 01:58:04  florian
+  Revision 1.2  2003-12-23 14:38:07  florian
+    + second_floataddsse implemented
+
+  Revision 1.1  2003/10/13 01:58:04  florian
     * some ideas for mm support implemented
 }