Browse Source

+ support for unaligned function

git-svn-id: trunk@3350 -
florian 19 years ago
parent
commit
9e00f894a9
7 changed files with 45 additions and 3 deletions
  1. 3 0
      compiler/cgutils.pas
  2. 1 0
      compiler/compinnr.inc
  3. 1 0
      compiler/fpcdefs.inc
  4. 9 0
      compiler/ncginl.pas
  5. 14 3
      compiler/ninl.pas
  6. 14 0
      compiler/pexpr.pas
  7. 3 0
      compiler/psystem.pas

+ 3 - 0
compiler/cgutils.pas

@@ -56,6 +56,9 @@ unit cgutils;
          { (An)+ and -(An)                      }
          direction : tdirection;
 {$endif m68k}
+{$ifdef SUPPORT_UNALIGNED}
+         alignment : byte;
+{$endif SUPPORT_UNALIGNED}
       end;
 
       tlocation = record

+ 1 - 0
compiler/compinnr.inc

@@ -62,6 +62,7 @@ const
    in_leave             = 51; {macpas}
    in_cycle             = 52; {macpas}
    in_slice_x           = 53;
+   in_unaligned_x       = 54;
 
 { Internal constant functions }
    in_const_sqr        = 100;

+ 1 - 0
compiler/fpcdefs.inc

@@ -94,3 +94,4 @@
 
 { Use the internal linker by default }
 { define INTERNALLINKER}
+{$define SUPPORT_UNALIGNED}

+ 9 - 0
compiler/ncginl.pas

@@ -150,6 +150,15 @@ implementation
               begin
                 second_assigned;
               end;
+{$ifdef SUPPORT_UNALIGNED}
+            in_unaligned_x:
+              begin
+                secondpass(tcallparanode(left).left);
+                location:=tcallparanode(left).left.location;
+                if location.loc in [LOC_CREFERENCE,LOC_REFERENCE] then
+                  location.reference.alignment:=1;
+              end;
+{$endif SUPPORT_UNALIGNED}
 {$ifdef SUPPORT_MMX}
             in_mmx_pcmpeqb..in_mmx_pcmpgtw:
               begin

+ 14 - 3
compiler/ninl.pas

@@ -2012,15 +2012,21 @@ implementation
                    end;
                 end;
 
- {$ifdef SUPPORT_MMX}
+{$ifdef SUPPORT_MMX}
               in_mmx_pcmpeqb..in_mmx_pcmpgtw:
                 begin
                 end;
- {$endif SUPPORT_MMX}
+{$endif SUPPORT_MMX}
               in_prefetch_var:
                 begin
                   resulttype:=voidtype;
                 end;
+{$ifdef SUPPORT_UNALIGNED}
+              in_unaligned_x:
+                begin
+                  resulttype:=left.resulttype;
+                end;
+{$endif SUPPORT_UNALIGNED}
               in_assert_x_y :
                 begin
                   resulttype:=voidtype;
@@ -2409,7 +2415,12 @@ implementation
            begin
              expectloc:=LOC_VOID;
            end;
-
+{$ifdef SUPPORT_UNALIGNED}
+         in_unaligned_x:
+           begin
+             expectloc:=left.expectloc;
+           end;
+{$endif SUPPORT_UNALIGNED}
           else
             internalerror(8);
           end;

+ 14 - 0
compiler/pexpr.pas

@@ -520,6 +520,20 @@ implementation
               statement_syssym:=p2;
             end;
 
+{$ifdef SUPPORT_UNALIGNED}
+          in_unaligned_x :
+            begin
+              err:=false;
+              consume(_LKLAMMER);
+              in_args:=true;
+              p1:=comp_expr(true);
+              p2:=ccallparanode.create(p1,nil);
+              p2:=geninlinenode(in_unaligned_x,false,p2);
+              consume(_RKLAMMER);
+              statement_syssym:=p2;
+            end;
+{$endif SUPPORT_UNALIGNED}
+
           in_assigned_x :
             begin
               err:=false;

+ 3 - 0
compiler/psystem.pas

@@ -90,6 +90,9 @@ implementation
         systemunit.insert(tsyssym.create('Length',in_length_x));
         systemunit.insert(tsyssym.create('New',in_new_x));
         systemunit.insert(tsyssym.create('Dispose',in_dispose_x));
+{$ifdef SUPPORT_UNALIGNED}
+        systemunit.insert(tsyssym.create('Unaligned',in_unaligned_x));
+{$endif SUPPORT_UNALIGNED}
       end;