summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/aarch64/ncpucnv.pas8
-rw-r--r--compiler/arm/narmadd.pas19
-rw-r--r--compiler/arm/narmcnv.pas15
-rw-r--r--compiler/cgutils.pas21
-rw-r--r--compiler/hlcg2ll.pas14
-rw-r--r--compiler/hlcgobj.pas65
-rw-r--r--compiler/i386/n386add.pas44
-rw-r--r--compiler/i8086/n8086add.pas88
-rw-r--r--compiler/jvm/njvmadd.pas36
-rw-r--r--compiler/jvm/njvmcnv.pas22
-rw-r--r--compiler/jvm/njvmmem.pas24
-rw-r--r--compiler/llvm/nllvmcnv.pas13
-rw-r--r--compiler/m68k/n68kadd.pas44
-rw-r--r--compiler/m68k/n68kcnv.pas17
-rw-r--r--compiler/mips/ncpuadd.pas35
-rw-r--r--compiler/mips/ncpucnv.pas16
-rw-r--r--compiler/ncgadd.pas58
-rw-r--r--compiler/ncgcal.pas8
-rw-r--r--compiler/ncgcnv.pas21
-rw-r--r--compiler/ncgflw.pas73
-rw-r--r--compiler/ncghlmat.pas13
-rw-r--r--compiler/ncgld.pas36
-rw-r--r--compiler/ncgmat.pas13
-rw-r--r--compiler/ncgmem.pas23
-rw-r--r--compiler/ncgset.pas69
-rw-r--r--compiler/ncgutil.pas43
-rw-r--r--compiler/powerpc/nppcadd.pas42
-rw-r--r--compiler/powerpc/nppcmat.pas2
-rw-r--r--compiler/ppcgen/ngppcadd.pas42
-rw-r--r--compiler/ppcgen/ngppccnv.pas17
-rw-r--r--compiler/procinfo.pas26
-rw-r--r--compiler/sparc/ncpucnv.pas15
-rw-r--r--compiler/x86/nx86cnv.pas14
33 files changed, 383 insertions, 613 deletions
diff --git a/compiler/aarch64/ncpucnv.pas b/compiler/aarch64/ncpucnv.pas
index f9124a01c0..baa218a811 100644
--- a/compiler/aarch64/ncpucnv.pas
+++ b/compiler/aarch64/ncpucnv.pas
@@ -142,7 +142,7 @@ implementation
procedure taarch64typeconvnode.second_int_to_bool;
var
resflags: tresflags;
- hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+ hlabel: tasmlabel;
begin
if (nf_explicit in flags) and
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
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);
if codegenerror then
exit;
@@ -195,8 +191,6 @@ implementation
else
cg.g_flags2reg(current_asmdata.CurrAsmList,location.size,resflags,location.register);
cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
end;
diff --git a/compiler/arm/narmadd.pas b/compiler/arm/narmadd.pas
index 0f1ee49cd2..c60d39afd8 100644
--- a/compiler/arm/narmadd.pas
+++ b/compiler/arm/narmadd.pas
@@ -407,10 +407,13 @@ interface
unsigned : boolean;
oldnodetype : tnodetype;
dummyreg : tregister;
+ truelabel, falselabel: tasmlabel;
l: tasmlabel;
const
lt_zero_swapped: array[boolean] of tnodetype = (ltn, gtn);
begin
+ truelabel:=nil;
+ falselabel:=nil;
unsigned:=not(is_signed(left.resultdef)) or
not(is_signed(right.resultdef));
@@ -472,17 +475,19 @@ interface
else
{ operation requiring proper N, Z and V flags ? }
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);
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 }
case nodetype of
ltn,gtn:
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 }
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);
toggleflag(nf_swapped);
end;
@@ -493,13 +498,13 @@ interface
nodetype:=ltn
else
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 }
if nodetype=ltn then
nodetype:=gtn
else
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);
nodetype:=oldnodetype;
end;
@@ -508,8 +513,8 @@ interface
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
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);
end;
end;
diff --git a/compiler/arm/narmcnv.pas b/compiler/arm/narmcnv.pas
index 48815479e4..40670b9394 100644
--- a/compiler/arm/narmcnv.pas
+++ b/compiler/arm/narmcnv.pas
@@ -283,13 +283,9 @@ implementation
hregister : tregister;
href : treference;
resflags : tresflags;
- hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+ hlabel : tasmlabel;
newsize : tcgsize;
begin
- oldTrueLabel:=current_procinfo.CurrTrueLabel;
- oldFalseLabel:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left);
if codegenerror then
exit;
@@ -307,8 +303,6 @@ implementation
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
else
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
exit;
end;
@@ -365,10 +359,10 @@ implementation
begin
hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
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_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_label(current_asmdata.CurrAsmList,hlabel);
tbasecgarm(cg).cgsetflags:=true;
@@ -401,9 +395,6 @@ implementation
else
{$endif cpu64bitalu}
location.register:=hreg1;
-
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
end;
diff --git a/compiler/cgutils.pas b/compiler/cgutils.pas
index d8c4943a04..2c3d508b84 100644
--- a/compiler/cgutils.pas
+++ b/compiler/cgutils.pas
@@ -151,7 +151,10 @@ unit cgutils;
);
LOC_SUBSETREF : (
sref: tsubsetreference;
- )
+ );
+ LOC_JUMP : (
+ truelabel, falselabel: tasmlabel;
+ );
end;
@@ -175,6 +178,8 @@ unit cgutils;
procedure location_reset(var l : tlocation;lt:TCGNonRefLoc;lsize:TCGSize);
{ for loc_(c)reference }
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_swap(var destloc,sourceloc : tlocation);
function location_reg2string(const locreg: tlocation): string;
@@ -247,8 +252,8 @@ uses
FillChar(l,sizeof(tlocation),0);
l.loc:=lt;
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);
end;
@@ -265,6 +270,16 @@ uses
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);
begin
destloc:=sourceloc;
diff --git a/compiler/hlcg2ll.pas b/compiler/hlcg2ll.pas
index 3100e0ec9b..f7eb494f68 100644
--- a/compiler/hlcg2ll.pas
+++ b/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_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;
protected
@@ -1041,11 +1041,11 @@ implementation
{$endif cpuflags}
LOC_JUMP :
begin
- cg.a_label(list,current_procinfo.CurrTrueLabel);
+ cg.a_label(list,l.truelabel);
cg.a_load_const_reg(list,OS_INT,1,hregister);
current_asmdata.getjumplabel(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_label(list,hl);
{$if defined(cpu8bitalu) or defined(cpu16bitalu)}
@@ -1141,11 +1141,11 @@ implementation
if TCGSize2Size[dst_cgsize]>TCGSize2Size[OS_INT] then
tmpsize:=OS_INT;
{$endif}
- cg.a_label(list,current_procinfo.CurrTrueLabel);
+ cg.a_label(list,l.truelabel);
cg.a_load_const_reg(list,tmpsize,1,hregister);
current_asmdata.getjumplabel(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_label(list,hl);
{$if defined(cpu8bitalu) or defined(cpu16bitalu)}
@@ -1311,11 +1311,11 @@ implementation
ncgutil.location_force_mmreg(list,l,maybeconst);
end;
*)
- procedure thlcg2ll.maketojumpbool(list: TAsmList; p: tnode);
+ procedure thlcg2ll.maketojumpboollabels(list: TAsmList; p: tnode; truelabel, falselabel: tasmlabel);
begin
{ loadregvars parameter is no longer used, should be removed from
ncgutil version as well }
- ncgutil.maketojumpbool(list,p,lr_dont_load_regvars);
+ ncgutil.maketojumpboollabels(list,p,truelabel,falselabel);
end;
procedure thlcg2ll.gen_load_para_value(list: TAsmList);
diff --git a/compiler/hlcgobj.pas b/compiler/hlcgobj.pas
index 253104be40..af13276320 100644
--- a/compiler/hlcgobj.pas
+++ b/compiler/hlcgobj.pas
@@ -552,7 +552,12 @@ unit hlcgobj;
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 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
loadn and change its location to a new register (= SSA). In case reload
is true, transfer the old to the new register }
@@ -3850,11 +3855,11 @@ implementation
{$endif cpuflags}
LOC_JUMP :
begin
- a_label(list,current_procinfo.CurrTrueLabel);
+ a_label(list,l.truelabel);
a_load_const_reg(list,dst_size,1,hregister);
current_asmdata.getjumplabel(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_label(list,hl);
end;
@@ -4035,15 +4040,27 @@ implementation
end;
end;
+
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
storepos : tfileposinfo;
begin
@@ -4056,9 +4073,9 @@ implementation
if is_constboolnode(p) then
begin
if Tordconstnode(p).value.uvalue<>0 then
- a_jmp_always(list,current_procinfo.CurrTrueLabel)
+ a_jmp_always(list,truelabel)
else
- a_jmp_always(list,current_procinfo.CurrFalseLabel)
+ a_jmp_always(list,falselabel)
end
else
begin
@@ -4067,17 +4084,28 @@ implementation
LOC_SUBSETREF,LOC_CSUBSETREF,
LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE :
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;
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}
LOC_FLAGS :
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_jmp_always(list,current_procinfo.CurrFalseLabel);
+ a_jmp_always(list,falselabel);
end;
{$endif cpuflags}
else
@@ -4087,6 +4115,7 @@ implementation
end;
end;
end;
+ location_reset_jump(p.location,truelabel,falselabel);
end
else
internalerror(2011010419);
diff --git a/compiler/i386/n386add.pas b/compiler/i386/n386add.pas
index b75b18d83d..22803944a0 100644
--- a/compiler/i386/n386add.pas
+++ b/compiler/i386/n386add.pas
@@ -229,6 +229,8 @@ interface
procedure ti386addnode.second_cmp64bit;
var
+ truelabel,
+ falselabel,
hlab : tasmlabel;
href : treference;
unsigned : boolean;
@@ -246,12 +248,12 @@ interface
case nodetype of
ltn,gtn:
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 }
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);
end;
lten,gten:
@@ -261,21 +263,21 @@ interface
nodetype:=ltn
else
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 }
if nodetype=ltn then
nodetype:=gtn
else
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;
end;
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:
- 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;
@@ -288,23 +290,25 @@ interface
begin
{ the comparisaion of the low dword have to be }
{ 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;
equaln:
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;
unequaln:
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;
begin
+ truelabel:=nil;
+ falselabel:=nil;
pass_left_right;
unsigned:=((left.resultdef.typ=orddef) and
@@ -313,7 +317,9 @@ interface
(torddef(right.resultdef).ordtype=u64bit));
{ 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
second compare based on the fact that any unsigned value is >=0 }
@@ -322,8 +328,8 @@ interface
(lo(right.location.value64)=0) then
begin
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;
diff --git a/compiler/i8086/n8086add.pas b/compiler/i8086/n8086add.pas
index 879b4a46aa..1730224c94 100644
--- a/compiler/i8086/n8086add.pas
+++ b/compiler/i8086/n8086add.pas
@@ -518,6 +518,8 @@ interface
procedure ti8086addnode.second_cmp64bit;
var
+ truelabel,
+ falselabel : tasmlabel;
hregister,
hregister2 : tregister;
href : treference;
@@ -536,10 +538,10 @@ interface
case nodetype of
ltn,gtn:
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 }
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);
end;
lten,gten:
@@ -549,19 +551,19 @@ interface
nodetype:=ltn
else
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 }
if nodetype=ltn then
nodetype:=gtn
else
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;
end;
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:
- 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;
@@ -580,10 +582,10 @@ interface
begin
{ the comparisaion of the low word have to be }
{ 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 }
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);
end;
lten,gten:
@@ -593,19 +595,19 @@ interface
nodetype:=ltn
else
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 }
if nodetype=ltn then
nodetype:=gtn
else
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;
end;
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:
- 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;
@@ -618,23 +620,25 @@ interface
begin
{ the comparisaion of the low word have to be }
{ 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;
equaln:
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;
unequaln:
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;
begin
+ truelabel:=nil;
+ falselabel:=nil;
pass_left_right;
unsigned:=((left.resultdef.typ=orddef) and
@@ -642,6 +646,11 @@ interface
((right.resultdef.typ=orddef) and
(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? }
{ then one must be demanded }
if (left.location.loc<>LOC_REGISTER) then
@@ -709,7 +718,7 @@ interface
middlejmp64bitcmp;
emit_ref_reg(A_CMP,S_W,right.location.reference,left.location.register64.reglo);
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);
end;
LOC_CONSTANT :
@@ -727,13 +736,12 @@ interface
internalerror(200203282);
end;
end;
-
- { we have LOC_JUMP as result }
- location_reset(location,LOC_JUMP,OS_NO)
end;
procedure ti8086addnode.second_cmp32bit;
var
+ truelabel,
+ falselabel: tasmlabel;
hregister : tregister;
href : treference;
unsigned : boolean;
@@ -751,10 +759,10 @@ interface
case nodetype of
ltn,gtn:
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 }
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);
end;
lten,gten:
@@ -764,19 +772,19 @@ interface
nodetype:=ltn
else
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 }
if nodetype=ltn then
nodetype:=gtn
else
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;
end;
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:
- 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;
@@ -789,23 +797,25 @@ interface
begin
{ the comparisaion of the low dword have to be }
{ 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;
equaln:
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;
unequaln:
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;
begin
+ truelabel:=nil;
+ falselabel:=nil;
pass_left_right;
unsigned:=((left.resultdef.typ=orddef) and
@@ -814,6 +824,11 @@ interface
(torddef(right.resultdef).ordtype=u32bit)) or
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? }
{ then one must be demanded }
if (left.location.loc<>LOC_REGISTER) then
@@ -866,7 +881,7 @@ interface
dec(href.offset,2);
emit_ref_reg(A_CMP,S_W,href,left.location.register);
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);
end;
LOC_CONSTANT :
@@ -880,9 +895,6 @@ interface
internalerror(200203282);
end;
end;
-
- { we have LOC_JUMP as result }
- location_reset(location,LOC_JUMP,OS_NO)
end;
diff --git a/compiler/jvm/njvmadd.pas b/compiler/jvm/njvmadd.pas
index e94a2c34a8..dbc466d045 100644
--- a/compiler/jvm/njvmadd.pas
+++ b/compiler/jvm/njvmadd.pas
@@ -56,7 +56,7 @@ interface
cutils,verbose,constexp,globtype,
symconst,symtable,symdef,symcpu,
paramgr,procinfo,pass_1,
- aasmtai,aasmdata,aasmcpu,defutil,
+ aasmbase,aasmtai,aasmdata,aasmcpu,defutil,
hlcgobj,hlcgcpu,cgutils,
cpupara,
nbas,ncon,nset,nadd,ncal,ncnv,ninl,nld,nmat,nmem,
@@ -335,8 +335,12 @@ interface
procedure tjvmaddnode.second_generic_compare(unsigned: boolean);
var
+ truelabel,
+ falselabel: tasmlabel;
cmpop: TOpCmp;
begin
+ truelabel:=nil;
+ falselabel:=nil;
pass_left_right;
{ swap the operands to make it easier for the optimizer to optimize
the operand stack slot reloading in case both are in a register }
@@ -346,21 +350,24 @@ interface
cmpop:=cmpnode2topcmp(unsigned);
if (nf_swapped in flags) then
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
- 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
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:
- 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:
- 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
internalerror(2011010413);
end;
- hlcg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+ hlcg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
end;
procedure tjvmaddnode.pass_left_right;
@@ -441,9 +448,13 @@ interface
procedure tjvmaddnode.second_cmpfloat;
var
- op : tasmop;
+ truelabel,
+ falselabel: tasmlabel;
+ op: tasmop;
cmpop: TOpCmp;
begin
+ truelabel:=nil;
+ falselabel:=nil;
pass_left_right;
{ swap the operands to make it easier for the optimizer to optimize
the operand stack slot reloading in case both are in a register }
@@ -453,7 +464,10 @@ interface
cmpop:=cmpnode2topcmp(false);
if (nf_swapped in flags) then
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,right.resultdef,right.location);
@@ -473,9 +487,9 @@ interface
current_asmdata.CurrAsmList.concat(taicpu.op_none(op));
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);
- hlcg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+ hlcg.a_jmp_always(current_asmdata.CurrAsmList,location.falselabel);
end;
diff --git a/compiler/jvm/njvmcnv.pas b/compiler/jvm/njvmcnv.pas
index 72ccbaa952..e239e7bc0a 100644
--- a/compiler/jvm/njvmcnv.pas
+++ b/compiler/jvm/njvmcnv.pas
@@ -704,12 +704,7 @@ implementation
procedure tjvmtypeconvnode.second_bool_to_int;
var
newsize: tcgsize;
- oldTrueLabel,oldFalseLabel : tasmlabel;
begin
- oldTrueLabel:=current_procinfo.CurrTrueLabel;
- oldFalseLabel:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left);
location_copy(location,left.location);
newsize:=def_cgsize(resultdef);
@@ -737,20 +732,14 @@ implementation
else
{ may differ in sign, e.g. bytebool -> byte }
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
end;
procedure tjvmtypeconvnode.second_int_to_bool;
var
- hlabel1,hlabel2,oldTrueLabel,oldFalseLabel : tasmlabel;
+ hlabel1,hlabel2: tasmlabel;
newsize : tcgsize;
begin
- oldTrueLabel:=current_procinfo.CurrTrueLabel;
- oldFalseLabel:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left);
if codegenerror then
exit;
@@ -770,8 +759,6 @@ implementation
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
else
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
exit;
end;
@@ -786,8 +773,8 @@ implementation
end;
LOC_JUMP :
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;
else
internalerror(10062);
@@ -805,9 +792,6 @@ implementation
thlcgjvm(hlcg).a_load_const_stack(current_asmdata.CurrAsmList,resultdef,0,R_INTREGISTER);
hlcg.a_label(current_asmdata.CurrAsmList,hlabel2);
thlcgjvm(hlcg).a_load_stack_reg(current_asmdata.CurrAsmList,resultdef,location.register);
-
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
end;
diff --git a/compiler/jvm/njvmmem.pas b/compiler/jvm/njvmmem.pas
index b19f454342..26c00c7b21 100644
--- a/compiler/jvm/njvmmem.pas
+++ b/compiler/jvm/njvmmem.pas
@@ -405,13 +405,9 @@ implementation
procedure tjvmvecnode.pass_generate_code;
var
- otl,ofl: tasmlabel;
psym: tsym;
newsize: tcgsize;
- isjump: boolean;
begin
- otl:=nil;
- ofl:=nil;
if left.resultdef.typ=stringdef then
internalerror(2011052702);
@@ -432,30 +428,18 @@ implementation
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);
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);
+ if (right.expectloc=LOC_JUMP)<>
+ (right.location.loc=LOC_JUMP) then
+ internalerror(2011090501);
{ simplify index location if necessary, since array references support
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.reference.arrayreftype<>art_none)) then
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 }
if (right.resultdef.typ=enumdef) then
begin
diff --git a/compiler/llvm/nllvmcnv.pas b/compiler/llvm/nllvmcnv.pas
index 2bdb6f8229..fabf303861 100644
--- a/compiler/llvm/nllvmcnv.pas
+++ b/compiler/llvm/nllvmcnv.pas
@@ -169,6 +169,8 @@ procedure tllvmtypeconvnode.second_bool_to_int;
procedure tllvmtypeconvnode.second_int_to_bool;
var
+ truelabel,
+ falselabel: tasmlabel;
newsize : tcgsize;
begin
secondpass(left);
@@ -191,17 +193,20 @@ procedure tllvmtypeconvnode.second_int_to_bool;
exit;
end;
- location_reset(location,LOC_JUMP,OS_NO);
case left.location.loc of
LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF,
LOC_CREFERENCE,LOC_REFERENCE,LOC_REGISTER,LOC_CREGISTER:
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;
LOC_JUMP :
begin
- { nothing to do, jumps already go to the right labels }
+ location:=left.location;
end;
else
internalerror(10062);
diff --git a/compiler/m68k/n68kadd.pas b/compiler/m68k/n68kadd.pas
index e71d0f4210..eb7c78ed36 100644
--- a/compiler/m68k/n68kadd.pas
+++ b/compiler/m68k/n68kadd.pas
@@ -375,6 +375,8 @@ implementation
procedure t68kaddnode.second_cmp64bit;
var
+ truelabel,
+ falselabel: tasmlabel;
hlab: tasmlabel;
unsigned : boolean;
href: treference;
@@ -386,12 +388,12 @@ implementation
case nodetype of
ltn,gtn:
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 }
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);
end;
lten,gten:
@@ -401,21 +403,21 @@ implementation
nodetype:=ltn
else
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 }
if nodetype=ltn then
nodetype:=gtn
else
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;
end;
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:
- 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;
@@ -424,30 +426,34 @@ implementation
case nodetype of
ltn,gtn,lten,gten:
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;
equaln:
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;
unequaln:
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;
begin
+ truelabel:=nil;
+ falselabel:=nil;
{ This puts constant operand (if any) to the right }
pass_left_right;
unsigned:=not(is_signed(left.resultdef)) or
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
second compare based on the fact that any unsigned value is >=0 }
@@ -456,8 +462,8 @@ implementation
(lo(right.location.value64)=0) then
begin
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;
diff --git a/compiler/m68k/n68kcnv.pas b/compiler/m68k/n68kcnv.pas
index b9dbbcecfb..0b58981571 100644
--- a/compiler/m68k/n68kcnv.pas
+++ b/compiler/m68k/n68kcnv.pas
@@ -165,16 +165,9 @@ implementation
resflags : tresflags;
opsize : tcgsize;
newsize : tcgsize;
- hlabel,
- oldTrueLabel,
- oldFalseLabel : tasmlabel;
+ hlabel : tasmlabel;
tmpreference : treference;
begin
- oldTrueLabel:=current_procinfo.CurrTrueLabel;
- oldFalseLabel:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
-
secondpass(left);
{ 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)
else
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
exit;
end;
@@ -266,13 +257,13 @@ implementation
location_reset(location,LOC_REGISTER,newsize);
location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
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
cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,1,location.register)
else
cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,-1,location.register);
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_label(current_asmdata.CurrAsmList,hlabel);
end;
@@ -305,8 +296,6 @@ implementation
cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,newsize,location.register,location.register);
end
end;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
end;
diff --git a/compiler/mips/ncpuadd.pas b/compiler/mips/ncpuadd.pas
index f55c89f452..5e438f0c94 100644
--- a/compiler/mips/ncpuadd.pas
+++ b/compiler/mips/ncpuadd.pas
@@ -108,28 +108,33 @@ const
procedure tmipsaddnode.cmp64_lt(left_reg, right_reg: TRegister64;unsigned: boolean);
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;
procedure tmipsaddnode.cmp64_le(left_reg, right_reg: TRegister64;unsigned: boolean);
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;
procedure tmipsaddnode.second_cmp64bit;
var
+ truelabel,
+ falselabel: tasmlabel;
unsigned: boolean;
left_reg,right_reg: TRegister64;
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;
force_reg_left_right(true,true);
@@ -160,15 +165,15 @@ begin
case NodeType of
equaln:
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;
unequaln:
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;
else
if nf_swapped in flags then
diff --git a/compiler/mips/ncpucnv.pas b/compiler/mips/ncpucnv.pas
index fab1cdf0fa..fb928972be 100644
--- a/compiler/mips/ncpucnv.pas
+++ b/compiler/mips/ncpucnv.pas
@@ -195,14 +195,10 @@ procedure tMIPSELtypeconvnode.second_int_to_bool;
var
hreg1, hreg2: tregister;
opsize: tcgsize;
- hlabel, oldtruelabel, oldfalselabel: tasmlabel;
+ hlabel: tasmlabel;
newsize : tcgsize;
href: treference;
begin
- oldtruelabel := current_procinfo.CurrTrueLabel;
- oldfalselabel := current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left);
if codegenerror then
exit;
@@ -220,8 +216,6 @@ begin
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
else
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
exit;
end;
@@ -271,10 +265,10 @@ begin
begin
hreg1 := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
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_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_label(current_asmdata.CurrAsmList, hlabel);
end;
@@ -305,10 +299,6 @@ begin
else
{$endif not cpu64bitalu}
location.Register := hreg1;
-
-
- current_procinfo.CurrTrueLabel := oldtruelabel;
- current_procinfo.CurrFalseLabel := oldfalselabel;
end;
diff --git a/compiler/ncgadd.pas b/compiler/ncgadd.pas
index 914ada6def..59f12c75b3 100644
--- a/compiler/ncgadd.pas
+++ b/compiler/ncgadd.pas
@@ -89,14 +89,9 @@ interface
var
tmpreg : tregister;
{$ifdef x86}
- pushedfpu,
+ pushedfpu : boolean;
{$endif x86}
- isjump : boolean;
- otl,ofl : tasmlabel;
begin
- otl:=nil;
- ofl:=nil;
-
{ calculate the operator which is more difficult }
firstcomplex(self);
@@ -104,26 +99,9 @@ interface
if (left.nodetype=ordconstn) then
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);
if left.location.loc in [LOC_FLAGS,LOC_JUMP] then
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}
{ are too few registers free? }
pushedfpu:=false;
@@ -135,22 +113,9 @@ interface
end;
{$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);
if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
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}
if pushedfpu then
begin
@@ -414,7 +379,7 @@ interface
procedure tcgaddnode.second_addboolean;
var
cgop : TOpCg;
- otl,ofl : tasmlabel;
+ truelabel, falselabel : tasmlabel;
oldflowcontrol : tflowcontrol;
begin
{ 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
(nf_short_bool in flags)) then
begin
- location_reset(location,LOC_JUMP,OS_NO);
case nodetype of
andn :
begin
- otl:=current_procinfo.CurrTrueLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
secondpass(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;
orn :
begin
- ofl:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(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;
else
internalerror(200307044);
@@ -451,7 +413,9 @@ interface
include(flowcontrol,fc_inflowcontrol);
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]);
end
diff --git a/compiler/ncgcal.pas b/compiler/ncgcal.pas
index d3a4963965..c0ff626568 100644
--- a/compiler/ncgcal.pas
+++ b/compiler/ncgcal.pas
@@ -262,8 +262,6 @@ implementation
procedure tcgcallparanode.secondcallparan;
var
href : treference;
- otlabel,
- oflabel : tasmlabel;
pushaddr: boolean;
begin
if not(assigned(parasym)) then
@@ -273,10 +271,6 @@ implementation
a parameter }
if (left.nodetype<>nothingn) then
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
secondpass(fparainit);
secondpass(left);
@@ -373,8 +367,6 @@ implementation
else
push_value_para;
end;
- current_procinfo.CurrTrueLabel:=otlabel;
- current_procinfo.CurrFalseLabel:=oflabel;
{ update return location in callnode when this is the function
result }
diff --git a/compiler/ncgcnv.pas b/compiler/ncgcnv.pas
index 32944385eb..89cf381a82 100644
--- a/compiler/ncgcnv.pas
+++ b/compiler/ncgcnv.pas
@@ -160,13 +160,9 @@ interface
hregister : tregister;
href : treference;
resflags : tresflags;
- hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+ hlabel : tasmlabel;
newsize : tcgsize;
begin
- oldTrueLabel:=current_procinfo.CurrTrueLabel;
- oldFalseLabel:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left);
if codegenerror then
exit;
@@ -189,8 +185,6 @@ interface
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
else
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
exit;
end;
{ though ppc/ppc64 doesn't use the generic code, we need to ifdef here
@@ -247,10 +241,10 @@ interface
begin
hregister:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
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_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_label(current_asmdata.CurrAsmList,hlabel);
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);
if (is_cbool(resultdef)) then
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;
{$endif cpuflags}
@@ -609,12 +601,7 @@ interface
procedure tcgtypeconvnode.second_bool_to_int;
var
newsize: tcgsize;
- oldTrueLabel,oldFalseLabel : tasmlabel;
begin
- oldTrueLabel:=current_procinfo.CurrTrueLabel;
- oldFalseLabel:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left);
location_copy(location,left.location);
newsize:=def_cgsize(resultdef);
@@ -637,8 +624,6 @@ interface
else
{ may differ in sign, e.g. bytebool -> byte }
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
end;
diff --git a/compiler/ncgflw.pas b/compiler/ncgflw.pas
index 0cdc576849..4b2a6fe385 100644
--- a/compiler/ncgflw.pas
+++ b/compiler/ncgflw.pas
@@ -134,7 +134,7 @@ implementation
var
lcont,lbreak,lloop,
oldclabel,oldblabel : tasmlabel;
- otlabel,oflabel : tasmlabel;
+ truelabel,falselabel : tasmlabel;
oldflowcontrol : tflowcontrol;
oldexecutionweight : longint;
begin
@@ -181,28 +181,23 @@ implementation
{$endif OLDREGVARS}
hlcg.a_label(current_asmdata.CurrAsmList,lcont);
- otlabel:=current_procinfo.CurrTrueLabel;
- oflabel:=current_procinfo.CurrFalseLabel;
if lnf_checknegate in loopflags then
- begin
- current_procinfo.CurrTrueLabel:=lbreak;
- current_procinfo.CurrFalseLabel:=lloop;
- end
+ begin
+ truelabel:=lbreak;
+ falselabel:=lloop;
+ end
else
- begin
- current_procinfo.CurrTrueLabel:=lloop;
- current_procinfo.CurrFalseLabel:=lbreak;
- end;
+ begin
+ truelabel:=lloop;
+ falselabel:=lbreak;
+ end;
secondpass(left);
- hlcg.maketojumpbool(current_asmdata.CurrAsmList,left);
+ hlcg.maketojumpboollabels(current_asmdata.CurrAsmList,left,truelabel,falselabel);
hlcg.a_label(current_asmdata.CurrAsmList,lbreak);
sync_regvars(false);
- current_procinfo.CurrTrueLabel:=otlabel;
- current_procinfo.CurrFalseLabel:=oflabel;
-
current_procinfo.CurrContinueLabel:=oldclabel;
current_procinfo.CurrBreakLabel:=oldblabel;
{ a break/continue in a while/repeat block can't be seen outside }
@@ -217,7 +212,7 @@ implementation
procedure tcgifnode.pass_generate_code;
var
- hl,otlabel,oflabel : tasmlabel;
+ hl : tasmlabel;
oldflowcontrol: tflowcontrol;
oldexecutionweight : longint;
(*
@@ -238,10 +233,6 @@ implementation
oldflowcontrol := flowcontrol;
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);
(*
@@ -270,7 +261,7 @@ implementation
if assigned(right) then
begin
- hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+ hlcg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
secondpass(right);
end;
@@ -305,7 +296,7 @@ implementation
;
hlcg.a_jmp_always(current_asmdata.CurrAsmList,hl);
end;
- hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+ hlcg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
secondpass(t1);
(*
{ save current asmlist (previous instructions + else-block) }
@@ -332,11 +323,11 @@ implementation
current_asmdata.CurrAsmList := TAsmList.create;
end;
*)
- hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
+ hlcg.a_label(current_asmdata.CurrAsmList,left.location.falselabel);
end;
if not(assigned(right)) then
begin
- hlcg.a_label(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+ hlcg.a_label(current_asmdata.CurrAsmList,left.location.truelabel);
end;
(*
@@ -376,8 +367,6 @@ implementation
cg.executionweight:=oldexecutionweight;
- current_procinfo.CurrTrueLabel:=otlabel;
- current_procinfo.CurrFalseLabel:=oflabel;
flowcontrol := oldflowcontrol + (flowcontrol - [fc_inflowcontrol]);
end;
@@ -423,8 +412,7 @@ implementation
procedure tcgfornode.pass_generate_code;
var
- l3,oldclabel,oldblabel,
- otl, ofl : tasmlabel;
+ l3,oldclabel,oldblabel : tasmlabel;
temptovalue : boolean;
hop : topcg;
hcond : topcmp;
@@ -433,11 +421,8 @@ implementation
cmp_const:Tconstexprint;
oldflowcontrol : tflowcontrol;
oldexecutionweight : longint;
- isjump: boolean;
begin
location_reset(location,LOC_VOID,OS_NO);
- ofl:=nil;
- otl:=nil;
oldclabel:=current_procinfo.CurrContinueLabel;
oldblabel:=current_procinfo.CurrBreakLabel;
@@ -458,22 +443,9 @@ implementation
}
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);
if t1.location.loc in [LOC_FLAGS,LOC_JUMP] then
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 }
{ load into temporary variable }
if t1.nodetype<>ordconstn then
@@ -491,22 +463,9 @@ implementation
cg.executionweight:=oldexecutionweight;
{ 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);
if right.location.loc in [LOC_FLAGS,LOC_JUMP] then
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);
oldflowcontrol:=flowcontrol;
diff --git a/compiler/ncghlmat.pas b/compiler/ncghlmat.pas
index 7274223d40..6868c5cd65 100644
--- a/compiler/ncghlmat.pas
+++ b/compiler/ncghlmat.pas
@@ -43,7 +43,7 @@ uses
aasmbase,aasmdata,
defutil,
procinfo,
- cgbase,pass_2,hlcgobj;
+ cgbase,cgutils,pass_2,hlcgobj;
{*****************************************************************************
tcghlnotnode
@@ -59,18 +59,11 @@ function tcghlnotnode.pass_1: tnode;
procedure tcghlnotnode.second_boolean;
- var
- hl : tasmlabel;
begin
- hl:=current_procinfo.CurrTrueLabel;
- current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
- current_procinfo.CurrFalseLabel:=hl;
secondpass(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.
diff --git a/compiler/ncgld.pas b/compiler/ncgld.pas
index caeded7691..401eac46c4 100644
--- a/compiler/ncgld.pas
+++ b/compiler/ncgld.pas
@@ -584,7 +584,7 @@ implementation
procedure tcgassignmentnode.pass_generate_code;
var
- otlabel,hlabel,oflabel : tasmlabel;
+ hlabel : tasmlabel;
href : treference;
releaseright : boolean;
alignmentrequirement,
@@ -601,11 +601,6 @@ implementation
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
the most complex code. Exceptions for this are:
@@ -962,7 +957,7 @@ implementation
LOC_JUMP :
begin
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
begin
{$ifndef cpu64bitalu}
@@ -983,7 +978,7 @@ implementation
end;
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}
if left.location.size in [OS_64,OS_S64] then
cg64.a_load64_const_loc(current_asmdata.CurrAsmList,0,left.location)
@@ -1073,9 +1068,6 @@ implementation
if releaseright then
location_freetemp(current_asmdata.CurrAsmList,right.location);
-
- current_procinfo.CurrTrueLabel:=otlabel;
- current_procinfo.CurrFalseLabel:=oflabel;
end;
@@ -1125,8 +1117,6 @@ implementation
href : treference;
lt : tdef;
paraloc : tcgparalocation;
- otlabel,
- oflabel : tasmlabel;
vtype : longint;
eledef: tdef;
elesize : longint;
@@ -1135,8 +1125,6 @@ implementation
freetemp,
dovariant: boolean;
begin
- otlabel:=nil;
- oflabel:=nil;
if is_packed_array(resultdef) then
internalerror(200608042);
dovariant:=
@@ -1175,26 +1163,14 @@ implementation
if assigned(hp.left) then
begin
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);
+ if (hp.left.location.loc=LOC_JUMP)<>
+ (hp.left.expectloc=LOC_JUMP) then
+ internalerror(2007103101);
{ Move flags and jump in register }
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);
- 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
begin
{ find the correct vtype value }
diff --git a/compiler/ncgmat.pas b/compiler/ncgmat.pas
index 96eb16a73d..4626b4d711 100644
--- a/compiler/ncgmat.pas
+++ b/compiler/ncgmat.pas
@@ -609,15 +609,10 @@ implementation
function tcgnotnode.handle_locjump: boolean;
- var
- hl: tasmlabel;
begin
result:=(left.expectloc=LOC_JUMP);
if result then
begin
- hl:=current_procinfo.CurrTrueLabel;
- current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
- current_procinfo.CurrFalseLabel:=hl;
secondpass(left);
if is_constboolnode(left) then
@@ -625,12 +620,8 @@ implementation
if left.location.loc<>LOC_JUMP then
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;
diff --git a/compiler/ncgmem.pas b/compiler/ncgmem.pas
index 91362db09f..82e4a8d0cd 100644
--- a/compiler/ncgmem.pas
+++ b/compiler/ncgmem.pas
@@ -872,12 +872,10 @@ implementation
offsetdec,
extraoffset : aint;
rightp : pnode;
- otl,ofl : tasmlabel;
newsize : tcgsize;
mulsize,
bytemulsize,
alignpow : aint;
- isjump : boolean;
paraloc1,
paraloc2 : tcgpara;
subsetref : tsubsetreference;
@@ -1083,17 +1081,10 @@ implementation
{ calculate from left to right }
if not(location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
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);
+ 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 not(right.location.loc in [LOC_CREGISTER,LOC_REGISTER]) or
@@ -1105,14 +1096,6 @@ implementation
else
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: }
if cs_check_range in current_settings.localswitches then
begin
diff --git a/compiler/ncgset.pas b/compiler/ncgset.pas
index 0d7582ec78..f0000a3630 100644
--- a/compiler/ncgset.pas
+++ b/compiler/ncgset.pas
@@ -241,7 +241,6 @@ implementation
adjustment,
setbase : aint;
l, l2 : tasmlabel;
- otl, ofl : tasmlabel;
hr,
pleftreg : tregister;
setparts : Tsetparts;
@@ -252,14 +251,11 @@ implementation
orgopsize : tcgsize;
orgopdef : tdef;
genjumps,
- use_small,
- isjump : boolean;
+ use_small : boolean;
i,numparts : byte;
needslabel : Boolean;
begin
l2:=nil;
- ofl:=nil;
- otl:=nil;
{ We check first if we can generate jumps, this can be done
because the resultdef is already set in firstpass }
@@ -282,35 +278,17 @@ implementation
end;
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 }
{ 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" and not "swapped left" in that case) }
firstcomplex(self);
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);
{ Only process the right if we are not generating jumps }
@@ -327,7 +305,9 @@ implementation
if genjumps then
begin
{ 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 }
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 }
{ beginning whether stop-start <> 255) }
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
else
{ if setparts[i].start = 0 and setparts[i].stop = 255, }
{ it's always true since "in" is only allowed for bytes }
begin
- hlcg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrTrueLabel);
+ hlcg.a_jmp_always(current_asmdata.CurrAsmList,location.truelabel);
end;
end
else
begin
{ Emit code to check if left is an element }
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;
{ To compensate for not doing a second pass }
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
else
{*****************************************************************}
@@ -935,15 +915,11 @@ implementation
max_label: tconstexprint;
labelcnt : tcgint;
max_linear_list : aint;
- otl, ofl: tasmlabel;
- isjump : boolean;
max_dist,
dist : aword;
oldexecutionweight : longint;
begin
location_reset(location,LOC_VOID,OS_NO);
- ofl:=nil;
- otl:=nil;
oldflowcontrol := flowcontrol;
include(flowcontrol,fc_inflowcontrol);
@@ -967,17 +943,10 @@ implementation
jmp_le:=OC_BE;
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);
+ if (left.expectloc=LOC_JUMP)<>
+ (left.location.loc=LOC_JUMP) then
+ internalerror(2006050501);
{ determines the size of the operand }
opsize:=left.resultdef;
{ copy the case expression to a register }
@@ -991,14 +960,6 @@ implementation
else
{$endif not cpu64bitalu}
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 }
{ cmps and subs/decs }
diff --git a/compiler/ncgutil.pas b/compiler/ncgutil.pas
index a3ef271eb2..a197320d09 100644
--- a/compiler/ncgutil.pas
+++ b/compiler/ncgutil.pas
@@ -57,7 +57,7 @@ interface
}
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 location_force_mmreg(list:TAsmList;var l: tlocation;maybeconst:boolean);
@@ -257,14 +257,9 @@ implementation
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
-
- 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
opsize : tcgsize;
@@ -277,16 +272,12 @@ implementation
current_filepos:=p.fileinfo;
if is_boolean(p.resultdef) then
begin
-{$ifdef OLDREGVARS}
- if loadregvars = lr_load_regvars then
- load_all_regvars(list);
-{$endif OLDREGVARS}
if is_constboolnode(p) then
begin
if Tordconstnode(p).value.uvalue<>0 then
- cg.a_jmp_always(list,current_procinfo.CurrTrueLabel)
+ cg.a_jmp_always(list,truelabel)
else
- cg.a_jmp_always(list,current_procinfo.CurrFalseLabel)
+ cg.a_jmp_always(list,falselabel)
end
else
begin
@@ -297,8 +288,8 @@ implementation
begin
tmpreg := cg.getintregister(list,OS_INT);
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;
LOC_CREGISTER,LOC_REGISTER,LOC_CREFERENCE,LOC_REFERENCE :
begin
@@ -323,17 +314,28 @@ implementation
opsize:=OS_32;
end;
{$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;
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}
LOC_FLAGS :
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_jmp_always(list,current_procinfo.CurrFalseLabel);
+ cg.a_jmp_always(list,falselabel);
end;
{$endif cpuflags}
else
@@ -343,6 +345,7 @@ implementation
end;
end;
end;
+ location_reset_jump(p.location,truelabel,falselabel);
end
else
internalerror(200112305);
diff --git a/compiler/powerpc/nppcadd.pas b/compiler/powerpc/nppcadd.pas
index a1f33a7bcd..e03910da28 100644
--- a/compiler/powerpc/nppcadd.pas
+++ b/compiler/powerpc/nppcadd.pas
@@ -143,6 +143,8 @@ interface
procedure tppcaddnode.second_add64bit;
var
+ truelabel,
+ falselabel : tasmlabel;
op : TOpCG;
op1,op2 : TAsmOp;
cmpop,
@@ -192,10 +194,10 @@ interface
case nodetype of
ltn,gtn:
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 }
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);
end;
lten,gten:
@@ -205,24 +207,24 @@ interface
nodetype:=ltn
else
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 }
if nodetype=ltn then
nodetype:=gtn
else
nodetype:=ltn;
- cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrFalseLabel);
+ cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,falselabel);
nodetype:=oldnodetype;
end;
equaln:
begin
nodetype := unequaln;
- cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrFalseLabel);
+ cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,falselabel);
nodetype := equaln;
end;
unequaln:
begin
- cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,current_procinfo.CurrTrueLabel);
+ cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags,truelabel);
end;
end;
end;
@@ -237,20 +239,20 @@ interface
begin
{ the comparison of the low dword always has }
{ 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;
equaln:
begin
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;
end;
unequaln:
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;
@@ -260,6 +262,8 @@ interface
tempreg64: tregister64;
begin
+ truelabel:=nil;
+ falselabel:=nil;
firstcomplex(self);
pass_left_and_right;
@@ -306,8 +310,16 @@ interface
internalerror(2002072705);
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
(nodetype in [addn,subn])) or (nodetype = muln));
@@ -544,7 +556,7 @@ interface
{ real location only now) (JM) }
if cmpop and
not(nodetype in [equaln,unequaln]) then
- location_reset(location,LOC_JUMP,OS_NO);
+ location_reset_jump(location,truelabel,falselabel);
end;
diff --git a/compiler/powerpc/nppcmat.pas b/compiler/powerpc/nppcmat.pas
index 6d280e4265..0202eccae6 100644
--- a/compiler/powerpc/nppcmat.pas
+++ b/compiler/powerpc/nppcmat.pas
@@ -26,7 +26,7 @@ unit nppcmat;
interface
uses
- node,nmat,ncgmat;
+ node,nmat, ncgmat;
type
tppcmoddivnode = class(tmoddivnode)
diff --git a/compiler/ppcgen/ngppcadd.pas b/compiler/ppcgen/ngppcadd.pas
index 09f3c447aa..4580ee0775 100644
--- a/compiler/ppcgen/ngppcadd.pas
+++ b/compiler/ppcgen/ngppcadd.pas
@@ -193,14 +193,10 @@ implementation
var
cgop : TOpCg;
cgsize : TCgSize;
- cmpop,
- isjump : boolean;
- otl,ofl : tasmlabel;
+ cmpop : boolean;
begin
{ calculate the operator which is more difficult }
firstcomplex(self);
- otl:=nil;
- ofl:=nil;
cmpop:=false;
if (torddef(left.resultdef).ordtype in [pasbool8,bool8bit]) or
@@ -223,43 +219,19 @@ implementation
if left.nodetype in [ordconstn,realconstn] then
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);
+ if (left.expectloc=LOC_JUMP)<>
+ (left.location.loc=LOC_JUMP) then
+ internalerror(2003122901);
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);
- 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);
+ if (right.expectloc=LOC_JUMP)<>
+ (right.location.loc=LOC_JUMP) then
+ internalerror(200312292);
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);
- 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];
diff --git a/compiler/ppcgen/ngppccnv.pas b/compiler/ppcgen/ngppccnv.pas
index 8692fd1c7a..fa997897bf 100644
--- a/compiler/ppcgen/ngppccnv.pas
+++ b/compiler/ppcgen/ngppccnv.pas
@@ -75,13 +75,9 @@ implementation
{$endif not cpu64bitalu}
resflags : tresflags;
opsize : tcgsize;
- hlabel, oldTrueLabel, oldFalseLabel : tasmlabel;
- newsize : tcgsize;
+ hlabel : tasmlabel;
+ newsize : tcgsize;
begin
- oldTrueLabel:=current_procinfo.CurrTrueLabel;
- oldFalseLabel:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left);
if codegenerror then
exit;
@@ -99,8 +95,6 @@ implementation
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
else
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
exit;
end;
@@ -176,13 +170,13 @@ implementation
begin
hreg1:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
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
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hreg1)
else
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,-1,hreg1);
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_label(current_asmdata.CurrAsmList,hlabel);
end;
@@ -204,9 +198,6 @@ implementation
else
{$endif cpu64bitalu}
location.register:=hreg1;
-
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
end;
end.
diff --git a/compiler/procinfo.pas b/compiler/procinfo.pas
index e3b0f64c61..88eca2a4da 100644
--- a/compiler/procinfo.pas
+++ b/compiler/procinfo.pas
@@ -108,9 +108,7 @@ unit procinfo;
{ Labels for TRUE/FALSE condition, BREAK and CONTINUE }
CurrBreakLabel,
- CurrContinueLabel,
- CurrTrueLabel,
- CurrFalseLabel : tasmlabel;
+ CurrContinueLabel : tasmlabel;
{ label to leave the sub routine }
CurrExitLabel : tasmlabel;
@@ -160,12 +158,6 @@ unit procinfo;
{ Destroy the entire procinfo tree, starting from the outermost parent }
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 has_nestedprocs: boolean;
function get_normal_proc: tprocinfo;
@@ -216,8 +208,6 @@ implementation
current_asmdata.getjumplabel(CurrGOTLabel);
CurrBreakLabel:=nil;
CurrContinueLabel:=nil;
- CurrTrueLabel:=nil;
- CurrFalseLabel:=nil;
if Assigned(parent) and (parent.procdef.parast.symtablelevel>=normal_function_level) then
parent.addnestedproc(Self);
end;
@@ -277,20 +267,6 @@ implementation
result:=result.parent;
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);
begin
if size>maxpushedparasize then
diff --git a/compiler/sparc/ncpucnv.pas b/compiler/sparc/ncpucnv.pas
index 34fb0335a3..50ef3d6773 100644
--- a/compiler/sparc/ncpucnv.pas
+++ b/compiler/sparc/ncpucnv.pas
@@ -233,13 +233,9 @@ implementation
hreg1,hreg2 : tregister;
resflags : tresflags;
opsize : tcgsize;
- hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+ hlabel : tasmlabel;
newsize : tcgsize;
begin
- oldTrueLabel:=current_procinfo.CurrTrueLabel;
- oldFalseLabel:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left);
if codegenerror then
exit;
@@ -257,8 +253,6 @@ implementation
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
else
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
exit;
end;
@@ -320,13 +314,13 @@ implementation
begin
hreg1:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
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
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,1,hreg1)
else
cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,-1,hreg1);
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_label(current_asmdata.CurrAsmList,hlabel);
end;
@@ -348,9 +342,6 @@ implementation
else
{$endif not cpu64bitalu}
location.register:=hreg1;
-
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
end;
diff --git a/compiler/x86/nx86cnv.pas b/compiler/x86/nx86cnv.pas
index a4449a6321..8b51b57f54 100644
--- a/compiler/x86/nx86cnv.pas
+++ b/compiler/x86/nx86cnv.pas
@@ -92,13 +92,9 @@ implementation
i : integer;
{$endif not cpu64bitalu}
resflags : tresflags;
- hlabel,oldTrueLabel,oldFalseLabel : tasmlabel;
+ hlabel : tasmlabel;
newsize : tcgsize;
begin
- oldTrueLabel:=current_procinfo.CurrTrueLabel;
- oldFalseLabel:=current_procinfo.CurrFalseLabel;
- current_asmdata.getjumplabel(current_procinfo.CurrTrueLabel);
- current_asmdata.getjumplabel(current_procinfo.CurrFalseLabel);
secondpass(left);
if codegenerror then
exit;
@@ -115,8 +111,6 @@ implementation
hlcg.location_force_reg(current_asmdata.CurrAsmList,location,left.resultdef,resultdef,true)
else
location.size:=newsize;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
exit;
end;
@@ -184,13 +178,13 @@ implementation
location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
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
cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,1,location.register)
else
cg.a_load_const_reg(current_asmdata.CurrAsmList,location.size,-1,location.register);
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_label(current_asmdata.CurrAsmList,hlabel);
end;
@@ -226,8 +220,6 @@ implementation
cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,location.register,location.register);
end
end;
- current_procinfo.CurrTrueLabel:=oldTrueLabel;
- current_procinfo.CurrFalseLabel:=oldFalseLabel;
end;