[Ada] Improve compile-time evaluation of value ranges
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 21 Apr 2020 20:28:00 +0000 (22:28 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 18 Jun 2020 09:08:25 +0000 (05:08 -0400)
commit12be130c3f1d09b4b9923de6b4c1c66d61c9497c
tree49357cc48430c837a2ef5777430c73ee9a2b8830
parent78689aa295f9b0e54807462d13d3125a5a83c64b
[Ada] Improve compile-time evaluation of value ranges

2020-06-18  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* checks.adb (Compute_Range_For_Arithmetic_Op): New procedure to
compute a range for an arithmetical operation extracted from...
(Minimize_Eliminate_Overflows): ...here.  Call it.
(Determine_Range_Cache_O): New cache for Original_Node nodes.
(Determine_Range): Call Compute_Range_For_Arithmetic_Op for all
arithmetic expressions. Use Attribute_Id in lieu of Attribute_Name
for attributes. Add handling for Range_Length alongside Length.
Add specific handling for Alignment, Bit, First_Bit, Last_Bit,
Max_Size_In_Storage_Elements, Position, Bit_Position,
Component_Size, Object_Size, Size, Value_Size, Descriptor_Size.
(Enable_Overflow_Check): Omit the check for Abs and Minus if the
operand cannot be the largest negative number.
(Selected_Length_Checks): Use Pos for Number_Dimensions.
* exp_attr.adb (Expand_N_Attribute_Reference): Move compile-time
handling of Bit_Position, Descriptor_Size, First_Bit, Last_Bit
and Position to...
* sem_attr.adb (Eval_Attribute): ...here.  Move up Alignment for
objects and use Compile_Time_Known_Attribute in this case too.
gcc/ada/checks.adb
gcc/ada/exp_attr.adb
gcc/ada/sem_attr.adb