mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 09:13:55 -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
|
@ -165,7 +165,7 @@ def analyze_opn_new(f, tag, regtype, regid, regno):
|
||||||
hex_common.bad_register(regtype, regid)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
|
|
||||||
def analyze_opn(f, tag, regtype, regid, toss, numregs, i):
|
def analyze_opn(f, tag, regtype, regid, i):
|
||||||
if hex_common.is_pair(regid):
|
if hex_common.is_pair(regid):
|
||||||
analyze_opn_old(f, tag, regtype, regid, i)
|
analyze_opn_old(f, tag, regtype, regid, i)
|
||||||
elif hex_common.is_single(regid):
|
elif hex_common.is_single(regid):
|
||||||
|
@ -174,9 +174,9 @@ def analyze_opn(f, tag, regtype, regid, toss, numregs, i):
|
||||||
elif hex_common.is_new_val(regtype, regid, tag):
|
elif hex_common.is_new_val(regtype, regid, tag):
|
||||||
analyze_opn_new(f, tag, regtype, regid, i)
|
analyze_opn_new(f, tag, regtype, regid, i)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -202,8 +202,8 @@ def gen_analyze_func(f, tag, regs, imms):
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
## Analyze all the registers
|
## Analyze all the registers
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
analyze_opn(f, tag, regtype, regid, toss, numregs, i)
|
analyze_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
has_generated_helper = not hex_common.skip_qemu_helper(
|
has_generated_helper = not hex_common.skip_qemu_helper(
|
||||||
|
|
|
@ -87,9 +87,9 @@ def gen_helper_arg_opn(f, regtype, regid, i, tag):
|
||||||
elif hex_common.is_new_val(regtype, regid, tag):
|
elif hex_common.is_new_val(regtype, regid, tag):
|
||||||
gen_helper_arg_new(f, regtype, regid, i)
|
gen_helper_arg_new(f, regtype, regid, i)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
|
|
||||||
def gen_helper_arg_imm(f, immlett):
|
def gen_helper_arg_imm(f, immlett):
|
||||||
|
@ -135,7 +135,7 @@ def gen_helper_dest_decl_opn(f, regtype, regid, i):
|
||||||
else:
|
else:
|
||||||
gen_helper_dest_decl(f, regtype, regid, i)
|
gen_helper_dest_decl(f, regtype, regid, i)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
|
|
||||||
def gen_helper_src_var_ext(f, 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:
|
else:
|
||||||
gen_helper_return(f, regtype, regid, i)
|
gen_helper_return(f, regtype, regid, i)
|
||||||
else:
|
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
|
numresults = 0
|
||||||
numscalarresults = 0
|
numscalarresults = 0
|
||||||
numscalarreadwrite = 0
|
numscalarreadwrite = 0
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_written(regid):
|
if hex_common.is_written(regid):
|
||||||
numresults += 1
|
numresults += 1
|
||||||
if hex_common.is_scalar_reg(regtype):
|
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
|
## The return type of the function is the type of the destination
|
||||||
## register (if scalar)
|
## register (if scalar)
|
||||||
i = 0
|
i = 0
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_written(regid):
|
if hex_common.is_written(regid):
|
||||||
if hex_common.is_pair(regid):
|
if hex_common.is_pair(regid):
|
||||||
if hex_common.is_hvx_reg(regtype):
|
if hex_common.is_hvx_reg(regtype):
|
||||||
|
@ -239,7 +239,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
|
||||||
else:
|
else:
|
||||||
gen_helper_return_type(f, regtype, regid, i)
|
gen_helper_return_type(f, regtype, regid, i)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
if numscalarresults == 0:
|
if numscalarresults == 0:
|
||||||
|
@ -248,7 +248,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
|
||||||
|
|
||||||
## Arguments include the vector destination operands
|
## Arguments include the vector destination operands
|
||||||
i = 1
|
i = 1
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_written(regid):
|
if hex_common.is_written(regid):
|
||||||
if hex_common.is_pair(regid):
|
if hex_common.is_pair(regid):
|
||||||
if hex_common.is_hvx_reg(regtype):
|
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
|
# This is the return value of the function
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
## For conditional instructions, we pass in the destination register
|
## For conditional instructions, we pass in the destination register
|
||||||
if "A_CONDEXEC" in hex_common.attribdict[tag]:
|
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(
|
if hex_common.is_writeonly(regid) and not hex_common.is_hvx_reg(
|
||||||
regtype
|
regtype
|
||||||
):
|
):
|
||||||
|
@ -275,7 +275,7 @@ def gen_helper_function(f, tag, tagregs, tagimms):
|
||||||
i += 1
|
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 in regs:
|
||||||
if hex_common.is_read(regid):
|
if hex_common.is_read(regid):
|
||||||
if hex_common.is_hvx_reg(regtype) and hex_common.is_readwrite(regid):
|
if hex_common.is_hvx_reg(regtype) and hex_common.is_readwrite(regid):
|
||||||
continue
|
continue
|
||||||
|
@ -315,12 +315,12 @@ def gen_helper_function(f, tag, tagregs, tagimms):
|
||||||
## Declare the return variable
|
## Declare the return variable
|
||||||
i = 0
|
i = 0
|
||||||
if "A_CONDEXEC" not in hex_common.attribdict[tag]:
|
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):
|
if hex_common.is_writeonly(regid):
|
||||||
gen_helper_dest_decl_opn(f, regtype, regid, i)
|
gen_helper_dest_decl_opn(f, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_read(regid):
|
if hex_common.is_read(regid):
|
||||||
if hex_common.is_pair(regid):
|
if hex_common.is_pair(regid):
|
||||||
if hex_common.is_hvx_reg(regtype):
|
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):
|
if hex_common.is_hvx_reg(regtype):
|
||||||
gen_helper_src_var_ext(f, regtype, regid)
|
gen_helper_src_var_ext(f, regtype, regid)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
if hex_common.need_slot(tag):
|
if hex_common.need_slot(tag):
|
||||||
if "A_LOAD" in hex_common.attribdict[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")
|
f.write(" arch_fpop_end(env);\n")
|
||||||
|
|
||||||
## Save/return the return variable
|
## Save/return the return variable
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_written(regid):
|
if hex_common.is_written(regid):
|
||||||
gen_helper_return_opn(f, regtype, regid, i)
|
gen_helper_return_opn(f, regtype, regid, i)
|
||||||
f.write("}\n\n")
|
f.write("}\n\n")
|
||||||
|
|
|
@ -46,13 +46,13 @@ def_helper_types_pair = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i):
|
def gen_def_helper_opn(f, tag, regtype, regid, i):
|
||||||
if hex_common.is_pair(regid):
|
if hex_common.is_pair(regid):
|
||||||
f.write(f", {def_helper_types_pair[regtype]}")
|
f.write(f", {def_helper_types_pair[regtype]}")
|
||||||
elif hex_common.is_single(regid):
|
elif hex_common.is_single(regid):
|
||||||
f.write(f", {def_helper_types[regtype]}")
|
f.write(f", {def_helper_types[regtype]}")
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -68,7 +68,7 @@ def gen_helper_prototype(f, tag, tagregs, tagimms):
|
||||||
numresults = 0
|
numresults = 0
|
||||||
numscalarresults = 0
|
numscalarresults = 0
|
||||||
numscalarreadwrite = 0
|
numscalarreadwrite = 0
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_written(regid):
|
if hex_common.is_written(regid):
|
||||||
numresults += 1
|
numresults += 1
|
||||||
if hex_common.is_scalar_reg(regtype):
|
if hex_common.is_scalar_reg(regtype):
|
||||||
|
@ -124,10 +124,10 @@ def gen_helper_prototype(f, tag, tagregs, tagimms):
|
||||||
## - Emit the scalar result
|
## - Emit the scalar result
|
||||||
## - Emit the vector result
|
## - Emit the vector result
|
||||||
i = 0
|
i = 0
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid 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):
|
||||||
gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
|
gen_def_helper_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
## Put the env between the outputs and inputs
|
## Put the env between the outputs and inputs
|
||||||
|
@ -135,27 +135,27 @@ def gen_helper_prototype(f, tag, tagregs, tagimms):
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
# Second pass
|
# Second pass
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_written(regid):
|
if hex_common.is_written(regid):
|
||||||
if hex_common.is_hvx_reg(regtype):
|
if hex_common.is_hvx_reg(regtype):
|
||||||
gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
|
gen_def_helper_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
## For conditional instructions, we pass in the destination register
|
## For conditional instructions, we pass in the destination register
|
||||||
if "A_CONDEXEC" in hex_common.attribdict[tag]:
|
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(
|
if hex_common.is_writeonly(regid) and not hex_common.is_hvx_reg(
|
||||||
regtype
|
regtype
|
||||||
):
|
):
|
||||||
gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
|
gen_def_helper_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
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 in regs:
|
||||||
if hex_common.is_read(regid):
|
if hex_common.is_read(regid):
|
||||||
if hex_common.is_hvx_reg(regtype) and hex_common.is_readwrite(regid):
|
if hex_common.is_hvx_reg(regtype) and hex_common.is_readwrite(regid):
|
||||||
continue
|
continue
|
||||||
gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
|
gen_def_helper_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
for immlett, bits, immshift in imms:
|
for immlett, bits, immshift in imms:
|
||||||
f.write(", s32")
|
f.write(", s32")
|
||||||
|
|
|
@ -131,7 +131,7 @@ def main():
|
||||||
imms = tagimms[tag]
|
imms = tagimms[tag]
|
||||||
|
|
||||||
arguments = []
|
arguments = []
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
prefix = "in " if hex_common.is_read(regid) else ""
|
prefix = "in " if hex_common.is_read(regid) else ""
|
||||||
|
|
||||||
is_pair = hex_common.is_pair(regid)
|
is_pair = hex_common.is_pair(regid)
|
||||||
|
@ -147,7 +147,7 @@ def main():
|
||||||
elif is_single_new:
|
elif is_single_new:
|
||||||
arguments.append(f"{prefix}{regtype}{regid}N")
|
arguments.append(f"{prefix}{regtype}{regid}N")
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
for immlett, bits, immshift in imms:
|
for immlett, bits, immshift in imms:
|
||||||
arguments.append(hex_common.imm_name(immlett))
|
arguments.append(hex_common.imm_name(immlett))
|
||||||
|
|
|
@ -70,7 +70,7 @@ def strip_reg_prefix(x):
|
||||||
def main():
|
def main():
|
||||||
hex_common.read_semantics_file(sys.argv[1])
|
hex_common.read_semantics_file(sys.argv[1])
|
||||||
hex_common.read_attribs_file(sys.argv[2])
|
hex_common.read_attribs_file(sys.argv[2])
|
||||||
tagregs = hex_common.get_tagregs()
|
tagregs = hex_common.get_tagregs(full=True)
|
||||||
tagimms = hex_common.get_tagimms()
|
tagimms = hex_common.get_tagimms()
|
||||||
|
|
||||||
with open(sys.argv[3], "w") as f:
|
with open(sys.argv[3], "w") as f:
|
||||||
|
@ -79,7 +79,7 @@ def main():
|
||||||
rregs = []
|
rregs = []
|
||||||
wregs = []
|
wregs = []
|
||||||
regids = ""
|
regids = ""
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid, _, numregs in regs:
|
||||||
if hex_common.is_read(regid):
|
if hex_common.is_read(regid):
|
||||||
if regid[0] not in regids:
|
if regid[0] not in regids:
|
||||||
regids += regid[0]
|
regids += regid[0]
|
||||||
|
|
|
@ -223,7 +223,7 @@ def genptr_decl_new(f, tag, regtype, regid, regno):
|
||||||
hex_common.bad_register(regtype, regid)
|
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):
|
if hex_common.is_pair(regid):
|
||||||
genptr_decl(f, tag, regtype, regid, i)
|
genptr_decl(f, tag, regtype, regid, i)
|
||||||
elif hex_common.is_single(regid):
|
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):
|
elif hex_common.is_new_val(regtype, regid, tag):
|
||||||
genptr_decl_new(f, tag, regtype, regid, i)
|
genptr_decl_new(f, tag, regtype, regid, i)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
|
|
||||||
def genptr_decl_imm(f, immlett):
|
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):
|
elif hex_common.is_new_val(regtype, regid, tag):
|
||||||
genptr_src_read_new(f, regtype, regid)
|
genptr_src_read_new(f, regtype, regid)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
else:
|
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:
|
if i > 0:
|
||||||
f.write(", ")
|
f.write(", ")
|
||||||
if hex_common.is_pair(regid):
|
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):
|
elif hex_common.is_new_val(regtype, regid, tag):
|
||||||
f.write(f"{regtype}{regid}N")
|
f.write(f"{regtype}{regid}N")
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
|
|
||||||
def gen_helper_decl_imm(f, immlett):
|
def gen_helper_decl_imm(f, immlett):
|
||||||
|
@ -468,7 +468,7 @@ def genptr_dst_write_opn(f, regtype, regid, tag):
|
||||||
else:
|
else:
|
||||||
genptr_dst_write(f, tag, regtype, regid)
|
genptr_dst_write(f, tag, regtype, regid)
|
||||||
else:
|
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)
|
gen_decl_ea_tcg(f, tag)
|
||||||
i = 0
|
i = 0
|
||||||
## Declare all the operands (regs and immediates)
|
## Declare all the operands (regs and immediates)
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
genptr_decl_opn(f, tag, regtype, regid, toss, numregs, i)
|
genptr_decl_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
for immlett, bits, immshift in imms:
|
for immlett, bits, immshift in imms:
|
||||||
genptr_decl_imm(f, immlett)
|
genptr_decl_imm(f, immlett)
|
||||||
|
@ -514,14 +514,14 @@ def gen_tcg_func(f, tag, regs, imms):
|
||||||
f.write(" fCHECKFORGUEST();\n")
|
f.write(" fCHECKFORGUEST();\n")
|
||||||
|
|
||||||
## Read all the inputs
|
## Read all the inputs
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_read(regid):
|
if hex_common.is_read(regid):
|
||||||
genptr_src_read_opn(f, regtype, regid, tag)
|
genptr_src_read_opn(f, regtype, regid, tag)
|
||||||
|
|
||||||
if hex_common.is_idef_parser_enabled(tag):
|
if hex_common.is_idef_parser_enabled(tag):
|
||||||
declared = []
|
declared = []
|
||||||
## Handle registers
|
## Handle registers
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_pair(regid) or (
|
if hex_common.is_pair(regid) or (
|
||||||
hex_common.is_single(regid)
|
hex_common.is_single(regid)
|
||||||
and hex_common.is_old_val(regtype, regid, tag)
|
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):
|
elif hex_common.is_new_val(regtype, regid, tag):
|
||||||
declared.append(f"{regtype}{regid}N")
|
declared.append(f"{regtype}{regid}N")
|
||||||
else:
|
else:
|
||||||
hex_common.bad_register(regtype, regid, toss, numregs)
|
hex_common.bad_register(regtype, regid)
|
||||||
|
|
||||||
## Handle immediates
|
## Handle immediates
|
||||||
for immlett, bits, immshift in imms:
|
for immlett, bits, immshift in imms:
|
||||||
|
@ -564,11 +564,11 @@ def gen_tcg_func(f, tag, regs, imms):
|
||||||
f.write(f" gen_helper_{tag}(")
|
f.write(f" gen_helper_{tag}(")
|
||||||
i = 0
|
i = 0
|
||||||
## If there is a scalar result, it is the return type
|
## 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_written(regid):
|
||||||
if hex_common.is_hvx_reg(regtype):
|
if hex_common.is_hvx_reg(regtype):
|
||||||
continue
|
continue
|
||||||
gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i)
|
gen_helper_call_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
if i > 0:
|
if i > 0:
|
||||||
f.write(", ")
|
f.write(", ")
|
||||||
|
@ -576,23 +576,23 @@ def gen_tcg_func(f, tag, regs, imms):
|
||||||
i = 1
|
i = 1
|
||||||
## For conditional instructions, we pass in the destination register
|
## For conditional instructions, we pass in the destination register
|
||||||
if "A_CONDEXEC" in hex_common.attribdict[tag]:
|
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(
|
if hex_common.is_writeonly(regid) and not hex_common.is_hvx_reg(
|
||||||
regtype
|
regtype
|
||||||
):
|
):
|
||||||
gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i)
|
gen_helper_call_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid 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):
|
||||||
continue
|
continue
|
||||||
gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i)
|
gen_helper_call_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_read(regid):
|
if hex_common.is_read(regid):
|
||||||
if hex_common.is_hvx_reg(regtype) and hex_common.is_readwrite(regid):
|
if hex_common.is_hvx_reg(regtype) and hex_common.is_readwrite(regid):
|
||||||
continue
|
continue
|
||||||
gen_helper_call_opn(f, tag, regtype, regid, toss, numregs, i)
|
gen_helper_call_opn(f, tag, regtype, regid, i)
|
||||||
i += 1
|
i += 1
|
||||||
for immlett, bits, immshift in imms:
|
for immlett, bits, immshift in imms:
|
||||||
gen_helper_call_imm(f, immlett)
|
gen_helper_call_imm(f, immlett)
|
||||||
|
@ -612,7 +612,7 @@ def gen_tcg_func(f, tag, regs, imms):
|
||||||
f.write(");\n")
|
f.write(");\n")
|
||||||
|
|
||||||
## Write all the outputs
|
## Write all the outputs
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if hex_common.is_written(regid):
|
if hex_common.is_written(regid):
|
||||||
genptr_dst_write_opn(f, regtype, regid, tag)
|
genptr_dst_write_opn(f, regtype, regid, tag)
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,8 @@ tags = [] # list of all tags
|
||||||
overrides = {} # tags with helper overrides
|
overrides = {} # tags with helper overrides
|
||||||
idef_parser_enabled = {} # tags enabled for idef-parser
|
idef_parser_enabled = {} # tags enabled for idef-parser
|
||||||
|
|
||||||
def bad_register(*args):
|
def bad_register(regtype, regid):
|
||||||
args_str = ", ".join(map(str, args))
|
raise Exception(f"Bad register parse: regtype '{regtype}' regid '{regid}'")
|
||||||
raise Exception(f"Bad register parse: {args_str}")
|
|
||||||
|
|
||||||
# We should do this as a hash for performance,
|
# We should do this as a hash for performance,
|
||||||
# but to keep order let's keep it as a list.
|
# but to keep order let's keep it as a list.
|
||||||
|
@ -124,7 +123,7 @@ def calculate_attribs():
|
||||||
tagregs = get_tagregs()
|
tagregs = get_tagregs()
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
regs = tagregs[tag]
|
regs = tagregs[tag]
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if regtype == "P" and is_written(regid):
|
if regtype == "P" and is_written(regid):
|
||||||
attribdict[tag].add("A_WRITES_PRED_REG")
|
attribdict[tag].add("A_WRITES_PRED_REG")
|
||||||
# Mark conditional jumps and calls
|
# Mark conditional jumps and calls
|
||||||
|
@ -170,10 +169,11 @@ def MACROATTRIB(macname, beh, attribstring):
|
||||||
attribs = []
|
attribs = []
|
||||||
macros[macname] = Macro(macname, beh, attribs)
|
macros[macname] = Macro(macname, beh, attribs)
|
||||||
|
|
||||||
|
def compute_tag_regs(tag, full):
|
||||||
def compute_tag_regs(tag):
|
tagregs = regre.findall(behdict[tag])
|
||||||
return uniquify(regre.findall(behdict[tag]))
|
if not full:
|
||||||
|
tagregs = map(lambda reg: reg[:2], tagregs)
|
||||||
|
return uniquify(tagregs)
|
||||||
|
|
||||||
def compute_tag_immediates(tag):
|
def compute_tag_immediates(tag):
|
||||||
return uniquify(immre.findall(behdict[tag]))
|
return uniquify(immre.findall(behdict[tag]))
|
||||||
|
@ -200,9 +200,9 @@ def compute_tag_immediates(tag):
|
||||||
## x, y read-write register
|
## x, y read-write register
|
||||||
## xx, yy read-write register pair
|
## xx, yy read-write register pair
|
||||||
##
|
##
|
||||||
def get_tagregs():
|
def get_tagregs(full=False):
|
||||||
return dict(zip(tags, list(map(compute_tag_regs, tags))))
|
compute_func = lambda tag: compute_tag_regs(tag, full)
|
||||||
|
return dict(zip(tags, list(map(compute_func, tags))))
|
||||||
|
|
||||||
def get_tagimms():
|
def get_tagimms():
|
||||||
return dict(zip(tags, list(map(compute_tag_immediates, tags))))
|
return dict(zip(tags, list(map(compute_tag_immediates, tags))))
|
||||||
|
@ -285,7 +285,7 @@ def need_pkt_need_commit(tag):
|
||||||
|
|
||||||
def need_condexec_reg(tag, regs):
|
def need_condexec_reg(tag, regs):
|
||||||
if "A_CONDEXEC" in attribdict[tag]:
|
if "A_CONDEXEC" in attribdict[tag]:
|
||||||
for regtype, regid, toss, numregs in regs:
|
for regtype, regid in regs:
|
||||||
if is_writeonly(regid) and not is_hvx_reg(regtype):
|
if is_writeonly(regid) and not is_hvx_reg(regtype):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue