GCC Middle and Back End API Reference
dfp.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "tm_p.h"
#include "dfp.h"
#include "decimal128.h"
#include "decimal128Local.h"
#include "decimal64.h"
#include "decimal32.h"
#include "decNumber.h"
Include dependency graph for dfp.c:

Macros

#define WORDS_BIGENDIAN   0

Functions

static void decimal_from_decnumber ()
void decimal_real_from_string ()
static void decimal_to_decnumber ()
void encode_decimal32 (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
void decode_decimal32 (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
void encode_decimal64 (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
void decode_decimal64 (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
void encode_decimal128 (const struct real_format *fmt, long *buf, const REAL_VALUE_TYPE *r)
void decode_decimal128 (const struct real_format *fmt, REAL_VALUE_TYPE *r, const long *buf)
static void decimal_to_binary (REAL_VALUE_TYPE *to, const REAL_VALUE_TYPE *from, enum machine_mode mode)
static void decimal_from_binary ()
int decimal_do_compare (const REAL_VALUE_TYPE *a, const REAL_VALUE_TYPE *b, int nan_result)
void decimal_round_for_format ()
void decimal_real_convert (REAL_VALUE_TYPE *r, enum machine_mode mode, const REAL_VALUE_TYPE *a)
void decimal_real_to_decimal (char *str, const REAL_VALUE_TYPE *r_orig, size_t buf_size, size_t digits, int crop_trailing_zeros)
static bool decimal_do_add (REAL_VALUE_TYPE *r, const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1, int subtract_p)
static bool decimal_do_multiply (REAL_VALUE_TYPE *r, const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1)
static bool decimal_do_divide (REAL_VALUE_TYPE *r, const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1)
void decimal_do_fix_trunc ()
HOST_WIDE_INT decimal_real_to_integer ()
void decimal_real_to_integer2 (HOST_WIDE_INT *plow, HOST_WIDE_INT *phigh, const REAL_VALUE_TYPE *r)
bool decimal_real_arithmetic (REAL_VALUE_TYPE *r, enum tree_code code, const REAL_VALUE_TYPE *op0, const REAL_VALUE_TYPE *op1)
void decimal_real_maxval ()

Macro Definition Documentation

#define WORDS_BIGENDIAN   0

Decimal floating point support. Copyright (C) 2005-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. The order of the following headers is important for making sure decNumber structure is large enough to hold decimal128 digits.


Function Documentation

static bool decimal_do_add ( REAL_VALUE_TYPE r,
const REAL_VALUE_TYPE op0,
const REAL_VALUE_TYPE op1,
int  subtract_p 
)
static

Return true, if inexact.

References decimal_from_decnumber(), and decimal_to_decnumber().

int decimal_do_compare ( const REAL_VALUE_TYPE a,
const REAL_VALUE_TYPE b,
int  nan_result 
)

Helper function to real.c:do_compare() to handle decimal internal representation including when one of the operands is still in the binary internal representation.

 If either operand is non-decimal, create temporary versions.   
 Convert into decNumber form for comparison operation.   
 Finally, do the comparison.   
 Return the comparison result.   
static bool decimal_do_divide ( REAL_VALUE_TYPE r,
const REAL_VALUE_TYPE op0,
const REAL_VALUE_TYPE op1 
)
static

Compute R = OP0 / OP1.

Return true, if inexact.

void decimal_do_fix_trunc ( )

Set R to A truncated to an integral value toward zero (decimal floating point).

Referenced by do_compare().

static bool decimal_do_multiply ( REAL_VALUE_TYPE r,
const REAL_VALUE_TYPE op0,
const REAL_VALUE_TYPE op1 
)
static

Compute R = OP0 * OP1.

Return true, if inexact.

static void decimal_from_binary ( )
static

Helper function to convert from a binary real internal representation.

We convert to string, then to decNumber then to decimal128.

References REAL_VALUE_TYPE.

Referenced by decimal_real_to_integer2().

static void decimal_from_decnumber ( )
static

Initialize R (a real with the decimal flag set) from DN. Can utilize status passed in via CONTEXT, if a previous operation had interesting status.

Referenced by decimal_do_add().

bool decimal_real_arithmetic ( REAL_VALUE_TYPE r,
enum tree_code  code,
const REAL_VALUE_TYPE op0,
const REAL_VALUE_TYPE op1 
)

Perform the decimal floating point operation described by CODE. For a unary operation, OP1 will be NULL. This function returns true if the result may be inexact due to loss of precision.

 If either operand is non-decimal, create temporaries.   
       Flip sign bit.   
       Keep sign field in sync.   
       Clear sign bit.   
       Keep sign field in sync.   
void decimal_real_convert ( REAL_VALUE_TYPE r,
enum machine_mode  mode,
const REAL_VALUE_TYPE a 
)

Extend or truncate to a new mode. Handles conversions between binary and decimal types.

Referenced by real_nan().

void decimal_real_from_string ( )

Create decimal encoded R from string S.

It would be more efficient to store directly in decNumber format, but that is impractical from current data structure size. Encoding as a decimal128 is much more compact.

Referenced by decimal_to_binary().

void decimal_real_maxval ( )

Fills R with the largest finite value representable in mode MODE. If SIGN is nonzero, R is set to the most negative finite value.

void decimal_real_to_decimal ( char *  str,
const REAL_VALUE_TYPE r_orig,
size_t  buf_size,
size_t  digits,
int  crop_trailing_zeros 
)

Render R_ORIG as a decimal floating point constant. Emit DIGITS significant digits in the result, bounded by BUF_SIZE. If DIGITS is 0, choose the maximum for the representation. If CROP_TRAILING_ZEROS, strip trailing zeros. Currently, not honoring DIGITS or CROP_TRAILING_ZEROS.

decimal128ToString requires space for at least 24 characters; Require two more for suffix.

HOST_WIDE_INT decimal_real_to_integer ( )

Render decimal float value R as an integer.

Convert to REAL_VALUE_TYPE and call appropriate conversion function.

void decimal_real_to_integer2 ( HOST_WIDE_INT plow,
HOST_WIDE_INT phigh,
const REAL_VALUE_TYPE r 
)

Likewise, but to an integer pair, HI+LOW.

Convert to REAL_VALUE_TYPE and call appropriate conversion function.

References decimal_from_binary().

Referenced by real_can_shorten_arithmetic().

void decimal_round_for_format ( )

Helper to round_for_format, handling decimal float types.

Real encoding occurs later.

     The internal format is already in this format.   

Referenced by real_nan().

static void decimal_to_binary ( REAL_VALUE_TYPE to,
const REAL_VALUE_TYPE from,
enum machine_mode  mode 
)
static

Helper function to convert from a binary real internal representation.

References decimal_real_from_string(), and real_to_decimal().

static void decimal_to_decnumber ( )
static

Initialize a decNumber from a REAL_VALUE_TYPE.

    dconst{1,2,m1,half} are used in various places in
    the middle-end and optimizers, allow them here
    as an exception by converting them to decimal.   

Fix up sign bit.

References dconst1, dconst2, dconsthalf, dconstm1, gcc_unreachable, rvc_inf, rvc_nan, rvc_normal, and rvc_zero.

Referenced by decimal_do_add().

void decode_decimal128 ( const struct real_format fmt,
REAL_VALUE_TYPE r,
const long *  buf 
)

Decode an IEEE 754 decimal128 type into a real.

void decode_decimal32 ( const struct real_format fmt,
REAL_VALUE_TYPE r,
const long *  buf 
)

Decode an IEEE 754 decimal32 type into a real.

void decode_decimal64 ( const struct real_format fmt,
REAL_VALUE_TYPE r,
const long *  buf 
)

Decode an IEEE 754 decimal64 type into a real.

void encode_decimal128 ( const struct real_format fmt,
long *  buf,
const REAL_VALUE_TYPE r 
)

Encode a real into an IEEE 754 decimal128 type.

void encode_decimal32 ( const struct real_format fmt,
long *  buf,
const REAL_VALUE_TYPE r 
)

Encode a real into an IEEE 754 decimal32 type.

void encode_decimal64 ( const struct real_format fmt,
long *  buf,
const REAL_VALUE_TYPE r 
)

Encode a real into an IEEE 754 decimal64 type.

Referenced by decode_vax_d().