[llvm] a35e67f - [RISCV][test] Add test for RISCVISAInfo::OrderedExtensionMap ordering
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 18 01:27:47 PDT 2023
Author: Alex Bradbury
Date: 2023-04-18T09:26:43+01:00
New Revision: a35e67fc5be654a7efdfa6125343b90f8960a487
URL: https://github.com/llvm/llvm-project/commit/a35e67fc5be654a7efdfa6125343b90f8960a487
DIFF: https://github.com/llvm/llvm-project/commit/a35e67fc5be654a7efdfa6125343b90f8960a487.diff
LOG: [RISCV][test] Add test for RISCVISAInfo::OrderedExtensionMap ordering
Added:
Modified:
llvm/unittests/Support/RISCVISAInfoTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/Support/RISCVISAInfoTest.cpp b/llvm/unittests/Support/RISCVISAInfoTest.cpp
index 8a353360f9f27..afdf308269154 100644
--- a/llvm/unittests/Support/RISCVISAInfoTest.cpp
+++ b/llvm/unittests/Support/RISCVISAInfoTest.cpp
@@ -473,3 +473,22 @@ TEST(ToFeatureVector, UnsupportedExtensionsAreDropped) {
ASSERT_THAT_EXPECTED(MaybeISAInfo, Succeeded());
EXPECT_THAT((*MaybeISAInfo)->toFeatureVector(), ElementsAre("+m"));
}
+
+TEST(OrderedExtensionMap, ExtensionsAreCorrectlyOrdered) {
+ RISCVISAInfo::OrderedExtensionMap Exts;
+ for (auto ExtName : {"y", "l", "m", "c", "i", "xfoo", "xbar", "sfoo", "sbar",
+ "zmfoo", "zzfoo", "zfinx", "zicsr"})
+ Exts[ExtName] = {1, 0};
+
+ std::vector<std::string> ExtNames;
+ for (const auto &Ext : Exts)
+ ExtNames.push_back(Ext.first);
+
+ // FIXME: z* extensions should be ordered before s* extensions. The current
+ // ordering matches what is documented in RISCVISAInfo, but this doesn't
+ // match the ISA manual.
+ // FIXME: 'l' and 'y' should be ordered after 'i', 'm', 'c'.
+ EXPECT_THAT(ExtNames,
+ ElementsAre("i", "m", "l", "c", "y", "sbar", "sfoo", "zicsr",
+ "zmfoo", "zfinx", "zzfoo", "xbar", "xfoo"));
+}
More information about the llvm-commits
mailing list