Browse Source

Update AVX test utilities (new output format: gas).

Margers 2 months ago
parent
commit
3811b307b5

File diff suppressed because it is too large
+ 436 - 186
tests/utils/avx/asmtestgenerator.pas


+ 25 - 10
tests/utils/avx/avxopcodes.pas

@@ -8,7 +8,7 @@ uses Classes;
 
 type
 
-  TTestFileTyp = (tfNasm, tfFPC, tfFasm, tfFPCInc, tfFPCMRef, tfFPCCDisp8);
+  TTestFileTyp = (tfNasm, tfGas, tfFPC, tfFasm, tfFPCInc, tfFPCMRef, tfFPCCDisp8);
 
   { TAVXTestGenerator }
 
@@ -20,8 +20,8 @@ type
 
     function SaveFile(aAsmList: TStringList; aOpcode, aDestPath, aFileExt: String; aHeaderList, aFooterList: TStringList): boolean;
 
-    function InternalMakeTestFiles(aMRef, aX64, aAVX512, aSAE: boolean; aDestPath, aFilemask, aFileExt: String; aOpCodeList, aHeaderList, aFooterList: TStringList): boolean;
-    function InternalMakeTestFilesCDisp8(aX64, aAVX512, aSAE: boolean; aDestPath, aFilemask, aFileExt: String; aOpCodeList, aHeaderList, aFooterList: TStringList): boolean;
+    function InternalMakeTestFiles(aGas, aMRef, aX64, aAVX512, aSAE: boolean; aDestPath, aFilemask, aFileExt: String; aOpCodeList, aHeaderList, aFooterList: TStringList): boolean;
+    function InternalMakeTestFilesCDisp8(aGas, aX64, aAVX512, aSAE: boolean; aDestPath, aFilemask, aFileExt: String; aOpCodeList, aHeaderList, aFooterList: TStringList): boolean;
 
   public
     constructor Create;
@@ -3393,7 +3393,7 @@ begin
   end;
 end;
 
