Ada: Uniform expansion for conditional expressions
Optimizes expansion of conditional expressions (if, case) in Ada, reducing temporaries and avoiding indirections.
This commit refactors how Ada conditional expressions, specifically N_Case_Expression and N_If_Expression, are expanded. It introduces a single, uniform criterion for deciding when to create temporary variables, aiming to eliminate large temporaries for N_If_Expression and N_Expression_With_Actions and avoid indirection for N_Case_Expression. The layout machinery is also improved to compute array type sizes more accurately, addressing issues with Component_Size clauses.
In Details
The GCC Ada front-end's expression expansion logic in gcc/ada/exp_ch4.adb and gcc/ada/layout.adb is modified for N_Case_Expression, N_If_Expression, and N_Expression_With_Actions. The change unifies the criteria for temporary variable creation during expansion, reducing overhead. Additionally, layout.adb is enhanced to compute sizes for 1-dimensional array types more robustly, impacting how Component_Size clauses are analyzed in sem_ch13.adb.
- N_Case_Expression
- An internal representation node in the GCC Ada front-end for a case expression.
- N_If_Expression
- An internal representation node in the GCC Ada front-end for an if expression.
- Temporary variable
- A short-lived variable used by the compiler to hold intermediate results during expression evaluation or code generation.
- Component_Size
- An Ada clause used to specify the size of array components, impacting memory layout.