This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: Using a SYMBOL_FLAG to encode below100 attribute
- From: Nick Clifton <nickc at redhat dot com>
- To: geoffk at geoffk dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 05 Aug 2005 12:37:22 +0100
- Subject: RFA: Using a SYMBOL_FLAG to encode below100 attribute
Hi Geoff,
Per rth's suggestion here is a patch to the xstormy16 backend to
make it use a SYMBOL_FLAG to encode the below100 attribute, rather
than mangling the name.
I tested the patch as best I could although it appears that the
gcc.target/xstormy16 testsuite does not run at the moment due to
problems with the assembler (rejecting the .space directives and the
"#0 <built-in>" line number) and also the compiler seg-faulting on
some of the test files. Instead I applied the patch to a set of GCC
4.0 branch sources which were able to run (most of) the xstormy16
testsuite and checked that the patch did not introduce any
regressions there.
May I apply the patch please ?
Cheers
Nick
gcc/ChangeLog
2005-08-05 Nick Clifton <nickc@redhat.com>
* config/stormy16/stormy16.h (SYMBOL_FLAG_XSTORMY16_BELOW100):
New define.
(ASM_OUTPUT_LABELREF): Use default_strip_name_encoding.
* config/stormy16/stormy16.c (xstormy16_below100_symbol):
Check symbol flags instead of symbol name mangling.
(xstormy16_asm_output_aligned_common): Likewise. Also
simplify code since the bss100_section cass is the only case
where the below100 code will be triggered.
(xstormy16_encode_section_info): Encode below100 attribute
using the SYMBOL_FLAG_XSTORMY16_BELOW100 instead of mangling
the name.
(xstormy16_strip_name_encoding): Delete - this function is no
longer needed.
(TARGET_STRIP_NAME_ENCODING): Undefine.
* config/stormy16/stormy16-protos.h: Delete prototype for
xstormy16_strip_name_encoding.
Index: gcc/config/stormy16/stormy16-protos.h
===================================================================
RCS file: /cvs/cvsfiles/gnupro/gcc/config/stormy16/stormy16-protos.h,v
retrieving revision 1.6
diff -c -3 -p -r1.6 stormy16-protos.h
*** gcc/config/stormy16/stormy16-protos.h 8 Feb 2005 17:34:57 -0000 1.6
--- gcc/config/stormy16/stormy16-protos.h 5 Aug 2005 11:20:30 -0000
*************** extern int direct_return (void);
*** 29,35 ****
extern int xstormy16_interrupt_function_p (void);
extern int xstormy16_epilogue_uses (int);
extern void xstormy16_function_profiler (void);
- extern const char *xstormy16_strip_name_encoding (const char *name);
extern void bss100_section (void);
#if defined (TREE_CODE)
--- 29,34 ----
Index: gcc/config/stormy16/stormy16.c
===================================================================
RCS file: /cvs/cvsfiles/gnupro/gcc/config/stormy16/stormy16.c,v
retrieving revision 1.11
diff -c -3 -p -r1.11 stormy16.c
*** gcc/config/stormy16/stormy16.c 5 Aug 2005 10:39:45 -0000 1.11
--- gcc/config/stormy16/stormy16.c 5 Aug 2005 11:20:31 -0000
*************** xstormy16_below100_symbol (rtx x,
*** 565,576 ****
if (GET_CODE (x) == PLUS
&& GET_CODE (XEXP (x, 1)) == CONST_INT)
x = XEXP (x, 0);
if (GET_CODE (x) == SYMBOL_REF)
! {
! const char *n = XSTR (x, 0);
! if (n[0] == '@' && n[1] == 'b' && n[2] == '.')
! return 1;
! }
if (GET_CODE (x) == CONST_INT)
{
HOST_WIDE_INT i = INTVAL (x);
--- 565,574 ----
if (GET_CODE (x) == PLUS
&& GET_CODE (XEXP (x, 1)) == CONST_INT)
x = XEXP (x, 0);
+
if (GET_CODE (x) == SYMBOL_REF)
! return (SYMBOL_REF_FLAGS (x) & SYMBOL_FLAG_XSTORMY16_BELOW100) != 0;
!
if (GET_CODE (x) == CONST_INT)
{
HOST_WIDE_INT i = INTVAL (x);
*************** xstormy16_asm_output_mi_thunk (FILE *fil
*** 1697,1738 ****
than uninitialized. */
void
xstormy16_asm_output_aligned_common (FILE *stream,
! tree decl ATTRIBUTE_UNUSED,
const char *name,
int size,
int align,
int global)
{
! if (name[0] == '@' && name[2] == '.')
{
! const char *op = 0;
! switch (name[1])
{
! case 'b':
! bss100_section();
! op = "space";
! break;
}
- if (op)
- {
- const char *name2;
- int p2align = 0;
! while (align > 8)
! {
! align /= 2;
! p2align ++;
! }
! name2 = xstormy16_strip_name_encoding (name);
! if (global)
! fprintf (stream, "\t.globl\t%s\n", name2);
! if (p2align)
! fprintf (stream, "\t.p2align %d\n", p2align);
! fprintf (stream, "\t.type\t%s, @object\n", name2);
! fprintf (stream, "\t.size\t%s, %d\n", name2, size);
! fprintf (stream, "%s:\n\t.%s\t%d\n", name2, op, size);
! return;
! }
}
if (!global)
--- 1695,1734 ----
than uninitialized. */
void
xstormy16_asm_output_aligned_common (FILE *stream,
! tree decl,
const char *name,
int size,
int align,
int global)
{
! rtx mem = DECL_RTL (decl);
! rtx symbol;
!
! if (mem != NULL_RTX
! && GET_CODE (mem) == MEM
! && GET_CODE (symbol = XEXP (mem, 0)) == SYMBOL_REF
! && SYMBOL_REF_FLAGS (symbol) & SYMBOL_FLAG_XSTORMY16_BELOW100)
{
! const char *name2;
! int p2align = 0;
!
! bss100_section();
!
! while (align > 8)
{
! align /= 2;
! p2align ++;
}
! name2 = default_strip_name_encoding (name);
! if (global)
! fprintf (stream, "\t.globl\t%s\n", name2);
! if (p2align)
! fprintf (stream, "\t.p2align %d\n", p2align);
! fprintf (stream, "\t.type\t%s, @object\n", name2);
! fprintf (stream, "\t.size\t%s, %d\n", name2, size);
! fprintf (stream, "%s:\n\t.space\t%d\n", name2, size);
! return;
}
if (!global)
*************** xstormy16_encode_section_info (tree decl
*** 1758,1804 ****
&& (lookup_attribute ("below100", DECL_ATTRIBUTES (decl))
|| lookup_attribute ("BELOW100", DECL_ATTRIBUTES (decl))))
{
! const char *newsection = 0;
! char *newname;
! tree idp;
! rtx rtlname, rtl;
! const char *oldname;
!
! rtl = r;
! rtlname = XEXP (rtl, 0);
! if (GET_CODE (rtlname) == SYMBOL_REF)
! oldname = XSTR (rtlname, 0);
! else if (GET_CODE (rtlname) == MEM
! && GET_CODE (XEXP (rtlname, 0)) == SYMBOL_REF)
! oldname = XSTR (XEXP (rtlname, 0), 0);
! else
! abort ();
!
! if (DECL_INITIAL (decl))
! {
! newsection = ".data_below100";
! DECL_SECTION_NAME (decl) = build_string (strlen (newsection), newsection);
! }
!
! newname = alloca (strlen (oldname) + 4);
! sprintf (newname, "@b.%s", oldname);
! idp = get_identifier (newname);
! XEXP (rtl, 0) =
! gen_rtx_SYMBOL_REF (Pmode, IDENTIFIER_POINTER (idp));
! }
! }
!
! const char *
! xstormy16_strip_name_encoding (const char *name)
! {
! while (1)
! {
! if (name[0] == '@' && name[2] == '.')
! name += 3;
! else if (name[0] == '*')
! name ++;
! else
! return name;
}
}
--- 1754,1763 ----
&& (lookup_attribute ("below100", DECL_ATTRIBUTES (decl))
|| lookup_attribute ("BELOW100", DECL_ATTRIBUTES (decl))))
{
! rtx symbol = XEXP (r, 0);
!
! gcc_assert (GET_CODE (symbol) == SYMBOL_REF);
! SYMBOL_REF_FLAGS (symbol) |= SYMBOL_FLAG_XSTORMY16_BELOW100;
}
}
*************** xstormy16_return_in_memory (tree type, t
*** 2813,2820 ****
#define TARGET_ASM_ALIGNED_SI_OP "\t.word\t"
#undef TARGET_ENCODE_SECTION_INFO
#define TARGET_ENCODE_SECTION_INFO xstormy16_encode_section_info
- #undef TARGET_STRIP_NAME_ENCODING
- #define TARGET_STRIP_NAME_ENCODING xstormy16_strip_name_encoding
#undef TARGET_ASM_OUTPUT_MI_THUNK
#define TARGET_ASM_OUTPUT_MI_THUNK xstormy16_asm_output_mi_thunk
--- 2772,2777 ----
Index: gcc/config/stormy16/stormy16.h
===================================================================
RCS file: /cvs/cvsfiles/gnupro/gcc/config/stormy16/stormy16.h,v
retrieving revision 1.15
diff -c -3 -p -r1.15 stormy16.h
*** gcc/config/stormy16/stormy16.h 5 Aug 2005 10:39:45 -0000 1.15
--- gcc/config/stormy16/stormy16.h 5 Aug 2005 11:20:31 -0000
*************** do { \
*** 668,673 ****
--- 668,674 ----
/* Output and Generation of Labels. */
+ #define SYMBOL_FLAG_XSTORMY16_BELOW100 (SYMBOL_FLAG_MACH_DEP << 0)
#define ASM_OUTPUT_SYMBOL_REF(STREAM, SYMBOL) \
do \
*************** do { \
*** 691,697 ****
} while (0)
#define ASM_OUTPUT_LABELREF(STREAM, NAME) \
! asm_fprintf ((STREAM), "%U%s", xstormy16_strip_name_encoding (NAME));
/* Globalizing directive for a label. */
#define GLOBAL_ASM_OP "\t.globl "
--- 692,698 ----
} while (0)
#define ASM_OUTPUT_LABELREF(STREAM, NAME) \
! asm_fprintf ((STREAM), "%U%s", default_strip_name_encoding (NAME));
/* Globalizing directive for a label. */
#define GLOBAL_ASM_OP "\t.globl "