diff --git a/compiler/wasm32/nwasminl.pas b/compiler/wasm32/nwasminl.pas index 4a456b263f..090e757e80 100644 --- a/compiler/wasm32/nwasminl.pas +++ b/compiler/wasm32/nwasminl.pas @@ -38,11 +38,14 @@ interface procedure second_memory_size; procedure second_memory_grow; procedure second_unreachable; + protected + function first_sqr_real: tnode; override; public function pass_typecheck_cpu: tnode; override; function first_cpu: tnode; override; procedure pass_generate_code_cpu; override; procedure second_length;override; + procedure second_sqr_real; override; end; implementation @@ -152,6 +155,13 @@ implementation end; + function twasminlinenode.first_sqr_real: tnode; + begin + expectloc:=LOC_FPUREGISTER; + first_sqr_real:=nil; + end; + + function twasminlinenode.pass_typecheck_cpu: tnode; begin Result:=nil; @@ -268,6 +278,30 @@ implementation end; end; + + procedure twasminlinenode.second_sqr_real; + begin + secondpass(left); + hlcg.location_force_fpureg(current_asmdata.CurrAsmList,left.location,left.resultdef,true); + + thlcgwasm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,left.resultdef,left.location); + thlcgwasm(hlcg).a_load_loc_stack(current_asmdata.CurrAsmList,left.resultdef,left.location); + + case left.location.size of + OS_F32: + current_asmdata.CurrAsmList.Concat(taicpu.op_none(a_f32_mul)); + OS_F64: + current_asmdata.CurrAsmList.Concat(taicpu.op_none(a_f64_mul)); + else + internalerror(2021060102); + end; + thlcgwasm(hlcg).decstack(current_asmdata.CurrAsmList,1); + + location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef)); + location.register:=hlcg.getregisterfordef(current_asmdata.CurrAsmList,resultdef); + thlcgwasm(hlcg).a_load_stack_loc(current_asmdata.CurrAsmList,resultdef,location); + end; + begin cinlinenode:=twasminlinenode; end.