From patchwork Wed Feb 17 23:40:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 384188 Delivered-To: patch@linaro.org Received: by 2002:a02:c80e:0:0:0:0:0 with SMTP id p14csp3229774jao; Wed, 17 Feb 2021 16:04:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUGnahanHGt4JxP6f72CAMTJOvfUjZtDg6xVITr5ZDVzd/QDCOMcn1aZoHqn7ONaTaaIZ9 X-Received: by 2002:a25:8e07:: with SMTP id p7mr3102675ybl.244.1613606645212; Wed, 17 Feb 2021 16:04:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613606645; cv=none; d=google.com; s=arc-20160816; b=sLzH9Uhw480vk/PNmeRJxSO8jNWfS4Oax8TpYmmnS2EFHT1ZN5GahIpEzx7N2ZJCIc lR5MNsneXkg+wOfgE9QzBmQkwSmwkAqkArowDj0xxsokYq5Z+zpitNMjEnuO3Kn+p+QF WFB5HmYQCD2FdZXWZmy22erS02tUX9UiLQIWmcMFXvpv3U20ZGSC4qWVQBpfPIUBcZUa yV7BxPngAzNHoFWUwDJylPwbZ3VDJAQ9zYL0R23imdIQ6WVBoYO3hABNy03l8S7u4WB1 PHkZWXGB894GiOn5m8zyB/QAFZx/fAnQl3wGGUyqvOcmIKYieNQX9zoeft/gkVuB2WBl 0TMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=LIEOAUG+JkwvNv25LtjNH0tsK4duimcTBk2bKR0/Buw=; b=Yyd3AG+IkjV727OiUMKaAmOB7S6tFZWB3fZbB8cNsGEm/hyVOwDmPjjU9QnympgQ7c cW3/fXqt1t7gX3CWuWp3jPipU64xh54pZl0PoQ/P8XlaHwT9MYbZZ1EdDA2CigIGJroy n/jvZoeEtACPZ2C+KGJY5meR10GYNXwbPrM2YYe6YCQHytJAJvFGI2jsHjcfvxdqtsRp mA3gspCy1m7QA/bjFP8EQxuQgATE7SBPaCWQn6I8LDYm44dUjiQRMeL4qTwype2SSktc pgc6uSg9c6dKdIhOPD1JGZxUaW5LP41ItcGmsCoyT6IZoT35G3hDLms2zdg2CPqlj30x sVZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=krgYlL13; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f23si4452976ybg.356.2021.02.17.16.04.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Feb 2021 16:04:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=krgYlL13; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCWna-0002iV-Ug for patch@linaro.org; Wed, 17 Feb 2021 19:04:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCWRz-0001Af-NH for qemu-devel@nongnu.org; Wed, 17 Feb 2021 18:41:46 -0500 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:40186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lCWRj-0004mV-HB for qemu-devel@nongnu.org; Wed, 17 Feb 2021 18:41:38 -0500 Received: by mail-pg1-x52b.google.com with SMTP id b21so9518501pgk.7 for ; Wed, 17 Feb 2021 15:41:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LIEOAUG+JkwvNv25LtjNH0tsK4duimcTBk2bKR0/Buw=; b=krgYlL13NzzTk1X70Fk3CSTVMuaOruZ9+OjCq1fSrUpYmxg9RFAciByp1zeevHDvAi Wm44Mp5M4LLEBpiv+OJ50mc1+X38+2Wk8zmpNQa9v3g1K+sByPDTT/llVwwNj0Eq0qhl tnURF3iXoSF7lAkr9O/hDx1hqXbLYpfiB15yteIlIv2jmb+zAUIiBOPONrL27KGVrL83 DCO9oAJkbtu2uP3L7GYU7bndgXj5KvUIWtjYck+acN9tSKwM49oXD1PMw7vqS5dkn95m trK+3Y6oFKccs/R+JemLfQezzIwNkkxUIWrl13k2hmQFV4Q4RCEBjvzPBi0jkDlFy21R bHGg== 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:mime-version:content-transfer-encoding; bh=LIEOAUG+JkwvNv25LtjNH0tsK4duimcTBk2bKR0/Buw=; b=awuk/7h4yPr3e3nGcvQ23YMbv0WnCH0VbLbvrB2p4AdhOlDZqJ/htxitqri+9KDmv/ OE/NpvIi403IUmTeV/GTAn/bq1B2B89Dst+4N89ZUrKRaxOb+pToHVwnTFzzPFs95xGK osk+s2wSjYFhdaStEXCppl2rvRin0EoGonbWP5hyhyFRtWFpNbKFO/P0ElTeWOgaQT3v fVarn6U8qnAbQ5K8fi47+QuHFFkf+KbIOCKg0f8Oc6a41b7eeUVkPbOK9qe0ym+OjahZ sAhTqCnSusYZVXKVm10ZDTgkgd4Vpom9hroEBZhMWmHlv++nru1fgqJHNXV2oLETZzLV hdmQ== X-Gm-Message-State: AOAM531ZBtFM2CiD6nLqjASaEp5dSsJoCdRc2romiRuSzgr7dViupSlO a5L8npNcoW+kHK3nE8boGQkbhsAb8rUikg== X-Received: by 2002:a62:8453:0:b029:1e4:3a6a:d5ba with SMTP id k80-20020a6284530000b02901e43a6ad5bamr1565727pfd.54.1613605285374; Wed, 17 Feb 2021 15:41:25 -0800 (PST) Received: from localhost.localdomain (047-051-160-125.biz.spectrum.com. [47.51.160.125]) by smtp.gmail.com with ESMTPSA id c21sm3950355pgh.0.2021.02.17.15.41.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 15:41:24 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 24/35] Hexagon (target/hexagon) opcode data structures Date: Wed, 17 Feb 2021 15:40:12 -0800 Message-Id: <20210217234023.1742406-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210217234023.1742406-1-richard.henderson@linaro.org> References: <20210217234023.1742406-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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: , Cc: peter.maydell@linaro.org, Taylor Simpson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Taylor Simpson Signed-off-by: Taylor Simpson Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-Id: <1612763186-18161-24-git-send-email-tsimpson@quicinc.com> Signed-off-by: Richard Henderson --- target/hexagon/opcodes.h | 58 ++++++++++++++++ target/hexagon/opcodes.c | 142 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 200 insertions(+) create mode 100644 target/hexagon/opcodes.h create mode 100644 target/hexagon/opcodes.c -- 2.25.1 diff --git a/target/hexagon/opcodes.h b/target/hexagon/opcodes.h new file mode 100644 index 0000000000..6e90e00fe2 --- /dev/null +++ b/target/hexagon/opcodes.h @@ -0,0 +1,58 @@ +/* + * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +#ifndef HEXAGON_OPCODES_H +#define HEXAGON_OPCODES_H + +typedef enum { +#define OPCODE(IID) IID +#include "opcodes_def_generated.h.inc" + XX_LAST_OPCODE +#undef OPCODE +} Opcode; + +typedef enum { + NORMAL, + HALF, + SUBINSN_A, + SUBINSN_L1, + SUBINSN_L2, + SUBINSN_S1, + SUBINSN_S2, + EXT_noext, + EXT_mmvec, + XX_LAST_ENC_CLASS +} EncClass; + +extern const char * const opcode_names[]; + +extern const char * const opcode_reginfo[]; +extern const char * const opcode_rregs[]; +extern const char * const opcode_wregs[]; + +typedef struct { + const char * const encoding; + const EncClass enc_class; +} OpcodeEncoding; + +extern const OpcodeEncoding opcode_encodings[XX_LAST_OPCODE]; + +void opcode_init(void); + +int opcode_which_immediate_is_extended(Opcode opcode); + +#endif diff --git a/target/hexagon/opcodes.c b/target/hexagon/opcodes.c new file mode 100644 index 0000000000..4eef5fc40f --- /dev/null +++ b/target/hexagon/opcodes.c @@ -0,0 +1,142 @@ +/* + * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see . + */ + +/* + * opcodes.c + * + * data tables generated automatically + * Maybe some functions too + */ + +#include "qemu/osdep.h" +#include "attribs.h" +#include "decode.h" + +#define VEC_DESCR(A, B, C) DESCR(A, B, C) +#define DONAME(X) #X + +const char * const opcode_names[] = { +#define OPCODE(IID) DONAME(IID) +#include "opcodes_def_generated.h.inc" + NULL +#undef OPCODE +}; + +const char * const opcode_reginfo[] = { +#define IMMINFO(TAG, SIGN, SIZE, SHAMT, SIGN2, SIZE2, SHAMT2) /* nothing */ +#define REGINFO(TAG, REGINFO, RREGS, WREGS) REGINFO, +#include "op_regs_generated.h.inc" + NULL +#undef REGINFO +#undef IMMINFO +}; + + +const char * const opcode_rregs[] = { +#define IMMINFO(TAG, SIGN, SIZE, SHAMT, SIGN2, SIZE2, SHAMT2) /* nothing */ +#define REGINFO(TAG, REGINFO, RREGS, WREGS) RREGS, +#include "op_regs_generated.h.inc" + NULL +#undef REGINFO +#undef IMMINFO +}; + + +const char * const opcode_wregs[] = { +#define IMMINFO(TAG, SIGN, SIZE, SHAMT, SIGN2, SIZE2, SHAMT2) /* nothing */ +#define REGINFO(TAG, REGINFO, RREGS, WREGS) WREGS, +#include "op_regs_generated.h.inc" + NULL +#undef REGINFO +#undef IMMINFO +}; + +const char * const opcode_short_semantics[] = { +#define DEF_SHORTCODE(TAG, SHORTCODE) [TAG] = #SHORTCODE, +#include "shortcode_generated.h.inc" +#undef DEF_SHORTCODE + NULL +}; + +DECLARE_BITMAP(opcode_attribs[XX_LAST_OPCODE], A_ZZ_LASTATTRIB); + +static void init_attribs(int tag, ...) +{ + va_list ap; + int attr; + va_start(ap, tag); + while ((attr = va_arg(ap, int)) != 0) { + set_bit(attr, opcode_attribs[tag]); + } +} + +const OpcodeEncoding opcode_encodings[] = { +#define DEF_ENC32(OPCODE, ENCSTR) \ + [OPCODE] = { .encoding = ENCSTR }, + +#define DEF_ENC_SUBINSN(OPCODE, CLASS, ENCSTR) \ + [OPCODE] = { .encoding = ENCSTR, .enc_class = CLASS }, + +#define DEF_EXT_ENC(OPCODE, CLASS, ENCSTR) \ + [OPCODE] = { .encoding = ENCSTR, .enc_class = CLASS }, + +#include "imported/encode.def" + +#undef DEF_ENC32 +#undef DEF_ENC_SUBINSN +#undef DEF_EXT_ENC +}; + +void opcode_init(void) +{ + init_attribs(0, 0); + +#define ATTRIBS(...) , ## __VA_ARGS__, 0 +#define OP_ATTRIB(TAG, ARGS) init_attribs(TAG ARGS); +#include "op_attribs_generated.h.inc" +#undef OP_ATTRIB +#undef ATTRIBS + + decode_init(); +} + + +#define NEEDLE "IMMEXT(" + +int opcode_which_immediate_is_extended(Opcode opcode) +{ + const char *p; + + g_assert(opcode < XX_LAST_OPCODE); + g_assert(GET_ATTRIB(opcode, A_EXTENDABLE)); + + p = opcode_short_semantics[opcode]; + p = strstr(p, NEEDLE); + g_assert(p); + p += strlen(NEEDLE); + while (isspace(*p)) { + p++; + } + /* lower is always imm 0, upper always imm 1. */ + if (islower(*p)) { + return 0; + } else if (isupper(*p)) { + return 1; + } else { + g_assert_not_reached(); + } +}