def visitCMPLInstr(self, n): global spilled global unspillable # What a pain, the right-hand operand can't be a constant! left = n.rhs[0] right = n.rhs[1] if not ((is_memory_access(left, self.color) and \ is_memory_access(right, self.color)) or \ isinstance(right, Const)): return [n] elif not isinstance(left, Const) and isinstance(right, Const): return [CMPLInstr(None, [right, left])] else: spilled[0] = True if debug: print 'need to introduce spill code for ' + repr(n) if in_register(left, self.color): new_left = left left_instr = [] else: tmp = generate_name('tmp') unspillable[0] = unspillable[0] + [tmp] new_left = Name(tmp) left_instr = [IntMoveInstr(new_left, [left])] if is_memory_access(right, self.color): tmp = generate_name('tmp') unspillable[0] = unspillable[0] + [tmp] new_right = Name(tmp) right_instr = [IntMoveInstr(new_right, [right])] else: new_right = right right_instr = [] return left_instr + right_instr + [CMPLInstr(None, [new_left, new_right])]
def visitIntMoveZeroExtendInstr(self, n): global spilled global unspillable if in_register(n.lhs, self.color): return [n] else: spilled[0] = True if debug: print 'need to introduce spill code for ' + repr(n) tmp = generate_name('tmp') unspillable[0] = unspillable[0] + [tmp] return [IntMoveZeroExtendInstr(Name(tmp), [n.rhs[0]]), IntMoveInstr(n.lhs, [Name(tmp)])]