Răsfoiți Sursa

+ define cpunodefaultint

git-svn-id: trunk@10415 -
florian 17 ani în urmă
părinte
comite
5826b9bdad
2 a modificat fișierele cu 34 adăugiri și 1 ștergeri
  1. 1 0
      compiler/fpcdefs.inc
  2. 33 1
      compiler/nadd.pas

+ 1 - 0
compiler/fpcdefs.inc

@@ -113,6 +113,7 @@
   {$define cpu16bit}
   {$define cpuflags}
   {$define cpunofpu}
+  {$define cpunodefaultint}
 {$endif avr}
 
 {$IFDEF MACOS}

+ 33 - 1
compiler/nadd.pas

@@ -1,7 +1,7 @@
 {
     Copyright (c) 1998-2002 by Florian Klaempfl
 
-    Type checking and register allocation for add nodes
+    Type checking and simplification for add nodes
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -1206,8 +1206,40 @@ implementation
                     is_signed(rd) or
                     (nodetype=subn) then
                    begin
+{$ifdef cpunodefaultint}
+                      { for small cpus we use the smallest common type }
+                      llow:=torddef(rd).low;
+                      if llow<torddef(ld).low then
+                        llow:=torddef(ld).low;
+                      lhigh:=torddef(rd).high;
+                      if lhigh<torddef(ld).high then
+                        lhigh:=torddef(ld).high;
+                      case range_to_basetype(llow,lhigh) of
+                        s8bit:
+                          nd:=s8inttype;
+                        u8bit:
+                          nd:=u8inttype;
+                        s16bit:
+                          nd:=s8inttype;
+                        u16bit:
+                          nd:=u8inttype;
+                        s32bit:
+                          nd:=s8inttype;
+                        u32bit:
+                          nd:=u8inttype;
+                        s64bit:
+                          nd:=s8inttype;
+                        u64bit:
+                          nd:=u8inttype;
+                        else
+                          internalerror(200802291);
+                      end;
+                     inserttypeconv(right,nd);
+                     inserttypeconv(left,nd);
+{$else cpunodefaultint}
                      inserttypeconv(right,sinttype);
                      inserttypeconv(left,sinttype);
+{$endif cpunodefaultint}
                    end
                  else
                    begin