Quellcode durchsuchen

* replaced current_procinfo.currtrue/falselabel with storing the true/false
labels of LOC_JUMP in the node's location. This generates some extra jumps
for short circuit boolean and/or-expressions if optimizations are off, but
with optimisations enabled the generated code is the same (except for JVM
because the jump threading optimisation isn't enabled there yet).

git-svn-id: trunk@31431 -

Jonas Maebe vor 10 Jahren
Ursprung
Commit
0fc1fd6ac1

+ 1 - 7
compiler/aarch64/ncpucnv.pas

@@ -142,7 +142,7 @@ implementation
   procedure taarch64typeconvnode.second_int_to_bool;
   procedure taarch64typeconvnode.second_int_to_bool;
     var
     var
       resflags: tresflags;
       resflags: tresflags;
-      hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+      hlabel: tasmlabel;
     begin
     begin
       if (nf_explicit in flags) and
       if (nf_explicit in flags) and
          not(left.expectloc in [LOC_FLAGS,LOC_JUMP]) then
          not(left.expectloc in [LOC_FLAGS,LOC_JUMP]) then
@@ -154,10 +154,6 @@ implementation
       { can't use the generic code, as it assumes that OP_OR automatically sets
       { can't use the generic code, as it assumes that OP_OR automatically sets
         the flags. We can also do things more efficiently directly }
         the flags. We can also do things more efficiently directly }
 
 
-      oldTrueLabel:=current_procinfo.CurrTrueLabel;
-      oldFalseLabel:=current_procinfo.CurrFalseLabel;
-      current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-      current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
       secondpass(left);
       secondpass(left);
       if codegenerror then
       if codegenerror then
        exit;
        exit;
@@ -195,8 +191,6 @@ implementation
       else
       else
         cg.g_flags2reg(current_asmdata.CurrAsmList,location.size,resflags,location.register);
         cg.g_flags2reg(current_asmdata.CurrAsmList,location.size,resflags,location.register);
       cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
       cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
-      current_procinfo.CurrTrueLabel:=oldTrueLabel;
-      current_procinfo.CurrFalseLabel:=oldFalseLabel;
     end;
     end;
 
 
 
 

+ 12 - 7
compiler/arm/narmadd.pas

@@ -407,10 +407,13 @@ interface
         unsigned : boolean;
         unsigned : boolean;
         oldnodetype : tnodetype;
         oldnodetype : tnodetype;
         dummyreg : tregister;
         dummyreg : tregister;
+        truelabel, falselabel: tasmlabel;
         l: tasmlabel;
         l: tasmlabel;
       const
       const
         lt_zero_swapped: array[boolean] of tnodetype = (ltn, gtn);
         lt_zero_swapped: array[boolean] of tnodetype = (ltn, gtn);
       begin
       begin
+        truelabel:=nil;
+        falselabel:=nil;
         unsigned:=not(is_signed(left.resultdef)) or
         unsigned:=not(is_signed(left.resultdef)) or
                   not(is_signed(right.resultdef));
                   not(is_signed(right.resultdef));
 
 
@@ -472,17 +475,19 @@ interface
             else
             else
             { operation requiring proper N, Z and V flags ? }
             { operation requiring proper N, Z and V flags ? }
               begin
               begin
-                location_reset(location,LOC_JUMP,OS_NO);
+                current_asmdata.getjumplabel(truelabel);
+                current_asmdata.getjumplabel(falselabel);
+                location_reset_jump(location,truelabel,falselabel);
                 cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                 cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                 current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
                 current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
                 { the jump the sequence is a little bit hairy }
                 { the jump the sequence is a little bit hairy }
                 case nodetype of
                 case nodetype of
                    ltn,gtn:
                    ltn,gtn:
                      begin
                      begin
-                        cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrTrueLabel);
+                        cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),location.truelabel);
                         { cheat a little bit for the negative test }
                         { cheat a little bit for the negative test }
                         toggleflag(nf_swapped);
                         toggleflag(nf_swapped);
-                        cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrFalseLabel);
+                        cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),location.falselabel);
                         cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                         cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                         toggleflag(nf_swapped);
                         toggleflag(nf_swapped);
                      end;
                      end;
@@ -493,13 +498,13 @@ interface
                           nodetype:=ltn
                           nodetype:=ltn
                         else
                         else
                           nodetype:=gtn;
                           nodetype:=gtn;
-                        cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
+                        cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.truelabel);
                         { cheat for the negative test }
                         { cheat for the negative test }
                         if nodetype=ltn then
                         if nodetype=ltn then
                           nodetype:=gtn
                           nodetype:=gtn
                         else
                         else
                           nodetype:=ltn;
                           nodetype:=ltn;
-                        cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
+                        cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.falselabel);
                         cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                         cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                         nodetype:=oldnodetype;
                         nodetype:=oldnodetype;
                      end;
                      end;
@@ -508,8 +513,8 @@ interface
                 current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
                 current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
                 { the comparisaion of the low dword have to be
                 { the comparisaion of the low dword have to be
                    always unsigned!                            }
                    always unsigned!                            }
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
-                cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),location.truelabel);
+                cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
                 cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
                 cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
               end;
               end;
           end;
           end;

+ 3 - 12
compiler/arm/narmcnv.pas

@@ -283,13 +283,9 @@ implementation
         hregister : tregister;
         hregister : tregister;
         href      : treference;
         href      : treference;
         resflags  : tresflags;
         resflags  : tresflags;
-        hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+        hlabel    : tasmlabel;
         newsize   : tcgsize;
         newsize   : tcgsize;
       begin
       begin
-         oldTrueLabel:=current_procinfo.CurrTrueLabel;
-         oldFalseLabel:=current_procinfo.CurrFalseLabel;
-         current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-         current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
          secondpass(left);
          secondpass(left);
          if codegenerror then
          if codegenerror then
           exit;
           exit;
@@ -307,8 +303,6 @@ implementation
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
               else
               else
                 location.size:=newsize;
                 location.size:=newsize;
-              current_procinfo.CurrTrueLabel:=oldTrueLabel;
-              current_procinfo.CurrFalseLabel:=oldFalseLabel;
               exit;
               exit;
            end;
            end;
 
 
@@ -365,10 +359,10 @@ implementation
               begin
               begin
                 hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
                 hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
                 current_asmdata.getjumplabel(hlabel);
                 current_asmdata.getjumplabel(hlabel);
-                cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                cg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hregister);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hregister);
                 cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
                 cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
-                cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hregister);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hregister);
                 cg.a_label(current_asmdata.CurrAsmList,hlabel);
                 cg.a_label(current_asmdata.CurrAsmList,hlabel);
                 tbasecgarm(cg).cgsetflags:=true;
                 tbasecgarm(cg).cgsetflags:=true;
@@ -401,9 +395,6 @@ implementation
          else
          else
 {$endif cpu64bitalu}
 {$endif cpu64bitalu}
            location.register:=hreg1;
            location.register:=hreg1;
-
-         current_procinfo.CurrTrueLabel:=oldTrueLabel;
-         current_procinfo.CurrFalseLabel:=oldFalseLabel;
       end;
       end;
 
 
 
 

+ 18 - 3
compiler/cgutils.pas

@@ -151,7 +151,10 @@ unit cgutils;
             );
             );
             LOC_SUBSETREF : (
             LOC_SUBSETREF : (
               sref: tsubsetreference;
               sref: tsubsetreference;
-            )
+            );
+            LOC_JUMP : (
+              truelabel, falselabel: tasmlabel;
+            );
       end;
       end;
 
 
 
 
@@ -175,6 +178,8 @@ unit cgutils;
     procedure location_reset(var l : tlocation;lt:TCGNonRefLoc;lsize:TCGSize);
     procedure location_reset(var l : tlocation;lt:TCGNonRefLoc;lsize:TCGSize);
     { for loc_(c)reference }
     { for loc_(c)reference }
     procedure location_reset_ref(var l : tlocation;lt:TCGRefLoc;lsize:TCGSize; alignment: longint);
     procedure location_reset_ref(var l : tlocation;lt:TCGRefLoc;lsize:TCGSize; alignment: longint);
+    { for loc_jump }
+    procedure location_reset_jump(out l: tlocation; truelab, falselab: tasmlabel);
     procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
     procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
     procedure location_swap(var destloc,sourceloc : tlocation);
     procedure location_swap(var destloc,sourceloc : tlocation);
     function location_reg2string(const locreg: tlocation): string;
     function location_reg2string(const locreg: tlocation): string;
@@ -247,8 +252,8 @@ uses
         FillChar(l,sizeof(tlocation),0);
         FillChar(l,sizeof(tlocation),0);
         l.loc:=lt;
         l.loc:=lt;
         l.size:=lsize;
         l.size:=lsize;
-        if l.loc in [LOC_REFERENCE,LOC_CREFERENCE] then
-          { call location_reset_ref instead }
+        if l.loc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_JUMP] then
+          { call location_reset_ref/jump instead }
           internalerror(2009020705);
           internalerror(2009020705);
       end;
       end;
 
 
@@ -265,6 +270,16 @@ uses
     end;
     end;
 
 
 
 
+    procedure location_reset_jump(out l: tlocation; truelab, falselab: tasmlabel);
+      begin
+        FillChar(l,sizeof(tlocation),0);
+        l.loc:=LOC_JUMP;
+        l.size:=OS_NO;
+        l.truelabel:=truelab;
+        l.falselabel:=falselab;
+      end;
+
+
     procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
     procedure location_copy(var destloc:tlocation; const sourceloc : tlocation);
       begin
       begin
         destloc:=sourceloc;
         destloc:=sourceloc;

+ 7 - 7
compiler/hlcg2ll.pas

@@ -307,7 +307,7 @@ unit hlcg2ll;
           procedure location_force_mmregscalar(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override;
           procedure location_force_mmregscalar(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override;
 //          procedure location_force_mmreg(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override;
 //          procedure location_force_mmreg(list:TAsmList;var l: tlocation;size:tdef;maybeconst:boolean);override;
 
 
-          procedure maketojumpbool(list:TAsmList; p : tnode);override;
+          procedure maketojumpboollabels(list: TAsmList; p: tnode; truelabel, falselabel: tasmlabel); override;
 
 
           procedure gen_load_para_value(list:TAsmList);override;
           procedure gen_load_para_value(list:TAsmList);override;
          protected
          protected
@@ -1041,11 +1041,11 @@ implementation
 {$endif cpuflags}
 {$endif cpuflags}
               LOC_JUMP :
               LOC_JUMP :
                 begin
                 begin
-                  cg.a_label(list,current_procinfo.CurrTrueLabel);
+                  cg.a_label(list,l.truelabel);
                   cg.a_load_const_reg(list,OS_INT,1,hregister);
                   cg.a_load_const_reg(list,OS_INT,1,hregister);
                   current_asmdata.getjumplabel(hl);
                   current_asmdata.getjumplabel(hl);
                   cg.a_jmp_always(list,hl);
                   cg.a_jmp_always(list,hl);
-                  cg.a_label(list,current_procinfo.CurrFalseLabel);
+                  cg.a_label(list,l.falselabel);
                   cg.a_load_const_reg(list,OS_INT,0,hregister);
                   cg.a_load_const_reg(list,OS_INT,0,hregister);
                   cg.a_label(list,hl);
                   cg.a_label(list,hl);
 {$if defined(cpu8bitalu) or defined(cpu16bitalu)}
 {$if defined(cpu8bitalu) or defined(cpu16bitalu)}
@@ -1141,11 +1141,11 @@ implementation
                 if TCGSize2Size[dst_cgsize]>TCGSize2Size[OS_INT] then
                 if TCGSize2Size[dst_cgsize]>TCGSize2Size[OS_INT] then
                   tmpsize:=OS_INT;
                   tmpsize:=OS_INT;
 {$endif}
 {$endif}
-                cg.a_label(list,current_procinfo.CurrTrueLabel);
+                cg.a_label(list,l.truelabel);
                 cg.a_load_const_reg(list,tmpsize,1,hregister);
                 cg.a_load_const_reg(list,tmpsize,1,hregister);
                 current_asmdata.getjumplabel(hl);
                 current_asmdata.getjumplabel(hl);
                 cg.a_jmp_always(list,hl);
                 cg.a_jmp_always(list,hl);
-                cg.a_label(list,current_procinfo.CurrFalseLabel);
+                cg.a_label(list,l.falselabel);
                 cg.a_load_const_reg(list,tmpsize,0,hregister);
                 cg.a_load_const_reg(list,tmpsize,0,hregister);
                 cg.a_label(list,hl);
                 cg.a_label(list,hl);
 {$if defined(cpu8bitalu) or defined(cpu16bitalu)}
 {$if defined(cpu8bitalu) or defined(cpu16bitalu)}
@@ -1311,11 +1311,11 @@ implementation
       ncgutil.location_force_mmreg(list,l,maybeconst);
       ncgutil.location_force_mmreg(list,l,maybeconst);
     end;
     end;
 *)
 *)
-  procedure thlcg2ll.maketojumpbool(list: TAsmList; p: tnode);
+  procedure thlcg2ll.maketojumpboollabels(list: TAsmList; p: tnode; truelabel, falselabel: tasmlabel);
     begin
     begin
       { loadregvars parameter is no longer used, should be removed from
       { loadregvars parameter is no longer used, should be removed from
          ncgutil version as well }
          ncgutil version as well }
-      ncgutil.maketojumpbool(list,p,lr_dont_load_regvars);
+      ncgutil.maketojumpboollabels(list,p,truelabel,falselabel);
     end;
     end;
 
 
   procedure thlcg2ll.gen_load_para_value(list: TAsmList);
   procedure thlcg2ll.gen_load_para_value(list: TAsmList);

+ 47 - 18
compiler/hlcgobj.pas

@@ -552,7 +552,12 @@ unit hlcgobj;
             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;def: tdef; const l:tlocation;var ref:treference;loadref:boolean; alignment: longint);virtual;
           procedure location_get_data_ref(list:TAsmList;def: tdef; const l:tlocation;var ref:treference;loadref:boolean; alignment: longint);virtual;
 
 
-          procedure maketojumpbool(list:TAsmList; p : tnode);virtual;
+          { if p is a boolean expression, turns p.location into a LOC_JUMP with
+            jumps to generated true and false labels; otherwise internalerrors }
+          procedure maketojumpbool(list: TAsmList; p: tnode);
+          { same as above, but using predefined true/false labels instead of
+            by generating new ones }
+          procedure maketojumpboollabels(list: TAsmList; p: tnode; truelabel, falselabel: tasmlabel);virtual;
           { if the result of n is a LOC_C(..)REGISTER, try to find the corresponding
           { if the result of n is a LOC_C(..)REGISTER, try to find the corresponding
             loadn and change its location to a new register (= SSA). In case reload
             loadn and change its location to a new register (= SSA). In case reload
             is true, transfer the old to the new register                            }
             is true, transfer the old to the new register                            }
