This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] PowerPC select_section / unique_section


	To use the varasm decl analysis machinery in PowerPC, I suggest
defining the functions to accept a "pic" argument as appended, with
appropriate changes to target-specific callers of decl_readonly_section.
Then the functions are flexible-enough to be called from more targets.

	Comments?  Geoff?  Richard?

David


	* output.h (decl_readonly_section): Add pic parameter.
	* varasm.c (default_section_type_flags): Use flag_pic as pic
	argument to decl_readonly_section.
	(default_select_section): Same.
	(categorize_decl_for_section): Add pic parameter. Use it in place
	of flag_pic.
	(decl_readonly_section): Add pic paramter.
	(default_elf_select_section): Use flag_pic as pic argument to
	categorize_decl_for_section. 
	(default_unique_section): Same.
	

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	22 Aug 2002 19:42:11 -0000
*************** extern rtx this_is_asm_operands;
*** 467,473 ****
  
  /* 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));
  
  /* User label prefix in effect for this compilation.  */
  extern const char *user_label_prefix;
--- 467,473 ----
  
  /* 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, int));
  
  /* User label prefix in effect for this compilation.  */
  extern const char *user_label_prefix;
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	22 Aug 2002 19:42:11 -0000
*************** default_section_type_flags (decl, name, 
*** 4695,4701 ****
  
    if (decl && TREE_CODE (decl) == FUNCTION_DECL)
      flags = SECTION_CODE;
!   else if (decl && decl_readonly_section (decl, reloc))
      flags = 0;
    else
      flags = SECTION_WRITE;
--- 4695,4701 ----
  
    if (decl && TREE_CODE (decl) == FUNCTION_DECL)
      flags = SECTION_CODE;
!   else if (decl && decl_readonly_section (decl, reloc, flag_pic))
      flags = 0;
    else
      flags = SECTION_WRITE;
*************** default_select_section (decl, reloc, ali
*** 4855,4861 ****
  
    if (DECL_P (decl))
      {
!       if (decl_readonly_section (decl, reloc))
  	readonly = true;
      }
    else if (TREE_CODE (decl) == CONSTRUCTOR)
--- 4855,4861 ----
  
    if (DECL_P (decl))
      {
!       if (decl_readonly_section (decl, reloc, flag_pic))
  	readonly = true;
      }
    else if (TREE_CODE (decl) == CONSTRUCTOR)
*************** 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;
  
--- 4913,4926 ----
    SECCAT_TBSS
  };
  
! static enum section_category
! categorize_decl_for_section PARAMS ((tree, int, int));
  
  static enum section_category
! categorize_decl_for_section (decl, reloc, pic)
       tree decl;
       int reloc;
+      int pic;
  {
    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
--- 4942,4957 ----
  	       || TREE_SIDE_EFFECTS (decl)
  	       || ! TREE_CONSTANT (DECL_INITIAL (decl)))
  	{
! 	  if (pic && (reloc & 2))
  	    ret = SECCAT_DATA_REL;
! 	  else if (pic && reloc)
  	    ret = SECCAT_DATA_REL_LOCAL;
  	  else
  	    ret = SECCAT_DATA;
  	}
!       else if (pic && (reloc & 2))
  	ret = SECCAT_DATA_REL_RO;
!       else if (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
*************** 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;
--- 4965,4971 ----
      }
    else if (TREE_CODE (decl) == CONSTRUCTOR)
      {
!       if ((pic && 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:
--- 4997,5008 ----
  }
  
  bool
! decl_readonly_section (decl, reloc, pic)
       tree decl;
       int reloc;
+      int pic;
  {
!   switch (categorize_decl_for_section (decl, reloc, pic))
      {
      case SECCAT_RODATA:
      case SECCAT_RODATA_MERGE_STR:
*************** default_elf_select_section (decl, reloc,
*** 5021,5027 ****
       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.  */
--- 5024,5030 ----
       int reloc;
       unsigned HOST_WIDE_INT align;
  {
!   switch (categorize_decl_for_section (decl, reloc, flag_pic))
      {
      case SECCAT_TEXT:
        /* We're not supposed to be called on FUNCTION_DECLs.  */
*************** default_unique_section (decl, reloc)
*** 5090,5096 ****
    size_t nlen, plen;
    char *string;
  
!   switch (categorize_decl_for_section (decl, reloc))
      {
      case SECCAT_TEXT:
        prefix = one_only ? ".gnu.linkonce.t." : ".text.";
--- 5093,5099 ----
    size_t nlen, plen;
    char *string;
  
!   switch (categorize_decl_for_section (decl, reloc, flag_pic))
      {
      case SECCAT_TEXT:
        prefix = one_only ? ".gnu.linkonce.t." : ".text.";


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]