kconfig: remove 'e1' and 'e2' macros from expression deduplication
I do not think the macros 'e1' and 'e2' are readable. The statement: e1 = expr_alloc_symbol(...); affects the caller's variable, but this is not sufficiently clear from the code. Remove the macros. No functional change intended. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
parent
94a4b0a4cb
commit
3c2f84ceda
@ -135,9 +135,6 @@ void expr_free(struct expr *e)
|
|||||||
|
|
||||||
static int trans_count;
|
static int trans_count;
|
||||||
|
|
||||||
#define e1 (*ep1)
|
|
||||||
#define e2 (*ep2)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* expr_eliminate_eq() helper.
|
* expr_eliminate_eq() helper.
|
||||||
*
|
*
|
||||||
@ -150,38 +147,38 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e
|
|||||||
{
|
{
|
||||||
/* Recurse down to leaves */
|
/* Recurse down to leaves */
|
||||||
|
|
||||||
if (e1->type == type) {
|
if ((*ep1)->type == type) {
|
||||||
__expr_eliminate_eq(type, &e1->left.expr, &e2);
|
__expr_eliminate_eq(type, &(*ep1)->left.expr, ep2);
|
||||||
__expr_eliminate_eq(type, &e1->right.expr, &e2);
|
__expr_eliminate_eq(type, &(*ep1)->right.expr, ep2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e2->type == type) {
|
if ((*ep2)->type == type) {
|
||||||
__expr_eliminate_eq(type, &e1, &e2->left.expr);
|
__expr_eliminate_eq(type, ep1, &(*ep2)->left.expr);
|
||||||
__expr_eliminate_eq(type, &e1, &e2->right.expr);
|
__expr_eliminate_eq(type, ep1, &(*ep2)->right.expr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* e1 and e2 are leaves. Compare them. */
|
/* *ep1 and *ep2 are leaves. Compare them. */
|
||||||
|
|
||||||
if (e1->type == E_SYMBOL && e2->type == E_SYMBOL &&
|
if ((*ep1)->type == E_SYMBOL && (*ep2)->type == E_SYMBOL &&
|
||||||
e1->left.sym == e2->left.sym &&
|
(*ep1)->left.sym == (*ep2)->left.sym &&
|
||||||
(e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no))
|
((*ep1)->left.sym == &symbol_yes || (*ep1)->left.sym == &symbol_no))
|
||||||
return;
|
return;
|
||||||
if (!expr_eq(e1, e2))
|
if (!expr_eq(*ep1, *ep2))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* e1 and e2 are equal leaves. Prepare them for elimination. */
|
/* *ep1 and *ep2 are equal leaves. Prepare them for elimination. */
|
||||||
|
|
||||||
trans_count++;
|
trans_count++;
|
||||||
expr_free(e1); expr_free(e2);
|
expr_free(*ep1); expr_free(*ep2);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case E_OR:
|
case E_OR:
|
||||||
e1 = expr_alloc_symbol(&symbol_no);
|
*ep1 = expr_alloc_symbol(&symbol_no);
|
||||||
e2 = expr_alloc_symbol(&symbol_no);
|
*ep2 = expr_alloc_symbol(&symbol_no);
|
||||||
break;
|
break;
|
||||||
case E_AND:
|
case E_AND:
|
||||||
e1 = expr_alloc_symbol(&symbol_yes);
|
*ep1 = expr_alloc_symbol(&symbol_yes);
|
||||||
e2 = expr_alloc_symbol(&symbol_yes);
|
*ep2 = expr_alloc_symbol(&symbol_yes);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
@ -219,29 +216,26 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e
|
|||||||
*/
|
*/
|
||||||
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
|
void expr_eliminate_eq(struct expr **ep1, struct expr **ep2)
|
||||||
{
|
{
|
||||||
if (!e1 || !e2)
|
if (!*ep1 || !*ep2)
|
||||||
return;
|
return;
|
||||||
switch (e1->type) {
|
switch ((*ep1)->type) {
|
||||||
case E_OR:
|
case E_OR:
|
||||||
case E_AND:
|
case E_AND:
|
||||||
__expr_eliminate_eq(e1->type, ep1, ep2);
|
__expr_eliminate_eq((*ep1)->type, ep1, ep2);
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
if (e1->type != e2->type) switch (e2->type) {
|
if ((*ep1)->type != (*ep2)->type) switch ((*ep2)->type) {
|
||||||
case E_OR:
|
case E_OR:
|
||||||
case E_AND:
|
case E_AND:
|
||||||
__expr_eliminate_eq(e2->type, ep1, ep2);
|
__expr_eliminate_eq((*ep2)->type, ep1, ep2);
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
e1 = expr_eliminate_yn(e1);
|
*ep1 = expr_eliminate_yn(*ep1);
|
||||||
e2 = expr_eliminate_yn(e2);
|
*ep2 = expr_eliminate_yn(*ep2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef e1
|
|
||||||
#undef e2
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns true if 'e1' and 'e2' are equal, after minor simplification. Two
|
* Returns true if 'e1' and 'e2' are equal, after minor simplification. Two
|
||||||
* &&/|| expressions are considered equal if every operand in one expression
|
* &&/|| expressions are considered equal if every operand in one expression
|
||||||
@ -564,59 +558,55 @@ static struct expr *expr_join_and(struct expr *e1, struct expr *e2)
|
|||||||
*/
|
*/
|
||||||
static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2)
|
static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2)
|
||||||
{
|
{
|
||||||
#define e1 (*ep1)
|
|
||||||
#define e2 (*ep2)
|
|
||||||
struct expr *tmp;
|
struct expr *tmp;
|
||||||
|
|
||||||
/* Recurse down to leaves */
|
/* Recurse down to leaves */
|
||||||
|
|
||||||
if (e1->type == type) {
|
if ((*ep1)->type == type) {
|
||||||
expr_eliminate_dups1(type, &e1->left.expr, &e2);
|
expr_eliminate_dups1(type, &(*ep1)->left.expr, ep2);
|
||||||
expr_eliminate_dups1(type, &e1->right.expr, &e2);
|
expr_eliminate_dups1(type, &(*ep1)->right.expr, ep2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e2->type == type) {
|
if ((*ep2)->type == type) {
|
||||||
expr_eliminate_dups1(type, &e1, &e2->left.expr);
|
expr_eliminate_dups1(type, ep1, &(*ep2)->left.expr);
|
||||||
expr_eliminate_dups1(type, &e1, &e2->right.expr);
|
expr_eliminate_dups1(type, ep1, &(*ep2)->right.expr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* e1 and e2 are leaves. Compare and process them. */
|
/* *ep1 and *ep2 are leaves. Compare and process them. */
|
||||||
|
|
||||||
if (e1 == e2)
|
if (*ep1 == *ep2)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (e1->type) {
|
switch ((*ep1)->type) {
|
||||||
case E_OR: case E_AND:
|
case E_OR: case E_AND:
|
||||||
expr_eliminate_dups1(e1->type, &e1, &e1);
|
expr_eliminate_dups1((*ep1)->type, ep1, ep1);
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case E_OR:
|
case E_OR:
|
||||||
tmp = expr_join_or(e1, e2);
|
tmp = expr_join_or(*ep1, *ep2);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
expr_free(e1); expr_free(e2);
|
expr_free(*ep1); expr_free(*ep2);
|
||||||
e1 = expr_alloc_symbol(&symbol_no);
|
*ep1 = expr_alloc_symbol(&symbol_no);
|
||||||
e2 = tmp;
|
*ep2 = tmp;
|
||||||
trans_count++;
|
trans_count++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case E_AND:
|
case E_AND:
|
||||||
tmp = expr_join_and(e1, e2);
|
tmp = expr_join_and(*ep1, *ep2);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
expr_free(e1); expr_free(e2);
|
expr_free(*ep1); expr_free(*ep2);
|
||||||
e1 = expr_alloc_symbol(&symbol_yes);
|
*ep1 = expr_alloc_symbol(&symbol_yes);
|
||||||
e2 = tmp;
|
*ep2 = tmp;
|
||||||
trans_count++;
|
trans_count++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
#undef e1
|
|
||||||
#undef e2
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user