Skip to content

[RISC-V] remove I ext when E ext has been enabled #92070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 14, 2024

Conversation

Xinlong-Wu
Copy link
Contributor

After patch #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,@function

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

@llvmbot
Copy link
Member

llvmbot commented May 14, 2024

@llvm/pr-subscribers-backend-risc-v

Author: VincentWu (Xinlong-Wu)

Changes

After patch #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,@<!-- -->function

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


Full diff: https://github.com/llvm/llvm-project/pull/92070.diff

1 Files Affected:

  • (modified) llvm/lib/TargetParser/RISCVISAInfo.cpp (+9)
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

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Xinlong-Wu Xinlong-Wu merged commit 844355a into llvm:main May 14, 2024
6 checks passed
@asb
Copy link
Contributor

asb commented May 19, 2024

Could you please add a test case so we can ensure we don't regress again?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants