1 /* TV --- Target Values, aka Constant Table.
2 Copyright (C) 1995, 1996 Christian von Roques */
6 /****i* tv/implementation
13 * Internal storage for tarvals, 1st draft:
14 * Integers as well as pointers are stored in a hex formatted string holding
15 * 16 characters. Booleans are not stored as there are only two of them.
17 * Floats are just reinterpreted as byte strings, because I am not sure if
18 * there is loss if I convert float to long double and back and furthermore
19 * the implementation of a fully ieee compatible floating point emulation
20 * is not sensible for now
21 * With this information it is easy to decide the kind of stored value:
22 * Integers have size 16, floats 4, doubles 8, long doubles 12.
25 /* This implementation assumes:
26 * both host and target have IEEE-754 floating-point arithmetic. */
28 /* !!! float and double divides MUST NOT SIGNAL !!! */
29 /* @@@ query the floating-point expception status flags */
31 /* @@@ Problem: All Values are stored twice, once as Univ_*s and a 2nd
32 time in their real target mode. :-( */
34 #define MAX_INT_LENGTH 8
35 #define CHAR_BUFFER_SIZE ((MAX_INT_LENGTH) * 2)
41 #include <assert.h> /* assertions */
42 #include <stdlib.h> /* atoi() */
43 #include <string.h> /* nice things for strings */
47 #include "set.h" /* to store tarvals in */
48 #include "tune.h" /* some constants */
49 #include "entity_t.h" /* needed to store pointers to entities */
50 #include "irmode.h" /* defines modes etc */
52 #include "irnode.h" /* defines boolean return values */
57 /****************************************************************************
58 * local definitions and macros
59 ****************************************************************************/
61 # define TARVAL_VERIFY(a) tarval_verify((a))
63 # define TARVAL_VERIFY(a) ((void)0)
66 #define INSERT_TARVAL(tv) ((tarval*)set_insert(tarvals, (tv), sizeof(tarval), hash_tv((tv))))
67 #define FIND_TARVAL(tv) ((tarval*)set_find(tarvals, (tv), sizeof(tarval), hash_tv((tv))))
69 #define INSERT_VALUE(val, size) (set_insert(values, (val), size, hash_val((val), size)))
70 #define FIND_VALUE(val, size) (set_find(values, (val), size, hash_val((val), size)))
72 #define fail_verify(a) _fail_verify((a), __FILE__, __LINE__)
74 static long long count = 0;
75 # define ANNOUNCE() printf(__FILE__": call no. %lld (%s)\n", count++, __FUNCTION__);
77 # define ANNOUNCE() ((void)0)
79 /****************************************************************************
81 ****************************************************************************/
82 static struct set *tarvals; /* container for tarval structs */
83 static struct set *values; /* container for values */
85 /****************************************************************************
87 ****************************************************************************/
89 static int hash_val(const void *value, unsigned int length);
90 static int hash_tv(tarval *tv);
91 static void _fail_verify(tarval *tv, const char* file, int line)
93 /* print a memory image of the tarval and throw an assertion */
95 printf("%s:%d: Invalid tarval:\n mode: %s\n value: [%p]\n", file, line, get_mode_name(tv->mode), tv->value);
97 printf("%s:%d: Invalid tarval (null)", file, line);
101 inline static void tarval_verify(tarval *tv)
107 if ((tv == tarval_bad) || (tv == tarval_undefined)) return;
108 if ((tv == tarval_b_true) || (tv == tarval_b_false)) return;
110 if (!FIND_TARVAL(tv)) fail_verify(tv);
111 if (tv->length > 0 && !FIND_VALUE(tv->value, tv->length)) fail_verify(tv);
117 static int hash_tv(tarval *tv)
119 return ((unsigned int)tv->value ^ (unsigned int)tv->mode) + tv->length;
122 static int hash_val(const void *value, unsigned int length)
125 unsigned int hash = 0;
127 /* scramble the byte - array */
128 for (i = 0; i < length; i++)
130 hash += (hash << 5) ^ (hash >> 27) ^ ((char*)value)[i];
131 hash += (hash << 11) ^ (hash >> 17);
137 /* finds tarval with value/mode or creates new tarval */
138 static tarval *get_tarval(const void *value, int length, ir_mode *mode)
145 /* if there already is such a value, it is returned, else value
146 * is copied into the set */
147 tv.value = INSERT_VALUE(value, length);
151 /* if there is such a tarval, it is returned, else tv is copied
153 return (tarval *)INSERT_TARVAL(&tv);
157 * Returns non-zero if a tarval overflows.
159 * @todo Implementation did not work on all modes
161 static int overflows(tarval *tv)
163 switch (get_mode_sort(tv->mode))
166 case irms_int_number:
167 if (sc_comp(tv->value, get_mode_max(tv->mode)->value) == 1) return 1;
168 if (sc_comp(tv->value, get_mode_min(tv->mode)->value) == -1) return 1;
171 case irms_float_number:
175 if (fc_comp(tv->value, get_mode_max(tv->mode)->value) == 1) return 1;
176 if (fc_comp(tv->value, get_mode_min(tv->mode)->value) == -1) return 1;
187 * public variables declared in tv.h
190 tarval *tarval_undefined;
191 tarval *tarval_b_false;
192 tarval *tarval_b_true;
193 tarval *tarval_P_void;
196 * public functions declared in tv.h
200 * Constructors =============================================================
202 tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode)
209 switch (get_mode_sort(mode))
215 case irms_internal_boolean:
216 /* match tTrRuUeE/fFaAlLsSeE */
217 if (strcasecmp(str, "true")) return tarval_b_true;
218 else if (strcasecmp(str, "false")) return tarval_b_true;
220 return atoi(str) ? tarval_b_true : tarval_b_false;
222 case irms_float_number:
223 fc_val_from_str(str, len);
224 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
226 case irms_int_number:
228 sc_val_from_str(str, len);
229 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
232 return get_tarval(str, len, mode);
235 assert(0); /* can't be reached, can it? */
240 int tarval_is_str(tarval *tv)
245 return ((get_mode_sort(tv->mode) == reference) && (tv->value != NULL) && (tv->length > 0));
247 char *tarval_to_str(tarval *tv)
250 assert(tarval_is_str(tv));
251 return (char *)tv->value;
256 * helper function, create a tarval from long
258 tarval *new_tarval_from_long(long l, ir_mode *mode)
261 assert(mode && !(get_mode_sort(mode) == irms_auxiliary));
263 switch(get_mode_sort(mode))
265 case irms_internal_boolean:
266 /* XXX C-Semantics ! */
267 return l ? tarval_b_true : tarval_b_false ;
269 case irms_int_number:
272 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
274 case irms_float_number:
275 return new_tarval_from_double((long double)l, mode);
278 return l ? tarval_bad : get_tarval(NULL, 0, mode); /* null pointer or tarval_bad */
286 /* returns non-zero if can be converted to long */
287 int tarval_is_long(tarval *tv)
290 return ((get_mode_sort(tv->mode) == irms_int_number) || (get_mode_sort(tv->mode) == irms_character));
293 /* this might overflow the machine's long, so use only with small values */
294 long tarval_to_long(tarval* tv)
297 assert(tv && get_mode_sort(tv->mode) == irms_int_number);
299 return sc_val_to_long(tv->value); /* might overflow */
302 tarval *new_tarval_from_double(long double d, ir_mode *mode)
305 assert(mode && (get_mode_sort(mode) == irms_float_number));
307 fc_val_from_float(d);
308 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
311 /* returns non-zero if can be converted to double */
312 int tarval_is_double(tarval *tv)
317 return (get_mode_sort(tv->mode) == irms_float_number);
320 long double tarval_to_double(tarval *tv)
323 assert(tarval_is_double(tv));
325 return fc_val_to_float(tv->value);
328 /* The tarval represents the address of the entity. As the address must
329 be constant the entity must have as owner the global type. */
330 tarval *new_tarval_from_entity (entity *ent, ir_mode *mode)
334 assert(mode && (get_mode_sort(mode) == irms_reference));
336 return get_tarval((void *)ent, 0, mode);
338 int tarval_is_entity(tarval *tv)
342 /* tv->value == NULL means dereferencing a null pointer */
343 return ((get_mode_sort(tv->mode) == irms_reference) && (tv->value != NULL) && (tv->length == 0));
346 entity *tarval_to_entity(tarval *tv)
351 if (tarval_is_entity(tv))
352 return (entity *)tv->value;
354 assert(0 && "tarval did not represent an entity");
359 void free_tarval_entity(entity *ent) {
360 /* There can be a tarval referencing this entity. Even if the
361 tarval is not used by the code any more, it can still reference
362 the entity as tarvals live indepently of the entity referenced.
363 Further the tarval is hashed into a set. If a hash function
364 evaluation happens to collide with this tarval, we will vrfy that
365 it contains a proper entity and we will crash if the entity is
368 Unluckily, tarvals can neither be changed nor deleted, and to find
369 one, all existing reference modes have to be tried -> a facility
370 to retrieve all modes of a kind is needed. */
375 * Access routines for tarval fields ========================================
377 ir_mode *get_tarval_mode (tarval *tv) /* get the mode of the tarval */
385 * Special value query functions ============================================
387 * These functions calculate and return a tarval representing the requested
389 * The functions get_mode_{Max,Min,...} return tarvals retrieved from these
390 * functions, but these are stored on initialization of the irmode module and
391 * therefore the irmode functions should be prefered to the functions below.
394 tarval *get_tarval_bad(void)
399 tarval *get_tarval_undefined(void)
402 return tarval_undefined;
404 tarval *get_tarval_b_false(void)
407 return tarval_b_false;
409 tarval *get_tarval_b_true(void)
412 return tarval_b_true;
414 tarval *get_tarval_P_void(void)
417 return tarval_P_void;
420 tarval *get_tarval_max(ir_mode *mode)
425 switch(get_mode_sort(mode))
432 case irms_internal_boolean:
433 return tarval_b_true;
435 case irms_float_number:
436 fc_get_max(get_mode_size_bits(mode));
437 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
439 case irms_int_number:
441 sc_max_from_bits(get_mode_size_bits(mode), mode_is_signed(mode));
442 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
447 tarval *get_tarval_min(ir_mode *mode)
452 switch(get_mode_sort(mode))
459 case irms_internal_boolean:
460 return tarval_b_false;
462 case irms_float_number:
463 fc_get_min(get_mode_size_bits(mode));
464 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
466 case irms_int_number:
468 sc_min_from_bits(get_mode_size_bits(mode), mode_is_signed(mode));
469 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
474 tarval *get_tarval_null(ir_mode *mode)
479 switch(get_mode_sort(mode))
482 case irms_internal_boolean:
486 case irms_float_number:
487 return new_tarval_from_double(0.0, mode);
489 case irms_int_number:
491 return new_tarval_from_long(0l, mode);
494 return tarval_P_void;
499 tarval *get_tarval_one(ir_mode *mode)
504 switch(get_mode_sort(mode))
507 case irms_internal_boolean:
512 case irms_float_number:
513 return new_tarval_from_double(1.0, mode);
515 case irms_int_number:
517 return new_tarval_from_long(1l, mode);
523 tarval *get_tarval_nan(ir_mode *mode)
528 if (get_mode_sort(mode) == irms_float_number) {
530 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
533 assert(0 && "tarval is not floating point");
538 tarval *get_tarval_inf(ir_mode *mode)
543 if (get_mode_sort(mode) == irms_float_number) {
545 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
548 assert(0 && "tarval is not floating point");
554 * Arithmethic operations on tarvals ========================================
558 * test if negative number, 1 means 'yes'
560 int tarval_is_negative(tarval *a)
565 switch (get_mode_sort(a->mode))
567 case irms_int_number:
568 if (!mode_is_signed(a->mode)) return 0;
570 return sc_comp(a->value, get_mode_null(a->mode)->value) == -1 ? 1 : 0;
572 case irms_float_number:
573 return fc_comp(a->value, get_mode_null(a->mode)->value) == -1 ? 1 : 0;
576 assert(0 && "not implemented");
582 * test if null, 1 means 'yes'
584 int tarval_is_null(tarval *a)
586 ir_mode *m = get_tarval_mode(a);
588 return a == get_tarval_null(m);
594 pnc_number tarval_cmp(tarval *a, tarval *b)
600 if (a == tarval_bad || b == tarval_bad) assert(0 && "Comparison with tarval_bad");
601 if (a == tarval_undefined || b == tarval_undefined) return False;
602 if (a == b) return Eq;
603 if (get_tarval_mode(a) != get_tarval_mode(b)) return Uo;
605 /* Here the two tarvals are unequal and of the same mode */
606 switch (get_mode_sort(a->mode))
611 case irms_float_number:
612 return (fc_comp(a->value, b->value)==1)?(Gt):(Lt);
614 case irms_int_number:
616 return (sc_comp(a->value, b->value)==1)?(Gt):(Lt);
618 case irms_internal_boolean:
619 return (a == tarval_b_true)?(Gt):(Lt);
628 * convert to other mode
630 tarval *tarval_convert_to(tarval *src, ir_mode *m)
638 if (src->mode == m) return src;
640 switch (get_mode_sort(src->mode))
645 case irms_float_number:
646 switch (get_mode_sort(m)) {
647 case irms_float_number:
649 tv.length = src->length;
650 tv.value = src->value;
651 if (overflows(&tv)) {
655 return INSERT_TARVAL(&tv);
662 case irms_int_number:
663 switch (get_mode_sort(m)) {
664 case irms_int_number:
667 tv.length = src->length;
668 tv.value = src->value;
672 return INSERT_TARVAL(&tv);
674 case irms_internal_boolean:
675 /* XXX C semantics */
676 if (src == get_mode_null(src->mode)) return tarval_b_false;
677 else return tarval_b_true;
684 case irms_internal_boolean:
685 switch (get_mode_sort(m))
687 case irms_int_number:
688 if (src == tarval_b_true) return get_mode_one(m);
689 else return get_mode_null(m);
708 tarval *tarval_neg(tarval *a)
712 assert(mode_is_num(a->mode)); /* negation only for numerical values */
713 assert(mode_is_signed(a->mode)); /* negation is difficult without negative numbers, isn't it */
715 switch (get_mode_sort(a->mode))
717 case irms_int_number:
719 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
721 case irms_float_number:
723 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
733 tarval *tarval_add(tarval *a, tarval *b)
738 assert((a->mode == b->mode) || (get_mode_sort(a->mode) == irms_character && mode_is_int(b->mode)));
740 switch (get_mode_sort(a->mode))
743 case irms_int_number:
744 /* modes of a,b are equal, so result has mode of a as this might be the character */
745 sc_add(a->value, b->value);
746 /* FIXME: Check for overflow */
747 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
749 case irms_float_number:
750 /* FIXME: Overflow/Underflow/transition to inf when mode < 80bit */
751 fc_add(a->value, b->value);
752 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
762 tarval *tarval_sub(tarval *a, tarval *b)
767 assert((a->mode == b->mode) || (get_mode_sort(a->mode) == irms_character && mode_is_int(b->mode)));
769 switch (get_mode_sort(a->mode))
772 case irms_int_number:
773 /* modes of a,b are equal, so result has mode of a as this might be the character */
774 sc_sub(a->value, b->value);
775 /* FIXME: check for overflow */
776 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
778 case irms_float_number:
779 /* FIXME: Overflow/Underflow/transition to inf when mode < 80bit */
780 fc_add(a->value, b->value);
781 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
791 tarval *tarval_mul(tarval *a, tarval *b)
796 assert((a->mode == b->mode) && mode_is_num(a->mode));
798 switch (get_mode_sort(a->mode))
800 case irms_int_number:
801 /* modes of a,b are equal */
802 sc_mul(a->value, b->value);
803 /* FIXME: check for overflow */
804 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
806 case irms_float_number:
807 /* FIXME: Overflow/Underflow/transition to inf when mode < 80bit */
808 fc_add(a->value, b->value);
809 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
817 * floating point division
819 tarval *tarval_quo(tarval *a, tarval *b)
824 assert((a->mode == b->mode) && mode_is_float(a->mode));
826 /* FIXME: Overflow/Underflow/transition to inf when mode < 80bit */
827 fc_div(a->value, b->value);
828 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
834 tarval *tarval_div(tarval *a, tarval *b)
839 assert((a->mode == b->mode) && mode_is_int(a->mode));
841 /* modes of a,b are equal */
842 sc_div(a->value, b->value);
843 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
849 tarval *tarval_mod(tarval *a, tarval *b)
854 assert((a->mode == b->mode) && mode_is_int(a->mode));
856 /* modes of a,b are equal */
857 sc_mod(a->value, b->value);
858 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
864 tarval *tarval_abs(tarval *a)
868 assert(mode_is_num(a->mode));
870 switch (get_mode_sort(a->mode))
872 case irms_int_number:
873 if (sc_comp(a->value, get_mode_null(a->mode)->value) == -1)
876 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
880 case irms_float_number:
892 tarval *tarval_and(tarval *a, tarval *b)
897 assert((a->mode == b->mode) && mode_is_int(a->mode));
899 sc_and(a->value, b->value);
900 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
906 tarval *tarval_or (tarval *a, tarval *b)
911 assert((a->mode == b->mode) && mode_is_int(a->mode));
913 sc_or(a->value, b->value);
914 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
918 * bitwise exclusive or (xor)
920 tarval *tarval_eor(tarval *a, tarval *b)
925 assert((a->mode == b->mode) && mode_is_int(a->mode));
927 sc_or(a->value, b->value);
928 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
934 tarval *tarval_shl(tarval *a, tarval *b)
939 assert(mode_is_int(a->mode) && mode_is_int(b->mode));
941 sc_shl(a->value, b->value, get_mode_size_bits(a->mode), mode_is_signed(a->mode));
942 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
946 * bitwise unsigned right shift
948 tarval *tarval_shr(tarval *a, tarval *b)
953 assert(mode_is_int(a->mode) && mode_is_int(b->mode));
955 sc_shr(a->value, b->value, get_mode_size_bits(a->mode), mode_is_signed(a->mode));
956 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
960 * bitwise signed right shift
962 tarval *tarval_shrs(tarval *a, tarval *b)
967 assert(mode_is_int(a->mode) && mode_is_int(b->mode));
969 sc_shrs(a->value, b->value, get_mode_size_bits(a->mode), mode_is_signed(a->mode));
970 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
976 tarval *tarval_rot(tarval *a, tarval *b)
981 assert(mode_is_int(a->mode) && mode_is_int(b->mode));
983 sc_rot(a->value, b->value, get_mode_size_bits(a->mode), mode_is_signed(a->mode));
984 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
991 int tarval_snprintf(char *buf, size_t len, tarval *tv)
993 static const tarval_mode_info default_info = { TVO_NATIVE, NULL, NULL };
997 const tarval_mode_info *mode_info;
998 const char *prefix, *suffix;
1002 mode_info = tv->mode->tv_priv;
1004 mode_info = &default_info;
1005 prefix = mode_info->mode_prefix ? mode_info->mode_prefix : "";
1006 suffix = mode_info->mode_suffix ? mode_info->mode_suffix : "";
1008 switch (get_mode_sort(tv->mode))
1010 case irms_int_number:
1011 case irms_character:
1012 switch (mode_info->mode_output) {
1015 str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_DEC);
1019 str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT);
1025 str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX);
1028 return snprintf(buf, len, "%s%s%s", prefix, str, suffix);
1030 case irms_float_number:
1031 return snprintf(buf, len, "%s%s%s", prefix, fc_print_dec(tv->value, tv_buf, sizeof(tv_buf)), suffix);
1033 case irms_reference:
1034 if (tv->value != NULL)
1035 if (tarval_is_entity(tv)) {
1036 if (get_entity_peculiarity((entity *)tv->value) == existent)
1037 return snprintf(buf, len, "%s%s%s", prefix, get_entity_ld_name((entity *)tv->value), suffix);
1039 if (mode_info->mode_output == TVO_NATIVE)
1040 return snprintf(buf, len, "NULL");
1042 return snprintf(buf, len, "0");
1046 if (size > tv->length) {
1047 memcpy(buf, tv->value, tv->length);
1048 buf[tv->length] = '\0';
1052 memcpy(buf, tv->value, size-1);
1058 return snprintf(buf, len, "void");
1060 case irms_internal_boolean:
1061 switch (mode_info->mode_output) {
1067 return snprintf(buf, len, "%s%c%s", prefix, (tv == tarval_b_true) ? '1' : '0', suffix);
1071 return snprintf(buf, len, "%s%s%s", prefix, (tv == tarval_b_true) ? "true" : "false", suffix);
1074 case irms_auxiliary:
1075 return snprintf(buf, len, "<BAD>");
1081 char *tarval_bitpattern(tarval *tv)
1087 * access to the bitpattern
1089 unsigned char tarval_sub_bits(tarval *tv, unsigned byte_ofs)
1091 switch (get_mode_sort(tv->mode)) {
1092 case irms_int_number:
1093 case irms_character:
1094 return sc_sub_bits(tv->value, tv->length, byte_ofs);
1096 case irms_float_number:
1097 return fc_sub_bits(tv->value, get_mode_size_bits(tv->mode), byte_ofs);
1105 * Specify the output options of one mode.
1107 * This functions stores the modinfo, so DO NOT DESTROY it.
1109 * Returns zero on success.
1111 int tarval_set_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinfo)
1115 mode->tv_priv = modeinfo;
1119 /* Identifying some tarvals ??? */
1120 /* Implemented in old tv.c as such:
1121 * return 0 for additive neutral,
1122 * 1 for multiplicative neutral,
1123 * -1 for bitwise-and neutral
1126 * Implemented for completeness */
1127 long tarval_classify(tarval *tv)
1130 if (!tv || tv == tarval_bad) return 2;
1132 if (tv == get_mode_null(tv->mode)) return 0;
1133 else if (tv == get_mode_one(tv->mode)) return 1;
1134 else if ((get_mode_sort(tv->mode) == irms_int_number)
1135 && (tv == new_tarval_from_long(-1, tv->mode))) return -1;
1141 * Initialization of the tarval module: called before init_mode()
1143 void init_tarval_1(void)
1146 /* initialize the sets holding the tarvals with a comparison function and
1147 * an initial size, which is the expected number of constants */
1148 tarvals = new_set(memcmp, TUNE_NCONSTANTS);
1149 values = new_set(memcmp, TUNE_NCONSTANTS);
1150 /* init with default precision */
1152 /* init_fltcalc(0); not yet*/
1156 * default mode_info for output as HEX
1158 static const tarval_mode_info hex_output = {
1165 * default mode_info for output as reference
1167 static const tarval_mode_info reference_output = {
1175 * Initialization of the tarval module: called after init_mode()
1177 void init_tarval_2(void)
1181 tarval_bad = (tarval*)malloc(sizeof(tarval));
1182 tarval_bad->mode = NULL;
1184 tarval_undefined = (tarval*)malloc(sizeof(tarval));
1185 tarval_undefined->mode = NULL;
1187 tarval_b_true = (tarval*)malloc(sizeof(tarval));
1188 tarval_b_true->mode = mode_b;
1190 tarval_b_false = (tarval*)malloc(sizeof(tarval));
1191 tarval_b_false->mode = mode_b;
1193 tarval_P_void = (tarval*)malloc(sizeof(tarval));
1194 tarval_P_void->mode = mode_P;
1197 * assign output modes that are compatible with the
1198 * old implementation: Hex output
1200 tarval_set_mode_output_option(mode_U, &hex_output);
1201 tarval_set_mode_output_option(mode_C, &hex_output);
1202 tarval_set_mode_output_option(mode_Bs, &hex_output);
1203 tarval_set_mode_output_option(mode_Bu, &hex_output);
1204 tarval_set_mode_output_option(mode_Hs, &hex_output);
1205 tarval_set_mode_output_option(mode_Hu, &hex_output);
1206 tarval_set_mode_output_option(mode_Hs, &hex_output);
1207 tarval_set_mode_output_option(mode_Hu, &hex_output);
1208 tarval_set_mode_output_option(mode_Is, &hex_output);
1209 tarval_set_mode_output_option(mode_Iu, &hex_output);
1210 tarval_set_mode_output_option(mode_Ls, &hex_output);
1211 tarval_set_mode_output_option(mode_Lu, &hex_output);
1212 tarval_set_mode_output_option(mode_P, &reference_output);
1215 /****************************************************************************
1217 ****************************************************************************/