Browse Source

Merge of several commits related to enhancements in PPU writing
and more precisely to cross reading/writing fixes.

------------------------------------------------------------------------
r41896 | pierre | 2019-04-18 14:08:03 +0000 (Thu, 18 Apr 2019) | 15 lines

Integrate patch from bug report 35409.
Add possibiliy to throw InternalError
for unhandled case values inside tentryfile,
But avoid adding dependency on verbose unit
as this would break ppudump handling of ppu files.

Add RaiseAssertion virtual method to tentryfile class.
Call RaiseAssertion in tentryfile methods
where an internal error is wanted.
Override RaiseAssertion method in symtype.pas unit
to call InternalError.
Add new class tppudumpfile to override RaiseAssertion
in utils/ppuutils/ppudump.pp unit.


------------------------------------------------------------------------
--- Merging r41896 into '.':
U compiler/entfile.pas
U compiler/pcp.pas
U compiler/symtype.pas
U compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r41896 into '.':
U .
------------------------------------------------------------------------
r42111 | pierre | 2019-05-20 22:06:57 +0000 (Mon, 20 May 2019) | 1 line

List TSettings partially and improve generic output
------------------------------------------------------------------------
--- Merging r42111 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42111 into '.':
G .
------------------------------------------------------------------------
r42322 | pierre | 2019-07-03 13:35:05 +0000 (Wed, 03 Jul 2019) | 1 line

Systematically include fpcdefs.inc at sart of all units used by compiler
------------------------------------------------------------------------
--- Merging r42322 into '.':
U compiler/aarch64/cpuinfo.pas
U compiler/arm/cpuinfo.pas
U compiler/avr/cpuinfo.pas
U compiler/ccharset.pas
U compiler/generic/cpuinfo.pas
U compiler/jvm/cpuinfo.pas
U compiler/m68k/cpuinfo.pas
U compiler/macho.pas
U compiler/machoutils.pas
U compiler/mips/cpuinfo.pas
G compiler/pcp.pas
U compiler/powerpc/cpuinfo.pas
U compiler/powerpc64/cpuinfo.pas
U compiler/systems/i_wii.pas
--- Recording mergeinfo for merge of r42322 into '.':
G .

------------------------------------------------------------------------
r42323 | pierre | 2019-07-04 15:24:49 +0000 (Thu, 04 Jul 2019) | 7 lines

* Set ControllerSupport to false for sparc/sparc64 and x86_64 CPUs.
This boolean must only be set to true if TControllerType is not simply (ct_none)
* ppu.pas: Increment CurrentPPULongVersion constant as the above modification
changes the number of fields of the TSettings record that is saved to
PPU in ST_LOADSETTINGS field. { not mereged }


------------------------------------------------------------------------
--- Merging r42323 into '.':
C compiler/ppu.pas { not mereged }
U compiler/sparc/cpuinfo.pas
U compiler/sparc64/cpuinfo.pas
U compiler/x86_64/cpuinfo.pas
--- Recording mergeinfo for merge of r42323 into '.':
G .

------------------------------------------------------------------------
r42324 | pierre | 2019-07-04 15:25:40 +0000 (Thu, 04 Jul 2019) | 1 line

Correctly read saved tsettings
------------------------------------------------------------------------
--- Merging r42324 into '.':
C compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42324 into '.':
G .
Summary of conflicts:
Text conflicts: 1
------------------------------------------------------------------------
r42325 | marcus | 2019-07-04 16:49:26 +0000 (Thu, 04 Jul 2019) | 1 line

Fixed ppudump compilation on big endian platforms after r42324
------------------------------------------------------------------------
--- Merging r42325 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42325 into '.':
G .
------------------------------------------------------------------------
r42353 | svenbarth | 2019-07-12 16:25:33 +0000 (Fri, 12 Jul 2019) | 1 line

* write an entry name for the property options
------------------------------------------------------------------------
--- Merging r42353 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42353 into '.':
G .
------------------------------------------------------------------------
r42354 | svenbarth | 2019-07-12 16:25:36 +0000 (Fri, 12 Jul 2019) | 1 line

* write a name for the none property access entry (looks nicer than a "(Nil)" at the start of the line)
------------------------------------------------------------------------
--- Merging r42354 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42354 into '.':
G .
------------------------------------------------------------------------
r42527 | pierre | 2019-07-29 05:33:00 +0000 (Mon, 29 Jul 2019) | 22 lines

Fix recordtoken writing into ppu files to allow correct
handling in cross-configuration with different endianess.

The code has been modified to use the same scheme as the writing of
the other parts of the ppu, i.e. change_endian filed has been
added also to tscannerfile class of scanner unit.
This field is then used to swap values that required endianess
conversion.

* scanner.pas: change_endian filed added to tscannerfile class.
The value of this field is set as the same field in tentryfile class of entfile unit.
Token read and write methods converted to use change_endian field.

* ppu.pas: Increase CurrentPPILongVersion

* utils/ppuutils/ppudump.pp: Remove unneeded FPC_BIG_ENDIAN code
which was needed because tokens were previously written using a
different rule.




------------------------------------------------------------------------
--- Merging r42527 into '.':
C compiler/ppu.pas
U compiler/scanner.pas
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42527 into '.':
G .
Summary of conflicts:
Text conflicts: 1
------------------------------------------------------------------------
r42528 | pierre | 2019-07-29 11:54:27 +0000 (Mon, 29 Jul 2019) | 1 line
Changed paths:
M /trunk/compiler/scanner.pas

Try to fix bug introduced in previous commit #42527, hopefully fixing bug report 35902
------------------------------------------------------------------------

--- Merging r42528 into '.':
G compiler/scanner.pas
--- Recording mergeinfo for merge of r42528 into '.':
G .------------------------------------------------------------------------
r42530 | pierre | 2019-07-29 16:40:58 +0000 (Mon, 29 Jul 2019) | 8 lines

Try to fix ppudump for generic/inline.

* entfile.pas: Differenciate ibsymtableoptions and ibrecsymtableoptions.
* ppu.pas: Increase ppu unit CurrentPPULongVersion value.
* utils/ppuutils/ppudump.pp: Add current_symtable_options variable.
Change readsymtableoptions from procedure to function returning
the new tsymtableoptions.

------------------------------------------------------------------------
--- Merging r42530 into '.':
G compiler/entfile.pas
G compiler/ppu.pas
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42530 into '.':
G .
------------------------------------------------------------------------
r42583 | pierre | 2019-08-05 09:15:12 +0000 (Mon, 05 Aug 2019) | 1 line

Reorganize token buffer output to be able to use it for generics and inlined functions
------------------------------------------------------------------------
--- Merging r42583 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42583 into '.':
G .
------------------------------------------------------------------------
r42591 | pierre | 2019-08-06 06:32:52 +0000 (Tue, 06 Aug 2019) | 1 line

Add mode and optimizer switches names, and check that no unknown switch is set
------------------------------------------------------------------------
--- Merging r42591 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42591 into '.':
G .
------------------------------------------------------------------------
r42596 | pierre | 2019-08-06 21:32:51 +0000 (Tue, 06 Aug 2019) | 1 line

Fix gettokenbufshortint, as shortint is one byte long, not two
------------------------------------------------------------------------
--- Merging r42596 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42596 into '.':
G .
------------------------------------------------------------------------
r42609 | pierre | 2019-08-09 09:29:50 +0000 (Fri, 09 Aug 2019) | 1 line

Correct size of asizeint, which is still 4-byte long even when CpuAddrBitSize is 16 as for avr and i8086
------------------------------------------------------------------------
--- Merging r42609 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42609 into '.':
G .
------------------------------------------------------------------------
r42670 | pierre | 2019-08-13 06:20:23 +0000 (Tue, 13 Aug 2019) | 1 line

Reduce cpu-os dependency on real constant printout by using system.str
------------------------------------------------------------------------
--- Merging r42670 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42670 into '.':
G .
------------------------------------------------------------------------
r42906 | pierre | 2019-09-02 16:00:15 +0000 (Mon, 02 Sep 2019) | 1 line

Fix problems with big endian systems without 80-bit floating point support
------------------------------------------------------------------------
--- Merging r42906 into '.':
G compiler/utils/ppuutils/ppudump.pp
--- Recording mergeinfo for merge of r42906 into '.':
G .

git-svn-id: branches/fixes_3_2@43387 -

pierre 5 years ago
parent
commit
1f20cfe991

+ 2 - 0
compiler/aarch64/cpuinfo.pas

@@ -14,6 +14,8 @@
 
 Unit CPUInfo;
 
+{$i fpcdefs.inc}
+
 Interface
 
   uses

+ 2 - 0
compiler/arm/cpuinfo.pas

@@ -14,6 +14,8 @@
 
 Unit CPUInfo;
 
+{$i fpcdefs.inc}
+
 Interface
 
   uses

+ 2 - 0
compiler/avr/cpuinfo.pas

@@ -14,6 +14,8 @@
 
 Unit CPUInfo;
 
+{$i fpcdefs.inc}
+
 Interface
 
   uses

+ 2 - 0
compiler/ccharset.pas

