def testConstants(self): with self.module.function_context("constants", [], []) as fun: E.constant_float(1.23, self.module.make_scalar_type("bf16")) E.constant_float(1.23, self.module.make_scalar_type("f16")) E.constant_float(1.23, self.module.make_scalar_type("f32")) E.constant_float(1.23, self.module.make_scalar_type("f64")) E.constant_int(1, 1) E.constant_int(123, 8) E.constant_int(123, 16) E.constant_int(123, 32) E.constant_int(123, 64) E.constant_index(123) E.constant_function(fun) code = str(fun) self.assertIn("constant 1.230000e+00 : bf16", code) self.assertIn("constant 1.230470e+00 : f16", code) self.assertIn("constant 1.230000e+00 : f32", code) self.assertIn("constant 1.230000e+00 : f64", code) self.assertIn("constant 1 : i1", code) self.assertIn("constant 123 : i8", code) self.assertIn("constant 123 : i16", code) self.assertIn("constant 123 : i32", code) self.assertIn("constant 123 : index", code) self.assertIn("constant @constants : () -> ()", code)
def testSelectOp(self): self.setUp() with self.module.function_context("foo", [self.boolType], [self.i32Type]) as fun: a = E.constant_int(42, 32) b = E.constant_int(0, 32) E.ret([E.select(fun.arg(0), a, b)]) printWithCurrentFunctionName(str(fun))
def testSelectOp(self): with self.module.function_context("foo", [self.boolType], [self.i32Type]) as fun: a = E.constant_int(42, 32) b = E.constant_int(0, 32) E.ret([E.select(fun.arg(0), a, b)]) code = str(fun) self.assertIn("%0 = select %arg0, %c42_i32, %c0_i32 : i32", code)
def testConstants(self): self.setUp() with self.module.function_context("constants", [], []) as fun: E.constant_float(1.23, self.module.make_scalar_type("bf16")) E.constant_float(1.23, self.module.make_scalar_type("f16")) E.constant_float(1.23, self.module.make_scalar_type("f32")) E.constant_float(1.23, self.module.make_scalar_type("f64")) E.constant_int(1, 1) E.constant_int(123, 8) E.constant_int(123, 16) E.constant_int(123, 32) E.constant_int(123, 64) E.constant_index(123) E.constant_function(fun) printWithCurrentFunctionName(str(fun))
def testType(self): self.setUp() printWithCurrentFunctionName("") with self.module.function_context( "foo", [self.module.make_memref_type(self.f32Type, [10])], []) as fun: c42 = E.constant_int(42, 32) print(str(c42.type())) print(str(fun.arg(0).type()))