mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-05-30 19:22:34 +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
|
||||
|
||||
@ -74,6 +74,7 @@ implementation
|
||||
indexreg : tregister;
|
||||
href : treference;
|
||||
tablelabel: TAsmLabel;
|
||||
opcgsize : tcgsize;
|
||||
|
||||
procedure genitem(list:TAsmList;t : pcaselabel);
|
||||
var
|
||||
@ -108,16 +109,17 @@ implementation
|
||||
end;
|
||||
|
||||
begin
|
||||
opcgsize:=def_cgsize(opsize);
|
||||
if not(jumptable_no_range) then
|
||||
begin
|
||||
{ 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 }
|
||||
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;
|
||||
{ make it a 32bit register }
|
||||
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
|
||||
begin
|
||||
@ -160,6 +162,7 @@ implementation
|
||||
lastrange : boolean;
|
||||
last : TConstExprInt;
|
||||
cond_lt,cond_le : tresflags;
|
||||
opcgsize : tcgsize;
|
||||
|
||||
procedure genitem(t : pcaselabel);
|
||||
begin
|
||||
@ -168,16 +171,16 @@ implementation
|
||||
{ need we to test the first value }
|
||||
if first and (t^._low>get_min_value(left.resultdef)) then
|
||||
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;
|
||||
if t^._low=t^._high then
|
||||
begin
|
||||
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
|
||||
begin
|
||||
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;
|
||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,F_EQ,blocklabel(t^.blockid));
|
||||
end;
|
||||
@ -195,7 +198,7 @@ implementation
|
||||
if (t^._low>get_min_value(left.resultdef)) or (get_min_value(left.resultdef)<>0) then
|
||||
begin
|
||||
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;
|
||||
end;
|
||||
end
|
||||
@ -206,7 +209,7 @@ implementation
|
||||
{ immediately. else check the range in between: }
|
||||
|
||||
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;
|
||||
{ no jump necessary here if the new range starts at }
|
||||
{ at the value following the previous one }
|
||||
@ -215,7 +218,7 @@ implementation
|
||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_lt,elselabel);
|
||||
end;
|
||||
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;
|
||||
cg.a_jmp_flags(current_asmdata.CurrAsmList,cond_le,blocklabel(t^.blockid));
|
||||
|
||||
@ -228,6 +231,7 @@ implementation
|
||||
end;
|
||||
|
||||
begin
|
||||
opcgsize:=def_cgsize(opsize);
|
||||
if with_sign then
|
||||
begin
|
||||
cond_lt:=F_LT;
|
||||
|
@ -74,23 +74,25 @@ implementation
|
||||
lastrange : boolean;
|
||||
last : TConstExprInt;
|
||||
cond_lt,cond_le : tresflags;
|
||||
opcgsize: tcgsize;
|
||||
|
||||
procedure genitem(t : pcaselabel);
|
||||
begin
|
||||
opcgsize:=def_cgsize(opsize);
|
||||
if assigned(t^.less) then
|
||||
genitem(t^.less);
|
||||
{ need we to test the first value }
|
||||
if first and (t^._low>get_min_value(left.resultdef)) then
|
||||
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;
|
||||
if t^._low=t^._high then
|
||||
begin
|
||||
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
|
||||
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));
|
||||
end;
|
||||
last:=t^._low;
|
||||
@ -105,7 +107,7 @@ implementation
|
||||
begin
|
||||
{ have we to ajust the first value ? }
|
||||
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
|
||||
else
|
||||
begin
|
||||
@ -113,7 +115,7 @@ implementation
|
||||
{ present label then the lower limit can be checked }
|
||||
{ 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 }
|
||||
{ at the value following the previous one }
|
||||
if ((t^._low-last) <> 1) or
|
||||
@ -122,7 +124,7 @@ implementation
|
||||
end;
|
||||
{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 }
|
||||
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));
|
||||
last:=t^._high;
|
||||
lastrange:=true;
|
||||
|
@ -48,7 +48,7 @@ uses
|
||||
cpubase,
|
||||
aasmbase, aasmtai, aasmcpu, aasmdata,
|
||||
cgbase, cgutils, cgobj,
|
||||
procinfo;
|
||||
defutil,procinfo;
|
||||
|
||||
procedure tcpucasenode.optimizevalues(var max_linear_list: aint; var max_dist: aword);
|
||||
begin
|
||||
@ -70,6 +70,7 @@ var
|
||||
indexreg, jmpreg, basereg: tregister;
|
||||
href: treference;
|
||||
jumpsegment: TAsmlist;
|
||||
opcgsize: tcgsize;
|
||||
|
||||
procedure genitem(t: pcaselabel);
|
||||
var
|
||||
@ -88,13 +89,14 @@ var
|
||||
end;
|
||||
|
||||
begin
|
||||
opcgsize:=def_cgsize(opsize);
|
||||
jumpsegment := current_procinfo.aktlocaldata;
|
||||
if not (jumptable_no_range) then
|
||||
begin
|
||||
{ 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 }
|
||||
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;
|
||||
current_asmdata.getjumplabel(table);
|
||||
indexreg := cg.getaddressregister(current_asmdata.CurrAsmList);
|
||||
|
@ -26,7 +26,7 @@ unit ncgset;
|
||||
interface
|
||||
|
||||
uses
|
||||
globtype,globals,constexp,
|
||||
globtype,globals,constexp,symtype,
|
||||
node,nset,cpubase,cgbase,cgutils,cgobj,aasmbase,aasmtai,aasmdata;
|
||||
|
||||
type
|
||||
@ -59,7 +59,7 @@ interface
|
||||
|
||||
protected
|
||||
with_sign : boolean;
|
||||
opsize : tcgsize;
|
||||
opsize : tdef;
|
||||
jmp_gt,jmp_lt,jmp_le : topcmp;
|
||||
{ register with case expression }
|
||||
hregister,hregister2 : tregister;
|
||||
@ -88,7 +88,7 @@ implementation
|
||||
paramgr,
|
||||
procinfo,pass_2,tgobj,
|
||||
nbas,ncon,nflw,
|
||||
ncgutil;
|
||||
ncgutil,hlcgobj;
|
||||
|
||||
|
||||
{*****************************************************************************
|
||||
@ -511,8 +511,8 @@ implementation
|
||||
to move the result before subtract to help
|
||||
the register allocator
|
||||
}
|
||||
cg.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_load_reg_reg(current_asmdata.CurrAsmList, opsize, opsize, hregister, scratch_reg);
|
||||
hlcg.a_op_const_reg(current_asmdata.CurrAsmList, OP_SUB, opsize, value, hregister);
|
||||
end;
|
||||
|
||||
begin
|
||||
@ -520,15 +520,15 @@ implementation
|
||||
genitem(t^.less);
|
||||
{ do we need to test the first value? }
|
||||
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
|
||||
begin
|
||||
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
|
||||
begin
|
||||
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));
|
||||
end;
|
||||
last:=t^._low;
|
||||
@ -550,10 +550,10 @@ implementation
|
||||
{ present label then the lower limit can be checked }
|
||||
{ immediately. else check the range in between: }
|
||||
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;
|
||||
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;
|
||||
end;
|
||||
first:=false;
|
||||
@ -569,9 +569,9 @@ implementation
|
||||
begin
|
||||
last:=0;
|
||||
first:=true;
|
||||
scratch_reg:=cg.getintregister(current_asmdata.CurrAsmList,opsize);
|
||||
scratch_reg:=hlcg.getintregister(current_asmdata.CurrAsmList,opsize);
|
||||
genitem(hp);
|
||||
cg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);
|
||||
hlcg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -595,7 +595,7 @@ implementation
|
||||
if t^._low=t^._high then
|
||||
begin
|
||||
{$ifndef cpu64bitalu}
|
||||
if opsize in [OS_S64,OS_64] then
|
||||
if def_cgsize(opsize) in [OS_S64,OS_64] then
|
||||
begin
|
||||
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);
|
||||
@ -605,7 +605,7 @@ implementation
|
||||
else
|
||||
{$endif not cpu64bitalu}
|
||||
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;
|
||||
{ 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 }
|
||||
@ -619,7 +619,7 @@ implementation
|
||||
if not lastwasrange or (t^._low-last>1) then
|
||||
begin
|
||||
{$ifndef cpu64bitalu}
|
||||
if opsize in [OS_64,OS_S64] then
|
||||
if def_cgsize(opsize) in [OS_64,OS_S64] then
|
||||
begin
|
||||
current_asmdata.getjumplabel(l1);
|
||||
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
|
||||
{$endif not cpu64bitalu}
|
||||
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);
|
||||
end;
|
||||
end;
|
||||
{$ifndef cpu64bitalu}
|
||||
if opsize in [OS_S64,OS_64] then
|
||||
if def_cgsize(opsize) in [OS_S64,OS_64] then
|
||||
begin
|
||||
current_asmdata.getjumplabel(l1);
|
||||
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
|
||||
{$endif not cpu64bitalu}
|
||||
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;
|
||||
|
||||
last:=t^._high;
|
||||
@ -665,7 +665,7 @@ implementation
|
||||
last:=0;
|
||||
lastwasrange:=false;
|
||||
genitem(hp);
|
||||
cg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);
|
||||
hlcg.a_jmp_always(current_asmdata.CurrAsmList,elselabel);
|
||||
end;
|
||||
|
||||
|
||||
@ -720,11 +720,11 @@ implementation
|
||||
end;
|
||||
secondpass(left);
|
||||
{ determines the size of the operand }
|
||||
opsize:=def_cgsize(left.resultdef);
|
||||
opsize:=left.resultdef;
|
||||
{ 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}
|
||||
if opsize in [OS_S64,OS_64] then
|
||||
if def_cgsize(opsize) in [OS_S64,OS_64] then
|
||||
begin
|
||||
hregister:=left.location.register64.reglo;
|
||||
hregister2:=left.location.register64.reghi;
|
||||
@ -750,7 +750,7 @@ implementation
|
||||
load_all_regvars(current_asmdata.CurrAsmList);
|
||||
{$endif OLDREGVARS}
|
||||
{$ifndef cpu64bitalu}
|
||||
if opsize in [OS_64,OS_S64] then
|
||||
if def_cgsize(opsize) in [OS_64,OS_S64] then
|
||||
genlinearcmplist(labels)
|
||||
else
|
||||
{$endif not cpu64bitalu}
|
||||
@ -847,11 +847,11 @@ implementation
|
||||
{$ifdef OLDREGVARS}
|
||||
load_all_regvars(current_asmdata.CurrAsmList);
|
||||
{$endif OLDREGVARS}
|
||||
cg.a_jmp_always(current_asmdata.CurrAsmList,endlabel);
|
||||
hlcg.a_jmp_always(current_asmdata.CurrAsmList,endlabel);
|
||||
end;
|
||||
current_asmdata.CurrAsmList.concat(cai_align.create(current_settings.alignment.jumpalign));
|
||||
{ ...and the else block }
|
||||
cg.a_label(current_asmdata.CurrAsmList,elselabel);
|
||||
hlcg.a_label(current_asmdata.CurrAsmList,elselabel);
|
||||
if assigned(elseblock) then
|
||||
begin
|
||||
secondpass(elseblock);
|
||||
@ -863,7 +863,7 @@ implementation
|
||||
cg.executionweight:=oldexecutionweight;
|
||||
|
||||
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 }
|
||||
for i:=0 to blocks.count-1 do
|
||||
|
@ -107,7 +107,7 @@ implementation
|
||||
// allocate base and index registers register
|
||||
indexreg:= cg.makeregsize(current_asmdata.CurrAsmList, hregister, OS_INT);
|
||||
{ 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
|
||||
begin
|
||||
{ use aword(value-min)<aword(max-min) instead of two comparisons }
|
||||
@ -225,7 +225,7 @@ implementation
|
||||
begin
|
||||
{ do we need to generate cmps? }
|
||||
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)
|
||||
else
|
||||
begin
|
||||
|
@ -47,7 +47,7 @@ unit ncpuset;
|
||||
cpubase,
|
||||
aasmbase,aasmtai,aasmdata,aasmcpu,
|
||||
cgbase,cgutils,cgobj,
|
||||
procinfo;
|
||||
defutil,procinfo;
|
||||
|
||||
procedure tcpucasenode.optimizevalues(var max_linear_list:aint;var max_dist:aword);
|
||||
begin
|
||||
@ -68,6 +68,7 @@ unit ncpuset;
|
||||
last : TConstExprInt;
|
||||
indexreg,jmpreg,basereg : tregister;
|
||||
href : treference;
|
||||
opcgsize : tcgsize;
|
||||
|
||||
procedure genitem(list:TAsmList;t : pcaselabel);
|
||||
var
|
||||
@ -86,12 +87,13 @@ unit ncpuset;
|
||||
end;
|
||||
|
||||
begin
|
||||
opcgsize:=def_cgsize(opsize);
|
||||
if not(jumptable_no_range) then
|
||||
begin
|
||||
{ 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 }
|
||||
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;
|
||||
current_asmdata.getjumplabel(table);
|
||||
indexreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
|
||||
|
@ -89,6 +89,7 @@ implementation
|
||||
href : treference;
|
||||
jtlist: tasmlist;
|
||||
sectype: TAsmSectiontype;
|
||||
opcgsize: tcgsize;
|
||||
|
||||
procedure genitem(list:TAsmList;t : pcaselabel);
|
||||
var
|
||||
@ -116,18 +117,19 @@ implementation
|
||||
|
||||
begin
|
||||
last:=min_;
|
||||
opcgsize:=def_cgsize(opsize);
|
||||
if not(jumptable_no_range) then
|
||||
begin
|
||||
{ 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 }
|
||||
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;
|
||||
end;
|
||||
current_asmdata.getdatalabel(table);
|
||||
{ make it a 32bit register }
|
||||
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 }
|
||||
reference_reset_symbol(href,table,0,sizeof(pint));
|
||||
href.offset:=(-aint(min_))*sizeof(aint);
|
||||
|
Loading…
Reference in New Issue
Block a user