فهرست منبع

* fixed handling of unaligned in assignments

git-svn-id: trunk@9302 -
Jonas Maebe 17 سال پیش
والد
کامیت
3b4eba9f86
3فایلهای تغییر یافته به همراه14 افزوده شده و 9 حذف شده
  1. 5 1
      compiler/ncgld.pas
  2. 1 0
      compiler/options.pas
  3. 8 8
      compiler/ppu.pas

+ 5 - 1
compiler/ncgld.pas

@@ -693,7 +693,11 @@ implementation
                         len:=left.resultdef.size;
                         len:=left.resultdef.size;
                         if (right.location.reference.offset mod sizeof(aint)<>0) or
                         if (right.location.reference.offset mod sizeof(aint)<>0) or
                           (left.location.reference.offset mod sizeof(aint)<>0) or
                           (left.location.reference.offset mod sizeof(aint)<>0) or
-                          (right.resultdef.alignment<sizeof(aint)) then
+                          (right.resultdef.alignment<sizeof(aint)) or
+                          ((right.location.reference.alignment<>0) and
+                           (right.location.reference.alignment<sizeof(aint))) or
+                          ((left.location.reference.alignment<>0) and
+                           (left.location.reference.alignment<sizeof(aint))) then
                           cg.g_concatcopy_unaligned(current_asmdata.CurrAsmList,right.location.reference,left.location.reference,len)
                           cg.g_concatcopy_unaligned(current_asmdata.CurrAsmList,right.location.reference,left.location.reference,len)
                         else
                         else
                           cg.g_concatcopy(current_asmdata.CurrAsmList,right.location.reference,left.location.reference,len);
                           cg.g_concatcopy(current_asmdata.CurrAsmList,right.location.reference,left.location.reference,len);

+ 1 - 0
compiler/options.pas

@@ -2144,6 +2144,7 @@ begin
 
 
 {$ifdef SUPPORT_UNALIGNED}
 {$ifdef SUPPORT_UNALIGNED}
   def_system_macro('FPC_SUPPORTS_UNALIGNED');
   def_system_macro('FPC_SUPPORTS_UNALIGNED');
+  def_system_macro('FPC_UNALIGNED_FIXED');
 {$endif SUPPORT_UNALIGNED}
 {$endif SUPPORT_UNALIGNED}
 {$ifdef powerpc64}
 {$ifdef powerpc64}
   def_system_macro('FPC_HAS_LWSYNC');
   def_system_macro('FPC_HAS_LWSYNC');

+ 8 - 8
compiler/ppu.pas

@@ -588,14 +588,14 @@ begin
      result:=0;
      result:=0;
      exit;
      exit;
    end;
    end;
-{$ifdef FPC_SUPPORTS_UNALIGNED}
+{$ifdef FPC_UNALIGNED_FIXED}
   if bufsize-bufidx>=sizeof(word) then
   if bufsize-bufidx>=sizeof(word) then
     begin
     begin
-      result:=Unaligned(pword(@buf[bufidx])^);
+      result:=Unaligned(pword(@buf[bufidx]))^;
       inc(bufidx,sizeof(word));
       inc(bufidx,sizeof(word));
     end
     end
   else
   else
-{$endif FPC_SUPPORTS_UNALIGNED}
+{$endif FPC_UNALIGNED_FIXED}
     readdata(result,sizeof(word));
     readdata(result,sizeof(word));
   if change_endian then
   if change_endian then
    result:=swapendian(result);
    result:=swapendian(result);
@@ -611,14 +611,14 @@ begin
      getlongint:=0;
      getlongint:=0;
      exit;
      exit;
    end;
    end;
-{$ifdef FPC_SUPPORTS_UNALIGNED}
+{$ifdef FPC_UNALIGNED_FIXED}
   if bufsize-bufidx>=sizeof(longint) then
   if bufsize-bufidx>=sizeof(longint) then
     begin
     begin
-      result:=Unaligned(plongint(@buf[bufidx])^);
+      result:=Unaligned(plongint(@buf[bufidx]))^;
       inc(bufidx,sizeof(longint));
       inc(bufidx,sizeof(longint));
     end
     end
   else
   else
-{$endif FPC_SUPPORTS_UNALIGNED}
+{$endif FPC_UNALIGNED_FIXED}
     readdata(result,sizeof(longint));
     readdata(result,sizeof(longint));
   if change_endian then
   if change_endian then
    result:=swapendian(result);
    result:=swapendian(result);
@@ -634,14 +634,14 @@ begin
      result:=0;
      result:=0;
      exit;
      exit;
    end;
    end;
-{$ifdef FPC_SUPPORTS_UNALIGNED}
+{$ifdef FPC_UNALIGNED_FIXED}
   if bufsize-bufidx>=sizeof(int64) then
   if bufsize-bufidx>=sizeof(int64) then
     begin
     begin
       result:=Unaligned(pint64(@buf[bufidx])^);
       result:=Unaligned(pint64(@buf[bufidx])^);
       inc(bufidx,sizeof(int64));
       inc(bufidx,sizeof(int64));
     end
     end
   else
   else
-{$endif FPC_SUPPORTS_UNALIGNED}
+{$endif FPC_UNALIGNED_FIXED}
     readdata(result,sizeof(int64));
     readdata(result,sizeof(int64));
   if change_endian then
   if change_endian then
    result:=swapendian(result);
    result:=swapendian(result);