summaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorrearnsha <rearnsha@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-18 11:26:24 +0000
committerrearnsha <rearnsha@138bc75d-0d04-0410-961f-82ee72b054a4>2002-03-18 11:26:24 +0000
commitfd957ef3c15055cd633717380745d366640dfb2f (patch)
tree26d7156b5d3be51ac40b7883e864783742cf5808 /gcc/config
parentae1df41de87b315c59d9d90cdaa4e1af663c12c2 (diff)
downloadgcc-fd957ef3c15055cd633717380745d366640dfb2f.tar.gz
* arm.md (tablejump): Make this a define_expand. For PIC add the
offset to the base of the table. (thumb_tablejump): Matcher for Thumb tablejump insn. * config/arm/aout.h (ASM_OUTPUT_ADDR_DIFF_ELT): Output thumb entries as the difference of two labels. * config/arm/aof.h (ASM_OUTPUT_ADDR_DIFF_ELT): Likewise. * config/arm/elf.h (JUMP_TABLES_IN_TEXT_SECTION): Only put ARM jump tables in the code. * config/arm/coff.h (JUMP_TABLES_IN_TEXT_SECTION): Likewise. * arm.c (get_jump_table_size): If the table is not in the text section, return zero. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@50960 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/arm/aof.h13
-rw-r--r--gcc/config/arm/aout.h12
-rw-r--r--gcc/config/arm/arm.c21
-rw-r--r--gcc/config/arm/arm.md21
-rw-r--r--gcc/config/arm/coff.h4
-rw-r--r--gcc/config/arm/elf.h4
6 files changed, 64 insertions, 11 deletions
diff --git a/gcc/config/arm/aof.h b/gcc/config/arm/aof.h
index 750bc08d123..f110ea215d1 100644
--- a/gcc/config/arm/aof.h
+++ b/gcc/config/arm/aof.h
@@ -120,6 +120,10 @@ do { \
(*ptr++) (); \
} while (0)
+/* We really want to put Thumb tables in a read-only data section, but
+ switching to another section during function output is not
+ possible. We could however do what the SPARC does and defer the
+ whole table generation until the end of the function. */
#define JUMP_TABLES_IN_TEXT_SECTION 1
#ifndef ARM_OS_NAME
@@ -322,8 +326,13 @@ do { \
/* Output of Dispatch Tables */
-#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
- fprintf ((STREAM), "\tb\t|L..%d|\n", (VALUE))
+#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM,BODY,VALUE,REL) \
+ do { \
+ if (TARGET_ARM) \
+ fprintf ((STREAM), "\tb\t|L..%d|\n", (VALUE)); \
+ else \
+ fprintf ((STREAM), "\tDCD\t|L..%d| - |L..%d|\n", (VALUE), (REL)); \
+ } while (0)
#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM,VALUE) \
fprintf ((STREAM), "\tDCD\t|L..%d|\n", (VALUE))
diff --git a/gcc/config/arm/aout.h b/gcc/config/arm/aout.h
index 64ca8b7caac..868eee0c7c8 100644
--- a/gcc/config/arm/aout.h
+++ b/gcc/config/arm/aout.h
@@ -181,8 +181,16 @@ Boston, MA 02111-1307, USA. */
#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \
asm_fprintf (STREAM, "\t.word\t%LL%d\n", VALUE)
-#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \
- asm_fprintf (STREAM, "\tb\t%LL%d\n", VALUE)
+#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \
+ do \
+ { \
+ if (TARGET_ARM) \
+ asm_fprintf (STREAM, "\tb\t%LL%d\n", VALUE); \
+ else \
+ asm_fprintf (STREAM, "\t.word\t%LL%d-%LL%d\n", VALUE, REL); \
+ } \
+ while (0)
+
#undef ASM_OUTPUT_ASCII
#define ASM_OUTPUT_ASCII(STREAM, PTR, LEN) \
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4b1775810b1..8ed4c6db131 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -5329,14 +5329,29 @@ is_jump_table (insn)
return NULL_RTX;
}
+#ifndef JUMP_TABLES_IN_TEXT_SECTION
+#define JUMP_TABLES_IN_TEXT_SECTION 0
+#endif
+
static HOST_WIDE_INT
get_jump_table_size (insn)
rtx insn;
{
- rtx body = PATTERN (insn);
- int elt = GET_CODE (body) == ADDR_DIFF_VEC ? 1 : 0;
+ /* ADDR_VECs only take room if read-only data does into the text
+ section. */
+ if (JUMP_TABLES_IN_TEXT_SECTION
+#if !defined(READONLY_DATA_SECTION)
+ || 1
+#endif
+ )
+ {
+ rtx body = PATTERN (insn);
+ int elt = GET_CODE (body) == ADDR_DIFF_VEC ? 1 : 0;
+
+ return GET_MODE_SIZE (GET_MODE (body)) * XVECLEN (body, elt);
+ }
- return GET_MODE_SIZE (GET_MODE (body)) * XVECLEN (body, elt);
+ return 0;
}
/* Move a minipool fix MP from its current location to before MAX_MP.
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index af0c9ecf1cf..cdab5c66ff8 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -9119,11 +9119,28 @@
;; Miscellaneous Thumb patterns
-(define_insn "tablejump"
+(define_expand "tablejump"
+ [(parallel [(set (pc) (match_operand:SI 0 "register_operand" "l*r"))
+ (use (label_ref (match_operand 1 "" "")))])]
+ "TARGET_THUMB"
+ "
+ if (flag_pic)
+ {
+ /* Hopefully, CSE will eliminate this copy. */
+ rtx reg1 = copy_addr_to_reg (gen_rtx_LABEL_REF (Pmode, operands[1]));
+ rtx reg2 = gen_reg_rtx (SImode);
+
+ emit_insn (gen_addsi3 (reg2, operands[0], reg1));
+ operands[0] = reg2;
+ }
+ "
+)
+
+(define_insn "*thumb_tablejump"
[(set (pc) (match_operand:SI 0 "register_operand" "l*r"))
(use (label_ref (match_operand 1 "" "")))]
"TARGET_THUMB"
- "mov pc, %0"
+ "mov\\t%|pc, %0"
[(set_attr "length" "2")]
)
diff --git a/gcc/config/arm/coff.h b/gcc/config/arm/coff.h
index f53dace9056..c9f0d9277ab 100644
--- a/gcc/config/arm/coff.h
+++ b/gcc/config/arm/coff.h
@@ -72,7 +72,9 @@ Boston, MA 02111-1307, USA. */
/* Define this macro if jump tables (for `tablejump' insns) should be
output in the text section, along with the assembler instructions.
Otherwise, the readonly data section is used. */
-#define JUMP_TABLES_IN_TEXT_SECTION 1
+/* We put ARM jump tables in the text section, because it makes the code
+ more efficient, but for Thumb it's better to put them out of band. */
+#define JUMP_TABLES_IN_TEXT_SECTION (TARGET_ARM)
#undef READONLY_DATA_SECTION
#define READONLY_DATA_SECTION rdata_section
diff --git a/gcc/config/arm/elf.h b/gcc/config/arm/elf.h
index c27dacaa58b..1cab2c4e144 100644
--- a/gcc/config/arm/elf.h
+++ b/gcc/config/arm/elf.h
@@ -103,7 +103,9 @@ Boston, MA 02111-1307, USA. */
/* Define this macro if jump tables (for `tablejump' insns) should be
output in the text section, along with the assembler instructions.
Otherwise, the readonly data section is used. */
-#define JUMP_TABLES_IN_TEXT_SECTION 1
+/* We put ARM jump tables in the text section, because it makes the code
+ more efficient, but for Thumb it's better to put them out of band. */
+#define JUMP_TABLES_IN_TEXT_SECTION (TARGET_ARM)
#ifndef LINK_SPEC
#define LINK_SPEC "%{mbig-endian:-EB} -X"