Change to build_int_cst via function overload.
This unifies build_int_cst-like functions.
Bootstrapped and regtested on x86_64-pc-linux-gnu.
PR middle-end/126622
gcc/ChangeLog:
* tree.h (double_int_to_tree): Rename to ...
(build_int_cst): this via function overload.
* tree.cc (double_int_to_tree): Ditto.
(build_int_cst): Ditto.
* fold-const.cc (native_encode_fixed): Ditto.
gcc/cp/ChangeLog:
* parser.cc (make_string_pack): Rename double_int_to_tree.
gcc/go/ChangeLog:
* go-gcc.cc (Gcc_backend::integer_constant_expression): Rename
double_int_to_tree.
Signed-off-by: Kael Andrew Franco <[email protected]>
---
gcc/cp/parser.cc | 2 +-
gcc/fold-const.cc | 2 +-
gcc/go/go-gcc.cc | 2 +-
gcc/tree.cc | 15 ++++++---------
gcc/tree.h | 5 +----
5 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 720dec6841e..f344378d3d7 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -5277,7 +5277,7 @@ make_string_pack (tree value)
charvec = make_tree_vec (len);
for (int i = 0; i < len; ++i)
TREE_VEC_ELT (charvec, i)
- = double_int_to_tree (str_char_type_node,
+ = build_int_cst (str_char_type_node,
double_int::from_buffer (str + i * sz, sz));
/* Build the argument packs. */
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 4c4b535d440..5df42184001 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -7644,7 +7644,7 @@ native_encode_fixed (const_tree expr, unsigned char *ptr,
int len, int off)
return 0;
value = TREE_FIXED_CST (expr);
- i_value = double_int_to_tree (i_type, value.data);
+ i_value = build_int_cst (i_type, value.data);
return native_encode_int (i_value, ptr, len, off);
}
diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index aa7939b2438..ebb5d008ac1 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -1540,7 +1540,7 @@ Gcc_backend::integer_constant_expression(Btype* btype,
mpz_t val)
if (t == error_mark_node)
return this->error_expression();
- tree ret = double_int_to_tree(t, mpz_get_double_int(t, val, true));
+ tree ret = build_int_cst(t, mpz_get_double_int(t, val, true));
return this->make_expression(ret);
}
diff --git a/gcc/tree.cc b/gcc/tree.cc
index 69a7c7e6d34..c6955d2e98b 100644
--- a/gcc/tree.cc
+++ b/gcc/tree.cc
@@ -1653,6 +1653,12 @@ build_int_cst (tree type, poly_int64 cst)
return wide_int_to_tree (type, wi::shwi (cst, TYPE_PRECISION (type)));
}
+tree
+build_int_cst (tree type, double_int cst)
+{
+ return wide_int_to_tree (type, widest_int::from (cst, TYPE_SIGN (type)));
+}
+
/* Create a constant tree that contains CST zero-extended to TYPE. */
tree
@@ -1670,15 +1676,6 @@ build_int_cst_type (tree type, poly_int64 cst)
return wide_int_to_tree (type, wi::shwi (cst, TYPE_PRECISION (type)));
}
-/* Constructs tree in type TYPE from with value given by CST. Signedness
- of CST is assumed to be the same as the signedness of TYPE. */
-
-tree
-double_int_to_tree (tree type, double_int cst)
-{
- return wide_int_to_tree (type, widest_int::from (cst, TYPE_SIGN (type)));
-}
-
/* We force the wide_int CST to the range of the type TYPE by sign or
zero extending it. OVERFLOWABLE indicates if we are interested in
overflow of the value, when >0 we are only interested in signed
diff --git a/gcc/tree.h b/gcc/tree.h
index 3fb643ea0fb..e440b94a43b 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5005,10 +5005,6 @@ build5_loc (location_t loc, enum tree_code code, tree
type, tree arg0,
return t;
}
-/* Constructs double_int from tree CST. */
-
-extern tree double_int_to_tree (tree, double_int);
-
extern tree wide_int_to_tree (tree type, const poly_wide_int_ref &cst);
extern tree force_fit_type (tree, const poly_wide_int_ref &, int, bool);
@@ -5016,6 +5012,7 @@ extern tree force_fit_type (tree, const poly_wide_int_ref
&, int, bool);
/* static inline */
extern tree build_int_cst (tree, poly_int64);
+extern tree build_int_cst (tree, double_int);
extern tree build_int_cstu (tree type, poly_uint64);
extern tree build_int_cst_type (tree, poly_int64);
extern tree make_vector (unsigned, unsigned CXX_MEM_STAT_INFO);
--
2.55.0