avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Using progmem on the reduced Tiny core?


From: Georg-Johann Lay
Subject: Re: [avr-gcc-list] Using progmem on the reduced Tiny core?
Date: Thu, 14 Jul 2016 17:34:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 13.07.2016 19:10, Georg-Johann Lay wrote:
Currently progmem attribute works the same way on the reduced core (no LPM, 16
GPRs) and on the ordinary cores (with LPM, 32 GPRs).

As we have a linearized memory model on reduced core and flash memory is
visible in the RAM address range (starting at 0x4000), it would make sense if
the compiler added that offset.

...same question arises for the __flash address space:

It's currently accepted for rTiny but generates nonsensical code: No offset is added to symbols and LPM instructions are generated or a silly libcall.

We could handle __flash but there is no benefit for the user, instead it makes things more complicated because qualified pointers would have to be passed around. And it would make the avr backend even more complicated.

Actually progmem makes much more sense here because it is about handling of symbols and their values and about different code needed to access flash vs. RAM.


Attached is a tentative patch that adds this feature to avr-gcc together with a
small test program that demonstrates some use cases.

If this does not break anything (e.g. because the current practice is to use
progmem together with hand-crafted offsets and / or inline assembly) and the
feedback is positive, I would propose the change to gcc-patches.

Johann

gcc/
    * doc/extend.texi (AVR Variable Attributes) [progmem]: Add
    documentation how it works on reduced Tiny cores.
    * avr.c (AVR_SYMBOL_FLAG_TINY_PM): New macro.
    (avr_address_tiny_pm_p): New static function.
    (avr_print_operand_address) [AVR_TINY]: Add AVR_TINY_PM_OFFSET
    if the address is in progmem.
    (avr_assemble_integer): Same.
    (avr_encode_section_info) [AVR_TINY]: Set AVR_SYMBOL_FLAG_TINY_PM
    for symbol_ref in progmem.
    * avr.h (AVR_TINY_PM_OFFSET): New macro.
    * avr-c.c (avr_cpu_cpp_builtins): Use it instead of magic 0x4000
    when built-in def'ing __AVR_TINY_PM_BASE_ADDRESS__.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]