From ca2bbb88f999f4d3cc40e89bc1aba712505dd598 Mon Sep 17 00:00:00 2001 From: Kito Cheng Date: Mon, 24 Jan 2022 15:46:10 +0800 Subject: [PATCH] RISC-V: Do not emit zcisr and zifencei if i-ext is 2.0 I-ext 2.0 already included zicsr and zifencei, skip that prevent confusing binutils. gcc/ChangeLog * common/config/riscv/riscv-common.cc (riscv_subset_list::to_string): Skip zicsr and zifencei if I-ext is 2.0. --- gcc/common/config/riscv/riscv-common.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gcc/common/config/riscv/riscv-common.cc b/gcc/common/config/riscv/riscv-common.cc index 25f56707d94..a904893b9ed 100644 --- a/gcc/common/config/riscv/riscv-common.cc +++ b/gcc/common/config/riscv/riscv-common.cc @@ -488,6 +488,7 @@ riscv_subset_list::to_string (bool version_p) const bool skip_zifencei = false; bool skip_zicsr = false; + bool i2p0 = false; /* For RISC-V ISA version 2.2 or earlier version, zicsr and zifencei is included in the base ISA. */ @@ -497,6 +498,13 @@ riscv_subset_list::to_string (bool version_p) const skip_zicsr = true; } + for (subset = m_head; subset != NULL; subset = subset->next) + if (subset->name == "i") + { + i2p0 = subset->major_version == 2 && subset->minor_version == 0; + break; + } + #ifndef HAVE_AS_MISA_SPEC /* Skip since older binutils doesn't recognize zicsr. */ skip_zicsr = true; @@ -509,10 +517,12 @@ riscv_subset_list::to_string (bool version_p) const for (subset = m_head; subset != NULL; subset = subset->next) { - if (subset->implied_p && skip_zifencei && subset->name == "zifencei") + if (((subset->implied_p && skip_zifencei) || i2p0) && + subset->name == "zifencei") continue; - if (subset->implied_p && skip_zicsr && subset->name == "zicsr") + if (((subset->implied_p && skip_zicsr) || i2p0) && + subset->name == "zicsr") continue; /* For !version_p, we only separate extension with underline for