This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[mep] Update support for VLIW sections
- From: DJ Delorie <dj at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 28 Jul 2009 21:08:49 -0400
- Subject: [mep] Update support for VLIW sections
Needed to prevent problems with mismatched section flags due to lack
of support for VLIW linkonce sections. Committed.
* config/mep/mep.c (vtext_section): New.
(vftext_section): New.
(ftext_section): New.
(mep_select_section): Add support for functions.
(mep_unique_section): Likewise.
(mep_asm_init_sections): Likewise.
(mep_encode_section_info): Remove it from here.
2009-07-28 Douglas B Rupp <rupp@gnat.com>
Index: config/mep/mep.c
===================================================================
--- config/mep/mep.c (revision 150189)
+++ config/mep/mep.c (working copy)
@@ -126,12 +126,16 @@ static GTY(()) section * based_section;
static GTY(()) section * tinybss_section;
static GTY(()) section * far_section;
static GTY(()) section * farbss_section;
static GTY(()) section * frodata_section;
static GTY(()) section * srodata_section;
+static GTY(()) section * vtext_section;
+static GTY(()) section * vftext_section;
+static GTY(()) section * ftext_section;
+
static void mep_set_leaf_registers (int);
static bool symbol_p (rtx);
static bool symbolref_p (rtx);
static void encode_pattern_1 (rtx);
static void encode_pattern (rtx);
static bool const_in_range (rtx, int, int);
@@ -4550,44 +4554,12 @@ mep_encode_section_info (tree decl, rtx
oldname,
(long) int_size_in_bytes (TREE_TYPE (decl)),
secname,
maxsize);
}
}
-
- /* Functions do not go through select_section, so we force it here
- by using the DECL_SECTION_NAME as if the user specified the
- .vtext or .ftext sections. */
- if (! DECL_SECTION_NAME (decl)
- && TREE_CODE (decl) == FUNCTION_DECL)
- {
- tree secname;
-
- if (lookup_attribute ("vliw", TYPE_ATTRIBUTES (TREE_TYPE (decl))))
- {
- if (encoding == 'f')
- DECL_SECTION_NAME (decl) = build_string (7, ".vftext");
- else
- DECL_SECTION_NAME (decl) = build_string (6, ".vtext");
- }
- else if (encoding == 'f')
- {
- if (flag_function_sections || DECL_ONE_ONLY (decl))
- mep_unique_section (decl, 0);
- else
- DECL_SECTION_NAME (decl) = build_string (6, ".ftext");
- }
-
- /* This is so we can control inlining. It does not matter what
- attribute we add, just that it has one. */
- secname = build_tree_list (get_identifier ("section"), DECL_SECTION_NAME (decl));
- if (TYPE_P (decl))
- TYPE_ATTRIBUTES (decl) = chainon (TYPE_ATTRIBUTES (decl), secname);
- else
- DECL_ATTRIBUTES (decl) = chainon (DECL_ATTRIBUTES (decl), secname);
- }
}
const char *
mep_strip_name_encoding (const char *sym)
{
while (1)
@@ -4603,12 +4575,13 @@ mep_strip_name_encoding (const char *sym
static section *
mep_select_section (tree decl, int reloc ATTRIBUTE_UNUSED,
unsigned HOST_WIDE_INT align ATTRIBUTE_UNUSED)
{
int readonly = 1;
+ int encoding;
switch (TREE_CODE (decl))
{
case VAR_DECL:
if (!TREE_READONLY (decl)
|| TREE_SIDE_EFFECTS (decl)
@@ -4623,12 +4596,36 @@ mep_select_section (tree decl, int reloc
break;
default:
break;
}
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
+
+ if (name[0] == '@' && name[2] == '.')
+ encoding = name[1];
+ else
+ encoding = 0;
+
+ if (flag_function_sections || DECL_ONE_ONLY (decl))
+ mep_unique_section (decl, 0);
+ else if (lookup_attribute ("vliw", TYPE_ATTRIBUTES (TREE_TYPE (decl))))
+ {
+ if (encoding == 'f')
+ return vftext_section;
+ else
+ return vtext_section;
+ }
+ else if (encoding == 'f')
+ return ftext_section;
+ else
+ return text_section;
+ }
+
if (TREE_CODE (decl) == VAR_DECL)
{
const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
if (name[0] == '@' && name[2] == '.')
switch (name[1])
@@ -4677,25 +4674,32 @@ mep_unique_section (tree decl, int reloc
{ ".data.", ".gnu.linkonce.d." },
{ ".based.", ".gnu.linkonce.based." },
{ ".sdata.", ".gnu.linkonce.s." },
{ ".far.", ".gnu.linkonce.far." },
{ ".ftext.", ".gnu.linkonce.ft." },
{ ".frodata.", ".gnu.linkonce.frd." },
- { ".srodata.", ".gnu.linkonce.srd." }
+ { ".srodata.", ".gnu.linkonce.srd." },
+ { ".vtext.", ".gnu.linkonce.v." },
+ { ".vftext.", ".gnu.linkonce.vf." }
};
int sec = 2; /* .data */
int len;
const char *name, *prefix;
char *string;
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
if (DECL_RTL (decl))
name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
if (TREE_CODE (decl) == FUNCTION_DECL)
- sec = 0; /* .text */
+ {
+ if (lookup_attribute ("vliw", TYPE_ATTRIBUTES (TREE_TYPE (decl))))
+ sec = 9; /* .vtext */
+ else
+ sec = 0; /* .text */
+ }
else if (decl_readonly_section (decl, reloc))
sec = 1; /* .rodata */
if (name[0] == '@' && name[2] == '.')
{
switch (name[1])
@@ -4709,12 +4713,14 @@ mep_unique_section (tree decl, int reloc
else
sec = 4; /* .sdata */
break;
case 'f':
if (sec == 0)
sec = 6; /* .ftext */
+ else if (sec == 9)
+ sec = 10; /* .vftext */
else if (sec == 1)
sec = 7; /* .frodata */
else
sec = 5; /* .far. */
break;
}
@@ -7350,9 +7356,21 @@ mep_asm_init_sections (void)
"\t.section .frodata,\"a\"");
srodata_section
= get_unnamed_section (0, output_section_asm_op,
"\t.section .srodata,\"a\"");
+ vtext_section
+ = get_unnamed_section (0, output_section_asm_op,
+ "\t.section .vtext,\"ax\"");
+
+ vftext_section
+ = get_unnamed_section (0, output_section_asm_op,
+ "\t.section .vftext,\"ax\"");
+
+ ftext_section
+ = get_unnamed_section (0, output_section_asm_op,
+ "\t.section .ftext,\"ax\"");
+
}
#include "gt-mep.h"
Index: config/mep/mep.h
===================================================================
--- config/mep/mep.h (revision 150189)
+++ config/mep/mep.h (working copy)
@@ -618,12 +618,14 @@ typedef struct
#define TEXT_SECTION_ASM_OP "\t.text\n\t.core"
#define DATA_SECTION_ASM_OP "\t.data"
#define BSS_SECTION_ASM_OP ".bss"
+#define USE_SELECT_SECTION_FOR_FUNCTIONS 1
+
#define TARGET_ASM_FILE_END mep_file_cleanups
#define ASM_APP_ON "#APP\n"
#define ASM_APP_OFF "#NO_APP\n"
#define ASM_OUTPUT_DOUBLE(FILE, VALUE) \