From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1gPV9x-0008E8-04 for mharc-grub-devel@gnu.org; Wed, 21 Nov 2018 11:15:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPV9p-0007vO-So for grub-devel@gnu.org; Wed, 21 Nov 2018 11:15:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPV2y-00087W-I6 for grub-devel@gnu.org; Wed, 21 Nov 2018 11:08:18 -0500 Received: from mx2.suse.de ([195.135.220.15]:42958 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 1gPV2y-00084X-Bi for grub-devel@gnu.org; Wed, 21 Nov 2018 11:08:12 -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 EC86CAD8F; Wed, 21 Nov 2018 16:08:09 +0000 (UTC) From: Andreas Schwab To: Daniel Kiper Cc: The development of GNU GRUB , "rickchen36 \@ gmail . com" , David Abdurachmanov , "greentime \@ andestech . com" , leif.lindholm@linaro.org, atish.patra@wdc.com, Michael Chang , Alistair Francis , Lukas Auer , Paul Walmsley , Bin Meng Subject: Re: [PATCH v3 07/10] RISC-V: Add awareness for RISC-V reloations References: <20181114172739.51640-1-agraf@suse.de> <20181114172739.51640-8-agraf@suse.de> <20181121155157.xe2kahpmvia45rbu@tomti.i.net-space.pl> X-Yow: Sign my PETITION. Date: Wed, 21 Nov 2018 17:08:09 +0100 In-Reply-To: <20181121155157.xe2kahpmvia45rbu@tomti.i.net-space.pl> (Daniel Kiper's message of "Wed, 21 Nov 2018 16:51:57 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: , X-List-Received-Date: Wed, 21 Nov 2018 16:15:22 -0000 On Nov 21 2018, Daniel Kiper wrote: >> + case R_RISCV_BRANCH: >> + { >> + grub_uint32_t *abs_place = place; >> + grub_ssize_t off = sym_addr - (grub_addr_t) place; >> + grub_uint32_t imm12 = (off & 0x1000) << (31 - 12); >> + grub_uint32_t imm11 = (off & 0x800) >> (11 - 7); >> + grub_uint32_t imm10_5 = (off & 0x7e0) << (30 - 10); >> + grub_uint32_t imm4_1 = (off & 0x1e) << (11 - 4); >> + *abs_place = (*abs_place & 0x1fff07f) >> + | imm12 | imm11 | imm10_5 | imm4_1; > > Could not we use some constants instead of numbers here? These are just where the insn encoding puts the bits. > If this does not make sense than please name the source of this numbers. https://github.com/riscv/riscv-isa-manual/blob/master/release/riscv-spec-v2.2.pdf Andreas. -- Andreas Schwab, SUSE Labs, schwab@suse.de GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7 "And now for something completely different."