Lines Matching defs:graft

25 	__isl_keep isl_ast_graft *graft);
39 isl_ctx *isl_ast_graft_get_ctx(__isl_keep isl_ast_graft *graft)
41 if (!graft)
43 return isl_basic_set_get_ctx(graft->enforced);
47 __isl_keep isl_ast_graft *graft)
49 return graft ? isl_ast_node_copy(graft->node) : NULL;
52 /* Create a graft for "node" with guards "guard" and
59 isl_ast_graft *graft;
65 graft = isl_calloc_type(ctx, isl_ast_graft);
66 if (!graft)
69 graft->ref = 1;
70 graft->node = node;
71 graft->guard = guard;
72 graft->enforced = enforced;
74 return graft;
82 /* Create a graft for "node" with no guards and no enforced conditions.
102 /* Create a graft with no guards and no enforced conditions
117 __isl_keep isl_ast_graft *graft)
119 if (!graft)
122 graft->ref++;
123 return graft;
162 isl_ast_graft *graft;
163 graft = isl_ast_graft_list_get_ast_graft(list, i);
164 if (!graft)
167 equal = isl_set_is_equal(graft_0->guard, graft->guard);
168 isl_ast_graft_free(graft);
208 * If there is only one graft in the list and if its guard
217 * from the build and the enforced constraints of the graft) and
269 isl_ast_graft *graft;
273 graft = isl_ast_graft_list_get_ast_graft(list, i);
274 enforced = isl_ast_graft_get_enforced(graft);
275 guard_i = isl_set_copy(graft->guard);
276 isl_ast_graft_free(graft);
368 /* Insert an if node around graft->node testing the condition encoded
372 __isl_take isl_ast_graft *graft, __isl_take isl_set *guard,
377 if (!graft)
385 return graft;
388 graft->node = ast_node_insert_if(graft->node, guard, build);
390 if (!graft->node)
391 return isl_ast_graft_free(graft);
393 return graft;
396 return isl_ast_graft_free(graft);
399 /* Insert an if node around graft->node testing the condition encoded
400 * in graft->guard, assuming graft->guard involves any conditions.
403 __isl_take isl_ast_graft *graft, __isl_keep isl_ast_build *build)
405 if (!graft)
408 return insert_if_node(graft, isl_set_copy(graft->guard), build);
411 /* Replace graft->enforced by "enforced".
414 __isl_take isl_ast_graft *graft, __isl_take isl_basic_set *enforced)
416 if (!graft || !enforced)
419 isl_basic_set_free(graft->enforced);
420 graft->enforced = enforced;
422 return graft;
425 return isl_ast_graft_free(graft);
429 * also enforced by "graft".
432 __isl_take isl_basic_set *enforced, __isl_keep isl_ast_graft *graft,
438 enforced_g = isl_ast_graft_get_enforced(graft);
482 /* Merge "graft" into the last graft of "list".
483 * body points to the then or else branch of an if node in that last graft.
485 * We attach graft->node to this branch and update the enforced
486 * set of the last graft of "list" to take into account the enforced
487 * set of "graft".
491 __isl_keep isl_ast_node **body, __isl_take isl_ast_graft *graft,
502 if (n < 0 || depth < 0 || !graft)
504 extend_body(body, isl_ast_node_copy(graft->node));
513 enforced = update_enforced(enforced, graft, depth);
517 isl_ast_graft_free(graft);
520 isl_ast_graft_free(graft);
524 /* Merge "graft" into the last graft of "list", attaching graft->node
529 __isl_keep isl_ast_node *last_if, __isl_take isl_ast_graft *graft,
532 return graft_extend_body(list, &last_if->u.i.then, graft, build);
535 /* Merge "graft" into the last graft of "list", attaching graft->node
540 __isl_keep isl_ast_node *last_if, __isl_take isl_ast_graft *graft,
543 return graft_extend_body(list, &last_if->u.i.else_node, graft, build);
573 /* For each graft in "list",
574 * insert an if node around graft->node testing the condition encoded
575 * in graft->guard, assuming graft->guard involves any conditions.
579 * If the guard of a graft is a subset of either the guard or its complement
581 * of the new graft is inserted into the then or else branch of the last graft
582 * and the current graft is discarded.
585 * Otherwise, the current graft is appended to the list.
619 isl_ast_graft *graft;
623 graft = isl_ast_graft_list_get_ast_graft(list, i);
624 if (!graft)
630 test = isl_set_copy(graft->guard);
653 graft = isl_ast_graft_free(graft);
657 guard = isl_set_copy(graft->guard);
659 graft->guard = isl_set_gist(graft->guard,
662 graft->guard = isl_set_gist(graft->guard,
665 node = graft->node;
666 if (!graft->guard)
667 graft = isl_ast_graft_free(graft);
668 graft = insert_pending_guard_node(graft, build);
669 if (graft && graft->node != node && i != n - 1) {
671 if_node[n_if].node = graft->node;
685 if (!graft)
690 graft, build);
693 graft, build);
695 res = isl_ast_graft_list_add(res, graft);
706 /* For each graft in "list",
707 * insert an if node around graft->node testing the condition encoded
708 * in graft->guard, assuming graft->guard involves any conditions.
725 isl_ast_graft *graft;
727 graft = isl_ast_graft_list_get_ast_graft(list, i);
728 if (!graft)
730 isl_set_free(graft->guard);
731 graft->guard = isl_set_copy(universe);
732 if (!graft->guard)
733 graft = isl_ast_graft_free(graft);
734 list = isl_ast_graft_list_set_ast_graft(list, i, graft);
760 isl_ast_graft *graft;
762 graft = isl_ast_graft_list_get_ast_graft(list, i);
763 node = isl_ast_graft_get_node(graft);
765 isl_ast_graft_free(graft);
795 isl_ast_graft *graft;
797 graft = isl_ast_graft_list_get_ast_graft(list, i);
798 enforced = update_enforced(enforced, graft, depth);
799 isl_ast_graft_free(graft);
805 /* Record "guard" in "graft" so that it will be enforced somewhere
806 * up the tree. If the graft already has a guard, then it may be partially
813 static __isl_give isl_ast_graft *store_guard(__isl_take isl_ast_graft *graft,
818 if (!graft)
826 return graft;
829 graft->guard = isl_set_intersect(graft->guard, guard);
830 graft->guard = isl_set_gist(graft->guard,
832 graft->guard = isl_set_coalesce(graft->guard);
833 if (!graft->guard)
834 return isl_ast_graft_free(graft);
836 return graft;
839 return isl_ast_graft_free(graft);
842 /* For each graft in "list", replace its guard with the gist with
856 isl_ast_graft *graft;
858 graft = isl_ast_graft_list_get_ast_graft(list, i);
859 if (!graft)
861 graft->guard = isl_set_gist(graft->guard,
863 if (!graft->guard)
864 graft = isl_ast_graft_free(graft);
865 list = isl_ast_graft_list_set_ast_graft(list, i, graft);
873 /* For each graft in "list", replace its guard with the gist with
885 /* Allocate a graft in "build" based on the list of grafts in "sub_build".
887 * of the allocated graft. The guard is used to simplify the guards
903 isl_ast_graft *graft;
916 graft = isl_ast_graft_alloc(node, build);
917 graft = store_guard(graft, guard, build);
918 graft = isl_ast_graft_enforce(graft, enforced);
920 return graft;
923 /* Combine the grafts in the list into a single graft.
933 * or the new graft will be used at the same level.
941 isl_ast_graft *graft;
950 graft = isl_ast_graft_alloc_from_children(list, guard, enforced,
953 return graft;
956 /* Combine the grafts in the list into a single graft.
957 * Return a list containing this single graft.
965 isl_ast_graft *graft;
972 graft = ast_graft_list_fuse(list, build);
973 return isl_ast_graft_list_from_ast_graft(graft);
976 /* Combine the two grafts into a single graft.
977 * Return a list containing this single graft.
995 /* Insert a for node enclosing the current graft->node.
998 __isl_take isl_ast_graft *graft, __isl_take isl_ast_node *node)
1000 if (!graft)
1003 graft->node = isl_ast_node_for_set_body(node, graft->node);
1004 if (!graft->node)
1005 return isl_ast_graft_free(graft);
1007 return graft;
1010 isl_ast_graft_free(graft);
1014 /* Insert a mark governing the current graft->node.
1017 __isl_take isl_ast_graft *graft, __isl_take isl_id *mark)
1019 if (!graft)
1022 graft->node = isl_ast_node_alloc_mark(mark, graft->node);
1023 if (!graft->node)
1024 return isl_ast_graft_free(graft);
1026 return graft;
1029 isl_ast_graft_free(graft);
1033 /* Represent the graft list as an AST node.
1050 __isl_null isl_ast_graft *isl_ast_graft_free(__isl_take isl_ast_graft *graft)
1052 if (!graft)
1055 if (--graft->ref > 0)
1058 isl_ast_node_free(graft->node);
1059 isl_set_free(graft->guard);
1060 isl_basic_set_free(graft->enforced);
1061 free(graft);
1067 * "enforced" by intersecting graft->enforced with "enforced".
1070 __isl_take isl_ast_graft *graft, __isl_take isl_basic_set *enforced)
1072 if (!graft || !enforced)
1076 isl_basic_set_get_space(graft->enforced));
1077 graft->enforced = isl_basic_set_align_params(graft->enforced,
1079 graft->enforced = isl_basic_set_intersect(graft->enforced, enforced);
1080 if (!graft->enforced)
1081 return isl_ast_graft_free(graft);
1083 return graft;
1086 return isl_ast_graft_free(graft);
1090 __isl_keep isl_ast_graft *graft)
1092 return graft ? isl_basic_set_copy(graft->enforced) : NULL;
1095 __isl_give isl_set *isl_ast_graft_get_guard(__isl_keep isl_ast_graft *graft)
1097 return graft ? isl_set_copy(graft->guard) : NULL;
1100 /* Record that "guard" needs to be inserted in "graft".
1103 __isl_take isl_ast_graft *graft,
1106 return store_guard(graft, guard, build);
1109 /* Reformulate the "graft", which was generated in the context
1123 __isl_give isl_ast_graft *isl_ast_graft_unembed(__isl_take isl_ast_graft *graft,
1128 if (!graft)
1132 enforced = graft->enforced;
1134 graft->enforced = enforced;
1135 graft->guard = isl_map_domain(isl_set_unwrap(graft->guard));
1137 graft->enforced = isl_basic_set_params(graft->enforced);
1138 graft->guard = isl_set_params(graft->guard);
1140 graft->guard = isl_set_compute_divs(graft->guard);
1142 if (!graft->enforced || !graft->guard)
1143 return isl_ast_graft_free(graft);
1145 return graft;
1162 isl_ast_graft *graft;
1164 graft = isl_ast_graft_list_get_ast_graft(list, i);
1165 graft = isl_ast_graft_unembed(graft, product);
1166 list = isl_ast_graft_list_set_ast_graft(list, i, graft);
1172 /* Compute the preimage of "graft" under the function represented by "ma".
1173 * In other words, plug in "ma" in "enforced" and "guard" fields of "graft".
1176 __isl_take isl_ast_graft *graft, __isl_take isl_multi_aff *ma)
1180 if (!graft)
1183 enforced = graft->enforced;
1184 graft->enforced = isl_basic_set_preimage_multi_aff(enforced,
1186 graft->guard = isl_set_preimage_multi_aff(graft->guard, ma);
1188 if (!graft->enforced || !graft->guard)
1189 return isl_ast_graft_free(graft);
1191 return graft;
1207 isl_ast_graft *graft;
1209 graft = isl_ast_graft_list_get_ast_graft(list, i);
1210 graft = isl_ast_graft_preimage_multi_aff(graft,
1212 list = isl_ast_graft_list_set_ast_graft(list, i, graft);
1236 * merging grafts with the same guard into a single graft.
1243 * but if the guard of a graft in "list2" is disjoint from the guards
1277 isl_ast_graft *graft;
1278 graft = isl_ast_graft_list_get_ast_graft(list2, i);
1279 if (!graft)
1290 graft->guard);
1292 disjoint = isl_set_is_disjoint(graft->guard,
1295 isl_ast_graft_free(graft);
1306 graft);
1313 graft_j = isl_ast_graft_fuse(graft_j, graft, build);
1320 isl_ast_graft_free(graft);
1351 /* Add "graft" to the list associated to its guard in data->guard2list.
1352 * If some other graft was already associated to this guard,
1355 static isl_stat add_to_guard_list(__isl_take isl_ast_graft *graft, void *user)
1361 if (!graft)
1363 m = isl_set_to_ast_graft_list_try_get(data->guard2list, graft->guard);
1365 return isl_stat_non_null(isl_ast_graft_free(graft));
1369 m.value = isl_ast_graft_list_add(m.value, graft);
1371 m.value = isl_ast_graft_list_from_ast_graft(graft);
1373 guard = isl_set_copy(graft->guard);
1485 __isl_keep isl_ast_graft *graft)
1489 if (!graft)
1495 p = isl_printer_print_set(p, graft->guard);
1499 p = isl_printer_print_basic_set(p, graft->enforced);
1503 p = isl_printer_print_ast_node(p, graft->node);