#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "flags.h"
#include "function.h"
#include "expr.h"
#include "hard-reg-set.h"
#include "regs.h"
#include "real.h"
#include "output.h"
#include "toplev.h"
#include "hashtab.h"
#include "c-pragma.h"
#include "ggc.h"
#include "langhooks.h"
#include "tm_p.h"
#include "debug.h"
#include "target.h"
#include "tree-mudflap.h"
#include "cgraph.h"
#include "cfglayout.h"
#ifdef XCOFF_DEBUGGING_INFO
#include "xcoffout.h"
#endif
const char *first_global_object_name;
const char *weak_global_object_name;
struct addr_const;
struct constant_descriptor_rtx;
struct rtx_constant_pool;
struct varasm_status GTY(())
{
struct rtx_constant_pool *pool;
unsigned int deferred_constants;
};
#define n_deferred_constants (cfun->varasm->deferred_constants)
static GTY(()) int const_labelno;
int size_directive_output;
tree last_assemble_variable_decl;
static bool unlikely_section_label_printed = false;
static char *unlikely_section_label = NULL;
static char *unlikely_text_section_name = NULL;
static HOST_WIDE_INT const_alias_set;
static const char *strip_reg_name (const char *);
static int contains_pointers_p (tree);
#ifdef ASM_OUTPUT_EXTERNAL
static bool incorporeal_function_p (tree);
#endif
static void decode_addr_const (tree, struct addr_const *);
static hashval_t const_desc_hash (const void *);
static int const_desc_eq (const void *, const void *);
static hashval_t const_hash_1 (const tree);
static int compare_constant (const tree, const tree);
static tree copy_constant (tree);
static void output_constant_def_contents (rtx);
static void output_addressed_constants (tree);
static unsigned HOST_WIDE_INT array_size_for_constructor (tree);
static unsigned min_align (unsigned, unsigned);
static void output_constructor (tree, unsigned HOST_WIDE_INT, unsigned int);
static void globalize_decl (tree);
static void maybe_assemble_visibility (tree);
static int in_named_entry_eq (const void *, const void *);
static hashval_t in_named_entry_hash (const void *);
#ifdef BSS_SECTION_ASM_OP
#ifdef ASM_OUTPUT_BSS
static void asm_output_bss (FILE *, tree, const char *,
unsigned HOST_WIDE_INT, unsigned HOST_WIDE_INT);
#endif
#ifdef ASM_OUTPUT_ALIGNED_BSS
static void asm_output_aligned_bss (FILE *, tree, const char *,
unsigned HOST_WIDE_INT, int)
ATTRIBUTE_UNUSED;
#endif
#endif
static bool asm_emit_uninitialised (tree, const char*,
unsigned HOST_WIDE_INT,
unsigned HOST_WIDE_INT);
static void mark_weak (tree);
enum in_section { no_section, in_text, in_unlikely_executed_text, in_data,
in_named
#ifdef BSS_SECTION_ASM_OP
, in_bss
#endif
#ifdef CTORS_SECTION_ASM_OP
, in_ctors
#endif
#ifdef DTORS_SECTION_ASM_OP
, in_dtors
#endif
#ifdef READONLY_DATA_SECTION_ASM_OP
, in_readonly_data
#endif
#ifdef EXTRA_SECTIONS
, EXTRA_SECTIONS
#endif
};
static GTY(()) enum in_section in_section = no_section;
#ifndef IN_NAMED_SECTION
#define IN_NAMED_SECTION(DECL) \
((TREE_CODE (DECL) == FUNCTION_DECL || TREE_CODE (DECL) == VAR_DECL) \
&& DECL_SECTION_NAME (DECL) != NULL_TREE)
#endif
static GTY(()) const char *in_named_name;
struct in_named_entry GTY(())
{
const char *name;
unsigned int flags;
bool declared;
};
static GTY((param_is (struct in_named_entry))) htab_t in_named_htab;
#ifdef EXTRA_SECTION_FUNCTIONS
EXTRA_SECTION_FUNCTIONS
#endif
void
text_section (void)
{
if (in_section != in_text)
{
in_section = in_text;
fprintf (asm_out_file, "%s\n", TEXT_SECTION_ASM_OP);
}
}
void
unlikely_text_section (void)
{
const char *name;
int len;
if (! unlikely_text_section_name)
{
if (DECL_SECTION_NAME (current_function_decl)
&& (strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME
(current_function_decl)),
HOT_TEXT_SECTION_NAME) != 0)
&& (strcmp (TREE_STRING_POINTER (DECL_SECTION_NAME
(current_function_decl)),
UNLIKELY_EXECUTED_TEXT_SECTION_NAME) != 0))
{
name = TREE_STRING_POINTER (DECL_SECTION_NAME
(current_function_decl));
len = strlen (name);
unlikely_text_section_name = xmalloc ((len + 10) * sizeof (char));
strcpy (unlikely_text_section_name, name);
strcat (unlikely_text_section_name, "_unlikely");
}
else
{
len = strlen (UNLIKELY_EXECUTED_TEXT_SECTION_NAME);
unlikely_text_section_name = xmalloc (len+1 * sizeof (char));
strcpy (unlikely_text_section_name,
UNLIKELY_EXECUTED_TEXT_SECTION_NAME);
}
}
if ((in_section != in_unlikely_executed_text)
&& (in_section != in_named
|| strcmp (in_named_name, unlikely_text_section_name) != 0))
{
named_section (NULL_TREE, unlikely_text_section_name, 0);
in_section = in_unlikely_executed_text;
if (!unlikely_section_label_printed)
{
ASM_OUTPUT_LABEL (asm_out_file, unlikely_section_label);
unlikely_section_label_printed = true;
}
}
}
void
data_section (void)
{
if (in_section != in_data)
{
in_section = in_data;
fprintf (asm_out_file, "%s\n", DATA_SECTION_ASM_OP);
}
}
void
readonly_data_section (void)
{
#ifdef READONLY_DATA_SECTION
READONLY_DATA_SECTION ();
#else
#ifdef READONLY_DATA_SECTION_ASM_OP
if (in_section != in_readonly_data)
{
in_section = in_readonly_data;
fputs (READONLY_DATA_SECTION_ASM_OP, asm_out_file);
fputc ('\n', asm_out_file);
}
#else
text_section ();
#endif
#endif
}
int
in_text_section (void)
{
return in_section == in_text;
}
int
in_unlikely_text_section (void)
{
bool ret_val;
ret_val = ((in_section == in_unlikely_executed_text)
|| (in_section == in_named
&& unlikely_text_section_name
&& strcmp (in_named_name, unlikely_text_section_name) == 0));
return ret_val;
}
int
in_data_section (void)
{
return in_section == in_data;
}
static int
in_named_entry_eq (const void *p1, const void *p2)
{
const struct in_named_entry *old = p1;
const char *new = p2;
return strcmp (old->name, new) == 0;
}
static hashval_t
in_named_entry_hash (const void *p)
{
const struct in_named_entry *old = p;
return htab_hash_string (old->name);
}
static unsigned int
get_named_section_flags (const char *section)
{
struct in_named_entry **slot;
slot = (struct in_named_entry **)
htab_find_slot_with_hash (in_named_htab, section,
htab_hash_string (section), NO_INSERT);
return slot ? (*slot)->flags : 0;
}
bool
named_section_first_declaration (const char *name)
{
struct in_named_entry **slot;
slot = (struct in_named_entry **)
htab_find_slot_with_hash (in_named_htab, name,
htab_hash_string (name), NO_INSERT);
if (! (*slot)->declared)
{
(*slot)->declared = true;
return true;
}
else
{
return false;
}
}
bool
set_named_section_flags (const char *section, unsigned int flags)
{
struct in_named_entry **slot, *entry;
slot = (struct in_named_entry **)
htab_find_slot_with_hash (in_named_htab, section,
htab_hash_string (section), INSERT);
entry = *slot;
if (!entry)
{
entry = ggc_alloc (sizeof (*entry));
*slot = entry;
entry->name = ggc_strdup (section);
entry->flags = flags;
entry->declared = false;
}
else if (entry->flags != flags)
return false;
return true;
}
void
named_section_real (const char *name, unsigned int flags, tree decl)
{
if (in_section != in_named || strcmp (name, in_named_name) != 0)
{
if (! set_named_section_flags (name, flags))
abort ();
targetm.asm_out.named_section (name, flags, decl);
if (flags & SECTION_FORGET)
in_section = no_section;
else
{
in_named_name = ggc_strdup (name);
in_section = in_named;
}
}
}
void
named_section (tree decl, const char *name, int reloc)
{
unsigned int flags;
if (decl != NULL_TREE && !DECL_P (decl))
abort ();
if (name == NULL)
name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
if (strcmp (name, UNLIKELY_EXECUTED_TEXT_SECTION_NAME) == 0
&& !unlikely_text_section_name)
{
unlikely_text_section_name = xmalloc
(strlen (UNLIKELY_EXECUTED_TEXT_SECTION_NAME) + 1
* sizeof (char));
strcpy (unlikely_text_section_name,
UNLIKELY_EXECUTED_TEXT_SECTION_NAME);
}
flags = targetm.section_type_flags (decl, name, reloc);
if (decl && ! set_named_section_flags (name, flags))
{
flags = get_named_section_flags (name);
if ((flags & SECTION_OVERRIDE) == 0)
error ("%J%D causes a section type conflict", decl, decl);
}
named_section_real (name, flags, decl);
}
void
resolve_unique_section (tree decl, int reloc ATTRIBUTE_UNUSED,
int flag_function_or_data_sections)
{
if (DECL_SECTION_NAME (decl) == NULL_TREE
&& targetm.have_named_sections
&& (flag_function_or_data_sections
|| DECL_ONE_ONLY (decl)))
targetm.asm_out.unique_section (decl, reloc);
}
#ifdef BSS_SECTION_ASM_OP
void
bss_section (void)
{
if (in_section != in_bss)
{
fprintf (asm_out_file, "%s\n", BSS_SECTION_ASM_OP);
in_section = in_bss;
}
}
#ifdef ASM_OUTPUT_BSS
static void
asm_output_bss (FILE *file, tree decl ATTRIBUTE_UNUSED,
const char *name,
unsigned HOST_WIDE_INT size ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT rounded)
{
targetm.asm_out.globalize_label (file, name);
bss_section ();
#ifdef ASM_DECLARE_OBJECT_NAME
last_assemble_variable_decl = decl;
ASM_DECLARE_OBJECT_NAME (file, name, decl);
#else
ASM_OUTPUT_LABEL (file, name);
#endif
ASM_OUTPUT_SKIP (file, rounded ? rounded : 1);
}
#endif
#ifdef ASM_OUTPUT_ALIGNED_BSS
static void
asm_output_aligned_bss (FILE *file, tree decl ATTRIBUTE_UNUSED,
const char *name, unsigned HOST_WIDE_INT size,
int align)
{
bss_section ();
ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT));
#ifdef ASM_DECLARE_OBJECT_NAME
last_assemble_variable_decl = decl;
ASM_DECLARE_OBJECT_NAME (file, name, decl);
#else
ASM_OUTPUT_LABEL (file, name);
#endif
ASM_OUTPUT_SKIP (file, size ? size : 1);
}
#endif
#endif
void
function_section (tree decl)
{
if (decl == NULL_TREE)
text_section ();
else
{
rtx insns = cfun && cfun->emit ? get_insns () : 0;
bool unlikely = insns && scan_ahead_for_unlikely_executed_note (insns);
#ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
targetm.asm_out.select_section (decl, unlikely, DECL_ALIGN (decl));
#else
if (unlikely)
unlikely_text_section ();
else if (DECL_SECTION_NAME (decl))
named_section (decl, 0, 0);
else
text_section ();
#endif
}
}
void
default_function_rodata_section (tree decl)
{
if (decl != NULL_TREE && DECL_SECTION_NAME (decl))
{
const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
if (DECL_ONE_ONLY (decl) && strncmp (name, ".gnu.linkonce.t.", 16) == 0)
{
size_t len = strlen (name) + 1;
char *rname = alloca (len);
memcpy (rname, name, len);
rname[14] = 'r';
named_section_real (rname, SECTION_LINKONCE, decl);
return;
}
else if (flag_function_sections && flag_data_sections
&& strncmp (name, ".text.", 6) == 0)
{
size_t len = strlen (name) + 1;
char *rname = alloca (len + 2);
memcpy (rname, ".rodata", 7);
memcpy (rname + 7, name + 5, len - 5);
named_section_flags (rname, 0);
return;
}
}
readonly_data_section ();
}
void
default_no_function_rodata_section (tree decl ATTRIBUTE_UNUSED)
{
readonly_data_section ();
}
void
variable_section (tree decl, int reloc)
{
if (IN_NAMED_SECTION (decl))
named_section (decl, NULL, reloc);
else
targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl));
}
void
mergeable_string_section (tree decl ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
unsigned int flags ATTRIBUTE_UNUSED)
{
if (HAVE_GAS_SHF_MERGE && flag_merge_constants
&& TREE_CODE (decl) == STRING_CST
&& TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
&& align <= 256
&& TREE_STRING_LENGTH (decl) >= int_size_in_bytes (TREE_TYPE (decl)))
{
enum machine_mode mode;
unsigned int modesize;
const char *str;
int i, j, len, unit;
char name[30];
mode = TYPE_MODE (TREE_TYPE (TREE_TYPE (decl)));
modesize = GET_MODE_BITSIZE (mode);
if (modesize >= 8 && modesize <= 256
&& (modesize & (modesize - 1)) == 0)
{
if (align < modesize)
align = modesize;
str = TREE_STRING_POINTER (decl);
len = TREE_STRING_LENGTH (decl);
unit = GET_MODE_SIZE (mode);
for (i = 0; i < len; i += unit)
{
for (j = 0; j < unit; j++)
if (str[i + j] != '\0')
break;
if (j == unit)
break;
}
if (i == len - unit)
{
sprintf (name, ".rodata.str%d.%d", modesize / 8,
(int) (align / 8));
flags |= (modesize / 8) | SECTION_MERGE | SECTION_STRINGS;
if (!i && modesize < align)
{
#ifdef ASM_OUTPUT_SECTION_START
named_section_flags (name, flags);
ASM_OUTPUT_SECTION_START (asm_out_file);
#else
readonly_data_section ();
#endif
return;
}
named_section_flags (name, flags);
return;
}
}
}
readonly_data_section ();
}
void
mergeable_constant_section (enum machine_mode mode ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED,
unsigned int flags ATTRIBUTE_UNUSED)
{
unsigned int modesize = GET_MODE_BITSIZE (mode);
if (HAVE_GAS_SHF_MERGE && flag_merge_constants
&& mode != VOIDmode
&& mode != BLKmode
&& modesize <= align
&& align >= 8
&& align <= 256
&& (align & (align - 1)) == 0)
{
char name[24];
sprintf (name, ".rodata.cst%d", (int) (align / 8));
flags |= (align / 8) | SECTION_MERGE;
named_section_flags (name, flags);
return;
}
readonly_data_section ();
}
static const char *
strip_reg_name (const char *name)
{
#ifdef REGISTER_PREFIX
if (!strncmp (name, REGISTER_PREFIX, strlen (REGISTER_PREFIX)))
name += strlen (REGISTER_PREFIX);
#endif
if (name[0] == '%' || name[0] == '#')
name++;
return name;
}
void
set_user_assembler_name (tree decl, const char *name)
{
char *starred = alloca (strlen (name) + 2);
starred[0] = '*';
strcpy (starred + 1, name);
change_decl_assembler_name (decl, get_identifier (starred));
SET_DECL_RTL (decl, NULL_RTX);
}
int
decode_reg_name (const char *asmspec)
{
if (asmspec != 0)
{
int i;
asmspec = strip_reg_name (asmspec);
for (i = strlen (asmspec) - 1; i >= 0; i--)
if (! ISDIGIT (asmspec[i]))
break;
if (asmspec[0] != 0 && i < 0)
{
i = atoi (asmspec);
if (i < FIRST_PSEUDO_REGISTER && i >= 0)
return i;
else
return -2;
}
for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
if (reg_names[i][0]
&& ! strcmp (asmspec, strip_reg_name (reg_names[i])))
return i;
#ifdef ADDITIONAL_REGISTER_NAMES
{
static const struct { const char *const name; const int number; } table[]
= ADDITIONAL_REGISTER_NAMES;
for (i = 0; i < (int) ARRAY_SIZE (table); i++)
if (! strcmp (asmspec, table[i].name))
return table[i].number;
}
#endif
if (!strcmp (asmspec, "memory"))
return -4;
if (!strcmp (asmspec, "cc"))
return -3;
return -2;
}
return -1;
}
void
make_decl_rtl (tree decl)
{
const char *name = 0;
int reg_number;
rtx x;
if (TREE_CODE (decl) == PARM_DECL
|| TREE_CODE (decl) == RESULT_DECL
|| (TREE_CODE (decl) == VAR_DECL
&& !TREE_STATIC (decl)
&& !TREE_PUBLIC (decl)
&& !DECL_EXTERNAL (decl)
&& !DECL_REGISTER (decl)))
abort ();
else if (TREE_CODE (decl) == TYPE_DECL
|| TREE_CODE (decl) == LABEL_DECL)
abort ();
if (DECL_RTL_SET_P (decl))
{
if (GET_MODE (DECL_RTL (decl)) != DECL_MODE (decl))
SET_DECL_RTL (decl, adjust_address_nv (DECL_RTL (decl),
DECL_MODE (decl), 0));
if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
return;
targetm.encode_section_info (decl, DECL_RTL (decl), false);
if (flag_mudflap && TREE_CODE (decl) == VAR_DECL)
mudflap_enqueue_decl (decl);
return;
}
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
{
reg_number = decode_reg_name (name);
if (reg_number == -1)
error ("%Jregister name not specified for %qD", decl, decl);
else if (reg_number < 0)
error ("%Jinvalid register name for %qD", decl, decl);
else if (TYPE_MODE (TREE_TYPE (decl)) == BLKmode)
error ("%Jdata type of %qD isn%'t suitable for a register",
decl, decl);
else if (! HARD_REGNO_MODE_OK (reg_number, TYPE_MODE (TREE_TYPE (decl))))
error ("%Jregister specified for %qD isn%'t suitable for data type",
decl, decl);
else
{
int nregs;
if (DECL_INITIAL (decl) != 0 && TREE_STATIC (decl))
{
DECL_INITIAL (decl) = 0;
error ("global register variable has initial value");
}
if (TREE_THIS_VOLATILE (decl))
warning ("volatile register variables don%'t "
"work as you might wish");
SET_DECL_RTL (decl, gen_rtx_raw_REG (DECL_MODE (decl), reg_number));
ORIGINAL_REGNO (DECL_RTL (decl)) = reg_number;
REG_USERVAR_P (DECL_RTL (decl)) = 1;
if (TREE_STATIC (decl))
{
#ifdef ASM_DECLARE_REGISTER_GLOBAL
name = IDENTIFIER_POINTER (DECL_NAME (decl));
ASM_DECLARE_REGISTER_GLOBAL (asm_out_file, decl, reg_number, name);
#endif
nregs = hard_regno_nregs[reg_number][DECL_MODE (decl)];
while (nregs > 0)
globalize_reg (reg_number + --nregs);
}
return;
}
}
else if (name[0] == '*')
{
#ifdef REGISTER_PREFIX
if (strlen (REGISTER_PREFIX) != 0)
{
reg_number = decode_reg_name (name);
if (reg_number >= 0 || reg_number == -3)
error ("%Jregister name given for non-register variable %qD", decl, decl);
}
#endif
}
if (TREE_CODE (decl) == VAR_DECL
&& DECL_SECTION_NAME (decl) != NULL_TREE
&& DECL_INITIAL (decl) == NULL_TREE
&& DECL_COMMON (decl))
DECL_COMMON (decl) = 0;
if (TREE_CODE (decl) == VAR_DECL && DECL_WEAK (decl))
DECL_COMMON (decl) = 0;
x = gen_rtx_SYMBOL_REF (Pmode, name);
SYMBOL_REF_WEAK (x) = DECL_WEAK (decl);
SYMBOL_REF_DECL (x) = decl;
x = gen_rtx_MEM (DECL_MODE (decl), x);
if (TREE_CODE (decl) != FUNCTION_DECL)
set_mem_attributes (x, decl, 1);
SET_DECL_RTL (decl, x);
targetm.encode_section_info (decl, DECL_RTL (decl), true);
if (flag_mudflap && TREE_CODE (decl) == VAR_DECL)
mudflap_enqueue_decl (decl);
}
void
make_var_volatile (tree var)
{
if (!MEM_P (DECL_RTL (var)))
abort ();
MEM_VOLATILE_P (DECL_RTL (var)) = 1;
}
void
assemble_asm (tree string)
{
app_enable ();
if (TREE_CODE (string) == ADDR_EXPR)
string = TREE_OPERAND (string, 0);
fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string));
}
void
default_stabs_asm_out_destructor (rtx symbol ATTRIBUTE_UNUSED,
int priority ATTRIBUTE_UNUSED)
{
#if defined DBX_DEBUGGING_INFO || defined XCOFF_DEBUGGING_INFO
dbxout_begin_simple_stabs ("___DTOR_LIST__", 22 );
dbxout_stab_value_label (XSTR (symbol, 0));
#else
sorry ("global destructors not supported on this target");
#endif
}
void
default_named_section_asm_out_destructor (rtx symbol, int priority)
{
const char *section = ".dtors";
char buf[16];
if (priority != DEFAULT_INIT_PRIORITY)
{
sprintf (buf, ".dtors.%.5u",
MAX_INIT_PRIORITY - priority);
section = buf;
}
named_section_flags (section, SECTION_WRITE);
assemble_align (POINTER_SIZE);
assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
}
#ifdef DTORS_SECTION_ASM_OP
void
dtors_section (void)
{
if (in_section != in_dtors)
{
in_section = in_dtors;
fputs (DTORS_SECTION_ASM_OP, asm_out_file);
fputc ('\n', asm_out_file);
}
}
void
default_dtor_section_asm_out_destructor (rtx symbol,
int priority ATTRIBUTE_UNUSED)
{
dtors_section ();
assemble_align (POINTER_SIZE);
assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
}
#endif
void
default_stabs_asm_out_constructor (rtx symbol ATTRIBUTE_UNUSED,
int priority ATTRIBUTE_UNUSED)
{
#if defined DBX_DEBUGGING_INFO || defined XCOFF_DEBUGGING_INFO
dbxout_begin_simple_stabs ("___CTOR_LIST__", 22 );
dbxout_stab_value_label (XSTR (symbol, 0));
#else
sorry ("global constructors not supported on this target");
#endif
}
void
default_named_section_asm_out_constructor (rtx symbol, int priority)
{
const char *section = ".ctors";
char buf[16];
if (priority != DEFAULT_INIT_PRIORITY)
{
sprintf (buf, ".ctors.%.5u",
MAX_INIT_PRIORITY - priority);
section = buf;
}
named_section_flags (section, SECTION_WRITE);
assemble_align (POINTER_SIZE);
assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
}
#ifdef CTORS_SECTION_ASM_OP
void
ctors_section (void)
{
if (in_section != in_ctors)
{
in_section = in_ctors;
fputs (CTORS_SECTION_ASM_OP, asm_out_file);
fputc ('\n', asm_out_file);
}
}
void
default_ctor_section_asm_out_constructor (rtx symbol,
int priority ATTRIBUTE_UNUSED)
{
ctors_section ();
assemble_align (POINTER_SIZE);
assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
}
#endif
#ifndef CONSTANT_POOL_BEFORE_FUNCTION
#define CONSTANT_POOL_BEFORE_FUNCTION 1
#endif
void
notice_global_symbol (tree decl)
{
const char **type = &first_global_object_name;
if (first_global_object_name
|| !TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
|| !DECL_NAME (decl)
|| (TREE_CODE (decl) != FUNCTION_DECL
&& (TREE_CODE (decl) != VAR_DECL
|| (DECL_COMMON (decl)
&& (DECL_INITIAL (decl) == 0
|| DECL_INITIAL (decl) == error_mark_node))))
|| !MEM_P (DECL_RTL (decl)))
return;
if (DECL_WEAK (decl) || DECL_ONE_ONLY (decl))
type = &weak_global_object_name;
if (!*type)
{
const char *p;
char *name;
rtx decl_rtl = DECL_RTL (decl);
p = targetm.strip_name_encoding (XSTR (XEXP (decl_rtl, 0), 0));
name = xstrdup (p);
*type = name;
}
}
void
assemble_start_function (tree decl, const char *fnname)
{
int align;
if (unlikely_text_section_name)
free (unlikely_text_section_name);
unlikely_section_label_printed = false;
unlikely_text_section_name = NULL;
unlikely_section_label = reconcat (unlikely_section_label,
fnname, ".unlikely_section", NULL);
app_disable ();
if (CONSTANT_POOL_BEFORE_FUNCTION)
output_constant_pool (fnname, decl);
if (flag_reorder_blocks_and_partition)
{
unlikely_section_label_printed = true;
unlikely_text_section ();
assemble_align (FUNCTION_BOUNDARY);
unlikely_section_label_printed = false;
}
resolve_unique_section (decl, 0, flag_function_sections);
function_section (decl);
align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);
if (align < force_align_functions_log)
align = force_align_functions_log;
if (align > 0)
{
ASM_OUTPUT_ALIGN (asm_out_file, align);
}
if (align_functions_log > align
&& cfun->function_frequency != FUNCTION_FREQUENCY_UNLIKELY_EXECUTED)
{
#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN
ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file,
align_functions_log, align_functions - 1);
#else
ASM_OUTPUT_ALIGN (asm_out_file, align_functions_log);
#endif
}
#ifdef ASM_OUTPUT_FUNCTION_PREFIX
ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);
#endif
(*debug_hooks->begin_function) (decl);
if (TREE_PUBLIC (decl))
{
notice_global_symbol (decl);
globalize_decl (decl);
maybe_assemble_visibility (decl);
}
if (DECL_PRESERVE_P (decl))
targetm.asm_out.mark_decl_preserved (fnname);
#ifdef ASM_DECLARE_FUNCTION_NAME
ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);
#else
ASM_OUTPUT_LABEL (asm_out_file, fnname);
#endif
if (in_unlikely_text_section ()
&& !unlikely_section_label_printed)
{
ASM_OUTPUT_LABEL (asm_out_file, unlikely_section_label);
unlikely_section_label_printed = true;
}
}
void
assemble_end_function (tree decl, const char *fnname)
{
#ifdef ASM_DECLARE_FUNCTION_SIZE
ASM_DECLARE_FUNCTION_SIZE (asm_out_file, fnname, decl);
#endif
if (! CONSTANT_POOL_BEFORE_FUNCTION)
{
output_constant_pool (fnname, decl);
function_section (decl);
}
}
void
assemble_zeros (unsigned HOST_WIDE_INT size)
{
if (flag_syntax_only)
return;
#ifdef ASM_NO_SKIP_IN_TEXT
if ((ASM_NO_SKIP_IN_TEXT && in_text_section ())
|| (ASM_NO_SKIP_IN_TEXT && in_unlikely_text_section ()))
{
unsigned HOST_WIDE_INT i;
for (i = 0; i < size; i++)
assemble_integer (const0_rtx, 1, BITS_PER_UNIT, 1);
}
else
#endif
if (size > 0)
ASM_OUTPUT_SKIP (asm_out_file, size);
}
void
assemble_align (int align)
{
if (align > BITS_PER_UNIT)
{
ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
}
}
void
assemble_string (const char *p, int size)
{
int pos = 0;
int maximum = 2000;
while (pos < size)
{
int thissize = size - pos;
if (thissize > maximum)
thissize = maximum;
ASM_OUTPUT_ASCII (asm_out_file, p, thissize);
pos += thissize;
p += thissize;
}
}
#if defined ASM_OUTPUT_ALIGNED_DECL_LOCAL
#define ASM_EMIT_LOCAL(decl, name, size, rounded) \
ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, decl, name, size, DECL_ALIGN (decl))
#else
#if defined ASM_OUTPUT_ALIGNED_LOCAL
#define ASM_EMIT_LOCAL(decl, name, size, rounded) \
ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, DECL_ALIGN (decl))
#else
#define ASM_EMIT_LOCAL(decl, name, size, rounded) \
ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded)
#endif
#endif
#if defined ASM_OUTPUT_ALIGNED_BSS
#define ASM_EMIT_BSS(decl, name, size, rounded) \
ASM_OUTPUT_ALIGNED_BSS (asm_out_file, decl, name, size, DECL_ALIGN (decl))
#else
#if defined ASM_OUTPUT_BSS
#define ASM_EMIT_BSS(decl, name, size, rounded) \
ASM_OUTPUT_BSS (asm_out_file, decl, name, size, rounded)
#else
#undef ASM_EMIT_BSS
#endif
#endif
#if defined ASM_OUTPUT_ALIGNED_DECL_COMMON
#define ASM_EMIT_COMMON(decl, name, size, rounded) \
ASM_OUTPUT_ALIGNED_DECL_COMMON (asm_out_file, decl, name, size, DECL_ALIGN (decl))
#else
#if defined ASM_OUTPUT_ALIGNED_COMMON
#define ASM_EMIT_COMMON(decl, name, size, rounded) \
ASM_OUTPUT_ALIGNED_COMMON (asm_out_file, name, size, DECL_ALIGN (decl))
#else
#define ASM_EMIT_COMMON(decl, name, size, rounded) \
ASM_OUTPUT_COMMON (asm_out_file, name, size, rounded)
#endif
#endif
static bool
asm_emit_uninitialised (tree decl, const char *name,
unsigned HOST_WIDE_INT size ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED)
{
enum
{
asm_dest_common,
asm_dest_bss,
asm_dest_local
}
destination = asm_dest_local;
if (TREE_PUBLIC (decl))
{
if (!DECL_COMMON (decl))
#ifdef ASM_EMIT_BSS
destination = asm_dest_bss;
#else
return false;
#endif
else
destination = asm_dest_common;
}
if (destination != asm_dest_common)
{
resolve_unique_section (decl, 0, flag_data_sections);
if (DECL_SECTION_NAME (decl))
return false;
}
if (destination == asm_dest_bss)
globalize_decl (decl);
if (flag_shared_data)
{
switch (destination)
{
#ifdef ASM_OUTPUT_SHARED_BSS
case asm_dest_bss:
ASM_OUTPUT_SHARED_BSS (asm_out_file, decl, name, size, rounded);
return;
#endif
#ifdef ASM_OUTPUT_SHARED_COMMON
case asm_dest_common:
ASM_OUTPUT_SHARED_COMMON (asm_out_file, name, size, rounded);
return;
#endif
#ifdef ASM_OUTPUT_SHARED_LOCAL
case asm_dest_local:
ASM_OUTPUT_SHARED_LOCAL (asm_out_file, name, size, rounded);
return;
#endif
default:
break;
}
}
switch (destination)
{
#ifdef ASM_EMIT_BSS
case asm_dest_bss:
ASM_EMIT_BSS (decl, name, size, rounded);
break;
#endif
case asm_dest_common:
ASM_EMIT_COMMON (decl, name, size, rounded);
break;
case asm_dest_local:
ASM_EMIT_LOCAL (decl, name, size, rounded);
break;
default:
abort ();
}
return true;
}
void
assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
int at_end ATTRIBUTE_UNUSED, int dont_output_data)
{
const char *name;
unsigned int align;
int reloc = 0;
rtx decl_rtl;
if (lang_hooks.decls.prepare_assemble_variable)
lang_hooks.decls.prepare_assemble_variable (decl);
last_assemble_variable_decl = 0;
if (DECL_EXTERNAL (decl))
return;
if (TREE_CODE (decl) == FUNCTION_DECL)
return;
if (DECL_RTL_SET_P (decl) && REG_P (DECL_RTL (decl)))
{
TREE_ASM_WRITTEN (decl) = 1;
return;
}
if (DECL_SIZE (decl) == 0)
layout_decl (decl, 0);
if (!dont_output_data && DECL_SIZE (decl) == 0)
{
error ("%Jstorage size of %qD isn%'t known", decl, decl);
TREE_ASM_WRITTEN (decl) = 1;
return;
}
if (TREE_ASM_WRITTEN (decl))
return;
decl_rtl = DECL_RTL (decl);
TREE_ASM_WRITTEN (decl) = 1;
if (flag_syntax_only)
return;
if (DECL_DUPLICATE_DECL (decl))
return;
app_disable ();
if (! dont_output_data
&& ! host_integerp (DECL_SIZE_UNIT (decl), 1))
{
error ("%Jsize of variable %qD is too large", decl, decl);
return;
}
name = XSTR (XEXP (decl_rtl, 0), 0);
if (TREE_PUBLIC (decl) && DECL_NAME (decl))
notice_global_symbol (decl);
align = DECL_ALIGN (decl);
if (dont_output_data && DECL_SIZE (decl) == 0
&& TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
align = MAX (align, TYPE_ALIGN (TREE_TYPE (TREE_TYPE (decl))));
if (align > MAX_OFILE_ALIGNMENT)
{
warning ("%Jalignment of %qD is greater than maximum object "
"file alignment. Using %d", decl, decl,
MAX_OFILE_ALIGNMENT/BITS_PER_UNIT);
align = MAX_OFILE_ALIGNMENT;
}
if (! DECL_USER_ALIGN (decl))
{
#ifdef DATA_ALIGNMENT
align = DATA_ALIGNMENT (TREE_TYPE (decl), align);
#endif
#ifdef CONSTANT_ALIGNMENT
if (DECL_INITIAL (decl) != 0 && DECL_INITIAL (decl) != error_mark_node)
align = CONSTANT_ALIGNMENT (DECL_INITIAL (decl), align);
#endif
}
DECL_ALIGN (decl) = align;
set_mem_align (decl_rtl, align);
if (TREE_PUBLIC (decl))
maybe_assemble_visibility (decl);
if (DECL_PRESERVE_P (decl))
targetm.asm_out.mark_decl_preserved (name);
if (DECL_SECTION_NAME (decl) || dont_output_data)
;
else if (DECL_THREAD_LOCAL (decl))
{
if (DECL_COMMON (decl))
sorry ("thread-local COMMON data not implemented");
}
else if (DECL_INITIAL (decl) == 0
|| DECL_INITIAL (decl) == error_mark_node
|| (flag_zero_initialized_in_bss
&& !TREE_READONLY (decl)
&& initializer_zerop (DECL_INITIAL (decl))))
{
unsigned HOST_WIDE_INT size = tree_low_cst (DECL_SIZE_UNIT (decl), 1);
unsigned HOST_WIDE_INT rounded = size;
if (size == 0)
rounded = 1;
rounded += (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1;
rounded = (rounded / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
* (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
#if !defined(ASM_OUTPUT_ALIGNED_COMMON) && !defined(ASM_OUTPUT_ALIGNED_DECL_COMMON) && !defined(ASM_OUTPUT_ALIGNED_BSS)
if ((unsigned HOST_WIDE_INT) DECL_ALIGN_UNIT (decl) > rounded)
warning ("%Jrequested alignment for %qD is greater than "
"implemented alignment of %d", decl, decl, rounded);
#endif
if (asm_emit_uninitialised (decl, name, size, rounded))
return;
}
if (TREE_PUBLIC (decl) && DECL_NAME (decl))
globalize_decl (decl);
if (DECL_INITIAL (decl) == error_mark_node)
reloc = contains_pointers_p (TREE_TYPE (decl)) ? 3 : 0;
else if (DECL_INITIAL (decl))
{
reloc = compute_reloc_for_constant (DECL_INITIAL (decl));
output_addressed_constants (DECL_INITIAL (decl));
}
resolve_unique_section (decl, reloc, flag_data_sections);
variable_section (decl, reloc);
#ifdef ASM_OUTPUT_ZEROFILL
if (!DECL_COMMON (decl)
&& ! dont_output_data
&& ! DECL_ONE_ONLY (decl)
&& ! DECL_WEAK (decl)
&& (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
{
ASM_OUTPUT_ZEROFILL (asm_out_file, name,
tree_low_cst (DECL_SIZE_UNIT (decl), 1),
floor_log2 (DECL_ALIGN (decl) / BITS_PER_UNIT));
return;
}
#endif
if (in_text_section () || in_unlikely_text_section ())
DECL_IN_TEXT_SECTION (decl) = 1;
if (align > BITS_PER_UNIT)
ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (DECL_ALIGN_UNIT (decl)));
#ifdef ASM_DECLARE_OBJECT_NAME
last_assemble_variable_decl = decl;
ASM_DECLARE_OBJECT_NAME (asm_out_file, name, decl);
#else
ASM_OUTPUT_LABEL (asm_out_file, name);
#endif
if (!dont_output_data)
{
if (DECL_INITIAL (decl)
&& DECL_INITIAL (decl) != error_mark_node
&& !initializer_zerop (DECL_INITIAL (decl)))
output_constant (DECL_INITIAL (decl),
tree_low_cst (DECL_SIZE_UNIT (decl), 1),
align);
else
assemble_zeros (tree_low_cst (DECL_SIZE_UNIT (decl), 1));
}
}
static int
contains_pointers_p (tree type)
{
switch (TREE_CODE (type))
{
case POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
return 1;
case RECORD_TYPE:
case UNION_TYPE:
case QUAL_UNION_TYPE:
{
tree fields;
for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
if (TREE_CODE (fields) == FIELD_DECL
&& contains_pointers_p (TREE_TYPE (fields)))
return 1;
return 0;
}
case ARRAY_TYPE:
return contains_pointers_p (TREE_TYPE (type));
default:
return 0;
}
}
static GTY(()) tree pending_assemble_externals;
#ifdef ASM_OUTPUT_EXTERNAL
static bool
incorporeal_function_p (tree decl)
{
if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl))
{
const char *name;
if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL
&& DECL_FUNCTION_CODE (decl) == BUILT_IN_ALLOCA)
return true;
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
if (strncmp (name, "__builtin_", strlen ("__builtin_")) == 0)
return true;
}
return false;
}
static void
assemble_external_real (tree decl)
{
rtx rtl = DECL_RTL (decl);
if (MEM_P (rtl) && GET_CODE (XEXP (rtl, 0)) == SYMBOL_REF
&& !SYMBOL_REF_USED (XEXP (rtl, 0))
&& !incorporeal_function_p (decl))
{
SYMBOL_REF_USED (XEXP (rtl, 0)) = 1;
ASM_OUTPUT_EXTERNAL (asm_out_file, decl, XSTR (XEXP (rtl, 0), 0));
}
}
#endif
void
process_pending_assemble_externals (void)
{
#ifdef ASM_OUTPUT_EXTERNAL
tree list;
for (list = pending_assemble_externals; list; list = TREE_CHAIN (list))
assemble_external_real (TREE_VALUE (list));
pending_assemble_externals = 0;
#endif
}
void
assemble_external (tree decl ATTRIBUTE_UNUSED)
{
gcc_assert (asm_out_file);
#ifdef ASM_OUTPUT_EXTERNAL
if (!DECL_P (decl) || !DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl))
return;
if (flag_unit_at_a_time)
pending_assemble_externals = tree_cons (0, decl,
pending_assemble_externals);
else
assemble_external_real (decl);
#endif
}
void
assemble_external_libcall (rtx fun)
{
if (! SYMBOL_REF_USED (fun))
{
SYMBOL_REF_USED (fun) = 1;
targetm.asm_out.external_libcall (fun);
}
}
void
assemble_label (const char *name)
{
ASM_OUTPUT_LABEL (asm_out_file, name);
}
void
mark_referenced (tree id)
{
TREE_SYMBOL_REFERENCED (id) = 1;
}
void
mark_decl_referenced (tree decl)
{
if (TREE_CODE (decl) == FUNCTION_DECL)
{
if (!DECL_EXTERNAL (decl))
cgraph_mark_needed_node (cgraph_node (decl));
}
else if (TREE_CODE (decl) == VAR_DECL)
cgraph_varpool_mark_needed_node (cgraph_varpool_node (decl));
}
void
assemble_name_raw (FILE *file, const char *name)
{
if (name[0] == '*')
fputs (&name[1], file);
else
ASM_OUTPUT_LABELREF (file, name);
}
void
assemble_name (FILE *file, const char *name)
{
const char *real_name;
tree id;
real_name = targetm.strip_name_encoding (name);
id = maybe_get_identifier (real_name);
if (id)
mark_referenced (id);
assemble_name_raw (file, name);
}
rtx
assemble_static_space (unsigned HOST_WIDE_INT size)
{
char name[12];
const char *namestring;
rtx x;
#if 0
if (flag_shared_data)
data_section ();
#endif
ASM_GENERATE_INTERNAL_LABEL (name, "LF", const_labelno);
++const_labelno;
namestring = ggc_strdup (name);
x = gen_rtx_SYMBOL_REF (Pmode, namestring);
SYMBOL_REF_FLAGS (x) = SYMBOL_FLAG_LOCAL;
#ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL
ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, NULL_TREE, name, size,
BIGGEST_ALIGNMENT);
#else
#ifdef ASM_OUTPUT_ALIGNED_LOCAL
ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);
#else
{
unsigned HOST_WIDE_INT rounded ATTRIBUTE_UNUSED
= ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)
/ (BIGGEST_ALIGNMENT / BITS_PER_UNIT)
* (BIGGEST_ALIGNMENT / BITS_PER_UNIT));
ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);
}
#endif
#endif
return x;
}
static GTY(()) rtx initial_trampoline;
#ifdef TRAMPOLINE_TEMPLATE
rtx
assemble_trampoline_template (void)
{
char label[256];
const char *name;
int align;
rtx symbol;
if (initial_trampoline)
return initial_trampoline;
#ifdef TRAMPOLINE_SECTION
TRAMPOLINE_SECTION ();
#else
readonly_data_section ();
#endif
align = floor_log2 (TRAMPOLINE_ALIGNMENT / BITS_PER_UNIT);
if (align > 0)
{
ASM_OUTPUT_ALIGN (asm_out_file, align);
}
targetm.asm_out.internal_label (asm_out_file, "LTRAMP", 0);
TRAMPOLINE_TEMPLATE (asm_out_file);
ASM_GENERATE_INTERNAL_LABEL (label, "LTRAMP", 0);
name = ggc_strdup (label);
symbol = gen_rtx_SYMBOL_REF (Pmode, name);
SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
initial_trampoline = gen_rtx_MEM (BLKmode, symbol);
set_mem_align (initial_trampoline, TRAMPOLINE_ALIGNMENT);
return initial_trampoline;
}
#endif
static inline unsigned
min_align (unsigned int a, unsigned int b)
{
return (a | b) & -(a | b);
}
const char *
integer_asm_op (int size, int aligned_p)
{
struct asm_int_op *ops;
if (aligned_p)
ops = &targetm.asm_out.aligned_op;
else
ops = &targetm.asm_out.unaligned_op;
switch (size)
{
case 1:
return targetm.asm_out.byte_op;
case 2:
return ops->hi;
case 4:
return ops->si;
case 8:
return ops->di;
case 16:
return ops->ti;
default:
return NULL;
}
}
void
assemble_integer_with_op (const char *op, rtx x)
{
fputs (op, asm_out_file);
output_addr_const (asm_out_file, x);
fputc ('\n', asm_out_file);
}
bool
default_assemble_integer (rtx x ATTRIBUTE_UNUSED,
unsigned int size ATTRIBUTE_UNUSED,
int aligned_p ATTRIBUTE_UNUSED)
{
const char *op = integer_asm_op (size, aligned_p);
if (size > UNITS_PER_WORD && size > POINTER_SIZE / BITS_PER_UNIT)
return false;
return op && (assemble_integer_with_op (op, x), true);
}
bool
assemble_integer (rtx x, unsigned int size, unsigned int align, int force)
{
int aligned_p;
aligned_p = (align >= MIN (size * BITS_PER_UNIT, BIGGEST_ALIGNMENT));
if (targetm.asm_out.integer (x, size, aligned_p))
return true;
if (size > 1)
{
enum machine_mode omode, imode;
unsigned int subalign;
unsigned int subsize, i;
subsize = size > UNITS_PER_WORD? UNITS_PER_WORD : 1;
subalign = MIN (align, subsize * BITS_PER_UNIT);
omode = mode_for_size (subsize * BITS_PER_UNIT, MODE_INT, 0);
imode = mode_for_size (size * BITS_PER_UNIT, MODE_INT, 0);
for (i = 0; i < size; i += subsize)
{
rtx partial = simplify_subreg (omode, x, imode, i);
if (!partial || !assemble_integer (partial, subsize, subalign, 0))
break;
}
if (i == size)
return true;
if (i > 0)
abort ();
}
if (force)
abort ();
return false;
}
void
assemble_real (REAL_VALUE_TYPE d, enum machine_mode mode, unsigned int align)
{
long data[4];
int i;
int bitsize, nelts, nunits, units_per;
nunits = GET_MODE_SIZE (mode);
bitsize = nunits * BITS_PER_UNIT;
nelts = CEIL (bitsize, 32);
units_per = 32 / BITS_PER_UNIT;
real_to_target (data, &d, mode);
assemble_integer (GEN_INT (data[0]), MIN (nunits, units_per), align, 1);
nunits -= units_per;
align = min_align (align, 32);
for (i = 1; i < nelts; i++)
{
assemble_integer (GEN_INT (data[i]), MIN (nunits, units_per), align, 1);
nunits -= units_per;
}
}
struct addr_const GTY(())
{
rtx base;
HOST_WIDE_INT offset;
};
static void
decode_addr_const (tree exp, struct addr_const *value)
{
tree target = TREE_OPERAND (exp, 0);
int offset = 0;
rtx x;
while (1)
{
if (TREE_CODE (target) == COMPONENT_REF
&& host_integerp (byte_position (TREE_OPERAND (target, 1)), 0))
{
offset += int_byte_position (TREE_OPERAND (target, 1));
target = TREE_OPERAND (target, 0);
}
else if (TREE_CODE (target) == ARRAY_REF
|| TREE_CODE (target) == ARRAY_RANGE_REF)
{
offset += (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (target)), 1)
* tree_low_cst (TREE_OPERAND (target, 1), 0));
target = TREE_OPERAND (target, 0);
}
else
break;
}
switch (TREE_CODE (target))
{
case VAR_DECL:
case FUNCTION_DECL:
x = DECL_RTL (target);
break;
case LABEL_DECL:
x = gen_rtx_MEM (FUNCTION_MODE,
gen_rtx_LABEL_REF (VOIDmode, force_label_rtx (target)));
break;
case REAL_CST:
case STRING_CST:
case COMPLEX_CST:
case CONSTRUCTOR:
case INTEGER_CST:
x = output_constant_def (target, 1);
break;
default:
abort ();
}
if (!MEM_P (x))
abort ();
x = XEXP (x, 0);
value->base = x;
value->offset = offset;
}
struct constant_descriptor_tree GTY(())
{
rtx rtl;
tree value;
};
static GTY((param_is (struct constant_descriptor_tree)))
htab_t const_desc_htab;
static struct constant_descriptor_tree * build_constant_desc (tree);
static void maybe_output_constant_def_contents (struct constant_descriptor_tree *, int);
static hashval_t
const_desc_hash (const void *ptr)
{
return const_hash_1 (((struct constant_descriptor_tree *)ptr)->value);
}
static hashval_t
const_hash_1 (const tree exp)
{
const char *p;
hashval_t hi;
int len, i;
enum tree_code code = TREE_CODE (exp);
switch (code)
{
case INTEGER_CST:
p = (char *) &TREE_INT_CST (exp);
len = sizeof TREE_INT_CST (exp);
break;
case REAL_CST:
return real_hash (TREE_REAL_CST_PTR (exp));
case STRING_CST:
if (flag_writable_strings
&& !darwin_constant_cfstring_p (exp))
{
p = (char *) &exp;
len = sizeof exp;
}
else
{
p = TREE_STRING_POINTER (exp);
len = TREE_STRING_LENGTH (exp);
}
break;
case COMPLEX_CST:
return (const_hash_1 (TREE_REALPART (exp)) * 5
+ const_hash_1 (TREE_IMAGPART (exp)));
case CONSTRUCTOR:
{
tree link;
hi = 5 + int_size_in_bytes (TREE_TYPE (exp));
for (link = CONSTRUCTOR_ELTS (exp); link; link = TREE_CHAIN (link))
if (TREE_VALUE (link))
hi = hi * 603 + const_hash_1 (TREE_VALUE (link));
return hi;
}
case ADDR_EXPR:
case FDESC_EXPR:
{
struct addr_const value;
decode_addr_const (exp, &value);
if (GET_CODE (value.base) == SYMBOL_REF)
{
hi = value.offset;
p = XSTR (value.base, 0);
for (i = 0; p[i] != 0; i++)
hi = ((hi * 613) + (unsigned) (p[i]));
}
else if (GET_CODE (value.base) == LABEL_REF)
hi = value.offset + CODE_LABEL_NUMBER (XEXP (value.base, 0)) * 13;
else
abort ();
}
return hi;
case PLUS_EXPR:
case MINUS_EXPR:
return (const_hash_1 (TREE_OPERAND (exp, 0)) * 9
+ const_hash_1 (TREE_OPERAND (exp, 1)));
case NOP_EXPR:
case CONVERT_EXPR:
case NON_LVALUE_EXPR:
return const_hash_1 (TREE_OPERAND (exp, 0)) * 7 + 2;
default:
return code;
}
hi = len;
for (i = 0; i < len; i++)
hi = ((hi * 613) + (unsigned) (p[i]));
return hi;
}
static int
const_desc_eq (const void *p1, const void *p2)
{
return compare_constant (((struct constant_descriptor_tree *)p1)->value,
((struct constant_descriptor_tree *)p2)->value);
}
static int
compare_constant (const tree t1, const tree t2)
{
enum tree_code typecode;
if (t1 == NULL_TREE)
return t2 == NULL_TREE;
if (t2 == NULL_TREE)
return 0;
if (TREE_CODE (t1) != TREE_CODE (t2))
return 0;
switch (TREE_CODE (t1))
{
case INTEGER_CST:
if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
return 0;
return tree_int_cst_equal (t1, t2);
case REAL_CST:
if (TYPE_PRECISION (TREE_TYPE (t1)) != TYPE_PRECISION (TREE_TYPE (t2)))
return 0;
return REAL_VALUES_IDENTICAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
case STRING_CST:
if (flag_writable_strings
&& !darwin_constant_cfstring_p (t1)
&& !darwin_constant_cfstring_p (t2))
return t1 == t2;
if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2)))
return 0;
return (TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
&& ! memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
TREE_STRING_LENGTH (t1)));
case COMPLEX_CST:
return (compare_constant (TREE_REALPART (t1), TREE_REALPART (t2))
&& compare_constant (TREE_IMAGPART (t1), TREE_IMAGPART (t2)));
case CONSTRUCTOR:
{
tree l1, l2;
typecode = TREE_CODE (TREE_TYPE (t1));
if (typecode != TREE_CODE (TREE_TYPE (t2)))
return 0;
if (typecode == ARRAY_TYPE)
{
HOST_WIDE_INT size_1 = int_size_in_bytes (TREE_TYPE (t1));
if (TYPE_MODE (TREE_TYPE (t1)) != TYPE_MODE (TREE_TYPE (t2))
|| size_1 == -1
|| size_1 != int_size_in_bytes (TREE_TYPE (t2)))
return 0;
}
else
{
if (TREE_TYPE (t1) != TREE_TYPE (t2))
return 0;
}
for (l1 = CONSTRUCTOR_ELTS (t1), l2 = CONSTRUCTOR_ELTS (t2);
l1 && l2;
l1 = TREE_CHAIN (l1), l2 = TREE_CHAIN (l2))
{
if (! compare_constant (TREE_VALUE (l1), TREE_VALUE (l2)))
return 0;
if (typecode == ARRAY_TYPE)
{
if (! compare_constant (TREE_PURPOSE (l1),
TREE_PURPOSE (l2)))
return 0;
}
else
{
if (TREE_PURPOSE (l1) != TREE_PURPOSE (l2))
return 0;
}
}
return l1 == NULL_TREE && l2 == NULL_TREE;
}
case ADDR_EXPR:
case FDESC_EXPR:
{
struct addr_const value1, value2;
decode_addr_const (t1, &value1);
decode_addr_const (t2, &value2);
return (value1.offset == value2.offset
&& strcmp (XSTR (value1.base, 0), XSTR (value2.base, 0)) == 0);
}
case PLUS_EXPR:
case MINUS_EXPR:
case RANGE_EXPR:
return (compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0))
&& compare_constant(TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)));
case NOP_EXPR:
case CONVERT_EXPR:
case NON_LVALUE_EXPR:
case VIEW_CONVERT_EXPR:
return compare_constant (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
default:
{
tree nt1, nt2;
nt1 = lang_hooks.expand_constant (t1);
nt2 = lang_hooks.expand_constant (t2);
if (nt1 != t1 || nt2 != t2)
return compare_constant (nt1, nt2);
else
return 0;
}
}
abort ();
}
static tree
copy_constant (tree exp)
{
switch (TREE_CODE (exp))
{
case ADDR_EXPR:
if (CONSTANT_CLASS_P (TREE_OPERAND (exp, 0)))
return build1 (TREE_CODE (exp), TREE_TYPE (exp),
copy_constant (TREE_OPERAND (exp, 0)));
else
return copy_node (exp);
case INTEGER_CST:
case REAL_CST:
case STRING_CST:
return copy_node (exp);
case COMPLEX_CST:
return build_complex (TREE_TYPE (exp),
copy_constant (TREE_REALPART (exp)),
copy_constant (TREE_IMAGPART (exp)));
case PLUS_EXPR:
case MINUS_EXPR:
return build2 (TREE_CODE (exp), TREE_TYPE (exp),
copy_constant (TREE_OPERAND (exp, 0)),
copy_constant (TREE_OPERAND (exp, 1)));
case NOP_EXPR:
case CONVERT_EXPR:
case NON_LVALUE_EXPR:
case VIEW_CONVERT_EXPR:
return build1 (TREE_CODE (exp), TREE_TYPE (exp),
copy_constant (TREE_OPERAND (exp, 0)));
case CONSTRUCTOR:
{
tree copy = copy_node (exp);
tree list = copy_list (CONSTRUCTOR_ELTS (exp));
tree tail;
CONSTRUCTOR_ELTS (copy) = list;
for (tail = list; tail; tail = TREE_CHAIN (tail))
TREE_VALUE (tail) = copy_constant (TREE_VALUE (tail));
return copy;
}
default:
{
tree t;
t = lang_hooks.expand_constant (exp);
if (t != exp)
return copy_constant (t);
else
abort ();
}
}
}
static struct constant_descriptor_tree *
build_constant_desc (tree exp)
{
rtx symbol;
rtx rtl;
char label[256];
int labelno;
struct constant_descriptor_tree *desc;
desc = ggc_alloc (sizeof (*desc));
if (flag_writable_strings && TREE_CODE (exp) == STRING_CST)
desc->value = exp;
else
desc->value = copy_constant (exp);
if (flag_mudflap && mf_marked_p (exp))
mf_mark (desc->value);
labelno = const_labelno++;
ASM_GENERATE_INTERNAL_LABEL (label, "LC", labelno);
symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label));
SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
SYMBOL_REF_DECL (symbol) = desc->value;
TREE_CONSTANT_POOL_ADDRESS_P (symbol) = 1;
rtl = gen_rtx_MEM (TYPE_MODE (TREE_TYPE (exp)), symbol);
set_mem_attributes (rtl, exp, 1);
set_mem_alias_set (rtl, 0);
set_mem_alias_set (rtl, const_alias_set);
targetm.encode_section_info (exp, rtl, true);
desc->rtl = rtl;
return desc;
}
rtx
output_constant_def (tree exp, int defer)
{
struct constant_descriptor_tree *desc;
struct constant_descriptor_tree key;
void **loc;
key.value = exp;
loc = htab_find_slot (const_desc_htab, &key, INSERT);
desc = *loc;
if (desc == 0)
{
desc = build_constant_desc (exp);
*loc = desc;
}
maybe_output_constant_def_contents (desc, defer);
return desc->rtl;
}
static void
maybe_output_constant_def_contents (struct constant_descriptor_tree *desc,
int defer)
{
rtx symbol = XEXP (desc->rtl, 0);
tree exp = desc->value;
if (flag_syntax_only)
return;
if (TREE_ASM_WRITTEN (exp))
return;
if (defer && (TREE_CODE (exp) != STRING_CST || !flag_writable_strings))
{
if (cfun)
n_deferred_constants++;
return;
}
output_constant_def_contents (symbol);
}
static void
output_constant_def_contents (rtx symbol)
{
tree exp = SYMBOL_REF_DECL (symbol);
const char *label = XSTR (symbol, 0);
HOST_WIDE_INT size;
int reloc = compute_reloc_for_constant (exp);
unsigned int align = TYPE_ALIGN (TREE_TYPE (exp));
#ifdef CONSTANT_ALIGNMENT
align = CONSTANT_ALIGNMENT (exp, align);
#endif
output_addressed_constants (exp);
TREE_ASM_WRITTEN (exp) = 1;
if (IN_NAMED_SECTION (exp))
named_section (exp, NULL, reloc);
else
targetm.asm_out.select_section (exp, reloc, align);
if (align > BITS_PER_UNIT)
{
ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (align / BITS_PER_UNIT));
}
size = int_size_in_bytes (TREE_TYPE (exp));
if (TREE_CODE (exp) == STRING_CST)
size = MAX (TREE_STRING_LENGTH (exp), size);
#ifdef ASM_DECLARE_CONSTANT_NAME
ASM_DECLARE_CONSTANT_NAME (asm_out_file, label, exp, size);
#else
ASM_OUTPUT_LABEL (asm_out_file, label);
#endif
output_constant (exp, size, align);
if (flag_mudflap)
mudflap_enqueue_constant (exp);
}
rtx
lookup_constant_def (tree exp)
{
struct constant_descriptor_tree *desc;
struct constant_descriptor_tree key;
key.value = exp;
desc = htab_find (const_desc_htab, &key);
return (desc ? desc->rtl : NULL_RTX);
}
struct rtx_constant_pool GTY(())
{
struct constant_descriptor_rtx *first;
struct constant_descriptor_rtx *last;
htab_t GTY((param_is (struct constant_descriptor_rtx))) const_rtx_htab;
htab_t GTY((param_is (struct constant_descriptor_rtx))) const_rtx_sym_htab;
HOST_WIDE_INT offset;
};
struct constant_descriptor_rtx GTY((chain_next ("%h.next")))
{
struct constant_descriptor_rtx *next;
rtx mem;
rtx sym;
rtx constant;
HOST_WIDE_INT offset;
hashval_t hash;
enum machine_mode mode;
unsigned int align;
int labelno;
int mark;
};
static hashval_t
const_desc_rtx_hash (const void *ptr)
{
const struct constant_descriptor_rtx *desc = ptr;
return desc->hash;
}
static int
const_desc_rtx_eq (const void *a, const void *b)
{
const struct constant_descriptor_rtx *x = a;
const struct constant_descriptor_rtx *y = b;
if (x->mode != y->mode)
return 0;
return rtx_equal_p (x->constant, y->constant);
}
static hashval_t
const_desc_rtx_sym_hash (const void *ptr)
{
const struct constant_descriptor_rtx *desc = ptr;
return htab_hash_string (XSTR (desc->sym, 0));
}
static int
const_desc_rtx_sym_eq (const void *a, const void *b)
{
const struct constant_descriptor_rtx *x = a;
const struct constant_descriptor_rtx *y = b;
return XSTR (x->sym, 0) == XSTR (y->sym, 0);
}
static int
const_rtx_hash_1 (rtx *xp, void *data)
{
unsigned HOST_WIDE_INT hwi;
enum machine_mode mode;
enum rtx_code code;
hashval_t h, *hp;
rtx x;
x = *xp;
code = GET_CODE (x);
mode = GET_MODE (x);
h = (hashval_t) code * 1048573 + mode;
switch (code)
{
case CONST_INT:
hwi = INTVAL (x);
fold_hwi:
{
const int shift = sizeof (hashval_t) * CHAR_BIT;
const int n = sizeof (HOST_WIDE_INT) / sizeof (hashval_t);
int i;
h ^= (hashval_t) hwi;
for (i = 1; i < n; ++i)
{
hwi >>= shift;
h ^= (hashval_t) hwi;
}
}
break;
case CONST_DOUBLE:
if (mode == VOIDmode)
{
hwi = CONST_DOUBLE_LOW (x) ^ CONST_DOUBLE_HIGH (x);
goto fold_hwi;
}
else
h ^= real_hash (CONST_DOUBLE_REAL_VALUE (x));
break;
case CONST_VECTOR:
{
int i;
for (i = XVECLEN (x, 0); i-- > 0; )
h = h * 251 + const_rtx_hash_1 (&XVECEXP (x, 0, i), data);
}
break;
case SYMBOL_REF:
h ^= htab_hash_string (XSTR (x, 0));
break;
case LABEL_REF:
h = h * 251 + CODE_LABEL_NUMBER (XEXP (x, 0));
break;
case UNSPEC:
case UNSPEC_VOLATILE:
h = h * 251 + XINT (x, 1);
break;
default:
break;
}
hp = data;
*hp = *hp * 509 + h;
return 0;
}
static hashval_t
const_rtx_hash (rtx x)
{
hashval_t h = 0;
for_each_rtx (&x, const_rtx_hash_1, &h);
return h;
}
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->deferred_constants = 0;
pool->const_rtx_htab = htab_create_ggc (31, const_desc_rtx_hash,
const_desc_rtx_eq, NULL);
pool->const_rtx_sym_htab = htab_create_ggc (31, const_desc_rtx_sym_hash,
const_desc_rtx_sym_eq, NULL);
pool->first = pool->last = NULL;
pool->offset = 0;
}
rtx
simplify_subtraction (rtx x)
{
rtx r = simplify_rtx (x);
return r ? r : x;
}
rtx
force_const_mem (enum machine_mode mode, rtx x)
{
struct constant_descriptor_rtx *desc, tmp;
struct rtx_constant_pool *pool = cfun->varasm->pool;
char label[256];
rtx def, symbol;
hashval_t hash;
unsigned int align;
void **slot;
if (targetm.cannot_force_const_mem (x))
return NULL_RTX;
tmp.constant = x;
tmp.mode = mode;
hash = const_rtx_hash (x);
slot = htab_find_slot_with_hash (pool->const_rtx_htab, &tmp, hash, INSERT);
desc = *slot;
if (desc)
return copy_rtx (desc->mem);
desc = ggc_alloc (sizeof (*desc));
*slot = desc;
align = GET_MODE_ALIGNMENT (mode == VOIDmode ? word_mode : mode);
#ifdef CONSTANT_ALIGNMENT
{
tree type = lang_hooks.types.type_for_mode (mode, 0);
if (type != NULL_TREE)
align = CONSTANT_ALIGNMENT (make_tree (type, x), align);
}
#endif
pool->offset += (align / BITS_PER_UNIT) - 1;
pool->offset &= ~ ((align / BITS_PER_UNIT) - 1);
desc->next = NULL;
desc->constant = tmp.constant;
desc->offset = pool->offset;
desc->hash = hash;
desc->mode = mode;
desc->align = align;
desc->labelno = const_labelno;
desc->mark = 0;
pool->offset += GET_MODE_SIZE (mode);
if (pool->last)
pool->last->next = desc;
else
pool->first = pool->last = desc;
pool->last = desc;
ASM_GENERATE_INTERNAL_LABEL (label, "LC", const_labelno);
++const_labelno;
desc->sym = symbol = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (label));
SYMBOL_REF_FLAGS (symbol) = SYMBOL_FLAG_LOCAL;
CONSTANT_POOL_ADDRESS_P (symbol) = 1;
current_function_uses_const_pool = 1;
slot = htab_find_slot (pool->const_rtx_sym_htab, desc, INSERT);
if (*slot)
abort ();
*slot = desc;
desc->mem = def = gen_const_mem (mode, symbol);
set_mem_attributes (def, lang_hooks.types.type_for_mode (mode, 0), 1);
set_mem_align (def, align);
if (GET_CODE (x) == LABEL_REF)
LABEL_PRESERVE_P (XEXP (x, 0)) = 1;
return copy_rtx (def);
}
static struct constant_descriptor_rtx *
find_pool_constant (struct rtx_constant_pool *pool, rtx sym)
{
struct constant_descriptor_rtx tmp;
tmp.sym = sym;
return htab_find (pool->const_rtx_sym_htab, &tmp);
}
rtx
get_pool_constant (rtx addr)
{
return find_pool_constant (cfun->varasm->pool, addr)->constant;
}
rtx
get_pool_constant_mark (rtx addr, bool *pmarked)
{
struct constant_descriptor_rtx *desc;
desc = find_pool_constant (cfun->varasm->pool, addr);
*pmarked = (desc->mark != 0);
return desc->constant;
}
rtx
get_pool_constant_for_function (struct function *f, rtx addr)
{
return find_pool_constant (f->varasm->pool, addr)->constant;
}
enum machine_mode
get_pool_mode (rtx addr)
{
return find_pool_constant (cfun->varasm->pool, addr)->mode;
}
int
get_pool_size (void)
{
return cfun->varasm->pool->offset;
}
static void
output_constant_pool_2 (enum machine_mode mode, rtx x, unsigned int align)
{
switch (GET_MODE_CLASS (mode))
{
case MODE_FLOAT:
if (GET_CODE (x) != CONST_DOUBLE)
abort ();
else
{
REAL_VALUE_TYPE r;
REAL_VALUE_FROM_CONST_DOUBLE (r, x);
assemble_real (r, mode, align);
}
break;
case MODE_INT:
case MODE_PARTIAL_INT:
assemble_integer (x, GET_MODE_SIZE (mode), align, 1);
break;
case MODE_VECTOR_FLOAT:
case MODE_VECTOR_INT:
{
int i, units;
enum machine_mode submode = GET_MODE_INNER (mode);
unsigned int subalign = MIN (align, GET_MODE_BITSIZE (submode));
if (GET_CODE (x) != CONST_VECTOR)
abort ();
units = CONST_VECTOR_NUNITS (x);
for (i = 0; i < units; i++)
{
rtx elt = CONST_VECTOR_ELT (x, i);
output_constant_pool_2 (submode, elt, i ? subalign : align);
}
}
break;
default:
abort ();
}
}
static void
output_constant_pool_1 (struct constant_descriptor_rtx *desc)
{
rtx x, tmp;
if (!desc->mark)
return;
x = desc->constant;
tmp = x;
switch (GET_CODE (x))
{
case CONST:
if (GET_CODE (XEXP (x, 0)) != PLUS
|| GET_CODE (XEXP (XEXP (x, 0), 0)) != LABEL_REF)
break;
tmp = XEXP (XEXP (x, 0), 0);
case LABEL_REF:
tmp = XEXP (x, 0);
if (INSN_DELETED_P (tmp)
|| (NOTE_P (tmp)
&& NOTE_LINE_NUMBER (tmp) == NOTE_INSN_DELETED))
{
abort ();
x = const0_rtx;
}
break;
default:
break;
}
targetm.asm_out.select_rtx_section (desc->mode, x, desc->align);
#ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
ASM_OUTPUT_SPECIAL_POOL_ENTRY (asm_out_file, x, desc->mode,
desc->align, desc->labelno, done);
#endif
assemble_align (desc->align);
targetm.asm_out.internal_label (asm_out_file, "LC", desc->labelno);
output_constant_pool_2 (desc->mode, x, desc->align);
if (desc->align > GET_MODE_BITSIZE (desc->mode)
&& in_section == in_named
&& get_named_section_flags (in_named_name) & SECTION_MERGE)
assemble_align (desc->align);
#ifdef ASM_OUTPUT_SPECIAL_POOL_ENTRY
done:
#endif
return;
}
static int
mark_constant (rtx *current_rtx, void *data)
{
struct rtx_constant_pool *pool = data;
rtx x = *current_rtx;
if (x == NULL_RTX || GET_CODE (x) != SYMBOL_REF)
return 0;
if (CONSTANT_POOL_ADDRESS_P (x))
{
struct constant_descriptor_rtx *desc = find_pool_constant (pool, x);
if (desc->mark == 0)
{
desc->mark = 1;
for_each_rtx (&desc->constant, mark_constant, pool);
}
}
else if (TREE_CONSTANT_POOL_ADDRESS_P (x))
{
tree exp = SYMBOL_REF_DECL (x);
if (!TREE_ASM_WRITTEN (exp))
{
n_deferred_constants--;
output_constant_def_contents (x);
}
}
return -1;
}
static void
mark_constants (struct rtx_constant_pool *pool, rtx insn)
{
if (!INSN_P (insn))
return;
if (GET_CODE (PATTERN (insn)) == SEQUENCE)
{
rtx seq = PATTERN (insn);
int i, n = XVECLEN (seq, 0);
for (i = 0; i < n; ++i)
{
rtx subinsn = XVECEXP (seq, 0, i);
if (INSN_P (subinsn))
for_each_rtx (&PATTERN (subinsn), mark_constant, pool);
}
}
else
for_each_rtx (&PATTERN (insn), mark_constant, pool);
}
static void
mark_constant_pool (struct rtx_constant_pool *pool)
{
rtx insn, link;
if (pool->first == 0 && n_deferred_constants == 0)
return;
for (insn = get_insns (); insn; insn = NEXT_INSN (insn))
mark_constants (pool, insn);
for (link = current_function_epilogue_delay_list;
link;
link = XEXP (link, 1))
mark_constants (pool, XEXP (link, 0));
}
void
output_constant_pool (const char *fnname ATTRIBUTE_UNUSED,
tree fndecl ATTRIBUTE_UNUSED)
{
struct rtx_constant_pool *pool = cfun->varasm->pool;
struct constant_descriptor_rtx *desc;
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)
output_constant_pool_1 (desc);
#ifdef ASM_OUTPUT_POOL_EPILOGUE
ASM_OUTPUT_POOL_EPILOGUE (asm_out_file, fnname, fndecl, pool->offset);
#endif
}
int
compute_reloc_for_constant (tree exp)
{
int reloc = 0, reloc2;
tree tem;
exp = lang_hooks.expand_constant (exp);
switch (TREE_CODE (exp))
{
case ADDR_EXPR:
case FDESC_EXPR:
for (tem = TREE_OPERAND (exp, 0); handled_component_p (tem);
tem = TREE_OPERAND (tem, 0))
;
if (TREE_PUBLIC (tem))
reloc |= 2;
else
reloc |= 1;
break;
case PLUS_EXPR:
reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
reloc |= compute_reloc_for_constant (TREE_OPERAND (exp, 1));
break;
case MINUS_EXPR:
reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
reloc2 = compute_reloc_for_constant (TREE_OPERAND (exp, 1));
if (reloc == 1 && reloc2 == 1)
reloc = 0;
else
reloc |= reloc2;
break;
case NOP_EXPR:
case CONVERT_EXPR:
case NON_LVALUE_EXPR:
reloc = compute_reloc_for_constant (TREE_OPERAND (exp, 0));
break;
case CONSTRUCTOR:
for (tem = CONSTRUCTOR_ELTS (exp); tem; tem = TREE_CHAIN (tem))
if (TREE_VALUE (tem) != 0)
reloc |= compute_reloc_for_constant (TREE_VALUE (tem));
break;
default:
break;
}
return reloc;
}
static void
output_addressed_constants (tree exp)
{
tree tem;
exp = lang_hooks.expand_constant (exp);
switch (TREE_CODE (exp))
{
case ADDR_EXPR:
case FDESC_EXPR:
for (tem = TREE_OPERAND (exp, 0); handled_component_p (tem);
tem = TREE_OPERAND (tem, 0))
;
if (TREE_CODE (tem) == CONST_DECL && DECL_INITIAL (tem))
tem = DECL_INITIAL (tem);
if (CONSTANT_CLASS_P (tem) || TREE_CODE (tem) == CONSTRUCTOR)
output_constant_def (tem, 0);
break;
case PLUS_EXPR:
case MINUS_EXPR:
output_addressed_constants (TREE_OPERAND (exp, 1));
case NOP_EXPR:
case CONVERT_EXPR:
case NON_LVALUE_EXPR:
output_addressed_constants (TREE_OPERAND (exp, 0));
break;
case CONSTRUCTOR:
for (tem = CONSTRUCTOR_ELTS (exp); tem; tem = TREE_CHAIN (tem))
if (TREE_VALUE (tem) != 0)
output_addressed_constants (TREE_VALUE (tem));
break;
default:
break;
}
}
tree
initializer_constant_valid_p (tree value, tree endtype)
{
value = lang_hooks.expand_constant (value);
switch (TREE_CODE (value))
{
case CONSTRUCTOR:
if ((TREE_CODE (TREE_TYPE (value)) == UNION_TYPE
|| TREE_CODE (TREE_TYPE (value)) == VECTOR_TYPE
|| TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE)
&& TREE_CONSTANT (value)
&& CONSTRUCTOR_ELTS (value))
{
tree elt;
bool absolute = true;
for (elt = CONSTRUCTOR_ELTS (value); elt; elt = TREE_CHAIN (elt))
{
tree reloc;
value = TREE_VALUE (elt);
reloc = initializer_constant_valid_p (value, TREE_TYPE (value));
if (!reloc)
return NULL_TREE;
if (reloc != null_pointer_node)
absolute = false;
}
return absolute ? null_pointer_node : error_mark_node;
}
return TREE_STATIC (value) ? null_pointer_node : NULL_TREE;
case INTEGER_CST:
case VECTOR_CST:
case REAL_CST:
case STRING_CST:
case COMPLEX_CST:
return null_pointer_node;
case ADDR_EXPR:
case FDESC_EXPR:
value = staticp (TREE_OPERAND (value, 0));
if (value
&& TREE_CODE (value) == INDIRECT_REF
&& TREE_CONSTANT (TREE_OPERAND (value, 0)))
return null_pointer_node;
if (value
&& TREE_CODE (value) == FUNCTION_DECL
&& ((decl_function_context (value) && !DECL_NO_STATIC_CHAIN (value))
|| DECL_NON_ADDR_CONST_P (value)))
return NULL_TREE;
return value;
case VIEW_CONVERT_EXPR:
case NON_LVALUE_EXPR:
return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
case CONVERT_EXPR:
case NOP_EXPR:
{
tree src;
tree src_type;
tree dest_type;
src = TREE_OPERAND (value, 0);
src_type = TREE_TYPE (src);
dest_type = TREE_TYPE (value);
if ((POINTER_TYPE_P (dest_type) && POINTER_TYPE_P (src_type))
|| (FLOAT_TYPE_P (dest_type) && FLOAT_TYPE_P (src_type))
|| (TREE_CODE (dest_type) == OFFSET_TYPE
&& TREE_CODE (src_type) == OFFSET_TYPE))
return initializer_constant_valid_p (src, endtype);
if (INTEGRAL_TYPE_P (dest_type) && INTEGRAL_TYPE_P (src_type)
&& (TYPE_PRECISION (dest_type) == TYPE_PRECISION (src_type)))
return initializer_constant_valid_p (src, endtype);
if (INTEGRAL_TYPE_P (dest_type) && INTEGRAL_TYPE_P (src_type))
{
tree inner = initializer_constant_valid_p (src, endtype);
if (inner == null_pointer_node)
return null_pointer_node;
break;
}
if (INTEGRAL_TYPE_P (dest_type) && POINTER_TYPE_P (src_type)
&& (TYPE_PRECISION (dest_type) >= TYPE_PRECISION (src_type)))
return initializer_constant_valid_p (src, endtype);
if ((POINTER_TYPE_P (dest_type)
|| TREE_CODE (dest_type) == OFFSET_TYPE)
&& INTEGRAL_TYPE_P (src_type))
{
if (integer_zerop (src))
return null_pointer_node;
else if (TYPE_PRECISION (dest_type) <= TYPE_PRECISION (src_type))
return initializer_constant_valid_p (src, endtype);
}
if (TREE_CODE (dest_type) == RECORD_TYPE
|| TREE_CODE (dest_type) == UNION_TYPE)
return initializer_constant_valid_p (src, endtype);
}
break;
case PLUS_EXPR:
if (! INTEGRAL_TYPE_P (endtype)
|| TYPE_PRECISION (endtype) >= POINTER_SIZE)
{
tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
endtype);
tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
endtype);
if (valid0 == null_pointer_node)
return valid1;
if (valid1 == null_pointer_node)
return valid0;
}
break;
case MINUS_EXPR:
if (! INTEGRAL_TYPE_P (endtype)
|| TYPE_PRECISION (endtype) >= POINTER_SIZE)
{
tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
endtype);
tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
endtype);
if (valid1 == null_pointer_node)
return valid0;
if (valid0 == valid1 && valid0 != 0)
return null_pointer_node;
if (valid0 && TREE_CODE (valid0) == STRING_CST
&& valid1 && TREE_CODE (valid1) == STRING_CST
&& operand_equal_p (valid0, valid1, 1))
return null_pointer_node;
}
if (INTEGRAL_TYPE_P (endtype))
{
tree op0, op1;
op0 = TREE_OPERAND (value, 0);
op1 = TREE_OPERAND (value, 1);
while (TREE_CODE (op0) == NOP_EXPR
|| TREE_CODE (op0) == CONVERT_EXPR
|| TREE_CODE (op0) == NON_LVALUE_EXPR)
{
tree inner = TREE_OPERAND (op0, 0);
if (inner == error_mark_node
|| ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
|| (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op0)))
> GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (inner)))))
break;
op0 = inner;
}
while (TREE_CODE (op1) == NOP_EXPR
|| TREE_CODE (op1) == CONVERT_EXPR
|| TREE_CODE (op1) == NON_LVALUE_EXPR)
{
tree inner = TREE_OPERAND (op1, 0);
if (inner == error_mark_node
|| ! INTEGRAL_MODE_P (TYPE_MODE (TREE_TYPE (inner)))
|| (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (op1)))
> GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (inner)))))
break;
op1 = inner;
}
op0 = initializer_constant_valid_p (op0, endtype);
op1 = initializer_constant_valid_p (op1, endtype);
if (op0 && op1)
{
if (op0 == op1)
return null_pointer_node;
if (TREE_CODE (op0) == LABEL_DECL
&& TREE_CODE (op1) == LABEL_DECL)
return null_pointer_node;
if (TREE_CODE (op0) == STRING_CST
&& TREE_CODE (op1) == STRING_CST
&& operand_equal_p (op0, op1, 1))
return null_pointer_node;
}
}
break;
default:
break;
}
return 0;
}
void
output_constant (tree exp, unsigned HOST_WIDE_INT size, unsigned int align)
{
enum tree_code code;
unsigned HOST_WIDE_INT thissize;
exp = lang_hooks.expand_constant (exp);
if (size == 0 || flag_syntax_only)
return;
while (TREE_CODE (exp) == NOP_EXPR || TREE_CODE (exp) == CONVERT_EXPR
|| TREE_CODE (exp) == NON_LVALUE_EXPR
|| TREE_CODE (exp) == VIEW_CONVERT_EXPR)
exp = TREE_OPERAND (exp, 0);
code = TREE_CODE (TREE_TYPE (exp));
thissize = int_size_in_bytes (TREE_TYPE (exp));
if (TREE_CODE (exp) == CONSTRUCTOR && CONSTRUCTOR_ELTS (exp) == 0)
{
assemble_zeros (size);
return;
}
if (TREE_CODE (exp) == FDESC_EXPR)
{
#ifdef ASM_OUTPUT_FDESC
HOST_WIDE_INT part = tree_low_cst (TREE_OPERAND (exp, 1), 0);
tree decl = TREE_OPERAND (exp, 0);
ASM_OUTPUT_FDESC (asm_out_file, decl, part);
#else
abort ();
#endif
return;
}
switch (code)
{
case CHAR_TYPE:
case BOOLEAN_TYPE:
case INTEGER_TYPE:
case ENUMERAL_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
case OFFSET_TYPE:
if (! assemble_integer (expand_expr (exp, NULL_RTX, VOIDmode,
EXPAND_INITIALIZER),
MIN (size, thissize), align, 0))
error ("initializer for integer value is too complicated");
break;
case REAL_TYPE:
if (TREE_CODE (exp) != REAL_CST)
error ("initializer for floating value is not a floating constant");
assemble_real (TREE_REAL_CST (exp), TYPE_MODE (TREE_TYPE (exp)), align);
break;
case COMPLEX_TYPE:
output_constant (TREE_REALPART (exp), thissize / 2, align);
output_constant (TREE_IMAGPART (exp), thissize / 2,
min_align (align, BITS_PER_UNIT * (thissize / 2)));
break;
case ARRAY_TYPE:
case VECTOR_TYPE:
if (TREE_CODE (exp) == CONSTRUCTOR)
{
output_constructor (exp, size, align);
return;
}
else if (TREE_CODE (exp) == STRING_CST)
{
thissize = MIN ((unsigned HOST_WIDE_INT)TREE_STRING_LENGTH (exp),
size);
assemble_string (TREE_STRING_POINTER (exp), thissize);
}
else if (TREE_CODE (exp) == VECTOR_CST)
{
int elt_size;
tree link;
unsigned int nalign;
enum machine_mode inner;
inner = TYPE_MODE (TREE_TYPE (TREE_TYPE (exp)));
nalign = MIN (align, GET_MODE_ALIGNMENT (inner));
elt_size = GET_MODE_SIZE (inner);
link = TREE_VECTOR_CST_ELTS (exp);
output_constant (TREE_VALUE (link), elt_size, align);
while ((link = TREE_CHAIN (link)) != NULL)
output_constant (TREE_VALUE (link), elt_size, nalign);
}
else
abort ();
break;
case RECORD_TYPE:
case UNION_TYPE:
if (TREE_CODE (exp) == CONSTRUCTOR)
output_constructor (exp, size, align);
else
abort ();
return;
case ERROR_MARK:
return;
default:
abort ();
}
if (size > thissize)
assemble_zeros (size - thissize);
}
static unsigned HOST_WIDE_INT
array_size_for_constructor (tree val)
{
tree max_index, i;
if (TREE_CODE (val) == STRING_CST)
return TREE_STRING_LENGTH (val);
max_index = NULL_TREE;
for (i = CONSTRUCTOR_ELTS (val); i; i = TREE_CHAIN (i))
{
tree index = TREE_PURPOSE (i);
if (TREE_CODE (index) == RANGE_EXPR)
index = TREE_OPERAND (index, 1);
if (max_index == NULL_TREE || tree_int_cst_lt (max_index, index))
max_index = index;
}
if (max_index == NULL_TREE)
return 0;
i = size_binop (MINUS_EXPR, convert (sizetype, max_index),
convert (sizetype,
TYPE_MIN_VALUE (TYPE_DOMAIN (TREE_TYPE (val)))));
i = size_binop (PLUS_EXPR, i, convert (sizetype, integer_one_node));
i = size_binop (MULT_EXPR, i, TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (val))));
return tree_low_cst (i, 1);
}
static void
output_constructor (tree exp, unsigned HOST_WIDE_INT size,
unsigned int align)
{
tree type = TREE_TYPE (exp);
tree link, field = 0;
tree min_index = 0;
HOST_WIDE_INT total_bytes = 0;
int byte_buffer_in_use = 0;
int byte = 0;
if (HOST_BITS_PER_WIDE_INT < BITS_PER_UNIT)
abort ();
if (TREE_CODE (type) == RECORD_TYPE)
field = TYPE_FIELDS (type);
if (TREE_CODE (type) == ARRAY_TYPE
&& TYPE_DOMAIN (type) != 0)
min_index = TYPE_MIN_VALUE (TYPE_DOMAIN (type));
for (link = CONSTRUCTOR_ELTS (exp);
link;
link = TREE_CHAIN (link),
field = field ? TREE_CHAIN (field) : 0)
{
tree val = TREE_VALUE (link);
tree index = 0;
if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE
|| TREE_CODE (type) == QUAL_UNION_TYPE)
&& TREE_PURPOSE (link) != 0)
field = TREE_PURPOSE (link);
else if (TREE_CODE (type) == ARRAY_TYPE)
index = TREE_PURPOSE (link);
#ifdef ASM_COMMENT_START
if (field && flag_verbose_asm)
fprintf (asm_out_file, "%s %s:\n",
ASM_COMMENT_START,
DECL_NAME (field)
? IDENTIFIER_POINTER (DECL_NAME (field))
: "<anonymous>");
#endif
if (val != 0)
STRIP_NOPS (val);
if (index && TREE_CODE (index) == RANGE_EXPR)
{
unsigned HOST_WIDE_INT fieldsize
= int_size_in_bytes (TREE_TYPE (type));
HOST_WIDE_INT lo_index = tree_low_cst (TREE_OPERAND (index, 0), 0);
HOST_WIDE_INT hi_index = tree_low_cst (TREE_OPERAND (index, 1), 0);
HOST_WIDE_INT index;
unsigned int align2 = min_align (align, fieldsize * BITS_PER_UNIT);
for (index = lo_index; index <= hi_index; index++)
{
if (val == 0)
assemble_zeros (fieldsize);
else
output_constant (val, fieldsize, align2);
total_bytes += fieldsize;
}
}
else if (field == 0 || !DECL_BIT_FIELD (field))
{
unsigned HOST_WIDE_INT fieldsize;
HOST_WIDE_INT pos = field ? int_byte_position (field) : 0;
unsigned int align2;
if (index != 0)
pos = (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (val)), 1)
* (tree_low_cst (index, 0) - tree_low_cst (min_index, 0)));
if (byte_buffer_in_use)
{
assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
total_bytes++;
byte_buffer_in_use = 0;
}
if ((field != 0 || index != 0) && pos != total_bytes)
{
assemble_zeros (pos - total_bytes);
total_bytes = pos;
}
align2 = min_align (align, BITS_PER_UNIT * pos);
if (field)
{
fieldsize = 0;
if (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE
&& TYPE_DOMAIN (TREE_TYPE (field))
&& ! TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (field))))
{
fieldsize = array_size_for_constructor (val);
if (fieldsize != 0 && TREE_CHAIN (field) != NULL_TREE)
abort ();
}
else if (DECL_SIZE_UNIT (field))
{
if (host_integerp (DECL_SIZE_UNIT (field), 1))
fieldsize = tree_low_cst (DECL_SIZE_UNIT (field), 1);
}
}
else
fieldsize = int_size_in_bytes (TREE_TYPE (type));
if (val == 0)
assemble_zeros (fieldsize);
else
output_constant (val, fieldsize, align2);
total_bytes += fieldsize;
}
else if (val != 0 && TREE_CODE (val) != INTEGER_CST)
error ("invalid initial value for member %qs",
IDENTIFIER_POINTER (DECL_NAME (field)));
else
{
HOST_WIDE_INT next_offset = int_bit_position (field);
HOST_WIDE_INT end_offset
= (next_offset + tree_low_cst (DECL_SIZE (field), 1));
if (val == 0)
val = integer_zero_node;
if (next_offset / BITS_PER_UNIT != total_bytes)
{
if (byte_buffer_in_use)
{
assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
total_bytes++;
byte_buffer_in_use = 0;
}
if (next_offset / BITS_PER_UNIT != total_bytes)
{
assemble_zeros (next_offset / BITS_PER_UNIT - total_bytes);
total_bytes = next_offset / BITS_PER_UNIT;
}
}
if (! byte_buffer_in_use)
byte = 0;
while (next_offset < end_offset)
{
int this_time;
int shift;
HOST_WIDE_INT value;
HOST_WIDE_INT next_byte = next_offset / BITS_PER_UNIT;
HOST_WIDE_INT next_bit = next_offset % BITS_PER_UNIT;
while (next_byte != total_bytes)
{
assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
total_bytes++;
byte = 0;
}
this_time = MIN (end_offset - next_offset,
BITS_PER_UNIT - next_bit);
if (BYTES_BIG_ENDIAN)
{
shift = end_offset - next_offset - this_time;
if (shift < HOST_BITS_PER_WIDE_INT
&& shift + this_time > HOST_BITS_PER_WIDE_INT)
{
this_time = shift + this_time - HOST_BITS_PER_WIDE_INT;
shift = HOST_BITS_PER_WIDE_INT;
}
if (shift < HOST_BITS_PER_WIDE_INT)
value = TREE_INT_CST_LOW (val);
else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
{
value = TREE_INT_CST_HIGH (val);
shift -= HOST_BITS_PER_WIDE_INT;
}
else
abort ();
byte |= (((value >> shift)
& (((HOST_WIDE_INT) 2 << (this_time - 1)) - 1))
<< (BITS_PER_UNIT - this_time - next_bit));
}
else
{
shift = next_offset - int_bit_position (field);
if (shift < HOST_BITS_PER_WIDE_INT
&& shift + this_time > HOST_BITS_PER_WIDE_INT)
this_time = (HOST_BITS_PER_WIDE_INT - shift);
if (shift < HOST_BITS_PER_WIDE_INT)
value = TREE_INT_CST_LOW (val);
else if (shift < 2 * HOST_BITS_PER_WIDE_INT)
{
value = TREE_INT_CST_HIGH (val);
shift -= HOST_BITS_PER_WIDE_INT;
}
else
abort ();
byte |= (((value >> shift)
& (((HOST_WIDE_INT) 2 << (this_time - 1)) - 1))
<< next_bit);
}
next_offset += this_time;
byte_buffer_in_use = 1;
}
}
}
if (byte_buffer_in_use)
{
assemble_integer (GEN_INT (byte), 1, BITS_PER_UNIT, 1);
total_bytes++;
}
if ((unsigned HOST_WIDE_INT)total_bytes < size)
assemble_zeros (size - total_bytes);
}
static GTY(()) tree weak_decls;
static void
mark_weak (tree decl)
{
DECL_WEAK (decl) = 1;
if (DECL_RTL_SET_P (decl)
&& MEM_P (DECL_RTL (decl))
&& XEXP (DECL_RTL (decl), 0)
&& GET_CODE (XEXP (DECL_RTL (decl), 0)) == SYMBOL_REF)
SYMBOL_REF_WEAK (XEXP (DECL_RTL (decl), 0)) = 1;
}
void
replace_weak (tree newdecl, tree olddecl)
{
if (SUPPORTS_WEAK)
{
tree wd;
for (wd = weak_decls; wd; wd = TREE_CHAIN (wd))
if (TREE_VALUE (wd) == newdecl)
{
TREE_VALUE (wd) = olddecl;
break;
}
}
}
void
merge_weak (tree newdecl, tree olddecl)
{
if (DECL_WEAK (newdecl) == DECL_WEAK (olddecl))
{
replace_weak (newdecl, olddecl);
return;
}
if (DECL_WEAK (newdecl))
{
if (TREE_ASM_WRITTEN (olddecl))
error ("%Jweak declaration of %qD must precede definition",
newdecl, newdecl);
else if (TREE_USED (olddecl)
&& TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (olddecl)))
warning ("%Jweak declaration of %qD after first use results "
"in unspecified behavior", newdecl, newdecl);
replace_weak (newdecl, olddecl);
mark_weak (olddecl);
}
else
mark_weak (newdecl);
}
void
declare_weak (tree decl)
{
if (! TREE_PUBLIC (decl))
error ("%Jweak declaration of %qD must be public", decl, decl);
else if (TREE_CODE (decl) == FUNCTION_DECL && TREE_ASM_WRITTEN (decl))
error ("%Jweak declaration of %qD must precede definition", decl, decl);
else if (SUPPORTS_WEAK)
{
if (! DECL_WEAK (decl))
weak_decls = tree_cons (NULL, decl, weak_decls);
}
else
warning ("%Jweak declaration of %qD not supported", decl, decl);
mark_weak (decl);
}
void
weak_finish (void)
{
tree t;
for (t = weak_decls; t; t = TREE_CHAIN (t))
{
tree decl = TREE_VALUE (t);
#if defined (ASM_WEAKEN_DECL) || defined (ASM_WEAKEN_LABEL)
const char *const name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
#endif
if (! TREE_USED (decl))
continue;
#ifdef ASM_WEAKEN_DECL
ASM_WEAKEN_DECL (asm_out_file, decl, name, NULL);
#else
#ifdef ASM_WEAKEN_LABEL
ASM_WEAKEN_LABEL (asm_out_file, name);
#else
#ifdef ASM_OUTPUT_WEAK_ALIAS
warning ("only weak aliases are supported in this configuration");
return;
#endif
#endif
#endif
}
}
static void
globalize_decl (tree decl)
{
const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
#if defined (ASM_WEAKEN_LABEL) || defined (ASM_WEAKEN_DECL)
if (DECL_WEAK (decl))
{
tree *p, t;
#ifdef ASM_WEAKEN_DECL
ASM_WEAKEN_DECL (asm_out_file, decl, name, 0);
#else
ASM_WEAKEN_LABEL (asm_out_file, name);
#endif
for (p = &weak_decls; (t = *p) ; )
{
if (DECL_ASSEMBLER_NAME (decl) == DECL_ASSEMBLER_NAME (TREE_VALUE (t)))
*p = TREE_CHAIN (t);
else
p = &TREE_CHAIN (t);
}
return;
}
#elif defined(ASM_MAKE_LABEL_LINKONCE)
if (DECL_ONE_ONLY (decl))
ASM_MAKE_LABEL_LINKONCE (asm_out_file, name);
#endif
targetm.asm_out.globalize_label (asm_out_file, name);
}
struct alias_pair GTY(())
{
tree decl;
tree target;
};
typedef struct alias_pair *alias_pair;
DEF_VEC_GC_P(alias_pair);
static GTY(()) VEC(alias_pair) *alias_pairs;
static tree
find_decl_and_mark_needed (tree decl, tree target)
{
struct cgraph_node *fnode = NULL;
struct cgraph_varpool_node *vnode = NULL;
if (!cgraph_global_info_ready)
{
if (TREE_CODE (decl) == FUNCTION_DECL)
{
fnode = cgraph_node_for_asm (target);
if (fnode == NULL)
vnode = cgraph_varpool_node_for_asm (target);
}
else
{
vnode = cgraph_varpool_node_for_asm (target);
if (vnode == NULL)
fnode = cgraph_node_for_asm (target);
}
}
if (fnode)
{
cgraph_mark_needed_node (fnode);
return fnode->decl;
}
else if (vnode)
{
cgraph_varpool_mark_needed_node (vnode);
return vnode->decl;
}
else
return NULL_TREE;
}
static void
do_assemble_alias (tree decl, tree target)
{
TREE_ASM_WRITTEN (decl) = 1;
TREE_ASM_WRITTEN (DECL_ASSEMBLER_NAME (decl)) = 1;
#ifdef ASM_OUTPUT_DEF
if (TREE_PUBLIC (decl))
{
globalize_decl (decl);
maybe_assemble_visibility (decl);
}
# ifdef ASM_OUTPUT_DEF_FROM_DECLS
ASM_OUTPUT_DEF_FROM_DECLS (asm_out_file, decl, target);
# else
ASM_OUTPUT_DEF (asm_out_file,
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
IDENTIFIER_POINTER (target));
# endif
#elif defined (ASM_OUTPUT_WEAK_ALIAS) || defined (ASM_WEAKEN_DECL)
{
const char *name;
tree *p, t;
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
# ifdef ASM_WEAKEN_DECL
ASM_WEAKEN_DECL (asm_out_file, decl, name, IDENTIFIER_POINTER (target));
# else
ASM_OUTPUT_WEAK_ALIAS (asm_out_file, name, IDENTIFIER_POINTER (target));
# endif
for (p = &weak_decls; (t = *p) ; )
if (DECL_ASSEMBLER_NAME (decl) == DECL_ASSEMBLER_NAME (TREE_VALUE (t)))
*p = TREE_CHAIN (t);
else
p = &TREE_CHAIN (t);
}
#endif
}
void
finish_aliases_1 (void)
{
unsigned i;
alias_pair p;
for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p); i++)
{
tree target_decl;
target_decl = find_decl_and_mark_needed (p->decl, p->target);
if (target_decl == NULL)
error ("%J%qD aliased to undefined symbol %qE",
p->decl, p->decl, p->target);
else if (DECL_EXTERNAL (target_decl))
error ("%J%qD aliased to external symbol %qE",
p->decl, p->decl, p->target);
}
}
void
finish_aliases_2 (void)
{
unsigned i;
alias_pair p;
for (i = 0; VEC_iterate (alias_pair, alias_pairs, i, p); i++)
do_assemble_alias (p->decl, p->target);
alias_pairs = NULL;
}
void
assemble_alias (tree decl, tree target)
{
tree target_decl;
#if !defined (ASM_OUTPUT_DEF)
# if !defined(ASM_OUTPUT_WEAK_ALIAS) && !defined (ASM_WEAKEN_DECL)
error ("%Jalias definitions not supported in this configuration", decl);
return;
# else
if (!DECL_WEAK (decl))
{
error ("%Jonly weak aliases are supported in this configuration", decl);
return;
}
# endif
#endif
make_decl_rtl (decl);
TREE_USED (decl) = 1;
DECL_EXTERNAL (decl) = 0;
if (TREE_CODE (decl) == FUNCTION_DECL)
cgraph_node (decl)->alias = true;
else
cgraph_varpool_node (decl)->alias = true;
target_decl = find_decl_and_mark_needed (decl, target);
if (target_decl && TREE_ASM_WRITTEN (target_decl))
do_assemble_alias (decl, target);
else
{
alias_pair p;
p = ggc_alloc (sizeof (struct alias_pair));
p->decl = decl;
p->target = target;
VEC_safe_push (alias_pair, alias_pairs, p);
}
}
void
default_assemble_visibility (tree decl, int vis)
{
static const char * const visibility_types[] = {
NULL, "internal", "hidden", "protected"
};
const char *name, *type;
name = (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
type = visibility_types[vis];
#ifdef HAVE_GAS_HIDDEN
fprintf (asm_out_file, "\t.%s\t", type);
assemble_name (asm_out_file, name);
fprintf (asm_out_file, "\n");
#else
warning ("visibility attribute not supported in this configuration; ignored");
#endif
}
static void
maybe_assemble_visibility (tree decl)
{
enum symbol_visibility vis = DECL_VISIBILITY (decl);
if (vis != VISIBILITY_DEFAULT)
targetm.asm_out.visibility (decl, vis);
}
int
supports_one_only (void)
{
if (SUPPORTS_ONE_ONLY)
return 1;
return SUPPORTS_WEAK;
}
void
make_decl_one_only (tree decl)
{
if (TREE_CODE (decl) != VAR_DECL && TREE_CODE (decl) != FUNCTION_DECL)
abort ();
TREE_PUBLIC (decl) = 1;
if (SUPPORTS_ONE_ONLY)
{
#ifdef MAKE_DECL_ONE_ONLY
MAKE_DECL_ONE_ONLY (decl);
#endif
DECL_ONE_ONLY (decl) = 1;
}
else if (TREE_CODE (decl) == VAR_DECL
&& (DECL_INITIAL (decl) == 0 || DECL_INITIAL (decl) == error_mark_node))
DECL_COMMON (decl) = 1;
else if (SUPPORTS_WEAK)
DECL_WEAK (decl) = 1;
else
abort ();
}
void
init_varasm_once (void)
{
in_named_htab = htab_create_ggc (31, in_named_entry_hash,
in_named_entry_eq, NULL);
const_desc_htab = htab_create_ggc (1009, const_desc_hash,
const_desc_eq, NULL);
const_alias_set = new_alias_set ();
}
static enum tls_model
decl_tls_model (tree decl)
{
enum tls_model kind;
tree attr = lookup_attribute ("tls_model", DECL_ATTRIBUTES (decl));
bool is_local;
if (attr)
{
attr = TREE_VALUE (TREE_VALUE (attr));
if (TREE_CODE (attr) != STRING_CST)
abort ();
if (!strcmp (TREE_STRING_POINTER (attr), "local-exec"))
kind = TLS_MODEL_LOCAL_EXEC;
else if (!strcmp (TREE_STRING_POINTER (attr), "initial-exec"))
kind = TLS_MODEL_INITIAL_EXEC;
else if (!strcmp (TREE_STRING_POINTER (attr), "local-dynamic"))
kind = optimize ? TLS_MODEL_LOCAL_DYNAMIC : TLS_MODEL_GLOBAL_DYNAMIC;
else if (!strcmp (TREE_STRING_POINTER (attr), "global-dynamic"))
kind = TLS_MODEL_GLOBAL_DYNAMIC;
else
abort ();
return kind;
}
is_local = targetm.binds_local_p (decl);
if (!flag_pic)
{
if (is_local)
kind = TLS_MODEL_LOCAL_EXEC;
else
kind = TLS_MODEL_INITIAL_EXEC;
}
else if (optimize && is_local)
kind = TLS_MODEL_LOCAL_DYNAMIC;
else
kind = TLS_MODEL_GLOBAL_DYNAMIC;
if (kind < flag_tls_default)
kind = flag_tls_default;
return kind;
}
unsigned int
default_section_type_flags (tree decl, const char *name, int reloc)
{
return default_section_type_flags_1 (decl, name, reloc, flag_pic);
}
unsigned int
default_section_type_flags_1 (tree decl, const char *name, int reloc,
int shlib)
{
unsigned int flags;
if (decl && TREE_CODE (decl) == FUNCTION_DECL)
flags = SECTION_CODE;
else if (decl && decl_readonly_section_1 (decl, reloc, shlib))
flags = 0;
else if (unlikely_text_section_name
&& strcmp (name, unlikely_text_section_name) == 0)
flags = SECTION_CODE;
else
flags = SECTION_WRITE;
if (decl && DECL_ONE_ONLY (decl))
flags |= SECTION_LINKONCE;
if (decl && TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
flags |= SECTION_TLS | SECTION_WRITE;
if (strcmp (name, ".bss") == 0
|| strncmp (name, ".bss.", 5) == 0
|| strncmp (name, ".gnu.linkonce.b.", 16) == 0
|| strcmp (name, ".sbss") == 0
|| strncmp (name, ".sbss.", 6) == 0
|| strncmp (name, ".gnu.linkonce.sb.", 17) == 0)
flags |= SECTION_BSS;
if (strcmp (name, ".tdata") == 0
|| strncmp (name, ".tdata.", 7) == 0
|| strncmp (name, ".gnu.linkonce.td.", 17) == 0)
flags |= SECTION_TLS;
if (strcmp (name, ".tbss") == 0
|| strncmp (name, ".tbss.", 6) == 0
|| strncmp (name, ".gnu.linkonce.tb.", 17) == 0)
flags |= SECTION_TLS | SECTION_BSS;
if (!(flags & (SECTION_CODE | SECTION_BSS | SECTION_TLS))
&& (strcmp (name, ".init_array") == 0
|| strcmp (name, ".fini_array") == 0
|| strcmp (name, ".preinit_array") == 0))
flags |= SECTION_NOTYPE;
return flags;
}
void
default_no_named_section (const char *name ATTRIBUTE_UNUSED,
unsigned int flags ATTRIBUTE_UNUSED,
tree decl ATTRIBUTE_UNUSED)
{
abort ();
}
void
default_elf_asm_named_section (const char *name, unsigned int flags,
tree decl ATTRIBUTE_UNUSED)
{
char flagchars[10], *f = flagchars;
if (!(HAVE_GAS_COMDAT_GROUP && (flags & SECTION_LINKONCE))
&& ! named_section_first_declaration (name))
{
fprintf (asm_out_file, "\t.section\t%s\n", name);
return;
}
if (!(flags & SECTION_DEBUG))
*f++ = 'a';
if (flags & SECTION_WRITE)
*f++ = 'w';
if (flags & SECTION_CODE)
*f++ = 'x';
if (flags & SECTION_SMALL)
*f++ = 's';
if (flags & SECTION_MERGE)
*f++ = 'M';
if (flags & SECTION_STRINGS)
*f++ = 'S';
if (flags & SECTION_TLS)
*f++ = 'T';
if (HAVE_GAS_COMDAT_GROUP && (flags & SECTION_LINKONCE))
*f++ = 'G';
*f = '\0';
fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars);
if (!(flags & SECTION_NOTYPE))
{
const char *type;
const char *format;
if (flags & SECTION_BSS)
type = "nobits";
else
type = "progbits";
format = ",@%s";
#ifdef ASM_COMMENT_START
if (strcmp (ASM_COMMENT_START, "@") == 0)
format = ",%%%s";
#endif
fprintf (asm_out_file, format, type);
if (flags & SECTION_ENTSIZE)
fprintf (asm_out_file, ",%d", flags & SECTION_ENTSIZE);
if (HAVE_GAS_COMDAT_GROUP && (flags & SECTION_LINKONCE))
fprintf (asm_out_file, ",%s,comdat",
lang_hooks.decls.comdat_group (decl));
}
putc ('\n', asm_out_file);
}
void
default_coff_asm_named_section (const char *name, unsigned int flags,
tree decl ATTRIBUTE_UNUSED)
{
char flagchars[8], *f = flagchars;
if (flags & SECTION_WRITE)
*f++ = 'w';
if (flags & SECTION_CODE)
*f++ = 'x';
*f = '\0';
fprintf (asm_out_file, "\t.section\t%s,\"%s\"\n", name, flagchars);
}
void
default_pe_asm_named_section (const char *name, unsigned int flags,
tree decl)
{
default_coff_asm_named_section (name, flags, decl);
if (flags & SECTION_LINKONCE)
{
fprintf (asm_out_file, "\t.linkonce %s\n",
(flags & SECTION_CODE ? "discard" : "same_size"));
}
}
void
default_select_section (tree decl, int reloc,
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
{
bool readonly = false;
if (DECL_P (decl))
{
if (decl_readonly_section (decl, reloc))
readonly = true;
}
else if (TREE_CODE (decl) == CONSTRUCTOR)
{
if (! ((flag_pic && reloc)
|| !TREE_READONLY (decl)
|| TREE_SIDE_EFFECTS (decl)
|| !TREE_CONSTANT (decl)))
readonly = true;
}
else if (TREE_CODE (decl) == STRING_CST)
readonly = !flag_writable_strings;
else if (! (flag_pic && reloc))
readonly = true;
if (readonly)
readonly_data_section ();
else
data_section ();
}
enum section_category
{
SECCAT_TEXT,
SECCAT_RODATA,
SECCAT_RODATA_MERGE_STR,
SECCAT_RODATA_MERGE_STR_INIT,
SECCAT_RODATA_MERGE_CONST,
SECCAT_SRODATA,
SECCAT_DATA,
SECCAT_DATA_REL,
SECCAT_DATA_REL_LOCAL,
SECCAT_DATA_REL_RO,
SECCAT_DATA_REL_RO_LOCAL,
SECCAT_SDATA,
SECCAT_TDATA,
SECCAT_BSS,
SECCAT_SBSS,
SECCAT_TBSS
};
static enum section_category
categorize_decl_for_section (tree, int, int);
static enum section_category
categorize_decl_for_section (tree decl, int reloc, int shlib)
{
enum section_category ret;
if (TREE_CODE (decl) == FUNCTION_DECL)
return SECCAT_TEXT;
else if (TREE_CODE (decl) == STRING_CST)
{
if (flag_writable_strings)
return SECCAT_DATA;
if (flag_mudflap)
return SECCAT_RODATA;
else
return SECCAT_RODATA_MERGE_STR;
}
else if (TREE_CODE (decl) == VAR_DECL)
{
if (DECL_INITIAL (decl) == NULL
|| DECL_INITIAL (decl) == error_mark_node
|| (flag_zero_initialized_in_bss
&& !TREE_READONLY (decl)
&& initializer_zerop (DECL_INITIAL (decl))))
ret = SECCAT_BSS;
else if (! TREE_READONLY (decl)
|| TREE_SIDE_EFFECTS (decl)
|| ! TREE_CONSTANT (DECL_INITIAL (decl)))
{
if (shlib && (reloc & 2))
ret = SECCAT_DATA_REL;
else if (shlib && reloc)
ret = SECCAT_DATA_REL_LOCAL;
else
ret = SECCAT_DATA;
}
else if (shlib && (reloc & 2))
ret = SECCAT_DATA_REL_RO;
else if (shlib && reloc)
ret = SECCAT_DATA_REL_RO_LOCAL;
else if (reloc || flag_merge_constants < 2)
ret = SECCAT_RODATA;
else if (TREE_CODE (DECL_INITIAL (decl)) == STRING_CST)
ret = SECCAT_RODATA_MERGE_STR_INIT;
else
ret = SECCAT_RODATA_MERGE_CONST;
}
else if (TREE_CODE (decl) == CONSTRUCTOR)
{
if ((shlib && reloc)
|| TREE_SIDE_EFFECTS (decl)
|| ! TREE_CONSTANT (decl))
ret = SECCAT_DATA;
else
ret = SECCAT_RODATA;
}
else
ret = SECCAT_RODATA;
if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
{
if (ret == SECCAT_BSS
|| (flag_zero_initialized_in_bss
&& initializer_zerop (DECL_INITIAL (decl))))
ret = SECCAT_TBSS;
else
ret = SECCAT_TDATA;
}
else if (targetm.in_small_data_p (decl))
{
if (ret == SECCAT_BSS)
ret = SECCAT_SBSS;
else if (targetm.have_srodata_section && ret == SECCAT_RODATA)
ret = SECCAT_SRODATA;
else
ret = SECCAT_SDATA;
}
return ret;
}
bool
decl_readonly_section (tree decl, int reloc)
{
return decl_readonly_section_1 (decl, reloc, flag_pic);
}
bool
decl_readonly_section_1 (tree decl, int reloc, int shlib)
{
switch (categorize_decl_for_section (decl, reloc, shlib))
{
case SECCAT_RODATA:
case SECCAT_RODATA_MERGE_STR:
case SECCAT_RODATA_MERGE_STR_INIT:
case SECCAT_RODATA_MERGE_CONST:
case SECCAT_SRODATA:
return true;
break;
default:
return false;
break;
}
}
void
default_elf_select_section (tree decl, int reloc,
unsigned HOST_WIDE_INT align)
{
default_elf_select_section_1 (decl, reloc, align, flag_pic);
}
void
default_elf_select_section_1 (tree decl, int reloc,
unsigned HOST_WIDE_INT align, int shlib)
{
const char *sname;
switch (categorize_decl_for_section (decl, reloc, shlib))
{
case SECCAT_TEXT:
abort ();
case SECCAT_RODATA:
readonly_data_section ();
return;
case SECCAT_RODATA_MERGE_STR:
mergeable_string_section (decl, align, 0);
return;
case SECCAT_RODATA_MERGE_STR_INIT:
mergeable_string_section (DECL_INITIAL (decl), align, 0);
return;
case SECCAT_RODATA_MERGE_CONST:
mergeable_constant_section (DECL_MODE (decl), align, 0);
return;
case SECCAT_SRODATA:
sname = ".sdata2";
break;
case SECCAT_DATA:
data_section ();
return;
case SECCAT_DATA_REL:
sname = ".data.rel";
break;
case SECCAT_DATA_REL_LOCAL:
sname = ".data.rel.local";
break;
case SECCAT_DATA_REL_RO:
sname = ".data.rel.ro";
break;
case SECCAT_DATA_REL_RO_LOCAL:
sname = ".data.rel.ro.local";
break;
case SECCAT_SDATA:
sname = ".sdata";
break;
case SECCAT_TDATA:
sname = ".tdata";
break;
case SECCAT_BSS:
#ifdef BSS_SECTION_ASM_OP
bss_section ();
return;
#else
sname = ".bss";
break;
#endif
case SECCAT_SBSS:
sname = ".sbss";
break;
case SECCAT_TBSS:
sname = ".tbss";
break;
default:
abort ();
}
if (!DECL_P (decl))
decl = NULL_TREE;
named_section (decl, sname, reloc);
}
void
default_unique_section (tree decl, int reloc)
{
default_unique_section_1 (decl, reloc, flag_pic);
}
void
default_unique_section_1 (tree decl, int reloc, int shlib)
{
bool one_only = DECL_ONE_ONLY (decl);
const char *prefix, *name;
size_t nlen, plen;
char *string;
switch (categorize_decl_for_section (decl, reloc, shlib))
{
case SECCAT_TEXT:
prefix = one_only ? ".gnu.linkonce.t." : ".text.";
break;
case SECCAT_RODATA:
case SECCAT_RODATA_MERGE_STR:
case SECCAT_RODATA_MERGE_STR_INIT:
case SECCAT_RODATA_MERGE_CONST:
prefix = one_only ? ".gnu.linkonce.r." : ".rodata.";
break;
case SECCAT_SRODATA:
prefix = one_only ? ".gnu.linkonce.s2." : ".sdata2.";
break;
case SECCAT_DATA:
case SECCAT_DATA_REL:
case SECCAT_DATA_REL_LOCAL:
case SECCAT_DATA_REL_RO:
case SECCAT_DATA_REL_RO_LOCAL:
prefix = one_only ? ".gnu.linkonce.d." : ".data.";
break;
case SECCAT_SDATA:
prefix = one_only ? ".gnu.linkonce.s." : ".sdata.";
break;
case SECCAT_BSS:
prefix = one_only ? ".gnu.linkonce.b." : ".bss.";
break;
case SECCAT_SBSS:
prefix = one_only ? ".gnu.linkonce.sb." : ".sbss.";
break;
case SECCAT_TDATA:
prefix = one_only ? ".gnu.linkonce.td." : ".tdata.";
break;
case SECCAT_TBSS:
prefix = one_only ? ".gnu.linkonce.tb." : ".tbss.";
break;
default:
abort ();
}
plen = strlen (prefix);
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
name = targetm.strip_name_encoding (name);
nlen = strlen (name);
string = alloca (nlen + plen + 1);
memcpy (string, prefix, plen);
memcpy (string + plen, name, nlen + 1);
DECL_SECTION_NAME (decl) = build_string (nlen + plen, string);
}
void
default_select_rtx_section (enum machine_mode mode ATTRIBUTE_UNUSED,
rtx x,
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
{
if (flag_pic)
switch (GET_CODE (x))
{
case CONST:
case SYMBOL_REF:
case LABEL_REF:
data_section ();
return;
default:
break;
}
readonly_data_section ();
}
void
default_elf_select_rtx_section (enum machine_mode mode, rtx x,
unsigned HOST_WIDE_INT align)
{
if (flag_pic)
switch (GET_CODE (x))
{
case CONST:
case SYMBOL_REF:
named_section (NULL_TREE, ".data.rel.ro", 3);
return;
case LABEL_REF:
named_section (NULL_TREE, ".data.rel.ro.local", 1);
return;
default:
break;
}
mergeable_constant_section (mode, align, 0);
}
void
default_encode_section_info (tree decl, rtx rtl, int first ATTRIBUTE_UNUSED)
{
rtx symbol;
int flags;
if (!MEM_P (rtl))
return;
symbol = XEXP (rtl, 0);
if (GET_CODE (symbol) != SYMBOL_REF)
return;
flags = 0;
if (TREE_CODE (decl) == FUNCTION_DECL)
flags |= SYMBOL_FLAG_FUNCTION;
if (targetm.binds_local_p (decl))
flags |= SYMBOL_FLAG_LOCAL;
if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL (decl))
flags |= decl_tls_model (decl) << SYMBOL_FLAG_TLS_SHIFT;
else if (targetm.in_small_data_p (decl))
flags |= SYMBOL_FLAG_SMALL;
if (DECL_P (decl) && DECL_EXTERNAL (decl) && TREE_PUBLIC (decl))
flags |= SYMBOL_FLAG_EXTERNAL;
SYMBOL_REF_FLAGS (symbol) = flags;
}
const char *
default_strip_name_encoding (const char *str)
{
return str + (*str == '*');
}
bool
default_binds_local_p (tree exp)
{
return default_binds_local_p_1 (exp, flag_shlib);
}
bool
default_binds_local_p_1 (tree exp, int shlib)
{
bool local_p;
if (!DECL_P (exp))
local_p = true;
else if (! TREE_PUBLIC (exp))
local_p = true;
else if (DECL_VISIBILITY_SPECIFIED (exp) && DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
local_p = true;
else if (DECL_EXTERNAL (exp))
local_p = false;
else if (DECL_ONE_ONLY (exp) || DECL_WEAK (exp))
local_p = false;
else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
local_p = true;
else if (shlib)
local_p = false;
else if (DECL_COMMON (exp)
&& (DECL_INITIAL (exp) == NULL
|| DECL_INITIAL (exp) == error_mark_node))
local_p = false;
else
local_p = true;
return local_p;
}
bool
default_valid_pointer_mode (enum machine_mode mode)
{
return (mode == ptr_mode || mode == Pmode);
}
#ifdef GLOBAL_ASM_OP
void
default_globalize_label (FILE * stream, const char *name)
{
fputs (GLOBAL_ASM_OP, stream);
assemble_name (stream, name);
putc ('\n', stream);
}
#endif
void
default_emit_unwind_label (FILE * stream ATTRIBUTE_UNUSED,
tree decl ATTRIBUTE_UNUSED,
int for_eh ATTRIBUTE_UNUSED,
int empty ATTRIBUTE_UNUSED)
{
}
void
default_internal_label (FILE *stream, const char *prefix,
unsigned long labelno)
{
char *const buf = alloca (40 + strlen (prefix));
ASM_GENERATE_INTERNAL_LABEL (buf, prefix, labelno);
ASM_OUTPUT_INTERNAL_LABEL (stream, buf);
}
void
default_file_start (void)
{
if (targetm.file_start_app_off && !flag_verbose_asm)
fputs (ASM_APP_OFF, asm_out_file);
if (targetm.file_start_file_directive)
output_file_directive (asm_out_file, main_input_filename);
}
int trampolines_created;
void
file_end_indicate_exec_stack (void)
{
unsigned int flags = SECTION_DEBUG;
if (trampolines_created)
flags |= SECTION_CODE;
named_section_flags (".note.GNU-stack", flags);
}
#include "gt-varasm.h"