2007-10-25 Wu Zhou <woodzltc@cn.ibm.com>
Thiago Jung Bauermann <bauerman@br.ibm.com> * c-exp.y (YYSTYPE): Add typed_val_decfloat for decimal floating point in YYSTYPE union. (DECFLOAT) Add token and expression element handling code. (parse_number): Parse DFP constants, which end with suffix 'df', 'dd' or 'dl'. Return DECFLOAT. * eval.c (evaluate_subexp_standard): Call value_from_decfloat to handle OP_DECFLOAT. * expression.h (enum exp_opcode): Add an opcode (OP_DECFLOAT) for DFP constants. (union exp_element): Add decfloatconst to represent DFP elements, which is 16 bytes by default. * parse.c (write_exp_elt_decfloatcst): New function to write a decimal float const into the expression. (operator_length_standard): Set operator length for OP_DECFLOAT to 4. * parser-defs.h (write_exp_elt_decfloatcst): Prototype. * valarith.c (value_neg): Add code to handle the negation operation of DFP values. * value.c (value_from_decfloat): New function to get the value from a decimal floating point. * value.h (value_from_decfloat): Prototype.
This commit is contained in:
parent
7678ef8fb0
commit
27bc4d809e
9 changed files with 140 additions and 0 deletions
|
@ -1376,6 +1376,23 @@ value_neg (struct value *arg1)
|
|||
|
||||
type = check_typedef (value_type (arg1));
|
||||
|
||||
if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT)
|
||||
{
|
||||
struct value *val = allocate_value (result_type);
|
||||
int len = TYPE_LENGTH (type);
|
||||
gdb_byte decbytes[16]; /* a decfloat is at most 128 bits long */
|
||||
|
||||
memcpy(decbytes, value_contents(arg1), len);
|
||||
|
||||
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE)
|
||||
decbytes[len-1] = decbytes[len - 1] | 0x80;
|
||||
else
|
||||
decbytes[0] = decbytes[0] | 0x80;
|
||||
|
||||
memcpy (value_contents_raw (val), decbytes, len);
|
||||
return val;
|
||||
}
|
||||
|
||||
if (TYPE_CODE (type) == TYPE_CODE_FLT)
|
||||
return value_from_double (result_type, -value_as_double (arg1));
|
||||
else if (is_integral_type (type))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue