mirror of https://github.com/m-labs/artiq.git
coredevice: add compile method
This commit is contained in:
parent
5e046dc5ce
commit
fda4ee1a83
|
@ -103,20 +103,23 @@ class Core(AutoDB):
|
|||
remove_dead_code(func_def)
|
||||
debug_unparse("remove_dead_code_2", func_def)
|
||||
|
||||
def run(self, k_function, k_args, k_kwargs):
|
||||
# transform/simplify AST
|
||||
def compile(self, k_function, k_args, k_kwargs, with_attr_writeback=True):
|
||||
debug_unparse = _make_debug_unparse("remove_dead_code_2")
|
||||
|
||||
func_def, rpc_map, exception_map = inline(
|
||||
self, k_function, k_args, k_kwargs)
|
||||
self, k_function, k_args, k_kwargs, with_attr_writeback)
|
||||
debug_unparse("inline", func_def)
|
||||
|
||||
self.transform_stack(func_def, rpc_map, exception_map, debug_unparse)
|
||||
|
||||
# compile to machine code and run
|
||||
binary = get_runtime_binary(self.runtime_env, func_def)
|
||||
|
||||
return binary, rpc_map, exception_map
|
||||
|
||||
def run(self, k_function, k_args, k_kwargs):
|
||||
binary, rpc_map, exception_map = self.compile(
|
||||
k_function, k_args, k_kwargs)
|
||||
self.comm.load(binary)
|
||||
self.comm.run(func_def.name)
|
||||
self.comm.run(k_function.__name__)
|
||||
self.comm.serve(rpc_map, exception_map)
|
||||
|
||||
@kernel
|
||||
|
|
|
@ -467,7 +467,7 @@ def get_attr_writeback(attribute_namespace, rpc_mapper, loc_node):
|
|||
return attr_writeback
|
||||
|
||||
|
||||
def inline(core, k_function, k_args, k_kwargs):
|
||||
def inline(core, k_function, k_args, k_kwargs, with_attr_writeback):
|
||||
# OrderedDict prevents non-determinism in attribute init
|
||||
attribute_namespace = OrderedDict()
|
||||
in_use_names = copy(embeddable_func_names)
|
||||
|
@ -486,6 +486,7 @@ def inline(core, k_function, k_args, k_kwargs):
|
|||
kwargs=k_kwargs)
|
||||
|
||||
func_def.body[0:0] = get_attr_init(attribute_namespace, func_def)
|
||||
if with_attr_writeback:
|
||||
func_def.body += get_attr_writeback(attribute_namespace, mappers.rpc,
|
||||
func_def)
|
||||
|
||||
|
|
Loading…
Reference in New Issue