From nobody Sat Nov 23 18:02:57 2024 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=1732153809; cv=none; d=zohomail.com; s=zohoarc; b=fo2cMXY0Rs9RnibbUAO5rr4K0iuojqtc3zKpLxOik/tcAdxXEWs5R+R7QDiY0zefavaysFUTzJ8fuiA/kNHIZmZZ/uB5LCr1t58wkmUgNCJhRXs7VXEMrXN+aGOvBoXme8qDsAGSParmni4pt5wn3VH2Y2F1xSDkVVOo2T/dQQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732153809; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=ktv0i4T9quoFh1XqbHeead8oN9HJCwFMqj8THqsqa04=; b=gWx+Rig7AJukWrxUyvb0KXhOX2Q0rnzHDrJ95Olz2v5Lup9C81Z4Z+amgqgolaAu7nppNhI5TnQ6CKAzJugmNj4C/PrC5p3Sjw/H7XXDfKrr5JpLpG3mHRrUzR5S4LQawW0WWPCRNJ3HV3YSg/Fr3qDK+rdYBGhdRYLsV/D5WmU= 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 1732153809836207.19426300041653; Wed, 20 Nov 2024 17:50:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tDwIz-0004Hj-5w; Wed, 20 Nov 2024 20:48:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDwIx-00042K-8j for qemu-devel@nongnu.org; Wed, 20 Nov 2024 20:48:23 -0500 Received: from rev.ng ([94.130.142.21]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tDwIu-0004hy-0I for qemu-devel@nongnu.org; Wed, 20 Nov 2024 20:48:22 -0500 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:List-Unsubscribe:List-Unsubscribe-Post: List-Help; bh=ktv0i4T9quoFh1XqbHeead8oN9HJCwFMqj8THqsqa04=; b=PVqGTMib49hP9Z2 OZtlZ8SOe1PAbISs/5MJTmf9evN7cIWHaSJSJ/lZL1fmtwAMY11472wgiKZCJ/fCbuZPbTjdwKFZy W8g2fniFXqHRl7I3DMg66/NnVz6W8QmTDcReD+STcii0uXoXvh6rXLRu8CCCQ2SFY+NLdDyBo5DYM ns=; To: qemu-devel@nongnu.org Cc: ale@rev.ng, ltaylorsimpson@gmail.com, bcain@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, alex.bennee@linaro.org Subject: [RFC PATCH v1 43/43] target/hexagon: Use helper-to-tcg Date: Thu, 21 Nov 2024 02:49:47 +0100 Message-ID: <20241121014947.18666-44-anjo@rev.ng> In-Reply-To: <20241121014947.18666-1-anjo@rev.ng> References: <20241121014947.18666-1-anjo@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=94.130.142.21; envelope-from=anjo@rev.ng; helo=rev.ng X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Anton Johansson From: Anton Johansson via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732153810627116600 Content-Type: text/plain; charset="utf-8" Modifies meson.build to use helper-to-tcg for automatic translation of helper functions. Any helper functions with the "helper-to-tcg" attribute will be automatically translated to TCG. Order of code generation is changed, and helper functions are always generated first, for all instructions. Helper functions are needed as input helper-to-tcg. Next, input to idef-parser is generated for all instructions that were not successfully translated by helper-to-tcg. As such, a majority of instructions will be translated by helper-to-tcg, and the remaining instructions fed through idef-parser can be reduced moving forward. Signed-off-by: Anton Johansson --- target/hexagon/meson.build | 151 +++++++++++++++++++++++++++---------- 1 file changed, 111 insertions(+), 40 deletions(-) diff --git a/target/hexagon/meson.build b/target/hexagon/meson.build index bb4ebaae81..563d60e976 100644 --- a/target/hexagon/meson.build +++ b/target/hexagon/meson.build @@ -262,22 +262,127 @@ hexagon_ss.add(files( 'mmvec/system_ext_mmvec.c', )) =20 +helper_dep =3D [semantics_generated] +helper_in =3D [semantics_generated, gen_tcg_h, gen_tcg_hvx_h] + +# +# Step 5 +# We use Python scripts to generate the following files +# helper_protos_generated.h.inc +# helper_funcs_generated.c.inc +# analyze_funcs_generated.c.inc +# +helper_protos_generated =3D custom_target( + 'helper_protos_generated.h.inc', + output: 'helper_protos_generated.h.inc', + depends: helper_dep, + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], + command: [python, files('gen_helper_protos.py'), helper_in, '@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: helper_dep, + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], + command: [python, files('gen_helper_funcs.py'), helper_in, '@OUTPUT@'], +) +hexagon_ss.add(helper_funcs_generated) + +analyze_funcs_generated =3D custom_target( + 'analyze_funcs_generated.c.inc', + output: 'analyze_funcs_generated.c.inc', + depends: helper_dep, + depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], + command: [python, files('gen_analyze_funcs.py'), helper_in, '@OUTPUT@'= ], +) +hexagon_ss.add(analyze_funcs_generated) + +# +# Step 6 +# If enabled, run helper-to-tcg to attempt to translate any remaining +# helper functions, producing: +# helper-to-tcg-emitted.c +# helper-to-tcg-emitted.h +# helper-to-tcg-enabled +# helper-to-tcg-log # -# Step 4.5 + +if helper_to_tcg_enabled + helper_to_tcg =3D subproject('helper-to-tcg', required: true) + helper_to_tcg_get_llvm_ir_cmd =3D helper_to_tcg.get_variable('get_llvm= _ir_cmd') + helper_to_tcg_pipeline =3D helper_to_tcg.get_variable('pipeline') +endif + +idef_command_extra =3D [] +idef_dep_extra =3D [] +if helper_to_tcg_enabled + helper_to_tcg_input_files =3D [ + meson.current_source_dir() / 'op_helper.c', + meson.current_source_dir() / 'translate.c', + meson.current_source_dir() / 'reg_fields.c', + meson.current_source_dir() / 'arch.c', + ] + + ll =3D custom_target('to-ll', + input: helper_to_tcg_input_files, + output:'helper-to-tcg-input.ll', + depends: [helper_funcs_generated, helper_protos_generated], + command: helper_to_tcg_get_llvm_ir_cmd + ['-o', '@OUTPUT@', '@INPU= T@', '--target-path', 'target/hexagon'] + ) + + helper_to_tcg_target =3D custom_target('helper-to-tcg-hexagon', + output: ['helper-to-tcg-emitted.c', + 'helper-to-tcg-emitted.h', + 'helper-to-tcg-enabled', + 'helper-to-tcg-log'], + input: [ll], + depends: [helper_to_tcg_pipeline, analyze_funcs_generated, helper_= funcs_generated, helper_protos_generated], + command: [helper_to_tcg_pipeline, + '--temp-vector-block=3Dtmp_vmem', + '--mmu-index-function=3Dget_tb_mmu_index', + '--tcg-global-mappings=3Dtcg_global_mappings', + '--output-source=3D@OUTPUT0@', + '--output-header=3D@OUTPUT1@', + '--output-enabled=3D@OUTPUT2@', + '--output-log=3D@OUTPUT3@', + '@INPUT@'] + ) + + hexagon_ss.add(helper_to_tcg_target) + + # List of instructions for which TCG generation was successful + generated_tcg_list =3D helper_to_tcg_target[2].full_path() + + # Setup dependencies for idef-parser + idef_dep_extra +=3D helper_to_tcg_target + idef_command_extra +=3D ['--helper-to-tcg', generated_tcg_list] + + # Setup input and dependencies for the final step, this depends on whe= ther + helper_dep +=3D [helper_to_tcg_target] + helper_in +=3D ['--helper-to-tcg', generated_tcg_list] +endif + + + +# +# Step 6 # We use flex/bison based idef-parser to generate TCG code for a lot # of instructions. idef-parser outputs # idef-generated-emitter.c # idef-generated-emitter.h.inc # idef-generated-enabled-instructions # + idef_parser_enabled =3D get_option('hexagon_idef_parser') if idef_parser_enabled and 'hexagon-linux-user' in target_dirs idef_parser_input_generated =3D custom_target( 'idef_parser_input.h.inc', output: 'idef_parser_input.h.inc', - depends: [semantics_generated], + depends: [semantics_generated, ] + idef_dep_extra, depend_files: [hex_common_py], - command: [python, files('gen_idef_parser_funcs.py'), semantics_gen= erated, '@OUTPUT@'], + command: [python, files('gen_idef_parser_funcs.py'), semantics_gen= erated, '@OUTPUT@'] + idef_command_extra ) =20 preprocessed_idef_parser_input_generated =3D custom_target( @@ -345,39 +450,14 @@ if idef_parser_enabled and 'hexagon-linux-user' in ta= rget_dirs =20 # Setup input and dependencies for the next step, this depends on whet= her or # not idef-parser is enabled - helper_dep =3D [semantics_generated, idef_generated_tcg_c, idef_genera= ted_tcg] - helper_in =3D [semantics_generated, gen_tcg_h, gen_tcg_hvx_h, '--idef-= parser', idef_generated_list] -else - # Setup input and dependencies for the next step, this depends on whet= her or - # not idef-parser is enabled - helper_dep =3D [semantics_generated] - helper_in =3D [semantics_generated, gen_tcg_h, gen_tcg_hvx_h] + helper_dep +=3D [idef_generated_tcg_c, idef_generated_tcg] + helper_in +=3D ['--idef-parser', idef_generated_list] endif =20 # -# Step 5 +# Step 7 # 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: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], - command: [python, files('gen_helper_protos.py'), helper_in, '@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: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], - command: [python, files('gen_helper_funcs.py'), helper_in, '@OUTPUT@'], -) -hexagon_ss.add(helper_funcs_generated) =20 tcg_funcs_generated =3D custom_target( 'tcg_funcs_generated.c.inc', @@ -388,13 +468,4 @@ tcg_funcs_generated =3D custom_target( ) hexagon_ss.add(tcg_funcs_generated) =20 -analyze_funcs_generated =3D custom_target( - 'analyze_funcs_generated.c.inc', - output: 'analyze_funcs_generated.c.inc', - depends: helper_dep, - depend_files: [hex_common_py, gen_tcg_h, gen_tcg_hvx_h], - command: [python, files('gen_analyze_funcs.py'), helper_in, '@OUTPUT@'= ], -) -hexagon_ss.add(analyze_funcs_generated) - target_arch +=3D {'hexagon': hexagon_ss} --=20 2.45.2