From nobody Tue Feb 10 07:22:19 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1626784752; cv=none; d=zohomail.com; s=zohoarc; b=IKhirYMUy4biEjc+c+CCcsmWpnbGfaQC3nHd0Xncw6p/Dx6pBgrRsg9RisQ+IDybKxRmbhu229H8MASf8dgEkmypNr2JrcH+CyfoL4322u1wDYxNLylv0TJPCbWN3wM+7vJY5/YyX2+JQBtpdZGkjWaVIE1rIVZ34L3VmtCmOjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1626784752; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=9prCpVQ+k9k0ctHLPx87lHc2c+mCuaXMEGiXpF45YJE=; b=irFDrXnollRRR5U15+XkxxiVRqLxKi7FLw4ys80DKmbMJ0/+qL4ZxqF3fmS1+RTmT8COM9UupUQ5to5IZ8kmuazwwQRXTWuXzDulXFuxhuGpP/n2NX5xqda+2a+I6ligM1I1bS1BS+duLgE74QU5iga3qdwSEXRkicypAG85zYQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1626784752037521.5019779282939; Tue, 20 Jul 2021 05:39:12 -0700 (PDT) Received: from localhost ([::1]:46584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5p1i-00034V-W2 for importer@patchew.org; Tue, 20 Jul 2021 08:39:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5ott-0004rI-ID for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:31:05 -0400 Received: from rev.ng ([5.9.113.41]:41597) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5otr-0004fN-7K for qemu-devel@nongnu.org; Tue, 20 Jul 2021 08:31:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=rev.ng; s=dkim; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=9prCpVQ+k9k0ctHLPx87lHc2c+mCuaXMEGiXpF45YJE=; b=Z9YnaSJJcW3B0x8Qvo7NF2KT3n c4iurmviDBMGmfxuEHLjr7dZlRzPlcBzWC/SkRW6BnEkWf1KfS5tVajYJxlluD3GH/b4HQ7mzEaAz HtAag7tCdcu4D5gKLNJTXQmZ0mUpSZR/KNa7MAp/D5/MyU8T0nfHWyXYvbBFdww880+Y=; To: qemu-devel@nongnu.org Cc: tsimpson@quicinc.com, bcain@quicinc.com, babush@rev.ng, nizzo@rev.ng, richard.henderson@linaro.org, Alessandro Di Federico Subject: [PATCH v6 10/12] target/hexagon: call idef-parser functions Date: Tue, 20 Jul 2021 14:30:29 +0200 Message-Id: <20210720123031.1101682-11-ale.qemu@rev.ng> In-Reply-To: <20210720123031.1101682-1-ale.qemu@rev.ng> References: <20210720123031.1101682-1-ale.qemu@rev.ng> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=5.9.113.41; envelope-from=ale@rev.ng; helo=rev.ng X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Reply-to: Alessandro Di Federico From: Alessandro Di Federico via X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1626784752923100001 Content-Type: text/plain; charset="utf-8" From: Alessandro Di Federico Extend gen_tcg_funcs.py in order to emit calls to the functions emitted by the idef-parser, if available. Signed-off-by: Alessandro Di Federico Reviewed-by: Taylor Simpson --- target/hexagon/gen_helper_funcs.py | 5 +- target/hexagon/gen_helper_protos.py | 5 +- target/hexagon/gen_tcg_funcs.py | 28 +++++++++- target/hexagon/hex_common.py | 10 ++++ target/hexagon/meson.build | 81 ++++++++++++++++++----------- 5 files changed, 95 insertions(+), 34 deletions(-) diff --git a/target/hexagon/gen_helper_funcs.py b/target/hexagon/gen_helper= _funcs.py index 2b1c5d8e3e..40fcc0269a 100755 --- a/target/hexagon/gen_helper_funcs.py +++ b/target/hexagon/gen_helper_funcs.py @@ -192,11 +192,12 @@ 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_idef_parser_enabled_file(sys.argv[4]) hex_common.calculate_attribs() tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[4], 'w') as f: + 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] ) : @@ -213,6 +214,8 @@ def main(): continue if ( hex_common.skip_qemu_helper(tag) ): continue + if ( hex_common.is_idef_parser_enabled(tag) ): + continue =20 gen_helper_function(f, tag, tagregs, tagimms) =20 diff --git a/target/hexagon/gen_helper_protos.py b/target/hexagon/gen_helpe= r_protos.py index ea41007ec9..6aee7229cb 100755 --- a/target/hexagon/gen_helper_protos.py +++ b/target/hexagon/gen_helper_protos.py @@ -121,11 +121,12 @@ 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_idef_parser_enabled_file(sys.argv[4]) hex_common.calculate_attribs() tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[4], 'w') as f: + 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] ) : @@ -143,6 +144,8 @@ def main(): =20 if ( hex_common.skip_qemu_helper(tag) ): continue + if ( hex_common.is_idef_parser_enabled(tag) ): + continue =20 gen_helper_prototype(f, tag, tagregs, tagimms) =20 diff --git a/target/hexagon/gen_tcg_funcs.py b/target/hexagon/gen_tcg_funcs= .py index 7ceb25b5f6..e12f6b7cfc 100755 --- a/target/hexagon/gen_tcg_funcs.py +++ b/target/hexagon/gen_tcg_funcs.py @@ -394,7 +394,29 @@ def gen_tcg_func(f, tag, regs, imms): if (hex_common.is_read(regid)): genptr_src_read_opn(f,regtype,regid,tag) =20 - if ( hex_common.skip_qemu_helper(tag) ): + if hex_common.is_idef_parser_enabled(tag): + declared =3D [] + ## Handle registers + for regtype,regid,toss,numregs in regs: + if (hex_common.is_pair(regid) + or (hex_common.is_single(regid) + and hex_common.is_old_val(regtype, regid, tag))): + declared.append("%s%sV" % (regtype, regid)) + if regtype =3D=3D "M": + declared.append("%s%sN" % (regtype, regid)) + elif hex_common.is_new_val(regtype, regid, tag): + declared.append("%s%sN" % (regtype,regid)) + else: + print("Bad register parse: ",regtype,regid,toss,numregs) + + ## Handle immediates + for immlett,bits,immshift in imms: + declared.append(hex_common.imm_name(immlett)) + + arguments =3D ", ".join(["ctx", "insn", "pkt"] + declared) + f.write(" emit_%s(%s);\n" % (tag, arguments)) + + elif ( hex_common.skip_qemu_helper(tag) ): f.write(" fGEN_TCG_%s(%s);\n" % (tag, hex_common.semdict[tag])) else: ## Generate the call to the helper @@ -455,12 +477,14 @@ def main(): hex_common.read_attribs_file(sys.argv[2]) hex_common.read_overrides_file(sys.argv[3]) hex_common.calculate_attribs() + hex_common.read_idef_parser_enabled_file(sys.argv[4]) tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 - with open(sys.argv[4], 'w') as f: + with open(sys.argv[5], 'w') as f: f.write("#ifndef HEXAGON_TCG_FUNCS_H\n") f.write("#define HEXAGON_TCG_FUNCS_H\n\n") + f.write("#include \"idef-generated-emitter.h.inc\"\n\n") =20 for tag in hex_common.tags: ## Skip the priv instructions diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py index b3b534057d..648ad29e94 100755 --- a/target/hexagon/hex_common.py +++ b/target/hexagon/hex_common.py @@ -28,6 +28,7 @@ attribinfo =3D {} # Register information and misc tags =3D [] # list of all tags overrides =3D {} # tags with helper overrides +idef_parser_enabled =3D {} # tags enabled for idef-parser =20 # We should do this as a hash for performance, # but to keep order let's keep it as a list. @@ -201,6 +202,9 @@ def need_ea(tag): def skip_qemu_helper(tag): return tag in overrides.keys() =20 +def is_idef_parser_enabled(tag): + return tag in idef_parser_enabled + def imm_name(immlett): return "%siV" % immlett =20 @@ -232,3 +236,9 @@ def read_overrides_file(name): continue tag =3D overridere.findall(line)[0] overrides[tag] =3D True + +def read_idef_parser_enabled_file(name): + global idef_parser_enabled + with open(name, "r") as idef_parser_enabled_file: + lines =3D idef_parser_enabled_file.read().strip().split("\n") + idef_parser_enabled =3D set(lines) diff --git a/target/hexagon/meson.build b/target/hexagon/meson.build index c064186b5c..92caf9ff3e 100644 --- a/target/hexagon/meson.build +++ b/target/hexagon/meson.build @@ -42,10 +42,7 @@ hexagon_ss.add(semantics_generated) # Step 2 # We use Python scripts to generate the following files # shortcode_generated.h.inc -# helper_protos_generated.h.inc -# tcg_funcs_generated.c.inc # tcg_func_table_generated.c.inc -# helper_funcs_generated.c.inc # printinsn_generated.h.inc # op_regs_generated.h.inc # op_attribs_generated.h.inc @@ -60,24 +57,6 @@ shortcode_generated =3D custom_target( ) hexagon_ss.add(shortcode_generated) =20 -helper_protos_generated =3D custom_target( - 'helper_protos_generated.h.inc', - output: 'helper_protos_generated.h.inc', - depends: [semantics_generated], - depend_files: [hex_common_py, attribs_def, gen_tcg_h], - command: [python, files('gen_helper_protos.py'), semantics_generated, = attribs_def, gen_tcg_h, '@OUTPUT@'], -) -hexagon_ss.add(helper_protos_generated) - -tcg_funcs_generated =3D custom_target( - 'tcg_funcs_generated.c.inc', - output: 'tcg_funcs_generated.c.inc', - depends: [semantics_generated], - depend_files: [hex_common_py, attribs_def, gen_tcg_h], - command: [python, files('gen_tcg_funcs.py'), semantics_generated, attr= ibs_def, gen_tcg_h, '@OUTPUT@'], -) -hexagon_ss.add(tcg_funcs_generated) - tcg_func_table_generated =3D custom_target( 'tcg_func_table_generated.c.inc', output: 'tcg_func_table_generated.c.inc', @@ -87,15 +66,6 @@ tcg_func_table_generated =3D custom_target( ) hexagon_ss.add(tcg_func_table_generated) =20 -helper_funcs_generated =3D custom_target( - 'helper_funcs_generated.c.inc', - output: 'helper_funcs_generated.c.inc', - depends: [semantics_generated], - depend_files: [hex_common_py, attribs_def, gen_tcg_h], - command: [python, files('gen_helper_funcs.py'), semantics_generated, a= ttribs_def, gen_tcg_h, '@OUTPUT@'], -) -hexagon_ss.add(helper_funcs_generated) - printinsn_generated =3D custom_target( 'printinsn_generated.h.inc', output: 'printinsn_generated.h.inc', @@ -220,4 +190,55 @@ idef_generated_tcg =3D custom_target( command: [idef_parser, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@= '], ) =20 +indent =3D find_program('indent', required: false) +if indent.found() + idef_generated_tcg_c =3D custom_target('asd', + input: idef_generated_tcg[0], + output: 'idef-generated-emitter.ind= ented.c', + command: [indent, '-linux', '@INPUT= @', '-o', '@OUTPUT@']) +else + idef_generated_tcg_c =3D custom_target('asd', + input: idef_generated_tcg[0], + output: 'idef-generated-emitter.ind= ented.c', + command: ['cp', '@INPUT@', '@OUTPUT= @']) +endif + +idef_generated_list =3D idef_generated_tcg[2].full_path() + +hexagon_ss.add(idef_generated_tcg_c) + +# +# Step 5 +# We use Python scripts to generate the following files +# helper_protos_generated.h.inc +# helper_funcs_generated.c.inc +# tcg_funcs_generated.c.inc +# +helper_protos_generated =3D custom_target( + 'helper_protos_generated.h.inc', + output: 'helper_protos_generated.h.inc', + depends: [semantics_generated, idef_generated_tcg_c, idef_generated_tc= g], + depend_files: [hex_common_py, attribs_def, gen_tcg_h], + command: [python, files('gen_helper_protos.py'), semantics_generated, = attribs_def, gen_tcg_h, idef_generated_list, '@OUTPUT@'], +) +hexagon_ss.add(helper_protos_generated) + +helper_funcs_generated =3D custom_target( + 'helper_funcs_generated.c.inc', + output: 'helper_funcs_generated.c.inc', + depends: [semantics_generated, idef_generated_tcg_c, idef_generated_tc= g], + depend_files: [hex_common_py, attribs_def, gen_tcg_h], + command: [python, files('gen_helper_funcs.py'), semantics_generated, a= ttribs_def, gen_tcg_h, idef_generated_list, '@OUTPUT@'], +) +hexagon_ss.add(helper_funcs_generated) + +tcg_funcs_generated =3D custom_target( + 'tcg_funcs_generated.c.inc', + output: 'tcg_funcs_generated.c.inc', + depends: [semantics_generated, idef_generated_tcg_c, idef_generated_tc= g], + depend_files: [hex_common_py, attribs_def, gen_tcg_h], + command: [python, files('gen_tcg_funcs.py'), semantics_generated, attr= ibs_def, gen_tcg_h, idef_generated_list, '@OUTPUT@'], +) +hexagon_ss.add(tcg_funcs_generated) + target_arch +=3D {'hexagon': hexagon_ss} --=20 2.32.0