Пример #1
0
    def test_bound_inst_inference(self):
        # First example from issue #26
        x = XForm(
            Rtl(self.v0 << iadd(self.v1, self.v2), ),
            Rtl(self.v3 << uextend.i32(self.v1),
                self.v4 << uextend.i32(self.v2),
                self.v5 << iadd(self.v3, self.v4),
                self.v0 << ireduce(self.v5)))
        itype = TypeVar("t", "", ints=True, simd=True)
        i32t = TypeVar.singleton(i32)

        check_typing(x.ti, ({
            self.v0: itype,
            self.v1: itype,
            self.v2: itype,
            self.v3: i32t,
            self.v4: i32t,
            self.v5: i32t,
        }, [WiderOrEq(i32t, itype)]), x.symtab)
Пример #2
0
    def test_fully_bound_inst_inference_bad(self):
        # Incompatible bound instructions fail accordingly
        r = Rtl(
            self.v3 << uextend.i32(self.v1),
            self.v4 << uextend.i16(self.v2),
            self.v5 << iadd(self.v3, self.v4),
        )
        ti = TypeEnv()
        typing = ti_rtl(r, ti)

        self.assertEqual(
            typing, "On line 2: fail ti on `typeof_v4` <: `4`: " +
            "Error: empty type created when unifying " + "`i16` and `i32`")
Пример #3
0
    def test_bound_inst_inference(self):
        # First example from issue #26
        x = XForm(
            Rtl(
                self.v0 << iadd(self.v1, self.v2),
            ),
            Rtl(
                self.v3 << uextend.i32(self.v1),
                self.v4 << uextend.i32(self.v2),
                self.v5 << iadd(self.v3, self.v4),
                self.v0 << ireduce(self.v5)
            ))
        itype = TypeVar("t", "", ints=True, simd=True)
        i32t = TypeVar.singleton(i32)

        check_typing(x.ti, ({
            self.v0:    itype,
            self.v1:    itype,
            self.v2:    itype,
            self.v3:    i32t,
            self.v4:    i32t,
            self.v5:    i32t,
        }, [WiderOrEq(i32t, itype)]), x.symtab)
Пример #4
0
    def test_fully_bound_inst_inference_bad(self):
        # Incompatible bound instructions fail accordingly
        r = Rtl(
                self.v3 << uextend.i32(self.v1),
                self.v4 << uextend.i16(self.v2),
                self.v5 << iadd(self.v3, self.v4),
            )
        ti = TypeEnv()
        typing = ti_rtl(r, ti)

        self.assertEqual(typing,
                         "On line 2: fail ti on `typeof_v4` <: `4`: " +
                         "Error: empty type created when unifying " +
                         "`i16` and `i32`")