예제 #1
0
def gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i):
    if (hex_common.is_pair(regid)):
        f.write(", %s" % (def_helper_types_pair[regtype]))
    elif (hex_common.is_single(regid)):
        f.write(", %s" % (def_helper_types[regtype]))
    else:
        print("Bad register parse: ",regtype,regid,toss,numregs)
예제 #2
0
def genptr_dst_write_opn(f, regtype, regid, tag):
    if (hex_common.is_pair(regid)):
        genptr_dst_write(f, tag, regtype, regid)
    elif (hex_common.is_single(regid)):
        genptr_dst_write(f, tag, regtype, regid)
    else:
        print("Bad register parse: ", regtype, regid, toss, numregs)
예제 #3
0
def gen_helper_dest_decl_opn(f, regtype, regid, i):
    if (hex_common.is_pair(regid)):
        gen_helper_dest_decl_pair(f, regtype, regid, i)
    elif (hex_common.is_single(regid)):
        gen_helper_dest_decl(f, regtype, regid, i)
    else:
        print("Bad register parse: ", regtype, regid, toss, numregs)
예제 #4
0
def genptr_src_read_opn(f, regtype, regid, tag):
    if (hex_common.is_pair(regid)):
        genptr_src_read(f, regtype, regid)
    elif (hex_common.is_single(regid)):
        if hex_common.is_old_val(regtype, regid, tag):
            genptr_src_read(f, regtype, regid)
        elif hex_common.is_new_val(regtype, regid, tag):
            genptr_src_read_new(f, regtype, regid)
        else:
            print("Bad register parse: ", regtype, regid, toss, numregs)
    else:
        print("Bad register parse: ", regtype, regid, toss, numregs)
예제 #5
0
def genptr_decl_opn(f, tag, regtype, regid, toss, numregs, i):
    if (hex_common.is_pair(regid)):
        genptr_decl(f, tag, regtype, regid, i)
    elif (hex_common.is_single(regid)):
        if hex_common.is_old_val(regtype, regid, tag):
            genptr_decl(f, tag, regtype, regid, i)
        elif hex_common.is_new_val(regtype, regid, tag):
            genptr_decl_new(f, regtype, regid, i)
        else:
            print("Bad register parse: ", regtype, regid, toss, numregs)
    else:
        print("Bad register parse: ", regtype, regid, toss, numregs)
예제 #6
0
def gen_helper_arg_opn(f, regtype, regid, i, tag):
    if (hex_common.is_pair(regid)):
        gen_helper_arg_pair(f, regtype, regid, i)
    elif (hex_common.is_single(regid)):
        if hex_common.is_old_val(regtype, regid, tag):
            gen_helper_arg(f, regtype, regid, i)
        elif hex_common.is_new_val(regtype, regid, tag):
            gen_helper_arg_new(f, regtype, regid, i)
        else:
            print("Bad register parse: ", regtype, regid, toss, numregs)
    else:
        print("Bad register parse: ", regtype, regid, toss, numregs)
예제 #7
0
def gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i):
    if (i > 0): f.write(", ")
    if (hex_common.is_pair(regid)):
        f.write("%s%sV" % (regtype, regid))
    elif (hex_common.is_single(regid)):
        if hex_common.is_old_val(regtype, regid, tag):
            f.write("%s%sV" % (regtype, regid))
        elif hex_common.is_new_val(regtype, regid, tag):
            f.write("%s%sN" % (regtype, regid))
        else:
            print("Bad register parse: ", regtype, regid, toss, numregs)
    else:
        print("Bad register parse: ", regtype, regid, toss, numregs)
예제 #8
0
def gen_helper_return_opn(f, regtype, regid, i):
    if (hex_common.is_pair(regid)):
        if (hex_common.is_hvx_reg(regtype)):
            gen_helper_dst_write_ext_pair(f, regtype, regid)
        else:
            gen_helper_return_pair(f, regtype, regid, i)
    elif (hex_common.is_single(regid)):
        if (hex_common.is_hvx_reg(regtype)):
            gen_helper_dst_write_ext(f, regtype, regid)
        else:
            gen_helper_return(f, regtype, regid, i)
    else:
        print("Bad register parse: ", regtype, regid, toss, numregs)
예제 #9
0
def genptr_dst_write_opn(f, regtype, regid, tag):
    if (hex_common.is_pair(regid)):
        if (hex_common.is_hvx_reg(regtype)):
            if (hex_common.is_tmp_result(tag)):
                genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP")
            else:
                genptr_dst_write_ext(f, tag, regtype, regid)
        else:
            genptr_dst_write(f, tag, regtype, regid)
    elif (hex_common.is_single(regid)):
        if (hex_common.is_hvx_reg(regtype)):
            if (hex_common.is_new_result(tag)):
                genptr_dst_write_ext(f, tag, regtype, regid, "EXT_NEW")
            if (hex_common.is_tmp_result(tag)):
                genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP")
            else:
                genptr_dst_write_ext(f, tag, regtype, regid, "EXT_DFL")
        else:
            genptr_dst_write(f, tag, regtype, regid)
    else:
        print("Bad register parse: ", regtype, regid, toss, numregs)
예제 #10
0
def genptr_dst_write_opn(f, regtype, regid, tag):
    if (hex_common.is_pair(regid)):
        if (hex_common.is_hvx_reg(regtype)):
            if ('A_CVI_TMP' in hex_common.attribdict[tag]
                    or 'A_CVI_TMP_DST' in hex_common.attribdict[tag]):
                genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP")
            else:
                genptr_dst_write_ext(f, tag, regtype, regid)
        else:
            genptr_dst_write(f, tag, regtype, regid)
    elif (hex_common.is_single(regid)):
        if (hex_common.is_hvx_reg(regtype)):
            if 'A_CVI_NEW' in hex_common.attribdict[tag]:
                genptr_dst_write_ext(f, tag, regtype, regid, "EXT_NEW")
            elif 'A_CVI_TMP' in hex_common.attribdict[tag]:
                genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP")
            elif 'A_CVI_TMP_DST' in hex_common.attribdict[tag]:
                genptr_dst_write_ext(f, tag, regtype, regid, "EXT_TMP")
            else:
                genptr_dst_write_ext(f, tag, regtype, regid, "EXT_DFL")
        else:
            genptr_dst_write(f, tag, regtype, regid)
    else:
        print("Bad register parse: ", regtype, regid, toss, numregs)
예제 #11
0
def gen_helper_function(f, tag, tagregs, tagimms):
    regs = tagregs[tag]
    imms = tagimms[tag]

    numresults = 0
    numscalarresults = 0
    numscalarreadwrite = 0
    for regtype, regid, toss, numregs in regs:
        if (hex_common.is_written(regid)):
            numresults += 1
            if (hex_common.is_scalar_reg(regtype)):
                numscalarresults += 1
        if (hex_common.is_readwrite(regid)):
            if (hex_common.is_scalar_reg(regtype)):
                numscalarreadwrite += 1

    if (numscalarresults > 1):
        ## The helper is bogus when there is more than one result
        f.write(
            "void HELPER(%s)(CPUHexagonState *env) { BOGUS_HELPER(%s); }\n" %
            (tag, tag))
    else:
        ## The return type of the function is the type of the destination
        ## register (if scalar)
        i = 0
        for regtype, regid, toss, numregs in regs:
            if (hex_common.is_written(regid)):
                if (hex_common.is_pair(regid)):
                    if (hex_common.is_hvx_reg(regtype)):
                        continue
                    else:
                        gen_helper_return_type_pair(f, regtype, regid, i)
                elif (hex_common.is_single(regid)):
                    if (hex_common.is_hvx_reg(regtype)):
                        continue
                    else:
                        gen_helper_return_type(f, regtype, regid, i)
                else:
                    print("Bad register parse: ", regtype, regid, toss,
                          numregs)
            i += 1

        if (numscalarresults == 0):
            f.write("void")
        f.write(" HELPER(%s)(CPUHexagonState *env" % tag)

        ## Arguments include the vector destination operands
        i = 1
        for regtype, regid, toss, numregs in regs:
            if (hex_common.is_written(regid)):
                if (hex_common.is_pair(regid)):
                    if (hex_common.is_hvx_reg(regtype)):
                        gen_helper_arg_ext_pair(f, regtype, regid, i)
                    else:
                        continue
                elif (hex_common.is_single(regid)):
                    if (hex_common.is_hvx_reg(regtype)):
                        gen_helper_arg_ext(f, regtype, regid, i)
                    else:
                        # This is the return value of the function
                        continue
                else:
                    print("Bad register parse: ", regtype, regid, toss,
                          numregs)
                i += 1

        ## Arguments to the helper function are the source regs and immediates
        for regtype, regid, toss, numregs in regs:
            if (hex_common.is_read(regid)):
                if (hex_common.is_hvx_reg(regtype)
                        and hex_common.is_readwrite(regid)):
                    continue
                gen_helper_arg_opn(f, regtype, regid, i, tag)
                i += 1
        for immlett, bits, immshift in imms:
            gen_helper_arg_imm(f, immlett)
            i += 1

        if hex_common.need_slot(tag):
            if i > 0: f.write(", ")
            f.write("uint32_t slot")
            i += 1
        if hex_common.need_part1(tag):
            if i > 0: f.write(", ")
            f.write("uint32_t part1")
        f.write(")\n{\n")
        if (not hex_common.need_slot(tag)):
            f.write("    uint32_t slot __attribute__((unused)) = 4;\n")
        if hex_common.need_ea(tag): gen_decl_ea(f)
        ## Declare the return variable
        i = 0
        for regtype, regid, toss, numregs in regs:
            if (hex_common.is_writeonly(regid)):
                gen_helper_dest_decl_opn(f, regtype, regid, i)
            i += 1

        for regtype, regid, toss, numregs in regs:
            if (hex_common.is_read(regid)):
                if (hex_common.is_pair(regid)):
                    if (hex_common.is_hvx_reg(regtype)):
                        gen_helper_src_var_ext_pair(f, regtype, regid, i)
                elif (hex_common.is_single(regid)):
                    if (hex_common.is_hvx_reg(regtype)):
                        gen_helper_src_var_ext(f, regtype, regid)
                else:
                    print("Bad register parse: ", regtype, regid, toss,
                          numregs)

        if 'A_FPOP' in hex_common.attribdict[tag]:
            f.write('    arch_fpop_start(env);\n')

        f.write("    %s\n" % hex_common.semdict[tag])

        if 'A_FPOP' in hex_common.attribdict[tag]:
            f.write('    arch_fpop_end(env);\n')

        ## Save/return the return variable
        for regtype, regid, toss, numregs in regs:
            if (hex_common.is_written(regid)):
                gen_helper_return_opn(f, regtype, regid, i)
        f.write("}\n\n")