|
@@ -92,9 +92,6 @@ uses
|
|
|
|
|
|
procedure a_jmp_always(list : TAsmList;l: tasmlabel); override;
|
|
procedure a_jmp_always(list : TAsmList;l: tasmlabel); override;
|
|
|
|
|
|
- procedure g_concatcopy(list : TAsmList;size: tdef; const source,dest : treference);override;
|
|
|
|
- procedure g_copyshortstring(list : TAsmList;const source,dest : treference;strdef:tstringdef);override;
|
|
|
|
-
|
|
|
|
procedure a_loadfpu_ref_ref(list: TAsmList; fromsize, tosize: tdef; const ref1, ref2: treference); override;
|
|
procedure a_loadfpu_ref_ref(list: TAsmList; fromsize, tosize: tdef; const ref1, ref2: treference); override;
|
|
procedure a_loadfpu_ref_reg(list: TAsmList; fromsize, tosize: tdef; const ref: treference; reg: tregister); override;
|
|
procedure a_loadfpu_ref_reg(list: TAsmList; fromsize, tosize: tdef; const ref: treference; reg: tregister); override;
|
|
procedure a_loadfpu_reg_ref(list: TAsmList; fromsize, tosize: tdef; reg: tregister; const ref: treference); override;
|
|
procedure a_loadfpu_reg_ref(list: TAsmList; fromsize, tosize: tdef; reg: tregister; const ref: treference); override;
|
|
@@ -207,12 +204,6 @@ uses
|
|
{ in case of an OS_32 OP_DIV, we have to use an OS_S64 OP_IDIV because the
|
|
{ in case of an OS_32 OP_DIV, we have to use an OS_S64 OP_IDIV because the
|
|
JVM does not support unsigned divisions }
|
|
JVM does not support unsigned divisions }
|
|
procedure maybepreparedivu32(list: TAsmList; var op: topcg; size: tdef; out isdivu32: boolean);
|
|
procedure maybepreparedivu32(list: TAsmList; var op: topcg; size: tdef; out isdivu32: boolean);
|
|
-
|
|
|
|
- { concatcopy helpers }
|
|
|
|
- procedure concatcopy_normal_array(list: TAsmList; size: tdef; const source, dest: treference);
|
|
|
|
- procedure concatcopy_record(list: TAsmList; size: tdef; const source, dest: treference);
|
|
|
|
- procedure concatcopy_set(list: TAsmList; size: tdef; const source, dest: treference);
|
|
|
|
- procedure concatcopy_shortstring(list: TAsmList; size: tdef; const source, dest: treference);
|
|
|
|
end;
|
|
end;
|
|
|
|
|
|
implementation
|
|
implementation
|
|
@@ -1166,217 +1157,6 @@ implementation
|
|
Internalerror(2019091806); // unexpected jump
|
|
Internalerror(2019091806); // unexpected jump
|
|
end;
|
|
end;
|
|
|
|
|
|
- procedure thlcgwasm.concatcopy_normal_array(list: TAsmList; size: tdef; const source, dest: treference);
|
|
|
|
- var
|
|
|
|
- procname: string;
|
|
|
|
- eledef: tdef;
|
|
|
|
- ndim: longint;
|
|
|
|
- adddefaultlenparas: boolean;
|
|
|
|
- tmpsource, tmpdest: treference;
|
|
|
|
- begin
|
|
|
|
- tmpsource:=source;
|
|
|
|
- tmpdest:=dest;
|
|
|
|
- { load copy helper parameters on the stack }
|
|
|
|
- a_load_ref_stack(list,ptruinttype,source,prepare_stack_for_ref(list,tmpsource,false));
|
|
|
|
- a_load_ref_stack(list,ptruinttype,dest,prepare_stack_for_ref(list,tmpdest,false));
|
|
|
|
- { call copy helper }
|
|
|
|
- eledef:=tarraydef(size).elementdef;
|
|
|
|
- ndim:=1;
|
|
|
|
- adddefaultlenparas:=true;
|
|
|
|
- case eledef.typ of
|
|
|
|
- orddef:
|
|
|
|
- begin
|
|
|
|
- case torddef(eledef).ordtype of
|
|
|
|
- pasbool1,pasbool8,s8bit,u8bit,bool8bit,uchar,
|
|
|
|
- s16bit,u16bit,bool16bit,pasbool16,
|
|
|
|
- uwidechar,
|
|
|
|
- s32bit,u32bit,bool32bit,pasbool32,
|
|
|
|
- s64bit,u64bit,bool64bit,pasbool64,scurrency:
|
|
|
|
- procname:='FPC_COPY_SHALLOW_ARRAY'
|
|
|
|
- else
|
|
|
|
- internalerror(2011020504);
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- arraydef:
|
|
|
|
- begin
|
|
|
|
- { call fpc_setlength_dynarr_multidim with deepcopy=true, and extra
|
|
|
|
- parameters }
|
|
|
|
- while (eledef.typ=arraydef) and
|
|
|
|
- not is_dynamic_array(eledef) do
|
|
|
|
- begin
|
|
|
|
- eledef:=tarraydef(eledef).elementdef;
|
|
|
|
- inc(ndim)
|
|
|
|
- end;
|
|
|
|
- if (ndim=1) then
|
|
|
|
- procname:='FPC_COPY_SHALLOW_ARRAY'
|
|
|
|
- else
|
|
|
|
- begin
|
|
|
|
- { deepcopy=true }
|
|
|
|
- a_load_const_stack(list,pasbool1type,1,R_INTREGISTER);
|
|
|
|
- { ndim }
|
|
|
|
- a_load_const_stack(list,s32inttype,ndim,R_INTREGISTER);
|
|
|
|
- { eletype }
|
|
|
|
- { todo: WASM
|
|
|
|
- a_load_const_stack(list,cwidechartype,ord(jvmarrtype_setlength(eledef)),R_INTREGISTER);
|
|
|
|
- }
|
|
|
|
- adddefaultlenparas:=false;
|
|
|
|
- procname:='FPC_SETLENGTH_DYNARR_MULTIDIM';
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- recorddef:
|
|
|
|
- procname:='FPC_COPY_JRECORD_ARRAY';
|
|
|
|
- procvardef:
|
|
|
|
- if tprocvardef(eledef).is_addressonly then
|
|
|
|
- procname:='FPC_COPY_SHALLOW_ARRAY'
|
|
|
|
- else
|
|
|
|
- procname:='FPC_COPY_JPROCVAR_ARRAY';
|
|
|
|
- setdef:
|
|
|
|
- if tsetdef(eledef).elementdef.typ=enumdef then
|
|
|
|
- procname:='FPC_COPY_JENUMSET_ARRAY'
|
|
|
|
- else
|
|
|
|
- procname:='FPC_COPY_JBITSET_ARRAY';
|
|
|
|
- floatdef:
|
|
|
|
- procname:='FPC_COPY_SHALLOW_ARRAY';
|
|
|
|
- stringdef:
|
|
|
|
- if is_shortstring(eledef) then
|
|
|
|
- procname:='FPC_COPY_JSHORTSTRING_ARRAY'
|
|
|
|
- else
|
|
|
|
- procname:='FPC_COPY_SHALLOW_ARRAY';
|
|
|
|
- variantdef:
|
|
|
|
- begin
|
|
|
|
-{$ifndef nounsupported}
|
|
|
|
- procname:='FPC_COPY_SHALLOW_ARRAY';
|
|
|
|
-{$else}
|
|
|
|
- { todo: make a deep copy via clone... }
|
|
|
|
- internalerror(2011020505);
|
|
|
|
-{$endif}
|
|
|
|
- end;
|
|
|
|
- else
|
|
|
|
- procname:='FPC_COPY_SHALLOW_ARRAY';
|
|
|
|
- end;
|
|
|
|
- if adddefaultlenparas then
|
|
|
|
- begin
|
|
|
|
- { -1, -1 means "copy entire array" }
|
|
|
|
- a_load_const_stack(list,s32inttype,-1,R_INTREGISTER);
|
|
|
|
- a_load_const_stack(list,s32inttype,-1,R_INTREGISTER);
|
|
|
|
- end;
|
|
|
|
- g_call_system_proc(list,procname,[],nil);
|
|
|
|
- if ndim<>1 then
|
|
|
|
- begin
|
|
|
|
- { pop return value, must be the same as dest }
|
|
|
|
- //list.concat(taicpu.op_none(a_pop));
|
|
|
|
- Internalerror(2019083001); // no support for arrays
|
|
|
|
- decstack(list,1);
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- procedure thlcgwasm.concatcopy_record(list: TAsmList; size: tdef; const source, dest: treference);
|
|
|
|
- var
|
|
|
|
- srsym: tsym;
|
|
|
|
- pd: tprocdef;
|
|
|
|
- tmpsource, tmpdest: treference;
|
|
|
|
- begin
|
|
|
|
- tmpsource:=source;
|
|
|
|
- tmpdest:=dest;
|
|
|
|
- { self }
|
|
|
|
- a_load_ref_stack(list,size,tmpsource,prepare_stack_for_ref(list,tmpsource,false));
|
|
|
|
- { result }
|
|
|
|
- a_load_ref_stack(list,size,tmpdest,prepare_stack_for_ref(list,tmpdest,false));
|
|
|
|
- { call fpcDeepCopy helper }
|
|
|
|
- srsym:=search_struct_member(tabstractrecorddef(size),'FPCDEEPCOPY');
|
|
|
|
- if not assigned(srsym) or
|
|
|
|
- (srsym.typ<>procsym) then
|
|
|
|
- Message1(cg_f_unknown_compilerproc,size.typename+'.fpcDeepCopy');
|
|
|
|
- pd:=tprocdef(tprocsym(srsym).procdeflist[0]);
|
|
|
|
- a_call_name(list,pd,pd.mangledname,[],nil,false);
|
|
|
|
- { both parameters are removed, no function result }
|
|
|
|
- decstack(list,2);
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- procedure thlcgwasm.concatcopy_set(list: TAsmList; size: tdef; const source, dest: treference);
|
|
|
|
- var
|
|
|
|
- tmpsource, tmpdest: treference;
|
|
|
|
- begin
|
|
|
|
- tmpsource:=source;
|
|
|
|
- tmpdest:=dest;
|
|
|
|
- a_load_ref_stack(list,size,tmpsource,prepare_stack_for_ref(list,tmpsource,false));
|
|
|
|
- a_load_ref_stack(list,size,tmpdest,prepare_stack_for_ref(list,tmpdest,false));
|
|
|
|
- { call set copy helper }
|
|
|
|
- if tsetdef(size).elementdef.typ=enumdef then
|
|
|
|
- g_call_system_proc(list,'fpc_enumset_copy',[],nil)
|
|
|
|
- else
|
|
|
|
- g_call_system_proc(list,'fpc_bitset_copy',[],nil);
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- procedure thlcgwasm.concatcopy_shortstring(list: TAsmList; size: tdef; const source, dest: treference);
|
|
|
|
- var
|
|
|
|
- srsym: tsym;
|
|
|
|
- pd: tprocdef;
|
|
|
|
- tmpsource, tmpdest: treference;
|
|
|
|
- begin
|
|
|
|
- tmpsource:=source;
|
|
|
|
- tmpdest:=dest;
|
|
|
|
- { self }
|
|
|
|
- a_load_ref_stack(list,size,tmpsource,prepare_stack_for_ref(list,tmpsource,false));
|
|
|
|
- { result }
|
|
|
|
- a_load_ref_stack(list,size,tmpdest,prepare_stack_for_ref(list,tmpdest,false));
|
|
|
|
- { call fpcDeepCopy helper }
|
|
|
|
- srsym:=search_struct_member(java_shortstring,'FPCDEEPCOPY');
|
|
|
|
- if not assigned(srsym) or
|
|
|
|
- (srsym.typ<>procsym) then
|
|
|
|
- Message1(cg_f_unknown_compilerproc,'ShortstringClass.FpcDeepCopy');
|
|
|
|
- pd:=tprocdef(tprocsym(srsym).procdeflist[0]);
|
|
|
|
- a_call_name(list,pd,pd.mangledname,[],nil,false);
|
|
|
|
- { both parameters are removed, no function result }
|
|
|
|
- decstack(list,2);
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- procedure thlcgwasm.g_concatcopy(list: TAsmList; size: tdef; const source, dest: treference);
|
|
|
|
- var
|
|
|
|
- handled: boolean;
|
|
|
|
- begin
|
|
|
|
- handled:=false;
|
|
|
|
- case size.typ of
|
|
|
|
- arraydef:
|
|
|
|
- begin
|
|
|
|
- if not is_dynamic_array(size) then
|
|
|
|
- begin
|
|
|
|
- concatcopy_normal_array(list,size,source,dest);
|
|
|
|
- handled:=true;
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- recorddef:
|
|
|
|
- begin
|
|
|
|
- concatcopy_record(list,size,source,dest);
|
|
|
|
- handled:=true;
|
|
|
|
- end;
|
|
|
|
- setdef:
|
|
|
|
- begin
|
|
|
|
- concatcopy_set(list,size,source,dest);
|
|
|
|
- handled:=true;
|
|
|
|
- end;
|
|
|
|
- stringdef:
|
|
|
|
- begin
|
|
|
|
- if is_shortstring(size) then
|
|
|
|
- begin
|
|
|
|
- concatcopy_shortstring(list,size,source,dest);
|
|
|
|
- handled:=true;
|
|
|
|
- end;
|
|
|
|
- end;
|
|
|
|
- else
|
|
|
|
- ;
|
|
|
|
- end;
|
|
|
|
- if not handled then
|
|
|
|
- inherited;
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
- procedure thlcgwasm.g_copyshortstring(list: TAsmList; const source, dest: treference; strdef: tstringdef);
|
|
|
|
- begin
|
|
|
|
- concatcopy_shortstring(list,strdef,source,dest);
|
|
|
|
- end;
|
|
|
|
-
|
|
|
|
procedure thlcgwasm.a_loadfpu_ref_ref(list: TAsmList; fromsize, tosize: tdef; const ref1, ref2: treference);
|
|
procedure thlcgwasm.a_loadfpu_ref_ref(list: TAsmList; fromsize, tosize: tdef; const ref1, ref2: treference);
|
|
var
|
|
var
|
|
dstack_slots: longint;
|
|
dstack_slots: longint;
|