[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK7LNAQwBu90CzjfSpP-sokwZMJMTq20UW-xP31gNQh+N7+GwA@mail.gmail.com>
Date: Mon, 12 Aug 2024 19:00:34 +0900
From: Masahiro Yamada <masahiroy@...nel.org>
To: Ole Schuerks <ole0811sch@...il.com>
Cc: linux-kbuild@...r.kernel.org, jude.gyimah@....de, thorsten.berger@....de,
deltaone@...ian.org, jan.sollmann@....de, mcgrof@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 06/12] kconfig: Add files for building constraints
On Mon, Aug 12, 2024 at 5:49 PM Masahiro Yamada <masahiroy@...nel.org> wrote:
>
> On Wed, Jul 10, 2024 at 3:54 PM Ole Schuerks <ole0811sch@...il.com> wrote:
> >
> > These files translate the Kconfig-model into propositional logic and store
> > the constraints for each symbol in the corresponding struct.
> >
> > Co-developed-by: Patrick Franz <deltaone@...ian.org>
> > Signed-off-by: Patrick Franz <deltaone@...ian.org>
> > Co-developed-by: Ibrahim Fayaz <phayax@...il.com>
> > Signed-off-by: Ibrahim Fayaz <phayax@...il.com>
> > Reviewed-by: Luis Chamberlain <mcgrof@...nel.org>
> > Tested-by: Evgeny Groshev <eugene.groshev@...il.com>
> > Suggested-by: Sarah Nadi <nadi@...berta.ca>
> > Suggested-by: Thorsten Berger <thorsten.berger@....de>
> > Signed-off-by: Thorsten Berger <thorsten.berger@....de>
> > Signed-off-by: Ole Schuerks <ole0811sch@...il.com>
> > ---
> > scripts/kconfig/cf_constraints.c | 1720 ++++++++++++++++++++++++++++++
> > scripts/kconfig/cf_constraints.h | 26 +
> > 2 files changed, 1746 insertions(+)
> > create mode 100644 scripts/kconfig/cf_constraints.c
> > create mode 100644 scripts/kconfig/cf_constraints.h
> >
> > diff --git a/scripts/kconfig/cf_constraints.c b/scripts/kconfig/cf_constraints.c
> > new file mode 100644
> > index 000000000000..1c02a4b47383
> > --- /dev/null
> > +++ b/scripts/kconfig/cf_constraints.c
> > @@ -0,0 +1,1720 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (C) 2023 Patrick Franz <deltaone@...ian.org>
> > + */
> > +
> > +#include "cf_defs.h"
> > +#include "expr.h"
> > +#define _GNU_SOURCE
> > +#include <assert.h>
> > +#include <locale.h>
> > +#include <stdarg.h>
> > +#include <stdbool.h>
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <string.h>
> > +#include <time.h>
> > +#include <unistd.h>
> > +
> > +#include "cf_utils.h"
> > +#include "internal.h"
> > +#include "cf_expr.h"
> > +#include "cf_constraints.h"
> > +
> > +#define KCR_CMP false
> > +#define NPC_OPTIMISATION true
> > +
> > +static void init_constraints(struct cfdata *data);
> > +static void get_constraints_bool(struct cfdata *data);
> > +static void get_constraints_select(struct cfdata *data);
> > +static void get_constraints_nonbool(struct cfdata *data);
> > +
> > +static void build_tristate_constraint_clause(struct symbol *sym,
> > + struct cfdata *data);
> > +
> > +static void add_selects_kcr(struct symbol *sym, struct cfdata *data);
> > +static void add_selects(struct symbol *sym, struct cfdata *data);
> > +
> > +static void add_dependencies_bool(struct symbol *sym, struct cfdata *data);
> > +static void add_dependencies_bool_kcr(struct symbol *sym, struct cfdata *data);
> > +static void add_dependencies_nonbool(struct symbol *sym, struct cfdata *data);
> > +
> > +static void add_choice_prompt_cond(struct symbol *sym, struct cfdata *data);
> > +static void add_choice_dependencies(struct symbol *sym, struct cfdata *data);
> > +static void add_choice_constraints(struct symbol *sym, struct cfdata *data);
> > +static void add_invisible_constraints(struct symbol *sym, struct cfdata *data);
> > +static void sym_nonbool_at_least_1(struct symbol *sym, struct cfdata *data);
> > +static void sym_nonbool_at_most_1(struct symbol *sym, struct cfdata *data);
> > +static void sym_add_nonbool_values_from_default_range(struct symbol *sym,
> > + struct cfdata *data);
> > +static void sym_add_range_constraints(struct symbol *sym, struct cfdata *data);
> > +static void sym_add_nonbool_prompt_constraint(struct symbol *sym,
> > + struct cfdata *data);
> > +
> > +static struct default_map *create_default_map_entry(struct fexpr *val,
> > + struct pexpr *e);
> > +static struct defm_list *get_defaults(struct symbol *sym, struct cfdata *data);
> > +static struct pexpr *get_default_y(struct defm_list *list, struct cfdata *data);
> > +static struct pexpr *get_default_m(struct defm_list *list, struct cfdata *data);
> > +static struct pexpr *get_default_any(struct symbol *sym, struct cfdata *data);
> > +static long sym_get_range_val(struct symbol *sym, int base);
> > +
> > +/* -------------------------------------- */
> > +
> > +/*
> > + * build the constraints for each symbol
> > + */
> > +void get_constraints(struct cfdata *data)
> > +{
> > + printd("Building constraints...");
> > +
> > + init_constraints(data);
> > + get_constraints_bool(data);
> > + get_constraints_select(data);
> > + get_constraints_nonbool(data);
> > +}
> > +
> > +/*
> > + * need to go through the constraints once to find all "known values"
> > + * for the non-Boolean symbols (and add them to sym->nb_vals for the given
> > + * symbols).
> > + * expr_calculate_pexpr_both and get_defaults have the side effect of creating
> > + * known values.
> > + */
> > +static void init_constraints(struct cfdata *data)
> > +{
> > + struct symbol *sym;
> > + struct property *p;
> > +
> > + for_all_symbols(sym) {
> > + struct property *prompt;
> > +
> > + if (sym->type == S_UNKNOWN)
> > + continue;
> > +
> > + if (sym_is_boolean(sym)) {
> > + for_all_properties(sym, p, P_SELECT)
> > + pexpr_put(expr_calculate_pexpr_both(p->visible.expr,
> > + data));
> > +
> > + for_all_properties(sym, p, P_IMPLY)
> > + pexpr_put(expr_calculate_pexpr_both(p->visible.expr,
> > + data));
>
>
>
> Does 'imply' give any constraint?
I take back this comment.
'imply' does give a constraint when the implied symbol has
no prompt.
--
Best Regards
Masahiro Yamada
Powered by blists - more mailing lists