From nobody Wed Nov 27 04:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1702246124; cv=none; d=zohomail.com; s=zohoarc; b=hQbeMIjYHVA9+hn8ft3tqy1z5LYYZcqOuw4136lIBZ9L8Bo6lhIbyxdTJGPItlAumt8rm7fEnqPJSvXVK6oKxiUQbaG+8INKGQXEYH9o371kaRlkFkuSIx3y/ptCo6dfo93hwvOWuhkfMihhsWOOmAeSSPVe0EBwzl7o133OlUE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1702246124; h=Content-Type: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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=7INVYMT5r1D4mt+61zSzjBSfhyLG7TlXNfcj/O5bdpo=; b=HkE2jdaVoy+jev2pZ4uJjNf8pKWZ7qKVDKJOzSY3yd9WYChmmE7liamjjdur26MQ5R7D42SVIr0ck1+QW78fW0Hmt1vhNfeNSXQSnsZBswadZ+i9kJzAU/0uYbrn00hkMrd2+kmjjYOlzkIqDq4WD8DjMfag0Zs8lY0VUwfM5OM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1702246124477330.9183211484233; Sun, 10 Dec 2023 14:08:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rCRxN-0004w4-7y; Sun, 10 Dec 2023 17:07: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 1rCRxM-0004vm-D1 for qemu-devel@nongnu.org; Sun, 10 Dec 2023 17:07:24 -0500 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rCRxK-0004Ym-9k for qemu-devel@nongnu.org; Sun, 10 Dec 2023 17:07:24 -0500 Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-590b3337d2bso1045932eaf.2 for ; Sun, 10 Dec 2023 14:07:21 -0800 (PST) Received: from taylor-ubuntu.austin.rr.com (068-203-008-061.res.spectrum.com. [68.203.8.61]) by smtp.gmail.com with ESMTPSA id q23-20020a4a6c17000000b0058e200a9065sm1588173ooc.29.2023.12.10.14.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 14:07:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702246040; x=1702850840; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7INVYMT5r1D4mt+61zSzjBSfhyLG7TlXNfcj/O5bdpo=; b=YjYkSXI3kkxqYVRoULPFTMbevAg0HtRQHuYFHqDZjzf04esfqd42pLRa9x6yPXJwcR emXXZfR2ZQFCg2kji7YJBospgaXjfa9uNOWuAmg4H6ecd7YRJ8+zB2DYpux6pwf3FJhC RiXjmTmDdDE/YLgX28+nBP7+fxVweGMiBFISLlXLTWm89XFnBPvZOfyySAC3HDl2dfo9 u49BqOGvzvn8BGYx55bJ6bMn4RtD/LkTino7gi4DQrzjm0DpKpsO27ZX7JkTRyTASXm/ ysfuaOFmHsYWe0WZld4WBqqY3hQcnokQMxbxC4NY4cItl0ExHBV/uwSV4NcI0nPJyL1A OfpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702246040; x=1702850840; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7INVYMT5r1D4mt+61zSzjBSfhyLG7TlXNfcj/O5bdpo=; b=eRAmUK5v1mL5bvT1ZS/tujYJq4pC1zb2+hB7GfFaNioIF6O0wC9LaG6OfBKdKFgQIj TZNGMj6M+Ma360SjkQsDzMIFlVSQlgb93saAjyi5OD/Kc5n8qfCXvEPLeub5qFAHbGnh lO/UX4mT+JWVoSpRHpKJNwrE1G8UnXEUcJqQvnVe1nB+2F28V97LgXqQ7R+tzHkO9y5D qulUV38PCqT8dxTtB4Q2jR1s0owxbybAr0ovc92xTcf/XOqIx1RuZ4gDwWIuPqXI48YH qL9uljNNrYMGSFUrnqHZ+VTczWPolA6RpfEDjUDOOp9S+QESUHx5gu3ON+5yiQxgSbI/ 3BLQ== X-Gm-Message-State: AOJu0Yw2MMz+ALijlwLCJFkhcOCq3atFGxMLUuqKP5LP5dPB3Emd9uG4 XyTv8m5pVoHR2qFeG+aulZ50St00Xtn99A== X-Google-Smtp-Source: AGHT+IG0fQLpAWozUYYYArVxFRqb3a7o7Rejbed/RzVjpDObuw+0uU26FUKz/2MX5gY8l0pDlgRaJQ== X-Received: by 2002:a4a:385a:0:b0:58e:2925:cef4 with SMTP id o26-20020a4a385a000000b0058e2925cef4mr1900141oof.5.1702246040255; Sun, 10 Dec 2023 14:07:20 -0800 (PST) From: Taylor Simpson To: qemu-devel@nongnu.org Cc: bcain@quicinc.com, quic_mathbern@quicinc.com, sidneym@quicinc.com, quic_mliebel@quicinc.com, richard.henderson@linaro.org, philmd@linaro.org, ale@rev.ng, anjo@rev.ng, ltaylorsimpson@gmail.com Subject: [PATCH v2 3/9] Hexagon (target/hexagon) Make generators object oriented - gen_helper_protos Date: Sun, 10 Dec 2023 15:07:06 -0700 Message-Id: <20231210220712.491494-4-ltaylorsimpson@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231210220712.491494-1-ltaylorsimpson@gmail.com> References: <20231210220712.491494-1-ltaylorsimpson@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2607:f8b0:4864:20::c32; envelope-from=ltaylorsimpson@gmail.com; helo=mail-oo1-xc32.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1702246125758100011 Signed-off-by: Taylor Simpson Reviewed-by: Brian Cain --- target/hexagon/gen_helper_protos.py | 149 ++-------------------------- target/hexagon/hex_common.py | 7 -- 2 files changed, 8 insertions(+), 148 deletions(-) diff --git a/target/hexagon/gen_helper_protos.py b/target/hexagon/gen_helpe= r_protos.py index 131043795a..c82b0f54e4 100755 --- a/target/hexagon/gen_helper_protos.py +++ b/target/hexagon/gen_helper_protos.py @@ -22,39 +22,6 @@ import string import hex_common =20 -## -## Helpers for gen_helper_prototype -## -def_helper_types =3D { - "N": "s32", - "O": "s32", - "P": "s32", - "M": "s32", - "C": "s32", - "R": "s32", - "V": "ptr", - "Q": "ptr", -} - -def_helper_types_pair =3D { - "R": "s64", - "C": "s64", - "S": "s64", - "G": "s64", - "V": "ptr", - "Q": "ptr", -} - - -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) - - ## ## Generate the DEF_HELPER prototype for an instruction ## For A2_add: Rd32=3Dadd(Rs32,Rt32) @@ -65,116 +32,15 @@ def gen_helper_prototype(f, tag, tagregs, tagimms): regs =3D tagregs[tag] imms =3D tagimms[tag] =20 - numresults =3D 0 - numscalarresults =3D 0 - numscalarreadwrite =3D 0 - for regtype, regid in regs: - if hex_common.is_written(regid): - numresults +=3D 1 - if hex_common.is_scalar_reg(regtype): - numscalarresults +=3D 1 - if hex_common.is_readwrite(regid): - if hex_common.is_scalar_reg(regtype): - numscalarreadwrite +=3D 1 - - if numscalarresults > 1: - ## The helper is bogus when there is more than one result - f.write(f"DEF_HELPER_1({tag}, void, env)\n") - else: - ## Figure out how many arguments the helper will take - if numscalarresults =3D=3D 0: - def_helper_size =3D len(regs) + len(imms) + numscalarreadwrite= + 1 - if hex_common.need_pkt_has_multi_cof(tag): - def_helper_size +=3D 1 - if hex_common.need_pkt_need_commit(tag): - def_helper_size +=3D 1 - if hex_common.need_part1(tag): - def_helper_size +=3D 1 - if hex_common.need_slot(tag): - def_helper_size +=3D 1 - if hex_common.need_PC(tag): - def_helper_size +=3D 1 - if hex_common.helper_needs_next_PC(tag): - def_helper_size +=3D 1 - if hex_common.need_condexec_reg(tag, regs): - def_helper_size +=3D 1 - f.write(f"DEF_HELPER_{def_helper_size}({tag}") - ## The return type is void - f.write(", void") - else: - def_helper_size =3D len(regs) + len(imms) + numscalarreadwrite - if hex_common.need_pkt_has_multi_cof(tag): - def_helper_size +=3D 1 - if hex_common.need_pkt_need_commit(tag): - def_helper_size +=3D 1 - if hex_common.need_part1(tag): - def_helper_size +=3D 1 - if hex_common.need_slot(tag): - def_helper_size +=3D 1 - if hex_common.need_PC(tag): - def_helper_size +=3D 1 - if hex_common.need_condexec_reg(tag, regs): - def_helper_size +=3D 1 - if hex_common.helper_needs_next_PC(tag): - def_helper_size +=3D 1 - f.write(f"DEF_HELPER_{def_helper_size}({tag}") - - ## Generate the qemu DEF_HELPER type for each result - ## Iterate over this list twice - ## - Emit the scalar result - ## - Emit the vector result - i =3D 0 - 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, i) - i +=3D 1 - - ## Put the env between the outputs and inputs - f.write(", env") - i +=3D 1 - - # Second pass - 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, i) - i +=3D 1 - - ## For conditional instructions, we pass in the destination regist= er - if "A_CONDEXEC" in hex_common.attribdict[tag]: - for regtype, regid in regs: - if hex_common.is_writeonly(regid) and not hex_common.is_hv= x_reg( - regtype - ): - gen_def_helper_opn(f, tag, regtype, regid, i) - i +=3D 1 + declared =3D [] + ret_type =3D hex_common.helper_ret_type(tag, regs).proto_arg + declared.append(ret_type) =20 - ## Generate the qemu type for each input operand (regs and immedia= tes) - for regtype, regid in regs: - if hex_common.is_read(regid): - if hex_common.is_hvx_reg(regtype) and hex_common.is_readwr= ite(regid): - continue - gen_def_helper_opn(f, tag, regtype, regid, i) - i +=3D 1 - for immlett, bits, immshift in imms: - f.write(", s32") + for arg in hex_common.helper_args(tag, regs, imms): + declared.append(arg.proto_arg) =20 - ## Add the arguments for the instruction pkt_has_multi_cof, - ## pkt_needs_commit, PC, next_PC, slot, and part1 (if needed) - if hex_common.need_pkt_has_multi_cof(tag): - f.write(", i32") - if hex_common.need_pkt_need_commit(tag): - f.write(', i32') - if hex_common.need_PC(tag): - f.write(", i32") - if hex_common.helper_needs_next_PC(tag): - f.write(", i32") - if hex_common.need_slot(tag): - f.write(", i32") - if hex_common.need_part1(tag): - f.write(" , i32") - f.write(")\n") + arguments =3D ", ".join(declared) + f.write(f"DEF_HELPER_{len(declared) - 1}({tag}, {arguments})\n") =20 =20 def main(): @@ -195,6 +61,7 @@ def main(): if is_idef_parser_enabled: hex_common.read_idef_parser_enabled_file(sys.argv[5]) hex_common.calculate_attribs() + hex_common.init_registers() tagregs =3D hex_common.get_tagregs() tagimms =3D hex_common.get_tagimms() =20 diff --git a/target/hexagon/hex_common.py b/target/hexagon/hex_common.py index 979f198a30..2abd653e6d 100755 --- a/target/hexagon/hex_common.py +++ b/target/hexagon/hex_common.py @@ -290,13 +290,6 @@ def need_pkt_has_multi_cof(tag): def need_pkt_need_commit(tag): return 'A_IMPLICIT_WRITES_USR' in attribdict[tag] =20 -def need_condexec_reg(tag, regs): - if "A_CONDEXEC" in attribdict[tag]: - for regtype, regid in regs: - if is_writeonly(regid) and not is_hvx_reg(regtype): - return True - return False - =20 def skip_qemu_helper(tag): return tag in overrides.keys() --=20 2.34.1