Commit 76cbf5bf by Richard Sandiford Committed by Richard Sandiford

mips-protos.h (m16_usym8_4, [...]): Delete.

	* config/mips/mips-protos.h (m16_usym8_4, m16_usym5_4): Delete.
	* config/mips/mips.h (mips_entry, mips_string_length): Delete.
	(CONSTANT_POOL_BEFORE_FUNCTION, ASM_OUTPUT_POOL_EPILOGUE): Undefine.
	* config/mips/mips.c (struct mips16_constant): Renamed from struct
	constant.  Propogate change throughout file.
	(struct machine_function): Remove insns_len.
	(mips_string_length, mips16_strings, string_constants): Delete.
	(mips_classify_symbol): Return SYMBOL_CONSTANT_POOL for LABEL_REFs
	when generating mips16 code.  Remove special mips16 treatment of
	string constants.
	(mips_symbolic_constant_p): Allow mips16 constant pool accesses
	to have the form LABEL+CONSTANT.
	(mips_symbolic_address_p): Fix comment.
	(m16_usym8_4, m16_usym5_4): Delete.
	(mips_output_function_epilogue): Remove mips16 string handling.
	(mips_output_mi_thunk): Call mips16_lay_out_constants.
	(mips_select_section, mips_encode_section_info): Remove mips16
	string handling.
	(struct mips16_constant_pool): New.
	(add_constant): Take a mips16_constant_pool structure.  Keep pool
	sorted into order of ascending mode size.  Keep track of the highest
	possible start address, taking padding and the masking of the base PC
	value into account.
	(dump_constants_1): New function, split out from dump_constants.
	Handle vector constants.  Use gen_consttable_{int,float} rather than
	separate functions for each mode.
	(dump_constants): Simplify.  Use GET_MODE_ALIGNMENT.  Use gen_align
	rather than separate functions for each alignment.
	(mips_find_symbol): Delete.
	(mips16_insn_length): New function, split out from
	mips16_lay_out_constants.
	(mips16_rewrite_pool_refs): New function.
	(mips16_lay_out_constants): Rework. Remove string handling.
	Always create an inline constant pool.
	* config/mips/mips.md (UNSPEC_CONSTTABLE_INT, UNSPEC_CONSTTABLE_FLOAT)
	(UNSPEC_ALIGN): New constants.
	(UNSPEC_CONSTTABLE_[QHSD]I, UNSPEC_CONSTTABLE_[SD]F): Delete.
	(UNSPEC_ALIGN_[248]): Delete.
	(consttable_int, consttable_float, align): New patterns.
	(consttable_[qhsd]i, consttable_[sd]f, align_[248]): Delete.

