Parcourir la source

+ min/max intrinsics for internal use by the compiler

git-svn-id: trunk@47692 -
florian il y a 4 ans
Parent
commit
6e4997265c
4 fichiers modifiés avec 71 ajouts et 1 suppressions
  1. 8 0
      compiler/compinnr.pas
  2. 16 0
      compiler/ncginl.pas
  3. 43 0
      compiler/ninl.pas
  4. 4 1
      compiler/optcse.pas

+ 8 - 0
compiler/compinnr.pas

@@ -153,6 +153,14 @@ type
      in_fma_double       = 134,
      in_fma_extended     = 135,
      in_fma_float128     = 136,
+     in_max_single       = 137,
+     in_max_double       = 138,
+     in_min_single       = 139,
+     in_min_double       = 140,
+     in_min_dword        = 141,
+     in_min_longint      = 142,
+     in_max_dword        = 143,
+     in_max_longint      = 144,
 
 { MMX functions }
 { these contants are used by the mmx unit }

+ 16 - 0
compiler/ncginl.pas

@@ -67,6 +67,7 @@ interface
           procedure second_fma; virtual;
           procedure second_frac_real; virtual;
           procedure second_high; virtual;
+          procedure second_minmax; virtual;
        protected
           function  second_incdec_tempregdef: tdef;virtual;
        end;
@@ -216,6 +217,15 @@ implementation
             in_fma_extended,
             in_fma_float128:
                second_fma;
+            in_max_longint,
+            in_max_dword,
+            in_min_longint,
+            in_min_dword,
+            in_min_single,
+            in_min_double,
+            in_max_single,
+            in_max_double:
+               second_minmax;
             in_and_assign_x_y,
             in_or_assign_x_y,
             in_xor_assign_x_y,
@@ -975,6 +985,12 @@ implementation
         internalerror(2014032701);
       end;
 
+
+    procedure tcginlinenode.second_minmax;
+      begin
+        internalerror(2020120501);
+      end;
+
 begin
    cinlinenode:=tcginlinenode;
 end.

+ 43 - 0
compiler/ninl.pas

@@ -98,6 +98,7 @@ interface
           function first_seg: tnode; virtual;
           function first_sar: tnode; virtual;
           function first_fma : tnode; virtual;
+          function first_minmax: tnode; virtual;
 {$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
           function first_ShiftRot_assign_64bitint: tnode; virtual;
 {$endif not cpu64bitalu and not cpuhighleveltarget}
@@ -3758,6 +3759,19 @@ implementation
                   set_varstate(tcallparanode(tcallparanode(tcallparanode(left).right).right).left,vs_read,[vsf_must_be_valid]);
                   resultdef:=tcallparanode(left).left.resultdef;
                 end;
+              in_max_longint,
+              in_max_dword,
+              in_min_longint,
+              in_min_dword,
+              in_max_single,
+              in_max_double,
+              in_min_single,
+              in_min_double:
+                begin
+                  set_varstate(tcallparanode(left).left,vs_read,[vsf_must_be_valid]);
+                  set_varstate(tcallparanode(tcallparanode(left).right).left,vs_read,[vsf_must_be_valid]);
+                  resultdef:=tcallparanode(left).left.resultdef;
+                end;
               in_delete_x_y_z:
                 begin
                   result:=handle_delete;
@@ -4190,6 +4204,15 @@ implementation
          in_fma_extended,
          in_fma_float128:
            result:=first_fma;
+         in_max_longint,
+         in_max_dword,
+         in_min_longint,
+         in_min_dword,
+         in_min_single,
+         in_min_double,
+         in_max_single,
+         in_max_double:
+           result:=first_minmax;
          else
            result:=first_cpu;
           end;
@@ -5481,6 +5504,26 @@ implementation
        end;
 
 
+     function tinlinenode.first_minmax: tnode;
+       begin
+         CGMessage1(cg_e_function_not_support_by_selected_instruction_set,'MIN/MAX');
+         result:=nil;
+       end;
+
+//
+//||||||| .merge-left.r31134
+//
+//{$ifdef ARM}
+//              {$i armtype.inc}
+//{$endif ARM}
+//=======
+//
+//{$ifdef x86}
+//              {$i x86type.inc}
+//{$endif x86}
+//{$ifdef ARM}
+//              {$i armtype.inc}
+//{$endif ARM}
 {$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
      function tinlinenode.first_ShiftRot_assign_64bitint: tnode;
        var

+ 4 - 1
compiler/optcse.pas

@@ -70,7 +70,10 @@ unit optcse;
              in_abs_real,in_exp_real,in_ln_real,in_pi_real,in_popcnt_x,in_arctan_real,in_round_real,in_trunc_real,
              { cse on fma will still not work because it would require proper handling of call nodes
                with more than one parameter }
-             in_fma_single,in_fma_double,in_fma_extended,in_fma_float128])
+             in_fma_single,in_fma_double,in_fma_extended,in_fma_float128,
+             in_min_single,in_min_double,in_max_single,in_max_double,
+             in_max_longint,in_max_dword,in_min_longint,in_min_dword
+             ])
           ) or
           ((n.nodetype=callparan) and not(assigned(tcallparanode(n).right))) or
           ((n.nodetype=loadn) and