Ver código fonte

* factored out some of the duplicated (between x86 targets) parts of process_ea() to a common function

git-svn-id: trunk@32940 -
nickysn 9 anos atrás
pai
commit
439ab331e9
1 arquivos alterados com 36 adições e 55 exclusões
  1. 36 55
      compiler/x86/aasmcpu.pas

+ 36 - 55
compiler/x86/aasmcpu.pas

@@ -1707,31 +1707,16 @@ implementation
         end;
         end;
       end;
       end;
 
 
-    function process_ea(const input:toper;out output:ea;rfield:longint):boolean;
+    function process_ea_ref(const input:toper;out output:ea;rfield:longint):boolean;
       var
       var
         sym   : tasmsymbol;
         sym   : tasmsymbol;
-        md,s,rv  : byte;
+        md,s  : byte;
         base,index,scalefactor,
         base,index,scalefactor,
         o     : longint;
         o     : longint;
         ir,br : Tregister;
         ir,br : Tregister;
         isub,bsub : tsubregister;
         isub,bsub : tsubregister;
       begin
       begin
-        process_ea:=false;
-        fillchar(output,sizeof(output),0);
-        {Register ?}
-        if (input.typ=top_reg) then
-          begin
-            rv:=regval(input.reg);
-            output.modrm:=$c0 or (rfield shl 3) or rv;
-            output.size:=1;
-            output.rex:=output.rex or (rexbits(input.reg) and $F1);
-            process_ea:=true;
-
-            exit;
-         end;
-        {No register, so memory reference.}
-        if input.typ<>top_ref then
-          internalerror(200409263);
+        result:=false;
         ir:=input.ref^.index;
         ir:=input.ref^.index;
         br:=input.ref^.base;
         br:=input.ref^.base;
         isub:=getsubreg(ir);
         isub:=getsubreg(ir);
@@ -1783,7 +1768,7 @@ implementation
             exit;
             exit;
 
 
            output.rex:=output.rex or (rexbits(br) and $F1) or (rexbits(ir) and $F2);
            output.rex:=output.rex or (rexbits(br) and $F1) or (rexbits(ir) and $F2);
-           process_ea:=true;
+           result:=true;
 
 
 
 
            { base }
            { base }
@@ -1929,36 +1914,22 @@ implementation
             end;
             end;
          end;
          end;
         output.size:=1+ord(output.sib_present)+output.bytes;
         output.size:=1+ord(output.sib_present)+output.bytes;
-        process_ea:=true;
+        result:=true;
       end;
       end;
 
 
 
 
 {$elseif defined(i386)}
 {$elseif defined(i386)}
 
 
-    function process_ea(const input:toper;out output:ea;rfield:longint):boolean;
+    function process_ea_ref(const input:toper;out output:ea;rfield:longint):boolean;
       var
       var
         sym   : tasmsymbol;
         sym   : tasmsymbol;
-        md,s,rv  : byte;
+        md,s  : byte;
         base,index,scalefactor,
         base,index,scalefactor,
         o     : longint;
         o     : longint;
         ir,br : Tregister;
         ir,br : Tregister;
         isub,bsub : tsubregister;
         isub,bsub : tsubregister;
       begin
       begin
-        process_ea:=false;
-        fillchar(output,sizeof(output),0);
-        {Register ?}
-        if (input.typ=top_reg) then
-          begin
-            rv:=regval(input.reg);
-            output.modrm:=$c0 or (rfield shl 3) or rv;
-            output.size:=1;
-            process_ea:=true;
-            exit;
-         end;
-        {No register, so memory reference.}
-        if (input.typ<>top_ref) then
-          internalerror(200409262);
-
+        result:=false;
         if ((input.ref^.index<>NR_NO) and (getregtype(input.ref^.index)=R_MMREGISTER) and (input.ref^.base<>NR_NO) and (getregtype(input.ref^.base)<>R_INTREGISTER)) or // vector memory (AVX2)
         if ((input.ref^.index<>NR_NO) and (getregtype(input.ref^.index)=R_MMREGISTER) and (input.ref^.base<>NR_NO) and (getregtype(input.ref^.base)<>R_INTREGISTER)) or // vector memory (AVX2)
            ((input.ref^.index<>NR_NO) and (getregtype(input.ref^.index)<>R_INTREGISTER) and (getregtype(input.ref^.index)<>R_MMREGISTER)) or
            ((input.ref^.index<>NR_NO) and (getregtype(input.ref^.index)<>R_INTREGISTER) and (getregtype(input.ref^.index)<>R_MMREGISTER)) or
            ((input.ref^.base<>NR_NO) and (getregtype(input.ref^.base)<>R_INTREGISTER)) then
            ((input.ref^.base<>NR_NO) and (getregtype(input.ref^.base)<>R_INTREGISTER)) then
