Пример #1
0
 def _generate_guard(self, op, verify_condition, reversed, exc=False):
     func = self.compiling_func
     bb_on_track = llvm_rffi.LLVMAppendBasicBlock(func, "")
     bb_off_track = llvm_rffi.LLVMAppendBasicBlock(func, "")
     llvm_rffi.LLVMBuildCondBr(self.builder, verify_condition,
                               bb_on_track, bb_off_track)
     if reversed:
         bb_on_track, bb_off_track = bb_off_track, bb_on_track
     # generate the on-track part first, and the off-track part later
     self.pending_blocks.append((op.suboperations, bb_off_track, exc))
     llvm_rffi.LLVMPositionBuilderAtEnd(self.builder, bb_on_track)
Пример #2
0
 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
Пример #3
0
 def _generate_branch(self, operations, basicblock, exc):
     llvm_rffi.LLVMPositionBuilderAtEnd(self.builder, basicblock)
     # The flag 'exc' is set to True if we are a branch handling a
     # GUARD_EXCEPTION or GUARD_NO_EXCEPTION.  In this case, we have to
     # store away the exception into self.backup_exc_xxx, *unless* the
     # branch starts with a further GUARD_EXCEPTION/GUARD_NO_EXCEPTION.
     if exc:
         opnum = operations[0].opnum
         if opnum not in (rop.GUARD_EXCEPTION, rop.GUARD_NO_EXCEPTION):
             self._store_away_exception()
     # Normal handling of the operations follows.
     for op in operations:
         self._generate_op(op)