Commit 501990bb by Neil Booth Committed by Neil Booth

system.h (TARGET_ESC): Move to ...

	* system.h (TARGET_ESC): Move to ...
	* defaults.h (TARGET_ESC): ... here.
	* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
	TARGET_VALID_TYPE_ATTRIBUTE): Default to a no-op handler.
	* tree.c (default_valid_attribute_p): New.
	(valid_machine_attribute): Handlers can not be NULL.
	* tree.h (default_valid_attribute_p): New.
	* doc/tm.texi: Document TARGET_ESC.
	* cp/decl2.c (import_export_class): Update.

From-SVN: r43605
parent 84690a97
2001-06-27 Neil Booth <neil@cat.daikokuya.demon.co.uk>
* system.h (TARGET_ESC): Move to ...
* defaults.h (TARGET_ESC): ... here.
* target-def.h (TARGET_VALID_DECL_ATTRIBUTE,
TARGET_VALID_TYPE_ATTRIBUTE): Default to a no-op handler.
* tree.c (default_valid_attribute_p): New.
(valid_machine_attribute): Handlers can not be NULL.
* tree.h (default_valid_attribute_p): New.
* doc/tm.texi: Document TARGET_ESC.
* cp/decl2.c (import_export_class): Update.
2001-06-26 Bruce Korb <bkorb@gnu.org> 2001-06-26 Bruce Korb <bkorb@gnu.org>
* gcc/fixinc/fixincl.c(initialize): In very strict ANSI, you cannot * gcc/fixinc/fixincl.c(initialize): In very strict ANSI, you cannot
......
2001-06-27 Neil Booth <neil@cat.daikokuya.demon.co.uk>
* decl2.c (import_export_class): Update.
2001-06-26 Gabriel Dos Reis <gdr@codesourcery.com> 2001-06-26 Gabriel Dos Reis <gdr@codesourcery.com>
* error.c (init_error): Adjust settings. * error.c (init_error): Adjust settings.
......
...@@ -2456,15 +2456,18 @@ import_export_class (ctype) ...@@ -2456,15 +2456,18 @@ import_export_class (ctype)
if (CLASSTYPE_INTERFACE_ONLY (ctype)) if (CLASSTYPE_INTERFACE_ONLY (ctype))
return; return;
if (target.valid_type_attribute != NULL) if ((*target.valid_type_attribute) (ctype,
{ TYPE_ATTRIBUTES (ctype),
/* FIXME this should really use some sort of target-independent get_identifier ("dllimport"),
macro. */ NULL_TREE)
if (lookup_attribute ("dllimport", TYPE_ATTRIBUTES (ctype))) && lookup_attribute ("dllimport", TYPE_ATTRIBUTES (ctype)))
import_export = -1; import_export = -1;
else if (lookup_attribute ("dllexport", TYPE_ATTRIBUTES (ctype))) else if ((*target.valid_type_attribute) (ctype,
import_export = 1; TYPE_ATTRIBUTES (ctype),
} get_identifier ("dllexport"),
NULL_TREE)
&& lookup_attribute ("dllexport", TYPE_ATTRIBUTES (ctype)))
import_export = 1;
/* If we got -fno-implicit-templates, we import template classes that /* If we got -fno-implicit-templates, we import template classes that
weren't explicitly instantiated. */ weren't explicitly instantiated. */
......
...@@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. */ ...@@ -32,6 +32,7 @@ Boston, MA 02111-1307, USA. */
# define TARGET_VT 013 # define TARGET_VT 013
# define TARGET_FF 014 # define TARGET_FF 014
# define TARGET_CR 015 # define TARGET_CR 015
# define TARGET_ESC 033
#endif #endif
/* Store in OUTPUT a string (made with alloca) containing /* Store in OUTPUT a string (made with alloca) containing
......
...@@ -12,6 +12,19 @@ ...@@ -12,6 +12,19 @@
In addition to the file @file{@var{machine}.md}, a machine description In addition to the file @file{@var{machine}.md}, a machine description
includes a C header file conventionally given the name includes a C header file conventionally given the name
<<<<<<< tm.texi
@file{@var{machine}.h} and a C source file named @file{@var{machine}.c}.
The header file defines numerous macros that convey the information
about the target machine that does not fit into the scheme of the
@file{.md} file. The file @file{tm.h} should be a link to
@file{@var{machine}.h}. The header file @file{config.h} includes
@file{tm.h} and most compiler source files include @file{config.h}. The
source file defines a variable @code{target}, which is a structure
containing pointers to functions and data relating to the target
machine. @file{@var{machine}.c} should also their definitions, if they
are not defined elsewhere in GCC, and other functions called through the
macros defined in the @file{.h} file.
=======
@file{@var{machine}.h} and a C source file named @file{@var{machine}.c}. @file{@var{machine}.h} and a C source file named @file{@var{machine}.c}.
The header file defines numerous macros that convey the information The header file defines numerous macros that convey the information
about the target machine that does not fit into the scheme of the about the target machine that does not fit into the scheme of the
...@@ -23,6 +36,7 @@ containing pointers to functions and data relating to the target ...@@ -23,6 +36,7 @@ containing pointers to functions and data relating to the target
machine. @file{@var{machine}.c} should also contain their definitions, machine. @file{@var{machine}.c} should also contain their definitions,
if they are not defined elsewhere in GCC, and other functions called if they are not defined elsewhere in GCC, and other functions called
through the macros defined in the @file{.h} file. through the macros defined in the @file{.h} file.
>>>>>>> 1.11
@menu @menu
* Target Structure:: The @code{target} variable. * Target Structure:: The @code{target} variable.
...@@ -1581,6 +1595,12 @@ explicitly define all of the macros below. ...@@ -1581,6 +1595,12 @@ explicitly define all of the macros below.
A C constant expression for the integer value for escape sequence A C constant expression for the integer value for escape sequence
@samp{\a}. @samp{\a}.
@findex TARGET_ESC
@item TARGET_ESC
A C constant expression for the integer value of the target escape
character. As an extension, GCC evaluates the escape sequences
@samp{\e} and @samp{\E} to this.
@findex TARGET_TAB @findex TARGET_TAB
@findex TARGET_BS @findex TARGET_BS
@findex TARGET_NEWLINE @findex TARGET_NEWLINE
...@@ -8300,6 +8320,33 @@ If defined, a C statement that assigns default attributes to ...@@ -8300,6 +8320,33 @@ If defined, a C statement that assigns default attributes to
newly defined @var{type}. newly defined @var{type}.
@end table @end table
<<<<<<< tm.texi
@deftypefn {Target Hook} tree TARGET_MERGE_TYPE_ATTRIBUTES (tree @var{type1}, tree @var{type2})
Define this target hook if the merging of type attributes needs special
handling. If defined, the result is a list of the combined
@code{TYPE_ATTRIBUTES} of @var{type1} and @var{type2}. It is assumed
that @code{comptypes} has already been called and returned 1. This
function may call @code{merge_attributes} to handle machine-independent
merging.
@end deftypefn
@deftypefn {Target Hook} tree TARGET_MERGE_DECL_ATTRIBUTES (tree @var{olddecl}, tree @var{newdecl})
Define this target hook if the merging of decl attributes needs special
handling. If defined, the result is a list of the combined
@code{DECL_MACHINE_ATTRIBUTES} of @var{olddecl} and @var{newdecl}.
@var{newdecl} is a duplicate declaration of @var{olddecl}. Examples of
when this is needed are when one attribute overrides another, or when an
attribute is nullified by a subsequent definition. This function may
call @code{merge_attributes} to handle machine-independent merging.
If the only target-specific handling you require is @samp{dllimport} for
Windows targets, you should define the macro
@code{TARGET_DLLIMPORT_DECL_ATTRIBUTES}. This links in a function
called @code{merge_dllimport_decl_attributes} which you can then define
as the expansion of @code{TARGET_MERGE_DECL_ATTRIBUTES}. This is done
in @file{i386/cygwin.h} and @file{i386/i386.c}, for example.
@end deftypefn
=======
@deftypefn {Target Hook} tree TARGET_MERGE_TYPE_ATTRIBUTES (tree @var{type1}, tree @var{type2}) @deftypefn {Target Hook} tree TARGET_MERGE_TYPE_ATTRIBUTES (tree @var{type1}, tree @var{type2})
Define this target hook if the merging of type attributes needs special Define this target hook if the merging of type attributes needs special
handling. If defined, the result is a list of the combined handling. If defined, the result is a list of the combined
...@@ -8326,6 +8373,7 @@ called @code{merge_dllimport_decl_attributes} which can then be defined ...@@ -8326,6 +8373,7 @@ called @code{merge_dllimport_decl_attributes} which can then be defined
as the expansion of @code{TARGET_MERGE_DECL_ATTRIBUTES}. This is done as the expansion of @code{TARGET_MERGE_DECL_ATTRIBUTES}. This is done
in @file{i386/cygwin.h} and @file{i386/i386.c}, for example. in @file{i386/cygwin.h} and @file{i386/i386.c}, for example.
@end deftypefn @end deftypefn
>>>>>>> 1.11
@table @code @table @code
@findex INSERT_ATTRIBUTES @findex INSERT_ATTRIBUTES
......
...@@ -84,11 +84,6 @@ extern int fputs_unlocked PARAMS ((const char *, FILE *)); ...@@ -84,11 +84,6 @@ extern int fputs_unlocked PARAMS ((const char *, FILE *));
replacement instead. */ replacement instead. */
#include <safe-ctype.h> #include <safe-ctype.h>
/* Define a default escape character; it's different for EBCDIC. */
#ifndef TARGET_ESC
#define TARGET_ESC 033
#endif
#include <sys/types.h> #include <sys/types.h>
#include <errno.h> #include <errno.h>
......
...@@ -2707,6 +2707,19 @@ build_type_attribute_variant (ttype, attribute) ...@@ -2707,6 +2707,19 @@ build_type_attribute_variant (ttype, attribute)
return ttype; return ttype;
} }
/* Default value of target.valid_decl_attribute_p and
target.valid_type_attribute_p that always returns false. */
int
default_valid_attribute_p PARAMS ((attr_name, attr_args, decl, type))
tree attr_name ATTRIBUTE_UNUSED;
tree attr_args ATTRIBUTE_UNUSED;
tree decl ATTRIBUTE_UNUSED;
tree type ATTRIBUTE_UNUSED;
{
return 0;
}
/* Return 1 if ATTR_NAME and ATTR_ARGS is valid for either declaration /* Return 1 if ATTR_NAME and ATTR_ARGS is valid for either declaration
DECL or type TYPE and 0 otherwise. Validity is determined the DECL or type TYPE and 0 otherwise. Validity is determined the
target functions valid_decl_attribute and valid_machine_attribute. */ target functions valid_decl_attribute and valid_machine_attribute. */
...@@ -2718,10 +2731,12 @@ valid_machine_attribute (attr_name, attr_args, decl, type) ...@@ -2718,10 +2731,12 @@ valid_machine_attribute (attr_name, attr_args, decl, type)
tree decl; tree decl;
tree type; tree type;
{ {
tree type_attrs;
if (TREE_CODE (attr_name) != IDENTIFIER_NODE) if (TREE_CODE (attr_name) != IDENTIFIER_NODE)
abort (); abort ();
if (decl && target.valid_decl_attribute != NULL) if (decl)
{ {
tree decl_attrs = DECL_MACHINE_ATTRIBUTES (decl); tree decl_attrs = DECL_MACHINE_ATTRIBUTES (decl);
...@@ -2748,75 +2763,70 @@ valid_machine_attribute (attr_name, attr_args, decl, type) ...@@ -2748,75 +2763,70 @@ valid_machine_attribute (attr_name, attr_args, decl, type)
} }
} }
if (target.valid_type_attribute != NULL) type_attrs = TYPE_ATTRIBUTES (type);
if ((*target.valid_type_attribute) (type, type_attrs, attr_name,
attr_args))
{ {
tree type_attrs = TYPE_ATTRIBUTES (type); tree attr = lookup_attribute (IDENTIFIER_POINTER (attr_name),
type_attrs);
if ((*target.valid_type_attribute) (type, type_attrs, attr_name, if (attr != NULL_TREE)
attr_args))
{ {
tree attr = lookup_attribute (IDENTIFIER_POINTER (attr_name), /* Override existing arguments. ??? This currently
type_attrs); works since attribute arguments are not included in
`attribute_hash_list'. Something more complicated
if (attr != NULL_TREE) may be needed in the future. */
{ TREE_VALUE (attr) = attr_args;
/* Override existing arguments. ??? This currently }
works since attribute arguments are not included in else
`attribute_hash_list'. Something more complicated {
may be needed in the future. */ /* If this is part of a declaration, create a type variant,
TREE_VALUE (attr) = attr_args; otherwise, this is part of a type definition, so add it
} to the base type. */
type_attrs = tree_cons (attr_name, attr_args, type_attrs);
if (decl != 0)
type = build_type_attribute_variant (type, type_attrs);
else else
{ TYPE_ATTRIBUTES (type) = type_attrs;
/* If this is part of a declaration, create a type variant,
otherwise, this is part of a type definition, so add it
to the base type. */
type_attrs = tree_cons (attr_name, attr_args, type_attrs);
if (decl != 0)
type = build_type_attribute_variant (type, type_attrs);
else
TYPE_ATTRIBUTES (type) = type_attrs;
}
if (decl)
TREE_TYPE (decl) = type;
return 1;
} }
/* Handle putting a type attribute on pointer-to-function-type if (decl)
by putting the attribute on the function type. */ TREE_TYPE (decl) = type;
else if (POINTER_TYPE_P (type)
&& TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
&& (*target.valid_type_attribute) (TREE_TYPE (type), type_attrs,
attr_name, attr_args))
{
tree inner_type = TREE_TYPE (type);
tree inner_attrs = TYPE_ATTRIBUTES (inner_type);
tree attr = lookup_attribute (IDENTIFIER_POINTER (attr_name),
type_attrs);
if (attr != NULL_TREE) return 1;
TREE_VALUE (attr) = attr_args; }
else /* Handle putting a type attribute on pointer-to-function-type
{ by putting the attribute on the function type. */
inner_attrs = tree_cons (attr_name, attr_args, inner_attrs); else if (POINTER_TYPE_P (type)
inner_type = build_type_attribute_variant (inner_type, && TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
inner_attrs); && (*target.valid_type_attribute) (TREE_TYPE (type), type_attrs,
} attr_name, attr_args))
{
tree inner_type = TREE_TYPE (type);
tree inner_attrs = TYPE_ATTRIBUTES (inner_type);
tree attr = lookup_attribute (IDENTIFIER_POINTER (attr_name),
type_attrs);
if (decl) if (attr != NULL_TREE)
TREE_TYPE (decl) = build_pointer_type (inner_type); TREE_VALUE (attr) = attr_args;
else else
{ {
/* Clear TYPE_POINTER_TO for the old inner type, since inner_attrs = tree_cons (attr_name, attr_args, inner_attrs);
`type' won't be pointing to it anymore. */ inner_type = build_type_attribute_variant (inner_type,
TYPE_POINTER_TO (TREE_TYPE (type)) = NULL_TREE; inner_attrs);
TREE_TYPE (type) = inner_type; }
}
return 1; if (decl)
TREE_TYPE (decl) = build_pointer_type (inner_type);
else
{
/* Clear TYPE_POINTER_TO for the old inner type, since
`type' won't be pointing to it anymore. */
TYPE_POINTER_TO (TREE_TYPE (type)) = NULL_TREE;
TREE_TYPE (type) = inner_type;
} }
return 1;
} }
return 0; return 0;
......
...@@ -2039,8 +2039,11 @@ extern tree make_tree PARAMS ((tree, struct rtx_def *)); ...@@ -2039,8 +2039,11 @@ extern tree make_tree PARAMS ((tree, struct rtx_def *));
extern tree build_type_attribute_variant PARAMS ((tree, tree)); extern tree build_type_attribute_variant PARAMS ((tree, tree));
extern tree build_decl_attribute_variant PARAMS ((tree, tree)); extern tree build_decl_attribute_variant PARAMS ((tree, tree));
/* Default versions of target-overridable functions. */
extern tree merge_decl_attributes PARAMS ((tree, tree)); extern tree merge_decl_attributes PARAMS ((tree, tree));
extern tree merge_type_attributes PARAMS ((tree, tree)); extern tree merge_type_attributes PARAMS ((tree, tree));
extern int default_valid_attribute_p PARAMS ((tree, tree, tree, tree));
/* Split a list of declspecs and attributes into two. */ /* Split a list of declspecs and attributes into two. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment