Messages in this thread |  | | Date | Fri, 15 May 2026 16:35:47 -0300 | | From | Wander Lairson Costa <> | | Subject | Re: [PATCH 06/13] verification/rvgen: Convert __fill_verify_guards_func() to Lark |
| |
On Tue, May 05, 2026 at 08:59:27AM +0200, Nam Cao wrote: > Prepare to remove self.guards and self.__parse_constraints(), convert > __fill_verify_guards_func() to use the parsed transitions from Lark. > > Signed-off-by: Nam Cao <namcao@linutronix.de> > --- > tools/verification/rvgen/rvgen/dot2k.py | 39 ++++++++++++++++++++----- > 1 file changed, 31 insertions(+), 8 deletions(-) > > diff --git a/tools/verification/rvgen/rvgen/dot2k.py b/tools/verification/rvgen/rvgen/dot2k.py > index 3a39ae29e41e..cf7e5ddc649c 100644 > --- a/tools/verification/rvgen/rvgen/dot2k.py > +++ b/tools/verification/rvgen/rvgen/dot2k.py > @@ -221,6 +221,20 @@ class ha2k(dot2k): > def __parse_single_constraint(self, rule: dict, value: str) -> str: > return f"ha_get_env(ha_mon, {rule["env"]}{self.enum_suffix}, time_ns) {rule["op"]} {value}" > > + def __parse_guard_rule(self, rule) -> str: > + buff = [] > + for c, sep in rule.rules: > + env = c.env + self.enum_suffix > + op = c.op > + val = self.__adjust_value(c.val, c.unit) > + > + cond = f"ha_get_env(ha_mon, {env}, time_ns) {op} {val}" > + if sep: > + cond += f" {sep}" > + buff.append(cond) > + buff[-1] += ';' > + return buff > + > def __get_constraint_env(self, constr: str) -> str: > """Extract the second argument from an ha_ function""" > env = constr.split("(")[1].split()[1].rstrip(")").rstrip(",") > @@ -398,8 +412,9 @@ f"""static inline void ha_convert_inv_guard(struct ha_monitor *ha_mon, > > def __fill_verify_guards_func(self) -> list[str]: > buff = [] > - if not self.guards: > - return [] > + > + if not self.has_guard: > + return
The signature of function says this function return a list, instead of None.
> > buff.append( > f"""static inline bool ha_verify_guards(struct ha_monitor *ha_mon, > @@ -410,14 +425,22 @@ f"""static inline bool ha_verify_guards(struct ha_monitor *ha_mon, > """) > > _else = "" > - for edge, constr in sorted(self.guards.items()): > + for transition in self.transitions: > + if not transition.rule and not transition.reset: > + continue > + > buff.append(f"\t{_else}if (curr_state == " > - f"{self.states[edge[0]]}{self.enum_suffix} && " > - f"event == {self.events[edge[1]]}{self.enum_suffix})") > - if constr.count(";") > 0: > + f"{transition.src}{self.enum_suffix} && " > + f"event == {transition.event}{self.enum_suffix})") > + rule = transition.rule > + reset = transition.reset > + if rule and reset: > buff[-1] += " {" > - buff += [f"\t\t{c};" for c in constr.split(";")] > - if constr.count(";") > 0: > + if rule: > + buff.append("\t\t" + self.__format_guard_rules(self.__parse_guard_rule(rule))[0]) > + if reset: > + buff.append(f"\t\tha_reset_env(ha_mon, {reset.env}{self.enum_suffix}, time_ns);") > + if rule and reset: > _else = "} else " > else: > _else = "else " > -- > 2.47.3 >
|  |