On 01/06/2017 09:08 AM, Mikael Pettersson wrote:
This fixes / works-around the wrong-code PR57583 on M68K, caused by
overflowing the 16-bit jump table offsets the backend uses.
Ideally the backend should define CASE_VECTOR_SHORTEN_MODE, but that
AFAIK needs insn length attributes, which the backend only has for CF
but not for classic M68K.
Instead this patch adds an -mlong-jump-table-offsets option, and adjusts
the code for emitting and using jump table offsets to handle both short
and long offsets. As long as the option is not selected, the backend
behaves exactly as before.
John Paul Adrian Glaubitz tested this patch by compiling "mednafen"
with it, which previously failed; I also tested earlier versions.
Is this Ok for trunk?
/Mikael
gcc/
2017-01-06 Mikael Pettersson <mikpeli...@gmail.com>
PR target/57583
* config/m68k/m68k.opt (LONG_JUMP_TABLE_OFFSETS): New option.
* config/m68k/linux.h (ASM_RETURN_CASE_JUMP): Handle
TARGET_LONG_JUMP_TABLE_OFFSETS.
* config/m68k/m68kelf.h (ASM_RETURN_CASE_JUMP): Likewise.
* config/m68k/netbsd-elf.h (ASM_RETURN_CASE_JUMP): Likewise.
* config/m68k/m68k.h (CASE_VECTOR_MODE): Likewise.
(ASM_OUTPUT_ADDR_DIFF_ELF): Likewise.
* config/m68k/m68k.md (tablejump expander): Likewise.
(*tablejump_pcrel_hi): Renamed from unnamed insn, reject
TARGET_LONG_JUMP_TABLE_OFFSETS.
(*tablejump_pcrel_si): New insn, handle TARGET_LONG_JUMP_TABLE_OFFSETS.
* doc/invoke.texi (M68K options): Add -mlong-jump-table-offsets.
Can't tablejump_pcrel_si be simplified? Isn't the output pattern just:
#ifdef ASM_RETURN_CASE_JUMP
ASM_RETURN_CASE_JUMP;
#else
return MOTOROLA ? "jmp (2,pc,%0.l)" : "jmp pc@(2,%0:l)";
#endif
With that simplification I think this will be fine.
jeff