GCC Middle and Back End API Reference
sreal.c File Reference

Functions

static void copy (sreal *, sreal *)
static void shift_right (sreal *, int)
static void normalize (sreal *)
void dump_sreal ()
DEBUG_FUNCTION void debug ()
static void copy ()
static void shift_right ()
static void normalize ()
srealsreal_init ()
HOST_WIDE_INT sreal_to_int ()
int sreal_compare ()
srealsreal_add ()
srealsreal_sub ()
srealsreal_mul ()
srealsreal_div ()

Function Documentation

static void copy ( sreal ,
sreal  
)
inlinestatic
@verbatim 

Simple data type for positive real numbers for the GNU compiler. Copyright (C) 2002-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/.

   This library supports positive real numbers and 0;
   inf and nan are NOT supported.
   It is written to be simple and fast.

   Value of sreal is
        x = sig * 2 ^ exp
   where
        sig = significant
          (for < 64-bit machines sig = sig_lo + sig_hi * 2 ^ SREAL_PART_BITS)
        exp = exponent

   One HOST_WIDE_INT is used for the significant on 64-bit (and more than
   64-bit) machines,
   otherwise two HOST_WIDE_INTs are used for the significant.
   Only a half of significant bits is used (in normalized sreals) so that we do
   not have problems with overflow, for example when c->sig = a->sig * b->sig.
   So the precision for 64-bit and 32-bit machines is 32-bit.

   Invariant: The numbers are normalized before and after each call of sreal_*.

   Normalized sreals:
   All numbers (except zero) meet following conditions:
         SREAL_MIN_SIG <= sig && sig <= SREAL_MAX_SIG
        -SREAL_MAX_EXP <= exp && exp <= SREAL_MAX_EXP

   If the number would be too large, it is set to upper bounds of these
   conditions.

   If the number is zero or would be too small it meets following conditions:
        sig == 0 && exp == -SREAL_MAX_EXP

Referenced by canonicalize_component_ref(), diddle_return_value(), emit_clobber(), gen_internal_sym(), gimple_redirect_edge_and_branch(), initialize_argument_information(), insn_decl_eq_p(), is_class_die(), move_all_children(), vnull::operator vec< T, A, L >(), shared_const_p(), sreal_sub(), and subscript_dependence_tester_1().

static void copy ( )
inlinestatic
   Copy the sreal number.  
DEBUG_FUNCTION void debug ( )
void dump_sreal ( )
   Print the content of struct sreal.  
static void normalize ( sreal )
static
static void normalize ( )
static
   Normalize *X.  
             Move lower part of significant to higher part.  
         Check underflow.  
         Find out how many bits will be shifted.  
         Round the number.  
                 x->sig_hi was SREAL_MAX_SIG before increment
                 so now last bit is zero.  
         Check overflow.  
         Check underflow.  
         Round the number.  
         Check overflow.  

References sreal::exp.

static void shift_right ( sreal ,
int   
)
inlinestatic

Referenced by sreal_sub().

static void shift_right ( )
inlinestatic
   Shift X right by S bits.  Needed: 0 < S <= SREAL_BITS.
   When the most significant bit shifted out is 1, add 1 to X (rounding).  
     Exponent should never be so large because shift_right is used only by
     sreal_add and sreal_sub ant thus the number cannot be shifted out from
     exponent range.  
sreal* sreal_add ( )
   *R = *A + *B.  Return R.  
int sreal_compare ( )
   Compare *A and *B. Return -1 if *A < *B, 1 if *A > *B and 0 if *A == *B.  
sreal* sreal_div ( )
   *R = *A / *B.  Return R.  
         Since division by the whole number is pretty ugly to write
         we are dividing by first 3/4 of bits of number.  

Referenced by edge_badness().

sreal* sreal_init ( )
   Set *R to SIG * 2 ^ EXP.  Return R.  

References sreal::exp, sreal::sig, sreal::sig_hi, and sreal::sig_lo.

Referenced by edge_badness().

sreal* sreal_mul ( )
   *R = *A * *B.  Return R.  

Referenced by edge_badness().

sreal* sreal_sub ( )
   *R = *A - *B.  Return R.  

References copy(), and shift_right().

HOST_WIDE_INT sreal_to_int ( )
   Return integer value of *R.  

Referenced by edge_badness().