From patchwork Mon Aug 31 16:05:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 248768 Delivered-To: patch@linaro.org Received: by 2002:a92:5b9c:0:0:0:0:0 with SMTP id c28csp3446063ilg; Mon, 31 Aug 2020 09:13:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYYPZz12BbFjPoi01AFV88mInaNGejiVHEGzT8Xgr6s1XDWyvPQg0LvC1xu6XpOJCDdKWJ X-Received: by 2002:a5b:1c4:: with SMTP id f4mr3230937ybp.48.1598890410631; Mon, 31 Aug 2020 09:13:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598890410; cv=none; d=google.com; s=arc-20160816; b=icCBnalKYZs1fMCvVI/CIFBV+D97MIKnnnyghaswO4Dr6yIuem2WJ9mjYb5vd2rTbh JolkpXocF5os1NHAMDvj0JinLnDNGhWVl7nTR1KwKohTtEdnFqd3C35bRbQ9JFBGNwuK vqOQ+riGV7xxOLFV8EHaGF3gL3nC5y47fDJPhkmRXi0SpDNvJTIxkVfzVgsnvzUPcgjX 7vpXqjSpXy1rNTLKE8lDY2EO/7TwO4MiFBXlvcd1tgV6JdRkNbw7WPGfrT5xq9X9fUVo tUGLE3sHoivZnsDiRGQpiim7RRLcp7GzdLibIdn8KC4cdsf+z6eye+MZoHLmpWFN3mhZ 2TVg== 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=AL0uzCSfOumwHkpirTGBR8ikbqPuw1vczWQqngjG3N0=; b=nlLPRQPrwcxhrH9OjFOUKsxs/IeOyc7pWbsS9sVGrub++nok85sTIGE7twEBCU0iye 3qqvsdFwc+jfomxj2POzN2s/d6Ividweenyl3LSPcveBHoK5DlyG9aPvkDB19NUPNfG8 EeOZ1GM+kiO0lwJ1CWuvnsjTSMhMoVae2QVPJm5m8W6PF17VxP7PxRO6Etq5WRbl+atf uZpZfK/u4h16OTbHm4KZsmJ+Qb8TCK1kZVn0Wl6s/IxYCctrxBlGYLB7QvPjUbnNjbaR ZOz7ECSqGx6C/wyIQDAgnn40tKq+rmaAkiwUVpPVVRSPtVr5iuQayHiBc6dFeOLmlAyp 1o1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=LzRSJzg+; 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=fail (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 r32si8885237ybd.365.2020.08.31.09.13.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 31 Aug 2020 09:13:30 -0700 (PDT) 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=fail header.i=@linaro.org header.s=google header.b=LzRSJzg+; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:57322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kCmR0-0000sx-30 for patch@linaro.org; Mon, 31 Aug 2020 12:13:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kCmKN-0004Rp-Pk for qemu-devel@nongnu.org; Mon, 31 Aug 2020 12:06:39 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:36781) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kCmKL-000600-Tx for qemu-devel@nongnu.org; Mon, 31 Aug 2020 12:06:39 -0400 Received: by mail-pg1-x544.google.com with SMTP id p37so839657pgl.3 for ; Mon, 31 Aug 2020 09:06:37 -0700 (PDT) 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=AL0uzCSfOumwHkpirTGBR8ikbqPuw1vczWQqngjG3N0=; b=LzRSJzg+9xLDiAfHG2MiCqfHY3rfpM7pRsngkZIBkIxLXE1Z13CuRkrmV2R7gYZdaT twX5EQP9nCJVl/VnULtIbP1lwrCTDDY/bzt62WZIi0KyHoiEpdYXkM6Cjyo61CMUmnoX FqpeV6jeIdPOiQi7fuC+rk6sh9I5VCRkXQNrPjaz1jWurnj3b2ILvcuYizkp+45N0X5h ptxbtNNwJ80gZCppo1N5SNEMYjATF7ku3k5k3q1VIF+f3dWM8000CWEnDh58f/s9x7Wz o6hh9+CvW1NxoX5RSZpPp0gWnwSR/E2hkWQnt9El/8l7wAfHZ7TzqDspVWIFhoV3gBnQ P1gQ== 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=AL0uzCSfOumwHkpirTGBR8ikbqPuw1vczWQqngjG3N0=; b=jsGGUlYFIV0kfGMTEyXIH+IgoAulzaBI/yPdqhCdI7FsXev8sIwAiFamge5zHp5TID 95zdcgxVS/Hu4T5i3VyCk2Sd06wdO2YCJD4/yQ0jkODGYYq8UFfbVgt79Cmgi34Og+cP wkHp4l4KGtTGT3GHeWFr1TFy6Tc0t7pYdXPo6j4cBdZLZCzbh1mQjGm+jNIonjglGCdJ XiLZ7QXMP41hoERS/2Lb9JQLNljscHHXSdVCA3mMAe+xNo3S597a9CXiv1ASIuP2R1JO ggcpAe4PP9Otl25nVetMSvx7/aP3jb+149ZmZwkjj0plD7hcsRDk8H6A+9PaS/2HkkPy 9b/w== X-Gm-Message-State: AOAM531s4BaGEPoEus3+R1m8LLXe3Ljp+FRUSTfmsU5XsG8FL/mS5E/y hvi/8OMVZsmE4THOeXD1xVwnxPlGnvAENQ== X-Received: by 2002:a63:1f42:: with SMTP id q2mr1692764pgm.265.1598889996131; Mon, 31 Aug 2020 09:06:36 -0700 (PDT) Received: from localhost.localdomain ([71.212.141.89]) by smtp.gmail.com with ESMTPSA id gt13sm17218pjb.43.2020.08.31.09.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 09:06:35 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 24/76] target/microblaze: Tidy mb_tcg_init Date: Mon, 31 Aug 2020 09:05:09 -0700 Message-Id: <20200831160601.833692-25-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200831160601.833692-1-richard.henderson@linaro.org> References: <20200831160601.833692-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::544; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x544.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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: "Edgar E . Iglesias" , peter.maydell@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" All of the tcg globals can be recorded in the same table. Drop the "r" prefix from "rpc" and "rmsr". Obviates the need for regnames[], which was incorrectly not const. Tested-by: Edgar E. Iglesias Reviewed-by: Edgar E. Iglesias Signed-off-by: Richard Henderson --- target/microblaze/translate.c | 62 +++++++++++++++-------------------- 1 file changed, 27 insertions(+), 35 deletions(-) -- 2.25.1 diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 9aa63ddcc5..e709884f2d 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -95,14 +95,6 @@ typedef struct DisasContext { int singlestep_enabled; } DisasContext; -static const char *regnames[] = -{ - "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", - "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", - "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", -}; - static inline void t_sync_flags(DisasContext *dc) { /* Synch the tb dependent flags between translator and runtime. */ @@ -1846,36 +1838,36 @@ void mb_cpu_dump_state(CPUState *cs, FILE *f, int flags) void mb_tcg_init(void) { - int i; +#define R(X) { &cpu_R[X], offsetof(CPUMBState, regs[X]), "r" #X } +#define SP(X) { &cpu_##X, offsetof(CPUMBState, X), #X } - cpu_iflags = tcg_global_mem_new_i32(cpu_env, - offsetof(CPUMBState, iflags), - "iflags"); - cpu_imm = tcg_global_mem_new_i32(cpu_env, - offsetof(CPUMBState, imm), - "imm"); - cpu_btarget = tcg_global_mem_new_i32(cpu_env, - offsetof(CPUMBState, btarget), - "btarget"); - cpu_btaken = tcg_global_mem_new_i32(cpu_env, - offsetof(CPUMBState, btaken), - "btaken"); - cpu_res_addr = tcg_global_mem_new(cpu_env, - offsetof(CPUMBState, res_addr), - "res_addr"); - cpu_res_val = tcg_global_mem_new_i32(cpu_env, - offsetof(CPUMBState, res_val), - "res_val"); - for (i = 0; i < ARRAY_SIZE(cpu_R); i++) { - cpu_R[i] = tcg_global_mem_new_i32(cpu_env, - offsetof(CPUMBState, regs[i]), - regnames[i]); + static const struct { + TCGv_i32 *var; int ofs; char name[8]; + } i32s[] = { + R(0), R(1), R(2), R(3), R(4), R(5), R(6), R(7), + R(8), R(9), R(10), R(11), R(12), R(13), R(14), R(15), + R(16), R(17), R(18), R(19), R(20), R(21), R(22), R(23), + R(24), R(25), R(26), R(27), R(28), R(29), R(30), R(31), + + SP(pc), + SP(msr), + SP(imm), + SP(iflags), + SP(btaken), + SP(btarget), + SP(res_val), + }; + +#undef R +#undef SP + + for (int i = 0; i < ARRAY_SIZE(i32s); ++i) { + *i32s[i].var = + tcg_global_mem_new_i32(cpu_env, i32s[i].ofs, i32s[i].name); } - cpu_pc = - tcg_global_mem_new_i32(cpu_env, offsetof(CPUMBState, pc), "rpc"); - cpu_msr = - tcg_global_mem_new_i32(cpu_env, offsetof(CPUMBState, msr), "rmsr"); + cpu_res_addr = + tcg_global_mem_new(cpu_env, offsetof(CPUMBState, res_addr), "res_addr"); } void restore_state_to_opc(CPUMBState *env, TranslationBlock *tb,