darwin.c (machopic_select_section): Rewrite.

2006-12-19  Eric Christopher  <echristo@apple.com>

        * config/darwin.c (machopic_select_section): Rewrite.
        (darwin_text_section): New.
        (darwin_rodata_section): Ditto.
        (darwin_mergeable_string_section): Ditto.
        (darwin_mergeable_constant_section): Ditto.
        * config/darwin-sections.def: Add SECTION_STRINGS for cstring_section.

From-SVN: r120066
This commit is contained in:
Eric Christopher 2006-12-20 00:42:34 +00:00
parent 91321cd022
commit 59ff4a1c1c
3 changed files with 188 additions and 102 deletions

View File

@ -1,3 +1,12 @@
2006-12-19 Eric Christopher <echristo@apple.com>
* config/darwin.c (machopic_select_section): Rewrite.
(darwin_text_section): New.
(darwin_rodata_section): Ditto.
(darwin_mergeable_string_section): Ditto.
(darwin_mergeable_constant_section): Ditto.
* config/darwin-sections.def: Add SECTION_STRINGS for cstring_section.
2006-12-19 Steve Ellcey <sje@cup.hp.com>
* config/pa/pa64-hpux.h (ASM_OUTPUT_EXTERNAL): Add undef.
@ -66,7 +75,7 @@
(init_ssa_operands): Initialize operand memory and free lists.
(fini_ssa_operands): Remove references to free_vuses and free_vdefs.
(ssa_operand_alloc): Use graduated size memory allocation.
(APPEND_OP_AFTER, MOVE_HEAD_AFTER, MOVE_HEAD_TO_FREELIST,
(APPEND_OP_AFTER, MOVE_HEAD_AFTER, MOVE_HEAD_TO_FREELIST,
INITIALIZE_USE): Remove.
(alloc_vop): New. Allocate a virtual operand.
(alloc_vdef, alloc_vuse): Delete.
@ -168,7 +177,7 @@
* c-opts.c (c_common_post_options): Enabled by -Wextra.
* c-common.c (empty_body_warning): Replace Wextra with Wempty-body.
* c-parser.c (c_parser_c99_block_statement): Likewise.
2006-12-15 Jakub Jelinek <jakub@redhat.com>
PR target/30185
@ -215,8 +224,8 @@
Trevor Smigiel <trevor_smigiel@playstation.sony.com>
* spu.c (TARGET_VECTORIZE_BUILTIN_MASK_FOR_LOAD): Defined.
(spu_init_builtins): Mark the SPU_MASK_FOR_LOAD builtin decl as read
only.
(spu_init_builtins): Mark the SPU_MASK_FOR_LOAD builtin decl as read
only.
(spu_expand_builtin_1): Handle the SPU_MASK_FOR_LOAD builtin.
(spu_builtin_mask_for_load): New.
* spu-builtins.def (SPU_MASK_FOR_LOAD): Define new builtin.
@ -474,7 +483,7 @@
2006-12-12 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR tree-opt/28624
* tree-ssa-dom.c (eliminate_degenerate_phis): Use a temporary
* tree-ssa-dom.c (eliminate_degenerate_phis): Use a temporary
bitmap for EXECUTE_IF_SET_IN_BITMAP.
2006-12-12 Andrew Pinski <andrew_pinski@playstation.sony.com>
@ -535,9 +544,9 @@
remove redundant pass_partition_blocks declaration.
2006-12-12 Andrew Macleod <amacleod@redhat.com>
PR tree-optimization/30159
* tree-ssa-coalesce.c (coalesce_ssa_name): Process single ssa_name
* tree-ssa-coalesce.c (coalesce_ssa_name): Process single ssa_name
functions in case a default_def coalesce is required.
2006-12-12 Jakub Jelinek <jakub@redhat.com>
@ -577,9 +586,9 @@
2006-12-12 Olivier Hainque <hainque@adacore.com>
* config/vxlib.c: Extract tls related routines into ...
* config/vxlib-tls.c: New file.
* config/vxlib-tls.c: New file.
* config/t-vxworks: Add vxlib-tls.c to LIB2FUNCS_EXTRA.
2006-12-12 Sa Liu <saliu@de.ibm.com>
Ben Elliston <bje@au.ibm.com>
@ -1204,7 +1213,7 @@
2006-12-11 Ira Rosen <irar@il.ibm.com>
* tree-vect-patterns.c (vect_recog_dot_prod_pattern): Use
* tree-vect-patterns.c (vect_recog_dot_prod_pattern): Use
GIMPLE_STMT_OPERAND.
* tree-vect-transform.c (vect_permute_store_chain): Likewise.
(vect_setup_realignment): Likewise.
@ -1326,7 +1335,7 @@
* tree-flow-inline.h (single_imm_use_p): New. Check for single use.
* tree-outof-ssa.c: Remove header files which aren't needed.
(SSANORM_*): Remove flags.
(print_exprs_edge, coalesce_abnormal_edges, coalesce_phi_operands,
(print_exprs_edge, coalesce_abnormal_edges, coalesce_phi_operands,
coalesce_result_decls_and_copies, coalesce_asm_operands): Remove.
(coalesce_ssa_name): Move to tree-ssa-coalesce.c.
(assign_vars): Use Basevar instead of root_var structure.
@ -1402,7 +1411,7 @@
tpa_dump): Moved to tree-ssa-coalesce.c and/or renamed there.
(dump_var_map): Use renamed fields.
* tree-ssa-live.h (struct _var_map): Modify fields.
(partition_to_var, version_to_var, var_to_partition): Use renamed
(partition_to_var, version_to_var, var_to_partition): Use renamed
fields.
(basevar_index): New. Index of the base variable of a partition.
(num_basevars): New. Number of unique base variables in partition map.
@ -1411,9 +1420,9 @@
(tpa_num_trees, tpa_tree, tpa_first_partition, tpa_next_partition,
tpa_find_tree, tpa_decompact, root_var_init, root_var_num,
root_var, root_var_first_partition, root_var_next_partition,
root_var_dump, root_var_delete, root_var_remove_partition,
root_var_dump, root_var_delete, root_var_remove_partition,
root_var_find, root_var_compact, root_var_decompact): Remove.
(struct partition_pair, struct coalesce_list_d): Moved to
(struct partition_pair, struct coalesce_list_d): Moved to
tree-ssa-coalesce.c
* tree-ssa-ter.c: Remove header files which aren't needed.

View File

@ -11,7 +11,7 @@ DEF_SECTION (const_data_coal_section, 0,
".section __DATA,__const_coal,coalesced", 0)
DEF_SECTION (data_coal_section, SECTION_WRITE,
".section __DATA,__datacoal_nt,coalesced", 0)
DEF_SECTION (cstring_section, SECTION_MERGE, ".cstring", 0)
DEF_SECTION (cstring_section, SECTION_MERGE | SECTION_STRINGS, ".cstring", 0)
DEF_SECTION (literal4_section, SECTION_MERGE, ".literal4", 0)
DEF_SECTION (literal8_section, SECTION_MERGE, ".literal8", 0)
DEF_SECTION (literal16_section, SECTION_MERGE, ".literal16", 0)

View File

@ -1095,138 +1095,215 @@ darwin_mark_decl_preserved (const char *name)
fputc ('\n', asm_out_file);
}
section *
machopic_select_section (tree exp, int reloc,
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
static section *
darwin_text_section (int reloc, int weak)
{
section *base_section;
bool weak_p = (DECL_P (exp) && DECL_WEAK (exp)
&& (lookup_attribute ("weak", DECL_ATTRIBUTES (exp))
|| ! lookup_attribute ("weak_import",
DECL_ATTRIBUTES (exp))));
if (TREE_CODE (exp) == FUNCTION_DECL)
{
if (reloc == 1)
base_section = (weak_p
? darwin_sections[text_unlikely_coal_section]
: unlikely_text_section ());
else
base_section = weak_p ? darwin_sections[text_coal_section]
: text_section;
}
else if (decl_readonly_section_1 (exp, reloc, MACHOPIC_INDIRECT))
base_section = weak_p ? darwin_sections[const_coal_section]
: darwin_sections[const_section];
else if (TREE_READONLY (exp) || TREE_CONSTANT (exp))
base_section = weak_p ? darwin_sections[const_data_coal_section]
: darwin_sections[const_data_section];
if (reloc)
return (weak
? darwin_sections[text_unlikely_coal_section]
: unlikely_text_section ());
else
base_section = weak_p ? darwin_sections[data_coal_section] : data_section;
return (weak
? darwin_sections[text_coal_section]
: text_section);
}
if (TREE_CODE (exp) == STRING_CST
static section *
darwin_rodata_section (int weak)
{
return (weak
? darwin_sections[const_coal_section]
: darwin_sections[const_section]);
}
static section *
darwin_mergeable_string_section (tree exp,
unsigned HOST_WIDE_INT align)
{
if (flag_merge_constants
&& TREE_CODE (exp) == STRING_CST
&& TREE_CODE (TREE_TYPE (exp)) == ARRAY_TYPE
&& align <= 256
&& ((size_t) TREE_STRING_LENGTH (exp)
== strlen (TREE_STRING_POINTER (exp)) + 1))
return darwin_sections[cstring_section];
else if ((TREE_CODE (exp) == INTEGER_CST || TREE_CODE (exp) == REAL_CST)
&& flag_merge_constants)
return readonly_data_section;
}
static section *
darwin_mergeable_constant_section (tree exp,
unsigned HOST_WIDE_INT align)
{
enum machine_mode mode = DECL_MODE (exp);
unsigned int modesize = GET_MODE_BITSIZE (mode);
if (flag_merge_constants
&& mode != VOIDmode
&& mode != BLKmode
&& modesize <= align
&& align >= 8
&& align <= 256
&& (align & (align -1)) == 0)
{
tree size = TYPE_SIZE_UNIT (TREE_TYPE (exp));
if (TREE_CODE (size) == INTEGER_CST &&
TREE_INT_CST_LOW (size) == 4 &&
TREE_INT_CST_HIGH (size) == 0)
return darwin_sections[literal4_section];
else if (TREE_CODE (size) == INTEGER_CST &&
TREE_INT_CST_LOW (size) == 8 &&
TREE_INT_CST_HIGH (size) == 0)
return darwin_sections[literal8_section];
else if (TARGET_64BIT
&& TREE_CODE (size) == INTEGER_CST
&& TREE_INT_CST_LOW (size) == 16
if (TREE_CODE (size) == INTEGER_CST
&& TREE_INT_CST_LOW (size) == 4
&& TREE_INT_CST_HIGH (size) == 0)
return darwin_sections[literal4_section];
else if (TREE_CODE (size) == INTEGER_CST
&& TREE_INT_CST_LOW (size) == 8
&& TREE_INT_CST_HIGH (size) == 0)
return darwin_sections[literal16_section];
return darwin_sections[literal8_section];
else if (TARGET_64BIT
&& TREE_CODE (size) == INTEGER_CST
&& TREE_INT_CST_LOW (size) == 16
&& TREE_INT_CST_HIGH (size) == 0)
return darwin_sections[literal16_section];
else
return base_section;
return readonly_data_section;
}
else if (TREE_CODE (exp) == CONSTRUCTOR
&& TREE_TYPE (exp)
&& TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
&& TYPE_NAME (TREE_TYPE (exp)))
return readonly_data_section;
}
section *
machopic_select_section (tree decl,
int reloc,
unsigned HOST_WIDE_INT align)
{
bool weak = (DECL_P (decl)
&& DECL_WEAK (decl)
&& (lookup_attribute ("weak", DECL_ATTRIBUTES (decl))
|| ! lookup_attribute ("weak_import",
DECL_ATTRIBUTES (decl))));
int shlib = flag_pic;
section *base_section;
switch (categorize_decl_for_section (decl, reloc, shlib))
{
tree name = TYPE_NAME (TREE_TYPE (exp));
case SECCAT_TEXT:
base_section = darwin_text_section (reloc, weak);
break;
case SECCAT_RODATA:
case SECCAT_SRODATA:
base_section = darwin_rodata_section (weak);
break;
case SECCAT_RODATA_MERGE_STR:
base_section = darwin_mergeable_string_section (decl, align);
break;
case SECCAT_RODATA_MERGE_STR_INIT:
base_section = darwin_mergeable_string_section (DECL_INITIAL (decl), align);
break;
case SECCAT_RODATA_MERGE_CONST:
base_section = darwin_mergeable_constant_section (decl, align);
break;
case SECCAT_DATA:
case SECCAT_DATA_REL:
case SECCAT_DATA_REL_LOCAL:
case SECCAT_DATA_REL_RO:
case SECCAT_DATA_REL_RO_LOCAL:
case SECCAT_SDATA:
case SECCAT_TDATA:
case SECCAT_BSS:
case SECCAT_SBSS:
case SECCAT_TBSS:
if (TREE_READONLY (decl) || TREE_CONSTANT (decl))
base_section = weak ? darwin_sections[const_data_coal_section]
: darwin_sections[const_data_section];
else
base_section = weak ? darwin_sections[data_coal_section] : data_section;
break;
default:
gcc_unreachable ();
}
/* Darwin weird special cases. */
if (TREE_CODE (decl) == CONSTRUCTOR
&& TREE_TYPE (decl)
&& TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
&& TYPE_NAME (TREE_TYPE (decl)))
{
tree name = TYPE_NAME (TREE_TYPE (decl));
if (TREE_CODE (name) == TYPE_DECL)
name = DECL_NAME (name);
name = DECL_NAME (name);
if (!strcmp (IDENTIFIER_POINTER (name), "__builtin_ObjCString"))
{
if (flag_next_runtime)
return darwin_sections[objc_constant_string_object_section];
else
return darwin_sections[objc_string_object_section];
}
{
if (flag_next_runtime)
return darwin_sections[objc_constant_string_object_section];
else
return darwin_sections[objc_string_object_section];
}
else
return base_section;
return base_section;
}
else if (TREE_CODE (exp) == VAR_DECL &&
DECL_NAME (exp) &&
TREE_CODE (DECL_NAME (exp)) == IDENTIFIER_NODE &&
IDENTIFIER_POINTER (DECL_NAME (exp)) &&
!strncmp (IDENTIFIER_POINTER (DECL_NAME (exp)), "_OBJC_", 6))
else if (TREE_CODE (decl) == VAR_DECL
&& DECL_NAME (decl)
&& TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE
&& IDENTIFIER_POINTER (DECL_NAME (decl))
&& !strncmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "_OBJC_", 6))
{
const char *name = IDENTIFIER_POINTER (DECL_NAME (exp));
const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
if (!strncmp (name, "_OBJC_CLASS_METHODS_", 20))
return darwin_sections[objc_cls_meth_section];
return darwin_sections[objc_cls_meth_section];
else if (!strncmp (name, "_OBJC_INSTANCE_METHODS_", 23))
return darwin_sections[objc_inst_meth_section];
return darwin_sections[objc_inst_meth_section];
else if (!strncmp (name, "_OBJC_CATEGORY_CLASS_METHODS_", 20))
return darwin_sections[objc_cat_cls_meth_section];
return darwin_sections[objc_cat_cls_meth_section];
else if (!strncmp (name, "_OBJC_CATEGORY_INSTANCE_METHODS_", 23))
return darwin_sections[objc_cat_inst_meth_section];
return darwin_sections[objc_cat_inst_meth_section];
else if (!strncmp (name, "_OBJC_CLASS_VARIABLES_", 22))
return darwin_sections[objc_class_vars_section];
return darwin_sections[objc_class_vars_section];
else if (!strncmp (name, "_OBJC_INSTANCE_VARIABLES_", 25))
return darwin_sections[objc_instance_vars_section];
return darwin_sections[objc_instance_vars_section];
else if (!strncmp (name, "_OBJC_CLASS_PROTOCOLS_", 22))
return darwin_sections[objc_cat_cls_meth_section];
return darwin_sections[objc_cat_cls_meth_section];
else if (!strncmp (name, "_OBJC_CLASS_NAME_", 17))
return darwin_sections[objc_class_names_section];
return darwin_sections[objc_class_names_section];
else if (!strncmp (name, "_OBJC_METH_VAR_NAME_", 20))
return darwin_sections[objc_meth_var_names_section];
return darwin_sections[objc_meth_var_names_section];
else if (!strncmp (name, "_OBJC_METH_VAR_TYPE_", 20))
return darwin_sections[objc_meth_var_types_section];
return darwin_sections[objc_meth_var_types_section];
else if (!strncmp (name, "_OBJC_CLASS_REFERENCES", 22))
return darwin_sections[objc_cls_refs_section];
return darwin_sections[objc_cls_refs_section];
else if (!strncmp (name, "_OBJC_CLASS_", 12))
return darwin_sections[objc_class_section];
return darwin_sections[objc_class_section];
else if (!strncmp (name, "_OBJC_METACLASS_", 16))
return darwin_sections[objc_meta_class_section];
return darwin_sections[objc_meta_class_section];
else if (!strncmp (name, "_OBJC_CATEGORY_", 15))
return darwin_sections[objc_category_section];
return darwin_sections[objc_category_section];
else if (!strncmp (name, "_OBJC_SELECTOR_REFERENCES", 25))
return darwin_sections[objc_selector_refs_section];
return darwin_sections[objc_selector_refs_section];
else if (!strncmp (name, "_OBJC_SELECTOR_FIXUP", 20))
return darwin_sections[objc_selector_fixup_section];
return darwin_sections[objc_selector_fixup_section];
else if (!strncmp (name, "_OBJC_SYMBOLS", 13))
return darwin_sections[objc_symbols_section];
return darwin_sections[objc_symbols_section];
else if (!strncmp (name, "_OBJC_MODULES", 13))
return darwin_sections[objc_module_info_section];
return darwin_sections[objc_module_info_section];
else if (!strncmp (name, "_OBJC_IMAGE_INFO", 16))
return darwin_sections[objc_image_info_section];
return darwin_sections[objc_image_info_section];
else if (!strncmp (name, "_OBJC_PROTOCOL_INSTANCE_METHODS_", 32))
return darwin_sections[objc_cat_inst_meth_section];
return darwin_sections[objc_cat_inst_meth_section];
else if (!strncmp (name, "_OBJC_PROTOCOL_CLASS_METHODS_", 29))
return darwin_sections[objc_cat_cls_meth_section];
return darwin_sections[objc_cat_cls_meth_section];
else if (!strncmp (name, "_OBJC_PROTOCOL_REFS_", 20))
return darwin_sections[objc_cat_cls_meth_section];
return darwin_sections[objc_cat_cls_meth_section];
else if (!strncmp (name, "_OBJC_PROTOCOL_", 15))
return darwin_sections[objc_protocol_section];
return darwin_sections[objc_protocol_section];
else
return base_section;
return base_section;
}
else
return base_section;
return base_section;
}
/* This can be called with address expressions as "rtx".