@@ -3850,11 +3855,11 @@ implementation
 {$endif cpuflags}
 {$endif cpuflags}
         LOC_JUMP :
         LOC_JUMP :
           begin
           begin
-            a_label(list,current_procinfo.CurrTrueLabel);
+            a_label(list,l.truelabel);
             a_load_const_reg(list,dst_size,1,hregister);
             a_load_const_reg(list,dst_size,1,hregister);
             current_asmdata.getjumplabel(hl);
             current_asmdata.getjumplabel(hl);
             a_jmp_always(list,hl);
             a_jmp_always(list,hl);
-            a_label(list,current_procinfo.CurrFalseLabel);
+            a_label(list,l.falselabel);
             a_load_const_reg(list,dst_size,0,hregister);
             a_load_const_reg(list,dst_size,0,hregister);
             a_label(list,hl);
             a_label(list,hl);
           end;
           end;
@@ -4035,15 +4040,27 @@ implementation
         end;
         end;
       end;
       end;
 
 
+
   procedure thlcgobj.maketojumpbool(list: TAsmList; p: tnode);
   procedure thlcgobj.maketojumpbool(list: TAsmList; p: tnode);
-  {
-    produces jumps to true respectively false labels using boolean expressions
-
-    depending on whether the loading of regvars is currently being
-    synchronized manually (such as in an if-node) or automatically (most of
-    the other cases where this procedure is called), loadregvars can be
-    "lr_load_regvars" or "lr_dont_load_regvars"
-  }
+    var
+      truelabel,
+      falselabel: tasmlabel;
+    begin
+       if p.location.loc<>LOC_JUMP then
+         begin
+           current_asmdata.getjumplabel(truelabel);
+           current_asmdata.getjumplabel(falselabel);
+         end
+       else
+         begin
+           truelabel:=p.location.truelabel;
+           falselabel:=p.location.falselabel;
+         end;
+       maketojumpboollabels(list,p,truelabel,falselabel);
+    end;
+
+
+  procedure thlcgobj.maketojumpboollabels(list: TAsmList; p: tnode; truelabel, falselabel: tasmlabel);
     var
     var
       storepos : tfileposinfo;
       storepos : tfileposinfo;
     begin
     begin
@@ -4056,9 +4073,9 @@ implementation
             if is_constboolnode(p) then
             if is_constboolnode(p) then
               begin
               begin
                  if Tordconstnode(p).value.uvalue<>0 then
                  if Tordconstnode(p).value.uvalue<>0 then
-                   a_jmp_always(list,current_procinfo.CurrTrueLabel)
+                   a_jmp_always(list,truelabel)
                  else
                  else
-                   a_jmp_always(list,current_procinfo.CurrFalseLabel)
+                   a_jmp_always(list,falselabel)
               end
               end
             else
             else
               begin
               begin
@@ -4067,17 +4084,28 @@ implementation
                    LOC_SUBSETREF,LOC_CSUBSETREF,
                    LOC_SUBSETREF,LOC_CSUBSETREF,
                    LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE :
                    LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE :
                      begin
                      begin
-                       a_cmp_const_loc_label(list,p.resultdef,OC_NE,0,p.location,current_procinfo.CurrTrueLabel);
-                       a_jmp_always(list,current_procinfo.CurrFalseLabel);
+                       a_cmp_const_loc_label(list,p.resultdef,OC_NE,0,p.location,truelabel);
+                       a_jmp_always(list,falselabel);
                      end;
                      end;
                    LOC_JUMP:
                    LOC_JUMP:
-                     ;
+                     begin
+                       if truelabel<>p.location.truelabel then
+                         begin
+                           a_label(list,p.location.truelabel);
+                           a_jmp_always(list,truelabel);
+                         end;
+                       if falselabel<>p.location.falselabel then
+                         begin
+                           a_label(list,p.location.falselabel);
+                           a_jmp_always(list,falselabel);
+                         end;
+                     end;
 {$ifdef cpuflags}
 {$ifdef cpuflags}
                    LOC_FLAGS :
                    LOC_FLAGS :
                      begin
                      begin
-                       a_jmp_flags(list,p.location.resflags,current_procinfo.CurrTrueLabel);
+                       a_jmp_flags(list,p.location.resflags,truelabel);
                        a_reg_dealloc(list,NR_DEFAULTFLAGS);
                        a_reg_dealloc(list,NR_DEFAULTFLAGS);
-                       a_jmp_always(list,current_procinfo.CurrFalseLabel);
+                       a_jmp_always(list,falselabel);
                      end;
                      end;
 {$endif cpuflags}
 {$endif cpuflags}
                    else
                    else
@@ -4087,6 +4115,7 @@ implementation
                      end;
                      end;
                  end;
                  end;
               end;
               end;
+            location_reset_jump(p.location,truelabel,falselabel);
          end
          end
        else
        else
          internalerror(2011010419);
          internalerror(2011010419);

+ 25 - 19
compiler/i386/n386add.pas

@@ -229,6 +229,8 @@ interface
 
 
     procedure ti386addnode.second_cmp64bit;
     procedure ti386addnode.second_cmp64bit;
       var
       var
+        truelabel,
+        falselabel,
         hlab       : tasmlabel;
         hlab       : tasmlabel;
         href       : treference;
         href       : treference;
         unsigned   : boolean;
         unsigned   : boolean;
@@ -246,12 +248,12 @@ interface
            case nodetype of
            case nodetype of
               ltn,gtn:
               ltn,gtn:
                 begin
                 begin
-                   if (hlab<>current_procinfo.CurrTrueLabel) then
-                     cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
+                   if (hlab<>location.truelabel) then
+                     cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.truelabel);
                    { cheat a little bit for the negative test }
                    { cheat a little bit for the negative test }
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
-                   if (hlab<>current_procinfo.CurrFalseLabel) then
-                     cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
+                   if (hlab<>location.falselabel) then
+                     cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.falselabel);
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
                 end;
                 end;
               lten,gten:
               lten,gten:
@@ -261,21 +263,21 @@ interface
                      nodetype:=ltn
                      nodetype:=ltn
                    else
                    else
                      nodetype:=gtn;
                      nodetype:=gtn;
-                   if (hlab<>current_procinfo.CurrTrueLabel) then
-                     cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
+                   if (hlab<>location.truelabel) then
+                     cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.truelabel);
                    { cheat for the negative test }
                    { cheat for the negative test }
                    if nodetype=ltn then
                    if nodetype=ltn then
                      nodetype:=gtn
                      nodetype:=gtn
                    else
                    else
                      nodetype:=ltn;
                      nodetype:=ltn;
-                   if (hlab<>current_procinfo.CurrFalseLabel) then
-                     cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
+                   if (hlab<>location.falselabel) then
+                     cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.falselabel);
                    nodetype:=oldnodetype;
                    nodetype:=oldnodetype;
                 end;
                 end;
               equaln:
               equaln:
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrFalseLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.falselabel);
               unequaln:
               unequaln:
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrTrueLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.truelabel);
            end;
            end;
         end;
         end;
 
 
@@ -288,23 +290,25 @@ interface
                 begin
                 begin
                    { the comparisaion of the low dword have to be }
                    { the comparisaion of the low dword have to be }
                    {  always unsigned!                            }
                    {  always unsigned!                            }
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),location.truelabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
                 end;
                 end;
               equaln:
               equaln:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrFalseLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.falselabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,location.truelabel);
                 end;
                 end;
               unequaln:
               unequaln:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrTrueLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.truelabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
                 end;
                 end;
            end;
            end;
         end;
         end;
 
 
       begin
       begin
+        truelabel:=nil;
+        falselabel:=nil;
         pass_left_right;
         pass_left_right;
 
 
         unsigned:=((left.resultdef.typ=orddef) and
         unsigned:=((left.resultdef.typ=orddef) and
@@ -313,7 +317,9 @@ interface
                    (torddef(right.resultdef).ordtype=u64bit));
                    (torddef(right.resultdef).ordtype=u64bit));
 
 
         { we have LOC_JUMP as result }
         { we have LOC_JUMP as result }
-        location_reset(location,LOC_JUMP,OS_NO);
+        current_asmdata.getjumplabel(truelabel);
+        current_asmdata.getjumplabel(falselabel);
+        location_reset_jump(location,truelabel,falselabel);
 
 
         { Relational compares against constants having low dword=0 can omit the
         { Relational compares against constants having low dword=0 can omit the
           second compare based on the fact that any unsigned value is >=0 }
           second compare based on the fact that any unsigned value is >=0 }
@@ -322,8 +328,8 @@ interface
            (lo(right.location.value64)=0) then
            (lo(right.location.value64)=0) then
           begin
           begin
             case getresflags(true) of
             case getresflags(true) of
-              F_AE: hlab:=current_procinfo.CurrTrueLabel;
-              F_B:  hlab:=current_procinfo.CurrFalseLabel;
+              F_AE: hlab:=location.truelabel ;
+              F_B:  hlab:=location.falselabel;
             end;
             end;
           end;
           end;
 
 

+ 50 - 38
compiler/i8086/n8086add.pas

@@ -518,6 +518,8 @@ interface
 
 
     procedure ti8086addnode.second_cmp64bit;
     procedure ti8086addnode.second_cmp64bit;
       var
       var
+        truelabel,
+        falselabel : tasmlabel;
         hregister,
         hregister,
         hregister2 : tregister;
         hregister2 : tregister;
         href       : treference;
         href       : treference;
@@ -536,10 +538,10 @@ interface
            case nodetype of
            case nodetype of
               ltn,gtn:
               ltn,gtn:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.truelabel);
                    { cheat a little bit for the negative test }
                    { cheat a little bit for the negative test }
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.falselabel);
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
                 end;
                 end;
               lten,gten:
               lten,gten:
@@ -549,19 +551,19 @@ interface
                      nodetype:=ltn
                      nodetype:=ltn
                    else
                    else
                      nodetype:=gtn;
                      nodetype:=gtn;
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.truelabel);
                    { cheat for the negative test }
                    { cheat for the negative test }
                    if nodetype=ltn then
                    if nodetype=ltn then
                      nodetype:=gtn
                      nodetype:=gtn
                    else
                    else
                      nodetype:=ltn;
                      nodetype:=ltn;
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.falselabel);
                    nodetype:=oldnodetype;
                    nodetype:=oldnodetype;
                 end;
                 end;
               equaln:
               equaln:
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrFalseLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.falselabel);
               unequaln:
               unequaln:
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrTrueLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.truelabel);
            end;
            end;
         end;
         end;
 
 
@@ -580,10 +582,10 @@ interface
                 begin
                 begin
                    { the comparisaion of the low word have to be }
                    { the comparisaion of the low word have to be }
                    {  always unsigned!                           }
                    {  always unsigned!                           }
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),location.truelabel);
                    { cheat a little bit for the negative test }
                    { cheat a little bit for the negative test }
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),location.falselabel);
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
                 end;
                 end;
               lten,gten:
               lten,gten:
@@ -593,19 +595,19 @@ interface
                      nodetype:=ltn
                      nodetype:=ltn
                    else
                    else
                      nodetype:=gtn;
                      nodetype:=gtn;
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),location.truelabel);
                    { cheat for the negative test }
                    { cheat for the negative test }
                    if nodetype=ltn then
                    if nodetype=ltn then
                      nodetype:=gtn
                      nodetype:=gtn
                    else
                    else
                      nodetype:=ltn;
                      nodetype:=ltn;
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),location.falselabel);
                    nodetype:=oldnodetype;
                    nodetype:=oldnodetype;
                 end;
                 end;
               equaln:
               equaln:
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrFalseLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.falselabel);
               unequaln:
               unequaln:
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrTrueLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.truelabel);
            end;
            end;
         end;
         end;
 
 
@@ -618,23 +620,25 @@ interface
                 begin
                 begin
                    { the comparisaion of the low word have to be }
                    { the comparisaion of the low word have to be }
                    {  always unsigned!                           }
                    {  always unsigned!                           }
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),location.truelabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
                 end;
                 end;
               equaln:
               equaln:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrFalseLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.falselabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,location.truelabel);
                 end;
                 end;
               unequaln:
               unequaln:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrTrueLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.truelabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
                 end;
                 end;
            end;
            end;
         end;
         end;
 
 
       begin
       begin
+        truelabel:=nil;
+        falselabel:=nil;
         pass_left_right;
         pass_left_right;
 
 
         unsigned:=((left.resultdef.typ=orddef) and
         unsigned:=((left.resultdef.typ=orddef) and
@@ -642,6 +646,11 @@ interface
                   ((right.resultdef.typ=orddef) and
                   ((right.resultdef.typ=orddef) and
                    (torddef(right.resultdef).ordtype=u64bit));
                    (torddef(right.resultdef).ordtype=u64bit));
 
 
+        { we have LOC_JUMP as result }
+        current_asmdata.getjumplabel(truelabel);
+        current_asmdata.getjumplabel(falselabel);
+        location_reset_jump(location,truelabel,falselabel);
+
         { left and right no register?  }
         { left and right no register?  }
         { then one must be demanded    }
         { then one must be demanded    }
         if (left.location.loc<>LOC_REGISTER) then
         if (left.location.loc<>LOC_REGISTER) then
@@ -709,7 +718,7 @@ interface
                  middlejmp64bitcmp;
                  middlejmp64bitcmp;
                  emit_ref_reg(A_CMP,S_W,right.location.reference,left.location.register64.reglo);
                  emit_ref_reg(A_CMP,S_W,right.location.reference,left.location.register64.reglo);
                  lastjmp64bitcmp;
                  lastjmp64bitcmp;
-                 cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                 cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
                  location_freetemp(current_asmdata.CurrAsmList,right.location);
                  location_freetemp(current_asmdata.CurrAsmList,right.location);
                end;
                end;
              LOC_CONSTANT :
              LOC_CONSTANT :
@@ -727,13 +736,12 @@ interface
                internalerror(200203282);
                internalerror(200203282);
            end;
            end;
          end;
          end;
-
-        { we have LOC_JUMP as result }
-        location_reset(location,LOC_JUMP,OS_NO)
       end;
       end;
 
 
     procedure ti8086addnode.second_cmp32bit;
     procedure ti8086addnode.second_cmp32bit;
       var
       var
+        truelabel,
+        falselabel: tasmlabel;
         hregister : tregister;
         hregister : tregister;
         href      : treference;
         href      : treference;
         unsigned  : boolean;
         unsigned  : boolean;
@@ -751,10 +759,10 @@ interface
            case nodetype of
            case nodetype of
               ltn,gtn:
               ltn,gtn:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.truelabel);
                    { cheat a little bit for the negative test }
                    { cheat a little bit for the negative test }
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.falselabel);
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
                 end;
                 end;
               lten,gten:
               lten,gten:
