def generate_GUARD_EXCEPTION(self, op): v = op.args[0] assert isinstance(v, Const) # etype, expectedtype: ty_char_ptr expectedtype = self.cpu._make_const(v.getint(), self.cpu.ty_char_ptr) etype = llvm_rffi.LLVMBuildLoad(self.builder, self.cpu.const_exc_type, "") eisequal = llvm_rffi.LLVMBuildICmp(self.builder, llvm_rffi.Predicate.EQ, etype, expectedtype, "") self._generate_guard(op, eisequal, False, exc=True) self.vars[op.result] = llvm_rffi.LLVMBuildLoad( self.builder, self.cpu.const_exc_value, "")
def _store_away_exception(self): # etype, evalue: ty_char_ptr etype = llvm_rffi.LLVMBuildLoad(self.builder, self.cpu.const_exc_type, "") llvm_rffi.LLVMBuildStore(self.builder, self.cpu.const_null_charptr, self.cpu.const_exc_type) llvm_rffi.LLVMBuildStore(self.builder, etype, self.cpu.const_backup_exc_type) evalue = llvm_rffi.LLVMBuildLoad(self.builder, self.cpu.const_exc_value, "") llvm_rffi.LLVMBuildStore(self.builder, self.cpu.const_null_charptr, self.cpu.const_exc_value) llvm_rffi.LLVMBuildStore(self.builder, evalue, self.cpu.const_backup_exc_value)
def generate_GUARD_CLASS(self, op): loc = self._generate_field_gep(op.args[0], self.cpu.fielddescr_vtable) cls = llvm_rffi.LLVMBuildLoad(self.builder, loc, "") equal = llvm_rffi.LLVMBuildICmp(self.builder, llvm_rffi.Predicate.EQ, cls, self.getintarg(op.args[1]), "") self._generate_guard(op, equal, False)
def generate_GUARD_NO_EXCEPTION(self, op): # etype: ty_char_ptr etype = llvm_rffi.LLVMBuildLoad(self.builder, self.cpu.const_exc_type, "") eisnull = llvm_rffi.LLVMBuildICmp(self.builder, llvm_rffi.Predicate.EQ, etype, self.cpu.const_null_charptr, "") self._generate_guard(op, eisnull, False, exc=True)
def generate_initial_arguments_load(self): loop = self.loop func = self.compiling_func bb_entry = llvm_rffi.LLVMAppendBasicBlock(func, "entry") llvm_rffi.LLVMPositionBuilderAtEnd(self.builder, bb_entry) self.cpu._ensure_in_args(len(loop.inputargs)) self.phi_incoming_blocks = [bb_entry] self.phi_incoming_values = [] for i in range(len(loop.inputargs)): ty = self.cpu._get_pointer_type(loop.inputargs[i]) llvmconstptr = self.cpu._make_const(self.cpu.in_out_args[i], ty) res = llvm_rffi.LLVMBuildLoad(self.builder, llvmconstptr, "") self.phi_incoming_values.append([res]) self.bb_start = llvm_rffi.LLVMAppendBasicBlock(func, "") llvm_rffi.LLVMBuildBr(self.builder, self.bb_start) # llvm_rffi.LLVMPositionBuilderAtEnd(self.builder, self.bb_start) for v in loop.inputargs: ty = self.cpu._get_var_type(v) phi = llvm_rffi.LLVMBuildPhi(self.builder, ty, "") self.vars[v] = phi
def generate_UNICODEGETITEM(self, op): loc = self._generate_gep(op, self.cpu.ty_unicode_ptr, self.cpu.const_unicode_index_array) self.vars[op.result] = llvm_rffi.LLVMBuildLoad(self.builder, loc, "")
def generate_STRGETITEM(self, op): loc = self._generate_gep(op, self.cpu.ty_string_ptr, self.cpu.const_string_index_array) self.vars[op.result] = llvm_rffi.LLVMBuildLoad(self.builder, loc, "")
def generate_GETARRAYITEM_GC(self, op): loc = self._generate_array_gep(op) self.vars[op.result] = llvm_rffi.LLVMBuildLoad(self.builder, loc, "")
def _generate_len(self, op, ty, const_index_length): loc = self._generate_len_gep(self.getptrarg(op.args[0]), ty, const_index_length) self.vars[op.result] = llvm_rffi.LLVMBuildLoad(self.builder, loc, "")
def generate_GETFIELD_GC(self, op): loc = self._generate_field_gep(op.args[0], op.descr) self.vars[op.result] = llvm_rffi.LLVMBuildLoad(self.builder, loc, "")