From patchwork Sat Dec 28 23:11:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 182513 Delivered-To: patch@linaro.org Received: by 2002:a92:815a:0:0:0:0:0 with SMTP id e87csp4646124ild; Sat, 28 Dec 2019 15:21:06 -0800 (PST) X-Google-Smtp-Source: APXvYqyeif3a/zFhEvDWUDwYUPUTcXKcYmb0FpmYS6prLFg8Fc35lWjQtEdac0JNqyHx/NKv6IhJ X-Received: by 2002:a9d:7e99:: with SMTP id m25mr62740738otp.212.1577575266247; Sat, 28 Dec 2019 15:21:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577575266; cv=none; d=google.com; s=arc-20160816; b=GfOxw8bJD7dILfnfg322JCV0Nef4rD93hy6F/t6HwIVvNHk3ghpdQXoNRBy04zDPyA QSzR4m+KXqeAeLF3pMTint03AES1ePC81reszGmIOqcqdETfvqRAbBsc3cT+TT+0G8Ft uNT4MiJGGDNjkfjboceLU6tLfdPCT/DtfcqLEeihaMIHyuE49Aji0xApHYEH6WnQnrLJ rj3EVA4T30jTO5EbTE+RDI+W2TyDzA5yIfPPB5Jr9jV7Rk5GLhCEVGDyp6dErwAh+znI 55SEO6ThufdCPwOS96HZLtRxnaC8SEpSxPuFDsa42d7dJPmAaNVc8Q2uN0lJ2tA6k7Wq VjOQ== 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=w1Tjfb9SeZwoP+jBqe2wdJ6MBodnhM7nlLGRuc9cKpc=; b=ZB/FhcCXy3ROnG16Q1o9eGkIj+3QGMov+Vj4B1fEVTlc+m9PPiaacFgLDsoA/RVp4w OvObvSVQY65f5u2Bn2ND06PE/BLAfkj+5yq7tjH89EEjbCHuxwStuyFR3/r8fTsEEH1B MmHBHShwVSuXjUtBEes17pOyaMdUuxCIlZA1YqNOBhIz3nIe6Fm0K+79JSlILGT4x/D9 vlWKy9FesR9ZMbUjLBsloAK2XZmwxooNFkxwxpjT8YSj0VayiGO97sEP93IFK5ZKTV4J l9BJJpiKECFYgLX5ccQOIGngXVIeSoLKYRsUCMc7r1Dn2sQz2ebOj1Rp8H3oEPtiQOSP GiCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XrU2WswT; 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 a64si19095959oif.256.2019.12.28.15.21.06 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 28 Dec 2019 15:21:06 -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=XrU2WswT; 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]:47358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ilLOL-0006yi-3f for patch@linaro.org; Sat, 28 Dec 2019 18:21:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:40461) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ilLFg-0004rn-9o for qemu-devel@nongnu.org; Sat, 28 Dec 2019 18:12:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ilLFe-00067X-S5 for qemu-devel@nongnu.org; Sat, 28 Dec 2019 18:12:08 -0500 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]:42699) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ilLFe-00062d-Kf for qemu-devel@nongnu.org; Sat, 28 Dec 2019 18:12:06 -0500 Received: by mail-pf1-x444.google.com with SMTP id 4so16523766pfz.9 for ; Sat, 28 Dec 2019 15:12:06 -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=w1Tjfb9SeZwoP+jBqe2wdJ6MBodnhM7nlLGRuc9cKpc=; b=XrU2WswTKopE2H/YsaObV1VEkPWJaFvc3EjTeZrF2NQqg/Ny9i7ovoBe6AhkSoF6s+ HZw4RuQjztwf7wvJoQoeHAx+MqlsXiGC4x5h1cSRLGGHf/29ABXdMIuzfT46men4kpr7 UqUGs2BtBU2xle1gvE79kkTYzaCbfgnUmj/fUr6V9gn/VDP4lNQgC0gk68QeqFclo0ho PnqH0JNmuNFgujM1Amne2+tQLCZvbJfPbr6V28gxg0SDnFkoloigLkHKelmIFbpi3Z6c Ns2actVIyuEbhkkJ0UdHweymqOVyNI3fx9vG6BYhkE9quTZqT+kZ9ec9AtRSNl1Q+weh 0efQ== 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=w1Tjfb9SeZwoP+jBqe2wdJ6MBodnhM7nlLGRuc9cKpc=; b=dhSyg5PMLpyZtNC81CUeVPLSuRrlLj5i9aQS3GYAEimKQLfiAgYep8lGjTHhtDyUV2 zWFxQQz78W7RoxAZFsxS5JE/6NXH3Ic7tPbxketyrBKl1dBpyBy3xvnsIhsuOX3+1TW/ GEO7p2zLDbM1nZhv1H0774yfDu1r+dymryykn7FwqvIl2H0b1W84GzCmusU1G7/uyNgi kD9DO5cbS38w9WPx3HHyfvnknlpNNkUvKeSqK4+IjDT8RBIpqyEpFz0QBPk4cJ6LmsJV Fk/ZcUFwSEy9p60qaM0zIV+tlGzFLWKlkp611j58e6QDu8hn6JVfNvOIUiex14m7G+Vi 7ddA== X-Gm-Message-State: APjAAAXtSP+MiUfexGBBqqnax0QZtME9Wb6kPfaYyoGARIpPpp+CaV77 3bsGEj17SjST1oeljEU4rAYSOXYXMgY= X-Received: by 2002:a63:696:: with SMTP id 144mr65402768pgg.260.1577574725329; Sat, 28 Dec 2019 15:12:05 -0800 (PST) Received: from localhost.localdomain (194-223-58-9.tpgi.com.au. [194.223.58.9]) by smtp.gmail.com with ESMTPSA id c18sm21077186pfr.40.2019.12.28.15.12.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Dec 2019 15:12:04 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/29] translator: Use cpu_ld*_code instead of open-coding Date: Sun, 29 Dec 2019 10:11:06 +1100 Message-Id: <20191228231124.18307-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191228231124.18307-1-richard.henderson@linaro.org> References: <20191228231124.18307-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::444 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: =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The DO_LOAD macros replicate the distinction already performed by the cpu_ldst.h functions. Use them. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- include/exec/cpu_ldst.h | 11 --------- include/exec/translator.h | 48 +++++++++++---------------------------- 2 files changed, 13 insertions(+), 46 deletions(-) -- 2.20.1 diff --git a/include/exec/cpu_ldst.h b/include/exec/cpu_ldst.h index cf8af36dbc..399ff6c3da 100644 --- a/include/exec/cpu_ldst.h +++ b/include/exec/cpu_ldst.h @@ -129,11 +129,6 @@ static inline void clear_helper_retaddr(void) #include "exec/cpu_ldst_useronly_template.h" #undef MEMSUFFIX -/* - * Code access is deprecated in favour of translator_ld* functions - * (see translator.h). However there are still users that need to - * converted so for now these stay. - */ #define MEMSUFFIX _code #define CODE_ACCESS #define DATA_SIZE 1 @@ -455,12 +450,6 @@ void cpu_stq_mmuidx_ra(CPUArchState *env, abi_ptr addr, uint64_t val, #undef CPU_MMU_INDEX #undef MEMSUFFIX -/* - * Code access is deprecated in favour of translator_ld* functions - * (see translator.h). However there are still users that need to - * converted so for now these stay. - */ - #define CPU_MMU_INDEX (cpu_mmu_index(env, true)) #define MEMSUFFIX _code #define SOFTMMU_CODE_ACCESS diff --git a/include/exec/translator.h b/include/exec/translator.h index 459dd72aab..638e1529c5 100644 --- a/include/exec/translator.h +++ b/include/exec/translator.h @@ -148,41 +148,19 @@ void translator_loop_temp_check(DisasContextBase *db); /* * Translator Load Functions * - * These are intended to replace the old cpu_ld*_code functions and - * are mandatory for front-ends that have been migrated to the common - * translator_loop. These functions are only intended to be called - * from the translation stage and should not be called from helper - * functions. Those functions should be converted to encode the - * relevant information at translation time. + * These are intended to replace the direct usage of the cpu_ld*_code + * functions and are mandatory for front-ends that have been migrated + * to the common translator_loop. These functions are only intended + * to be called from the translation stage and should not be called + * from helper functions. Those functions should be converted to encode + * the relevant information at translation time. */ -#ifdef CONFIG_USER_ONLY - -#define DO_LOAD(type, name, shift) \ - do { \ - set_helper_retaddr(1); \ - ret = name ## _p(g2h(pc)); \ - clear_helper_retaddr(); \ - } while (0) - -#else - -#define DO_LOAD(type, name, shift) \ - do { \ - int mmu_idx = cpu_mmu_index(env, true); \ - TCGMemOpIdx oi = make_memop_idx(shift, mmu_idx); \ - ret = helper_ret_ ## name ## _cmmu(env, pc, oi, 0); \ - } while (0) - -#endif - -#define GEN_TRANSLATOR_LD(fullname, name, type, shift, swap_fn) \ +#define GEN_TRANSLATOR_LD(fullname, type, load_fn, swap_fn) \ static inline type \ fullname ## _swap(CPUArchState *env, abi_ptr pc, bool do_swap) \ { \ - type ret; \ - DO_LOAD(type, name, shift); \ - \ + type ret = load_fn(env, pc); \ if (do_swap) { \ ret = swap_fn(ret); \ } \ @@ -195,11 +173,11 @@ void translator_loop_temp_check(DisasContextBase *db); return fullname ## _swap(env, pc, false); \ } -GEN_TRANSLATOR_LD(translator_ldub, ldub, uint8_t, 0, /* no swap */ ) -GEN_TRANSLATOR_LD(translator_ldsw, ldsw, int16_t, 1, bswap16) -GEN_TRANSLATOR_LD(translator_lduw, lduw, uint16_t, 1, bswap16) -GEN_TRANSLATOR_LD(translator_ldl, ldl, uint32_t, 2, bswap32) -GEN_TRANSLATOR_LD(translator_ldq, ldq, uint64_t, 3, bswap64) +GEN_TRANSLATOR_LD(translator_ldub, uint8_t, cpu_ldub_code, /* no swap */) +GEN_TRANSLATOR_LD(translator_ldsw, int16_t, cpu_ldsw_code, bswap16) +GEN_TRANSLATOR_LD(translator_lduw, uint16_t, cpu_lduw_code, bswap16) +GEN_TRANSLATOR_LD(translator_ldl, uint32_t, cpu_ldl_code, bswap32) +GEN_TRANSLATOR_LD(translator_ldq, uint64_t, cpu_ldq_code, bswap64) #undef GEN_TRANSLATOR_LD #endif /* EXEC__TRANSLATOR_H */