Browse Source

working on new testmethods and bug-fixing size of (memref-operands | global and local variable

git-svn-id: branches/tg74/avx512-0037785@47685 -
tg74 4 years ago
parent
commit
8e5a54c92e
3 changed files with 198 additions and 26 deletions
  1. 31 24
      compiler/x86/rax86.pas
  2. 102 0
      tests/utils/avx/asmtestgenerator.pas
  3. 65 2
      tests/utils/avx/avxopcodes.pas

+ 31 - 24
compiler/x86/rax86.pas

@@ -72,7 +72,7 @@ type
     procedure FixupOpcode;virtual;
     { opcode adding }
     function ConcatInstruction(p : TAsmList) : tai;override;
-    function getstring: string;
+    function getstring(aAddMemRefSize: boolean = true): string;
     { returns true, if the opcode might have an extension as used by AVX512 }
     function MightHaveExtension : boolean;
   end;
@@ -457,20 +457,22 @@ var
   multiplicator: integer;
   bcst1,bcst2: string;
 
-  function ScanLowestActiveBit(aValue: int64): int64;
+  function ScanLowestOpsize(aValue: int64): int64;
   var
     i: integer;
   begin
     result := 0;
 
-    for i := 0 to 63 do
-     if aValue and (1 shl i) <> 0 then
-     begin
-       result := 1 shl i;
-       break;
-     end;
+    if aValue and OT_BITS8 = OT_BITS8 then result := 8
+     else if aValue and OT_BITS16  = OT_BITS16  then result := 16
+     else if aValue and OT_BITS32  = OT_BITS32  then result := 32
+     else if aValue and OT_BITS64  = OT_BITS64  then result := 64
+     else if aValue and OT_BITS128 = OT_BITS128 then result := 128
+     else if aValue and OT_BITS256 = OT_BITS256 then result := 256
+     else if aValue and OT_BITS512 = OT_BITS512 then result := 512;
   end;
 
+
 begin
   ExistsMemRefNoSize := false;
   ExistsMemRef       := false;
@@ -762,15 +764,15 @@ begin
                   begin
                     case getsubreg(operands[j].opr.reg) of
                       R_SUBMMX: begin
-                                  memrefsize := ScanLowestActiveBit(MemRefInfo(opcode).RegXMMSizeMask);
+                                  memrefsize := ScanLowestOpsize(MemRefInfo(opcode).RegXMMSizeMask);
                                   break;
                                 end;
                       R_SUBMMY: begin
-                                  memrefsize := ScanLowestActiveBit(MemRefInfo(opcode).RegYMMSizeMask);
+                                  memrefsize := ScanLowestOpsize(MemRefInfo(opcode).RegYMMSizeMask);
                                   break;
                                 end;
                       R_SUBMMZ: begin
-                                  memrefsize := ScanLowestActiveBit(MemRefInfo(opcode).RegZMMSizeMask);
+                                  memrefsize := ScanLowestOpsize(MemRefInfo(opcode).RegZMMSizeMask);
                                   break;
                                 end;
                            else;
@@ -861,7 +863,8 @@ begin
               if memoffset < 0 then
               begin
                 Message2(asmr_w_check_mem_operand_negative_offset,
-                         std_op2str[opcode],
+                         //std_op2str[opcode],
+			 getstring(false),
                          ToStr(memoffset));
               end
               else if ((tx86operand(operands[i]).hastype) and (memopsize < memrefsize)) or
@@ -872,7 +875,8 @@ begin
                   if memoffset = 0 then
                   begin
                     Message3(asmr_w_check_mem_operand_size3,
-                             std_op2str[opcode],
+                             //std_op2str[opcode],
+			     getstring(false),
                              ToStr(memopsize),
                              ToStr(memrefsize)
                              );
@@ -880,7 +884,8 @@ begin
                   else
                   begin
                     Message4(asmr_w_check_mem_operand_size_offset,
-                             std_op2str[opcode],
+                             //std_op2str[opcode],
+			     getstring(false),
                              ToStr(memopsize),
                              ToStr(memrefsize),
                              ToStr(memoffset)
@@ -933,7 +938,7 @@ begin
                                 tx86operand(operands[i]).opsize := S_B;
                                 tx86operand(operands[i]).size   := OS_8;
 
-                                Message2(asmr_w_check_mem_operand_automap_multiple_size, std_op2str[opcode], '"8 bit memory operand"');
+                                Message2(asmr_w_check_mem_operand_automap_multiple_size, GetString(false), '"8 bit memory operand"');
                               end;
                       msiMem16:
                               begin
@@ -945,7 +950,7 @@ begin
                                  tx86operand(operands[i]).opsize := S_W;
                                  tx86operand(operands[i]).size   := OS_16;
 
-                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, std_op2str[opcode], '"16 bit memory operand"');
+                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, GetString(false), '"16 bit memory operand"');
                                end;
                       msiMem32:
                                begin
