mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-27 03:51:57 -06:00
Hexagon (target/hexagon) Remove gen_log_predicated_reg_write[_pair]
We assign the instruction destination register to hex_new_value[num] instead of a TCG temp that gets copied back to hex_new_value[num]. We introduce new functions get_result_gpr[_pair] to facilitate getting the proper destination register. Since we preload hex_new_value for predicated instructions, we don't need the check for slot_cancelled. So, we call gen_log_reg_write instead. We update the helper function generation and gen_tcg.h to maintain the disable-hexagon-idef-parser configuration. Here is a simple example of the differences in the TCG code generated: IN: 0x00400094: 0xf900c102 { if (P0) R2 = and(R0,R1) } BEFORE ---- 00400094 mov_i32 slot_cancelled,$0x0 mov_i32 new_r2,r2 mov_i32 loc2,$0x0 and_i32 tmp0,p0,$0x1 brcond_i32 tmp0,$0x0,eq,$L1 and_i32 tmp0,r0,r1 mov_i32 loc2,tmp0 br $L2 set_label $L1 or_i32 slot_cancelled,slot_cancelled,$0x8 set_label $L2 and_i32 tmp0,slot_cancelled,$0x8 movcond_i32 new_r2,tmp0,$0x0,loc2,new_r2,eq mov_i32 r2,new_r2 AFTER ---- 00400094 mov_i32 slot_cancelled,$0x0 mov_i32 new_r2,r2 and_i32 tmp0,p0,$0x1 brcond_i32 tmp0,$0x0,eq,$L1 and_i32 tmp0,r0,r1 mov_i32 new_r2,tmp0 br $L2 set_label $L1 or_i32 slot_cancelled,slot_cancelled,$0x8 set_label $L2 mov_i32 r2,new_r2 We'll remove the unnecessary manipulation of slot_cancelled in a subsequent patch. Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> Reviewed-by: Anton Johansson <anjo@rev.ng> Message-Id: <20230307025828.1612809-13-tsimpson@quicinc.com>
This commit is contained in:
parent
1a442c0931
commit
e28b77a6b4
8 changed files with 110 additions and 152 deletions
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
##
|
##
|
||||||
## Copyright(c) 2019-2022 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
||||||
##
|
##
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## This program is free software; you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
@ -226,6 +226,14 @@ def gen_helper_function(f, tag, tagregs, tagimms):
|
||||||
print("Bad register parse: ",regtype,regid,toss,numregs)
|
print("Bad register parse: ",regtype,regid,toss,numregs)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
## For conditional instructions, we pass in the destination register
|
||||||
|
if 'A_CONDEXEC' in hex_common.attribdict[tag]:
|
||||||
|
for regtype, regid, toss, numregs in regs:
|
||||||
|
if (hex_common.is_writeonly(regid) and
|
||||||
|
not hex_common.is_hvx_reg(regtype)):
|
||||||
|
gen_helper_arg_opn(f, regtype, regid, i, tag)
|
||||||
|
i += 1
|
||||||
|
|
||||||
## Arguments to the helper function are the source regs and immediates
|
## Arguments to the helper function are the source regs and immediates
|
||||||
for regtype,regid,toss,numregs in regs:
|
for regtype,regid,toss,numregs in regs:
|
||||||
if (hex_common.is_read(regid)):
|
if (hex_common.is_read(regid)):
|
||||||
|
@ -262,10 +270,11 @@ def gen_helper_function(f, tag, tagregs, tagimms):
|
||||||
if hex_common.need_ea(tag): gen_decl_ea(f)
|
if hex_common.need_ea(tag): gen_decl_ea(f)
|
||||||
## Declare the return variable
|
## Declare the return variable
|
||||||
i=0
|
i=0
|
||||||
for regtype,regid,toss,numregs in regs:
|
if 'A_CONDEXEC' not in hex_common.attribdict[tag]:
|
||||||
if (hex_common.is_writeonly(regid)):
|
for regtype,regid,toss,numregs in regs:
|
||||||
gen_helper_dest_decl_opn(f,regtype,regid,i)
|
if (hex_common.is_writeonly(regid)):
|
||||||
i += 1
|
gen_helper_dest_decl_opn(f,regtype,regid,i)
|
||||||
|
i += 1
|
||||||
|
|
||||||
for regtype,regid,toss,numregs in regs:
|
for regtype,regid,toss,numregs in regs:
|
||||||
if (hex_common.is_read(regid)):
|
if (hex_common.is_read(regid)):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
##
|
##
|
||||||
## Copyright(c) 2019-2022 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
||||||
##
|
##
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## This program is free software; you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
@ -87,6 +87,7 @@ def gen_helper_prototype(f, tag, tagregs, tagimms):
|
||||||
if hex_common.need_slot(tag): def_helper_size += 1
|
if hex_common.need_slot(tag): def_helper_size += 1
|
||||||
if hex_common.need_PC(tag): def_helper_size += 1
|
if hex_common.need_PC(tag): def_helper_size += 1
|
||||||
if hex_common.helper_needs_next_PC(tag): def_helper_size += 1
|
if hex_common.helper_needs_next_PC(tag): def_helper_size += 1
|
||||||
|
if hex_common.need_condexec_reg(tag, regs): def_helper_size += 1
|
||||||
f.write('DEF_HELPER_%s(%s' % (def_helper_size, tag))
|
f.write('DEF_HELPER_%s(%s' % (def_helper_size, tag))
|
||||||
## The return type is void
|
## The return type is void
|
||||||
f.write(', void' )
|
f.write(', void' )
|
||||||
|
@ -96,6 +97,7 @@ def gen_helper_prototype(f, tag, tagregs, tagimms):
|
||||||
if hex_common.need_part1(tag): def_helper_size += 1
|
if hex_common.need_part1(tag): def_helper_size += 1
|
||||||
if hex_common.need_slot(tag): def_helper_size += 1
|
if hex_common.need_slot(tag): def_helper_size += 1
|
||||||
if hex_common.need_PC(tag): def_helper_size += 1
|
if hex_common.need_PC(tag): def_helper_size += 1
|
||||||
|
if hex_common.need_condexec_reg(tag, regs): def_helper_size += 1
|
||||||
if hex_common.helper_needs_next_PC(tag): def_helper_size += 1
|
if hex_common.helper_needs_next_PC(tag): def_helper_size += 1
|
||||||
f.write('DEF_HELPER_%s(%s' % (def_helper_size, tag))
|
f.write('DEF_HELPER_%s(%s' % (def_helper_size, tag))
|
||||||
|
|
||||||
|
@ -121,6 +123,14 @@ def gen_helper_prototype(f, tag, tagregs, tagimms):
|
||||||
gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
|
gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
|
## For conditional instructions, we pass in the destination register
|
||||||
|
if 'A_CONDEXEC' in hex_common.attribdict[tag]:
|
||||||
|
for regtype, regid, toss, numregs in regs:
|
||||||
|
if (hex_common.is_writeonly(regid) and
|
||||||
|
not hex_common.is_hvx_reg(regtype)):
|
||||||
|
gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
|
||||||
|
i += 1
|
||||||
|
|
||||||
## Generate the qemu type for each input operand (regs and immediates)
|
## Generate the qemu type for each input operand (regs and immediates)
|
||||||
for regtype,regid,toss,numregs in regs:
|
for regtype,regid,toss,numregs in regs:
|
||||||
if (hex_common.is_read(regid)):
|
if (hex_common.is_read(regid)):
|
||||||
|
|
|
@ -332,8 +332,6 @@
|
||||||
tcg_gen_movi_tl(EA, 0); \
|
tcg_gen_movi_tl(EA, 0); \
|
||||||
PRED; \
|
PRED; \
|
||||||
CHECK_NOSHUF_PRED(GET_EA, SIZE, LSB); \
|
CHECK_NOSHUF_PRED(GET_EA, SIZE, LSB); \
|
||||||
PRED_LOAD_CANCEL(LSB, EA); \
|
|
||||||
tcg_gen_movi_tl(RdV, 0); \
|
|
||||||
tcg_gen_brcondi_tl(TCG_COND_EQ, LSB, 0, label); \
|
tcg_gen_brcondi_tl(TCG_COND_EQ, LSB, 0, label); \
|
||||||
fLOAD(1, SIZE, SIGN, EA, RdV); \
|
fLOAD(1, SIZE, SIGN, EA, RdV); \
|
||||||
gen_set_label(label); \
|
gen_set_label(label); \
|
||||||
|
@ -391,8 +389,6 @@
|
||||||
tcg_gen_movi_tl(EA, 0); \
|
tcg_gen_movi_tl(EA, 0); \
|
||||||
PRED; \
|
PRED; \
|
||||||
CHECK_NOSHUF_PRED(GET_EA, 8, LSB); \
|
CHECK_NOSHUF_PRED(GET_EA, 8, LSB); \
|
||||||
PRED_LOAD_CANCEL(LSB, EA); \
|
|
||||||
tcg_gen_movi_i64(RddV, 0); \
|
|
||||||
tcg_gen_brcondi_tl(TCG_COND_EQ, LSB, 0, label); \
|
tcg_gen_brcondi_tl(TCG_COND_EQ, LSB, 0, label); \
|
||||||
fLOAD(1, 8, u, EA, RddV); \
|
fLOAD(1, 8, u, EA, RddV); \
|
||||||
gen_set_label(label); \
|
gen_set_label(label); \
|
||||||
|
@ -504,7 +500,7 @@
|
||||||
*/
|
*/
|
||||||
#define fGEN_TCG_SL2_return(SHORTCODE) \
|
#define fGEN_TCG_SL2_return(SHORTCODE) \
|
||||||
do { \
|
do { \
|
||||||
TCGv_i64 RddV = tcg_temp_new_i64(); \
|
TCGv_i64 RddV = get_result_gpr_pair(ctx, HEX_REG_FP); \
|
||||||
gen_return(ctx, RddV, hex_gpr[HEX_REG_FP]); \
|
gen_return(ctx, RddV, hex_gpr[HEX_REG_FP]); \
|
||||||
gen_log_reg_write_pair(HEX_REG_FP, RddV); \
|
gen_log_reg_write_pair(HEX_REG_FP, RddV); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
|
@ -30,23 +30,33 @@ def gen_decl_ea_tcg(f, tag):
|
||||||
|
|
||||||
def genptr_decl_pair_writable(f, tag, regtype, regid, regno):
|
def genptr_decl_pair_writable(f, tag, regtype, regid, regno):
|
||||||
regN="%s%sN" % (regtype,regid)
|
regN="%s%sN" % (regtype,regid)
|
||||||
f.write(" TCGv_i64 %s%sV = tcg_temp_new_i64();\n" % \
|
if (regtype == "R"):
|
||||||
(regtype, regid))
|
f.write(" const int %s = insn->regno[%d];\n" % (regN, regno))
|
||||||
if (regtype == "C"):
|
elif (regtype == "C"):
|
||||||
f.write(" const int %s = insn->regno[%d] + HEX_REG_SA0;\n" % \
|
f.write(" const int %s = insn->regno[%d] + HEX_REG_SA0;\n" % \
|
||||||
(regN, regno))
|
(regN, regno))
|
||||||
else:
|
else:
|
||||||
f.write(" const int %s = insn->regno[%d];\n" % (regN, regno))
|
print("Bad register parse: ", regtype, regid)
|
||||||
|
f.write(" TCGv_i64 %s%sV = get_result_gpr_pair(ctx, %s);\n" % \
|
||||||
|
(regtype, regid, regN))
|
||||||
|
|
||||||
def genptr_decl_writable(f, tag, regtype, regid, regno):
|
def genptr_decl_writable(f, tag, regtype, regid, regno):
|
||||||
regN="%s%sN" % (regtype,regid)
|
regN="%s%sN" % (regtype,regid)
|
||||||
f.write(" TCGv %s%sV = tcg_temp_new();\n" % \
|
if (regtype == "R"):
|
||||||
(regtype, regid))
|
f.write(" const int %s = insn->regno[%d];\n" % (regN, regno))
|
||||||
if (regtype == "C"):
|
f.write(" TCGv %s%sV = get_result_gpr(ctx, %s);\n" % \
|
||||||
|
(regtype, regid, regN))
|
||||||
|
elif (regtype == "C"):
|
||||||
f.write(" const int %s = insn->regno[%d] + HEX_REG_SA0;\n" % \
|
f.write(" const int %s = insn->regno[%d] + HEX_REG_SA0;\n" % \
|
||||||
(regN, regno))
|
(regN, regno))
|
||||||
else:
|
f.write(" TCGv %s%sV = get_result_gpr(ctx, %s);\n" % \
|
||||||
|
(regtype, regid, regN))
|
||||||
|
elif (regtype == "P"):
|
||||||
f.write(" const int %s = insn->regno[%d];\n" % (regN, regno))
|
f.write(" const int %s = insn->regno[%d];\n" % (regN, regno))
|
||||||
|
f.write(" TCGv %s%sV = tcg_temp_new();\n" % \
|
||||||
|
(regtype, regid))
|
||||||
|
else:
|
||||||
|
print("Bad register parse: ", regtype, regid)
|
||||||
|
|
||||||
def genptr_decl(f, tag, regtype, regid, regno):
|
def genptr_decl(f, tag, regtype, regid, regno):
|
||||||
regN="%s%sN" % (regtype,regid)
|
regN="%s%sN" % (regtype,regid)
|
||||||
|
@ -249,8 +259,12 @@ def genptr_src_read(f, tag, regtype, regid):
|
||||||
f.write(" hex_gpr[%s%sN + 1]);\n" % \
|
f.write(" hex_gpr[%s%sN + 1]);\n" % \
|
||||||
(regtype, regid))
|
(regtype, regid))
|
||||||
elif (regid in {"x", "y"}):
|
elif (regid in {"x", "y"}):
|
||||||
f.write(" tcg_gen_mov_tl(%s%sV, hex_gpr[%s%sN]);\n" % \
|
## For read/write registers, we need to get the original value into
|
||||||
(regtype,regid,regtype,regid))
|
## the result TCGv. For conditional instructions, this is done in
|
||||||
|
## gen_start_packet. For unconditional instructions, we do it here.
|
||||||
|
if ('A_CONDEXEC' not in hex_common.attribdict[tag]):
|
||||||
|
f.write(" tcg_gen_mov_tl(%s%sV, hex_gpr[%s%sN]);\n" % \
|
||||||
|
(regtype, regid, regtype, regid))
|
||||||
elif (regid not in {"s", "t", "u", "v"}):
|
elif (regid not in {"s", "t", "u", "v"}):
|
||||||
print("Bad register parse: ", regtype, regid)
|
print("Bad register parse: ", regtype, regid)
|
||||||
elif (regtype == "P"):
|
elif (regtype == "P"):
|
||||||
|
@ -360,25 +374,16 @@ def gen_helper_call_imm(f,immlett):
|
||||||
f.write(", tcgv_%s" % hex_common.imm_name(immlett))
|
f.write(", tcgv_%s" % hex_common.imm_name(immlett))
|
||||||
|
|
||||||
def genptr_dst_write_pair(f, tag, regtype, regid):
|
def genptr_dst_write_pair(f, tag, regtype, regid):
|
||||||
if ('A_CONDEXEC' in hex_common.attribdict[tag]):
|
f.write(" gen_log_reg_write_pair(%s%sN, %s%sV);\n" % \
|
||||||
f.write(" gen_log_predicated_reg_write_pair(%s%sN, %s%sV, insn->slot);\n" % \
|
(regtype, regid, regtype, regid))
|
||||||
(regtype, regid, regtype, regid))
|
|
||||||
else:
|
|
||||||
f.write(" gen_log_reg_write_pair(%s%sN, %s%sV);\n" % \
|
|
||||||
(regtype, regid, regtype, regid))
|
|
||||||
|
|
||||||
def genptr_dst_write(f, tag, regtype, regid):
|
def genptr_dst_write(f, tag, regtype, regid):
|
||||||
if (regtype == "R"):
|
if (regtype == "R"):
|
||||||
if (regid in {"dd", "xx", "yy"}):
|
if (regid in {"dd", "xx", "yy"}):
|
||||||
genptr_dst_write_pair(f, tag, regtype, regid)
|
genptr_dst_write_pair(f, tag, regtype, regid)
|
||||||
elif (regid in {"d", "e", "x", "y"}):
|
elif (regid in {"d", "e", "x", "y"}):
|
||||||
if ('A_CONDEXEC' in hex_common.attribdict[tag]):
|
f.write(" gen_log_reg_write(%s%sN, %s%sV);\n" % \
|
||||||
f.write(" gen_log_predicated_reg_write(%s%sN, %s%sV,\n" % \
|
(regtype, regid, regtype, regid))
|
||||||
(regtype, regid, regtype, regid))
|
|
||||||
f.write(" insn->slot);\n")
|
|
||||||
else:
|
|
||||||
f.write(" gen_log_reg_write(%s%sN, %s%sV);\n" % \
|
|
||||||
(regtype, regid, regtype, regid))
|
|
||||||
else:
|
else:
|
||||||
print("Bad register parse: ", regtype, regid)
|
print("Bad register parse: ", regtype, regid)
|
||||||
elif (regtype == "P"):
|
elif (regtype == "P"):
|
||||||
|
@ -462,14 +467,15 @@ def genptr_dst_write_opn(f,regtype, regid, tag):
|
||||||
## For A2_add: Rd32=add(Rs32,Rt32), { RdV=RsV+RtV;}
|
## For A2_add: Rd32=add(Rs32,Rt32), { RdV=RsV+RtV;}
|
||||||
## We produce:
|
## We produce:
|
||||||
## static void generate_A2_add(DisasContext *ctx)
|
## static void generate_A2_add(DisasContext *ctx)
|
||||||
## {
|
## {
|
||||||
## TCGv RdV = tcg_temp_new();
|
## Insn *insn __attribute__((unused)) = ctx->insn;
|
||||||
## const int RdN = insn->regno[0];
|
## const int RdN = insn->regno[0];
|
||||||
## TCGv RsV = hex_gpr[insn->regno[1]];
|
## TCGv RdV = get_result_gpr(ctx, RdN);
|
||||||
## TCGv RtV = hex_gpr[insn->regno[2]];
|
## TCGv RsV = hex_gpr[insn->regno[1]];
|
||||||
## <GEN>
|
## TCGv RtV = hex_gpr[insn->regno[2]];
|
||||||
## gen_log_reg_write(RdN, RdV);
|
## <GEN>
|
||||||
## }
|
## gen_log_reg_write(RdN, RdV);
|
||||||
|
## }
|
||||||
##
|
##
|
||||||
## where <GEN> depends on hex_common.skip_qemu_helper(tag)
|
## where <GEN> depends on hex_common.skip_qemu_helper(tag)
|
||||||
## if hex_common.skip_qemu_helper(tag) is True
|
## if hex_common.skip_qemu_helper(tag) is True
|
||||||
|
@ -553,6 +559,14 @@ def gen_tcg_func(f, tag, regs, imms):
|
||||||
if (i > 0): f.write(", ")
|
if (i > 0): f.write(", ")
|
||||||
f.write("cpu_env")
|
f.write("cpu_env")
|
||||||
i=1
|
i=1
|
||||||
|
## For conditional instructions, we pass in the destination register
|
||||||
|
if 'A_CONDEXEC' in hex_common.attribdict[tag]:
|
||||||
|
for regtype, regid, toss, numregs in regs:
|
||||||
|
if (hex_common.is_writeonly(regid) and
|
||||||
|
not hex_common.is_hvx_reg(regtype)):
|
||||||
|
gen_helper_call_opn(f, tag, regtype, regid, toss, \
|
||||||
|
numregs, i)
|
||||||
|
i += 1
|
||||||
for regtype,regid,toss,numregs in regs:
|
for regtype,regid,toss,numregs in regs:
|
||||||
if (hex_common.is_written(regid)):
|
if (hex_common.is_written(regid)):
|
||||||
if (not hex_common.is_hvx_reg(regtype)):
|
if (not hex_common.is_hvx_reg(regtype)):
|
||||||
|
|
|
@ -68,26 +68,17 @@ static inline void gen_masked_reg_write(TCGv new_val, TCGv cur_val,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void gen_log_predicated_reg_write(int rnum, TCGv val,
|
static TCGv get_result_gpr(DisasContext *ctx, int rnum)
|
||||||
uint32_t slot)
|
|
||||||
{
|
{
|
||||||
TCGv zero = tcg_constant_tl(0);
|
return hex_new_value[rnum];
|
||||||
TCGv slot_mask = tcg_temp_new();
|
}
|
||||||
|
|
||||||
tcg_gen_andi_tl(slot_mask, hex_slot_cancelled, 1 << slot);
|
static TCGv_i64 get_result_gpr_pair(DisasContext *ctx, int rnum)
|
||||||
tcg_gen_movcond_tl(TCG_COND_EQ, hex_new_value[rnum], slot_mask, zero,
|
{
|
||||||
val, hex_new_value[rnum]);
|
TCGv_i64 result = tcg_temp_new_i64();
|
||||||
if (HEX_DEBUG) {
|
tcg_gen_concat_i32_i64(result, hex_new_value[rnum],
|
||||||
/*
|
hex_new_value[rnum + 1]);
|
||||||
* Do this so HELPER(debug_commit_end) will know
|
return result;
|
||||||
*
|
|
||||||
* Note that slot_mask indicates the value is not written
|
|
||||||
* (i.e., slot was cancelled), so we create a true/false value before
|
|
||||||
* or'ing with hex_reg_written[rnum].
|
|
||||||
*/
|
|
||||||
tcg_gen_setcond_tl(TCG_COND_EQ, slot_mask, slot_mask, zero);
|
|
||||||
tcg_gen_or_tl(hex_reg_written[rnum], hex_reg_written[rnum], slot_mask);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void gen_log_reg_write(int rnum, TCGv val)
|
void gen_log_reg_write(int rnum, TCGv val)
|
||||||
|
@ -102,39 +93,6 @@ void gen_log_reg_write(int rnum, TCGv val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_log_predicated_reg_write_pair(int rnum, TCGv_i64 val,
|
|
||||||
uint32_t slot)
|
|
||||||
{
|
|
||||||
TCGv val32 = tcg_temp_new();
|
|
||||||
TCGv zero = tcg_constant_tl(0);
|
|
||||||
TCGv slot_mask = tcg_temp_new();
|
|
||||||
|
|
||||||
tcg_gen_andi_tl(slot_mask, hex_slot_cancelled, 1 << slot);
|
|
||||||
/* Low word */
|
|
||||||
tcg_gen_extrl_i64_i32(val32, val);
|
|
||||||
tcg_gen_movcond_tl(TCG_COND_EQ, hex_new_value[rnum],
|
|
||||||
slot_mask, zero,
|
|
||||||
val32, hex_new_value[rnum]);
|
|
||||||
/* High word */
|
|
||||||
tcg_gen_extrh_i64_i32(val32, val);
|
|
||||||
tcg_gen_movcond_tl(TCG_COND_EQ, hex_new_value[rnum + 1],
|
|
||||||
slot_mask, zero,
|
|
||||||
val32, hex_new_value[rnum + 1]);
|
|
||||||
if (HEX_DEBUG) {
|
|
||||||
/*
|
|
||||||
* Do this so HELPER(debug_commit_end) will know
|
|
||||||
*
|
|
||||||
* Note that slot_mask indicates the value is not written
|
|
||||||
* (i.e., slot was cancelled), so we create a true/false value before
|
|
||||||
* or'ing with hex_reg_written[rnum].
|
|
||||||
*/
|
|
||||||
tcg_gen_setcond_tl(TCG_COND_EQ, slot_mask, slot_mask, zero);
|
|
||||||
tcg_gen_or_tl(hex_reg_written[rnum], hex_reg_written[rnum], slot_mask);
|
|
||||||
tcg_gen_or_tl(hex_reg_written[rnum + 1], hex_reg_written[rnum + 1],
|
|
||||||
slot_mask);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void gen_log_reg_write_pair(int rnum, TCGv_i64 val)
|
static void gen_log_reg_write_pair(int rnum, TCGv_i64 val)
|
||||||
{
|
{
|
||||||
const target_ulong reg_mask_low = reg_immut_masks[rnum];
|
const target_ulong reg_mask_low = reg_immut_masks[rnum];
|
||||||
|
@ -290,11 +248,12 @@ static inline void gen_write_ctrl_reg_pair(DisasContext *ctx, int reg_num,
|
||||||
TCGv_i64 val)
|
TCGv_i64 val)
|
||||||
{
|
{
|
||||||
if (reg_num == HEX_REG_P3_0_ALIASED) {
|
if (reg_num == HEX_REG_P3_0_ALIASED) {
|
||||||
|
TCGv result = get_result_gpr(ctx, reg_num + 1);
|
||||||
TCGv val32 = tcg_temp_new();
|
TCGv val32 = tcg_temp_new();
|
||||||
tcg_gen_extrl_i64_i32(val32, val);
|
tcg_gen_extrl_i64_i32(val32, val);
|
||||||
gen_write_p3_0(ctx, val32);
|
gen_write_p3_0(ctx, val32);
|
||||||
tcg_gen_extrh_i64_i32(val32, val);
|
tcg_gen_extrh_i64_i32(val32, val);
|
||||||
gen_log_reg_write(reg_num + 1, val32);
|
tcg_gen_mov_tl(result, val32);
|
||||||
} else {
|
} else {
|
||||||
gen_log_reg_write_pair(reg_num, val);
|
gen_log_reg_write_pair(reg_num, val);
|
||||||
if (reg_num == HEX_REG_QEMU_PKT_CNT) {
|
if (reg_num == HEX_REG_QEMU_PKT_CNT) {
|
||||||
|
@ -673,31 +632,28 @@ static void gen_jumpr(DisasContext *ctx, TCGv new_pc)
|
||||||
|
|
||||||
static void gen_call(DisasContext *ctx, int pc_off)
|
static void gen_call(DisasContext *ctx, int pc_off)
|
||||||
{
|
{
|
||||||
TCGv next_PC =
|
TCGv lr = get_result_gpr(ctx, HEX_REG_LR);
|
||||||
tcg_constant_tl(ctx->pkt->pc + ctx->pkt->encod_pkt_size_in_bytes);
|
tcg_gen_movi_tl(lr, ctx->next_PC);
|
||||||
gen_log_reg_write(HEX_REG_LR, next_PC);
|
|
||||||
gen_write_new_pc_pcrel(ctx, pc_off, TCG_COND_ALWAYS, NULL);
|
gen_write_new_pc_pcrel(ctx, pc_off, TCG_COND_ALWAYS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_callr(DisasContext *ctx, TCGv new_pc)
|
static void gen_callr(DisasContext *ctx, TCGv new_pc)
|
||||||
{
|
{
|
||||||
TCGv next_PC = tcg_constant_tl(ctx->next_PC);
|
TCGv lr = get_result_gpr(ctx, HEX_REG_LR);
|
||||||
gen_log_reg_write(HEX_REG_LR, next_PC);
|
tcg_gen_movi_tl(lr, ctx->next_PC);
|
||||||
gen_write_new_pc_addr(ctx, new_pc, TCG_COND_ALWAYS, NULL);
|
gen_write_new_pc_addr(ctx, new_pc, TCG_COND_ALWAYS, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_cond_call(DisasContext *ctx, TCGv pred,
|
static void gen_cond_call(DisasContext *ctx, TCGv pred,
|
||||||
TCGCond cond, int pc_off)
|
TCGCond cond, int pc_off)
|
||||||
{
|
{
|
||||||
TCGv next_PC;
|
TCGv lr = get_result_gpr(ctx, HEX_REG_LR);
|
||||||
TCGv lsb = tcg_temp_new();
|
TCGv lsb = tcg_temp_new();
|
||||||
TCGLabel *skip = gen_new_label();
|
TCGLabel *skip = gen_new_label();
|
||||||
tcg_gen_andi_tl(lsb, pred, 1);
|
tcg_gen_andi_tl(lsb, pred, 1);
|
||||||
gen_write_new_pc_pcrel(ctx, pc_off, cond, lsb);
|
gen_write_new_pc_pcrel(ctx, pc_off, cond, lsb);
|
||||||
tcg_gen_brcondi_tl(cond, lsb, 0, skip);
|
tcg_gen_brcondi_tl(cond, lsb, 0, skip);
|
||||||
next_PC =
|
tcg_gen_movi_tl(lr, ctx->next_PC);
|
||||||
tcg_constant_tl(ctx->pkt->pc + ctx->pkt->encod_pkt_size_in_bytes);
|
|
||||||
gen_log_reg_write(HEX_REG_LR, next_PC);
|
|
||||||
gen_set_label(skip);
|
gen_set_label(skip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,8 +684,7 @@ static void gen_load_frame(DisasContext *ctx, TCGv_i64 frame, TCGv EA)
|
||||||
tcg_gen_qemu_ld64(frame, EA, ctx->mem_idx);
|
tcg_gen_qemu_ld64(frame, EA, ctx->mem_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_return_base(DisasContext *ctx, TCGv_i64 dst, TCGv src,
|
static void gen_return(DisasContext *ctx, TCGv_i64 dst, TCGv src)
|
||||||
TCGv r29)
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* frame = *src
|
* frame = *src
|
||||||
|
@ -739,6 +694,7 @@ static void gen_return_base(DisasContext *ctx, TCGv_i64 dst, TCGv src,
|
||||||
*/
|
*/
|
||||||
TCGv_i64 frame = tcg_temp_new_i64();
|
TCGv_i64 frame = tcg_temp_new_i64();
|
||||||
TCGv r31 = tcg_temp_new();
|
TCGv r31 = tcg_temp_new();
|
||||||
|
TCGv r29 = get_result_gpr(ctx, HEX_REG_SP);
|
||||||
|
|
||||||
gen_load_frame(ctx, frame, src);
|
gen_load_frame(ctx, frame, src);
|
||||||
gen_frame_unscramble(frame);
|
gen_frame_unscramble(frame);
|
||||||
|
@ -748,45 +704,25 @@ static void gen_return_base(DisasContext *ctx, TCGv_i64 dst, TCGv src,
|
||||||
gen_jumpr(ctx, r31);
|
gen_jumpr(ctx, r31);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_return(DisasContext *ctx, TCGv_i64 dst, TCGv src)
|
|
||||||
{
|
|
||||||
TCGv r29 = tcg_temp_new();
|
|
||||||
gen_return_base(ctx, dst, src, r29);
|
|
||||||
gen_log_reg_write(HEX_REG_SP, r29);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if (pred) dst = dealloc_return(src):raw */
|
/* if (pred) dst = dealloc_return(src):raw */
|
||||||
static void gen_cond_return(DisasContext *ctx, TCGv_i64 dst, TCGv src,
|
static void gen_cond_return(DisasContext *ctx, TCGv_i64 dst, TCGv src,
|
||||||
TCGv pred, TCGCond cond)
|
TCGv pred, TCGCond cond)
|
||||||
{
|
{
|
||||||
TCGv LSB = tcg_temp_new();
|
TCGv LSB = tcg_temp_new();
|
||||||
TCGv mask = tcg_temp_new();
|
|
||||||
TCGv r29 = tcg_temp_new();
|
|
||||||
TCGLabel *skip = gen_new_label();
|
TCGLabel *skip = gen_new_label();
|
||||||
tcg_gen_andi_tl(LSB, pred, 1);
|
tcg_gen_andi_tl(LSB, pred, 1);
|
||||||
|
|
||||||
/* Initialize the results in case the predicate is false */
|
|
||||||
tcg_gen_movi_i64(dst, 0);
|
|
||||||
tcg_gen_movi_tl(r29, 0);
|
|
||||||
|
|
||||||
/* Set the bit in hex_slot_cancelled if the predicate is flase */
|
|
||||||
tcg_gen_movi_tl(mask, 1 << ctx->insn->slot);
|
|
||||||
tcg_gen_or_tl(mask, hex_slot_cancelled, mask);
|
|
||||||
tcg_gen_movcond_tl(cond, hex_slot_cancelled, LSB, tcg_constant_tl(0),
|
|
||||||
mask, hex_slot_cancelled);
|
|
||||||
|
|
||||||
tcg_gen_brcondi_tl(cond, LSB, 0, skip);
|
tcg_gen_brcondi_tl(cond, LSB, 0, skip);
|
||||||
gen_return_base(ctx, dst, src, r29);
|
gen_return(ctx, dst, src);
|
||||||
gen_set_label(skip);
|
gen_set_label(skip);
|
||||||
gen_log_predicated_reg_write(HEX_REG_SP, r29, ctx->insn->slot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sub-instruction version (no RddV, so handle it manually) */
|
/* sub-instruction version (no RddV, so handle it manually) */
|
||||||
static void gen_cond_return_subinsn(DisasContext *ctx, TCGCond cond, TCGv pred)
|
static void gen_cond_return_subinsn(DisasContext *ctx, TCGCond cond, TCGv pred)
|
||||||
{
|
{
|
||||||
TCGv_i64 RddV = tcg_temp_new_i64();
|
TCGv_i64 RddV = get_result_gpr_pair(ctx, HEX_REG_FP);
|
||||||
gen_cond_return(ctx, RddV, hex_gpr[HEX_REG_FP], pred, cond);
|
gen_cond_return(ctx, RddV, hex_gpr[HEX_REG_FP], pred, cond);
|
||||||
gen_log_predicated_reg_write_pair(HEX_REG_FP, RddV, ctx->insn->slot);
|
gen_log_reg_write_pair(HEX_REG_FP, RddV);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gen_endloop0(DisasContext *ctx)
|
static void gen_endloop0(DisasContext *ctx)
|
||||||
|
@ -836,9 +772,9 @@ static void gen_endloop0(DisasContext *ctx)
|
||||||
TCGLabel *label3 = gen_new_label();
|
TCGLabel *label3 = gen_new_label();
|
||||||
tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC0], 1, label3);
|
tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC0], 1, label3);
|
||||||
{
|
{
|
||||||
|
TCGv lc0 = get_result_gpr(ctx, HEX_REG_LC0);
|
||||||
gen_jumpr(ctx, hex_gpr[HEX_REG_SA0]);
|
gen_jumpr(ctx, hex_gpr[HEX_REG_SA0]);
|
||||||
tcg_gen_subi_tl(hex_new_value[HEX_REG_LC0],
|
tcg_gen_subi_tl(lc0, hex_gpr[HEX_REG_LC0], 1);
|
||||||
hex_gpr[HEX_REG_LC0], 1);
|
|
||||||
}
|
}
|
||||||
gen_set_label(label3);
|
gen_set_label(label3);
|
||||||
}
|
}
|
||||||
|
@ -855,8 +791,9 @@ static void gen_endloop1(DisasContext *ctx)
|
||||||
TCGLabel *label = gen_new_label();
|
TCGLabel *label = gen_new_label();
|
||||||
tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC1], 1, label);
|
tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC1], 1, label);
|
||||||
{
|
{
|
||||||
|
TCGv lc1 = get_result_gpr(ctx, HEX_REG_LC1);
|
||||||
gen_jumpr(ctx, hex_gpr[HEX_REG_SA1]);
|
gen_jumpr(ctx, hex_gpr[HEX_REG_SA1]);
|
||||||
tcg_gen_subi_tl(hex_new_value[HEX_REG_LC1], hex_gpr[HEX_REG_LC1], 1);
|
tcg_gen_subi_tl(lc1, hex_gpr[HEX_REG_LC1], 1);
|
||||||
}
|
}
|
||||||
gen_set_label(label);
|
gen_set_label(label);
|
||||||
}
|
}
|
||||||
|
@ -909,15 +846,17 @@ static void gen_endloop01(DisasContext *ctx)
|
||||||
*/
|
*/
|
||||||
tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC0], 1, label3);
|
tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC0], 1, label3);
|
||||||
{
|
{
|
||||||
|
TCGv lc0 = get_result_gpr(ctx, HEX_REG_LC0);
|
||||||
gen_jumpr(ctx, hex_gpr[HEX_REG_SA0]);
|
gen_jumpr(ctx, hex_gpr[HEX_REG_SA0]);
|
||||||
tcg_gen_subi_tl(hex_new_value[HEX_REG_LC0], hex_gpr[HEX_REG_LC0], 1);
|
tcg_gen_subi_tl(lc0, hex_gpr[HEX_REG_LC0], 1);
|
||||||
tcg_gen_br(done);
|
tcg_gen_br(done);
|
||||||
}
|
}
|
||||||
gen_set_label(label3);
|
gen_set_label(label3);
|
||||||
tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC1], 1, done);
|
tcg_gen_brcondi_tl(TCG_COND_LEU, hex_gpr[HEX_REG_LC1], 1, done);
|
||||||
{
|
{
|
||||||
|
TCGv lc1 = get_result_gpr(ctx, HEX_REG_LC1);
|
||||||
gen_jumpr(ctx, hex_gpr[HEX_REG_SA1]);
|
gen_jumpr(ctx, hex_gpr[HEX_REG_SA1]);
|
||||||
tcg_gen_subi_tl(hex_new_value[HEX_REG_LC1], hex_gpr[HEX_REG_LC1], 1);
|
tcg_gen_subi_tl(lc1, hex_gpr[HEX_REG_LC1], 1);
|
||||||
}
|
}
|
||||||
gen_set_label(done);
|
gen_set_label(done);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
##
|
##
|
||||||
## Copyright(c) 2019-2022 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
## Copyright(c) 2019-2023 Qualcomm Innovation Center, Inc. All Rights Reserved.
|
||||||
##
|
##
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## This program is free software; you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published by
|
## it under the terms of the GNU General Public License as published by
|
||||||
|
@ -237,6 +237,13 @@ def helper_needs_next_PC(tag):
|
||||||
def need_pkt_has_multi_cof(tag):
|
def need_pkt_has_multi_cof(tag):
|
||||||
return 'A_COF' in attribdict[tag]
|
return 'A_COF' in attribdict[tag]
|
||||||
|
|
||||||
|
def need_condexec_reg(tag, regs):
|
||||||
|
if 'A_CONDEXEC' in attribdict[tag]:
|
||||||
|
for regtype, regid, toss, numregs in regs:
|
||||||
|
if is_writeonly(regid) and not is_hvx_reg(regtype):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def skip_qemu_helper(tag):
|
def skip_qemu_helper(tag):
|
||||||
return tag in overrides.keys()
|
return tag in overrides.keys()
|
||||||
|
|
||||||
|
|
|
@ -1668,9 +1668,7 @@ void gen_inst_init_args(Context *c, YYLTYPE *locp)
|
||||||
for (unsigned i = 0; i < c->inst.init_list->len; i++) {
|
for (unsigned i = 0; i < c->inst.init_list->len; i++) {
|
||||||
HexValue *val = &g_array_index(c->inst.init_list, HexValue, i);
|
HexValue *val = &g_array_index(c->inst.init_list, HexValue, i);
|
||||||
if (val->type == REGISTER_ARG) {
|
if (val->type == REGISTER_ARG) {
|
||||||
char reg_id[5];
|
/* Nothing to do here */
|
||||||
reg_compose(c, locp, &val->reg, reg_id);
|
|
||||||
EMIT_HEAD(c, "tcg_gen_movi_i%u(%s, 0);\n", val->bit_width, reg_id);
|
|
||||||
} else if (val->type == PREDICATE) {
|
} else if (val->type == PREDICATE) {
|
||||||
char suffix = val->is_dotnew ? 'N' : 'V';
|
char suffix = val->is_dotnew ? 'N' : 'V';
|
||||||
EMIT_HEAD(c, "tcg_gen_movi_i%u(P%c%c, 0);\n", val->bit_width,
|
EMIT_HEAD(c, "tcg_gen_movi_i%u(P%c%c, 0);\n", val->bit_width,
|
||||||
|
|
|
@ -210,21 +210,6 @@ static inline void gen_cancel(uint32_t slot)
|
||||||
|
|
||||||
#define LOAD_CANCEL(EA) do { CANCEL; } while (0)
|
#define LOAD_CANCEL(EA) do { CANCEL; } while (0)
|
||||||
|
|
||||||
#ifdef QEMU_GENERATE
|
|
||||||
static inline void gen_pred_cancel(TCGv pred, uint32_t slot_num)
|
|
||||||
{
|
|
||||||
TCGv slot_mask = tcg_temp_new();
|
|
||||||
TCGv tmp = tcg_temp_new();
|
|
||||||
TCGv zero = tcg_constant_tl(0);
|
|
||||||
tcg_gen_ori_tl(slot_mask, hex_slot_cancelled, 1 << slot_num);
|
|
||||||
tcg_gen_andi_tl(tmp, pred, 1);
|
|
||||||
tcg_gen_movcond_tl(TCG_COND_EQ, hex_slot_cancelled, tmp, zero,
|
|
||||||
slot_mask, hex_slot_cancelled);
|
|
||||||
}
|
|
||||||
#define PRED_LOAD_CANCEL(PRED, EA) \
|
|
||||||
gen_pred_cancel(PRED, insn->is_endloop ? 4 : insn->slot)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define STORE_CANCEL(EA) { env->slot_cancelled |= (1 << slot); }
|
#define STORE_CANCEL(EA) { env->slot_cancelled |= (1 << slot); }
|
||||||
|
|
||||||
#define fMAX(A, B) (((A) > (B)) ? (A) : (B))
|
#define fMAX(A, B) (((A) > (B)) ? (A) : (B))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue