From patchwork Thu Jan 7 15:10:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 59287 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp609584lbb; Thu, 7 Jan 2016 07:11:22 -0800 (PST) X-Received: by 10.55.42.5 with SMTP id q5mr9698873qkh.101.1452179482054; Thu, 07 Jan 2016 07:11:22 -0800 (PST) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t6si13913706qge.108.2016.01.07.07.11.21 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Jan 2016 07:11:22 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dkim=fail header.i=@linaro.org Received: from localhost ([::1]:59049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHCDh-0002jT-IT for patch@linaro.org; Thu, 07 Jan 2016 10:11:21 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHCD9-0002Rl-A0 for qemu-devel@nongnu.org; Thu, 07 Jan 2016 10:10:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHCD6-00027l-3Q for qemu-devel@nongnu.org; Thu, 07 Jan 2016 10:10:47 -0500 Received: from mail-wm0-x230.google.com ([2a00:1450:400c:c09::230]:37686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHCD5-00027h-OF for qemu-devel@nongnu.org; Thu, 07 Jan 2016 10:10:44 -0500 Received: by mail-wm0-x230.google.com with SMTP id f206so128170525wmf.0 for ; Thu, 07 Jan 2016 07:10:43 -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; bh=11OkO0EBjqaJ1i+W5CwHc1KXPu/F4Zp/vojZbpcjNzI=; b=GUSrp1sNIrMir3Yt7N6ocXFkRcuXRaK7jcb8JGvn71UX+hCn0MdrjhRepxSp3jgLh1 VgssG37PFeeArHzCs7SlEWtA9ZfON7HEqrF10CV8Gblz9urR+vK5mU5R2Vrv90Yc3IWs +FTCKIH8shKbb4L+KJzp9xcOXjU5B64nLe0ts= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=11OkO0EBjqaJ1i+W5CwHc1KXPu/F4Zp/vojZbpcjNzI=; b=CQWt5TADZkMDgdR3GFW0ak54wVjief1HA/aMADYVWCBKH0L/HlTO1fuTq4QAG4L8T/ r7PlyRrf7v0TpKBtWIPZt1KsffA30DbRGTkTDZV4roIStypxmXP1EwSiJ6xrnrV4hnng 9rib/bZnazkWrliUxJUVuNCuSd3IGxEIS9t1bS/L4QdnWT9ERBZ41dwiOhf1Ct2gRFDu J/Q6vhxPjgsYSLCXCPvudwsTNjTFfTZQErEeuIOB76T6cWY6D7+bkDv7QBa0grAjCbLD /663RW1fQ9VQ7CIu46oK+sVPzB8F3AMAjKxHN0hnLoNqayzHaNqDpxfVSSJk1lqZ3W+W 7LXg== X-Gm-Message-State: ALoCoQkzvC1sThXMNqBx2oYQBAzJlux8c9Co353/K1BFNUmfbmRvpwElxK74dCGQqyvDL1oxdthReKkp1t5RmK4LIxqK24iJNg== X-Received: by 10.194.121.35 with SMTP id lh3mr113992840wjb.164.1452179443148; Thu, 07 Jan 2016 07:10:43 -0800 (PST) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id 193sm13976142wmg.16.2016.01.07.07.10.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jan 2016 07:10:42 -0800 (PST) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A50BC3E014F; Thu, 7 Jan 2016 15:10:41 +0000 (GMT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: a.rigo@virtualopensystems.com Date: Thu, 7 Jan 2016 15:10:25 +0000 Message-Id: <1452179425-11353-1-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 2.6.4 In-Reply-To: <760z5cury.fsf@linaro.org> References: <760z5cury.fsf@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::230 Cc: mttcg@listserver.greensocs.com, Peter Crosthwaite , mark.burton@greensocs.com, qemu-devel@nongnu.org, Paolo Bonzini , Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , fred.konrad@greensocs.com Subject: [Qemu-devel] [PATCH] softmmu_template: POC simpler do_unl_access inline X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 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 As any constant arguments will be folded by the compiler when a function is in-lined we can squash the be/le handlers together and let the compiler figure it out. --- softmmu_template.h | 68 ++++++++++++++++++++---------------------------------- 1 file changed, 25 insertions(+), 43 deletions(-) -- 2.6.4 diff --git a/softmmu_template.h b/softmmu_template.h index 65cce0a..6d86a21 100644 --- a/softmmu_template.h +++ b/softmmu_template.h @@ -108,6 +108,8 @@ # define helper_be_st_name glue(glue(helper_be_st, SUFFIX), MMUSUFFIX) #endif +#define helper_generic_st_name glue(glue(helper_generic_st, SUFFIX), MMUSUFFIX) + #ifdef TARGET_WORDS_BIGENDIAN # define helper_te_ld_name helper_be_ld_name # define helper_te_st_name helper_be_st_name @@ -378,12 +380,13 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env, iotlbentry->attrs); } -static inline void glue(helper_le_st_name, _do_unl_access)(CPUArchState *env, - DATA_TYPE val, - target_ulong addr, - TCGMemOpIdx oi, - unsigned mmu_idx, - uintptr_t retaddr) +static inline void glue(helper_generic_st_name, _do_unl_access)(CPUArchState *env, + bool little_endian, + DATA_TYPE val, + target_ulong addr, + TCGMemOpIdx oi, + unsigned mmu_idx, + uintptr_t retaddr) { int i; @@ -391,12 +394,17 @@ static inline void glue(helper_le_st_name, _do_unl_access)(CPUArchState *env, cpu_unaligned_access(ENV_GET_CPU(env), addr, MMU_DATA_STORE, mmu_idx, retaddr); } - /* XXX: not efficient, but simple */ /* Note: relies on the fact that tlb_fill() does not remove the * previous page from the TLB cache. */ for (i = DATA_SIZE - 1; i >= 0; i--) { - /* Little-endian extract. */ - uint8_t val8 = val >> (i * 8); + uint8_t val8; + if (little_endian) { + /* Little-endian extract. */ + val8 = val >> (i * 8); + } else { + /* Big-endian extract. */ + val8 = val >> (((DATA_SIZE - 1) * 8) - (i * 8)); + } /* Note the adjustment at the beginning of the function. Undo that for the recursion. */ glue(helper_ret_stb, MMUSUFFIX)(env, addr + i, val8, @@ -415,8 +423,8 @@ static inline void glue(helper_le_st_name, _do_mmio_access)(CPUArchState *env, CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; if ((addr & (DATA_SIZE - 1)) != 0) { - glue(helper_le_st_name, _do_unl_access)(env, val, addr, mmu_idx, - oi, retaddr); + glue(helper_generic_st_name, _do_unl_access)(env, true, val, addr, + mmu_idx, oi, retaddr); } /* ??? Note that the io helpers always read data in the target byte ordering. We should push the LE/BE request down into io. */ @@ -438,8 +446,8 @@ static inline void glue(helper_le_st_name, _do_ram_access)(CPUArchState *env, if (DATA_SIZE > 1 && unlikely((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1 >= TARGET_PAGE_SIZE)) { - glue(helper_le_st_name, _do_unl_access)(env, val, addr, oi, mmu_idx, - retaddr); + glue(helper_generic_st_name, _do_unl_access)(env, true, val, addr, oi, mmu_idx, + retaddr); return; } @@ -538,32 +546,6 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val, } #if DATA_SIZE > 1 -static inline void glue(helper_be_st_name, _do_unl_access)(CPUArchState *env, - DATA_TYPE val, - target_ulong addr, - TCGMemOpIdx oi, - unsigned mmu_idx, - uintptr_t retaddr) -{ - int i; - - if ((get_memop(oi) & MO_AMASK) == MO_ALIGN) { - cpu_unaligned_access(ENV_GET_CPU(env), addr, MMU_DATA_STORE, - mmu_idx, retaddr); - } - /* XXX: not efficient, but simple */ - /* Note: relies on the fact that tlb_fill() does not remove the - * previous page from the TLB cache. */ - for (i = DATA_SIZE - 1; i >= 0; i--) { - /* Big-endian extract. */ - uint8_t val8 = val >> (((DATA_SIZE - 1) * 8) - (i * 8)); - /* Note the adjustment at the beginning of the function. - Undo that for the recursion. */ - glue(helper_ret_stb, MMUSUFFIX)(env, addr + i, val8, - oi, retaddr + GETPC_ADJ); - } -} - static inline void glue(helper_be_st_name, _do_mmio_access)(CPUArchState *env, DATA_TYPE val, target_ulong addr, @@ -575,8 +557,8 @@ static inline void glue(helper_be_st_name, _do_mmio_access)(CPUArchState *env, CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index]; if ((addr & (DATA_SIZE - 1)) != 0) { - glue(helper_be_st_name, _do_unl_access)(env, val, addr, mmu_idx, - oi, retaddr); + glue(helper_generic_st_name, _do_unl_access)(env, false, val, addr, mmu_idx, + oi, retaddr); } /* ??? Note that the io helpers always read data in the target byte ordering. We should push the LE/BE request down into io. */ @@ -598,8 +580,8 @@ static inline void glue(helper_be_st_name, _do_ram_access)(CPUArchState *env, if (DATA_SIZE > 1 && unlikely((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1 >= TARGET_PAGE_SIZE)) { - glue(helper_be_st_name, _do_unl_access)(env, val, addr, oi, mmu_idx, - retaddr); + glue(helper_generic_st_name, _do_unl_access)(env, false, val, addr, oi, mmu_idx, + retaddr); return; }