浏览代码

+ abs(long/int64): overflow checking for xtensa implemented

florian 1 年之前
父节点
当前提交
a90691435b
共有 1 个文件被更改,包括 17 次插入0 次删除
  1. 17 0
      compiler/xtensa/ncpuinl.pas

+ 17 - 0
compiler/xtensa/ncpuinl.pas

@@ -58,13 +58,30 @@ unit ncpuinl;
       cpubase;
       cpubase;
 
 
     procedure tcpuinlinenode.second_abs_long;
     procedure tcpuinlinenode.second_abs_long;
+      var
+       hl: TAsmLabel;
       begin
       begin
+        if is_64bitint(resultdef) then
+          begin
+            inherited second_abs_long;
+            exit;
+          end;
+
         secondpass(left);
         secondpass(left);
         hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
         hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
 
 
         location:=left.location;
         location:=left.location;
         location.register:=hlcg.getintregister(current_asmdata.CurrAsmList,left.resultdef);
         location.register:=hlcg.getintregister(current_asmdata.CurrAsmList,left.resultdef);
 
 
+        if cs_check_overflow in current_settings.localswitches then
+          begin
+            current_asmdata.getjumplabel(hl);
+
+            hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,resultdef,OC_NE,$80000000,left.location.register,hl);
+            hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_overflow',[],nil).resetiftemp;
+            hlcg.a_label(current_asmdata.CurrAsmList,hl);
+          end;
+
         current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_ABS,location.register,left.location.register));
         current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_ABS,location.register,left.location.register));
       end;
       end;