From patchwork Mon Sep 30 09:10:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 831539 Delivered-To: patch@linaro.org Received: by 2002:a5d:66c8:0:b0:367:895a:4699 with SMTP id k8csp1852213wrw; Mon, 30 Sep 2024 02:13:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW1Ma0k7SM/Yt+OAkNNknU8Pc3xqJnKoQ+N0yEIZLTRqPl0qJC5axoJL0uta/O5BP3tyUaA/A==@linaro.org X-Google-Smtp-Source: AGHT+IEyyaWi6SIVqH73FTTYc1PNte+j6VUAWNahVPmaYgI787W+Mr55nLGea9RO05ZLJqt16xbY X-Received: by 2002:a05:622a:40f:b0:458:b56:9096 with SMTP id d75a77b69052e-45c9f2927eemr184485051cf.59.1727687591820; Mon, 30 Sep 2024 02:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727687591; cv=none; d=google.com; s=arc-20240605; b=alTxaz3jzCDafek2hvFN+m6FRRcmq+kqp1M8nAzRZTneSqUxsfkBEZtSsYlmCrm2Xq jcAD60NmH5Wxk/i3RSZI57LQTIQfAMLTzy7FAuRl7uPW7UPVTnnD7xZ+ASamqQmDZq9g JaAMAxdFGyuN/4SCRItzMWXjP5OPW7R0dG2HvntO4IyagCkwzy6pde+tSuEUFHlog5B3 4VlO7DI7cPocAnADgl2JPcufP5t0MRLGVBDnSqDd2XNqmTaJz8yo3XLLFWj51hhq5NXe jeux+0ZnwB5QEcJVENmxTydCM+it11lRkY20LfzoTJpNv9frUVw3bJX5eVXqSKWCah98 1ynA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to: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:cc:to :from:dkim-signature; bh=7QhDoekpFyldPlQdJYrNU9meNhoETaKUrN8Umy5eIAI=; fh=k5rVqKUsbd8Y0L3bPWUhjMmTdbpOHX+if6Hlm9il+vc=; b=eI02ZbFftHAatiZgsvozbuAwZjI/hizfk8yph9wX7BSZdoq2cQqWK9M53wJJDcc3t+ LN2y4BbHnGmbRysqsVKLvBjzkA220LOqcCmWjGcE2RckifbwzVDNI0Royt/08+q+d2PY 1vFwQ5ORO6MVMkxjz++w5lTjZsIB2tEoNCH9Ca9eGuxitvneieyIzalkmz9i5Mklw8QV JAxZqpGwPH5ggCxvkVxhHk3mvNCRKQEC+p7z0azVsx77SnMZL6KgYzrCJHxoDkxpHl5g mcF49a2CYgo//XFDTGbPz5HuE+uzlmeMlWIsgyy+8VGpen3bt59v4xJxkjq30ruucm2z +rLQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ps1Jw4bW; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-45c9f328b48si78884281cf.333.2024.09.30.02.13.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Sep 2024 02:13:11 -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=pass header.i=@linaro.org header.s=google header.b=ps1Jw4bW; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1svCRd-0000qs-DE; Mon, 30 Sep 2024 05:11:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1svCRW-0000bW-FX for qemu-devel@nongnu.org; Mon, 30 Sep 2024 05:11:47 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1svCRT-0004XP-IW for qemu-devel@nongnu.org; Mon, 30 Sep 2024 05:11:46 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-37cc810ce73so2354053f8f.1 for ; Mon, 30 Sep 2024 02:11:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727687495; x=1728292295; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7QhDoekpFyldPlQdJYrNU9meNhoETaKUrN8Umy5eIAI=; b=ps1Jw4bWCezUraDLV9ca4l8aOhKBkFZdrSJPjvyw+jgNLj8Uexc7/kfoTxrWC5jvZZ 5nZvvobPC0u1Plm5RjNzLtAY2vcISxpBYHSn3wuVIsgJBVbYcHKKXum7flP57rV5U+Ck MqhHhpDbR3uB8B+cxwdg9NTHv/UqC5cyppI2Z6jypdbv4hbGrrb5s2P9VONIn+ybU1MO b52iGn/sT6dAgBIgyJndj444Ghfj87h0RYs79B1El2chYk5GysYaYeHw57zyOQ0k4f4R w0hxhgvI3HaFn64m0IEL/1qFENQKiMYrctOL5h5rjAfLbBdZXx5BW0dptoWWla8Ui3VS 29Ig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727687495; x=1728292295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7QhDoekpFyldPlQdJYrNU9meNhoETaKUrN8Umy5eIAI=; b=prPgDn4AKKQaEVMD4/1K8nc7pjjZnVRGeqABDngcWm9P+93ohRCFqsDEIgvhal1U49 BKV5PFPxkxetKrLRQqheKvIu/VA6EOcQb5b2p4BUbTzlrT8rVJJuIxKO0NqdHrDDgS2v pr/Ov0h/P2LtA90A7MVqKQ4ZGYSWdHeA+FL+GYKEvJ5XvX3v7ViTLW1REw6e/HDuO7UX qHcvc3aqF6rZH0r2N3Do/IkVf7q+yS/l0TLmp3GYST0Uh/cBNKG6f7OcAYLxej1MB8vt /wZ8gukJWd+/rBqIad3gqeUx2AjkVKRYBhFJeAzFXCU3ObaOoM+8ym7KtGtZp7XUORBp 7VsA== X-Gm-Message-State: AOJu0YzqfXyUX06lhmS7N4/vj47Pjccmtw9HNNrs9D8dv0e6JYQKX32x Il7rwY72+v982P8sj/onF9aN3ZFNPHLbMfe7L90OQ4+ue+R3W+Q0+8l86WRqJDcyuZvw7932kRU K X-Received: by 2002:adf:fec3:0:b0:37c:ca21:bc5d with SMTP id ffacd0b85a97d-37cd5aa9ab4mr5030789f8f.17.1727687494884; Mon, 30 Sep 2024 02:11:34 -0700 (PDT) Received: from localhost.localdomain (183.red-88-28-18.dynamicip.rima-tde.net. [88.28.18.183]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37cd55a5414sm8663530f8f.0.2024.09.30.02.11.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Sep 2024 02:11:34 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Thomas Huth , Aurelien Jarno , =?utf-8?q?Herv=C3=A9_Poussineau?= , =?utf-8?q?Philipp?= =?utf-8?q?e_Mathieu-Daud=C3=A9?= , Richard Henderson , Jiaxun Yang , Aleksandar Rikalo , Huacai Chen , Anton Johansson Subject: [PATCH 04/12] target/mips: Convert mips16e decr_and_load/store() macros to functions Date: Mon, 30 Sep 2024 11:10:53 +0200 Message-ID: <20240930091101.40591-5-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240930091101.40591-1-philmd@linaro.org> References: <20240930091101.40591-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=philmd@linaro.org; helo=mail-wr1-x435.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, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Functions are easier to rework than macros. Besides, there is no gain here in inlining these. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/mips/tcg/mips16e_translate.c.inc | 101 +++++++++++++----------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/target/mips/tcg/mips16e_translate.c.inc b/target/mips/tcg/mips16e_translate.c.inc index 5cffe0e412..31bc14f9ca 100644 --- a/target/mips/tcg/mips16e_translate.c.inc +++ b/target/mips/tcg/mips16e_translate.c.inc @@ -122,11 +122,23 @@ enum { static int xlat(int r) { - static int map[] = { 16, 17, 2, 3, 4, 5, 6, 7 }; + static const int map[] = { 16, 17, 2, 3, 4, 5, 6, 7 }; return map[r]; } +static void decr_and_store(DisasContext *ctx, unsigned regidx, TCGv t0) +{ + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + tcg_gen_movi_tl(t2, -4); + gen_op_addr_add(ctx, t0, t0, t2); + gen_load_gpr(t1, regidx); + tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | + ctx->default_tcg_memop_mask); +} + static void gen_mips16_save(DisasContext *ctx, int xsregs, int aregs, int do_ra, int do_s0, int do_s1, @@ -196,46 +208,38 @@ static void gen_mips16_save(DisasContext *ctx, gen_load_gpr(t0, 29); -#define DECR_AND_STORE(reg) do { \ - tcg_gen_movi_tl(t2, -4); \ - gen_op_addr_add(ctx, t0, t0, t2); \ - gen_load_gpr(t1, reg); \ - tcg_gen_qemu_st_tl(t1, t0, ctx->mem_idx, MO_TEUL | \ - ctx->default_tcg_memop_mask); \ - } while (0) - if (do_ra) { - DECR_AND_STORE(31); + decr_and_store(ctx, 31, t0); } switch (xsregs) { case 7: - DECR_AND_STORE(30); + decr_and_store(ctx, 30, t0); /* Fall through */ case 6: - DECR_AND_STORE(23); + decr_and_store(ctx, 23, t0); /* Fall through */ case 5: - DECR_AND_STORE(22); + decr_and_store(ctx, 22, t0); /* Fall through */ case 4: - DECR_AND_STORE(21); + decr_and_store(ctx, 21, t0); /* Fall through */ case 3: - DECR_AND_STORE(20); + decr_and_store(ctx, 20, t0); /* Fall through */ case 2: - DECR_AND_STORE(19); + decr_and_store(ctx, 19, t0); /* Fall through */ case 1: - DECR_AND_STORE(18); + decr_and_store(ctx, 18, t0); } if (do_s1) { - DECR_AND_STORE(17); + decr_and_store(ctx, 17, t0); } if (do_s0) { - DECR_AND_STORE(16); + decr_and_store(ctx, 16, t0); } switch (aregs) { @@ -270,23 +274,34 @@ static void gen_mips16_save(DisasContext *ctx, } if (astatic > 0) { - DECR_AND_STORE(7); + decr_and_store(ctx, 7, t0); if (astatic > 1) { - DECR_AND_STORE(6); + decr_and_store(ctx, 6, t0); if (astatic > 2) { - DECR_AND_STORE(5); + decr_and_store(ctx, 5, t0); if (astatic > 3) { - DECR_AND_STORE(4); + decr_and_store(ctx, 4, t0); } } } } -#undef DECR_AND_STORE tcg_gen_movi_tl(t2, -framesize); gen_op_addr_add(ctx, cpu_gpr[29], cpu_gpr[29], t2); } +static void decr_and_load(DisasContext *ctx, unsigned regidx, TCGv t0) +{ + TCGv t1 = tcg_temp_new(); + TCGv t2 = tcg_temp_new(); + + tcg_gen_movi_tl(t2, -4); + gen_op_addr_add(ctx, t0, t0, t2); + tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TESL | + ctx->default_tcg_memop_mask); + gen_store_gpr(t1, regidx); +} + static void gen_mips16_restore(DisasContext *ctx, int xsregs, int aregs, int do_ra, int do_s0, int do_s1, @@ -294,52 +309,43 @@ static void gen_mips16_restore(DisasContext *ctx, { int astatic; TCGv t0 = tcg_temp_new(); - TCGv t1 = tcg_temp_new(); TCGv t2 = tcg_temp_new(); tcg_gen_movi_tl(t2, framesize); gen_op_addr_add(ctx, t0, cpu_gpr[29], t2); -#define DECR_AND_LOAD(reg) do { \ - tcg_gen_movi_tl(t2, -4); \ - gen_op_addr_add(ctx, t0, t0, t2); \ - tcg_gen_qemu_ld_tl(t1, t0, ctx->mem_idx, MO_TESL | \ - ctx->default_tcg_memop_mask); \ - gen_store_gpr(t1, reg); \ - } while (0) - if (do_ra) { - DECR_AND_LOAD(31); + decr_and_load(ctx, 31, t0); } switch (xsregs) { case 7: - DECR_AND_LOAD(30); + decr_and_load(ctx, 30, t0); /* Fall through */ case 6: - DECR_AND_LOAD(23); + decr_and_load(ctx, 23, t0); /* Fall through */ case 5: - DECR_AND_LOAD(22); + decr_and_load(ctx, 22, t0); /* Fall through */ case 4: - DECR_AND_LOAD(21); + decr_and_load(ctx, 21, t0); /* Fall through */ case 3: - DECR_AND_LOAD(20); + decr_and_load(ctx, 20, t0); /* Fall through */ case 2: - DECR_AND_LOAD(19); + decr_and_load(ctx, 19, t0); /* Fall through */ case 1: - DECR_AND_LOAD(18); + decr_and_load(ctx, 18, t0); } if (do_s1) { - DECR_AND_LOAD(17); + decr_and_load(ctx, 17, t0); } if (do_s0) { - DECR_AND_LOAD(16); + decr_and_load(ctx, 16, t0); } switch (aregs) { @@ -374,18 +380,17 @@ static void gen_mips16_restore(DisasContext *ctx, } if (astatic > 0) { - DECR_AND_LOAD(7); + decr_and_load(ctx, 7, t0); if (astatic > 1) { - DECR_AND_LOAD(6); + decr_and_load(ctx, 6, t0); if (astatic > 2) { - DECR_AND_LOAD(5); + decr_and_load(ctx, 5, t0); if (astatic > 3) { - DECR_AND_LOAD(4); + decr_and_load(ctx, 4, t0); } } } } -#undef DECR_AND_LOAD tcg_gen_movi_tl(t2, framesize); gen_op_addr_add(ctx, cpu_gpr[29], cpu_gpr[29], t2);