浏览代码

* treat parameters that are passed in registers as register operands in the
x86 intel assembler reader (patch by Sergei Gorelkin, mantis #6851)

git-svn-id: trunk@14402 -

Jonas Maebe 15 年之前
父节点
当前提交
f2c0190aa3
共有 3 个文件被更改,包括 53 次插入0 次删除
  1. 1 0
      .gitattributes
  2. 12 0
      compiler/x86/rax86int.pas
  3. 40 0
      tests/webtbs/tw6851.pp

+ 1 - 0
.gitattributes

@@ -10760,6 +10760,7 @@ tests/webtbs/tw6769.pp svneol=native#text/plain
 tests/webtbs/tw6822a.pp svneol=native#text/plain
 tests/webtbs/tw6822b.pp svneol=native#text/plain
 tests/webtbs/tw6822c.pp svneol=native#text/plain
+tests/webtbs/tw6851.pp svneol=native#text/plain
 tests/webtbs/tw6865.pp svneol=native#text/plain
 tests/webtbs/tw6868.pp svneol=native#text/plain
 tests/webtbs/tw6960.pp svneol=native#text/plain

+ 12 - 0
compiler/x86/rax86int.pas

@@ -225,9 +225,19 @@ Unit Rax86int;
 
 
     function tx86intreader.is_register(const s:string):boolean;
+      var
+        entry: TSymEntry;
       begin
         is_register:=false;
         actasmregister:=masm_regnum_search(lower(s));
+        if (actasmregister=NR_NO) and (current_procinfo.procdef.proccalloption=pocall_register) then
+          begin
+            entry := current_procinfo.procdef.parast.Find(s);
+            if assigned(entry) and (entry.typ=paravarsym) and
+              assigned(tparavarsym(entry).paraloc[calleeside].Location) and
+              (tparavarsym(entry).paraloc[calleeside].Location^.Loc=LOC_REGISTER) then
+                actasmregister:=tparavarsym(entry).paraloc[calleeside].Location^.register;
+          end;
         if actasmregister<>NR_NO then
           begin
             is_register:=true;
@@ -2081,6 +2091,8 @@ Unit Rax86int;
       curlist:=TAsmList.Create;
       { setup label linked list }
       LocalLabelList:=TLocalLabelList.Create;
+      { we might need to know which parameters are passed in registers }
+      current_procinfo.generate_parameter_info;
       { start tokenizer }
       c:=current_scanner.asmgetcharstart;
       gettoken;

+ 40 - 0
tests/webtbs/tw6851.pp

@@ -0,0 +1,40 @@
+{ %norun }
+{ %cpu=i386 }
+{ %opt=-Cg- }
+
+{$mode delphi}
+
+program test;
+
+const
+
+  BitMaskTable: Array[0..31] of LongWord =
+    ($00000001, $00000002, $00000004, $00000008,
+     $00000010, $00000020, $00000040, $00000080,
+     $00000100, $00000200, $00000400, $00000800,
+     $00001000, $00002000, $00004000, $00008000,
+     $00010000, $00020000, $00040000, $00080000,
+     $00100000, $00200000, $00400000, $00800000,
+     $01000000, $02000000, $04000000, $08000000,
+     $10000000, $20000000, $40000000, $80000000);
+
+  BitsPerByte      = 8;
+  BitsPerWord      = 16;
+  BitsPerLongWord  = 32;
+  BytesPerCardinal = Sizeof(Cardinal);
+  BitsPerCardinal  = BytesPerCardinal * 8;
+
+
+function SetBit(const Value, BitIndex: LongWord): LongWord;
+asm
+     {$IFOPT R+}
+      CMP     BitIndex, BitsPerLongWord
+      JAE     @Fin
+     {$ENDIF}
+      OR      EAX, DWORD PTR [BitIndex * 4 + BitMaskTable]
+    @Fin:
+end;
+
+begin
+
+end.