Browse Source

* first fixes to compile the x86-64 system unit

florian 21 years ago
parent
commit
6d3d97e845
3 changed files with 56 additions and 12 deletions
  1. 18 1
      compiler/symdef.pas
  2. 11 1
      compiler/x86/cgx86.pas
  3. 27 10
      compiler/x86_64/cgcpu.pas

+ 18 - 1
compiler/symdef.pas

@@ -2831,10 +2831,24 @@ implementation
            cachedsize := elesize;
            if (cachedsize>0) and
                (
+{$ifdef cpu64bit}
+{$ifdef VER1_0}
+                { 1.0.x can't handle this and while bootstrapping with 1.0.x we can forget about it }
+                false
+{$else}
+                (TConstExprInt(highrange)-TConstExprInt(lowrange) > $7fffffffffffffff) or
+
+                { () are needed around cachedsize-1 to avoid a possible
+                  integer overflow for cachedsize=1 !! PM }
+                (($7fffffffffffffff div cachedsize + (cachedsize -1)) < (int64(highrange) - int64(lowrange)))
+{$endif VER1_0}
+{$else cpu64bit}
                 (TConstExprInt(highrange)-TConstExprInt(lowrange) > $7fffffff) or
+
                 { () are needed around cachedsize-1 to avoid a possible
                   integer overflow for cachedsize=1 !! PM }
                 (($7fffffff div cachedsize + (cachedsize -1)) < (int64(highrange) - int64(lowrange)))
+{$endif cpu64bit}
                ) Then
              Message(sym_e_segment_too_large);
          end;
@@ -6138,7 +6152,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.194  2003-12-21 19:42:43  florian
+  Revision 1.195  2003-12-24 01:47:22  florian
+    * first fixes to compile the x86-64 system unit
+
+  Revision 1.194  2003/12/21 19:42:43  florian
     * fixed ppc inlining stuff
     * fixed wrong unit writing
     + added some sse stuff

+ 11 - 1
compiler/x86/cgx86.pas

@@ -147,10 +147,17 @@ unit cgx86;
       end;
 
    const
+{$ifdef x86_64}
+      TCGSize2OpSize: Array[tcgsize] of topsize =
+        (S_NO,S_B,S_W,S_L,S_D,S_B,S_W,S_L,S_D,
+         S_FS,S_FL,S_FX,S_IQ,S_FXX,
+         S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO);
+{$else x86_64}
       TCGSize2OpSize: Array[tcgsize] of topsize =
         (S_NO,S_B,S_W,S_L,S_L,S_B,S_W,S_L,S_L,
          S_FS,S_FL,S_FX,S_IQ,S_FXX,
          S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO,S_NO);
+{$endif x86_64}
 
 
   implementation
@@ -1901,7 +1908,10 @@ unit cgx86;
 end.
 {
   $Log$
-  Revision 1.94  2003-12-24 00:10:03  florian
+  Revision 1.95  2003-12-24 01:47:23  florian
+    * first fixes to compile the x86-64 system unit
+
+  Revision 1.94  2003/12/24 00:10:03  florian
     - delete parameter in cg64 methods removed
 
   Revision 1.93  2003/12/21 19:42:43  florian

+ 27 - 10
compiler/x86_64/cgcpu.pas

@@ -49,15 +49,29 @@ unit cgcpu;
 
 
     class function tcgx86_64.reg_cgsize(const reg: tregister): tcgsize;
-      const
-        opsize_2_cgsize: array[topsize] of tcgsize = (OS_NO,
-          OS_8,OS_16,OS_32,OS_NO,OS_NO,OS_NO,OS_NO,OS_NO,OS_NO,
-          OS_32,OS_64,OS_64,
-          OS_F32,OS_F64,OS_F80,OS_F32,OS_F64,OS_NO,OS_NO,
-          OS_NO,OS_NO,OS_NO
-        );
-      begin
-        result := opsize_2_cgsize[reg2opsize(reg)];
+    const subreg2cgsize:array[Tsubregister] of Tcgsize =
+          (OS_NO,OS_8,OS_8,OS_16,OS_32,OS_64,OS_NO);
+
+    begin
+      case getregtype(reg) of
+        R_INTREGISTER :
+          reg_cgsize:=subreg2cgsize[getsubreg(reg)];
+        R_FPUREGISTER :
+          reg_cgsize:=OS_F80;
+        R_MMXREGISTER:
+          reg_cgsize:=OS_M64;
+        R_MMREGISTER:
+          reg_cgsize:=OS_M128;
+        R_SPECIALREGISTER :
+          case reg of
+            NR_CS,NR_DS,NR_ES,NR_SS,NR_FS,NR_GS:
+              reg_cgsize:=OS_16
+            else
+              reg_cgsize:=OS_32
+          end
+        else
+            internalerror(200303181);
+        end;
       end;
 
 
@@ -192,7 +206,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.6  2003-12-22 19:00:17  florian
+  Revision 1.7  2003-12-24 01:47:23  florian
+    * first fixes to compile the x86-64 system unit
+
+  Revision 1.6  2003/12/22 19:00:17  florian
     * fixed some x86-64 issues
 
   Revision 1.5  2003/09/25 13:13:32  florian