fhdl/tools: BUGFIX: fix group_by_target grouping
group_by_target does not properly combine target groups if statements are presented in the order: ({A}, statement1) ({B}, statement2) ({A, B}, statement3) which returns groups: ({A, B}, [statement1, statement3]) ({B}, [statement2]) This patch fixes group_by_target such that the resulting group is: ({A, B}, [statement1, statement2, statement3])
This commit is contained in:
parent
5b36f688ea
commit
16ebe41028
|
@ -48,20 +48,29 @@ def list_targets(node):
|
||||||
lister.visit(node)
|
lister.visit(node)
|
||||||
return lister.output_list
|
return lister.output_list
|
||||||
|
|
||||||
|
def resort_statements(ol):
|
||||||
|
return [statement for i, statement in
|
||||||
|
sorted(ol, key=lambda x: x[0])]
|
||||||
|
|
||||||
def group_by_targets(sl):
|
def group_by_targets(sl):
|
||||||
groups = []
|
groups = []
|
||||||
for statement in flat_iteration(sl):
|
for statement_order, statement in enumerate(flat_iteration(sl)):
|
||||||
targets = list_targets(statement)
|
targets = list_targets(statement)
|
||||||
processed = False
|
|
||||||
for g in groups:
|
chk_groups = [(targets.isdisjoint(g[0]), g) for g in groups]
|
||||||
if not targets.isdisjoint(g[0]):
|
merge_groups = [g for dj, g in chk_groups if not dj]
|
||||||
g[0].update(targets)
|
groups = [g for dj, g in chk_groups if dj]
|
||||||
g[1].append(statement)
|
|
||||||
processed = True
|
new_group = (set(targets), [(statement_order, statement)])
|
||||||
break
|
|
||||||
if not processed:
|
for g in merge_groups:
|
||||||
groups.append((targets, [statement]))
|
new_group[0].update(g[0])
|
||||||
return groups
|
new_group[1].extend(g[1])
|
||||||
|
|
||||||
|
groups.append(new_group)
|
||||||
|
|
||||||
|
return [(target, resort_statements(stmts))
|
||||||
|
for target, stmts in groups]
|
||||||
|
|
||||||
def list_special_ios(f, ins, outs, inouts):
|
def list_special_ios(f, ins, outs, inouts):
|
||||||
r = set()
|
r = set()
|
||||||
|
|
Loading…
Reference in New Issue