diff --git a/compiler/arm/cpubase.pas b/compiler/arm/cpubase.pas index 46ca1d2705..8ae0c1febf 100644 --- a/compiler/arm/cpubase.pas +++ b/compiler/arm/cpubase.pas @@ -314,7 +314,7 @@ unit cpubase; (RS_R4,RS_R5,RS_R6,RS_R7,RS_R8,RS_R9,RS_R10); { this is only for the generic code which is not used for this architecture } - saved_mm_registers : array[0..0] of tsuperregister = (RS_NO); + saved_mm_registers : array[0..0] of tsuperregister = (RS_INVALID); { Required parameter alignment when calling a routine declared as stdcall and cdecl. The alignment value should be the one defined diff --git a/compiler/avr/cpubase.pas b/compiler/avr/cpubase.pas index 2b02b97751..b0a3ba014f 100644 --- a/compiler/avr/cpubase.pas +++ b/compiler/avr/cpubase.pas @@ -101,11 +101,11 @@ unit cpubase; { Float Super register first and last } first_fpu_supreg = RS_INVALID; - first_fpu_imreg = RS_INVALID; + first_fpu_imreg = 0; { MM Super register first and last } first_mm_supreg = RS_INVALID; - first_mm_imreg = RS_INVALID; + first_mm_imreg = 0; regnumber_count_bsstart = 32; diff --git a/compiler/cgobj.pas b/compiler/cgobj.pas index 674623deb5..51a8d68f88 100644 --- a/compiler/cgobj.pas +++ b/compiler/cgobj.pas @@ -2507,12 +2507,19 @@ implementation for r:=low(saved_mm_registers) to high(saved_mm_registers) do begin - if saved_mm_registers[r] in rg[R_MMREGISTER].used_in_proc then + { the array has to be declared even if no MM registers are saved + (such as with SSE on i386), and since 0-element arrays don't + exist, they contain a single RS_INVALID element in that case + } + if saved_mm_registers[r]<>RS_INVALID then begin - a_loadmm_reg_ref(list,OS_VECTOR,OS_VECTOR,newreg(R_MMREGISTER,saved_mm_registers[r],R_SUBNONE),href,nil); - inc(href.offset,tcgsize2size[OS_VECTOR]); + if saved_mm_registers[r] in rg[R_MMREGISTER].used_in_proc then + begin + a_loadmm_reg_ref(list,OS_VECTOR,OS_VECTOR,newreg(R_MMREGISTER,saved_mm_registers[r],R_SUBNONE),href,nil); + inc(href.offset,tcgsize2size[OS_VECTOR]); + end; + include(rg[R_MMREGISTER].preserved_by_proc,saved_mm_registers[r]); end; - include(rg[R_MMREGISTER].preserved_by_proc,saved_mm_registers[r]); end; end; end; diff --git a/compiler/jvm/cpubase.pas b/compiler/jvm/cpubase.pas index 57e6c46298..ee82ea3ede 100644 --- a/compiler/jvm/cpubase.pas +++ b/compiler/jvm/cpubase.pas @@ -254,7 +254,7 @@ uses ); { this is only for the generic code which is not used for this architecture } - saved_mm_registers : array[0..0] of tsuperregister = (RS_NO); + saved_mm_registers : array[0..0] of tsuperregister = (RS_INVALID); {# Required parameter alignment when calling a routine } diff --git a/compiler/m68k/cpubase.pas b/compiler/m68k/cpubase.pas index 42979a5dc5..9e8e140d6a 100644 --- a/compiler/m68k/cpubase.pas +++ b/compiler/m68k/cpubase.pas @@ -304,7 +304,7 @@ unit cpubase; saved_standard_address_registers : array[0..3] of tsuperregister = (RS_A2,RS_A3,RS_A4,RS_A5); { this is only for the generic code which is not used for this architecture } - saved_mm_registers : array[0..0] of tsuperregister = (RS_NO); + saved_mm_registers : array[0..0] of tsuperregister = (RS_INVALID); {# Required parameter alignment when calling a routine declared as stdcall and cdecl. The alignment value should be the one defined diff --git a/compiler/mips/cpubase.pas b/compiler/mips/cpubase.pas index 76ef839b19..e05cbe1b1b 100644 --- a/compiler/mips/cpubase.pas +++ b/compiler/mips/cpubase.pas @@ -244,7 +244,7 @@ unit cpubase; (RS_NO); { this is only for the generic code which is not used for this architecture } - saved_mm_registers : array[0..0] of tsuperregister = (RS_NO); + saved_mm_registers : array[0..0] of tsuperregister = (RS_INVALID); { Required parameter alignment when calling a routine declared as stdcall and cdecl. The alignment value should be the one defined diff --git a/compiler/powerpc/cpubase.pas b/compiler/powerpc/cpubase.pas index a33e214d48..629ccfee4a 100644 --- a/compiler/powerpc/cpubase.pas +++ b/compiler/powerpc/cpubase.pas @@ -352,7 +352,7 @@ uses ); { this is only for the generic code which is not used for this architecture } - saved_mm_registers : array[0..0] of tsuperregister = (RS_NO); + saved_mm_registers : array[0..0] of tsuperregister = (RS_INVALID); {# Required parameter alignment when calling a routine declared as stdcall and cdecl. The alignment value should be the one defined diff --git a/compiler/powerpc64/cpubase.pas b/compiler/powerpc64/cpubase.pas index 57cea3cbf4..ded99ac0e4 100644 --- a/compiler/powerpc64/cpubase.pas +++ b/compiler/powerpc64/cpubase.pas @@ -350,7 +350,7 @@ const ); { this is only for the generic code which is not used for this architecture } - saved_mm_registers : array[0..0] of tsuperregister = (RS_NO); + saved_mm_registers : array[0..0] of tsuperregister = (RS_INVALID); {# Required parameter alignment when calling a routine declared as stdcall and cdecl. The alignment value should be the one defined diff --git a/compiler/sparc/cpubase.pas b/compiler/sparc/cpubase.pas index d07eeebbf0..880b0be023 100644 --- a/compiler/sparc/cpubase.pas +++ b/compiler/sparc/cpubase.pas @@ -249,10 +249,10 @@ uses This value can be deduced from CALLED_USED_REGISTERS array in the GCC source. } - saved_standard_registers : array[0..0] of tsuperregister = (RS_NO); + saved_standard_registers : array[0..0] of tsuperregister = (RS_INVALID); { this is only for the generic code which is not used for this architecture } - saved_mm_registers : array[0..0] of tsuperregister = (RS_NO); + saved_mm_registers : array[0..0] of tsuperregister = (RS_INVALID); {# Required parameter alignment when calling a routine declared as stdcall and cdecl. The alignment value should be the one defined