arc: Check If The Addend Fits When Referencing Small Data Memory
The compiler now checks if the offset fits when accessing small data memory on ARC, preventing potential linker errors.
When referencing small data memory on the ARC architecture, the compiler will now check if the offset used fits within the allowed range. This check prevents potential linker errors that could occur when using large offsets. Although such errors are unlikely in practice, the check ensures consistency with other compilers and allows certain tests to pass.
In Details
This commit modifies config/arc/arc.cc to check the offset size in legitimate_small_data_address_p. This prevents linker errors when referencing small data with large offsets. The change was made for consistency with other compilers. It affects the code generation for ARC and potentially impacts ABI compatibility if large offsets were previously allowed.
For Context
Microcontrollers often have dedicated regions of memory for storing small pieces of data, which can be accessed more quickly. This commit fixes an issue in the ARC compiler where it wasn't properly checking the size of the offset used to access this small data memory. By adding this check, the compiler prevents potential errors during the linking stage, where different parts of the compiled program are combined. This ensures that the program can correctly access the small data.