summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraesok <aesok@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-01 17:52:02 +0000
committeraesok <aesok@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-01 17:52:02 +0000
commit3327418041ec57f6db06ba8ec7ea88616c2d7728 (patch)
tree04b921bafe9da0814bfd9d39ff3475fef41e5805
parentbfe513a49f83aeaed190d83ba4497b85c1d8aaaf (diff)
downloadgcc-3327418041ec57f6db06ba8ec7ea88616c2d7728.tar.gz
* rtl.h (CONST_DOUBLE_P): Define.
(rtx_to_double_int): Declare. * emit-rtl.c (rtx_to_double_int): New function. * dwarf2out.c (insert_double): New function. (loc_descriptor, add_const_value_attribute): Clean up, use rtx_to_double_int and insert_double functions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158963 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/dwarf2out.c87
-rw-r--r--gcc/emit-rtl.c21
-rw-r--r--gcc/rtl.h5
4 files changed, 62 insertions, 60 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b9621186e5f..f978694a953 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-01 Anatoly Sokolov <aesok@post.ru>
+
+ * rtl.h (CONST_DOUBLE_P): Define.
+ (rtx_to_double_int): Declare.
+ * emit-rtl.c (rtx_to_double_int): New function.
+ * dwarf2out.c (insert_double): New function.
+ (loc_descriptor, add_const_value_attribute): Clean up, use
+ rtx_to_double_int and insert_double functions.
+
2010-05-01 Jonathan Wakely <jwakely.gcc@gmail.com>
* doc/extend.texi (Inline): Add missing return keyword to examples.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ac0258c98d3..ab04b68edec 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -6116,6 +6116,7 @@ static void add_AT_location_description (dw_die_ref, enum dwarf_attribute,
static void add_data_member_location_attribute (dw_die_ref, tree);
static bool add_const_value_attribute (dw_die_ref, rtx);
static void insert_int (HOST_WIDE_INT, unsigned, unsigned char *);
+static void insert_double (double_int, unsigned char *);
static void insert_float (const_rtx, unsigned char *);
static rtx rtl_for_decl_location (tree);
static bool add_location_or_const_value_attribute (dw_die_ref, tree,
@@ -13887,10 +13888,8 @@ loc_descriptor (rtx rtl, enum machine_mode mode,
else
{
loc_result->dw_loc_oprnd2.val_class = dw_val_class_const_double;
- loc_result->dw_loc_oprnd2.v.val_double.high
- = CONST_DOUBLE_HIGH (rtl);
- loc_result->dw_loc_oprnd2.v.val_double.low
- = CONST_DOUBLE_LOW (rtl);
+ loc_result->dw_loc_oprnd2.v.val_double
+ = rtx_to_double_int (rtl);
}
}
break;
@@ -13914,39 +13913,14 @@ loc_descriptor (rtx rtl, enum machine_mode mode,
for (i = 0, p = array; i < length; i++, p += elt_size)
{
rtx elt = CONST_VECTOR_ELT (rtl, i);
- HOST_WIDE_INT lo, hi;
-
- switch (GET_CODE (elt))
- {
- case CONST_INT:
- lo = INTVAL (elt);
- hi = -(lo < 0);
- break;
-
- case CONST_DOUBLE:
- lo = CONST_DOUBLE_LOW (elt);
- hi = CONST_DOUBLE_HIGH (elt);
- break;
-
- default:
- gcc_unreachable ();
- }
+ double_int val = rtx_to_double_int (elt);
if (elt_size <= sizeof (HOST_WIDE_INT))
- insert_int (lo, elt_size, p);
+ insert_int (double_int_to_shwi (val), elt_size, p);
else
{
- unsigned char *p0 = p;
- unsigned char *p1 = p + sizeof (HOST_WIDE_INT);
-
gcc_assert (elt_size == 2 * sizeof (HOST_WIDE_INT));
- if (WORDS_BIG_ENDIAN)
- {
- p0 = p1;
- p1 = p;
- }
- insert_int (lo, sizeof (HOST_WIDE_INT), p0);
- insert_int (hi, sizeof (HOST_WIDE_INT), p1);
+ insert_double (val, p);
}
}
break;
@@ -15334,6 +15308,24 @@ extract_int (const unsigned char *src, unsigned int size)
return val;
}
+/* Writes double_int values to dw_vec_const array. */
+
+static void
+insert_double (double_int val, unsigned char *dest)
+{
+ unsigned char *p0 = dest;
+ unsigned char *p1 = dest + sizeof (HOST_WIDE_INT);
+
+ if (WORDS_BIG_ENDIAN)
+ {
+ p0 = p1;
+ p1 = dest;
+ }
+
+ insert_int ((HOST_WIDE_INT) val.low, sizeof (HOST_WIDE_INT), p0);
+ insert_int ((HOST_WIDE_INT) val.high, sizeof (HOST_WIDE_INT), p1);
+}
+
/* Writes floating point values to dw_vec_const array. */
static void
@@ -15413,39 +15405,14 @@ add_const_value_attribute (dw_die_ref die, rtx rtl)
for (i = 0, p = array; i < length; i++, p += elt_size)
{
rtx elt = CONST_VECTOR_ELT (rtl, i);
- HOST_WIDE_INT lo, hi;
-
- switch (GET_CODE (elt))
- {
- case CONST_INT:
- lo = INTVAL (elt);
- hi = -(lo < 0);
- break;
-
- case CONST_DOUBLE:
- lo = CONST_DOUBLE_LOW (elt);
- hi = CONST_DOUBLE_HIGH (elt);
- break;
-
- default:
- gcc_unreachable ();
- }
+ double_int val = rtx_to_double_int (elt);
if (elt_size <= sizeof (HOST_WIDE_INT))
- insert_int (lo, elt_size, p);
+ insert_int (double_int_to_shwi (val), elt_size, p);
else
{
- unsigned char *p0 = p;
- unsigned char *p1 = p + sizeof (HOST_WIDE_INT);
-
gcc_assert (elt_size == 2 * sizeof (HOST_WIDE_INT));
- if (WORDS_BIG_ENDIAN)
- {
- p0 = p1;
- p1 = p;
- }
- insert_int (lo, sizeof (HOST_WIDE_INT), p0);
- insert_int (hi, sizeof (HOST_WIDE_INT), p1);
+ insert_double (val, p);
}
}
break;
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index d4ba5d706ed..e0acc0c2766 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -518,6 +518,27 @@ const_fixed_from_fixed_value (FIXED_VALUE_TYPE value, enum machine_mode mode)
return lookup_const_fixed (fixed);
}
+/* Constructs double_int from rtx CST. */
+
+double_int
+rtx_to_double_int (const_rtx cst)
+{
+ double_int r;
+
+ if (CONST_INT_P (cst))
+ r = shwi_to_double_int (INTVAL (cst));
+ else if (CONST_DOUBLE_P (cst) && GET_MODE (cst) == VOIDmode)
+ {
+ r.low = CONST_DOUBLE_LOW (cst);
+ r.high = CONST_DOUBLE_HIGH (cst);
+ }
+ else
+ gcc_unreachable ();
+
+ return r;
+}
+
+
/* Return a CONST_DOUBLE or CONST_INT for a value specified as
a double_int. */
diff --git a/gcc/rtl.h b/gcc/rtl.h
index ccb3c1a044a..fe17ae7cba5 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -375,6 +375,10 @@ struct GTY(()) rtvec_def {
/* Predicate yielding nonzero iff X is an rtx for a constant integer. */
#define CONST_INT_P(X) (GET_CODE (X) == CONST_INT)
+/* Predicate yielding true iff X is an rtx for a double-int
+ or floating point constant. */
+#define CONST_DOUBLE_P(X) (GET_CODE (X) == CONST_DOUBLE)
+
/* Predicate yielding nonzero iff X is a label insn. */
#define LABEL_P(X) (GET_CODE (X) == CODE_LABEL)
@@ -1627,6 +1631,7 @@ extern void start_sequence (void);
extern void push_to_sequence (rtx);
extern void push_to_sequence2 (rtx, rtx);
extern void end_sequence (void);
+extern double_int rtx_to_double_int (const_rtx);
extern rtx immed_double_int_const (double_int, enum machine_mode);
extern rtx immed_double_const (HOST_WIDE_INT, HOST_WIDE_INT,
enum machine_mode);