From 61c0b65323c41397d1432858c7a20ee9c70bc1af Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 5 Jul 2014 22:48:14 +0200 Subject: [PATCH] devices/runtime: machine code emission --- artiq/devices/runtime.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/artiq/devices/runtime.py b/artiq/devices/runtime.py index 47055d2de..0cdf14910 100644 --- a/artiq/devices/runtime.py +++ b/artiq/devices/runtime.py @@ -1,4 +1,7 @@ from llvm import core as lc +from llvm import target as lt + +lt.initialize_all() _syscalls = [ ("print_int", lc.Type.void(), [lc.Type.int()]), @@ -6,7 +9,7 @@ _syscalls = [ ] class Environment: - def __init__(self, module): + def set_module(self, module): for func_name, func_type_ret, func_type_args in _syscalls: function_type = lc.Type.function(func_type_ret, func_type_args) module.add_function(function_type, "__syscall_"+func_name) @@ -15,3 +18,7 @@ class Environment: def emit_syscall(self, builder, syscall_name, args): builder.call(self.module.get_function_named("__syscall_"+syscall_name), args) + + def emit_object(self): + tm = lt.TargetMachine.new(triple="or1k", cpu="generic") + return tm.emit_object(self.module)