@@ -764,19 +772,19 @@ interface
                      nodetype:=ltn
                      nodetype:=ltn
                    else
                    else
                      nodetype:=gtn;
                      nodetype:=gtn;
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.truelabel);
                    { cheat for the negative test }
                    { cheat for the negative test }
                    if nodetype=ltn then
                    if nodetype=ltn then
                      nodetype:=gtn
                      nodetype:=gtn
                    else
                    else
                      nodetype:=ltn;
                      nodetype:=ltn;
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.falselabel);
                    nodetype:=oldnodetype;
                    nodetype:=oldnodetype;
                 end;
                 end;
               equaln:
               equaln:
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrFalseLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.falselabel);
               unequaln:
               unequaln:
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrTrueLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.truelabel);
            end;
            end;
         end;
         end;
 
 
@@ -789,23 +797,25 @@ interface
                 begin
                 begin
                    { the comparisaion of the low dword have to be }
                    { the comparisaion of the low dword have to be }
                    {  always unsigned!                            }
                    {  always unsigned!                            }
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),location.truelabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
                 end;
                 end;
               equaln:
               equaln:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrFalseLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.falselabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,location.truelabel);
                 end;
                 end;
               unequaln:
               unequaln:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrTrueLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.truelabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
                 end;
                 end;
            end;
            end;
         end;
         end;
 
 
       begin
       begin
+        truelabel:=nil;
+        falselabel:=nil;
         pass_left_right;
         pass_left_right;
 
 
         unsigned:=((left.resultdef.typ=orddef) and
         unsigned:=((left.resultdef.typ=orddef) and
@@ -814,6 +824,11 @@ interface
                    (torddef(right.resultdef).ordtype=u32bit)) or
                    (torddef(right.resultdef).ordtype=u32bit)) or
                   is_hugepointer(left.resultdef);
                   is_hugepointer(left.resultdef);
 
 
+        { we have LOC_JUMP as result }
+        current_asmdata.getjumplabel(truelabel);
+        current_asmdata.getjumplabel(falselabel);
+        location_reset_jump(location,truelabel,falselabel);
+
         { left and right no register?  }
         { left and right no register?  }
         { then one must be demanded    }
         { then one must be demanded    }
         if (left.location.loc<>LOC_REGISTER) then
         if (left.location.loc<>LOC_REGISTER) then
@@ -866,7 +881,7 @@ interface
                  dec(href.offset,2);
                  dec(href.offset,2);
                  emit_ref_reg(A_CMP,S_W,href,left.location.register);
                  emit_ref_reg(A_CMP,S_W,href,left.location.register);
                  secondjmp32bitcmp;
                  secondjmp32bitcmp;
-                 cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                 cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
                  location_freetemp(current_asmdata.CurrAsmList,right.location);
                  location_freetemp(current_asmdata.CurrAsmList,right.location);
                end;
                end;
              LOC_CONSTANT :
              LOC_CONSTANT :
@@ -880,9 +895,6 @@ interface
                internalerror(200203282);
                internalerror(200203282);
            end;
            end;
          end;
          end;
-
-        { we have LOC_JUMP as result }
-        location_reset(location,LOC_JUMP,OS_NO)
       end;
       end;
 
 
 
 

+ 25 - 11
compiler/jvm/njvmadd.pas

@@ -56,7 +56,7 @@ interface
       cutils,verbose,constexp,globtype,
       cutils,verbose,constexp,globtype,
       symconst,symtable,symdef,symcpu,
       symconst,symtable,symdef,symcpu,
       paramgr,procinfo,pass_1,
       paramgr,procinfo,pass_1,
-      aasmtai,aasmdata,aasmcpu,defutil,
+      aasmbase,aasmtai,aasmdata,aasmcpu,defutil,
       hlcgobj,hlcgcpu,cgutils,
       hlcgobj,hlcgcpu,cgutils,
       cpupara,
       cpupara,
       nbas,ncon,nset,nadd,ncal,ncnv,ninl,nld,nmat,nmem,
       nbas,ncon,nset,nadd,ncal,ncnv,ninl,nld,nmat,nmem,
@@ -335,8 +335,12 @@ interface
 
 
     procedure tjvmaddnode.second_generic_compare(unsigned: boolean);
     procedure tjvmaddnode.second_generic_compare(unsigned: boolean);
       var
       var
+        truelabel,
+        falselabel: tasmlabel;
         cmpop: TOpCmp;
         cmpop: TOpCmp;
       begin
       begin
+        truelabel:=nil;
+        falselabel:=nil;
         pass_left_right;
         pass_left_right;
         { swap the operands to make it easier for the optimizer to optimize
         { swap the operands to make it easier for the optimizer to optimize
           the operand stack slot reloading in case both are in a register }
           the operand stack slot reloading in case both are in a register }
@@ -346,21 +350,24 @@ interface
         cmpop:=cmpnode2topcmp(unsigned);
         cmpop:=cmpnode2topcmp(unsigned);
         if (nf_swapped in flags) then
         if (nf_swapped in flags) then
           cmpop:=swap_opcmp(cmpop);
           cmpop:=swap_opcmp(cmpop);
-        location_reset(location,LOC_JUMP,OS_NO);
+
+        current_asmdata.getjumplabel(truelabel);
+        current_asmdata.getjumplabel(falselabel);
+        location_reset_jump(location,truelabel,falselabel);
 
 
         if left.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
         if left.location.loc in [LOC_REGISTER,LOC_CREGISTER] then
-          hlcg.a_cmp_loc_reg_label(current_asmdata.CurrAsmList,left.resultdef,cmpop,right.location,left.location.register,current_procinfo.CurrTrueLabel)
+          hlcg.a_cmp_loc_reg_label(current_asmdata.CurrAsmList,left.resultdef,cmpop,right.location,left.location.register,location.truelabel)
         else case right.location.loc of
         else case right.location.loc of
           LOC_REGISTER,LOC_CREGISTER:
           LOC_REGISTER,LOC_CREGISTER:
-            hlcg.a_cmp_reg_loc_label(current_asmdata.CurrAsmList,left.resultdef,cmpop,right.location.register,left.location,current_procinfo.CurrTrueLabel);
+            hlcg.a_cmp_reg_loc_label(current_asmdata.CurrAsmList,left.resultdef,cmpop,right.location.register,left.location,location.truelabel);
           LOC_REFERENCE,LOC_CREFERENCE:
           LOC_REFERENCE,LOC_CREFERENCE:
-            hlcg.a_cmp_ref_loc_label(current_asmdata.CurrAsmList,left.resultdef,cmpop,right.location.reference,left.location,current_procinfo.CurrTrueLabel);
+            hlcg.a_cmp_ref_loc_label(current_asmdata.CurrAsmList,left.resultdef,cmpop,right.location.reference,left.location,location.truelabel);
           LOC_CONSTANT:
           LOC_CONSTANT:
-            hlcg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,left.resultdef,cmpop,right.location.value,left.location,current_procinfo.CurrTrueLabel);
+            hlcg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,left.resultdef,cmpop,right.location.value,left.location,location.truelabel);
           else
           else
             internalerror(2011010413);
             internalerror(2011010413);
         end;
         end;
-        hlcg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+        hlcg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
       end;
       end;
 
 
     procedure tjvmaddnode.pass_left_right;
     procedure tjvmaddnode.pass_left_right;
@@ -441,9 +448,13 @@ interface
 
 
     procedure tjvmaddnode.second_cmpfloat;
     procedure tjvmaddnode.second_cmpfloat;
       var
       var
-        op : tasmop;
+        truelabel,
+        falselabel: tasmlabel;
+        op: tasmop;
         cmpop: TOpCmp;
         cmpop: TOpCmp;
       begin
       begin
+        truelabel:=nil;
+        falselabel:=nil;
         pass_left_right;
         pass_left_right;
         { swap the operands to make it easier for the optimizer to optimize
         { swap the operands to make it easier for the optimizer to optimize
           the operand stack slot reloading in case both are in a register }
           the operand stack slot reloading in case both are in a register }
@@ -453,7 +464,10 @@ interface
         cmpop:=cmpnode2topcmp(false);
         cmpop:=cmpnode2topcmp(false);
         if (nf_swapped in flags) then
         if (nf_swapped in flags) then
           cmpop:=swap_opcmp(cmpop);
           cmpop:=swap_opcmp(cmpop);
-        location_reset(location,LOC_JUMP,OS_NO);
+
+        current_asmdata.getjumplabel(truelabel);
+        current_asmdata.getjumplabel(falselabel);
+        location_reset_jump(location,truelabel,falselabel);
 
 
         thlcgjvm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,left.resultdef,left.location);
         thlcgjvm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,left.resultdef,left.location);
         thlcgjvm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,right.resultdef,right.location);
         thlcgjvm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,right.resultdef,right.location);
@@ -473,9 +487,9 @@ interface
         current_asmdata.CurrAsmList.concat(taicpu.op_none(op));
         current_asmdata.CurrAsmList.concat(taicpu.op_none(op));
         thlcgjvm(hlcg).decstack(current_asmdata.CurrAsmList,(1+ord(left.location.size=OS_F64))*2-1);
         thlcgjvm(hlcg).decstack(current_asmdata.CurrAsmList,(1+ord(left.location.size=OS_F64))*2-1);
 
 
-        current_asmdata.CurrAsmList.concat(taicpu.op_sym(opcmp2if[cmpop],current_procinfo.CurrTrueLabel));
+        current_asmdata.CurrAsmList.concat(taicpu.op_sym(opcmp2if[cmpop],location.truelabel));
         thlcgjvm(hlcg).decstack(current_asmdata.CurrAsmList,1);
         thlcgjvm(hlcg).decstack(current_asmdata.CurrAsmList,1);
-        hlcg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+        hlcg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
       end;
       end;
 
 
 
 

+ 3 - 19
compiler/jvm/njvmcnv.pas

@@ -704,12 +704,7 @@ implementation
     procedure tjvmtypeconvnode.second_bool_to_int;
     procedure tjvmtypeconvnode.second_bool_to_int;
       var
       var
          newsize: tcgsize;
          newsize: tcgsize;
-         oldTrueLabel,oldFalseLabel : tasmlabel;
       begin
       begin
-         oldTrueLabel:=current_procinfo.CurrTrueLabel;
-         oldFalseLabel:=current_procinfo.CurrFalseLabel;
-         current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-         current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
          secondpass(left);
          secondpass(left);
          location_copy(location,left.location);
          location_copy(location,left.location);
          newsize:=def_cgsize(resultdef);
          newsize:=def_cgsize(resultdef);
@@ -737,20 +732,14 @@ implementation
          else
          else
            { may differ in sign, e.g. bytebool -> byte   }
            { may differ in sign, e.g. bytebool -> byte   }
            location.size:=newsize;
            location.size:=newsize;
-         current_procinfo.CurrTrueLabel:=oldTrueLabel;
-         current_procinfo.CurrFalseLabel:=oldFalseLabel;
       end;
       end;
 
 
 
 
     procedure tjvmtypeconvnode.second_int_to_bool;
     procedure tjvmtypeconvnode.second_int_to_bool;
       var
       var
-        hlabel1,hlabel2,oldTrueLabel,oldFalseLabel : tasmlabel;
+        hlabel1,hlabel2: tasmlabel;
         newsize  : tcgsize;
         newsize  : tcgsize;
       begin
       begin
-        oldTrueLabel:=current_procinfo.CurrTrueLabel;
-        oldFalseLabel:=current_procinfo.CurrFalseLabel;
-        current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-        current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
         secondpass(left);
         secondpass(left);
         if codegenerror then
         if codegenerror then
           exit;
           exit;
@@ -770,8 +759,6 @@ implementation
                hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
                hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
              else
              else
                location.size:=newsize;
                location.size:=newsize;
-             current_procinfo.CurrTrueLabel:=oldTrueLabel;
-             current_procinfo.CurrFalseLabel:=oldFalseLabel;
              exit;
              exit;
           end;
           end;
 
 
@@ -786,8 +773,8 @@ implementation
            end;
            end;
          LOC_JUMP :
          LOC_JUMP :
            begin
            begin
-             hlabel1:=current_procinfo.CurrFalseLabel;
-             hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+             hlabel1:=left.location.falselabel;
+             hlcg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
            end;
            end;
          else
          else
            internalerror(10062);
            internalerror(10062);
@@ -805,9 +792,6 @@ implementation
        thlcgjvm(hlcg).a_load_const_stack(current_asmdata.CurrAsmList,resultdef,0,R_INTREGISTER);
        thlcgjvm(hlcg).a_load_const_stack(current_asmdata.CurrAsmList,resultdef,0,R_INTREGISTER);
        hlcg.a_label(current_asmdata.CurrAsmList,hlabel2);
        hlcg.a_label(current_asmdata.CurrAsmList,hlabel2);
        thlcgjvm(hlcg).a_load_stack_reg(current_asmdata.CurrAsmList,resultdef,location.register);
        thlcgjvm(hlcg).a_load_stack_reg(current_asmdata.CurrAsmList,resultdef,location.register);
-
-       current_procinfo.CurrTrueLabel:=oldTrueLabel;
-       current_procinfo.CurrFalseLabel:=oldFalseLabel;
      end;
      end;
 
 
 
 

+ 4 - 20
compiler/jvm/njvmmem.pas

@@ -405,13 +405,9 @@ implementation
 
 
     procedure tjvmvecnode.pass_generate_code;
     procedure tjvmvecnode.pass_generate_code;
       var
       var
-        otl,ofl: tasmlabel;
         psym: tsym;
         psym: tsym;
         newsize: tcgsize;
         newsize: tcgsize;
-        isjump: boolean;
       begin
       begin
-        otl:=nil;
-        ofl:=nil;
         if left.resultdef.typ=stringdef then
         if left.resultdef.typ=stringdef then
           internalerror(2011052702);
           internalerror(2011052702);
 
 
@@ -432,30 +428,18 @@ implementation
           and then asking for the size doesn't make any sense }
           and then asking for the size doesn't make any sense }
         hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,java_jlobject,java_jlobject,true);
         hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,java_jlobject,java_jlobject,true);
         location.reference.base:=left.location.register;
         location.reference.base:=left.location.register;
-        isjump:=(right.expectloc=LOC_JUMP);
-        if isjump then
-         begin
-           otl:=current_procinfo.CurrTrueLabel;
-           current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-           ofl:=current_procinfo.CurrFalseLabel;
-           current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-         end;
         secondpass(right);
         secondpass(right);
+        if (right.expectloc=LOC_JUMP)<>
+           (right.location.loc=LOC_JUMP) then
+          internalerror(2011090501);
 
 
         { simplify index location if necessary, since array references support
         { simplify index location if necessary, since array references support
           an index in memory, but not an another array index }
           an index in memory, but not an another array index }
