Browse Source

* remove registers{int/mmx/fpu} from firstpass
* small cleanups of unused variables in firstpass
* node_resources_fpu() created to get an approximation of the
required fpu registers
* for the moment use node_complexity in the CG until the
node_resource_int() is created

git-svn-id: trunk@8655 -

peter 18 years ago
parent
commit
6b8aed593f

+ 0 - 2
compiler/arm/narmcnv.pas

@@ -108,8 +108,6 @@ implementation
                 firstpass(left);
                 firstpass(left);
               end;
               end;
             result := nil;
             result := nil;
-            if registersfpu<1 then
-              registersfpu:=1;
             expectloc:=LOC_FPUREGISTER;
             expectloc:=LOC_FPUREGISTER;
           end;
           end;
       end;
       end;

+ 0 - 14
compiler/arm/narminl.pas

@@ -92,8 +92,6 @@ implementation
         else
         else
           begin
           begin
             expectloc:=LOC_FPUREGISTER;
             expectloc:=LOC_FPUREGISTER;
-            registersint:=left.registersint;
-            registersfpu:=max(left.registersfpu,1);
             first_abs_real:=nil;
             first_abs_real:=nil;
           end;
           end;
       end;
       end;
@@ -106,8 +104,6 @@ implementation
         else
         else
           begin
           begin
             expectloc:=LOC_FPUREGISTER;
             expectloc:=LOC_FPUREGISTER;
-            registersint:=left.registersint;
-            registersfpu:=max(left.registersfpu,1);
             first_sqr_real:=nil;
             first_sqr_real:=nil;
           end;
           end;
       end;
       end;
@@ -120,8 +116,6 @@ implementation
         else
         else
           begin
           begin
             expectloc:=LOC_FPUREGISTER;
             expectloc:=LOC_FPUREGISTER;
-            registersint:=left.registersint;
-                    registersfpu:=max(left.registersfpu,1);
             first_sqrt_real := nil;
             first_sqrt_real := nil;
           end;
           end;
       end;
       end;
@@ -131,8 +125,6 @@ implementation
     function tarminlinenode.first_arctan_real: tnode;
     function tarminlinenode.first_arctan_real: tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
         result:=nil;
         result:=nil;
       end;
       end;
 
 
@@ -140,16 +132,12 @@ implementation
     function tarminlinenode.first_ln_real: tnode;
     function tarminlinenode.first_ln_real: tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
         result:=nil;
         result:=nil;
       end;
       end;
 
 
     function tarminlinenode.first_cos_real: tnode;
     function tarminlinenode.first_cos_real: tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
         result:=nil;
         result:=nil;
       end;
       end;
 
 
@@ -157,8 +145,6 @@ implementation
     function tarminlinenode.first_sin_real: tnode;
     function tarminlinenode.first_sin_real: tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
         result:=nil;
         result:=nil;
       end;
       end;
     }
     }

+ 0 - 2
compiler/globals.pas

@@ -242,8 +242,6 @@ interface
 
 
        block_type : tblock_type;         { type of currently parsed block }
        block_type : tblock_type;         { type of currently parsed block }
 
 
-       parsing_para_level : integer;     { parameter level, used to convert
-                                           proc calls to proc loads in firstcalln }
        compile_level : word;
        compile_level : word;
        resolving_forward : boolean;      { used to add forward reference as second ref }
        resolving_forward : boolean;      { used to add forward reference as second ref }
        exceptblockcounter    : integer;  { each except block gets a unique number check gotos      }
        exceptblockcounter    : integer;  { each except block gets a unique number check gotos      }

+ 1 - 1
compiler/globtype.pas

@@ -141,7 +141,7 @@ interface
           ds_dwarf_sets
           ds_dwarf_sets
        );
        );
        tdebugswitches = set of tdebugswitch;
        tdebugswitches = set of tdebugswitch;
-       
+
 
 
        { adding a new entry here requires also adding the appropriate define in
        { adding a new entry here requires also adding the appropriate define in
          systemh.inc (FK)
          systemh.inc (FK)

+ 2 - 64
compiler/htypechk.pas

@@ -118,11 +118,7 @@ interface
         (tok:_UNEQUAL ;nod:unequaln;op_overloading_supported:false)   { binary overloading NOT supported  overload = instead }
         (tok:_UNEQUAL ;nod:unequaln;op_overloading_supported:false)   { binary overloading NOT supported  overload = instead }
       );
       );
     const
     const
