Sfoglia il codice sorgente

* Added support for 64-bit min/max intrinsics

J. Gareth "Curious Kit" Moreton 1 anno fa
parent
commit
81b7b80749

+ 8 - 4
compiler/aarch64/ncpuinl.pas

@@ -384,7 +384,7 @@ implementation
             if needs_check_for_fpu_exceptions then
               Include(current_procinfo.flags,pi_do_call);
           end
-        else if is_32bitint(resultdef) then
+        else if is_32bitint(resultdef) or is_64bitint(resultdef) then
           begin
             expectloc:=LOC_REGISTER;
             Result:=nil;
@@ -438,7 +438,7 @@ implementation
 
              cg.maybe_check_for_fpu_exception(current_asmdata.CurrAsmList);
            end
-         else if is_32bitint(resultdef) then
+         else if is_32bitint(resultdef) or is_64bitint(resultdef) then
            begin
              { no memory operand is allowed }
              for i:=low(paraarray) to high(paraarray) do
@@ -456,11 +456,15 @@ implementation
 
              case inlinenumber of
                in_min_dword,
-               in_min_longint:
+               in_min_longint,
+               in_min_qword,
+               in_min_int64:
                 current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_cond(A_CSEL,
                   location.register,paraarray[1].location.register,paraarray[2].location.register,C_LT));
                in_max_dword,
-               in_max_longint:
+               in_max_longint,
+               in_max_qword,
+               in_max_int64:
                 current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_cond(A_CSEL,
                   location.register,paraarray[1].location.register,paraarray[2].location.register,C_GT));
                else

+ 4 - 0
compiler/compinnr.pas

@@ -172,6 +172,10 @@ type
      in_min_longint      = 142,
      in_max_dword        = 143,
      in_max_longint      = 144,
+     in_min_qword        = 145,
+     in_min_int64        = 146,
+     in_max_qword        = 147,
+     in_max_int64        = 148,
 
 { MMX functions }
 { these contants are used by the mmx unit }

+ 9 - 0
compiler/defutil.pas

@@ -283,6 +283,9 @@ interface
     {# Returns true, if def is a 64 bit signed integer type }
     function is_s64bitint(def : tdef) : boolean;
 
+    {# Returns true, if def is a qword type }
+    function is_u64bitint(def : tdef) : boolean;
+
     {# Returns true, if def is a 64 bit ordinal type }
     function is_64bit(def : tdef) : boolean;
 
@@ -1149,6 +1152,12 @@ implementation
       end;
 
 
+    function is_u64bitint(def: tdef): boolean;
+      begin
+        is_u64bitint:=(def.typ=orddef) and (torddef(def).ordtype=u64bit)
+      end;
+
+
     { true, if def is a 64 bit type }
     function is_64bit(def : tdef) : boolean;
       begin

+ 4 - 0
compiler/ncginl.pas

@@ -221,6 +221,10 @@ implementation
             in_max_dword,
             in_min_longint,
             in_min_dword,
+            in_min_int64,
+            in_min_qword,
+            in_max_int64,
+            in_max_qword,
             in_min_single,
             in_min_double,
             in_max_single,

+ 11 - 3
compiler/nflw.pas

@@ -1632,7 +1632,7 @@ implementation
 {$endif defined(xtensa)}
 {$if defined(aarch64)}
           (is_single(tassignmentnode(thenstmnt).left.resultdef) or is_double(tassignmentnode(thenstmnt).left.resultdef) or
-           is_32bitint(tassignmentnode(thenstmnt).right.resultdef)) and
+           is_32bitint(tassignmentnode(thenstmnt).left.resultdef) or is_64bitint(tassignmentnode(thenstmnt).left.resultdef)) and
 {$endif defined(aarch64)}
           (
           { the right size of the assignment in the then clause must either }
@@ -1679,7 +1679,11 @@ implementation
                 else if is_u32bitint(paratype) then
                   in_nr:=in_max_dword
                 else if is_s32bitint(paratype) then
-                  in_nr:=in_max_longint;
+                  in_nr:=in_max_longint
+                else if is_u64bitint(paratype) then
+                  in_nr:=in_max_qword
+                else if is_s64bitint(paratype) then
+                  in_nr:=in_max_int64;
               end
             else
               begin
@@ -1690,7 +1694,11 @@ implementation
                 else if is_u32bitint(paratype) then
                   in_nr:=in_min_dword
                 else if is_s32bitint(paratype) then
-                  in_nr:=in_min_longint;
+                  in_nr:=in_min_longint
+                else if is_u64bitint(paratype) then
+                  in_nr:=in_min_qword
+                else if is_s64bitint(paratype) then
+                  in_nr:=in_min_int64;
               end;
             { for inline nodes, the first parameter is the last one in the linked list
 

+ 8 - 0
compiler/ninl.pas

@@ -3889,6 +3889,10 @@ implementation
               in_max_dword,
               in_min_longint,
               in_min_dword,
+              in_max_int64,
+              in_max_qword,
+              in_min_int64,
+              in_min_qword,
               in_max_single,
               in_max_double,
               in_min_single,
@@ -4345,6 +4349,10 @@ implementation
          in_max_dword,
          in_min_longint,
          in_min_dword,
+         in_max_int64,
+         in_max_qword,
+         in_min_int64,
+         in_min_qword,
          in_min_single,
          in_min_double,
          in_max_single,

+ 2 - 1
compiler/optcse.pas

@@ -76,7 +76,8 @@ unit optcse;
                with more than one parameter }
              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
+             in_max_longint,in_max_dword,in_min_longint,in_min_dword,
+             in_max_int64,in_max_qword,in_min_int64,in_min_qword
              ])
           ) or
           ((n.nodetype=callparan) and not(assigned(tcallparanode(n).right))) or