@@ -1165,6 +1165,92 @@ INSTANTIATE_TEST_SUITE_P(
11651165 AArch64CPUTestParams(" oryon-1" , " armv8.6-a" )),
11661166 AArch64CPUTestParams::PrintToStringParamName);
11671167
1168+ struct AArch64CPUAliasTestParams {
1169+ AArch64CPUAliasTestParams (std::vector<StringRef> Aliases)
1170+ : Aliases(Aliases) {}
1171+
1172+ friend std::ostream &operator <<(std::ostream &os,
1173+ const AArch64CPUAliasTestParams ¶ms) {
1174+ raw_os_ostream oss (os);
1175+ interleave (params.Aliases , oss, " , " );
1176+ return os;
1177+ }
1178+
1179+ // / Print a gtest-compatible facsimile of the first cpu (the aliasee), to make
1180+ // / the test's name human-readable.
1181+ static std::string PrintToStringParamName (
1182+ const testing::TestParamInfo<AArch64CPUAliasTestParams> &Info) {
1183+ std::string Name = Info.param .Aliases .front ().str ();
1184+ for (char &C : Name)
1185+ if (!std::isalnum (C))
1186+ C = ' _' ;
1187+ return Name;
1188+ }
1189+
1190+ std::vector<StringRef> Aliases;
1191+ };
1192+
1193+ class AArch64CPUAliasTestFixture
1194+ : public ::testing::TestWithParam<AArch64CPUAliasTestParams> {};
1195+
1196+ static std::string aarch64FeaturesFromBits (AArch64::ExtensionBitset BitFlags) {
1197+ std::vector<StringRef> Flags;
1198+ bool OK = AArch64::getExtensionFeatures (BitFlags, Flags);
1199+ assert (OK);
1200+ (void )OK;
1201+ std::string S;
1202+ raw_string_ostream OS (S);
1203+ interleave (Flags, OS, " , " );
1204+ return OS.str ();
1205+ }
1206+
1207+ TEST_P (AArch64CPUAliasTestFixture, testCPUAlias) {
1208+ AArch64CPUAliasTestParams params = GetParam ();
1209+
1210+ StringRef MainName = params.Aliases [0 ];
1211+ const std::optional<AArch64::CpuInfo> Cpu = AArch64::parseCpu (MainName);
1212+ const AArch64::ArchInfo &MainAI = Cpu->Arch ;
1213+ AArch64::ExtensionBitset MainFlags = Cpu->getImpliedExtensions ();
1214+
1215+ for (size_t I = 1 , E = params.Aliases .size (); I != E; ++I) {
1216+ StringRef OtherName = params.Aliases [I];
1217+ const std::optional<AArch64::CpuInfo> OtherCpu =
1218+ AArch64::parseCpu (OtherName);
1219+ const AArch64::ArchInfo &OtherAI = OtherCpu->Arch ;
1220+
1221+ EXPECT_EQ (MainAI.Version , OtherAI.Version )
1222+ << MainName << " vs " << OtherName;
1223+ EXPECT_EQ (MainAI.Name , OtherAI.Name ) << MainName << " vs " << OtherName;
1224+ EXPECT_EQ (MainAI.Profile , OtherAI.Profile )
1225+ << MainName << " vs " << OtherName;
1226+ EXPECT_EQ (MainAI.DefaultExts , OtherAI.DefaultExts )
1227+ << MainName << " vs " << OtherName;
1228+ EXPECT_EQ (MainAI, OtherAI) << MainName << " vs " << OtherName;
1229+
1230+ AArch64::ExtensionBitset OtherFlags = OtherCpu->getImpliedExtensions ();
1231+
1232+ EXPECT_EQ (MainFlags, OtherFlags) << MainName << " vs " << OtherName;
1233+
1234+ EXPECT_EQ (aarch64FeaturesFromBits (MainFlags),
1235+ aarch64FeaturesFromBits (OtherFlags))
1236+ << MainName << " vs " << OtherName << " \n Diff: "
1237+ << (aarch64FeaturesFromBits (MainFlags ^ OtherFlags));
1238+ }
1239+ }
1240+
1241+ INSTANTIATE_TEST_SUITE_P (
1242+ AArch64CPUAliasTests, AArch64CPUAliasTestFixture,
1243+ ::testing::Values (AArch64CPUAliasTestParams({" neoverse-n2" , " cobalt-100" }),
1244+ AArch64CPUAliasTestParams({" neoverse-v2" , " grace" }),
1245+ AArch64CPUAliasTestParams({" apple-a7" , " cyclone" ,
1246+ " apple-a8" , " apple-a9" }),
1247+ AArch64CPUAliasTestParams({" apple-a12" , " apple-s4" ,
1248+ " apple-s5" }),
1249+ AArch64CPUAliasTestParams({" apple-a14" , " apple-m1" }),
1250+ AArch64CPUAliasTestParams({" apple-a15" , " apple-m2" }),
1251+ AArch64CPUAliasTestParams({" apple-a16" , " apple-m3" })),
1252+ AArch64CPUAliasTestParams::PrintToStringParamName);
1253+
11681254// Note: number of CPUs includes aliases.
11691255static constexpr unsigned NumAArch64CPUArchs = 82 ;
11701256
0 commit comments