Преглед изворни кода

+ make cycle "OPT=-Anasmwin32 -dNO_SMART_LINK" works

Merged revisions 6835,6838,6842-6843,6849 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

........
  r6835 | pierre | 2007-03-14 00:17:09 +0100 (Wed, 14 Mar 2007) | 1 line
  
   * force S_IQ size for movq instruction, needed for nasm
........
  r6838 | pierre | 2007-03-14 00:17:55 +0100 (Wed, 14 Mar 2007) | 1 line
  
   * try to get a complete cycle with nasm
........
  r6849 | pierre | 2007-03-14 18:10:23 +0100 (Wed, 14 Mar 2007) | 1 line
  
   * use qword also for S_Q opsize
........

git-svn-id: branches/fixes_2_2@6946 -
pierre пре 18 година
родитељ
комит
5337caca22
2 измењених фајлова са 171 додато и 12 уклоњено
  1. 169 12
      compiler/i386/ag386nsm.pas
  2. 2 0
      compiler/x86/rax86.pas

+ 169 - 12
compiler/i386/ag386nsm.pas

@@ -52,6 +52,12 @@ interface
       fmodule,finput,verbose,cpuinfo,cgbase
       ;
 
+    type
+{$ifdef cpuextended}
+      t80bitarray = array[0..9] of byte;
+{$endif cpuextended}
+      t64bitarray = array[0..7] of byte;
+      t32bitarray = array[0..3] of byte;
     const
       line_length = 64;
 
@@ -145,6 +151,44 @@ interface
       end;
 
 
+  { convert floating point values }
+  { to correct endian             }
+  procedure swap64bitarray(var t: t64bitarray);
+    var
+     b: byte;
+    begin
+      b:= t[7];
+      t[7] := t[0];
+      t[0] := b;
+
+      b := t[6];
+      t[6] := t[1];
+      t[1] := b;
+
+      b:= t[5];
+      t[5] := t[2];
+      t[2] := b;
+
+      b:= t[4];
+      t[4] := t[3];
+      t[3] := b;
+   end;
+
+
+   procedure swap32bitarray(var t: t32bitarray);
+    var
+     b: byte;
+    begin
+      b:= t[1];
+      t[1]:= t[2];
+      t[2]:= b;
+
+      b:= t[0];
+      t[0]:= t[3];
+      t[3]:= b;
+    end;
+
+
     function comp2str(d : bestreal) : string;
       type
         pdouble = ^double;
@@ -164,6 +208,7 @@ interface
            S_B : sizestr:='byte ';
            S_W : sizestr:='word ';
            S_L : sizestr:='dword ';
+           S_Q : sizestr:='qword ';
            S_IS : sizestr:='word ';
            S_IL : sizestr:='dword ';
            S_IQ : sizestr:='qword ';
@@ -298,7 +343,8 @@ interface
                   if o.ref^.offset>0 then
                    asmwrite('+');
                   asmwrite(tostr(o.ref^.offset));
-                end;
+
+                  end;
             end;
           else
             internalerror(10001);
@@ -346,8 +392,8 @@ interface
 
     const
       ait_const2str : array[aitconst_128bit..aitconst_indirect_symbol] of string[20]=(
-        #9'DDQ'#9,#9'DQ'#9,#9'DD'#9,#9'DW'#9,#9'DB'#9,
-        #9'FIXMESLEB',#9'FIXEMEULEB',
+        #9'FIXME_128BIT'#9,#9'FIXME_64BIT'#9,#9'DD'#9,#9'DW'#9,#9'DB'#9,
+        #9'FIXME_SLEB128BIT'#9,#9'FIXME_ULEB128BIT'#9,
         #9'RVA'#9,#9'FIXMEINDIRECT'#9
       );
 
@@ -386,6 +432,10 @@ interface
       end;
 
     procedure T386NasmAssembler.WriteTree(p:TAsmList);
+{$ifdef cpuextended}
+    type
+      t80bitarray = array[0..9] of byte;
+{$endif cpuextended}
     var
       s : string;
       hp       : tai;
@@ -397,6 +447,12 @@ interface
       consttype : taiconst_type;
       do_line,
       quoted   : boolean;
+      co       : comp;
+      sin      : single;
+      d        : double;
+{$ifdef cpuextended}
+      e        : extended;
+{$endif cpuextended}
     begin
       if not assigned(p) then
        exit;
@@ -518,10 +574,21 @@ interface
              begin
                consttype:=tai_const(hp).consttype;
                case consttype of
+                 aitconst_64bit :
+                    begin
+                      if assigned(tai_const(hp).sym) then
+                        internalerror(200404292);
+                      AsmWrite(ait_const2str[aitconst_32bit]);
+                      AsmWrite(tostr(longint(lo(tai_const(hp).value))));
+                      AsmWrite(',');
+                      AsmWrite(tostr(longint(hi(tai_const(hp).value))));
+                      AsmLn;
+                    end;
                  aitconst_uleb128bit,
                  aitconst_sleb128bit,