-        if isjump or
+        if (right.location.loc=LOC_JUMP) or
            ((right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and
            ((right.location.loc in [LOC_REFERENCE,LOC_CREFERENCE]) and
             (right.location.reference.arrayreftype<>art_none)) then
             (right.location.reference.arrayreftype<>art_none)) then
           hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
           hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
 
 
-        if isjump then
-         begin
-           current_procinfo.CurrTrueLabel:=otl;
-           current_procinfo.CurrFalseLabel:=ofl;
-         end
-        else if (right.location.loc = LOC_JUMP) then
-          internalerror(2011090501);
         { replace enum class instance with the corresponding integer value }
         { replace enum class instance with the corresponding integer value }
         if (right.resultdef.typ=enumdef) then
         if (right.resultdef.typ=enumdef) then
           begin
           begin

+ 9 - 4
compiler/llvm/nllvmcnv.pas

@@ -169,6 +169,8 @@ procedure tllvmtypeconvnode.second_bool_to_int;
 
 
 procedure tllvmtypeconvnode.second_int_to_bool;
 procedure tllvmtypeconvnode.second_int_to_bool;
   var
   var
+    truelabel,
+    falselabel: tasmlabel;
     newsize  : tcgsize;
     newsize  : tcgsize;
   begin
   begin
     secondpass(left);
     secondpass(left);
@@ -191,17 +193,20 @@ procedure tllvmtypeconvnode.second_int_to_bool;
          exit;
          exit;
       end;
       end;
 
 
-    location_reset(location,LOC_JUMP,OS_NO);
     case left.location.loc of
     case left.location.loc of
       LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF,
       LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF,
       LOC_CREFERENCE,LOC_REFERENCE,LOC_REGISTER,LOC_CREGISTER:
       LOC_CREFERENCE,LOC_REFERENCE,LOC_REGISTER,LOC_CREGISTER:
         begin
         begin
-          hlcg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,left.resultdef,OC_EQ,0,left.location,current_procinfo.CurrFalseLabel);
-          hlcg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+          current_asmdata.getjumplabel(truelabel);
+          current_asmdata.getjumplabel(falselabel);
+          location_reset_jump(location,truelabel,falselabel);
+
+          hlcg.a_cmp_const_loc_label(current_asmdata.CurrAsmList,left.resultdef,OC_EQ,0,left.location,location.falselabel);
+          hlcg.a_jmp_always(current_asmdata.CurrAsmList,location.truelabel);
         end;
         end;
       LOC_JUMP :
       LOC_JUMP :
         begin
         begin
-          { nothing to do, jumps already go to the right labels }
+          location:=left.location;
         end;
         end;
       else
       else
         internalerror(10062);
         internalerror(10062);

+ 25 - 19
compiler/m68k/n68kadd.pas

@@ -375,6 +375,8 @@ implementation
 
 
     procedure t68kaddnode.second_cmp64bit;
     procedure t68kaddnode.second_cmp64bit;
       var
       var
+        truelabel,
+        falselabel: tasmlabel;
         hlab: tasmlabel;
         hlab: tasmlabel;
         unsigned : boolean;
         unsigned : boolean;
         href: treference;
         href: treference;
@@ -386,12 +388,12 @@ implementation
           case nodetype of
           case nodetype of
             ltn,gtn:
             ltn,gtn:
               begin
               begin
-                if (hlab<>current_procinfo.CurrTrueLabel) then
-                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
+                if (hlab<>location.truelabel) then
+                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.truelabel);
                 { cheat a little bit for the negative test }
                 { cheat a little bit for the negative test }
                 toggleflag(nf_swapped);
                 toggleflag(nf_swapped);
-                if (hlab<>current_procinfo.CurrFalseLabel) then
-                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
+                if (hlab<>location.falselabel) then
+                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.falselabel);
                 toggleflag(nf_swapped);
                 toggleflag(nf_swapped);
               end;
               end;
             lten,gten:
             lten,gten:
@@ -401,21 +403,21 @@ implementation
                   nodetype:=ltn
                   nodetype:=ltn
                 else
                 else
                   nodetype:=gtn;
                   nodetype:=gtn;
-                if (hlab<>current_procinfo.CurrTrueLabel) then
-                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
+                if (hlab<>location.truelabel) then
+                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.truelabel);
                 { cheat for the negative test }
                 { cheat for the negative test }
                 if nodetype=ltn then
                 if nodetype=ltn then
                   nodetype:=gtn
                   nodetype:=gtn
                 else
                 else
                   nodetype:=ltn;
                   nodetype:=ltn;
-                if (hlab<>current_procinfo.CurrFalseLabel) then
-                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
+                if (hlab<>location.falselabel) then
+                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),location.falselabel);
                 nodetype:=oldnodetype;
                 nodetype:=oldnodetype;
               end;
               end;
             equaln:
             equaln:
-              cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrFalseLabel);
+              cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.falselabel);
             unequaln:
             unequaln:
-              cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrTrueLabel);
+              cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.truelabel);
           end;
           end;
         end;
         end;
 
 
@@ -424,30 +426,34 @@ implementation
           case nodetype of
           case nodetype of
             ltn,gtn,lten,gten:
             ltn,gtn,lten,gten:
               begin
               begin
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
-                cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),location.truelabel);
+                cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
               end;
               end;
             equaln:
             equaln:
               begin
               begin
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrFalseLabel);
-                cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.falselabel);
+                cg.a_jmp_always(current_asmdata.CurrAsmList,location.truelabel);
               end;
               end;
             unequaln:
             unequaln:
               begin
               begin
-                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,current_procinfo.CurrTrueLabel);
-                cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,location.truelabel);
+                cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
               end;
               end;
           end;
           end;
         end;
         end;
 
 
       begin
       begin
+        truelabel:=nil;
+        falselabel:=nil;
         { This puts constant operand (if any) to the right }
         { This puts constant operand (if any) to the right }
         pass_left_right;
         pass_left_right;
 
 
         unsigned:=not(is_signed(left.resultdef)) or
         unsigned:=not(is_signed(left.resultdef)) or
                   not(is_signed(right.resultdef));
                   not(is_signed(right.resultdef));
 
 
-        location_reset(location,LOC_JUMP,OS_NO);
+        current_asmdata.getjumplabel(truelabel);
+        current_asmdata.getjumplabel(falselabel);
+        location_reset_jump(location,truelabel,falselabel);
 
 
         { Relational compares against constants having low dword=0 can omit the
         { Relational compares against constants having low dword=0 can omit the
           second compare based on the fact that any unsigned value is >=0 }
           second compare based on the fact that any unsigned value is >=0 }
@@ -456,8 +462,8 @@ implementation
            (lo(right.location.value64)=0) then
            (lo(right.location.value64)=0) then
           begin
           begin
             case getresflags(true) of
             case getresflags(true) of
-              F_AE: hlab:=current_procinfo.CurrTrueLabel;
-              F_B:  hlab:=current_procinfo.CurrFalseLabel;
+              F_AE: hlab:=location.truelabel;
+              F_B:  hlab:=location.falselabel;
             end;
             end;
           end;
           end;
 
 

+ 3 - 14
compiler/m68k/n68kcnv.pas

@@ -165,16 +165,9 @@ implementation
         resflags : tresflags;
         resflags : tresflags;
         opsize   : tcgsize;
         opsize   : tcgsize;
         newsize  : tcgsize;
         newsize  : tcgsize;
-        hlabel,
-        oldTrueLabel,
-        oldFalseLabel : tasmlabel;
+        hlabel   : tasmlabel;
         tmpreference : treference;
         tmpreference : treference;
       begin
       begin
-         oldTrueLabel:=current_procinfo.CurrTrueLabel;
-         oldFalseLabel:=current_procinfo.CurrFalseLabel;
-         current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-         current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-
          secondpass(left);
          secondpass(left);
 
 
          { Explicit typecasts from any ordinal type to a boolean type }
          { Explicit typecasts from any ordinal type to a boolean type }
@@ -190,8 +183,6 @@ implementation
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
               else
               else
                 location.size:=newsize;
                 location.size:=newsize;
-              current_procinfo.CurrTrueLabel:=oldTrueLabel;
-              current_procinfo.CurrFalseLabel:=oldFalseLabel;
               exit;
               exit;
            end;
            end;
 
 
@@ -266,13 +257,13 @@ implementation
                 location_reset(location,LOC_REGISTER,newsize);
                 location_reset(location,LOC_REGISTER,newsize);
                 location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
                 location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
                 current_asmdata.getjumplabel(hlabel);
                 current_asmdata.getjumplabel(hlabel);
-                cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                cg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
                 if not(is_cbool(resultdef)) then
                 if not(is_cbool(resultdef)) then
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,1,location.register)
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,1,location.register)
                 else
                 else
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,-1,location.register);
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,-1,location.register);
                 cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
                 cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
-                cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,0,location.register);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,0,location.register);
                 cg.a_label(current_asmdata.CurrAsmList,hlabel);
                 cg.a_label(current_asmdata.CurrAsmList,hlabel);
               end;
               end;
@@ -305,8 +296,6 @@ implementation
                   cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,newsize,location.register,location.register);
                   cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,newsize,location.register,location.register);
               end
               end
            end;
            end;
-         current_procinfo.CurrTrueLabel:=oldTrueLabel;
-         current_procinfo.CurrFalseLabel:=oldFalseLabel;
       end;
       end;
 
 
 
 

+ 20 - 15
compiler/mips/ncpuadd.pas

@@ -108,28 +108,33 @@ const
 
 
 procedure tmipsaddnode.cmp64_lt(left_reg, right_reg: TRegister64;unsigned: boolean);
 procedure tmipsaddnode.cmp64_lt(left_reg, right_reg: TRegister64;unsigned: boolean);
 begin
 begin
-  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,cmpops[unsigned],right_reg.reghi,left_reg.reghi,current_procinfo.CurrTrueLabel);
-  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reghi,right_reg.reghi,current_procinfo.CurrFalseLabel);
-  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_B,right_reg.reglo,left_reg.reglo,current_procinfo.CurrTrueLabel);
-  cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,cmpops[unsigned],right_reg.reghi,left_reg.reghi,location.truelabel);
+  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reghi,right_reg.reghi,location.falselabel);
+  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_B,right_reg.reglo,left_reg.reglo,location.truelabel);
+  cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
 end;
 end;
 
 
 
 
 procedure tmipsaddnode.cmp64_le(left_reg, right_reg: TRegister64;unsigned: boolean);
 procedure tmipsaddnode.cmp64_le(left_reg, right_reg: TRegister64;unsigned: boolean);
 begin
 begin
-  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,cmpops[unsigned],left_reg.reghi,right_reg.reghi,current_procinfo.CurrFalseLabel);
-  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reghi,right_reg.reghi,current_procinfo.CurrTrueLabel);
-  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_B,left_reg.reglo,right_reg.reglo,current_procinfo.CurrFalseLabel);
-  cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,cmpops[unsigned],left_reg.reghi,right_reg.reghi,location.falselabel);
+  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reghi,right_reg.reghi,location.truelabel);
+  cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_B,left_reg.reglo,right_reg.reglo,location.falselabel);
+  cg.a_jmp_always(current_asmdata.CurrAsmList,location.truelabel);
 end;
 end;
 
 
 
 
 procedure tmipsaddnode.second_cmp64bit;
 procedure tmipsaddnode.second_cmp64bit;
 var
 var
+  truelabel,
+  falselabel: tasmlabel;
   unsigned: boolean;
   unsigned: boolean;
   left_reg,right_reg: TRegister64;
   left_reg,right_reg: TRegister64;
 begin
 begin
-  location_reset(location, LOC_JUMP, OS_NO);
+  current_asmdata.getjumplabel(truelabel);
+  current_asmdata.getjumplabel(falselabel);
+  location_reset_jump(location,truelabel,falselabel);
+
   pass_left_right;
   pass_left_right;
   force_reg_left_right(true,true);
   force_reg_left_right(true,true);
 
 
@@ -160,15 +165,15 @@ begin
   case NodeType of
   case NodeType of
     equaln:
     equaln:
       begin
       begin
-        cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reghi,right_reg.reghi,current_procinfo.CurrFalseLabel);
-        cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reglo,right_reg.reglo,current_procinfo.CurrFalseLabel);
-        cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+        cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reghi,right_reg.reghi,location.falselabel);
+        cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reglo,right_reg.reglo,location.falselabel);
+        cg.a_jmp_always(current_asmdata.CurrAsmList,location.truelabel);
       end;
       end;
     unequaln:
     unequaln:
       begin
       begin
-        cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reghi,right_reg.reghi,current_procinfo.CurrTrueLabel);
-        cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reglo,right_reg.reglo,current_procinfo.CurrTrueLabel);
-        cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+        cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reghi,right_reg.reghi,location.truelabel);
+        cg.a_cmp_reg_reg_label(current_asmdata.CurrAsmList,OS_INT,OC_NE,left_reg.reglo,right_reg.reglo,location.truelabel);
+        cg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
       end;
       end;
   else
   else
     if nf_swapped in flags then
     if nf_swapped in flags then

+ 3 - 13
compiler/mips/ncpucnv.pas

@@ -195,14 +195,10 @@ procedure tMIPSELtypeconvnode.second_int_to_bool;
 var
 var
   hreg1, hreg2: tregister;
   hreg1, hreg2: tregister;
   opsize: tcgsize;
   opsize: tcgsize;
-  hlabel, oldtruelabel, oldfalselabel: tasmlabel;
+  hlabel: tasmlabel;
   newsize  : tcgsize;
   newsize  : tcgsize;
   href: treference;
   href: treference;
 begin
 begin
-  oldtruelabel  := current_procinfo.CurrTrueLabel;
-  oldfalselabel := current_procinfo.CurrFalseLabel;
-  current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-  current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
   secondpass(left);
   secondpass(left);
   if codegenerror then
   if codegenerror then
     exit;
     exit;
@@ -220,8 +216,6 @@ begin
          hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
          hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
        else
        else
          location.size:=newsize;
          location.size:=newsize;
-       current_procinfo.CurrTrueLabel:=oldTrueLabel;
-       current_procinfo.CurrFalseLabel:=oldFalseLabel;
        exit;
        exit;
     end;
     end;
 
 
@@ -271,10 +265,10 @@ begin
     begin
     begin
       hreg1 := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
       hreg1 := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
       current_asmdata.getjumplabel(hlabel);
       current_asmdata.getjumplabel(hlabel);
