@@ -187,16 +187,16 @@
switch (GET_MODE (body)) \
{ \
case E_QImode: \
- asm_fprintf (STREAM, "\t.byte\t(%LL%d-%LL%d-4)/4\n", \
+ asm_fprintf (STREAM, "\t.byte\t(%LL%d-%LLrtx%d-4)/4\n", \
VALUE, REL); \
break; \
case E_HImode: \
- asm_fprintf (STREAM, "\t.2byte\t(%LL%d-%LL%d-4)/4\n", \
+ asm_fprintf (STREAM, "\t.2byte\t(%LL%d-%LLrtx%d-4)/4\n", \
VALUE, REL); \
break; \
case E_SImode: \
if (flag_pic) \
- asm_fprintf (STREAM, "\t.word\t%LL%d-%LL%d-4\n", \
+ asm_fprintf (STREAM, "\t.word\t%LL%d-%LLrtx%d-4\n", \
VALUE, REL); \
else \
asm_fprintf (STREAM, "\t.word\t%LL%d\n", VALUE); \
@@ -2092,10 +2092,10 @@ enum arm_auto_incmodes
for the index in the tablejump instruction. */
#define CASE_VECTOR_MODE Pmode
-#define CASE_VECTOR_PC_RELATIVE ((TARGET_ARM || TARGET_THUMB2 \
+#define CASE_VECTOR_PC_RELATIVE (TARGET_ARM || ((TARGET_THUMB2 \
|| (TARGET_THUMB1 \
&& (optimize_size || flag_pic))) \
- && (!target_pure_code))
+ && (!target_pure_code)))
#define CASE_VECTOR_SHORTEN_MODE(min, max, body) \
@@ -2301,8 +2301,14 @@ extern int making_const_table;
asm_fprintf (STREAM, "\tpop {%r}\n", REGNO); \
} while (0)
-#define ADDR_VEC_ALIGN(JUMPTABLE) \
- ((TARGET_THUMB && GET_MODE (PATTERN (JUMPTABLE)) == SImode) ? 2 : 0)
+/* If the switch table is in the code segment, additional alignment is
+ needed for Thumb SImode tables. Otherwise, tables in RO data have
+ natural alignment. */
+#define ADDR_VEC_ALIGN(TABLE) \
+ (JUMP_TABLES_IN_TEXT_SECTION \
+ ? ((TARGET_THUMB && GET_MODE (PATTERN (TABLE)) == SImode) ? 2 : 0) \
+ : (exact_log2 (GET_MODE_ALIGNMENT (GET_MODE (PATTERN (TABLE))) \
+ / BITS_PER_UNIT)))
/* Alignment for case labels comes from ADDR_VEC_ALIGN; avoid the
default alignment from elfos.h. */
@@ -30469,44 +30469,58 @@ arm_output_iwmmxt_tinsr (rtx *operands)
const char *
arm_output_casesi (rtx *operands)
{
+ char buf[100];
+ char label[100];
rtx diff_vec = PATTERN (NEXT_INSN (as_a <rtx_insn *> (operands[2])));
-
gcc_assert (GET_CODE (diff_vec) == ADDR_DIFF_VEC);
-
output_asm_insn ("cmp\t%0, %1", operands);
output_asm_insn ("bhi\t%l3", operands);
+ ASM_GENERATE_INTERNAL_LABEL (label, "Lrtx", CODE_LABEL_NUMBER (operands[2]));
switch (GET_MODE (diff_vec))
{
case E_QImode:
- output_asm_insn ("adr\t%4, %l2", operands);
if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
- output_asm_insn ("ldrb\t%4, [%4, %0]", operands);
+ output_asm_insn ("ldrb\t%4, [%5, %0]", operands);
else
- output_asm_insn ("ldrsb\t%4, [%4, %0]", operands);
- return "add\t%|pc, %|pc, %4, lsl #2";
-
+ output_asm_insn ("ldrsb\t%4, [%5, %0]", operands);
+ output_asm_insn ("add\t%|pc, %|pc, %4, lsl #2", operands);;
+ break;
case E_HImode:
- output_asm_insn ("adr\t%4, %l2", operands);
- output_asm_insn ("add\t%4, %4, %0", operands);
- if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
- output_asm_insn ("ldrh\t%4, [%4, %0]", operands);
- else
- output_asm_insn ("ldrsh\t%4, [%4, %0]", operands);
- return "add\t%|pc, %|pc, %4, lsl #2";
-
+ if (REGNO (operands[4]) != REGNO (operands[5]))
+ {
+ output_asm_insn ("add\t%4, %0, %0", operands);
+ if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
+ output_asm_insn ("ldrh\t%4, [%5, %4]", operands);
+ else
+ output_asm_insn ("ldrsh\t%4, [%5, %4]", operands);
+ }
+ else
+ {
+ output_asm_insn ("add\t%4, %5, %0", operands);
+ if (ADDR_DIFF_VEC_FLAGS (diff_vec).offset_unsigned)
+ output_asm_insn ("ldrh\t%4, [%4, %0]", operands);
+ else
+ output_asm_insn ("ldrsh\t%4, [%4, %0]", operands);
+ }
+ output_asm_insn ("add\t%|pc, %|pc, %4, lsl #2", operands);
+ break;
case E_SImode:
if (flag_pic)
{
- output_asm_insn ("adr\t%4, %l2", operands);
- output_asm_insn ("ldr\t%4, [%4, %0, lsl #2]", operands);
- return "add\t%|pc, %|pc, %4";
+ output_asm_insn ("ldr\t%4, [%5, %0, lsl #2]", operands);
+ output_asm_insn ("add\t%|pc, %|pc, %4", operands);
}
- output_asm_insn ("adr\t%4, %l2", operands);
- return "ldr\t%|pc, [%4, %0, lsl #2]";
-
+ else
+ {
+ output_asm_insn ("ldr\t%|pc, [%5, %0, lsl #2]", operands);
+ }
+ break;
default:
gcc_unreachable ();
}
+ assemble_label (asm_out_file, label);
+ output_asm_insn ("nop;", operands);
+ return "";
}
/* Output a Thumb-1 casesi dispatch sequence. */
@@ -9514,7 +9514,8 @@
(match_operand:SI 2 "const_int_operand") ; total range
(match_operand:SI 3 "" "") ; table label
(match_operand:SI 4 "" "")] ; Out of range label
- "(TARGET_32BIT || optimize_size || flag_pic) && !target_pure_code"
+ "TARGET_ARM || ((TARGET_THUMB2 || optimize_size || flag_pic) &&
+ (!target_pure_code))"
"
{
enum insn_code code;
@@ -9557,13 +9558,13 @@
(label_ref:SI (match_operand 3 ""))))
(clobber (reg:CC CC_REGNUM))
(clobber (match_scratch:SI 5))
- (clobber (match_scratch:SI 6))
(use (label_ref:SI (match_operand 2 "")))])]
"TARGET_ARM"
{
+ rtx tmp = force_reg (SImode, gen_rtx_LABEL_REF (SImode, operands[2]));
operands[4] = gen_rtx_MULT (SImode, operands[0], GEN_INT (4));
operands[4] = gen_rtx_PLUS (SImode, operands[4],
- gen_rtx_LABEL_REF (SImode, operands[2]));
+ tmp);
operands[4] = gen_rtx_MEM (SImode, operands[4]);
MEM_READONLY_P (operands[4]) = 1;
MEM_NOTRAP_P (operands[4]) = 1;
@@ -9575,12 +9576,11 @@
(leu (match_operand:SI 0 "s_register_operand" "r")
(match_operand:SI 1 "arm_rhs_operand" "rI"))
(mem:SI (plus:SI (mult:SI (match_dup 0) (const_int 4))
- (label_ref:SI (match_operand 2 "" ""))))
+ (match_operand:SI 5 "s_register_operand" "r")))
(label_ref:SI (match_operand 3 "" ""))))
(clobber (reg:CC CC_REGNUM))
- (clobber (match_scratch:SI 4 "=&r"))
- (clobber (match_scratch:SI 5 "=r"))
- (use (label_ref:SI (match_dup 2)))])]
+ (clobber (match_scratch:SI 4 "=r"))
+ (use (label_ref:SI (match_operand 2 "")))])]
"TARGET_ARM"
{
return arm_output_casesi (operands);
@@ -91,11 +91,11 @@
/* 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. */
-/* We put ARM and Thumb-2 jump tables in the text section, because it makes
- the code more efficient, but for Thumb-1 it's better to put them out of
+/* We put Thumb-2 jump tables in the text section, because it makes
+ the code more efficient, but for Thumb-1 and ARM it's better to put them out of
band unless we are generating compressed tables. */
#define JUMP_TABLES_IN_TEXT_SECTION \
- ((TARGET_32BIT || (TARGET_THUMB && (optimize_size || flag_pic))) \
+ ((TARGET_THUMB2 || (TARGET_THUMB && (optimize_size || flag_pic))) \
&& !target_pure_code)
#ifndef LINK_SPEC
@@ -53,9 +53,10 @@ inline void SIFunction (const char* flag)
/*
**QImode_test:
** ...
-** adr (r[0-9]+), .L[0-9]+
-** ldrb \1, \[\1, r[0-9]+\]
-** add pc, pc, \1, lsl #2
+** ldr (r[0-9]+), .L[0-9]+
+** ...
+** ldrb (r[0-9]+), \[\1, r[0-9]+\]
+** add pc, pc, \2, lsl #2
** ...
*/
__attribute__ ((noinline)) __attribute__ ((noclone)) const char* QImode_test(enum z x)
@@ -77,10 +78,11 @@ __attribute__ ((noinline)) __attribute__ ((noclone)) const char* QImode_test(enu
/*
**HImode_test:
** ...
-** adr (r[0-9]+), .L[0-9]+
-** add \1, \1, (r[0-9]+)
-** ldrh \1, \[\1, \2\]
-** add pc, pc, \1, lsl #2
+** ldr (r[0-9]+), .L[0-9]+
+** ...
+** add r[0-9]+, r[0-9]+, r[0-9]+
+** ldrh (r[0-9]+), \[r[0-9]+, r[0-9]+]
+** add pc, pc, \2, lsl #2
** ...
*/
__attribute__ ((noinline)) __attribute__ ((noclone)) const char* HImode_test(enum z x)
@@ -102,7 +104,8 @@ __attribute__ ((noinline)) __attribute__ ((noclone)) const char* HImode_test(enu
/*
**SImode_test:
** ...
-** adr (r[0-9]+), .L[0-9]+
+** ldr (r[0-9]+), .L[0-9]+
+** ...
** ldr pc, \[\1, r[0-9]+, lsl #2\]
** ...
*/
@@ -125,10 +128,11 @@ __attribute__ ((noinline)) __attribute__ ((noclone)) const char* SImode_test(enu
/*
**backwards_branch_test:
** ...
-** adr (r[0-9]+), .L[0-9]+
-** add \1, \1, (r[0-9]+)
-** ldrsh \1, \[\1, \2\]
-** add pc, pc, \1, lsl #2
+** ldr (r[0-9]+), .L[0-9]+
+** ...
+** add r[0-9]+, r[0-9]+, r[0-9]+
+** ldrsh (r[0-9]+), \[r[0-9]+, r[0-9]+]
+** add pc, pc, \2, lsl #2
** ...
*/
__attribute__ ((noinline)) __attribute__ ((noclone)) const char* backwards_branch_test(enum z x, int flag)