Update of /cvsroot/monetdb/pathfinder/compiler/mil
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19997/mil
Modified Files:
mil.c mil_dce.c mil_opt.c milgen.brg milprint.c
milprint_summer.c
Log Message:
-- The endless Odyssey through the pathfinder code checking
for correct initialization of global variables (Part 6).
This time---checking all files in folders:
o compiler/mil
U mil.c
Index: mil.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/mil.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- mil.c 20 Mar 2008 10:55:14 -0000 1.57
+++ mil.c 3 Apr 2008 09:20:41 -0000 1.58
@@ -359,14 +359,14 @@
case PF_MIL_VAR_AXIS_PREC_S: return "AXIS_preceding_sibling";
case PF_MIL_VAR_AXIS_SELF: return "AXIS_self";
case PF_MIL_VAR_AXIS_ATTR: return "AXIS_attribute";
-
+
case PF_MIL_VAR_CODE_NONE: return "TEST_none";
case PF_MIL_VAR_CODE_KIND: return "TEST_kind";
case PF_MIL_VAR_CODE_NS: return "TEST_ns";
case PF_MIL_VAR_CODE_LOC: return "TEST_loc";
case PF_MIL_VAR_CODE_NSLOC: return "TEST_nsloc";
case PF_MIL_VAR_CODE_TARGET: return "TEST_target";
-
+
case PF_MIL_VAR_TIME_LOAD: return "time_load";
case PF_MIL_VAR_TIME_QUERY: return "time_query";
case PF_MIL_VAR_TIME_PRINT: return "time_print";
U milgen.brg
Index: milgen.brg
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milgen.brg,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -d -r1.127 -r1.128
--- milgen.brg 2 Apr 2008 08:48:18 -0000 1.127
+++ milgen.brg 3 Apr 2008 09:20:42 -0000 1.128
@@ -7,11 +7,11 @@
*
* @page milgenDetail MIL Code generation
*
- * @section phys2mil Physical algebra to MIL Code compilation
+ * @section phys2mil Physical algebra to MIL Code compilation
*
* The compilation from physical algebra is controlled by the function
* #PFmilgen() and a Burg pattern matcher. It registers a global variable
- * #milprog which stores a MIL tree that is build during a bottom-up
+ * #milprog which stores a MIL tree that is build during a bottom-up
* traversal of the physical algebra DAG. The preferred way to extend
* the MIL program is to use the macro #execute() which appends the new
* commands to the MIL program. (More high-level information can be found
@@ -48,8 +48,8 @@
*
* Variables that are used to represent the result of an operator have
* to pinned with <code>p->refctr</code> (the number of consuming parents).
- * For these variables is done automatically after the consumption.
- *
+ * For these variables is done automatically after the consumption.
+ *
* @if COPYRIGHT
*
* Copyright Notice:
@@ -103,7 +103,7 @@
/* fold( define burg accessors */
/** @cond BRG */ /* make doxygen ignore brg specific code */
-
+
/* Accessors for the burg matcher */
typedef struct PFpa_op_t *NODEPTR_TYPE;
@@ -300,7 +300,7 @@
%%
/** @endcond */
-/* fold( execute() / global milprog definition */
+/* fold( execute() / global milprog definition */
/**
* @brief Global variable to collect the MIL program during compilation
*/
@@ -318,7 +318,7 @@
#define execute(...) milprog = seq (milprog, __VA_ARGS__)
/* fold) */
-/* fold( mvar_t / global mvars / new_var() / pin() / unpin() definition */
+/* fold( mvar_t / global mvars / new_var() / pin() / unpin() definition */
/**
* @brief Represents a MIL variable.
*
@@ -351,10 +351,15 @@
static PFarray_t *mvars;
/**
+ * @brief running variable number.
+ */
+static unsigned int varno;
+
+/**
* @brief Create a ``new'' valid variable
*
* Will try to re-use an old, no longer needed, variable, if possible.
- * For this, the function searches #mvars for a variable with
+ * For this, the function searches #mvars for a variable with
* @a pins = 0. If no such variable can be found, a new one will
* be created and appended to the list.
*
@@ -367,8 +372,7 @@
static mvar_t *
new_var (unsigned int pins)
{
- static unsigned int varno = PF_MIL_RES_VAR_COUNT;
- mvar_t *var = NULL;
+ mvar_t *var = NULL;
assert (mvars);
assert (varno < 10000);
@@ -425,7 +429,7 @@
/* fold) */
-/* fold( TYPE_MASK() / type_bit_check() / impl_types() / implty() definition
*/
+/* fold( TYPE_MASK() / type_bit_check() / impl_types() / implty() definition */
/** @brief ``mask out'' the flags identifying non-attribute nodes */
#define TYPE_MASK(t) ((t) & ~(aat_nkind))
@@ -463,23 +467,23 @@
case aat_attr1:
case aat_frag1:
return mty_oid;
-
+
case aat_int:
case aat_update:
case aat_docmgmt:
return mty_lng;
-
+
case aat_path:
case aat_colnm:
case aat_docnm:
case aat_str:
case aat_uA:
return mty_str;
-
+
case aat_dec:
case aat_dbl:
return mty_dbl;
-
+
case aat_bln:
return mty_bit;
@@ -501,7 +505,7 @@
#endif
/* fold) */
-/* fold( env_t / new_env() / env_*() / VAR() / ANY_VAR() definition */
+/* fold( env_t / new_env() / env_*() / VAR() / ANY_VAR() definition */
/**
* @brief Environment entry.
*
@@ -661,7 +665,7 @@
assert (p);
assert (in_env);
assert (v);
-
+
for (unsigned int i = 0; i < env_count (in_env); i++) {
mvar_t *tmp = new_var (p->refctr);
/* expand variables */
@@ -684,7 +688,7 @@
}
/* fold) */
-/* fold( twig_state_t / global twig_state definition */
+/* fold( twig_state_t / global twig_state definition */
/**
* @brief The state information necessary to build a twig
* of multiple node constructors in one go.
@@ -710,7 +714,7 @@
static twig_state_t *twig_state;
/* fold) */
-/* fold( new_trace_id() / global global_trace_id definition */
+/* fold( new_trace_id() / global global_trace_id definition */
/** @brief global ID for tracing */
static unsigned int global_trace_id;
@@ -820,7 +824,7 @@
*r = NULL;
assert (left.count == right.count);
-
+
/* collect all arguments/columns for the intersection ... */
for (unsigned int i = 0; i < left.count; i++) { /* fold( */
latt = left.items[i].name;
@@ -829,7 +833,7 @@
rty = right.items[i].type;
/* cope with simple types */
- if (type_bit_check (lty) && lty == rty) {
+ if (type_bit_check (lty) && lty == rty) {
l = env_mvar (L(p)->env, latt, lty);
r = env_mvar (R(p)->env, ratt, rty);
}
@@ -875,7 +879,7 @@
other nodes only match non-attribute nodes. */
l = env_mvar (L(p)->env, latt, aat_pre);
r = env_mvar (R(p)->env, ratt, aat_pre);
-
+
execute (
assgn (var (lpre->name),
mifthenelse (
@@ -893,14 +897,14 @@
madd (mcast (type (mty_lng),
var (r->name)),
lit_int (1)))));
-
+
/* add the pre column */
if (!args)
args = arg (var (lpre->name), var (rpre->name));
else
args = arg (args, arg (var (lpre->name),
var (rpre->name)));
-
+
l = env_mvar (L(p)->env, latt, aat_attr);
r = env_mvar (R(p)->env, ratt, aat_attr);
@@ -921,13 +925,13 @@
madd (mcast (type (mty_lng),
var (r->name)),
lit_int (1)))));
-
+
/* add the attr column */
args = arg (args, arg (var (lattr->name), var (rattr->name)));
l = env_mvar (L(p)->env, latt, aat_frag);
r = env_mvar (R(p)->env, ratt, aat_frag);
-
+
args = arg (args, arg (var (l->name), var (r->name)));
/* jump over the shared code as we already added
@@ -948,7 +952,7 @@
l = env_mvar (L(p)->env, latt, aat_frag);
r = env_mvar (R(p)->env, ratt, aat_frag);
}
- /* cope with QNames */
+ /* cope with QNames */
else if (aat_qname == lty && aat_qname == rty) {
mvar_t *luri_loc = new_var (1),
*ruri_loc = new_var (1);
@@ -965,13 +969,13 @@
mposjoin (VAR (R(p)->env, ratt, aat_qname_id),
VAR (R(p)->env, ratt, aat_qname_cont),
var (PF_MIL_VAR_QN_URI_LOC))));
-
+
if (!args)
args = arg (var (luri_loc->name), var (ruri_loc->name));
else
args = arg (args, arg (var (luri_loc->name),
var (ruri_loc->name)));
-
+
/* jump over the shared code as we already added
everything to the argument by hand. */
continue;
@@ -1019,7 +1023,7 @@
rty = type_of (r, ratt);
/* cope with simple types */
- if (type_bit_check (lty) && lty == rty) {
+ if (type_bit_check (lty) && lty == rty) {
execute (
assgn (var (lres->name),
VAR (l->env, latt, lty)),
@@ -1087,7 +1091,7 @@
execute (
assgn (var (lp->name),
project (var (lf->name), lit_int (0))));
-
+
if (rty & aat_pre)
execute (
assgn (var (rp->name), VAR (r->env, ratt, aat_pre)),
@@ -1103,7 +1107,7 @@
execute (
assgn (var (rp->name),
project (var (rf->name), lit_int (0))));
-
+
if (lty & aat_attr)
execute (
assgn (var (la->name), VAR (l->env, latt, aat_attr)),
@@ -1119,7 +1123,7 @@
execute (
assgn (var (la->name),
project (var (lf->name), lit_int (0))));
-
+
if (rty & aat_attr)
execute (
assgn (var (ra->name), VAR (r->env, ratt, aat_attr)),
@@ -1135,7 +1139,7 @@
execute (
assgn (var (ra->name),
project (var (rf->name), lit_int (0))));
-
+
execute (
assgn (var (tmp_res->name),
zip_nodes (
@@ -1162,7 +1166,7 @@
lit_int (1))));
unpin (tmp_res, 1);
}
- /* cope with QNames */
+ /* cope with QNames */
else if (aat_qname == lty && aat_qname == rty) {
execute (
assgn (var (lres->name),
@@ -1199,7 +1203,7 @@
PFalg_att_t att;
bool dir,
initialized = false;
-
+
for (unsigned int i = 0; i < PFord_count (ord); i++) {
att = PFord_order_col_at (ord, i);
dir = PFord_order_dir_at (ord, i);
@@ -1285,7 +1289,7 @@
fetch (var (PF_MIL_VAR_WS),
var (PF_MIL_VAR_PRE_KIND)))),
assgn (var (map->name),
- hmark (select_ (var (kind->name),
+ hmark (select_ (var (kind->name),
var (PF_MIL_VAR_KIND_ELEM)),
lit_oid (0))),
assgn (var (elem->name),
@@ -1331,14 +1335,14 @@
}
else {
assert (ty == aat_node);
-
+
/* split up nodes and attributes,
find all element nodes and extract their QName references */
mvar_t *elem = new_var (1),
*elem_cont = new_var (1),
*pre_sel = new_var (1),
*attr_sel = new_var (1),
-
+
*pid = new_var (1),
*pcont = new_var (1),
*aid = new_var (1),
@@ -1389,7 +1393,7 @@
fetch (var (PF_MIL_VAR_WS),
var (PF_MIL_VAR_PRE_KIND))))),
assgn (var (pre_sel->name),
- hmark (select_ (var (pre_sel->name),
+ hmark (select_ (var (pre_sel->name),
var (PF_MIL_VAR_KIND_ELEM)),
lit_oid (0))),
assgn (var (elem->name),
@@ -1534,17 +1538,17 @@
var (qn_map->name),
var (in_qn_cont->name))),
assgn (var (prefix->name),
- mposjoin (var (qn_id->name),
+ mposjoin (var (qn_id->name),
var (qn_cont->name),
fetch (var (PF_MIL_VAR_WS),
var (PF_MIL_VAR_QN_PREFIX)))),
assgn (var (uri->name),
- mposjoin (var (qn_id->name),
+ mposjoin (var (qn_id->name),
var (qn_cont->name),
fetch (var (PF_MIL_VAR_WS),
var (PF_MIL_VAR_QN_URI)))),
assgn (var (local->name),
- mposjoin (var (qn_id->name),
+ mposjoin (var (qn_id->name),
var (qn_cont->name),
fetch (var (PF_MIL_VAR_WS),
var (PF_MIL_VAR_QN_LOC)))),
@@ -1570,7 +1574,7 @@
leftfetchjoin (
reverse (fetch (var (mu_res->name), lit_int (0))),
fetch (var (mu_res->name), lit_int (1)))));
-
+
/* store nested MIL code */
bodymilprog = milprog;
/* activate old mil program */
@@ -1584,7 +1588,7 @@
count (var (in_qn_cont->name))),
/* then */ assgn (var (qn_id->name), var (in_qn_id->name)),
/* else */ bodymilprog));
-
+
unpin (qn_cont, 1);
unpin (qn_id_ws, 1);
unpin (qn_bool, 1);
@@ -1621,7 +1625,7 @@
res_ty = type_of (p, res);
assert (att_ty == res_ty);
-
+
if (part != att_NULL) {
mvar_t *v = new_var (1);
mvar_t *res_var = new_var (p->refctr);
@@ -1700,7 +1704,7 @@
assert (iter_ty == aat_nat);
assert (p); assert (L(p)); assert (L(p)->env);
-
+
/* collect all information to check *//* fold( */
/* translate axis information */
axis = NULL;
@@ -1741,7 +1745,7 @@
order = lit_int (o);
/* initialize the code */
- code = var (PF_MIL_VAR_CODE_KIND);
+ code = var (PF_MIL_VAR_CODE_KIND);
/* translate kind information */
kind = NULL;
switch (p->sem.scjoin.spec.kind) {
@@ -1786,7 +1790,7 @@
tgt = cast (type (mty_str), nil ());
}
/* end of collect all information to check *//* fold) */
-
+
/*
* step := step (...);
* iter := step.fetch (0);
@@ -1794,7 +1798,7 @@
* pre := step.fetch (2);
*/
execute (
- assgn (var (step->name),
+ assgn (var (step->name),
step (axis, code,
VAR (L(p)->env, pa_iter, iter_ty),
VAR (L(p)->env, pa_item, aat_frag),
@@ -1833,14 +1837,14 @@
if (item_res_ty & aat_attr) {
mvar_t *ret_attr = new_var (p->refctr);
-
+
execute (
assgn (var (ret_attr->name),
fetch (var (step->name), lit_int (3))));
-
+
env_add (p->env, pa_item, aat_attr, ret_attr);
}
-
+
unpin (step, 1);
unpin (map, 1);
@@ -2448,7 +2452,7 @@
assgn (var (upd_kind->name),
VAR (L(p)->env, pa_item, aat_update)),
);
-
+
/* consider node tgt */
if (ty & aat_pnode1)
execute (
@@ -2646,7 +2650,7 @@
mvar_t *intVAL, *dblVAL, *decVAL, *strVAL;
mvar_t *item, *kind;
bool sorted = false;
-
+
/* Set up all the value containers for print_result().
* (It is actually too much overhead to introduce the value
* containers just for printing. But this way we can re-use
@@ -3455,7 +3459,7 @@
ratt = p->sem.thetajoin.pred[i].right;
lty = type_of (L(p), latt);
rty = type_of (R(p), ratt);
-
+
left.items[left.count++] =
(struct PFalg_schm_item_t)
{ .name = latt, .type = lty };
@@ -3469,7 +3473,7 @@
if (initialized) {
/* apply the intersection on all equality predicates */
intersect (p, left, right, res);
-
+
execute (assgn (var (lmap->name),
reverse (mark (var (res->name), lit_oid (0)))),
assgn (var (rmap->name),
@@ -3561,7 +3565,7 @@
initialized = true;
} /* fold) */
-
+
/* map all columns from the left and the right argument */
env_map (p, L(p)->env, lmap);
env_map (p, R(p)->env, rmap);
@@ -3629,7 +3633,7 @@
PFoops (OOPS_FATAL, "incorrect comparison");
}
- if (p->kind == pa_unq2_thetajoin) {
+ if (p->kind == pa_unq2_thetajoin) {
v1 = new_var (p->refctr);
v2 = new_var (p->refctr);
@@ -3669,7 +3673,7 @@
comp)),
assgn (var (v1->name),
reverse( mark (var (v->name), lit_oid (0)))));
-
+
/* add the result column to the environment */
env_add (p->env, ldist_att, ldist_ty, v1);
}
@@ -3738,7 +3742,7 @@
nodes or qnames. */
PFoops (OOPS_FATAL,
"multi-predicate selections are not supported yet");
-
+
/*
* For the predicate column c do
*
@@ -3840,10 +3844,10 @@
"MergeUnion for more complex orderings "
"is not implemented (got %s)",
PFord_str (p->sem.merge_union.ord));
-
+
grp_att = PFord_order_col_at (p->sem.merge_union.ord, 0);
grp_ty = type_of (p, grp_att);
-
+
if (!type_bit_check (grp_ty) ||
type_of (L(p), grp_att) != grp_ty ||
type_of (R(p), grp_att) != grp_ty)
@@ -3943,10 +3947,10 @@
right.items[right.count++] =
(struct PFalg_schm_item_t) { .name = att, .type = rty
};
}
-
+
/* apply the intersection */
intersect (p, left, right, res);
-
+
execute (assgn (var (res->name),
reverse (
mark (tunique (reverse (var (res->name))),
@@ -4017,10 +4021,10 @@
(struct PFalg_schm_item_t)
{ .name = att, .type = rty };
}
-
+
/* apply the intersection */
intersect (p, left, right, res);
-
+
/* build the difference */
execute (
assgn (var (res->name),
@@ -4029,7 +4033,7 @@
kdiff (ANY_VAR(L(p)->env),
var (res->name)),
lit_oid (0)))));
-
+
/* map all columns from the argument */
env_map (p, L(p)->env, res);
@@ -4103,7 +4107,7 @@
/* create the MIL code that stores
the ordered extend in variable v */
order_extend (L(p), ord, v);
-
+
/* prepare the map relation */
execute (
assgn (var (v->name),
@@ -4140,7 +4144,7 @@
/* create the MIL code that stores
the ordered extend in variable v */
order_extend (L(p), ord, v);
-
+
/* prepare the map relation */
execute (
assgn (var (v->name),
@@ -4528,9 +4532,9 @@
*prefix_bool = new_var (1),
*true_oid = new_var (1),
*false_oid = new_var (1);
-
+
/* look up the correct QName references */
- fn_node_name (L(p), att, id, cont);
+ fn_node_name (L(p), att, id, cont);
/* get all prefixes */
execute (
@@ -4560,7 +4564,7 @@
arg (var (false_oid->name),
arg (lit_str(""),
var (prefix->name)))))),
- /* we know that prefix now contains all rows
+ /* we know that prefix now contains all rows
(and thus treat a tmark for a leftjoin) */
assgn (var (prefix->name),
tmark (
@@ -4614,7 +4618,7 @@
*empty_str = new_var (1),
*mu = new_var (1);
PFmil_ident_t uri_loc = PF_MIL_VAR_UNUSED;
-
+
switch (p->sem.fun_1to1.kind) {
case alg_fun_fn_local_name:
uri_loc = PF_MIL_VAR_QN_LOC; break;
@@ -4625,7 +4629,7 @@
}
/* look up the correct QName references */
- fn_node_name (L(p), att, id, cont);
+ fn_node_name (L(p), att, id, cont);
/* get all prefixes */
execute (
@@ -4664,13 +4668,13 @@
PFalg_att_t att = p->sem.fun_1to1.refs.atts[0];
PFalg_simple_type_t ty = type_of (L(p), att);
bool first = true;
-
+
res_type = aat_dbl;
if (ty & aat_qname)
PFoops (OOPS_FATAL,
"We do not support the value NaN.");
-
+
for (PFalg_simple_type_t t = 1; t; t <<= 1)
if (t & TYPE_MASK(ty)) {
@@ -4784,7 +4788,7 @@
/* and put the result into p's environment */
env_add (p->env, p->sem.fun_1to1.res, aat_qname_cont,
cont);
-
+
res_type = aat_qname_id;
} break; /* fold) */
case alg_fun_pf_fragment: /* fold( */
@@ -4841,7 +4845,7 @@
execute (
assgn ( var (res->name),
project (VAR (L(p)->env, docname, aat_str),
- lit_lng(0))));
+ lit_lng(0))));
} break; /* fold) */
case alg_fun_pf_add_doc_str_int: /* fold( */
@@ -4887,7 +4891,7 @@
res_type = aat_docmgmt;
execute (
assgn ( var (res->name),
- VAR (L(p)->env, percentage, aat_int)));
+ VAR (L(p)->env, percentage, aat_int)));
} break; /* fold) */
case alg_fun_pf_del_doc: /* fold( */
@@ -4911,7 +4915,7 @@
execute (
assgn ( var (res->name),
project (VAR (L(p)->env, docname, aat_str),
- lit_lng(-1))));
+ lit_lng(-1))));
} break; /* fold) */
case alg_fun_upd_delete: /* fold( */
@@ -5033,7 +5037,7 @@
mvar_t *l = new_var (1),
*r = new_var (1),
*res = new_var (p->refctr);
-
+
/* choose the correct operator */
if (p->kind == pa_eq) op = PFmil_meq;
else if (p->kind == pa_gt) op = PFmil_mgt;
@@ -5047,7 +5051,7 @@
into two single BATs (stored in l and r) */
prepare_comp (
L(p), L(p), p->sem.binary.att1, p->sem.binary.att2, l, r);
-
+
/* do the comparison */
execute (
assgn (var (res->name), op (var (l->name), var (r->name))));
@@ -5063,9 +5067,9 @@
case 60: /* fold( */
{
mvar_t *res = new_var (p->refctr);
-
+
assert (aat_bln == type_of (L(p), p->sem.unary.att));
-
+
/* copy the complete environment of the argument */
env_copy (p, L(p)->env);
@@ -5085,10 +5089,10 @@
{
PFmil_t * (*op) (const PFmil_t *, const PFmil_t *) = NULL;
mvar_t *res = new_var (p->refctr);
-
+
assert (aat_bln == type_of (L(p), p->sem.binary.att1));
assert (aat_bln == type_of (L(p), p->sem.binary.att2));
-
+
/* choose the correct operator */
if (p->kind == pa_bool_and) op = PFmil_mand;
else if (p->kind == pa_bool_or) op = PFmil_mor;
@@ -5113,13 +5117,13 @@
{
mvar_t *v = new_var (1);
mvar_t *res = new_var (p->refctr);
-
+
execute (
/* v := in2.[-](in1).[+](1LL).[max](0LL);
v := enumerate(in1, v);
res := v.reverse().mark([EMAIL PROTECTED]).reverse();
v := v.mark([EMAIL PROTECTED]).reverse();
-
+
out_n := v.leftjoin(in_n);
out_n := out_n.tmark([EMAIL PROTECTED]); */
assgn (
@@ -5142,7 +5146,7 @@
assgn (
var (v->name),
reverse (mark (var (v->name), lit_oid (0)))));
-
+
env_add (p->env, p->sem.binary.res, aat_int, res);
/* map all columns from the argument */
@@ -5158,7 +5162,7 @@
mvar_t *res = new_var (p->refctr);
mvar_t *part = new_var (p->refctr);
PFalg_simple_type_t ty = type_of (p, p->sem.count.part);
-
+
if (!type_bit_check (ty))
PFoops (OOPS_FATAL,
"Count not implemented for polymorphic groups");
@@ -5363,7 +5367,7 @@
/* release our temporary variable */
unpin (v, 1);
} break; /* fold) */
-
+
/* Rel: mark_grp (Rel) */
case 75: /* fold( */
{
@@ -5431,7 +5435,7 @@
else
/* we have one simple type */
type = not (misnil (VAR (L(p)->env, att, req_ty)));
-
+
execute (assgn (var (res->name), type));
} break; /* fold) */
@@ -5457,7 +5461,7 @@
PFoops (OOPS_FATAL,
"cast to type QName is only possible "
"for values of type QName or string.");
-
+
if (input_ty == aat_qname) {
env_add (p->env, p->sem.cast.res, aat_qname_id,
env_mvar (L(p)->env, att, aat_qname_id));
@@ -5474,7 +5478,7 @@
assgn (var (res_cont->name),
project (var (res_id->name),
var (PF_MIL_VAR_WS_CONT))));
-
+
/* and put the result into p's environment */
env_add (p->env, p->sem.cast.res, aat_qname_id, res_id);
env_add (p->env, p->sem.cast.res, aat_qname_cont,
res_cont);
@@ -5520,7 +5524,7 @@
misnil (var (res_cont->name)),
var (str_cont->name),
var (res_cont->name))));
-
+
unpin (str_id, 1);
unpin (str_cont, 1);
}
@@ -5534,7 +5538,7 @@
unsigned int parts = 0;
mvar_t *res = new_var (p->refctr),
*tmp = new_var (1);
-
+
/* and put the result into p's environment */
env_add (p->env, p->sem.cast.res, req_ty, res);
@@ -5759,7 +5763,7 @@
PFalg_simple_type_t ty = type_of (L(p), p->sem.doc_access.att);
#endif
mvar_t *str = new_var (p->refctr);
-
+
PFmil_t *frag = VAR (L(p)->env, att, aat_frag),
*pre = VAR (L(p)->env, att, aat_pre),
*attr,
@@ -5780,7 +5784,7 @@
case (doc_atext):
assert (ty == aat_anode);
attr = VAR (L(p)->env, att, aat_attr);
-
+
execute (
assgn (var (str->name),
mposjoin (
@@ -6469,7 +6473,7 @@
unpin (seqb, 1);
unpin (qn_id, 1);
-
+
pin (iter, p->refctr);
env_add (p->env, p->sem.ii.iter, aat_nat, iter);
env_add (p->env, p->sem.ii.item, aat_pre, root_pre);
@@ -6829,7 +6833,7 @@
mvar_t *v = new_var (1),
*qn_id = new_var (1);
PFmil_t *iter = VAR (L(p)->env, p->sem.ii.iter, aat_nat);
-
+
/* Ensure that the QNames are stored in the WS container
and copy them if they reside in a different container. */
copy_QName (
@@ -7034,7 +7038,7 @@
env_mvar (L(p)->env, qn_att, aat_qname_id),
env_mvar (L(p)->env, qn_att, aat_qname_cont),
qn_id);
-
+
execute (
assgn (var (prop->name),
add_content (val,
@@ -7210,10 +7214,10 @@
*iter = env_mvar (L(p)->env, p->sem.ii.iter, aat_nat),
*frag = env_mvar (L(p)->env, p->sem.ii.item, aat_frag),
*tmp;
-
+
treat_pre = true;
treat_attr = true;
-
+
p_iter = new_var (1);
p_item = new_var (1);
p_cont = new_var (1);
@@ -7223,13 +7227,13 @@
/* create a boolean BAT that distinct attributes
and other nodes */
-
+
/* attr := [isnil](attr); */
execute (
assgn (
var (attr->name),
misnil (VAR (L(p)->env, p->sem.ii.item, aat_attr))));
-
+
/* split up by nodes... */
/* sel := attr.uselect(true).hmark([EMAIL PROTECTED]);
@@ -7540,7 +7544,7 @@
v.append(p_iter.project(0));
v.append(p_iter.project(%twig_state->level%));
v.append(p_iter.project(REFERENCE));
- # store the references to look up the reference
+ # store the references to look up the reference
# in the PRE_PROP column
v.append(p_item);
# store the node container to look up the reference
@@ -7659,7 +7663,7 @@
env_add (p->env, iter_att, aat_nat, iter);
env_add (p->env, item_att, aat_pre, pre);
env_add (p->env, item_att, aat_frag, frag);
-
+
/* if we have attributes and other nodes we need to
split them up first */
if (item_ty & aat_attr) {
@@ -7669,9 +7673,9 @@
*in_frag = env_mvar (L(p)->env, item_att, aat_frag),
*in_pre = env_mvar (L(p)->env, item_att, aat_pre),
*in_attr = env_mvar (L(p)->env, item_att, aat_attr);
-
+
treat_attr = true;
-
+
p_iter = new_var (1);
p_pre = new_var (1);
p_cont = new_var (1);
@@ -7682,13 +7686,13 @@
/* create a boolean BAT that distinct attributes
and other nodes */
-
+
/* attr := [isnil](attr); */
execute (
assgn (
var (attr->name),
misnil (var (in_attr->name))));
-
+
/* split up by nodes... */
/* sel := attr.uselect(true).hmark([EMAIL PROTECTED]);
@@ -7744,7 +7748,7 @@
/* apply the merge_adjacent operation */
ma = new_var (1);
-
+
execute (
assgn (var (ma->name),
merge_adjacent (var (p_iter->name),
@@ -7766,13 +7770,13 @@
fetch (var (ma->name), lit_int (0))));
unpin (ma, 1);
-
+
/* if we have attributes and other nodes we need to
merge them back again */
if (treat_attr) {
mvar_t *mu = new_var (1),
*attr = new_var (p->refctr);
-
+
env_add (p->env, item_att, aat_frag, attr);
/* Attributes have to appear before the other nodes.
@@ -7827,7 +7831,7 @@
if (env_at (L(p)->env, i).att == p->sem.err.att) {
PFalg_simple_type_t ty = type_of (p, p->sem.err.att);
assert (env_at (L(p)->env, i).ty == aat_str);
-
+
for (PFalg_simple_type_t t = 1; t; t <<= 1)
if (t & TYPE_MASK(ty)) {
/* create new variable */
@@ -8331,6 +8335,10 @@
/* initialize list of variables we use */
mvars = PFarray (sizeof (mvar_t), 100);
+ /* initialize the variable name counter
+ with the first free variable number */
+ varno = PF_MIL_RES_VAR_COUNT;
+
/* dummy initializations */
twig_state = NULL;
fun_params = NULL;
U mil_opt.c
Index: mil_opt.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/mil_opt.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- mil_opt.c 24 Feb 2008 17:22:26 -0000 1.33
+++ mil_opt.c 3 Apr 2008 09:20:42 -0000 1.34
@@ -37,87 +37,87 @@
#include <stdlib.h>
/* malloc to return result buffers with */
-#define EXTERN_MALLOC(n) PFmalloc(n)
-#define EXTERN_REALLOC(p, o, n) PFrealloc(p, o, n)
-#define EXTERN_FREE(p)
+#define EXTERN_MALLOC(n) PFmalloc(n)
+#define EXTERN_REALLOC(p, o, n) PFrealloc(p, o, n)
+#define EXTERN_FREE(p)
[...1463 lines suppressed...]
- /* if (*query) */ EXTERN_FREE(*query);
- /* if (*epilogue) */ EXTERN_FREE(*epilogue);
- *prologue = *query = *epilogue = NULL;
- return -1;
- }
- return 0;
+ /* return the three buffers */
+ *prologue = o->buf[OPT_SEC_PROLOGUE];
+ *query = o->buf[OPT_SEC_QUERY];
+ *epilogue = o->buf[OPT_SEC_EPILOGUE];
+ EXTERN_FREE(o);
+ if (*prologue == NULL || *query == NULL || *epilogue == NULL) {
+ /* if (*prologue) */ EXTERN_FREE(*prologue);
+ /* if (*query) */ EXTERN_FREE(*query);
+ /* if (*epilogue) */ EXTERN_FREE(*epilogue);
+ *prologue = *query = *epilogue = NULL;
+ return -1;
+ }
+ return 0;
}
U milprint_summer.c
Index: milprint_summer.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint_summer.c,v
retrieving revision 1.415
retrieving revision 1.416
diff -u -d -r1.415 -r1.416
--- milprint_summer.c 28 Mar 2008 20:47:53 -0000 1.415
+++ milprint_summer.c 3 Apr 2008 09:20:43 -0000 1.416
@@ -97,7 +97,7 @@
/* ... and so on ... */
#define DRL(p) L(R(L(p)))
-/* starting level of user-defined functions */
+/* starting level of user-defined functions */
#define UDF_LEV 1024
/* starting level of global variables */
#define GLO_LEV -1
@@ -143,31 +143,31 @@
[...4457 lines suppressed...]
+ milprintf(f, PFstandoffMIL());
}
- milprintf(f, PFvarMIL());
+ milprintf(f, PFvarMIL());
- /* get_var_usage appends information to the core nodes and creates a
+ /* get_var_usage appends information to the core nodes and creates a
* var_usage table, which is later split in vu_fid and vu_vid */
opt_output(f, OPT_SEC_PROLOGUE);
get_var_usage (f, c, way, counter);
@@ -11857,7 +11857,7 @@
" var v_item000 :=
bat(void,oid).access(BAT_APPEND).seqbase([EMAIL PROTECTED]);\n"
" var v_kind000 :=
bat(void,int).access(BAT_APPEND).seqbase([EMAIL PROTECTED]);\n");
}
-
+
/* recursive translation of the core tree */
translate2MIL (f, 0, 0, 0, c);
U mil_dce.c
Index: mil_dce.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/mil_dce.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mil_dce.c 20 Jan 2008 22:35:05 -0000 1.18
+++ mil_dce.c 3 Apr 2008 09:20:42 -0000 1.19
@@ -47,11 +47,11 @@
* These sanity checks introduce additional recursive calls whenever
* all variables in its body are marked 'used' (and thus the recursive
* descent is avoided). They traverse the MIL tree without transformation
- * (change = false) and rely in some situations on some MIL coding
+ * (change = false) and rely in some situations on some MIL coding
* convention (ensured only by a later phase). Otherwise they might hit
* an assignment which would break the DCE.
*
- * The convention is that only the operators seq, catch (body arg),
+ * The convention is that only the operators seq, catch (body arg),
* if (then & else arg), and while (body arg) may contain assignments.
*/
@@ -60,26 +60,26 @@
bool change);
/** Adds recursivly all variables to the set of the used variables. */
-static void add_vars_to_used (PFmil_t *root, PFbitset_t *used_vars)
+static void add_vars_to_used (PFmil_t *root, PFbitset_t *used_vars)
{
- if (root->kind == m_var)
+ if (root->kind == m_var)
PFbitset_set (used_vars, root->sem.ident, true);
else {
- for (unsigned int i = 0; i < MIL_MAXCHILD
+ for (unsigned int i = 0; i < MIL_MAXCHILD
&& root->child[i] != NULL; i++)
add_vars_to_used(root->child[i], used_vars);
}
}
/**
- * Reduce unused subexpressions of root to a sequence of statements
+ * Reduce unused subexpressions of root to a sequence of statements
* with side effects.
*/
static PFmil_t *
reduce_expressions (PFmil_t *root,
PFbitset_t *used_vars,
PFbitset_t *dirty_vars,
- bool change)
+ bool change)
{
/* new node, replacing this expression node. */
PFmil_t *new_op = PFmil_nop();
@@ -97,7 +97,7 @@
return change?new_op:root;
}
-/**
+/**
* Returns true if the subtree duplicates a variable.
* e.g. append(append(x, 1), 2) duplicates the variable x.
*/
@@ -131,7 +131,7 @@
static PFmil_t *
mil_dce_worker (PFmil_t *root, PFbitset_t *used_vars, PFbitset_t *dirty_vars,
- bool change)
+ bool change)
{
#ifdef NDEBUG
@@ -162,7 +162,7 @@
{
PFmil_t *lvalue = root->child[0];
PFmil_t *rvalue = root->child[1];
- bool used = PFbitset_get (used_vars,
lvalue->sem.ident);
+ bool used = PFbitset_get (used_vars, lvalue->sem.ident);
assert(lvalue->kind == m_var);
@@ -170,7 +170,7 @@
PFbitset_set (used_vars, lvalue->sem.ident, false);
/* recognize x := unused; assignment */
- if (rvalue->kind == m_var
+ if (rvalue->kind == m_var
&& rvalue->sem.ident == PF_MIL_VAR_UNUSED) {
return root;
}
@@ -193,7 +193,7 @@
PFmil_ident_t var;
if (var_duplication (rvalue, &var) ) {
- /* Assignment is of the form x := y. Neither x nor y
+ /* Assignment is of the form x := y. Neither x nor y
can be dirty */
if ((PFbitset_get (dirty_vars, var) && used) ||
(PFbitset_get (dirty_vars, lvalue->sem.ident) &&
@@ -201,13 +201,13 @@
PFoops (OOPS_FATAL,
"illegal combination of copy-by-reference "
"and side-effects");
- }
-
+ }
+
/* variable on the left side is clean */
PFbitset_set (dirty_vars, lvalue->sem.ident, false);
#endif
- if (!used)
+ if (!used)
/*
* assignment on unused variable, remove assignment,
* but invoke elimination recursively on the r-value
@@ -249,7 +249,7 @@
PFbitset_set (dirty_vars, var->sem.ident, false);
#endif
- /* try to find dead code in the body */
+ /* try to find dead code in the body */
new_child = mil_dce_worker (body,
used_vars,
dirty_vars,
@@ -273,7 +273,7 @@
#endif
/*
- * to find the used variables of a if-then-else block, we must
+ * to find the used variables of a if-then-else block, we must
* find them for the if and for the else part and join the
sets.
*/
PFbitset_t *else_used_vars = PFbitset_copy (used_vars);
@@ -284,15 +284,15 @@
#endif
/* invoke dce on if part */
- new_child = mil_dce_worker (root->child[1],
+ new_child = mil_dce_worker (root->child[1],
used_vars,
dirty_vars,
change);
if (change) root->child[1] = new_child;
/* invoke dce on else part */
- new_child = mil_dce_worker (root->child[2],
- else_used_vars,
+ new_child = mil_dce_worker (root->child[2],
+ else_used_vars,
else_dirty_vars,
change);
if (change) root->child[2] = new_child;
@@ -304,12 +304,12 @@
#endif
/*
- * further optimization: check if if-block and else-block are
+ * further optimization: check if if-block and else-block are
* empty and remove if clause.
* (I think this is not needed because the if clause is only
* used rarely).
*/
-
+
/* the variables of the condition are required (add them again
in case the then and else branch did throw them away) */
add_vars_to_used (root->child[0], used_vars);
@@ -340,12 +340,12 @@
/* invoke dce on the loop body (used_vars now contains the
variables in the condition as well as the ones required
for another pass through the body */
- new_child = mil_dce_worker (root->child[1],
+ new_child = mil_dce_worker (root->child[1],
used_vars,
dirty_vars,
change);
if (change) root->child[1] = new_child;
-
+
/* the variables of the condition are required for the first
check of the condition */
add_vars_to_used (root->child[0], used_vars);
@@ -358,7 +358,7 @@
case m_comment:
case m_declare:
/*
- * we must preserve all variable declarations, because the
+ * we must preserve all variable declarations, because the
* unused assignments are not removed.
*/
return root;
@@ -403,10 +403,10 @@
#ifndef NDEBUG
/* update dirty vars */
- for (unsigned int i = 0; i < MIL_MAXCHILD
+ for (unsigned int i = 0; i < MIL_MAXCHILD
&& root->child[i] != NULL; i++)
mil_dce_worker (root->child[i],
- used_vars,
+ used_vars,
dirty_vars,
false);
#endif
@@ -415,7 +415,7 @@
}
else
/*
- * statement is e.g. append(a, b) and a is not used,
+ * statement is e.g. append(a, b) and a is not used,
* but b could have side effects.
*/
return reduce_expressions (root,
@@ -428,7 +428,7 @@
* statement is e.g. append(a, b) and a is not used,
* but b could have side effects.
*/
- return reduce_expressions (root,
+ return reduce_expressions (root,
used_vars,
dirty_vars,
change);
@@ -445,7 +445,7 @@
#ifndef NDEBUG
/* update dirty vars */
- for (unsigned int i = 0; i < MIL_MAXCHILD
+ for (unsigned int i = 0; i < MIL_MAXCHILD
&& root->child[i] != NULL; i++)
mil_dce_worker (root->child[i], used_vars, dirty_vars, false);
#endif
@@ -468,10 +468,10 @@
* a mvaljoin).
*/
static void
-mil_materialize_elimination (PFmil_t *n,
+mil_materialize_elimination (PFmil_t *n,
PFbitset_t *used_vars,
bool mark_used,
- bool change)
+ bool change)
{
assert (n);
switch (n->kind) {
@@ -496,7 +496,7 @@
PFbitset_get (used_vars,
n->child[0]->sem.ident),
change);
-
+
/* The variable is unused before the assignment. */
PFbitset_set (used_vars, n->child[0]->sem.ident, false);
break;
@@ -506,7 +506,7 @@
if (mark_used)
PFbitset_set (used_vars, n->sem.ident, true);
break;
-
+
case m_mposjoin:
case m_mvaljoin:
/* The inputs to this operators may be un-materialized */
@@ -516,7 +516,7 @@
false,
change);
break;
-
+
case m_materialize:
/* remove the materialize operator if we are
in the change mode and it the materialize
@@ -528,7 +528,7 @@
case m_if:
{
/*
- * to find the used variables of a if-then-else block, we must
+ * to find the used variables of a if-then-else block, we must
* find them for the if and for the else part and join the sets.
*/
PFbitset_t *else_used_vars = PFbitset_copy (used_vars);
@@ -597,11 +597,11 @@
* Peform a dead MIL code elimination.
* It reads the code from the end to the beginning of the program and
* collects the used variables, starting from the serialize, error and
- * print statements.
+ * print statements.
* Assignments on unused variables are removed, expressions are only
* kept if they have side effects (e.g. v.append(x)).
* Problems:
- * If two variables point to the same BAT, an expression with side
+ * If two variables point to the same BAT, an expression with side
* effects can be deleted, because the variable is recognized as unused.
* Example:
* var x := y;
U milprint.c
Index: milprint.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- milprint.c 20 Mar 2008 10:55:16 -0000 1.67
+++ milprint.c 3 Apr 2008 09:20:43 -0000 1.68
@@ -428,10 +428,10 @@
break;
case m_comment:
- milprintf ("# ");
- /* FIXME: What if c contains \n's? */
- milprintf ("%s\n", n->sem.s);
- break;
+ milprintf ("# ");
+ /* FIXME: What if c contains \n's? */
+ milprintf ("%s\n", n->sem.s);
+ break;
/* statements : statement ';' */
default:
@@ -696,9 +696,9 @@
case m_avg:
/* expression : expression '.max' */
case m_max:
- /* expression : expression '.min' */
+ /* expression : expression '.min' */
case m_min:
- /* expression : expression '.sum' */
+ /* expression : expression '.sum' */
case m_sum:
/* expression : expression 'bat()' */
case m_bat:
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins