1 /* Declarations for Target Values.
2 Copyright (C) 1995, 1996 Christian von Roques
4 Discussion of new interface, proposals by Prof. Waite:
6 > 1. You say that you plan to replace the tv module. That replacement is
7 > absolutely essential for an ANSI C translator: Section 6.1.3.2 of the
8 > standard says that the representation of an integer_constant depends
9 > upon its value as well as any suffixes that are attached to it. The
10 > possible Firm modes for such a constant are i, I, l, and L. The
11 > current tv module provides only one integer conversion routine, and
12 > that requires conversion by the client. Since the type of the value
13 > argument is long, this may preclude the representation of an unsigned
16 > There is a similar problem with floating constants. Floating
17 > constants can be suffixed in C, and the mode depends upon the suffix.
18 > It can indicate that the constant is of type long double, which your
19 > current tv module is incapable of representing.
21 > Your tv module interface accepts two kinds of information: modes and
22 > values. Values obtained from the program text might be uninterpreted
23 > strings, strings interpreted as integers, and strings interpreted as
24 > reals. Values provided by the compiler are usually integers. Modes are
25 > always Firm modes. It seems to me that the tv module should provide
26 > tarval* constructors for three of the four kinds of values. Each of these
27 > constructors should have an ir_mode parameter and one or more parameters
28 > appropriate for the kind of value. As is currently the case, one
29 > constructor should be provided for both compiler-generated integers and
30 > source strings interpreted as integers. (This avoids problems of
31 > different conversion radices -- the client does the conversion.) For
32 > symmetry, the constructor for source strings interpreted as reals should
33 > accept a long double parameter and require the client to do the
45 #ifndef _TARVAL_TYPEDEF_
46 #define _TARVAL_TYPEDEF_
47 typedef struct tarval tarval;
51 #undef __need_size_t /* erroneously defined by 1.3.2's gmp.h */
53 /* how to represent target types on host */
54 typedef float tarval_f;
55 typedef double tarval_d;
56 typedef long tarval_chil;
57 typedef unsigned long tarval_CHIL;
58 typedef MP_INT tarval_Z;
60 /* if ent then xname is missing or mangled from ent,
61 else if xname then xname is a linker symbol that is not mangled
63 else this is tarval_p_void.
64 if this tarval describes a symbolic address of another tarval, tv points
71 unsigned char *p; /* may contain embedded 0, not 0-terminated */
74 typedef tarval_s tarval_B;
78 tarval_f f; /* float */
79 tarval_d d; /* double */
80 tarval_chil chil; /* signed integral */
81 tarval_CHIL CHIL; /* unsigned integral */
82 tarval_Z Z; /* universal int */
83 tarval_p p; /* pointer */
85 tarval_B B; /* universal bits */
86 tarval_s s; /* string */
91 extern tarval *tarval_bad;
92 extern tarval *tarval_b_false;
93 extern tarval *tarval_b_true;
94 extern tarval *tarval_d_NaN;
95 extern tarval *tarval_d_Inf;
96 extern tarval *tarval_p_void;
97 extern tarval *tarval_mode_null[];
98 extern tarval *tarval_mode_min[];
99 extern tarval *tarval_mode_max[];
101 void tarval_init_1 (void);
102 void tarval_init_2 (void);
104 /* Hash function on tarvals */
105 unsigned tarval_hash (tarval *);
107 /* ************************ Constructors for tarvals ************************ */
108 tarval *tarval_Z_from_str (const char *, size_t, int base);
109 tarval *tarval_B_from_str (const char *, size_t);
110 tarval *tarval_d_from_str (const char *, size_t);
111 tarval *tarval_s_from_str (const char *, size_t);
112 tarval *tarval_S_from_str (const char *, size_t);
113 tarval *tarval_from_long (ir_mode *, long);
114 tarval *tarval_p_from_str (const char *);
115 tarval *tarval_p_from_entity (entity *);
117 tarval *tarval_convert_to (tarval *, ir_mode *);
119 /* Building an irm_C, irm_s, irm_S or irm_B target value step by step. */
120 void tarval_start (void);
121 void tarval_append (const char *, size_t);
122 void tarval_append1 (char);
123 tarval *tarval_finish_as (ir_mode *);
124 tarval *tarval_cancel (void); /* returns tarval_bad */
127 /* The flags for projecting a comparison result */
129 irpn_False=0, /* false */
132 irpn_Le, /* less or equal */
133 irpn_Gt, /* greater */
134 irpn_Ge, /* greater of equal */
135 irpn_Lg, /* less or greater */
136 irpn_Leg, /* less, equal or greater = ordered */
137 irpn_Uo, /* unordered */
138 irpn_Ue, /* unordered or equal */
139 irpn_Ul, /* unordered or less */
140 irpn_Ule, /* unordered, less or equal */
141 irpn_Ug, /* unordered or greater */
142 irpn_Uge, /* unordered, greater or equal */
143 irpn_Ne, /* unordered, less or greater = not equal */
144 irpn_True, /* true */
145 irpn_notmask = irpn_Leg
148 /* ******************** Arithmethic operations on tarvals ******************** */
149 /* Compare a with b and return an ir_pncmp describing the relation
150 between a and b. This is either Uo, Lt, Eq, Gt, or False if a or b
151 are symbolic pointers which can not be compared at all. */
152 ir_pncmp tarval_comp (tarval *a, tarval *b);
154 tarval *tarval_neg (tarval *a);
155 tarval *tarval_add (tarval *, tarval *);
156 tarval *tarval_sub (tarval *, tarval *);
157 tarval *tarval_mul (tarval *, tarval *);
158 tarval *tarval_quo (tarval *, tarval *);
159 tarval *tarval_div (tarval *, tarval *);
160 tarval *tarval_mod (tarval *, tarval *);
161 tarval *tarval_and (tarval *, tarval *);
162 tarval *tarval_or (tarval *, tarval *);
163 tarval *tarval_eor (tarval *, tarval *);
164 tarval *tarval_shl (tarval *, tarval *);
165 tarval *tarval_shr (tarval *, tarval *);
167 /* Identifying some tarvals */
168 long tarval_classify (tarval *);
169 long tarval_ord (tarval *, int *fail);
172 int tarval_print (XP_PAR1, const xprintf_info *, XP_PARN); */
174 /* return a mode-specific value */
176 tarval_f tv_val_f (tarval *tv);
177 tarval_d tv_val_d (tarval *tv);
178 tarval_chil tv_val_chil (tarval *tv);
179 tarval_CHIL tv_val_CHIL (tarval *tv);
180 tarval_Z tv_val_Z (tarval *tv);
181 tarval_p tv_val_p (tarval *tv);
182 bool tv_val_b (tarval *tv);
183 tarval_B tv_val_B (tarval *tv);
184 tarval_s tv_val_s (tarval *tv);
187 #define TARVAL_VRFY(val) ((void)0)
189 #define TARVAL_VRFY(val) _tarval_vrfy ((val))
190 extern void _tarval_vrfy (const tarval *);
194 void tarval_stats (void);
196 #define tarval_stats() ((void)0)
199 ir_mode *get_tv_mode (tarval *tv);