libFirm 1.20
libfirm/tv.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
00003  *
00004  * This file is part of libFirm.
00005  *
00006  * This file may be distributed and/or modified under the terms of the
00007  * GNU General Public License version 2 as published by the Free Software
00008  * Foundation and appearing in the file LICENSE.GPL included in the
00009  * packaging of this file.
00010  *
00011  * Licensees holding valid libFirm Professional Edition licenses may use
00012  * this file in accordance with the libFirm Commercial License.
00013  * Agreement provided with the Software.
00014  *
00015  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017  * PURPOSE.
00018  */
00019 
00028 #ifndef FIRM_TV_TV_H
00029 #define FIRM_TV_TV_H
00030 
00031 #include <stddef.h>
00032 #include "firm_types.h"
00033 
00034 #include "begin.h"
00035 
00101 FIRM_API ir_tarval *new_tarval_from_str(const char *str, size_t len,
00102                                         ir_mode *mode);
00103 
00121 FIRM_API ir_tarval *new_integer_tarval_from_str(const char *str, size_t len,
00122                                                 char sign, unsigned char base,
00123                                                 ir_mode *mode);
00124 
00152 FIRM_API ir_tarval *new_tarval_from_long(long l, ir_mode *mode);
00153 
00164 FIRM_API long get_tarval_long(ir_tarval *tv);
00165 
00173 FIRM_API int tarval_is_long(ir_tarval *tv);
00174 
00202 FIRM_API ir_tarval *new_tarval_from_double(double d, ir_mode *mode);
00203 
00207 FIRM_API ir_tarval *new_tarval_from_long_double(long double d, ir_mode *mode);
00208 
00218 FIRM_API double get_tarval_double(ir_tarval *tv);
00219 
00223 FIRM_API long double get_tarval_long_double(ir_tarval *tv);
00224 
00232 FIRM_API int tarval_is_double(ir_tarval *tv);
00233 
00239 FIRM_API ir_mode *get_tarval_mode(const ir_tarval *tv);
00240 
00246 FIRM_API int tarval_is_negative(ir_tarval *tv);
00247 
00253 FIRM_API int tarval_is_null(ir_tarval *tv);
00254 
00260 FIRM_API int tarval_is_one(ir_tarval *tv);
00261 
00267 FIRM_API int tarval_is_minus_one(ir_tarval *tv);
00268 
00272 FIRM_API int tarval_is_all_one(ir_tarval *tv);
00273 
00278 FIRM_API int tarval_is_constant(ir_tarval *tv);
00279 
00281 FIRM_API ir_tarval *tarval_bad;
00283 FIRM_API ir_tarval *get_tarval_bad(void);
00284 
00286 FIRM_API ir_tarval *tarval_undefined;
00288 FIRM_API ir_tarval *get_tarval_undefined(void);
00289 
00291 FIRM_API ir_tarval *tarval_b_false;
00293 FIRM_API ir_tarval *get_tarval_b_false(void);
00294 
00296 FIRM_API ir_tarval *tarval_b_true;
00298 FIRM_API ir_tarval *get_tarval_b_true(void);
00299 
00301 FIRM_API ir_tarval *tarval_unreachable;
00303 FIRM_API ir_tarval *get_tarval_unreachable(void);
00304 
00306 FIRM_API ir_tarval *tarval_reachable;
00308 FIRM_API ir_tarval *get_tarval_reachable(void);
00309 
00311 #define tarval_top          tarval_undefined
00312 
00313 #define get_tarval_top()    get_tarval_undefined()
00314 
00316 #define tarval_bottom       tarval_bad
00317 
00318 #define get_tarval_bottom() get_tarval_bad()
00319 
00321 FIRM_API ir_tarval *get_tarval_max(ir_mode *mode);
00322 
00324 FIRM_API ir_tarval *get_tarval_min(ir_mode *mode);
00325 
00328 FIRM_API ir_tarval *get_tarval_null(ir_mode *mode);
00329 
00331 FIRM_API ir_tarval *get_tarval_one(ir_mode *mode);
00332 
00335 FIRM_API ir_tarval *get_tarval_minus_one(ir_mode *mode);
00336 
00339 FIRM_API ir_tarval *get_tarval_all_one(ir_mode *mode);
00340 
00342 FIRM_API ir_tarval *get_tarval_nan(ir_mode *mode);
00343 
00345 FIRM_API ir_tarval *get_tarval_plus_inf(ir_mode *mode);
00346 
00348 FIRM_API ir_tarval *get_tarval_minus_inf(ir_mode *mode);
00349 
00351 typedef enum tarval_int_overflow_mode_t {
00352     TV_OVERFLOW_BAD,      
00353     TV_OVERFLOW_WRAP,     
00354     TV_OVERFLOW_SATURATE  
00355 } tarval_int_overflow_mode_t;
00356 
00362 FIRM_API void tarval_set_integer_overflow_mode(tarval_int_overflow_mode_t ov_mode);
00363 
00367 FIRM_API tarval_int_overflow_mode_t tarval_get_integer_overflow_mode(void);
00368 
00380 FIRM_API ir_relation tarval_cmp(ir_tarval *a, ir_tarval *b);
00381 
00404 FIRM_API ir_tarval *tarval_convert_to(ir_tarval *src, ir_mode *mode);
00405 
00406 /*
00407  * These function implement basic computations representable as opcodes
00408  * in FIRM nodes.
00409  *
00410  * PARAMETERS
00411  *    tarval_neg:
00412  *    traval_abs:
00413  *      a - the tarval to operate on
00414  *
00415  *    all others:
00416  *      a - the first operand tarval
00417  *      b - the second operand tarval
00418  *
00419  * RESULT
00420  *    If necessary a new tarval is constructed for the resulting value,
00421  *   or the one already carrying the computation result is retrieved and
00422  *   returned as result.
00423  *
00424  * NOTES
00425  *   The order the arguments are given in is important, imagine postfix
00426  *   notation.
00427  *   Illegal operations will trigger an assertion.
00428  *   The sort member of the struct mode defines which operations are valid
00429  */
00430 
00438 FIRM_API ir_tarval *tarval_not(ir_tarval *a);
00439 
00447 FIRM_API ir_tarval *tarval_neg(ir_tarval *a);
00448 
00457 FIRM_API ir_tarval *tarval_add(ir_tarval *a, ir_tarval *b);
00458 
00468 FIRM_API ir_tarval *tarval_sub(ir_tarval *a, ir_tarval *b, ir_mode *dst_mode);
00469 
00478 FIRM_API ir_tarval *tarval_mul(ir_tarval *a, ir_tarval *b);
00479 
00488 FIRM_API ir_tarval *tarval_div(ir_tarval *a, ir_tarval *b);
00489 
00498 FIRM_API ir_tarval *tarval_mod(ir_tarval *a, ir_tarval *b);
00499 
00509 FIRM_API ir_tarval *tarval_divmod(ir_tarval *a, ir_tarval *b, ir_tarval **mod_res);
00510 
00518 FIRM_API ir_tarval *tarval_abs(ir_tarval *a);
00519 
00528 FIRM_API ir_tarval *tarval_and(ir_tarval *a, ir_tarval *b);
00529 
00538 FIRM_API ir_tarval *tarval_andnot(ir_tarval *a, ir_tarval *b);
00539 
00548 FIRM_API ir_tarval *tarval_or(ir_tarval *a, ir_tarval *b);
00549 
00558 FIRM_API ir_tarval *tarval_eor(ir_tarval *a, ir_tarval *b);
00559 
00568 FIRM_API ir_tarval *tarval_shl(ir_tarval *a, ir_tarval *b);
00569 
00578 FIRM_API ir_tarval *tarval_shr(ir_tarval *a, ir_tarval *b);
00579 
00588 FIRM_API ir_tarval *tarval_shrs(ir_tarval *a, ir_tarval *b);
00589 
00598 FIRM_API ir_tarval *tarval_rotl(ir_tarval *a, ir_tarval *b);
00599 
00603 FIRM_API int tarval_carry(void);
00604 
00613 typedef enum {
00614     TVO_NATIVE,  
00615     TVO_HEX,     
00616     TVO_DECIMAL, 
00617     TVO_OCTAL,   
00618     TVO_BINARY,  
00619     TVO_FLOAT,   
00620     TVO_HEXFLOAT 
00622 } tv_output_mode;
00623 
00628 typedef struct tarval_mode_info {
00629     tv_output_mode mode_output;  
00630     const char *mode_prefix;     
00632     const char *mode_suffix;     
00634 } tarval_mode_info;
00635 
00646 FIRM_API int set_tarval_mode_output_option(ir_mode *mode,
00647                                            const tarval_mode_info *modeinfo);
00648 
00658 FIRM_API const tarval_mode_info *get_tarval_mode_output_option(ir_mode *mode);
00659 
00683 FIRM_API char *get_tarval_bitpattern(ir_tarval *tv);
00684 
00711 FIRM_API unsigned char get_tarval_sub_bits(ir_tarval *tv, unsigned byte_ofs);
00712 
00719 FIRM_API int tarval_is_single_bit(ir_tarval *tv);
00720 
00728 FIRM_API int get_tarval_popcount(ir_tarval *tv);
00729 
00737 FIRM_API int get_tarval_lowest_bit(ir_tarval *tv);
00738 
00746 FIRM_API int tarval_snprintf(char *buf, size_t buflen, ir_tarval *tv);
00747 
00753 FIRM_API int tarval_printf(ir_tarval *tv);
00754 
00761 FIRM_API int tarval_zero_mantissa(ir_tarval *tv);
00762 
00769 FIRM_API int tarval_get_exponent(ir_tarval *tv);
00770 
00778 FIRM_API int tarval_ieee754_can_conv_lossless(ir_tarval *tv, ir_mode *mode);
00779 
00783 FIRM_API unsigned tarval_ieee754_get_exact(void);
00784 
00788 FIRM_API void tarval_enable_fp_ops(int enable);
00789 
00791 FIRM_API int tarval_fp_ops_enabled(void);
00792 
00798 FIRM_API int tarval_is_NaN(ir_tarval *tv);
00799 
00805 FIRM_API int tarval_is_plus_inf(ir_tarval *tv);
00806 
00812 FIRM_API int tarval_is_minus_inf(ir_tarval *tv);
00813 
00819 FIRM_API int tarval_is_finite(ir_tarval *tv);
00820 
00829 FIRM_API int is_tarval(const void *thing);
00830 
00833 #include "end.h"
00834 
00835 #endif