-function TAVXTestGenerator.InternalMakeTestFiles(aMRef, aX64, aAVX512, aSAE: boolean; aDestPath, aFilemask, aFileExt: String;
+function TAVXTestGenerator.InternalMakeTestFiles(aGas, aMRef, aX64, aAVX512, aSAE: boolean; aDestPath, aFilemask, aFileExt: String;
                                         aOpCodeList, aHeaderList, aFooterList: TStringList): boolean;
 var
   i,j: integer;
@@ -3478,7 +3478,7 @@ begin
                   if aMREF then
 	          begin
                     sLocalVarDataTyp := '';
- 	            TAsmTestGenerator.CalcTestDataMREF(aX64, aAVX512 and (sl[3] = '1'), aSAE, sl[0], sl[4], sl[5], sl[6], sl[7], slAsm);
+ 	            TAsmTestGenerator.CalcTestDataMREF(aGas, aX64, aAVX512 and (sl[3] = '1'), aSAE, sl[0], sl[4], sl[5], sl[6], sl[7], slAsm);
 		    sDestFile := 'MREF_' + sDestFile;
 
 		    if trim(sLocalVarDataTyp) = '' then
@@ -3486,7 +3486,7 @@ begin
 
                     slLocalHeader.Text :=  StringReplace(aHeaderList.Text, '$$$LOCALVARDATATYP$$$', sLocalVarDataTyp, [rfReplaceAll]);
 	          end
-   	          else TAsmTestGenerator.CalcTestData(aX64, aAVX512 and (sl[3] = '1'), aSAE, sl[0], sl[4], sl[5], sl[6], sl[7], slAsm);
+   	          else TAsmTestGenerator.CalcTestData(aGas, aX64, aAVX512 and (sl[3] = '1'), aSAE, sl[0], sl[4], sl[5], sl[6], sl[7], slAsm);
 	        end;
 
                 SaveFile(slAsm, sDestFile, aDestPath, aFileExt, slLocalHeader, aFooterList);
@@ -3511,7 +3511,7 @@ begin
   end;
 end;
 
-function TAVXTestGenerator.InternalMakeTestFilesCDisp8(aX64, aAVX512,
+function TAVXTestGenerator.InternalMakeTestFilesCDisp8(aGas, aX64, aAVX512,
   aSAE: boolean; aDestPath, aFilemask, aFileExt: String; aOpCodeList,
   aHeaderList, aFooterList: TStringList): boolean;
 var
@@ -3588,7 +3588,7 @@ begin
                 end
                 else
 	        begin
-   	          TAsmTestGenerator.CalcTestDataCDisp8(aX64, aAVX512 and (sl[3] = '1'), aSAE, sl[0], sl[4], sl[5], sl[6], sl[7], slAsm);
+   	          TAsmTestGenerator.CalcTestDataCDisp8(aGas, aX64, aAVX512 and (sl[3] = '1'), aSAE, sl[0], sl[4], sl[5], sl[6], sl[7], slAsm);
 	        end;
 
                 if trim(slAsm.Text) <> '' then
@@ -3950,6 +3950,21 @@ begin
                   slHeader.Add('section ''.text'' code readable executable');
                   slHeader.Add('myproc:');
 
+                  for i := 1 to 10 do
+                   slHeader.Add('NOP');
+
+                  for i := 1 to 10 do
+                   slFooter.Add('NOP');
+                end;
+        tfGas: begin
+                  writeln(format('outputformat: Gas  platform: %s  path: %s',
+                                 [cPlatform[aX64], aDestPath]));
+
+                  FileExt := '.s';
+                  {
+                  if aX64 then slHeader.Add('[BITS 64]')
+                   else slHeader.Add('[BITS 32]');
+                  }
                   for i := 1 to 10 do
                    slHeader.Add('NOP');
 
@@ -3959,8 +3974,8 @@ begin
       end;
 
       case aTyp of
-        tfFPCCDisp8: InternalMakeTestFilesCDisp8(aX64, aAVX512, aSAE, aDestPath, aFilemask, Fileext, FOpCodeList, slHeader, slFooter);
-                else InternalMakeTestFiles(aTyp = tfFPCMRef, aX64, aAVX512, aSAE, aDestPath, aFilemask, Fileext, FOpCodeList, slHeader, slFooter);
+        tfFPCCDisp8: InternalMakeTestFilesCDisp8(aTyp = tfGas, aX64, aAVX512, aSAE, aDestPath, aFilemask, Fileext, FOpCodeList, slHeader, slFooter);
+                else InternalMakeTestFiles(aTyp = tfGas, aTyp = tfFPCMRef, aX64, aAVX512, aSAE, aDestPath, aFilemask, Fileext, FOpCodeList, slHeader, slFooter);
       end;
 
     finally

+ 3 - 2
tests/utils/avx/avxtestgenerator.pp

@@ -36,13 +36,13 @@ begin
 
       if Help then
       begin
-        writeln('avx-testfile-generator 0.1');
+        writeln('avx-testfile-generator 0.2');
         writeln('author: torsten grundke');
         writeln('');
         writeln('make avx assembler-testfiles');
         writeln('');
         writeln('-h  help');
-        writeln('-f  [fpc,fpcmref,fpccd8,nasm,fasm,fpcinc] outputformat');
+        writeln('-f  [fpc,fpcmref,fpccd8,nasm,fasm,gas,fpcinc] outputformat');
         writeln('-l  list opcode-memrefsize-states');
         writeln('-m  create only these testfile(s) (e.g. -mvgather,vpgather)');
         writeln('-o  destination path');
@@ -60,6 +60,7 @@ begin
           'f': MakeTestFiles(tfFPC, x64, AVX512, false, Path, Filemask);
           'F': MakeTestFiles(tfFasm, x64, AVX512, false, Path, Filemask);
           'n': MakeTestFiles(tfNasm, x64, AVX512, false, Path, Filemask);
+          'g': MakeTestFiles(tfGas, x64, AVX512, false, Path, Filemask);
           'I': MakeTestFiles(tfFPCInc, x64, AVX512, false, Path, Filemask);
           'm': MakeTestFiles(tfFPCMRef, x64, AVX512, false, Path, Filemask);
           'd': MakeTestFiles(tfFPCCDisp8, x64, true, false, Path, Filemask);

+ 21 - 3
tests/utils/avx/filecomparer.pas

@@ -25,6 +25,19 @@ implementation
 uses SysUtils;
 
 
+function CompareX(M1, M2:pbyte;Size:sizeint): sizeint;
+var k : sizeint;
+begin
+  CompareX:=0;
+  if size >0 then
+  for k:=0 to size-1 do
+  begin
+    if M1^<>M2^ then begin CompareX:=k; break; end;
+    inc(m1);
+    inc(m2);
+  end;
+end;
+
 { TFileComparer }
 
 function TFileComparer.Compare(const aFileName1,
@@ -32,6 +45,7 @@ function TFileComparer.Compare(const aFileName1,
 var
   MStream1: TMemoryStream;
   MStream2: TMemoryStream;
+  DiffAt : sizeint;
 begin
   result := false;
   aMsg   := '';
@@ -62,13 +76,17 @@ begin
         end
         else
         begin
-          if MStream1.Size <> MStream2.Size then aMsg := format('diff: file: "%s"  size: %d - file: "%s"  size: %d',
+          if MStream1.Size< MStream2.Size then
+            DiffAt:=CompareX(MStream1.Memory, MStream2.Memory,MStream1.Size)+1
+          else
+            DiffAt:=CompareX(MStream1.Memory, MStream2.Memory,MStream2.Size)+1;
+          if MStream1.Size <> MStream2.Size then aMsg := format('diff: file: "%s"  size: %d - file: "%s"  size: %d (at %d)',
                                                                 [aFilename1, MStream1.Size,
-                                                                 aFilename2, MStream2.Size])
+                                                                 aFilename2, MStream2.Size, DiffAt])
           else
           begin
             if CompareMem(MStream1.Memory, MStream2.Memory, MStream1.Size) then result := true
-             else aMsg := format('diff: file: "%s" <> file: "%s"', [aFileName1, aFileName2]);
+             else aMsg := format('diff: file: "%s" <> file: "%s"  (at %d)', [aFileName1, aFileName2, DiffAt]);
           end;
         end;
       finally

+ 1 - 0
tests/utils/avx/options.pas

@@ -94,6 +94,7 @@ begin
          'h': FHelp := true;
          'f': if sValue = 'fpc' then FOutputFormat := 'f'
                else if sValue = 'nasm' then FOutputFormat := 'n'
+               else if sValue = 'gas' then FOutputFormat := 'g'
                else if sValue = 'fasm' then FOutputFormat := 'F'
                else if sValue = 'fpcinc' then FOutputFormat := 'I'
                else if sValue = 'fpcmref' then FOutputFormat := 'm'

Some files were not shown because too many files changed in this diff