forked from M-Labs/artiq
devices/runtime: use regular function call instead of syscall
This commit is contained in:
parent
99c99484ae
commit
de238503d2
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user