mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 07:13:54 -06:00
target/hexagon/*.py: clean up used 'toss' and 'numregs' vars
Many Hexagon python scripts call hex_common.get_tagregs(), but only one call site use the full reg structure given by this function. To make the code cleaner, let's make get_tagregs() filter out the unused fields (i.e. 'toss' and 'numregs'), properly removed the unused variables at the call sites. The hex_common.bad_register() function is also adjusted to work exclusively with 'regtype' and 'regid' args. For the single call site that does use toss/numregs, we provide an optional parameter to get_tagregs() which will restore the old full behavior. Suggested-by: Taylor Simpson <tsimpson@quicinc.com> Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Reviewed-by: Taylor Simpson <tsimpson@quicinc.com> Tested-by: Taylor Simpson <tsimpson@quicinc.com> Signed-off-by: Taylor Simpson <tsimpson@quicinc.com> Message-Id: <3ffd4ccb972879f57f499705c624e8eaba7f8b52.1684939078.git.quic_mathbern@quicinc.com>
This commit is contained in:
parent
3fd49e2217
commit
3608c2419c
7 changed files with 70 additions and 70 deletions
|
@ -223,7 +223,7 @@ def genptr_decl_new(f, tag, regtype, regid, regno):
|
|||
hex_common.bad_register(regtype, regid)
|
||||
|
||||
|
||||
def genptr_decl_opn(f, tag, regtype, regid, toss, numregs, i):
|
||||
def genptr_decl_opn(f, tag, regtype, regid, i):
|
||||
if hex_common.is_pair(regid):
|
||||
genptr_decl(f, tag, regtype, regid, i)
|
||||
elif hex_common.is_single(regid):
|
||||
|
@ -232,9 +232,9 @@ def genptr_decl_opn(f, tag, regtype, regid, toss, numregs, i):
|
|||
elif hex_common.is_new_val(regtype, regid, tag):
|
||||
genptr_decl_new(f, tag, regtype, regid, i)
|
||||
else:
|
||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
||||
hex_common.bad_register(regtype, regid)
|
||||
else:
|
||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
||||
hex_common.bad_register(regtype, regid)
|
||||
|
||||
|
||||
def genptr_decl_imm(f, immlett):
|
||||
|
@ -354,12 +354,12 @@ def genptr_src_read_opn(f, regtype, regid, tag):
|
|||
elif hex_common.is_new_val(regtype, regid, tag):
|
||||
genptr_src_read_new(f, regtype, regid)
|
||||
else:
|
||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
||||
hex_common.bad_register(regtype, regid)
|
||||
else:
|
||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
||||
hex_common.bad_register(regtype, regid)
|
||||
|
||||
|
||||
def gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i):
|
||||
def gen_helper_call_opn(f, tag, regtype, regid, i):
|
||||
if i > 0:
|
||||
f.write(", ")
|
||||
if hex_common.is_pair(regid):
|
||||
|
@ -370,9 +370,9 @@ def gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i):
|
|||
elif hex_common.is_new_val(regtype, regid, tag):
|
||||
f.write(f"{regtype}{regid}N")
|
||||
else:
|
||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
||||
hex_common.bad_register(regtype, regid)
|
||||
else:
|
||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
||||
hex_common.bad_register(regtype, regid)
|
||||
|
||||
|
||||
def gen_helper_decl_imm(f, immlett):
|
||||
|
@ -468,7 +468,7 @@ def genptr_dst_write_opn(f, regtype, regid, tag):
|
|||
else:
|
||||
genptr_dst_write(f, tag, regtype, regid)
|
||||
else:
|
||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
||||
hex_common.bad_register(regtype, regid)
|
||||
|
||||
|
||||
##
|
||||
|
@ -502,8 +502,8 @@ def gen_tcg_func(f, tag, regs, imms):
|
|||
gen_decl_ea_tcg(f, tag)
|
||||
i = 0
|
||||
## Declare all the operands (regs and immediates)
|
||||
for regtype, regid, toss, numregs in regs:
|
||||
genptr_decl_opn(f, tag, regtype, regid, toss, numregs, i)
|
||||
for regtype, regid in regs:
|
||||
genptr_decl_opn(f, tag, regtype, regid, i)
|
||||
i += 1
|
||||
for immlett, bits, immshift in imms:
|
||||
genptr_decl_imm(f, immlett)
|
||||
|
@ -514,14 +514,14 @@ def gen_tcg_func(f, tag, regs, imms):
|
|||
f.write(" fCHECKFORGUEST();\n")
|
||||
|
||||
## Read all the inputs
|
||||
for regtype, regid, toss, numregs in regs:
|
||||
for regtype, regid in regs:
|
||||
if hex_common.is_read(regid):
|
||||
genptr_src_read_opn(f, regtype, regid, tag)
|
||||
|
||||
if hex_common.is_idef_parser_enabled(tag):
|
||||
declared = []
|
||||
## Handle registers
|
||||
for regtype, regid, toss, numregs in regs:
|
||||
for regtype, regid in regs:
|
||||
if hex_common.is_pair(regid) or (
|
||||
hex_common.is_single(regid)
|
||||
and hex_common.is_old_val(regtype, regid, tag)
|
||||
|
@ -532,7 +532,7 @@ def gen_tcg_func(f, tag, regs, imms):
|
|||
elif hex_common.is_new_val(regtype, regid, tag):
|
||||
declared.append(f"{regtype}{regid}N")
|
||||
else:
|
||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
||||
hex_common.bad_register(regtype, regid)
|
||||
|
||||
## Handle immediates
|
||||
for immlett, bits, immshift in imms:
|
||||
|
@ -564,11 +564,11 @@ def gen_tcg_func(f, tag, regs, imms):
|
|||
f.write(f" gen_helper_{tag}(")
|
||||
i = 0
|
||||
## If there is a scalar result, it is the return type
|
||||
for regtype, regid, toss, numregs in regs:
|
||||
for regtype, regid in regs:
|
||||
if hex_common.is_written(regid):
|
||||
if hex_common.is_hvx_reg(regtype):
|
||||
continue
|
||||
gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i)
|
||||
gen_helper_call_opn(f, tag, regtype, regid, i)
|
||||
i += 1
|
||||
if i > 0:
|
||||
f.write(", ")
|
||||
|
@ -576,23 +576,23 @@ def gen_tcg_func(f, tag, regs, imms):
|
|||
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:
|
||||
for regtype, regid 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)
|
||||
gen_helper_call_opn(f, tag, regtype, regid, i)
|
||||
i += 1
|
||||
for regtype, regid, toss, numregs in regs:
|
||||
for regtype, regid in regs:
|
||||
if hex_common.is_written(regid):
|
||||
if not hex_common.is_hvx_reg(regtype):
|
||||
continue
|
||||
gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i)
|
||||
gen_helper_call_opn(f, tag, regtype, regid, i)
|
||||
i += 1
|
||||
for regtype, regid, toss, numregs in regs:
|
||||
for regtype, regid in regs:
|
||||
if hex_common.is_read(regid):
|
||||
if hex_common.is_hvx_reg(regtype) and hex_common.is_readwrite(regid):
|
||||
continue
|
||||
gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i)
|
||||
gen_helper_call_opn(f, tag, regtype, regid, i)
|
||||
i += 1
|
||||
for immlett, bits, immshift in imms:
|
||||
gen_helper_call_imm(f, immlett)
|
||||
|
@ -612,7 +612,7 @@ def gen_tcg_func(f, tag, regs, imms):
|
|||
f.write(");\n")
|
||||
|
||||
## Write all the outputs
|
||||
for regtype, regid, toss, numregs in regs:
|
||||
for regtype, regid in regs:
|
||||
if hex_common.is_written(regid):
|
||||
genptr_dst_write_opn(f, regtype, regid, tag)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue