coan 4.2.4
|
![]() |
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) |
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.
direction | String specifying the direction of shift: "left" or "right". |
type | The int_type of the lefthand op[erand. |
shiftval | The 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().
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
l | Pointer to an int_spec_t representing the unconverted left-hand operand. |
r | Pointer to an int_spec_t representing the unconverted right-hand operand. |
cl | Pointer to an int_spec_t representing the converted left-hand operand on return. |
cr | Pointer 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().
static int sign | ( | int_spec_t const * | int_spec | ) | [static] |
Return the sign of the value represented by an int_spec_t object
int_spec | The int_spec_t from which the sign is required. |
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
converted | Pointer to an int_spec_t having the correct converted type and the pre-sign-extended value. |
unconverted | Pointer 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().