+2003-06-09 Richard Sandiford <rsandifo@redhat.com>
+
+ PR target/10913
+ * config/mips/mips.h (TARGET_FILE_SWITCHING, NO_DBX_FUNCTION_END,
+ PUT_SDB_SCL, PUT_SDB_INT_VAL, PUT_SDB_VAL, PUT_SDB_ENDEF,
+ PUT_SDB_TYPE, PUT_SDB_SIZE, PUT_SDB_DIM, PUT_SDB_START_DIM,
+ PUT_SDB_NEXT_DIM, PUT_SDB_LAST_DIM, PUT_SDB_TAG, PUT_SDB_SRC_FILE,
+ SDB_GENERATE_FAKE, TEXT_SECTION): Delete.
+ (PUT_SDB_DEF, PUT_SDB_PLAIN_DEF, PUT_SDB_BLOCK_START,
+ PUT_SDB_BLOCK_END, PUT_SDB_FUNCTION_END): Replace use of
+ asm_out_text_file with asm_out_file.
+ * config/mips/iris5gas.h (PUT_SDB_SIZE, PUT_SDB_TYPE): Likewise.
+ * config/mips/elf.h (TEXT_SECTION): Undefine.
+ * config/mips/elf64.h (TEXT_SECION): Undefine.
+ * config/mips/openbsd.h (TEXT_SECION): Undefine.
+ * config/mips/mips.c (asm_out_text_file, asm_out_data_file): Delete.
+ (override_options): Disable small-data optimizations unless using
+ gas or explicit relocations.
+ (mips_asm_file_start, mips_asm_file_end, mips_output_function_epilogue,
+ iris6_asm_named_section, iris6_asm_file_start): Remove code for
+ handling TARGET_FILE_SWITCHING.
+ (copy_file_data): Move into TARGET_IRIX6 block.
+
2003-06-08 Richard Henderson <rth@redhat.com>
* expr.h (EXPAND_MEMORY): New.
#undef TARGET_ASM_NAMED_SECTION
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
-/* Given that Irix has it's own headers, not having TARGET_GAS here
- seems a mistake. If we actually need to be prepared for file
- switching, then we need a custom TARGET_ASM_NAMED_SECTION too. */
-
-#undef TEXT_SECTION
-#define TEXT_SECTION() \
-do { \
- if (TARGET_FILE_SWITCHING) \
- abort (); \
- fputs (TEXT_SECTION_ASM_OP, asm_out_file); \
- fputc ('\n', asm_out_file); \
-} while (0)
-
/* The following macro defines the format used to output the second
operand of the .type assembler directive. Different svr4 assemblers
expect various different forms for this operand. The one given here
#undef TARGET_ASM_NAMED_SECTION
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
-/* Given that Irix has it's own headers, not having TARGET_GAS here
- seems a mistake. If we actually need to be prepared for file
- switching, then we need a custom TARGET_ASM_NAMED_SECTION too. */
-
-#undef TEXT_SECTION
-#define TEXT_SECTION() \
-do { \
- if (TARGET_FILE_SWITCHING) \
- abort (); \
- fputs (TEXT_SECTION_ASM_OP, asm_out_file); \
- fputc ('\n', asm_out_file); \
-} while (0)
-
/* The following macro defines the format used to output the second
operand of the .type assembler directive. Different svr4 assemblers
expect various different forms for this operand. The one given here
avoid conflicting with ELF directives. These are only recognized
by gas, anyhow, not the native assembler. */
#undef PUT_SDB_SIZE
-#define PUT_SDB_SIZE(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.esize\t" HOST_WIDE_INT_PRINT_DEC ";", \
- (HOST_WIDE_INT) (a)); \
+#define PUT_SDB_SIZE(a) \
+do { \
+ fprintf (asm_out_file, "\t.esize\t" HOST_WIDE_INT_PRINT_DEC ";", \
+ (HOST_WIDE_INT) (a)); \
} while (0)
#undef PUT_SDB_TYPE
-#define PUT_SDB_TYPE(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.etype\t0x%x;", (a)); \
+#define PUT_SDB_TYPE(a) \
+do { \
+ fprintf (asm_out_file, "\t.etype\t0x%x;", (a)); \
} while (0)
/* Switch into a generic section. */
static const struct mips_cpu_info *mips_parse_cpu PARAMS ((const char *,
const char *));
static const struct mips_cpu_info *mips_cpu_info_from_isa PARAMS ((int));
-static void copy_file_data PARAMS ((FILE *, FILE *));
#ifdef TARGET_IRIX6
+static void copy_file_data PARAMS ((FILE *, FILE *));
static void iris6_asm_named_section_1 PARAMS ((const char *,
unsigned int,
unsigned int));
handle .files inside of functions. */
int inside_function = 0;
-/* Files to separate the text and the data output, so that all of the data
- can be emitted before the text, which will mean that the assembler will
- generate smaller code, based on the global pointer. */
-FILE *asm_out_data_file;
-FILE *asm_out_text_file;
-
/* Linked list of all externals that are to be emitted when optimizing
for the global pointer if they haven't been declared by the end of
the program with an appropriate .comm or initialization. */
else
mips_abicalls = MIPS_ABICALLS_NO;
+ /* The MIPS and SGI o32 assemblers expect small-data variables to
+ be declared before they are used. Although we once had code to
+ do this, it was very invasive and fragile. It no longer seems
+ worth the effort. */
+ if (!TARGET_EXPLICIT_RELOCS && !TARGET_GAS)
+ {
+ mips_section_threshold = 0;
+ target_flags &= ~MASK_GPOPT;
+ }
+
/* -membedded-pic is a form of PIC code suitable for embedded
systems. All calls are made using PC relative addressing, and
all data is addressed using the $gp register. This requires gas,
if (TARGET_MIPS16)
fprintf (stream, "\t.set\tmips16\n");
- /* This code exists so that we can put all externs before all symbol
- references. This is necessary for the MIPS assembler's global pointer
- optimizations to work. */
- if (TARGET_FILE_SWITCHING)
- {
- asm_out_data_file = stream;
- asm_out_text_file = tmpfile ();
- }
- else
- asm_out_data_file = asm_out_text_file = stream;
-
if (flag_verbose_asm)
fprintf (stream, "\n%s -G value = %d, Arch = %s, ISA = %d\n",
ASM_COMMENT_START,
}
}
}
-
- if (TARGET_FILE_SWITCHING)
- {
- fputs ("\n\t.text\n", asm_out_file);
- copy_file_data (asm_out_file, asm_out_text_file);
- }
-}
-
-static void
-copy_file_data (to, from)
- FILE *to, *from;
-{
- char buffer[8192];
- size_t len;
- rewind (from);
- if (ferror (from))
- fatal_error ("can't rewind temp file: %m");
-
- while ((len = fread (buffer, 1, sizeof (buffer), from)) > 0)
- if (fwrite (buffer, 1, len, to) != len)
- fatal_error ("can't write to output file: %m");
-
- if (ferror (from))
- fatal_error ("can't read from temp file: %m");
-
- if (fclose (from))
- fatal_error ("can't close temp file: %m");
}
/* Emit either a label, .comm, or .lcomm directive, and mark that the symbol
for (string = mips16_strings; string != 0; string = XEXP (string, 1))
SYMBOL_REF_FLAG (XEXP (string, 0)) = 0;
free_EXPR_LIST_list (&mips16_strings);
-
- /* Restore the output file if optimizing the GP (optimizing the GP causes
- the text to be diverted to a tempfile, so that data decls come before
- references to the data). */
- if (TARGET_FILE_SWITCHING)
- {
- asm_out_file = asm_out_data_file;
- data_section ();
- }
}
\f
/* Expand the epilogue into a bunch of separate insns. SIBCALL_P is true
const char *name;
unsigned int flags;
{
- if (TARGET_FILE_SWITCHING && (flags & SECTION_CODE))
- asm_out_file = asm_out_text_file;
iris6_asm_named_section_1 (name, flags, 0);
}
}
/* The Iris assembler does not record alignment from .align directives,
- but takes it from the first .section directive seen. Play yet more
- file switching games so that we can emit a .section directive at the
+ but takes it from the first .section directive seen. Play file
+ switching games so that we can emit a .section directive at the
beginning of the file with the proper alignment attached. */
void
iris_orig_asm_out_file = asm_out_file;
stream = tmpfile ();
asm_out_file = stream;
- asm_out_data_file = stream;
- if (! TARGET_FILE_SWITCHING)
- asm_out_text_file = stream;
iris_section_align_htab = htab_create (31, iris_section_align_entry_hash,
iris_section_align_entry_eq, NULL);
return 1;
}
+static void
+copy_file_data (to, from)
+ FILE *to, *from;
+{
+ char buffer[8192];
+ size_t len;
+ rewind (from);
+ if (ferror (from))
+ fatal_error ("can't rewind temp file: %m");
+
+ while ((len = fread (buffer, 1, sizeof (buffer), from)) > 0)
+ if (fwrite (buffer, 1, len, to) != len)
+ fatal_error ("can't write to output file: %m");
+
+ if (ferror (from))
+ fatal_error ("can't read from temp file: %m");
+
+ if (fclose (from))
+ fatal_error ("can't close temp file: %m");
+}
+
static void
iris6_file_end ()
{
#define TARGET_EXPLICIT_RELOCS (target_flags & MASK_EXPLICIT_RELOCS)
-/* This is true if we must enable the assembly language file switching
- code. */
-
-#define TARGET_FILE_SWITCHING \
- (TARGET_GP_OPT && ! TARGET_GAS && ! TARGET_MIPS16)
-
/* True if the call patterns should be split into a jalr followed by
an instruction to restore $gp. This is only ever true for SVR4 PIC,
in which $gp is call-clobbered. It is only safe to split the load
#define TARGET_GPWORD (TARGET_ABICALLS && (!TARGET_NEWABI || TARGET_GAS))
-
-/* We must disable the function end stabs when doing the file switching trick,
- because the Lscope stabs end up in the wrong place, making it impossible
- to debug the resulting code. */
-#define NO_DBX_FUNCTION_END TARGET_FILE_SWITCHING
-
/* Generate mips16 code */
#define TARGET_MIPS16 (target_flags & MASK_MIPS16)
#define FIND_BASE_TERM(X) mips_delegitimize_address (X)
-/* Overrides for the COFF debug format. */
-#define PUT_SDB_SCL(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.scl\t%d;", (a)); \
-} while (0)
-
-#define PUT_SDB_INT_VAL(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.val\t" HOST_WIDE_INT_PRINT_DEC ";", \
- (HOST_WIDE_INT)(a)); \
-} while (0)
-
-#define PUT_SDB_VAL(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fputs ("\t.val\t", asm_out_text_file); \
- output_addr_const (asm_out_text_file, (a)); \
- fputc (';', asm_out_text_file); \
-} while (0)
-
#define PUT_SDB_DEF(a) \
do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t%s.def\t", \
+ fprintf (asm_out_file, "\t%s.def\t", \
(TARGET_GAS) ? "" : "#"); \
- ASM_OUTPUT_LABELREF (asm_out_text_file, a); \
- fputc (';', asm_out_text_file); \
+ ASM_OUTPUT_LABELREF (asm_out_file, a); \
+ fputc (';', asm_out_file); \
} while (0)
#define PUT_SDB_PLAIN_DEF(a) \
do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t%s.def\t.%s;", \
+ fprintf (asm_out_file, "\t%s.def\t.%s;", \
(TARGET_GAS) ? "" : "#", (a)); \
} while (0)
-#define PUT_SDB_ENDEF \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.endef\n"); \
-} while (0)
-
-#define PUT_SDB_TYPE(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.type\t0x%x;", (a)); \
-} while (0)
-
-#define PUT_SDB_SIZE(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.size\t" HOST_WIDE_INT_PRINT_DEC ";", \
- (HOST_WIDE_INT)(a)); \
-} while (0)
-
-#define PUT_SDB_DIM(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.dim\t%d;", (a)); \
-} while (0)
-
-#ifndef PUT_SDB_START_DIM
-#define PUT_SDB_START_DIM \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.dim\t"); \
-} while (0)
-#endif
-
-#ifndef PUT_SDB_NEXT_DIM
-#define PUT_SDB_NEXT_DIM(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "%d,", a); \
-} while (0)
-#endif
-
-#ifndef PUT_SDB_LAST_DIM
-#define PUT_SDB_LAST_DIM(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "%d;", a); \
-} while (0)
-#endif
-
-#define PUT_SDB_TAG(a) \
-do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, "\t.tag\t"); \
- ASM_OUTPUT_LABELREF (asm_out_text_file, a); \
- fputc (';', asm_out_text_file); \
-} while (0)
-
/* For block start and end, we create labels, so that
later we can figure out where the correct offset is.
The normal .ent/.end serve well enough for functions,
#define PUT_SDB_BLOCK_START(LINE) \
do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, \
+ fprintf (asm_out_file, \
"%sLb%d:\n\t%s.begin\t%sLb%d\t%d\n", \
LOCAL_LABEL_PREFIX, \
sdb_label_count, \
#define PUT_SDB_BLOCK_END(LINE) \
do { \
- extern FILE *asm_out_text_file; \
- fprintf (asm_out_text_file, \
+ fprintf (asm_out_file, \
"%sLe%d:\n\t%s.bend\t%sLe%d\t%d\n", \
LOCAL_LABEL_PREFIX, \
sdb_label_count, \
#define PUT_SDB_FUNCTION_END(LINE) \
do { \
- extern FILE *asm_out_text_file; \
- ASM_OUTPUT_SOURCE_LINE (asm_out_text_file, LINE + sdb_begin_function_line); \
+ ASM_OUTPUT_SOURCE_LINE (asm_out_file, LINE + sdb_begin_function_line); \
} while (0)
#define PUT_SDB_EPILOGUE_END(NAME)
-#define PUT_SDB_SRC_FILE(FILENAME) \
-do { \
- extern FILE *asm_out_text_file; \
- output_file_directive (asm_out_text_file, (FILENAME));\
-} while (0)
-
-#define SDB_GENERATE_FAKE(BUFFER, NUMBER) \
- sprintf ((BUFFER), ".%dfake", (NUMBER));
-
/* Correct the offset of automatic variables and arguments. Note that
the MIPS debug format wants all automatic variables and arguments
to be in terms of the virtual frame pointer (stack pointer before
#define ASM_OUTPUT_EXTERNAL(STREAM,DECL,NAME) \
mips_output_external(STREAM,DECL,NAME)
-/* Play switch file games if we're optimizing the global pointer. */
-
-#undef TEXT_SECTION
-#define TEXT_SECTION() \
-do { \
- extern FILE *asm_out_text_file; \
- if (TARGET_FILE_SWITCHING) \
- asm_out_file = asm_out_text_file; \
- fputs (TEXT_SECTION_ASM_OP, asm_out_file); \
- fputc ('\n', asm_out_file); \
-} while (0)
-
/* This is how to declare a function name. The actual work of
emitting the label is moved to function_prologue, so that we can
#undef TARGET_ASM_NAMED_SECTION
#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section
-/* Not having TARGET_GAS here seems a mistake. If we actually need to
- be prepared for file switching, then we need a custom
- TARGET_ASM_NAMED_SECTION too. */
-
-#undef TEXT_SECTION
-#define TEXT_SECTION() \
-do { \
- if (TARGET_FILE_SWITCHING) \
- abort (); \
- fputs (TEXT_SECTION_ASM_OP, asm_out_file); \
- fputc ('\n', asm_out_file); \
-} while (0)
-
/* collect2 support (Macros for initialization). */
/* Mips default configuration is COFF-only, and confuses collect2. */