From patchwork Thu Jun 6 18:05:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 249517 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B05112C0096 for ; Fri, 7 Jun 2013 04:10:57 +1000 (EST) Received: from localhost ([::1]:52955 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ukebq-0005f5-Ul for incoming@patchwork.ozlabs.org; Thu, 06 Jun 2013 14:08:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34566) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkeZc-0001f6-Q6 for qemu-devel@nongnu.org; Thu, 06 Jun 2013 14:06:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UkeZY-0000yn-8c for qemu-devel@nongnu.org; Thu, 06 Jun 2013 14:06:08 -0400 Received: from mail-pd0-f174.google.com ([209.85.192.174]:33304) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UkeZY-0000yf-1e for qemu-devel@nongnu.org; Thu, 06 Jun 2013 14:06:04 -0400 Received: by mail-pd0-f174.google.com with SMTP id 10so2690779pdc.5 for ; Thu, 06 Jun 2013 11:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=BD5QhU5Xe7IWs0nlFWYlEesJ3SUmX3IoSB7uScSlaJ8=; b=T8kF/+QJPHHycv9kIIAF20JSD+VUr4ZxcuEeFgmxfafk7XS7le9rVWxGHJ8qWwVOog jmt0vJn6NpAdSGsfS5Ks0baPgVb4/xylE9bMehEU3oYkHkh/8Qa33WV2mq6iM7hxFzxQ JbI191dSI5fsVcuWvX4EN2hpYbx4g/9NGGMiDc1ooavUpZv5oeqIulX7MggbJKXY+a6+ 4Pe3IiwYDV4QVxzj7lq2BetpQl4NyexhFkPA8scrfBamJdpsJjQEvcksQndJx9q0yP+Y YsK+qlHzhph7T7AHD6/ZN94694DBEDl79Ka7omT4ygvi+Rw5QFJIeNeng73/Y8AY0Sv3 qLUw== X-Received: by 10.68.176.37 with SMTP id cf5mr39776420pbc.173.1370541963243; Thu, 06 Jun 2013 11:06:03 -0700 (PDT) Received: from fremont.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id al2sm73773782pbc.25.2013.06.06.11.06.01 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 06 Jun 2013 11:06:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 6 Jun 2013 11:05:45 -0700 Message-Id: <1370541947-909-4-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1370541947-909-1-git-send-email-rth@twiddle.net> References: <1370541947-909-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.174 Cc: aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 3/5] tcg-arm: Make use of conditional availability of opcodes for divide 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org We can now detect and use divide instructions at runtime, rather than having to restrict their availability to compile-time. Signed-off-by: Richard Henderson --- tcg/arm/tcg-target.c | 16 ++++++++++++++-- tcg/arm/tcg-target.h | 14 ++++++++------ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/tcg/arm/tcg-target.c b/tcg/arm/tcg-target.c index 3d43412..f6bc165 100644 --- a/tcg/arm/tcg-target.c +++ b/tcg/arm/tcg-target.c @@ -67,6 +67,13 @@ static const int use_armv7_instructions = 0; #endif #undef USE_ARMV7_INSTRUCTIONS +#ifndef use_idiv_instructions +bool use_idiv_instructions; +#endif +#ifdef CONFIG_GETAUXVAL +# include +#endif + #ifndef NDEBUG static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { "%r0", @@ -2041,18 +2048,23 @@ static const TCGTargetOpDef arm_op_defs[] = { { INDEX_op_deposit_i32, { "r", "0", "rZ" } }, -#if TCG_TARGET_HAS_div_i32 { INDEX_op_div_i32, { "r", "r", "r" } }, { INDEX_op_rem_i32, { "r", "r", "r" } }, { INDEX_op_divu_i32, { "r", "r", "r" } }, { INDEX_op_remu_i32, { "r", "r", "r" } }, -#endif { -1 }, }; static void tcg_target_init(TCGContext *s) { +#if defined(CONFIG_GETAUXVAL) && !defined(use_idiv_instructions) + { + unsigned long hwcap = getauxval(AT_HWCAP); + use_idiv_instructions = hwcap & (HWCAP_ARM_IDIVA | HWCAP_ARM_IDIVT); + } +#endif + #if !defined(CONFIG_USER_ONLY) /* fail safe */ if ((1 << CPU_TLB_ENTRY_BITS) != sizeof(CPUTLBEntry)) diff --git a/tcg/arm/tcg-target.h b/tcg/arm/tcg-target.h index 3be41cc..4e1a88f 100644 --- a/tcg/arm/tcg-target.h +++ b/tcg/arm/tcg-target.h @@ -49,6 +49,13 @@ typedef enum { #define TCG_TARGET_NB_REGS 16 +#ifdef __ARM_ARCH_EXT_IDIV__ +#define use_idiv_instructions 1 +#else +extern bool use_idiv_instructions; +#endif + + /* used for function call generation */ #define TCG_REG_CALL_STACK TCG_REG_R13 #define TCG_TARGET_STACK_ALIGN 8 @@ -73,12 +80,7 @@ typedef enum { #define TCG_TARGET_HAS_deposit_i32 1 #define TCG_TARGET_HAS_movcond_i32 1 #define TCG_TARGET_HAS_muls2_i32 1 - -#ifdef __ARM_ARCH_EXT_IDIV__ -#define TCG_TARGET_HAS_div_i32 1 -#else -#define TCG_TARGET_HAS_div_i32 0 -#endif +#define TCG_TARGET_HAS_div_i32 use_idiv_instructions extern bool tcg_target_deposit_valid(int ofs, int len); #define TCG_TARGET_deposit_i32_valid tcg_target_deposit_valid