libFirm
|
Tarvals only represent values of mode_sort: More...
Typedefs | |
typedef struct ir_tarval | ir_tarval |
Target Machine Value. More... | |
Functions | |
ir_tarval * | new_tarval_from_str (const char *str, size_t len, ir_mode *mode) |
Constructor function for new tarvals. More... | |
ir_tarval * | new_integer_tarval_from_str (const char *str, size_t len, int negative, unsigned char base, ir_mode *mode) |
Construct a new tarval from a given string. More... | |
ir_tarval * | new_tarval_from_long (long l, ir_mode *mode) |
Constructor function for new tarvals. More... | |
ir_tarval * | new_tarval_from_bytes (unsigned char const *buf, ir_mode *mode) |
Construct a new tarval from a sequence of bytes. More... | |
ir_tarval * | new_tarval_nan (ir_mode *mode, int signaling, ir_tarval const *payload) |
Construct a new floating point quiet NaN value. More... | |
void | tarval_to_bytes (unsigned char *buffer, ir_tarval const *tv) |
Write tarval to a sequence of bytes. More... | |
long | get_tarval_long (ir_tarval const *tv) |
Returns value as long if possible. More... | |
int | tarval_is_long (ir_tarval const *tv) |
This validates if get_tarval_long() will return something sensible. More... | |
ir_tarval * | new_tarval_from_double (double d, ir_mode *mode) |
Constructor function for new tarvals. More... | |
ir_tarval * | new_tarval_from_long_double (long double d, ir_mode *mode) |
same as new_tarval_from_double(), but with a long double argument More... | |
double | get_tarval_double (ir_tarval const *tv) |
This returns a double with the value represented value, or gibberish, depending on the size of double and the size of the stored value. More... | |
long double | get_tarval_long_double (ir_tarval const *tv) |
same as get_tarval_double but returns a long double value More... | |
int | tarval_is_double (ir_tarval const *tv) |
This validates if tarval_to_double() will return a satisfying result. More... | |
ir_mode * | get_tarval_mode (ir_tarval const *tv) |
Returns the mode of the tarval. More... | |
int | tarval_is_negative (ir_tarval const *tv) |
Returns 1 if tv is negative. More... | |
int | tarval_is_null (ir_tarval const *tv) |
Returns 1 if tv is null. More... | |
int | tarval_is_one (ir_tarval const *tv) |
Returns 1 if tv is the "one". More... | |
int | tarval_is_all_one (ir_tarval const *tv) |
returns non-zero if all bits in the tarval are set. More... | |
int | tarval_is_constant (ir_tarval const *tv) |
Returns non-zero if the tarval is a constant (i.e. More... | |
ir_tarval * | get_tarval_bad (void) |
Returns the 'bad' tarval. More... | |
ir_tarval * | get_tarval_unknown (void) |
Returns the 'unknown' tarval. More... | |
ir_tarval * | get_tarval_b_false (void) |
Returns the mode_b tarval 'false'. More... | |
ir_tarval * | get_tarval_b_true (void) |
Returns the mode_b tarval 'true'. More... | |
void | tarval_set_wrap_on_overflow (int wrap_on_overflow) |
Sets whether values should wrap on overflow or return the bad value. More... | |
int | tarval_get_wrap_on_overflow (void) |
Returns 0 if operations return bad on overflow, != 0 if they wrap around. More... | |
ir_relation | tarval_cmp (ir_tarval const *a, ir_tarval const *b) |
Compares two tarvals. More... | |
ir_tarval * | tarval_convert_to (ir_tarval const *src, ir_mode *mode) |
Converts a tarval to another mode. More... | |
ir_tarval * | tarval_bitcast (ir_tarval const *src, ir_mode *mode) |
Converts a tarval to another mode by reinterpreting the contained bits. More... | |
ir_tarval * | tarval_not (ir_tarval const *a) |
Bitwise Negation of a tarval. More... | |
ir_tarval * | tarval_neg (ir_tarval const *a) |
Arithmetic Negation of a tarval. More... | |
ir_tarval * | tarval_add (ir_tarval const *a, ir_tarval const *b) |
Addition of two tarvals. More... | |
ir_tarval * | tarval_sub (ir_tarval const *a, ir_tarval const *b) |
Subtraction from a tarval. More... | |
ir_tarval * | tarval_mul (ir_tarval const *a, ir_tarval const *b) |
Multiplication of tarvals. More... | |
ir_tarval * | tarval_div (ir_tarval const *a, ir_tarval const *b) |
Integer division of two tarvals. More... | |
ir_tarval * | tarval_mod (ir_tarval const *a, ir_tarval const *b) |
Remainder of integer division. More... | |
ir_tarval * | tarval_divmod (ir_tarval const *a, ir_tarval const *b, ir_tarval **mod_res) |
Integer division AND remainder. More... | |
ir_tarval * | tarval_abs (ir_tarval const *a) |
Absolute value of a tarval. More... | |
ir_tarval * | tarval_and (ir_tarval const *a, ir_tarval const *b) |
Bitwise and of two integer tarvals. More... | |
ir_tarval * | tarval_andnot (ir_tarval const *a, ir_tarval const *b) |
Bitwise and not of two integer tarvals. More... | |
ir_tarval * | tarval_or (ir_tarval const *a, ir_tarval const *b) |
Bitwise or of two integer tarvals. More... | |
ir_tarval * | tarval_ornot (ir_tarval const *a, ir_tarval const *b) |
Bitwise or not of two integer tarvals. More... | |
ir_tarval * | tarval_eor (ir_tarval const *a, ir_tarval const *b) |
Bitwise exclusive or of two integer tarvals. More... | |
ir_tarval * | tarval_shl (ir_tarval const *a, ir_tarval const *b) |
Logical Left shift. More... | |
ir_tarval * | tarval_shl_unsigned (ir_tarval const *a, unsigned b) |
logical left shift (variant with unsigned argument). More... | |
ir_tarval * | tarval_shr (ir_tarval const *a, ir_tarval const *b) |
Unsigned (logical) right shift. More... | |
ir_tarval * | tarval_shr_unsigned (ir_tarval const *a, unsigned b) |
unsigned (logical) right shift (variant with unsigned argument). More... | |
ir_tarval * | tarval_shrs (ir_tarval const *a, ir_tarval const *b) |
Signed (arithmetic) right shift. More... | |
ir_tarval * | tarval_shrs_unsigned (ir_tarval const *a, unsigned b) |
signed (arithmetic) right shift (variant with unsigned argument). More... | |
unsigned char | get_tarval_sub_bits (ir_tarval const *tv, unsigned byte_ofs) |
Returns the bitpattern of the bytes_ofs byte. More... | |
int | get_tarval_popcount (ir_tarval const *tv) |
Returns the number of set bits in a given (integer) tarval. More... | |
int | get_tarval_lowest_bit (ir_tarval const *tv) |
Returns the number of the lowest set bit in a given (integer) tarval. More... | |
int | get_tarval_highest_bit (ir_tarval const *tv) |
Return the number of the highest set bit in a given (integer) tarval. More... | |
int | tarval_zero_mantissa (ir_tarval const *tv) |
Returns non-zero if the mantissa of a floating point tarval is zero (i.e. More... | |
int | tarval_get_exponent (ir_tarval const *tv) |
Returns the exponent of a floating point IEEE-754 tarval. More... | |
int | tarval_ieee754_can_conv_lossless (ir_tarval const *tv, const ir_mode *mode) |
Check if the tarval can be converted to the given mode without precision loss. More... | |
unsigned | tarval_ieee754_get_exact (void) |
Returns non-zero if the result of the last IEEE-754 operation was exact. More... | |
int | tarval_is_nan (ir_tarval const *tv) |
Check if tv is a floating point NaN. More... | |
int | tarval_is_quiet_nan (ir_tarval const *tv) |
Check if tv is a floating point quiet NaN. More... | |
int | tarval_is_signaling_nan (ir_tarval const *tv) |
Check if tv is a floating point signaling NaN. More... | |
int | tarval_is_finite (ir_tarval const *tv) |
Check if the tarval represents a finite value, ie neither NaN nor inf. More... | |
Variables | |
ir_tarval *const | tarval_bad |
The 'bad' tarval. More... | |
ir_tarval *const | tarval_unknown |
The 'unknown' tarval. More... | |
ir_tarval * | tarval_b_false |
The mode_b tarval 'false'. More... | |
ir_tarval * | tarval_b_true |
The mode_b tarval 'true'. More... | |
Tarvals only represent values of mode_sort:
In case of references the module accepts an entity to represent the value. Furthermore, computations and conversions of these values can be performed.
Target Machine Value.
Definition at line 68 of file firm_types.h.
ir_tarval* get_tarval_b_false | ( | void | ) |
Returns the mode_b tarval 'false'.
ir_tarval* get_tarval_b_true | ( | void | ) |
Returns the mode_b tarval 'true'.
ir_tarval* get_tarval_bad | ( | void | ) |
Returns the 'bad' tarval.
double get_tarval_double | ( | ir_tarval const * | tv | ) |
This returns a double with the value represented value, or gibberish, depending on the size of double and the size of the stored value.
This will overflow silently, so use only if you know what you are doing! (better check with tarval_is_long...)
tv | the tarval |
int get_tarval_highest_bit | ( | ir_tarval const * | tv | ) |
Return the number of the highest set bit in a given (integer) tarval.
tv | the tarval |
long get_tarval_long | ( | ir_tarval const * | tv | ) |
Returns value as long if possible.
long double get_tarval_long_double | ( | ir_tarval const * | tv | ) |
same as get_tarval_double but returns a long double value
int get_tarval_lowest_bit | ( | ir_tarval const * | tv | ) |
Returns the number of the lowest set bit in a given (integer) tarval.
tv | the tarval |
int get_tarval_popcount | ( | ir_tarval const * | tv | ) |
Returns the number of set bits in a given (integer) tarval.
tv | the tarval |
unsigned char get_tarval_sub_bits | ( | ir_tarval const * | tv, |
unsigned | byte_ofs | ||
) |
Returns the bitpattern of the bytes_ofs byte.
This function succeeds even if the mode of the tarval uses fewer bits than requested, in that case the bitpattern is filled with zero bits.
To query a 32bit value the following code can be used:
val0 = tarval_sub_bits(tv, 0); <- lowest bits val1 = tarval_sub_bits(tv, 1); val2 = tarval_sub_bits(tv, 2); val3 = tarval_sub_bits(tv, 3); <- highest bits
Because this is the bit representation of the target machine, only the following operations are legal on the result:
tv | the tarval |
byte_ofs | the byte offset from lower to higher |
ir_tarval* get_tarval_unknown | ( | void | ) |
Returns the 'unknown' tarval.
ir_tarval* new_integer_tarval_from_str | ( | const char * | str, |
size_t | len, | ||
int | negative, | ||
unsigned char | base, | ||
ir_mode * | mode | ||
) |
Construct a new tarval from a given string.
str | The string representing the target value |
len | The length of the string |
negative | != 0 if number should be negative |
base | number system base. binary(2), octal(8), decimal(10) and hexadecimal(16) numbers are supported. |
mode | The mode requested for the result tarval |
Construct a new tarval from a sequence of bytes.
The bytes are interpreted in a "little endian" fashion which means less significant bytes come first.
buf | pointer to a buffer holding at least get_ir_mode_size_bytes(mode) bytes. |
mode | mode for the resulting tarval |
Constructor function for new tarvals.
d | The (long) double representing the value |
mode | The mode requested for the result tarval |
This function creates a new tarval representing the value represented by a (long) double. If a tarval representing this value already exists, this tarval is returned instead of a new one. So tarvals are directly comparable since their representation is unique. Only modes of sort float_number can be constructed this way.
Constructor function for new tarvals.
l | The long representing the value |
mode | The mode requested for the result tarval must be a twos_complement mode. |
This function creates a new tarval representing the value represented by a long integer. If a tarval representing this value already exists, this tarval is returned instead of a new one. So tarvals are directly comparable since their representation is unique.
same as new_tarval_from_double(), but with a long double argument
Constructor function for new tarvals.
str | The string representing the target value |
len | The length of the string |
mode | The mode requested for the result tarval |
This function creates a new tarval representing the value represented by a CString, aka char array. If a tarval representing this value already exists, this tarval is returned instead of a new one. So tarvals are directly comparable since their representation is unique.
This function accepts the following strings:
if mode is int_number:
if mode is float_number:
if mode is boolean: true, True, TRUE ... False... 0, 1,
if mode is reference: "null" and the same as for int_number
Leading and/or trailing spaces are ignored
str
is malformed. Debug builds should fail assertions in these cases.Construct a new floating point quiet NaN value.
mode | floating point mode for the resulting value |
signaling | if != 0 produces a signaling NaN else a quiet one. |
payload | if != NULL puts the integer tarval into the mantissa. |
Absolute value of a tarval.
a | the first tarval |
Addition of two tarvals.
a | the first tarval |
b | the second tarval |
Bitwise and of two integer tarvals.
a | the first tarval |
b | the second tarval |
Bitwise and not of two integer tarvals.
a | the first tarval |
b | the second tarval |
Converts a tarval to another mode by reinterpreting the contained bits.
This is only allowed if the source and destination mode have the same number of bits.
ir_relation tarval_cmp | ( | ir_tarval const * | a, |
ir_tarval const * | b | ||
) |
Compares two tarvals.
Compare a with b and return their relation. This is either ir_rel_unordered, ir_rel_less, ir_rel_greater, ir_rel_equal or ir_rel_false if a or b are symbolic pointers which can not be compared at all.
a | the first tarval to be compared |
b | the second tarval to be compared |
Converts a tarval to another mode.
Convert tarval 'src' to mode 'mode', this will succeed if and only if mode 'mode' is wider than the mode of src, as defined in the firm documentation and as returned by the function mode_is_smaller defined in irmode.h.
src | The tarval to convert |
mode | Tho mode to convert to |
Integer division of two tarvals.
a | the first tarval |
b | the second tarval |
Integer division AND remainder.
a | the first tarval |
b | the second tarval |
mod_res | after return, contains the remainder result, a % b or tarval_bad |
Bitwise exclusive or of two integer tarvals.
a | the first tarval |
b | the second tarval |
int tarval_get_exponent | ( | ir_tarval const * | tv | ) |
Returns the exponent of a floating point IEEE-754 tarval.
tv | the tarval |
int tarval_get_wrap_on_overflow | ( | void | ) |
Returns 0 if operations return bad on overflow, != 0 if they wrap around.
Check if the tarval can be converted to the given mode without precision loss.
tv | the tarval |
mode | the mode to convert to |
unsigned tarval_ieee754_get_exact | ( | void | ) |
Returns non-zero if the result of the last IEEE-754 operation was exact.
int tarval_is_all_one | ( | ir_tarval const * | tv | ) |
returns non-zero if all bits in the tarval are set.
This means the value is -1 for signed modes with irma_twos_complement.
int tarval_is_constant | ( | ir_tarval const * | tv | ) |
Returns non-zero if the tarval is a constant (i.e.
NOT a reserved tarval like bad, undef, reachable etc.)
int tarval_is_double | ( | ir_tarval const * | tv | ) |
This validates if tarval_to_double() will return a satisfying result.
I.e. if tv is an float_number and between min, max of double
tv | the tarval |
int tarval_is_finite | ( | ir_tarval const * | tv | ) |
Check if the tarval represents a finite value, ie neither NaN nor inf.
tv | the tarval |
int tarval_is_long | ( | ir_tarval const * | tv | ) |
This validates if get_tarval_long() will return something sensible.
This is the case if the value is a two_complement (integer/reference) mode and converting it to a mode equivalent to "long" would not result in information loss. So ULONGMAX in an unsigned mode is fine, ULONG_MAX in a signed mode not.
tv | the tarval |
int tarval_is_nan | ( | ir_tarval const * | tv | ) |
Check if tv
is a floating point NaN.
tv | the tarval |
int tarval_is_negative | ( | ir_tarval const * | tv | ) |
Returns 1 if tv is negative.
tv | the tarval |
int tarval_is_null | ( | ir_tarval const * | tv | ) |
Returns 1 if tv is null.
tv | the tarval |
int tarval_is_one | ( | ir_tarval const * | tv | ) |
Returns 1 if tv is the "one".
tv | the tarval |
int tarval_is_quiet_nan | ( | ir_tarval const * | tv | ) |
Check if tv
is a floating point quiet NaN.
tv | the tarval |
int tarval_is_signaling_nan | ( | ir_tarval const * | tv | ) |
Check if tv
is a floating point signaling NaN.
tv | the tarval |
Remainder of integer division.
a | the first tarval |
b | the second tarval |
Multiplication of tarvals.
a | the first tarval |
b | the second tarval |
Arithmetic Negation of a tarval.
a | the first tarval |
Bitwise Negation of a tarval.
a | the first tarval |
Bitwise or of two integer tarvals.
a | the first tarval |
b | the second tarval |
Bitwise or not of two integer tarvals.
a | the first tarval |
b | the second tarval |
void tarval_set_wrap_on_overflow | ( | int | wrap_on_overflow | ) |
Sets whether values should wrap on overflow or return the bad value.
Logical Left shift.
a | the first tarval |
b | the second tarval |
logical left shift (variant with unsigned argument).
Unsigned (logical) right shift.
a | the first tarval |
b | the second tarval |
unsigned (logical) right shift (variant with unsigned argument).
Signed (arithmetic) right shift.
a | the first tarval |
b | the second tarval |
signed (arithmetic) right shift (variant with unsigned argument).
Subtraction from a tarval.
a | the first tarval |
b | the second tarval |
void tarval_to_bytes | ( | unsigned char * | buffer, |
ir_tarval const * | tv | ||
) |
Write tarval to a sequence of bytes.
The value is written in a "little endian" fashion which means the less significant bytes come first.
int tarval_zero_mantissa | ( | ir_tarval const * | tv | ) |
Returns non-zero if the mantissa of a floating point tarval is zero (i.e.
1.0Exxx)
tv | the tarval |
ir_tarval* const tarval_bad |