From nobody Mon Feb 9 10:11:59 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail header.i=@quicinc.com; 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=fail(p=none dis=none) header.from=quicinc.com ARC-Seal: i=1; a=rsa-sha256; t=1604018997; cv=none; d=zohomail.com; s=zohoarc; b=nVqXhaGwUR6ts5hDQObsZBm3vNDRDyc2Jj5ekSaQVuDO2G/uJyqUJKoPtA9XRfIm+/3z4hvgSUogNNgB1rZYshqx2xSVbIlJUVUJZ6b7ELG2Iuhe2pnf1QySx1IPmTUautsepI7opdyhv1/GGkVrWdrIPFKyCmbY1cN3Tq0I+oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604018997; h=Content-Type: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:References:Sender:Subject:To; bh=imU09Tt+d1ujYxvMKPP7vwVzxTmlGL4gnQuSe05AbUk=; b=RGg40gftNkJKMW+PF5U9/WJIFaqGo8ApeuTPvp8kJ81VGqqR0s8jpD0HxhERwwZUDNPcp4K7NjcWfou65AHSc0MwkL8UNWbdEj+YbANdAQDwkiGhct8PmvS9RQvJme8vAXqqlJn7DxgvtNvJ94+a7dqQ0KByxqzb0GQ4eh7VnxU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail header.i=@quicinc.com; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604018997271104.60100078762241; Thu, 29 Oct 2020 17:49:57 -0700 (PDT) Received: from localhost ([::1]:47566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYIc6-0003q0-4p for importer@patchew.org; Thu, 29 Oct 2020 20:49:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYHyy-0004GB-6O for qemu-devel@nongnu.org; Thu, 29 Oct 2020 20:09:28 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:51268) by eggs.gnu.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kYHyp-0005RC-53 for qemu-devel@nongnu.org; Thu, 29 Oct 2020 20:09:27 -0400 Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 29 Oct 2020 17:08:46 -0700 Received: from vu-tsimpson-aus.qualcomm.com (HELO vu-tsimpson1-aus.qualcomm.com) ([10.222.150.1]) by ironmsg03-sd.qualcomm.com with ESMTP; 29 Oct 2020 17:08:46 -0700 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id ED3A5411C; Thu, 29 Oct 2020 19:08:45 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1604016559; x=1635552559; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=imU09Tt+d1ujYxvMKPP7vwVzxTmlGL4gnQuSe05AbUk=; b=v9lW/NelC9cw10zHL3ZCXJ+jo8NV/SrRrXW84LXzeO0V2yzf86dX8iyX RGOTkzOThaRgPM5o8LBC7XhdxjDsattVyTVhipx+MtNlGWSqvZsbGIiFs hvNyj8c4MWZ+ydx5/2KANpjJCjstWstUep+3Gl6yOvcQQpRvlemXg+4nO U=; X-QCInternal: smtphost From: Taylor Simpson To: qemu-devel@nongnu.org Subject: [RFC PATCH v5 23/33] Hexagon (target/hexagon) opcode data structures Date: Thu, 29 Oct 2020 19:08:29 -0500 Message-Id: <1604016519-28065-24-git-send-email-tsimpson@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604016519-28065-1-git-send-email-tsimpson@quicinc.com> References: <1604016519-28065-1-git-send-email-tsimpson@quicinc.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=199.106.114.38; envelope-from=tsimpson@qualcomm.com; helo=alexa-out-sd-01.qualcomm.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/29 19:58:53 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_MED=-2.3, 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: ale@rev.ng, bcain@quicinc.com, richard.henderson@linaro.org, at.org@qualcomm.com, laurent@vivier.eu, tsimpson@quicinc.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Signed-off-by: Taylor Simpson --- target/hexagon/opcodes.h | 63 +++++++++++++++++++++ target/hexagon/opcodes.c | 142 +++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 205 insertions(+) create mode 100644 target/hexagon/opcodes.h create mode 100644 target/hexagon/opcodes.c diff --git a/target/hexagon/opcodes.h b/target/hexagon/opcodes.h new file mode 100644 index 0000000..1aa2074 --- /dev/null +++ b/target/hexagon/opcodes.h @@ -0,0 +1,63 @@ +/* + * Copyright(c) 2019-2020 Qualcomm Innovation Center, Inc. All Rights Res= erved. + * + * 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 + +#include "qemu/bitmap.h" +#include "attribs.h" + +typedef enum { +#define OPCODE(IID) IID +#include "opcodes_def_generated.h" + 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]; + +extern DECLARE_BITMAP(opcode_attribs[XX_LAST_OPCODE], A_ZZ_LASTATTRIB); + +extern void opcode_init(void); + +extern 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 0000000..20400f5 --- /dev/null +++ b/target/hexagon/opcodes.c @@ -0,0 +1,142 @@ +/* + * Copyright(c) 2019-2020 Qualcomm Innovation Center, Inc. All Rights Res= erved. + * + * 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 "opcodes.h" +#include "decode.h" + +#define VEC_DESCR(A, B, C) DESCR(A, B, C) +#define DONAME(X) #X + +const char * const opcode_names[] =3D { +#define OPCODE(IID) DONAME(IID) +#include "opcodes_def_generated.h" + NULL +#undef OPCODE +}; + +const char * const opcode_reginfo[] =3D { +#define IMMINFO(TAG, SIGN, SIZE, SHAMT, SIGN2, SIZE2, SHAMT2) /* nothin= g */ +#define REGINFO(TAG, REGINFO, RREGS, WREGS) REGINFO, +#include "op_regs_generated.h" + NULL +#undef REGINFO +#undef IMMINFO +}; + + +const char * const opcode_rregs[] =3D { +#define IMMINFO(TAG, SIGN, SIZE, SHAMT, SIGN2, SIZE2, SHAMT2) /* nothin= g */ +#define REGINFO(TAG, REGINFO, RREGS, WREGS) RREGS, +#include "op_regs_generated.h" + NULL +#undef REGINFO +#undef IMMINFO +}; + + +const char * const opcode_wregs[] =3D { +#define IMMINFO(TAG, SIGN, SIZE, SHAMT, SIGN2, SIZE2, SHAMT2) /* nothin= g */ +#define REGINFO(TAG, REGINFO, RREGS, WREGS) WREGS, +#include "op_regs_generated.h" + NULL +#undef REGINFO +#undef IMMINFO +}; + +const char * const opcode_short_semantics[] =3D { +#define DEF_SHORTCODE(TAG, SHORTCODE) [TAG] =3D #SHORTCODE, +#include "shortcode_generated.h" +#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 =3D va_arg(ap, int)) !=3D 0) { + set_bit(attr, opcode_attribs[tag]); + } +} + +const OpcodeEncoding opcode_encodings[] =3D { +#define DEF_ENC32(OPCODE, ENCSTR) \ + [OPCODE] =3D { .encoding =3D ENCSTR }, + +#define DEF_ENC_SUBINSN(OPCODE, CLASS, ENCSTR) \ + [OPCODE] =3D { .encoding =3D ENCSTR, .enc_class =3D CLASS }, + +#define DEF_EXT_ENC(OPCODE, CLASS, ENCSTR) \ + [OPCODE] =3D { .encoding =3D ENCSTR, .enc_class =3D 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" +#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 =3D opcode_short_semantics[opcode]; + p =3D strstr(p, NEEDLE); + g_assert(p); + p +=3D 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(); + } +} --=20 2.7.4