mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-13 20:29:24 +02:00
* fixes in thlcgwasm.resize_stack_int_val
git-svn-id: branches/wasm@47974 -
This commit is contained in:
parent
189c4025c2
commit
fc95e7f22d
@ -69,6 +69,7 @@ uses
|
|||||||
a_f32_le, a_f64_le, a_f32_gt, a_f64_gt, a_f32_ge, a_f64_ge,
|
a_f32_le, a_f64_le, a_f32_gt, a_f64_gt, a_f32_ge, a_f64_ge,
|
||||||
// conversion
|
// conversion
|
||||||
a_i32_wrap_i64, a_i64_extend_s_i32, a_i64_extend_u_i32,
|
a_i32_wrap_i64, a_i64_extend_s_i32, a_i64_extend_u_i32,
|
||||||
|
a_i32_extend_s_8,a_i32_extend_s_16,a_i64_extend_s_8,a_i64_extend_s_16,a_i64_extend_s_32,
|
||||||
a_i32_trunc_s_f32, a_i32_trunc_s_f64, a_i64_trunc_s_f32, a_i64_trunc_s_f64,
|
a_i32_trunc_s_f32, a_i32_trunc_s_f64, a_i64_trunc_s_f32, a_i64_trunc_s_f64,
|
||||||
a_i32_trunc_u_f32, a_i32_trunc_u_f64, a_i64_trunc_u_f32, a_i64_trunc_u_f64,
|
a_i32_trunc_u_f32, a_i32_trunc_u_f64, a_i64_trunc_u_f32, a_i64_trunc_u_f64,
|
||||||
a_f32_demote_f64, a_f64_promote_f32,
|
a_f32_demote_f64, a_f64_promote_f32,
|
||||||
|
@ -2245,13 +2245,26 @@ implementation
|
|||||||
else if tocgsize in [OS_S64,OS_64] then
|
else if tocgsize in [OS_S64,OS_64] then
|
||||||
begin
|
begin
|
||||||
{ extend }
|
{ extend }
|
||||||
if tocgsize = OS_S64 then
|
case fromcgsize of
|
||||||
list.concat(taicpu.op_none(a_i64_extend_s_i32))
|
OS_8:
|
||||||
else
|
begin
|
||||||
list.concat(taicpu.op_none(a_i64_extend_u_i32));
|
a_op_const_stack(list,OP_AND,s32inttype,255);
|
||||||
{ if it was an unsigned 32 bit value, remove sign extension }
|
list.concat(taicpu.op_none(a_i64_extend_u_i32));
|
||||||
if fromcgsize=OS_32 then
|
end;
|
||||||
a_op_const_stack(list,OP_AND,s64inttype,cardinal($ffffffff));
|
OS_S8:
|
||||||
|
list.concat(taicpu.op_none(a_i64_extend_s_8));
|
||||||
|
OS_16:
|
||||||
|
begin
|
||||||
|
a_op_const_stack(list,OP_AND,s32inttype,65535);
|
||||||
|
list.concat(taicpu.op_none(a_i64_extend_u_i32));
|
||||||
|
end;
|
||||||
|
OS_S16:
|
||||||
|
list.concat(taicpu.op_none(a_i64_extend_s_16));
|
||||||
|
OS_32:
|
||||||
|
list.concat(taicpu.op_none(a_i64_extend_u_i32));
|
||||||
|
OS_S32:
|
||||||
|
list.concat(taicpu.op_none(a_i64_extend_s_i32))
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
{ Conversions between 32 and 64 bit types have been completely handled
|
{ Conversions between 32 and 64 bit types have been completely handled
|
||||||
above. We still may have to truncate or sign extend in case the
|
above. We still may have to truncate or sign extend in case the
|
||||||
@ -2259,40 +2272,16 @@ implementation
|
|||||||
sign. In case the destination is a widechar and the source is not, we
|
sign. In case the destination is a widechar and the source is not, we
|
||||||
also have to insert a conversion to widechar.
|
also have to insert a conversion to widechar.
|
||||||
}
|
}
|
||||||
if (not(fromcgsize in [OS_S64,OS_64,OS_32,OS_S32]) or
|
case fromcgsize of
|
||||||
not(tocgsize in [OS_S64,OS_64,OS_32,OS_S32])) and
|
OS_8:
|
||||||
((tcgsize2size[fromcgsize]>tcgsize2size[tocgsize]) or
|
a_op_const_stack(list,OP_AND,s32inttype,255);
|
||||||
((tcgsize2size[fromcgsize]=tcgsize2size[tocgsize]) and
|
OS_S8:
|
||||||
(fromcgsize<>tocgsize)) or
|
list.concat(taicpu.op_none(a_i32_extend_s_8));
|
||||||
{ needs to mask out the sign in the top 16 bits }
|
OS_16:
|
||||||
((fromcgsize=OS_S8) and
|
a_op_const_stack(list,OP_AND,s32inttype,65535);
|
||||||
(tocgsize=OS_16)) or
|
OS_S16:
|
||||||
((tosize=cwidechartype) and
|
list.concat(taicpu.op_none(a_i32_extend_s_16));
|
||||||
(fromsize<>cwidechartype))) then
|
end;
|
||||||
case tocgsize of
|
|
||||||
OS_8:
|
|
||||||
//todo: conversion
|
|
||||||
//a_op_const_stack(list,OP_AND,s32inttype,255);
|
|
||||||
;
|
|
||||||
OS_S8:
|
|
||||||
//todo: conversion
|
|
||||||
//list.concat(taicpu.op_none(a_i2b));
|
|
||||||
;
|
|
||||||
OS_16:
|
|
||||||
//todo: conversion
|
|
||||||
//if (tosize.typ=orddef) and
|
|
||||||
// (torddef(tosize).ordtype=uwidechar) then
|
|
||||||
// list.concat(taicpu.op_none(a_i2c))
|
|
||||||
//else
|
|
||||||
// a_op_const_stack(list,OP_AND,s32inttype,65535);
|
|
||||||
;
|
|
||||||
OS_S16:
|
|
||||||
//todo: conversion
|
|
||||||
//list.concat(taicpu.op_none(a_i2s));
|
|
||||||
;
|
|
||||||
else
|
|
||||||
;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure thlcgwasm.maybe_resize_stack_para_val(list: TAsmList; retdef: tdef; callside: boolean);
|
procedure thlcgwasm.maybe_resize_stack_para_val(list: TAsmList; retdef: tdef; callside: boolean);
|
||||||
|
@ -67,7 +67,8 @@ interface
|
|||||||
'f32.eq', 'f64.eq', 'f32.ne', 'f64.ne', 'f32.lt', 'f64.lt',
|
'f32.eq', 'f64.eq', 'f32.ne', 'f64.ne', 'f32.lt', 'f64.lt',
|
||||||
'f32.le', 'f64.le', 'f32.gt', 'f64.gt', 'f32.ge', 'f64.gt',
|
'f32.le', 'f64.le', 'f32.gt', 'f64.gt', 'f32.ge', 'f64.gt',
|
||||||
// conversion
|
// conversion
|
||||||
'i32.wrap/i64', 'i64.extend_s/i32', 'i64.extend_u/i32',
|
'i32.wrap_i64', 'i64.extend_i32_s', 'i64.extend_i32_u',
|
||||||
|
'i32.extend8_s','i32.extend16_s','i64.extend8_s','i64.extend16_s','i64.extend32_s',
|
||||||
'i32.trunc_s/f32', 'i32.trunc_s/f64', 'i64.trunc_s/f32', 'i64.trunc_s/f64',
|
'i32.trunc_s/f32', 'i32.trunc_s/f64', 'i64.trunc_s/f32', 'i64.trunc_s/f64',
|
||||||
'i32.trunc_u/f32', 'i32.trunc_u/f64', 'i64.trunc_u/f32', 'i64.trunc_u/f64',
|
'i32.trunc_u/f32', 'i32.trunc_u/f64', 'i64.trunc_u/f32', 'i64.trunc_u/f64',
|
||||||
'f32.demote/f64', 'f64.promote/f32',
|
'f32.demote/f64', 'f64.promote/f32',
|
||||||
|
@ -130,7 +130,7 @@ implementation
|
|||||||
(torddef(resultdef).ordtype=s64bit) then
|
(torddef(resultdef).ordtype=s64bit) then
|
||||||
begin
|
begin
|
||||||
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_i64_rem_s));
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_i64_rem_s));
|
||||||
thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,2);
|
thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
'f32.le', 'f64.le', 'f32.gt', 'f64.gt', 'f32.ge', 'f64.gt',
|
'f32.le', 'f64.le', 'f32.gt', 'f64.gt', 'f32.ge', 'f64.gt',
|
||||||
// conversion
|
// conversion
|
||||||
'i32.wrap/i64', 'i64.extend_s/i32', 'i64.extend_u/i32',
|
'i32.wrap/i64', 'i64.extend_s/i32', 'i64.extend_u/i32',
|
||||||
|
'i32.extend_s/8','i32.extend_s/16','i64.extend_s/8','i64.extend_s/16','i64.extend_s/32',
|
||||||
'i32.trunc_s/f32', 'i32.trunc_s/f64', 'i64.trunc_s/f32', 'i64.trunc_s/f64',
|
'i32.trunc_s/f32', 'i32.trunc_s/f64', 'i64.trunc_s/f32', 'i64.trunc_s/f64',
|
||||||
'i32.trunc_u/f32', 'i32.trunc_u/f64', 'i64.trunc_u/f32', 'i64.trunc_u/f64',
|
'i32.trunc_u/f32', 'i32.trunc_u/f64', 'i64.trunc_u/f32', 'i64.trunc_u/f64',
|
||||||
'f32.demote/f64', 'f64.promote/f32',
|
'f32.demote/f64', 'f64.promote/f32',
|
||||||
|
Loading…
Reference in New Issue
Block a user