-      cg.a_label(current_asmdata.CurrAsmList, current_procinfo.CurrTrueLabel);
+      cg.a_label(current_asmdata.CurrAsmList, left.location.truelabel);
       cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, 1, hreg1);
       cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, 1, hreg1);
       cg.a_jmp_always(current_asmdata.CurrAsmList, hlabel);
       cg.a_jmp_always(current_asmdata.CurrAsmList, hlabel);
-      cg.a_label(current_asmdata.CurrAsmList, current_procinfo.CurrFalseLabel);
+      cg.a_label(current_asmdata.CurrAsmList, left.location.falselabel);
       cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, 0, hreg1);
       cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, 0, hreg1);
       cg.a_label(current_asmdata.CurrAsmList, hlabel);
       cg.a_label(current_asmdata.CurrAsmList, hlabel);
     end;
     end;
@@ -305,10 +299,6 @@ begin
        else
        else
 {$endif not cpu64bitalu}
 {$endif not cpu64bitalu}
          location.Register := hreg1;
          location.Register := hreg1;
-
-
-  current_procinfo.CurrTrueLabel  := oldtruelabel;
-  current_procinfo.CurrFalseLabel := oldfalselabel;
 end;
 end;
 
 
 
 

+ 11 - 47
compiler/ncgadd.pas

@@ -89,14 +89,9 @@ interface
       var
       var
         tmpreg     : tregister;
         tmpreg     : tregister;
 {$ifdef x86}
 {$ifdef x86}
-        pushedfpu,
+        pushedfpu  : boolean;
 {$endif x86}
 {$endif x86}
-        isjump     : boolean;
-        otl,ofl    : tasmlabel;
       begin
       begin
-        otl:=nil;
-        ofl:=nil;
-
         { calculate the operator which is more difficult }
         { calculate the operator which is more difficult }
         firstcomplex(self);
         firstcomplex(self);
 
 
@@ -104,26 +99,9 @@ interface
         if (left.nodetype=ordconstn) then
         if (left.nodetype=ordconstn) then
           swapleftright;
           swapleftright;
 
 
-        isjump:=(left.expectloc=LOC_JUMP);
-        if isjump then
-          begin
-             otl:=current_procinfo.CurrTrueLabel;
-             current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-             ofl:=current_procinfo.CurrFalseLabel;
-             current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-          end;
         secondpass(left);
         secondpass(left);
         if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
         if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
           hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,false);
           hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,false);
-        if isjump then
-          begin
-            current_procinfo.CurrTrueLabel:=otl;
-            current_procinfo.CurrFalseLabel:=ofl;
-          end
-        else
-          if left.location.loc=LOC_JUMP then
-            internalerror(2012081302);
-
 {$ifdef x86}
 {$ifdef x86}
         { are too few registers free? }
         { are too few registers free? }
         pushedfpu:=false;
         pushedfpu:=false;
@@ -135,22 +113,9 @@ interface
           end;
           end;
 {$endif x86}
 {$endif x86}
 
 
-        isjump:=(right.expectloc=LOC_JUMP);
-        if isjump then
-          begin
-             otl:=current_procinfo.CurrTrueLabel;
-             current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-             ofl:=current_procinfo.CurrFalseLabel;
-             current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-          end;
         secondpass(right);
         secondpass(right);
         if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
         if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
           hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,resultdef,false);
           hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,resultdef,false);
-        if isjump then
-          begin
-            current_procinfo.CurrTrueLabel:=otl;
-            current_procinfo.CurrFalseLabel:=ofl;
-          end;
 {$ifdef x86}
 {$ifdef x86}
         if pushedfpu then
         if pushedfpu then
           begin
           begin
@@ -414,7 +379,7 @@ interface
     procedure tcgaddnode.second_addboolean;
     procedure tcgaddnode.second_addboolean;
       var
       var
         cgop    : TOpCg;
         cgop    : TOpCg;
-        otl,ofl : tasmlabel;
+        truelabel, falselabel : tasmlabel;
         oldflowcontrol : tflowcontrol;
         oldflowcontrol : tflowcontrol;
       begin
       begin
         { And,Or will only evaluate from left to right only the
         { And,Or will only evaluate from left to right only the
@@ -423,25 +388,22 @@ interface
            (not(cs_full_boolean_eval in current_settings.localswitches) or
            (not(cs_full_boolean_eval in current_settings.localswitches) or
             (nf_short_bool in flags)) then
             (nf_short_bool in flags)) then
           begin
           begin
-            location_reset(location,LOC_JUMP,OS_NO);
             case nodetype of
             case nodetype of
               andn :
               andn :
                 begin
                 begin
-                   otl:=current_procinfo.CurrTrueLabel;
-                   current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
                    secondpass(left);
                    secondpass(left);
                    hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
                    hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
-                   hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
-                   current_procinfo.CurrTrueLabel:=otl;
+                   hlcg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
+                   current_asmdata.getjumplabel(truelabel);
+                   location_reset_jump(location,truelabel,left.location.falselabel);
                 end;
                 end;
               orn :
               orn :
                 begin
                 begin
-                   ofl:=current_procinfo.CurrFalseLabel;
-                   current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
                    secondpass(left);
                    secondpass(left);
                    hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
                    hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
-                   hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
-                   current_procinfo.CurrFalseLabel:=ofl;
+                   hlcg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
+                   current_asmdata.getjumplabel(falselabel);
+                   location_reset_jump(location,left.location.truelabel,falselabel);
                 end;
                 end;
               else
               else
                 internalerror(200307044);
                 internalerror(200307044);
@@ -451,7 +413,9 @@ interface
             include(flowcontrol,fc_inflowcontrol);
             include(flowcontrol,fc_inflowcontrol);
 
 
             secondpass(right);
             secondpass(right);
-            hlcg.maketojumpbool(current_asmdata.CurrAsmList,right);
+            { jump to the same labels as the left side, since the andn/orn
+              merges the results of left and right }
+            hlcg.maketojumpboollabels(current_asmdata.CurrAsmList,right,location.truelabel,location.falselabel);
 
 
             flowcontrol:=oldflowcontrol+(flowcontrol-[fc_inflowcontrol]);
             flowcontrol:=oldflowcontrol+(flowcontrol-[fc_inflowcontrol]);
           end
           end

+ 0 - 8
compiler/ncgcal.pas

@@ -262,8 +262,6 @@ implementation
     procedure tcgcallparanode.secondcallparan;
     procedure tcgcallparanode.secondcallparan;
       var
       var
          href    : treference;
          href    : treference;
-         otlabel,
-         oflabel : tasmlabel;
          pushaddr: boolean;
          pushaddr: boolean;
       begin
       begin
          if not(assigned(parasym)) then
          if not(assigned(parasym)) then
@@ -273,10 +271,6 @@ implementation
            a parameter }
            a parameter }
          if (left.nodetype<>nothingn) then
          if (left.nodetype<>nothingn) then
            begin
            begin
-             otlabel:=current_procinfo.CurrTrueLabel;
-             oflabel:=current_procinfo.CurrFalseLabel;
-             current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-             current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
              if assigned(fparainit) then
              if assigned(fparainit) then
                secondpass(fparainit);
                secondpass(fparainit);
              secondpass(left);
              secondpass(left);
@@ -373,8 +367,6 @@ implementation
                  else
                  else
                    push_value_para;
                    push_value_para;
                end;
                end;
-             current_procinfo.CurrTrueLabel:=otlabel;
-             current_procinfo.CurrFalseLabel:=oflabel;
 
 
              { update return location in callnode when this is the function
              { update return location in callnode when this is the function
                result }
                result }

+ 3 - 18
compiler/ncgcnv.pas

@@ -160,13 +160,9 @@ interface
         hregister : tregister;
         hregister : tregister;
         href      : treference;
         href      : treference;
         resflags  : tresflags;
         resflags  : tresflags;
-        hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+        hlabel    : tasmlabel;
         newsize   : tcgsize;
         newsize   : tcgsize;
       begin
       begin
-        oldTrueLabel:=current_procinfo.CurrTrueLabel;
-        oldFalseLabel:=current_procinfo.CurrFalseLabel;
-        current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-        current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
         secondpass(left);
         secondpass(left);
         if codegenerror then
         if codegenerror then
          exit;
          exit;
@@ -189,8 +185,6 @@ interface
                hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
                hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
              else
              else
                location.size:=newsize;
                location.size:=newsize;
-             current_procinfo.CurrTrueLabel:=oldTrueLabel;
-             current_procinfo.CurrFalseLabel:=oldFalseLabel;
              exit;
              exit;
           end;
           end;
         { though ppc/ppc64 doesn't use the generic code, we need to ifdef here
         { though ppc/ppc64 doesn't use the generic code, we need to ifdef here
@@ -247,10 +241,10 @@ interface
             begin
             begin
               hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
               hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
               current_asmdata.getjumplabel(hlabel);
               current_asmdata.getjumplabel(hlabel);
-              cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+              cg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
               cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hregister);
               cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hregister);
               cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
               cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
-              cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+              cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
               cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hregister);
               cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hregister);
               cg.a_label(current_asmdata.CurrAsmList,hlabel);
               cg.a_label(current_asmdata.CurrAsmList,hlabel);
               cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_INT,hregister,hregister);
               cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_INT,hregister,hregister);
@@ -265,8 +259,6 @@ interface
         cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
         cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
         if (is_cbool(resultdef)) then
         if (is_cbool(resultdef)) then
           cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,location.register,location.register);
           cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,location.register,location.register);
-        current_procinfo.CurrTrueLabel:=oldTrueLabel;
-        current_procinfo.CurrFalseLabel:=oldFalseLabel;
       end;
       end;
 {$endif cpuflags}
 {$endif cpuflags}
 
 
@@ -609,12 +601,7 @@ interface
     procedure tcgtypeconvnode.second_bool_to_int;
     procedure tcgtypeconvnode.second_bool_to_int;
       var
       var
          newsize: tcgsize;
          newsize: tcgsize;
-         oldTrueLabel,oldFalseLabel : tasmlabel;
       begin
       begin
-         oldTrueLabel:=current_procinfo.CurrTrueLabel;
-         oldFalseLabel:=current_procinfo.CurrFalseLabel;
-         current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-         current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
          secondpass(left);
          secondpass(left);
          location_copy(location,left.location);
          location_copy(location,left.location);
          newsize:=def_cgsize(resultdef);
          newsize:=def_cgsize(resultdef);
@@ -637,8 +624,6 @@ interface
          else
          else
            { may differ in sign, e.g. bytebool -> byte   }
            { may differ in sign, e.g. bytebool -> byte   }
            location.size:=newsize;
            location.size:=newsize;
-         current_procinfo.CurrTrueLabel:=oldTrueLabel;
-         current_procinfo.CurrFalseLabel:=oldFalseLabel;
       end;
       end;
 
 
 
 

+ 16 - 57
compiler/ncgflw.pas

@@ -134,7 +134,7 @@ implementation
       var
       var
          lcont,lbreak,lloop,
          lcont,lbreak,lloop,
          oldclabel,oldblabel : tasmlabel;
          oldclabel,oldblabel : tasmlabel;
-         otlabel,oflabel : tasmlabel;
+         truelabel,falselabel : tasmlabel;
          oldflowcontrol : tflowcontrol;
          oldflowcontrol : tflowcontrol;
          oldexecutionweight : longint;
          oldexecutionweight : longint;
       begin
       begin
@@ -181,28 +181,23 @@ implementation
 {$endif OLDREGVARS}
 {$endif OLDREGVARS}
 
 
          hlcg.a_label(current_asmdata.CurrAsmList,lcont);
          hlcg.a_label(current_asmdata.CurrAsmList,lcont);
-         otlabel:=current_procinfo.CurrTrueLabel;
-         oflabel:=current_procinfo.CurrFalseLabel;
          if lnf_checknegate in loopflags then
          if lnf_checknegate in loopflags then
-          begin
-            current_procinfo.CurrTrueLabel:=lbreak;
-            current_procinfo.CurrFalseLabel:=lloop;
-          end
+           begin
+             truelabel:=lbreak;
+             falselabel:=lloop;
+           end
          else
          else
-          begin
-            current_procinfo.CurrTrueLabel:=lloop;
-            current_procinfo.CurrFalseLabel:=lbreak;
-          end;
+           begin
+             truelabel:=lloop;
+             falselabel:=lbreak;
+           end;
          secondpass(left);
          secondpass(left);
 
 
-         hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
+         hlcg.maketojumpboollabels(current_asmdata.CurrAsmList,left,truelabel,falselabel);
          hlcg.a_label(current_asmdata.CurrAsmList,lbreak);
          hlcg.a_label(current_asmdata.CurrAsmList,lbreak);
 
 
          sync_regvars(false);
          sync_regvars(false);
 
 
