ソースを参照

Merged revisions 12043 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
r12043 | florian | 2008-11-09 22:14:45 +0100 (So, 09 Nov 2008) | 2 lines

* fixes taking the address of an assembler block defined label
* create short jumps also for asm blocks, thanks to Sergej Gorelkin for the patch, resolves #11638
........

git-svn-id: branches/fixes_2_2@12044 -

florian 17 年 前
コミット
4d91bc8704
5 ファイル変更26 行追加1 行削除
  1. 1 0
      .gitattributes
  2. 4 1
      compiler/ncgld.pas
  3. 2 0
      compiler/x86/aasmcpu.pas
  4. 4 0
      compiler/x86/rax86.pas
  5. 15 0
      tests/webtbs/tw11638.pp

+ 1 - 0
.gitattributes

@@ -8062,6 +8062,7 @@ tests/webtbs/tw1152.pp svneol=native#text/plain
 tests/webtbs/tw1157.pp svneol=native#text/plain
 tests/webtbs/tw1157b.pp svneol=native#text/plain
 tests/webtbs/tw11619.pp svneol=native#text/plain
+tests/webtbs/tw11638.pp svneol=native#text/plain
 tests/webtbs/tw11786.pp svneol=native#text/plain
 tests/webtbs/tw1181.pp svneol=native#text/plain
 tests/webtbs/tw1203.pp svneol=native#text/plain

+ 4 - 1
compiler/ncgld.pas

@@ -353,7 +353,10 @@ implementation
                     end;
                end;
             labelsym :
-              location.reference.symbol:=tcglabelnode((tlabelsym(symtableentry).code)).getasmlabel;
+              if assigned(tlabelsym(symtableentry).asmblocklabel) then
+                location.reference.symbol:=tlabelsym(symtableentry).asmblocklabel
+              else
+                location.reference.symbol:=tcglabelnode((tlabelsym(symtableentry).code)).getasmlabel;
             else internalerror(200510032);
          end;
       end;

+ 2 - 0
compiler/x86/aasmcpu.pas

@@ -1002,6 +1002,8 @@ implementation
                     ot:=OT_IMM8 or OT_SIGNED
                   else
                     ot:=OT_IMMEDIATE or opsize_2_type[i,opsize];
+                  if (val=1) and (i=1) then
+                    ot := ot or OT_ONENESS;
                 end;
               top_none :
                 begin

+ 4 - 0
compiler/x86/rax86.pas

@@ -754,6 +754,10 @@ begin
  { Condition ? }
   if condition<>C_None then
    ai.SetCondition(condition);
+  
+  { Set is_jmp, it enables asmwriter to emit short jumps if appropriate }
+  if (opcode=A_JMP) or (opcode=A_JCC) then
+    ai.is_jmp := True;
 
  { Concat the opcode or give an error }
   if assigned(ai) then

+ 15 - 0
tests/webtbs/tw11638.pp

@@ -0,0 +1,15 @@
+{ %cpu=i386 }
+{$goto on}
+label
+  l1,l2;
+begin
+  if PtrInt(@l2-@l1)>3 then
+    halt(1);
+  halt(0);
+  asm
+     l1:
+        JMP l1 // E9 01000000 instead EB 01
+        NOP
+     l2:
+  end;
+end.