def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) hex_common.read_overrides_file(sys.argv[3]) hex_common.calculate_attribs() tagregs = hex_common.get_tagregs() tagimms = hex_common.get_tagimms() with open(sys.argv[4], 'w') as f: f.write("#ifndef HEXAGON_TCG_FUNCS_H\n") f.write("#define HEXAGON_TCG_FUNCS_H\n\n") for tag in hex_common.tags: ## Skip the priv instructions if ("A_PRIV" in hex_common.attribdict[tag]): continue ## Skip the guest instructions if ("A_GUEST" in hex_common.attribdict[tag]): continue ## Skip the diag instructions if (tag == "Y6_diag"): continue if (tag == "Y6_diag0"): continue if (tag == "Y6_diag1"): continue gen_def_tcg_func(f, tag, tagregs, tagimms) f.write("#endif /* HEXAGON_TCG_FUNCS_H */\n")
def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) hex_common.read_overrides_file(sys.argv[3]) hex_common.read_overrides_file(sys.argv[4]) hex_common.calculate_attribs() tagregs = hex_common.get_tagregs() tagimms = hex_common.get_tagimms() with open(sys.argv[5], 'w') as f: for tag in hex_common.tags: ## Skip the priv instructions if ("A_PRIV" in hex_common.attribdict[tag]): continue ## Skip the guest instructions if ("A_GUEST" in hex_common.attribdict[tag]): continue ## Skip the diag instructions if (tag == "Y6_diag"): continue if (tag == "Y6_diag0"): continue if (tag == "Y6_diag1"): continue if (hex_common.skip_qemu_helper(tag)): continue gen_helper_function(f, tag, tagregs, tagimms)
def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) hex_common.calculate_attribs() tagregs = hex_common.get_tagregs() tagimms = hex_common.get_tagimms() with open(sys.argv[3], 'w') as f: f.write("#ifndef HEXAGON_FUNC_TABLE_H\n") f.write("#define HEXAGON_FUNC_TABLE_H\n\n") f.write("const SemanticInsn opcode_genptr[XX_LAST_OPCODE] = {\n") for tag in hex_common.tags: ## Skip the priv instructions if ("A_PRIV" in hex_common.attribdict[tag]): continue ## Skip the guest instructions if ("A_GUEST" in hex_common.attribdict[tag]): continue ## Skip the diag instructions if (tag == "Y6_diag"): continue if (tag == "Y6_diag0"): continue if (tag == "Y6_diag1"): continue f.write(" [%s] = generate_%s,\n" % (tag, tag)) f.write("};\n\n") f.write("#endif /* HEXAGON_FUNC_TABLE_H */\n")
def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) hex_common.calculate_attribs() tagregs = hex_common.get_tagregs() tagimms = hex_common.get_tagimms() with open(sys.argv[3], 'w') as f: f.write("#ifndef DEF_SHORTCODE\n") f.write("#define DEF_SHORTCODE(TAG,SHORTCODE) /* Nothing */\n") f.write("#endif\n") for tag in hex_common.tags: ## Skip the priv instructions if ("A_PRIV" in hex_common.attribdict[tag]): continue ## Skip the guest instructions if ("A_GUEST" in hex_common.attribdict[tag]): continue ## Skip the diag instructions if (tag == "Y6_diag"): continue if (tag == "Y6_diag0"): continue if (tag == "Y6_diag1"): continue gen_shortcode(f, tag) f.write("#undef DEF_SHORTCODE\n")
def main(): hex_common.read_semantics_file(sys.argv[1]) ## ## Generate a list of all the opcodes ## with open(sys.argv[3], 'w') as f: for tag in hex_common.tags: f.write("OPCODE(%s),\n" % (tag))
def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) hex_common.calculate_attribs() ## ## Generate all the attributes associated with each instruction ## with open(sys.argv[3], 'w') as f: for tag in hex_common.tags: f.write('OP_ATTRIB(%s,ATTRIBS(%s))\n' % \ (tag, ','.join(sorted(hex_common.attribdict[tag]))))
def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) tagregs = hex_common.get_tagregs() tagimms = hex_common.get_tagimms() with open(sys.argv[3], 'w') as f: for tag in hex_common.tags: regs = tagregs[tag] rregs = [] wregs = [] regids = "" for regtype, regid, toss, numregs in regs: if hex_common.is_read(regid): if regid[0] not in regids: regids += regid[0] rregs.append(regtype + regid + numregs) if hex_common.is_written(regid): wregs.append(regtype + regid + numregs) if regid[0] not in regids: regids += regid[0] for attrib in hex_common.attribdict[tag]: if hex_common.attribinfo[attrib]['rreg']: rregs.append(strip_reg_prefix(attribinfo[attrib]['rreg'])) if hex_common.attribinfo[attrib]['wreg']: wregs.append(strip_reg_prefix(attribinfo[attrib]['wreg'])) regids += calculate_regid_letters(tag) f.write('REGINFO(%s,"%s",\t/*RD:*/\t"%s",\t/*WR:*/\t"%s")\n' % \ (tag,regids,",".join(rregs),",".join(wregs))) for tag in hex_common.tags: imms = tagimms[tag] f.write('IMMINFO(%s' % tag) if not imms: f.write(''','u',0,0,'U',0,0''') for sign, size, shamt in imms: if sign == 'r': sign = 's' if not shamt: shamt = "0" f.write(''','%s',%s,%s''' % (sign, size, shamt)) if len(imms) == 1: if sign.isupper(): myu = 'u' else: myu = 'U' f.write(''','%s',0,0''' % myu) f.write(')\n')
def main(): hex_common.read_semantics_file(sys.argv[1]) hex_common.read_attribs_file(sys.argv[2]) immext_casere = re.compile(r'IMMEXT\(([A-Za-z])') with open(sys.argv[3], 'w') as f: for tag in hex_common.tags: if not hex_common.behdict[tag]: continue extendable_upper_imm = False extendable_lower_imm = False m = immext_casere.search(hex_common.semdict[tag]) if m: if m.group(1).isupper(): extendable_upper_imm = True else: extendable_lower_imm = True beh = hex_common.behdict[tag] beh = hex_common.regre.sub(regprinter, beh) beh = hex_common.absimmre.sub(r"#%s0x%x", beh) beh = hex_common.relimmre.sub(r"PC+%s%d", beh) beh = spacify(beh) # Print out a literal "%s" at the end, used to match empty string # so C won't complain at us if ("A_VECX" in hex_common.attribdict[tag]): macname = "DEF_VECX_PRINTINFO" else: macname = "DEF_PRINTINFO" f.write('%s(%s,"%s%%s"' % (macname, tag, beh)) regs_or_imms = \ hex_common.reg_or_immre.findall(hex_common.behdict[tag]) ri = 0 seenregs = {} for allregs, a, b, c, d, allimm, immlett, bits, immshift in regs_or_imms: if a: #register if b in seenregs: regno = seenregs[b] else: regno = ri if len(b) == 1: f.write(', insn->regno[%d]' % regno) if 'S' in a: f.write(', sreg2str(insn->regno[%d])' % regno) elif 'C' in a: f.write(', creg2str(insn->regno[%d])' % regno) elif len(b) == 2: f.write(', insn->regno[%d] + 1, insn->regno[%d]' % \ (regno,regno)) else: print("Put some stuff to handle quads here") if b not in seenregs: seenregs[b] = ri ri += 1 else: #immediate if (immlett.isupper()): if extendable_upper_imm: if immlett in 'rR': f.write(',insn->extension_valid?"##":""') else: f.write(',insn->extension_valid?"#":""') else: f.write(',""') ii = 1 else: if extendable_lower_imm: if immlett in 'rR': f.write(',insn->extension_valid?"##":""') else: f.write(',insn->extension_valid?"#":""') else: f.write(',""') ii = 0 f.write(', insn->immed[%d]' % ii) # append empty string so there is at least one more arg f.write(',"")\n')