summaryrefslogtreecommitdiff
path: root/tests/utils
diff options
context:
space:
mode:
authorflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-10-07 10:10:20 +0000
committerflorian <florian@3ad0048d-3df7-0310-abae-a5850022a9f2>2018-10-07 10:10:20 +0000
commit1f7abbd0ba75f1cc151695c7f391645c9f275aa5 (patch)
treebf121d407717747ecd26b4dae776d1986f463389 /tests/utils
parentf046f3e2011ef16c59476b6cf1c5604d11b768c6 (diff)
downloadfpc-1f7abbd0ba75f1cc151695c7f391645c9f275aa5.tar.gz
+ support fpc include output in avx test generation code
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@39876 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'tests/utils')
-rw-r--r--tests/utils/avx/avxopcodes.pas47
-rw-r--r--tests/utils/avx/avxtestgenerator.lpi15
-rw-r--r--tests/utils/avx/avxtestgenerator.pp3
-rw-r--r--tests/utils/avx/options.pas1
-rw-r--r--tests/utils/avx/readme.txt14
5 files changed, 71 insertions, 9 deletions
diff --git a/tests/utils/avx/avxopcodes.pas b/tests/utils/avx/avxopcodes.pas
index 8e60032013..e5a44e5c64 100644
--- a/tests/utils/avx/avxopcodes.pas
+++ b/tests/utils/avx/avxopcodes.pas
@@ -8,7 +8,7 @@ uses Classes;
type
- TTestFileTyp = (tfNasm, tfFPC, tfFasm);
+ TTestFileTyp = (tfNasm, tfFPC, tfFasm, tfFPCInc);
TAVXTestGenerator = class(TObject)
private
@@ -59,6 +59,7 @@ begin
FOpCodeList.Add('PDEP,1,1,REG64,REG64,RM64,,');
FOpCodeList.Add('PEXT,1,1,REG32,REG32,RM32,,');
FOpCodeList.Add('PEXT,1,1,REG64,REG64,RM64,,');
+
FOpCodeList.Add('VADDPD,1,1,XMMREG,XMMREG,XMMRM,');
FOpCodeList.Add('VADDPD,1,1,YMMREG,YMMREG,YMMRM,');
FOpCodeList.Add('VADDPS,1,1,XMMREG,XMMREG,XMMRM,');
@@ -828,8 +829,8 @@ var
if aAsmList.Count > 0 then
begin
- aAsmList.Insert(0, StringReplace(aHeaderList.Text, '$$$OPCODE$$$', aOpCode, []));
- aAsmList.AddStrings(aFooterList);
+ aAsmList.Insert(0, StringReplace(aHeaderList.Text, '$$$OPCODE$$$', aOpCode, [rfReplaceAll]));
+ aAsmList.AddStrings(StringReplace(aFooterList.Text, '$$$OPCODE$$$', aOpCode, [rfReplaceAll]));
aAsmList.SaveToFile(IncludeTrailingBackslash(aDestPath) + aOpCode + aFileExt);
end;
@@ -936,6 +937,46 @@ begin
slFooter.Add(' end;');
slFooter.Add('end.');
end;
+ tfFPCInc: begin
+ writeln(format('outputformat: fpc platform: %s path: %s',
+ [cPlatform[aX64], aDestPath]));
+
+ FileExt := '.pp';
+
+ slHeader.Add('Program Test$$$OPCODE$$$;');
+ slHeader.Add('{$asmmode intel}');
+ slHeader.Add('{$warn 7102 off}');
+ slHeader.Add('{$I $$$OPCODE$$$.inc}');
+ slHeader.Add('Procedure Proc$$$OPCODE$$$;assembler;nostackframe;');
+ slHeader.Add(' asm');
+
+ for i := 1 to 10 do
+ slHeader.Add(#9'NOP');
+
+ for i := 1 to 10 do
+ slFooter.Add(#9'NOP');
+
+ slFooter.Add(' end;');
+ slFooter.Add('procedure check(const id: string; const expected: array of byte; p: pointer);');
+ slFooter.Add('var');
+ slFooter.Add(' i : longint;');
+ slFooter.Add('begin');
+ slFooter.Add(' for i:=0 to high(expected) do');
+ slFooter.Add(' if expected[i]<>pbyte(p)[i] then');
+ slFooter.Add(' begin');
+ slFooter.Add(' writeln(id, '' mismatch at offset $'',hexstr(i,4), '', expected=$'',hexstr(expected[i],2),'' actual=$'',hexstr(pbyte(p)[i],2));');
+ slFooter.Add(' halt(1);');
+ slFooter.Add(' end;');
+ slFooter.Add('end;');
+
+ slFooter.Add('begin');
+ if aX64 then
+ slFooter.Add(' check(''x86_64'',$$$OPCODE$$$,@Proc$$$OPCODE$$$);')
+ else
+ slFooter.Add(' check(''i386'',$$$OPCODE$$$,@Proc$$$OPCODE$$$);');
+ slFooter.Add(' writeln(''ok'');');
+ slFooter.Add('end.');
+ end;
tfNasm: begin
writeln(format('outputformat: Nasm platform: %s path: %s',
[cPlatform[aX64], aDestPath]));
diff --git a/tests/utils/avx/avxtestgenerator.lpi b/tests/utils/avx/avxtestgenerator.lpi
index 2722593dec..c14694660c 100644
--- a/tests/utils/avx/avxtestgenerator.lpi
+++ b/tests/utils/avx/avxtestgenerator.lpi
@@ -8,7 +8,6 @@
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<MainUnitHasScaledStatement Value="False"/>
- <UseDefaultCompilerOptions Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
@@ -27,12 +26,24 @@
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
- <Units Count="1">
+ <Units Count="4">
<Unit0>
<Filename Value="avxtestgenerator.pp"/>
<IsPartOfProject Value="True"/>
<UnitName Value="AVXTestGenerator"/>
</Unit0>
+ <Unit1>
+ <Filename Value="options.pas"/>
+ <IsPartOfProject Value="True"/>
+ </Unit1>
+ <Unit2>
+ <Filename Value="avxopcodes.pas"/>
+ <IsPartOfProject Value="True"/>
+ </Unit2>
+ <Unit3>
+ <Filename Value="asmtestgenerator.pas"/>
+ <IsPartOfProject Value="True"/>
+ </Unit3>
</Units>
</ProjectOptions>
<CompilerOptions>
diff --git a/tests/utils/avx/avxtestgenerator.pp b/tests/utils/avx/avxtestgenerator.pp
index 3c246e54e2..81aa1efc05 100644
--- a/tests/utils/avx/avxtestgenerator.pp
+++ b/tests/utils/avx/avxtestgenerator.pp
@@ -42,7 +42,7 @@ begin
writeln('make avx assembler-testfiles');
writeln('');
writeln('-h help');
- writeln('-f [fpc,nasm,fasm] outputformat');
+ writeln('-f [fpc,nasm,fasm,fpcinc] outputformat');
writeln('-p [x8664] codegenerator for x86_64 platform');
writeln('-o destination path');
writeln('');
@@ -53,6 +53,7 @@ begin
'f': MakeTestFiles(tfFPC, x64, Path);
'F': MakeTestFiles(tfFasm, x64, Path);
'n': MakeTestFiles(tfNasm, x64, Path);
+ 'I': MakeTestFiles(tfFPCInc, x64, Path);
end;
end;
finally
diff --git a/tests/utils/avx/options.pas b/tests/utils/avx/options.pas
index 8f5efafa54..183ca26104 100644
--- a/tests/utils/avx/options.pas
+++ b/tests/utils/avx/options.pas
@@ -84,6 +84,7 @@ begin
'f': if sValue = 'fpc' then FOutputFormat := 'f'
else if sValue = 'nasm' then FOutputFormat := 'n'
else if sValue = 'fasm' then FOutputFormat := 'F'
+ else if sValue = 'fpcinc' then FOutputFormat := 'I'
else IsInvalidParam := true;
'p': if sValue = 'x8664' then
begin
diff --git a/tests/utils/avx/readme.txt b/tests/utils/avx/readme.txt
index d6954df602..1f370df093 100644
--- a/tests/utils/avx/readme.txt
+++ b/tests/utils/avx/readme.txt
@@ -22,14 +22,22 @@ x86_64:
fpc avxtestgenerator
fpc avxtestfilecmp
avxtestgenerator -px8664 -ffpc -otmp
+avxtestgenerator -px8664 -fnasm -otmp
cd tmp
for %%p in (*.pp) do call fpc -Px86_64 %%p -v0
+for %a in (*.asm) do nasm -fwin64 %a
cd ..
+avxtestfilecmp -mtmp\*.obj -dtmp -eexe -s
+
+
+x86_64 testing by using self testing fpc executables:
+avxtestgenerator -px8664 -ffpcinc -otmp
avxtestgenerator -px8664 -fnasm -otmp
cd tmp
-for %%a in (*.asm) do nasm -fwin64 %%a
-cd ..
-avxtestfilecmp -mtmp\*.obj -dtmp -eexe -s
+for %a in (*.asm) do nasm -fbin %a -o %~na.bin
+for %b in (*.bin) do bin2obj -x -c %~nb %b -o%~nb.inc
+for %p in (*.pp) do call fpc -Px86_64 %p -v0i
+for %e in (*.exe) do call %e
****************************************************************************************************
Note: