From patchwork Mon Dec 16 22:11:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 181807 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4931811ile; Mon, 16 Dec 2019 14:17:56 -0800 (PST) X-Google-Smtp-Source: APXvYqx8AkxyadR0GNjQmdWVxv8Sp1bCAwlGekKyETHMmiTo28+jZmqPXs9eCOwZR6FeMwmbAejd X-Received: by 2002:aca:c645:: with SMTP id w66mr703334oif.43.1576534676288; Mon, 16 Dec 2019 14:17:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576534676; cv=none; d=google.com; s=arc-20160816; b=aQVcwqMOfm4n5/1ZGgultbjkuXS7kR7oymdI3Tc/sSGMbQW2e31aeYjT87ZFUeD85Q uJUXIyZhTtbtACG50SJRO/BPzstKgKzkb0n3QH9+0pjnFOkVECxnA4zwvTuBJK35U9il yjy1iyL6EQVEKIxoj5BEy6oEf/qk6vjmJ3U/FQoYDoi30FJWSPgjMvez7FCplupOPN1F JQ1XgqgfSWmdHc37cFbq5XsU7R4hdcuZa04y1JhfIz50zuR07bjxuwy2vQ8zicxZDCy4 AKhTVKOV9HPiyT+rnRojdmU91DrDtDcO0yjqIdy8Y9tbI99NvcZkIgqU9TDZR6ea+9rZ iX5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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:to:from :dkim-signature; bh=LZjfj7f7LiMXr9N5B8njH/lhRDK1JnIrdikl5tdqwbU=; b=hgeEzj+MZgac8I2J3z99vU+YU83GJHYCAtdlu0hOm0n8dBkW1sSVSkm/Edbtd9OiII DaPAoV7ivv1aEzHa1lArdfchhT323wG7w0BTsTXX2TI8t+ccZF+yORs6MsLk456pZrzA Y4+bYzuueTUYRPgjodrbblRRG25dIoE+kGhwnJoxsW9EmFnwt6Srov9o0rZS5q9EmrZs mWSbh+abuEc373v1sDLq2bDju3Fh/bxdmUZ7m2zkdha8IMj4ngHwy4hw9fRuy9H5lxGO SmJxPoQPorMVeLwWw20DI1T7eevCKgydArMTnUOPTTWVcddCnGPZR3CkOpD4pm0APeUc 3KeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tBtwE3Lu; 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 x7si11308277oia.165.2019.12.16.14.17.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Dec 2019 14:17:56 -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=tBtwE3Lu; 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]:60710 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igygc-0003IL-Th for patch@linaro.org; Mon, 16 Dec 2019 17:17:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36641) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1igyb6-0004qL-I4 for qemu-devel@nongnu.org; Mon, 16 Dec 2019 17:12:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1igyb5-0006zU-8n for qemu-devel@nongnu.org; Mon, 16 Dec 2019 17:12:12 -0500 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:38442) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1igyb5-0006zM-30 for qemu-devel@nongnu.org; Mon, 16 Dec 2019 17:12:11 -0500 Received: by mail-pg1-x543.google.com with SMTP id a33so4500417pgm.5 for ; Mon, 16 Dec 2019 14:12:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=LZjfj7f7LiMXr9N5B8njH/lhRDK1JnIrdikl5tdqwbU=; b=tBtwE3Luzpx99iyXa1B18fGUgCPrg1ftkjeQ8PHIDqiOc6Zbh716zAL7gEeLtx1fAO fB5k5pF6eLsNxcTdaGqGdpafX2uRyYNagaO08Ea7ghtVoIHaR7c7E2l4VvU3Y93tCcPx 47V08FW/4EkQqMmHfZ2epFhrN1KZp7PumR79OihzCFHl3nEYtKfVKMpcN+x0Hvl3yrGK wKwnJJey2a4RmQ7BOJR5AKvG4Dg9WGy0W4tn4LS6G12BDSDjsvH8VsrMjFV2Lyfdd4bh eMEE7E2jxKb0U+hk9WObnp/8WESuroPCl4Np3o4sabr5i1HTDWnEIcf80VSRj9CpDo+E ERCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LZjfj7f7LiMXr9N5B8njH/lhRDK1JnIrdikl5tdqwbU=; b=o012W0CnY0d6PK482iIkZWXt2yS44SshXnzn1/LPh2eE4f+g89d6oHNz7SmQTTbQuk vHQw+mv9d3gc6ewpYuli1y90ShAo9dE7pLqp6Bb8CzHFW1QfHUaaF0a2e8LUQL28DbOX bArmLkYMfZFumq7d9dkscR7+L1ZQOZzKzb407SfEjZsOlD82ctCoOd9rhbTcPz3/6PME ATSLtUZX1zY/cpZ2iR9JRqENqNnljVstjsFpMDI1vbhLNICjnRy8tZScg+xwfCHVvWGE aLXQpnVxTvD1cFsuIQoJ5qVpSKgl46RVPgdssb7O5ShIx1uNB7VzATrSPhwptOkg0DUn rowQ== X-Gm-Message-State: APjAAAUho4DQTXa4vQwzIjL5HHpeEzVqM6gxVbUhD9kdF0NQHX/Ifpdw W04IW1WpQi3AzkRT8OrPMnTDVjm52OA= X-Received: by 2002:a65:530d:: with SMTP id m13mr21246848pgq.351.1576534329663; Mon, 16 Dec 2019 14:12:09 -0800 (PST) Received: from localhost.localdomain ([2605:e000:c74f:dc00:6838:d2b2:17e2:8445]) by smtp.gmail.com with ESMTPSA id d6sm529767pjl.8.2019.12.16.14.12.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Dec 2019 14:12:08 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v2 05/28] translator: Use cpu_ld*_code instead of open-coding Date: Mon, 16 Dec 2019 12:11:35 -1000 Message-Id: <20191216221158.29572-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191216221158.29572-1-richard.henderson@linaro.org> References: <20191216221158.29572-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::543 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: , 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. 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 Reviewed-by: Alex Bennée 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 */