devices/runtime: register eh_raise service

This commit is contained in:
Sebastien Bourdeauducq 2014-09-22 13:22:04 +08:00
parent a8df1703fb
commit 5244a63b55
1 changed files with 12 additions and 0 deletions

View File

@ -52,6 +52,8 @@ def _str_to_functype(s):
class LinkInterface: class LinkInterface:
def init_module(self, module): def init_module(self, module):
self.llvm_module = module.llvm_module self.llvm_module = module.llvm_module
# syscalls
self.var_arg_fixcount = dict() self.var_arg_fixcount = dict()
for func_name, func_type_str in _syscalls.items(): for func_name, func_type_str in _syscalls.items():
var_arg_fixcount, func_type = _str_to_functype(func_type_str) var_arg_fixcount, func_type = _str_to_functype(func_type_str)
@ -59,6 +61,10 @@ class LinkInterface:
self.var_arg_fixcount[func_name] = var_arg_fixcount self.var_arg_fixcount[func_name] = var_arg_fixcount
self.llvm_module.add_function(func_type, "__syscall_"+func_name) self.llvm_module.add_function(func_type, "__syscall_"+func_name)
# eh
func_type = lc.Type.function(lc.Type.void(), [lc.Type.int()])
self.llvm_module.add_function(func_type, "__eh_raise")
def syscall(self, syscall_name, args, builder): def syscall(self, syscall_name, args, builder):
r = _chr_to_value[_syscalls[syscall_name][-1]]() r = _chr_to_value[_syscalls[syscall_name][-1]]()
if builder is not None: if builder is not None:
@ -73,6 +79,12 @@ class LinkInterface:
r.auto_store(builder, builder.call(llvm_function, args)) r.auto_store(builder, builder.call(llvm_function, args))
return r return r
def build_raise(self, eid, builder):
if builder is not None:
llvm_function = self.llvm_module.get_function_named(
"__eh_raise")
builder.call(llvm_function, [lc.Constant.int(lc.Type.int(), eid)])
def _debug_dump_obj(obj): def _debug_dump_obj(obj):
try: try: