Fixes too-short instruction lengths in AVR fractional output function.
GCC's AVR backend now correctly calculates instruction lengths in `avr_out_fract`, resolving a bug where sequences were too short.
This commit fixes a bug in the avr_out_fract function within GCC’s AVR backend where the calculated instruction lengths for fractional number output were too short. The function, located in config/avr/avr.cc, was incorrectly invoking avr_asm_len with insufficient sequence lengths, potentially leading to malformed assembly or incorrect code generation. Correcting these lengths ensures that the AVR compiler generates accurate and properly aligned assembly code for fractional operations, improving the reliability of embedded applications that rely on such arithmetic.
In Details
The avr_out_fract function in avr.cc is responsible for emitting assembly code sequences for fractional number operations on the AVR architecture. The bug involved incorrect parameters passed to avr_asm_len, which determines the length of emitted instruction sequences. Providing too small a sequence length can lead to truncated or malformed instruction sequences, impacting the correctness of the generated assembly. This fix directly addresses the precision issues in length calculations for these specific fractional operations, ensuring the generated .s file correctly represents the in…
For Context
When a computer program deals with numbers that have decimal points, it's performing \"fractional arithmetic.\" For microcontrollers like the AVR, the GCC compiler has a special part that takes these fractional number operations and translates them into very specific instructions the AVR chip can understand. This update fixes a subtle bug in this translation process where the compiler was miscalculating the length of these instructions. This could lead to the generated code being slightly off, potentially causing incorrect calculations or even program crashes. The fix ensures that the compiler now produces the correct and full instruction sequences for fractional numbers, making programs for AVR chips more reliable.