@@ -957,7 +962,7 @@ begin
                                  tx86operand(operands[i]).opsize := S_L;
                                  tx86operand(operands[i]).size   := OS_32;
 
-                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, std_op2str[opcode], '"32 bit memory operand"');
+                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, GetString(false), '"32 bit memory operand"');
                                end;
                       msiMem64:
                                begin
@@ -969,7 +974,7 @@ begin
                                  tx86operand(operands[i]).opsize := S_Q;
                                  tx86operand(operands[i]).size   := OS_M64;
 
-                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, std_op2str[opcode], '"64 bit memory operand"');
+                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, GetString(false), '"64 bit memory operand"');
                                end;
                       msiMem128:
                                begin
@@ -981,7 +986,7 @@ begin
                                  tx86operand(operands[i]).opsize := S_XMM;
                                  tx86operand(operands[i]).size   := OS_M128;
 
-                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, std_op2str[opcode], '"128 bit memory operand"');
+                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, GetString(false), '"128 bit memory operand"');
                                end;
                       msiMem256:
                                begin
@@ -995,7 +1000,7 @@ begin
                                  tx86operand(operands[i]).size   := OS_M256;
                                  opsize := S_YMM;
 
-                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, std_op2str[opcode], '"256 bit memory operand"');
+                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, GetString(false), '"256 bit memory operand"');
                                end;
                       msiMem512:
                                begin
@@ -1009,7 +1014,7 @@ begin
                                  tx86operand(operands[i]).size   := OS_M512;
                                  opsize := S_ZMM;
 
-                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, std_op2str[opcode], '"512 bit memory operand"');
+                                 Message2(asmr_w_check_mem_operand_automap_multiple_size, GetString(false), '"512 bit memory operand"');
                                end;
 
                     msiMemRegSize:
@@ -2170,7 +2175,7 @@ begin
   result:=ai;
 end;
 
-function Tx86Instruction.getstring: string;
+function Tx86Instruction.getstring(aAddMemRefSize: boolean): string;
 var
   i : longint;
   s, sval : string;
@@ -2182,7 +2187,7 @@ begin
    begin
      with operands[i] as Tx86Operand do
        begin
-         if i=0 then
+         if i=1 then
           s:=s+' '
          else
           s:=s+',';
@@ -2232,7 +2237,9 @@ begin
                OPR_LOCAL,
             OPR_REFERENCE: begin
                              s:=s + 'mem';
-                             addsize:=true;
+
+                             if aAddMemRefSize then
+                              addsize:=true;
                            end;
                       else s:=s + '???';
          end;

+ 102 - 0
tests/utils/avx/asmtestgenerator.pas

@@ -1985,9 +1985,22 @@ begin
 
               Item.Values.Add(' lOWord');
               Item.Values.Add(' gOWord');
+              Item.Values.Add(' clOWord');
+              Item.Values.Add(' cgOWord');
 
               Item.Values.Add(' oword lOWord');
               Item.Values.Add(' oword gOWord');
+              Item.Values.Add(' oword clOWord');
+              Item.Values.Add(' oword cgOWord');
+
+              Item.Values.Add(' byte lOWord');
+              Item.Values.Add(' byte gOWord');
+              Item.Values.Add(' byte clOWord');
+              Item.Values.Add(' byte cgOWord');
+
+              Item.Values.Add(' lRec');
+              Item.Values.Add(' gRec');
+
 
             end
             else if (AnsiSameText(sl_Operand, 'XMMRM8')) or
@@ -2004,6 +2017,15 @@ begin
 
               Item.Values.Add('lbyte');
               Item.Values.Add('gbyte');
+              Item.Values.Add('clbyte');
+              Item.Values.Add('cgbyte');
+
+              Item.Values.Add('byte lbyte');
+              Item.Values.Add('byte gbyte');
+              Item.Values.Add('byte clbyte');
+              Item.Values.Add('byte cgbyte');
+
+
             end
             else if (AnsiSameText(sl_Operand, 'XMMRM16')) or
                     (AnsiSameText(sl_Operand, 'XMMRM16_M')) or
@@ -2018,6 +2040,14 @@ begin
 
               Item.Values.Add('lword');
               Item.Values.Add('gword');
+              Item.Values.Add('clword');
+              Item.Values.Add('cgword');
+
+              Item.Values.Add('word lword');
+              Item.Values.Add('word gword');
+              Item.Values.Add('word clword');
+              Item.Values.Add('word cgword');
+
             end
             else if (AnsiSameText(sl_Operand, 'YMMREG')) or
                     (AnsiSameText(sl_Operand, 'YMMREG_M')) or
@@ -2045,6 +2075,14 @@ begin
 
               Item.Values.Add('lYWord');
               Item.Values.Add('gYWord');
+              Item.Values.Add('clYWord');
+              Item.Values.Add('cgYWord');
+
+              Item.Values.Add('yword lYWord');
+              Item.Values.Add('yword gYWord');
+              Item.Values.Add('yword clYWord');
+              Item.Values.Add('yword cgYWord');
+
             end
             else if (AnsiSameText(sl_Operand, 'ZMMREG')) or
                     (AnsiSameText(sl_Operand, 'ZMMREG_M')) or
@@ -2072,6 +2110,14 @@ begin
 
               Item.Values.Add('lZWord');
               Item.Values.Add('gZWord');
+              Item.Values.Add('clZWord');
+              Item.Values.Add('cgZWord');
+
+              Item.Values.Add('zword lZWord');
+              Item.Values.Add('zword gZWord');
+              Item.Values.Add('zword clZWord');
+              Item.Values.Add('zword cgZWord');
+
             end
             else if AnsiSameText(sl_Operand, 'MEM8') then
             begin
@@ -2081,6 +2127,14 @@ begin
 
               Item.Values.Add('lByte');
               Item.Values.Add('gByte');
+              Item.Values.Add('clByte');
+              Item.Values.Add('cgByte');
+
+              Item.Values.Add('byte lByte');
+              Item.Values.Add('byte gByte');
+              Item.Values.Add('byte clByte');
+              Item.Values.Add('byte cgByte');
+
             end
             else if AnsiSameText(sl_Operand, 'MEM16') or
                     AnsiSameText(sl_Operand, 'MEM16_M') then
@@ -2091,6 +2145,14 @@ begin
 
               Item.Values.Add('lWord');
               Item.Values.Add('gWord');
+              Item.Values.Add('clWord');
+              Item.Values.Add('cgWord');
+
+              Item.Values.Add('word lWord');
+              Item.Values.Add('word gWord');
+              Item.Values.Add('word clWord');
+              Item.Values.Add('word cgWord');
+
             end
             else if AnsiSameText(sl_Operand, 'MEM32') or
                     AnsiSameText(sl_Operand, 'MEM32_M') or
@@ -2102,6 +2164,14 @@ begin
 
               Item.Values.Add('lDWord');
               Item.Values.Add('gDWord');
+              Item.Values.Add('clDWord');
+              Item.Values.Add('cgDWord');
+
+              Item.Values.Add('dword lDWord');
+              Item.Values.Add('dword gDWord');
+              Item.Values.Add('dword clDWord');
+              Item.Values.Add('dword cgDWord');
+
             end
             else if (AnsiSameText(sl_Operand, 'MEM64')) or
                     (AnsiSameText(sl_Operand, 'MEM64_M')) or
@@ -2113,6 +2183,14 @@ begin
 
               Item.Values.Add('lQWord');
               Item.Values.Add('gQWord');
+              Item.Values.Add('clQWord');
+              Item.Values.Add('cgQWord');
+
+              Item.Values.Add('qword lQWord');
+              Item.Values.Add('qword gQWord');
+              Item.Values.Add('qword clQWord');
+              Item.Values.Add('qword cgQWord');
+
             end
             else if (AnsiSameText(sl_Operand, 'MEM128')) or
                     (AnsiSameText(sl_Operand, 'MEM128_M')) or
@@ -2124,6 +2202,14 @@ begin
 
               Item.Values.Add('lOWord');
               Item.Values.Add('gOWord');
+              Item.Values.Add('clOWord');
+              Item.Values.Add('cgOWord');
+
+              Item.Values.Add('oword lOWord');
+              Item.Values.Add('oword gOWord');
+              Item.Values.Add('oword clOWord');
+              Item.Values.Add('oword cgOWord');
+
             end
             else if (AnsiSameText(sl_Operand, 'MEM256')) or
                     (AnsiSameText(sl_Operand, 'MEM256_M')) or
@@ -2135,6 +2221,14 @@ begin
 
               Item.Values.Add('lYWord');
               Item.Values.Add('gYWord');
+              Item.Values.Add('clYWord');
+              Item.Values.Add('cgYWord');
+
+              Item.Values.Add('yword lYWord');
+              Item.Values.Add('yword gYWord');
+              Item.Values.Add('yword clYWord');
+              Item.Values.Add('yword cgYWord');
+
             end
             else if (AnsiSameText(sl_Operand, 'MEM512')) or
                     (AnsiSameText(sl_Operand, 'MEM512_M')) or
@@ -2146,6 +2240,14 @@ begin
 
               Item.Values.Add('lZWord');
               Item.Values.Add('gZWord');
+              Item.Values.Add('clZWord');
+              Item.Values.Add('cgZWord');
+
+              Item.Values.Add('zword lZWord');
+              Item.Values.Add('zword gZWord');
+              Item.Values.Add('zword clZWord');
+              Item.Values.Add('zword cgZWord');
+
             end
             else if AnsiSameText(sl_Operand, 'REG8') then
             begin

+ 65 - 2
tests/utils/avx/avxopcodes.pas

@@ -3400,8 +3400,22 @@ begin
                   slHeader.Add('Program $$$OPCODE$$$;');
                   slHeader.Add('{$asmmode intel}');
 
+                  slHeader.Add('type');
+                  slHeader.Add('  rec = record');
+
+                  slHeader.Add('    rByte: byte;');
+                  slHeader.Add('    rWord: word;');
+                  slHeader.Add('    rDWord: dword;');
+                  slHeader.Add('    rQWord: qword;');
+                  slHeader.Add('    rOWord: array[0..15] of byte;');
+                  slHeader.Add('    rYWord: array[0..31] of byte;');
+                  slHeader.Add('    rZWord: array[0..63] of byte;');
+
+                  slHeader.Add('  end;');
+
 
 		  slHeader.Add('var');
+                  slHeader.Add('   gRec: rec;');
 		  slHeader.Add('   gByte: byte;');
 		  slHeader.Add('   gWord: word;');
 		  slHeader.Add('  gDWord: dword;');
@@ -3410,18 +3424,67 @@ begin
 		  slHeader.Add('  gYWord: array[0..31] of byte;');
 		  slHeader.Add('  gZWord: array[0..63] of byte;');
 
+		  slHeader.Add('const');
+		  slHeader.Add('   cgByte: byte = 0;');
+		  slHeader.Add('   cgWord: word = 0;');
+		  slHeader.Add('  cgDWord: dword = 0;');
+		  slHeader.Add('  cgQWord: qword = 0;');
+		  slHeader.Add('  cgOWord: array[0..15] of byte = ((0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                  '(0),(0),(0),(0),(0),(0),(0),(0));');
+
+		  slHeader.Add('  cgYWord: array[0..31] of byte = ((0),(0),(0),(0),(0),(0),(0),(0),' +
+		                                                  '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                  '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                  '(0),(0),(0),(0),(0),(0),(0),(0));');
+
+		  slHeader.Add('  cgZWord: array[0..63] of byte = ((0),(0),(0),(0),(0),(0),(0),(0),' +
+		                                                  '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                  '(0),(0),(0),(0),(0),(0),(0),(0),' +
+		                                                  '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                  '(0),(0),(0),(0),(0),(0),(0),(0),' +
+		                                                  '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                  '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                  '(0),(0),(0),(0),(0),(0),(0),(0));');
+
+//  slHeader.Add('  cgZWord: array[0..63] of byte;');
+
                   slHeader.Add(' procedure dummyproc;');
 		  slHeader.Add(' var');
+                  slHeader.Add('     lRec: rec;');
 		  slHeader.Add('     lByte: byte;');
 		  slHeader.Add('     lWord: word;');
 		  slHeader.Add('    lDWord: dword;');
 		  slHeader.Add('    lQWord: qword;');
 		  slHeader.Add('    lOWord: array[0..15] of byte;');
 		  slHeader.Add('    lYWord: array[0..31] of byte;');
-		  slHeader.Add('    lZWord: array[0..63] of byte;');
-
 		  slHeader.Add('    lSingle: single;');
+
 		  slHeader.Add('    lDouble: double;');
+		  slHeader.Add('    lZWord: array[0..63] of byte;');
+
+                  slHeader.Add(' const');
+		  slHeader.Add('     clByte: byte = 0;');
+		  slHeader.Add('     clWord: word = 0;');
+		  slHeader.Add('    clDWord: dword = 0;');
+		  slHeader.Add('    clQWord: qword = 0;');
+		  slHeader.Add('    clOWord: array[0..15] of byte = ((0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                    '(0),(0),(0),(0),(0),(0),(0),(0));');
+
+		  slHeader.Add('    clYWord: array[0..31] of byte = ((0),(0),(0),(0),(0),(0),(0),(0),' +
+		                                                    '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                    '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                    '(0),(0),(0),(0),(0),(0),(0),(0));');
+
+		  slHeader.Add('    clZWord: array[0..63] of byte = ((0),(0),(0),(0),(0),(0),(0),(0),' +
+		                                                    '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                    '(0),(0),(0),(0),(0),(0),(0),(0),' +
+		                                                    '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                    '(0),(0),(0),(0),(0),(0),(0),(0),' +
+		                                                    '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                    '(0),(0),(0),(0),(0),(0),(0),(0),' +
+                                                                    '(0),(0),(0),(0),(0),(0),(0),(0));');
+
+
 
                   slHeader.Add(' begin');
                   slHeader.Add('   asm');