From patchwork Wed Feb 17 23:40:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 384179 Delivered-To: patch@linaro.org Received: by 2002:a02:c80e:0:0:0:0:0 with SMTP id p14csp3225903jao; Wed, 17 Feb 2021 15:57:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJx5WxZh24+Cnz9IQoCasmjKCyF+dpF4WIcyHfATUoGWsUg9imf3XJxb7N3Mzy1K1+wqL6ci X-Received: by 2002:a25:824c:: with SMTP id d12mr2907591ybn.137.1613606260707; Wed, 17 Feb 2021 15:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613606260; cv=none; d=google.com; s=arc-20160816; b=JsNVNDourDEpUXt6yETmbysy4brLWZ6jY6bsVe0/89yjOQxf2ZkWTtnfpD3hprDO69 yXpwG7xUhGsKwuOjrl9fpcXZN1S3Gr/TnrfxEE4JXamULHo388J1/XzJLzur9+WKeiCs VkOPOefOEeRWlRiinlUuHvgdvz3a3stR9tJcMmsAmXm+jmaOE7TP3mnI6zyAoIoairLn 7ildtJVqsmomeCJyDxFhJ2CWbA586v98tDhn6Sm5NV4rOYgESOLir10axNVXgozcmI2e J6ueOJ86zqc7TPvsVIpJfIFFz1qpt+QJTtyWAlJqBaWW4DRbZ4NcDUgjJTCJkMakctmU oAAw== 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=wCQDJjv5dp1zQTdh7sTFK04v3fhiE0inPOMJx+iX1dA=; b=ApWI2/aVzEi10C+uEGqjO6iaxJVTqn5J+9KTzWOd3jSAyc5Av1wNx7dJ1Tu10Saf/5 Y9aNKhyFUkPODmDBMSmK1YftNzoAlRJcy8/KTeUrp0RRtdIItOyFzZ8PaPT2oFWm03pz 479XV0nkoQ01cW7SFaJszoOqEpkn2Oo5ZPbSAcwqnvXrFqVXDEjRrg0REd0EpAj4zfW3 8pJmkatsF2SKbl/UNtgY7tKvotJgYMHrNQtCRD0L5ho2egTCmSlVawtsxV+69iX/nzzL Bs9kPEvrXpdSG+wqp1G/XYPo9m0JFvcyZtpzlAgtYpBKqcVeWuSHf3KhTrHsXb7EIYU2 QFEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="worM/Tbi"; 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 k3si3536303ybh.301.2021.02.17.15.57.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Feb 2021 15:57:40 -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="worM/Tbi"; 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]:55216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCWhQ-0003a1-2Z for patch@linaro.org; Wed, 17 Feb 2021 18:57:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCWRp-00018K-Tk for qemu-devel@nongnu.org; Wed, 17 Feb 2021 18:41:35 -0500 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:38646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lCWRg-0004lb-Gc for qemu-devel@nongnu.org; Wed, 17 Feb 2021 18:41:33 -0500 Received: by mail-pg1-x52b.google.com with SMTP id m2so9526031pgq.5 for ; Wed, 17 Feb 2021 15:41:24 -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=wCQDJjv5dp1zQTdh7sTFK04v3fhiE0inPOMJx+iX1dA=; b=worM/Tbigbf1l/K87YSNHmoSzFS6/Lv50RxjSiYN071gU/oau9iGbEzfJNSQlGt4PD CbELLvSn/GojjkNsygroIyGWaCZoiCKnuZaeORPj1UFx8qUTA7QZJwCC85F5iYeJiLaR nFau/oiRoHDvj3rPjZQeabIG5lYbh6LDOcYgj34kPWF0DCS3uvdX+Uy4DD93mziFvidv rAvfymK+dfp5rfMi+WKixj0DasRHXxLyw4Lgy0CGIEYA0m21N+3zLn3tZxboJq473O4S doupX0SxDNyj49VpL/qSzZdZmCLYa++mlYujDUN6ue+BL6zpA6shYmp7lqZcGzShIV5o kBCw== 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=wCQDJjv5dp1zQTdh7sTFK04v3fhiE0inPOMJx+iX1dA=; b=MoZy6AWfq1W0dH+iS2K+UecdMG9smyTAnaaw8bnjvguiyt5CCFRETk5xLjDvcaFQll PuEjezM2e27VacZLXOavZ23bal4wHVFgeqIESvNEx0rfZpP03OcOu9bk5iqWCtTmzrMS 3WHiH5fNxaDPtPSgUOjbffDomQlLs2JeLWspsSg5Kl7jr04BMwoTWEg2O5k/fWW4ti2S Bj3sQv8TT4rS/S3jhma+kbZvjpWGYjjZ1U+rSK3+y//Jbzm1ESGF3ZGt6WXyCmAIkuvT 57edr8VNjlcdPY4mn8nabm2ap6fjWSatlLN5S/31EEwe49atiIYjG2UFN0o3WjZ6OVvN y3Ew== X-Gm-Message-State: AOAM530bKgjMHqA5Lff5Yrxt13xTznIsAcmcAAUyrjh9lcGklIXTJhbO pmysQkmNM8btEmTRioxJksu8ME8To3qIHA== X-Received: by 2002:a62:6382:0:b029:1d2:46ed:d813 with SMTP id x124-20020a6263820000b02901d246edd813mr1475280pfb.44.1613605273575; Wed, 17 Feb 2021 15:41:13 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 15:41:13 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 20/35] Hexagon (target/hexagon) generator phase 1 - C preprocessor for semantics Date: Wed, 17 Feb 2021 15:40:08 -0800 Message-Id: <20210217234023.1742406-21-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 Run the C preprocessor across the instruction definition files and macro definition file to expand macros and prepare the semantics_generated.pyinc file. The resulting file contains one entry with the semantics for each instruction and one line with the instruction attributes associated with each macro. Signed-off-by: Taylor Simpson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <1612763186-18161-20-git-send-email-tsimpson@quicinc.com> Signed-off-by: Richard Henderson --- target/hexagon/gen_semantics.c | 88 ++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 target/hexagon/gen_semantics.c -- 2.25.1 diff --git a/target/hexagon/gen_semantics.c b/target/hexagon/gen_semantics.c new file mode 100644 index 0000000000..c5fccecc9e --- /dev/null +++ b/target/hexagon/gen_semantics.c @@ -0,0 +1,88 @@ +/* + * 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 . + */ + +/* + * 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 != 2) { + fprintf(stderr, "Usage: gen_semantics ouptputfile\n"); + return 1; + } + outfile = fopen(argv[1], "w"); + if (outfile == 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=add(Rs32,Rt32)",ATTRIBS(), + * "Add 32-bit registers", + * { RdV=RsV+RtV;}) + */ +#define Q6INSN(TAG, BEH, ATTRIBS, DESCR, SEM) \ + do { \ + fprintf(outfile, "SEMANTICS( \\\n" \ + " \"%s\", \\\n" \ + " %s, \\\n" \ + " \"\"\"%s\"\"\" \\\n" \ + ")\n", \ + #TAG, STRINGIZE(BEH), STRINGIZE(SEM)); \ + fprintf(outfile, "ATTRIBUTES( \\\n" \ + " \"%s\", \\\n" \ + " \"%s\" \\\n" \ + ")\n", \ + #TAG, STRINGIZE(ATTRIBS)); \ + } while (0); +#include "imported/allidefs.def" +#undef Q6INSN + +/* + * Process the macro definitions + * Macros definitions have the following form + * DEF_MACRO( + * fLSBNEW0, + * predlog_read(thread,0), + * () + * ) + * 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, BEH, ATTRS) \ + fprintf(outfile, "MACROATTRIB( \\\n" \ + " \"%s\", \\\n" \ + " \"\"\"%s\"\"\", \\\n" \ + " \"%s\" \\\n" \ + ")\n", \ + #MNAME, STRINGIZE(BEH), STRINGIZE(ATTRS)); +#include "imported/macros.def" +#undef DEF_MACRO + + fclose(outfile); + return 0; +}