[PATCH] ARM half-precision floating point, 3/8 (target hooks)

Ian Lance Taylor iant@google.com
Sat May 16 01:17:00 GMT 2009


Sandra Loosemore <sandra@codesourcery.com> writes:

> 2009-04-15  Sandra Loosemore  <sandra@codesourcery.com>
>
> 	gcc/
> 	* doc/tm.texi (Misc): Document TARGET_INVALID_PARAMETER_TYPE,
> 	TARGET_INVALID_RETURN_TYPE, TARGET_PROMOTED_TYPE, and
> 	TARGET_CONVERT_TO_TYPE.
> 	* hooks.c (hook_tree_const_tree_null): Define.
> 	* hooks.h (hook_tree_const_tree_null): Declare.
> 	* target.h (struct gcc_target):  Add invalid_parameter_type,
> 	invalid_return_type, promoted_type, and convert_to_type fields.
> 	* target-def.h: (TARGET_INVALID_PARAMETER_TYPE): Define.
> 	(TARGET_INVALID_RETURN_TYPE): Define.
> 	(TARGET_PROMOTED_TYPE): Define.
> 	(TARGET_CONVERT_TO_TYPE): Define.
> 	(TARGET_INITIALIZER): Update for new fields.
> 	* c-decl.c (grokdeclarator): Check targetm.invalid_return_type.
> 	(grokparms): Check targetm.invalid_parameter_type.
> 	* c-typeck.c (default_conversion): Check targetm.promoted_type.
> 	* c-convert.c (convert): Check targetm.convert_to_type.
> 	* cp/typeck.c (default_conversion): Check targetm.promoted_type.
> 	* cp/decl.c (grokdeclarator): Check targetm.invalid_return_type.
> 	(grokparms): Check targetm.invalid_parameter_type.
> 	* cp/cvt.c (ocp_convert): Check targetm.convert_to_type.
> 	(build_expr_type_conversion): Check targetm.promoted_type.



> +@deftypefn {Target Hook} {const char *} TARGET_INVALID_PARAMETER_TYPE (tree @var{type})
> +If defined, this macro returns the diagnostic message when it is
> +invalid for functions to include parameters of type @var{type}, 
> +or @code{NULL} if validity should be determined by
> +the front end.
> +@end deftypefn

As far as I can tell, you have only implemented for the C and C++
frontends.  Unless you intend to extend the work other frontends, I
think that should be documented here.

> +@deftypefn {Target Hook} {const char *} TARGET_INVALID_RETURN_TYPE (tree @var{type})
> +If defined, this macro returns the diagnostic message when it is
> +invalid for functions to have return type @var{type}, 
> +or @code{NULL} if validity should be determined by
> +the front end.
> +@end deftypefn

Same comment.

> +@deftypefn {Target Hook} {tree} TARGET_PROMOTED_TYPE (tree @var{type})
> +If defined, this target hook returns the type to which values of 
> +@var{type} should be promoted when they appear in expressions, 
> +analogous to the integer promotions, or @code{NULL_TREE} to use the
> +front end's normal promotion rules.  This hook is useful when there are
> +target-specific types with special promotion rules.
> +@end deftypefn

This target hook will presumably never be used by frontends other than
C/C++, and that should be documented hre.

> +@deftypefn {Target Hook} {tree} TARGET_CONVERT_TO_TYPE (tree @var{type}, tree @var{expr})
> +If defined, this hook returns the result of converting @var{expr} to 
> +@var{type}.  It should return the converted expression, 
> +or @code{NULL_TREE} to apply the front end's normal conversion rules.
> +This hook is useful when there are target-specific types with special 
> +conversion rules.
> +@end deftypefn

I don't know whether this one is C/C++ specific or not.  I suspect that
it is.


> +  if ((e1 = targetm.convert_to_type (type, e)))
> +    return e1;

Don't do this kind of thing when you don't need to.  Replace with
something like:
  e1 = targetm.convert_to_type (type, e);
  if (e1)
    return e1;

> +  if ((ret =  targetm.convert_to_type (type, expr)))
> +      return ret;

Same here.


OK with those changes.

Thanks.

Ian



More information about the Gcc-patches mailing list