mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 21:00:30 +02:00
* fixed WebAssembly code generation for integer unary minus with overflow checking
This commit is contained in:
parent
b11434a6f8
commit
90e43e055b
@ -46,6 +46,7 @@ interface
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
twasmunaryminusnode = class(tcgunaryminusnode)
|
twasmunaryminusnode = class(tcgunaryminusnode)
|
||||||
|
procedure second_integer;override;
|
||||||
procedure second_float;override;
|
procedure second_float;override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -211,6 +212,30 @@ implementation
|
|||||||
twasmunaryminustnode
|
twasmunaryminustnode
|
||||||
*****************************************************************************}
|
*****************************************************************************}
|
||||||
|
|
||||||
|
procedure twasmunaryminusnode.second_integer;
|
||||||
|
var
|
||||||
|
hl: tasmlabel;
|
||||||
|
begin
|
||||||
|
secondpass(left);
|
||||||
|
if not(left.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
|
||||||
|
hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,false);
|
||||||
|
location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
|
||||||
|
location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
|
||||||
|
|
||||||
|
if (cs_check_overflow in current_settings.localswitches) then
|
||||||
|
begin
|
||||||
|
current_asmdata.getjumplabel(hl);
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_block));
|
||||||
|
hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,resultdef,OC_NE,torddef(resultdef).low.svalue,left.location.register,hl);
|
||||||
|
hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_overflow',[],nil).resetiftemp;
|
||||||
|
hlcg.a_label(current_asmdata.CurrAsmList,hl);
|
||||||
|
current_asmdata.CurrAsmList.concat(taicpu.op_none(a_end_block));
|
||||||
|
end;
|
||||||
|
|
||||||
|
hlcg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,resultdef,left.location.register,location.register);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure twasmunaryminusnode.second_float;
|
procedure twasmunaryminusnode.second_float;
|
||||||
var
|
var
|
||||||
opc: tasmop;
|
opc: tasmop;
|
||||||
|
Loading…
Reference in New Issue
Block a user