mirror of https://github.com/m-labs/artiq.git
transforms.interleaver: determine when inlining is not necessary.
This commit is contained in:
parent
af43c66149
commit
73845279ae
|
@ -25,6 +25,9 @@ def delay_free_subgraph(root, limit):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def is_pure_delay(insn):
|
||||||
|
return isinstance(insn, ir.Builtin) and insn.op in ("delay", "delay_mu")
|
||||||
|
|
||||||
class Interleaver:
|
class Interleaver:
|
||||||
def __init__(self, engine):
|
def __init__(self, engine):
|
||||||
self.engine = engine
|
self.engine = engine
|
||||||
|
@ -98,14 +101,26 @@ class Interleaver:
|
||||||
if target_time_delta > 0:
|
if target_time_delta > 0:
|
||||||
assert isinstance(source_terminator, ir.Delay)
|
assert isinstance(source_terminator, ir.Delay)
|
||||||
|
|
||||||
if isinstance(old_decomp, ir.Builtin) and \
|
if is_pure_delay(old_decomp):
|
||||||
old_decomp.op in ("delay", "delay_mu"):
|
|
||||||
new_decomp_expr = ir.Constant(target_time_delta, builtins.TInt64())
|
new_decomp_expr = ir.Constant(target_time_delta, builtins.TInt64())
|
||||||
new_decomp = ir.Builtin("delay_mu", [new_decomp_expr], builtins.TNone())
|
new_decomp = ir.Builtin("delay_mu", [new_decomp_expr], builtins.TNone())
|
||||||
new_decomp.loc = old_decomp.loc
|
new_decomp.loc = old_decomp.loc
|
||||||
source_terminator.basic_block.insert(source_terminator, new_decomp)
|
source_terminator.basic_block.insert(source_terminator, new_decomp)
|
||||||
else:
|
else: # It's a call.
|
||||||
old_decomp, new_decomp = None, old_decomp
|
need_to_inline = False
|
||||||
|
for other_source_block in filter(lambda block: block != source_block,
|
||||||
|
source_blocks):
|
||||||
|
other_source_terminator = other_source_block.terminator()
|
||||||
|
if not (is_pure_delay(other_source_terminator.decomposition()) and \
|
||||||
|
iodelay.is_const(other_source_terminator.expr) and \
|
||||||
|
other_source_terminator.expr.fold().value >= source_block_delay):
|
||||||
|
need_to_inline = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if need_to_inline:
|
||||||
|
assert False
|
||||||
|
else:
|
||||||
|
old_decomp, new_decomp = None, old_decomp
|
||||||
|
|
||||||
source_terminator.replace_with(ir.Delay(iodelay.Const(target_time_delta), {},
|
source_terminator.replace_with(ir.Delay(iodelay.Const(target_time_delta), {},
|
||||||
new_decomp, source_terminator.target()))
|
new_decomp, source_terminator.target()))
|
||||||
|
|
Loading…
Reference in New Issue