This patch adds support for checked arithmetic builtins, including:
__builtin_add_overflow and __builtin_{s|u}add{|l|ll}_overflow;
__builtin_sub_overflow and __builtin_{s|u}sub{|l|ll}_overflow;
__builtin_mul_overflow and __builtin_{s|u}mul{|l|ll}_overflow.
This patch adds a new operation cir.checked_arith to represent these builtins. Unlike other CIR operations, this new operation has two result values. One for the possibly truncated result, and the other for a boolean flag that indicates whether the operation has overflowed.
CIRGen and LLVMIR lowering support for the new operation is both included in this PR.
This patch adds support for checked arithmetic builtins, including:
__builtin_add_overflow
and__builtin_{s|u}add{|l|ll}_overflow
;__builtin_sub_overflow
and__builtin_{s|u}sub{|l|ll}_overflow
;__builtin_mul_overflow
and__builtin_{s|u}mul{|l|ll}_overflow
.This patch adds a new operation
cir.checked_arith
to represent these builtins. Unlike other CIR operations, this new operation has two result values. One for the possibly truncated result, and the other for a boolean flag that indicates whether the operation has overflowed.CIRGen and LLVMIR lowering support for the new operation is both included in this PR.