@@ -2100,7 +2071,7 @@ implementation
          output.size:=2+output.bytes
          output.size:=2+output.bytes
         else
         else
          output.size:=1+output.bytes;
          output.size:=1+output.bytes;
-        process_ea:=true;
+        result:=true;
       end;
       end;
 {$elseif defined(i8086)}
 {$elseif defined(i8086)}
 
 
@@ -2117,7 +2088,7 @@ implementation
           end;
           end;
       end;
       end;
 
 
-    function process_ea(const input:toper;out output:ea;rfield:longint):boolean;
+    function process_ea_ref(const input:toper;out output:ea;rfield:longint):boolean;
       var
       var
         sym   : tasmsymbol;
         sym   : tasmsymbol;
         md,s,rv  : byte;
         md,s,rv  : byte;
@@ -2126,21 +2097,7 @@ implementation
         ir,br : Tregister;
         ir,br : Tregister;
         isub,bsub : tsubregister;
         isub,bsub : tsubregister;
       begin
       begin
-        process_ea:=false;
-        fillchar(output,sizeof(output),0);
-        {Register ?}
-        if (input.typ=top_reg) then
-          begin
-            rv:=regval(input.reg);
-            output.modrm:=$c0 or (rfield shl 3) or rv;
-            output.size:=1;
-            process_ea:=true;
-            exit;
-          end;
-        {No register, so memory reference.}
-        if (input.typ<>top_ref) then
-          internalerror(200409262);
-
+        result:=false;
         if ((input.ref^.index<>NR_NO) and (getregtype(input.ref^.index)<>R_INTREGISTER)) or
         if ((input.ref^.index<>NR_NO) and (getregtype(input.ref^.index)<>R_INTREGISTER)) or
            ((input.ref^.base<>NR_NO) and (getregtype(input.ref^.base)<>R_INTREGISTER)) then
            ((input.ref^.base<>NR_NO) and (getregtype(input.ref^.base)<>R_INTREGISTER)) then
           internalerror(200301081);
           internalerror(200301081);
@@ -2201,10 +2158,34 @@ implementation
           end;
           end;
         output.size:=1+output.bytes;
         output.size:=1+output.bytes;
         output.sib_present:=false;
         output.sib_present:=false;
-        process_ea:=true;
+        result:=true;
       end;
       end;
 {$endif}
 {$endif}
 
 
+    function process_ea(const input:toper;out output:ea;rfield:longint):boolean;
+      var
+        rv  : byte;
+      begin
+        result:=false;
+        fillchar(output,sizeof(output),0);
+        {Register ?}
+        if (input.typ=top_reg) then
+          begin
+            rv:=regval(input.reg);
+            output.modrm:=$c0 or (rfield shl 3) or rv;
+            output.size:=1;
+{$ifdef x86_64}
+            output.rex:=output.rex or (rexbits(input.reg) and $F1);
+{$endif x86_64}
+            result:=true;
+            exit;
+          end;
+        {No register, so memory reference.}
+        if input.typ<>top_ref then
+          internalerror(200409263);
+        result:=process_ea_ref(input,output,rfield);
+      end;
+
     function taicpu.calcsize(p:PInsEntry):shortint;
     function taicpu.calcsize(p:PInsEntry):shortint;
       var
       var
         codes : pchar;
         codes : pchar;