Skip to content

Commit

Permalink
Move IDENTITY and DOMINATOR out of boolexpr.h
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdrake committed Jun 11, 2015
1 parent 5de672c commit 5120faf
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions extension/boolexpr/argset.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,12 @@ BX_OrAndArgSet_Insert(struct BX_OrAndArgSet *argset, struct BoolExpr *key)
{
/* 1 | x = 1 ; 0 & x = 0 */
/* x | 0 = x ; x & 1 = x */
if (argset->max || key == IDENTITY[argset->kind])
if (argset->max || key == _bx_identity[argset->kind])
return true;

bool dominate = false;
/* x | 1 = 1 ; x & 0 = 0 */
if (key == DOMINATOR[argset->kind]) {
if (key == _bx_dominator[argset->kind]) {
dominate = true;
}
/* x | ~x = 1 ; x & ~x = 0 */
Expand Down Expand Up @@ -108,10 +108,10 @@ BX_OrAndArgSet_Reduce(struct BX_OrAndArgSet *argset)
size_t length = argset->xs->length;

if (argset->min)
return BX_IncRef(IDENTITY[argset->kind]);
return BX_IncRef(_bx_identity[argset->kind]);

if (argset->max)
return BX_IncRef(DOMINATOR[argset->kind]);
return BX_IncRef(_bx_dominator[argset->kind]);

CHECK_NULL(xs, _set2array(argset->xs));

Expand Down Expand Up @@ -215,7 +215,7 @@ BX_XorArgSet_Reduce(struct BX_XorArgSet *argset)
size_t length = argset->xs->length;

if (length == 0) {
temp = BX_IncRef(IDENTITY[BX_OP_XOR]);
temp = BX_IncRef(_bx_identity[BX_OP_XOR]);
y = argset->parity ? BX_IncRef(temp) : BX_Not(temp);
BX_DecRef(temp);
return y;
Expand Down
6 changes: 3 additions & 3 deletions extension/boolexpr/boolexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ struct BoolExpr BX_One = {1, BX_ONE, BX_NNF | BX_SIMPLE, {.pcval=2}};
struct BoolExpr BX_Logical = {1, BX_LOGICAL, BX_NNF | BX_SIMPLE, {.pcval=3}};
struct BoolExpr BX_Illogical = {1, BX_ILLOGICAL, BX_NNF | BX_SIMPLE, {.pcval=0}};

struct BoolExpr * IDENTITY[16] = {
struct BoolExpr * _bx_identity[16] = {
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
&BX_Zero, &BX_One, &BX_Zero, NULL,
NULL, NULL, NULL, NULL,
};

struct BoolExpr * DOMINATOR[16] = {
struct BoolExpr * _bx_dominator[16] = {
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
&BX_One, &BX_Zero, NULL, NULL,
Expand Down Expand Up @@ -205,7 +205,7 @@ struct BoolExpr *
_bx_orandxor_new(BX_Kind kind, size_t n, struct BoolExpr **xs)
{
if (n == 0)
return BX_IncRef(IDENTITY[kind]);
return BX_IncRef(_bx_identity[kind]);

if (n == 1)
return BX_IncRef(xs[0]);
Expand Down
3 changes: 0 additions & 3 deletions extension/boolexpr/boolexpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ extern struct BoolExpr BX_One;
extern struct BoolExpr BX_Logical;
extern struct BoolExpr BX_Illogical;

extern struct BoolExpr * IDENTITY[16];
extern struct BoolExpr * DOMINATOR[16];


/*
** Return a literal expression.
Expand Down
2 changes: 1 addition & 1 deletion extension/boolexpr/product.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static struct BX_Array *
_product(BX_Kind kind, size_t n, struct BX_Array **arrays)
{
if (n == 0) {
struct BoolExpr *items[] = {IDENTITY[kind]};
struct BoolExpr *items[] = {_bx_identity[kind]};
return BX_Array_New(1, items);
}

Expand Down
3 changes: 3 additions & 0 deletions extension/boolexpr/share.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
struct BX_Array * _bx_array_from(size_t length, struct BoolExpr **items);

/* boolexpr.c */
extern struct BoolExpr * _bx_identity[16];
extern struct BoolExpr * _bx_dominator[16];

struct BoolExpr * _bx_op_from(BX_Kind kind, size_t n, struct BoolExpr **xs);
struct BoolExpr * _bx_op_new(BX_Kind kind, size_t n, struct BoolExpr **xs);
struct BoolExpr * _bx_orandxor_new(BX_Kind kind, size_t n, struct BoolExpr **xs);
Expand Down
14 changes: 7 additions & 7 deletions extension/boolexpr/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,27 +119,27 @@ _orand_simplify(struct BoolExpr *op)
for (size_t i = 0; i < op->data.xs->length; ++i) {
xi = op->data.xs->items[i];
/* Or(1, x) <=> 1 */
if (xi == DOMINATOR[op->kind]) {
if (xi == _bx_dominator[op->kind]) {
free(flat);
return BX_IncRef(DOMINATOR[op->kind]);
return BX_IncRef(_bx_dominator[op->kind]);
}
/* Or(Or(x0, x1), x2) <=> Or(x0, x1, x2) */
else if (xi->kind == op->kind) {
for (size_t j = 0; j < xi->data.xs->length; ++j) {
xj = xi->data.xs->items[j];
/* Or(1, x) <=> 1 */
if (xj == DOMINATOR[op->kind]) {
if (xj == _bx_dominator[op->kind]) {
free(flat);
return BX_IncRef(DOMINATOR[op->kind]);
return BX_IncRef(_bx_dominator[op->kind]);
}
/* Or(0, x) <=> x */
else if (xj != IDENTITY[op->kind]) {
else if (xj != _bx_identity[op->kind]) {
flat[flat_len++] = xj;
}
}
}
/* Or(0, x) <=> x */
else if (xi != IDENTITY[op->kind]) {
else if (xi != _bx_identity[op->kind]) {
flat[flat_len++] = xi;
}
}
Expand All @@ -163,7 +163,7 @@ _orand_simplify(struct BoolExpr *op)
if (COMPLEMENTARY(uniq[uniq_len-1], flat[i])) {
free(flat);
free(uniq);
return BX_IncRef(DOMINATOR[op->kind]);
return BX_IncRef(_bx_dominator[op->kind]);
}
/* Or(x, x) <=> x */
else if (!_eq(flat[i], uniq[uniq_len-1])) {
Expand Down

0 comments on commit 5120faf

Please sign in to comment.