Example #1
0
 def generate_CALL(self, op):
     calldescr = op.descr
     assert isinstance(calldescr, CallDescr)
     ty_function_ptr = self.cpu.get_calldescr_ty_function_ptr(calldescr)
     v = op.args[0]
     if isinstance(v, Const):
         func = self.cpu._make_const(v.getint(), ty_function_ptr)
     else:
         func = self.getintarg(v)
         func = llvm_rffi.LLVMBuildIntToPtr(self.builder,
                                            func,
                                            ty_function_ptr, "")
     nb_args = len(op.args) - 1
     arglist = lltype.malloc(rffi.CArray(llvm_rffi.LLVMValueRef), nb_args,
                             flavor='raw')
     for i in range(nb_args):
         v = op.args[1 + i]
         index = calldescr.args_indices[i]
         getarg = self.cpu.getarg_by_index[index]
         value_ref = getarg(self, v)
         arglist[i] = value_ref
     res = llvm_rffi.LLVMBuildCall(self.builder,
                                   func, arglist, nb_args, "")
     lltype.free(arglist, flavor='raw')
     if op.result is not None:
         assert calldescr.res_index >= 0
         self.vars[op.result] = res
Example #2
0
 def _generate_new(self, size_ref):
     malloc_func = self.cpu._make_const(self.cpu.malloc_fn_ptr,
                                        self.cpu.ty_malloc_fn)
     arglist = lltype.malloc(rffi.CArray(llvm_rffi.LLVMValueRef), 1,
                             flavor='raw')
     arglist[0] = size_ref
     res = llvm_rffi.LLVMBuildCall(self.builder, malloc_func,
                                   arglist, 1, "")
     lltype.free(arglist, flavor='raw')
     return res
Example #3
0
 def _generate_ovf_test(self, f_intrinsic, arg0, arg1, result):
     arglist = lltype.malloc(rffi.CArray(llvm_rffi.LLVMValueRef), 2,
                             flavor='raw')
     arglist[0] = arg0
     arglist[1] = arg1
     tmp = llvm_rffi.LLVMBuildCall(self.builder, f_intrinsic,
                                   arglist, 2, "")
     lltype.free(arglist, flavor='raw')
     self.vars[result] = llvm_rffi.LLVMBuildExtractValue(self.builder,
                                                         tmp, 0, "")
     self.lastovf = llvm_rffi.LLVMBuildExtractValue(self.builder, tmp, 1,
                                                    "")