[PATCH, PPC 2/2] Fix Darwin bootstrap after split of rs6000.c.

To fix this we need to make the branch islands (or code) visible between
both files.  This keeps the generation side in rs6000.c and moves the
output routine to rs6000-logue.c, placing a reference to the islands
vector in rs6000-internal.h.

2019-06-26  Iain Sandoe  <iain@sandoe.co.uk>

	* config/rs6000/rs6000-internal.h (branch_island): New typedef.
	(branch_islands): New extern.
	* config/rs6000/rs6000-logue.c (macho_branch_islands): Moved from
	* config/rs6000/rs6000.c: .. here.

From-SVN: r272710
This commit is contained in:
Iain Sandoe 2019-06-26 19:04:50 +00:00 committed by Iain Sandoe
parent 6b011221fd
commit 9ff33839fc
4 changed files with 113 additions and 98 deletions

View File

@ -1,3 +1,10 @@
2019-06-26 Iain Sandoe <iain@sandoe.co.uk>
* config/rs6000/rs6000-internal.h (branch_island): New typedef.
(branch_islands): New extern.
* config/rs6000/rs6000-logue.c (macho_branch_islands): Moved from
* config/rs6000/rs6000.c: .. here.
2019-06-26 Iain Sandoe <iain@sandoe.co.uk>
* config.gcc (powerpc*-*-linux*): Move target_gtfiles from here..

View File

@ -110,5 +110,18 @@ quad_address_offset_p (HOST_WIDE_INT offset)
return (IN_RANGE (offset, -32768, 32767) && ((offset) & 0xf) == 0);
}
/* Mach-O (Darwin) support for longcalls, emitted from rs6000-logue.c. */
#if TARGET_MACHO
typedef struct branch_island_d {
tree function_name;
tree label_name;
int line_number;
} branch_island;
extern vec<branch_island, va_gc> *branch_islands;
#endif
#endif

View File

@ -48,6 +48,10 @@
#include "params.h"
#include "alias.h"
#include "rs6000-internal.h"
#if TARGET_MACHO
#include "gstab.h" /* for N_SLINE */
#include "dbxout.h" /* dbxout_ */
#endif
static int rs6000_ra_ever_killed (void);
static void is_altivec_return_reg (rtx, void *);
@ -5061,6 +5065,94 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type)
}
}
#if TARGET_MACHO
/* Generate far-jump branch islands for everything recorded in
branch_islands. Invoked immediately after the last instruction of
the epilogue has been emitted; the branch islands must be appended
to, and contiguous with, the function body. Mach-O stubs are
generated in machopic_output_stub(). */
static void
macho_branch_islands (void)
{
char tmp_buf[512];
while (!vec_safe_is_empty (branch_islands))
{
branch_island *bi = &branch_islands->last ();
const char *label = IDENTIFIER_POINTER (bi->label_name);
const char *name = IDENTIFIER_POINTER (bi->function_name);
char name_buf[512];
/* Cheap copy of the details from the Darwin ASM_OUTPUT_LABELREF(). */
if (name[0] == '*' || name[0] == '&')
strcpy (name_buf, name+1);
else
{
name_buf[0] = '_';
strcpy (name_buf+1, name);
}
strcpy (tmp_buf, "\n");
strcat (tmp_buf, label);
#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
dbxout_stabd (N_SLINE, bi->line_number);
#endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
if (flag_pic)
{
if (TARGET_LINK_STACK)
{
char name[32];
get_ppc476_thunk_name (name);
strcat (tmp_buf, ":\n\tmflr r0\n\tbl ");
strcat (tmp_buf, name);
strcat (tmp_buf, "\n");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic:\n\tmflr r11\n");
}
else
{
strcat (tmp_buf, ":\n\tmflr r0\n\tbcl 20,31,");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic\n");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic:\n\tmflr r11\n");
}
strcat (tmp_buf, "\taddis r11,r11,ha16(");
strcat (tmp_buf, name_buf);
strcat (tmp_buf, " - ");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic)\n");
strcat (tmp_buf, "\tmtlr r0\n");
strcat (tmp_buf, "\taddi r12,r11,lo16(");
strcat (tmp_buf, name_buf);
strcat (tmp_buf, " - ");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic)\n");
strcat (tmp_buf, "\tmtctr r12\n\tbctr\n");
}
else
{
strcat (tmp_buf, ":\n\tlis r12,hi16(");
strcat (tmp_buf, name_buf);
strcat (tmp_buf, ")\n\tori r12,r12,lo16(");
strcat (tmp_buf, name_buf);
strcat (tmp_buf, ")\n\tmtctr r12\n\tbctr");
}
output_asm_insn (tmp_buf, 0);
#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
dbxout_stabd (N_SLINE, bi->line_number);
#endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
branch_islands->pop ();
}
}
#endif
/* Write function epilogue. */
void

