2017-07-27 16:50 GMT+04:00 Georg-Johann Lay <a...@gjlay.de>: > On 27.07.2017 14:29, Georg-Johann Lay wrote: >> >> For some targets, the best place to put read-only lookup tables as >> generated by -ftree-switch-conversion is not the generic address space >> but some target specific address space. >> >> This is the case for AVR, where for most devices .rodata must be >> located in RAM. >> >> Part #1 adds a new, optional target hook that queries the back-end >> about the desired address space. There is currently only one user: >> tree-switch-conversion.c::build_one_array() which re-builds value_type >> and array_type if the address space returned by the backend is not >> the generic one. >> >> Part #2 is the AVR part that implements the new hook and adds some >> sugar around it. > > > This is the AVR part. > > It implements the new hook which returns a convenient flash address > space for devices where .rodata is located in RAM: The 16-bit __flash > for devices with <= 64 KiB flash and 24-bit __memx for > 64 KiB flash. > > It adds a new option -madd-space-for-lookup= which allows to pick a > specific address space. > > Some new insns and combine-split suport best code generation by the > knowledge that the 24-bit addresses will never point to RAM so that > the expensive decision-at-runtime whether LD or LPM has to be used > can be avoided. > > Passed without new regressions on atmega128. > > Ok for trunk provided the gcc part 1/2 is approved?
It's cool. Thank you. Please apply. > > Johann > > > Implement TARGET_ADDR_SPACE_FOR_ARTIFICIAL_RODATA. > > PR target/49857 > * 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<mode>-flashx): New insns. > (*split_xload<mode>-cswtch): New insn-and-split. > * doc/invoke.texi (AVR Options) <-maddr-space-for-lookup=>: > Document. >