* Claudiu Zissulescu [2018-10-10 11:00:13 +0300]:
> Use BI/BIH instruction to implement casesi pattern. Only ARC V2.
This removes the compact-casesi as an option for earlier ARC, right?
Was there a reason why that had to be done?
>
> gcc/
> 2018-03-21 Claudiu Zissulescu
>
> * config/arc/arc.c (arc_override_options): Remove
> TARGET_COMPACT_CASESI.
> * config/arc/arc.h (ASM_OUTPUT_ADDR_DIFF_ELT): Update.
> (CASE_VECTOR_MODE): Likewise.
> (CASE_VECTOR_PC_RELATIVE): Likewise.
> (CASE_VECTOR_SHORTEN_MODE): Likewise.
> (CASE_VECTOR_SHORTEN_MODE1): Delete.
> (ADDR_VEC_ALIGN): Update.
> (ASM_OUTPUT_CASE_LABEL): Undefine.
> (ASM_OUTPUT_BEFORE_CASE_LABEL): Undefine.
> (TARGET_BI_BIH): Define.
> (DEFAULT_BRANCH_INDEX): Likewise.
> * config/arc/arc.md (casesi): Rework to accept BI/BIH
> instructions, remove compact_casesi use case.
> (casesi_compact_jump): Remove.
> (casesi_dispatch): New pattern.
> * config/arc/arc.opt: Add mbranch-index option. Deprecate
> compact_casesi option.
> * doc/invoke.texi: Document mbranch-index option.
I guess if you feel that dropping compact-casesi support for earlier
targets is appropriate, then that's fine. There's some formatting
issues I point out below. But otherwise seems reasonable.
Thanks,
Andrew
>
> gcc/testsuite
> Claudiu Zissulescu
>
> * gcc.target/arc/jumptable.c: New test.
> ---
> gcc/config/arc/arc.c | 19 --
> gcc/config/arc/arc.h | 106 ++-
> gcc/config/arc/arc.md| 218 +++
> gcc/config/arc/arc.opt | 6 +-
> gcc/doc/invoke.texi | 9 +-
> gcc/testsuite/gcc.target/arc/jumptable.c | 34
> 6 files changed, 171 insertions(+), 221 deletions(-)
> create mode 100644 gcc/testsuite/gcc.target/arc/jumptable.c
>
> diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
> index 56f566795ff..18dd0de6af7 100644
> --- a/gcc/config/arc/arc.c
> +++ b/gcc/config/arc/arc.c
> @@ -1291,33 +1291,14 @@ arc_override_options (void)
>if (arc_size_opt_level == 3)
> optimize_size = 1;
>
> - /* Compact casesi is not a valid option for ARCv2 family. */
> - if (TARGET_V2)
> -{
> - if (TARGET_COMPACT_CASESI)
> - {
> - warning (OPT_mcompact_casesi,
> -"compact-casesi is not applicable to ARCv2");
> - TARGET_COMPACT_CASESI = 0;
> - }
> -}
> - else if (optimize_size == 1
> -&& !global_options_set.x_TARGET_COMPACT_CASESI)
> -TARGET_COMPACT_CASESI = 1;
> -
>if (flag_pic)
> target_flags |= MASK_NO_SDATA_SET;
>
>if (flag_no_common == 255)
> flag_no_common = !TARGET_NO_SDATA_SET;
>
> - /* TARGET_COMPACT_CASESI needs the "q" register class. */
>if (TARGET_MIXED_CODE)
> TARGET_Q_CLASS = 1;
> - if (!TARGET_Q_CLASS)
> -TARGET_COMPACT_CASESI = 0;
> - if (TARGET_COMPACT_CASESI)
> -TARGET_CASE_VECTOR_PC_RELATIVE = 1;
>
>/* Check for small data option */
>if (!global_options_set.x_g_switch_value && !TARGET_NO_SDATA_SET)
> diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h
> index dd78a6bbbd1..cb48b85d6e7 100644
> --- a/gcc/config/arc/arc.h
> +++ b/gcc/config/arc/arc.h
> @@ -1264,25 +1264,39 @@ do {
> \
> } while (0)
>
> /* This is how to output an element of a case-vector that is relative. */
> -#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
> -do { \
> - char label[30];\
> - ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
> - switch (GET_MODE (BODY)) \
> -{\
> -case E_QImode: fprintf (FILE, "\t.byte "); break;\
> -case E_HImode: fprintf (FILE, "\t.hword "); break; \
> -case E_SImode: fprintf (FILE, "\t.word "); break;\
> -default: gcc_unreachable (); \
> -}\
> - assemble_name (FILE, label); \
> - fprintf (FILE, "-"); \
> - ASM_GENERATE_INTERNAL_LABEL (label, "L", REL); \
> - assemble_name (FILE, label); \
> - if (TARGET_COMPACT_CASESI) \
> -fprintf (FILE, " + %d", 4 + arc_get_unalign ()); \
> - fprintf(FILE, "\n"); \
> -} while (0)
> +#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \
> + do { \
> +char label[30]; \
> +ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \
> +if (!TARGET_BI_BIH) \
> + {