From patchwork Tue Feb 12 10:31:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 158142 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3665951jaa; Tue, 12 Feb 2019 02:33:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IZpf9JknkJHo672o9E1soq2v8yyJbNwulpgE6KyLnJiWFEYga+0j+QvzbMY1oTy0fzasXPG X-Received: by 2002:a81:a68e:: with SMTP id d136mr2189788ywh.214.1549967633797; Tue, 12 Feb 2019 02:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549967633; cv=none; d=google.com; s=arc-20160816; b=iYqI6APo6KwHhLN+9jszDOBaag3LOGn/sE0zAMrl2uhutuAInH/nU37tdWjWkJv6w8 5MS73PSd03RfzcpHxKHHXB9NpPMhC1YuFeexrtZTxXLmbci555Hgegn5ooGdwZP2iSZ3 NIvI8zsruPMzGcQ4IcZC0+LgIxUF0MwSF/CbIlW+q8srIL72rtXvOEwOE61ZRdYYMiWc RVflR/oRtfJOWQXGeCpO4o62co7et5W4ZWKDbIwCBSF8uNXR4GIcpjhJMUKD3PrOvLbW xUuXKwwVbm1Gcv3AmGZX6Zyn5XggcZbHG+HJ/8eIbOxhyCgEgBRM440/ouSwc2uD97xh hjkg== 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=yROeE7RJCuppREJ3eLKQ8Ksz7PGx/hMj+1wTgecZBHfvfRNJk9zUtW5aKYDneUS/gr qQ75s51/QGL5Ui4g2Aut/VrIY3LKjIcY4zG8jpKYr1NUMHvwoatXrbVLlJXSW35OGkyn V2m90ZFI7JL9ohykfkPqA1ziXgLXR0uXRiXuNU3u2lH6Rv3J6aAa8cUHFqh6wy68uMfT 1fsxY5+hlRG+0Uv+E1o2IUvraJmLKxWv0xl4mZuu34t+3FkfPSvklQLUO6iG9703oLss QQezvB9xeOykf0QEnwYuaRaq650AE3JGJorhb4eWK1oohcBsc/h9MwDXsI3QaQk3Kl9C FwIw== 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 a13si591262ybe.315.2019.02.12.02.33.53 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 12 Feb 2019 02:33:53 -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]:36936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtVNx-0001y3-8Z for patch@linaro.org; Tue, 12 Feb 2019 05:33:53 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gtVML-0000w7-BV for grub-devel@gnu.org; Tue, 12 Feb 2019 05:32:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gtVMJ-0004Mi-9V for grub-devel@gnu.org; Tue, 12 Feb 2019 05:32:13 -0500 Received: from mx2.suse.de ([195.135.220.15]:52046 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 1gtVMH-00045e-4Y for grub-devel@gnu.org; Tue, 12 Feb 2019 05:32:10 -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 0EFF7B25D; Tue, 12 Feb 2019 10:31:12 +0000 (UTC) From: Alexander Graf To: grub-devel@gnu.org Subject: [PATCH v6 09/11] RISC-V: Add libgcc helpers for clz Date: Tue, 12 Feb 2019 11:31:06 +0100 Message-Id: <20190212103108.56963-10-agraf@suse.de> X-Mailer: git-send-email 2.12.3 In-Reply-To: <20190212103108.56963-1-agraf@suse.de> References: <20190212103108.56963-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" , David Abdurachmanov , schwab@suse.de, "greentime @ andestech . com" , 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__)