This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] PowerPC select_section / unique_section
- From: David Edelsohn <dje at watson dot ibm dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Jeff Sturm <jsturm at one-point dot com>, Alan Modra <amodra at bigpond dot net dot au>, Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>, Geoff Keating <geoffk at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Tue, 03 Sep 2002 13:40:19 -0400
- Subject: Re: [RFC] PowerPC select_section / unique_section
>>>>> Richard Henderson writes:
>> Do you want all of the default_* functions wrapped around a
>> default_*_1 function instead of adding flag_pic at the call sites?
Richard> I think so, yes.
How about the following patch? Then we can move on to integrating
sdata.
Thanks, David
* varasm.c (default_section_type_flags): Append _1 to name with
shlib parameter. Use original name to call new function with
implicit flag_pic.
(decl_readonly_section): Likewise.
(default_elf_select_section): Likewise.
(default_unique_section): Likewise.
(default_bind_local_p): Likewise.
(categorize_decl_for_section): Add shlib parameter to use in place
of implicit flag_pic.
* output.h: Declare new functions with _1 and shlib argument.
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.303
diff -c -p -r1.303 varasm.c
*** varasm.c 21 Aug 2002 02:41:44 -0000 1.303
--- varasm.c 3 Sep 2002 17:29:08 -0000
*************** init_varasm_once ()
*** 4686,4701 ****
read-only for a const data decl, and writable for a non-const data decl. */
unsigned int
! default_section_type_flags (decl, name, reloc)
tree decl;
const char *name;
int reloc;
{
unsigned int flags;
if (decl && TREE_CODE (decl) == FUNCTION_DECL)
flags = SECTION_CODE;
! else if (decl && decl_readonly_section (decl, reloc))
flags = 0;
else
flags = SECTION_WRITE;
--- 4686,4702 ----
read-only for a const data decl, and writable for a non-const data decl. */
unsigned int
! default_section_type_flags_1 (decl, name, reloc, shlib)
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
flags = SECTION_WRITE;
*************** default_section_type_flags (decl, name,
*** 4725,4730 ****
--- 4726,4740 ----
return flags;
}
+ unsigned int
+ default_section_type_flags (decl, name, reloc)
+ tree decl;
+ const char *name;
+ int reloc;
+ {
+ return default_section_type_flags_1 (decl, name, reloc, flag_pic);
+ }
+
/* Output assembly to switch to section NAME with attribute FLAGS.
Four variants for common object file formats. */
*************** enum section_category
*** 4913,4924 ****
SECCAT_TBSS
};
! static enum section_category categorize_decl_for_section PARAMS ((tree, int));
static enum section_category
! categorize_decl_for_section (decl, reloc)
tree decl;
int reloc;
{
enum section_category ret;
--- 4923,4936 ----
SECCAT_TBSS
};
! static enum section_category
! categorize_decl_for_section PARAMS ((tree, int, int));
static enum section_category
! categorize_decl_for_section (decl, reloc, shlib)
tree decl;
int reloc;
+ int shlib;
{
enum section_category ret;
*************** categorize_decl_for_section (decl, reloc
*** 4940,4955 ****
|| TREE_SIDE_EFFECTS (decl)
|| ! TREE_CONSTANT (DECL_INITIAL (decl)))
{
! if (flag_pic && (reloc & 2))
ret = SECCAT_DATA_REL;
! else if (flag_pic && reloc)
ret = SECCAT_DATA_REL_LOCAL;
else
ret = SECCAT_DATA;
}
! else if (flag_pic && (reloc & 2))
ret = SECCAT_DATA_REL_RO;
! else if (flag_pic && reloc)
ret = SECCAT_DATA_REL_RO_LOCAL;
else if (flag_merge_constants < 2)
/* C and C++ don't allow different variables to share the same
--- 4952,4967 ----
|| 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 (flag_merge_constants < 2)
/* C and C++ don't allow different variables to share the same
*************** categorize_decl_for_section (decl, reloc
*** 4963,4969 ****
}
else if (TREE_CODE (decl) == CONSTRUCTOR)
{
! if ((flag_pic && reloc)
|| TREE_SIDE_EFFECTS (decl)
|| ! TREE_CONSTANT (decl))
ret = SECCAT_DATA;
--- 4975,4981 ----
}
else if (TREE_CODE (decl) == CONSTRUCTOR)
{
! if ((shlib && reloc)
|| TREE_SIDE_EFFECTS (decl)
|| ! TREE_CONSTANT (decl))
ret = SECCAT_DATA;
*************** categorize_decl_for_section (decl, reloc
*** 4995,5005 ****
}
bool
! decl_readonly_section (decl, reloc)
tree decl;
int reloc;
{
! switch (categorize_decl_for_section (decl, reloc))
{
case SECCAT_RODATA:
case SECCAT_RODATA_MERGE_STR:
--- 5007,5018 ----
}
bool
! decl_readonly_section_1 (decl, reloc, shlib)
tree decl;
int reloc;
+ int shlib;
{
! switch (categorize_decl_for_section (decl, reloc, shlib))
{
case SECCAT_RODATA:
case SECCAT_RODATA_MERGE_STR:
*************** decl_readonly_section (decl, reloc)
*** 5013,5027 ****
}
}
/* Select a section based on the above categorization. */
void
! default_elf_select_section (decl, reloc, align)
tree decl;
int reloc;
unsigned HOST_WIDE_INT align;
{
! switch (categorize_decl_for_section (decl, reloc))
{
case SECCAT_TEXT:
/* We're not supposed to be called on FUNCTION_DECLs. */
--- 5026,5049 ----
}
}
+ bool
+ decl_readonly_section (decl, reloc)
+ tree decl;
+ int reloc;
+ {
+ return decl_readonly_section_1 (decl, reloc, flag_pic);
+ }
+
/* Select a section based on the above categorization. */
void
! default_elf_select_section_1 (decl, reloc, align, shlib)
tree decl;
int reloc;
unsigned HOST_WIDE_INT align;
+ int shlib;
{
! switch (categorize_decl_for_section (decl, reloc, shlib))
{
case SECCAT_TEXT:
/* We're not supposed to be called on FUNCTION_DECLs. */
*************** default_elf_select_section (decl, reloc,
*** 5077,5096 ****
}
}
/* Construct a unique section name based on the decl name and the
categorization performed above. */
void
! default_unique_section (decl, reloc)
tree decl;
int reloc;
{
bool one_only = DECL_ONE_ONLY (decl);
const char *prefix, *name;
size_t nlen, plen;
char *string;
! switch (categorize_decl_for_section (decl, reloc))
{
case SECCAT_TEXT:
prefix = one_only ? ".gnu.linkonce.t." : ".text.";
--- 5099,5128 ----
}
}
+ void
+ default_elf_select_section (decl, reloc, align)
+ tree decl;
+ int reloc;
+ unsigned HOST_WIDE_INT align;
+ {
+ return default_elf_select_section_1 (decl, reloc, align, flag_pic);
+ }
+
/* Construct a unique section name based on the decl name and the
categorization performed above. */
void
! default_unique_section_1 (decl, reloc, shlib)
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.";
*************** default_unique_section (decl, reloc)
*** 5140,5145 ****
--- 5172,5185 ----
}
void
+ default_unique_section (decl, reloc)
+ tree decl;
+ int reloc;
+ {
+ return default_unique_section_1 (decl, reloc, flag_pic);
+ }
+
+ void
default_select_rtx_section (mode, x, align)
enum machine_mode mode ATTRIBUTE_UNUSED;
rtx x;
*************** default_strip_name_encoding (str)
*** 5202,5209 ****
wrt cross-module name binding. */
bool
! default_binds_local_p (exp)
tree exp;
{
bool local_p;
--- 5242,5250 ----
wrt cross-module name binding. */
bool
! default_binds_local_p_1 (exp, shlib)
tree exp;
+ int shlib;
{
bool local_p;
*************** default_binds_local_p (exp)
*** 5224,5230 ****
local_p = false;
/* If PIC, then assume that any global name can be overridden by
symbols resolved from other modules. */
! else if (flag_pic)
local_p = false;
/* Uninitialized COMMON variable may be unified with symbols
resolved from other modules. */
--- 5265,5271 ----
local_p = false;
/* If PIC, then assume that any global name can be overridden by
symbols resolved from other modules. */
! else if (shlib)
local_p = false;
/* Uninitialized COMMON variable may be unified with symbols
resolved from other modules. */
*************** default_binds_local_p (exp)
*** 5238,5243 ****
--- 5279,5291 ----
local_p = true;
return local_p;
+ }
+
+ bool
+ default_binds_local_p (exp)
+ tree exp;
+ {
+ return default_binds_local_p (exp, flag_pic);
}
/* Default function to output code that will globalize a label. A
Index: output.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/output.h,v
retrieving revision 1.109
diff -c -p -r1.109 output.h
*** output.h 21 Aug 2002 02:41:44 -0000 1.109
--- output.h 3 Sep 2002 17:29:08 -0000
*************** extern rtx this_is_asm_operands;
*** 468,473 ****
--- 468,474 ----
/* Decide whether DECL needs to be in a writable section.
RELOC is the same as for SELECT_SECTION. */
extern bool decl_readonly_section PARAMS ((tree, int));
+ extern bool decl_readonly_section_1 PARAMS ((tree, int, int));
/* User label prefix in effect for this compilation. */
extern const char *user_label_prefix;
*************** extern bool named_section_first_declarat
*** 508,513 ****
--- 509,517 ----
union tree_node;
extern unsigned int default_section_type_flags PARAMS ((union tree_node *,
const char *, int));
+ extern unsigned int default_section_type_flags_1 PARAMS ((union tree_node *,
+ const char *,
+ int, int));
extern void default_no_named_section PARAMS ((const char *, unsigned int));
extern void default_elf_asm_named_section PARAMS ((const char *, unsigned int));
*************** extern void default_select_section PARAM
*** 530,542 ****
--- 534,550 ----
unsigned HOST_WIDE_INT));
extern void default_elf_select_section PARAMS ((tree, int,
unsigned HOST_WIDE_INT));
+ extern void default_elf_select_section_1 PARAMS ((tree, int,
+ unsigned HOST_WIDE_INT, int));
extern void default_unique_section PARAMS ((tree, int));
+ extern void default_unique_section_1 PARAMS ((tree, int, int));
extern void default_select_rtx_section PARAMS ((enum machine_mode, rtx,
unsigned HOST_WIDE_INT));
extern void default_elf_select_rtx_section PARAMS ((enum machine_mode, rtx,
unsigned HOST_WIDE_INT));
extern const char *default_strip_name_encoding PARAMS ((const char *));
extern bool default_binds_local_p PARAMS ((tree));
+ extern bool default_binds_local_p_1 PARAMS ((tree, int));
extern void default_globalize_label PARAMS ((FILE *, const char *));
/* Emit data for vtable gc for GNU binutils. */