Prechádzať zdrojové kódy

* Handle "SarInt64" always as internal procedure, introduced virtual method tinlinenode.first_sar that by default converts it into call to "fpc_sarint64" unless target CPU is 64-bit. This provides a point to insert target-specific optimizations.

git-svn-id: trunk@25876 -
sergei 11 rokov pred
rodič
commit
9ad98a2c4d
3 zmenil súbory, kde vykonal 23 pridanie a 9 odobranie
  1. 21 3
      compiler/ninl.pas
  2. 1 3
      rtl/inc/systemh.inc
  3. 1 3
      rtl/java/jsystemh.inc

+ 21 - 3
compiler/ninl.pas

@@ -82,7 +82,7 @@ interface
           { override these for Seg() support }
           function typecheck_seg: tnode; virtual;
           function first_seg: tnode; virtual;
-
+          function first_sar: tnode; virtual;
         private
           function handle_str: tnode;
           function handle_reset_rewrite_typed: tnode;
@@ -3604,11 +3604,12 @@ implementation
          in_rol_x_y,
          in_ror_x,
          in_ror_x_y,
-         in_sar_x,
-         in_sar_x_y,
          in_bsf_x,
          in_bsr_x:
            expectloc:=LOC_REGISTER;
+         in_sar_x,
+         in_sar_x_y:
+           result:=first_sar;
          in_popcnt_x:
            result:=first_popcnt;
          in_new_x:
@@ -4044,6 +4045,23 @@ implementation
        end;
 
 
+     function tinlinenode.first_sar: tnode;
+       begin
+         result:=nil;
+         expectloc:=LOC_REGISTER;
+{$ifndef cpu64bitalu}
+         if is_64bitint(resultdef) then
+           begin
+             if (inlinenumber=in_sar_x) then
+               left:=ccallparanode.create(cordconstnode.create(1,u8inttype,false),
+                 ccallparanode.create(left,nil));
+             result:=ccallnode.createintern('fpc_sarint64',left);
+             left:=nil;
+           end;
+{$endif cpu64bitalu}
+       end;
+
+
      function tinlinenode.handle_box: tnode;
        begin
          result:=nil;

+ 1 - 3
rtl/inc/systemh.inc

@@ -938,12 +938,10 @@ function SarLongint(Const AValue : Longint;Shift : Byte): Longint;[internproc:fp
 function SarLongint(Const AValue : Longint;const Shift : Byte = 1): Longint;
 {$endif FPC_HAS_INTERNAL_SAR_DWORD}
 
-{$ifdef FPC_HAS_INTERNAL_SAR_QWORD}
 function SarInt64(Const AValue : Int64): Int64;[internproc:fpc_in_sar_x];
 function SarInt64(Const AValue : Int64;Shift : Byte): Int64;[internproc:fpc_in_sar_x_y];
-{$else FPC_HAS_INTERNAL_SAR_QWORD}
+{$ifndef FPC_HAS_INTERNAL_SAR_QWORD}
 function fpc_SarInt64(Const AValue : Int64;const Shift : Byte): Int64;compilerproc;
-function SarInt64(Const AValue : Int64;const Shift : Byte = 1): Int64; [external name 'FPC_SARINT64'];
 {$endif FPC_HAS_INTERNAL_SAR_QWORD}
 
 {$ifdef FPC_HAS_INTERNAL_BSF}

+ 1 - 3
rtl/java/jsystemh.inc

@@ -334,12 +334,10 @@ function SarLongint(Const AValue : Longint;Shift : Byte): Longint;[internproc:fp
 function SarLongint(Const AValue : Longint;const Shift : Byte = 1): Longint;
 {$endif FPC_HAS_INTERNAL_SAR_DWORD}
 
-{$ifdef FPC_HAS_INTERNAL_SAR_QWORD}
 function SarInt64(Const AValue : Int64): Int64;[internproc:fpc_in_sar_x];
 function SarInt64(Const AValue : Int64;Shift : Byte): Int64;[internproc:fpc_in_sar_x_y];
-{$else FPC_HAS_INTERNAL_SAR_QWORD}
+{$ifndef FPC_HAS_INTERNAL_SAR_QWORD}
 function fpc_SarInt64(Const AValue : Int64;const Shift : Byte): Int64;compilerproc;
-function SarInt64(Const AValue : Int64;const Shift : Byte = 1): Int64; [external name 'fpc_sarint64'];
 {$endif FPC_HAS_INTERNAL_SAR_QWORD}
 
 {$ifdef FPC_HAS_INTERNAL_BSF}