#endif
#endif /* BSS_SECTION_ASM_OP */
static void mark_weak (tree);
+static void output_constant_pool (const char *, tree);
\f
/* Well-known sections, each one associated with some sort of *_ASM_OP. */
section *text_section;
/* The next number to use for internal anchor labels. */
static GTY(()) int anchor_labelno;
+/* A pool of constants that can be shared between functions. */
+static GTY(()) struct rtx_constant_pool *shared_constant_pool;
+
/* Helper routines for maintaining section_htab. */
static int
function. DECL describes the function. NAME is the function's name. */
void
-assemble_end_function (tree decl, const char *fnname)
+assemble_end_function (tree decl, const char *fnname ATTRIBUTE_UNUSED)
{
#ifdef ASM_DECLARE_FUNCTION_SIZE
/* We could have switched section in the middle of the function. */
output_addressed_constants (DECL_INITIAL (decl));
/* dbxout.c needs to know this. */
- if (in_section && (in_section->common.flags & SECTION_CODE) != 0)
+ if (sect && (sect->common.flags & SECTION_CODE) != 0)
DECL_IN_TEXT_SECTION (decl) = 1;
/* If the decl is part of an object_block, make sure that the decl
}
\f
+/* Create and return a new rtx constant pool. */
+
+static struct rtx_constant_pool *
+create_constant_pool (void)
+{
+ struct rtx_constant_pool *pool;
+
+ pool = ggc_alloc (sizeof (struct rtx_constant_pool));
+ pool->const_rtx_htab = htab_create_ggc (31, const_desc_rtx_hash,
+ const_desc_rtx_eq, NULL);
+ pool->first = NULL;
+ pool->last = NULL;
+ pool->offset = 0;
+ return pool;
+}
+
/* Initialize constant pool hashing for a new function. */
void
init_varasm_status (struct function *f)
{
struct varasm_status *p;
- struct rtx_constant_pool *pool;
p = ggc_alloc (sizeof (struct varasm_status));
f->varasm = p;
- pool = ggc_alloc (sizeof (struct rtx_constant_pool));
- p->pool = pool;
+ p->pool = create_constant_pool ();
p->deferred_constants = 0;
-
- pool->const_rtx_htab = htab_create_ggc (31, const_desc_rtx_hash,
- const_desc_rtx_eq, NULL);
- pool->first = pool->last = NULL;
- pool->offset = 0;
}
\f
/* Given a MINUS expression, simplify it if both sides
force_const_mem (enum machine_mode mode, rtx x)
{
struct constant_descriptor_rtx *desc, tmp;
- struct rtx_constant_pool *pool = cfun->varasm->pool;
+ struct rtx_constant_pool *pool;
char label[256];
rtx def, symbol;
hashval_t hash;
if (targetm.cannot_force_const_mem (x))
return NULL_RTX;
+ /* Record that this function has used a constant pool entry. */
+ current_function_uses_const_pool = 1;
+
+ /* Decide which pool to use. */
+ pool = (targetm.use_blocks_for_constant_p (mode, x)
+ ? shared_constant_pool
+ : cfun->varasm->pool);
+
/* Lookup the value in the hashtable. */
tmp.constant = x;
tmp.mode = mode;
SYMBOL_REF_FLAGS (symbol) |= SYMBOL_FLAG_LOCAL;
CONSTANT_POOL_ADDRESS_P (symbol) = 1;
SET_SYMBOL_REF_CONSTANT (symbol, desc);
- current_function_uses_const_pool = 1;
/* Construct the MEM. */
desc->mem = def = gen_const_mem (mode, symbol);
be used with for_each_rtx to mark all SYMBOL_REFs in an rtx. */
static int
-mark_constant (rtx *current_rtx, void *data)
+mark_constant (rtx *current_rtx, void *data ATTRIBUTE_UNUSED)
{
- struct rtx_constant_pool *pool = data;
rtx x = *current_rtx;
if (x == NULL_RTX || GET_CODE (x) != SYMBOL_REF)
if (desc->mark == 0)
{
desc->mark = 1;
- for_each_rtx (&desc->constant, mark_constant, pool);
+ for_each_rtx (&desc->constant, mark_constant, NULL);
}
}
else if (TREE_CONSTANT_POOL_ADDRESS_P (x))
deferred strings that are used. */
static void
-mark_constants (struct rtx_constant_pool *pool, rtx insn)
+mark_constants (rtx insn)
{
if (!INSN_P (insn))
return;
{
rtx subinsn = XVECEXP (seq, 0, i);
if (INSN_P (subinsn))
- for_each_rtx (&PATTERN (subinsn), mark_constant, pool);
+ for_each_rtx (&PATTERN (subinsn), mark_constant, NULL);
}
}
else
- for_each_rtx (&PATTERN (insn), mark_constant, pool);
+ for_each_rtx (&PATTERN (insn), mark_constant, NULL);
}
/* Look through the instructions for this function, and mark all the
which have indeed been used. */
static void
-mark_constant_pool (struct rtx_constant_pool *pool)
+mark_constant_pool (void)
{
rtx insn, link;
- if (pool->first == 0 && n_deferred_constants == 0)
+ if (!current_function_uses_const_pool && n_deferred_constants == 0)
return;
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
- mark_constants (pool, insn);
+ mark_constants (insn);
for (link = current_function_epilogue_delay_list;
link;
link = XEXP (link, 1))
- mark_constants (pool, XEXP (link, 0));
+ mark_constants (XEXP (link, 0));
}
-/* Write all the constants in the constant pool. */
+/* Write all the constants in POOL. */
-void
-output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
- tree fndecl ATTRIBUTE_UNUSED)
+static void
+output_constant_pool_contents (struct rtx_constant_pool *pool)
{
- struct rtx_constant_pool *pool = cfun->varasm->pool;
struct constant_descriptor_rtx *desc;
- /* It is possible for gcc to call force_const_mem and then to later
- discard the instructions which refer to the constant. In such a
- case we do not need to output the constant. */
- mark_constant_pool (pool);
-
-#ifdef ASM_OUTPUT_POOL_PROLOGUE
- ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool->offset);
-#endif
-
for (desc = pool->first; desc ; desc = desc->next)
if (desc->mark)
{
output_constant_pool_1 (desc, desc->align);
}
}
+}
+
+/* Mark all constants that are used in the current function, then write
+ out the function's private constant pool. */
+
+static void
+output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
+ tree fndecl ATTRIBUTE_UNUSED)
+{
+ struct rtx_constant_pool *pool = cfun->varasm->pool;
+
+ /* It is possible for gcc to call force_const_mem and then to later
+ discard the instructions which refer to the constant. In such a
+ case we do not need to output the constant. */
+ mark_constant_pool ();
+
+#ifdef ASM_OUTPUT_POOL_PROLOGUE
+ ASM_OUTPUT_POOL_PROLOGUE (asm_out_file, fnname, fndecl, pool->offset);
+#endif
+
+ output_constant_pool_contents (pool);
#ifdef ASM_OUTPUT_POOL_EPILOGUE
ASM_OUTPUT_POOL_EPILOGUE (asm_out_file, fnname, fndecl, pool->offset);
#endif
}
\f
+/* Write the contents of the shared constant pool. */
+
+void
+output_shared_constant_pool (void)
+{
+ output_constant_pool_contents (shared_constant_pool);
+}
+\f
/* Determine what kind of relocations EXP may need. */
int
{
tree max_index, i;
unsigned HOST_WIDE_INT cnt;
- tree index, value;
+ tree index, value, tmp;
/* This code used to attempt to handle string constants that are not
arrays of single-bytes, but nothing else does, so there's no point in
return 0;
/* Compute the total number of array elements. */
- i = size_binop (MINUS_EXPR, convert (sizetype, max_index),
- convert (sizetype,
- TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val)))));
+ tmp = TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val)));
+ i = size_binop (MINUS_EXPR, fold_convert (sizetype, max_index),
+ fold_convert (sizetype, tmp));
i = size_binop (PLUS_EXPR, i, build_int_cst (sizetype, 1));
/* Multiply by the array element unit size to find number of bytes. */
const_desc_eq, NULL);
const_alias_set = new_alias_set ();
+ shared_constant_pool = create_constant_pool ();
#ifdef TEXT_SECTION_ASM_OP
text_section = get_unnamed_section (SECTION_CODE, output_section_asm_op,