Fixups for v850 target specific pragma support.
Nick Clifton
nickc@redhat.com
Fri Nov 24 16:42:00 GMT 2000
Hi Guys,
I have now applied the target specific, language specific object
file support patch, and now I am going to apply the patch below to
allow the v850 port to make use of this feature.
Cheers
Nick
2000-11-24 Nick Clifton <nickc@redhat.com>
* config.gcc (v850-*-*): Define c_target_objs and
cxx_target_objs.
* config/v850/t-v850: Define how to build v850-c.o
* config/v850/v850.h (struct data_area_stack_element): Move
definition here from v850.c.
* config/v850v850.c: Include gcc.h to avoid compile time
warning.
(push_data_area): Move to v850-c.c.
(pop_data_area): Move to v850-c.c.
(mark_current_function_as_interrupt): Move to v850-c.c.
(GHS_default_section_names): Allow to be exported.
(GHS_current_section_names): Allow to be exported.
(data_area_stack_elements): Allow to be exported.
(ghs_pragma_section): Move to v850-c.c.
(ghs_pragma_interrupt): Move to v850-c.c.
(ghs_pragma_starttda): Move to v850-c.c.
(ghs_pragma_startsda): Move to v850-c.c.
(ghs_pragma_startzda): Move to v850-c.c.
(ghs_pragma_endtda): Move to v850-c.c.
(ghs_pragma_endsda): Move to v850-c.c.
(ghs_pragma_endzda): Move to v850-c.c.
* config/v850/v850-c.c: New file: Contains v850 specific
pragma parsing functions.
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config.gcc,v
retrieving revision 1.7
diff -p -w -r1.7 config.gcc
*** config.gcc 2000/11/25 00:33:03 1.7
--- config.gcc 2000/11/25 00:38:39
*************** v850-*-rtems*)
*** 3133,3138 ****
--- 3133,3140 ----
tm_file="${tm_file} dbx.h"
fi
use_collect2=no
+ c_target_objs="v850-c.o"
+ cxx_target_objs="v850-c.o"
;;
v850-*-*)
target_cpu_default="TARGET_CPU_generic"
*************** v850-*-*)
*** 3145,3150 ****
--- 3147,3154 ----
tm_file="${tm_file} dbx.h"
fi
use_collect2=no
+ c_target_objs="v850-c.o"
+ cxx_target_objs="v850-c.o"
;;
vax-*-bsd*) # vaxen running BSD
use_collect2=yes
Index: config/v850/t-v850
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/v850/t-v850,v
retrieving revision 1.5
diff -p -w -r1.5 t-v850
*** t-v850 1999/08/05 03:27:49 1.5
--- t-v850 2000/11/25 00:38:39
*************** fp-bit.c: $(srcdir)/config/fp-bit.c
*** 52,54 ****
--- 51,57 ----
cat $(srcdir)/config/fp-bit.c >> fp-bit.c
TCFLAGS = -Wa,-mwarn-signed-overflow -Wa,-mwarn-unsigned-overflow
+
+ v850-c.o: $(srcdir)/config/v850/v850-c.c
+ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+
Index: config/v850/v850.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/v850/v850.c,v
retrieving revision 1.33
diff -p -w -r1.33 v850.c
*** v850.c 2000/11/14 19:45:29 1.33
--- v850.c 2000/11/25 00:38:39
*************** Boston, MA 02111-1307, USA. */
*** 38,44 ****
#include "toplev.h"
#include "cpplib.h"
#include "c-lex.h"
! #include "c-pragma.h"
#include "tm_p.h"
#ifndef streq
--- 38,44 ----
#include "toplev.h"
#include "cpplib.h"
#include "c-lex.h"
! #include "ggc.h"
#include "tm_p.h"
#ifndef streq
*************** static void const_double_split
*** 50,59 ****
PARAMS ((rtx, HOST_WIDE_INT *, HOST_WIDE_INT *));
static int const_costs_int PARAMS ((HOST_WIDE_INT, int));
static void substitute_ep_register PARAMS ((rtx, rtx, int, int, rtx *, rtx *));
- static int push_data_area PARAMS ((v850_data_area));
- static int pop_data_area PARAMS ((v850_data_area));
static int ep_memory_offset PARAMS ((enum machine_mode, int));
- static int mark_current_function_as_interrupt PARAMS ((void));
static void v850_set_data_area PARAMS ((tree, v850_data_area));
/* True if the current function has anonymous arguments. */
--- 50,56 ----
*************** struct small_memory_info small_memory[ (
*** 68,75 ****
{ "zda", (char *)0, 0, 32768 },
};
/* True if we don't need to check any more if the current
! function is an interrupt handler */
static int v850_interrupt_cache_p = FALSE;
/* Whether current function is an interrupt handler. */
--- 65,80 ----
{ "zda", (char *)0, 0, 32768 },
};
+ /* Names of the various data areas used on the v850. */
+ tree GHS_default_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
+ tree GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
+
+ /* Track the current data area set by the data area pragma (which
+ can be nested). Tested by check_default_data_area. */
+ data_area_stack_element * data_area_stack = NULL;
+
/* True if we don't need to check any more if the current
! function is an interrupt handler. */
static int v850_interrupt_cache_p = FALSE;
/* Whether current function is an interrupt handler. */
*************** not_power_of_two_operand (op, mode)
*** 1028,1034 ****
else if (mode == HImode)
mask = 0xffff;
else if (mode == SImode)
! mask = 0xffffffff;
else
return 0;
--- 1033,1039 ----
else if (mode == HImode)
mask = 0xffff;
else if (mode == SImode)
! mask = 0xffffffffU;
else
return 0;
*************** Saved %d bytes (%d uses of register %s)
*** 1104,1115 ****
{
rtx addr = XEXP (*p_mem, 0);
! if (GET_CODE (addr) == REG && REGNO (addr) == regno)
*p_mem = change_address (*p_mem, VOIDmode, *p_ep);
else if (GET_CODE (addr) == PLUS
&& GET_CODE (XEXP (addr, 0)) == REG
! && REGNO (XEXP (addr, 0)) == regno
&& GET_CODE (XEXP (addr, 1)) == CONST_INT
&& ((INTVAL (XEXP (addr, 1)))
< ep_memory_offset (GET_MODE (*p_mem),
--- 1109,1120 ----
{
rtx addr = XEXP (*p_mem, 0);
! if (GET_CODE (addr) == REG && REGNO (addr) == (unsigned) regno)
*p_mem = change_address (*p_mem, VOIDmode, *p_ep);
else if (GET_CODE (addr) == PLUS
&& GET_CODE (XEXP (addr, 0)) == REG
! && REGNO (XEXP (addr, 0)) == (unsigned) regno
&& GET_CODE (XEXP (addr, 1)) == CONST_INT
&& ((INTVAL (XEXP (addr, 1)))
< ep_memory_offset (GET_MODE (*p_mem),
*************** v850_output_local (file, decl, name, siz
*** 2636,2875 ****
fprintf (file, "\n");
ASM_OUTPUT_ALIGNED_DECL_COMMON (file, decl, name, size, align);
- }
-
- /* The following code is for handling pragmas supported by the
- v850 compiler produced by Green Hills Software. This is at
- the specific request of a customer. */
-
- /* Track the current data area set by the data area pragma (which
- can be nested). Tested by check_default_data_area. */
-
- typedef struct data_area_stack_element
- {
- struct data_area_stack_element * prev;
- v850_data_area data_area; /* current default data area. */
- } data_area_stack_element;
-
- static data_area_stack_element * data_area_stack = NULL;
-
- /* Names of the various data areas used on the v850. */
- static tree GHS_default_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
- static tree GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
-
- /* Push a data area onto the stack. */
- static int
- push_data_area (data_area)
- v850_data_area data_area;
- {
- data_area_stack_element * elem;
-
- elem = (data_area_stack_element *) xmalloc (sizeof (* elem));
-
- if (elem == NULL)
- return 0;
-
- elem->prev = data_area_stack;
- elem->data_area = data_area;
-
- data_area_stack = elem;
-
- return 1;
- }
-
- /* Remove a data area from the stack. */
- static int
- pop_data_area (data_area)
- v850_data_area data_area;
- {
- if (data_area_stack == NULL)
- warning ("#pragma GHS endXXXX found without previous startXXX");
- else if (data_area != data_area_stack->data_area)
- warning ("#pragma GHS endXXX does not match previous startXXX");
- else
- {
- data_area_stack_element * elem;
-
- elem = data_area_stack;
- data_area_stack = data_area_stack->prev;
-
- free (elem);
-
- return 1;
- }
-
- return 0;
- }
-
- /* Set the machine specific 'interrupt' attribute on the current function. */
- static int
- mark_current_function_as_interrupt ()
- {
- tree name;
-
- if (current_function_decl == NULL_TREE)
- {
- warning ("Cannot set interrupt attribute: no current function");
- return 0;
- }
-
- name = get_identifier ("interrupt");
-
- if (name == NULL_TREE || TREE_CODE (name) != IDENTIFIER_NODE)
- {
- warning ("Cannot set interrupt attribute: no such identifier");
- return 0;
- }
-
- return valid_machine_attribute
- (name, NULL_TREE, current_function_decl, NULL_TREE);
- }
-
- /* Support for GHS pragmata. */
-
- void
- ghs_pragma_section (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
- {
- int repeat;
-
- /* #pragma ghs section [name = alias [, name = alias [, ...]]] */
- do {
- tree x;
- enum cpp_ttype type;
- const char *sect, *alias;
- enum GHS_section_kind kind;
-
- type = c_lex (&x);
- if (type == CPP_EOF && !repeat)
- goto reset;
- else if (type == CPP_NAME)
- sect = IDENTIFIER_POINTER (x);
- else
- goto bad;
- repeat = 0;
-
- if (c_lex (&x) != CPP_EQ)
- goto bad;
- if (c_lex (&x) != CPP_NAME)
- goto bad;
- alias = IDENTIFIER_POINTER (x);
-
- type = c_lex (&x);
- if (type == CPP_COMMA)
- repeat = 1;
- else if (type != CPP_EOF)
- warning ("junk at end of #pragma ghs section");
-
- if (streq (sect, "data")) kind = GHS_SECTION_KIND_DATA;
- else if (streq (sect, "text")) kind = GHS_SECTION_KIND_TEXT;
- else if (streq (sect, "rodata")) kind = GHS_SECTION_KIND_RODATA;
- else if (streq (sect, "const")) kind = GHS_SECTION_KIND_RODATA;
- else if (streq (sect, "rosdata")) kind = GHS_SECTION_KIND_ROSDATA;
- else if (streq (sect, "rozdata")) kind = GHS_SECTION_KIND_ROZDATA;
- else if (streq (sect, "sdata")) kind = GHS_SECTION_KIND_SDATA;
- else if (streq (sect, "tdata")) kind = GHS_SECTION_KIND_TDATA;
- else if (streq (sect, "zdata")) kind = GHS_SECTION_KIND_ZDATA;
- /* According to GHS beta documentation, the following should not be
- allowed! */
- else if (streq (sect, "bss")) kind = GHS_SECTION_KIND_BSS;
- else if (streq (sect, "zbss")) kind = GHS_SECTION_KIND_ZDATA;
- else
- {
- warning ("unrecognised section name \"%s\"", sect);
- return;
- }
-
- if (streq (alias, "default"))
- GHS_current_section_names [kind] = NULL;
- else
- GHS_current_section_names [kind] =
- build_string (strlen (alias) + 1, alias);
-
- } while (repeat);
- return;
-
- bad:
- warning ("malformed #pragma ghs section");
- return;
-
- reset:
- /* #pragma ghs section \n: Reset all section names back to their defaults. */
- {
- int i;
- for (i = COUNT_OF_GHS_SECTION_KINDS; i--;)
- GHS_current_section_names [i] = NULL;
- }
- }
-
- void
- ghs_pragma_interrupt (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
- {
- tree x;
- if (c_lex (&x) != CPP_EOF)
- warning ("junk at end of #pragma ghs interrupt");
- mark_current_function_as_interrupt ();
- }
-
- void
- ghs_pragma_starttda (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
- {
- tree x;
- if (c_lex (&x) != CPP_EOF)
- warning ("junk at end of #pragma ghs starttda");
- push_data_area (DATA_AREA_TDA);
- }
-
- void
- ghs_pragma_startsda (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
- {
- tree x;
- if (c_lex (&x) != CPP_EOF)
- warning ("junk at end of #pragma ghs startsda");
- push_data_area (DATA_AREA_SDA);
- }
-
- void
- ghs_pragma_startzda (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
- {
- tree x;
- if (c_lex (&x) != CPP_EOF)
- warning ("junk at end of #pragma ghs startzda");
- push_data_area (DATA_AREA_ZDA);
- }
-
- void
- ghs_pragma_endtda (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
- {
- tree x;
- if (c_lex (&x) != CPP_EOF)
- warning ("junk at end of #pragma ghs endtda");
- pop_data_area (DATA_AREA_TDA);
- }
-
- void
- ghs_pragma_endsda (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
- {
- tree x;
- if (c_lex (&x) != CPP_EOF)
- warning ("junk at end of #pragma ghs endsda");
- pop_data_area (DATA_AREA_SDA);
- }
-
- void
- ghs_pragma_endzda (pfile)
- cpp_reader *pfile ATTRIBUTE_UNUSED;
- {
- tree x;
- if (c_lex (&x) != CPP_EOF)
- warning ("junk at end of #pragma ghs endzda");
- pop_data_area (DATA_AREA_ZDA);
}
/* Add data area to the given declaration if a ghs data area pragma is
--- 2641,2646 ----
Index: config/v850/v850.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/v850/v850.h,v
retrieving revision 1.30
diff -p -w -r1.30 v850.h
*** v850.h 2000/09/25 10:24:22 1.30
--- v850.h 2000/11/25 00:38:39
*************** enum GHS_section_kind
*** 1555,1560 ****
--- 1555,1578 ----
COUNT_OF_GHS_SECTION_KINDS /* must be last */
};
+ /* The following code is for handling pragmas supported by the
+ v850 compiler produced by Green Hills Software. This is at
+ the specific request of a customer. */
+
+ typedef struct data_area_stack_element
+ {
+ struct data_area_stack_element * prev;
+ v850_data_area data_area; /* Current default data area. */
+ } data_area_stack_element;
+
+ /* Track the current data area set by the
+ data area pragma (which can be nested). */
+ extern data_area_stack_element * data_area_stack;
+
+ /* Names of the various data areas used on the v850. */
+ extern union tree_node * GHS_default_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
+ extern union tree_node * GHS_current_section_names [(int) COUNT_OF_GHS_SECTION_KINDS];
+
/* The assembler op to start the file. */
#define FILE_ASM_OP "\t.file\n"
Index: config/v850/v850-c.c
===================================================================
RCS file: v850-c.c
diff -N v850-c.c
*** /dev/null Tue May 5 13:32:27 1998
--- v850-c.c Fri Nov 24 16:38:39 2000
***************
*** 0 ****
--- 1,276 ----
+ /* v850 specific, C compiler specific functions.
+ Copyright (C) 2000 Free Software Foundation, Inc.
+ Contributed by Jeff Law (law@cygnus.com).
+
+ This file is part of GNU CC.
+
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING. If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+ #include "config.h"
+ #include "system.h"
+ #include "cpplib.h"
+ #include "tree.h"
+ #include "c-pragma.h"
+ #include "c-lex.h"
+ #include "toplev.h"
+ #include "ggc.h"
+ #include "tm_p.h"
+
+ #ifndef streq
+ #define streq(a,b) (strcmp (a, b) == 0)
+ #endif
+
+ static int pop_data_area PARAMS ((v850_data_area));
+ static int push_data_area PARAMS ((v850_data_area));
+ static int mark_current_function_as_interrupt PARAMS ((void));
+
+ /* Push a data area onto the stack. */
+
+ static int
+ push_data_area (data_area)
+ v850_data_area data_area;
+ {
+ data_area_stack_element * elem;
+
+ elem = (data_area_stack_element *) xmalloc (sizeof (* elem));
+
+ if (elem == NULL)
+ return 0;
+
+ elem->prev = data_area_stack;
+ elem->data_area = data_area;
+
+ data_area_stack = elem;
+
+ return 1;
+ }
+
+ /* Remove a data area from the stack. */
+
+ static int
+ pop_data_area (data_area)
+ v850_data_area data_area;
+ {
+ if (data_area_stack == NULL)
+ warning ("#pragma GHS endXXXX found without previous startXXX");
+ else if (data_area != data_area_stack->data_area)
+ warning ("#pragma GHS endXXX does not match previous startXXX");
+ else
+ {
+ data_area_stack_element * elem;
+
+ elem = data_area_stack;
+ data_area_stack = data_area_stack->prev;
+
+ free (elem);
+
+ return 1;
+ }
+
+ return 0;
+ }
+
+ /* Set the machine specific 'interrupt' attribute on the current function. */
+
+ static int
+ mark_current_function_as_interrupt ()
+ {
+ tree name;
+
+ if (current_function_decl == NULL_TREE)
+ {
+ warning ("Cannot set interrupt attribute: no current function");
+ return 0;
+ }
+
+ name = get_identifier ("interrupt");
+
+ if (name == NULL_TREE || TREE_CODE (name) != IDENTIFIER_NODE)
+ {
+ warning ("Cannot set interrupt attribute: no such identifier");
+ return 0;
+ }
+
+ return valid_machine_attribute
+ (name, NULL_TREE, current_function_decl, NULL_TREE);
+ }
+
+
+ /* Support for GHS pragmata. */
+
+ void
+ ghs_pragma_section (pfile)
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
+ {
+ int repeat;
+
+ /* #pragma ghs section [name = alias [, name = alias [, ...]]] */
+ do
+ {
+ tree x;
+ enum cpp_ttype type;
+ const char *sect, *alias;
+ enum GHS_section_kind kind;
+
+ type = c_lex (&x);
+
+ if (type == CPP_EOF && !repeat)
+ goto reset;
+ else if (type == CPP_NAME)
+ sect = IDENTIFIER_POINTER (x);
+ else
+ goto bad;
+ repeat = 0;
+
+ if (c_lex (&x) != CPP_EQ)
+ goto bad;
+ if (c_lex (&x) != CPP_NAME)
+ goto bad;
+
+ alias = IDENTIFIER_POINTER (x);
+
+ type = c_lex (&x);
+ if (type == CPP_COMMA)
+ repeat = 1;
+ else if (type != CPP_EOF)
+ warning ("junk at end of #pragma ghs section");
+
+ if (streq (sect, "data")) kind = GHS_SECTION_KIND_DATA;
+ else if (streq (sect, "text")) kind = GHS_SECTION_KIND_TEXT;
+ else if (streq (sect, "rodata")) kind = GHS_SECTION_KIND_RODATA;
+ else if (streq (sect, "const")) kind = GHS_SECTION_KIND_RODATA;
+ else if (streq (sect, "rosdata")) kind = GHS_SECTION_KIND_ROSDATA;
+ else if (streq (sect, "rozdata")) kind = GHS_SECTION_KIND_ROZDATA;
+ else if (streq (sect, "sdata")) kind = GHS_SECTION_KIND_SDATA;
+ else if (streq (sect, "tdata")) kind = GHS_SECTION_KIND_TDATA;
+ else if (streq (sect, "zdata")) kind = GHS_SECTION_KIND_ZDATA;
+ /* According to GHS beta documentation, the following should not be
+ allowed! */
+ else if (streq (sect, "bss")) kind = GHS_SECTION_KIND_BSS;
+ else if (streq (sect, "zbss")) kind = GHS_SECTION_KIND_ZDATA;
+ else
+ {
+ warning ("unrecognised section name \"%s\"", sect);
+ return;
+ }
+
+ if (streq (alias, "default"))
+ GHS_current_section_names [kind] = NULL;
+ else
+ GHS_current_section_names [kind] =
+ build_string (strlen (alias) + 1, alias);
+ }
+ while (repeat);
+
+ return;
+
+ bad:
+ warning ("malformed #pragma ghs section");
+ return;
+
+ reset:
+ /* #pragma ghs section \n: Reset all section names back to their defaults. */
+ {
+ int i;
+
+ for (i = COUNT_OF_GHS_SECTION_KINDS; i--;)
+ GHS_current_section_names [i] = NULL;
+ }
+ }
+
+ void
+ ghs_pragma_interrupt (pfile)
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
+ {
+ tree x;
+
+ if (c_lex (&x) != CPP_EOF)
+ warning ("junk at end of #pragma ghs interrupt");
+
+ mark_current_function_as_interrupt ();
+ }
+
+ void
+ ghs_pragma_starttda (pfile)
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
+ {
+ tree x;
+
+ if (c_lex (&x) != CPP_EOF)
+ warning ("junk at end of #pragma ghs starttda");
+
+ push_data_area (DATA_AREA_TDA);
+ }
+
+ void
+ ghs_pragma_startsda (pfile)
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
+ {
+ tree x;
+
+ if (c_lex (&x) != CPP_EOF)
+ warning ("junk at end of #pragma ghs startsda");
+
+ push_data_area (DATA_AREA_SDA);
+ }
+
+ void
+ ghs_pragma_startzda (pfile)
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
+ {
+ tree x;
+
+ if (c_lex (&x) != CPP_EOF)
+ warning ("junk at end of #pragma ghs startzda");
+
+ push_data_area (DATA_AREA_ZDA);
+ }
+
+ void
+ ghs_pragma_endtda (pfile)
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
+ {
+ tree x;
+
+ if (c_lex (&x) != CPP_EOF)
+ warning ("junk at end of #pragma ghs endtda");
+
+ pop_data_area (DATA_AREA_TDA);
+ }
+
+ void
+ ghs_pragma_endsda (pfile)
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
+ {
+ tree x;
+
+ if (c_lex (&x) != CPP_EOF)
+ warning ("junk at end of #pragma ghs endsda");
+
+ pop_data_area (DATA_AREA_SDA);
+ }
+
+ void
+ ghs_pragma_endzda (pfile)
+ cpp_reader *pfile ATTRIBUTE_UNUSED;
+ {
+ tree x;
+
+ if (c_lex (&x) != CPP_EOF)
+ warning ("junk at end of #pragma ghs endzda");
+
+ pop_data_area (DATA_AREA_ZDA);
+ }
More information about the Gcc-patches
mailing list