Пример #1
0
    def get_normal_case(self):

        s = SIMD()

        case_data = self.get_case_data()

        cases = []

        for item in case_data:
            # Recognize '#' as a commentary
            if item[0] == '#':
                cases.append('\n;; {}'.format(item[1]))
                continue
            """
            Generate assert_return
            Params: instruction: instruction name;
                    param: param for instruction;
                    ret: excepted result;
                    lane_type: lane type
            """
            instruction, param, ret, lane_type = item
            cases.append(
                str(
                    AssertReturn(instruction, [
                        s.v128_const(param[0], lane_type[0]),
                        s.v128_const(param[1], lane_type[1])
                    ], s.v128_const(ret, lane_type[2]))))

        return '\n'.join(cases)
Пример #2
0
    def init_case_data(case_data):
        """
        Rearrange const data into standard format
        e.g. [0][i32x4] => (v128.const i32x4 0 0 0 0)
             [0][i32]   => (i32.const 0)
        """

        s_i = SIMD()

        lst_i_p_r = []

        for item in case_data:
            # Recognize '#' as a commentary
            if item[0] == '#':
                comment = '\n' if len(item[1]) == 0 else '\n;; {}'.format(item[1])
                lst_i_p_r.append(['#', comment])
                continue

            # Params: instruction: instruction name;
            #         params: param for instruction;
            #         rets: excepted result;
            #         lane_type: lane type for param and ret
            instruction, params, rets, lane_type = item

            p_const_list = []
            for idx, param in enumerate(params):
                p_const_list.append(s_i.v128_const(param, lane_type[idx]))

            r_const_list = []
            for idx, ret in enumerate(rets):
                r_const_list.append(s_i.v128_const(ret, lane_type[idx + len(params)]))

            lst_i_p_r.append([instruction, p_const_list, r_const_list])

        return lst_i_p_r
Пример #3
0
    def get_normal_case(self):
        s = SIMD()
        cases = []

        # store using arg
        for (addr, ret) in self.get_case_data():
            i32_addr = s.const(addr, "i32")
            v128_val = s.v128_const(list_stringify(ret), self.LANE_TYPE)
            result = s.const(ret[addr], "i64")
            instr = "v128.store{lane_len}_lane_{idx}".format(
                lane_len=self.LANE_LEN, idx=addr)
            cases.append(str(AssertReturn(instr, [i32_addr, v128_val],
                                          result)))

        # store using offset
        for (addr, ret) in self.get_case_data():
            v128_val = s.v128_const(list_stringify(ret), self.LANE_TYPE)
            result = s.const(ret[addr], "i64")
            instr = "v128.store{lane_len}_lane_{idx}_offset_{idx}".format(
                lane_len=self.LANE_LEN, idx=addr)
            cases.append(str(AssertReturn(instr, [v128_val], result)))

        # store using offset with alignment
        for (addr, ret) in self.get_case_data():
            for align in self.valid_alignments():
                i32_addr = s.const(addr, "i32")
                v128_val = s.v128_const(list_stringify(ret), self.LANE_TYPE)
                result = s.const(ret[addr], "i64")
                instr = "v128.store{lane_len}_lane_{idx}_align_{align}".format(
                    lane_len=self.LANE_LEN, idx=addr, align=align)
                cases.append(
                    str(AssertReturn(instr, [i32_addr, v128_val], result)))

        return '\n'.join(cases)
Пример #4
0
    def get_normal_case(self):
        s = SIMD()
        case_data = self.get_case_data()
        cases = []

        for item in case_data:
            # Recognize '#' as a commentary
            if item[0] == '#':
                cases.append('\n;; {}'.format(item[1]))
                continue

            instruction, param, ret, lane_type = item
            v128_result = s.v128_const(ret, lane_type[-1])
            v128_params = []
            for i, p in enumerate(param):
                v128_params.append(s.v128_const(p, lane_type[i]))
            cases.append(
                str(AssertReturn(instruction, v128_params, v128_result)))

        return '\n'.join(cases)
Пример #5
0
    def v128_const(lane, value):

        return SIMD().v128_const(value, lane)
Пример #6
0
    def v128_const(lane, val):

        return SIMD().v128_const(val, lane)