2016-07-15 18:26 GMT+03:00 Georg-Johann Lay <a...@gjlay.de>: > This patch needs new hook TARGET_ADDR_SPACE_DIAGNOSE_USAGE: > https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00839.html > > This patch turns attribute progmem into a working feature for AVR_TINY > cores. > > It boils down to adding 0x4000 to all symbols with progmem: Flash memory > can be seen in the RAM address space starting at 0x4000, i.e. data in flash > can be read by means of LD instruction if we add offsets of 0x4000. There > is no need for special access macros like pgm_read_* or special address > spaces as there is nothing like a LPM instruction. > > This is simply achieved by setting a respective symbol_ref_flag, and when > such a symbol has to be printed, then plus_constant with 0x4000 is used. > > Diagnosing of unsupported address spaces is now performed by > TARGET_ADDR_SPACE_DIAGNOSE_USAGE which has exact location information. > Hence there is no need to scan all decls for invalid address spaces. > > For AVR_TINY, alls address spaces have been disabled. They are of no use. > Supporting __flash would just make the backend more complicated without any > gains. > > > Ok for trunk? > > Johann > > > gcc/ > * 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. > * avr-protos.h (avr_addr_space_supported_p): New prototype. > * 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. > (TARGET_ADDR_SPACE_DIAGNOSE_USAGE): New hook define... > (avr_addr_space_diagnose_usage): ...and implementation. > (avr_addr_space_supported_p): New function. > (avr_nonconst_pointer_addrspace, avr_pgm_check_var_decl): Only > report bad address space usage if that space is supported. > (avr_insert_attributes): Same. No more complain about unsupported > address spaces. > * avr.h (AVR_TINY_PM_OFFSET): New macro. > * avr-c.c (tm_p.h): Include it. > (avr_cpu_cpp_builtins) [__AVR_TINY_PM_BASE_ADDRESS__]: Use > AVR_TINY_PM_OFFSET instead of magic 0x4000 when built-in def'ing. > Only define addr-space related built-in macro if > avr_addr_space_supported_p. > gcc/testsuite/ > * gcc.target/avr/torture/tiny-progmem.c: New test. >
Approved.