Esempio n. 1
0
 def testBlockContextAppend(self):
     with self.module.function_context("foo", [], []) as fun:
         E.constant_index(41)
         with E.BlockContext() as b:
             blk = b  # save block handle for later
             E.constant_index(0)
         E.constant_index(42)
         with E.BlockContext(E.appendTo(blk)):
             E.constant_index(1)
     code = str(fun)
     # Find positions of instructions and make sure they are in the block we put
     # them by comparing those positions.
     c41pos = code.find("%c41 = constant 41 : index")
     c42pos = code.find("%c42 = constant 42 : index")
     bb1pos = code.find("^bb1:")
     c0pos = code.find("%c0 = constant 0 : index")
     c1pos = code.find("%c1 = constant 1 : index")
     self.assertNotEqual(c41pos, -1)
     self.assertNotEqual(c42pos, -1)
     self.assertNotEqual(bb1pos, -1)
     self.assertNotEqual(c0pos, -1)
     self.assertNotEqual(c1pos, -1)
     self.assertGreater(bb1pos, c41pos)
     self.assertGreater(bb1pos, c42pos)
     self.assertLess(bb1pos, c0pos)
     self.assertLess(bb1pos, c1pos)
 def testBlockContextAppend(self):
     self.setUp()
     with self.module.function_context("foo", [], []) as fun:
         E.constant_index(41)
         with E.BlockContext() as b:
             blk = b  # save block handle for later
             E.constant_index(0)
         E.constant_index(42)
         with E.BlockContext(E.appendTo(blk)):
             E.constant_index(1)
         printWithCurrentFunctionName(str(fun))