coan 4.2.4
The Integer Operations component internals.
Collaboration diagram for The Integer Operations component internals.:

Files

file  integer_ops.c

Functions

static int sign (int_spec_t const *int_spec)
static void sign_extend (int_spec_t *converted, int_spec_t const *unconverted)
static void do_usual_conversions (int_spec_t const *l, int_spec_t const *r, int_spec_t *cl, int_spec_t *cr)
static bool check_shift_validity (char const *direction, int_type type, int_spec_t const *shiftval)

Function Documentation

static bool check_shift_validity ( char const *  direction,
int_type  type,
int_spec_t const *  shiftval 
) [static]

Check the validity of a shift operation. The operation has undefined behaviour if the promoted righthand operand is negative or is >= the width in bits of the lefthand operand.

Parameters:
directionString specifying the direction of shift: "left" or "right".
typeThe int_type of the lefthand op[erand.
shiftvalThe integer value of the righthand operand.

Definition at line 227 of file integer_ops.c.

References GRIPE_NEGATIVE_SHIFT, GRIPE_SHIFT_OVERFLOW, IS_SIGNED, report(), SIZEOF, int_spec::type, and int_spec::val.

Referenced by lshift(), and rshift().

Here is the call graph for this function:

static void do_usual_conversions ( int_spec_t const *  l,
int_spec_t const *  r,
int_spec_t cl,
int_spec_t cr 
) [static]

Apply the Usual Arithmetic Conversions to a pair of int_spec_t objects to determine the result type of a binary integer operations with these objects as operands. See standard ISO/IEC 9899:1999 6.3.1.8

Parameters:
lPointer to an int_spec_t representing the unconverted left-hand operand.
rPointer to an int_spec_t representing the unconverted right-hand operand.
clPointer to an int_spec_t representing the converted left-hand operand on return.
crPointer to an int_spec_t representing the converted right-hand operand on return.

Sign extension is performed on the converted operands if required.

Definition at line 141 of file integer_ops.c.

References format_int(), GRIPE_SIGN_CHANGED, IS_SIGNED, MAKE_UNSIGNED, RANK, report(), sign(), sign_extend(), SIZEOF, and int_spec::type.

Referenced by add(), bit_and(), bit_or(), bit_xor(), divide(), le(), lt(), modulus(), multiply(), and subtract().

Here is the call graph for this function:

static int sign ( int_spec_t const *  int_spec) [static]

Return the sign of the value represented by an int_spec_t object

Parameters:
int_specThe int_spec_t from which the sign is required.
Returns:
-1 if the value is of signed integral type and is negative, 1 if the value is of signed integral type and is non-negative; otherwise 0.

Definition at line 58 of file integer_ops.c.

References INT_INT, INT_LLONG, INT_LONG, INT_UINT, INT_ULLONG, INT_ULONG, int_spec::type, and int_spec::val.

Referenced by do_usual_conversions(), and sign_extend().

static void sign_extend ( int_spec_t converted,
int_spec_t const *  unconverted 
) [static]

Apply sign extension to a type-converted int_spec_t

Parameters:
convertedPointer to an int_spec_t having the correct converted type and the pre-sign-extended value.
unconvertedPointer to an int_spec_t having the uncoverted value and type.

If unconverted does not represent a signed type with integer conversion rank > than that of converted and with a negative value then nothing is done to converted. Otherwise the uncoverted value from uncoverted is assigned to the field in converted corresponding to the converted type, thus accomplishing sign-extension if required.

Definition at line 93 of file integer_ops.c.

References INT_INT, INT_LLONG, INT_LONG, INT_ULLONG, INT_ULONG, IS_SIGNED, RANK, sign(), int_spec::type, and int_spec::val.

Referenced by do_usual_conversions().

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines