def test_cycle_2(): assembler = MockAssembler() s8 = stack_pos(8, 1) s12 = stack_pos(12, 1) s20 = stack_pos(19, 1) s24 = stack_pos(1, 1) s2 = stack_pos(2, 1) s3 = stack_pos(3, 1) remap_stack_layout(assembler, [eax, s8, edi, s20, eax, s20, s24, esi, s2, s3], [s8, s20, edi, eax, edx, s24, ebx, s12, s3, s2], ecx) assert assembler.got([('mov', eax, edx), ('mov', s24, ebx), ('mov', esi, s12), ('mov', s20, ecx), ('mov', ecx, s24), ('push', s8), ('mov', eax, s8), ('mov', s20, eax), ('pop', s20), ('push', s3), ('mov', s2, ecx), ('mov', ecx, s3), ('pop', s2)])
def consider_jump(self, op, ignored): assembler = self.assembler assert self.jump_target_descr is None descr = op.descr assert isinstance(descr, LoopToken) self.jump_target_descr = descr nonfloatlocs, floatlocs = assembler.target_arglocs(self.jump_target_descr) # compute 'tmploc' to be all_regs[0] by spilling what is there box = TempBox() box1 = TempBox() tmpreg = X86RegisterManager.all_regs[0] tmploc = self.rm.force_allocate_reg(box, selected_reg=tmpreg) xmmtmp = X86XMMRegisterManager.all_regs[0] xmmtmploc = self.xrm.force_allocate_reg(box1, selected_reg=xmmtmp) # Part about non-floats src_locations = [self.loc(arg) for arg in op.args if arg.type != FLOAT] assert tmploc not in nonfloatlocs dst_locations = [loc for loc in nonfloatlocs if loc is not None] remap_stack_layout(assembler, src_locations, dst_locations, tmploc) # Part about floats src_locations = [self.loc(arg) for arg in op.args if arg.type == FLOAT] dst_locations = [loc for loc in floatlocs if loc is not None] remap_stack_layout(assembler, src_locations, dst_locations, xmmtmp) self.rm.possibly_free_var(box) self.xrm.possibly_free_var(box1) self.possibly_free_vars(op.args) assembler.closing_jump(self.jump_target_descr)
def test_constants(): assembler = MockAssembler() c3 = imm(3) remap_stack_layout(assembler, [c3], [eax], '?') assert assembler.ops == [('mov', c3, eax)] assembler = MockAssembler() s12 = stack_pos(12, 1) remap_stack_layout(assembler, [c3], [s12], '?') assert assembler.ops == [('mov', c3, s12)]
def test_constants_and_cycle(): assembler = MockAssembler() c3 = imm(3) s12 = stack_pos(13, 1) remap_stack_layout(assembler, [ebx, c3, s12], [s12, eax, ebx], edi) assert assembler.ops == [('mov', c3, eax), ('push', s12), ('mov', ebx, s12), ('pop', ebx)]
def test_simple_stacklocs(): assembler = MockAssembler() s8 = stack_pos(0, 1) s12 = stack_pos(13, 1) s20 = stack_pos(20, 1) s24 = stack_pos(221, 1) remap_stack_layout(assembler, [s8, eax, s12], [s20, s24, edi], edx) assert assembler.ops == [('mov', s8, edx), ('mov', edx, s20), ('mov', eax, s24), ('mov', s12, edi)]
def test_reordering(): assembler = MockAssembler() s8 = stack_pos(8, 1) s12 = stack_pos(12, 1) s20 = stack_pos(19, 1) s24 = stack_pos(1, 1) remap_stack_layout(assembler, [eax, s8, s20, ebx], [s8, ebx, eax, edi], '?') assert assembler.got([('mov', ebx, edi), ('mov', s8, ebx), ('mov', eax, s8), ('mov', s20, eax)])
def test_cycle(): assembler = MockAssembler() s8 = stack_pos(8, 1) s12 = stack_pos(12, 1) s20 = stack_pos(19, 1) s24 = stack_pos(1, 1) remap_stack_layout(assembler, [eax, s8, s20, ebx], [s8, ebx, eax, s20], '?') assert assembler.got([('push', s8), ('mov', eax, s8), ('mov', s20, eax), ('mov', ebx, s20), ('pop', ebx)])
def test_trivial(): assembler = MockAssembler() remap_stack_layout(assembler, [], [], '?') assert assembler.ops == [] remap_stack_layout(assembler, [eax, ebx, ecx, edx, esi, edi], [eax, ebx, ecx, edx, esi, edi], '?') assert assembler.ops == [] s8 = stack_pos(1, 1) s12 = stack_pos(31, 1) s20 = stack_pos(6, 1) remap_stack_layout(assembler, [eax, ebx, ecx, s20, s8, edx, s12, esi, edi], [eax, ebx, ecx, s20, s8, edx, s12, esi, edi], '?') assert assembler.ops == []
def test_simple_registers(): assembler = MockAssembler() remap_stack_layout(assembler, [eax, ebx, ecx], [edx, esi, edi], '?') assert assembler.ops == [('mov', eax, edx), ('mov', ebx, esi), ('mov', ecx, edi)]