mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 16:06:09 +02:00
* convert loop..end_loop blocks to flat list + branch instruction
This commit is contained in:
parent
9584348c40
commit
ce742b5b4d
@ -135,6 +135,7 @@ uses
|
|||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
function getcopy:TLinkedListItem;override;
|
function getcopy:TLinkedListItem;override;
|
||||||
procedure Map(f: TAsmMapFunc; blockstack: twasmstruc_stack);override;
|
procedure Map(f: TAsmMapFunc; blockstack: twasmstruc_stack);override;
|
||||||
|
procedure ConvertToBr(list: TAsmList);
|
||||||
procedure ConvertToFlatList(l: TAsmList);override;
|
procedure ConvertToFlatList(l: TAsmList);override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -659,6 +660,13 @@ uses
|
|||||||
blockstack.pop;
|
blockstack.pop;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure tai_wasmstruc_loop.ConvertToBr(list: TAsmList);
|
||||||
|
begin
|
||||||
|
list.concat(tai_label.create(GetLabel));
|
||||||
|
list.concatList(inner_asmlist);
|
||||||
|
list.concat(taicpu.op_sym(a_br,GetLabel));
|
||||||
|
end;
|
||||||
|
|
||||||
procedure tai_wasmstruc_loop.ConvertToFlatList(l: TAsmList);
|
procedure tai_wasmstruc_loop.ConvertToFlatList(l: TAsmList);
|
||||||
begin
|
begin
|
||||||
l.Concat(loop_instr);
|
l.Concat(loop_instr);
|
||||||
|
@ -41,6 +41,7 @@ interface
|
|||||||
|
|
||||||
function ConvertBranchTargetNumbersToLabels(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
function ConvertBranchTargetNumbersToLabels(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
||||||
function ConvertIfToBrIf(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
function ConvertIfToBrIf(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
||||||
|
function ConvertLoopToBr(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
||||||
|
|
||||||
{ used for allocating locals during the postprocess_code stage (i.e. after register allocation) }
|
{ used for allocating locals during the postprocess_code stage (i.e. after register allocation) }
|
||||||
function AllocWasmLocal(wbt: TWasmBasicType): Integer;
|
function AllocWasmLocal(wbt: TWasmBasicType): Integer;
|
||||||
@ -389,6 +390,17 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function tcpuprocinfo.ConvertLoopToBr(ai: tai; blockstack: twasmstruc_stack): TAsmMapFuncResult;
|
||||||
|
begin
|
||||||
|
result.typ:=amfrtNoChange;
|
||||||
|
if (ai.typ=ait_wasm_structured_instruction) and (ai is tai_wasmstruc_loop) then
|
||||||
|
begin
|
||||||
|
result.typ:=amfrtNewList;
|
||||||
|
result.newlist:=TAsmList.Create;
|
||||||
|
tai_wasmstruc_loop(ai).ConvertToBr(result.newlist);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function tcpuprocinfo.AllocWasmLocal(wbt: TWasmBasicType): Integer;
|
function tcpuprocinfo.AllocWasmLocal(wbt: TWasmBasicType): Integer;
|
||||||
begin
|
begin
|
||||||
SetLength(FAllocatedLocals,Length(FAllocatedLocals)+1);
|
SetLength(FAllocatedLocals,Length(FAllocatedLocals)+1);
|
||||||
@ -656,6 +668,7 @@ implementation
|
|||||||
|
|
||||||
map_structured_asmlist(asmlist,@ConvertBranchTargetNumbersToLabels);
|
map_structured_asmlist(asmlist,@ConvertBranchTargetNumbersToLabels);
|
||||||
map_structured_asmlist(asmlist,@ConvertIfToBrIf);
|
map_structured_asmlist(asmlist,@ConvertIfToBrIf);
|
||||||
|
map_structured_asmlist(asmlist,@ConvertLoopToBr);
|
||||||
|
|
||||||
l2:=TAsmList.Create;
|
l2:=TAsmList.Create;
|
||||||
wasm_convert_to_flat_asmlist(asmlist,l2);
|
wasm_convert_to_flat_asmlist(asmlist,l2);
|
||||||
|
Loading…
Reference in New Issue
Block a user