From-SVN: r80814
parent f178c2d6
2004-04-18 Richard Sandiford <rsandifo@redhat.com>
* config/mips/mips-protos.h (m16_usym8_4, m16_usym5_4): Delete.
* config/mips/mips.h (mips_entry, mips_string_length): Delete.
(CONSTANT_POOL_BEFORE_FUNCTION, ASM_OUTPUT_POOL_EPILOGUE): Undefine.
* config/mips/mips.c (struct mips16_constant): Renamed from struct
constant. Propogate change throughout file.
(struct machine_function): Remove insns_len.
(mips_string_length, mips16_strings, string_constants): Delete.
(mips_classify_symbol): Return SYMBOL_CONSTANT_POOL for LABEL_REFs
when generating mips16 code. Remove special mips16 treatment of
string constants.
(mips_symbolic_constant_p): Allow mips16 constant pool accesses
to have the form LABEL+CONSTANT.
(mips_symbolic_address_p): Fix comment.
(m16_usym8_4, m16_usym5_4): Delete.
(mips_output_function_epilogue): Remove mips16 string handling.
(mips_output_mi_thunk): Call mips16_lay_out_constants.
(mips_select_section, mips_encode_section_info): Remove mips16
string handling.
(struct mips16_constant_pool): New.
(add_constant): Take a mips16_constant_pool structure. Keep pool
sorted into order of ascending mode size. Keep track of the highest
possible start address, taking padding and the masking of the base PC
value into account.
(dump_constants_1): New function, split out from dump_constants.
Handle vector constants. Use gen_consttable_{int,float} rather than
separate functions for each mode.
(dump_constants): Simplify. Use GET_MODE_ALIGNMENT. Use gen_align
rather than separate functions for each alignment.
(mips_find_symbol): Delete.
(mips16_insn_length): New function, split out from
mips16_lay_out_constants.
(mips16_rewrite_pool_refs): New function.
(mips16_lay_out_constants): Rework. Remove string handling.
Always create an inline constant pool.
* config/mips/mips.md (UNSPEC_CONSTTABLE_INT, UNSPEC_CONSTTABLE_FLOAT)
(UNSPEC_ALIGN): New constants.
(UNSPEC_CONSTTABLE_[QHSD]I, UNSPEC_CONSTTABLE_[SD]F): Delete.
(UNSPEC_ALIGN_[248]): Delete.
(consttable_int, consttable_float, align): New patterns.
(consttable_[qhsd]i, consttable_[sd]f, align_[248]): Delete.
2004-04-17 Aldy Hernandez <aldyh@redhat.com> 2004-04-17 Aldy Hernandez <aldyh@redhat.com>
* config/rs6000/altivec.h (vec_any_numeric): Correct typo in * config/rs6000/altivec.h (vec_any_numeric): Correct typo in
......
...@@ -114,8 +114,6 @@ extern int m16_uimm8_4 (rtx, enum machine_mode); ...@@ -114,8 +114,6 @@ extern int m16_uimm8_4 (rtx, enum machine_mode);
extern int m16_nuimm8_4 (rtx, enum machine_mode); extern int m16_nuimm8_4 (rtx, enum machine_mode);
extern int m16_simm8_8 (rtx, enum machine_mode); extern int m16_simm8_8 (rtx, enum machine_mode);
extern int m16_nsimm8_8 (rtx, enum machine_mode); extern int m16_nsimm8_8 (rtx, enum machine_mode);
extern int m16_usym8_4 (rtx, enum machine_mode);
extern int m16_usym5_4 (rtx, enum machine_mode);
extern struct rtx_def *embedded_pic_fnaddr_reg (void); extern struct rtx_def *embedded_pic_fnaddr_reg (void);
extern struct rtx_def *embedded_pic_offset (rtx); extern struct rtx_def *embedded_pic_offset (rtx);
......
...@@ -134,7 +134,7 @@ enum mips_address_type { ...@@ -134,7 +134,7 @@ enum mips_address_type {
register and the second is the stack slot. */ register and the second is the stack slot. */
typedef void (*mips_save_restore_fn) (rtx, rtx); typedef void (*mips_save_restore_fn) (rtx, rtx);
struct constant; struct mips16_constant;
struct mips_arg_info; struct mips_arg_info;
struct mips_address_info; struct mips_address_info;
struct mips_integer_op; struct mips_integer_op;
...@@ -215,9 +215,10 @@ static rtx mips_return_fpr_pair (enum machine_mode mode, ...@@ -215,9 +215,10 @@ static rtx mips_return_fpr_pair (enum machine_mode mode,
static rtx mips16_gp_pseudo_reg (void); static rtx mips16_gp_pseudo_reg (void);
static void mips16_fp_args (FILE *, int, int); static void mips16_fp_args (FILE *, int, int);
static void build_mips16_function_stub (FILE *); static void build_mips16_function_stub (FILE *);
static rtx add_constant (struct constant **, rtx, enum machine_mode); static rtx dump_constants_1 (enum machine_mode, rtx, rtx);
static void dump_constants (struct constant *, rtx); static void dump_constants (struct mips16_constant *, rtx);
static rtx mips_find_symbol (rtx); static int mips16_insn_length (rtx);
static int mips16_rewrite_pool_refs (rtx *, void *);
static void mips16_lay_out_constants (void); static void mips16_lay_out_constants (void);
static void mips_avoid_hazard (rtx, rtx, int *, rtx *, rtx); static void mips_avoid_hazard (rtx, rtx, int *, rtx *, rtx);
static void mips_avoid_hazards (void); static void mips_avoid_hazards (void);
...@@ -283,9 +284,6 @@ struct machine_function GTY(()) { ...@@ -283,9 +284,6 @@ struct machine_function GTY(()) {
/* Current frame information, calculated by compute_frame_size. */ /* Current frame information, calculated by compute_frame_size. */
struct mips_frame_info frame; struct mips_frame_info frame;
/* Length of instructions in function; mips16 only. */
long insns_len;
/* The register to use as the global pointer within this function. */ /* The register to use as the global pointer within this function. */
unsigned int global_pointer; unsigned int global_pointer;
...@@ -462,28 +460,6 @@ static enum machine_mode gpr_mode; ...@@ -462,28 +460,6 @@ static enum machine_mode gpr_mode;
can support a given mode. */ can support a given mode. */
char mips_hard_regno_mode_ok[(int)MAX_MACHINE_MODE][FIRST_PSEUDO_REGISTER]; char mips_hard_regno_mode_ok[(int)MAX_MACHINE_MODE][FIRST_PSEUDO_REGISTER];
/* The length of all strings seen when compiling for the mips16. This
is used to tell how many strings are in the constant pool, so that
we can see if we may have an overflow. This is reset each time the
constant pool is output. */
int mips_string_length;
/* When generating mips16 code, a list of all strings that are to be
output after the current function. */
static GTY(()) rtx mips16_strings;
/* In mips16 mode, we build a list of all the string constants we see
in a particular function. */
struct string_constant
{
struct string_constant *next;
const char *label;
};
static struct string_constant *string_constants;
/* List of all MIPS punctuation characters used by print_operand. */ /* List of all MIPS punctuation characters used by print_operand. */
char mips_print_operand_punct[256]; char mips_print_operand_punct[256];
...@@ -776,7 +752,13 @@ static enum mips_symbol_type ...@@ -776,7 +752,13 @@ static enum mips_symbol_type
mips_classify_symbol (rtx x) mips_classify_symbol (rtx x)
{ {
if (GET_CODE (x) == LABEL_REF) if (GET_CODE (x) == LABEL_REF)
return (TARGET_ABICALLS ? SYMBOL_GOT_LOCAL : SYMBOL_GENERAL); {
if (TARGET_MIPS16)
return SYMBOL_CONSTANT_POOL;
if (TARGET_ABICALLS)
return SYMBOL_GOT_LOCAL;
return SYMBOL_GENERAL;
}
if (GET_CODE (x) != SYMBOL_REF) if (GET_CODE (x) != SYMBOL_REF)
abort (); abort ();
...@@ -798,11 +780,6 @@ mips_classify_symbol (rtx x) ...@@ -798,11 +780,6 @@ mips_classify_symbol (rtx x)
if (SYMBOL_REF_SMALL_P (x)) if (SYMBOL_REF_SMALL_P (x))
return SYMBOL_SMALL_DATA; return SYMBOL_SMALL_DATA;
/* When generating mips16 code, SYMBOL_REF_FLAG indicates a string
in the current function's constant pool. */
if (TARGET_MIPS16 && SYMBOL_REF_FLAG (x))
return SYMBOL_CONSTANT_POOL;
if (TARGET_ABICALLS) if (TARGET_ABICALLS)
{ {
if (SYMBOL_REF_DECL (x) == 0) if (SYMBOL_REF_DECL (x) == 0)
...@@ -919,8 +896,16 @@ mips_symbolic_constant_p (rtx x, enum mips_symbol_type *symbol_type) ...@@ -919,8 +896,16 @@ mips_symbolic_constant_p (rtx x, enum mips_symbol_type *symbol_type)
/* In other cases the relocations can handle any offset. */ /* In other cases the relocations can handle any offset. */
return true; return true;
case SYMBOL_SMALL_DATA:
case SYMBOL_CONSTANT_POOL: case SYMBOL_CONSTANT_POOL:
/* Allow constant pool references to be converted to LABEL+CONSTANT.
In this case, we no longer have access to the underlying constant,
but the original symbol-based access was known to be valid. */
if (GET_CODE (x) == LABEL_REF)
return true;
/* Fall through. */
case SYMBOL_SMALL_DATA:
/* Make sure that the offset refers to something within the /* Make sure that the offset refers to something within the
underlying object. This should guarantee that the final underlying object. This should guarantee that the final
PC- or GP-relative offset is within the 16-bit limit. */ PC- or GP-relative offset is within the 16-bit limit. */
...@@ -1012,7 +997,7 @@ mips_symbolic_address_p (enum mips_symbol_type symbol_type, ...@@ -1012,7 +997,7 @@ mips_symbolic_address_p (enum mips_symbol_type symbol_type,
return true; return true;
case SYMBOL_CONSTANT_POOL: case SYMBOL_CONSTANT_POOL:
/* PC-relative addressing is only available for lw, sw, ld and sd. */ /* PC-relative addressing is only available for lw and ld. */
return GET_MODE_SIZE (mode) == 4 || GET_MODE_SIZE (mode) == 8; return GET_MODE_SIZE (mode) == 4 || GET_MODE_SIZE (mode) == 8;
case SYMBOL_GOT_LOCAL: case SYMBOL_GOT_LOCAL:
...@@ -2126,55 +2111,6 @@ m16_nsimm8_8 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED) ...@@ -2126,55 +2111,6 @@ m16_nsimm8_8 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
return m16_check_op (op, (- 0x7f) << 3, 0x80 << 3, 7); return m16_check_op (op, (- 0x7f) << 3, 0x80 << 3, 7);
} }
/* References to the string table on the mips16 only use a small
offset if the function is small. We can't check for LABEL_REF here,
because the offset is always large if the label is before the
referencing instruction. */
int
m16_usym8_4 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
if (GET_CODE (op) == SYMBOL_REF
&& SYMBOL_REF_FLAG (op)
&& cfun->machine->insns_len > 0
&& (cfun->machine->insns_len + get_pool_size () + mips_string_length
< 4 * 0x100))
{
struct string_constant *l;
/* Make sure this symbol is on thelist of string constants to be
output for this function. It is possible that it has already
been output, in which case this requires a large offset. */
for (l = string_constants; l != NULL; l = l->next)
if (strcmp (l->label, XSTR (op, 0)) == 0)
return 1;
}
return 0;
}
int
m16_usym5_4 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
{
if (GET_CODE (op) == SYMBOL_REF
&& SYMBOL_REF_FLAG (op)
&& cfun->machine->insns_len > 0
&& (cfun->machine->insns_len + get_pool_size () + mips_string_length
< 4 * 0x20))
{
struct string_constant *l;
/* Make sure this symbol is on thelist of string constants to be
output for this function. It is possible that it has already
been output, in which case this requires a large offset. */
for (l = string_constants; l != NULL; l = l->next)
if (strcmp (l->label, XSTR (op, 0)) == 0)
return 1;
}
return 0;
}
static bool static bool
mips_rtx_costs (rtx x, int code, int outer_code, int *total) mips_rtx_costs (rtx x, int code, int outer_code, int *total)
{ {
...@@ -6887,8 +6823,6 @@ static void ...@@ -6887,8 +6823,6 @@ static void
mips_output_function_epilogue (FILE *file ATTRIBUTE_UNUSED, mips_output_function_epilogue (FILE *file ATTRIBUTE_UNUSED,
HOST_WIDE_INT size ATTRIBUTE_UNUSED) HOST_WIDE_INT size ATTRIBUTE_UNUSED)
{ {
rtx string;
/* Reinstate the normal $gp. */ /* Reinstate the normal $gp. */
REGNO (pic_offset_table_rtx) = GLOBAL_POINTER_REGNUM; REGNO (pic_offset_table_rtx) = GLOBAL_POINTER_REGNUM;
mips_output_cplocal (); mips_output_cplocal ();
...@@ -6913,26 +6847,6 @@ mips_output_function_epilogue (FILE *file ATTRIBUTE_UNUSED, ...@@ -6913,26 +6847,6 @@ mips_output_function_epilogue (FILE *file ATTRIBUTE_UNUSED,
assemble_name (file, fnname); assemble_name (file, fnname);
fputs ("\n", file); fputs ("\n", file);
} }
while (string_constants != NULL)
{
struct string_constant *next;
next = string_constants->next;
free (string_constants);
string_constants = next;
}
/* If any following function uses the same strings as this one, force
them to refer those strings indirectly. Nearby functions could
refer them using pc-relative addressing, but it isn't safe in
general. For instance, some functions may be placed in sections
other than .text, and we don't know whether they be close enough
to this one. In large files, even other .text functions can be
too far away. */
for (string = mips16_strings; string != 0; string = XEXP (string, 1))
SYMBOL_REF_FLAG (XEXP (string, 0)) = 0;
free_EXPR_LIST_list (&mips16_strings);
} }
/* Emit instructions to restore register REG from slot MEM. */ /* Emit instructions to restore register REG from slot MEM. */
...@@ -7218,6 +7132,8 @@ mips_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED, ...@@ -7218,6 +7132,8 @@ mips_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED,
insn = get_insns (); insn = get_insns ();
insn_locators_initialize (); insn_locators_initialize ();
split_all_insns_noflow (); split_all_insns_noflow ();
if (TARGET_MIPS16)
mips16_lay_out_constants ();
shorten_branches (insn); shorten_branches (insn);
final_start_function (insn, file, 1); final_start_function (insn, file, 1);
final (insn, file, 1, 0); final (insn, file, 1, 0);
...@@ -7298,12 +7214,9 @@ static void ...@@ -7298,12 +7214,9 @@ static void
mips_select_section (tree decl, int reloc, mips_select_section (tree decl, int reloc,
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED) unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
{ {
if ((TARGET_EMBEDDED_PIC || TARGET_MIPS16) if (TARGET_EMBEDDED_PIC && TREE_CODE (decl) == STRING_CST)
&& TREE_CODE (decl) == STRING_CST)
/* For embedded position independent code, put constant strings in the /* For embedded position independent code, put constant strings in the
text section, because the data section is limited to 64K in size. text section, because the data section is limited to 64K in size. */
For mips16 code, put strings in the text section so that a PC
relative load instruction can be used to get their address. */
text_section (); text_section ();
else if (targetm.have_named_sections) else if (targetm.have_named_sections)
default_elf_select_section (decl, reloc, align); default_elf_select_section (decl, reloc, align);
...@@ -7362,13 +7275,7 @@ mips_in_small_data_p (tree decl) ...@@ -7362,13 +7275,7 @@ mips_in_small_data_p (tree decl)
/* When generating embedded PIC code, SYMBOL_REF_FLAG is set for /* When generating embedded PIC code, SYMBOL_REF_FLAG is set for
symbols which are not in the .text section. symbols which are not in the .text section. */
When generating mips16 code, SYMBOL_REF_FLAG is set for string
constants which are put in the .text section. We also record the
total length of all such strings; this total is used to decide
whether we need to split the constant table, and need not be
precisely correct. */
static void static void
mips_encode_section_info (tree decl, rtx rtl, int first) mips_encode_section_info (tree decl, rtx rtl, int first)
...@@ -7383,29 +7290,6 @@ mips_encode_section_info (tree decl, rtx rtl, int first) ...@@ -7383,29 +7290,6 @@ mips_encode_section_info (tree decl, rtx rtl, int first)
if (GET_CODE (symbol) != SYMBOL_REF) if (GET_CODE (symbol) != SYMBOL_REF)
return; return;
if (TARGET_MIPS16)
{
if (first && TREE_CODE (decl) == STRING_CST
/* If this string is from a function, and the function will
go in a gnu linkonce section, then we can't directly
access the string. This gets an assembler error
"unsupported PC relative reference to different section".
If we modify SELECT_SECTION to put it in function_section
instead of text_section, it still fails because
DECL_SECTION_NAME isn't set until assemble_start_function.
If we fix that, it still fails because strings are shared
among multiple functions, and we have cross section
references again. We force it to work by putting string
addresses in the constant pool and indirecting. */
&& (! current_function_decl
|| ! DECL_ONE_ONLY (current_function_decl)))
{
mips16_strings = alloc_EXPR_LIST (0, symbol, mips16_strings);
SYMBOL_REF_FLAG (symbol) = 1;
mips_string_length += TREE_STRING_LENGTH (decl);
}
}
if (TARGET_EMBEDDED_PIC) if (TARGET_EMBEDDED_PIC)
{ {
if (TREE_CODE (decl) == VAR_DECL) if (TREE_CODE (decl) == VAR_DECL)
...@@ -8319,329 +8203,236 @@ build_mips16_call_stub (rtx retval, rtx fn, rtx arg_size, int fp_code) ...@@ -8319,329 +8203,236 @@ build_mips16_call_stub (rtx retval, rtx fn, rtx arg_size, int fp_code)
return 0; return 0;
} }
/* We keep a list of constants we which we have to add to internal /* An entry in the mips16 constant pool. VALUE is the pool constant,
constant tables in the middle of large functions. */ MODE is its mode, and LABEL is the CODE_LABEL associated with it. */
struct constant struct mips16_constant {
{ struct mips16_constant *next;
struct constant *next;
rtx value; rtx value;
rtx label; rtx label;
enum machine_mode mode; enum machine_mode mode;
}; };
/* Add a constant to the list in *PCONSTANTS. */ /* Information about an incomplete mips16 constant pool. FIRST is the
first constant, HIGHEST_ADDRESS is the highest address that the first
byte of the pool can have, and INSN_ADDRESS is the current instruction
address. */
struct mips16_constant_pool {
struct mips16_constant *first;
int highest_address;
int insn_address;
};
/* Add constant VALUE to POOL and return its label. MODE is the
value's mode (used for CONST_INTs, etc.). */
static rtx static rtx
add_constant (struct constant **pconstants, rtx val, enum machine_mode mode) add_constant (struct mips16_constant_pool *pool,
rtx value, enum machine_mode mode)
{ {
struct constant *c; struct mips16_constant **p, *c;
bool first_of_size_p;
for (c = *pconstants; c != NULL; c = c->next) /* See whether the constant is already in the pool. If so, return the
if (mode == c->mode && rtx_equal_p (val, c->value)) existing label, otherwise leave P pointing to the place where the
return c->label; constant should be added.
c = (struct constant *) xmalloc (sizeof *c); Keep the pool sorted in increasing order of mode size so that we can
c->value = val; reduce the number of alignments needed. */
first_of_size_p = true;
for (p = &pool->first; *p != 0; p = &(*p)->next)
{
if (mode == (*p)->mode && rtx_equal_p (value, (*p)->value))
return (*p)->label;
if (GET_MODE_SIZE (mode) < GET_MODE_SIZE ((*p)->mode))
break;
if (GET_MODE_SIZE (mode) == GET_MODE_SIZE ((*p)->mode))
first_of_size_p = false;
}
/* In the worst case, the constant needed by the earliest instruction
will end up at the end of the pool. The entire pool must then be
accessible from that instruction.
When adding the first constant, set the pool's highest address to
the address of the first out-of-range byte. Adjust this address
downwards each time a new constant is added. */
if (pool->first == 0)
/* For pc-relative lw, addiu and daddiu instructions, the base PC value
is the address of the instruction with the lowest two bits clear.
The base PC value for ld has the lowest three bits clear. Assume
the worst case here. */
pool->highest_address = pool->insn_address - (UNITS_PER_WORD - 2) + 0x8000;
pool->highest_address -= GET_MODE_SIZE (mode);
if (first_of_size_p)
/* Take into account the worst possible padding due to alignment. */
pool->highest_address -= GET_MODE_SIZE (mode) - 1;
/* Create a new entry. */
c = (struct mips16_constant *) xmalloc (sizeof *c);
c->value = value;
c->mode = mode; c->mode = mode;
c->label = gen_label_rtx (); c->label = gen_label_rtx ();
c->next = *pconstants; c->next = *p;
*pconstants = c; *p = c;
return c->label; return c->label;
} }
/* Dump out the constants in CONSTANTS after INSN. */ /* Output constant VALUE after instruction INSN and return the last
instruction emitted. MODE is the mode of the constant. */
static void static rtx
dump_constants (struct constant *constants, rtx insn) dump_constants_1 (enum machine_mode mode, rtx value, rtx insn)
{ {
struct constant *c; switch (GET_MODE_CLASS (mode))
int align;
c = constants;
align = 0;
while (c != NULL)
{ {
rtx r; case MODE_INT:
struct constant *next;
switch (GET_MODE_SIZE (c->mode))
{ {
case 1: rtx size = GEN_INT (GET_MODE_SIZE (mode));
align = 0; return emit_insn_after (gen_consttable_int (value, size), insn);
break;
case 2:
if (align < 1)
insn = emit_insn_after (gen_align_2 (), insn);
align = 1;
break;
case 4:
if (align < 2)
insn = emit_insn_after (gen_align_4 (), insn);
align = 2;
break;
default:
if (align < 3)
insn = emit_insn_after (gen_align_8 (), insn);
align = 3;
break;
} }
insn = emit_label_after (c->label, insn); case MODE_FLOAT:
return emit_insn_after (gen_consttable_float (value), insn);
switch (c->mode) case MODE_VECTOR_FLOAT:
case MODE_VECTOR_INT:
{ {
case QImode: int i;
r = gen_consttable_qi (c->value); for (i = 0; i < CONST_VECTOR_NUNITS (value); i++)
break; insn = dump_constants_1 (GET_MODE_INNER (mode),
case HImode: CONST_VECTOR_ELT (value, i), insn);
r = gen_consttable_hi (c->value); return insn;
break;
case SImode:
r = gen_consttable_si (c->value);
break;
case SFmode:
r = gen_consttable_sf (c->value);
break;
case DImode:
r = gen_consttable_di (c->value);
break;
case DFmode:
r = gen_consttable_df (c->value);
break;
default:
abort ();
} }
insn = emit_insn_after (r, insn); default:
abort ();
next = c->next;
free (c);
c = next;
} }
emit_barrier_after (insn);
} }
/* Find the symbol in an address expression. */
static rtx
mips_find_symbol (rtx addr)
{
if (GET_CODE (addr) == MEM)
addr = XEXP (addr, 0);
while (GET_CODE (addr) == CONST)
addr = XEXP (addr, 0);
if (GET_CODE (addr) == SYMBOL_REF || GET_CODE (addr) == LABEL_REF)
return addr;
if (GET_CODE (addr) == PLUS)
{
rtx l1, l2;
l1 = mips_find_symbol (XEXP (addr, 0));
l2 = mips_find_symbol (XEXP (addr, 1));
if (l1 != NULL_RTX && l2 == NULL_RTX)
return l1;
else if (l1 == NULL_RTX && l2 != NULL_RTX)
return l2;
}
return NULL_RTX;
}
/* In mips16 mode, we need to look through the function to check for /* Dump out the constants in CONSTANTS after INSN. */
PC relative loads that are out of range. */
static void static void
mips16_lay_out_constants (void) dump_constants (struct mips16_constant *constants, rtx insn)
{ {
int insns_len, max_internal_pool_size, pool_size, addr, first_constant_ref; struct mips16_constant *c, *next;
rtx first, insn; int align;
struct constant *constants;
first = get_insns ();
/* Scan the function looking for PC relative loads which may be out
of range. All such loads will either be from the constant table,
or be getting the address of a constant string. If the size of
the function plus the size of the constant table is less than
0x8000, then all loads are in range. */
insns_len = 0; align = 0;
for (insn = first; insn; insn = NEXT_INSN (insn)) for (c = constants; c != NULL; c = next)
{ {
insns_len += get_attr_length (insn); /* If necessary, increase the alignment of PC. */
if (align < GET_MODE_SIZE (c->mode))
/* ??? We put switch tables in .text, but we don't define
JUMP_TABLES_IN_TEXT_SECTION, so get_attr_length will not
compute their lengths correctly. */
if (GET_CODE (insn) == JUMP_INSN)
{ {
rtx body; int align_log = floor_log2 (GET_MODE_SIZE (c->mode));
insn = emit_insn_after (gen_align (GEN_INT (align_log)), insn);
body = PATTERN (insn);
if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
insns_len += (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC)
* GET_MODE_SIZE (GET_MODE (body)));
insns_len += GET_MODE_SIZE (GET_MODE (body)) - 1;
} }
} align = GET_MODE_SIZE (c->mode);
/* Store the original value of insns_len in cfun->machine, so
that m16_usym8_4 and m16_usym5_4 can look at it. */
cfun->machine->insns_len = insns_len;
pool_size = get_pool_size ();
if (insns_len + pool_size + mips_string_length < 0x8000)
return;
/* Loop over the insns and figure out what the maximum internal pool insn = emit_label_after (c->label, insn);
size could be. */ insn = dump_constants_1 (c->mode, c->value, insn);
max_internal_pool_size = 0;
for (insn = first; insn; insn = NEXT_INSN (insn))
{
if (GET_CODE (insn) == INSN
&& GET_CODE (PATTERN (insn)) == SET)
{
rtx src;
src = mips_find_symbol (SET_SRC (PATTERN (insn))); next = c->next;
if (src == NULL_RTX) free (c);
continue;
if (CONSTANT_POOL_ADDRESS_P (src))
max_internal_pool_size += GET_MODE_SIZE (get_pool_mode (src));
else if (SYMBOL_REF_FLAG (src))
max_internal_pool_size += GET_MODE_SIZE (Pmode);
}
} }
constants = NULL; emit_barrier_after (insn);
addr = 0; }
first_constant_ref = -1;
for (insn = first; insn; insn = NEXT_INSN (insn)) /* Return the length of instruction INSN.
{
if (GET_CODE (insn) == INSN
&& GET_CODE (PATTERN (insn)) == SET)
{
rtx val, src;
enum machine_mode mode = VOIDmode;
val = NULL_RTX; ??? MIPS16 switch tables go in .text, but we don't define
src = mips_find_symbol (SET_SRC (PATTERN (insn))); JUMP_TABLES_IN_TEXT_SECTION, so get_attr_length will not
if (src != NULL_RTX && CONSTANT_POOL_ADDRESS_P (src)) compute their lengths correctly. */
{
/* ??? This is very conservative, which means that we
will generate too many copies of the constant table.
The only solution would seem to be some form of
relaxing. */
if (((insns_len - addr)
+ max_internal_pool_size
+ get_pool_offset (src))
>= 0x8000)
{
val = get_pool_constant (src);
mode = get_pool_mode (src);
}
max_internal_pool_size -= GET_MODE_SIZE (get_pool_mode (src));
}
else if (src != NULL_RTX && SYMBOL_REF_FLAG (src))
{
/* Including all of mips_string_length is conservative,
and so is including all of max_internal_pool_size. */
if (((insns_len - addr)
+ max_internal_pool_size
+ pool_size
+ mips_string_length)
>= 0x8000)
{
val = src;
mode = Pmode;
}
max_internal_pool_size -= Pmode;
}
if (val != NULL_RTX) static int
mips16_insn_length (rtx insn)
{
if (GET_CODE (insn) == JUMP_INSN)
{ {
rtx lab, newsrc; rtx body = PATTERN (insn);
if (GET_CODE (body) == ADDR_VEC)
return GET_MODE_SIZE (GET_MODE (body)) * XVECLEN (body, 0);
if (GET_CODE (body) == ADDR_DIFF_VEC)
return GET_MODE_SIZE (GET_MODE (body)) * XVECLEN (body, 1);
}
return get_attr_length (insn);
}
/* This PC relative load is out of range. ??? In the /* Rewrite *X so that constant pool references refer to the constant's
case of a string constant, we are only guessing that label instead. DATA points to the constant pool structure. */
it is range, since we don't know the offset of a
particular string constant. */
lab = add_constant (&constants, val, mode); static int
newsrc = gen_rtx_MEM (mode, mips16_rewrite_pool_refs (rtx *x, void *data)
gen_rtx_LABEL_REF (VOIDmode, lab)); {
RTX_UNCHANGING_P (newsrc) = 1; struct mips16_constant_pool *pool = data;
PATTERN (insn) = gen_rtx_SET (VOIDmode, if (GET_CODE (*x) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (*x))
SET_DEST (PATTERN (insn)), *x = gen_rtx_LABEL_REF (Pmode, add_constant (pool,
newsrc); get_pool_constant (*x),
INSN_CODE (insn) = -1; get_pool_mode (*x)));
return 0;
}
if (first_constant_ref < 0) /* Build MIPS16 constant pools. */
first_constant_ref = addr;
}
}
addr += get_attr_length (insn); static void
mips16_lay_out_constants (void)
{
struct mips16_constant_pool pool;
rtx insn, barrier;
/* ??? We put switch tables in .text, but we don't define barrier = 0;
JUMP_TABLES_IN_TEXT_SECTION, so get_attr_length will not memset (&pool, 0, sizeof (pool));
compute their lengths correctly. */ for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
if (GET_CODE (insn) == JUMP_INSN)
{ {
rtx body; /* Rewrite constant pool references in INSN. */
if (INSN_P (insn))
for_each_rtx (&PATTERN (insn), mips16_rewrite_pool_refs, &pool);
body = PATTERN (insn); pool.insn_address += mips16_insn_length (insn);
if (GET_CODE (body) == ADDR_VEC || GET_CODE (body) == ADDR_DIFF_VEC)
addr += (XVECLEN (body, GET_CODE (body) == ADDR_DIFF_VEC)
* GET_MODE_SIZE (GET_MODE (body)));
addr += GET_MODE_SIZE (GET_MODE (body)) - 1;
}
if (GET_CODE (insn) == BARRIER) if (pool.first != NULL)
{ {
/* Output any constants we have accumulated. Note that we /* If there are no natural barriers between the first user of
don't need to change ADDR, since its only use is the pool and the highest acceptable address, we'll need to
subtraction from INSNS_LEN, and both would be changed by create a new instruction to jump around the constant pool.
the same amount. In the worst case, this instruction will be 4 bytes long.
??? If the instructions up to the next barrier reuse a
constant, it would often be better to continue
accumulating. */
if (constants != NULL)
dump_constants (constants, insn);
constants = NULL;
first_constant_ref = -1;
}
if (constants != NULL If it's too late to do this transformation after INSN,
&& (NEXT_INSN (insn) == NULL do it immediately before INSN. */
|| (first_constant_ref >= 0 if (barrier == 0 && pool.insn_address + 4 > pool.highest_address)
&& (((addr - first_constant_ref)
+ 2 /* for alignment */
+ 2 /* for a short jump insn */
+ pool_size)
>= 0x8000))))
{ {
/* If we haven't had a barrier within 0x8000 bytes of a rtx label, jump;
constant reference or we are at the end of the function,
emit a barrier now. */
rtx label, jump, barrier;
label = gen_label_rtx (); label = gen_label_rtx ();
jump = emit_jump_insn_after (gen_jump (label), insn);
jump = emit_jump_insn_before (gen_jump (label), insn);
JUMP_LABEL (jump) = label; JUMP_LABEL (jump) = label;
LABEL_NUSES (label) = 1; LABEL_NUSES (label) = 1;
barrier = emit_barrier_after (jump); barrier = emit_barrier_after (jump);
emit_label_after (label, barrier); emit_label_after (label, barrier);
first_constant_ref = -1; pool.insn_address += 4;
}
} }
/* ??? If we output all references to a constant in internal /* See whether the constant pool is now out of range of the first
constants table, we don't need to output the constant in the real user. If so, output the constants after the previous barrier.
constant table, but we have no way to prevent that. */ Note that any instructions between BARRIER and INSN (inclusive)
will use negative offsets to refer to the pool. */
if (pool.insn_address > pool.highest_address)
{
dump_constants (pool.first, barrier);
pool.first = NULL;
barrier = 0;
}
else if (BARRIER_P (insn))
barrier = insn;
}
}
dump_constants (pool.first, get_last_insn ());
} }
......
...@@ -117,13 +117,11 @@ extern enum processor_type mips_tune; /* which cpu to schedule for */ ...@@ -117,13 +117,11 @@ extern enum processor_type mips_tune; /* which cpu to schedule for */
extern int mips_isa; /* architectural level */ extern int mips_isa; /* architectural level */
extern int mips_abi; /* which ABI to use */ extern int mips_abi; /* which ABI to use */
extern int mips16_hard_float; /* mips16 without -msoft-float */ extern int mips16_hard_float; /* mips16 without -msoft-float */
extern int mips_entry; /* generate entry/exit for mips16 */
extern const char *mips_arch_string; /* for -march=<xxx> */ extern const char *mips_arch_string; /* for -march=<xxx> */
extern const char *mips_tune_string; /* for -mtune=<xxx> */ extern const char *mips_tune_string; /* for -mtune=<xxx> */
extern const char *mips_isa_string; /* for -mips{1,2,3,4} */ extern const char *mips_isa_string; /* for -mips{1,2,3,4} */
extern const char *mips_abi_string; /* for -mabi={32,n32,64} */ extern const char *mips_abi_string; /* for -mabi={32,n32,64} */
extern const char *mips_cache_flush_func;/* for -mflush-func= and -mno-flush-func */ extern const char *mips_cache_flush_func;/* for -mflush-func= and -mno-flush-func */
extern int mips_string_length; /* length of strings for mips16 */
extern const struct mips_cpu_info mips_cpu_info_table[]; extern const struct mips_cpu_info mips_cpu_info_table[];
extern const struct mips_cpu_info *mips_arch_info; extern const struct mips_cpu_info *mips_arch_info;
extern const struct mips_cpu_info *mips_tune_info; extern const struct mips_cpu_info *mips_tune_info;
...@@ -2575,14 +2573,6 @@ typedef struct mips_args { ...@@ -2575,14 +2573,6 @@ typedef struct mips_args {
else \ else \
asm_fprintf ((FILE), "%U%s", (NAME)) asm_fprintf ((FILE), "%U%s", (NAME))
/* The mips16 wants the constant pool to be after the function,
because the PC relative load instructions use unsigned offsets. */
#define CONSTANT_POOL_BEFORE_FUNCTION (! TARGET_MIPS16)
#define ASM_OUTPUT_POOL_EPILOGUE(FILE, FNNAME, FNDECL, SIZE) \
mips_string_length = 0;
/* Specify the machine mode that this machine uses /* Specify the machine mode that this machine uses
for the index in the tablejump instruction. for the index in the tablejump instruction.
??? Using HImode in mips16 mode can cause overflow. */ ??? Using HImode in mips16 mode can cause overflow. */
......
...@@ -35,15 +35,9 @@ ...@@ -35,15 +35,9 @@
(UNSPEC_CPRESTORE 5) (UNSPEC_CPRESTORE 5)
(UNSPEC_EH_RECEIVER 6) (UNSPEC_EH_RECEIVER 6)
(UNSPEC_EH_RETURN 7) (UNSPEC_EH_RETURN 7)
(UNSPEC_CONSTTABLE_QI 8) (UNSPEC_CONSTTABLE_INT 8)
(UNSPEC_CONSTTABLE_HI 9) (UNSPEC_CONSTTABLE_FLOAT 9)
(UNSPEC_CONSTTABLE_SI 10) (UNSPEC_ALIGN 14)
(UNSPEC_CONSTTABLE_DI 11)
(UNSPEC_CONSTTABLE_SF 12)
(UNSPEC_CONSTTABLE_DF 13)
(UNSPEC_ALIGN_2 14)
(UNSPEC_ALIGN_4 15)
(UNSPEC_ALIGN_8 16)
(UNSPEC_HIGH 17) (UNSPEC_HIGH 17)
(UNSPEC_LWL 18) (UNSPEC_LWL 18)
(UNSPEC_LWR 19) (UNSPEC_LWR 19)
...@@ -9147,74 +9141,21 @@ ld\\t%2,%1-%S1(%2)\;daddu\\t%2,%2,$31\\n\\t%*j\\t%2%/" ...@@ -9147,74 +9141,21 @@ ld\\t%2,%1-%S1(%2)\;daddu\\t%2,%2,$31\\n\\t%*j\\t%2%/"
;; .................... ;; ....................
;; ;;
(define_insn "consttable_qi" (define_insn "consttable_int"
[(unspec_volatile [(match_operand:QI 0 "consttable_operand" "=g")] [(unspec_volatile [(match_operand 0 "consttable_operand" "")
UNSPEC_CONSTTABLE_QI)] (match_operand 1 "const_int_operand" "")]
UNSPEC_CONSTTABLE_INT)]
"TARGET_MIPS16" "TARGET_MIPS16"
{ {
assemble_integer (operands[0], 1, BITS_PER_UNIT, 1); assemble_integer (operands[0], INTVAL (operands[1]),
BITS_PER_UNIT * INTVAL (operands[1]), 1);
return ""; return "";
} }
[(set_attr "type" "unknown") [(set (attr "length") (symbol_ref "INTVAL (operands[1])"))])
(set_attr "mode" "QI")
(set_attr "length" "8")])
(define_insn "consttable_hi"
[(unspec_volatile [(match_operand:HI 0 "consttable_operand" "=g")]
UNSPEC_CONSTTABLE_HI)]
"TARGET_MIPS16"
{
assemble_integer (operands[0], 2, BITS_PER_UNIT * 2, 1);
return "";
}
[(set_attr "type" "unknown")
(set_attr "mode" "HI")
(set_attr "length" "8")])
(define_insn "consttable_si"
[(unspec_volatile [(match_operand:SI 0 "consttable_operand" "=g")]
UNSPEC_CONSTTABLE_SI)]
"TARGET_MIPS16"
{
assemble_integer (operands[0], 4, BITS_PER_UNIT * 4, 1);
return "";
}
[(set_attr "type" "unknown")
(set_attr "mode" "SI")
(set_attr "length" "8")])
(define_insn "consttable_di"
[(unspec_volatile [(match_operand:DI 0 "consttable_operand" "=g")]
UNSPEC_CONSTTABLE_DI)]
"TARGET_MIPS16"
{
assemble_integer (operands[0], 8, BITS_PER_UNIT * 8, 1);
return "";
}
[(set_attr "type" "unknown")
(set_attr "mode" "DI")
(set_attr "length" "16")])
(define_insn "consttable_sf"
[(unspec_volatile [(match_operand:SF 0 "consttable_operand" "=g")]
UNSPEC_CONSTTABLE_SF)]
"TARGET_MIPS16"
{
REAL_VALUE_TYPE d;
if (GET_CODE (operands[0]) != CONST_DOUBLE) (define_insn "consttable_float"
abort (); [(unspec_volatile [(match_operand 0 "consttable_operand" "")]
REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]); UNSPEC_CONSTTABLE_FLOAT)]
assemble_real (d, SFmode, GET_MODE_ALIGNMENT (SFmode));
return "";
}
[(set_attr "type" "unknown")
(set_attr "mode" "SF")
(set_attr "length" "8")])
(define_insn "consttable_df"
[(unspec_volatile [(match_operand:DF 0 "consttable_operand" "=g")]
UNSPEC_CONSTTABLE_DF)]
"TARGET_MIPS16" "TARGET_MIPS16"
{ {
REAL_VALUE_TYPE d; REAL_VALUE_TYPE d;
...@@ -9222,36 +9163,18 @@ ld\\t%2,%1-%S1(%2)\;daddu\\t%2,%2,$31\\n\\t%*j\\t%2%/" ...@@ -9222,36 +9163,18 @@ ld\\t%2,%1-%S1(%2)\;daddu\\t%2,%2,$31\\n\\t%*j\\t%2%/"
if (GET_CODE (operands[0]) != CONST_DOUBLE) if (GET_CODE (operands[0]) != CONST_DOUBLE)
abort (); abort ();
REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]); REAL_VALUE_FROM_CONST_DOUBLE (d, operands[0]);
assemble_real (d, DFmode, GET_MODE_ALIGNMENT (DFmode)); assemble_real (d, GET_MODE (operands[0]),
GET_MODE_BITSIZE (GET_MODE (operands[0])));
return ""; return "";
} }
[(set_attr "type" "unknown") [(set (attr "length")
(set_attr "mode" "DF") (symbol_ref "GET_MODE_SIZE (GET_MODE (operands[0]))"))])
(set_attr "length" "16")])
(define_insn "align_2" (define_insn "align"
[(unspec_volatile [(const_int 0)] UNSPEC_ALIGN_2)] [(unspec_volatile [(match_operand 0 "const_int_operand" "")] UNSPEC_ALIGN)]
"TARGET_MIPS16" ""
".align 1" ".align\t%0"
[(set_attr "type" "unknown") [(set (attr "length") (symbol_ref "(1 << INTVAL (operands[0])) - 1"))])
(set_attr "mode" "HI")
(set_attr "length" "8")])
(define_insn "align_4"
[(unspec_volatile [(const_int 0)] UNSPEC_ALIGN_4)]
"TARGET_MIPS16"
".align 2"
[(set_attr "type" "unknown")
(set_attr "mode" "SI")
(set_attr "length" "8")])
(define_insn "align_8"
[(unspec_volatile [(const_int 0)] UNSPEC_ALIGN_8)]
"TARGET_MIPS16"
".align 3"
[(set_attr "type" "unknown")
(set_attr "mode" "DI")
(set_attr "length" "12")])
;; ;;
;; .................... ;; ....................
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment