From patchwork Mon Jan 28 12:44:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 156730 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3388023jaa; Mon, 28 Jan 2019 04:47:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IbVD6beM5917mQDTbn6SZ3RznKddi83ee8waEQu7C6d7EyyvWwWcWejcVC84NEZubKql/lG X-Received: by 2002:a5d:444a:: with SMTP id x10mr7743723wrr.162.1548679662156; Mon, 28 Jan 2019 04:47:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548679662; cv=none; d=google.com; s=arc-20160816; b=sqBgyQI68bmRCOJ1pzqwE37nQ6wnLxmkUsqb7U4r1VwXPp6LNr8rkncWZndia0T/ul 6+7inB9G076LjukgEtRBVIYWrkYchgGkqYoalJx+a4VikwLtmy3rM+dSMtanmaoEYAEe uMr5UWGbUUzoKwddeUryOtztrHtOcmxRdd/g3QBJG/j13CDsGYA0UQwuAk2EAwBONxtZ ZPF/GoyMLCJC8CCV/88fhRsFc9PqmWMneWHDNHHZw/nFrRHb0lBV/SaSB9gP4QGImngD mgmZEzqai5whWLiPynQGnz4ukQnC+rqb+kKQz23WxJrQ1rFSBfZU1GjBs0hTq14XnFkV PNCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from; bh=nytzG3hUgOFCE7zE30Hr1gRhEyiv7oSPUiFNEnOYc8Q=; b=mepeFhrbaNZP3PCRuwv63nGIvA1HnFMoubV4Mrd7Lb3E4y9/CLCz53rqSclCSpIs+I 5C16X3EV0or2aHBqfYk/48kJt8KUIK2FlqE9kghrddXBXfkb3FX+Mz/2h4dujd585M/J 2milD2jugGwdfrChKWoTGmwVooYOkp5nF40uY3oFEtG2uMfLWg8UfDi7CmGif9J5Hc1J 0DEXM9j/BBud6CivZaTJHvVGIbqAM5pfTHNwce5PVH3gHzMq+mxnjUqdIdnrxN+hosVL E4clKbtTEhFqJVnamRXXSaVQf/Q2MXAe2DRPvMUTc7rkkWxMGaSAeb7QA9YAY/gZ2bqq 3nVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f2si78225961wrj.427.2019.01.28.04.47.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 04:47:42 -0800 (PST) Received-SPF: pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of grub-devel-bounces+patch=linaro.org@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="grub-devel-bounces+patch=linaro.org@gnu.org" Received: from localhost ([127.0.0.1]:59250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go6KD-00010c-47 for patch@linaro.org; Mon, 28 Jan 2019 07:47:41 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1go6Hc-0007O1-5n for grub-devel@gnu.org; Mon, 28 Jan 2019 07:45:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1go6Ha-0003We-47 for grub-devel@gnu.org; Mon, 28 Jan 2019 07:44:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:60056 helo=mx1.suse.de) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1go6HY-0003Rj-6P for grub-devel@gnu.org; Mon, 28 Jan 2019 07:44:57 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 92045AE24; Mon, 28 Jan 2019 12:44:48 +0000 (UTC) From: Alexander Graf To: grub-devel@gnu.org Subject: [PATCH v5 09/11] RISC-V: Add libgcc helpers for clz Date: Mon, 28 Jan 2019 13:44:45 +0100 Message-Id: <20190128124447.81028-10-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20190128124447.81028-1-agraf@suse.de> References: <20190128124447.81028-1-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 195.135.220.15 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The development of GNU GRUB Cc: rickchen36@gmail.com, greentime , Andreas Schwab , David Abdurachmanov , leif.lindholm@linaro.org, atish.patra@wdc.com, Michael Chang , Alistair Francis , Lukas Auer , Paul Walmsley , Bin Meng , Daniel Kiper MIME-Version: 1.0 Errors-To: grub-devel-bounces+patch=linaro.org@gnu.org Sender: "Grub-devel" Gcc may decide it wants to call helper functions to execute clz. Provide them in our own copy of libgcc. Signed-off-by: Alexander Graf --- grub-core/kern/compiler-rt.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/grub/compiler-rt.h | 7 +++++++ 2 files changed, 49 insertions(+) -- 2.12.3 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c index 5cfcb3907..404902119 100644 --- a/grub-core/kern/compiler-rt.c +++ b/grub-core/kern/compiler-rt.c @@ -417,3 +417,45 @@ __aeabi_llsl (grub_uint64_t u, int b) __attribute__ ((alias ("__ashldi3"))); #endif + +#ifdef __riscv + +/* Based on libgcc from gcc suite. */ +int +__clzsi2 (grub_uint32_t val) +{ + int i = 32; + int j = 16; + int temp; + + for (; j; j >>= 1) + { + if ((temp = val) >> j) + { + if (j == 1) + { + return (i - 2); + } + else + { + i -= j; + val = temp; + } + } + } + return (i - val); +} + +int +__clzdi2 (grub_uint64_t val) +{ + if (val >> 32) + { + return __clzsi2 (val >> 32); + } + else + { + return __clzsi2 (val) + 32; + } +} +#endif diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h index dc73649a5..2cc69e239 100644 --- a/include/grub/compiler-rt.h +++ b/include/grub/compiler-rt.h @@ -108,6 +108,13 @@ EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b); #endif +#ifdef __riscv +int +EXPORT_FUNC (__clzsi2) (grub_uint32_t val); + +int +EXPORT_FUNC (__clzdi2) (grub_uint64_t val); +#endif #if defined (__powerpc__)