-                 aitconst_128bit,
-                 aitconst_64bit,
+                 aitconst_128bit:
+                    begin
+                    end;
                  aitconst_32bit,
                  aitconst_16bit,
                  aitconst_8bit,
@@ -557,17 +624,107 @@ interface
                end;
              end;
 
-           ait_real_32bit :
-             AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
-
-           ait_real_64bit :
-             AsmWriteLn(#9#9'DQ'#9+double2str(tai_real_64bit(hp).value));
-
+{$if defined(cpuextended) and defined(FPC_HAS_TYPE_EXTENDED)}
+           ait_real_80bit :
+             begin
+               if do_line then
+                AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_real_80bit(hp).value));
+             { Make sure e is a extended type, bestreal could be
+               a different type (bestreal) !! (PFV) }
+               e:=tai_real_80bit(hp).value;
+               AsmWrite(#9#9'DB'#9);
+               for i:=0 to 9 do
+                begin
+                  if i<>0 then
+                   AsmWrite(',');
+                  AsmWrite(tostr(t80bitarray(e)[i]));
+                end;
+               AsmLn;
+             end;
+{$else cpuextended}
            ait_real_80bit :
              AsmWriteLn(#9#9'DT'#9+extended2str(tai_real_80bit(hp).value));
+{$endif cpuextended}
 
+           // ait_real_64bit :
+           //   AsmWriteLn(#9#9'DQ'#9+double2str(tai_real_64bit(hp).value));
+           ait_real_64bit :
+             begin
+               if do_line then
+                AsmWriteLn(target_asm.comment+'value: '+double2str(tai_real_64bit(hp).value));
+               d:=tai_real_64bit(hp).value;
+               { swap the values to correct endian if required }
+               if source_info.endian <> target_info.endian then
+                 swap64bitarray(t64bitarray(d));
+               AsmWrite(#9#9'DB'#9);
+{$ifdef arm}
+{ on a real arm cpu, it's already hi/lo swapped }
+{$ifndef cpuarm}
+               if tai_real_64bit(hp).formatoptions=fo_hiloswapped then
+                 begin
+                   for i:=4 to 7 do
+                     begin
+                       if i<>4 then
+                         AsmWrite(',');
+                       AsmWrite(tostr(t64bitarray(d)[i]));
+                     end;
+                   for i:=0 to 3 do
+                     begin
+                       AsmWrite(',');
+                       AsmWrite(tostr(t64bitarray(d)[i]));
+                     end;
+                 end
+               else
+{$endif cpuarm}
+{$endif arm}
+                 begin
+                   for i:=0 to 7 do
+                     begin
+                       if i<>0 then
+                         AsmWrite(',');
+                       AsmWrite(tostr(t64bitarray(d)[i]));
+                     end;
+                 end;
+               AsmLn;
+             end;
+           // ait_real_32bit :
+           //   AsmWriteLn(#9#9'DD'#9+single2str(tai_real_32bit(hp).value));
+           ait_real_32bit :
+             begin
+               if do_line then
+                 AsmWriteLn(target_asm.comment+'value: '+single2str(tai_real_32bit(hp).value));
+               sin:=tai_real_32bit(hp).value;
+               { swap the values to correct endian if required }
+               if source_info.endian <> target_info.endian then
+                 swap32bitarray(t32bitarray(sin));
+               AsmWrite(#9#9'DB'#9);
+               for i:=0 to 3 do
+                begin
+                  if i<>0 then
+                    AsmWrite(',');
+                  AsmWrite(tostr(t32bitarray(sin)[i]));
+                end;
+               AsmLn;
+             end;
+           // ait_comp_64bit :
+           //   AsmWriteLn(#9#9'DQ'#9+comp2str(tai_real_80bit(hp).value));
            ait_comp_64bit :
-             AsmWriteLn(#9#9'DQ'#9+comp2str(tai_real_80bit(hp).value));
+             begin
+               if do_line then
+                AsmWriteLn(target_asm.comment+'value: '+extended2str(tai_comp_64bit(hp).value));
+               AsmWrite(#9#9'DB'#9);
+               co:=comp(tai_comp_64bit(hp).value);
+               { swap the values to correct endian if required }
+               if source_info.endian <> target_info.endian then
+                 swap64bitarray(t64bitarray(co));
+               for i:=0 to 7 do
+                begin
+                  if i<>0 then
+                   AsmWrite(',');
+                  AsmWrite(tostr(t64bitarray(co)[i]));
+                end;
+               AsmLn;
+             end;
 
            ait_string :
              begin

+ 2 - 0
compiler/x86/rax86.pas

@@ -387,6 +387,8 @@ begin
           A_MOVD : { movd is a move from a mmx register to a
                      32 bit register or memory, so no opsize is correct here PM }
             exit;
+          A_MOVQ :
+            opsize:=S_IQ;
           A_OUT :
             opsize:=tx86operand(operands[1]).opsize;
           else