* synchronized with trunk

git-svn-id: branches/wasm@47045 -
This commit is contained in:
nickysn 2020-10-03 21:39:57 +00:00
commit fd772822d1
34 changed files with 589 additions and 149 deletions

View File

@ -352,6 +352,24 @@ override PACKAGE_VERSION=3.3.1
unexport FPC_VERSION FPC_COMPILERINFO
CYCLETARGETS=i386 powerpc sparc arm x86_64 powerpc64 m68k armeb mipsel mips avr jvm i8086 aarch64 sparc64 riscv32 riscv64 xtensa z80 wasm32
ALLTARGETS=$(CYCLETARGETS)
NO_NATIVE_COMPILER_OS_LIST=amstradcpc embedded freertos gba macosclassic msdos msxdos nds palmos symbian watcom wii win16 zxspectrum
NO_NATIVE_COMPILER_CPU_LIST=avr i8086 jvm z80
ifneq ($(CPU_SOURCE),$(CPU_TARGET))
ifneq ($(findstring $(CPU_TARGET),$(NO_NATIVE_COMPILER_CPU_LIST)),)
NoNativeBinaries=1
endif
endif
ifneq ($(OS_SOURCE),$(OS_TARGET))
ifneq ($(findstring $(OS_TARGET),$(NO_NATIVE_COMPILER_OS_LIST)),)
NoNativeBinaries=1
endif
endif
ifndef FORCE_NATIVE_BINARIES
ifeq ($(NoNativeBinaries),1)
override EXEEXT=$(SRCEXEEXT)
CROSSINSTALL=1
endif
endif
ifdef POWERPC
PPC_TARGET=powerpc
endif
@ -619,37 +637,6 @@ OPTWPOPERFORM+=-Owsymbolliveness
endif
endif
endif
ifeq ($(CPU_TARGET),jvm)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),embedded)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),gba)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),msdos)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),nds)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),win16)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),macosclassic)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),freertos)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),zxspectrum)
NoNativeBinaries=1
endif
ifeq ($(NoNativeBinaries),1)
override EXEEXT=$(SRCEXEEXT)
CROSSINSTALL=1
endif
ifeq ($(FULL_TARGET),i386-linux)
override TARGET_DIRS+=utils
endif

View File

@ -37,6 +37,33 @@ CYCLETARGETS=i386 powerpc sparc arm x86_64 powerpc64 m68k armeb mipsel mips avr
# All supported targets used for clean
ALLTARGETS=$(CYCLETARGETS)
# All OS targets that do not support native compiler
NO_NATIVE_COMPILER_OS_LIST=amstradcpc embedded freertos gba macosclassic msdos msxdos nds palmos symbian watcom wii win16 zxspectrum
# All CPU targets that do not support native compiler
NO_NATIVE_COMPILER_CPU_LIST=avr i8086 jvm z80
# Don't compile a native compiler & utilities for targets
# which do not support it
ifneq ($(CPU_SOURCE),$(CPU_TARGET))
ifneq ($(findstring $(CPU_TARGET),$(NO_NATIVE_COMPILER_CPU_LIST)),)
NoNativeBinaries=1
endif
endif
ifneq ($(OS_SOURCE),$(OS_TARGET))
ifneq ($(findstring $(OS_TARGET),$(NO_NATIVE_COMPILER_OS_LIST)),)
NoNativeBinaries=1
endif
endif
ifndef FORCE_NATIVE_BINARIES
ifeq ($(NoNativeBinaries),1)
override EXEEXT=$(SRCEXEEXT)
# In those cases, installation in a cross-installation
CROSSINSTALL=1
endif
endif
# Allow POWERPC, POWERPC64, M68K, I386, jvm defines for target cpu
ifdef POWERPC
PPC_TARGET=powerpc
@ -388,43 +415,6 @@ endif
endif
endif
# Don't compile a native compiler & utilities for JVM and embedded
# targets
ifeq ($(CPU_TARGET),jvm)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),embedded)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),gba)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),msdos)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),nds)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),win16)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),macosclassic)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),freertos)
NoNativeBinaries=1
endif
ifeq ($(OS_TARGET),zxspectrum)
NoNativeBinaries=1
endif
# Allow install for jvm
ifeq ($(NoNativeBinaries),1)
override EXEEXT=$(SRCEXEEXT)
# In those cases, installation in a cross-installation
CROSSINSTALL=1
endif
[rules]
#####################################################################
# Setup Targets

View File