-    { firstcallparan without varspez we don't count the ref }
-{$ifdef extdebug}
-       count_ref : boolean = true;
-{$endif def extdebug}
-       allow_array_constructor : boolean = false;
+      allow_array_constructor : boolean = false;
 
 
     function node2opstr(nt:tnodetype):string;
     function node2opstr(nt:tnodetype):string;
 
 
@@ -134,7 +130,6 @@ interface
 
 
     { Register Allocation }
     { Register Allocation }
     procedure make_not_regable(p : tnode; how: tregableinfoflags);
     procedure make_not_regable(p : tnode; how: tregableinfoflags);
-    procedure calcregisters(p : tbinarynode;r32,fpu,mmx : word);
 
 
     { procvar handling }
     { procvar handling }
     function  is_procvar_load(p:tnode):boolean;
     function  is_procvar_load(p:tnode):boolean;
@@ -702,7 +697,7 @@ implementation
               begin
               begin
                 { arrays are currently never regable and pointers indexed like }
                 { arrays are currently never regable and pointers indexed like }
                 { arrays do not have be made unregable, but we do need to      }
                 { arrays do not have be made unregable, but we do need to      }
-                { propagate the ra_addr_taken info                             }                                          
+                { propagate the ra_addr_taken info                             }
                 update_regable:=false;
                 update_regable:=false;
                 p:=tvecnode(p).left;
                 p:=tvecnode(p).left;
               end;
               end;
@@ -752,63 +747,6 @@ implementation
         make_not_regable_intern(p,how,false);
         make_not_regable_intern(p,how,false);
       end;
       end;
 
 
-    { calculates the needed registers for a binary operator }
-    procedure calcregisters(p : tbinarynode;r32,fpu,mmx : word);
-
-      begin
-         p.left_right_max;
-
-      { Only when the difference between the left and right registers < the
-        wanted registers allocate the amount of registers }
-
-        if assigned(p.left) then
-         begin
-           if assigned(p.right) then
-            begin
-              { the location must be already filled in because we need it to }
-              { calculate the necessary number of registers (JM)             }
-              if p.expectloc = LOC_INVALID then
-                internalerror(200110101);
-
-              if (abs(p.left.registersint-p.right.registersint)<r32) or
-                 ((p.expectloc = LOC_FPUREGISTER) and
-                  (p.right.registersfpu <= p.left.registersfpu) and
-                  ((p.right.registersfpu <> 0) or (p.left.registersfpu <> 0)) and
-                  (p.left.registersint   < p.right.registersint)) then
-                inc(p.registersint,r32);
-              if (abs(p.left.registersfpu-p.right.registersfpu)<fpu) then
-               inc(p.registersfpu,fpu);
-{$ifdef SUPPORT_MMX}
-              if (abs(p.left.registersmmx-p.right.registersmmx)<mmx) then
-               inc(p.registersmmx,mmx);
-{$endif SUPPORT_MMX}
-              { the following is a little bit guessing but I think }
-              { it's the only way to solve same internalerrors:    }
-              { if the left and right node both uses registers     }
-              { and return a mem location, but the current node    }
-              { doesn't use an integer register we get probably    }
-              { trouble when restoring a node                      }
-              if (p.left.registersint=p.right.registersint) and
-                 (p.registersint=p.left.registersint) and
-                 (p.registersint>0) and
-                (p.left.expectloc in [LOC_REFERENCE,LOC_CREFERENCE]) and
-                (p.right.expectloc in [LOC_REFERENCE,LOC_CREFERENCE]) then
-                inc(p.registersint);
-            end
-           else
-            begin
-              if (p.left.registersint<r32) then
-               inc(p.registersint,r32);
-              if (p.left.registersfpu<fpu) then
-               inc(p.registersfpu,fpu);
-{$ifdef SUPPORT_MMX}
-              if (p.left.registersmmx<mmx) then
-               inc(p.registersmmx,mmx);
-{$endif SUPPORT_MMX}
-            end;
-         end;
-      end;
-
 
 
 {****************************************************************************
 {****************************************************************************
                           Subroutine Handling
                           Subroutine Handling

+ 0 - 2
compiler/m68k/n68kcnv.pas

@@ -101,8 +101,6 @@ implementation
             firstpass(left);
             firstpass(left);
           end;
           end;
         result := nil;
         result := nil;
-        if registersfpu<1 then
-          registersfpu:=1;
         location.loc:=LOC_FPUREGISTER;
         location.loc:=LOC_FPUREGISTER;
       end;
       end;
 
 

+ 8 - 74
compiler/nadd.pas

@@ -1214,7 +1214,7 @@ implementation
                   { note: ld cannot be an empty set with elementdef=nil in }
                   { note: ld cannot be an empty set with elementdef=nil in }
                   { case right is not a set, arrayconstructor_to_set takes }
                   { case right is not a set, arrayconstructor_to_set takes }
                   { care of that                                           }
                   { care of that                                           }
-                  
+
                   { 1: rd is a set with an assigned elementdef, and ld is    }
                   { 1: rd is a set with an assigned elementdef, and ld is    }
                   {    either an empty set without elementdef or a set whose }
                   {    either an empty set without elementdef or a set whose }
                   {    elementdef fits in rd's elementdef -> convert to rd   }
                   {    elementdef fits in rd's elementdef -> convert to rd   }
@@ -2003,7 +2003,7 @@ implementation
                           tsetelementnode(right).left:=caddnode.create(subn,
                           tsetelementnode(right).left:=caddnode.create(subn,
                             ctypeconvnode.create_internal(tsetelementnode(right).left,sinttype),
                             ctypeconvnode.create_internal(tsetelementnode(right).left,sinttype),
                             cordconstnode.create(tsetdef(resultdef).setbase,sinttype,false));
                             cordconstnode.create(tsetdef(resultdef).setbase,sinttype,false));
-                           
+
                           { add a range or a single element? }
                           { add a range or a single element? }
                           if assigned(tsetelementnode(right).right) then
                           if assigned(tsetelementnode(right).right) then
                             begin
                             begin
@@ -2353,23 +2353,6 @@ implementation
                end;
                end;
 {$endif cpufpemu}
 {$endif cpufpemu}
              expectloc:=LOC_FPUREGISTER;
              expectloc:=LOC_FPUREGISTER;
-             { maybe we need an integer register to save }
-             { a reference                               }
-             if ((left.expectloc<>LOC_FPUREGISTER) or
-                 (right.expectloc<>LOC_FPUREGISTER)) and
-                (left.registersint=right.registersint) then
-               calcregisters(self,1,1,0)
-             else
-               calcregisters(self,0,1,0);
-              { an add node always first loads both the left and the    }
-              { right in the fpu before doing the calculation. However, }
-              { calcregisters(0,2,0) will overestimate the number of    }
-              { necessary registers (it will make it 3 in case one of   }
-              { the operands is already in the fpu) (JM)                }
-              if ((left.expectloc<>LOC_FPUREGISTER) or
-                  (right.expectloc<>LOC_FPUREGISTER)) and
-                 (registersfpu < 2) then
-                inc(registersfpu);
            end
            end
 
 
          { if both are orddefs then check sub types }
          { if both are orddefs then check sub types }
@@ -2381,26 +2364,13 @@ implementation
                 if (not(cs_full_boolean_eval in current_settings.localswitches) or
                 if (not(cs_full_boolean_eval in current_settings.localswitches) or
                     (nf_short_bool in flags)) and
                     (nf_short_bool in flags)) and
                    (nodetype in [andn,orn]) then
                    (nodetype in [andn,orn]) then
-                 begin
-                   expectloc:=LOC_JUMP;
-                   calcregisters(self,0,0,0);
-                 end
+                  expectloc:=LOC_JUMP
                 else
                 else
                  begin
                  begin
                    if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
                    if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
-                     begin
-                       expectloc:=LOC_FLAGS;
-                       if (left.expectloc in [LOC_JUMP,LOC_FLAGS]) and
-                          (left.expectloc in [LOC_JUMP,LOC_FLAGS]) then
-                         calcregisters(self,2,0,0)
-                       else
-                         calcregisters(self,1,0,0);
-                     end
+                     expectloc:=LOC_FLAGS
                    else
                    else
-                     begin
-                       expectloc:=LOC_REGISTER;
-                       calcregisters(self,0,0,0);
-                     end;
+                     expectloc:=LOC_REGISTER;
                  end;
                  end;
               end
               end
              else
              else
@@ -2410,7 +2380,6 @@ implementation
                  if nodetype=addn then
                  if nodetype=addn then
                   internalerror(200103291);
                   internalerror(200103291);
                  expectloc:=LOC_FLAGS;
                  expectloc:=LOC_FLAGS;
-                 calcregisters(self,1,0,0);
                end
                end
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
               { is there a 64 bit type ? }
               { is there a 64 bit type ? }
@@ -2423,7 +2392,6 @@ implementation
                     expectloc:=LOC_REGISTER
                     expectloc:=LOC_REGISTER
                   else
                   else
                     expectloc:=LOC_JUMP;
                     expectloc:=LOC_JUMP;
-                  calcregisters(self,2,0,0)
                end
                end
 {$endif cpu64bit}
 {$endif cpu64bit}
              { is there a cardinal? }
              { is there a cardinal? }
@@ -2433,10 +2401,6 @@ implementation
                     expectloc:=LOC_REGISTER
                     expectloc:=LOC_REGISTER
                   else
                   else
                     expectloc:=LOC_FLAGS;
                     expectloc:=LOC_FLAGS;
-                 calcregisters(self,1,0,0);
-                 { for unsigned mul we need an extra register }
-                 if nodetype=muln then
-                  inc(registersint);
                end
                end
              { generic s32bit conversion }
              { generic s32bit conversion }
              else
              else
@@ -2445,7 +2409,6 @@ implementation
                     expectloc:=LOC_REGISTER
                     expectloc:=LOC_REGISTER
                   else
                   else
                     expectloc:=LOC_FLAGS;
                     expectloc:=LOC_FLAGS;
-                 calcregisters(self,1,0,0);
                end;
                end;
            end
            end
 
 
@@ -2510,21 +2473,14 @@ implementation
                            normal temp }
                            normal temp }
                          addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
                          addstatement(newstatement,ctempdeletenode.create_normal_temp(temp));
                          addstatement(newstatement,ctemprefnode.create(temp));
                          addstatement(newstatement,ctemprefnode.create(temp));
-                       end
-                     else
-                       calcregisters(self,2,0,0)
-                   end
-                 else
-                   calcregisters(self,1,0,0);
+                       end;
+                   end;
                end
                end
              else
              else
 {$ifdef MMXSET}
 {$ifdef MMXSET}
 {$ifdef i386}
 {$ifdef i386}
                if cs_mmx in current_settings.localswitches then
                if cs_mmx in current_settings.localswitches then
-                 begin
-                   expectloc:=LOC_MMXREGISTER;
-                   calcregisters(self,0,0,4);
-                 end
+                 expectloc:=LOC_MMXREGISTER
                else
                else
 {$endif}
 {$endif}
 {$endif MMXSET}
 {$endif MMXSET}
@@ -2533,7 +2489,6 @@ implementation
                    if assigned(result) then
                    if assigned(result) then
                      exit;
                      exit;
                    expectloc:=LOC_CREFERENCE;
                    expectloc:=LOC_CREFERENCE;
-                   calcregisters(self,0,0,0);
                    { here we call SET... }
                    { here we call SET... }
                    include(current_procinfo.flags,pi_do_call);
                    include(current_procinfo.flags,pi_do_call);
                  end;
                  end;
@@ -2546,7 +2501,6 @@ implementation
                expectloc:=LOC_REGISTER
                expectloc:=LOC_REGISTER
              else
              else
                expectloc:=LOC_FLAGS;
                expectloc:=LOC_FLAGS;
-             calcregisters(self,1,0,0);
            end
            end
 
 
          { is one of the operands a string }
          { is one of the operands a string }
@@ -2617,16 +2571,6 @@ implementation
                 expectloc:=LOC_FPUREGISTER
                 expectloc:=LOC_FPUREGISTER
               else
               else
                 expectloc:=LOC_FLAGS;
                 expectloc:=LOC_FLAGS;
-              calcregisters(self,0,1,0);
-              { an add node always first loads both the left and the    }
-              { right in the fpu before doing the calculation. However, }
-              { calcregisters(0,2,0) will overestimate the number of    }
-              { necessary registers (it will make it 3 in case one of   }
-              { the operands is already in the fpu) (JM)                }
-              if ((left.expectloc<>LOC_FPUREGISTER) or
-                  (right.expectloc<>LOC_FPUREGISTER)) and
-                 (registersfpu < 2) then
-                inc(registersfpu);
             end
             end
 
 
          { pointer comperation and subtraction }
          { pointer comperation and subtraction }
@@ -2636,19 +2580,16 @@ implementation
                 expectloc:=LOC_REGISTER
                 expectloc:=LOC_REGISTER
               else
               else
                 expectloc:=LOC_FLAGS;
                 expectloc:=LOC_FLAGS;
-              calcregisters(self,1,0,0);
            end
            end
 
 
          else if is_class_or_interface(ld) then
          else if is_class_or_interface(ld) then
             begin
             begin
               expectloc:=LOC_FLAGS;
               expectloc:=LOC_FLAGS;
-              calcregisters(self,1,0,0);
             end
             end
 
 
          else if (ld.typ=classrefdef) then
          else if (ld.typ=classrefdef) then
             begin
             begin
               expectloc:=LOC_FLAGS;
               expectloc:=LOC_FLAGS;
-              calcregisters(self,1,0,0);
             end
             end
 
 
          { support procvar=nil,procvar<>nil }
          { support procvar=nil,procvar<>nil }
@@ -2656,7 +2597,6 @@ implementation
                  ((rd.typ=procvardef) and (lt=niln)) then
                  ((rd.typ=procvardef) and (lt=niln)) then
             begin
             begin
               expectloc:=LOC_FLAGS;
               expectloc:=LOC_FLAGS;
-              calcregisters(self,1,0,0);
             end
             end
 
 
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
@@ -2666,14 +2606,12 @@ implementation
                  is_mmx_able_array(rd) then
                  is_mmx_able_array(rd) then
             begin
             begin
               expectloc:=LOC_MMXREGISTER;
               expectloc:=LOC_MMXREGISTER;
-              calcregisters(self,0,0,1);
             end
             end
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 
 
          else if (rd.typ=pointerdef) or (ld.typ=pointerdef) then
          else if (rd.typ=pointerdef) or (ld.typ=pointerdef) then
             begin
             begin
               expectloc:=LOC_REGISTER;
               expectloc:=LOC_REGISTER;
-              calcregisters(self,1,0,0);
             end
             end
 
 
          else  if (rd.typ=procvardef) and
          else  if (rd.typ=procvardef) and
@@ -2681,13 +2619,11 @@ implementation
                   equal_defs(rd,ld) then
                   equal_defs(rd,ld) then
            begin
            begin
              expectloc:=LOC_FLAGS;
              expectloc:=LOC_FLAGS;
-             calcregisters(self,1,0,0);
            end
            end
 
 
          else if (ld.typ=enumdef) then
          else if (ld.typ=enumdef) then
            begin
            begin
               expectloc:=LOC_FLAGS;
               expectloc:=LOC_FLAGS;
-              calcregisters(self,1,0,0);
            end
            end
 
 
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
@@ -2696,7 +2632,6 @@ implementation
                  is_mmx_able_array(rd) then
                  is_mmx_able_array(rd) then
             begin
             begin
               expectloc:=LOC_MMXREGISTER;
               expectloc:=LOC_MMXREGISTER;
-              calcregisters(self,0,0,1);
             end
             end
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 
 
@@ -2704,7 +2639,6 @@ implementation
          else
          else
            begin
            begin
              expectloc:=LOC_REGISTER;
              expectloc:=LOC_REGISTER;
-             calcregisters(self,1,0,0);
            end;
            end;
       end;
       end;
 
 

+ 1 - 23
compiler/nbas.pas

@@ -400,11 +400,6 @@ implementation
          if codegenerror then
          if codegenerror then
            exit;
            exit;
          expectloc:=left.expectloc;
          expectloc:=left.expectloc;
-         registersint:=left.registersint;
-         registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
          { right is the next in the list }
          { right is the next in the list }
          if assigned(right) then
          if assigned(right) then
            firstpass(right);
            firstpass(right);
@@ -517,25 +512,8 @@ implementation
                 begin
                 begin
                    codegenerror:=false;
                    codegenerror:=false;
                    firstpass(hp.left);
                    firstpass(hp.left);
-
                    hp.expectloc:=hp.left.expectloc;
                    hp.expectloc:=hp.left.expectloc;
-                   hp.registersint:=hp.left.registersint;
-                   hp.registersfpu:=hp.left.registersfpu;
-{$ifdef SUPPORT_MMX}
-                   hp.registersmmx:=hp.left.registersmmx;
-{$endif SUPPORT_MMX}
-                end
-              else
-                hp.registersint:=0;
-
-              if hp.registersint>registersint then
-                registersint:=hp.registersint;
-              if hp.registersfpu>registersfpu then
-                registersfpu:=hp.registersfpu;
-{$ifdef SUPPORT_MMX}
-              if hp.registersmmx>registersmmx then
-                registersmmx:=hp.registersmmx;
-{$endif}
+                end;
               expectloc:=hp.expectloc;
               expectloc:=hp.expectloc;
               inc(count);
               inc(count);
               hp:=tstatementnode(hp.right);
               hp:=tstatementnode(hp.right);

+ 46 - 159
compiler/ncal.pas

@@ -168,11 +168,11 @@ interface
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           procedure ppuwrite(ppufile:tcompilerppufile);override;
           function dogetcopy : tnode;override;
           function dogetcopy : tnode;override;
           procedure insertintolist(l : tnodelist);override;
           procedure insertintolist(l : tnodelist);override;
-          function  pass_1 : tnode;override;
+          function pass_typecheck : tnode;override;
+          function pass_1 : tnode;override;
           procedure get_paratype;
           procedure get_paratype;
-          procedure insert_typeconv(do_count : boolean);
-          procedure det_registers;
           procedure firstcallparan;
           procedure firstcallparan;
+          procedure insert_typeconv(do_count : boolean);
           procedure secondcallparan;virtual;abstract;
           procedure secondcallparan;virtual;abstract;
           function docompare(p: tnode): boolean; override;
           function docompare(p: tnode): boolean; override;
           procedure printnodetree(var t:text);override;
           procedure printnodetree(var t:text);override;
@@ -536,11 +536,18 @@ implementation
       end;
       end;
 
 
 
 
+    function tcallparanode.pass_typecheck : tnode;
+      begin
+        { need to use get_paratype }
+        internalerror(200709251);
+        result:=nil;
+      end;
+
+
     function tcallparanode.pass_1 : tnode;
     function tcallparanode.pass_1 : tnode;
       begin
       begin
-        firstpass(left);
-        if assigned(right) then
-          firstpass(right);
+        { need to use firstcallparan }
+        internalerror(200709252);
         result:=nil;
         result:=nil;
       end;
       end;
 
 
@@ -549,7 +556,6 @@ implementation
       var
       var
         old_array_constructor : boolean;
         old_array_constructor : boolean;
       begin
       begin
-         inc(parsing_para_level);
          if assigned(right) then
          if assigned(right) then
           tcallparanode(right).get_paratype;
           tcallparanode(right).get_paratype;
          old_array_constructor:=allow_array_constructor;
          old_array_constructor:=allow_array_constructor;
@@ -560,7 +566,17 @@ implementation
           resultdef:=generrordef
           resultdef:=generrordef
          else
          else
           resultdef:=left.resultdef;
           resultdef:=left.resultdef;
-         dec(parsing_para_level);
+      end;
+
+
+    procedure tcallparanode.firstcallparan;
+      begin
+        if assigned(right) then
+          tcallparanode(right).firstcallparan;
+        if not assigned(left.resultdef) then
+          get_paratype;
+        firstpass(left);
+        expectloc:=left.expectloc;
       end;
       end;
 
 
 
 
@@ -568,19 +584,7 @@ implementation
       var
       var
         olddef  : tdef;
         olddef  : tdef;
         hp       : tnode;
         hp       : tnode;
-{$ifdef extdebug}
-        store_count_ref : boolean;
-{$endif def extdebug}
       begin
       begin
-         inc(parsing_para_level);
-
-{$ifdef extdebug}
-         if do_count then
-           begin
-             store_count_ref:=count_ref;
-             count_ref:=true;
-           end;
-{$endif def extdebug}
          { Be sure to have the resultdef }
          { Be sure to have the resultdef }
          if not assigned(left.resultdef) then
          if not assigned(left.resultdef) then
            typecheckpass(left);
            typecheckpass(left);
@@ -685,10 +689,7 @@ implementation
                          inserttypeconv(left,parasym.vardef);
                          inserttypeconv(left,parasym.vardef);
                        end;
                        end;
                       if codegenerror then
                       if codegenerror then
-                        begin
-                           dec(parsing_para_level);
-                           exit;
-                        end;
+                        exit;
                    end;
                    end;
 
 
                  { check var strings }
                  { check var strings }
@@ -786,38 +787,6 @@ implementation
          { process next node }
          { process next node }
          if assigned(right) then
          if assigned(right) then
            tcallparanode(right).insert_typeconv(do_count);
            tcallparanode(right).insert_typeconv(do_count);
-
-         dec(parsing_para_level);
-{$ifdef extdebug}
-         if do_count then
-           count_ref:=store_count_ref;
-{$endif def extdebug}
-      end;
-
-
-    procedure tcallparanode.det_registers;
-      begin
-         if assigned(right) then
-           begin
-              tcallparanode(right).det_registers;
-
-              registersint:=right.registersint;
-              registersfpu:=right.registersfpu;
-{$ifdef SUPPORT_MMX}
-              registersmmx:=right.registersmmx;
-{$endif}
-           end;
-
-         firstpass(left);
-
-         if left.registersint>registersint then
-           registersint:=left.registersint;
-         if left.registersfpu>registersfpu then
-           registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         if left.registersmmx>registersmmx then
-           registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
       end;
       end;
 
 
 
 
@@ -845,14 +814,6 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tcallparanode.firstcallparan;
-      begin
-        if not assigned(left.resultdef) then
-          get_paratype;
-        det_registers;
-      end;
-
-
     function tcallparanode.docompare(p: tnode): boolean;
     function tcallparanode.docompare(p: tnode): boolean;
       begin
       begin
         docompare :=
         docompare :=
@@ -2471,10 +2432,10 @@ implementation
             { pull in at the correct place.
             { pull in at the correct place.
               Used order:
               Used order:
                 1. LOC_REFERENCE with smallest offset (i386 only)
                 1. LOC_REFERENCE with smallest offset (i386 only)
-                2. LOC_REFERENCE with most registers and least complexity (non-i386 only)
-                3. LOC_REFERENCE with least registers and most complexity (non-i386 only)
-                4. LOC_REGISTER with most registers and most complexity
-                5. LOC_REGISTER with least registers and least complexity
+                2. LOC_REFERENCE with least complexity (non-i386 only)
+                3. LOC_REFERENCE with most complexity (non-i386 only)
+                4. LOC_REGISTER with most complexity
+                5. LOC_REGISTER with least complexity
               For the moment we only look at the first parameter field. Combining it
               For the moment we only look at the first parameter field. Combining it
               with multiple parameter fields will make things a lot complexer (PFV)
               with multiple parameter fields will make things a lot complexer (PFV)
 
 
@@ -2519,8 +2480,7 @@ implementation
                             { pushes                                        }
                             { pushes                                        }
                             if (hpcurr.parasym.paraloc[callerside].location^.reference.offset>hp.parasym.paraloc[callerside].location^.reference.offset) then
                             if (hpcurr.parasym.paraloc[callerside].location^.reference.offset>hp.parasym.paraloc[callerside].location^.reference.offset) then
 {$else i386}
 {$else i386}
-                            if (hpcurr.registersint>hp.registersint) or
-                               (node_complexity(hpcurr)<node_complexity(hp)) then
+                            if (node_complexity(hpcurr)<node_complexity(hp)) then
 {$endif i386}
 {$endif i386}
                               break;
                               break;
                           end;
                           end;
@@ -2660,18 +2620,10 @@ implementation
          { record maximum parameter size used in this proc }
          { record maximum parameter size used in this proc }
          current_procinfo.allocate_push_parasize(pushedparasize);
          current_procinfo.allocate_push_parasize(pushedparasize);
 
 
-         { work trough all parameters to get the register requirements }
-         if assigned(left) then
-           begin
-             tcallparanode(left).det_registers;
-
-             { check for stacked parameters }
-             if (current_settings.optimizerswitches*[cs_opt_stackframe,cs_opt_level1]<>[]) then
-               check_stack_parameters;
-           end;
-
-         { order parameters }
-         order_parameters;
+         { check for stacked parameters }
+         if assigned(left) and
+            (current_settings.optimizerswitches*[cs_opt_stackframe,cs_opt_level1]<>[]) then
+           check_stack_parameters;
 
 
          if assigned(callinitblock) then
          if assigned(callinitblock) then
            firstpass(callinitblock);
            firstpass(callinitblock);
@@ -2680,16 +2632,27 @@ implementation
          if assigned(funcretnode) then
          if assigned(funcretnode) then
            firstpass(funcretnode);
            firstpass(funcretnode);
 
 
+         { parameters }
+         if assigned(left) then
+           tcallparanode(left).firstcallparan;
+
          { procedure variable ? }
          { procedure variable ? }
          if assigned(right) then
          if assigned(right) then
            firstpass(right);
            firstpass(right);
 
 
+         if assigned(methodpointer) and
+            (methodpointer.nodetype<>typen) then
+           firstpass(methodpointer);
+
          if assigned(callcleanupblock) then
          if assigned(callcleanupblock) then
            firstpass(callcleanupblock);
            firstpass(callcleanupblock);
 
 
          if not (block_type in [bt_const,bt_type]) then
          if not (block_type in [bt_const,bt_type]) then
            include(current_procinfo.flags,pi_do_call);
            include(current_procinfo.flags,pi_do_call);
 
 
+         { order parameters }
+         order_parameters;
+
          { get a register for the return value }
          { get a register for the return value }
          if (not is_void(resultdef)) then
          if (not is_void(resultdef)) then
            begin
            begin
@@ -2703,7 +2666,6 @@ implementation
                  is_widestring(resultdef) then
                  is_widestring(resultdef) then
                begin
                begin
                  expectloc:=LOC_REFERENCE;
                  expectloc:=LOC_REFERENCE;
-                 registersint:=1;
                end
                end
              else
              else
              { we have only to handle the result if it is used }
              { we have only to handle the result if it is used }
@@ -2713,47 +2675,15 @@ implementation
                    enumdef,
                    enumdef,
                    orddef :
                    orddef :
                      begin
                      begin
-                       if (procdefinition.proctypeoption=potype_constructor) then
-                        begin
-                          expectloc:=LOC_REGISTER;
-                          registersint:=1;
-                        end
-                       else
-                        begin
-                          expectloc:=LOC_REGISTER;
-                          if is_64bit(resultdef) then
-                            registersint:=2
-                          else
-                            registersint:=1;
-                        end;
+                       expectloc:=LOC_REGISTER;
                      end;
                      end;
                    floatdef :
                    floatdef :
                      begin
                      begin
                        expectloc:=LOC_FPUREGISTER;
                        expectloc:=LOC_FPUREGISTER;
-{$ifdef cpufpemu}
-                       if (cs_fp_emulation in current_settings.moduleswitches) then
-                         registersint:=1
-                       else
-{$endif cpufpemu}
-{$ifdef m68k}
-                        if (tfloatdef(resultdef).floattype=s32real) then
-                         registersint:=1
-                       else
-{$endif m68k}
-                         registersfpu:=1;
                      end;
                      end;
                    else
                    else
                      begin
                      begin
                        expectloc:=procdefinition.funcretloc[callerside].loc;
                        expectloc:=procdefinition.funcretloc[callerside].loc;
-                       if (expectloc = LOC_REGISTER) then
-{$ifndef cpu64bit}
-                         if (resultdef.size > sizeof(aint)) then
-                           registersint:=2
-                         else
-{$endif cpu64bit}
-                          registersint:=1
-                       else
-                         registersint:=0;
                      end;
                      end;
                  end;
                  end;
                end
                end
@@ -2762,49 +2692,6 @@ implementation
            end
            end
          else
          else
            expectloc:=LOC_VOID;
            expectloc:=LOC_VOID;
-
-{$ifdef m68k}
-         { we need one more address register for virtual calls on m68k }
-         if (po_virtualmethod in procdefinition.procoptions) then
-           inc(registersint);
-{$endif m68k}
-         { a fpu can be used in any procedure !! }
-{$ifdef i386}
-         registersfpu:=procdefinition.fpu_used;
-{$endif i386}
-         { if this is a call to a method calc the registers }
-         if (methodpointer<>nil) then
-           begin
-              if methodpointer.nodetype<>typen then
-               begin
-                 firstpass(methodpointer);
-                 registersfpu:=max(methodpointer.registersfpu,registersfpu);
-                 registersint:=max(methodpointer.registersint,registersint);
-{$ifdef SUPPORT_MMX }
-                 registersmmx:=max(methodpointer.registersmmx,registersmmx);
-{$endif SUPPORT_MMX}
-               end;
-           end;
-
-         { determine the registers of the procedure variable }
-         { is this OK for inlined procs also ?? (PM)     }
-         if assigned(right) then
-           begin
-              registersfpu:=max(right.registersfpu,registersfpu);
-              registersint:=max(right.registersint,registersint);
-{$ifdef SUPPORT_MMX}
-              registersmmx:=max(right.registersmmx,registersmmx);
-{$endif SUPPORT_MMX}
-           end;
-         { determine the registers of the procedure }
-         if assigned(left) then
-           begin
-              registersfpu:=max(left.registersfpu,registersfpu);
-              registersint:=max(left.registersint,registersint);
-{$ifdef SUPPORT_MMX}
-              registersmmx:=max(left.registersmmx,registersmmx);
-{$endif SUPPORT_MMX}
-           end;
       end;
       end;
 
 
 {$ifdef state_tracking}
 {$ifdef state_tracking}

+ 14 - 6
compiler/ncgadd.pas

@@ -73,8 +73,8 @@ interface
       cutils,verbose,globals,
       cutils,verbose,globals,
       symconst,symdef,paramgr,
       symconst,symdef,paramgr,
       aasmbase,aasmtai,aasmdata,defutil,
       aasmbase,aasmtai,aasmdata,defutil,
-      cgbase,procinfo,pass_2,
-      ncon,nset,ncgutil,cgobj,cgutils
+      cgbase,procinfo,pass_2,tgobj,
+      nutils,ncon,nset,ncgutil,cgobj,cgutils
       ;
       ;
 
 
 
 
@@ -114,10 +114,16 @@ interface
           end;
           end;
 
 
         { are too few registers free? }
         { are too few registers free? }
-        if left.location.loc=LOC_FPUREGISTER then
-          pushedfpu:=maybe_pushfpu(current_asmdata.CurrAsmList,right.registersfpu,left.location)
-        else
-          pushedfpu:=false;
+        pushedfpu:=false;
+{$ifdef i386}
+        if (left.location.loc=LOC_FPUREGISTER) and
+           (node_resources_fpu(right)>=maxfpuregs) then
+          begin
+            location_force_mem(current_asmdata.CurrAsmList,left.location);
+            pushedfpu:=true;
+          end;
+{$endif i386}
+
         isjump:=(right.expectloc=LOC_JUMP);
         isjump:=(right.expectloc=LOC_JUMP);
         if isjump then
         if isjump then
           begin
           begin
@@ -141,6 +147,7 @@ interface
               begin
               begin
                 tmpreg := cg.getmmregister(current_asmdata.CurrAsmList,left.location.size);
                 tmpreg := cg.getmmregister(current_asmdata.CurrAsmList,left.location.size);
                 cg.a_loadmm_loc_reg(current_asmdata.CurrAsmList,left.location.size,left.location,tmpreg,mms_movescalar);
                 cg.a_loadmm_loc_reg(current_asmdata.CurrAsmList,left.location.size,left.location,tmpreg,mms_movescalar);
+                location_freetemp(current_asmdata.CurrAsmList,left.location);
                 location_reset(left.location,LOC_MMREGISTER,left.location.size);
                 location_reset(left.location,LOC_MMREGISTER,left.location.size);
                 left.location.register := tmpreg;
                 left.location.register := tmpreg;
               end
               end
@@ -149,6 +156,7 @@ interface
               begin
               begin
                 tmpreg := cg.getfpuregister(current_asmdata.CurrAsmList,left.location.size);
                 tmpreg := cg.getfpuregister(current_asmdata.CurrAsmList,left.location.size);
                 cg.a_loadfpu_loc_reg(current_asmdata.CurrAsmList,left.location.size,left.location,tmpreg);
                 cg.a_loadfpu_loc_reg(current_asmdata.CurrAsmList,left.location.size,left.location,tmpreg);
+                location_freetemp(current_asmdata.CurrAsmList,left.location);
                 location_reset(left.location,LOC_FPUREGISTER,left.location.size);
                 location_reset(left.location,LOC_FPUREGISTER,left.location.size);
                 left.location.register := tmpreg;
                 left.location.register := tmpreg;
 {$ifdef x86}
 {$ifdef x86}

+ 2 - 4
compiler/ncgld.pas

@@ -518,15 +518,13 @@ implementation
               right then decreasing the refcnt on left can possibly release
               right then decreasing the refcnt on left can possibly release
               the memory before right increased the refcnt, result is that an
               the memory before right increased the refcnt, result is that an
               empty value is assigned
               empty value is assigned
-            - calln, call destroys most registers and is therefor 'complex'
 
 
            But not when the result is in the flags, then
            But not when the result is in the flags, then
           loading the left node afterwards can destroy the flags.
           loading the left node afterwards can destroy the flags.
         }
         }
         if not(right.expectloc in [LOC_FLAGS,LOC_JUMP]) and
         if not(right.expectloc in [LOC_FLAGS,LOC_JUMP]) and
-           ((right.nodetype=calln) or
-            (right.resultdef.needs_inittable) or
-            (right.registersint>=left.registersint)) then
+           ((right.resultdef.needs_inittable) or
+            (node_complexity(right)>node_complexity(left))) then
          begin
          begin
            secondpass(right);
            secondpass(right);
            { increment source reference counter, this is
            { increment source reference counter, this is

+ 1 - 18
compiler/ncgmem.pas

@@ -831,10 +831,6 @@ implementation
                           begin
                           begin
                              extraoffset:=tordconstnode(taddnode(right).right).value.svalue;
                              extraoffset:=tordconstnode(taddnode(right).right).value.svalue;
                              t:=taddnode(right).left;
                              t:=taddnode(right).left;
-                             { First pass processed this with the assumption   }
-                             { that there was an add node which may require an }
-                             { extra register. Fake it or die with IE10 (JM)   }
-                             t.registersint := taddnode(right).registersint;
                              taddnode(right).left:=nil;
                              taddnode(right).left:=nil;
                              right.free;
                              right.free;
                              right:=t;
                              right:=t;
@@ -843,7 +839,6 @@ implementation
                           begin
                           begin
                              extraoffset:=tordconstnode(taddnode(right).left).value.svalue;
                              extraoffset:=tordconstnode(taddnode(right).left).value.svalue;
                              t:=taddnode(right).right;
                              t:=taddnode(right).right;
-                             t.registersint :=  right.registersint;
                              taddnode(right).right:=nil;
                              taddnode(right).right:=nil;
                              right.free;
                              right.free;
                              right:=t;
                              right:=t;
@@ -855,22 +850,10 @@ implementation
                           begin
                           begin
                              extraoffset:=-tordconstnode(taddnode(right).right).value.svalue;
                              extraoffset:=-tordconstnode(taddnode(right).right).value.svalue;
                              t:=taddnode(right).left;
                              t:=taddnode(right).left;
-                             t.registersint :=  right.registersint;
                              taddnode(right).left:=nil;
                              taddnode(right).left:=nil;
                              right.free;
                              right.free;
                              right:=t;
                              right:=t;
-                          end
-{ You also have to negate right.right in this case! I can't add an
-  unaryminusn without causing a crash, so I've disabled it (JM)
-                        else if right.left.nodetype=ordconstn then
-                          begin
-                             extraoffset:=right.left.value;
-                             t:=right.right;
-                             t^.registersint :=  right.registersint;
-                             putnode(right);
-                             putnode(right.left);
-                             right:=t;
-                         end;}
+                          end;
                      end;
                      end;
                    inc(location.reference.offset,
                    inc(location.reference.offset,
                        mulsize*extraoffset);
                        mulsize*extraoffset);

+ 0 - 5
compiler/ncgopt.pas

@@ -73,11 +73,6 @@ begin
   if codegenerror then
   if codegenerror then
     exit;
     exit;
   expectloc:=LOC_REFERENCE;
   expectloc:=LOC_REFERENCE;
-  if not is_constcharnode(right) then
-    { it's not sure we need the register, but we can't know it here yet }
-    calcregisters(self,2,0,0)
-  else
-    calcregisters(self,1,0,0);
 end;
 end;
 
 
 
 

+ 3 - 51
compiler/ncgutil.pas

@@ -71,8 +71,6 @@ interface
       a register it is expected to contain the address of the data }
       a register it is expected to contain the address of the data }
     procedure location_get_data_ref(list:TAsmList;const l:tlocation;var ref:treference;loadref:boolean);
     procedure location_get_data_ref(list:TAsmList;const l:tlocation;var ref:treference;loadref:boolean);
 
 
-    function  maybe_pushfpu(list:TAsmList;needed : byte;var l:tlocation) : boolean;
-
     function  has_alias_name(pd:tprocdef;const s:string):boolean;
     function  has_alias_name(pd:tprocdef;const s:string):boolean;
     procedure alloc_proc_symbol(pd: tprocdef);
     procedure alloc_proc_symbol(pd: tprocdef);
     procedure gen_proc_symbol(list:TAsmList);
     procedure gen_proc_symbol(list:TAsmList);
@@ -214,43 +212,18 @@ implementation
       end;
       end;
 
 
 
 
-
-   { DO NOT RELY on the fact that the tnode is not yet swaped
-     because of inlining code PM }
     procedure firstcomplex(p : tbinarynode);
     procedure firstcomplex(p : tbinarynode);
-      var
-         hp : tnode;
       begin
       begin
          { always calculate boolean AND and OR from left to right }
          { always calculate boolean AND and OR from left to right }
          if (p.nodetype in [orn,andn]) and
          if (p.nodetype in [orn,andn]) and
             is_boolean(p.left.resultdef) then
             is_boolean(p.left.resultdef) then
            begin
            begin
              if nf_swapped in p.flags then
              if nf_swapped in p.flags then
-               internalerror(234234);
+               internalerror(200709253);
            end
            end
          else
          else
-           if (
-               (p.expectloc=LOC_FPUREGISTER) and
-               (p.right.registersfpu > p.left.registersfpu)
-              ) or
-              (
-               (
-                (
-                 ((p.left.registersfpu = 0) and (p.right.registersfpu = 0)) or
-                 (p.expectloc<>LOC_FPUREGISTER)
-                ) and
-                (p.left.registersint<p.right.registersint)
-               )
-              ) then
-            begin
-              hp:=p.left;
-              p.left:=p.right;
-              p.right:=hp;
-              if nf_swapped in p.flags then
-                exclude(p.flags,nf_swapped)
-              else
-                include(p.flags,nf_swapped);
-            end;
+           if node_resources_fpu(p.right)>node_resources_fpu(p.left) then
+             p.swapleftright;
       end;
       end;
 
 
 
 
@@ -847,27 +820,6 @@ implementation
       end;
       end;
 
 
 
 
-{*****************************************************************************
-                                  Maybe_Save
-*****************************************************************************}
-
-    function maybe_pushfpu(list:TAsmList;needed : byte;var l:tlocation) : boolean;
-      begin
-{$ifdef i386}
-        if (needed>=maxfpuregs) and
-           (l.loc = LOC_FPUREGISTER) then
-          begin
-            location_force_mem(list,l);
-            maybe_pushfpu:=true;
-          end
-        else
-          maybe_pushfpu:=false;
-{$else i386}
-        maybe_pushfpu:=false;
-{$endif i386}
-      end;
-
-
 {****************************************************************************
 {****************************************************************************
                             Init/Finalize Code
                             Init/Finalize Code
 ****************************************************************************}
 ****************************************************************************}

+ 13 - 62
compiler/ncnv.pas

@@ -2022,12 +2022,6 @@ implementation
                  (resultdef.size<left.resultdef.size) then
                  (resultdef.size<left.resultdef.size) then
                 expectloc:=LOC_REGISTER;
                 expectloc:=LOC_REGISTER;
           end;
           end;
-{$ifndef cpu64bit}
-        if is_64bit(resultdef) then
-          registersint:=max(registersint,2)
-        else
-{$endif cpu64bit}
-          registersint:=max(registersint,1);
       end;
       end;
 
 
 
 
@@ -2035,7 +2029,6 @@ implementation
 
 
       begin
       begin
          result:=nil;
          result:=nil;
-         registersint:=1;
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
       end;
       end;
 
 
@@ -2074,8 +2067,6 @@ implementation
 
 
       begin
       begin
          first_array_to_pointer:=nil;
          first_array_to_pointer:=nil;
-         if registersint<1 then
-           registersint:=1;
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
       end;
       end;
 
 
@@ -2237,8 +2228,6 @@ implementation
 {$endif cpufpemu}
 {$endif cpufpemu}
           begin
           begin
             first_real_to_real:=nil;
             first_real_to_real:=nil;
-            if registersfpu<1 then
-              registersfpu:=1;
             expectloc:=LOC_FPUREGISTER;
             expectloc:=LOC_FPUREGISTER;
           end;
           end;
       end;
       end;
@@ -2248,8 +2237,6 @@ implementation
 
 
       begin
       begin
          first_pointer_to_array:=nil;
          first_pointer_to_array:=nil;
-         if registersint<1 then
-           registersint:=1;
          expectloc:=LOC_REFERENCE;
          expectloc:=LOC_REFERENCE;
       end;
       end;
 
 
@@ -2283,8 +2270,6 @@ implementation
              exit;
              exit;
            end;
            end;
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
-         if registersint<1 then
-           registersint:=1;
       end;
       end;
 
 
 
 
@@ -2293,19 +2278,12 @@ implementation
       begin
       begin
          first_int_to_bool:=nil;
          first_int_to_bool:=nil;
          { byte(boolean) or word(wordbool) or longint(longbool) must
          { byte(boolean) or word(wordbool) or longint(longbool) must
-         be accepted for var parameters }
+           be accepted for var parameters }
          if (nf_explicit in flags) and
          if (nf_explicit in flags) and
             (left.resultdef.size=resultdef.size) and
             (left.resultdef.size=resultdef.size) and
             (left.expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
             (left.expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
            exit;
            exit;
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
-         { need if bool to bool !!
-           not very nice !!
-         insertypeconv(left,s32inttype);
-         left.explizit:=true;
-         firstpass(left);  }
-         if registersint<1 then
-           registersint:=1;
       end;
       end;
 
 
 
 
@@ -2315,11 +2293,7 @@ implementation
          if (left.expectloc in [LOC_FLAGS,LOC_JUMP]) then
          if (left.expectloc in [LOC_FLAGS,LOC_JUMP]) then
            expectloc := left.expectloc
            expectloc := left.expectloc
          else
          else
-           begin
-             expectloc:=LOC_REGISTER;
-             if registersint<1 then
-               registersint:=1;
-           end;
+           expectloc:=LOC_REGISTER;
       end;
       end;
 
 
 
 
@@ -2351,28 +2325,22 @@ implementation
          if (tprocdef(left.resultdef).parast.symtablelevel>=normal_function_level) then
          if (tprocdef(left.resultdef).parast.symtablelevel>=normal_function_level) then
            include(current_procinfo.flags,pi_needs_stackframe);
            include(current_procinfo.flags,pi_needs_stackframe);
          if tabstractprocdef(resultdef).is_addressonly then
          if tabstractprocdef(resultdef).is_addressonly then
-          begin
-            registersint:=left.registersint;
-            if registersint<1 then
-              registersint:=1;
-            expectloc:=LOC_REGISTER;
-          end
+           expectloc:=LOC_REGISTER
          else
          else
-          begin
-            if not(left.expectloc in [LOC_CREFERENCE,LOC_REFERENCE]) then
-              CGMessage(parser_e_illegal_expression);
-            registersint:=left.registersint;
-            expectloc:=left.expectloc
-          end
+           begin
+             if not(left.expectloc in [LOC_CREFERENCE,LOC_REFERENCE]) then
+               CGMessage(parser_e_illegal_expression);
+             expectloc:=left.expectloc;
+           end;
       end;
       end;
 
 
+
     function ttypeconvnode.first_nil_to_methodprocvar : tnode;
     function ttypeconvnode.first_nil_to_methodprocvar : tnode;
+      begin
+        first_nil_to_methodprocvar:=nil;
+        expectloc:=LOC_REFERENCE;
+      end;
 
 
-    begin
-      first_nil_to_methodprocvar:=nil;
-      registersint:=0;
-      expectloc:=LOC_REFERENCE;
-    end;
 
 
     function ttypeconvnode.first_set_to_set : tnode;
     function ttypeconvnode.first_set_to_set : tnode;
       var
       var
@@ -2459,8 +2427,6 @@ implementation
       begin
       begin
          first_ansistring_to_pchar:=nil;
          first_ansistring_to_pchar:=nil;
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
-         if registersint<1 then
-           registersint:=1;
       end;
       end;
 
 
 
 
@@ -2475,8 +2441,6 @@ implementation
       begin
       begin
          first_class_to_intf:=nil;
          first_class_to_intf:=nil;
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
-         if registersint<1 then
-           registersint:=1;
       end;
       end;
 
 
     function ttypeconvnode._first_int_to_int : tnode;
     function ttypeconvnode._first_int_to_int : tnode;
@@ -2658,15 +2622,7 @@ implementation
         firstpass(left);
         firstpass(left);
         if codegenerror then
         if codegenerror then
          exit;
          exit;
-
-        { load the value_str from the left part }
-        registersint:=left.registersint;
-        registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif}
         expectloc:=left.expectloc;
         expectloc:=left.expectloc;
-
         result:=first_call_helper(convtype);
         result:=first_call_helper(convtype);
       end;
       end;
 
 
@@ -3119,11 +3075,6 @@ implementation
             if codegenerror then
             if codegenerror then
               exit;
               exit;
            expectloc:=call.expectloc;
            expectloc:=call.expectloc;
-           registersint:=call.registersint;
-           registersfpu:=call.registersfpu;
-{$ifdef SUPPORT_MMX}
-           registersmmx:=call.registersmmx;
-{$endif SUPPORT_MMX}
          end;
          end;
       end;
       end;
 
 

+ 1 - 3
compiler/ncon.pas

@@ -536,8 +536,6 @@ implementation
       begin
       begin
          result:=nil;
          result:=nil;
          expectloc:=LOC_CREFERENCE;
          expectloc:=LOC_CREFERENCE;
-         { needs to be loaded into an FPU register }
-         registersfpu:=1;
       end;
       end;
 
 
     function trealconstnode.docompare(p: tnode): boolean;
     function trealconstnode.docompare(p: tnode): boolean;
@@ -1029,7 +1027,7 @@ implementation
           end;
           end;
       end;
       end;
 
 
-    
+
 
 
     function tsetconstnode.dogetcopy : tnode;
     function tsetconstnode.dogetcopy : tnode;
 
 

+ 8 - 141
compiler/nflw.pas

@@ -500,11 +500,6 @@ implementation
          firstpass(left);
          firstpass(left);
          if codegenerror then
          if codegenerror then
            exit;
            exit;
-         registersint:=left.registersint;
-         registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
 
 
          { loop instruction }
          { loop instruction }
          if assigned(right) then
          if assigned(right) then
@@ -512,15 +507,6 @@ implementation
               firstpass(right);
               firstpass(right);
               if codegenerror then
               if codegenerror then
                 exit;
                 exit;
-
-              if registersint<right.registersint then
-                registersint:=right.registersint;
-              if registersfpu<right.registersfpu then
-                registersfpu:=right.registersfpu;
-{$ifdef SUPPORT_MMX}
-              if registersmmx<right.registersmmx then
-                registersmmx:=right.registersmmx;
-{$endif SUPPORT_MMX}
            end;
            end;
 
 
          cg.t_times:=old_t_times;
          cg.t_times:=old_t_times;
@@ -736,11 +722,6 @@ implementation
          expectloc:=LOC_VOID;
          expectloc:=LOC_VOID;
          old_t_times:=cg.t_times;
          old_t_times:=cg.t_times;
          firstpass(left);
          firstpass(left);
-         registersint:=left.registersint;
-         registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
 
 
          { determines registers weigths }
          { determines registers weigths }
          if not(cs_opt_size in current_settings.optimizerswitches) then
          if not(cs_opt_size in current_settings.optimizerswitches) then
@@ -750,33 +731,11 @@ implementation
 
 
          { if path }
          { if path }
          if assigned(right) then
          if assigned(right) then
-           begin
-              firstpass(right);
-
-              if registersint<right.registersint then
-                registersint:=right.registersint;
-              if registersfpu<right.registersfpu then
-                registersfpu:=right.registersfpu;
-{$ifdef SUPPORT_MMX}
-              if registersmmx<right.registersmmx then
-                registersmmx:=right.registersmmx;
-{$endif SUPPORT_MMX}
-           end;
+           firstpass(right);
 
 
          { else path }
          { else path }
          if assigned(t1) then
          if assigned(t1) then
-           begin
-              firstpass(t1);
-
-              if registersint<t1.registersint then
-                registersint:=t1.registersint;
-              if registersfpu<t1.registersfpu then
-                registersfpu:=t1.registersfpu;
-{$ifdef SUPPORT_MMX}
-              if registersmmx<t1.registersmmx then
-                registersmmx:=t1.registersmmx;
-{$endif SUPPORT_MMX}
-           end;
+           firstpass(t1);
 
 
          { leave if we've got an error in one of the paths }
          { leave if we've got an error in one of the paths }
 
 
@@ -879,34 +838,8 @@ implementation
          expectloc:=LOC_VOID;
          expectloc:=LOC_VOID;
 
 
          firstpass(left);
          firstpass(left);
-         if left.registersint>registersint then
-           registersint:=left.registersint;
-         if left.registersfpu>registersfpu then
-           registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         if left.registersmmx>registersmmx then
-           registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-
          firstpass(right);
          firstpass(right);
-         if right.registersint>registersint then
-           registersint:=right.registersint;
-         if right.registersfpu>registersfpu then
-           registersfpu:=right.registersfpu;
-{$ifdef SUPPORT_MMX}
-         if right.registersmmx>registersmmx then
-           registersmmx:=right.registersmmx;
-{$endif SUPPORT_MMX}
-
          firstpass(t1);
          firstpass(t1);
-         if t1.registersint>registersint then
-           registersint:=t1.registersint;
-         if t1.registersfpu>registersfpu then
-           registersfpu:=t1.registersfpu;
-{$ifdef SUPPORT_MMX}
-         if t1.registersmmx>registersmmx then
-           registersmmx:=t1.registersmmx;
-{$endif SUPPORT_MMX}
 
 
          if assigned(t2) then
          if assigned(t2) then
           begin
           begin
@@ -917,20 +850,8 @@ implementation
             firstpass(t2);
             firstpass(t2);
             if codegenerror then
             if codegenerror then
              exit;
              exit;
-            if t2.registersint>registersint then
-              registersint:=t2.registersint;
-            if t2.registersfpu>registersfpu then
-              registersfpu:=t2.registersfpu;
-{$ifdef SUPPORT_MMX}
-            if t2.registersmmx>registersmmx then
-              registersmmx:=t2.registersmmx;
-{$endif SUPPORT_MMX}
             cg.t_times:=old_t_times;
             cg.t_times:=old_t_times;
           end;
           end;
-
-         { we need at least one register for comparisons PM }
-         if registersint=0 then
-           inc(registersint);
       end;
       end;
 
 
 
 
@@ -982,11 +903,6 @@ implementation
               firstpass(left);
               firstpass(left);
               if codegenerror then
               if codegenerror then
                exit;
                exit;
-              registersint:=left.registersint;
-              registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-              registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
            end;
            end;
       end;
       end;
 
 
@@ -1202,14 +1118,7 @@ implementation
          result:=nil;
          result:=nil;
          expectloc:=LOC_VOID;
          expectloc:=LOC_VOID;
          if assigned(left) then
          if assigned(left) then
-          begin
-            firstpass(left);
-            registersint:=left.registersint;
-            registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-            registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-          end;
+           firstpass(left);
       end;
       end;
 
 
 
 
@@ -1287,7 +1196,6 @@ implementation
                  if assigned(third) then
                  if assigned(third) then
                   firstpass(third);
                   firstpass(third);
                end;
                end;
-              left_right_max;
            end;
            end;
       end;
       end;
 
 
@@ -1324,24 +1232,10 @@ implementation
          firstpass(left);
          firstpass(left);
          { on statements }
          { on statements }
          if assigned(right) then
          if assigned(right) then
-           begin
-              firstpass(right);
-              registersint:=max(registersint,right.registersint);
-              registersfpu:=max(registersfpu,right.registersfpu);
-{$ifdef SUPPORT_MMX}
-              registersmmx:=max(registersmmx,right.registersmmx);
-{$endif SUPPORT_MMX}
-           end;
+           firstpass(right);
          { else block }
          { else block }
          if assigned(t1) then
          if assigned(t1) then
-           begin
-              firstpass(t1);
-              registersint:=max(registersint,t1.registersint);
-              registersfpu:=max(registersfpu,t1.registersfpu);
-{$ifdef SUPPORT_MMX}
-              registersmmx:=max(registersmmx,t1.registersmmx);
-{$endif SUPPORT_MMX}
-           end;
+           firstpass(t1);
       end;
       end;
 
 
 
 
@@ -1394,17 +1288,9 @@ implementation
          firstpass(left);
          firstpass(left);
 
 
          firstpass(right);
          firstpass(right);
-         left_right_max;
 
 
          if assigned(t1) then
          if assigned(t1) then
-           begin
-             firstpass(t1);
-             registersint:=max(registersint,t1.registersint);
-             registersfpu:=max(registersfpu,t1.registersfpu);
-{$ifdef SUPPORT_MMX}
-             registersmmx:=max(registersmmx,t1.registersmmx);
-{$endif SUPPORT_MMX}
-           end;
+           firstpass(t1);
       end;
       end;
 
 
 
 
@@ -1469,30 +1355,11 @@ implementation
          result:=nil;
          result:=nil;
          include(current_procinfo.flags,pi_do_call);
          include(current_procinfo.flags,pi_do_call);
          expectloc:=LOC_VOID;
          expectloc:=LOC_VOID;
-         registersint:=0;
-         registersfpu:=0;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=0;
-{$endif SUPPORT_MMX}
          if assigned(left) then
          if assigned(left) then
-           begin
-              firstpass(left);
-              registersint:=left.registersint;
-              registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-              registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-           end;
+           firstpass(left);
 
 
          if assigned(right) then
          if assigned(right) then
-           begin
-              firstpass(right);
-              registersint:=max(registersint,right.registersint);
-              registersfpu:=max(registersfpu,right.registersfpu);
-{$ifdef SUPPORT_MMX}
-              registersmmx:=max(registersmmx,right.registersmmx);
-{$endif SUPPORT_MMX}
-           end;
+           firstpass(right);
       end;
       end;
 
 
 
 

+ 0 - 53
compiler/ninl.pas

@@ -1483,7 +1483,6 @@ implementation
              else
              else
                typecheckpass(left);
                typecheckpass(left);
            end;
            end;
-         inc(parsing_para_level);
 
 
          { handle intern constant functions in separate case }
          { handle intern constant functions in separate case }
          if nf_inlineconst in flags then
          if nf_inlineconst in flags then
@@ -2379,7 +2378,6 @@ implementation
               (left.nodetype=callparan) then
               (left.nodetype=callparan) then
             tcallparanode(left).get_paratype;
             tcallparanode(left).get_paratype;
          end;
          end;
-        dec(parsing_para_level);
       end;
       end;
 
 
 
 
@@ -2400,10 +2398,8 @@ implementation
                 tcallparanode(left).firstcallparan
                 tcallparanode(left).firstcallparan
               else
               else
                 firstpass(left);
                 firstpass(left);
-              left_max;
            end;
            end;
 
 
-         inc(parsing_para_level);
          { intern const should already be handled }
          { intern const should already be handled }
          if nf_inlineconst in flags then
          if nf_inlineconst in flags then
           internalerror(200104044);
           internalerror(200104044);
@@ -2435,15 +2431,11 @@ implementation
 
 
           in_sizeof_x:
           in_sizeof_x:
             begin
             begin
-              if registersint<1 then
-                 registersint:=1;
               expectloc:=LOC_REGISTER;
               expectloc:=LOC_REGISTER;
             end;
             end;
 
 
           in_typeof_x:
           in_typeof_x:
             begin
             begin
-               if registersint<1 then
-                 registersint:=1;
                expectloc:=LOC_REGISTER;
                expectloc:=LOC_REGISTER;
             end;
             end;
 
 
@@ -2454,8 +2446,6 @@ implementation
                else
                else
                 begin
                 begin
                   { ansi/wide string }
                   { ansi/wide string }
-                  if registersint<1 then
-                   registersint:=1;
                   expectloc:=LOC_REGISTER;
                   expectloc:=LOC_REGISTER;
                 end;
                 end;
             end;
             end;
@@ -2463,28 +2453,16 @@ implementation
           in_typeinfo_x:
           in_typeinfo_x:
             begin
             begin
                expectloc:=LOC_REGISTER;
                expectloc:=LOC_REGISTER;
-               registersint:=1;
             end;
             end;
 
 
           in_assigned_x:
           in_assigned_x:
             begin
             begin
               expectloc := LOC_JUMP;
               expectloc := LOC_JUMP;
-              registersint:=1;
             end;
             end;
 
 
           in_pred_x,
           in_pred_x,
           in_succ_x:
           in_succ_x:
             begin
             begin
-              if is_64bit(resultdef) then
-               begin
-                 if (registersint<2) then
-                  registersint:=2
-               end
-              else
-               begin
-                 if (registersint<1) then
-                  registersint:=1;
-               end;
               expectloc:=LOC_REGISTER;
               expectloc:=LOC_REGISTER;
             end;
             end;
 
 
@@ -2586,23 +2564,6 @@ implementation
                    firstpass(newblock);
                    firstpass(newblock);
                    { return new node }
                    { return new node }
                    result := newblock;
                    result := newblock;
-                 end
-               else if (left.resultdef.typ in [enumdef,pointerdef]) or
-                       is_ordinal(left.resultdef) then
-                 begin
-                    { two paras ? }
-                    if assigned(tcallparanode(left).right) then
-                      begin
-                         { need we an additional register ? }
-                         if not(is_constintnode(tcallparanode(tcallparanode(left).right).left)) and
-                           (tcallparanode(tcallparanode(left).right).left.expectloc in [LOC_CREFERENCE,LOC_REFERENCE]) and
-                           (tcallparanode(tcallparanode(left).right).left.registersint<=1) then
-                           inc(registersint);
-
-                         { do we need an additional register to restore the first parameter? }
-                         if tcallparanode(tcallparanode(left).right).left.registersint>=registersint then
-                           inc(registersint);
-                      end;
                  end;
                  end;
             end;
             end;
 
 
@@ -2610,12 +2571,6 @@ implementation
          in_exclude_x_y:
          in_exclude_x_y:
            begin
            begin
               expectloc:=LOC_VOID;
               expectloc:=LOC_VOID;
-
-              registersint:=left.registersint;
-              registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-              registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
            end;
            end;
 
 
          in_pack_x_y_z,
          in_pack_x_y_z,
@@ -2698,11 +2653,6 @@ implementation
          in_assert_x_y :
          in_assert_x_y :
             begin
             begin
               expectloc:=LOC_VOID;
               expectloc:=LOC_VOID;
-              registersint:=left.registersint;
-              registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-              registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
             end;
             end;
 
 
           in_low_x,
           in_low_x,
@@ -2746,12 +2696,10 @@ implementation
          in_get_caller_frame:
          in_get_caller_frame:
             begin
             begin
               expectloc:=LOC_REGISTER;
               expectloc:=LOC_REGISTER;
-              registersint:=1;
             end;
             end;
          in_get_caller_addr:
          in_get_caller_addr:
             begin
             begin
               expectloc:=LOC_REGISTER;
               expectloc:=LOC_REGISTER;
-              registersint:=1;
             end;
             end;
 
 
          in_prefetch_var:
          in_prefetch_var:
@@ -2767,7 +2715,6 @@ implementation
           else
           else
             internalerror(89);
             internalerror(89);
           end;
           end;
-         dec(parsing_para_level);
        end;
        end;
 {$maxfpuregisters default}
 {$maxfpuregisters default}
 
 

+ 3 - 27
compiler/nld.pas

@@ -351,11 +351,6 @@ implementation
       begin
       begin
          result:=nil;
          result:=nil;
          expectloc:=LOC_REFERENCE;
          expectloc:=LOC_REFERENCE;
-         registersint:=0;
-         registersfpu:=0;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=0;
-{$endif SUPPORT_MMX}
          if (cs_create_pic in current_settings.moduleswitches) and
          if (cs_create_pic in current_settings.moduleswitches) and
            not(symtableentry.typ in [paravarsym,localvarsym]) then
            not(symtableentry.typ in [paravarsym,localvarsym]) then
            include(current_procinfo.flags,pi_needs_got);
            include(current_procinfo.flags,pi_needs_got);
@@ -380,11 +375,6 @@ implementation
                 else
                 else
                   if (tabstractvarsym(symtableentry).varspez=vs_const) then
                   if (tabstractvarsym(symtableentry).varspez=vs_const) then
                     expectloc:=LOC_CREFERENCE;
                     expectloc:=LOC_CREFERENCE;
-                { we need a register for call by reference parameters }
-                if paramanager.push_addr_param(tabstractvarsym(symtableentry).varspez,tabstractvarsym(symtableentry).vardef,pocall_default) then
-                  registersint:=1;
-                if ([vo_is_thread_var,vo_is_dll_var]*tabstractvarsym(symtableentry).varoptions)<>[] then
-                  registersint:=1;
                 if (target_info.system=system_powerpc_darwin) and
                 if (target_info.system=system_powerpc_darwin) and
                    ([vo_is_dll_var,vo_is_external] * tabstractvarsym(symtableentry).varoptions <> []) then
                    ([vo_is_dll_var,vo_is_external] * tabstractvarsym(symtableentry).varoptions <> []) then
                   include(current_procinfo.flags,pi_needs_got);
                   include(current_procinfo.flags,pi_needs_got);
@@ -406,11 +396,6 @@ implementation
                      begin
                      begin
                         expectloc:=LOC_CREFERENCE;
                         expectloc:=LOC_CREFERENCE;
                         firstpass(left);
                         firstpass(left);
-                        registersint:=max(registersint,left.registersint);
-                        registersfpu:=max(registersfpu,left.registersfpu);
- {$ifdef SUPPORT_MMX}
-                        registersmmx:=max(registersmmx,left.registersmmx);
- {$endif SUPPORT_MMX}
                      end;
                      end;
                 end;
                 end;
            labelsym :
            labelsym :
@@ -716,12 +701,6 @@ implementation
                end;
                end;
             end;
             end;
            end;
            end;
-
-         registersint:=left.registersint+right.registersint;
-         registersfpu:=max(left.registersfpu,right.registersfpu);
-{$ifdef SUPPORT_MMX}
-         registersmmx:=max(left.registersmmx,right.registersmmx);
-{$endif SUPPORT_MMX}
       end;
       end;
 
 
 
 
@@ -782,7 +761,6 @@ implementation
         firstpass(left);
         firstpass(left);
         firstpass(right);
         firstpass(right);
         expectloc:=LOC_CREFERENCE;
         expectloc:=LOC_CREFERENCE;
-        calcregisters(self,0,0,0);
         result:=nil;
         result:=nil;
       end;
       end;
 
 
@@ -968,15 +946,13 @@ implementation
               end;
               end;
           end;
           end;
         expectloc:=LOC_CREFERENCE;
         expectloc:=LOC_CREFERENCE;
-        calcregisters(self,0,0,0);
       end;
       end;
 
 
 
 
     function tarrayconstructornode.docompare(p: tnode): boolean;
     function tarrayconstructornode.docompare(p: tnode): boolean;
-
-    begin
-      docompare:=inherited docompare(p);
-    end;
+      begin
+        docompare:=inherited docompare(p);
+      end;
 
 
 
 
 {*****************************************************************************
 {*****************************************************************************

+ 7 - 62
compiler/nmat.pas

@@ -434,7 +434,6 @@ implementation
              if assigned(result) then
              if assigned(result) then
                exit;
                exit;
              expectloc:=LOC_REGISTER;
              expectloc:=LOC_REGISTER;
-             calcregisters(self,2,0,0);
            end
            end
          else
          else
 {$endif cpu64bit}
 {$endif cpu64bit}
@@ -442,9 +441,6 @@ implementation
              result := first_moddivint;
              result := first_moddivint;
              if assigned(result) then
              if assigned(result) then
                exit;
                exit;
-             left_right_max;
-             if left.registersint<=right.registersint then
-              inc(registersint);
            end;
            end;
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
       end;
       end;
@@ -573,7 +569,6 @@ implementation
          if (right.nodetype<>ordconstn) then
          if (right.nodetype<>ordconstn) then
            inc(regs);
            inc(regs);
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
-         calcregisters(self,regs,0,0);
       end;
       end;
 
 
 
 
@@ -722,44 +717,15 @@ implementation
           end
           end
         else
         else
           begin
           begin
-            registersint:=left.registersint;
-            registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-            registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-
             if (left.resultdef.typ=floatdef) then
             if (left.resultdef.typ=floatdef) then
-              begin
-                if (left.expectloc<>LOC_REGISTER) and
-                  (registersfpu<1) then
-                  registersfpu:=1;
-                expectloc:=LOC_FPUREGISTER;
-              end
+              expectloc:=LOC_FPUREGISTER
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
              else if (cs_mmx in current_settings.localswitches) and
              else if (cs_mmx in current_settings.localswitches) and
                is_mmx_able_array(left.resultdef) then
                is_mmx_able_array(left.resultdef) then
-                 begin
-                   if (left.expectloc<>LOC_MMXREGISTER) and
-                      (registersmmx<1) then
-                     registersmmx:=1;
-                 end
+              expectloc:=LOC_MMXREGISTER
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
-{$ifndef cpu64bit}
-             else if is_64bit(left.resultdef) then
-               begin
-                  if (left.expectloc<>LOC_REGISTER) and
-                     (registersint<2) then
-                    registersint:=2;
-                  expectloc:=LOC_REGISTER;
-               end
-{$endif cpu64bit}
              else if (left.resultdef.typ=orddef) then
              else if (left.resultdef.typ=orddef) then
-               begin
-                  if (left.expectloc<>LOC_REGISTER) and
-                     (registersint<1) then
-                    registersint:=1;
-                  expectloc:=LOC_REGISTER;
-               end;
+               expectloc:=LOC_REGISTER;
           end;
           end;
       end;
       end;
 
 
@@ -909,18 +875,10 @@ implementation
            exit;
            exit;
 
 
          expectloc:=left.expectloc;
          expectloc:=left.expectloc;
-         registersint:=left.registersint;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
          if is_boolean(resultdef) then
          if is_boolean(resultdef) then
            begin
            begin
              if (expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
              if (expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
-              begin
-                expectloc:=LOC_REGISTER;
-                if (registersint<1) then
-                 registersint:=1;
-              end;
+               expectloc:=LOC_REGISTER;
             { before loading it into flags we need to load it into
             { before loading it into flags we need to load it into
               a register thus 1 register is need PM }
               a register thus 1 register is need PM }
 {$ifdef cpuflags}
 {$ifdef cpuflags}
@@ -932,32 +890,19 @@ implementation
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
            if (cs_mmx in current_settings.localswitches) and
            if (cs_mmx in current_settings.localswitches) and
              is_mmx_able_array(left.resultdef) then
              is_mmx_able_array(left.resultdef) then
-             begin
-               if (left.expectloc<>LOC_MMXREGISTER) and
-                 (registersmmx<1) then
-                 registersmmx:=1;
-             end
+             expectloc:=LOC_MMXREGISTER
          else
          else
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}
            if is_64bit(left.resultdef) then
            if is_64bit(left.resultdef) then
              begin
              begin
                 if (expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
                 if (expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
-                 begin
-                   expectloc:=LOC_REGISTER;
-                   if (registersint<2) then
-                    registersint:=2;
-                 end;
+                  expectloc:=LOC_REGISTER;
              end
              end
          else
          else
 {$endif cpu64bit}
 {$endif cpu64bit}
            if is_integer(left.resultdef) then
            if is_integer(left.resultdef) then
-             begin
-               if (left.expectloc<>LOC_REGISTER) and
-                  (registersint<1) then
-                 registersint:=1;
-               expectloc:=LOC_REGISTER;
-             end;
+             expectloc:=LOC_REGISTER;
       end;
       end;
 
 
 {$ifdef state_tracking}
 {$ifdef state_tracking}

+ 2 - 92
compiler/nmem.pas

@@ -168,12 +168,7 @@ implementation
          result:=nil;
          result:=nil;
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
          if left.nodetype<>typen then
          if left.nodetype<>typen then
-           begin
-             firstpass(left);
-             registersint:=left.registersint;
-           end;
-         if registersint<1 then
-           registersint:=1;
+           firstpass(left);
       end;
       end;
 
 
 
 
@@ -241,7 +236,6 @@ implementation
         resultdef:=voidpointertype;
         resultdef:=voidpointertype;
 {$ifdef dummy}
 {$ifdef dummy}
         { currently parentfps are never loaded in registers (FK) }
         { currently parentfps are never loaded in registers (FK) }
-
         if (current_procinfo.procdef.parast.symtablelevel<>parentpd.parast.symtablelevel) then
         if (current_procinfo.procdef.parast.symtablelevel<>parentpd.parast.symtablelevel) then
           begin
           begin
             currpi:=current_procinfo;
             currpi:=current_procinfo;
@@ -265,7 +259,6 @@ implementation
       begin
       begin
         result:=nil;
         result:=nil;
         expectloc:=LOC_REGISTER;
         expectloc:=LOC_REGISTER;
-        registersint:=1;
       end;
       end;
 
 
 
 
@@ -458,9 +451,6 @@ implementation
 
 
         if (mark_read_written) then
         if (mark_read_written) then
           begin
           begin
-            { this is like the function addr }
-            inc(parsing_para_level);
-
             { This is actually only "read", but treat it nevertheless as  }
             { This is actually only "read", but treat it nevertheless as  }
             { modified due to the possible use of pointers                }
             { modified due to the possible use of pointers                }
             { To avoid false positives regarding "uninitialised"          }
             { To avoid false positives regarding "uninitialised"          }
@@ -469,7 +459,6 @@ implementation
             { vsf_must_be_valid so it doesn't get changed into }
             { vsf_must_be_valid so it doesn't get changed into }
             { vsf_referred_not_inited                          }
             { vsf_referred_not_inited                          }
             set_varstate(left,vs_read,[vsf_must_be_valid]);
             set_varstate(left,vs_read,[vsf_must_be_valid]);
-            dec(parsing_para_level);
           end;
           end;
       end;
       end;
 
 
@@ -481,13 +470,6 @@ implementation
          if codegenerror then
          if codegenerror then
           exit;
           exit;
 
 
-         registersint:=left.registersint;
-         registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-         if registersint<1 then
-           registersint:=1;
          { is this right for object of methods ?? }
          { is this right for object of methods ?? }
          expectloc:=LOC_REGISTER;
          expectloc:=LOC_REGISTER;
       end;
       end;
@@ -534,12 +516,6 @@ implementation
          if codegenerror then
          if codegenerror then
           exit;
           exit;
 
 
-         registersint:=max(left.registersint,1);
-         registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-
          expectloc:=LOC_REFERENCE;
          expectloc:=LOC_REFERENCE;
       end;
       end;
 
 
@@ -623,18 +599,9 @@ implementation
          if codegenerror then
          if codegenerror then
           exit;
           exit;
 
 
-         registersint:=left.registersint;
-         registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
          { classes must be dereferenced implicit }
          { classes must be dereferenced implicit }
          if is_class_or_interface(left.resultdef) then
          if is_class_or_interface(left.resultdef) then
-           begin
-              if registersint=0 then
-                registersint:=1;
-              expectloc:=LOC_REFERENCE;
-           end
+           expectloc:=LOC_REFERENCE
          else
          else
            begin
            begin
              case left.expectloc of
              case left.expectloc of
@@ -875,58 +842,6 @@ implementation
          else if is_widestring(left.resultdef) and (tf_winlikewidestring in target_info.flags) then
          else if is_widestring(left.resultdef) and (tf_winlikewidestring in target_info.flags) then
            exclude(flags,nf_callunique);
            exclude(flags,nf_callunique);
 
 
-         { the register calculation is easy if a const index is used }
-         if right.nodetype=ordconstn then
-           begin
-              registersint:=left.registersint;
-
-              { for ansi/wide strings, we need at least one register }
-              if is_ansistring(left.resultdef) or
-                is_widestring(left.resultdef) or
-              { ... as well as for dynamic arrays }
-                is_dynamic_array(left.resultdef) then
-                registersint:=max(registersint,1);
-           end
-         else
-           begin
-              { this rules are suboptimal, but they should give }
-              { good results                                }
-              registersint:=max(left.registersint,right.registersint);
-
-              { for ansi/wide strings, we need at least one register }
-              if is_ansistring(left.resultdef) or
-                is_widestring(left.resultdef) or
-              { ... as well as for dynamic arrays }
-                is_dynamic_array(left.resultdef) then
-                registersint:=max(registersint,1);
-
-              { need we an extra register when doing the restore ? }
-              if (left.registersint<=right.registersint) and
-              { only if the node needs less than 3 registers }
-              { two for the right node and one for the       }
-              { left address                             }
-                (registersint<3) then
-                inc(registersint);
-
-              { need we an extra register for the index ? }
-              if (right.expectloc<>LOC_REGISTER)
-              { only if the right node doesn't need a register }
-                and (right.registersint<1) then
-                inc(registersint);
-
-              { not correct, but what works better ?
-              if left.registersint>0 then
-                registersint:=max(registersint,2)
-              else
-                 min. one register
-                registersint:=max(registersint,1);
-              }
-           end;
-
-         registersfpu:=max(left.registersfpu,right.registersfpu);
-{$ifdef SUPPORT_MMX}
-         registersmmx:=max(left.registersmmx,right.registersmmx);
-{$endif SUPPORT_MMX}
          if (not is_packed_array(left.resultdef)) or
          if (not is_packed_array(left.resultdef)) or
             ((tarraydef(left.resultdef).elepackedbitsize mod 8) = 0) then
             ((tarraydef(left.resultdef).elepackedbitsize mod 8) = 0) then
            if left.expectloc=LOC_CREFERENCE then
            if left.expectloc=LOC_CREFERENCE then
@@ -992,11 +907,6 @@ implementation
       begin
       begin
         result:=nil;
         result:=nil;
         expectloc:=LOC_VOID;
         expectloc:=LOC_VOID;
-        registersint:=left.registersint;
-        registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
       end;
       end;
 
 
 
 

+ 1 - 60
compiler/node.pas

@@ -290,11 +290,6 @@ interface
          { there are some properties about the node stored }
          { there are some properties about the node stored }
          flags  : tnodeflags;
          flags  : tnodeflags;
          ppuidx : longint;
          ppuidx : longint;
-         { the number of registers needed to evalute the node }
-         registersint,registersfpu,registersmm : longint;  { must be longint !!!! }
-{$ifdef SUPPORT_MMX}
-         registersmmx  : longint;
-{$endif SUPPORT_MMX}
          resultdef     : tdef;
          resultdef     : tdef;
          resultdefderef : tderef;
          resultdefderef : tderef;
          fileinfo      : tfileposinfo;
          fileinfo      : tfileposinfo;
@@ -389,7 +384,6 @@ interface
          function docompare(p : tnode) : boolean;override;
          function docompare(p : tnode) : boolean;override;
          function dogetcopy : tnode;override;
          function dogetcopy : tnode;override;
          procedure insertintolist(l : tnodelist);override;
          procedure insertintolist(l : tnodelist);override;
-         procedure left_max;
          procedure printnodedata(var t:text);override;
          procedure printnodedata(var t:text);override;
       end;
       end;
 
 
@@ -409,7 +403,6 @@ interface
          procedure swapleftright;
          procedure swapleftright;
          function dogetcopy : tnode;override;
          function dogetcopy : tnode;override;
          procedure insertintolist(l : tnodelist);override;
          procedure insertintolist(l : tnodelist);override;
-         procedure left_right_max;
          procedure printnodedata(var t:text);override;
          procedure printnodedata(var t:text);override;
          procedure printnodelist(var t:text);
          procedure printnodelist(var t:text);
       end;
       end;
@@ -695,11 +688,6 @@ implementation
          fileinfo:=current_filepos;
          fileinfo:=current_filepos;
          localswitches:=current_settings.localswitches;
          localswitches:=current_settings.localswitches;
          resultdef:=nil;
          resultdef:=nil;
-         registersint:=0;
-         registersfpu:=0;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=0;
-{$endif SUPPORT_MMX}
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
          maxfirstpasscount:=0;
          maxfirstpasscount:=0;
          firstpasscount:=0;
          firstpasscount:=0;
@@ -727,11 +715,6 @@ implementation
         expectloc:=LOC_INVALID;
         expectloc:=LOC_INVALID;
         { updated by secondpass }
         { updated by secondpass }
         location.loc:=LOC_INVALID;
         location.loc:=LOC_INVALID;
-        registersint:=0;
-        registersfpu:=0;
-{$ifdef SUPPORT_MMX}
-        registersmmx:=0;
-{$endif SUPPORT_MMX}
 {$ifdef EXTDEBUG}
 {$ifdef EXTDEBUG}
         maxfirstpasscount:=0;
         maxfirstpasscount:=0;
         firstpasscount:=0;
         firstpasscount:=0;
@@ -821,9 +804,7 @@ implementation
           write(t,', resultdef = <nil>');
           write(t,', resultdef = <nil>');
         write(t,', pos = (',fileinfo.line,',',fileinfo.column,')',
         write(t,', pos = (',fileinfo.line,',',fileinfo.column,')',
                   ', loc = ',tcgloc2str[location.loc],
                   ', loc = ',tcgloc2str[location.loc],
-                  ', expectloc = ',tcgloc2str[expectloc],
-                  ', intregs = ',registersint,
-                  ', fpuregs = ',registersfpu);
+                  ', expectloc = ',tcgloc2str[expectloc]);
       end;
       end;
 
 
 
 
@@ -898,12 +879,6 @@ implementation
          p.location:=location;
          p.location:=location;
          p.parent:=parent;
          p.parent:=parent;
          p.flags:=flags;
          p.flags:=flags;
-         p.registersint:=registersint;
-         p.registersfpu:=registersfpu;
-{$ifdef SUPPORT_MMX}
-         p.registersmmx:=registersmmx;
-         p.registersmm:=registersmm;
-{$endif SUPPORT_MMX}
          p.resultdef:=resultdef;
          p.resultdef:=resultdef;
          p.fileinfo:=fileinfo;
          p.fileinfo:=fileinfo;
          p.localswitches:=localswitches;
          p.localswitches:=localswitches;
@@ -1017,16 +992,6 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tunarynode.left_max;
-      begin
-         registersint:=left.registersint;
-         registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-      end;
-
-
     procedure tunarynode.concattolist(l : tlinkedlist);
     procedure tunarynode.concattolist(l : tlinkedlist);
       begin
       begin
          left.parent:=self;
          left.parent:=self;
@@ -1155,30 +1120,6 @@ implementation
       end;
       end;
 
 
 
 
-    procedure tbinarynode.left_right_max;
-      begin
-        if assigned(left) then
-         begin
-           if assigned(right) then
-            begin
-              registersint:=max(left.registersint,right.registersint);
-              registersfpu:=max(left.registersfpu,right.registersfpu);
-{$ifdef SUPPORT_MMX}
-              registersmmx:=max(left.registersmmx,right.registersmmx);
-{$endif SUPPORT_MMX}
-            end
-           else
-            begin
-              registersint:=left.registersint;
-              registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-              registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-            end;
-         end;
-      end;
-
-
     procedure tbinarynode.printnodedata(var t:text);
     procedure tbinarynode.printnodedata(var t:text);
       begin
       begin
          inherited printnodedata(t);
          inherited printnodedata(t);

+ 0 - 1
compiler/nopt.pas

@@ -140,7 +140,6 @@ function taddsstringoptnode.pass_1: tnode;
 begin
 begin
   pass_1 := nil;
   pass_1 := nil;
   expectloc:= LOC_REFERENCE;
   expectloc:= LOC_REFERENCE;
-  calcregisters(self,0,0,0);
   { here we call STRCONCAT or STRCMP or STRCOPY }
   { here we call STRCONCAT or STRCMP or STRCOPY }
   include(current_procinfo.flags,pi_do_call);
   include(current_procinfo.flags,pi_do_call);
 end;
 end;

+ 2 - 57
compiler/nset.pas

@@ -153,7 +153,6 @@ implementation
           exit;
           exit;
 
 
          expectloc:=left.expectloc;
          expectloc:=left.expectloc;
-         calcregisters(self,0,0,0);
       end;
       end;
 
 
 
 
@@ -335,22 +334,6 @@ implementation
          firstpass(left);
          firstpass(left);
          if codegenerror then
          if codegenerror then
            exit;
            exit;
-
-         left_right_max;
-
-         if tsetdef(right.resultdef).settype<>smallset then
-           begin
-             if registersint < 3 then
-               registersint := 3;
-           end
-         else
-           begin
-              { a smallset needs maybe an misc. register }
-              if (left.nodetype<>ordconstn) and
-                 not(right.expectloc in [LOC_CREGISTER,LOC_REGISTER]) and
-                 (right.registersint<1) then
-                inc(registersint);
-           end;
       end;
       end;
 
 
 
 
@@ -396,7 +379,6 @@ implementation
          firstpass(right);
          firstpass(right);
          if codegenerror then
          if codegenerror then
            exit;
            exit;
-        left_right_max;
         expectloc:=left.expectloc;
         expectloc:=left.expectloc;
       end;
       end;
 
 
@@ -607,7 +589,6 @@ implementation
     function tcasenode.pass_1 : tnode;
     function tcasenode.pass_1 : tnode;
       var
       var
          old_t_times : longint;
          old_t_times : longint;
-         hp : tnode;
          i  : integer;
          i  : integer;
       begin
       begin
          result:=nil;
          result:=nil;
@@ -617,12 +598,6 @@ implementation
          set_varstate(left,vs_read,[vsf_must_be_valid]);
          set_varstate(left,vs_read,[vsf_must_be_valid]);
          if codegenerror then
          if codegenerror then
            exit;
            exit;
-         registersint:=left.registersint;
-         registersfpu:=left.registersfpu;
-{$ifdef SUPPORT_MMX}
-         registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
-
          { walk through all instructions }
          { walk through all instructions }
 
 
          { estimates the repeat of each instruction }
          { estimates the repeat of each instruction }
@@ -635,42 +610,12 @@ implementation
            end;
            end;
          { first case }
          { first case }
          for i:=0 to blocks.count-1 do
          for i:=0 to blocks.count-1 do
-           begin
-
-              firstpass(pcaseblock(blocks[i])^.statement);
-
-              { searchs max registers }
-              hp:=pcaseblock(blocks[i])^.statement;
-              if hp.registersint>registersint then
-                registersint:=hp.registersint;
-              if hp.registersfpu>registersfpu then
-                registersfpu:=hp.registersfpu;
-{$ifdef SUPPORT_MMX}
-              if hp.registersmmx>registersmmx then
-                registersmmx:=hp.registersmmx;
-{$endif SUPPORT_MMX}
-           end;
+           firstpass(pcaseblock(blocks[i])^.statement);
 
 
          { may be handle else tree }
          { may be handle else tree }
          if assigned(elseblock) then
          if assigned(elseblock) then
-           begin
-              firstpass(elseblock);
-              if registersint<elseblock.registersint then
-                registersint:=elseblock.registersint;
-              if registersfpu<elseblock.registersfpu then
-                registersfpu:=elseblock.registersfpu;
-{$ifdef SUPPORT_MMX}
-              if registersmmx<elseblock.registersmmx then
-                registersmmx:=elseblock.registersmmx;
-{$endif SUPPORT_MMX}
-           end;
+           firstpass(elseblock);
          cg.t_times:=old_t_times;
          cg.t_times:=old_t_times;
-
-         { there is one register required for the case expression    }
-         { for 64 bit ints we cheat: the high dword is stored in EDI }
-         { so we don't need an extra register                        }
-         if registersint<1 then
-           registersint:=1;
       end;
       end;
 
 
 
 

+ 56 - 2
compiler/nutils.pas

@@ -75,6 +75,7 @@ interface
     function finalize_data_node(p:tnode):tnode;
     function finalize_data_node(p:tnode):tnode;
 
 
     function node_complexity(p: tnode): cardinal;
     function node_complexity(p: tnode): cardinal;
+    function node_resources_fpu(p: tnode): cardinal;
     procedure node_tree_set_filepos(var n:tnode;const filepos:tfileposinfo);
     procedure node_tree_set_filepos(var n:tnode;const filepos:tfileposinfo);
 
 
     { tries to simplify the given node }
     { tries to simplify the given node }
@@ -84,11 +85,11 @@ interface
 implementation
 implementation
 
 
     uses
     uses
-      verbose,constexp,globals,
+      cutils,verbose,constexp,globals,
       symconst,symbase,symdef,symtable,
       symconst,symbase,symdef,symtable,
       defutil,defcmp,
       defutil,defcmp,
       nbas,ncon,ncnv,nld,nflw,nset,ncal,nadd,nmem,
       nbas,ncon,ncnv,nld,nflw,nset,ncal,nadd,nmem,
-      cgbase,procinfo,
+      cpubase,cgbase,procinfo,
       pass_1;
       pass_1;
 
 
   function foreachnode(procmethod : tforeachprocmethod;var n: tnode; f: foreachnodefunction; arg: pointer): boolean;
   function foreachnode(procmethod : tforeachprocmethod;var n: tnode; f: foreachnodefunction; arg: pointer): boolean;
@@ -705,6 +706,59 @@ implementation
       end;
       end;
 
 
 
 
+    { this function returns an indication how much fpu registers
+      will be required.
+      Note: The algorithms need to be pessimistic to prevent a
+      fpu stack overflow on i386 }
+    function node_resources_fpu(p: tnode): cardinal;
+      var
+        res1,res2,res3 : cardinal;
+      begin
+        result:=0;
+        res1:=0;
+        res2:=0;
+        res3:=0;
+        if p.inheritsfrom(ttertiarynode) and assigned(ttertiarynode(p).third) then
+          res3:=node_resources_fpu(ttertiarynode(p).third)
+        else if p.inheritsfrom(tbinarynode) and assigned(tbinarynode(p).right) then
+          res2:=node_resources_fpu(tbinarynode(p).right)
+        else
+          if p.inheritsfrom(tunarynode) and assigned(tunarynode(p).left) then
+            res1:=node_resources_fpu(tunarynode(p).left);
+        result:=max(max(res1,res2),res3);
+        case p.nodetype of
+          calln:
+            begin
+{$ifdef i386}
+              if tcallnode(p).procdefinition.typ=procdef then
+                result:=max(result,tprocdef(tcallnode(p).procdefinition).fpu_used)
+              else
+                result:=maxfpuregs;
+{$else i386}
+              result:=maxfpuregs;
+{$endif i386}
+            end;
+          realconstn,
+          typeconvn,
+          loadn :
+            begin
+              if p.expectloc in [LOC_CFPUREGISTER,LOC_FPUREGISTER] then
+                result:=max(result,1);
+            end;
+          assignn,
+          addn,subn,muln,slashn,
+          equaln,unequaln,gtn,gten,ltn,lten :
+            begin
+              if (tbinarynode(p).left.expectloc in [LOC_CFPUREGISTER,LOC_FPUREGISTER]) or
+                 (tbinarynode(p).right.expectloc in [LOC_CFPUREGISTER,LOC_FPUREGISTER])then
+                result:=max(result,2);
+              if(p.expectloc in [LOC_CFPUREGISTER,LOC_FPUREGISTER]) then
+                inc(result);
+            end;
+        end;
+      end;
+
+
     function setnodefilepos(var n: tnode; arg: pointer): foreachnoderesult;
     function setnodefilepos(var n: tnode; arg: pointer): foreachnoderesult;
       begin
       begin
         result:=fen_true;
         result:=fen_true;

+ 0 - 2
compiler/pdecsub.pas

@@ -952,7 +952,6 @@ implementation
                          single_type(pd.returndef,false);
                          single_type(pd.returndef,false);
                          if popclass then
                          if popclass then
                            symtablestack.pop(pd._class.symtable);
                            symtablestack.pop(pd._class.symtable);
-                         pd.test_if_fpu_result;
                          dec(testcurobject);
                          dec(testcurobject);
 
 
                          if (target_info.system in [system_m68k_amiga]) then
                          if (target_info.system in [system_m68k_amiga]) then
@@ -1092,7 +1091,6 @@ implementation
                   else
                   else
                    begin
                    begin
                      single_type(pd.returndef,false);
                      single_type(pd.returndef,false);
-                     pd.test_if_fpu_result;
                      if (optoken in [_EQUAL,_GT,_LT,_GTE,_LTE]) and
                      if (optoken in [_EQUAL,_GT,_LT,_GTE,_LTE]) and
                         ((pd.returndef.typ<>orddef) or
                         ((pd.returndef.typ<>orddef) or
                          (torddef(pd.returndef).ordtype<>bool8bit)) then
                          (torddef(pd.returndef).ordtype<>bool8bit)) then

+ 0 - 2
compiler/pexpr.pas

@@ -258,7 +258,6 @@ implementation
          { set para parsing values }
          { set para parsing values }
          in_args:=true;
          in_args:=true;
          named_args_allowed:=false;
          named_args_allowed:=false;
-         inc(parsing_para_level);
          allow_array_constructor:=true;
          allow_array_constructor:=true;
          p2:=nil;
          p2:=nil;
          repeat
          repeat
@@ -307,7 +306,6 @@ implementation
              end;
              end;
          until not try_to_consume(_COMMA);
          until not try_to_consume(_COMMA);
          allow_array_constructor:=old_allow_array_constructor;
          allow_array_constructor:=old_allow_array_constructor;
-         dec(parsing_para_level);
          in_args:=prev_in_args;
          in_args:=prev_in_args;
          named_args_allowed:=old_named_args_allowed;
          named_args_allowed:=old_named_args_allowed;
          parse_paras:=p2;
          parse_paras:=p2;

+ 0 - 2
compiler/pinline.pas

@@ -498,10 +498,8 @@ implementation
          end;
          end;
         { last param must be var }
         { last param must be var }
         destppn:=ppn.left;
         destppn:=ppn.left;
-        inc(parsing_para_level);
         valid_for_var(destppn,true);
         valid_for_var(destppn,true);
         set_varstate(destppn,vs_written,[]);
         set_varstate(destppn,vs_written,[]);
-        dec(parsing_para_level);
         { first param must be a string or dynamic array ...}
         { first param must be a string or dynamic array ...}
         isarray:=is_dynamic_array(destppn.resultdef);
         isarray:=is_dynamic_array(destppn.resultdef);
         if not((destppn.resultdef.typ=stringdef) or
         if not((destppn.resultdef.typ=stringdef) or

+ 0 - 2
compiler/powerpc/nppccnv.pas

@@ -102,8 +102,6 @@ implementation
             firstpass(left);
             firstpass(left);
           end;
           end;
         result := nil;
         result := nil;
-        if registersfpu<1 then
-          registersfpu:=1;
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
       end;
       end;
 
 

+ 0 - 2
compiler/powerpc64/nppccnv.pas

@@ -85,8 +85,6 @@ begin
   end;
   end;
   firstpass(left);
   firstpass(left);
   result := nil;
   result := nil;
-  if registersfpu < 1 then
-    registersfpu := 1;
   expectloc := LOC_FPUREGISTER;
   expectloc := LOC_FPUREGISTER;
 end;
 end;
 
 

+ 0 - 1
compiler/ppcgen/ngppcadd.pas

@@ -76,7 +76,6 @@ implementation
             firstpass(left);
             firstpass(left);
             firstpass(right);
             firstpass(right);
             expectloc := LOC_FLAGS;
             expectloc := LOC_FLAGS;
-            calcregisters(self,2,0,0);
             exit;
             exit;
           end;
           end;
         result := inherited pass_1;
         result := inherited pass_1;

+ 1 - 13
compiler/ppcgen/ngppcinl.pas

@@ -66,23 +66,16 @@ implementation
         if (current_settings.cputype >= cpu_PPC970) then
         if (current_settings.cputype >= cpu_PPC970) then
           begin
           begin
             expectloc:=LOC_FPUREGISTER;
             expectloc:=LOC_FPUREGISTER;
-            registersint:=left.registersint;
-            registersfpu:=max(left.registersfpu,1);
             first_sqrt_real := nil;
             first_sqrt_real := nil;
           end
           end
         else
         else
           result:=inherited first_sqrt_real;
           result:=inherited first_sqrt_real;
       end;
       end;
 
 
-    
+
     function tgppcinlinenode.first_abs_real : tnode;
     function tgppcinlinenode.first_abs_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
         first_abs_real := nil;
         first_abs_real := nil;
       end;
       end;
 
 
@@ -90,11 +83,6 @@ implementation
      function tgppcinlinenode.first_sqr_real : tnode;
      function tgppcinlinenode.first_sqr_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
         first_sqr_real := nil;
         first_sqr_real := nil;
       end;
       end;
 
 

+ 4 - 4
compiler/psub.pas

@@ -756,8 +756,11 @@ implementation
         { firstpass everything }
         { firstpass everything }
         flowcontrol:=[];
         flowcontrol:=[];
         do_firstpass(code);
         do_firstpass(code);
-        if code.registersfpu>0 then
+{$ifdef i386}
+        procdef.fpu_used:=node_resources_fpu(code);
+        if procdef.fpu_used>0 then
           include(flags,pi_uses_fpu);
           include(flags,pi_uses_fpu);
+{$endif i386}
 
 
         { do this before adding the entry code else the tail recursion recognition won't work,
         { do this before adding the entry code else the tail recursion recognition won't work,
           if this causes troubles, it must be if'ed
           if this causes troubles, it must be if'ed
@@ -910,9 +913,6 @@ implementation
             { generate code for the node tree }
             { generate code for the node tree }
             do_secondpass(code);
             do_secondpass(code);
             aktproccode.concatlist(current_asmdata.CurrAsmList);
             aktproccode.concatlist(current_asmdata.CurrAsmList);
-{$ifdef i386}
-            procdef.fpu_used:=code.registersfpu;
-{$endif i386}
 
 
             { The position of the loadpara_asmnode is now known }
             { The position of the loadpara_asmnode is now known }
             aktproccode.insertlistafter(loadpara_asmnode.currenttai,templist);
             aktproccode.insertlistafter(loadpara_asmnode.currenttai,templist);

+ 0 - 2
compiler/sparc/ncpucnv.pas

@@ -101,8 +101,6 @@ implementation
             firstpass(left);
             firstpass(left);
           end;
           end;
         result := nil;
         result := nil;
-        if registersfpu<1 then
-          registersfpu:=1;
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
       end;
       end;
 
 

+ 0 - 6
compiler/sparc/ncpuinln.pas

@@ -73,8 +73,6 @@ implementation
     function tsparcinlinenode.first_abs_real : tnode;
     function tsparcinlinenode.first_abs_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
         first_abs_real := nil;
         first_abs_real := nil;
       end;
       end;
 
 
@@ -82,8 +80,6 @@ implementation
     function tsparcinlinenode.first_sqr_real : tnode;
     function tsparcinlinenode.first_sqr_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
         first_sqr_real:=nil;
         first_sqr_real:=nil;
       end;
       end;
 
 
@@ -91,8 +87,6 @@ implementation
     function tsparcinlinenode.first_sqrt_real : tnode;
     function tsparcinlinenode.first_sqrt_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
         first_sqrt_real := nil;
         first_sqrt_real := nil;
       end;
       end;
 
 

+ 10 - 45
compiler/symdef.pas

@@ -347,9 +347,6 @@ interface
           { number of user visibile parameters }
           { number of user visibile parameters }
           maxparacount,
           maxparacount,
           minparacount    : byte;
           minparacount    : byte;
-{$ifdef i386}
-          fpu_used        : longint;    { how many stack fpu must be empty }
-{$endif i386}
 {$ifdef m68k}
 {$ifdef m68k}
           exp_funcretloc : tregister;   { explicit funcretloc for AmigaOS }
           exp_funcretloc : tregister;   { explicit funcretloc for AmigaOS }
 {$endif}
 {$endif}
@@ -363,7 +360,6 @@ interface
           procedure deref;override;
           procedure deref;override;
           procedure calcparas;
           procedure calcparas;
           function  typename_paras(showhidden:boolean): string;
           function  typename_paras(showhidden:boolean): string;
-          procedure test_if_fpu_result;
           function  is_methodpointer:boolean;virtual;
           function  is_methodpointer:boolean;virtual;
           function  is_addressonly:boolean;virtual;
           function  is_addressonly:boolean;virtual;
        private
        private
@@ -463,6 +459,9 @@ interface
 {$ifdef oldregvars}
 {$ifdef oldregvars}
           regvarinfo: pregvarinfo;
           regvarinfo: pregvarinfo;
 {$endif oldregvars}
 {$endif oldregvars}
+{$ifdef i386}
+          fpu_used     : byte;
+{$endif i386}
           { position in aasmoutput list }
           { position in aasmoutput list }
           procstarttai,
           procstarttai,
           procendtai   : tai;
           procendtai   : tai;
@@ -2542,13 +2541,9 @@ implementation
          proccalloption:=pocall_none;
          proccalloption:=pocall_none;
          procoptions:=[];
          procoptions:=[];
          returndef:=voidtype;
          returndef:=voidtype;
-{$ifdef i386}
-         fpu_used:=0;
-{$endif i386}
          savesize:=sizeof(aint);
          savesize:=sizeof(aint);
          requiredargarea:=0;
          requiredargarea:=0;
          has_paraloc_info:=false;
          has_paraloc_info:=false;
-
          location_reset(funcretloc[callerside],LOC_INVALID,OS_NO);
          location_reset(funcretloc[callerside],LOC_INVALID,OS_NO);
          location_reset(funcretloc[calleeside],LOC_INVALID,OS_NO);
          location_reset(funcretloc[calleeside],LOC_INVALID,OS_NO);
       end;
       end;
@@ -2625,20 +2620,6 @@ implementation
       end;
       end;
 
 
 
 
-    { all functions returning in FPU are
-      assume to use 2 FPU registers
-      until the function implementation
-      is processed   PM }
-    procedure tabstractprocdef.test_if_fpu_result;
-      begin
-{$ifdef i386}
-         if assigned(returndef) and
-            (returndef.typ=floatdef) then
-           fpu_used:=maxfpuregs;
-{$endif i386}
-      end;
-
-
     procedure tabstractprocdef.buildderef;
     procedure tabstractprocdef.buildderef;
       begin
       begin
          { released procdef? }
          { released procdef? }
@@ -2672,11 +2653,8 @@ implementation
          minparacount:=0;
          minparacount:=0;
          maxparacount:=0;
          maxparacount:=0;
          ppufile.getderef(returndefderef);
          ppufile.getderef(returndefderef);
-{$ifdef i386}
-         fpu_used:=ppufile.getbyte;
-{$else}
+{$warning TODO remove fpu_used loading}
          ppufile.getbyte;
          ppufile.getbyte;
-{$endif i386}
          proctypeoption:=tproctypeoption(ppufile.getbyte);
          proctypeoption:=tproctypeoption(ppufile.getbyte);
          proccalloption:=tproccalloption(ppufile.getbyte);
          proccalloption:=tproccalloption(ppufile.getbyte);
          ppufile.getnormalset(procoptions);
          ppufile.getnormalset(procoptions);
@@ -2707,13 +2685,7 @@ implementation
          ppufile.putderef(returndefderef);
          ppufile.putderef(returndefderef);
          oldintfcrc:=ppufile.do_interface_crc;
          oldintfcrc:=ppufile.do_interface_crc;
          ppufile.do_interface_crc:=false;
          ppufile.do_interface_crc:=false;
-{$ifdef i386}
-         if simplify_ppu then
-          fpu_used:=0;
-         ppufile.putbyte(fpu_used);
-{$else}
          ppufile.putbyte(0);
          ppufile.putbyte(0);
-{$endif}
          ppufile.putbyte(ord(proctypeoption));
          ppufile.putbyte(ord(proctypeoption));
          ppufile.putbyte(ord(proccalloption));
          ppufile.putbyte(ord(proccalloption));
          ppufile.putnormalset(procoptions);
          ppufile.putnormalset(procoptions);
@@ -2851,6 +2823,9 @@ implementation
          import_name:=nil;
          import_name:=nil;
          import_nr:=0;
          import_nr:=0;
          inlininginfo:=nil;
          inlininginfo:=nil;
+{$ifdef i386}
+          fpu_used:=maxfpuregs;
+{$endif i386}
       end;
       end;
 
 
 
 
@@ -2926,6 +2901,9 @@ implementation
          hasforward:=false;
          hasforward:=false;
          { Disable po_has_inlining until the derefimpl is done }
          { Disable po_has_inlining until the derefimpl is done }
          exclude(procoptions,po_has_inlininginfo);
          exclude(procoptions,po_has_inlininginfo);
+{$ifdef i386}
+         fpu_used:=maxfpuregs;
+{$endif i386}
       end;
       end;
 
 
 
 
@@ -3501,9 +3479,6 @@ implementation
         for i:=low(tcallercallee) to high(tcallercallee) do
         for i:=low(tcallercallee) to high(tcallercallee) do
           location_copy(tprocvardef(result).funcretloc[i],funcretloc[i]);
           location_copy(tprocvardef(result).funcretloc[i],funcretloc[i]);
         tprocvardef(result).has_paraloc_info:=has_paraloc_info;
         tprocvardef(result).has_paraloc_info:=has_paraloc_info;
-{$ifdef i386}
-        tprocvardef(result).fpu_used:=fpu_used;
-{$endif i386}
 {$ifdef m68k}
 {$ifdef m68k}
         tprocvardef(result).exp_funcretloc:=exp_funcretloc;
         tprocvardef(result).exp_funcretloc:=exp_funcretloc;
 {$endif}
 {$endif}
@@ -3512,16 +3487,6 @@ implementation
 
 
     procedure tprocvardef.ppuwrite(ppufile:tcompilerppufile);
     procedure tprocvardef.ppuwrite(ppufile:tcompilerppufile);
       begin
       begin
-        { here we cannot get a real good value so just give something }
-        { plausible (PM) }
-        { a more secure way would be
-          to allways store in a temp }
-{$ifdef i386}
-        if is_fpu(returndef) then
-          fpu_used:={2}maxfpuregs
-        else
-          fpu_used:=0;
-{$endif i386}
         inherited ppuwrite(ppufile);
         inherited ppuwrite(ppufile);
 
 
         { Write this entry }
         { Write this entry }

+ 3 - 13
compiler/x86/nx86cnv.pas

@@ -77,17 +77,9 @@ implementation
             not (nf_explicit in flags) then
             not (nf_explicit in flags) then
            CGMessage(type_w_convert_real_2_comp);
            CGMessage(type_w_convert_real_2_comp);
          if use_sse(resultdef) then
          if use_sse(resultdef) then
-           begin
-             if registersmm<1 then
-               registersmm:=1;
-             expectloc:=LOC_MMREGISTER;
-           end
+           expectloc:=LOC_MMREGISTER
          else
          else
-           begin
-             if registersfpu<1 then
-               registersfpu:=1;
-             expectloc:=LOC_FPUREGISTER;
-           end;
+           expectloc:=LOC_FPUREGISTER;
       end;
       end;
 
 
 
 
@@ -189,8 +181,6 @@ implementation
 
 
       begin
       begin
         first_int_to_real:=nil;
         first_int_to_real:=nil;
-         if registersfpu<1 then
-          registersfpu:=1;
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
       end;
       end;
 
 
@@ -244,7 +234,7 @@ implementation
                      begin
                      begin
                        emit_const_reg(A_BT,S_Q,63,left.location.register);
                        emit_const_reg(A_BT,S_Q,63,left.location.register);
                        current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,S_Q,left.location.register,location.register));
                        current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,S_Q,left.location.register,location.register));
-                     end                       
+                     end
                    else
                    else
                      begin
                      begin
                        inc(left.location.reference.offset,4);
                        inc(left.location.reference.offset,4);

+ 1 - 4
compiler/x86/nx86con.pas

@@ -51,10 +51,7 @@ implementation
       begin
       begin
          result:=nil;
          result:=nil;
          if is_number_float(value_real) and not(use_sse(resultdef)) and (value_real=1.0) or (value_real=0.0) then
          if is_number_float(value_real) and not(use_sse(resultdef)) and (value_real=1.0) or (value_real=0.0) then
-           begin
-              expectloc:=LOC_FPUREGISTER;
-              registersfpu:=1;
-           end
+           expectloc:=LOC_FPUREGISTER
          else
          else
            expectloc:=LOC_CREFERENCE;
            expectloc:=LOC_CREFERENCE;
       end;
       end;

+ 2 - 53
compiler/x86/nx86inl.pas

@@ -86,7 +86,6 @@ implementation
      function tx86inlinenode.first_pi : tnode;
      function tx86inlinenode.first_pi : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersfpu:=1;
         first_pi := nil;
         first_pi := nil;
       end;
       end;
 
 
@@ -94,85 +93,45 @@ implementation
      function tx86inlinenode.first_arctan_real : tnode;
      function tx86inlinenode.first_arctan_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,2);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
         first_arctan_real := nil;
         first_arctan_real := nil;
       end;
       end;
 
 
      function tx86inlinenode.first_abs_real : tnode;
      function tx86inlinenode.first_abs_real : tnode;
        begin
        begin
          if use_sse(resultdef) then
          if use_sse(resultdef) then
-           begin
-             expectloc:=LOC_MMREGISTER;
-             registersmm:=max(left.registersmm,1);
-           end
+           expectloc:=LOC_MMREGISTER
          else
          else
-           begin
-             expectloc:=LOC_FPUREGISTER;
-             registersfpu:=max(left.registersfpu,1);
-          end;
-        registersint:=left.registersint;
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
+           expectloc:=LOC_FPUREGISTER;
         first_abs_real := nil;
         first_abs_real := nil;
       end;
       end;
 
 
      function tx86inlinenode.first_sqr_real : tnode;
      function tx86inlinenode.first_sqr_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
         first_sqr_real := nil;
         first_sqr_real := nil;
       end;
       end;
 
 
      function tx86inlinenode.first_sqrt_real : tnode;
      function tx86inlinenode.first_sqrt_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
         first_sqrt_real := nil;
         first_sqrt_real := nil;
       end;
       end;
 
 
      function tx86inlinenode.first_ln_real : tnode;
      function tx86inlinenode.first_ln_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,2);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
         first_ln_real := nil;
         first_ln_real := nil;
       end;
       end;
 
 
      function tx86inlinenode.first_cos_real : tnode;
      function tx86inlinenode.first_cos_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
         first_cos_real := nil;
         first_cos_real := nil;
       end;
       end;
 
 
      function tx86inlinenode.first_sin_real : tnode;
      function tx86inlinenode.first_sin_real : tnode;
       begin
       begin
         expectloc:=LOC_FPUREGISTER;
         expectloc:=LOC_FPUREGISTER;
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
         first_sin_real := nil;
         first_sin_real := nil;
       end;
       end;
 
 
@@ -186,11 +145,6 @@ implementation
 {$else x86_64}
 {$else x86_64}
           expectloc:=LOC_REFERENCE;
           expectloc:=LOC_REFERENCE;
 {$endif x86_64}
 {$endif x86_64}
-        registersint:=left.registersint;
-        registersfpu:=max(left.registersfpu,1);
-{$ifdef SUPPORT_MMX}
-        registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
         result:=nil;
         result:=nil;
       end;
       end;
 
 
@@ -212,11 +166,6 @@ implementation
 {$else x86_64}
 {$else x86_64}
                expectloc:=LOC_REFERENCE;
                expectloc:=LOC_REFERENCE;
 {$endif x86_64}
 {$endif x86_64}
-             registersint:=left.registersint;
-             registersfpu:=max(left.registersfpu,1);
-{$ifdef SUPPORT_MMX}
-             registersmmx:=left.registersmmx;
-{$endif SUPPORT_MMX}
              result:=nil;
              result:=nil;
            end;
            end;
        end;
        end;

+ 3 - 16
compiler/x86/nx86mat.pas

@@ -72,29 +72,16 @@ interface
          if (left.resultdef.typ=floatdef) then
          if (left.resultdef.typ=floatdef) then
            begin
            begin
              if use_sse(left.resultdef) then
              if use_sse(left.resultdef) then
-               begin
-                 if (registersmm < 1) then
-                   registersmm := 1;
-                 expectloc:=LOC_MMREGISTER;
-               end
+               expectloc:=LOC_MMREGISTER
              else
              else
-               begin
-                 if (registersfpu < 1) then
-                   registersfpu := 1;
-                 expectloc:=LOC_FPUREGISTER;
-               end;
+               expectloc:=LOC_FPUREGISTER;
            end
            end
 {$ifdef SUPPORT_MMX}
 {$ifdef SUPPORT_MMX}
          else
          else
            if (cs_mmx in current_settings.localswitches) and
            if (cs_mmx in current_settings.localswitches) and
               is_mmx_able_array(left.resultdef) then
               is_mmx_able_array(left.resultdef) then
              begin
              begin
-               registersint:=left.registersint;
-               registersfpu:=left.registersfpu;
-               registersmmx:=left.registersmmx;
-               if (left.location.loc<>LOC_MMXREGISTER) and
-                  (registersmmx<1) then
-                 registersmmx:=1;
+               expectloc:=LOC_MMXREGISTER;
              end
              end
 {$endif SUPPORT_MMX}
 {$endif SUPPORT_MMX}
          else
          else

+ 1 - 8
compiler/x86/nx86set.pas

@@ -63,13 +63,6 @@ implementation
          firstpass(left);
          firstpass(left);
          if codegenerror then
          if codegenerror then
            exit;
            exit;
-
-         left_right_max;
-         { a smallset needs maybe an misc. register }
-         if (left.nodetype<>ordconstn) and
-            not(right.expectloc in [LOC_CREGISTER,LOC_REGISTER]) and
-            (right.registersint<1) then
-           inc(registersint);
       end;
       end;
 
 
 
 
@@ -417,7 +410,7 @@ implementation
                   pleftreg:=left.location.register;
                   pleftreg:=left.location.register;
 
 
                   if (opsize >= OS_S8) or { = if signed }
                   if (opsize >= OS_S8) or { = if signed }
-                     ((left.resultdef.typ=orddef) and 
+                     ((left.resultdef.typ=orddef) and
                       ((torddef(left.resultdef).low < int64(tsetdef(right.resultdef).setbase)) or
                       ((torddef(left.resultdef).low < int64(tsetdef(right.resultdef).setbase)) or
                        (torddef(left.resultdef).high > int64(tsetdef(right.resultdef).setmax)))) or
                        (torddef(left.resultdef).high > int64(tsetdef(right.resultdef).setmax)))) or
                      ((left.resultdef.typ=enumdef) and
                      ((left.resultdef.typ=enumdef) and