From de238503d261f423af37430af377caa7b9588a0e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 5 Jul 2014 19:39:05 +0200 Subject: [PATCH] devices/runtime: use regular function call instead of syscall --- artiq/devices/runtime.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/artiq/devices/runtime.py b/artiq/devices/runtime.py index 5d5aa764c..628f68c56 100644 --- a/artiq/devices/runtime.py +++ b/artiq/devices/runtime.py @@ -1,22 +1,16 @@ from llvm import core as lc -syscall_map = { - "rpc": 0, - "rtio_set": 1, - "rtio_sync": 2, - "dds_program": 3, -} +_syscalls = [ + ("printint", lc.Type.void(), [lc.Type.int()]) +] class Environment: + def __init__(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) + + self.module = module + def emit_syscall(self, builder, syscall_name, args): - syscall_nr = syscall_map[syscall_name] - - assert(0 <= syscall_nr <= 0xffff) - # FIXME: replace with "l.sys syscall_nr" after the LLVM problems are fixed - opcode = 0x20000000 | syscall_nr - asm_string = "\n".join(".byte 0x{:02x}".format((opcode >> 8*i) & 0xff) - for i in reversed(range(4))) - - sc_type = lc.Type.function(lc.Type.void(), []) - asm = lc.InlineAsm.get(sc_type, asm_string, "") - builder.call(asm, []) + builder.call(self.module.get_function_named("__syscall_"+syscall_name), args)