aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2020-06-19 16:51:13 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2020-06-25 17:02:47 +0200
commitbbd6a326f4e630f017e4cd715f617587048d4501 (patch)
treeebf31e52e752025d4c289e00a5bf1a59f982f797
parent1b7b352a8379dbdd74c962d11951982e21e20f13 (diff)
downloadgcc-bbd6a326f4e630f017e4cd715f617587048d4501.zip
gcc-bbd6a326f4e630f017e4cd715f617587048d4501.tar.gz
gcc-bbd6a326f4e630f017e4cd715f617587048d4501.tar.bz2
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.
-rw-r--r--gcc/d/d-lang.cc47
-rw-r--r--gcc/d/d-tree.h4
-rw-r--r--gcc/d/types.cc43
3 files changed, 47 insertions, 47 deletions
diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc
index 2c474f8..6412c1c 100644
--- a/gcc/d/d-lang.cc
+++ b/gcc/d/d-lang.cc
@@ -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. */
diff --git a/gcc/d/d-tree.h b/gcc/d/d-tree.h
index 4ae38d1..b4b832f 100644
--- a/gcc/d/d-tree.h
+++ b/gcc/d/d-tree.h
@@ -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 *);
diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index b8984a5..0d05e4d 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -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. */