# include <config.h>
#endif
+# include "xprintf.h"
#include <assert.h>
#include <limits.h>
#include <math.h>
#include "obst.h"
#include "ieee754.h"
#include "tune.h"
-#include "ident.h"
-#include "tv.h"
+#include "ident_t.h"
+#include "tv_t.h"
+#include "entity_t.h"
+#include "irmode.h"
static struct obstack tv_obst; /* obstack for all the target values */
static pset *tarvals; /* pset containing pointers to _all_ tarvals */
static inline bool
chil_overflow (tarval_chil chil, ir_mode *mode)
{
- assert (is_chilCHIL(mode->code));
- return (mode->min && mode->max /* only valid after firm initialization */
- && (chil < tv_val_chil (mode->min) || tv_val_chil (mode->max) < chil));
+ assert (is_chilCHIL(get_mode_modecode(mode)));
+ return (get_mode_min(mode) && get_mode_max(mode) /* only valid after firm initialization */
+ && (chil < tv_val_chil (get_mode_min(mode))
+ || tv_val_chil (get_mode_max(mode)) < chil));
}
static inline bool
CHIL_overflow (tarval_CHIL CHIL, ir_mode *mode)
{
- assert (is_chilCHIL(mode->code));
- return (mode->max /* only valid after firm initialization */
- && tv_val_CHIL (mode->max) < CHIL);
+ assert (is_chilCHIL(get_mode_modecode(mode)));
+ return (get_mode_max(mode) /* only valid after firm initialization */
+ && tv_val_CHIL (get_mode_max(mode)) < CHIL);
}
_tarval_vrfy (const tarval *val)
{
assert (val);
- switch (val->mode->code) {
+ switch (get_mode_modecode(val->mode)) {
/* floating */
case irm_f:
case irm_d:
TARVAL_VRFY (b);
if (a == b) return 0;
- if (a->mode - b->mode) return a->mode - b->mode;
+ if ((void *)a->mode - (void *)b->mode)
+ return (void *)a->mode - (void *)b->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f:
return memcmp (&a->u.f, &b->u.f, sizeof (a->u.f));
{
unsigned h;
- h = tv->mode->code * 0x421u;
- switch (tv->mode->code) {
+ h = get_mode_modecode(tv->mode) * 0x421u;
+ switch (get_mode_modecode(tv->mode)) {
case irm_T:
h = 0x94b527ce; break;
case irm_f:
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_T;
- tv->lab = 0;
tarval_bad = tarval_identify (tv);
tarval_b_false = tarval_from_long (mode_b, 0);
/* IsInf <-> exponent == 0x7ff && ! (bits | fraction_low) */
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_d;
- tv->lab = 0;
x.ieee.negative = 0;
x.ieee.exponent = 0x7ff;
x.ieee.mantissa0 = 0;
/* IsNaN <-> exponent==0x7ff && (qnan_bit | bits | fraction_low) */
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_d;
- tv->lab = 0;
x.ieee_nan.negative = 0;
x.ieee_nan.exponent = 0x7ff;
x.ieee_nan.quiet_nan = 1; /* @@@ quiet or signalling? */
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_p;
- tv->lab = 0;
tv->u.p.xname = NULL;
tv->u.p.ent = NULL;
tv->u.p.tv = NULL;
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_Z;
- tv->lab = 0;
if (mpz_init_set_str (&tv->u.Z, buf, base)) assert (0);
return tarval_identify (tv);
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_B;
- tv->lab = 0;
assert (s[0] == '0');
switch (s[1]) {
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_d;
- tv->lab = 0;
tv->u.d = strtod (buf, &eptr);
assert (eptr == buf+strlen(buf));
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_s;
- tv->lab = 0;
tv->u.s.n = len;
tv->u.s.p = obstack_copy (&tv_obst, s, len);
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_S;
- tv->lab = 0;
tv->u.s.n = len;
tv->u.s.p = obstack_copy (&tv_obst, s, len);
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = m;
- tv->lab = 0;
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
/* floating */
case irm_f:
tv->u.f = val; break;
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_p;
- tv->lab = 0;
tv->u.p.xname = obstack_copy0 (&tv_obst, xname, strlen (xname));
tv->u.p.ent = NULL;
tv->u.p.tv = NULL;
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_p;
- tv->lab = 0;
tv->u.p.xname = NULL;
tv->u.p.ent = ent;
tv->u.p.tv = NULL;
tv = obstack_finish (&tv_obst);
p = (unsigned char *)tv + sizeof (tarval);
tv->mode = m;
- tv->lab = 0;
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_C:
tv->u.CHIL = ch;
break;
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = m;
- tv->lab = 0;
- switch (src->mode->code) {
+ switch (get_mode_modecode(src->mode)) {
case irm_d:
if (m != mode_f) goto fail;
break;
case irm_Z:
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_C: case irm_H: case irm_I: case irm_L:
if (mpz_cmp_si (&src->u.Z, 0) < 0) goto fail;
break;
case irm_c: case irm_h: case irm_i: case irm_l:
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_c: case irm_h: case irm_i: case irm_l:
tv->u.chil = src->u.chil;
if (chil_overflow (tv->u.chil, m)) goto fail;
}
case irm_C: case irm_H: case irm_I: case irm_L:
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_c: case irm_h: case irm_i: case irm_l:
tv->u.chil = src->u.CHIL;
if (chil_overflow (tv->u.chil, m)) goto fail;
break;
case irm_b:
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_c: case irm_h: case irm_i: case irm_l:
tv->u.chil = src->u.b;
break;
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = -a->u.f; break;
case irm_d: tv->u.d = -a->u.d; break;
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- tv->u.CHIL = -a->u.CHIL & tv_val_CHIL (a->mode->max);
+ tv->u.CHIL = -a->u.CHIL & tv_val_CHIL (get_mode_max(a->mode));
break;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
assert (a->mode == b->mode);
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: return ( a->u.f == b->u.f ? irpn_Eq
: a->u.f > b->u.f ? irpn_Gt
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = a->u.f + b->u.f; break; /* @@@ overflow etc */
case irm_d: tv->u.d = a->u.d + b->u.d; break; /* @@@ dto. */
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- tv->u.CHIL = (a->u.CHIL + b->u.CHIL) & tv_val_CHIL (a->mode->max);
+ tv->u.CHIL = (a->u.CHIL + b->u.CHIL) & tv_val_CHIL (get_mode_max(a->mode));
break;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = a->u.f - b->u.f; break; /* @@@ overflow etc */
case irm_d: tv->u.d = a->u.d - b->u.d; break; /* @@@ dto. */
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- tv->u.CHIL = (a->u.CHIL - b->u.CHIL) & tv_val_CHIL (a->mode->max);
+ tv->u.CHIL = (a->u.CHIL - b->u.CHIL) & tv_val_CHIL (get_mode_max(a->mode));
break;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = a->u.f * b->u.f; break; /* @@@ overflow etc */
case irm_d: tv->u.d = a->u.d * b->u.d; break; /* @@@ dto. */
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- tv->u.CHIL = (a->u.CHIL * b->u.CHIL) & tv_val_CHIL (a->mode->max);
+ tv->u.CHIL = (a->u.CHIL * b->u.CHIL) & tv_val_CHIL (get_mode_max(a->mode));
break;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
TARVAL_VRFY (a); TARVAL_VRFY (b);
assert (a->mode == b->mode);
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f:
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_f;
- tv->lab = 0;
tv->u.f = a->u.f / b->u.f; /* @@@ overflow etc */
break;
case irm_d:
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = mode_d;
- tv->lab = 0;
tv->u.d = a->u.d / b->u.d; /* @@@ overflow etc */
break;
default:
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = floor (a->u.f / b->u.f); break; /* @@@ overflow etc */
case irm_d: tv->u.d = floor (a->u.d / b->u.d); break; /* @@@ dto. */
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
if ( !b->u.chil
- || ((b->u.chil == -1) && (a->u.chil == tv_val_chil (a->mode->max) ))) {
+ || ((b->u.chil == -1) && (a->u.chil == tv_val_chil (get_mode_max(a->mode)) ))) {
fail:
obstack_free (&tv_obst, tv);
return NULL;
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = fmod (a->u.f, b->u.f); break; /* @@@ overflow etc */
case irm_d: tv->u.d = fmod (a->u.d, b->u.d); break; /* @@@ dto */
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL & b->u.CHIL; break;
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL | b->u.CHIL; break;
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL ^ b->u.CHIL; break;
shift = tarval_ord (b, &b_is_huge);
if ( b_is_huge
|| (shift < 0)
- || ((shift >= mode_l->size*target_bits) && (a->mode != mode_Z))) {
+ || ((shift >= get_mode_size(mode_l)*target_bits) && (a->mode != mode_Z))) {
return NULL;
}
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL << shift;
shift = tarval_ord (b, &b_is_huge);
if ( b_is_huge
|| (shift < 0)
- || ((shift >= mode_l->size*target_bits) && (a->mode != mode_Z))) {
+ || ((shift >= get_mode_size(mode_l)*target_bits) && (a->mode != mode_Z))) {
return NULL;
}
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- tv->lab = 0;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL >> shift;
TARVAL_VRFY (tv);
- switch (tv->mode->code) {
+ switch (get_mode_modecode(tv->mode)) {
/* floating */
case irm_f: case irm_d:
return 2;
/* unsigned */
case irm_C:
- return (long)((tv->u.CHIL+1) & tv_val_CHIL (mode_C->max)) - 1;
+ return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_C))) - 1;
case irm_H:
- return (long)((tv->u.CHIL+1) & tv_val_CHIL (mode_H->max)) - 1;
+ return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_H))) - 1;
case irm_I:
- return (long)((tv->u.CHIL+1) & tv_val_CHIL (mode_I->max)) - 1;
+ return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_I))) - 1;
case irm_L:
- return (long)((tv->u.CHIL+1) & tv_val_CHIL (mode_L->max)) - 1;
+ return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_L))) - 1;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
return tv->u.chil;
{
TARVAL_VRFY (tv);
- switch (tv->mode->code) {
+ switch (get_mode_modecode(tv->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- *fail = tv->u.CHIL > tv_val_CHIL (mode_l->max);
+ *fail = tv->u.CHIL > tv_val_CHIL (get_mode_max(mode_l));
return tv->u.CHIL;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
*fail = 0;
return tv->u.chil;
case irm_Z:
- *fail = ( (mpz_cmp_si (&tv->u.Z, tv_val_chil(mode_l->max)) > 0)
- || (mpz_cmp_si (&tv->u.Z, tv_val_chil(mode_l->min)) < 0));
+ *fail = ( (mpz_cmp_si (&tv->u.Z, tv_val_chil(get_mode_max(mode_l))) > 0)
+ || (mpz_cmp_si (&tv->u.Z, tv_val_chil(get_mode_max(mode_l))) < 0));
return mpz_get_si (&tv->u.Z);
/* strange */
case irm_b:
TARVAL_VRFY (val);
- switch (val->mode->code) {
+ switch (get_mode_modecode(val->mode)) {
case irm_T: /* none */
printed = XPSR ("<bad>");
return printed;
}
-\f
-/* Labeling of tarvals */
-// CS-hac
-/*
-label
-tarval_label (tarval *tv)
-{
- if (!tv->lab) {
- tv->lab = new_label();
- tv->used = 1;
- }
- return tv->lab;
-}
-
-
-void
-tarval_forall_labeled (int (*f) (tarval *, void *), void *data)
-{
- tarval *tv;
-
- for (tv = pset_first (tarvals); tv; tv = pset_next (tarvals)) {
- if (tv->lab && f (tv, data)) {
- pset_break (tarvals);
- return;
- }
- }
-}
-*/
-
ir_mode *
get_tv_mode (tarval *tv)
{