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):
analyze_opn_old(f, tag, regtype, regid, i)
elif hex_common.is_single(regid):
elif hex_common.is_new_val(regtype, regid, tag):
analyze_opn_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)
##
i = 0
## Analyze all the registers
- for regtype, regid, toss, numregs in regs:
- analyze_opn(f, tag, regtype, regid, toss, numregs, i)
+ for regtype, regid in regs:
+ analyze_opn(f, tag, regtype, regid, i)
i += 1
has_generated_helper = not hex_common.skip_qemu_helper(
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):
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):
else:
gen_helper_return(f, regtype, regid, i)
else:
- hex_common.bad_register(regtype, regid, toss, numregs)
+ hex_common.bad_register(regtype, regid)
##
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):
## 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):
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:
## 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):
# 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
):
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
## 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):
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]:
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")
}
-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):
f.write(f", {def_helper_types_pair[regtype]}")
elif hex_common.is_single(regid):
f.write(f", {def_helper_types[regtype]}")
else:
- hex_common.bad_register(regtype, regid, toss, numregs)
+ hex_common.bad_register(regtype, regid)
##
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):
## - Emit the scalar result
## - Emit the vector result
i = 0
- 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):
- gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
+ gen_def_helper_opn(f, tag, regtype, regid, i)
i += 1
## Put the env between the outputs and inputs
i += 1
# Second pass
- 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):
- gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
+ gen_def_helper_opn(f, tag, regtype, regid, i)
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_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
+ gen_def_helper_opn(f, tag, regtype, regid, i)
i += 1
## 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_hvx_reg(regtype) and hex_common.is_readwrite(regid):
continue
- gen_def_helper_opn(f, tag, regtype, regid, toss, numregs, i)
+ gen_def_helper_opn(f, tag, regtype, regid, i)
i += 1
for immlett, bits, immshift in imms:
f.write(", s32")
imms = tagimms[tag]
arguments = []
- for regtype, regid, toss, numregs in regs:
+ for regtype, regid in regs:
prefix = "in " if hex_common.is_read(regid) else ""
is_pair = hex_common.is_pair(regid)
elif is_single_new:
arguments.append(f"{prefix}{regtype}{regid}N")
else:
- hex_common.bad_register(regtype, regid, toss, numregs)
+ hex_common.bad_register(regtype, regid)
for immlett, bits, immshift in imms:
arguments.append(hex_common.imm_name(immlett))
def main():
hex_common.read_semantics_file(sys.argv[1])
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()
with open(sys.argv[3], "w") as f:
rregs = []
wregs = []
regids = ""
- for regtype, regid, toss, numregs in regs:
+ for regtype, regid, _, numregs in regs:
if hex_common.is_read(regid):
if regid[0] not in regids:
regids += regid[0]
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):
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):
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):
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):
else:
genptr_dst_write(f, tag, regtype, regid)
else:
- hex_common.bad_register(regtype, regid, toss, numregs)
+ hex_common.bad_register(regtype, regid)
##
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)
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)
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:
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(", ")
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)
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)
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.
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
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]))
## 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))))
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