[PATCH] D144696: [RISCV][NFC] Package version number information using RISCVExtensionVersion.

yanming via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 23 23:25:39 PST 2023


ym1813382441 added a comment.

I want to use arrays to maintain the supported version number of each extension, this patch in using the `find` algorithm helps to simplify the code.



================
Comment at: llvm/include/llvm/Support/RISCVISAInfo.h:24
+  unsigned Minor;
+  bool operator==(const RISCVExtensionVersion &Vers) const {
+    return this->Major == Vers.Major && this->Minor == Vers.Minor;
----------------
eopXD wrote:
> Does the structure already work as-is?
I've tested it and it works.


================
Comment at: llvm/lib/Support/RISCVISAInfo.cpp:190
+                                RISCVExtensionVersion Version) {
+  assert(!Exts.count(ExtName.str()) && "Extension already exists");
+  Exts[ExtName.str()] = Version;
----------------
eopXD wrote:
> Maybe handling this with a compiler error is better than an assertion error.
Currently the compiler does not allow the same extension to appear more than once.
If it happens something has gone wrong.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144696/new/

https://reviews.llvm.org/D144696



More information about the cfe-commits mailing list