[llvm] [RISC-V] remove I ext when E ext has been enabled (PR #92070)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 13 22:49:12 PDT 2024


https://github.com/Xinlong-Wu created https://github.com/llvm/llvm-project/pull/92070

After patch https://github.com/llvm/llvm-project/pull/88805

`I` Ext will be added automatically when we running the command like 
`./build/bin/llc -mtriple=riscv32 -mattr=+e -target-abi ilp32e -verify-machineinstrs llvm/test/CodeGen/RISCV/zcmp-additional-stack.ll`

it will generate 
```
	.text
	.attribute	4, 16
	.attribute	5, "rv32i2p1_e2pe"
	.file	"zcmp-additional-stack.ll"
	.globl	func                            # -- Begin function func
	.p2align	1
	.type	func, at function
```

This patch reset the I ext in FeatureBit when `+e` has been specify

>From 7fbb92a7e259713cac691d63a1be78df705b865f Mon Sep 17 00:00:00 2001
From: WuXinlong <821408745 at qq.com>
Date: Tue, 14 May 2024 12:26:09 +0800
Subject: [PATCH] remove I ext when E has specify

---
 llvm/lib/TargetParser/RISCVISAInfo.cpp | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index e22dd6032cb0c..575c9dbad5156 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -758,6 +758,8 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
 }
 
 Error RISCVISAInfo::checkDependency() {
+  bool HasE = Exts.count("e") != 0;
+  bool HasI = Exts.count("i") != 0;
   bool HasC = Exts.count("c") != 0;
   bool HasF = Exts.count("f") != 0;
   bool HasZfinx = Exts.count("zfinx") != 0;
@@ -765,6 +767,10 @@ Error RISCVISAInfo::checkDependency() {
   bool HasZvl = MinVLen != 0;
   bool HasZcmt = Exts.count("zcmt") != 0;
 
+  if (HasI && HasE)
+    return createStringError(errc::invalid_argument,
+                             "'I' and 'E' extensions are incompatible");
+
   if (HasF && HasZfinx)
     return createStringError(errc::invalid_argument,
                              "'f' and 'zfinx' extensions are incompatible");
@@ -852,6 +858,9 @@ void RISCVISAInfo::updateImplication() {
     addExtension("i", Version.value());
   }
 
+  if (HasE && HasI)
+    Exts.erase("i");
+
   assert(llvm::is_sorted(ImpliedExts) && "Table not sorted by Name");
 
   // This loop may execute over 1 iteration since implication can be layered



More information about the llvm-commits mailing list