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:
Matheus Tavares Bernardino 2023-05-24 11:41:47 -03:00 committed by Taylor Simpson
parent 3fd49e2217
commit 3608c2419c
7 changed files with 70 additions and 70 deletions

View file

@ -87,9 +87,9 @@ def gen_helper_arg_opn(f, regtype, regid, i, tag):
elif hex_common.is_new_val(regtype, regid, tag):
gen_helper_arg_new(f, 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 gen_helper_arg_imm(f, immlett):
@ -135,7 +135,7 @@ def gen_helper_dest_decl_opn(f, regtype, regid, i):
else:
gen_helper_dest_decl(f, regtype, regid, i)
else:
hex_common.bad_register(regtype, regid, toss, numregs)
hex_common.bad_register(regtype, regid)
def gen_helper_src_var_ext(f, regtype, regid):
@ -185,7 +185,7 @@ def gen_helper_return_opn(f, regtype, regid, i):
else:
gen_helper_return(f, regtype, regid, i)
else:
hex_common.bad_register(regtype, regid, toss, numregs)
hex_common.bad_register(regtype, regid)
##
@ -208,7 +208,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
numresults = 0
numscalarresults = 0
numscalarreadwrite = 0
for regtype, regid, toss, numregs in regs:
for regtype, regid in regs:
if hex_common.is_written(regid):
numresults += 1
if hex_common.is_scalar_reg(regtype):
@ -226,7 +226,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
## The return type of the function is the type of the destination
## register (if scalar)
i = 0
for regtype, regid, toss, numregs in regs:
for regtype, regid in regs:
if hex_common.is_written(regid):
if hex_common.is_pair(regid):
if hex_common.is_hvx_reg(regtype):
@ -239,7 +239,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
else:
gen_helper_return_type(f, regtype, regid, i)
else:
hex_common.bad_register(regtype, regid, toss, numregs)
hex_common.bad_register(regtype, regid)
i += 1
if numscalarresults == 0:
@ -248,7 +248,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
## Arguments include the vector destination operands
i = 1
for regtype, regid, toss, numregs in regs:
for regtype, regid in regs:
if hex_common.is_written(regid):
if hex_common.is_pair(regid):
if hex_common.is_hvx_reg(regtype):
@ -262,12 +262,12 @@ def gen_helper_function(f, tag, tagregs, tagimms):
# This is the return value of the function
continue
else:
hex_common.bad_register(regtype, regid, toss, numregs)
hex_common.bad_register(regtype, regid)
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
):
@ -275,7 +275,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
i += 1
## Arguments to the helper function are the source regs and immediates
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
@ -315,12 +315,12 @@ def gen_helper_function(f, tag, tagregs, tagimms):
## Declare the return variable
i = 0
if "A_CONDEXEC" not in hex_common.attribdict[tag]:
for regtype, regid, toss, numregs in regs:
for regtype, regid 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:
for regtype, regid in regs:
if hex_common.is_read(regid):
if hex_common.is_pair(regid):
if hex_common.is_hvx_reg(regtype):
@ -329,7 +329,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
if hex_common.is_hvx_reg(regtype):
gen_helper_src_var_ext(f, regtype, regid)
else:
hex_common.bad_register(regtype, regid, toss, numregs)
hex_common.bad_register(regtype, regid)
if hex_common.need_slot(tag):
if "A_LOAD" in hex_common.attribdict[tag]:
@ -345,7 +345,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
f.write(" arch_fpop_end(env);\n")
## Save/return the return variable
for regtype, regid, toss, numregs in regs:
for regtype, regid in regs:
if hex_common.is_written(regid):
gen_helper_return_opn(f, regtype, regid, i)
f.write("}\n\n")