GCC Middle and Back End API Reference
fixed-value.c File Reference

Enumerations

enum  fixed_value_range_code { FIXED_OK, FIXED_UNDERFLOW, FIXED_GT_MAX_EPS, FIXED_MAX_EPS }

Functions

bool fixed_identical ()
unsigned int fixed_hash ()
static enum fixed_value_range_code check_real_for_fixed_mode ()
FIXED_VALUE_TYPE fixed_from_double_int ()
void fixed_from_string ()
void fixed_to_decimal (char *str, const FIXED_VALUE_TYPE *f_orig, size_t buf_size)
static bool fixed_saturate1 (enum machine_mode mode, double_int a, double_int *f, bool sat_p)
static bool fixed_saturate2 (enum machine_mode mode, double_int a_high, double_int a_low, double_int *f, bool sat_p)
static int get_fixed_sign_bit ()
static bool do_fixed_add (FIXED_VALUE_TYPE *f, const FIXED_VALUE_TYPE *a, const FIXED_VALUE_TYPE *b, bool subtract_p, bool sat_p)
static bool do_fixed_multiply (FIXED_VALUE_TYPE *f, const FIXED_VALUE_TYPE *a, const FIXED_VALUE_TYPE *b, bool sat_p)
static bool do_fixed_divide (FIXED_VALUE_TYPE *f, const FIXED_VALUE_TYPE *a, const FIXED_VALUE_TYPE *b, bool sat_p)
static bool do_fixed_shift (FIXED_VALUE_TYPE *f, const FIXED_VALUE_TYPE *a, const FIXED_VALUE_TYPE *b, bool left_p, bool sat_p)
static bool do_fixed_neg ()
bool fixed_arithmetic (FIXED_VALUE_TYPE *f, int icode, const FIXED_VALUE_TYPE *op0, const FIXED_VALUE_TYPE *op1, bool sat_p)
bool fixed_compare (int icode, const FIXED_VALUE_TYPE *op0, const FIXED_VALUE_TYPE *op1)
bool fixed_convert (FIXED_VALUE_TYPE *f, enum machine_mode mode, const FIXED_VALUE_TYPE *a, bool sat_p)
bool fixed_convert_from_int (FIXED_VALUE_TYPE *f, enum machine_mode mode, double_int a, bool unsigned_p, bool sat_p)
bool fixed_convert_from_real (FIXED_VALUE_TYPE *f, enum machine_mode mode, const REAL_VALUE_TYPE *a, bool sat_p)
void real_convert_from_fixed (REAL_VALUE_TYPE *r, enum machine_mode mode, const FIXED_VALUE_TYPE *f)
bool fixed_isneg ()

Enumeration Type Documentation

Define the enum code for the range of the fixed-point value.   
Enumerator:
FIXED_OK 
FIXED_UNDERFLOW 
FIXED_GT_MAX_EPS 
FIXED_MAX_EPS 

Function Documentation

static enum fixed_value_range_code check_real_for_fixed_mode ( )
static
Check REAL_VALUE against the range of the fixed-point mode.
   Return FIXED_OK, if it is within the range.
          FIXED_UNDERFLOW, if it is less than the minimum.
          FIXED_GT_MAX_EPS, if it is greater than the maximum, but not equal to
            the maximum plus the epsilon.
          FIXED_MAX_EPS, if it is equal to the maximum plus the epsilon.   

References FIXED_GT_MAX_EPS, FIXED_MAX_EPS, FIXED_OK, FIXED_UNDERFLOW, real_2expN(), real_arithmetic(), real_compare(), real_from_string(), and real_value_negate().

Referenced by fixed_convert_from_real(), and fixed_from_string().

static bool do_fixed_add ( FIXED_VALUE_TYPE f,
const FIXED_VALUE_TYPE a,
const FIXED_VALUE_TYPE b,
bool  subtract_p,
bool  sat_p 
)
static
Calculate F = A + (SUBTRACT_P ? -B : B).
   If SAT_P, saturate the result to the max or the min.
   Return true, if !SAT_P and overflow.   

References get_fixed_sign_bit(), and double_int::high.

Referenced by fixed_arithmetic().

static bool do_fixed_divide ( FIXED_VALUE_TYPE f,
const FIXED_VALUE_TYPE a,
const FIXED_VALUE_TYPE b,
bool  sat_p 
)
static
Calculate F = A / B.
   If SAT_P, saturate the result to the max or the min.
   Return true, if !SAT_P and overflow.   

References double_int::divmod(), fixed_saturate1(), fixed_saturate2(), double_int::high, HOST_BITS_PER_WIDE_INT, double_int::llshift(), double_int::low, double_int::lshift(), and double_int::ucmp().

Referenced by fixed_arithmetic().

static bool do_fixed_multiply ( FIXED_VALUE_TYPE f,
const FIXED_VALUE_TYPE a,
const FIXED_VALUE_TYPE b,
bool  sat_p 
)
static
Calculate F = A * B.
   If SAT_P, saturate the result to the max or the min.
   Return true, if !SAT_P and overflow.   

References fixed_saturate1(), fixed_saturate2(), double_int::high, HOST_BITS_PER_WIDE_INT, double_int::llshift(), double_int::low, double_int::lshift(), and double_int::ult().

Referenced by fixed_arithmetic().

static bool do_fixed_neg ( )
static
Calculate F = -A.
   If SAT_P, saturate the result to the max or the min.
   Return true, if !SAT_P and overflow.   

Referenced by fixed_arithmetic().

static bool do_fixed_shift ( FIXED_VALUE_TYPE f,
const FIXED_VALUE_TYPE a,
const FIXED_VALUE_TYPE b,
bool  left_p,
bool  sat_p 
)
static
Calculate F = A << B if LEFT_P.  Otherwise, F = A >> B.
   If SAT_P, saturate the result to the max or the min.
   Return true, if !SAT_P and overflow.   

References double_int::ext(), fixed_saturate1(), fixed_saturate2(), double_int::high, HOST_BITS_PER_WIDE_INT, double_int::llshift(), double_int::low, and double_int::lshift().

Referenced by fixed_arithmetic().

bool fixed_arithmetic ( FIXED_VALUE_TYPE f,
int  icode,
const FIXED_VALUE_TYPE op0,
const FIXED_VALUE_TYPE op1,
bool  sat_p 
)
Perform the binary or unary operation described by CODE.
   Note that OP0 and OP1 must have the same mode for binary operators.
   For a unary operation, leave OP1 NULL.
   Return true, if !SAT_P and overflow.   

References do_fixed_add(), do_fixed_divide(), do_fixed_multiply(), do_fixed_neg(), and do_fixed_shift().

Referenced by const_binop(), and fold_negate_const().

bool fixed_compare ( int  icode,
const FIXED_VALUE_TYPE op0,
const FIXED_VALUE_TYPE op1 
)
Compare fixed-point values by tree_code.
   Note that OP0 and OP1 must have the same mode.   

Referenced by fold_relational_const().

bool fixed_convert ( FIXED_VALUE_TYPE f,
enum machine_mode  mode,
const FIXED_VALUE_TYPE a,
bool  sat_p 
)
Extend or truncate to a new mode.
   If SAT_P, saturate the result to the max or the min.
   Return true, if !SAT_P and overflow.   

References fixed_saturate1(), fixed_saturate2(), double_int::high, double_int::llshift(), double_int::lshift(), and double_int::sext().

Referenced by fold_convert_const_fixed_from_fixed().

bool fixed_convert_from_int ( FIXED_VALUE_TYPE f,
enum machine_mode  mode,
double_int  a,
bool  unsigned_p,
bool  sat_p 
)
Convert to a new fixed-point mode from an integer.
   If UNSIGNED_P, this integer is unsigned.
   If SAT_P, saturate the result to the max or the min.
   Return true, if !SAT_P and overflow.   

References fixed_saturate2(), double_int::high, double_int::llshift(), double_int::low, and double_int::sext().

Referenced by fold_convert_const_fixed_from_int().

bool fixed_convert_from_real ( FIXED_VALUE_TYPE f,
enum machine_mode  mode,
const REAL_VALUE_TYPE *  a,
bool  sat_p 
)
Convert to a new fixed-point mode from a real.
   If SAT_P, saturate the result to the max or the min.
   Return true, if !SAT_P and overflow.   

References check_real_for_fixed_mode(), FIXED_GT_MAX_EPS, FIXED_MAX_EPS, FIXED_UNDERFLOW, HOST_WIDE_INT, real_2expN(), real_arithmetic(), and real_to_integer2().

Referenced by fold_convert_const_fixed_from_real().

FIXED_VALUE_TYPE fixed_from_double_int ( )
Construct a CONST_FIXED from a bit payload and machine mode MODE.
   The bits in PAYLOAD are sign-extended/zero-extended according to MODE.   

References FIXED_VALUE_TYPE, double_int::sext(), and double_int::zext().

Referenced by build_minus_one_cst(), const_fixed_from_double_int(), and native_interpret_fixed().

unsigned int fixed_hash ( )
bool fixed_identical ( )
@verbatim Fixed-point arithmetic support.

Copyright (C) 2006-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/.

Compare two fixed objects for bitwise identity.   

Referenced by const_fixed_htab_eq().

bool fixed_isneg ( )
Determine whether a fixed-point value F is negative.   

References get_fixed_sign_bit().

static bool fixed_saturate1 ( enum machine_mode  mode,
double_int  a,
double_int f,
bool  sat_p 
)
static
If SAT_P, saturate A to the maximum or the minimum, and save to *F based on
   the machine mode MODE.
   Do not modify *F otherwise.
   This function assumes the width of double_int is greater than the width
   of the fixed-point value (the sum of a possible sign bit, possible ibits,
   and fbits).
   Return true, if !SAT_P and overflow.   

References double_int::alshift(), double_int::high, double_int::low, double_int::sext(), double_int::sgt(), double_int::slt(), double_int::ugt(), and double_int::zext().

Referenced by do_fixed_divide(), do_fixed_multiply(), do_fixed_shift(), and fixed_convert().

static bool fixed_saturate2 ( enum machine_mode  mode,
double_int  a_high,
double_int  a_low,
double_int f,
bool  sat_p 
)
static
If SAT_P, saturate {A_HIGH, A_LOW} to the maximum or the minimum, and
   save to *F based on the machine mode MODE.
   Do not modify *F otherwise.
   This function assumes the width of two double_int is greater than the width
   of the fixed-point value (the sum of a possible sign bit, possible ibits,
   and fbits).
   Return true, if !SAT_P and overflow.   

References double_int::alshift(), double_int::high, double_int::low, double_int::sext(), double_int::sgt(), double_int::slt(), double_int::ugt(), double_int::ult(), and double_int::zext().

Referenced by do_fixed_divide(), do_fixed_multiply(), do_fixed_shift(), fixed_convert(), and fixed_convert_from_int().

void fixed_to_decimal ( char *  str,
const FIXED_VALUE_TYPE f_orig,
size_t  buf_size 
)
Render F as a decimal floating point constant.   

References real_2expN(), real_arithmetic(), real_from_integer(), and real_to_decimal().

Referenced by dump_fixed(), dump_generic_node(), print_node(), print_node_brief(), and print_value().

static int get_fixed_sign_bit ( )
inlinestatic
Return the sign bit based on I_F_BITS.   

References double_int::high, HOST_BITS_PER_WIDE_INT, and double_int::low.

Referenced by do_fixed_add(), and fixed_isneg().

void real_convert_from_fixed ( REAL_VALUE_TYPE *  r,
enum machine_mode  mode,
const FIXED_VALUE_TYPE f 
)
Convert to a new real mode from a fixed-point.   

References real_2expN(), real_arithmetic(), real_convert(), and real_from_integer().

Referenced by fold_convert_const_real_from_fixed().