00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "espresso.h"
00022
00023 pcover make_sparse(F, D, R)
00024 pcover F, D, R;
00025 {
00026 cost_t cost, best_cost;
00027
00028 cover_cost(F, &best_cost);
00029
00030 do {
00031 EXECUTE(F = mv_reduce(F, D), MV_REDUCE_TIME, F, cost);
00032 if (cost.total == best_cost.total)
00033 break;
00034 copy_cost(&cost, &best_cost);
00035
00036 EXECUTE(F = expand(F, R, TRUE), RAISE_IN_TIME, F, cost);
00037 if (cost.total == best_cost.total)
00038 break;
00039 copy_cost(&cost, &best_cost);
00040 } while (force_irredundant);
00041
00042 return F;
00043 }
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 pcover
00060 mv_reduce(F, D)
00061 pcover F, D;
00062 {
00063 register int i, var;
00064 register pcube p, p1, last;
00065 int index;
00066 pcover F1, D1;
00067 pcube *F_cube_table;
00068
00069
00070 for(var = 0; var < cube.num_vars; var++) {
00071
00072 if (cube.sparse[var]) {
00073
00074
00075 for(i = cube.first_part[var]; i <= cube.last_part[var]; i++) {
00076
00077
00078 F_cube_table = ALLOC(pcube, F->count);
00079
00080
00081 F1 = new_cover(F->count);
00082 foreach_set(F, last, p) {
00083 if (is_in_set(p, i)) {
00084 F_cube_table[F1->count] = p;
00085 p1 = GETSET(F1, F1->count++);
00086 (void) set_diff(p1, p, cube.var_mask[var]);
00087 set_insert(p1, i);
00088 }
00089 }
00090
00091
00092
00093 D1 = new_cover(D->count);
00094 foreach_set(D, last, p) {
00095 if (is_in_set(p, i)) {
00096 p1 = GETSET(D1, D1->count++);
00097 (void) set_diff(p1, p, cube.var_mask[var]);
00098 set_insert(p1, i);
00099 }
00100 }
00101
00102 mark_irredundant(F1, D1);
00103
00104
00105 index = 0;
00106 foreach_set(F1, last, p1) {
00107 if (! TESTP(p1, ACTIVE)) {
00108 p = F_cube_table[index];
00109
00110
00111
00112
00113 if (var == cube.num_vars-1 ||
00114 ! setp_implies(cube.var_mask[var], p)) {
00115 set_remove(p, i);
00116 }
00117 RESET(p, PRIME);
00118 }
00119 index++;
00120 }
00121
00122 free_cover(F1);
00123 free_cover(D1);
00124 FREE(F_cube_table);
00125 }
00126 }
00127 }
00128
00129
00130 (void) sf_active(F);
00131 for(var = 0; var < cube.num_vars; var++) {
00132 if (cube.sparse[var]) {
00133 foreach_active_set(F, last, p) {
00134 if (setp_disjoint(p, cube.var_mask[var])) {
00135 RESET(p, ACTIVE);
00136 F->active_count--;
00137 }
00138 }
00139 }
00140 }
00141
00142 if (F->count != F->active_count) {
00143 F = sf_inactive(F);
00144 }
00145 return F;
00146 }