@@ -16,6 +16,8 @@
 {$mode objfpc}
 unit ccharset;
 
+{$i fpcdefs.inc}
+
   interface
 
     type

+ 28 - 6
compiler/entfile.pas

@@ -122,9 +122,9 @@ const
 
   ibmainname       = 90;
   ibsymtableoptions = 91;
-  ibrecsymtableoptions = 91;
   ibpackagefiles   = 92;
   ibpackagename    = 93;
+  ibrecsymtableoptions = 94;
   { target-specific things }
   iblinkotherframeworks = 100;
   ibjvmnamespace = 101;
@@ -231,6 +231,7 @@ type
     procedure resetfile;virtual;abstract;
     function getheadersize:longint;virtual;abstract;
     function getheaderaddr:pentryheader;virtual;abstract;
+    procedure RaiseAssertion(Code: Longint); virtual;
   public
     entrytyp : byte;
     size             : integer;
@@ -379,6 +380,13 @@ begin
 end;
 
 
+procedure tentryfile.RaiseAssertion(Code: Longint);
+begin
+  { It's down to descendent classes to raise an internal error as desired. [Kit] }
+  error := true;
+end;
+
+
 procedure tentryfile.closefile;
 begin
   if mode<>0 then
@@ -739,12 +747,16 @@ begin
       result:=0;
     end;
 {$else not generic_cpu}
-  result:=4;
   case sizeof(aint) of
     8: result:=getint64;
     4: result:=getlongint;
     2: result:=smallint(getword);
     1: result:=shortint(getbyte);
+  else
+    begin
+      RaiseAssertion(2019041801);
+      result:=0;
+    end;
   end;
 {$endif not generic_cpu}
 end;
@@ -783,9 +795,12 @@ begin
     4: result:=asizeint(getlongint);
     2: result:=asizeint(getword);
     1: result:=asizeint(getbyte);
-    else
+  else
+    begin
+      RaiseAssertion(2019041802);
       result:=0;
-end;
+    end;
+  end;
 {$endif not generic_cpu}
 end;
 
@@ -816,7 +831,10 @@ begin
     2: result:=getword;
     1: result:=getbyte;
   else
-    result:=0;
+    begin
+      RaiseAssertion(2019041803);
+      result:=0;
+    end;
   end;
 {$endif not generic_cpu}
 end;
@@ -865,12 +883,16 @@ begin
       result:=0;
     end;
 {$else not generic_cpu}
-  result:=4;
   case sizeof(aword) of
     8: result:=getqword;
     4: result:=getdword;
     2: result:=getword;
     1: result:=getbyte;
+  else
+    begin
+      RaiseAssertion(2019041804);
+      result:=0;
+    end;
   end;
 {$endif not generic_cpu}
 end;

+ 2 - 0
compiler/generic/cpuinfo.pas

@@ -15,6 +15,8 @@
 
 Unit CPUInfo;
 
+{$i fpcdefs.inc}
+
 Interface
 
   uses

+ 2 - 0
compiler/jvm/cpuinfo.pas

@@ -14,6 +14,8 @@
 
 Unit cpuinfo;
 
+{$i fpcdefs.inc}
+
 Interface
 
   uses

+ 2 - 0
compiler/m68k/cpuinfo.pas

@@ -14,6 +14,8 @@
 
 Unit CPUInfo;
 
+{$i fpcdefs.inc}
+
 Interface
 
   uses

+ 3 - 1
compiler/macho.pas

@@ -24,7 +24,9 @@ unit macho;
 
 { converted by Dmitry Boyarintsev 2009 }
 
-{$mode objfpc}{$H+}
+{$i fpcdefs.inc}
+
+{$H+}
 
 interface
 

+ 4 - 2
compiler/machoutils.pas

@@ -23,9 +23,11 @@
 
 unit machoutils;
 
-interface
+{$i fpcdefs.inc}
+
+{$h+}
 
-{$mode objfpc}{$h+}
+interface
 
 uses
   macho;

+ 2 - 0
compiler/mips/cpuinfo.pas

@@ -14,6 +14,8 @@
 
 Unit CPUInfo;
 
+{$i fpcdefs.inc}
+
 Interface
 
   uses

+ 10 - 1
compiler/pcp.pas

@@ -21,7 +21,9 @@
 }
 unit pcp;
 
-{$mode objfpc}{$H+}
+{$i fpcdefs.inc}
+
+{$H+}
 
 interface
 
@@ -66,6 +68,7 @@ interface
       procedure newheader;override;
       function readheader:longint;override;
       procedure resetfile;override;
+      procedure RaiseAssertion(Code: Longint); override;
     public
       procedure writeheader;override;
       function checkpcpid:boolean;
@@ -89,6 +92,12 @@ uses
       result:=@header;
     end;
 
+  procedure tpcpfile.RaiseAssertion(Code: Longint);
+    begin
+      // InternalError(nb);
+      inherited RaiseAssertion(Code);
+    end;
+
   procedure tpcpfile.newheader;
     var
       s : string;

+ 2 - 0
compiler/powerpc/cpuinfo.pas

@@ -14,6 +14,8 @@
 
 Unit CPUInfo;
 
+{$i fpcdefs.inc}
+
 Interface
 
   uses

+ 2 - 0
compiler/powerpc64/cpuinfo.pas

@@ -14,6 +14,8 @@
 
 unit CPUInfo;
 
+{$i fpcdefs.inc}
+
 interface
 
 uses

+ 5 - 1
compiler/ppu.pas

@@ -43,7 +43,11 @@ type
 {$endif Test_Double_checksum}
 
 const
-  CurrentPPUVersion = 206;
+  { only update this version if something change in the tppuheader:
+     * the unit flags listed below
+     * the format of the header itslf
+    This number cannot become bigger than 255 (it's stored in a byte) }
+  CurrentPPUVersion = 207;
 
 { unit flags }
   uf_init                = $000001; { unit has initialization section }

+ 21 - 49
compiler/scanner.pas

@@ -145,6 +145,8 @@ interface
 
           { true, if we are parsing preprocessor expressions }
           in_preproc_comp_expr : boolean;
+          { true if cross-compiling for a CPU in opposite endianess}
+          change_endian_for_tokens : boolean;
 
           constructor Create(const fn:string; is_macro: boolean = false);
           destructor Destroy;override;
@@ -284,7 +286,7 @@ implementation
       symbase,symtable,symtype,symsym,symconst,symdef,defutil,
       { This is needed for tcputype }
       cpuinfo,
-      fmodule,
+      fmodule,fppu,
       { this is needed for $I %CURRENTROUTINE%}
       procinfo
 {$if FPC_FULLVERSION<20700}
@@ -2698,7 +2700,11 @@ type
         lasttoken:=NOTOKEN;
         nexttoken:=NOTOKEN;
         ignoredirectives:=TFPHashList.Create;
-      end;
+        if (current_module is tppumodule) and assigned(tppumodule(current_module).ppufile) then
+          change_endian_for_tokens:=tppumodule(current_module).ppufile.change_endian
+        else
+          change_endian_for_tokens:=false;
+       end;
 
 
     procedure tscannerfile.firstfile;
@@ -2870,17 +2876,11 @@ type
 
     procedure tscannerfile.tokenwritesizeint(val : asizeint);
       begin
-{$ifdef FPC_BIG_ENDIAN}
-        val:=swapendian(val);
-{$endif}
         recordtokenbuf.write(val,sizeof(asizeint));
       end;
 
     procedure tscannerfile.tokenwritelongint(val : longint);
       begin
-{$ifdef FPC_BIG_ENDIAN}
-        val:=swapendian(val);
-{$endif}
         recordtokenbuf.write(val,sizeof(longint));
       end;
 
@@ -2891,17 +2891,11 @@ type
 
     procedure tscannerfile.tokenwriteword(val : word);
       begin
-{$ifdef FPC_BIG_ENDIAN}
-        val:=swapendian(val);
-{$endif}
         recordtokenbuf.write(val,sizeof(word));
       end;
 
     procedure tscannerfile.tokenwritelongword(val : longword);
       begin
-{$ifdef FPC_BIG_ENDIAN}
-        val:=swapendian(val);
-{$endif}
         recordtokenbuf.write(val,sizeof(longword));
       end;
 
@@ -2910,9 +2904,8 @@ type
         val : asizeint;
       begin
         replaytokenbuf.read(val,sizeof(asizeint));
-{$ifdef FPC_BIG_ENDIAN}
-        val:=swapendian(val);
-{$endif}
+        if change_endian_for_tokens then
+          val:=swapendian(val);
         result:=val;
       end;
 
@@ -2921,9 +2914,8 @@ type
         val : longword;
       begin
         replaytokenbuf.read(val,sizeof(longword));
-{$ifdef FPC_BIG_ENDIAN}
-        val:=swapendian(val);
-{$endif}
+        if change_endian_for_tokens then
+          val:=swapendian(val);
         result:=val;
       end;
 
@@ -2932,9 +2924,8 @@ type
         val : longint;
       begin
         replaytokenbuf.read(val,sizeof(longint));
-{$ifdef FPC_BIG_ENDIAN}
-        val:=swapendian(val);
-{$endif}
+        if change_endian_for_tokens then
+          val:=swapendian(val);
         result:=val;
       end;
 
@@ -2959,9 +2950,8 @@ type
         val : smallint;
       begin
         replaytokenbuf.read(val,sizeof(smallint));
-{$ifdef FPC_BIG_ENDIAN}
-        val:=swapendian(val);
-{$endif}
+        if change_endian_for_tokens then
+          val:=swapendian(val);
         result:=val;
       end;
 
@@ -2970,9 +2960,8 @@ type
         val : word;
       begin
         replaytokenbuf.read(val,sizeof(word));
-{$ifdef FPC_BIG_ENDIAN}
-        val:=swapendian(val);
-{$endif}
+        if change_endian_for_tokens then
+          val:=swapendian(val);
         result:=val;
       end;
 
@@ -2989,16 +2978,13 @@ type
    end;
 
    procedure tscannerfile.tokenreadset(var b;size : longint);
-{$ifdef FPC_BIG_ENDIAN}
    var
      i : longint;
-{$endif}
    begin
      replaytokenbuf.read(b,size);
-{$ifdef FPC_BIG_ENDIAN}
-     for i:=0 to size-1 do
-       Pbyte(@b)[i]:=reverse_byte(Pbyte(@b)[i]);
-{$endif}
+     if change_endian_for_tokens then
+       for i:=0 to size-1 do
+         Pbyte(@b)[i]:=reverse_byte(Pbyte(@b)[i]);
    end;
 
    procedure tscannerfile.tokenwriteenum(var b;size : longint);
@@ -3007,22 +2993,8 @@ type
    end;
 
    procedure tscannerfile.tokenwriteset(var b;size : longint);
-{$ifdef FPC_BIG_ENDIAN}
-   var
-     i: longint;
-     tmpset: array[0..31] of byte;
-{$endif}
    begin
-{$ifdef FPC_BIG_ENDIAN}
-     { satisfy DFA because it assumes that size may be 0 and doesn't know that
-       recordtokenbuf.write wouldn't use tmpset in that case }
-     tmpset[0]:=0;
-     for i:=0 to size-1 do
-       tmpset[i]:=reverse_byte(Pbyte(@b)[i]);
-     recordtokenbuf.write(tmpset,size);
-{$else}
      recordtokenbuf.write(b,size);
-{$endif}
    end;
 
 

+ 1 - 1
compiler/sparc/cpuinfo.pas

@@ -65,7 +65,7 @@ type
 Const
   { Is there support for dealing with multiple microcontrollers available }
   { for this platform? }
-  ControllerSupport = true;
+  ControllerSupport = false;
 
   { We know that there are fields after sramsize
     but we don't care about this warning }

+ 1 - 1
compiler/sparc64/cpuinfo.pas

@@ -63,7 +63,7 @@ type
 Const
   { Is there support for dealing with multiple microcontrollers available }
   { for this platform? }
-  ControllerSupport = true;
+  ControllerSupport = false;
 
   { We know that there are fields after sramsize
     but we don't care about this warning }

+ 6 - 0
compiler/symtype.pas

@@ -206,6 +206,8 @@ interface
          procedure putderef(const d:tderef);
          procedure putpropaccesslist(p:tpropaccesslist);
          procedure putasmsymbol(s:tasmsymbol);
+       protected
+         procedure RaiseAssertion(Code: Longint); override;
        end;
 
 {$ifdef MEMDEBUG}
@@ -887,6 +889,10 @@ implementation
          Message(unit_f_ppu_read_error);
       end;
 
+    procedure tcompilerppufile.RaiseAssertion(Code: Longint);
+      begin
+        InternalError(Code);
+      end;
 
     procedure tcompilerppufile.getguid(var g: tguid);
       begin

+ 2 - 0
compiler/systems/i_wii.pas

@@ -21,6 +21,8 @@
 { This unit implements support information structures for the Nintendo Wii. }
 unit i_wii;
 
+{$i fpcdefs.inc}
+
   interface
 
     uses

File diff suppressed because it is too large
+ 1056 - 90
compiler/utils/ppuutils/ppudump.pp


+ 1 - 1
compiler/x86_64/cpuinfo.pas

@@ -79,7 +79,7 @@ Type
 Const
    { Is there support for dealing with multiple microcontrollers available }
    { for this platform? }
-   ControllerSupport = true;
+   ControllerSupport = false;
    { Size of native extended type }
    extended_size = 10;
    { target cpu string (used by compiler options) }

Some files were not shown because too many files changed in this diff