Browse Source

* don't pack softfpu helper records and added dummy for proper alignment, generates much better code on CPUs like arm

git-svn-id: trunk@20398 -
florian 13 years ago
parent
commit
f0f64a573b
1 changed files with 50 additions and 21 deletions
  1. 50 21
      rtl/inc/softfpu.pp

+ 50 - 21
rtl/inc/softfpu.pp

@@ -129,24 +129,40 @@ TYPE
   sbits64 = int64;
 
 {$ifdef ENDIAN_LITTLE}
-  float64 = packed record
-    low: bits32;
-    high: bits32;
+  float64 = record
+    case byte of
+      1: (low,high : bits32);
+      // force the record to be aligned like a double
+      // else *_to_double will fail for cpus like sparc
+      // and avoid expensive unpacking/packing operations
+      2: (dummy : double);
   end;
 
-  int64rec = packed record
-    low: bits32;
-    high: bits32;
+  int64rec = record
+    case byte of
+      1: (low,high : bits32);
+      // force the record to be aligned like a double
+      // else *_to_double will fail for cpus like sparc
+      // and avoid expensive unpacking/packing operations
+      2: (dummy : int64);
   end;
 
-  floatx80 = packed record
-    low : qword;
-    high : word;
+  floatx80 = record
+    case byte of
+      1: (low : qword;high : word);
+      // force the record to be aligned like a double
+      // else *_to_double will fail for cpus like sparc
+      // and avoid expensive unpacking/packing operations
+      2: (dummy : extended);
   end;
 
-  float128 = packed record
-    low : qword;
-    high : qword;
+  float128 = record
+    case byte of
+      1: (low,high : qword);
+      // force the record to be aligned like a double
+      // else *_to_double will fail for cpus like sparc
+      // and avoid expensive unpacking/packing operations
+      2: (dummy : qword);
   end;
 {$else}
   float64 = record
@@ -157,18 +173,31 @@ TYPE
         2: (dummy : double);
   end;
 
-  int64rec = packed record
-    high,low : bits32;
-  end;
+  int64rec = record
+    case byte of
+      1: high,low : bits32;
+      // force the record to be aligned like a double
+      // else *_to_double will fail for cpus like sparc
+      // and avoid expensive unpacking/packing operations
+      2: (dummy : int64);
+end;
 
-  floatx80 = packed record
-    high : word;
-    low : qword;
+  floatx80 = record
+    case byte of
+      1: (high : word;low : qword);
+      // force the record to be aligned like a double
+      // else *_to_double will fail for cpus like sparc
+      // and avoid expensive unpacking/packing operations
+      2: (dummy : qword);
   end;
 
-  float128 = packed record
-    high : qword;
-    low : qword;
+  float128 = record
+    case byte of
+      1: (high : qword;low : qword);
+      // force the record to be aligned like a double
+      // else *_to_double will fail for cpus like sparc
+      // and avoid expensive unpacking/packing operations
+      2: (dummy : qword);
   end;
 {$endif}