From patchwork Tue Feb 11 00:39:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Simpson X-Patchwork-Id: 11374381 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A4F1C109A for ; Tue, 11 Feb 2020 00:45:38 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7BC1220733 for ; Tue, 11 Feb 2020 00:45:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="fT/04AA6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7BC1220733 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1JgH-0001aA-7L for patchwork-qemu-devel@patchwork.kernel.org; Mon, 10 Feb 2020 19:45:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59841) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j1Jbu-0000ye-Ri for qemu-devel@nongnu.org; Mon, 10 Feb 2020 19:41:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j1Jbs-00056Y-5t for qemu-devel@nongnu.org; Mon, 10 Feb 2020 19:41:06 -0500 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:3646) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j1Jbr-0004rG-5O for qemu-devel@nongnu.org; Mon, 10 Feb 2020 19:41:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1581381663; x=1612917663; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YKyXz9BJGWk0HFTvLbxOeHB6m1PFDX/vuoM82Z6Pb4k=; b=fT/04AA6v54Rmp1JQjUH54+6YRBbJVt5bMwlcvxY/YXo0fptV6qK1bhK p/D+FiE2/tY/h5w6hMPwMQOGER1c0DfNVmV3J3y2JLeHOz6VgE90AkfzN wENd0GNC3Vz6mkWyKpXKsvtsj7wP3tkdoJ18CTRJnpGz1wLIc7+brS0Be I=; Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 10 Feb 2020 16:40:59 -0800 Received: from vu-tsimpson-aus.qualcomm.com (HELO vu-tsimpson1-aus.qualcomm.com) ([10.222.150.1]) by ironmsg-SD-alpha.qualcomm.com with ESMTP; 10 Feb 2020 16:40:58 -0800 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id 5E9F31B5B; Mon, 10 Feb 2020 18:40:58 -0600 (CST) From: Taylor Simpson To: qemu-devel@nongnu.org Subject: [RFC PATCH 14/66] Hexagon instruction printing Date: Mon, 10 Feb 2020 18:39:52 -0600 Message-Id: <1581381644-13678-15-git-send-email-tsimpson@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1581381644-13678-1-git-send-email-tsimpson@quicinc.com> References: <1581381644-13678-1-git-send-email-tsimpson@quicinc.com> MIME-Version: 1.0 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Taylor Simpson --- target/hexagon/printinsn.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++ target/hexagon/printinsn.h | 26 +++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 target/hexagon/printinsn.c create mode 100644 target/hexagon/printinsn.h diff --git a/target/hexagon/printinsn.c b/target/hexagon/printinsn.c new file mode 100644 index 0000000..cb1004b --- /dev/null +++ b/target/hexagon/printinsn.c @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2019 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 . + */ + +#include +#include +#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_ARGS__) +#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] = '\0'; + int i, slot, opcode; + + if (pkt == NULL) { + snprintf(buf, n, ""); + return; + } + + if (pkt->num_insns > 1) { + strncat(buf, "\n{\n", n); + } + for (i = 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 = pkt->insn[i].slot; + opcode = pkt->insn[i].opcode; + snprintf(tmpbuf, 127, " //slot=%d:tag=%s", slot, opcode_names[opcode]); + strncat(buf, tmpbuf, n); + + strncat(buf, "\n", n); + } + if (pkt->num_insns > 1) { + strncat(buf, "}\n", n); + } +} + diff --git a/target/hexagon/printinsn.h b/target/hexagon/printinsn.h new file mode 100644 index 0000000..64af75c --- /dev/null +++ b/target/hexagon/printinsn.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2019 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 PRINTINSN_H +#define PRINTINSN_H + +#include +#include "insn.h" + +extern void snprint_a_pkt(char *buf, int n, packet_t *pkt); + +#endif