WEDNESDAY, JULY 8, 2026
avr
AVR: Add R18:SI = neg R18:SI to libgcc.
AVR libgcc gains a factored-out negation function for R18:SI and a conditional call macro.
The AVR version of libgcc now includes a new function, _negsi2_r18, which factors out common code for negating the R18:SI register. Additionally, a new macro, .call_if_neg, is introduced to conditionally call a label based on a register’s value. These changes improve code reuse and convenience in libgcc’s AVR implementation.
In Details
This change factors out the negation of the R18:SI register in libgcc for the AVR target, creating a reusable function __negsi2_r18. It also introduces a .call_if_neg macro for conditional branching. These are used to simplify existing functions like __divmodsi4 and __divsa3 within lib1funcs.S and lib1funcs-fixed.S.
For Context
- libgcc
- A GCC helper library containing runtime support routines for arithmetic, exceptions, and other features not directly supported by the target architecture's instruction set. It's linked into user programs.
- AVR
- A family of microcontrollers developed by Atmel (now Microchip Technology). GCC has support for compiling C and C++ code for AVR targets.
- R18:SI
- Refers to a specific register pair (R18 and its associated register) on the AVR architecture, likely used to hold a 16-bit signed integer (SI).
- neg
- In this context, 'neg' refers to the negation operation, typically performing a two's complement negation on a signed integer.