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
|
@ -30,9 +30,8 @@ tags = [] # list of all tags
|
|||
overrides = {} # tags with helper overrides
|
||||
idef_parser_enabled = {} # tags enabled for idef-parser
|
||||
|
||||
def bad_register(*args):
|
||||
args_str = ", ".join(map(str, args))
|
||||
raise Exception(f"Bad register parse: {args_str}")
|
||||
def bad_register(regtype, regid):
|
||||
raise Exception(f"Bad register parse: regtype '{regtype}' regid '{regid}'")
|
||||
|
||||
# We should do this as a hash for performance,
|
||||
# but to keep order let's keep it as a list.
|
||||
|
@ -124,7 +123,7 @@ def calculate_attribs():
|
|||
tagregs = get_tagregs()
|
||||
for tag in tags:
|
||||
regs = tagregs[tag]
|
||||
for regtype, regid, toss, numregs in regs:
|
||||
for regtype, regid in regs:
|
||||
if regtype == "P" and is_written(regid):
|
||||
attribdict[tag].add("A_WRITES_PRED_REG")
|
||||
# Mark conditional jumps and calls
|
||||
|
@ -170,10 +169,11 @@ def MACROATTRIB(macname, beh, attribstring):
|
|||
attribs = []
|
||||
macros[macname] = Macro(macname, beh, attribs)
|
||||
|
||||
|
||||
def compute_tag_regs(tag):
|
||||
return uniquify(regre.findall(behdict[tag]))
|
||||
|
||||
def compute_tag_regs(tag, full):
|
||||
tagregs = regre.findall(behdict[tag])
|
||||
if not full:
|
||||
tagregs = map(lambda reg: reg[:2], tagregs)
|
||||
return uniquify(tagregs)
|
||||
|
||||
def compute_tag_immediates(tag):
|
||||
return uniquify(immre.findall(behdict[tag]))
|
||||
|
@ -200,9 +200,9 @@ def compute_tag_immediates(tag):
|
|||
## x, y read-write register
|
||||
## xx, yy read-write register pair
|
||||
##
|
||||
def get_tagregs():
|
||||
return dict(zip(tags, list(map(compute_tag_regs, tags))))
|
||||
|
||||
def get_tagregs(full=False):
|
||||
compute_func = lambda tag: compute_tag_regs(tag, full)
|
||||
return dict(zip(tags, list(map(compute_func, tags))))
|
||||
|
||||
def get_tagimms():
|
||||
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):
|
||||
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):
|
||||
return True
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue