Bug 71948 - [avr] Make progmem work on reduced Tiny cores by adding 0x4000 to symbols
Summary: [avr] Make progmem work on reduced Tiny cores by adding 0x4000 to symbols
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.0
: P5 enhancement
Target Milestone: 7.0
Assignee: Georg-Johann Lay
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-07-20 14:01 UTC by Georg-Johann Lay
Modified: 2016-08-01 17:13 UTC (History)
0 users

See Also:
Host:
Target: avr
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-07-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2016-07-20 14:01:45 UTC
The reduced tiny cores feature reading from flash:  The flash memory can be seen in the RAM address range at an offset starting at 0x4000.

Hence progmem can be used to put data into flash and to generate the correct accesses without the need of special functions (like pgm_read_* which is needed on generic core).  This can easily be achieved by adding 0x4000 to the value of symbols.
Comment 1 Georg-Johann Lay 2016-07-20 14:12:48 UTC
Author: gjl
Date: Wed Jul 20 14:12:16 2016
New Revision: 238525

URL: https://gcc.gnu.org/viewcvs?rev=238525&root=gcc&view=rev
Log:
gcc/
	Implement attribute progmem on reduced Tiny cores by adding
	flash offset 0x4000 to respective symbols.

	PR target/71948
	* doc/extend.texi (AVR Variable Attributes) [progmem]: Add
	documentation how it works on reduced Tiny cores.
	(AVR Named Address Spaces): No support for reduced Tiny.
	* config/avr/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.
	* config/avr/avr.h (AVR_TINY_PM_OFFSET): New macro.
	* config/avr/avr-c.c (avr_cpu_cpp_builtins): Use it instead of
	magic 0x4000 when built-in def'ing __AVR_TINY_PM_BASE_ADDRESS__.
gcc/testsuite/
	PR target/71948
	* gcc.target/avr/torture/tiny-progmem.c: New test.


Added:
    trunk/gcc/testsuite/gcc.target/avr/torture/tiny-progmem.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr-c.c
    trunk/gcc/config/avr/avr.c
    trunk/gcc/config/avr/avr.h
    trunk/gcc/doc/extend.texi
    trunk/gcc/testsuite/ChangeLog
Comment 2 Georg-Johann Lay 2016-07-21 12:27:54 UTC
Done, cf.

https://gcc.gnu.org/onlinedocs/gcc/AVR-Variable-Attributes.html

for an example.
Comment 3 Georg-Johann Lay 2016-08-01 17:13:04 UTC
Author: gjl
Date: Mon Aug  1 17:12:32 2016
New Revision: 238961

URL: https://gcc.gnu.org/viewcvs?rev=238961&root=gcc&view=rev
Log:
	PR target/71948
	* config/avr/avr.c (AVR_SYMBOL_FLAG_TINY_PM): Use a value that
	does not overlap with other symbol flags.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.c