mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 11:09:42 +02:00
* force writing of new section before generating the jumptable
git-svn-id: trunk@1085 -
This commit is contained in:
parent
fdc4925fcd
commit
ca66b9f7c1
@ -82,30 +82,24 @@ implementation
|
||||
last : TConstExprInt;
|
||||
indexreg : tregister;
|
||||
href : treference;
|
||||
jumpsegment : TAAsmOutput;
|
||||
|
||||
procedure genitem(t : pcaselabel);
|
||||
procedure genitem(list:taasmoutput;t : pcaselabel);
|
||||
var
|
||||
i : aint;
|
||||
begin
|
||||
if assigned(t^.less) then
|
||||
genitem(t^.less);
|
||||
genitem(list,t^.less);
|
||||
{ fill possible hole }
|
||||
for i:=last+1 to t^._low-1 do
|
||||
jumpSegment.concat(Tai_const.Create_sym(elselabel));
|
||||
list.concat(Tai_const.Create_sym(elselabel));
|
||||
for i:=t^._low to t^._high do
|
||||
jumpSegment.concat(Tai_const.Create_sym(blocklabel(t^.blockid)));
|
||||
list.concat(Tai_const.Create_sym(blocklabel(t^.blockid)));
|
||||
last:=t^._high;
|
||||
if assigned(t^.greater) then
|
||||
genitem(t^.greater);
|
||||
genitem(list,t^.greater);
|
||||
end;
|
||||
|
||||
begin
|
||||
if (cs_create_smart in aktmoduleswitches) or
|
||||
(af_smartlink_sections in target_asm.flags) then
|
||||
jumpsegment:=current_procinfo.aktlocaldata
|
||||
else
|
||||
jumpsegment:=asmlist[al_globals];
|
||||
if not(jumptable_no_range) then
|
||||
begin
|
||||
{ case expr less than min_ => goto elselabel }
|
||||
@ -124,11 +118,10 @@ implementation
|
||||
href.scalefactor:=4;
|
||||
emit_ref(A_JMP,S_NO,href);
|
||||
{ generate jump table }
|
||||
if not(cs_littlesize in aktglobalswitches) then
|
||||
jumpSegment.concat(Tai_Align.Create_Op(4,0));
|
||||
jumpSegment.concat(Tai_label.Create(table));
|
||||
new_section(current_procinfo.aktlocaldata,sec_data,current_procinfo.procdef.mangledname,sizeof(aint));
|
||||
current_procinfo.aktlocaldata.concat(Tai_label.Create(table));
|
||||
last:=min_;
|
||||
genitem(hp);
|
||||
genitem(current_procinfo.aktlocaldata,hp);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -68,14 +68,13 @@ implementation
|
||||
last : TConstExprInt;
|
||||
indexreg : tregister;
|
||||
href : treference;
|
||||
jumpsegment : TAAsmOutput;
|
||||
|
||||
procedure genitem(t : pcaselabel);
|
||||
procedure genitem(list:taasmoutput;t : pcaselabel);
|
||||
var
|
||||
i : aint;
|
||||
begin
|
||||
if assigned(t^.less) then
|
||||
genitem(t^.less);
|
||||
genitem(list,t^.less);
|
||||
{ fill possible hole }
|
||||
for i:=last+1 to t^._low-1 do
|
||||
jumpSegment.concat(Tai_const.Create_sym(elselabel));
|
||||
@ -83,15 +82,10 @@ implementation
|
||||
jumpSegment.concat(Tai_const.Create_sym(blocklabel(t^.blockid)));
|
||||
last:=t^._high;
|
||||
if assigned(t^.greater) then
|
||||
genitem(t^.greater);
|
||||
genitem(list,t^.greater);
|
||||
end;
|
||||
|
||||
begin
|
||||
if (cs_create_smart in aktmoduleswitches) or
|
||||
(af_smartlink_sections in target_asm.flags) then
|
||||
jumpsegment:=current_procinfo.aktlocaldata
|
||||
else
|
||||
jumpsegment:=asmlist[al_globals];
|
||||
if not(jumptable_no_range) then
|
||||
begin
|
||||
{ case expr less than min_ => goto elselabel }
|
||||
@ -111,16 +105,15 @@ implementation
|
||||
href.index := indexreg;
|
||||
|
||||
cg.a_load_ref_reg(exprasmlist, OS_INT, OS_INT, href, indexreg);
|
||||
|
||||
|
||||
exprasmlist.concat(taicpu.op_reg(A_MTCTR, indexreg));
|
||||
exprasmlist.concat(taicpu.op_none(A_BCTR));
|
||||
|
||||
{ generate jump table }
|
||||
if not(cs_littlesize in aktglobalswitches) then
|
||||
jumpSegment.concat(Tai_Align.Create_Op(4, 0));
|
||||
jumpSegment.concat(Tai_label.Create(table));
|
||||
new_section(current_procinfo.aktlocaldata,sec_data,current_procinfo.procdef.mangledname,sizeof(aint));
|
||||
current_procinfo.aktlocaldata.concat(Tai_label.Create(table));
|
||||
last:=min_;
|
||||
genitem(hp);
|
||||
genitem(current_procinfo.aktlocaldata,hp);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -845,27 +845,18 @@ implementation
|
||||
aktproccode.concatlist(templist);
|
||||
|
||||
{$ifdef ARM}
|
||||
{ because of the limited constant size of the arm, all data access is done pc relative }
|
||||
insertpcrelativedata(aktproccode,aktlocaldata);
|
||||
{$endif ARM}
|
||||
|
||||
{ save local data (casetable) also in the same file }
|
||||
if assigned(aktlocaldata) and
|
||||
(not aktlocaldata.empty) then
|
||||
begin
|
||||
{ because of the limited constant size of the arm, all data access is done pc relative }
|
||||
if target_info.cpu=cpu_arm then
|
||||
aktproccode.concatlist(aktlocaldata)
|
||||
else
|
||||
begin
|
||||
new_section(aktproccode,sec_data,lower(procdef.mangledname),0);
|
||||
aktproccode.concatlist(aktlocaldata);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ add the procedure to the al_procedures }
|
||||
maybe_new_object_file(asmlist[al_procedures]);
|
||||
new_section(asmlist[al_procedures],sec_code,lower(procdef.mangledname),aktalignment.procalign);
|
||||
asmlist[al_procedures].concatlist(aktproccode);
|
||||
{ save local data (casetable) also in the same file }
|
||||
if assigned(aktlocaldata) and
|
||||
(not aktlocaldata.empty) then
|
||||
asmlist[al_procedures].concatlist(aktlocaldata);
|
||||
|
||||
{ only now we can remove the temps }
|
||||
tg.resettempgen;
|
||||
|
@ -68,30 +68,24 @@ unit ncpuset;
|
||||
last : TConstExprInt;
|
||||
indexreg,jmpreg,basereg : tregister;
|
||||
href : treference;
|
||||
jumpsegment : TAAsmOutput;
|
||||
|
||||
procedure genitem(t : pcaselabel);
|
||||
procedure genitem(list:taasmoutput;t : pcaselabel);
|
||||
var
|
||||
i : aint;
|
||||
begin
|
||||
if assigned(t^.less) then
|
||||
genitem(t^.less);
|
||||
genitem(list,t^.less);
|
||||
{ fill possible hole }
|
||||
for i:=last+1 to t^._low-1 do
|
||||
jumpSegment.concat(Tai_const.Create_sym(elselabel));
|
||||
list.concat(Tai_const.Create_sym(elselabel));
|
||||
for i:=t^._low to t^._high do
|
||||
jumpSegment.concat(Tai_const.Create_sym(blocklabel(t^.blockid)));
|
||||
list.concat(Tai_const.Create_sym(blocklabel(t^.blockid)));
|
||||
last:=t^._high;
|
||||
if assigned(t^.greater) then
|
||||
genitem(t^.greater);
|
||||
genitem(list,t^.greater);
|
||||
end;
|
||||
|
||||
begin
|
||||
if (cs_create_smart in aktmoduleswitches) or
|
||||
(af_smartlink_sections in target_asm.flags) then
|
||||
jumpsegment:=current_procinfo.aktlocaldata
|
||||
else
|
||||
jumpsegment:=asmlist[al_globals];
|
||||
if not(jumptable_no_range) then
|
||||
begin
|
||||
{ case expr less than min_ => goto elselabel }
|
||||
@ -119,11 +113,10 @@ unit ncpuset;
|
||||
{ Delay slot }
|
||||
exprasmlist.concat(taicpu.op_none(A_NOP));
|
||||
{ generate jump table }
|
||||
if not(cs_littlesize in aktglobalswitches) then
|
||||
jumpSegment.concat(Tai_Align.Create_Op(4,0));
|
||||
jumpSegment.concat(Tai_label.Create(table));
|
||||
new_section(current_procinfo.aktlocaldata,sec_data,current_procinfo.procdef.mangledname,sizeof(aint));
|
||||
current_procinfo.aktlocaldata.concat(Tai_label.Create(table));
|
||||
last:=min_;
|
||||
genitem(hp);
|
||||
genitem(current_procinfo.aktlocaldata,hp);
|
||||
end;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user