mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 04:29:17 +02:00
* use a functype operand for a_if, instead of hardcoding
git-svn-id: branches/wasm@48028 -
This commit is contained in:
parent
07c1783e24
commit
b6735179ed
@ -304,9 +304,7 @@ implementation
|
|||||||
writer.AsmWrite(#9#9);
|
writer.AsmWrite(#9#9);
|
||||||
writer.AsmWrite(gas_op2str[cpu.opcode]);
|
writer.AsmWrite(gas_op2str[cpu.opcode]);
|
||||||
|
|
||||||
if (cpu.opcode = a_if) then
|
if cpu.ops<>0 then
|
||||||
writer.AsmWrite(' i32') //todo: this is a hardcode, but shouldn't
|
|
||||||
else if cpu.ops<>0 then
|
|
||||||
begin
|
begin
|
||||||
for i:=0 to cpu.ops-1 do
|
for i:=0 to cpu.ops-1 do
|
||||||
begin
|
begin
|
||||||
|
@ -87,12 +87,14 @@ uses
|
|||||||
);
|
);
|
||||||
|
|
||||||
TWasmBasicType = (wbt_i32, wbt_i64, wbt_f32, wbt_f64);
|
TWasmBasicType = (wbt_i32, wbt_i64, wbt_f32, wbt_f64);
|
||||||
|
TWasmResultType = array of TWasmBasicType;
|
||||||
|
|
||||||
{ TWasmFuncType }
|
{ TWasmFuncType }
|
||||||
|
|
||||||
TWasmFuncType = class
|
TWasmFuncType = class
|
||||||
params: array of TWasmBasicType;
|
params: TWasmResultType;
|
||||||
results: array of TWasmBasicType;
|
results: TWasmResultType;
|
||||||
|
constructor Create(aparams, aresults: TWasmResultType);
|
||||||
procedure add_param(param: TWasmBasicType);
|
procedure add_param(param: TWasmBasicType);
|
||||||
procedure add_result(res: TWasmBasicType);
|
procedure add_result(res: TWasmBasicType);
|
||||||
end;
|
end;
|
||||||
@ -390,6 +392,13 @@ uses
|
|||||||
TWasmFuncType
|
TWasmFuncType
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
|
constructor TWasmFuncType.Create(aparams, aresults: TWasmResultType);
|
||||||
|
begin
|
||||||
|
inherited Create;
|
||||||
|
params:=aparams;
|
||||||
|
results:=aresults;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TWasmFuncType.add_param(param: TWasmBasicType);
|
procedure TWasmFuncType.add_param(param: TWasmBasicType);
|
||||||
begin
|
begin
|
||||||
SetLength(params,Length(params)+1);
|
SetLength(params,Length(params)+1);
|
||||||
|
@ -261,7 +261,7 @@ interface
|
|||||||
(nf_short_bool in flags)) then
|
(nf_short_bool in flags)) then
|
||||||
begin
|
begin
|
||||||
secondpass(left);
|
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
|
case nodetype of
|
||||||
andn :
|
andn :
|
||||||
|
@ -152,7 +152,7 @@ begin
|
|||||||
|
|
||||||
secondpass(left); // condition exprssions
|
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;
|
thlcgwasm(hlcg).incblock;
|
||||||
|
|
||||||
secondpass(right); // then branchs
|
secondpass(right); // then branchs
|
||||||
|
@ -274,7 +274,7 @@ implementation
|
|||||||
prm: tcpuparavarsym;
|
prm: tcpuparavarsym;
|
||||||
bt: TWasmBasicType;
|
bt: TWasmBasicType;
|
||||||
begin
|
begin
|
||||||
result:=TWasmFuncType.Create;
|
result:=TWasmFuncType.Create([],[]);
|
||||||
if Assigned(paras) and (paras.Count>0) then
|
if Assigned(paras) and (paras.Count>0) then
|
||||||
begin
|
begin
|
||||||
for i:=0 to paras.Count-1 do
|
for i:=0 to paras.Count-1 do
|
||||||
|
Loading…
Reference in New Issue
Block a user