-         current_procinfo.CurrTrueLabel:=otlabel;
-         current_procinfo.CurrFalseLabel:=oflabel;
-
          current_procinfo.CurrContinueLabel:=oldclabel;
          current_procinfo.CurrContinueLabel:=oldclabel;
          current_procinfo.CurrBreakLabel:=oldblabel;
          current_procinfo.CurrBreakLabel:=oldblabel;
          { a break/continue in a while/repeat block can't be seen outside }
          { a break/continue in a while/repeat block can't be seen outside }
@@ -217,7 +212,7 @@ implementation
     procedure tcgifnode.pass_generate_code;
     procedure tcgifnode.pass_generate_code;
 
 
       var
       var
-         hl,otlabel,oflabel : tasmlabel;
+         hl : tasmlabel;
          oldflowcontrol: tflowcontrol;
          oldflowcontrol: tflowcontrol;
          oldexecutionweight : longint;
          oldexecutionweight : longint;
 (*
 (*
@@ -238,10 +233,6 @@ implementation
 
 
          oldflowcontrol := flowcontrol;
          oldflowcontrol := flowcontrol;
          include(flowcontrol,fc_inflowcontrol);
          include(flowcontrol,fc_inflowcontrol);
-         otlabel:=current_procinfo.CurrTrueLabel;
-         oflabel:=current_procinfo.CurrFalseLabel;
-         current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-         current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
          secondpass(left);
          secondpass(left);
 
 
 (*
 (*
@@ -270,7 +261,7 @@ implementation
 
 
          if assigned(right) then
          if assigned(right) then
            begin
            begin
-              hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+              hlcg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
               secondpass(right);
               secondpass(right);
            end;
            end;
 
 
@@ -305,7 +296,7 @@ implementation
                    ;
                    ;
                    hlcg.a_jmp_always(current_asmdata.CurrAsmList,hl);
                    hlcg.a_jmp_always(current_asmdata.CurrAsmList,hl);
                 end;
                 end;
-              hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+              hlcg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
               secondpass(t1);
               secondpass(t1);
 (*
 (*
               { save current asmlist (previous instructions + else-block) }
               { save current asmlist (previous instructions + else-block) }
@@ -332,11 +323,11 @@ implementation
                   current_asmdata.CurrAsmList := TAsmList.create;
                   current_asmdata.CurrAsmList := TAsmList.create;
                 end;
                 end;
 *)
 *)
-              hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+              hlcg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
            end;
            end;
          if not(assigned(right)) then
          if not(assigned(right)) then
            begin
            begin
-              hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+              hlcg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
            end;
            end;
 
 
 (*
 (*
@@ -376,8 +367,6 @@ implementation
 
 
          cg.executionweight:=oldexecutionweight;
          cg.executionweight:=oldexecutionweight;
 
 
-         current_procinfo.CurrTrueLabel:=otlabel;
-         current_procinfo.CurrFalseLabel:=oflabel;
          flowcontrol := oldflowcontrol + (flowcontrol - [fc_inflowcontrol]);
          flowcontrol := oldflowcontrol + (flowcontrol - [fc_inflowcontrol]);
       end;
       end;
 
 
@@ -423,8 +412,7 @@ implementation
 
 
     procedure tcgfornode.pass_generate_code;
     procedure tcgfornode.pass_generate_code;
       var
       var
-         l3,oldclabel,oldblabel,
-         otl, ofl : tasmlabel;
+         l3,oldclabel,oldblabel : tasmlabel;
          temptovalue : boolean;
          temptovalue : boolean;
          hop : topcg;
          hop : topcg;
          hcond : topcmp;
          hcond : topcmp;
@@ -433,11 +421,8 @@ implementation
          cmp_const:Tconstexprint;
          cmp_const:Tconstexprint;
          oldflowcontrol : tflowcontrol;
          oldflowcontrol : tflowcontrol;
          oldexecutionweight : longint;
          oldexecutionweight : longint;
-         isjump: boolean;
       begin
       begin
          location_reset(location,LOC_VOID,OS_NO);
          location_reset(location,LOC_VOID,OS_NO);
-         ofl:=nil;
-         otl:=nil;
 
 
          oldclabel:=current_procinfo.CurrContinueLabel;
          oldclabel:=current_procinfo.CurrContinueLabel;
          oldblabel:=current_procinfo.CurrBreakLabel;
          oldblabel:=current_procinfo.CurrBreakLabel;
@@ -458,22 +443,9 @@ implementation
          }
          }
            and not(assigned(entrylabel));
            and not(assigned(entrylabel));
 
 
-        isjump:=(t1.expectloc=LOC_JUMP);
-        if isjump then
-          begin
-             otl:=current_procinfo.CurrTrueLabel;
-             current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-             ofl:=current_procinfo.CurrFalseLabel;
-             current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-          end;
         secondpass(t1);
         secondpass(t1);
         if t1.location.loc in [LOC_FLAGS,LOC_JUMP] then
         if t1.location.loc in [LOC_FLAGS,LOC_JUMP] then
           hlcg.location_force_reg(current_asmdata.CurrAsmList,t1.location,t1.resultdef,t1.resultdef,false);
           hlcg.location_force_reg(current_asmdata.CurrAsmList,t1.location,t1.resultdef,t1.resultdef,false);
-        if isjump then
-          begin
-            current_procinfo.CurrTrueLabel:=otl;
-            current_procinfo.CurrFalseLabel:=ofl;
-          end;
          { calculate pointer value and check if changeable and if so }
          { calculate pointer value and check if changeable and if so }
          { load into temporary variable                       }
          { load into temporary variable                       }
          if t1.nodetype<>ordconstn then
          if t1.nodetype<>ordconstn then
@@ -491,22 +463,9 @@ implementation
          cg.executionweight:=oldexecutionweight;
          cg.executionweight:=oldexecutionweight;
 
 
          { load from value }
          { load from value }
-         isjump:=(right.expectloc=LOC_JUMP);
-         if isjump then
-           begin
-              otl:=current_procinfo.CurrTrueLabel;
-              current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-              ofl:=current_procinfo.CurrFalseLabel;
-              current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-           end;
          secondpass(right);
          secondpass(right);
          if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
          if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
            hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,false);
            hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,false);
-         if isjump then
-           begin
-             current_procinfo.CurrTrueLabel:=otl;
-             current_procinfo.CurrFalseLabel:=ofl;
-           end;
 
 
          hlcg.maybe_change_load_node_reg(current_asmdata.CurrAsmList,left,false);
          hlcg.maybe_change_load_node_reg(current_asmdata.CurrAsmList,left,false);
          oldflowcontrol:=flowcontrol;
          oldflowcontrol:=flowcontrol;

+ 3 - 10
compiler/ncghlmat.pas

@@ -43,7 +43,7 @@ uses
   aasmbase,aasmdata,
   aasmbase,aasmdata,
   defutil,
   defutil,
   procinfo,
   procinfo,
-  cgbase,pass_2,hlcgobj;
+  cgbase,cgutils,pass_2,hlcgobj;
 
 
 {*****************************************************************************
 {*****************************************************************************
                                tcghlnotnode
                                tcghlnotnode
@@ -59,18 +59,11 @@ function tcghlnotnode.pass_1: tnode;
 
 
 
 
 procedure tcghlnotnode.second_boolean;
 procedure tcghlnotnode.second_boolean;
-  var
-    hl : tasmlabel;
   begin
   begin
-    hl:=current_procinfo.CurrTrueLabel;
-    current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
-    current_procinfo.CurrFalseLabel:=hl;
     secondpass(left);
     secondpass(left);
     hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
     hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
-    hl:=current_procinfo.CurrTrueLabel;
-    current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
-    current_procinfo.CurrFalseLabel:=hl;
-    location.loc:=LOC_JUMP;
+    { switch true and false labels to invert result }
+    location_reset_jump(location,left.location.falselabel,left.location.truelabel);
   end;
   end;
 
 
 end.
 end.

+ 6 - 30
compiler/ncgld.pas

@@ -584,7 +584,7 @@ implementation
 
 
     procedure tcgassignmentnode.pass_generate_code;
     procedure tcgassignmentnode.pass_generate_code;
       var
       var
-         otlabel,hlabel,oflabel : tasmlabel;
+         hlabel : tasmlabel;
          href : treference;
          href : treference;
          releaseright : boolean;
          releaseright : boolean;
          alignmentrequirement,
          alignmentrequirement,
@@ -601,11 +601,6 @@ implementation
 
 
         location_reset(location,LOC_VOID,OS_NO);
         location_reset(location,LOC_VOID,OS_NO);
 
 
-        otlabel:=current_procinfo.CurrTrueLabel;
-        oflabel:=current_procinfo.CurrFalseLabel;
-        current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-        current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-
         {
         {
           in most cases we can process first the right node which contains
           in most cases we can process first the right node which contains
           the most complex code. Exceptions for this are:
           the most complex code. Exceptions for this are:
@@ -962,7 +957,7 @@ implementation
               LOC_JUMP :
               LOC_JUMP :
                 begin
                 begin
                   current_asmdata.getjumplabel(hlabel);
                   current_asmdata.getjumplabel(hlabel);
-                  hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                  hlcg.a_label(current_asmdata.CurrAsmList,right.location.truelabel);
                   if is_pasbool(left.resultdef) then
                   if is_pasbool(left.resultdef) then
                     begin
                     begin
 {$ifndef cpu64bitalu}
 {$ifndef cpu64bitalu}
@@ -983,7 +978,7 @@ implementation
                     end;
                     end;
 
 
                   hlcg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
                   hlcg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
-                  hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                  hlcg.a_label(current_asmdata.CurrAsmList,right.location.falselabel);
 {$ifndef cpu64bitalu}
 {$ifndef cpu64bitalu}
                   if left.location.size in [OS_64,OS_S64] then
                   if left.location.size in [OS_64,OS_S64] then
                     cg64.a_load64_const_loc(current_asmdata.CurrAsmList,0,left.location)
                     cg64.a_load64_const_loc(current_asmdata.CurrAsmList,0,left.location)
@@ -1073,9 +1068,6 @@ implementation
 
 
         if releaseright then
         if releaseright then
           location_freetemp(current_asmdata.CurrAsmList,right.location);
           location_freetemp(current_asmdata.CurrAsmList,right.location);
-
-        current_procinfo.CurrTrueLabel:=otlabel;
-        current_procinfo.CurrFalseLabel:=oflabel;
       end;
       end;
 
 
 
 
@@ -1125,8 +1117,6 @@ implementation
         href  : treference;
         href  : treference;
         lt    : tdef;
         lt    : tdef;
         paraloc : tcgparalocation;
         paraloc : tcgparalocation;
-        otlabel,
-        oflabel : tasmlabel;
         vtype : longint;
         vtype : longint;
         eledef: tdef;
         eledef: tdef;
         elesize : longint;
         elesize : longint;
@@ -1135,8 +1125,6 @@ implementation
         freetemp,
         freetemp,
         dovariant: boolean;
         dovariant: boolean;
       begin
       begin
-        otlabel:=nil;
-        oflabel:=nil;
         if is_packed_array(resultdef) then
         if is_packed_array(resultdef) then
           internalerror(200608042);
           internalerror(200608042);
         dovariant:=
         dovariant:=
@@ -1175,26 +1163,14 @@ implementation
            if assigned(hp.left) then
            if assigned(hp.left) then
             begin
             begin
               freetemp:=true;
               freetemp:=true;
-              if (hp.left.expectloc=LOC_JUMP) then
-                begin
-                  otlabel:=current_procinfo.CurrTrueLabel;
-                  oflabel:=current_procinfo.CurrFalseLabel;
-                  current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-                  current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-                end;
               secondpass(hp.left);
               secondpass(hp.left);
+              if (hp.left.location.loc=LOC_JUMP)<>
+                 (hp.left.expectloc=LOC_JUMP) then
+                internalerror(2007103101);
               { Move flags and jump in register }
               { Move flags and jump in register }
               if hp.left.location.loc in [LOC_FLAGS,LOC_JUMP] then
               if hp.left.location.loc in [LOC_FLAGS,LOC_JUMP] then
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,hp.left.location,hp.left.resultdef,hp.left.resultdef,false);
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,hp.left.location,hp.left.resultdef,hp.left.resultdef,false);
 
 
-              if (hp.left.location.loc=LOC_JUMP) then
-                begin
-                  if (hp.left.expectloc<>LOC_JUMP) then
-                    internalerror(2007103101);
-                  current_procinfo.CurrTrueLabel:=otlabel;
-                  current_procinfo.CurrFalseLabel:=oflabel;
-                end;
-
               if dovariant then
               if dovariant then
                begin
                begin
                  { find the correct vtype value }
                  { find the correct vtype value }

+ 2 - 11
compiler/ncgmat.pas

@@ -609,15 +609,10 @@ implementation
 
 
 
 
     function tcgnotnode.handle_locjump: boolean;
     function tcgnotnode.handle_locjump: boolean;
-      var
-        hl: tasmlabel;
       begin
       begin
         result:=(left.expectloc=LOC_JUMP);
         result:=(left.expectloc=LOC_JUMP);
         if result then
         if result then
           begin
           begin
-            hl:=current_procinfo.CurrTrueLabel;
-            current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
-            current_procinfo.CurrFalseLabel:=hl;
             secondpass(left);
             secondpass(left);
 
 
             if is_constboolnode(left) then
             if is_constboolnode(left) then
@@ -625,12 +620,8 @@ implementation
             if left.location.loc<>LOC_JUMP then
             if left.location.loc<>LOC_JUMP then
               internalerror(2012081306);
               internalerror(2012081306);
 
 
-            { This does nothing for LOC_JUMP }
-            //maketojumpbool(current_asmdata.CurrAsmList,left,lr_load_regvars);
-            hl:=current_procinfo.CurrTrueLabel;
-            current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
-            current_procinfo.CurrFalseLabel:=hl;
-            location_reset(location,LOC_JUMP,OS_NO);
+            { switch true and false labels to invert result }
+            location_reset_jump(location,left.location.falselabel,left.location.truelabel);
           end;
           end;
       end;
       end;
 
 

+ 3 - 20
compiler/ncgmem.pas

@@ -872,12 +872,10 @@ implementation
          offsetdec,
          offsetdec,
          extraoffset : aint;
          extraoffset : aint;
          rightp      : pnode;
          rightp      : pnode;
-         otl,ofl  : tasmlabel;
          newsize  : tcgsize;
          newsize  : tcgsize;
          mulsize,
          mulsize,
          bytemulsize,
          bytemulsize,
          alignpow : aint;
          alignpow : aint;
-         isjump   : boolean;
          paraloc1,
          paraloc1,
          paraloc2 : tcgpara;
          paraloc2 : tcgpara;
          subsetref : tsubsetreference;
          subsetref : tsubsetreference;
@@ -1083,17 +1081,10 @@ implementation
               { calculate from left to right }
               { calculate from left to right }
               if not(location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
               if not(location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
                 internalerror(200304237);
                 internalerror(200304237);
-              isjump:=(right.expectloc=LOC_JUMP);
-              otl:=nil;
-              ofl:=nil;
-              if isjump then
-               begin
-                 otl:=current_procinfo.CurrTrueLabel;
-                 current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-                 ofl:=current_procinfo.CurrFalseLabel;
-                 current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-               end;
               secondpass(right);
               secondpass(right);
+              if (right.expectloc=LOC_JUMP)<>
+                 (right.location.loc=LOC_JUMP) then
+                internalerror(2006010801);
 
 
               { if mulsize = 1, we won't have to modify the index }
               { if mulsize = 1, we won't have to modify the index }
               if not(right.location.loc in [LOC_CREGISTER,LOC_REGISTER]) or
               if not(right.location.loc in [LOC_CREGISTER,LOC_REGISTER]) or
@@ -1105,14 +1096,6 @@ implementation
               else
               else
                 indexdef:=right.resultdef;
                 indexdef:=right.resultdef;
 
 
-              if isjump then
-               begin
-                 current_procinfo.CurrTrueLabel:=otl;
-                 current_procinfo.CurrFalseLabel:=ofl;
-               end
-              else if (right.location.loc = LOC_JUMP) then
-                internalerror(2006010801);
-
             { produce possible range check code: }
             { produce possible range check code: }
               if cs_check_range in current_settings.localswitches then
               if cs_check_range in current_settings.localswitches then
                begin
                begin

+ 15 - 54
compiler/ncgset.pas

@@ -241,7 +241,6 @@ implementation
          adjustment,
          adjustment,
          setbase    : aint;
          setbase    : aint;
          l, l2      : tasmlabel;
          l, l2      : tasmlabel;
-         otl, ofl   : tasmlabel;
          hr,
          hr,
          pleftreg   : tregister;
          pleftreg   : tregister;
          setparts   : Tsetparts;
          setparts   : Tsetparts;
@@ -252,14 +251,11 @@ implementation
          orgopsize  : tcgsize;
          orgopsize  : tcgsize;
          orgopdef   : tdef;
          orgopdef   : tdef;
          genjumps,
          genjumps,
-         use_small,
-         isjump     : boolean;
+         use_small  : boolean;
          i,numparts : byte;
          i,numparts : byte;
          needslabel : Boolean;
          needslabel : Boolean;
        begin
        begin
          l2:=nil;
          l2:=nil;
-         ofl:=nil;
-         otl:=nil;
 
 
          { We check first if we can generate jumps, this can be done
          { We check first if we can generate jumps, this can be done
            because the resultdef is already set in firstpass }
            because the resultdef is already set in firstpass }
@@ -282,35 +278,17 @@ implementation
            end;
            end;
          needslabel := false;
          needslabel := false;
 
 
-         isjump:=false;
-         if (left.expectloc=LOC_JUMP) then
-           begin
-             otl:=current_procinfo.CurrTrueLabel;
-             current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-             ofl:=current_procinfo.CurrFalseLabel;
-             current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-             isjump:=true;
-           end
-         else if not genjumps then
+         if not genjumps then
            { calculate both operators }
            { calculate both operators }
            { the complex one first }
            { the complex one first }
-           { only if left will not be a LOC_JUMP, to keep complexity in the }
-           { code generator down. This almost never happens anyway, only in }
-           { case like "if ((a in someset) in someboolset) then" etc        }
-           { also not in case of genjumps, because then we don't secondpass }
+           { not in case of genjumps, because then we don't secondpass      }
            { right at all (so we have to make sure that "right" really is   }
            { right at all (so we have to make sure that "right" really is   }
            { "right" and not "swapped left" in that case)                   }
            { "right" and not "swapped left" in that case)                   }
            firstcomplex(self);
            firstcomplex(self);
 
 
          secondpass(left);
          secondpass(left);
-         if isjump then
-           begin
-             hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,orgopdef,opdef,true);
-             left.resultdef:=opdef;
-             current_procinfo.CurrTrueLabel:=otl;
-             current_procinfo.CurrFalseLabel:=ofl;
-           end
-         else if (left.location.loc=LOC_JUMP) then
+         if (left.expectloc=LOC_JUMP)<>
+            (left.location.loc=LOC_JUMP) then
            internalerror(2007070101);
            internalerror(2007070101);
 
 
          { Only process the right if we are not generating jumps }
          { Only process the right if we are not generating jumps }
@@ -327,7 +305,9 @@ implementation
          if genjumps then
          if genjumps then
            begin
            begin
              { location is always LOC_JUMP }
              { location is always LOC_JUMP }
-             location_reset(location,LOC_JUMP,OS_NO);
+             current_asmdata.getjumplabel(l);
+             current_asmdata.getjumplabel(l2);
+             location_reset_jump(location,l,l2);
 
 
              { If register is used, use only lower 8 bits }
              { If register is used, use only lower 8 bits }
              hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,opdef,false);
              hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,opdef,false);
@@ -375,24 +355,24 @@ implementation
                      { (this will never overflow since we check at the     }
                      { (this will never overflow since we check at the     }
                      { beginning whether stop-start <> 255)                }
                      { beginning whether stop-start <> 255)                }
                      hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, uopdef, OC_B,
                      hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, uopdef, OC_B,
-                       setparts[i].stop-setparts[i].start+1,pleftreg,current_procinfo.CurrTrueLabel);
+                       setparts[i].stop-setparts[i].start+1,pleftreg,location.truelabel);
                    end
                    end
                  else
                  else
                    { if setparts[i].start = 0 and setparts[i].stop = 255,  }
                    { if setparts[i].start = 0 and setparts[i].stop = 255,  }
                    { it's always true since "in" is only allowed for bytes }
                    { it's always true since "in" is only allowed for bytes }
                    begin
                    begin
-                     hlcg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                     hlcg.a_jmp_always(current_asmdata.CurrAsmList,location.truelabel);
                    end;
                    end;
                end
                end
               else
               else
                begin
                begin
                  { Emit code to check if left is an element }
                  { Emit code to check if left is an element }
                  hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opdef, OC_EQ,
                  hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opdef, OC_EQ,
-                       setparts[i].stop-adjustment,pleftreg,current_procinfo.CurrTrueLabel);
+                       setparts[i].stop-adjustment,pleftreg,location.truelabel);
                end;
                end;
               { To compensate for not doing a second pass }
               { To compensate for not doing a second pass }
               right.location.reference.symbol:=nil;
               right.location.reference.symbol:=nil;
-              hlcg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+              hlcg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
            end
            end
          else
          else
          {*****************************************************************}
          {*****************************************************************}
@@ -935,15 +915,11 @@ implementation
          max_label: tconstexprint;
          max_label: tconstexprint;
          labelcnt : tcgint;
          labelcnt : tcgint;
          max_linear_list : aint;
          max_linear_list : aint;
-         otl, ofl: tasmlabel;
-         isjump : boolean;
          max_dist,
          max_dist,
          dist : aword;
          dist : aword;
          oldexecutionweight : longint;
          oldexecutionweight : longint;
       begin
       begin
          location_reset(location,LOC_VOID,OS_NO);
          location_reset(location,LOC_VOID,OS_NO);
-         ofl:=nil;
-         otl:=nil;
 
 
          oldflowcontrol := flowcontrol;
          oldflowcontrol := flowcontrol;
          include(flowcontrol,fc_inflowcontrol);
          include(flowcontrol,fc_inflowcontrol);
@@ -967,17 +943,10 @@ implementation
               jmp_le:=OC_BE;
               jmp_le:=OC_BE;
            end;
            end;
 
 
-         { save current current_procinfo.CurrTrueLabel and current_procinfo.CurrFalseLabel }
-         isjump:=false;
-         if left.expectloc=LOC_JUMP then
-          begin
-            otl:=current_procinfo.CurrTrueLabel;
-            current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-            ofl:=current_procinfo.CurrFalseLabel;
-            current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-            isjump:=true;
-          end;
          secondpass(left);
          secondpass(left);
+         if (left.expectloc=LOC_JUMP)<>
+            (left.location.loc=LOC_JUMP) then
+           internalerror(2006050501);
          { determines the size of the operand }
          { determines the size of the operand }
          opsize:=left.resultdef;
          opsize:=left.resultdef;
          { copy the case expression to a register }
          { copy the case expression to a register }
@@ -991,14 +960,6 @@ implementation
          else
          else
 {$endif not cpu64bitalu}
 {$endif not cpu64bitalu}
            hregister:=left.location.register;
            hregister:=left.location.register;
-         if isjump then
-          begin
-            current_procinfo.CurrTrueLabel:=otl;
-            current_procinfo.CurrFalseLabel:=ofl;
-          end
-         else
-          if (left.location.loc=LOC_JUMP) then
-            internalerror(2006050501);
 
 
          { we need the min_label always to choose between }
          { we need the min_label always to choose between }
          { cmps and subs/decs                             }
          { cmps and subs/decs                             }

+ 23 - 20
compiler/ncgutil.pas

@@ -57,7 +57,7 @@ interface
 }
 }
 
 
     procedure firstcomplex(p : tbinarynode);
     procedure firstcomplex(p : tbinarynode);
-    procedure maketojumpbool(list:TAsmList; p : tnode; loadregvars: tloadregvars);
+    procedure maketojumpboollabels(list: TAsmList; p: tnode; truelabel, falselabel: tasmlabel);
 //    procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsuperregisterset);
 //    procedure remove_non_regvars_from_loc(const t: tlocation; var regs:Tsuperregisterset);
 
 
     procedure location_force_mmreg(list:TAsmList;var l: tlocation;maybeconst:boolean);
     procedure location_force_mmreg(list:TAsmList;var l: tlocation;maybeconst:boolean);
@@ -257,14 +257,9 @@ implementation
       end;
       end;
 
 
 
 
-    procedure maketojumpbool(list:TAsmList; p : tnode; loadregvars: tloadregvars);
+    procedure maketojumpboollabels(list: TAsmList; p: tnode; truelabel, falselabel: tasmlabel);
     {
     {
       produces jumps to true respectively false labels using boolean expressions
       produces jumps to true respectively false labels using boolean expressions
-
-      depending on whether the loading of regvars is currently being
-      synchronized manually (such as in an if-node) or automatically (most of
-      the other cases where this procedure is called), loadregvars can be
-      "lr_load_regvars" or "lr_dont_load_regvars"
     }
     }
       var
       var
         opsize : tcgsize;
         opsize : tcgsize;
@@ -277,16 +272,12 @@ implementation
          current_filepos:=p.fileinfo;
          current_filepos:=p.fileinfo;
          if is_boolean(p.resultdef) then
          if is_boolean(p.resultdef) then
            begin
            begin
-{$ifdef OLDREGVARS}
-              if loadregvars = lr_load_regvars then
-                load_all_regvars(list);
-{$endif OLDREGVARS}
               if is_constboolnode(p) then
               if is_constboolnode(p) then
                 begin
                 begin
                    if Tordconstnode(p).value.uvalue<>0 then
                    if Tordconstnode(p).value.uvalue<>0 then
-                     cg.a_jmp_always(list,current_procinfo.CurrTrueLabel)
+                     cg.a_jmp_always(list,truelabel)
                    else
                    else
-                     cg.a_jmp_always(list,current_procinfo.CurrFalseLabel)
+                     cg.a_jmp_always(list,falselabel)
                 end
                 end
               else
               else
                 begin
                 begin
@@ -297,8 +288,8 @@ implementation
                        begin
                        begin
                          tmpreg := cg.getintregister(list,OS_INT);
                          tmpreg := cg.getintregister(list,OS_INT);
                          hlcg.a_load_loc_reg(list,p.resultdef,osuinttype,p.location,tmpreg);
                          hlcg.a_load_loc_reg(list,p.resultdef,osuinttype,p.location,tmpreg);
-                         cg.a_cmp_const_reg_label(list,OS_INT,OC_NE,0,tmpreg,current_procinfo.CurrTrueLabel);
-                         cg.a_jmp_always(list,current_procinfo.CurrFalseLabel);
+                         cg.a_cmp_const_reg_label(list,OS_INT,OC_NE,0,tmpreg,truelabel);
+                         cg.a_jmp_always(list,falselabel);
                        end;
                        end;
                      LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE :
                      LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE :
                        begin
                        begin
@@ -323,17 +314,28 @@ implementation
                              opsize:=OS_32;
                              opsize:=OS_32;
                            end;
                            end;
 {$endif cpu64bitalu}
 {$endif cpu64bitalu}
-                         cg.a_cmp_const_loc_label(list,opsize,OC_NE,0,p.location,current_procinfo.CurrTrueLabel);
-                         cg.a_jmp_always(list,current_procinfo.CurrFalseLabel);
+                         cg.a_cmp_const_loc_label(list,opsize,OC_NE,0,p.location,truelabel);
+                         cg.a_jmp_always(list,falselabel);
                        end;
                        end;
                      LOC_JUMP:
                      LOC_JUMP:
-                       ;
+                       begin
+                         if truelabel<>p.location.truelabel then
+                           begin
+                             cg.a_label(list,p.location.truelabel);
+                             cg.a_jmp_always(list,truelabel);
+                           end;
+                         if falselabel<>p.location.falselabel then
+                           begin
+                             cg.a_label(list,p.location.falselabel);
+                             cg.a_jmp_always(list,falselabel);
+                           end;
+                       end;
 {$ifdef cpuflags}
 {$ifdef cpuflags}
                      LOC_FLAGS :
                      LOC_FLAGS :
                        begin
                        begin
-                         cg.a_jmp_flags(list,p.location.resflags,current_procinfo.CurrTrueLabel);
+                         cg.a_jmp_flags(list,p.location.resflags,truelabel);
                          cg.a_reg_dealloc(list,NR_DEFAULTFLAGS);
                          cg.a_reg_dealloc(list,NR_DEFAULTFLAGS);
-                         cg.a_jmp_always(list,current_procinfo.CurrFalseLabel);
+                         cg.a_jmp_always(list,falselabel);
                        end;
                        end;
 {$endif cpuflags}
 {$endif cpuflags}
                      else
                      else
@@ -343,6 +345,7 @@ implementation
                        end;
                        end;
                    end;
                    end;
                 end;
                 end;
+              location_reset_jump(p.location,truelabel,falselabel);
            end
            end
          else
          else
            internalerror(200112305);
            internalerror(200112305);

+ 27 - 15
compiler/powerpc/nppcadd.pas

@@ -143,6 +143,8 @@ interface
 
 
     procedure tppcaddnode.second_add64bit;
     procedure tppcaddnode.second_add64bit;
       var
       var
+        truelabel,
+        falselabel : tasmlabel;
         op         : TOpCG;
         op         : TOpCG;
         op1,op2    : TAsmOp;
         op1,op2    : TAsmOp;
         cmpop,
         cmpop,
@@ -192,10 +194,10 @@ interface
            case nodetype of
            case nodetype of
               ltn,gtn:
               ltn,gtn:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,truelabel);
                    { cheat a little bit for the negative test }
                    { cheat a little bit for the negative test }
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,falselabel);
                    toggleflag(nf_swapped);
                    toggleflag(nf_swapped);
                 end;
                 end;
               lten,gten:
               lten,gten:
@@ -205,24 +207,24 @@ interface
                      nodetype:=ltn
                      nodetype:=ltn
                    else
                    else
                      nodetype:=gtn;
                      nodetype:=gtn;
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,truelabel);
                    { cheat for the negative test }
                    { cheat for the negative test }
                    if nodetype=ltn then
                    if nodetype=ltn then
                      nodetype:=gtn
                      nodetype:=gtn
                    else
                    else
                      nodetype:=ltn;
                      nodetype:=ltn;
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,falselabel);
                    nodetype:=oldnodetype;
                    nodetype:=oldnodetype;
                 end;
                 end;
               equaln:
               equaln:
                 begin
                 begin
                   nodetype := unequaln;
                   nodetype := unequaln;
-                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrFalseLabel);
+                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,falselabel);
                   nodetype := equaln;
                   nodetype := equaln;
                 end;
                 end;
               unequaln:
               unequaln:
                 begin
                 begin
