+ wrap block nodes with exit in a_block..a_end_block instructions. This fixes

'exit' in inlined procedures on the WebAssembly target.
This commit is contained in:
Nikolay Nikolov 2021-10-20 11:09:08 +03:00
parent 703ae75ba6
commit bb30958665
2 changed files with 70 additions and 1 deletions

View File

@ -33,7 +33,7 @@ implementation
ncgbas,ncgflw,ncgcnv,ncgld,ncgmem,ncgcon,ncgset,
ncgadd, ncgcal,ncgmat,ncginl,
nwasmadd,nwasmcal,nwasmmat,nwasmflw,nwasmcon,nwasmcnv,nwasmset,nwasminl,
nwasmbas,nwasmadd,nwasmcal,nwasmmat,nwasmflw,nwasmcon,nwasmcnv,nwasmset,nwasminl,
{ these are not really nodes }
nwasmutil,
{ symtable }

View File

@ -0,0 +1,69 @@
{
Copyright (c) 2021 by Nikolay Nikolov
This unit implements code generation for some basic nodes on the
WebAssembly target.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************
}
unit nwasmbas;
{$i fpcdefs.inc}
interface
uses
nbas,ncgbas;
type
{ twasmblocknode }
twasmblocknode=class(tcgblocknode)
procedure pass_generate_code; override;
end;
implementation
uses
aasmdata,aasmcpu,
cpubase,
hlcgobj,hlcgcpu,
node;
{ twasmblocknode }
procedure twasmblocknode.pass_generate_code;
begin
if nf_block_with_exit in flags then
begin
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
thlcgwasm(hlcg).incblock;
end;
inherited pass_generate_code;
if nf_block_with_exit in flags then
begin
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
thlcgwasm(hlcg).decblock;
end;
end;
begin
cblocknode:=twasmblocknode;
end.