mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-06-05 20:38:28 +02:00
* converted tcgcasenode.pass_generate_code() to hlcgobj
o changed type of opsize field of tcgcasenode from tcgsize into tdef, and fixed compilation of other code generator units after this change git-svn-id: branches/jvmbackend@18339 -
This commit is contained in:
parent
71b348757b
commit
b023627f6a
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
Copyright (c) 1998-2002 by Florian Klaempfl
|
Copyright (c) 1998-2002 by Florian Klaempfl
|
||||||
|
|
||||||
Generate arm assembler for in set/case nodes
|
Generate arm assembler for in set/case nodes
|
||||||
|
|
||||||
@ -74,6 +74,7 @@ implementation
|
|||||||
indexreg : tregister;
|
indexreg : tregister;
|
||||||
href : treference;
|
href : treference;
|
||||||
tablelabel: TAsmLabel;
|
tablelabel: TAsmLabel;
|
||||||
|
opcgsize : tcgsize;
|
||||||
|
|
||||||
procedure genitem(list:TAsmList;t : pcaselabel);
|
procedure genitem(list:TAsmList;t : pcaselabel);
|
||||||
var
|
var
|
||||||
@ -108,16 +109,17 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
opcgsize:=def_cgsize(opsize);
|
||||||
if not(jumptable_no_range) then
|
if not(jumptable_no_range) then
|
||||||
begin
|
begin
|
||||||
{ case expr less than min_ => goto elselabel }
|
{ case expr less than min_ => goto elselabel }
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,aint(min_),hregister,elselabel);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opcgsize,jmp_lt,aint(min_),hregister,elselabel);
|
||||||
{ case expr greater than max_ => goto elselabel }
|
{ case expr greater than max_ => goto elselabel }
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_gt,aint(max_),hregister,elselabel);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opcgsize,jmp_gt,aint(max_),hregister,elselabel);
|
||||||
end;
|
end;
|
||||||
{ make it a 32bit register }
|
{ make it a 32bit register }
|
||||||
indexreg:=cg.makeregsize(current_asmdata.CurrAsmList,hregister,OS_INT);
|
indexreg:=cg.makeregsize(current_asmdata.CurrAsmList,hregister,OS_INT);
|
||||||
cg.a_load_reg_reg(current_asmdata.CurrAsmList,opsize,OS_INT,hregister,indexreg);
|
cg.a_load_reg_reg(current_asmdata.CurrAsmList,opcgsize,OS_INT,hregister,indexreg);
|
||||||
|
|
||||||
if current_settings.cputype in cpu_thumb2 then
|
if current_settings.cputype in cpu_thumb2 then
|
||||||
begin
|
begin
|
||||||
@ -160,6 +162,7 @@ implementation
|
|||||||
lastrange : boolean;
|
lastrange : boolean;
|
||||||
last : TConstExprInt;
|
last : TConstExprInt;
|
||||||
cond_lt,cond_le : tresflags;
|
cond_lt,cond_le : tresflags;
|
||||||
|
opcgsize : tcgsize;
|
||||||
|
|
||||||
procedure genitem(t : pcaselabel);
|
procedure genitem(t : pcaselabel);
|
||||||
begin
|
begin
|
||||||
@ -168,16 +171,16 @@ implementation
|
|||||||
{ need we to test the first value }
|
{ need we to test the first value }
|
||||||
if first and (t^._low>get_min_value(left.resultdef)) then
|
if first and (t^._low>get_min_value(left.resultdef)) then
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,aint(t^._low.svalue),hregister,elselabel);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opcgsize,jmp_lt,aint(t^._low.svalue),hregister,elselabel);
|
||||||
end;
|
end;
|
||||||
if t^._low=t^._high then
|
if t^._low=t^._high then
|
||||||
begin
|
begin
|
||||||
if t^._low-last=0 then
|
if t^._low-last=0 then
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, OC_EQ,0,hregister,blocklabel(t^.blockid))
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opcgsize, OC_EQ,0,hregister,blocklabel(t^.blockid))
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
tcgarm(cg).cgsetflags:=true;
|
tcgarm(cg).cgsetflags:=true;
|
||||||
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opsize, aint(int64(t^._low-last)), hregister);
|
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, aint(int64(t^._low-last)), hregister);
|
||||||
tcgarm(cg).cgsetflags:=false;
|
tcgarm(cg).cgsetflags:=false;
|
||||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,F_EQ,blocklabel(t^.blockid));
|
cg.a_jmp_flags(current_asmdata.CurrAsmList,F_EQ,blocklabel(t^.blockid));
|
||||||
end;
|
end;
|
||||||
@ -195,7 +198,7 @@ implementation
|
|||||||
if (t^._low>get_min_value(left.resultdef)) or (get_min_value(left.resultdef)<>0) then
|
if (t^._low>get_min_value(left.resultdef)) or (get_min_value(left.resultdef)<>0) then
|
||||||
begin
|
begin
|
||||||
tcgarm(cg).cgsetflags:=true;
|
tcgarm(cg).cgsetflags:=true;
|
||||||
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opsize, aint(int64(t^._low)), hregister);
|
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, aint(int64(t^._low)), hregister);
|
||||||
tcgarm(cg).cgsetflags:=false;
|
tcgarm(cg).cgsetflags:=false;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
@ -206,7 +209,7 @@ implementation
|
|||||||
{ immediately. else check the range in between: }
|
{ immediately. else check the range in between: }
|
||||||
|
|
||||||
tcgarm(cg).cgsetflags:=true;
|
tcgarm(cg).cgsetflags:=true;
|
||||||
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opsize, aint(int64(t^._low-last)), hregister);
|
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, aint(int64(t^._low-last)), hregister);
|
||||||
tcgarm(cg).cgsetflags:=false;
|
tcgarm(cg).cgsetflags:=false;
|
||||||
{ no jump necessary here if the new range starts at }
|
{ no jump necessary here if the new range starts at }
|
||||||
{ at the value following the previous one }
|
{ at the value following the previous one }
|
||||||
@ -215,7 +218,7 @@ implementation
|
|||||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_lt,elselabel);
|
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_lt,elselabel);
|
||||||
end;
|
end;
|
||||||
tcgarm(cg).cgsetflags:=true;
|
tcgarm(cg).cgsetflags:=true;
|
||||||
cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SUB,opsize,aint(int64(t^._high-t^._low)),hregister);
|
cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SUB,opcgsize,aint(int64(t^._high-t^._low)),hregister);
|
||||||
tcgarm(cg).cgsetflags:=false;
|
tcgarm(cg).cgsetflags:=false;
|
||||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_le,blocklabel(t^.blockid));
|
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_le,blocklabel(t^.blockid));
|
||||||
|
|
||||||
@ -228,6 +231,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
opcgsize:=def_cgsize(opsize);
|
||||||
if with_sign then
|
if with_sign then
|
||||||
begin
|
begin
|
||||||
cond_lt:=F_LT;
|
cond_lt:=F_LT;
|
||||||
|
@ -74,23 +74,25 @@ implementation
|
|||||||
lastrange : boolean;
|
lastrange : boolean;
|
||||||
last : TConstExprInt;
|
last : TConstExprInt;
|
||||||
cond_lt,cond_le : tresflags;
|
cond_lt,cond_le : tresflags;
|
||||||
|
opcgsize: tcgsize;
|
||||||
|
|
||||||
procedure genitem(t : pcaselabel);
|
procedure genitem(t : pcaselabel);
|
||||||
begin
|
begin
|
||||||
|
opcgsize:=def_cgsize(opsize);
|
||||||
if assigned(t^.less) then
|
if assigned(t^.less) then
|
||||||
genitem(t^.less);
|
genitem(t^.less);
|
||||||
{ need we to test the first value }
|
{ need we to test the first value }
|
||||||
if first and (t^._low>get_min_value(left.resultdef)) then
|
if first and (t^._low>get_min_value(left.resultdef)) then
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,aint(t^._low.svalue),hregister,elselabel);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opcgsize,jmp_lt,aint(t^._low.svalue),hregister,elselabel);
|
||||||
end;
|
end;
|
||||||
if t^._low=t^._high then
|
if t^._low=t^._high then
|
||||||
begin
|
begin
|
||||||
if t^._low-last=0 then
|
if t^._low-last=0 then
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, OC_EQ,0,hregister,blocklabel(t^.blockid))
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opcgsize, OC_EQ,0,hregister,blocklabel(t^.blockid))
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opsize, aint(t^._low.svalue-last.svalue), hregister);
|
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, aint(t^._low.svalue-last.svalue), hregister);
|
||||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,F_E,blocklabel(t^.blockid));
|
cg.a_jmp_flags(current_asmdata.CurrAsmList,F_E,blocklabel(t^.blockid));
|
||||||
end;
|
end;
|
||||||
last:=t^._low;
|
last:=t^._low;
|
||||||
@ -105,7 +107,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
{ have we to ajust the first value ? }
|
{ have we to ajust the first value ? }
|
||||||
if (t^._low>get_min_value(left.resultdef)) or (get_min_value(left.resultdef)<>0) then
|
if (t^._low>get_min_value(left.resultdef)) or (get_min_value(left.resultdef)<>0) then
|
||||||
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opsize, aint(t^._low.svalue), hregister);
|
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, aint(t^._low.svalue), hregister);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -113,7 +115,7 @@ implementation
|
|||||||
{ present label then the lower limit can be checked }
|
{ present label then the lower limit can be checked }
|
||||||
{ immediately. else check the range in between: }
|
{ immediately. else check the range in between: }
|
||||||
|
|
||||||
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opsize, aint(t^._low.svalue-last.svalue), hregister);
|
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opcgsize, aint(t^._low.svalue-last.svalue), hregister);
|
||||||
{ no jump necessary here if the new range starts at }
|
{ no jump necessary here if the new range starts at }
|
||||||
{ at the value following the previous one }
|
{ at the value following the previous one }
|
||||||
if ((t^._low-last) <> 1) or
|
if ((t^._low-last) <> 1) or
|
||||||
@ -122,7 +124,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
{we need to use A_SUB, because A_DEC does not set the correct flags, therefor
|
{we need to use A_SUB, because A_DEC does not set the correct flags, therefor
|
||||||
using a_op_const_reg(OP_SUB) is not possible }
|
using a_op_const_reg(OP_SUB) is not possible }
|
||||||
emit_const_reg(A_SUB,TCGSize2OpSize[opsize],aint(t^._high.svalue-t^._low.svalue),hregister);
|
emit_const_reg(A_SUB,TCGSize2OpSize[opcgsize],aint(t^._high.svalue-t^._low.svalue),hregister);
|
||||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_le,blocklabel(t^.blockid));
|
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_le,blocklabel(t^.blockid));
|
||||||
last:=t^._high;
|
last:=t^._high;
|
||||||
lastrange:=true;
|
lastrange:=true;
|
||||||
|
@ -48,7 +48,7 @@ uses
|
|||||||
cpubase,
|
cpubase,
|
||||||
aasmbase, aasmtai, aasmcpu, aasmdata,
|
aasmbase, aasmtai, aasmcpu, aasmdata,
|
||||||
cgbase, cgutils, cgobj,
|
cgbase, cgutils, cgobj,
|
||||||
procinfo;
|
defutil,procinfo;
|
||||||
|
|
||||||
procedure tcpucasenode.optimizevalues(var max_linear_list: aint; var max_dist: aword);
|
procedure tcpucasenode.optimizevalues(var max_linear_list: aint; var max_dist: aword);
|
||||||
begin
|
begin
|
||||||
@ -70,6 +70,7 @@ var
|
|||||||
indexreg, jmpreg, basereg: tregister;
|
indexreg, jmpreg, basereg: tregister;
|
||||||
href: treference;
|
href: treference;
|
||||||
jumpsegment: TAsmlist;
|
jumpsegment: TAsmlist;
|
||||||
|
opcgsize: tcgsize;
|
||||||
|
|
||||||
procedure genitem(t: pcaselabel);
|
procedure genitem(t: pcaselabel);
|
||||||
var
|
var
|
||||||
@ -88,13 +89,14 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
opcgsize:=def_cgsize(opsize);
|
||||||
jumpsegment := current_procinfo.aktlocaldata;
|
jumpsegment := current_procinfo.aktlocaldata;
|
||||||
if not (jumptable_no_range) then
|
if not (jumptable_no_range) then
|
||||||
begin
|
begin
|
||||||
{ case expr less than min_ => goto elselabel }
|
{ case expr less than min_ => goto elselabel }
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, jmp_lt, aint(min_), hregister, elselabel);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opcgsize, jmp_lt, aint(min_), hregister, elselabel);
|
||||||
{ case expr greater than max_ => goto elselabel }
|
{ case expr greater than max_ => goto elselabel }
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, jmp_gt, aint(max_), hregister, elselabel);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opcgsize, jmp_gt, aint(max_), hregister, elselabel);
|
||||||
end;
|
end;
|
||||||
current_asmdata.getjumplabel(table);
|
current_asmdata.getjumplabel(table);
|
||||||
indexreg := cg.getaddressregister(current_asmdata.CurrAsmList);
|
indexreg := cg.getaddressregister(current_asmdata.CurrAsmList);
|
||||||
|
@ -26,7 +26,7 @@ unit ncgset;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
globtype,globals,constexp,
|
globtype,globals,constexp,symtype,
|
||||||
node,nset,cpubase,cgbase,cgutils,cgobj,aasmbase,aasmtai,aasmdata;
|
node,nset,cpubase,cgbase,cgutils,cgobj,aasmbase,aasmtai,aasmdata;
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -59,7 +59,7 @@ interface
|
|||||||
|
|
||||||
protected
|
protected
|
||||||
with_sign : boolean;
|
with_sign : boolean;
|
||||||
opsize : tcgsize;
|
opsize : tdef;
|
||||||
jmp_gt,jmp_lt,jmp_le : topcmp;
|
jmp_gt,jmp_lt,jmp_le : topcmp;
|
||||||
{ register with case expression }
|
{ register with case expression }
|
||||||
hregister,hregister2 : tregister;
|
hregister,hregister2 : tregister;
|
||||||
@ -88,7 +88,7 @@ implementation
|
|||||||
paramgr,
|
paramgr,
|
||||||
procinfo,pass_2,tgobj,
|
procinfo,pass_2,tgobj,
|
||||||
nbas,ncon,nflw,
|
nbas,ncon,nflw,
|
||||||
ncgutil;
|
ncgutil,hlcgobj;
|
||||||
|
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
@ -511,8 +511,8 @@ implementation
|
|||||||
to move the result before subtract to help
|
to move the result before subtract to help
|
||||||
the register allocator
|
the register allocator
|
||||||
}
|
}
|
||||||
cg.a_load_reg_reg(current_asmdata.CurrAsmList, opsize, opsize, hregister, scratch_reg);
|
hlcg.a_load_reg_reg(current_asmdata.CurrAsmList, opsize, opsize, hregister, scratch_reg);
|
||||||
cg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opsize, value, hregister);
|
hlcg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opsize, value, hregister);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -520,15 +520,15 @@ implementation
|
|||||||
genitem(t^.less);
|
genitem(t^.less);
|
||||||
{ do we need to test the first value? }
|
{ do we need to test the first value? }
|
||||||
if first and (t^._low>get_min_value(left.resultdef)) then
|
if first and (t^._low>get_min_value(left.resultdef)) then
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,aint(t^._low.svalue),hregister,elselabel);
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,aint(t^._low.svalue),hregister,elselabel);
|
||||||
if t^._low=t^._high then
|
if t^._low=t^._high then
|
||||||
begin
|
begin
|
||||||
if t^._low-last=0 then
|
if t^._low-last=0 then
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,OC_EQ,0,hregister,blocklabel(t^.blockid))
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,OC_EQ,0,hregister,blocklabel(t^.blockid))
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
gensub(aint(t^._low.svalue-last.svalue));
|
gensub(aint(t^._low.svalue-last.svalue));
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,
|
||||||
OC_EQ,aint(t^._low.svalue-last.svalue),scratch_reg,blocklabel(t^.blockid));
|
OC_EQ,aint(t^._low.svalue-last.svalue),scratch_reg,blocklabel(t^.blockid));
|
||||||
end;
|
end;
|
||||||
last:=t^._low;
|
last:=t^._low;
|
||||||
@ -550,10 +550,10 @@ implementation
|
|||||||
{ present label then the lower limit can be checked }
|
{ present label then the lower limit can be checked }
|
||||||
{ immediately. else check the range in between: }
|
{ immediately. else check the range in between: }
|
||||||
gensub(aint(t^._low.svalue-last.svalue));
|
gensub(aint(t^._low.svalue-last.svalue));
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize,jmp_lt,aint(t^._low.svalue-last.svalue),scratch_reg,elselabel);
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize,jmp_lt,aint(t^._low.svalue-last.svalue),scratch_reg,elselabel);
|
||||||
end;
|
end;
|
||||||
gensub(aint(t^._high.svalue-t^._low.svalue));
|
gensub(aint(t^._high.svalue-t^._low.svalue));
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_le,aint(t^._high.svalue-t^._low.svalue),scratch_reg,blocklabel(t^.blockid));
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_le,aint(t^._high.svalue-t^._low.svalue),scratch_reg,blocklabel(t^.blockid));
|
||||||
last:=t^._high;
|
last:=t^._high;
|
||||||
end;
|
end;
|
||||||
first:=false;
|
first:=false;
|
||||||
@ -569,9 +569,9 @@ implementation
|
|||||||
begin
|
begin
|
||||||
last:=0;
|
last:=0;
|
||||||
first:=true;
|
first:=true;
|
||||||
scratch_reg:=cg.getintregister(current_asmdata.CurrAsmList,opsize);
|
scratch_reg:=hlcg.getintregister(current_asmdata.CurrAsmList,opsize);
|
||||||
genitem(hp);
|
genitem(hp);
|
||||||
cg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);
|
hlcg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -595,7 +595,7 @@ implementation
|
|||||||
if t^._low=t^._high then
|
if t^._low=t^._high then
|
||||||
begin
|
begin
|
||||||
{$ifndef cpu64bitalu}
|
{$ifndef cpu64bitalu}
|
||||||
if opsize in [OS_S64,OS_64] then
|
if def_cgsize(opsize) in [OS_S64,OS_64] then
|
||||||
begin
|
begin
|
||||||
current_asmdata.getjumplabel(l1);
|
current_asmdata.getjumplabel(l1);
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, OS_32, OC_NE, aint(hi(int64(t^._low.svalue))),hregister2,l1);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, OS_32, OC_NE, aint(hi(int64(t^._low.svalue))),hregister2,l1);
|
||||||
@ -605,7 +605,7 @@ implementation
|
|||||||
else
|
else
|
||||||
{$endif not cpu64bitalu}
|
{$endif not cpu64bitalu}
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, OC_EQ, aint(t^._low.svalue),hregister, blocklabel(t^.blockid));
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, OC_EQ, aint(t^._low.svalue),hregister, blocklabel(t^.blockid));
|
||||||
end;
|
end;
|
||||||
{ Reset last here, because we've only checked for one value and need to compare
|
{ Reset last here, because we've only checked for one value and need to compare
|
||||||
for the next range both the lower and upper bound }
|
for the next range both the lower and upper bound }
|
||||||
@ -619,7 +619,7 @@ implementation
|
|||||||
if not lastwasrange or (t^._low-last>1) then
|
if not lastwasrange or (t^._low-last>1) then
|
||||||
begin
|
begin
|
||||||
{$ifndef cpu64bitalu}
|
{$ifndef cpu64bitalu}
|
||||||
if opsize in [OS_64,OS_S64] then
|
if def_cgsize(opsize) in [OS_64,OS_S64] then
|
||||||
begin
|
begin
|
||||||
current_asmdata.getjumplabel(l1);
|
current_asmdata.getjumplabel(l1);
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, OS_32, jmp_lt, aint(hi(int64(t^._low.svalue))),
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, OS_32, jmp_lt, aint(hi(int64(t^._low.svalue))),
|
||||||
@ -633,12 +633,12 @@ implementation
|
|||||||
else
|
else
|
||||||
{$endif not cpu64bitalu}
|
{$endif not cpu64bitalu}
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, jmp_lt, aint(t^._low.svalue), hregister,
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, jmp_lt, aint(t^._low.svalue), hregister,
|
||||||
elselabel);
|
elselabel);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$ifndef cpu64bitalu}
|
{$ifndef cpu64bitalu}
|
||||||
if opsize in [OS_S64,OS_64] then
|
if def_cgsize(opsize) in [OS_S64,OS_64] then
|
||||||
begin
|
begin
|
||||||
current_asmdata.getjumplabel(l1);
|
current_asmdata.getjumplabel(l1);
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, OS_32, jmp_lt, aint(hi(int64(t^._high.svalue))), hregister2,
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, OS_32, jmp_lt, aint(hi(int64(t^._high.svalue))), hregister2,
|
||||||
@ -651,7 +651,7 @@ implementation
|
|||||||
else
|
else
|
||||||
{$endif not cpu64bitalu}
|
{$endif not cpu64bitalu}
|
||||||
begin
|
begin
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, jmp_le, aint(t^._high.svalue), hregister, blocklabel(t^.blockid));
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList, opsize, jmp_le, aint(t^._high.svalue), hregister, blocklabel(t^.blockid));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
last:=t^._high;
|
last:=t^._high;
|
||||||
@ -665,7 +665,7 @@ implementation
|
|||||||
last:=0;
|
last:=0;
|
||||||
lastwasrange:=false;
|
lastwasrange:=false;
|
||||||
genitem(hp);
|
genitem(hp);
|
||||||
cg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);
|
hlcg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -720,11 +720,11 @@ implementation
|
|||||||
end;
|
end;
|
||||||
secondpass(left);
|
secondpass(left);
|
||||||
{ determines the size of the operand }
|
{ determines the size of the operand }
|
||||||
opsize:=def_cgsize(left.resultdef);
|
opsize:=left.resultdef;
|
||||||
{ copy the case expression to a register }
|
{ copy the case expression to a register }
|
||||||
location_force_reg(current_asmdata.CurrAsmList,left.location,opsize,false);
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,opsize,false);
|
||||||
{$ifndef cpu64bitalu}
|
{$ifndef cpu64bitalu}
|
||||||
if opsize in [OS_S64,OS_64] then
|
if def_cgsize(opsize) in [OS_S64,OS_64] then
|
||||||
begin
|
begin
|
||||||
hregister:=left.location.register64.reglo;
|
hregister:=left.location.register64.reglo;
|
||||||
hregister2:=left.location.register64.reghi;
|
hregister2:=left.location.register64.reghi;
|
||||||
@ -750,7 +750,7 @@ implementation
|
|||||||
load_all_regvars(current_asmdata.CurrAsmList);
|
load_all_regvars(current_asmdata.CurrAsmList);
|
||||||
{$endif OLDREGVARS}
|
{$endif OLDREGVARS}
|
||||||
{$ifndef cpu64bitalu}
|
{$ifndef cpu64bitalu}
|
||||||
if opsize in [OS_64,OS_S64] then
|
if def_cgsize(opsize) in [OS_64,OS_S64] then
|
||||||
genlinearcmplist(labels)
|
genlinearcmplist(labels)
|
||||||
else
|
else
|
||||||
{$endif not cpu64bitalu}
|
{$endif not cpu64bitalu}
|
||||||
@ -847,11 +847,11 @@ implementation
|
|||||||
{$ifdef OLDREGVARS}
|
{$ifdef OLDREGVARS}
|
||||||
load_all_regvars(current_asmdata.CurrAsmList);
|
load_all_regvars(current_asmdata.CurrAsmList);
|
||||||
{$endif OLDREGVARS}
|
{$endif OLDREGVARS}
|
||||||
cg.a_jmp_always(current_asmdata.CurrAsmList,endlabel);
|
hlcg.a_jmp_always(current_asmdata.CurrAsmList,endlabel);
|
||||||
end;
|
end;
|
||||||
current_asmdata.CurrAsmList.concat(cai_align.create(current_settings.alignment.jumpalign));
|
current_asmdata.CurrAsmList.concat(cai_align.create(current_settings.alignment.jumpalign));
|
||||||
{ ...and the else block }
|
{ ...and the else block }
|
||||||
cg.a_label(current_asmdata.CurrAsmList,elselabel);
|
hlcg.a_label(current_asmdata.CurrAsmList,elselabel);
|
||||||
if assigned(elseblock) then
|
if assigned(elseblock) then
|
||||||
begin
|
begin
|
||||||
secondpass(elseblock);
|
secondpass(elseblock);
|
||||||
@ -863,7 +863,7 @@ implementation
|
|||||||
cg.executionweight:=oldexecutionweight;
|
cg.executionweight:=oldexecutionweight;
|
||||||
|
|
||||||
current_asmdata.CurrAsmList.concat(cai_align.create(current_settings.alignment.jumpalign));
|
current_asmdata.CurrAsmList.concat(cai_align.create(current_settings.alignment.jumpalign));
|
||||||
cg.a_label(current_asmdata.CurrAsmList,endlabel);
|
hlcg.a_label(current_asmdata.CurrAsmList,endlabel);
|
||||||
|
|
||||||
{ Reset labels }
|
{ Reset labels }
|
||||||
for i:=0 to blocks.count-1 do
|
for i:=0 to blocks.count-1 do
|
||||||
|
@ -107,7 +107,7 @@ implementation
|
|||||||
// allocate base and index registers register
|
// allocate base and index registers register
|
||||||
indexreg:= cg.makeregsize(current_asmdata.CurrAsmList, hregister, OS_INT);
|
indexreg:= cg.makeregsize(current_asmdata.CurrAsmList, hregister, OS_INT);
|
||||||
{ indexreg := hregister; }
|
{ indexreg := hregister; }
|
||||||
cg.a_load_reg_reg(current_asmdata.CurrAsmList, opsize, OS_INT, hregister, indexreg);
|
cg.a_load_reg_reg(current_asmdata.CurrAsmList, def_cgsize(opsize), OS_INT, hregister, indexreg);
|
||||||
if not(jumptable_no_range) then
|
if not(jumptable_no_range) then
|
||||||
begin
|
begin
|
||||||
{ use aword(value-min)<aword(max-min) instead of two comparisons }
|
{ use aword(value-min)<aword(max-min) instead of two comparisons }
|
||||||
@ -225,7 +225,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
{ do we need to generate cmps? }
|
{ do we need to generate cmps? }
|
||||||
if (with_sign and (min_label<0)) or
|
if (with_sign and (min_label<0)) or
|
||||||
(opsize in [OS_32,OS_64,OS_S64]) then
|
(def_cgsize(opsize) in [OS_32,OS_64,OS_S64]) then
|
||||||
genlinearcmplist(hp)
|
genlinearcmplist(hp)
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
@ -47,7 +47,7 @@ unit ncpuset;
|
|||||||
cpubase,
|
cpubase,
|
||||||
aasmbase,aasmtai,aasmdata,aasmcpu,
|
aasmbase,aasmtai,aasmdata,aasmcpu,
|
||||||
cgbase,cgutils,cgobj,
|
cgbase,cgutils,cgobj,
|
||||||
procinfo;
|
defutil,procinfo;
|
||||||
|
|
||||||
procedure tcpucasenode.optimizevalues(var max_linear_list:aint;var max_dist:aword);
|
procedure tcpucasenode.optimizevalues(var max_linear_list:aint;var max_dist:aword);
|
||||||
begin
|
begin
|
||||||
@ -68,6 +68,7 @@ unit ncpuset;
|
|||||||
last : TConstExprInt;
|
last : TConstExprInt;
|
||||||
indexreg,jmpreg,basereg : tregister;
|
indexreg,jmpreg,basereg : tregister;
|
||||||
href : treference;
|
href : treference;
|
||||||
|
opcgsize : tcgsize;
|
||||||
|
|
||||||
procedure genitem(list:TAsmList;t : pcaselabel);
|
procedure genitem(list:TAsmList;t : pcaselabel);
|
||||||
var
|
var
|
||||||
@ -86,12 +87,13 @@ unit ncpuset;
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
opcgsize:=def_cgsize(opsize);
|
||||||
if not(jumptable_no_range) then
|
if not(jumptable_no_range) then
|
||||||
begin
|
begin
|
||||||
{ case expr less than min_ => goto elselabel }
|
{ case expr less than min_ => goto elselabel }
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_lt,aint(min_),hregister,elselabel);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opcgsize,jmp_lt,aint(min_),hregister,elselabel);
|
||||||
{ case expr greater than max_ => goto elselabel }
|
{ case expr greater than max_ => goto elselabel }
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,jmp_gt,aint(max_),hregister,elselabel);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opcgsize,jmp_gt,aint(max_),hregister,elselabel);
|
||||||
end;
|
end;
|
||||||
current_asmdata.getjumplabel(table);
|
current_asmdata.getjumplabel(table);
|
||||||
indexreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
|
indexreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
|
||||||
|
@ -89,6 +89,7 @@ implementation
|
|||||||
href : treference;
|
href : treference;
|
||||||
jtlist: tasmlist;
|
jtlist: tasmlist;
|
||||||
sectype: TAsmSectiontype;
|
sectype: TAsmSectiontype;
|
||||||
|
opcgsize: tcgsize;
|
||||||
|
|
||||||
procedure genitem(list:TAsmList;t : pcaselabel);
|
procedure genitem(list:TAsmList;t : pcaselabel);
|
||||||
var
|
var
|
||||||
@ -116,18 +117,19 @@ implementation
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
last:=min_;
|
last:=min_;
|
||||||
|
opcgsize:=def_cgsize(opsize);
|
||||||
if not(jumptable_no_range) then
|
if not(jumptable_no_range) then
|
||||||
begin
|
begin
|
||||||
{ a <= x <= b <-> unsigned(x-a) <= (b-a) }
|
{ a <= x <= b <-> unsigned(x-a) <= (b-a) }
|
||||||
cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SUB,opsize,aint(min_),hregister);
|
cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SUB,opcgsize,aint(min_),hregister);
|
||||||
{ case expr greater than max_ => goto elselabel }
|
{ case expr greater than max_ => goto elselabel }
|
||||||
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opsize,OC_A,aint(max_)-aint(min_),hregister,elselabel);
|
cg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,opcgsize,OC_A,aint(max_)-aint(min_),hregister,elselabel);
|
||||||
min_:=0;
|
min_:=0;
|
||||||
end;
|
end;
|
||||||
current_asmdata.getdatalabel(table);
|
current_asmdata.getdatalabel(table);
|
||||||
{ make it a 32bit register }
|
{ make it a 32bit register }
|
||||||
indexreg:=cg.makeregsize(current_asmdata.CurrAsmList,hregister,OS_INT);
|
indexreg:=cg.makeregsize(current_asmdata.CurrAsmList,hregister,OS_INT);
|
||||||
cg.a_load_reg_reg(current_asmdata.CurrAsmList,opsize,OS_INT,hregister,indexreg);
|
cg.a_load_reg_reg(current_asmdata.CurrAsmList,opcgsize,OS_INT,hregister,indexreg);
|
||||||
{ create reference }
|
{ create reference }
|
||||||
reference_reset_symbol(href,table,0,sizeof(pint));
|
reference_reset_symbol(href,table,0,sizeof(pint));
|
||||||
href.offset:=(-aint(min_))*sizeof(aint);
|
href.offset:=(-aint(min_))*sizeof(aint);
|
||||||
|
Loading…
Reference in New Issue
Block a user