d: Move d_signed_type and d_unsigned_type to types.cc
These two functions are not tied to the language-specific part of the front-end in any way. gcc/d/ChangeLog: * d-lang.cc (d_gimplify_expr_p): Make static. (d_parse_file): Likewise. (d_signed_or_unsigned_type): Move to types.cc. (d_unsigned_type): Likewise. (d_signed_type): Likewise. * d-tree.h (d_unsigned_type): Change the location in file. (d_signed_type): Likewise. * types.cc (d_signed_or_unsigned_type): Moved from d-lang.cc. (d_unsigned_type): Likewise. (d_signed_type): Likewise.
This commit is contained in:
parent
1b7b352a83
commit
bbd6a326f4
3 changed files with 47 additions and 47 deletions
|
@ -880,7 +880,7 @@ empty_modify_p (tree type, tree op)
|
|||
/* Implements the lang_hooks.gimplify_expr routine for language D.
|
||||
Do gimplification of D specific expression trees in EXPR_P. */
|
||||
|
||||
int
|
||||
static int
|
||||
d_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
|
||||
gimple_seq *post_p ATTRIBUTE_UNUSED)
|
||||
{
|
||||
|
@ -1024,7 +1024,7 @@ d_add_entrypoint_module (Module *entry, Module *root)
|
|||
|
||||
/* Implements the lang_hooks.parse_file routine for language D. */
|
||||
|
||||
void
|
||||
static void
|
||||
d_parse_file (void)
|
||||
{
|
||||
if (global.params.verbose)
|
||||
|
@ -1507,49 +1507,6 @@ d_type_for_size (unsigned bits, int unsignedp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Return the signed or unsigned version of TYPE, an integral type, the
|
||||
signedness being specified by UNSIGNEDP. */
|
||||
|
||||
static tree
|
||||
d_signed_or_unsigned_type (int unsignedp, tree type)
|
||||
{
|
||||
if (TYPE_UNSIGNED (type) == (unsigned) unsignedp)
|
||||
return type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_cent_type))
|
||||
return unsignedp ? d_ucent_type : d_cent_type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_long_type))
|
||||
return unsignedp ? d_ulong_type : d_long_type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_int_type))
|
||||
return unsignedp ? d_uint_type : d_int_type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_short_type))
|
||||
return unsignedp ? d_ushort_type : d_short_type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_byte_type))
|
||||
return unsignedp ? d_ubyte_type : d_byte_type;
|
||||
|
||||
return signed_or_unsigned_type_for (unsignedp, type);
|
||||
}
|
||||
|
||||
/* Return the unsigned version of TYPE, an integral type. */
|
||||
|
||||
tree
|
||||
d_unsigned_type (tree type)
|
||||
{
|
||||
return d_signed_or_unsigned_type (1, type);
|
||||
}
|
||||
|
||||
/* Return the signed version of TYPE, an integral type. */
|
||||
|
||||
tree
|
||||
d_signed_type (tree type)
|
||||
{
|
||||
return d_signed_or_unsigned_type (0, type);
|
||||
}
|
||||
|
||||
/* Implements the lang_hooks.types.type_promotes_to routine for language D.
|
||||
All promotions for variable arguments are handled by the D frontend. */
|
||||
|
||||
|
|
|
@ -598,8 +598,6 @@ extern d_tree_node_structure_enum d_tree_node_structure (lang_tree_node *);
|
|||
extern struct lang_type *build_lang_type (Type *);
|
||||
extern struct lang_decl *build_lang_decl (Declaration *);
|
||||
extern tree d_pushdecl (tree);
|
||||
extern tree d_unsigned_type (tree);
|
||||
extern tree d_signed_type (tree);
|
||||
extern void d_keep (tree);
|
||||
|
||||
/* In decl.cc. */
|
||||
|
@ -672,6 +670,8 @@ extern void add_stmt (tree);
|
|||
extern void build_function_body (FuncDeclaration *);
|
||||
|
||||
/* In types.cc. */
|
||||
extern tree d_unsigned_type (tree);
|
||||
extern tree d_signed_type (tree);
|
||||
extern bool valist_array_p (Type *);
|
||||
extern bool empty_aggregate_p (tree);
|
||||
extern bool same_type_p (Type *, Type *);
|
||||
|
|
|
@ -42,6 +42,49 @@ along with GCC; see the file COPYING3. If not see
|
|||
#include "d-tree.h"
|
||||
|
||||
|
||||
/* Return the signed or unsigned version of TYPE, an integral type, the
|
||||
signedness being specified by UNSIGNEDP. */
|
||||
|
||||
static tree
|
||||
d_signed_or_unsigned_type (int unsignedp, tree type)
|
||||
{
|
||||
if (TYPE_UNSIGNED (type) == (unsigned) unsignedp)
|
||||
return type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_cent_type))
|
||||
return unsignedp ? d_ucent_type : d_cent_type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_long_type))
|
||||
return unsignedp ? d_ulong_type : d_long_type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_int_type))
|
||||
return unsignedp ? d_uint_type : d_int_type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_short_type))
|
||||
return unsignedp ? d_ushort_type : d_short_type;
|
||||
|
||||
if (TYPE_PRECISION (type) == TYPE_PRECISION (d_byte_type))
|
||||
return unsignedp ? d_ubyte_type : d_byte_type;
|
||||
|
||||
return signed_or_unsigned_type_for (unsignedp, type);
|
||||
}
|
||||
|
||||
/* Return the unsigned version of TYPE, an integral type. */
|
||||
|
||||
tree
|
||||
d_unsigned_type (tree type)
|
||||
{
|
||||
return d_signed_or_unsigned_type (1, type);
|
||||
}
|
||||
|
||||
/* Return the signed version of TYPE, an integral type. */
|
||||
|
||||
tree
|
||||
d_signed_type (tree type)
|
||||
{
|
||||
return d_signed_or_unsigned_type (0, type);
|
||||
}
|
||||
|
||||
/* Return TRUE if TYPE is a static array va_list. This is for compatibility
|
||||
with the C ABI, where va_list static arrays are passed by reference.
|
||||
However for every other case in D, static arrays are passed by value. */
|
||||
|
|
Loading…
Add table
Reference in a new issue