-                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrTrueLabel);
+                  cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,truelabel);
                 end;
                 end;
            end;
            end;
         end;
         end;
@@ -237,20 +239,20 @@ interface
                 begin
                 begin
                    { the comparison of the low dword always has }
                    { the comparison of the low dword always has }
                    { to be always unsigned!                     }
                    { to be always unsigned!                     }
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrTrueLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,truelabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,falselabel);
                 end;
                 end;
               equaln:
               equaln:
                 begin
                 begin
                    nodetype := unequaln;
                    nodetype := unequaln;
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrFalseLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,falselabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,truelabel);
                    nodetype := equaln;
                    nodetype := equaln;
                 end;
                 end;
               unequaln:
               unequaln:
                 begin
                 begin
-                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrTrueLabel);
-                   cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                   cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,truelabel);
+                   cg.a_jmp_always(current_asmdata.CurrAsmList,falselabel);
                 end;
                 end;
            end;
            end;
         end;
         end;
@@ -260,6 +262,8 @@ interface
       tempreg64: tregister64;
       tempreg64: tregister64;
 
 
       begin
       begin
+        truelabel:=nil;
+        falselabel:=nil;
         firstcomplex(self);
         firstcomplex(self);
 
 
         pass_left_and_right;
         pass_left_and_right;
@@ -306,8 +310,16 @@ interface
             internalerror(2002072705);
             internalerror(2002072705);
         end;
         end;
 
 
-        if not cmpop then
-          location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
+        if not cmpop or
+           (nodetype in [equaln,unequaln]) then
+          location_reset(location,LOC_REGISTER,def_cgsize(resultdef))
+        else
+          begin
+            { we call emit_cmp, which will set location.loc to LOC_FLAGS ->
+              wait till the end with setting the location }
+            current_asmdata.getjumplabel(truelabel);
+            current_asmdata.getjumplabel(falselabel);
+          end;
 
 
         load_left_right(cmpop,((cs_check_overflow in current_settings.localswitches) and
         load_left_right(cmpop,((cs_check_overflow in current_settings.localswitches) and
             (nodetype in [addn,subn])) or (nodetype = muln));
             (nodetype in [addn,subn])) or (nodetype = muln));
@@ -544,7 +556,7 @@ interface
         {  real location only now) (JM)                               }
         {  real location only now) (JM)                               }
         if cmpop and
         if cmpop and
            not(nodetype in [equaln,unequaln]) then
            not(nodetype in [equaln,unequaln]) then
-          location_reset(location,LOC_JUMP,OS_NO);
+          location_reset_jump(location,truelabel,falselabel);
       end;
       end;
 
 
 
 

+ 1 - 1
compiler/powerpc/nppcmat.pas

@@ -26,7 +26,7 @@ unit nppcmat;
 interface
 interface
 
 
     uses
     uses
-      node,nmat,ncgmat;
+      node,nmat, ncgmat;
 
 
     type
     type
       tppcmoddivnode = class(tmoddivnode)
       tppcmoddivnode = class(tmoddivnode)

+ 7 - 35
compiler/ppcgen/ngppcadd.pas

@@ -193,14 +193,10 @@ implementation
       var
       var
         cgop      : TOpCg;
         cgop      : TOpCg;
         cgsize  : TCgSize;
         cgsize  : TCgSize;
-        cmpop,
-        isjump  : boolean;
-        otl,ofl : tasmlabel;
+        cmpop   : boolean;
       begin
       begin
         { calculate the operator which is more difficult }
         { calculate the operator which is more difficult }
         firstcomplex(self);
         firstcomplex(self);
-        otl:=nil;
-        ofl:=nil;
 
 
         cmpop:=false;
         cmpop:=false;
         if (torddef(left.resultdef).ordtype in [pasbool8,bool8bit]) or
         if (torddef(left.resultdef).ordtype in [pasbool8,bool8bit]) or
@@ -223,43 +219,19 @@ implementation
             if left.nodetype in [ordconstn,realconstn] then
             if left.nodetype in [ordconstn,realconstn] then
              swapleftright;
              swapleftright;
 
 
-            isjump:=(left.expectloc=LOC_JUMP);
-            if isjump then
-              begin
-                 otl:=current_procinfo.CurrTrueLabel;
-                 current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-                 ofl:=current_procinfo.CurrFalseLabel;
-                 current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-              end;
             secondpass(left);
             secondpass(left);
+            if (left.expectloc=LOC_JUMP)<>
+               (left.location.loc=LOC_JUMP) then
+              internalerror(2003122901);
             if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
             if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
               hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,cgsize_orddef(cgsize),false);
               hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,cgsize_orddef(cgsize),false);
-            if isjump then
-             begin
-               current_procinfo.CurrTrueLabel:=otl;
-               current_procinfo.CurrFalseLabel:=ofl;
-             end
-            else if left.location.loc=LOC_JUMP then
-              internalerror(2003122901);
 
 
-            isjump:=(right.expectloc=LOC_JUMP);
-            if isjump then
-              begin
-                 otl:=current_procinfo.CurrTrueLabel;
-                 current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-                 ofl:=current_procinfo.CurrFalseLabel;
-                 current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-              end;
             secondpass(right);
             secondpass(right);
+            if (right.expectloc=LOC_JUMP)<>
+               (right.location.loc=LOC_JUMP) then
+              internalerror(200312292);
             if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
             if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
               hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,cgsize_orddef(cgsize),false);
               hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,cgsize_orddef(cgsize),false);
-            if isjump then
-             begin
-               current_procinfo.CurrTrueLabel:=otl;
-               current_procinfo.CurrFalseLabel:=ofl;
-             end
-            else if right.location.loc=LOC_JUMP then
-              internalerror(200312292);
 
 
             cmpop := nodetype in [ltn,lten,gtn,gten,equaln,unequaln];
             cmpop := nodetype in [ltn,lten,gtn,gten,equaln,unequaln];
 
 

+ 4 - 13
compiler/ppcgen/ngppccnv.pas

@@ -75,13 +75,9 @@ implementation
 {$endif not cpu64bitalu}
 {$endif not cpu64bitalu}
         resflags : tresflags;
         resflags : tresflags;
         opsize   : tcgsize;
         opsize   : tcgsize;
-        hlabel, oldTrueLabel, oldFalseLabel : tasmlabel;
-        newsize   : tcgsize;
+        hlabel   : tasmlabel;
+        newsize  : tcgsize;
       begin
       begin
-         oldTrueLabel:=current_procinfo.CurrTrueLabel;
-         oldFalseLabel:=current_procinfo.CurrFalseLabel;
-         current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-         current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
          secondpass(left);
          secondpass(left);
          if codegenerror then
          if codegenerror then
           exit;
           exit;
@@ -99,8 +95,6 @@ implementation
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
               else
               else
                 location.size:=newsize;
                 location.size:=newsize;
-              current_procinfo.CurrTrueLabel:=oldTrueLabel;
-              current_procinfo.CurrFalseLabel:=oldFalseLabel;
               exit;
               exit;
            end;
            end;
 
 
@@ -176,13 +170,13 @@ implementation
               begin
               begin
                 hreg1:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
                 hreg1:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
                 current_asmdata.getjumplabel(hlabel);
                 current_asmdata.getjumplabel(hlabel);
-                cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                cg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
                 if not(is_cbool(resultdef)) then
                 if not(is_cbool(resultdef)) then
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hreg1)
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hreg1)
                 else
                 else
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,-1,hreg1);
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,-1,hreg1);
                 cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
                 cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
-                cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hreg1);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hreg1);
                 cg.a_label(current_asmdata.CurrAsmList,hlabel);
                 cg.a_label(current_asmdata.CurrAsmList,hlabel);
               end;
               end;
@@ -204,9 +198,6 @@ implementation
          else
          else
 {$endif cpu64bitalu}
 {$endif cpu64bitalu}
            location.register:=hreg1;
            location.register:=hreg1;
-
-         current_procinfo.CurrTrueLabel:=oldTrueLabel;
-         current_procinfo.CurrFalseLabel:=oldFalseLabel;
       end;
       end;
 
 
 end.
 end.

+ 1 - 25
compiler/procinfo.pas

@@ -108,9 +108,7 @@ unit procinfo;
 
 
           { Labels for TRUE/FALSE condition, BREAK and CONTINUE }
           { Labels for TRUE/FALSE condition, BREAK and CONTINUE }
           CurrBreakLabel,
           CurrBreakLabel,
-          CurrContinueLabel,
-          CurrTrueLabel,
-          CurrFalseLabel : tasmlabel;
+          CurrContinueLabel : tasmlabel;
 
 
           { label to leave the sub routine }
           { label to leave the sub routine }
           CurrExitLabel : tasmlabel;
           CurrExitLabel : tasmlabel;
@@ -160,12 +158,6 @@ unit procinfo;
           { Destroy the entire procinfo tree, starting from the outermost parent }
           { Destroy the entire procinfo tree, starting from the outermost parent }
           procedure destroy_tree;
           procedure destroy_tree;
 
 
-          { Store CurrTrueLabel and CurrFalseLabel to saved and generate new ones }
-          procedure save_jump_labels(out saved: tsavedlabels);
-
-          { Restore CurrTrueLabel and CurrFalseLabel from saved }
-          procedure restore_jump_labels(const saved: tsavedlabels);
-
           function get_first_nestedproc: tprocinfo;
           function get_first_nestedproc: tprocinfo;
           function has_nestedprocs: boolean;
           function has_nestedprocs: boolean;
           function get_normal_proc: tprocinfo;
           function get_normal_proc: tprocinfo;
@@ -216,8 +208,6 @@ implementation
         current_asmdata.getjumplabel(CurrGOTLabel);
         current_asmdata.getjumplabel(CurrGOTLabel);
         CurrBreakLabel:=nil;
         CurrBreakLabel:=nil;
         CurrContinueLabel:=nil;
         CurrContinueLabel:=nil;
-        CurrTrueLabel:=nil;
-        CurrFalseLabel:=nil;
         if Assigned(parent) and (parent.procdef.parast.symtablelevel>=normal_function_level) then
         if Assigned(parent) and (parent.procdef.parast.symtablelevel>=normal_function_level) then
           parent.addnestedproc(Self);
           parent.addnestedproc(Self);
       end;
       end;
@@ -277,20 +267,6 @@ implementation
           result:=result.parent;
           result:=result.parent;
       end;
       end;
 
 
-    procedure tprocinfo.save_jump_labels(out saved: tsavedlabels);
-      begin
-        saved[false]:=CurrFalseLabel;
-        saved[true]:=CurrTrueLabel;
-        current_asmdata.getjumplabel(CurrTrueLabel);
-        current_asmdata.getjumplabel(CurrFalseLabel);
-      end;
-
-    procedure tprocinfo.restore_jump_labels(const saved: tsavedlabels);
-      begin
-        CurrFalseLabel:=saved[false];
-        CurrTrueLabel:=saved[true];
-      end;
-
     procedure tprocinfo.allocate_push_parasize(size:longint);
     procedure tprocinfo.allocate_push_parasize(size:longint);
       begin
       begin
         if size>maxpushedparasize then
         if size>maxpushedparasize then

+ 3 - 12
compiler/sparc/ncpucnv.pas

@@ -233,13 +233,9 @@ implementation
         hreg1,hreg2 : tregister;
         hreg1,hreg2 : tregister;
         resflags : tresflags;
         resflags : tresflags;
         opsize   : tcgsize;
         opsize   : tcgsize;
-        hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+        hlabel   : tasmlabel;
         newsize  : tcgsize;
         newsize  : tcgsize;
       begin
       begin
-        oldTrueLabel:=current_procinfo.CurrTrueLabel;
-        oldFalseLabel:=current_procinfo.CurrFalseLabel;
-        current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-        current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
         secondpass(left);
         secondpass(left);
         if codegenerror then
         if codegenerror then
           exit;
           exit;
@@ -257,8 +253,6 @@ implementation
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
               else
               else
                 location.size:=newsize;
                 location.size:=newsize;
-              current_procinfo.CurrTrueLabel:=oldTrueLabel;
-              current_procinfo.CurrFalseLabel:=oldFalseLabel;
               exit;
               exit;
            end;
            end;
 
 
@@ -320,13 +314,13 @@ implementation
             begin
             begin
               hreg1:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
               hreg1:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
               current_asmdata.getjumplabel(hlabel);
               current_asmdata.getjumplabel(hlabel);
-              cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+              cg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
               if not(is_cbool(resultdef)) then
               if not(is_cbool(resultdef)) then
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hreg1)
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hreg1)
               else
               else
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,-1,hreg1);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,-1,hreg1);
               cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
               cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
-              cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+              cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
               cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hreg1);
               cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,0,hreg1);
               cg.a_label(current_asmdata.CurrAsmList,hlabel);
               cg.a_label(current_asmdata.CurrAsmList,hlabel);
             end;
             end;
@@ -348,9 +342,6 @@ implementation
          else
          else
 {$endif not cpu64bitalu}
 {$endif not cpu64bitalu}
            location.register:=hreg1;
            location.register:=hreg1;
-
-        current_procinfo.CurrTrueLabel:=oldTrueLabel;
-        current_procinfo.CurrFalseLabel:=oldFalseLabel;
       end;
       end;
 
 
 
 

+ 3 - 11
compiler/x86/nx86cnv.pas

@@ -92,13 +92,9 @@ implementation
         i         : integer;
         i         : integer;
 {$endif not cpu64bitalu}
 {$endif not cpu64bitalu}
         resflags  : tresflags;
         resflags  : tresflags;
-        hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+        hlabel    : tasmlabel;
         newsize   : tcgsize;
         newsize   : tcgsize;
       begin
       begin
-         oldTrueLabel:=current_procinfo.CurrTrueLabel;
-         oldFalseLabel:=current_procinfo.CurrFalseLabel;
-         current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
-         current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
          secondpass(left);
          secondpass(left);
          if codegenerror then
          if codegenerror then
           exit;
           exit;
@@ -115,8 +111,6 @@ implementation
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
                 hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
               else
               else
                 location.size:=newsize;
                 location.size:=newsize;
-              current_procinfo.CurrTrueLabel:=oldTrueLabel;
-              current_procinfo.CurrFalseLabel:=oldFalseLabel;
               exit;
               exit;
            end;
            end;
 
 
@@ -184,13 +178,13 @@ implementation
                 location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
                 location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
                 location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
                 location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
                 current_asmdata.getjumplabel(hlabel);
                 current_asmdata.getjumplabel(hlabel);
-                cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+                cg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
                 if not(is_cbool(resultdef)) then
                 if not(is_cbool(resultdef)) then
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,1,location.register)
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,1,location.register)
                 else
                 else
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,-1,location.register);
                   cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,-1,location.register);
                 cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
                 cg.a_jmp_always(current_asmdata.CurrAsmList,hlabel);
-                cg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+                cg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,0,location.register);
                 cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,0,location.register);
                 cg.a_label(current_asmdata.CurrAsmList,hlabel);
                 cg.a_label(current_asmdata.CurrAsmList,hlabel);
               end;
               end;
@@ -226,8 +220,6 @@ implementation
                    cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,location.register,location.register);
                    cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,location.register,location.register);
                end
                end
            end;
            end;
-         current_procinfo.CurrTrueLabel:=oldTrueLabel;
-         current_procinfo.CurrFalseLabel:=oldFalseLabel;
        end;
        end;