libFirm 1.20
|
Tarvals only represent values of mode_sort: More...
Data Structures | |
struct | tarval_mode_info |
This structure contains helper information to format the output of a tarval of a mode. More... | |
Defines | |
#define | tarval_top tarval_undefined |
The 'top' tarval. | |
#define | get_tarval_top() get_tarval_undefined() |
Returns the 'top' tarval. | |
#define | tarval_bottom tarval_bad |
The 'bottom' tarval. | |
#define | get_tarval_bottom() get_tarval_bad() |
Returns the 'bottom' tarval. | |
Typedefs | |
typedef struct ir_tarval | ir_tarval |
Target Machine Value. | |
Enumerations | |
enum | tarval_int_overflow_mode_t { TV_OVERFLOW_BAD, TV_OVERFLOW_WRAP, TV_OVERFLOW_SATURATE } |
Modes for handling integer overflows. More... | |
enum | tv_output_mode { TVO_NATIVE, TVO_HEX, TVO_DECIMAL, TVO_OCTAL, TVO_BINARY, TVO_FLOAT, TVO_HEXFLOAT } |
The output mode for tarval values. More... | |
Functions | |
ir_tarval * | new_tarval_from_str (const char *str, size_t len, ir_mode *mode) |
Constructor function for new tarvals. | |
ir_tarval * | new_integer_tarval_from_str (const char *str, size_t len, char sign, unsigned char base, ir_mode *mode) |
Construct a new tarval from a given string. | |
ir_tarval * | new_tarval_from_long (long l, ir_mode *mode) |
Constructor function for new tarvals. | |
long | get_tarval_long (ir_tarval *tv) |
Returns value as long if possible. | |
int | tarval_is_long (ir_tarval *tv) |
This validates if get_tarval_long() will return a satisfying result. | |
ir_tarval * | new_tarval_from_double (double d, ir_mode *mode) |
Constructor function for new tarvals. | |
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 | |
double | get_tarval_double (ir_tarval *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. | |
long double | get_tarval_long_double (ir_tarval *tv) |
same as get_tarval_double but returns a long double value | |
int | tarval_is_double (ir_tarval *tv) |
This validates if tarval_to_double() will return a satisfying result. | |
ir_mode * | get_tarval_mode (const ir_tarval *tv) |
Returns the mode of the tarval. | |
int | tarval_is_negative (ir_tarval *tv) |
Returns 1 if tv is negative. | |
int | tarval_is_null (ir_tarval *tv) |
Returns 1 if tv is null. | |
int | tarval_is_one (ir_tarval *tv) |
Returns 1 if tv is the "one". | |
int | tarval_is_minus_one (ir_tarval *tv) |
Returns 1 if tv is the "minus one". | |
int | tarval_is_all_one (ir_tarval *tv) |
returns non-zero if all bits in the tarval are set | |
int | tarval_is_constant (ir_tarval *tv) |
Returns non-zero if the tarval is a constant (ie. | |
ir_tarval * | get_tarval_bad (void) |
Returns the 'bad' tarval. | |
ir_tarval * | get_tarval_undefined (void) |
Returns the 'undefined' tarval. | |
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_unreachable (void) |
Returns the mode_X tarval 'unreachable'. | |
ir_tarval * | get_tarval_reachable (void) |
Returns the mode_X tarval 'reachable'. | |
ir_tarval * | get_tarval_max (ir_mode *mode) |
Returns the maximum value of a given mode. | |
ir_tarval * | get_tarval_min (ir_mode *mode) |
Returns the minimum value of a given mode. | |
ir_tarval * | get_tarval_null (ir_mode *mode) |
Returns the 0 value (additive neutral) of a given mode. | |
ir_tarval * | get_tarval_one (ir_mode *mode) |
Returns the 1 value (multiplicative neutral) of a given mode. | |
ir_tarval * | get_tarval_minus_one (ir_mode *mode) |
Returns the -1 value (multiplicative neutral) of a given mode. | |
ir_tarval * | get_tarval_all_one (ir_mode *mode) |
returns the value where all bits are 1 of a given mode. | |
ir_tarval * | get_tarval_nan (ir_mode *mode) |
Returns quite nan for float_number modes. | |
ir_tarval * | get_tarval_plus_inf (ir_mode *mode) |
Returns +inf for float_number modes. | |
ir_tarval * | get_tarval_minus_inf (ir_mode *mode) |
Returns -inf for float_number modes. | |
void | tarval_set_integer_overflow_mode (tarval_int_overflow_mode_t ov_mode) |
Sets the overflow mode for integer operations. | |
tarval_int_overflow_mode_t | tarval_get_integer_overflow_mode (void) |
Returns the overflow mode for integer operations. | |
ir_relation | tarval_cmp (ir_tarval *a, ir_tarval *b) |
Compares two tarvals. | |
ir_tarval * | tarval_convert_to (ir_tarval *src, ir_mode *mode) |
Converts a tarval to another mode. | |
ir_tarval * | tarval_not (ir_tarval *a) |
Bitwise Negation of a tarval. | |
ir_tarval * | tarval_neg (ir_tarval *a) |
Arithmetic Negation of a tarval. | |
ir_tarval * | tarval_add (ir_tarval *a, ir_tarval *b) |
Addition of two tarvals. | |
ir_tarval * | tarval_sub (ir_tarval *a, ir_tarval *b, ir_mode *dst_mode) |
Subtraction from a tarval. | |
ir_tarval * | tarval_mul (ir_tarval *a, ir_tarval *b) |
Multiplication of tarvals. | |
ir_tarval * | tarval_div (ir_tarval *a, ir_tarval *b) |
Integer division of two tarvals. | |
ir_tarval * | tarval_mod (ir_tarval *a, ir_tarval *b) |
Remainder of integer division. | |
ir_tarval * | tarval_divmod (ir_tarval *a, ir_tarval *b, ir_tarval **mod_res) |
Integer division AND remainder. | |
ir_tarval * | tarval_abs (ir_tarval *a) |
Absolute value of a tarval. | |
ir_tarval * | tarval_and (ir_tarval *a, ir_tarval *b) |
Bitwise and of two integer tarvals. | |
ir_tarval * | tarval_andnot (ir_tarval *a, ir_tarval *b) |
Bitwise and not of two integer tarvals. | |
ir_tarval * | tarval_or (ir_tarval *a, ir_tarval *b) |
Bitwise or of two integer tarvals. | |
ir_tarval * | tarval_eor (ir_tarval *a, ir_tarval *b) |
Bitwise exclusive or of two integer tarvals. | |
ir_tarval * | tarval_shl (ir_tarval *a, ir_tarval *b) |
Logical Left shift. | |
ir_tarval * | tarval_shr (ir_tarval *a, ir_tarval *b) |
Unsigned (logical) right shift. | |
ir_tarval * | tarval_shrs (ir_tarval *a, ir_tarval *b) |
Signed (arithmetic) right shift. | |
ir_tarval * | tarval_rotl (ir_tarval *a, ir_tarval *b) |
Rotation to left. | |
int | tarval_carry (void) |
Returns the carry flag of the last operation. | |
int | set_tarval_mode_output_option (ir_mode *mode, const tarval_mode_info *modeinfo) |
Specify the output options of one mode. | |
const tarval_mode_info * | get_tarval_mode_output_option (ir_mode *mode) |
Returns the output options of one mode. | |
char * | get_tarval_bitpattern (ir_tarval *tv) |
Returns Bit representation of a tarval value, as string of '0' and '1'. | |
unsigned char | get_tarval_sub_bits (ir_tarval *tv, unsigned byte_ofs) |
Returns the bitpattern of the bytes_ofs byte. | |
int | tarval_is_single_bit (ir_tarval *tv) |
Returns non-zero if a given (integer) tarval has only one single bit set. | |
int | get_tarval_popcount (ir_tarval *tv) |
Returns the number of set bits in a given (integer) tarval. | |
int | get_tarval_lowest_bit (ir_tarval *tv) |
Returns the number of the lowest set bit in a given (integer) tarval. | |
int | tarval_snprintf (char *buf, size_t buflen, ir_tarval *tv) |
Output a tarval to a string buffer. | |
int | tarval_printf (ir_tarval *tv) |
Output a tarval to stdio. | |
int | tarval_zero_mantissa (ir_tarval *tv) |
Returns non-zero if the mantissa of a floating point tarval is zero (i.e. | |
int | tarval_get_exponent (ir_tarval *tv) |
Returns the exponent of a floating point IEEE-754 tarval. | |
int | tarval_ieee754_can_conv_lossless (ir_tarval *tv, ir_mode *mode) |
Check if the tarval can be converted to the given mode without precision loss. | |
unsigned | tarval_ieee754_get_exact (void) |
Returns non-zero if the result of the last IEEE-754 operation was exact. | |
void | tarval_enable_fp_ops (int enable) |
Enable/Disable floating point constant folding. | |
int | tarval_fp_ops_enabled (void) |
returns 0/1 if floating point folding is enable/disabled | |
int | tarval_is_NaN (ir_tarval *tv) |
Check if its the a floating point NaN. | |
int | tarval_is_plus_inf (ir_tarval *tv) |
Check if its the a floating point +inf. | |
int | tarval_is_minus_inf (ir_tarval *tv) |
Check if its the a floating point -inf. | |
int | tarval_is_finite (ir_tarval *tv) |
Check if the tarval represents a finite value, ie neither NaN nor inf. | |
int | is_tarval (const void *thing) |
Checks whether a pointer points to a tarval. | |
Variables | |
ir_tarval * | tarval_bad |
The 'bad' tarval. | |
ir_tarval * | tarval_undefined |
The 'undefined' tarval. | |
ir_tarval * | tarval_b_false |
The mode_b tarval 'false'. | |
ir_tarval * | tarval_b_true |
The mode_b tarval 'true'. | |
ir_tarval * | tarval_unreachable |
The mode_X tarval 'unreachable'. | |
ir_tarval * | tarval_reachable |
The mode_X tarval 'reachable'. |
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.
#define get_tarval_bottom | ( | ) | get_tarval_bad() |
#define get_tarval_top | ( | ) | get_tarval_undefined() |
#define tarval_bottom tarval_bad |
#define tarval_top tarval_undefined |
Target Machine Value.
Definition at line 78 of file firm_types.h.
enum tv_output_mode |
The output mode for tarval values.
Some modes allow more that one representation, for instance integers can be represented hex or decimal. Of course it would be enough to have one and let every backend convert it into the 'right' one. However, we can do this in the tarval much simpler...
returns the value where all bits are 1 of a given mode.
returns tarval_bad for float modes
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.
char* get_tarval_bitpattern | ( | ir_tarval * | tv | ) |
Returns Bit representation of a tarval value, as string of '0' and '1'.
tv | The tarval |
This function returns a printable bit representation of any value stored as tarval. This representation is a null terminated C string.
double get_tarval_double | ( | ir_tarval * | 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 |
long get_tarval_long | ( | ir_tarval * | tv | ) |
Returns value as long if possible.
This returns a long int with the value represented value, or gibberish, depending on the size of long int and the size of the stored value. It works for e.g. 1 as mode_Ls, but might not work for get_mode_max(mode_Ls). This will overflow silently, so use only if you know what you are doing! (better check with tarval_is_long()...) Works only for int modes, even not for character modes!
long double get_tarval_long_double | ( | ir_tarval * | tv | ) |
same as get_tarval_double but returns a long double value
int get_tarval_lowest_bit | ( | ir_tarval * | tv | ) |
Returns the number of the lowest set bit in a given (integer) tarval.
tv | the tarval |
Returns the -1 value (multiplicative neutral) of a given mode.
Returns tarval bad for unsigned modes
Returns the mode of the tarval.
tv | the tarval |
const tarval_mode_info* get_tarval_mode_output_option | ( | ir_mode * | mode | ) |
Returns the output options of one mode.
This functions returns the mode info of a given mode.
mode | a ir_mode that should be associated |
Returns the 0 value (additive neutral) of a given mode.
For reference modes, the NULL value is returned (old tarval_P_void)
Returns the 1 value (multiplicative neutral) of a given mode.
int get_tarval_popcount | ( | ir_tarval * | tv | ) |
Returns the number of set bits in a given (integer) tarval.
tv | the tarval |
ir_tarval* get_tarval_reachable | ( | void | ) |
Returns the mode_X tarval 'reachable'.
unsigned char get_tarval_sub_bits | ( | ir_tarval * | tv, |
unsigned | byte_ofs | ||
) |
Returns the bitpattern of the bytes_ofs byte.
This function succeeds even if the mode of the tarval uses lesser 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_undefined | ( | void | ) |
Returns the 'undefined' tarval.
ir_tarval* get_tarval_unreachable | ( | void | ) |
Returns the mode_X tarval 'unreachable'.
int is_tarval | ( | const void * | thing | ) |
Checks whether a pointer points to a tarval.
thing | an arbitrary pointer |
ir_tarval* new_integer_tarval_from_str | ( | const char * | str, |
size_t | len, | ||
char | sign, | ||
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 |
sign | is -1 or 1 depending on the numbers sign |
base | number system base. binary(2), octal(8), decimal(10) and hexadecimal(16) numbers are supported. |
mode | The mode requested for the result 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 |
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: hexadecimal of decimal number as int
if mode is character: hex or dec
Leading and/or trailing spaces are ignored
int set_tarval_mode_output_option | ( | ir_mode * | mode, |
const tarval_mode_info * | modeinfo | ||
) |
Specify the output options of one mode.
This functions stores the mode info, so DO NOT DESTROY it.
mode | a ir_mode that should be associated |
modeinfo | the output format info |
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 |
int tarval_carry | ( | void | ) |
Returns the carry flag of the last operation.
ir_relation tarval_cmp | ( | ir_tarval * | a, |
ir_tarval * | 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 |
void tarval_enable_fp_ops | ( | int | enable | ) |
Enable/Disable floating point constant folding.
Bitwise exclusive or of two integer tarvals.
a | the first tarval |
b | the second tarval |
int tarval_fp_ops_enabled | ( | void | ) |
returns 0/1 if floating point folding is enable/disabled
int tarval_get_exponent | ( | ir_tarval * | tv | ) |
Returns the exponent of a floating point IEEE-754 tarval.
tv | the tarval |
tarval_int_overflow_mode_t tarval_get_integer_overflow_mode | ( | void | ) |
Returns the overflow mode for integer operations.
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 * | tv | ) |
returns non-zero if all bits in the tarval are set
int tarval_is_constant | ( | ir_tarval * | tv | ) |
Returns non-zero if the tarval is a constant (ie.
NOT a reserved tarval like bad, undef, reachable etc.)
int tarval_is_double | ( | ir_tarval * | 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 * | tv | ) |
Check if the tarval represents a finite value, ie neither NaN nor inf.
tv | the tarval |
int tarval_is_long | ( | ir_tarval * | tv | ) |
This validates if get_tarval_long() will return a satisfying result.
I.e. if tv is an int_number and between min, max of long int (signed!)
tv | the tarval |
int tarval_is_minus_inf | ( | ir_tarval * | tv | ) |
Check if its the a floating point -inf.
tv | the tarval |
int tarval_is_minus_one | ( | ir_tarval * | tv | ) |
Returns 1 if tv is the "minus one".
tv | the tarval |
int tarval_is_NaN | ( | ir_tarval * | tv | ) |
Check if its the a floating point NaN.
tv | the tarval |
int tarval_is_negative | ( | ir_tarval * | tv | ) |
Returns 1 if tv is negative.
tv | the tarval |
int tarval_is_null | ( | ir_tarval * | tv | ) |
Returns 1 if tv is null.
tv | the tarval |
int tarval_is_one | ( | ir_tarval * | tv | ) |
Returns 1 if tv is the "one".
tv | the tarval |
int tarval_is_plus_inf | ( | ir_tarval * | tv | ) |
Check if its the a floating point +inf.
tv | the tarval |
int tarval_is_single_bit | ( | ir_tarval * | tv | ) |
Returns non-zero if a given (integer) tarval has only one single bit set.
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 |
int tarval_printf | ( | ir_tarval * | tv | ) |
Output a tarval to stdio.
tv | the tarval |
Rotation to left.
a | the first tarval |
b | the second tarval |
void tarval_set_integer_overflow_mode | ( | tarval_int_overflow_mode_t | ov_mode | ) |
Sets the overflow mode for integer operations.
ov_mode | one of the overflow modes |
Logical Left shift.
a | the first tarval |
b | the second tarval |
Unsigned (logical) right shift.
a | the first tarval |
b | the second tarval |
Signed (arithmetic) right shift.
a | the first tarval |
b | the second tarval |
int tarval_snprintf | ( | char * | buf, |
size_t | buflen, | ||
ir_tarval * | tv | ||
) |
Output a tarval to a string buffer.
buf | the output buffer |
buflen | the length of the buffer |
tv | the tarval |
Subtraction from a tarval.
a | the first tarval |
b | the second tarval |
dst_mode | the mode of the result, needed for mode_P - mode_P, else NULL |
int tarval_zero_mantissa | ( | ir_tarval * | tv | ) |
Returns non-zero if the mantissa of a floating point tarval is zero (i.e.
1.0Exxx)
tv | the tarval |