diff options
author | Claudiu Zissulescu <claziss@synopsys.com> | 2018-10-31 12:27:35 +0100 |
---|---|---|
committer | Claudiu Zissulescu <claziss@gcc.gnu.org> | 2018-10-31 12:27:35 +0100 |
commit | aac1c11ce4edd9c2e6af7e9ee8abcaba98d8741f (patch) | |
tree | 07e0408043af521dfe832f263dea8d6e7cea5011 /gcc/config/arc/arc.h | |
parent | 8efa18d693207598020f6d7aabb680397ff3815c (diff) | |
download | gcc-aac1c11ce4edd9c2e6af7e9ee8abcaba98d8741f.zip gcc-aac1c11ce4edd9c2e6af7e9ee8abcaba98d8741f.tar.gz gcc-aac1c11ce4edd9c2e6af7e9ee8abcaba98d8741f.tar.bz2 |
[ARC] Add BI/BIH instruction support.
Use BI/BIH instruction to implement casesi pattern. Only ARC V2.
gcc/
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* 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.
gcc/testsuite
xxxx-xx-xx Claudiu Zissulescu <claziss@synopsys.com>
* gcc.target/arc/jumptable.c: New test.
From-SVN: r265675
Diffstat (limited to 'gcc/config/arc/arc.h')
-rw-r--r-- | gcc/config/arc/arc.h | 110 |
1 files changed, 65 insertions, 45 deletions
diff --git a/gcc/config/arc/arc.h b/gcc/config/arc/arc.h index 98fa928..58d66d7 100644 --- a/gcc/config/arc/arc.h +++ b/gcc/config/arc/arc.h @@ -1266,29 +1266,45 @@ do { \ ASM_GENERATE_INTERNAL_LABEL (label, "L", VALUE); \ fprintf (FILE, "\t.word "); \ assemble_name (FILE, label); \ - fprintf(FILE, "\n"); \ + fprintf (FILE, "\n"); \ } 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) \ + { \ + 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); \ + fprintf (FILE, "\n"); \ + } \ + else \ + { \ + switch (GET_MODE (BODY)) \ + { \ + case E_SImode: fprintf (FILE, "\tb\t@"); break; \ + case E_HImode: \ + case E_QImode: fprintf (FILE, "\tb_s\t@"); break; \ + default: gcc_unreachable (); \ + } \ + assemble_name (FILE, label); \ + fprintf(FILE, "\n"); \ + } \ + } while (0) + +/* Defined to also emit an .align in elfos.h. We don't want that. */ +#undef ASM_OUTPUT_CASE_LABEL /* ADDR_DIFF_VECs are in the text section and thus can affect the current alignment. */ @@ -1386,36 +1402,34 @@ do { \ for the index in the tablejump instruction. If we have pc relative case vectors, we start the case vector shortening with QImode. */ -#define CASE_VECTOR_MODE \ - ((optimize && (CASE_VECTOR_PC_RELATIVE || flag_pic)) ? QImode : Pmode) +#define CASE_VECTOR_MODE \ + (TARGET_BI_BIH ? SImode \ + : (optimize && (CASE_VECTOR_PC_RELATIVE || flag_pic)) ? QImode : Pmode) /* Define as C expression which evaluates to nonzero if the tablejump instruction expects the table to contain offsets from the address of the table. Do not define this if the table should contain absolute addresses. */ -#define CASE_VECTOR_PC_RELATIVE TARGET_CASE_VECTOR_PC_RELATIVE - -#define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \ - CASE_VECTOR_SHORTEN_MODE_1 \ - (MIN_OFFSET, TARGET_COMPACT_CASESI ? MAX_OFFSET + 6 : MAX_OFFSET, BODY) - -#define CASE_VECTOR_SHORTEN_MODE_1(MIN_OFFSET, MAX_OFFSET, BODY) \ -((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \ - ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \ - : (MIN_OFFSET) >= -128 && (MAX_OFFSET) <= 127 \ - ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \ - : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 65535 \ - ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, HImode) \ - : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 \ - ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, HImode) \ - : SImode) - -#define ADDR_VEC_ALIGN(VEC_INSN) \ - (exact_log2 (GET_MODE_SIZE (as_a <scalar_int_mode> \ - (GET_MODE (PATTERN (VEC_INSN)))))) -#undef ASM_OUTPUT_BEFORE_CASE_LABEL -#define ASM_OUTPUT_BEFORE_CASE_LABEL(FILE, PREFIX, NUM, TABLE) \ - ASM_OUTPUT_ALIGN ((FILE), ADDR_VEC_ALIGN (TABLE)) +#define CASE_VECTOR_PC_RELATIVE \ + (TARGET_CASE_VECTOR_PC_RELATIVE || TARGET_BI_BIH) + +#define CASE_VECTOR_SHORTEN_MODE(MIN_OFFSET, MAX_OFFSET, BODY) \ + (TARGET_BI_BIH ? \ + ((MIN_OFFSET) >= -512 && (MAX_OFFSET) <= 508 ? HImode : SImode) \ + : ((MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 255 \ + ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, QImode) \ + : (MIN_OFFSET) >= -128 && (MAX_OFFSET) <= 127 \ + ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, QImode) \ + : (MIN_OFFSET) >= 0 && (MAX_OFFSET) <= 65535 \ + ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 1, HImode) \ + : (MIN_OFFSET) >= -32768 && (MAX_OFFSET) <= 32767 \ + ? (ADDR_DIFF_VEC_FLAGS (BODY).offset_unsigned = 0, HImode) \ + : SImode)) + +#define ADDR_VEC_ALIGN(VEC_INSN) \ + (TARGET_BI_BIH ? 0 \ + : exact_log2 (GET_MODE_SIZE (as_a <scalar_int_mode> \ + (GET_MODE (PATTERN (VEC_INSN)))))) #define INSN_LENGTH_ALIGNMENT(INSN) \ ((JUMP_TABLE_DATA_P (INSN) \ @@ -1638,4 +1652,10 @@ enum /* DBNZ support is available for ARCv2 core3 and newer cpus. */ #define TARGET_DBNZ (TARGET_V2 && (arc_tune >= ARC_TUNE_CORE_3)) +/* BI/BIH feature macro. */ +#define TARGET_BI_BIH (TARGET_BRANCH_INDEX && TARGET_CODE_DENSITY) + +/* The default option for BI/BIH instructions. */ +#define DEFAULT_BRANCH_INDEX 0 + #endif /* GCC_ARC_H */ |