mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-31 01:12:04 +02:00
* refactor: wasm_convert_to_flat_asmlist and wasm_convert_to_structured_asmlist now accept a single var parameter
This commit is contained in:
parent
d66a8cb902
commit
84e2613ca8
@ -278,8 +278,8 @@ uses
|
||||
function spilling_create_load(const ref:treference;r:tregister):Taicpu;
|
||||
function spilling_create_store(r:tregister; const ref:treference):Taicpu;
|
||||
|
||||
procedure wasm_convert_to_structured_asmlist(srclist, destlist: TAsmList);
|
||||
procedure wasm_convert_to_flat_asmlist(srclist, destlist: TAsmList);
|
||||
procedure wasm_convert_to_structured_asmlist(var asmlist: TAsmList);
|
||||
procedure wasm_convert_to_flat_asmlist(var asmlist: TAsmList);
|
||||
procedure map_structured_asmlist(l: TAsmList; f: TAsmMapFunc);
|
||||
|
||||
implementation
|
||||
@ -2836,14 +2836,24 @@ uses
|
||||
end;
|
||||
|
||||
|
||||
procedure wasm_convert_to_structured_asmlist(srclist, destlist: TAsmList);
|
||||
procedure wasm_convert_to_structured_asmlist_internal(srclist, destlist: TAsmList);
|
||||
begin
|
||||
while not srclist.Empty do
|
||||
destlist.Concat(wasm_convert_first_item_to_structured(srclist));
|
||||
end;
|
||||
|
||||
|
||||
procedure wasm_convert_to_flat_asmlist(srclist, destlist: TAsmList);
|
||||
procedure wasm_convert_to_structured_asmlist(var asmlist: TAsmList);
|
||||
var
|
||||
tmplist: TAsmList;
|
||||
begin
|
||||
tmplist:=TAsmList.Create;
|
||||
wasm_convert_to_structured_asmlist_internal(asmlist,tmplist);
|
||||
asmlist.Free;
|
||||
asmlist:=tmplist;
|
||||
end;
|
||||
|
||||
procedure wasm_convert_to_flat_asmlist_internal(srclist, destlist: TAsmList);
|
||||
var
|
||||
p: tai;
|
||||
tmplist: TAsmList;
|
||||
@ -2865,6 +2875,17 @@ uses
|
||||
end;
|
||||
|
||||
|
||||
procedure wasm_convert_to_flat_asmlist(var asmlist: TAsmList);
|
||||
var
|
||||
tmplist: TAsmList;
|
||||
begin
|
||||
tmplist:=TAsmList.Create;
|
||||
wasm_convert_to_flat_asmlist_internal(asmlist,tmplist);
|
||||
asmlist.Free;
|
||||
asmlist:=tmplist;
|
||||
end;
|
||||
|
||||
|
||||
procedure map_structured_asmlist_inner(l: TAsmList; f: TAsmMapFunc; blockstack: twasmstruc_stack);
|
||||
var
|
||||
p, q: tai;
|
||||
|
@ -836,40 +836,28 @@ implementation
|
||||
|
||||
procedure resolve_labels_complex(var asmlist: TAsmList);
|
||||
var
|
||||
l2, entry_code, proc_body, exit_code: TAsmList;
|
||||
entry_code, proc_body, exit_code: TAsmList;
|
||||
begin
|
||||
filter_start_exit_code(asmlist,entry_code,proc_body,exit_code);
|
||||
asmlist.Free;
|
||||
asmlist:=proc_body;
|
||||
proc_body:=nil;
|
||||
|
||||
l2:=TAsmList.Create;
|
||||
wasm_convert_to_structured_asmlist(asmlist,l2);
|
||||
asmlist.Free;
|
||||
asmlist:=l2;
|
||||
wasm_convert_to_structured_asmlist(asmlist);
|
||||
|
||||
map_structured_asmlist(asmlist,@ConvertBranchTargetNumbersToLabels);
|
||||
map_structured_asmlist(asmlist,@ConvertIfToBrIf);
|
||||
map_structured_asmlist(asmlist,@ConvertLoopToBr);
|
||||
|
||||
l2:=TAsmList.Create;
|
||||
wasm_convert_to_flat_asmlist(asmlist,l2);
|
||||
asmlist.Free;
|
||||
asmlist:=l2;
|
||||
wasm_convert_to_flat_asmlist(asmlist);
|
||||
|
||||
map_structured_asmlist(asmlist,@StripBlockInstructions);
|
||||
|
||||
l2:=TAsmList.Create;
|
||||
wasm_convert_to_structured_asmlist(asmlist,l2);
|
||||
asmlist.Free;
|
||||
asmlist:=l2;
|
||||
wasm_convert_to_structured_asmlist(asmlist);
|
||||
|
||||
resolve_labels_of_asmlist_with_try_blocks_recursive(asmlist);
|
||||
|
||||
l2:=TAsmList.Create;
|
||||
wasm_convert_to_flat_asmlist(asmlist,l2);
|
||||
asmlist.Free;
|
||||
asmlist:=l2;
|
||||
wasm_convert_to_flat_asmlist(asmlist);
|
||||
|
||||
asmlist.insertList(entry_code);
|
||||
entry_code.free;
|
||||
|
Loading…
Reference in New Issue
Block a user