Please add possibility to disable atomic routines codegen
For this add:
#pragma noatomics. This pragma should have source code file scope. If it used in the file with main function declaration additional assembler code for atomic operations support should not be generated.--noatomics. All source code files scope. Assembler code for atomic operations support should not be generatedWhen pragma or complier flag is used, sdcc compiler should check than user source code dont use atomics C-language features. Otherwise sdcc compiler should raise a warning "atomic operations support disabled".
Diff:
The option to disable atomics has also been mentioned in the original atomics issue https://sourceforge.net/p/sdcc/feature-requests/624/
The option
--norestartseqatomicshas been implemented in th eatomics branch, and can be tested by users.Currently it only affects the mcs51 and ds390 ports, and mostly disables atomics support for these two ports.
I did not call it
--noatomics, and did not make it disable all atomics support; it just disables the restartable sequence support routines for atomics; depending on the target architecture and how the user uses atomics, stuff might work or not; basically, one could just try to compile with--norestartseqatomics, and the atomics will either work, or there will be a diagnostic from the linker.P.S.: E.g. without restartable sequence support routines mcs51 and ds390 loose virtually all atomics support except
volatile sig_atomic_t, but AFAIK all other targets can still doatomic_flagand once we have support for more atomic types and improve atomics support, there will be even more differences (e.g. mcs51 hardware could handle anatomic_flagin__idatawithout the restartable sequence support routines, but not in__xdata).Last edit: Philipp Klaus Krause 5 days ago
Ok, i built sdcc from atomics branch and make smoke tests for mcs51.
sdcc --version
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/r4k/r5k/r6k/sm83/tlcs90/ez80/z80n/r800/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502/mos65c02/f8/f8l TD- 4.5.24 #16459 (Linux)
published under GNU General Public License (GPL)
Wow At first look its worked.
Details:
First test is try to build main.c with content
void main(void) {}If no --norestartseqatomics compiler flag the size of firmware is
Name Start End Size Max
ROM/EPROM/FLASH 0x0000 0x00ae 175 65536
main.asm contains atomic related code like
; restartable atomic support routines
.ds 5
sdcc_atomic_exchange_rollback_start::
nop
nop
If add --norestartseqatomics compiler flag
Name Start End Size Max
ROM/EPROM/FLASH 0x0000 0x0068 105 65536
Second test on main.c
Without --norestartseqatomics
Other memory:
Name Start End Size Max
PAGED EXT. RAM 0 256
EXTERNAL RAM 0 65536
ROM/EPROM/FLASH 0x0000 0x00d6 215 65536
Try to compile with --norestartseqatomics is failed (and there is expected behavior)
?ASlink-Warning-Undefined Global sdcc_atomic_exchange_gptr_impl referenced by module
The feature is now in trunk.