summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2009-06-03 17:47:54 +0000
committerUlrich Weigand <uweigand@de.ibm.com>2009-06-03 17:47:54 +0000
commit77a91124678352c6cd265a189d9e4e9d9323ed8c (patch)
tree6ea7b47b04eda02333a5b21baeea51dfed87f1df
parentbc5284cc19ee108242a81b378fcdec6a7691170a (diff)
downloadgdb-77a91124678352c6cd265a189d9e4e9d9323ed8c.tar.gz
* dfp.h (decimal_binop): Convert LEN_RESULT to input parameter.
* dfp.c (promote_decimal): Remove. (decimal_binop): Convert LEN_RESULT to input parameter. Remove call to decimal_binop. (decimal_compare): Remove call to decimal_binop. * valarith.c (value_binop): Pass desired result type length to decimal_binop.
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/dfp.c55
-rw-r--r--gdb/dfp.h2
-rw-r--r--gdb/valarith.c26
4 files changed, 38 insertions, 56 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 69003a58493..d979a680353 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,14 @@
+2009-06-03 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * dfp.h (decimal_binop): Convert LEN_RESULT to input parameter.
+ * dfp.c (promote_decimal): Remove.
+ (decimal_binop): Convert LEN_RESULT to input parameter.
+ Remove call to decimal_binop.
+ (decimal_compare): Remove call to decimal_binop.
+
+ * valarith.c (value_binop): Pass desired result type length
+ to decimal_binop.
+
2009-06-01 Tristan Gingold <gingold@adacore.com>
* configure.tgt (avr): Set gdb_sim to use the simulator.
diff --git a/gdb/dfp.c b/gdb/dfp.c
index 92d7daad6a6..4b3cdb1f95b 100644
--- a/gdb/dfp.c
+++ b/gdb/dfp.c
@@ -255,38 +255,11 @@ decimal_to_doublest (const gdb_byte *from, int len)
return strtod (buffer, NULL);
}
-/* Check if operands have the same size and convert them to the
- biggest of the two if necessary. */
-static int
-promote_decimal (gdb_byte *x, int len_x, gdb_byte *y, int len_y)
-{
- int len_result;
- decNumber number;
-
- if (len_x < len_y)
- {
- decimal_to_number (x, len_x, &number);
- decimal_from_number (&number, x, len_y);
- len_result = len_y;
- }
- else if (len_x > len_y)
- {
- decimal_to_number (y, len_y, &number);
- decimal_from_number (&number, y, len_x);
- len_result = len_x;
- }
- else
- len_result = len_x;
-
- return len_result;
-}
-
-/* Perform operation OP with operands X and Y and store value in RESULT.
- If LEN_X and LEN_Y are not equal, RESULT will have the size of the biggest
- of the two, and LEN_RESULT will be set accordingly. */
+/* Perform operation OP with operands X and Y with sizes LEN_X and LEN_Y
+ and store value in RESULT with size LEN_RESULT. */
void
decimal_binop (enum exp_opcode op, const gdb_byte *x, int len_x,
- const gdb_byte *y, int len_y, gdb_byte *result, int *len_result)
+ const gdb_byte *y, int len_y, gdb_byte *result, int len_result)
{
decContext set;
decNumber number1, number2, number3;
@@ -295,14 +268,10 @@ decimal_binop (enum exp_opcode op, const gdb_byte *x, int len_x,
match_endianness (x, len_x, dec1);
match_endianness (y, len_y, dec2);
- *len_result = promote_decimal (dec1, len_x, dec2, len_y);
+ decimal_to_number (dec1, len_x, &number1);
+ decimal_to_number (dec2, len_y, &number2);
- /* Both operands are of size *len_result from now on. */
-
- decimal_to_number (dec1, *len_result, &number1);
- decimal_to_number (dec2, *len_result, &number2);
-
- set_decnumber_context (&set, *len_result);
+ set_decnumber_context (&set, len_result);
switch (op)
{
@@ -330,9 +299,9 @@ decimal_binop (enum exp_opcode op, const gdb_byte *x, int len_x,
/* Check for errors in the DFP operation. */
decimal_check_errors (&set);
- decimal_from_number (&number3, dec3, *len_result);
+ decimal_from_number (&number3, dec3, len_result);
- match_endianness (dec3, *len_result, result);
+ match_endianness (dec3, len_result, result);
}
/* Returns true if X (which is LEN bytes wide) is the number zero. */
@@ -362,11 +331,11 @@ decimal_compare (const gdb_byte *x, int len_x, const gdb_byte *y, int len_y)
match_endianness (x, len_x, dec1);
match_endianness (y, len_y, dec2);
- len_result = promote_decimal (dec1, len_x, dec2, len_y);
-
- decimal_to_number (dec1, len_result, &number1);
- decimal_to_number (dec2, len_result, &number2);
+ decimal_to_number (dec1, len_x, &number1);
+ decimal_to_number (dec2, len_y, &number2);
+ /* Perform the comparison in the larger of the two sizes. */
+ len_result = len_x > len_y ? len_x : len_y;
set_decnumber_context (&set, len_result);
decNumberCompare (&result, &number1, &number2, &set);
diff --git a/gdb/dfp.h b/gdb/dfp.h
index 737e905e31f..b8df9e89e0d 100644
--- a/gdb/dfp.h
+++ b/gdb/dfp.h
@@ -35,7 +35,7 @@ extern void decimal_from_integral (struct value *from, gdb_byte *to, int len);
extern void decimal_from_floating (struct value *from, gdb_byte *to, int len);
extern DOUBLEST decimal_to_doublest (const gdb_byte *from, int len);
extern void decimal_binop (enum exp_opcode, const gdb_byte *, int,
- const gdb_byte *, int, gdb_byte *, int *);
+ const gdb_byte *, int, gdb_byte *, int);
extern int decimal_is_zero (const gdb_byte *x, int len);
extern int decimal_compare (const gdb_byte *x, int len_x, const gdb_byte *y, int len_y);
extern void decimal_convert (const gdb_byte *from, int len_from, gdb_byte *to,
diff --git a/gdb/valarith.c b/gdb/valarith.c
index f38cdb842fc..57e6194c7f9 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -887,6 +887,19 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
gdb_byte v1[16], v2[16];
gdb_byte v[16];
+ /* If only one type is decimal float, use its type.
+ Otherwise use the bigger type. */
+ if (TYPE_CODE (type1) != TYPE_CODE_DECFLOAT)
+ result_type = type2;
+ else if (TYPE_CODE (type2) != TYPE_CODE_DECFLOAT)
+ result_type = type1;
+ else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1))
+ result_type = type2;
+ else
+ result_type = type1;
+
+ len_v = TYPE_LENGTH (result_type);
+
value_args_as_decimal (arg1, arg2, v1, &len_v1, v2, &len_v2);
switch (op)
@@ -896,24 +909,13 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
case BINOP_MUL:
case BINOP_DIV:
case BINOP_EXP:
- decimal_binop (op, v1, len_v1, v2, len_v2, v, &len_v);
+ decimal_binop (op, v1, len_v1, v2, len_v2, v, len_v);
break;
default:
error (_("Operation not valid for decimal floating point number."));
}
- /* If only one type is decimal float, use its type.
- Otherwise use the bigger type. */
- if (TYPE_CODE (type1) != TYPE_CODE_DECFLOAT)
- result_type = type2;
- else if (TYPE_CODE (type2) != TYPE_CODE_DECFLOAT)
- result_type = type1;
- else if (TYPE_LENGTH (type2) > TYPE_LENGTH (type1))
- result_type = type2;
- else
- result_type = type1;
-
val = value_from_decfloat (result_type, v);
}
else if (TYPE_CODE (type1) == TYPE_CODE_FLT