* use a functype operand for a_if, instead of hardcoding

git-svn-id: branches/wasm@48028 -
This commit is contained in:
nickysn 2021-01-04 11:01:18 +00:00
parent 07c1783e24
commit b6735179ed
5 changed files with 15 additions and 8 deletions

View File

@ -304,9 +304,7 @@ implementation
writer.AsmWrite(#9#9);
writer.AsmWrite(gas_op2str[cpu.opcode]);
if (cpu.opcode = a_if) then
writer.AsmWrite(' i32') //todo: this is a hardcode, but shouldn't
else if cpu.ops<>0 then
if cpu.ops<>0 then
begin
for i:=0 to cpu.ops-1 do
begin

View File

@ -87,12 +87,14 @@ uses
);
TWasmBasicType = (wbt_i32, wbt_i64, wbt_f32, wbt_f64);
TWasmResultType = array of TWasmBasicType;
{ TWasmFuncType }
TWasmFuncType = class
params: array of TWasmBasicType;
results: array of TWasmBasicType;
params: TWasmResultType;
results: TWasmResultType;
constructor Create(aparams, aresults: TWasmResultType);
procedure add_param(param: TWasmBasicType);
procedure add_result(res: TWasmBasicType);
end;
@ -390,6 +392,13 @@ uses
TWasmFuncType
*****************************************************************************}
constructor TWasmFuncType.Create(aparams, aresults: TWasmResultType);
begin
inherited Create;
params:=aparams;
results:=aresults;
end;
procedure TWasmFuncType.add_param(param: TWasmBasicType);
begin
SetLength(params,Length(params)+1);

View File

@ -261,7 +261,7 @@ interface
(nf_short_bool in flags)) then
begin
secondpass(left);
current_asmdata.CurrAsmList.Concat( taicpu.op_none(a_if) );
current_asmdata.CurrAsmList.Concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i32])));
case nodetype of
andn :

View File

@ -152,7 +152,7 @@ begin
secondpass(left); // condition exprssions
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_if)); // IF
current_asmdata.CurrAsmList.concat(taicpu.op_functype(a_if,TWasmFuncType.Create([],[wbt_i32])));
thlcgwasm(hlcg).incblock;
secondpass(right); // then branchs

View File

@ -274,7 +274,7 @@ implementation
prm: tcpuparavarsym;
bt: TWasmBasicType;
begin
result:=TWasmFuncType.Create;
result:=TWasmFuncType.Create([],[]);
if Assigned(paras) and (paras.Count>0) then
begin
for i:=0 to paras.Count-1 do