[Bug tree-optimization/49857] Put constant switch-tables into flash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857 Georg-Johann Lay changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |WONTFIX --- Comment #17 from Georg-Johann Lay --- Giving up on this. A working solution as patch series is here, so anyone can pick it up. http://gcc.gnu.org/ml/gcc-patches/2017-07/msg01804.html http://gcc.gnu.org/ml/gcc-patches/2017-07/msg01808.html http://gcc.gnu.org/ml/gcc-patches/2017-07/msg01810.html Note that it only can be done for artificial data -- or you have to make sure that the data is not accessed by inline asm by different means (and of course, no pointers must escape, and a respective hook must not be called from within the C++ front-end). avr-part approval: http://gcc.gnu.org/ml/gcc-patches/2017-07/msg01835.html gcc-part rejection as "too specific": http://gcc.gnu.org/ml/gcc-patches/2017-07/msg01879.html
[Bug tree-optimization/49857] Put constant switch-tables into flash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857 --- Comment #16 from Georg-Johann Lay --- (In reply to Georg-Johann Lay from comment #15) > pr49857-v2-all.diff: Proposed patch Problems so far: * ivopts may shred address-space which results in wrong code. This is is the reason for why the patch doesn't -maddr-space-for-lookup=memx $ make -k check-gcc RUNTESTFLAGS="--target_board=atmega128-sim execute.exp='20120808-1.c pr35800.c' --tool_opts=-maddr-space-for-lookup=memx" * tree-swich-conversion might bloat the code, cf. PR81540 so it may even be better to disable tree-switch-conversion per default.
[Bug tree-optimization/49857] Put constant switch-tables into flash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857 --- Comment #15 from Georg-Johann Lay --- Created attachment 41829 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41829=edit pr49857-v2-all.diff: Proposed patch PR 49857 * target.def (TARGET_ADDR_SPACE_FOR_ARTIFICIAL_RODATA): New hook. * targhooks.c (default_addr_space_for_artificial_rodata): New function. * targhooks.h (default_addr_space_for_artificial_rodata): New proto. * tree-switch-conversion.c (target.h): Include it. (build_one_array): Set address space of array_type according to targetm.addr_space.for_artificial_rodata(). * doc/tm.texi.in (Named Address Spaces) [TARGET_ADDR_SPACE_FOR_ARTIFICIAL_RODATA]: Add hook anchor. * doc/tm.texi: Regenerate. * config/avr/avr-opts.h: New file. * config/avr/avr.opt: Include it. (-maddr-space-for-lookup=): New option and... (avr_opt_addr_space_for_lookup): ...associated Var. (avr_aspace_for_lookup): New option enums used by above. * config/avr/avr-protos.h (avr_out_load_flashx): New proto. * config/avr/avr.c (avr_out_load_flashx): New function. * avr_adjust_insn_length [ADJUST_LEN_LOAD_FLASHX]: Handle it. * avr_rtx_costs_1 [ZERO_EXTEND, SIGN_EXTEND]: Handle shift-and-extend-by-1 of HI -> PSI. [ASHIFT,PSImode]: Describe cost of extend-and-shift-by-1. (TARGET_ADDR_SPACE_FOR_ARTIFICIAL_RODATA): Define to... (avr_addr_space_for_artificial_rodata): ...this new static function. * config/avr/avr.md (unspec): Add UNSPEC_LOAD_FLASHX. (adjust_len): Add load_flashx. (*ashiftpsi.1_sign_extend.hi, *ashiftpsi.1_zero_extend.hi) (*extendpsi.ashift.1.uqi, *load-flashx): New insns. (*split_xload-cswtch): New insn-and-split. * doc/invoke.texi (AVR Options) <-maddr-space-for-lookup=>: Document.
[Bug tree-optimization/49857] Put constant switch-tables into flash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857 Georg-Johann Lay changed: What|Removed |Added Component|target |tree-optimization --- Comment #14 from Georg-Johann Lay --- Please, this is (not only) a target issue. As already mentioned, in order for the target to be able to generate correct code, this needs a new target hook, hence byond "target". Just putting the tables in flash won't adjust the address spaces which is needed for correct accesses.
[Bug tree-optimization/49857] Put constant switch-tables into flash
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49857 Georg-Johann Lay gjl at gcc dot gnu.org changed: What|Removed |Added Component|target |tree-optimization --- Comment #1 from Georg-Johann Lay gjl at gcc dot gnu.org 2012-01-29 14:55:48 UTC --- Changed component from target to tree-optimization because: The code in tree-switch-conversion.c needs to be extended by, say, a target hook that queries the backend for the right address space for the generated lookup table, i.e. the CSWTCH.num objects. This is needed for two reasons: 1) The data (CSWTCH.num) has to be located in the preferred section, i.e. in Flash and not in RAM. 2) The accesses have to use the right instructions, i.e. instructions to read from non-generic address space (Flash) and not instructions to access generic address space (RAM).