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 */
59 /****************************************************************************
60 * local definitions and macros
61 ****************************************************************************/
63 # define TARVAL_VERIFY(a) tarval_verify((a))
65 # define TARVAL_VERIFY(a) ((void)0)
68 #define INSERT_TARVAL(tv) ((tarval*)set_insert(tarvals, (tv), sizeof(tarval), hash_tv((tv))))
69 #define FIND_TARVAL(tv) ((tarval*)set_find(tarvals, (tv), sizeof(tarval), hash_tv((tv))))
71 #define INSERT_VALUE(val, size) (set_insert(values, (val), size, hash_val((val), size)))
72 #define FIND_VALUE(val, size) (set_find(values, (val), size, hash_val((val), size)))
74 #define fail_verify(a) _fail_verify((a), __FILE__, __LINE__)
76 static long long count = 0;
77 # define ANNOUNCE() printf(__FILE__": call no. %lld (%s)\n", count++, __FUNCTION__);
79 # define ANNOUNCE() ((void)0)
81 /****************************************************************************
83 ****************************************************************************/
84 static struct set *tarvals; /* container for tarval structs */
85 static struct set *values; /* container for values */
87 /****************************************************************************
89 ****************************************************************************/
91 static int hash_val(const void *value, unsigned int length);
92 static int hash_tv(tarval *tv);
93 static void _fail_verify(tarval *tv, const char* file, int line)
95 /* print a memory image of the tarval and throw an assertion */
97 printf("%s:%d: Invalid tarval:\n mode: %s\n value: [%p]\n", file, line, get_mode_name(tv->mode), tv->value);
99 printf("%s:%d: Invalid tarval (null)", file, line);
103 static void tarval_verify(tarval *tv)
109 if ((tv == tarval_bad) || (tv == tarval_undefined)) return;
110 if ((tv == tarval_b_true) || (tv == tarval_b_false)) return;
112 if (!FIND_TARVAL(tv)) fail_verify(tv);
113 if (tv->length > 0 && !FIND_VALUE(tv->value, tv->length)) fail_verify(tv);
119 static int hash_tv(tarval *tv)
121 return ((unsigned int)tv->value ^ (unsigned int)tv->mode) + tv->length;
124 static int hash_val(const void *value, unsigned int length)
127 unsigned int hash = 0;
129 /* scramble the byte - array */
130 for (i = 0; i < length; i++)
132 hash += (hash << 5) ^ (hash >> 27) ^ ((char*)value)[i];
133 hash += (hash << 11) ^ (hash >> 17);
139 /* finds tarval with value/mode or creates new tarval */
140 static tarval *get_tarval(const void *value, int length, ir_mode *mode)
147 /* if there already is such a value, it is returned, else value
148 * is copied into the set */
149 tv.value = INSERT_VALUE(value, length);
153 /* if there is such a tarval, it is returned, else tv is copied
155 return (tarval *)INSERT_TARVAL(&tv);
159 * Returns non-zero if a tarval overflows.
161 * @todo Implementation did not work on all modes
163 static int overflows(tarval *tv)
165 switch (get_mode_sort(tv->mode))
168 case irms_int_number:
169 if (sc_comp(tv->value, get_mode_max(tv->mode)->value) == 1) return 1;
170 if (sc_comp(tv->value, get_mode_min(tv->mode)->value) == -1) return 1;
173 case irms_float_number:
174 if (fc_comp(tv->value, get_mode_max(tv->mode)->value) == 1) return 1;
175 if (fc_comp(tv->value, get_mode_min(tv->mode)->value) == -1) return 1;
185 /****************************************************************************
186 * public variables declared in tv.h
187 ****************************************************************************/
189 tarval *tarval_undefined;
190 tarval *tarval_b_false;
191 tarval *tarval_b_true;
192 tarval *tarval_P_void;
194 /****************************************************************************
195 * public functions declared in tv.h
196 ****************************************************************************/
198 * Constructors =============================================================
200 tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode)
207 switch (get_mode_sort(mode))
213 case irms_internal_boolean:
214 /* match tTrRuUeE/fFaAlLsSeE */
215 if (strcasecmp(str, "true")) return tarval_b_true;
216 else if (strcasecmp(str, "false")) return tarval_b_true;
218 return atoi(str) ? tarval_b_true : tarval_b_false;
220 case irms_float_number:
221 fc_val_from_str(str, len);
222 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
224 case irms_int_number:
226 sc_val_from_str(str, len);
227 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
230 return get_tarval(str, len, mode);
233 assert(0); /* can't be reached, can it? */
238 int tarval_is_str(tarval *tv)
243 return ((get_mode_sort(tv->mode) == reference) && (tv->value != NULL) && (tv->length > 0));
245 char *tarval_to_str(tarval *tv)
248 assert(tarval_is_str(tv));
249 return (char *)tv->value;
253 tarval *new_tarval_from_long(long l, ir_mode *mode)
256 assert(mode && !(get_mode_sort(mode) == irms_auxiliary));
258 switch(get_mode_sort(mode))
260 case irms_internal_boolean:
261 /* XXX C-Semantics ! */
262 return l ? tarval_b_true : tarval_b_false ;
264 case irms_int_number:
267 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
269 case irms_float_number:
270 return new_tarval_from_double((long double)l, mode);
273 return l ? tarval_bad : get_tarval(NULL, 0, mode); /* null pointer or tarval_bad */
281 int tarval_is_long(tarval *tv)
284 return ((get_mode_sort(tv->mode) == irms_int_number) || (get_mode_sort(tv->mode) == irms_character));
287 /* this might overflow the machine's long, so use only with small values */
288 long tarval_to_long(tarval* tv)
291 assert(tv && get_mode_sort(tv->mode) == irms_int_number);
293 return sc_val_to_long(tv->value); /* might overflow */
296 tarval *new_tarval_from_double(long double d, ir_mode *mode)
299 assert(mode && (get_mode_sort(mode) == irms_float_number));
301 fc_val_from_float(d);
302 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
305 int tarval_is_double(tarval *tv)
310 return (get_mode_sort(tv->mode) == irms_float_number);
313 long double tarval_to_double(tarval *tv)
316 assert(tarval_is_double(tv));
318 return fc_val_to_float(tv->value);
321 /* The tarval represents the address of the entity. As the address must
322 be constant the entity must have as owner the global type. */
323 tarval *new_tarval_from_entity (entity *ent, ir_mode *mode)
327 assert(mode && (get_mode_sort(mode) == irms_reference));
329 return get_tarval((void *)ent, 0, mode);
331 int tarval_is_entity(tarval *tv)
335 /* tv->value == NULL means dereferencing a null pointer */
336 return ((get_mode_sort(tv->mode) == irms_reference) && (tv->value != NULL) && (tv->length == 0));
339 entity *tarval_to_entity(tarval *tv)
344 if (tarval_is_entity(tv))
345 return (entity *)tv->value;
347 assert(0 && "tarval did not represent an entity");
352 void free_tarval_entity(entity *ent) {
353 /* There can be a tarval referencing this entity. Even if the
354 tarval is not used by the code any more, it can still reference
355 the entity as tarvals live indepently of the entity referenced.
356 Further the tarval is hashed into a set. If a hash function
357 evaluation happens to collide with this tarval, we will vrfy that
358 it contains a proper entity and we will crash if the entity is
361 Unluckily, tarvals can neither be changed nor deleted, and to find
362 one, all existing reference modes have to be tried -> a facility
363 to retrieve all modes of a kind is needed. */
368 * Access routines for tarval fields ========================================
370 ir_mode *get_tarval_mode (tarval *tv) /* get the mode of the tarval */
378 * Special value query functions ============================================
380 * These functions calculate and return a tarval representing the requested
382 * The functions get_mode_{Max,Min,...} return tarvals retrieved from these
383 * functions, but these are stored on initialization of the irmode module and
384 * therefore the irmode functions should be prefered to the functions below.
387 tarval *get_tarval_bad(void)
392 tarval *get_tarval_undefined(void)
395 return tarval_undefined;
397 tarval *get_tarval_b_false(void)
400 return tarval_b_false;
402 tarval *get_tarval_b_true(void)
405 return tarval_b_true;
407 tarval *get_tarval_P_void(void)
410 return tarval_P_void;
413 tarval *get_tarval_max(ir_mode *mode)
418 switch(get_mode_sort(mode))
425 case irms_internal_boolean:
426 return tarval_b_true;
428 case irms_float_number:
429 fc_get_max(get_mode_size_bits(mode));
430 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
432 case irms_int_number:
434 sc_max_from_bits(get_mode_size_bits(mode), mode_is_signed(mode));
435 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
440 tarval *get_tarval_min(ir_mode *mode)
445 switch(get_mode_sort(mode))
452 case irms_internal_boolean:
453 return tarval_b_false;
455 case irms_float_number:
456 fc_get_min(get_mode_size_bits(mode));
457 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
459 case irms_int_number:
461 sc_min_from_bits(get_mode_size_bits(mode), mode_is_signed(mode));
462 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), mode);
467 tarval *get_tarval_null(ir_mode *mode)
472 switch(get_mode_sort(mode))
475 case irms_internal_boolean:
479 case irms_float_number:
480 return new_tarval_from_double(0.0, mode);
482 case irms_int_number:
484 return new_tarval_from_long(0l, mode);
487 return tarval_P_void;
492 tarval *get_tarval_one(ir_mode *mode)
497 switch(get_mode_sort(mode))
500 case irms_internal_boolean:
505 case irms_float_number:
506 return new_tarval_from_double(1.0, mode);
508 case irms_int_number:
510 return new_tarval_from_long(1l, mode);
516 tarval *get_tarval_nan(ir_mode *mode)
521 if (get_mode_sort(mode) == irms_float_number) {
523 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
526 assert(0 && "tarval is not floating point");
531 tarval *get_tarval_inf(ir_mode *mode)
536 if (get_mode_sort(mode) == irms_float_number) {
538 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), mode);
541 assert(0 && "tarval is not floating point");
547 * Arithmethic operations on tarvals ========================================
551 * test if negative number, 1 means 'yes'
553 int tarval_is_negative(tarval *a)
558 switch (get_mode_sort(a->mode))
560 case irms_int_number:
561 if (!mode_is_signed(a->mode)) return 0;
563 return sc_comp(a->value, get_mode_null(a->mode)->value) == -1 ? 1 : 0;
565 case irms_float_number:
566 return fc_comp(a->value, get_mode_null(a->mode)->value) == -1 ? 1 : 0;
569 assert(0 && "not implemented");
577 pnc_number tarval_cmp(tarval *a, tarval *b)
583 if (a == tarval_bad || b == tarval_bad) assert(0 && "Comparison with tarval_bad");
584 if (a == tarval_undefined || b == tarval_undefined) return False;
585 if (a == b) return Eq;
586 if (get_tarval_mode(a) != get_tarval_mode(b)) return Uo;
588 /* Here the two tarvals are unequal and of the same mode */
589 switch (get_mode_sort(a->mode))
594 case irms_float_number:
595 return (fc_comp(a->value, b->value)==1)?(Gt):(Lt);
597 case irms_int_number:
599 return (sc_comp(a->value, b->value)==1)?(Gt):(Lt);
601 case irms_internal_boolean:
602 return (a == tarval_b_true)?(Gt):(Lt);
611 * convert to other mode
613 tarval *tarval_convert_to(tarval *src, ir_mode *m)
621 if (src->mode == m) return src;
623 switch (get_mode_sort(src->mode))
628 case irms_float_number:
631 case irms_int_number:
632 switch (get_mode_sort(m))
634 case irms_int_number:
637 tv.length = src->length;
638 tv.value = src->value;
643 return INSERT_TARVAL(&tv);
645 case irms_internal_boolean:
646 /* XXX C semantics */
647 if (src == get_mode_null(src->mode)) return tarval_b_false;
648 else return tarval_b_true;
655 case irms_internal_boolean:
656 switch (get_mode_sort(m))
658 case irms_int_number:
659 if (src == tarval_b_true) return get_mode_one(m);
660 else return get_mode_null(m);
679 tarval *tarval_neg(tarval *a)
683 assert(mode_is_num(a->mode)); /* negation only for numerical values */
684 assert(mode_is_signed(a->mode)); /* negation is difficult without negative numbers, isn't it */
686 switch (get_mode_sort(a->mode))
688 case irms_int_number:
690 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
692 case irms_float_number:
694 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
704 tarval *tarval_add(tarval *a, tarval *b)
709 assert((a->mode == b->mode) || (get_mode_sort(a->mode) == irms_character && mode_is_int(b->mode)));
711 switch (get_mode_sort(a->mode))
714 case irms_int_number:
715 /* modes of a,b are equal, so result has mode of a as this might be the character */
716 sc_add(a->value, b->value);
717 /* FIXME: Check for overflow */
718 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
720 case irms_float_number:
721 /* FIXME: Overflow/Underflow/transition to inf when mode < 80bit */
722 fc_add(a->value, b->value);
723 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
733 tarval *tarval_sub(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_sub(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_mul(tarval *a, tarval *b)
767 assert((a->mode == b->mode) && mode_is_num(a->mode));
769 switch (get_mode_sort(a->mode))
771 case irms_int_number:
772 /* modes of a,b are equal */
773 sc_mul(a->value, b->value);
774 /* FIXME: check for overflow */
775 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
777 case irms_float_number:
778 /* FIXME: Overflow/Underflow/transition to inf when mode < 80bit */
779 fc_add(a->value, b->value);
780 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
788 * floating point division
790 tarval *tarval_quo(tarval *a, tarval *b)
795 assert((a->mode == b->mode) && mode_is_float(a->mode));
797 /* FIXME: Overflow/Underflow/transition to inf when mode < 80bit */
798 fc_div(a->value, b->value);
799 return get_tarval(fc_get_buffer(), fc_get_buffer_length(), a->mode);
805 tarval *tarval_div(tarval *a, tarval *b)
810 assert((a->mode == b->mode) && mode_is_int(a->mode));
812 /* modes of a,b are equal */
813 sc_div(a->value, b->value);
814 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
820 tarval *tarval_mod(tarval *a, tarval *b)
825 assert((a->mode == b->mode) && mode_is_int(a->mode));
827 /* modes of a,b are equal */
828 sc_mod(a->value, b->value);
829 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
835 tarval *tarval_abs(tarval *a)
839 assert(mode_is_num(a->mode));
841 switch (get_mode_sort(a->mode))
843 case irms_int_number:
844 if (sc_comp(a->value, get_mode_null(a->mode)->value) == -1)
847 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
851 case irms_float_number:
863 tarval *tarval_and(tarval *a, tarval *b)
868 assert((a->mode == b->mode) && mode_is_int(a->mode));
870 sc_and(a->value, b->value);
871 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
877 tarval *tarval_or (tarval *a, tarval *b)
882 assert((a->mode == b->mode) && mode_is_int(a->mode));
884 sc_or(a->value, b->value);
885 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
889 * bitwise exclusive or (xor)
891 tarval *tarval_eor(tarval *a, tarval *b)
896 assert((a->mode == b->mode) && mode_is_int(a->mode));
898 sc_or(a->value, b->value);
899 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
905 tarval *tarval_shl(tarval *a, tarval *b)
910 assert(mode_is_int(a->mode) && mode_is_int(b->mode));
912 sc_shl(a->value, b->value, get_mode_size_bits(a->mode), mode_is_signed(a->mode));
913 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
917 * bitwise unsigned right shift
919 tarval *tarval_shr(tarval *a, tarval *b)
924 assert(mode_is_int(a->mode) && mode_is_int(b->mode));
926 sc_shr(a->value, b->value, get_mode_size_bits(a->mode), mode_is_signed(a->mode));
927 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
931 * bitwise signed right shift
933 tarval *tarval_shrs(tarval *a, tarval *b)
938 assert(mode_is_int(a->mode) && mode_is_int(b->mode));
940 sc_shrs(a->value, b->value, get_mode_size_bits(a->mode), mode_is_signed(a->mode));
941 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
947 tarval *tarval_rot(tarval *a, tarval *b)
952 assert(mode_is_int(a->mode) && mode_is_int(b->mode));
954 sc_rot(a->value, b->value, get_mode_size_bits(a->mode), mode_is_signed(a->mode));
955 return get_tarval(sc_get_buffer(), sc_get_buffer_length(), a->mode);
961 int tarval_print(XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN)
963 static const tarval_mode_info default_info = { TVO_NATIVE, NULL, NULL };
968 const tarval_mode_info *mode_info;
969 const char *prefix, *suffix;
973 tv = XP_GETARG(tarval *, 0);
974 mode_info = tv->mode->tv_priv;
976 mode_info = &default_info;
977 prefix = mode_info->mode_prefix ? mode_info->mode_prefix : "";
978 suffix = mode_info->mode_suffix ? mode_info->mode_suffix : "";
980 switch (get_mode_sort(tv->mode))
982 case irms_int_number:
984 switch (mode_info->mode_output) {
987 str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_DEC);
991 str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_OCT);
997 str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX);
1000 return XPF3R("%s%s%s", prefix, str, suffix);
1002 case irms_float_number:
1003 return XPF3R("%s%s%s", prefix, fc_print_dec(tv->value, buf, sizeof(buf)), suffix);
1005 case irms_reference:
1006 if (tv->value != NULL)
1007 if (tarval_is_entity(tv))
1008 if (get_entity_peculiarity((entity *)tv->value) == existent)
1009 return XPF1R("&(%I)", get_entity_ld_ident((entity *)tv->value));
1011 return XPSR("NULL");
1013 return XPMR((char*)tv->value, tv->length);
1015 return XPSR("void");
1017 case irms_internal_boolean:
1018 switch (mode_info->mode_output) {
1024 return XPF3R("%s%c%s", prefix, (tv == tarval_b_true) ? '1' : '0', suffix);
1028 return XPF3R("%s%s%s", prefix, (tv == tarval_b_true) ? "true" : "false", suffix);
1031 case irms_auxiliary:
1032 return XPSR("<BAD>");
1038 int tarval_xprintf(printf_func print_func, void * out , tarval *tv)
1043 switch (get_mode_sort(tv->mode))
1045 case irms_int_number:
1046 case irms_character:
1047 str = sc_print(tv->value, get_mode_size_bits(tv->mode), SC_HEX);
1049 return print_func(out,"0x%s", str);
1051 case irms_float_number:
1052 return print_func(out,"%s", fc_print_dec(tv->value, buf, sizeof(buf)));
1054 case irms_reference:
1055 if (tv->value != NULL)
1056 if (tarval_is_entity(tv))
1057 if (get_entity_peculiarity((entity *)tv->value) == existent)
1058 return print_func(out,"&(%s)", id_to_str(get_entity_ld_ident((entity *)tv->value)));
1060 return print_func(out,"NULL",0);
1062 return print_func(out,(char*)tv->value, tv->length);
1064 return print_func(out,"void",0);
1066 case irms_internal_boolean:
1067 if (tv == tarval_b_true) return print_func(out,"true",0);
1068 else return print_func(out,"false",0);
1070 case irms_auxiliary:
1071 return print_func(out,"<BAD>",0);
1077 char *tarval_bitpattern(tarval *tv)
1083 * access to the bitpattern
1085 unsigned char tarval_sub_bits(tarval *tv, unsigned byte_ofs)
1087 switch (get_mode_sort(tv->mode)) {
1088 case irms_int_number:
1089 case irms_character:
1090 return sc_sub_bits(tv->value, tv->length, byte_ofs);
1092 case irms_float_number:
1093 return fc_sub_bits(tv->value, get_mode_size_bits(tv->mode), byte_ofs);
1101 * Specify the output options of one mode.
1103 * This functions stores the modinfo, so DO NOT DESTROY it.
1105 * Returns zero on success.
1107 int tarval_set_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinfo)
1111 mode->tv_priv = modeinfo;
1115 /* Identifying some tarvals ??? */
1116 /* Implemented in old tv.c as such:
1117 * return 0 for additive neutral,
1118 * 1 for multiplicative neutral,
1119 * -1 for bitwise-and neutral
1122 * Implemented for completeness */
1123 long tarval_classify(tarval *tv)
1126 if (!tv || tv == tarval_bad) return 2;
1128 if (tv == get_mode_null(tv->mode)) return 0;
1129 else if (tv == get_mode_one(tv->mode)) return 1;
1130 else if ((get_mode_sort(tv->mode) == irms_int_number)
1131 && (tv == new_tarval_from_long(-1, tv->mode))) return -1;
1137 * Initialization of the tarval module: called before init_mode()
1139 void init_tarval_1(void)
1142 /* initialize the sets holding the tarvals with a comparison function and
1143 * an initial size, which is the expected number of constants */
1144 tarvals = new_set(memcmp, TUNE_NCONSTANTS);
1145 values = new_set(memcmp, TUNE_NCONSTANTS);
1146 /* init with default precision */
1148 /* init_fltcalc(0); not yet*/
1152 * default mode_info for output as HEX
1154 static const tarval_mode_info hex_output = {
1161 * Initialization of the tarval module: called after init_mode()
1163 void init_tarval_2(void)
1167 tarval_bad = (tarval*)malloc(sizeof(tarval));
1168 tarval_bad->mode = NULL;
1170 tarval_undefined = (tarval*)malloc(sizeof(tarval));
1171 tarval_undefined->mode = NULL;
1173 tarval_b_true = (tarval*)malloc(sizeof(tarval));
1174 tarval_b_true->mode = mode_b;
1176 tarval_b_false = (tarval*)malloc(sizeof(tarval));
1177 tarval_b_false->mode = mode_b;
1179 tarval_P_void = (tarval*)malloc(sizeof(tarval));
1180 tarval_P_void->mode = mode_P;
1183 * assign output modes that are compatible with the
1184 * old implementation: Hex output
1186 tarval_set_mode_output_option(mode_U, &hex_output);
1187 tarval_set_mode_output_option(mode_C, &hex_output);
1188 tarval_set_mode_output_option(mode_Bs, &hex_output);
1189 tarval_set_mode_output_option(mode_Bu, &hex_output);
1190 tarval_set_mode_output_option(mode_Hs, &hex_output);
1191 tarval_set_mode_output_option(mode_Hu, &hex_output);
1192 tarval_set_mode_output_option(mode_Hs, &hex_output);
1193 tarval_set_mode_output_option(mode_Hu, &hex_output);
1194 tarval_set_mode_output_option(mode_Is, &hex_output);
1195 tarval_set_mode_output_option(mode_Iu, &hex_output);
1196 tarval_set_mode_output_option(mode_Ls, &hex_output);
1197 tarval_set_mode_output_option(mode_Lu, &hex_output);
1200 /****************************************************************************
1202 ****************************************************************************/