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=1582909107; cv=none; d=zohomail.com; s=zohoarc; b=gIEbLMtICLL7l7xtyaVzx/mVK+qX/nCoWIDICbN6O3GLA2sOnGkJl2d9V82yefbGaoNGAEJ3XAeJu0DuyxdxgY4ugDmd+W1ujC1/mnHJpf8XkXMCxNgvJWOL9h7KHNvepTKVunedBBGPLBHz/e6uJI/UtNFgHCU3ySRA/kgOLmo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582909107; 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=xiLXgllqTqa4Dg32wC1/ZDzc5/wh/SzgW76sGR5PjCI=; b=gQ8u98v7Mxxy1JMyZ52PSPMOGTWpzcuJrZdP+Pm48ZdEMcxsardkUjHqVcOi4K7V+BOba8wcUi8NRuybNssgWoZBT46IxQ2kMo4MSdrj9/gzV6fXIt/Z4l+X62dFRhVzWKLD0BXgiM1X2S+gncaZ2AEUh7BOOuVqIqnnRCKU68w= 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 1582909107364621.8502444583094; Fri, 28 Feb 2020 08:58:27 -0800 (PST) Received: from localhost ([::1]:50800 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7iy2-0007sa-43 for importer@patchew.org; Fri, 28 Feb 2020 11:58:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57748) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j7ike-0002pB-EU 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-0005Yb-Tl 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]:13235) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j7ikb-0005U6-BS for qemu-devel@nongnu.org; Fri, 28 Feb 2020 11:44:33 -0500 Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 28 Feb 2020 08:44:30 -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; 28 Feb 2020 08:44:29 -0800 Received: by vu-tsimpson1-aus.qualcomm.com (Postfix, from userid 47164) id 9D124115A; Fri, 28 Feb 2020 10:44:29 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1582908273; x=1614444273; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xiLXgllqTqa4Dg32wC1/ZDzc5/wh/SzgW76sGR5PjCI=; b=mfW4oYB7lH7PCLLEZJDh58Cioj6F66XoK3ULd+fZ4ZKNr0JET40NtpYE k5vjQre6ZUro4a9WoV6ifdErtPamG5wtgYLZvfYa5n4bAf2Kphs1WeUJb tSLheElNr4wF45fcMv+DQXULBPE0V0fHtR6U5JJuSAOJ9jiNpLB/U+K6m M=; From: Taylor Simpson To: qemu-devel@nongnu.org Subject: [RFC PATCH v2 21/67] Hexagon generator phase 1 - C preprocessor for semantics Date: Fri, 28 Feb 2020 10:43:17 -0600 Message-Id: <1582908244-304-22-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-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) Content-Type: text/plain; charset="utf-8" Run the C preprocessor across the instruction definition files and macro de= finitoin file to expand macros and prepare the semantics_generated.pyinc fi= le. The resulting file contains one entry with the semantics for each instruction a= nd one line with the instruction attributes associated with each macro. Tested-by: Philippe Mathieu-Daud=C3=A9 --- target/hexagon/gen_semantics.c | 92 ++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 92 insertions(+) create mode 100644 target/hexagon/gen_semantics.c diff --git a/target/hexagon/gen_semantics.c b/target/hexagon/gen_semantics.c new file mode 100644 index 0000000..65d04fa --- /dev/null +++ b/target/hexagon/gen_semantics.c @@ -0,0 +1,92 @@ +/* + * 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 . + */ + +/* + * This program generates the semantics file that is processed by + * the do_qemu.py script. We use the C preporcessor to manipulate the + * files imported from the Hexagon architecture library. + */ + +#include +#define STRINGIZE(X) #X + +int main(int argc, char *argv[]) +{ + FILE *outfile; + + if (argc !=3D 2) { + fprintf(stderr, "Usage: gen_semantics ouptputfile\n"); + return -1; + } + outfile =3D fopen(argv[1], "w"); + if (outfile =3D=3D NULL) { + fprintf(stderr, "Cannot open %s for writing\n", argv[1]); + return -1; + } + +/* + * Process the instruction definitions + * Scalar core instructions have the following form + * Q6INSN(A2_add,"Rd32=3Dadd(Rs32,Rt32)",ATTRIBS(), + * "Add 32-bit registers", + * { RdV=3DRsV+RtV;}) + * HVX instructions have the following form + * EXTINSN(V6_vinsertwr, "Vx32.w=3Dvinsert(Rt32)", + * ATTRIBS(A_EXTENSION,A_CVI,A_CVI_VX,A_CVI_LATE,A_NOTE_MPY_RESOUR= CE), + * "Insert Word Scalar into Vector", + * VxV.uw[0] =3D RtV;) + */ +#define Q6INSN(TAG, BEH, ATTRIBS, DESCR, SEM) \ + do { \ + fprintf(outfile, "SEMANTICS(\"%s\",%s,\"\"\"%s\"\"\")\n", \ + #TAG, STRINGIZE(BEH), STRINGIZE(SEM)); \ + fprintf(outfile, "ATTRIBUTES(\"%s\",\"%s\")\n", \ + #TAG, STRINGIZE(ATTRIBS)); \ + } while (0); +#define EXTINSN(TAG, BEH, ATTRIBS, DESCR, SEM) \ + do { \ + fprintf(outfile, "EXT_SEMANTICS(\"%s\",\"%s\",%s,\"\"\"%s\"\"\")\n= ", \ + EXTSTR, #TAG, STRINGIZE(BEH), STRINGIZE(SEM)); \ + fprintf(outfile, "ATTRIBUTES(\"%s\",\"%s\")\n", \ + #TAG, STRINGIZE(ATTRIBS)); \ + } while (0); +#include "imported/allidefs.def" +#undef Q6INSN +#undef EXTINSN + +/* + * Process the macro definitions + * Macros definitions have the following form + * DEF_MACRO( + * fLSBNEW0,, + * "P0.new[0]", + * "Least significant bit of new P0", + * predlog_read(thread,0), + * (A_DOTNEW,A_IMPLICIT_READS_P0) + * ) + * The important part here is the attributes. Whenever an instruction + * invokes a macro, we add the macro's attributes to the instruction. + */ +#define DEF_MACRO(MNAME, PARAMS, SDESC, LDESC, BEH, ATTRS) \ + fprintf(outfile, "MACROATTRIB(\"%s\",\"\"\"%s\"\"\",\"%s\")\n", \ + #MNAME, STRINGIZE(BEH), STRINGIZE(ATTRS)); +#include "imported/macros.def" +#undef DEF_MACRO + + fclose(outfile); + return 0; +} --=20 2.7.4