@ -1101,13 +1101,16 @@ Implementation
mov rX,...
mov rX,...
}
else if GetNextInstruction(p,hp1) and MatchInstruction(hp1,A_MOV) then
else if GetNextInstruction(p,hp1) and MatchInstruction(hp1,A_MOV) and
{ test condition here already instead in the while loop only, else MovMov2Mov 2 might be oversight }
MatchInstruction(hp1,A_MOV) and
MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) then
while MatchInstruction(hp1,A_MOV) and
MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) and
{ don't remove the first mov if the second is a mov rX,rX }
not(MatchOperand(taicpu(hp1).oper[0]^,taicpu(hp1).oper[1]^)) do
begin
DebugMsg('Peephole MovMov2Mov performed', p);
DebugMsg('Peephole MovMov2Mov 1 performed', p);
RemoveCurrentP(p,hp1);
Result := True;
@ -1115,7 +1118,28 @@ Implementation
GetNextInstruction(hp1,hp1);
if not assigned(hp1) then
break;
end;
end
{
This removes the second mov from
mov rX,rY
...
mov rX,rY
if rX and rY are not modified in-between
}
else if GetNextInstructionUsingReg(p,hp1,taicpu(p).oper[1]^.reg) and
MatchInstruction(hp1,A_MOV) and
MatchOperand(taicpu(p).oper[0]^, taicpu(hp1).oper[0]^) and
MatchOperand(taicpu(p).oper[1]^, taicpu(hp1).oper[1]^) and
not(RegModifiedBetween(taicpu(p).oper[0]^.reg,p,hp1)) then
begin
DebugMsg('Peephole MovMov2Mov 2 performed', p);
AllocRegBetween(taicpu(p).oper[0]^.reg,p,hp1,UsedRegs);
RemoveInstruction(hp1);
Result := True;
end;
end;
A_SBIC,
A_SBIS:

View File

@ -465,7 +465,7 @@ interface
fputype : fpu_none;
{$else not GENERIC_CPU}
{$ifdef i386}
cputype : cpu_Pentium;
cputype : cpu_Pentium2;
optimizecputype : cpu_Pentium3;
asmcputype : cpu_none;
fputype : fpu_x87;

View File

@ -1125,6 +1125,13 @@
'rdrand',
'rdseed',
'xgetbv',
'xsetbv',
'xsave',
'xsave64',
'xrstor',
'xrstor64',
'xsaveopt',
'xsaveopt64',
'prefetchwt1',
'kaddb',
'kaddd',

View File

@ -1125,6 +1125,13 @@ attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufINT,
attsufNONE,
attsufNONE,

View File

@ -1125,6 +1125,13 @@
'rdrand',
'rdseed',
'xgetbv',
'xsetbv',
'xsave',
'xsave64',
'xrstor',
'xrstor64',
'xsaveopt',
'xsaveopt64',
'prefetchwt1',
'kaddb',
'kaddd',

View File

@ -1,2 +1,2 @@
{ don't edit, this file is generated from x86ins.dat }
4143;
4150;

View File

@ -1125,6 +1125,13 @@ A_XTEST,
A_RDRAND,
A_RDSEED,
A_XGETBV,
A_XSETBV,
A_XSAVE,
A_XSAVE64,
A_XRSTOR,
A_XRSTOR64,
A_XSAVEOPT,
A_XSAVEOPT64,
A_PREFETCHWT1,
A_KADDB,
A_KADDD,

View File

@ -1125,6 +1125,13 @@
(Ch: [Ch_Wop1, Ch_WFlags]),
(Ch: [Ch_Wop1, Ch_WFlags]),
(Ch: [Ch_WEAX, Ch_WEDX, Ch_RECX]),
(Ch: [Ch_REAX, Ch_REDX, Ch_RECX]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),

View File

@ -20223,6 +20223,55 @@
code : #3#15#1#208;
flags : [if_xsave]
),
(
opcode : A_XSETBV;
ops : 0;
optypes : (ot_none,ot_none,ot_none,ot_none);
code : #3#15#1#209;
flags : [if_xsave]
),
(
opcode : A_XSAVE;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #2#15#174#132;
flags : [if_xsave]
),
(
opcode : A_XSAVE64;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #214#2#15#174#132;
flags : [if_xsave]
),
(
opcode : A_XRSTOR;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #2#15#174#133;
flags : [if_xsave]
),
(
opcode : A_XRSTOR64;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #214#2#15#174#133;
flags : [if_xsave]
),
(
opcode : A_XSAVEOPT;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #2#15#174#134;
flags : [if_xsave]
),
(
opcode : A_XSAVEOPT64;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #214#2#15#174#134;
flags : [if_xsave]
),
(
opcode : A_PREFETCHWT1;
ops : 1;

View File

@ -1139,6 +1139,13 @@
'rdrand',
'rdseed',
'xgetbv',
'xsetbv',
'xsave',
'xsave64',
'xrstor',
'xrstor64',
'xsaveopt',
'xsaveopt64',
'prefetchwt1',
'kaddb',
'kaddd',

View File

@ -1139,6 +1139,13 @@ attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufINT,
attsufNONE,
attsufNONE,

View File

@ -1139,6 +1139,13 @@
'rdrand',
'rdseed',
'xgetbv',
'xsetbv',
'xsave',
'xsave64',
'xrstor',
'xrstor64',
'xsaveopt',
'xsaveopt64',
'prefetchwt1',
'kaddb',
'kaddd',

View File

@ -1,2 +1,2 @@
{ don't edit, this file is generated from x86ins.dat }
4175;
4182;

View File

@ -1139,6 +1139,13 @@ A_XTEST,
A_RDRAND,
A_RDSEED,
A_XGETBV,
A_XSETBV,
A_XSAVE,
A_XSAVE64,
A_XRSTOR,
A_XRSTOR64,
A_XSAVEOPT,
A_XSAVEOPT64,
A_PREFETCHWT1,
A_KADDB,
A_KADDD,

View File

@ -1139,6 +1139,13 @@
(Ch: [Ch_Wop1, Ch_WFlags]),
(Ch: [Ch_Wop1, Ch_WFlags]),
(Ch: [Ch_WEAX, Ch_WEDX, Ch_RECX]),
(Ch: [Ch_REAX, Ch_REDX, Ch_RECX]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),

View File

@ -20447,6 +20447,55 @@
code : #3#15#1#208;
flags : [if_xsave]
),
(
opcode : A_XSETBV;
ops : 0;
optypes : (ot_none,ot_none,ot_none,ot_none);
code : #3#15#1#209;
flags : [if_xsave]
),
(
opcode : A_XSAVE;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #2#15#174#132;
flags : [if_xsave]
),
(
opcode : A_XSAVE64;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #214#2#15#174#132;
flags : [if_xsave]
),
(
opcode : A_XRSTOR;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #2#15#174#133;
flags : [if_xsave]
),
(
opcode : A_XRSTOR64;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #214#2#15#174#133;
flags : [if_xsave]
),
(
opcode : A_XSAVEOPT;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #2#15#174#134;
flags : [if_xsave]
),
(
opcode : A_XSAVEOPT64;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #214#2#15#174#134;
flags : [if_xsave]
),
(
opcode : A_PREFETCHWT1;
ops : 1;

View File

@ -1046,7 +1046,7 @@ interface
begin
if tai_symbol(hp).sym.typ=AT_FUNCTION then
WriteProcedureHeader(hp)
else if tai_symbol(hp).sym.typ=AT_DATA then
else if tai_symbol(hp).sym.typ in [AT_DATA,AT_METADATA] then
begin
s:= tai_symbol(hp).sym.name;
WriteDataHeader(s, tai_symbol(hp).is_global, true);

View File

@ -175,7 +175,7 @@ function TLinkerZXSpectrum.WriteResponseFile_Vlink: Boolean;
Add(' . = 0x'+hexstr(FOrigin,4)+';');
Add(' .text : { *(.text .text.* _CODE _CODE.* ) }');
Add(' .data : { *(.data .data.* .rodata .rodata.* .fpc.* ) }');
Add(' .bss : { *(.bss .bss.* _BSS _BSS.* _BSSEND _BSSEND.* _HEAP _HEAP.* .stack .stack.* _STACK _STACK.* ) }');
Add(' .bss : { *(_BSS _BSS.*) *(.bss .bss.*) *(_BSSEND _BSSEND.*) *(_HEAP _HEAP.*) *(.stack .stack.*) *(_STACK _STACK.*) }');
Add('}');
end;

View File

@ -4187,7 +4187,7 @@ ymmreg_mz,zmmreg_er \334\350\351\352\370\1\xE6\110
; VCVTPD2PS xmmreg_mz,mem256 must come first - map MemRefSize 256bits correct
; map all other MemrefSize (without broasdcast MemRef) to xmmreg, xmmrm
; map all other MemrefSize (without broasdcast MemRef) to xmmreg, xmmrm
[VCVTPD2PS,vcvtpd2psM]
(Ch_Wop2, Ch_Rop1)
xmmreg_mz,mem256 \350\352\361\362\364\370\1\x5A\110 AVX,SANDYBRIDGE,TFV
@ -4286,7 +4286,7 @@ reg64,mem32 \333\350\352\362\363\370\1\x2D\110
reg64,xmmreg_er \333\350\352\362\363\370\1\x2D\110 AVX,SANDYBRIDGE
; VCVTTPD2DQ xmmreg_mz,mem256 must come first - map MemRefSize 256bits correct
; map all other MemrefSize (without broasdcast MemRef) to xmmreg, xmmrm
; map all other MemrefSize (without broasdcast MemRef) to xmmreg, xmmrm
[VCVTTPD2DQ,vcvttpd2dqM]
(Ch_Wop2, Ch_Rop1)
xmmreg_mz,mem256 \350\352\361\362\364\370\1\xE6\110 AVX,SANDYBRIDGE,AVX512,TFV
@ -6924,6 +6924,35 @@ reg16|32|64 \320\2\x0F\xC7\207 RAND
(Ch_WEAX, Ch_WEDX, Ch_RECX)
void \3\x0F\x01\xD0 XSAVE
[XSETBV]
(Ch_REAX, Ch_REDX, Ch_RECX)
void \3\x0F\x01\xD1 XSAVE
[XSAVE]
(Ch_All)
mem \2\x0F\xAE\204 XSAVE
[XSAVE64]
(Ch_All)
mem \326\2\x0F\xAE\204 XSAVE
[XRSTOR]
(Ch_All)
mem \2\x0F\xAE\205 XSAVE
[XRSTOR64]
(Ch_All)
mem \326\2\x0F\xAE\205 XSAVE
[XSAVEOPT]
(Ch_All)
mem \2\x0F\xAE\206 XSAVE
[XSAVEOPT64]
(Ch_All)
mem \326\2\x0F\xAE\206 XSAVE
;*******************************************************************************
;********** PREFETCHWT1 ********************************************************
;*******************************************************************************
@ -6931,7 +6960,6 @@ void \3\x0F\x01\xD0 XSAVE
(Ch_All)
mem \2\x0F\x0D\202 PREFETCHWT1
;*******************************************************************************
;********** AVX 512 - MASKRegister *********************************************
;*******************************************************************************

View File

@ -1121,6 +1121,13 @@ attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufNONE,
attsufINT,
attsufNONE,
attsufNONE,

View File

@ -1121,6 +1121,13 @@
'rdrand',
'rdseed',
'xgetbv',
'xsetbv',
'xsave',
'xsave64',
'xrstor',
'xrstor64',
'xsaveopt',
'xsaveopt64',
'prefetchwt1',
'kaddb',
'kaddd',

View File

@ -1121,6 +1121,13 @@
'rdrand',
'rdseed',
'xgetbv',
'xsetbv',
'xsave',
'xsave64',
'xrstor',
'xrstor64',
'xsaveopt',
'xsaveopt64',
'prefetchwt1',
'kaddb',
'kaddd',

View File

@ -1,2 +1,2 @@
{ don't edit, this file is generated from x86ins.dat }
4207;
4214;

View File

@ -1121,6 +1121,13 @@ A_XTEST,
A_RDRAND,
A_RDSEED,
A_XGETBV,
A_XSETBV,
A_XSAVE,
A_XSAVE64,
A_XRSTOR,
A_XRSTOR64,
A_XSAVEOPT,
A_XSAVEOPT64,
A_PREFETCHWT1,
A_KADDB,
A_KADDD,

View File

@ -1121,6 +1121,13 @@
(Ch: [Ch_Wop1, Ch_WFlags]),
(Ch: [Ch_Wop1, Ch_WFlags]),
(Ch: [Ch_WEAX, Ch_WEDX, Ch_RECX]),
(Ch: [Ch_REAX, Ch_REDX, Ch_RECX]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),
(Ch: [Ch_All]),

View File

@ -20671,6 +20671,55 @@
code : #3#15#1#208;
flags : [if_xsave]
),
(
opcode : A_XSETBV;
ops : 0;
optypes : (ot_none,ot_none,ot_none,ot_none);
code : #3#15#1#209;
flags : [if_xsave]
),
(
opcode : A_XSAVE;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #2#15#174#132;
flags : [if_xsave]
),
(
opcode : A_XSAVE64;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #214#2#15#174#132;
flags : [if_xsave]
),
(
opcode : A_XRSTOR;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #2#15#174#133;
flags : [if_xsave]
),
(
opcode : A_XRSTOR64;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #214#2#15#174#133;
flags : [if_xsave]
),
(
opcode : A_XSAVEOPT;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #2#15#174#134;
flags : [if_xsave]
),
(
opcode : A_XSAVEOPT64;
ops : 1;
optypes : (ot_memory,ot_none,ot_none,ot_none);
code : #214#2#15#174#134;
flags : [if_xsave]
),
(
opcode : A_PREFETCHWT1;
ops : 1;

View File

@ -1796,7 +1796,7 @@ end;
function TJSONBoolean.GetAsString: TJSONStringType;
begin
Result:=BoolToStr(FValue, True);
Result:=BoolToStr(FValue, 'true', 'false');
end;
procedure TJSONBoolean.SetAsString(const AValue: TJSONStringType);

View File

@ -19,7 +19,7 @@ unit testjsondata;
interface
uses
Classes, SysUtils, fpcunit, testregistry, fpjson, contnrs;
Classes, SysUtils, fpcunit, testregistry, fpjson;
type
TMyNull = Class(TJSONNull);
@ -1311,7 +1311,7 @@ begin
TestAsInteger(J,1);
TestAsInt64(J,1);
TestAsQword(J,1);
TestAsString(J,BoolToStr(True,True));
TestAsString(J,BoolToStr(True,'true','false'));
TestAsFloat(J,1.0);
finally
FreeAndNil(J);
@ -1334,7 +1334,7 @@ begin
TestAsInteger(J,0);
TestAsInt64(J,0);
TestAsQWord(J,0);
TestAsString(J,BoolToStr(False,True));
TestAsString(J,BoolToStr(False,'true','false'));
TestAsFloat(J,0.0);
finally
FreeAndNil(J);

View File

@ -29715,12 +29715,19 @@ function TPasResolver.CheckClassIsClass(SrcType, DestType: TPasType): integer;
i: Integer;
SrcParam, DestParam: TPasType;
SrcParamScope, DestParamScope: TPasGenericScope;
SrcSpecializedFromItem, DestSpecializedFromItem: TPRSpecializedItem;
begin
if SrcScope.SpecializedFromItem.GenericEl<>DestScope.SpecializedFromItem.GenericEl then
SrcSpecializedFromItem:=SrcScope.SpecializedFromItem;
DestSpecializedFromItem:=DestScope.SpecializedFromItem;
if SrcSpecializedFromItem=nil then
exit(false);
if DestSpecializedFromItem=nil then
exit(false);
if SrcSpecializedFromItem.GenericEl<>DestSpecializedFromItem.GenericEl then
exit(false);
// specialized from same generic -> check params
SrcParams:=SrcScope.SpecializedFromItem.Params;
DestParams:=DestScope.SpecializedFromItem.Params;
SrcParams:=SrcSpecializedFromItem.Params;
DestParams:=DestSpecializedFromItem.Params;
for i:=0 to length(SrcParams)-1 do
begin
SrcParam:=SrcParams[i];

View File

@ -571,6 +571,7 @@ type
const Arg: Pointer); override;
procedure AddConstraint(El: TPasElement);
procedure ClearConstraints;
procedure ClearTypeReferences(aType: TPasElement); override;
Public
TypeConstraint: String deprecated; // deprecated in fpc 3.3.1
Constraints: TPasElementArray; // list of TPasExpr or TPasType, can be nil!
@ -597,6 +598,7 @@ type
public
constructor Create(const AName: string; AParent: TPasElement); override;
destructor Destroy; override;
procedure ClearTypeReferences(aType: TPasElement); override;
function ElementTypeName: string; override;
function GetDeclaration(full: boolean) : string; override;
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
@ -611,6 +613,7 @@ type
public
constructor Create(const AName: string; AParent: TPasElement); override;
destructor Destroy; override;
procedure ClearTypeReferences(aType: TPasElement); override;
function ElementTypeName: string; override;
function GetDeclaration(full : Boolean): string; override;
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
@ -650,6 +653,7 @@ type
procedure SetParent(const AValue: TPasElement); override;
public
destructor Destroy; override;
procedure ClearTypeReferences(aType: TPasElement); override;
function ElementTypeName: string; override;
function GetDeclaration(full : boolean) : string; override;
public
@ -667,6 +671,7 @@ type
TPasFileType = class(TPasType)
public
destructor Destroy; override;
procedure ClearTypeReferences(aType: TPasElement); override;
function ElementTypeName: string; override;
function GetDeclaration(full : boolean) : string; override;
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
@ -708,6 +713,7 @@ type
TPasSetType = class(TPasType)
public
destructor Destroy; override;
procedure ClearTypeReferences(aType: TPasElement); override;
function ElementTypeName: string; override;
function GetDeclaration(full : boolean) : string; override;
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
@ -755,6 +761,7 @@ type
public
constructor Create(const AName: string; AParent: TPasElement); override;
destructor Destroy; override;
procedure ClearTypeReferences(aType: TPasElement); override;
function ElementTypeName: string; override;
function GetDeclaration(full : boolean) : string; override;
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
@ -793,6 +800,7 @@ type
public
constructor Create(const AName: string; AParent: TPasElement); override;
destructor Destroy; override;
procedure ClearTypeReferences(aType: TPasElement); override;
function ElementTypeName: string; override;
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
const Arg: Pointer); override;
@ -826,11 +834,11 @@ type
TPasArgument = class(TPasElement)
public
destructor Destroy; override;
procedure ClearTypeReferences(aType: TPasElement); override;
function ElementTypeName: string; override;
function GetDeclaration(full : boolean) : string; override;
procedure ForEachCall(const aMethodCall: TOnForEachPasElement;
const Arg: Pointer); override;
procedure ClearTypeReferences(aType: TPasElement); override;
public
Access: TArgumentAccess;
ArgType: TPasType; // can be nil, when Access<>argDefault
@ -853,6 +861,7 @@ type
public
constructor Create(const AName: string; AParent: TPasElement); override;
destructor Destroy; override;
procedure ClearTypeReferences(aType: TPasElement); override;
class function TypeName: string; virtual;
function ElementTypeName: string; override;
function GetDeclaration(full : boolean) : string; override;
@ -1924,7 +1933,7 @@ begin
if (AValue=nil) and (Parent<>nil) then
begin
// parent is cleared
// -> clear all child references to this array (releasing loops)
// -> clear all child references to self (releasing loops)
ForEachCall(@ClearChildReferences,nil);
end;
inherited SetParent(AValue);
@ -2027,6 +2036,7 @@ begin
for i:=0 to length(Constraints)-1 do
begin
aConstraint:=Constraints[i];
if aConstraint=nil then continue;
if aConstraint.Parent=Self then
aConstraint.Parent:=nil;
aConstraint.Release{$IFDEF CheckPasTreeRefCount}('CreateElement'){$ENDIF};
@ -2034,6 +2044,22 @@ begin
Constraints:=nil;
end;
procedure TPasGenericTemplateType.ClearTypeReferences(aType: TPasElement);
var
i: SizeInt;
aConstraint: TPasElement;
begin
for i:=length(Constraints)-1 downto 0 do
begin
aConstraint:=Constraints[i];
if aConstraint=aType then
begin
aConstraint.Release{$IFDEF CheckPasTreeRefCount}('CreateElement'){$ENDIF};
Constraints[i]:=nil;
end;
end;
end;
{$IFDEF HasPTDumpStack}
procedure PTDumpStack;
begin
@ -2133,6 +2159,22 @@ begin
inherited Destroy;
end;
procedure TInlineSpecializeExpr.ClearTypeReferences(aType: TPasElement);
var
i: Integer;
El: TPasElement;
begin
for i:=Params.Count-1 downto 0 do
begin
El:=TPasElement(Params[i]);
if El=aType then
begin
El.Release{$IFDEF CheckPasTreeRefCount}('TInlineSpecializeExpr.Params'){$ENDIF};
Params.Delete(i);
end;
end;
end;
function TInlineSpecializeExpr.ElementTypeName: string;
begin
Result:=SPasTreeSpecializedExpr;
@ -2183,6 +2225,23 @@ begin
inherited Destroy;
end;
procedure TPasSpecializeType.ClearTypeReferences(aType: TPasElement);
var
i: Integer;
El: TPasElement;
begin
inherited ClearTypeReferences(aType);
for i:=Params.Count-1 downto 0 do
begin
El:=TPasElement(Params[i]);
if El=aType then
begin
El.Release{$IFDEF CheckPasTreeRefCount}('TPasSpecializeType.Params'){$ENDIF};
Params.Delete(i);
end;
end;
end;
function TPasSpecializeType.ElementTypeName: string;
begin
Result:=SPasTreeSpecializedType;
@ -3212,7 +3271,7 @@ end;
procedure TPasPointerType.SetParent(const AValue: TPasElement);
begin
if (AValue=nil) and (Parent<>nil) and (DestType<>nil)
and ((DestType.Parent=Parent) or (DestType=Self)) then
and ((DestType.HasParent(Parent)) or (DestType=Self)) then
begin
// DestType in same type section can create a loop
// -> break loop when type section is closed
@ -3231,7 +3290,7 @@ end;
procedure TPasAliasType.SetParent(const AValue: TPasElement);
begin
if (AValue=nil) and (Parent<>nil) and (DestType<>nil)
and ((DestType.Parent=Parent) or (DestType=Self)) then
and ((DestType.HasParent(Parent)) or (DestType=Self)) then
begin
// DestType in same type section can create a loop
// -> break loop when type section is closed
@ -3261,7 +3320,7 @@ begin
begin
if CurArr.ElType=Self then
begin
ReleaseAndNil(TPasElement(CurArr.ElType){$IFDEF CheckPasTreeRefCount},'TPasClassType.AncestorType'{$ENDIF});
ReleaseAndNil(TPasElement(CurArr.ElType){$IFDEF CheckPasTreeRefCount},'TPasArrayType.ElType'{$ENDIF});
break;
end;
CurArr:=TPasArrayType(CurArr.ElType);
@ -3280,12 +3339,25 @@ begin
inherited Destroy;
end;
procedure TPasArrayType.ClearTypeReferences(aType: TPasElement);
begin
inherited ClearTypeReferences(aType);
if ElType=aType then
ReleaseAndNil(TPasElement(ElType){$IFDEF CheckPasTreeRefCount},'TPasArrayType.ElType'{$ENDIF});
end;
destructor TPasFileType.Destroy;
begin
ReleaseAndNil(TPasElement(ElType){$IFDEF CheckPasTreeRefCount},'TPasFileType.ElType'{$ENDIF});
inherited Destroy;
end;
procedure TPasFileType.ClearTypeReferences(aType: TPasElement);
begin
if aType=ElType then
ReleaseAndNil(TPasElement(ElType){$IFDEF CheckPasTreeRefCount},'TPasFileType.ElType'{$ENDIF});
end;
constructor TPasEnumType.Create(const AName: string; AParent: TPasElement);
begin
inherited Create(AName, AParent);
@ -3405,9 +3477,19 @@ begin
inherited Destroy;
end;
procedure TPasRecordType.ClearTypeReferences(aType: TPasElement);
begin
inherited ClearTypeReferences(aType);
if VariantEl=aType then
ReleaseAndNil(TPasElement(VariantEl){$IFDEF CheckPasTreeRefCount},'TPasRecordType.VariantEl'{$ENDIF});
end;
{ TPasClassType }
procedure TPasClassType.SetParent(const AValue: TPasElement);
var
i: Integer;
Intf: TPasElement;
begin
if (AValue=nil) and (Parent<>nil) then
begin
@ -3417,6 +3499,15 @@ begin
ReleaseAndNil(TPasElement(AncestorType){$IFDEF CheckPasTreeRefCount},'TPasClassType.AncestorType'{$ENDIF});
if HelperForType=Self then
ReleaseAndNil(TPasElement(HelperForType){$IFDEF CheckPasTreeRefCount},'TPasClassType.HelperForType'{$ENDIF});
for i := Interfaces.Count - 1 downto 0 do
begin
Intf:=TPasElement(Interfaces[i]);
if Intf=Self then
begin
Intf.Release{$IFDEF CheckPasTreeRefCount}('TPasClassType.Interfaces'){$ENDIF};
Interfaces.Delete(i);
end;
end;
end;
inherited SetParent(AValue);
end;
@ -3443,6 +3534,27 @@ begin
inherited Destroy;
end;
procedure TPasClassType.ClearTypeReferences(aType: TPasElement);
var
i: Integer;
El: TPasElement;
begin
inherited ClearTypeReferences(aType);
if AncestorType=aType then
ReleaseAndNil(TPasElement(AncestorType){$IFDEF CheckPasTreeRefCount},'TPasClassType.AncestorType'{$ENDIF});
if HelperForType=aType then
ReleaseAndNil(TPasElement(HelperForType){$IFDEF CheckPasTreeRefCount},'TPasClassType.HelperForType'{$ENDIF});
for i := Interfaces.Count - 1 downto 0 do
begin
El:=TPasElement(Interfaces[i]);
if El=aType then
begin
El.Release{$IFDEF CheckPasTreeRefCount}('TPasClassType.Interfaces'){$ENDIF};
Interfaces[i]:=nil;
end;
end;
end;
function TPasClassType.ElementTypeName: string;
begin
case ObjKind of
@ -3557,6 +3669,45 @@ begin
inherited Destroy;
end;
procedure TPasArgument.ClearTypeReferences(aType: TPasElement);
begin
if ArgType=aType then
ReleaseAndNil(TPasElement(ArgType){$IFDEF CheckPasTreeRefCount},'TPasArgument.ArgType'{$ENDIF});
end;
function TPasArgument.GetDeclaration (full : boolean) : string;
begin
If Assigned(ArgType) then
begin
If ArgType.Name<>'' then
Result:=ArgType.SafeName
else
Result:=ArgType.GetDeclaration(False);
If Full and (Name<>'') then
Result:=SafeName+': '+Result;
end
else If Full then
Result:=SafeName
else
Result:='';
end;
procedure TPasArgument.ForEachCall(const aMethodCall: TOnForEachPasElement;
const Arg: Pointer);
begin
inherited ForEachCall(aMethodCall, Arg);
ForEachChildCall(aMethodCall,Arg,ArgType,true);
ForEachChildCall(aMethodCall,Arg,ValueExpr,false);
end;
function TPasArgument.Value: String;
begin
If Assigned(ValueExpr) then
Result:=ValueExpr.GetDeclaration(true)
else
Result:='';
end;
{ TPasProcedureType }
// inline
@ -3632,6 +3783,13 @@ begin
inherited Destroy;
end;
procedure TPasProcedureType.ClearTypeReferences(aType: TPasElement);
begin
inherited ClearTypeReferences(aType);
if VarArgsType=aType then
ReleaseAndNil(TPasElement(VarArgsType){$IFDEF CheckPasTreeRefCount},'CreateElement'{$ENDIF});
end;
class function TPasProcedureType.TypeName: string;
begin
Result := 'procedure';
@ -4356,6 +4514,12 @@ begin
inherited Destroy;
end;
procedure TPasSetType.ClearTypeReferences(aType: TPasElement);
begin
if EnumType=aType then
ReleaseAndNil(TPasElement(EnumType){$IFDEF CheckPasTreeRefCount},'TPasSetType.EnumType'{$ENDIF});
end;
function TPasSetType.GetDeclaration (full : boolean) : string;
Var
@ -5105,45 +5269,6 @@ begin
Result:=ptDestructor;
end;
function TPasArgument.GetDeclaration (full : boolean) : string;
begin
If Assigned(ArgType) then
begin
If ArgType.Name<>'' then
Result:=ArgType.SafeName
else
Result:=ArgType.GetDeclaration(False);
If Full and (Name<>'') then
Result:=SafeName+': '+Result;
end
else If Full then
Result:=SafeName
else
Result:='';
end;
procedure TPasArgument.ForEachCall(const aMethodCall: TOnForEachPasElement;
const Arg: Pointer);
begin
inherited ForEachCall(aMethodCall, Arg);
ForEachChildCall(aMethodCall,Arg,ArgType,true);
ForEachChildCall(aMethodCall,Arg,ValueExpr,false);
end;
procedure TPasArgument.ClearTypeReferences(aType: TPasElement);
begin
if ArgType=aType then
ReleaseAndNil(TPasElement(ArgType){$IFDEF CheckPasTreeRefCount},'TPasArgument.ArgType'{$ENDIF});
end;
function TPasArgument.Value: String;
begin
If Assigned(ValueExpr) then
Result:=ValueExpr.GetDeclaration(true)
else
Result:='';
end;
{ TPassTreeVisitor }
procedure TPassTreeVisitor.Visit(obj: TPasElement);

View File

@ -95,6 +95,7 @@ type
procedure TestGen_Class_ReferenceTo;
procedure TestGen_Class_TwoSpecsAreNotRelatedWarn;
procedure TestGen_Class_List;
procedure TestGen_Class_Typecast;
// ToDo: different modeswitches at parse time and specialize time
// generic external class
@ -1629,6 +1630,35 @@ begin
ParseProgram;
end;
procedure TTestResolveGenerics.TestGen_Class_Typecast;
begin
StartProgram(false);
Add([
'{$mode delphi}',
'type',
' TObject = class end;',
' TList<T> = class',
' end;',
' TEagle = class;',
' TBird = class',
' FLegs: TList<TBird>;',
' property Legs: TList<TBird> read FLegs write FLegs;',
' end;',
' TEagle = class(TBird)',
' end;',
'var',
' B: TBird;',
' List: TList<TEagle>;',
'begin',
' List:=TList<TEagle>(B.Legs);',
' TList<TEagle>(B.Legs):=List;',
'',
'']);
ParseProgram;
// FPC/pas2js: Class types "TList<afile.TBird>" and "TList<afile.TEagle>" are not related
// Delphi: no warning
end;
procedure TTestResolveGenerics.TestGen_ExtClass_Array;
begin
StartProgram(false);

View File

@ -52,6 +52,17 @@ end;
procedure TAVXTestGenerator.Init;
begin
// Opcode, i386, x8664, AVX512, Parameter
{ XSAVE opcodes }
FOpCodeList.Add('XGETBV,1,1,0,,,,,');
FOpCodeList.Add('XSETBV,1,1,0,,,,,');
FOpCodeList.Add('XSAVE,1,1,0,MEM64,,,,');
FOpCodeList.Add('XSAVE64,1,1,0,MEM64,,,,');
FOpCodeList.Add('XRSTOR,1,1,0,MEM64,,,,');
FOpCodeList.Add('XRSTOR64,1,1,0,MEM64,,,,');
FOpCodeList.Add('XSAVEOPT,1,1,0,MEM64,,,,');
FOpCodeList.Add('XSAVEOPT64,1,1,0,MEM64,,,,');
FOpCodeList.Add('ADDSS,1,1,0,XMMREG,XMMREG,,,');
FOpCodeList.Add('ADDSS,1,1,0,XMMREG,MEM32,,,');
@ -144,17 +155,6 @@ begin
FOpCodeList.Add('ADCX,1,1,0,REG32,RM32,,,');
FOpCodeList.Add('ADCX,1,1,0,REG64,RM64,,,');
FOpCodeList.Add('ADOX,1,1,0,REG32,RM32,,,');
@ -174,7 +174,7 @@ begin
FOpCodeList.Add('PDEP,1,1,0,REG64,REG64,RM64,,');
FOpCodeList.Add('PEXT,1,1,0,REG32,REG32,RM32,,');
FOpCodeList.Add('PEXT,1,1,0,REG64,REG64,RM64,,');
FOpCodeList.Add('MOVBE,1,1,0,REG16,MEM16,,,');
FOpCodeList.Add('MOVBE,1,1,0,MEM16,REG16,,,');
FOpCodeList.Add('MOVBE,1,1,0,REG32,MEM32,,,');
@ -425,7 +425,7 @@ begin
FOpCodeList.Add('vcvtdq2pd,1,1,1,ZMMREG_MZ,MEM256,,');
FOpCodeList.Add('vcvtdq2pd,1,1,1,ZMMREG_MZ,YMMREG_ER,,');
FOpCodeList.Add('vcvtdq2pd,1,1,1,ZMMREG_MZ,8B32,,');
FOpCodeList.Add('vcvtdq2ps,1,1,1,XMMREG_MZ,XMMRM,,');
FOpCodeList.Add('vcvtdq2ps,1,1,1,XMMREG_MZ,4B32,,');
FOpCodeList.Add('vcvtdq2ps,1,1,1,YMMREG_MZ,YMMRM,,');
@ -3134,10 +3134,10 @@ begin
FOpCodeList.Add('vshufi64x2,1,1,1,ymmreg_mz,ymmreg,4b64,imm8');
FOpCodeList.Add('vshufi64x2,1,1,1,zmmreg_mz,zmmreg,zmmrm,imm8');
FOpCodeList.Add('vshufi64x2,1,1,1,zmmreg_mz,zmmreg,8b64,imm8');
FOpCodeList.Add('movntss,1,1,0,MEM32,XMMREG,');
FOpCodeList.Add('movntsd,1,1,0,MEM64,XMMREG,');
FOpCodeList.Add('VAESDEC,1,1,1,xmmreg,xmmreg,xmmrm,');
FOpCodeList.Add('VAESDEC,1,1,1,zmmreg,zmmreg,zmmrm,');
FOpCodeList.Add('VAESDECLAST,1,1,1,xmmreg,xmmreg,xmmrm,');
@ -3269,9 +3269,6 @@ begin
FOpCodeList.Add('VPSHUFBITQMB,1,1,1,kreg_m,xmmreg,xmmrm,');
FOpCodeList.Add('VPSHUFBITQMB,1,1,1,kreg_m,ymmreg,ymmrm,');
FOpCodeList.Add('VPSHUFBITQMB,1,1,1,kreg_m,zmmreg,zmmrm,');
end;
function TAVXTestGenerator.InternalMakeTestFiles(aX64, aAVX512, aSAE: boolean; aDestPath, aFileExt: String;