Browse Source

* throw an error if esp/rsp are used as index register

git-svn-id: trunk@49568 -
florian 4 years ago
parent
commit
ce1f9cce01
6 changed files with 296 additions and 286 deletions
  1. 1 0
      .gitattributes
  2. 2 1
      compiler/msg/errore.msg
  3. 3 2
      compiler/msgidx.inc
  4. 281 283
      compiler/msgtxt.inc
  5. 2 0
      compiler/x86/aasmcpu.pas
  6. 7 0
      tests/tbf/tb0275.pp

+ 1 - 0
.gitattributes

@@ -12891,6 +12891,7 @@ tests/tbf/tb0271.pp svneol=native#text/pascal
 tests/tbf/tb0272.pp svneol=native#text/plain
 tests/tbf/tb0273.pp svneol=native#text/pascal
 tests/tbf/tb0274.pp svneol=native#text/pascal
+tests/tbf/tb0275.pp svneol=native#text/pascal
 tests/tbf/tb0588.pp svneol=native#text/pascal
 tests/tbf/ub0115.pp svneol=native#text/plain
 tests/tbf/ub0149.pp svneol=native#text/plain

+ 2 - 1
compiler/msg/errore.msg

@@ -2929,7 +2929,7 @@ asmr_e_unknown_field=07145_E_Unknown field identifier
 #
 # Assembler/binary writers
 #
-# 08035 is the last used one
+# 08036 is the last used one
 #
 asmw_f_too_many_asm_files=08000_F_Too many assembler files
 % With smartlinking enabled, there are too many assembler
@@ -2986,6 +2986,7 @@ asmw_e_instruction_not_supported_by_cpu=08032_E_Instruction not supported by the
 asmw_e_brxx_out_of_range=08033_E_Asm: conditional branch destination is out of range
 asmw_e_illegal_use_of_rip=08034_E_Asm: RIP cannot be used as index register or with another register in a reference
 asmw_e_seh_invalid_data_size=08035_F_Illegal function size for SEH function
+asmw_e_illegal_use_of_sp=08036_E_Asm: ESP/RSP cannot be used as index register
 #
 # Executing linker/assembler
 #

+ 3 - 2
compiler/msgidx.inc

@@ -895,6 +895,7 @@ const
   asmw_e_brxx_out_of_range=08033;
   asmw_e_illegal_use_of_rip=08034;
   asmw_e_seh_invalid_data_size=08035;
+  asmw_e_illegal_use_of_sp=08036;
   exec_w_source_os_redefined=09000;
   exec_i_assembling_pipe=09001;
   exec_d_cant_create_asmfile=09002;
@@ -1139,9 +1140,9 @@ const
   option_info=11024;
   option_help_pages=11025;
 
-  MsgTxtSize = 87808;
+  MsgTxtSize = 87862;
 
   MsgIdxMax : array[1..20] of longint=(
-    28,107,361,131,99,63,146,36,223,68,
+    28,107,361,131,99,63,146,37,223,68,
     64,20,30,1,1,1,1,1,1,1
   );

File diff suppressed because it is too large
+ 281 - 283
compiler/msgtxt.inc


+ 2 - 0
compiler/x86/aasmcpu.pas

@@ -2584,6 +2584,8 @@ implementation
            if ((br=NR_RIP) and (ir<>NR_NO)) or
              (ir=NR_RIP) then
              message(asmw_e_illegal_use_of_rip);
+           if ir=NR_STACK_POINTER_REG then
+             Message(asmw_e_illegal_use_of_sp);
            { 16 bit? }
 
            if ((ir<>NR_NO) and (isub in [R_SUBMMX,R_SUBMMY,R_SUBMMZ]) and

+ 7 - 0
tests/tbf/tb0275.pp

@@ -0,0 +1,7 @@
+{ %fail }
+{ %CPU=x86_64 }
+begin
+  asm
+    movq (%rdi,%rsp),%rax
+  end;
+end.

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