From nobody Thu Nov 13 22:04:22 2025 Delivered-To: importer@patchew.org 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; 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=1582909018; cv=none; d=zohomail.com; s=zohoarc; b=kZdzYzExthb8i483GB/ZsVe4ToKTM9eZq4BpT6cvrvGZx3wI722/TfZV0FnwLSxWl9+UXocqCydWUt/wsS1ZG2jjVmPFFWaLR98uOmTYtVTJw/blmf6DGJ90hSrizYCE8OjEVwd89usAW+80n8GC0Vx63Oh8OUCg55tkqLKDsRo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582909018; 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=nmaNHOXJLS0IoFi9w9IXnOwHbfpZW/oqSktNaMagkXc=; b=Oh0s6MG3N1NcyHWuzTEDeb3nEtZ3WOkn3km5CbBWQZnmZ5FrAy5UMFfOPzHS2SBwZ5SM7EVsYhY/g2N81eh3EG1/DwjNwJvprkogKsp/iNv6UHyD7BVOrWZ7DSSJk27hcaPdl3m6NA8/Dqehbxx2LOtgDoztA0php93Rx1fAr7s= 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 1582909018648691.2484168976503; Fri, 28 Feb 2020 08:56:58 -0800 (PST) Received: from localhost ([::1]:50760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7iwb-0005Sz-31 for importer@patchew.org; Fri, 28 Feb 2020 11:56:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57749) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7ike-0002pC-DF for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:44:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j7ikb-0005Xj-1U for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:44:36 -0500 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:13242) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7ika-0005Uc-Kx for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:44:32 -0500 Received: from unknown (HELO ironmsg05-sd.qualcomm.com) ([10.53.140.145]) by alexa-out-sd-01.qualcomm.com with ESMTP; 28 Feb 2020 08:44:29 -0800 Received: from vu-tsimpson-aus.qualcomm.com (HELO vu-tsimpson1-aus.qualcomm.com) ([10.222.150.1]) by ironmsg05-sd.qualcomm.com with ESMTP; 28 Feb 2020 08:44:28 -0800 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id 6B6F1115A; Fri, 28 Feb 2020 10:44:28 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1582908272; x=1614444272; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=nmaNHOXJLS0IoFi9w9IXnOwHbfpZW/oqSktNaMagkXc=; b=E55zXvFpISm6Q19DvPnW+btORFq+ihzMhhn6OKm60voaXVeVqCQRtDYP uj+WPVvBYSVonK/GM+H9WBD/kfSpTGXN59KX6ido4va18yoZz7EoOK2fv OygofH/uSqrv+R7fwmntIWDq7OFRu8BYKsojsoNFIDYYtvwMN0wn/VzKo 0=; From: Taylor Simpson To: qemu-devel@nongnu.org Subject: [RFC PATCH v2 15/67] Hexagon instruction printing Date: Fri, 28 Feb 2020 10:43:11 -0600 Message-Id: <1582908244-304-16-git-send-email-tsimpson@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582908244-304-1-git-send-email-tsimpson@quicinc.com> References: <1582908244-304-1-git-send-email-tsimpson@quicinc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 199.106.114.38 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: riku.voipio@iki.fi, richard.henderson@linaro.org, laurent@vivier.eu, Taylor Simpson , philmd@redhat.com, aleksandar.m.mail@gmail.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/printinsn.h | 26 +++++++++++++ target/hexagon/printinsn.c | 91 ++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 117 insertions(+) create mode 100644 target/hexagon/printinsn.h create mode 100644 target/hexagon/printinsn.c diff --git a/target/hexagon/printinsn.h b/target/hexagon/printinsn.h new file mode 100644 index 0000000..264b63c --- /dev/null +++ b/target/hexagon/printinsn.h @@ -0,0 +1,26 @@ +/* + * 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_PRINTINSN_H +#define HEXAGON_PRINTINSN_H + +#include "qemu/osdep.h" +#include "insn.h" + +extern void snprint_a_pkt(char *buf, int n, packet_t *pkt); + +#endif diff --git a/target/hexagon/printinsn.c b/target/hexagon/printinsn.c new file mode 100644 index 0000000..f59383e --- /dev/null +++ b/target/hexagon/printinsn.c @@ -0,0 +1,91 @@ +/* + * 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 . + */ + +#include "qemu/osdep.h" +#include "opcodes.h" +#include "printinsn.h" +#include "insn.h" +#include "macros.h" +#include "internal.h" + +static const char *sreg2str(unsigned int reg) +{ + if (reg < TOTAL_PER_THREAD_REGS) { + return hexagon_regnames[reg]; + } else { + return "???"; + } +} + +static const char *creg2str(unsigned int reg) +{ + return sreg2str(reg + NUM_GEN_REGS); +} + +static void snprintinsn(char *buf, int n, insn_t * insn) +{ + switch (insn->opcode) { +#define DEF_VECX_PRINTINFO(TAG, FMT, ...) DEF_PRINTINFO(TAG, FMT, __VA_ARG= S__) +#define DEF_PRINTINFO(TAG, FMT, ...) \ + case TAG: \ + snprintf(buf, n, FMT, __VA_ARGS__);\ + break; +#include "printinsn_generated.h" +#undef DEF_VECX_PRINTINFO +#undef DEF_PRINTINFO + } +} + +void snprint_a_pkt(char *buf, int n, packet_t * pkt) +{ + char tmpbuf[128]; + buf[0] =3D '\0'; + int i, slot, opcode; + + if (pkt =3D=3D NULL) { + snprintf(buf, n, ""); + return; + } + + if (pkt->num_insns > 1) { + strncat(buf, "\n{\n", n); + } + for (i =3D 0; i < pkt->num_insns; i++) { + if (pkt->insn[i].part1) { + continue; + } + snprintinsn(tmpbuf, 127, &(pkt->insn[i])); + strncat(buf, "\t", n); + strncat(buf, tmpbuf, n); + if (GET_ATTRIB(pkt->insn[i].opcode, A_SUBINSN)) { + strncat(buf, " //subinsn", n); + } + if (pkt->insn[i].extension_valid) { + strncat(buf, " //constant extended", n); + } + slot =3D pkt->insn[i].slot; + opcode =3D pkt->insn[i].opcode; + snprintf(tmpbuf, 127, " //slot=3D%d:tag=3D%s", slot, opcode_names[= opcode]); + strncat(buf, tmpbuf, n); + + strncat(buf, "\n", n); + } + if (pkt->num_insns > 1) { + strncat(buf, "}\n", n); + } +} + --=20 2.7.4