View File

@ -52,7 +52,6 @@
#include "explow.h"
#include "expr.h"
#include "output.h"
#include "dbxout.h"
#include "common/common-target.h"
#include "langhooks.h"
#include "reload.h"
@ -75,9 +74,6 @@
#if TARGET_XCOFF
#include "xcoffout.h" /* get declarations of xcoff_*_section_name */
#endif
#if TARGET_MACHO
#include "gstab.h" /* for N_SLINE */
#endif
#include "case-cfn-macros.h"
#include "ppc-auxv.h"
#include "tree-ssa-propagate.h"
@ -1291,7 +1287,6 @@ static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
static rtx rs6000_darwin64_record_arg (CUMULATIVE_ARGS *, const_tree,
bool, bool);
#if TARGET_MACHO
static void macho_branch_islands (void);
static tree get_prev_label (tree);
#endif
static bool rs6000_mode_dependent_address (const_rtx);
@ -27438,14 +27433,7 @@ rs6000_fatal_bad_address (rtx op)
#if TARGET_MACHO
typedef struct branch_island_d {
tree function_name;
tree label_name;
int line_number;
} branch_island;
static vec<branch_island, va_gc> *branch_islands;
vec<branch_island, va_gc> *branch_islands;
/* Remember to generate a branch island for far calls to the given
function. */
@ -27458,91 +27446,6 @@ add_compiler_branch_island (tree label_name, tree function_name,
vec_safe_push (branch_islands, bi);
}
/* Generate far-jump branch islands for everything recorded in
branch_islands. Invoked immediately after the last instruction of
the epilogue has been emitted; the branch islands must be appended
to, and contiguous with, the function body. Mach-O stubs are
generated in machopic_output_stub(). */
static void
macho_branch_islands (void)
{
char tmp_buf[512];
while (!vec_safe_is_empty (branch_islands))
{
branch_island *bi = &branch_islands->last ();
const char *label = IDENTIFIER_POINTER (bi->label_name);
const char *name = IDENTIFIER_POINTER (bi->function_name);
char name_buf[512];
/* Cheap copy of the details from the Darwin ASM_OUTPUT_LABELREF(). */
if (name[0] == '*' || name[0] == '&')
strcpy (name_buf, name+1);
else
{
name_buf[0] = '_';
strcpy (name_buf+1, name);
}
strcpy (tmp_buf, "\n");
strcat (tmp_buf, label);
#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
dbxout_stabd (N_SLINE, bi->line_number);
#endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
if (flag_pic)
{
if (TARGET_LINK_STACK)
{
char name[32];
get_ppc476_thunk_name (name);
strcat (tmp_buf, ":\n\tmflr r0\n\tbl ");
strcat (tmp_buf, name);
strcat (tmp_buf, "\n");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic:\n\tmflr r11\n");
}
else
{
strcat (tmp_buf, ":\n\tmflr r0\n\tbcl 20,31,");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic\n");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic:\n\tmflr r11\n");
}
strcat (tmp_buf, "\taddis r11,r11,ha16(");
strcat (tmp_buf, name_buf);
strcat (tmp_buf, " - ");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic)\n");
strcat (tmp_buf, "\tmtlr r0\n");
strcat (tmp_buf, "\taddi r12,r11,lo16(");
strcat (tmp_buf, name_buf);
strcat (tmp_buf, " - ");
strcat (tmp_buf, label);
strcat (tmp_buf, "_pic)\n");
strcat (tmp_buf, "\tmtctr r12\n\tbctr\n");
}
else
{
strcat (tmp_buf, ":\n\tlis r12,hi16(");
strcat (tmp_buf, name_buf);
strcat (tmp_buf, ")\n\tori r12,r12,lo16(");
strcat (tmp_buf, name_buf);
strcat (tmp_buf, ")\n\tmtctr r12\n\tbctr");
}
output_asm_insn (tmp_buf, 0);
#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
dbxout_stabd (N_SLINE, bi->line_number);
#endif /* DBX_DEBUGGING_INFO || XCOFF_DEBUGGING_INFO */
branch_islands->pop ();
}
}
/* NO_PREVIOUS_DEF checks in the link list whether the function name is
already there or not. */