libFirm
Loading...
Searching...
No Matches
tv.h
1/*
2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
4 */
5
14#ifndef FIRM_TV_TV_H
15#define FIRM_TV_TV_H
16
17#include <stddef.h>
18#include "firm_types.h"
19
20#include "begin.h"
21
86FIRM_API ir_tarval *new_tarval_from_str(const char *str, size_t len,
87 ir_mode *mode);
88
106FIRM_API ir_tarval *new_integer_tarval_from_str(const char *str, size_t len,
107 int negative,
108 unsigned char base,
109 ir_mode *mode);
110
139FIRM_API ir_tarval *new_tarval_from_long(long l, ir_mode *mode);
140
150FIRM_API ir_tarval *new_tarval_from_bytes(unsigned char const *buf,
151 ir_mode *mode);
152
159FIRM_API ir_tarval *new_tarval_nan(ir_mode *mode, int signaling,
160 ir_tarval const *payload);
161
166FIRM_API void tarval_to_bytes(unsigned char *buffer, ir_tarval const *tv);
167
171FIRM_API long get_tarval_long(ir_tarval const *tv);
172
182FIRM_API int tarval_is_long(ir_tarval const *tv);
183
211FIRM_API ir_tarval *new_tarval_from_double(double d, ir_mode *mode);
212
216FIRM_API ir_tarval *new_tarval_from_long_double(long double d, ir_mode *mode);
217
227FIRM_API double get_tarval_double(ir_tarval const *tv);
228
232FIRM_API long double get_tarval_long_double(ir_tarval const *tv);
233
241FIRM_API int tarval_is_double(ir_tarval const *tv);
242
248FIRM_API ir_mode *get_tarval_mode(ir_tarval const *tv);
249
255FIRM_API int tarval_is_negative(ir_tarval const *tv);
256
262FIRM_API int tarval_is_null(ir_tarval const *tv);
263
269FIRM_API int tarval_is_one(ir_tarval const *tv);
270
275FIRM_API int tarval_is_all_one(ir_tarval const *tv);
276
281FIRM_API int tarval_is_constant(ir_tarval const *tv);
282
285FIRM_API ir_tarval *const tarval_bad;
287FIRM_API ir_tarval *get_tarval_bad(void);
288
291FIRM_API ir_tarval *const tarval_unknown;
294
299
304
308FIRM_API void tarval_set_wrap_on_overflow(int wrap_on_overflow);
309
314
326FIRM_API ir_relation tarval_cmp(ir_tarval const *a, ir_tarval const *b);
327
350FIRM_API ir_tarval *tarval_convert_to(ir_tarval const *src, ir_mode *mode);
351
357FIRM_API ir_tarval *tarval_bitcast(ir_tarval const *src, ir_mode *mode);
358
359/*
360 * These function implement basic computations representable as opcodes
361 * in FIRM nodes.
362 *
363 * PARAMETERS
364 * tarval_neg:
365 * traval_abs:
366 * a - the tarval to operate on
367 *
368 * all others:
369 * a - the first operand tarval
370 * b - the second operand tarval
371 *
372 * RESULT
373 * If necessary a new tarval is constructed for the resulting value,
374 * or the one already carrying the computation result is retrieved and
375 * returned as result.
376 *
377 * NOTES
378 * The order the arguments are given in is important, imagine postfix
379 * notation.
380 * Illegal operations will trigger an assertion.
381 * The sort member of the struct mode defines which operations are valid
382 */
383
391FIRM_API ir_tarval *tarval_not(ir_tarval const *a);
392
400FIRM_API ir_tarval *tarval_neg(ir_tarval const *a);
401
410FIRM_API ir_tarval *tarval_add(ir_tarval const *a, ir_tarval const *b);
411
420FIRM_API ir_tarval *tarval_sub(ir_tarval const *a, ir_tarval const *b);
421
430FIRM_API ir_tarval *tarval_mul(ir_tarval const *a, ir_tarval const *b);
431
440FIRM_API ir_tarval *tarval_div(ir_tarval const *a, ir_tarval const *b);
441
450FIRM_API ir_tarval *tarval_mod(ir_tarval const *a, ir_tarval const *b);
451
461FIRM_API ir_tarval *tarval_divmod(ir_tarval const *a, ir_tarval const *b,
462 ir_tarval **mod_res);
463
471FIRM_API ir_tarval *tarval_abs(ir_tarval const *a);
472
481FIRM_API ir_tarval *tarval_and(ir_tarval const *a, ir_tarval const *b);
482
491FIRM_API ir_tarval *tarval_andnot(ir_tarval const *a, ir_tarval const *b);
492
501FIRM_API ir_tarval *tarval_or(ir_tarval const *a, ir_tarval const *b);
502
511FIRM_API ir_tarval *tarval_ornot(ir_tarval const *a, ir_tarval const *b);
512
521FIRM_API ir_tarval *tarval_eor(ir_tarval const *a, ir_tarval const *b);
522
531FIRM_API ir_tarval *tarval_shl(ir_tarval const *a, ir_tarval const *b);
532
537FIRM_API ir_tarval *tarval_shl_unsigned(ir_tarval const *a, unsigned b);
538
547FIRM_API ir_tarval *tarval_shr(ir_tarval const *a, ir_tarval const *b);
548
553FIRM_API ir_tarval *tarval_shr_unsigned(ir_tarval const *a, unsigned b);
554
563FIRM_API ir_tarval *tarval_shrs(ir_tarval const *a, ir_tarval const *b);
564
569FIRM_API ir_tarval *tarval_shrs_unsigned(ir_tarval const *a, unsigned b);
570
597FIRM_API unsigned char get_tarval_sub_bits(ir_tarval const *tv, unsigned byte_ofs);
598
606FIRM_API int get_tarval_popcount(ir_tarval const *tv);
607
615FIRM_API int get_tarval_lowest_bit(ir_tarval const *tv);
616
624FIRM_API int get_tarval_highest_bit(ir_tarval const *tv);
625
632FIRM_API int tarval_zero_mantissa(ir_tarval const *tv);
633
640FIRM_API int tarval_get_exponent(ir_tarval const *tv);
641
649FIRM_API int tarval_ieee754_can_conv_lossless(ir_tarval const *tv, const ir_mode *mode);
650
654FIRM_API unsigned tarval_ieee754_get_exact(void);
655
661FIRM_API int tarval_is_nan(ir_tarval const *tv);
662
668FIRM_API int tarval_is_quiet_nan(ir_tarval const *tv);
669
675FIRM_API int tarval_is_signaling_nan(ir_tarval const *tv);
676
682FIRM_API int tarval_is_finite(ir_tarval const *tv);
683
686#include "end.h"
687
688#endif
struct ir_mode ir_mode
SSA Value mode.
Definition firm_types.h:59
ir_relation
Relations for comparing numbers.
Definition firm_types.h:162
ir_tarval * tarval_div(ir_tarval const *a, ir_tarval const *b)
Integer division of two tarvals.
ir_tarval * tarval_b_false
The mode_b tarval 'false'.
Definition tv.h:296
int tarval_get_wrap_on_overflow(void)
Returns 0 if operations return bad on overflow, != 0 if they wrap around.
int tarval_is_signaling_nan(ir_tarval const *tv)
Check if tv is a floating point signaling NaN.
unsigned tarval_ieee754_get_exact(void)
Returns non-zero if the result of the last IEEE-754 operation was exact.
struct ir_tarval ir_tarval
Target Machine Value.
Definition firm_types.h:68
int tarval_is_all_one(ir_tarval const *tv)
returns non-zero if all bits in the tarval are set.
ir_tarval * tarval_ornot(ir_tarval const *a, ir_tarval const *b)
Bitwise or not of two integer tarvals.
int tarval_is_nan(ir_tarval const *tv)
Check if tv is a floating point NaN.
ir_tarval * tarval_abs(ir_tarval const *a)
Absolute value of a tarval.
ir_tarval * tarval_add(ir_tarval const *a, ir_tarval const *b)
Addition of two tarvals.
ir_tarval * new_tarval_from_long(long l, ir_mode *mode)
Constructor function for new tarvals.
unsigned char get_tarval_sub_bits(ir_tarval const *tv, unsigned byte_ofs)
Returns the bitpattern of the bytes_ofs byte.
ir_tarval * tarval_shrs_unsigned(ir_tarval const *a, unsigned b)
signed (arithmetic) right shift (variant with unsigned argument).
int tarval_is_one(ir_tarval const *tv)
Returns 1 if tv is the "one".
ir_tarval *const tarval_unknown
The 'unknown' tarval.
Definition tv.h:291
ir_relation tarval_cmp(ir_tarval const *a, ir_tarval const *b)
Compares two tarvals.
ir_tarval * tarval_eor(ir_tarval const *a, ir_tarval const *b)
Bitwise exclusive or of two integer tarvals.
int tarval_is_constant(ir_tarval const *tv)
Returns non-zero if the tarval is a constant (i.e.
int get_tarval_highest_bit(ir_tarval const *tv)
Return the number of the highest set bit in a given (integer) tarval.
ir_tarval * new_tarval_from_double(double d, ir_mode *mode)
Constructor function for new tarvals.
ir_tarval * tarval_bitcast(ir_tarval const *src, ir_mode *mode)
Converts a tarval to another mode by reinterpreting the contained bits.
ir_tarval * new_tarval_from_bytes(unsigned char const *buf, ir_mode *mode)
Construct a new tarval from a sequence of bytes.
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.
int tarval_is_finite(ir_tarval const *tv)
Check if the tarval represents a finite value, ie neither NaN nor inf.
ir_tarval * tarval_or(ir_tarval const *a, ir_tarval const *b)
Bitwise or of two integer tarvals.
ir_tarval * tarval_shr_unsigned(ir_tarval const *a, unsigned b)
unsigned (logical) right shift (variant with unsigned argument).
ir_tarval * get_tarval_bad(void)
Returns the 'bad' tarval.
ir_tarval * get_tarval_unknown(void)
Returns the 'unknown' tarval.
ir_tarval * tarval_mul(ir_tarval const *a, ir_tarval const *b)
Multiplication of tarvals.
ir_tarval * tarval_andnot(ir_tarval const *a, ir_tarval const *b)
Bitwise and not of two integer tarvals.
ir_tarval * tarval_shr(ir_tarval const *a, ir_tarval const *b)
Unsigned (logical) right shift.
int tarval_zero_mantissa(ir_tarval const *tv)
Returns non-zero if the mantissa of a floating point tarval is zero (i.e.
ir_tarval * tarval_and(ir_tarval const *a, ir_tarval const *b)
Bitwise and of two integer tarvals.
ir_tarval * get_tarval_b_false(void)
Returns the mode_b tarval 'false'.
int tarval_is_double(ir_tarval const *tv)
This validates if tarval_to_double() will return a satisfying result.
ir_tarval * tarval_divmod(ir_tarval const *a, ir_tarval const *b, ir_tarval **mod_res)
Integer division AND remainder.
int tarval_is_quiet_nan(ir_tarval const *tv)
Check if tv is a floating point quiet NaN.
int tarval_is_long(ir_tarval const *tv)
This validates if get_tarval_long() will return something sensible.
ir_mode * get_tarval_mode(ir_tarval const *tv)
Returns the mode of the tarval.
int tarval_is_null(ir_tarval const *tv)
Returns 1 if tv is null.
int tarval_get_exponent(ir_tarval const *tv)
Returns the exponent of a floating point IEEE-754 tarval.
ir_tarval * tarval_not(ir_tarval const *a)
Bitwise Negation of a tarval.
ir_tarval *const tarval_bad
The 'bad' tarval.
Definition tv.h:285
ir_tarval * tarval_mod(ir_tarval const *a, ir_tarval const *b)
Remainder of integer division.
ir_tarval * tarval_convert_to(ir_tarval const *src, ir_mode *mode)
Converts a tarval to another mode.
ir_tarval * new_tarval_from_str(const char *str, size_t len, ir_mode *mode)
Constructor function for new tarvals.
ir_tarval * tarval_shrs(ir_tarval const *a, ir_tarval const *b)
Signed (arithmetic) right shift.
ir_tarval * tarval_sub(ir_tarval const *a, ir_tarval const *b)
Subtraction from a tarval.
ir_tarval * new_tarval_nan(ir_mode *mode, int signaling, ir_tarval const *payload)
Construct a new floating point quiet NaN value.
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
ir_tarval * get_tarval_b_true(void)
Returns the mode_b tarval 'true'.
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...
int get_tarval_popcount(ir_tarval const *tv)
Returns the number of set bits in a given (integer) tarval.
int tarval_is_negative(ir_tarval const *tv)
Returns 1 if tv is negative.
int get_tarval_lowest_bit(ir_tarval const *tv)
Returns the number of the lowest set bit in a given (integer) tarval.
ir_tarval * tarval_neg(ir_tarval const *a)
Arithmetic Negation of a tarval.
long double get_tarval_long_double(ir_tarval const *tv)
same as get_tarval_double but returns a long double value
ir_tarval * tarval_b_true
The mode_b tarval 'true'.
Definition tv.h:301
long get_tarval_long(ir_tarval const *tv)
Returns value as long if possible.
void tarval_set_wrap_on_overflow(int wrap_on_overflow)
Sets whether values should wrap on overflow or return the bad value.
void tarval_to_bytes(unsigned char *buffer, ir_tarval const *tv)
Write tarval to a sequence of bytes.
ir_tarval * tarval_shl_unsigned(ir_tarval const *a, unsigned b)
logical left shift (variant with unsigned argument).
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.
ir_tarval * tarval_shl(ir_tarval const *a, ir_tarval const *b)
Logical Left shift.