value bv_CAML_union( value vbv1, value vbv2 ) { CAMLparam2( vbv1, vbv2 ); CAMLlocal1( vres ); vect *res, *bv1, *bv2; bv1 = Vect_val(vbv1); bv2 = Vect_val(vbv2); res = bv_copy(bv1,0); bv_alloc_val(vres,res); bv_union(res, bv1, bv2); CAMLreturn(vres); }
/* lvrelax: compute live variable info for block b if necessary (if updates have been performed by any of its successors), or in any case if force is true. */ static void lvrelax (i_bb_t b, int force) { unsigned int i; bvt out, fout; /* "Out" bit vectors */ bvt in, fin; /* "In" bit vector */ i_bb_t *n = b->n; /* List of successors */ i_bb_t *p = b->p; /* List of predecessors */ unsigned int nn = b->nn; /* Numbers of predecessors and successors */ unsigned int np = b->np; assert(b); /* Either this is the first round or we are here because we need to update something */ assert(force || b->iupdates+b->fupdates > 0); if (nn == 0) { /* Sinks: in = use */ assert(force); /* Sinks are touched only once */ if (num_i) { /* Handle ints */ b->ilv_in = bv_cp(b->iv_use); /* Increase updates for each predecessor */ for (i = 0; i < np; i++) ++p[i]->iupdates; iupdates += np; /* Increase updates count */ } if (num_f) { /* Handle floats */ b->flv_in = bv_cp(b->fv_use); for (i = 0; i < np; i++) ++p[i]->fupdates; fupdates += np; } return; /* Nothing more to be done for sinks */ } /* Handle integers */ if (num_i && (b->iupdates || force)) { out = bv_cp(b->ilv_out); /* out = \sum_{s\in succ}{in(s)} */ for (i = 0; i < nn; i++) { assert(n[i]); if (n[i]->ilv_in) bv_union(out, n[i]->ilv_in); } /* in = use + (out - def) */ if (!bv_eq(b->ilv_out, out)) { b->ilv_out = out; in = bv_cp(out); } else in = out; /* We don't use 'out': optimize away bv_cp */ bv_diff(in, b->iv_def); bv_union(in, b->iv_use); iupdates -= b->iupdates;/* This node has just been updates */ assert(iupdates >= 0); b->iupdates = 0; if (!b->ilv_in || !bv_eq(b->ilv_in, in)) { b->ilv_in = in; for (i = 0; i < np; i++) ++p[i]->iupdates; iupdates += np; /* Increase updates count; always >= 0 */ } } /* Handle floats */ if (num_f && (b->fupdates || force)) { fout = bv_cp(b->flv_out); /* out = \sum_{s\in succ}{in(s)} */ for (i = 0; i < nn; i++) { assert(n[i]); if (n[i]->flv_in) bv_union(fout, n[i]->flv_in); } /* in = use + (out - def) */ if (!bv_eq(b->flv_out, fout)) { b->flv_out = fout; fin = bv_cp(fout); } else fin = fout; /* We don't use 'out': optimize away bv_cp */ bv_diff(fin, b->fv_def); bv_union(fin, b->fv_use); fupdates -= b->fupdates; assert(fupdates >= 0); b->fupdates = 0; if (!b->flv_in || !bv_eq(b->flv_in, fin)) { b->flv_in = fin; for (i = 0; i < np; i++) ++p[i]->fupdates; /* Increase updates count; always >= 0 */ fupdates += np; } } }
/* i_igcliqueinternal: set row n of matrix for IG x to union of row n and v */ static inline void i_igcliqueinternal (unsigned int n, bvt v, void *x) { ig_t g = (ig_t)x; bv_union(row(n,g), v); }