Pārlūkot izejas kodu

* 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: trunk@12043 -

florian 16 gadi atpakaļ
vecāks
revīzija
53ffda14f3
5 mainītis faili ar 26 papildinājumiem un 1 dzēšanām
  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

@@ -8574,6 +8574,7 @@ tests/webtbs/tw11568.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/tw11711.pp svneol=native#text/plain
 tests/webtbs/tw11762.pp svneol=native#text/plain
 tests/webtbs/tw11763.pp svneol=native#text/plain

+ 4 - 1
compiler/ncgld.pas

@@ -510,7 +510,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

@@ -1003,6 +1003,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.