From patchwork Thu Feb 14 22:59:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10813979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1B8613B5 for ; Thu, 14 Feb 2019 23:19:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE9022F3B1 for ; Thu, 14 Feb 2019 23:19:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2A7A2F3BA; Thu, 14 Feb 2019 23:19:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,FROM_LOCAL_NOVOWEL,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2AE902F3B1 for ; Thu, 14 Feb 2019 23:19:49 +0000 (UTC) Received: from localhost ([127.0.0.1]:56560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guQIG-0002Ee-G2 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 14 Feb 2019 18:19:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49516) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1guQ8v-00035F-21 for qemu-devel@nongnu.org; Thu, 14 Feb 2019 18:10:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1guQ05-00054v-Cc for qemu-devel@nongnu.org; Thu, 14 Feb 2019 18:01:02 -0500 Received: from mail-lf1-x141.google.com ([2a00:1450:4864:20::141]:42949) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1guQ03-0004wH-V2 for qemu-devel@nongnu.org; Thu, 14 Feb 2019 18:01:01 -0500 Received: by mail-lf1-x141.google.com with SMTP id l10so5777065lfh.9 for ; Thu, 14 Feb 2019 15:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HHDULZG3e7Z1kWGHd+saNhXiNIAfTG6ECOMuNoYajDQ=; b=V/GjmvZ30ZUTCaMaC8UWB8zraXSNlqqLOxQCkzzplHiE8iEJdl8b7vQxzLcTCdU6E3 TkHsgAUnmiTsnoef3s/8FkTr3i+94cUBcds5ID682v0ROSa/sMcKEuAs6Wmwhykm8+hG cgRhvDJJg2SwgHvzX3NQIPBB28rlfm+LIKcAo1hVhQSlJhVa8ThrdaWAmnxwN1ZZM3Pc Htmtk4U37AsySHn4vkhO1Zgiqc2+QpmPHJW4+6wqKT9G4K5kYws32hDu74OroJ1ooK9r AAWYbSuRN8obyMvoQVu1SIVVDz1JswfUoFxZfm1tFgLGVybD0FJaaYTaG0ESFQqfkOf3 mZsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HHDULZG3e7Z1kWGHd+saNhXiNIAfTG6ECOMuNoYajDQ=; b=C9GKPxt2qK5k5nXCWvakunJe1E5KtPz8olzis8MjzvE0GOPN2LNkQ8uba8tqrqwla4 isDyjjnpjaOGop/oNWDdjZyVXsf54rrjrQ70AEjlxcw30VdnDdYad/NI0DflaBT0cy7J Hnb77Si6AhZz+OyZA1dHcW7F8waqYW81ZHWm4kq8C/UHcXTN4usmrvKGkF6RPP/zsxbf EOkix+TIgz0He/laIm1ylJonbjy5o0aIwJBweDovTV02G4mrYPDWgYpIx2uPoEWAdezs XkGWGwYfkRQ4rcNsxBJp0o+eHB+I8zwNFoYRXbjWE6Bg6/CrvL0FfFaka12szswPRX7/ bbTQ== X-Gm-Message-State: AHQUAubJLehtR+QQJ5+ijaCfnnexvKnLWXUvhQXdP1MO2mm0k/b/moI3 jMof6OdyCbtehH0kM7xwreOnhLJ6MVY= X-Google-Smtp-Source: AHgI3IakEkK0Va3jFQYKmUV7BU22WkuQHJU4VgFJ3V3LuyltH+VftXM77b3A4sUb/P21Tb2A3ApqNQ== X-Received: by 2002:ac2:4194:: with SMTP id z20mr3622190lfh.74.1550185246354; Thu, 14 Feb 2019 15:00:46 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id h123sm172384lfh.26.2019.02.14.15.00.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 15:00:45 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Thu, 14 Feb 2019 14:59:50 -0800 Message-Id: <20190214230000.24894-4-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190214230000.24894-1-jcmvbkbc@gmail.com> References: <20190214230000.24894-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::141 Subject: [Qemu-devel] [PATCH 03/13] target/xtensa: allow multiple names for single opcode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP There are opcodes that differ only in encoding or possible range of immediate arguments. Allow multiple names for single opcode translation table entry to reduce code duplication in that case. Signed-off-by: Max Filippov --- target/xtensa/cpu.h | 4 +- target/xtensa/helper.c | 16 ++++++-- target/xtensa/translate.c | 100 ++++++++++++++++++++-------------------------- 3 files changed, 60 insertions(+), 60 deletions(-) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 2765665ceca6..db8ee70a0386 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -371,10 +371,12 @@ enum { XTENSA_OP_CHECK_INTERRUPTS = 0x200, XTENSA_OP_EXIT_TB_M1 = 0x400, XTENSA_OP_EXIT_TB_0 = 0x800, + + XTENSA_OP_NAME_ARRAY = 0x8000, }; typedef struct XtensaOpcodeOps { - const char *name; + const void *name; XtensaOpcodeOp translate; XtensaOpcodeBoolTest test_ill; XtensaOpcodeUintTest test_overflow; diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c index 57709fc20caf..7008c6390d20 100644 --- a/target/xtensa/helper.c +++ b/target/xtensa/helper.c @@ -51,9 +51,19 @@ static GHashTable *hash_opcode_translators(const XtensaOpcodeTranslators *t) GHashTable *translator = g_hash_table_new(g_str_hash, g_str_equal); for (i = 0; i < t->num_opcodes; ++i) { - add_translator_to_hash(translator, - (void *)t->opcode[i].name, - (void *)(t->opcode + i)); + if (t->opcode[i].op_flags & XTENSA_OP_NAME_ARRAY) { + const char * const *name = t->opcode[i].name; + + for (j = 0; name[j]; ++j) { + add_translator_to_hash(translator, + (void *)name[j], + (void *)(t->opcode + i)); + } + } else { + add_translator_to_hash(translator, + (void *)t->opcode[i].name, + (void *)(t->opcode + i)); + } } return translator; } diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 26342aaa1f82..1b730781ec05 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -2409,17 +2409,17 @@ static const XtensaOpcodeOps core_ops[] = { .name = "abs", .translate = translate_abs, }, { - .name = "add", + .name = (const char * const[]) { + "add", "add.n", NULL, + }, .translate = translate_add, + .op_flags = XTENSA_OP_NAME_ARRAY, }, { - .name = "add.n", - .translate = translate_add, - }, { - .name = "addi", - .translate = translate_addi, - }, { - .name = "addi.n", + .name = (const char * const[]) { + "addi", "addi.n", NULL, + }, .translate = translate_addi, + .op_flags = XTENSA_OP_NAME_ARRAY, }, { .name = "addmi", .translate = translate_addi, @@ -2495,13 +2495,12 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_bi, .par = (const uint32_t[]){TCG_COND_EQ}, }, { - .name = "beqz", - .translate = translate_bz, - .par = (const uint32_t[]){TCG_COND_EQ}, - }, { - .name = "beqz.n", + .name = (const char * const[]) { + "beqz", "beqz.n", NULL, + }, .translate = translate_bz, .par = (const uint32_t[]){TCG_COND_EQ}, + .op_flags = XTENSA_OP_NAME_ARRAY, }, { .name = "bf", .translate = translate_bp, @@ -2559,13 +2558,12 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_bi, .par = (const uint32_t[]){TCG_COND_NE}, }, { - .name = "bnez", - .translate = translate_bz, - .par = (const uint32_t[]){TCG_COND_NE}, - }, { - .name = "bnez.n", + .name = (const char * const[]) { + "bnez", "bnez.n", NULL, + }, .translate = translate_bz, .par = (const uint32_t[]){TCG_COND_NE}, + .op_flags = XTENSA_OP_NAME_ARRAY, }, { .name = "bnone", .translate = translate_bany, @@ -2725,11 +2723,10 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_nop, .op_flags = XTENSA_OP_PRIVILEGED, }, { - .name = "ill", - .op_flags = XTENSA_OP_ILL, - }, { - .name = "ill.n", - .op_flags = XTENSA_OP_ILL, + .name = (const char * const[]) { + "ill", "ill.n", NULL, + }, + .op_flags = XTENSA_OP_ILL | XTENSA_OP_NAME_ARRAY, }, { .name = "ipf", .translate = translate_nop, @@ -2763,13 +2760,12 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_l32e, .op_flags = XTENSA_OP_PRIVILEGED, }, { - .name = "l32i", - .translate = translate_ldst, - .par = (const uint32_t[]){MO_TEUL, false, false}, - }, { - .name = "l32i.n", + .name = (const char * const[]) { + "l32i", "l32i.n", NULL, + }, .translate = translate_ldst, .par = (const uint32_t[]){MO_TEUL, false, false}, + .op_flags = XTENSA_OP_NAME_ARRAY, }, { .name = "l32r", .translate = translate_l32r, @@ -2816,11 +2812,11 @@ static const XtensaOpcodeOps core_ops[] = { .name = "minu", .translate = translate_umin, }, { - .name = "mov", - .translate = translate_mov, - }, { - .name = "mov.n", + .name = (const char * const[]) { + "mov", "mov.n", NULL, + }, .translate = translate_mov, + .op_flags = XTENSA_OP_NAME_ARRAY, }, { .name = "moveqz", .translate = translate_movcond, @@ -3134,11 +3130,11 @@ static const XtensaOpcodeOps core_ops[] = { .name = "neg", .translate = translate_neg, }, { - .name = "nop", - .translate = translate_nop, - }, { - .name = "nop.n", + .name = (const char * const[]) { + "nop", "nop.n", NULL, + }, .translate = translate_nop, + .op_flags = XTENSA_OP_NAME_ARRAY, }, { .name = "nsa", .translate = translate_nsa, @@ -3202,21 +3198,18 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_rer, .op_flags = XTENSA_OP_PRIVILEGED, }, { - .name = "ret", + .name = (const char * const[]) { + "ret", "ret.n", NULL, + }, .translate = translate_ret, + .op_flags = XTENSA_OP_NAME_ARRAY, }, { - .name = "ret.n", - .translate = translate_ret, - }, { - .name = "retw", + .name = (const char * const[]) { + "retw", "retw.n", NULL, + }, .translate = translate_retw, .test_ill = test_ill_retw, - .op_flags = XTENSA_OP_UNDERFLOW, - }, { - .name = "retw.n", - .translate = translate_retw, - .test_ill = test_ill_retw, - .op_flags = XTENSA_OP_UNDERFLOW, + .op_flags = XTENSA_OP_UNDERFLOW | XTENSA_OP_NAME_ARRAY, }, { .name = "rfdd", .op_flags = XTENSA_OP_ILL, @@ -3742,17 +3735,12 @@ static const XtensaOpcodeOps core_ops[] = { .translate = translate_s32e, .op_flags = XTENSA_OP_PRIVILEGED, }, { - .name = "s32i", - .translate = translate_ldst, - .par = (const uint32_t[]){MO_TEUL, false, true}, - }, { - .name = "s32i.n", - .translate = translate_ldst, - .par = (const uint32_t[]){MO_TEUL, false, true}, - }, { - .name = "s32nb", + .name = (const char * const[]) { + "s32i", "s32i.n", "s32nb", NULL, + }, .translate = translate_ldst, .par = (const uint32_t[]){MO_TEUL, false, true}, + .op_flags = XTENSA_OP_NAME_ARRAY, }, { .name = "s32ri", .translate = translate_ldst,