summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-28 20:25:14 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2014-04-28 20:25:14 +0000
commit28e557ef838c3e4f48d40654ace9b2b85563a6c9 (patch)
tree7927d7f2a78108900b25f0e8a0d94ff3db049c56
parent1cee90adce76bf3df916a16cbf24460b25578892 (diff)
downloadgcc-28e557ef838c3e4f48d40654ace9b2b85563a6c9.tar.gz
Prevent wide_int = {widest,offset}_int
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@209874 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/emit-rtl.c2
-rw-r--r--gcc/rtl.h2
-rw-r--r--gcc/tree-ssa-ccp.c7
-rw-r--r--gcc/tree-vrp.c3
-rw-r--r--gcc/wide-int-print.cc16
-rw-r--r--gcc/wide-int-print.h16
-rw-r--r--gcc/wide-int.cc27
-rw-r--r--gcc/wide-int.h5
8 files changed, 40 insertions, 38 deletions
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index 5258eebdf8f..f2b8257de7c 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -535,7 +535,7 @@ lookup_const_wide_int (rtx wint)
(if TARGET_SUPPORTS_WIDE_INT). */
rtx
-immed_wide_int_const (const wide_int &v, enum machine_mode mode)
+immed_wide_int_const (const wide_int_ref &v, enum machine_mode mode)
{
unsigned int len = v.get_len ();
unsigned int prec = GET_MODE_PRECISION (mode);
diff --git a/gcc/rtl.h b/gcc/rtl.h
index f62c334351d..9fb75574e95 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2008,7 +2008,7 @@ extern double_int rtx_to_double_int (const_rtx);
#endif
extern void cwi_output_hex (FILE *, const_rtx);
#ifndef GENERATOR_FILE
-extern rtx immed_wide_int_const (const wide_int &cst, enum machine_mode mode);
+extern rtx immed_wide_int_const (const wide_int_ref &, enum machine_mode);
#endif
#if TARGET_SUPPORTS_WIDE_INT == 0
extern rtx immed_double_const (HOST_WIDE_INT, HOST_WIDE_INT,
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 301675eb139..b1e21b8b47c 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -218,7 +218,8 @@ dump_lattice_value (FILE *outf, const char *prefix, prop_value_t val)
}
else
{
- wide_int cval = wi::bit_and_not (wi::to_widest (val.value), val.mask);
+ widest_int cval = wi::bit_and_not (wi::to_widest (val.value),
+ val.mask);
fprintf (outf, "%sCONSTANT ", prefix);
print_hex (cval, outf);
fprintf (outf, " (");
@@ -1249,7 +1250,7 @@ bit_value_binop_1 (enum tree_code code, tree type,
case RROTATE_EXPR:
if (r2mask == 0)
{
- wide_int shift = r2val;
+ widest_int shift = r2val;
if (shift == 0)
{
*mask = r1mask;
@@ -1286,7 +1287,7 @@ bit_value_binop_1 (enum tree_code code, tree type,
is zero. */
if (r2mask == 0)
{
- wide_int shift = r2val;
+ widest_int shift = r2val;
if (shift == 0)
{
*mask = r1mask;
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 7951805e473..890ee936fea 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -3860,7 +3860,8 @@ adjust_range_with_scev (value_range_t *vr, struct loop *loop,
signop sgn = TYPE_SIGN (TREE_TYPE (step));
bool overflow;
- wide_int wtmp = wi::mul (wi::to_widest (step), nit, sgn, &overflow);
+ widest_int wtmp = wi::mul (wi::to_widest (step), nit, sgn,
+ &overflow);
/* If the multiplication overflowed we can't do a meaningful
adjustment. Likewise if the result doesn't fit in the type
of the induction variable. For a signed type we have to
diff --git a/gcc/wide-int-print.cc b/gcc/wide-int-print.cc
index 61d732ba3cb..c79c781d3ef 100644
--- a/gcc/wide-int-print.cc
+++ b/gcc/wide-int-print.cc
@@ -34,7 +34,7 @@ along with GCC; see the file COPYING3. If not see
(((PREC) + HOST_BITS_PER_WIDE_INT - 1) / HOST_BITS_PER_WIDE_INT)
void
-print_dec (const wide_int &wi, char *buf, signop sgn)
+print_dec (const wide_int_ref &wi, char *buf, signop sgn)
{
if (sgn == SIGNED)
print_decs (wi, buf);
@@ -43,7 +43,7 @@ print_dec (const wide_int &wi, char *buf, signop sgn)
}
void
-print_dec (const wide_int &wi, FILE *file, signop sgn)
+print_dec (const wide_int_ref &wi, FILE *file, signop sgn)
{
if (sgn == SIGNED)
print_decs (wi, file);
@@ -56,7 +56,7 @@ print_dec (const wide_int &wi, FILE *file, signop sgn)
in a HWI. Other print in hex. */
void
-print_decs (const wide_int &wi, char *buf)
+print_decs (const wide_int_ref &wi, char *buf)
{
if ((wi.get_precision () <= HOST_BITS_PER_WIDE_INT)
|| (wi.get_len () == 1))
@@ -74,7 +74,7 @@ print_decs (const wide_int &wi, char *buf)
in a HWI. Other print in hex. */
void
-print_decs (const wide_int &wi, FILE *file)
+print_decs (const wide_int_ref &wi, FILE *file)
{
char buf[WIDE_INT_PRINT_BUFFER_SIZE];
print_decs (wi, buf);
@@ -85,7 +85,7 @@ print_decs (const wide_int &wi, FILE *file)
in a HWI. Other print in hex. */
void
-print_decu (const wide_int &wi, char *buf)
+print_decu (const wide_int_ref &wi, char *buf)
{
if ((wi.get_precision () <= HOST_BITS_PER_WIDE_INT)
|| (wi.get_len () == 1 && !wi::neg_p (wi)))
@@ -98,7 +98,7 @@ print_decu (const wide_int &wi, char *buf)
in a HWI. Other print in hex. */
void
-print_decu (const wide_int &wi, FILE *file)
+print_decu (const wide_int_ref &wi, FILE *file)
{
char buf[WIDE_INT_PRINT_BUFFER_SIZE];
print_decu (wi, buf);
@@ -106,7 +106,7 @@ print_decu (const wide_int &wi, FILE *file)
}
void
-print_hex (const wide_int &wi, char *buf)
+print_hex (const wide_int_ref &wi, char *buf)
{
int i = wi.get_len ();
@@ -136,7 +136,7 @@ print_hex (const wide_int &wi, char *buf)
/* Print one big hex number to FILE. Note that some assemblers may not
accept this for large modes. */
void
-print_hex (const wide_int &wi, FILE *file)
+print_hex (const wide_int_ref &wi, FILE *file)
{
char buf[WIDE_INT_PRINT_BUFFER_SIZE];
print_hex (wi, buf);
diff --git a/gcc/wide-int-print.h b/gcc/wide-int-print.h
index af0751760af..9ab37d33432 100644
--- a/gcc/wide-int-print.h
+++ b/gcc/wide-int-print.h
@@ -27,13 +27,13 @@ along with GCC; see the file COPYING3. If not see
/* Printing functions. */
-extern void print_dec (const wide_int &wi, char *buf, signop sgn);
-extern void print_dec (const wide_int &wi, FILE *file, signop sgn);
-extern void print_decs (const wide_int &wi, char *buf);
-extern void print_decs (const wide_int &wi, FILE *file);
-extern void print_decu (const wide_int &wi, char *buf);
-extern void print_decu (const wide_int &wi, FILE *file);
-extern void print_hex (const wide_int &wi, char *buf);
-extern void print_hex (const wide_int &wi, FILE *file);
+extern void print_dec (const wide_int_ref &wi, char *buf, signop sgn);
+extern void print_dec (const wide_int_ref &wi, FILE *file, signop sgn);
+extern void print_decs (const wide_int_ref &wi, char *buf);
+extern void print_decs (const wide_int_ref &wi, FILE *file);
+extern void print_decu (const wide_int_ref &wi, char *buf);
+extern void print_decu (const wide_int_ref &wi, FILE *file);
+extern void print_hex (const wide_int_ref &wi, char *buf);
+extern void print_hex (const wide_int_ref &wi, FILE *file);
#endif /* WIDE_INT_PRINT_H */
diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc
index 0627cf5e5fd..bf414c125bf 100644
--- a/gcc/wide-int.cc
+++ b/gcc/wide-int.cc
@@ -174,37 +174,36 @@ wi::from_buffer (const unsigned char *buffer, unsigned int buffer_len)
return result;
}
-/* Sets RESULT from THIS, the sign is taken according to SGN. */
+/* Sets RESULT from X, the sign is taken according to SGN. */
void
-wi::to_mpz (wide_int x, mpz_t result, signop sgn)
+wi::to_mpz (const wide_int_ref &x, mpz_t result, signop sgn)
{
- bool negative = false;
int len = x.get_len ();
const HOST_WIDE_INT *v = x.get_val ();
- int small_prec = x.get_precision () & (HOST_BITS_PER_WIDE_INT - 1);
+ int excess = len * HOST_BITS_PER_WIDE_INT - x.get_precision ();
if (wi::neg_p (x, sgn))
{
- negative = true;
/* We use ones complement to avoid -x80..0 edge case that -
won't work on. */
- x = ~x;
+ HOST_WIDE_INT *t = XALLOCAVEC (HOST_WIDE_INT, len);
+ for (int i = 0; i < len; i++)
+ t[i] = ~v[i];
+ if (excess > 0)
+ t[len - 1] = (unsigned HOST_WIDE_INT) t[len - 1] << excess >> excess;
+ mpz_import (result, len, -1, sizeof (HOST_WIDE_INT), 0, 0, t);
+ mpz_com (result, result);
}
-
- if (sgn == UNSIGNED && small_prec)
+ else if (excess > 0)
{
- HOST_WIDE_INT t[WIDE_INT_MAX_ELTS];
-
+ HOST_WIDE_INT *t = XALLOCAVEC (HOST_WIDE_INT, len);
for (int i = 0; i < len - 1; i++)
t[i] = v[i];
- t[len-1] = zext_hwi (v[len-1], small_prec);
+ t[len - 1] = (unsigned HOST_WIDE_INT) v[len - 1] << excess >> excess;
mpz_import (result, len, -1, sizeof (HOST_WIDE_INT), 0, 0, t);
}
else
mpz_import (result, len, -1, sizeof (HOST_WIDE_INT), 0, 0, v);
-
- if (negative)
- mpz_com (result, result);
}
/* Returns X converted to TYPE. If WRAP is true, then out-of-range
diff --git a/gcc/wide-int.h b/gcc/wide-int.h
index a98c57178e3..f6e30bc953a 100644
--- a/gcc/wide-int.h
+++ b/gcc/wide-int.h
@@ -1033,7 +1033,8 @@ inline wide_int_storage::wide_int_storage () {}
template <typename T>
inline wide_int_storage::wide_int_storage (const T &x)
{
- STATIC_ASSERT (!wi::int_traits<T>::host_dependent_precision);
+ { STATIC_ASSERT (!wi::int_traits<T>::host_dependent_precision); }
+ { STATIC_ASSERT (wi::int_traits<T>::precision_type != wi::CONST_PRECISION); }
WIDE_INT_REF_FOR (T) xi (x);
precision = xi.precision;
wi::copy (*this, xi);
@@ -3087,7 +3088,7 @@ namespace wi
wide_int from_buffer (const unsigned char *, unsigned int);
#ifndef GENERATOR_FILE
- void to_mpz (wide_int, mpz_t, signop);
+ void to_mpz (const wide_int_ref &, mpz_t, signop);
#endif
wide_int mask (unsigned int, bool, unsigned int);