-#include "gmp.h"
-#undef __need_size_t /* erroneously defined by 1.3.2's gmp.h */
-
-/* how to represent target types on host */
-typedef float tarval_f;
-typedef double tarval_d;
-typedef long tarval_chil;
-typedef unsigned long tarval_CHIL;
-typedef MP_INT tarval_Z;
-typedef struct {
- /* if ent then xname is missing or mangled from ent,
- else if xname then xname is a linker symbol that is not mangled
- from an entity,
- else this is tarval_p_void.
- if this tarval describes a symbolic address of another tarval, tv points
- to this val */
- const char *xname;
- entity *ent;
- tarval *tv;
-} tarval_p;
-typedef struct {
- unsigned char *p; /* may contain embedded 0, not 0-terminated */
- size_t n;
-} tarval_s;
-typedef tarval_s tarval_B;
-
-struct tarval {
- union {
- tarval_f f; /* float */
- tarval_d d; /* double */
- tarval_chil chil; /* signed integral */
- tarval_CHIL CHIL; /* unsigned integral */
- tarval_Z Z; /* universal int */
- tarval_p p; /* pointer */
- bool b; /* boolean */
- tarval_B B; /* universal bits */
- tarval_s s; /* string */
- } u;
- ir_mode *mode;
-};
+/* ************************ Constructors for tarvals ************************ */
+
+/**
+ * Constructor function for new tarvals.
+ *
+ * @param str The string representing the target value
+ * @param len The length of the string
+ * @param 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:
+ * - 0(x|X)[0-9a-fA-F]+ (hexadecimal representation)
+ * - 0[0-7]* (octal representation)
+ * - (+|-)?[1-9][0-9]* (decimal representation)
+ *
+ * if mode if float_number:
+ * - (+|-)?(decimal int) (. (decimal int))? ((e|E)(+|-)?(decimal int))?
+ *
+ * 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
+ *
+ * @return
+ * A tarval of proper type representing the requested value is returned.
+ * Tarvals are unique, so for any value/mode pair at most one tarval will
+ * exist, which will be returned upon further requests with an identical
+ * value/mode pair.
+ *
+ * @note
+ * If the string is not representable in the given mode an assertion is
+ * thrown in assert build.
+ *
+ * @sa
+ * irmode.h for predefined modes
+ * new_tarval_from_long()
+ * new_tarval_from_double()
+ */
+tarval *new_tarval_from_str(const char *str, size_t len, ir_mode *mode);
+
+/**
+ * Constructor function for new tarvals
+ *
+ * @param l The long representing the value
+ * @param 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.
+ *
+ * @return
+ * A tarval of proper type representing the requested value is returned.
+ * Tarvals are unique, so for any value/mode pair at most one tarval will
+ * exist, which will be returned upon further requests with an identical
+ * value/mode pair.
+ *
+ * @note
+ * If the long is not representable in the given mode an assertion is
+ * thrown in assert build.
+ *
+ * @sa
+ * irmode.h for predefined modes
+ * new_tarval_from_str()
+ * new_tarval_from_double()
+ *
+ */
+tarval *new_tarval_from_long(long l, ir_mode *mode);
+
+/**
+ * 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()...)
+ */
+long tarval_to_long(tarval *tv);
+
+/**
+ * This validates if tarval_to_long() will return a satisfying
+ * result. I.e. if tv is an int_number and between min, max
+ * of long int (signed!)
+ */
+int tarval_is_long(tarval *tv);
+
+/**
+ * Constructor function for new tarvals.
+ *
+ * @param d The long double representing the value
+ * @param 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.
+ *
+ * @return
+ * A tarval of proper type representing the requested value is returned.
+ * Tarvals are unique, so for any value/mode pair at most one tarval will
+ * exist, which will be returned upon further requests with an identical
+ * value/mode pair.
+ *
+ * @note
+ * If the long double is not representable in the given mode an assertion
+ * is thrown. This will happen for any mode not of sort float_number.
+ *
+ * @sa
+ * irmode.h for predefined values
+ * new_tarval_from_str()
+ * new_tarval_from_long()
+ */
+tarval *new_tarval_from_double(long double d, ir_mode *mode);