mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-28 21:20:29 +02:00
+ support the f32.const and f64.const instructions in twasmreader.HandlePlainInstruction
This commit is contained in:
parent
02e90adfe1
commit
09f2fa0daf
@ -45,7 +45,7 @@ type
|
|||||||
TOprType=(OPR_NONE,OPR_CONSTANT,OPR_SYMBOL,OPR_LOCAL,
|
TOprType=(OPR_NONE,OPR_CONSTANT,OPR_SYMBOL,OPR_LOCAL,
|
||||||
OPR_REFERENCE,OPR_REGISTER,OPR_COND,OPR_REGSET,
|
OPR_REFERENCE,OPR_REGISTER,OPR_COND,OPR_REGSET,
|
||||||
OPR_SHIFTEROP,OPR_MODEFLAGS,OPR_SPECIALREG,
|
OPR_SHIFTEROP,OPR_MODEFLAGS,OPR_SPECIALREG,
|
||||||
OPR_REGPAIR,OPR_FENCEFLAGS,OPR_INDEXEDREG);
|
OPR_REGPAIR,OPR_FENCEFLAGS,OPR_INDEXEDREG,OPR_FLOATCONSTANT);
|
||||||
|
|
||||||
TOprRec = record
|
TOprRec = record
|
||||||
case typ:TOprType of
|
case typ:TOprType of
|
||||||
@ -89,6 +89,9 @@ type
|
|||||||
{$if defined(riscv32) or defined(riscv64)}
|
{$if defined(riscv32) or defined(riscv64)}
|
||||||
OPR_FENCEFLAGS: (fenceflags : TFenceFlags);
|
OPR_FENCEFLAGS: (fenceflags : TFenceFlags);
|
||||||
{$endif aarch64}
|
{$endif aarch64}
|
||||||
|
{$ifdef wasm32}
|
||||||
|
OPR_FLOATCONSTANT: (floatval:double);
|
||||||
|
{$endif wasm32}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TInstruction = class;
|
TInstruction = class;
|
||||||
|
@ -55,6 +55,7 @@ Unit rawasmtext;
|
|||||||
actasmtoken : tasmtoken;
|
actasmtoken : tasmtoken;
|
||||||
prevasmtoken : tasmtoken;
|
prevasmtoken : tasmtoken;
|
||||||
actinttoken : aint;
|
actinttoken : aint;
|
||||||
|
actfloattoken : double;
|
||||||
procedure SetupTables;
|
procedure SetupTables;
|
||||||
procedure GetToken;
|
procedure GetToken;
|
||||||
function consume(t : tasmtoken):boolean;
|
function consume(t : tasmtoken):boolean;
|
||||||
@ -146,6 +147,20 @@ Unit rawasmtext;
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetFloatToken: double;
|
||||||
|
var
|
||||||
|
s: string;
|
||||||
|
begin
|
||||||
|
s:=actasmpattern;
|
||||||
|
if is_hex then
|
||||||
|
begin
|
||||||
|
{ TODO: parse hex floats }
|
||||||
|
internalerror(2024071501);
|
||||||
|
end
|
||||||
|
else
|
||||||
|
Val(s,result);
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
len: Integer;
|
len: Integer;
|
||||||
tmpS: string;
|
tmpS: string;
|
||||||
@ -337,7 +352,10 @@ Unit rawasmtext;
|
|||||||
end;
|
end;
|
||||||
actasmpattern[0]:=chr(len);
|
actasmpattern[0]:=chr(len);
|
||||||
if is_float then
|
if is_float then
|
||||||
actasmtoken:=AS_REALNUM
|
begin
|
||||||
|
actasmtoken:=AS_REALNUM;
|
||||||
|
actfloattoken:=GetFloatToken;
|
||||||
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
actasmtoken:=AS_INTNUM;
|
actasmtoken:=AS_INTNUM;
|
||||||
@ -770,6 +788,32 @@ Unit rawasmtext;
|
|||||||
Consume(AS_INTNUM);
|
Consume(AS_INTNUM);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
{ instructions with a float const operand }
|
||||||
|
a_f32_const,
|
||||||
|
a_f64_const:
|
||||||
|
begin
|
||||||
|
case actasmtoken of
|
||||||
|
AS_INTNUM:
|
||||||
|
begin
|
||||||
|
result.operands[1].opr.typ:=OPR_FLOATCONSTANT;
|
||||||
|
result.operands[1].opr.floatval:=actinttoken;
|
||||||
|
Consume(AS_INTNUM);
|
||||||
|
end;
|
||||||
|
AS_REALNUM:
|
||||||
|
begin
|
||||||
|
result.operands[1].opr.typ:=OPR_FLOATCONSTANT;
|
||||||
|
result.operands[1].opr.floatval:=actfloattoken;
|
||||||
|
Consume(AS_REALNUM);
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
{ error: expected real }
|
||||||
|
result.Free;
|
||||||
|
result:=nil;
|
||||||
|
Consume(AS_REALNUM);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
internalerror(2024071401);
|
internalerror(2024071401);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user