瀏覽代碼

* Tighten rules for accepting ATT suffixes, no longer accept FPU suffixes for integer instructions and vice versa. Resolves #18900.
* tb0267.pp required patching due to 'fildw' instruction at line 72, which is rejected by GAS. Before this commit, FPC was silently converting it to 'filds', so it went unnoticed. Now FPC rejects 'fildw' like GAS does.

git-svn-id: trunk@17363 -

sergei 14 年之前
父節點
當前提交
92adf34e3f
共有 3 個文件被更改,包括 20 次插入12 次删除
  1. 4 4
      compiler/x86/itcpugas.pas
  2. 15 7
      compiler/x86/rax86att.pas
  3. 1 1
      tests/tbs/tb0267.pp

+ 4 - 4
compiler/x86/itcpugas.pas

@@ -60,10 +60,10 @@ interface
        '','BW','BL','WL','BQ','WQ',{'LQ',}'B','W','L','S','Q','T'
        '','BW','BL','WL','BQ','WQ',{'LQ',}'B','W','L','S','Q','T'
      );
      );
      att_sizesuffix : array[0..11] of topsize = (
      att_sizesuffix : array[0..11] of topsize = (
-       S_NO,S_BW,S_BL,S_WL,S_BQ,S_WQ,{S_LQ,}S_B,S_W,S_L,S_FS,S_IQ,S_FX
+       S_NO,S_BW,S_BL,S_WL,S_BQ,S_WQ,{S_LQ,}S_B,S_W,S_L,S_NO,S_Q,S_NO
      );
      );
      att_sizefpusuffix : array[0..11] of topsize = (
      att_sizefpusuffix : array[0..11] of topsize = (
-       S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,{S_NO,}S_NO,S_NO,S_FL,S_FS,S_IQ,S_FX
+       S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,{S_NO,}S_NO,S_NO,S_FL,S_FS,S_NO,S_FX
      );
      );
      att_sizefpuintsuffix : array[0..11] of topsize = (
      att_sizefpuintsuffix : array[0..11] of topsize = (
        S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,{S_NO,}S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO
        S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,{S_NO,}S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO
@@ -83,10 +83,10 @@ interface
        '','BW','BL','WL','B','W','L','S','Q','T'
        '','BW','BL','WL','B','W','L','S','Q','T'
      );
      );
      att_sizesuffix : array[0..9] of topsize = (
      att_sizesuffix : array[0..9] of topsize = (
-       S_NO,S_BW,S_BL,S_WL,S_B,S_W,S_L,S_FS,S_IQ,S_FX
+       S_NO,S_BW,S_BL,S_WL,S_B,S_W,S_L,S_NO,S_NO,S_NO
      );
      );
      att_sizefpusuffix : array[0..9] of topsize = (
      att_sizefpusuffix : array[0..9] of topsize = (
-       S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_FL,S_FS,S_IQ,S_FX
+       S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_FL,S_FS,S_NO,S_FX
      );
      );
      att_sizefpuintsuffix : array[0..9] of topsize = (
      att_sizefpuintsuffix : array[0..9] of topsize = (
        S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO
        S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_IL,S_IS,S_IQ,S_NO

+ 15 - 7
compiler/x86/rax86att.pas

@@ -798,9 +798,13 @@ Implementation
                        actopsize:=att_sizefpuintsuffix[sufidx]
                        actopsize:=att_sizefpuintsuffix[sufidx]
                       else
                       else
                        actopsize:=att_sizesuffix[sufidx];
                        actopsize:=att_sizesuffix[sufidx];
-                      actasmtoken:=AS_OPCODE;
-                      is_asmopcode:=TRUE;
-                      exit;
+                      { only accept suffix from the same category that the opcode belongs to }
+                      if (actopsize<>S_NO) or (suflen=0) then
+                        begin
+                          actasmtoken:=AS_OPCODE;
+                          is_asmopcode:=TRUE;
+                          exit;
+                        end;
                     end;
                     end;
                 end;
                 end;
               { not found, check condition opcodes }
               { not found, check condition opcodes }
@@ -822,10 +826,14 @@ Implementation
                             actopsize:=att_sizefpuintsuffix[sufidx]
                             actopsize:=att_sizefpuintsuffix[sufidx]
                            else
                            else
                             actopsize:=att_sizesuffix[sufidx];
                             actopsize:=att_sizesuffix[sufidx];
-                           actcondition:=cnd;
-                           actasmtoken:=AS_OPCODE;
-                           is_asmopcode:=TRUE;
-                           exit;
+                           { only accept suffix from the same category that the opcode belongs to }
+                           if (actopsize<>S_NO) or (suflen=0) then
+                             begin
+                               actcondition:=cnd;
+                               actasmtoken:=AS_OPCODE;
+                               is_asmopcode:=TRUE;
+                               exit;
+                             end;
                          end;
                          end;
                      end;
                      end;
                   end;
                   end;

+ 1 - 1
tests/tbs/tb0267.pp

@@ -69,7 +69,7 @@ begin
    aw:=-4;
    aw:=-4;
    bw:=45;
    bw:=45;
    asm
    asm
-     fildw aw
+     filds aw
      fstpl a
      fstpl a
    end;
    end;
    if a<>-4.0 then
    if a<>-4.0 then