浏览代码

+ added a warning for using cs/ds/es/ss segment overrides in inline assembly on
the x86_64 target

git-svn-id: trunk@38517 -

nickysn 7 年之前
父节点
当前提交
602dd31a45

+ 20 - 0
.gitattributes

@@ -12542,6 +12542,26 @@ tests/test/tasm23.pp svneol=native#text/plain
 tests/test/tasm23a.pp svneol=native#text/plain
 tests/test/tasm23b.pp svneol=native#text/plain
 tests/test/tasm24.pp svneol=native#text/plain
+tests/test/tasm25cs0.pp svneol=native#text/plain
+tests/test/tasm25cs1.pp svneol=native#text/plain
+tests/test/tasm25cs2.pp svneol=native#text/plain
+tests/test/tasm25cs3.pp svneol=native#text/plain
+tests/test/tasm25ds0.pp svneol=native#text/plain
+tests/test/tasm25ds1.pp svneol=native#text/plain
+tests/test/tasm25ds2.pp svneol=native#text/plain
+tests/test/tasm25ds3.pp svneol=native#text/plain
+tests/test/tasm25es0.pp svneol=native#text/plain
+tests/test/tasm25es1.pp svneol=native#text/plain
+tests/test/tasm25es2.pp svneol=native#text/plain
+tests/test/tasm25es3.pp svneol=native#text/plain
+tests/test/tasm25fs0.pp svneol=native#text/plain
+tests/test/tasm25fs1.pp svneol=native#text/plain
+tests/test/tasm25gs0.pp svneol=native#text/plain
+tests/test/tasm25gs1.pp svneol=native#text/plain
+tests/test/tasm25ss0.pp svneol=native#text/plain
+tests/test/tasm25ss1.pp svneol=native#text/plain
+tests/test/tasm25ss2.pp svneol=native#text/plain
+tests/test/tasm25ss3.pp svneol=native#text/plain
 tests/test/tasm2a.pp svneol=native#text/plain
 tests/test/tasm3.pp svneol=native#text/plain
 tests/test/tasm4.pp svneol=native#text/plain

+ 2 - 1
compiler/msg/errore.msg

@@ -2491,7 +2491,7 @@ cg_h_no_inline=06058_H_Call to subroutine "$1" marked as inline is not inlined
 #
 # Assembler reader
 #
-# 07139 is the last used one
+# 07141 is the last used one
 #
 asmr_d_start_reading=07000_DL_Starting $1 styled assembler parsing
 % This informs you that an assembler block is being parsed
@@ -2829,6 +2829,7 @@ asmr_e_public_must_be_used_before_label_definition=07137_E_Label $1 can only be
 asmr_e_local_label_cannot_be_declared_public=07138_E_Local label $1 cannot be declared public
 asmr_e_multiple_segment_overrides=07139_E_Cannot use multiple segment overrides
 asmr_w_multiple_segment_overrides=07140_W_Multiple segment overrides (only the last one will take effect)
+asmr_w_segment_override_ignored_in_64bit_mode=07141_W_Segment base $1 will be generated, but is ignored by the CPU in 64-bit mode
 #
 # Assembler/binary writers
 #

+ 3 - 2
compiler/msgidx.inc

@@ -826,6 +826,7 @@ const
   asmr_e_local_label_cannot_be_declared_public=07138;
   asmr_e_multiple_segment_overrides=07139;
   asmr_w_multiple_segment_overrides=07140;
+  asmr_w_segment_override_ignored_in_64bit_mode=07141;
   asmw_f_too_many_asm_files=08000;
   asmw_f_assembler_output_not_supported=08001;
   asmw_f_comp_not_supported=08002;
@@ -1098,9 +1099,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 81753;
+  MsgTxtSize = 81837;
 
   MsgIdxMax : array[1..20] of longint=(
-    27,106,347,126,96,59,141,34,221,67,
+    27,106,347,126,96,59,142,34,221,67,
     61,20,30,1,1,1,1,1,1,1
   );

文件差异内容过多而无法显示
+ 294 - 295
compiler/msgtxt.inc


+ 4 - 0
compiler/x86/rax86att.pas

@@ -747,6 +747,10 @@ Implementation
                  oper.InitRef;
                  if not is_segment_reg(tempreg) then
                    Message(asmr_e_invalid_seg_override);
+{$ifdef x86_64}
+                 if (tempreg=NR_CS) or (tempreg=NR_DS) or (tempreg=NR_SS) or (tempreg=NR_ES) then
+                   Message1(asmr_w_segment_override_ignored_in_64bit_mode,gas_regname(tempreg));
+{$endif x86_64}
                  oper.opr.ref.segment:=tempreg;
                  { This must absolutely be followed by a reference }
                  if not MaybeBuildReference then

+ 4 - 0
compiler/x86/rax86int.pas

