Skip to content

[RISCV][TableGen] Get right experimental extension name #90185

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

Conversation

wangpc-pp
Copy link
Contributor

We should remove the experimental- prefix when printing march
string.

We didn't meet this problem because there is no processor containing
experimental extensions.

Created using spr 1.3.6-beta.1
@llvmbot
Copy link
Member

llvmbot commented Apr 26, 2024

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

Author: Pengcheng Wang (wangpc-pp)

Changes

We should remove the experimental- prefix when printing march
string.

We didn't meet this problem because there is no processor containing
experimental extensions.


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

2 Files Affected:

  • (modified) llvm/test/TableGen/riscv-target-def.td (+4-2)
  • (modified) llvm/utils/TableGen/RISCVTargetDefEmitter.cpp (+1-1)
diff --git a/llvm/test/TableGen/riscv-target-def.td b/llvm/test/TableGen/riscv-target-def.td
index b23c7e4d40198b..175b68f9f8bad7 100644
--- a/llvm/test/TableGen/riscv-target-def.td
+++ b/llvm/test/TableGen/riscv-target-def.td
@@ -83,6 +83,7 @@ def ROCKET_RV32 : RISCVProcessorModel<"rocket-rv32",
                                        FeatureStdExtI,
                                        FeatureStdExtZifencei,
                                        FeatureStdExtZicsr,
+                                       FeatureStdExtZidummy,
                                        FeatureDummy]>;
 def ROCKET_RV64 : RISCVProcessorModel<"rocket-rv64",
                                       NoSchedModel,
@@ -90,6 +91,7 @@ def ROCKET_RV64 : RISCVProcessorModel<"rocket-rv64",
                                        FeatureStdExtI,
                                        FeatureStdExtZifencei,
                                        FeatureStdExtZicsr,
+                                       FeatureStdExtZidummy,
                                        FeatureDummy]>;
 def ROCKET : RISCVTuneProcessorModel<"rocket",
                                      NoSchedModel>;
@@ -127,8 +129,8 @@ def ROCKET : RISCVTuneProcessorModel<"rocket",
 
 // CHECK:      PROC(GENERIC_RV32, {"generic-rv32"}, {"rv32i2p1"}, 0)
 // CHECK-NEXT: PROC(GENERIC_RV64, {"generic-rv64"}, {"rv64i2p1"}, 0)
-// CHECK-NEXT: PROC(ROCKET_RV32, {"rocket-rv32"}, {"rv32i2p1_zicsr2p0_zifencei2p0"}, 0)
-// CHECK-NEXT: PROC(ROCKET_RV64, {"rocket-rv64"}, {"rv64i2p1_zicsr2p0_zifencei2p0"}, 0)
+// CHECK-NEXT: PROC(ROCKET_RV32, {"rocket-rv32"}, {"rv32i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0)
+// CHECK-NEXT: PROC(ROCKET_RV64, {"rocket-rv64"}, {"rv64i2p1_zicsr2p0_zidummy0p1_zifencei2p0"}, 0)
 
 // CHECK: #undef PROC
 
diff --git a/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp b/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
index 217b531dcfd394..4580a0ab12669c 100644
--- a/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
+++ b/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
@@ -119,7 +119,7 @@ static void printMArch(raw_ostream &OS, const Record &Rec) {
 
   // Convert features to FeatureVector.
   for (auto *Feature : Rec.getValueAsListOfDefs("Features")) {
-    StringRef FeatureName = Feature->getValueAsString("Name");
+    StringRef FeatureName = getExtensionName(Feature);
     if (Feature->isSubClassOf("RISCVExtension")) {
       unsigned Major = Feature->getValueAsInt("MajorVersion");
       unsigned Minor = Feature->getValueAsInt("MinorVersion");

@asb
Copy link
Contributor

asb commented Apr 26, 2024

Alternatively, should we reject processor definitions that have experimental extensions? Are we sure that processors with experimental extensions interact properly with the gating of experimental extensions behind -menable-experimental-extensions for user facing tools like clang?

@wangpc-pp
Copy link
Contributor Author

wangpc-pp commented Apr 26, 2024

Alternatively, should we reject processor definitions that have experimental extensions? Are we sure that processors with experimental extensions interact properly with the gating of experimental extensions behind -menable-experimental-extensions for user facing tools like clang?

I found this issue (if it is an issue) in #90187 as Ssnpm, which is a mandatory extension in RVA23S64, is an experimental extension.
I think we shouldn't have experimental extensions in processor definitions, but there are some intermediate periods that we don't have other choices. For example, Zicond is experimental in LLVM 17, but it hasn't been changed for a long time and we moved it out from experimental in LLVM 18. For downstreams, there is a period of half a year that experimental extensions exist in processor definitions (these definitions are just used for pre-silicon tests).
And yes, of course, -menable-experimental-extensions should be specified along with -mcpu in this situation.

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

Copy link
Contributor

@asb asb left a comment

Choose a reason for hiding this comment

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

Ok, thanks for answering my question. LGTM.

@wangpc-pp wangpc-pp merged commit 7037878 into main Apr 28, 2024
@wangpc-pp wangpc-pp deleted the users/wangpc-pp/spr/riscvtablegen-get-right-experimental-extension-name branch April 28, 2024 03:16
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