Пример #1
0
    def test_create_gen_kill(self):
        s1 = S('command', 'addu', '$3', '$1', '$2')
        s2 = S('command', 'addu', '$1', '$3', 10)
        s3 = S('command', 'subu', '$3', '$1', 5)
        s4 = S('command', 'li', '$4', '0x00000001')
        block = B([s1, s2, s3, s4])

        create_gen_kill(block, get_defs([block]))

        self.assertEqual(block.gen_set, set([s2.sid, s3.sid, s4.sid]))
        self.assertEqual(block.kill_set, set([s1.sid]))
Пример #2
0
    def test_get_defs(self):
        s1 = S('command', 'add', '$3', '$1', '$2')
        s2 = S('command', 'move', '$1', '$3')
        s3 = S('command', 'move', '$3', '$2')
        s4 = S('command', 'li', '$4', '0x00000001')
        block = B([s1, s2, s3, s4])

        self.assertEqual(get_defs([block]), {
            '$3': set([s1.sid, s3.sid]),
            '$1': set([s2.sid]),
            '$4': set([s4.sid])
        })