From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id 879223857373 for ; Thu, 11 Aug 2022 07:01:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 879223857373 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id E0661300089; Thu, 11 Aug 2022 07:01:04 +0000 (UTC) From: Tsukasa OI To: Tsukasa OI , Nelson Chu , Kito Cheng , Palmer Dabbelt Cc: binutils@sourceware.org Subject: [RFC PATCH 0/5] RISC-V: Support mapping symbols with ISA string Date: Thu, 11 Aug 2022 16:00:48 +0900 Message-Id: In-Reply-To: <1659692183-5682-1-git-send-email-nelson.chu@sifive.com> References: <1659692183-5682-1-git-send-email-nelson.chu@sifive.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Aug 2022 07:01:10 -0000 Hello, After a detailed analysis of Nelson's patch, I made my own version based on it. It clearly lacks proper attribution (Signed-Off-By lines) and should be considered as RFC. Nelson, I would like to hear your thoughts. Nelson's original patch: Tracker on GitHub: Also see: [1] Proposal: Extend .option directive for control enabled extensions on specific code region, [2] Proposal: Add mapping symbol, I found two issues on his patch: (1) "$x" is the start of instructions with the default architecture. Nelson's patch effectively handled it as a change to code but with no ISA changes and this is clearly against Kito's proposal: > an instruction mapping symobl > without ISA string means using ISA configuration from ELF attribute. In my version, "$x" is emitted if no architecture string is changed by .option directives and such. Even if the arch is changed to revert the original, it's not the same: # Example # (we have default architecture here such as RV32I) .option arch, +c .option arch, -c # (not default, even if the resulting ISA string is the same) The only exception is when we use ".option push" before the architecture is changed and that state is restored by ".option pop". # Example # (we have default architecture here) .option push # (now we can make changes to the architecture) .option arch, +c # (... then restore it) .option pop # (now we have the default architecture, again) This also applies to the disassembler. If we meet the "$x" mapping symbol, we need to revert to the default architecture. Since we need to save the default architecture, the disassembler part is a bit more complex than Nelson's implementation. (2) Also, the mapping symbols are handled per section but "current" architecture as managed by the assembler is not. It did work previously because we didn't have to keep track of the architecture (ISA string) but we have to explicitly handle that now. So, the first instruction after the section change requires emitting the mapping symbol if necessary. Still, to do that, looking up the last mapping symbol is sufficient (saving RISC-V preset list is not required). My changes made MAP_INSN_ARCH not necessary so I removed it. I also added four test cases (mapping-{05..08}) whether we are handling complex situations correctly. Note that mapping-{05,06,08} will fail on Nelson's implementation. p.s. Nelson, are you going to upstream this feature now or wait until the proposal by Kito is approved? If your answer is the latter, I will submit my disassembler changes first (to make the disassembler support of this feature cleaner). Thanks, Tsukasa Tsukasa OI (5): RISC-V: Use bool on riscv_set_options members gas: Copyediting on tc-riscv.c RISC-V: Mapping symbols with ISA string on assembler RISC-V: Mapping symbols with ISA string on disassembler RISC-V: New testcases for mapping symbols w/ ISA gas/config/tc-riscv.c | 67 +++++++++++++++---- gas/config/tc-riscv.h | 5 ++ gas/testsuite/gas/riscv/mapping-01a.d | 4 +- gas/testsuite/gas/riscv/mapping-02a.d | 4 +- gas/testsuite/gas/riscv/mapping-03a.d | 10 +-- gas/testsuite/gas/riscv/mapping-04a.d | 4 +- gas/testsuite/gas/riscv/mapping-05.s | 11 +++ gas/testsuite/gas/riscv/mapping-05a.d | 14 ++++ gas/testsuite/gas/riscv/mapping-05b.d | 14 ++++ gas/testsuite/gas/riscv/mapping-06.s | 11 +++ gas/testsuite/gas/riscv/mapping-06a.d | 14 ++++ gas/testsuite/gas/riscv/mapping-06b.d | 14 ++++ gas/testsuite/gas/riscv/mapping-07.s | 12 ++++ gas/testsuite/gas/riscv/mapping-07a.d | 14 ++++ gas/testsuite/gas/riscv/mapping-07b.d | 21 ++++++ gas/testsuite/gas/riscv/mapping-08.s | 34 ++++++++++ gas/testsuite/gas/riscv/mapping-08a.d | 18 +++++ gas/testsuite/gas/riscv/mapping-08b.d | 23 +++++++ gas/testsuite/gas/riscv/mapping-norelax-03a.d | 10 +-- gas/testsuite/gas/riscv/mapping-norelax-04a.d | 4 +- gas/testsuite/gas/riscv/option-arch-01a.d | 2 +- opcodes/riscv-dis.c | 44 ++++++++++-- 22 files changed, 317 insertions(+), 37 deletions(-) create mode 100644 gas/testsuite/gas/riscv/mapping-05.s create mode 100644 gas/testsuite/gas/riscv/mapping-05a.d create mode 100644 gas/testsuite/gas/riscv/mapping-05b.d create mode 100644 gas/testsuite/gas/riscv/mapping-06.s create mode 100644 gas/testsuite/gas/riscv/mapping-06a.d create mode 100644 gas/testsuite/gas/riscv/mapping-06b.d create mode 100644 gas/testsuite/gas/riscv/mapping-07.s create mode 100644 gas/testsuite/gas/riscv/mapping-07a.d create mode 100644 gas/testsuite/gas/riscv/mapping-07b.d create mode 100644 gas/testsuite/gas/riscv/mapping-08.s create mode 100644 gas/testsuite/gas/riscv/mapping-08a.d create mode 100644 gas/testsuite/gas/riscv/mapping-08b.d base-commit: 453595283c323e106a60b229999756b45ae6b2d8 -- 2.34.1