@@ -1833,6 +1833,92 @@ INSTANTIATE_TEST_SUITE_P(
1833
1833
1834
1834
AArch64CPUTestParams::PrintToStringParamName);
1835
1835
1836
+ struct AArch64CPUAliasTestParams {
1837
+ AArch64CPUAliasTestParams (std::vector<StringRef> Aliases)
1838
+ : Aliases(Aliases) {}
1839
+
1840
+ friend std::ostream &operator <<(std::ostream &os,
1841
+ const AArch64CPUAliasTestParams ¶ms) {
1842
+ raw_os_ostream oss (os);
1843
+ interleave (params.Aliases , oss, " , " );
1844
+ return os;
1845
+ }
1846
+
1847
+ // / Print a gtest-compatible facsimile of the first cpu (the aliasee), to make
1848
+ // / the test's name human-readable.
1849
+ static std::string PrintToStringParamName (
1850
+ const testing::TestParamInfo<AArch64CPUAliasTestParams> &Info) {
1851
+ std::string Name = Info.param .Aliases .front ().str ();
1852
+ for (char &C : Name)
1853
+ if (!std::isalnum (C))
1854
+ C = ' _' ;
1855
+ return Name;
1856
+ }
1857
+
1858
+ std::vector<StringRef> Aliases;
1859
+ };
1860
+
1861
+ class AArch64CPUAliasTestFixture
1862
+ : public ::testing::TestWithParam<AArch64CPUAliasTestParams> {};
1863
+
1864
+ static std::string aarch64FeaturesFromBits (AArch64::ExtensionBitset BitFlags) {
1865
+ std::vector<StringRef> Flags;
1866
+ bool OK = AArch64::getExtensionFeatures (BitFlags, Flags);
1867
+ assert (OK);
1868
+ (void )OK;
1869
+ std::string S;
1870
+ raw_string_ostream OS (S);
1871
+ interleave (Flags, OS, " , " );
1872
+ return OS.str ();
1873
+ }
1874
+
1875
+ TEST_P (AArch64CPUAliasTestFixture, testCPUAlias) {
1876
+ AArch64CPUAliasTestParams params = GetParam ();
1877
+
1878
+ StringRef MainName = params.Aliases [0 ];
1879
+ const std::optional<AArch64::CpuInfo> Cpu = AArch64::parseCpu (MainName);
1880
+ const AArch64::ArchInfo &MainAI = Cpu->Arch ;
1881
+ AArch64::ExtensionBitset MainFlags = Cpu->getImpliedExtensions ();
1882
+
1883
+ for (size_t I = 1 , E = params.Aliases .size (); I != E; ++I) {
1884
+ StringRef OtherName = params.Aliases [I];
1885
+ const std::optional<AArch64::CpuInfo> OtherCpu =
1886
+ AArch64::parseCpu (OtherName);
1887
+ const AArch64::ArchInfo &OtherAI = OtherCpu->Arch ;
1888
+
1889
+ EXPECT_EQ (MainAI.Version , OtherAI.Version )
1890
+ << MainName << " vs " << OtherName;
1891
+ EXPECT_EQ (MainAI.Name , OtherAI.Name ) << MainName << " vs " << OtherName;
1892
+ EXPECT_EQ (MainAI.Profile , OtherAI.Profile )
1893
+ << MainName << " vs " << OtherName;
1894
+ EXPECT_EQ (MainAI.DefaultExts , OtherAI.DefaultExts )
1895
+ << MainName << " vs " << OtherName;
1896
+ EXPECT_EQ (MainAI, OtherAI) << MainName << " vs " << OtherName;
1897
+
1898
+ AArch64::ExtensionBitset OtherFlags = OtherCpu->getImpliedExtensions ();
1899
+
1900
+ EXPECT_EQ (MainFlags, OtherFlags) << MainName << " vs " << OtherName;
1901
+
1902
+ EXPECT_EQ (aarch64FeaturesFromBits (MainFlags),
1903
+ aarch64FeaturesFromBits (OtherFlags))
1904
+ << MainName << " vs " << OtherName << " \n Diff: "
1905
+ << (aarch64FeaturesFromBits (MainFlags ^ OtherFlags));
1906
+ }
1907
+ }
1908
+
1909
+ INSTANTIATE_TEST_SUITE_P (
1910
+ AArch64CPUAliasTests, AArch64CPUAliasTestFixture,
1911
+ ::testing::Values (AArch64CPUAliasTestParams({" neoverse-n2" , " cobalt-100" }),
1912
+ AArch64CPUAliasTestParams({" neoverse-v2" , " grace" }),
1913
+ AArch64CPUAliasTestParams({" apple-a7" , " cyclone" ,
1914
+ " apple-a8" , " apple-a9" }),
1915
+ AArch64CPUAliasTestParams({" apple-a12" , " apple-s4" ,
1916
+ " apple-s5" }),
1917
+ AArch64CPUAliasTestParams({" apple-a14" , " apple-m1" }),
1918
+ AArch64CPUAliasTestParams({" apple-a15" , " apple-m2" }),
1919
+ AArch64CPUAliasTestParams({" apple-a16" , " apple-m3" })),
1920
+ AArch64CPUAliasTestParams::PrintToStringParamName);
1921
+
1836
1922
// Note: number of CPUs includes aliases.
1837
1923
static constexpr unsigned NumAArch64CPUArchs = 81 ;
1838
1924
0 commit comments