@@ -949,6 +949,10 @@ Unit Rax86int;
       begin
         if not is_segment_reg(seg) then
           Message(asmr_e_invalid_seg_override);
+{$ifdef x86_64}
+        if (seg=NR_CS) or (seg=NR_DS) or (seg=NR_SS) or (seg=NR_ES) then
+          Message1(asmr_w_segment_override_ignored_in_64bit_mode,masm_regname(seg));
+{$endif x86_64}
         case oper.opr.typ of
           OPR_REFERENCE:
             begin

+ 12 - 0
tests/test/tasm25cs0.pp

@@ -0,0 +1,12 @@
+{ %CPU=x86_64 }
+{ %NORUN }
+
+program tasm25cs0;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, cs:[rdi+5]
+  end;
+end.

+ 13 - 0
tests/test/tasm25cs1.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %FAIL }
+
+program tasm25cs1;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, cs:[rdi+5]
+  end;
+end.

+ 12 - 0
tests/test/tasm25cs2.pp

@@ -0,0 +1,12 @@
+{ %CPU=x86_64 }
+{ %NORUN }
+
+program tasm25cs2;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %cs:5(%rdi), %rax
+  end;
+end.

+ 13 - 0
tests/test/tasm25cs3.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %FAIL }
+
+program tasm25cs3;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %cs:5(%rdi), %rax
+  end;
+end.

+ 12 - 0
tests/test/tasm25ds0.pp

@@ -0,0 +1,12 @@
+{ %CPU=x86_64 }
+{ %NORUN }
+
+program tasm25ds0;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, ds:[rdi+5]
+  end;
+end.

+ 13 - 0
tests/test/tasm25ds1.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %FAIL }
+
+program tasm25ds1;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, ds:[rdi+5]
+  end;
+end.

+ 12 - 0
tests/test/tasm25ds2.pp

@@ -0,0 +1,12 @@
+{ %CPU=x86_64 }
+{ %NORUN }
+
+program tasm25ds2;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %ds:5(%rdi), %rax
+  end;
+end.

+ 13 - 0
tests/test/tasm25ds3.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %FAIL }
+
+program tasm25ds3;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %ds:5(%rdi), %rax
+  end;
+end.

+ 12 - 0
tests/test/tasm25es0.pp

@@ -0,0 +1,12 @@
+{ %CPU=x86_64 }
+{ %NORUN }
+
+program tasm25es0;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, es:[rdi+5]
+  end;
+end.

+ 13 - 0
tests/test/tasm25es1.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %FAIL }
+
+program tasm25es1;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, es:[rdi+5]
+  end;
+end.

+ 12 - 0
tests/test/tasm25es2.pp

@@ -0,0 +1,12 @@
+{ %CPU=x86_64 }
+{ %NORUN }
+
+program tasm25es2;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %es:5(%rdi), %rax
+  end;
+end.

+ 13 - 0
tests/test/tasm25es3.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %FAIL }
+
+program tasm25es3;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %es:5(%rdi), %rax
+  end;
+end.

+ 13 - 0
tests/test/tasm25fs0.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %NORUN }
+
+program tasm25fs0;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, fs:[rdi+5]
+  end;
+end.

+ 13 - 0
tests/test/tasm25fs1.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %NORUN }
+
+program tasm25fs1;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %fs:5(%rdi), %rax
+  end;
+end.

+ 13 - 0
tests/test/tasm25gs0.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %NORUN }
+
+program tasm25gs0;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, gs:[rdi+5]
+  end;
+end.

+ 13 - 0
tests/test/tasm25gs1.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %NORUN }
+
+program tasm25gs1;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %gs:5(%rdi), %rax
+  end;
+end.

+ 12 - 0
tests/test/tasm25ss0.pp

@@ -0,0 +1,12 @@
+{ %CPU=x86_64 }
+{ %NORUN }
+
+program tasm25ss0;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, ss:[rdi+5]
+  end;
+end.

+ 13 - 0
tests/test/tasm25ss1.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %FAIL }
+
+program tasm25ss1;
+
+{$asmmode intel}
+
+begin
+  asm
+    mov rax, ss:[rdi+5]
+  end;
+end.

+ 12 - 0
tests/test/tasm25ss2.pp

@@ -0,0 +1,12 @@
+{ %CPU=x86_64 }
+{ %NORUN }
+
+program tasm25ss2;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %ss:5(%rdi), %rax
+  end;
+end.

+ 13 - 0
tests/test/tasm25ss3.pp

@@ -0,0 +1,13 @@
+{ %CPU=x86_64 }
+{ %OPT=-Sew }
+{ %FAIL }
+
+program tasm25ss3;
+
+{$asmmode att}
+
+begin
+  asm
+    mov %ss:5(%rdi), %rax
+  end;
+end.

部分文件因为文件数量过多而无法显示