xref: /aosp_15_r20/external/cpu_features/test/cpuinfo_aarch64_test.cc (revision eca53ba6d2e951e174b64682eaf56a36b8204c89)
1*eca53ba6SRoland Levillain // Copyright 2017 Google LLC
2*eca53ba6SRoland Levillain //
3*eca53ba6SRoland Levillain // Licensed under the Apache License, Version 2.0 (the "License");
4*eca53ba6SRoland Levillain // you may not use this file except in compliance with the License.
5*eca53ba6SRoland Levillain // You may obtain a copy of the License at
6*eca53ba6SRoland Levillain //
7*eca53ba6SRoland Levillain //    http://www.apache.org/licenses/LICENSE-2.0
8*eca53ba6SRoland Levillain //
9*eca53ba6SRoland Levillain // Unless required by applicable law or agreed to in writing, software
10*eca53ba6SRoland Levillain // distributed under the License is distributed on an "AS IS" BASIS,
11*eca53ba6SRoland Levillain // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*eca53ba6SRoland Levillain // See the License for the specific language governing permissions and
13*eca53ba6SRoland Levillain // limitations under the License.
14*eca53ba6SRoland Levillain 
15*eca53ba6SRoland Levillain #include "cpuinfo_aarch64.h"
16*eca53ba6SRoland Levillain 
17*eca53ba6SRoland Levillain #include <set>
18*eca53ba6SRoland Levillain 
19*eca53ba6SRoland Levillain #include "filesystem_for_testing.h"
20*eca53ba6SRoland Levillain #include "gtest/gtest.h"
21*eca53ba6SRoland Levillain #include "hwcaps_for_testing.h"
22*eca53ba6SRoland Levillain #if defined(CPU_FEATURES_OS_WINDOWS)
23*eca53ba6SRoland Levillain #include "internal/windows_utils.h"
24*eca53ba6SRoland Levillain #endif  // CPU_FEATURES_OS_WINDOWS
25*eca53ba6SRoland Levillain 
26*eca53ba6SRoland Levillain namespace cpu_features {
27*eca53ba6SRoland Levillain class FakeCpuAarch64 {
28*eca53ba6SRoland Levillain #if defined(CPU_FEATURES_OS_LINUX)
29*eca53ba6SRoland Levillain   // No particular implementation for Linux as we use /proc/cpuinfo
30*eca53ba6SRoland Levillain #elif defined(CPU_FEATURES_OS_MACOS)
31*eca53ba6SRoland Levillain   std::set<std::string> darwin_sysctlbyname_;
32*eca53ba6SRoland Levillain   std::map<std::string, int> darwin_sysctlbynamevalue_;
33*eca53ba6SRoland Levillain 
34*eca53ba6SRoland Levillain  public:
35*eca53ba6SRoland Levillain   bool GetDarwinSysCtlByName(std::string name) const {
36*eca53ba6SRoland Levillain     return darwin_sysctlbyname_.count(name);
37*eca53ba6SRoland Levillain   }
38*eca53ba6SRoland Levillain 
39*eca53ba6SRoland Levillain   int GetDarwinSysCtlByNameValue(std::string name) const {
40*eca53ba6SRoland Levillain     const auto iter = darwin_sysctlbynamevalue_.find(name);
41*eca53ba6SRoland Levillain     if (iter != darwin_sysctlbynamevalue_.end()) return iter->second;
42*eca53ba6SRoland Levillain     return 0;
43*eca53ba6SRoland Levillain   }
44*eca53ba6SRoland Levillain 
45*eca53ba6SRoland Levillain   void SetDarwinSysCtlByName(std::string name) {
46*eca53ba6SRoland Levillain     darwin_sysctlbyname_.insert(name);
47*eca53ba6SRoland Levillain   }
48*eca53ba6SRoland Levillain 
49*eca53ba6SRoland Levillain   void SetDarwinSysCtlByNameValue(std::string name, int value) {
50*eca53ba6SRoland Levillain     darwin_sysctlbynamevalue_[name] = value;
51*eca53ba6SRoland Levillain   }
52*eca53ba6SRoland Levillain #elif defined(CPU_FEATURES_OS_WINDOWS)
53*eca53ba6SRoland Levillain   std::set<DWORD> windows_isprocessorfeaturepresent_;
54*eca53ba6SRoland Levillain   WORD processor_revision_{};
55*eca53ba6SRoland Levillain 
56*eca53ba6SRoland Levillain  public:
57*eca53ba6SRoland Levillain   bool GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) {
58*eca53ba6SRoland Levillain     return windows_isprocessorfeaturepresent_.count(dwProcessorFeature);
59*eca53ba6SRoland Levillain   }
60*eca53ba6SRoland Levillain 
61*eca53ba6SRoland Levillain   void SetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) {
62*eca53ba6SRoland Levillain     windows_isprocessorfeaturepresent_.insert(dwProcessorFeature);
63*eca53ba6SRoland Levillain   }
64*eca53ba6SRoland Levillain 
65*eca53ba6SRoland Levillain   WORD GetWindowsNativeSystemInfoProcessorRevision() const {
66*eca53ba6SRoland Levillain     return processor_revision_;
67*eca53ba6SRoland Levillain   }
68*eca53ba6SRoland Levillain 
69*eca53ba6SRoland Levillain   void SetWindowsNativeSystemInfoProcessorRevision(WORD wProcessorRevision) {
70*eca53ba6SRoland Levillain     processor_revision_ = wProcessorRevision;
71*eca53ba6SRoland Levillain   }
72*eca53ba6SRoland Levillain #endif
73*eca53ba6SRoland Levillain };
74*eca53ba6SRoland Levillain 
75*eca53ba6SRoland Levillain static FakeCpuAarch64* g_fake_cpu_instance = nullptr;
76*eca53ba6SRoland Levillain 
cpu()77*eca53ba6SRoland Levillain static FakeCpuAarch64& cpu() {
78*eca53ba6SRoland Levillain   assert(g_fake_cpu_instance != nullptr);
79*eca53ba6SRoland Levillain   return *g_fake_cpu_instance;
80*eca53ba6SRoland Levillain }
81*eca53ba6SRoland Levillain 
82*eca53ba6SRoland Levillain // Define OS dependent mock functions
83*eca53ba6SRoland Levillain #if defined(CPU_FEATURES_OS_LINUX)
84*eca53ba6SRoland Levillain // No particular functions to implement for Linux as we use /proc/cpuinfo
85*eca53ba6SRoland Levillain #elif defined(CPU_FEATURES_OS_MACOS)
GetDarwinSysCtlByName(const char * name)86*eca53ba6SRoland Levillain extern "C" bool GetDarwinSysCtlByName(const char* name) {
87*eca53ba6SRoland Levillain   return cpu().GetDarwinSysCtlByName(name);
88*eca53ba6SRoland Levillain }
89*eca53ba6SRoland Levillain 
GetDarwinSysCtlByNameValue(const char * name)90*eca53ba6SRoland Levillain extern "C" int GetDarwinSysCtlByNameValue(const char* name) {
91*eca53ba6SRoland Levillain   return cpu().GetDarwinSysCtlByNameValue(name);
92*eca53ba6SRoland Levillain }
93*eca53ba6SRoland Levillain #elif defined(CPU_FEATURES_OS_WINDOWS)
GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature)94*eca53ba6SRoland Levillain extern "C" bool GetWindowsIsProcessorFeaturePresent(DWORD dwProcessorFeature) {
95*eca53ba6SRoland Levillain   return cpu().GetWindowsIsProcessorFeaturePresent(dwProcessorFeature);
96*eca53ba6SRoland Levillain }
97*eca53ba6SRoland Levillain 
GetWindowsNativeSystemInfoProcessorRevision()98*eca53ba6SRoland Levillain extern "C" WORD GetWindowsNativeSystemInfoProcessorRevision() {
99*eca53ba6SRoland Levillain   return cpu().GetWindowsNativeSystemInfoProcessorRevision();
100*eca53ba6SRoland Levillain }
101*eca53ba6SRoland Levillain #endif
102*eca53ba6SRoland Levillain 
103*eca53ba6SRoland Levillain namespace {
104*eca53ba6SRoland Levillain 
105*eca53ba6SRoland Levillain class CpuidAarch64Test : public ::testing::Test {
106*eca53ba6SRoland Levillain  protected:
SetUp()107*eca53ba6SRoland Levillain   void SetUp() override {
108*eca53ba6SRoland Levillain     assert(g_fake_cpu_instance == nullptr);
109*eca53ba6SRoland Levillain     g_fake_cpu_instance = new FakeCpuAarch64();
110*eca53ba6SRoland Levillain   }
TearDown()111*eca53ba6SRoland Levillain   void TearDown() override {
112*eca53ba6SRoland Levillain     delete g_fake_cpu_instance;
113*eca53ba6SRoland Levillain     g_fake_cpu_instance = nullptr;
114*eca53ba6SRoland Levillain   }
115*eca53ba6SRoland Levillain };
116*eca53ba6SRoland Levillain 
TEST_F(CpuidAarch64Test,Aarch64FeaturesEnum)117*eca53ba6SRoland Levillain TEST_F(CpuidAarch64Test, Aarch64FeaturesEnum) {
118*eca53ba6SRoland Levillain   const char* last_name = GetAarch64FeaturesEnumName(AARCH64_LAST_);
119*eca53ba6SRoland Levillain   EXPECT_STREQ(last_name, "unknown_feature");
120*eca53ba6SRoland Levillain   for (int i = static_cast<int>(AARCH64_FP);
121*eca53ba6SRoland Levillain        i != static_cast<int>(AARCH64_LAST_); ++i) {
122*eca53ba6SRoland Levillain     const auto feature = static_cast<Aarch64FeaturesEnum>(i);
123*eca53ba6SRoland Levillain     const char* name = GetAarch64FeaturesEnumName(feature);
124*eca53ba6SRoland Levillain     ASSERT_FALSE(name == nullptr);
125*eca53ba6SRoland Levillain     EXPECT_STRNE(name, "");
126*eca53ba6SRoland Levillain     EXPECT_STRNE(name, last_name);
127*eca53ba6SRoland Levillain   }
128*eca53ba6SRoland Levillain }
129*eca53ba6SRoland Levillain 
130*eca53ba6SRoland Levillain // OS dependent tests
131*eca53ba6SRoland Levillain #if defined(CPU_FEATURES_OS_LINUX)
TEST_F(CpuidAarch64Test,FromHardwareCap)132*eca53ba6SRoland Levillain TEST_F(CpuidAarch64Test, FromHardwareCap) {
133*eca53ba6SRoland Levillain   ResetHwcaps();
134*eca53ba6SRoland Levillain   SetHardwareCapabilities(AARCH64_HWCAP_FP | AARCH64_HWCAP_AES, 0);
135*eca53ba6SRoland Levillain   GetEmptyFilesystem();  // disabling /proc/cpuinfo
136*eca53ba6SRoland Levillain   const auto info = GetAarch64Info();
137*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.fp);
138*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimd);
139*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.evtstrm);
140*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.aes);
141*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.pmull);
142*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha1);
143*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha2);
144*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.crc32);
145*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.atomics);
146*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.fphp);
147*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimdhp);
148*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.cpuid);
149*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimdrdm);
150*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.jscvt);
151*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.fcma);
152*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.lrcpc);
153*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dcpop);
154*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha3);
155*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sm3);
156*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sm4);
157*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimddp);
158*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha512);
159*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sve);
160*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimdfhm);
161*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dit);
162*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.uscat);
163*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.ilrcpc);
164*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.flagm);
165*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.ssbs);
166*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sb);
167*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.paca);
168*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.pacg);
169*eca53ba6SRoland Levillain }
170*eca53ba6SRoland Levillain 
TEST_F(CpuidAarch64Test,FromHardwareCap2)171*eca53ba6SRoland Levillain TEST_F(CpuidAarch64Test, FromHardwareCap2) {
172*eca53ba6SRoland Levillain   ResetHwcaps();
173*eca53ba6SRoland Levillain   SetHardwareCapabilities(AARCH64_HWCAP_FP,
174*eca53ba6SRoland Levillain                           AARCH64_HWCAP2_SVE2 | AARCH64_HWCAP2_BTI);
175*eca53ba6SRoland Levillain   GetEmptyFilesystem();  // disabling /proc/cpuinfo
176*eca53ba6SRoland Levillain   const auto info = GetAarch64Info();
177*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.fp);
178*eca53ba6SRoland Levillain 
179*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.sve2);
180*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.bti);
181*eca53ba6SRoland Levillain 
182*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dcpodp);
183*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sveaes);
184*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svepmull);
185*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svebitperm);
186*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svesha3);
187*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svesm4);
188*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.flagm2);
189*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.frint);
190*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svei8mm);
191*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svef32mm);
192*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svef64mm);
193*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svebf16);
194*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.i8mm);
195*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.bf16);
196*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dgh);
197*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.rng);
198*eca53ba6SRoland Levillain }
199*eca53ba6SRoland Levillain 
TEST_F(CpuidAarch64Test,ARMCortexA53)200*eca53ba6SRoland Levillain TEST_F(CpuidAarch64Test, ARMCortexA53) {
201*eca53ba6SRoland Levillain   ResetHwcaps();
202*eca53ba6SRoland Levillain   auto& fs = GetEmptyFilesystem();
203*eca53ba6SRoland Levillain   fs.CreateFile("/proc/cpuinfo",
204*eca53ba6SRoland Levillain                 R"(Processor   : AArch64 Processor rev 3 (aarch64)
205*eca53ba6SRoland Levillain processor   : 0
206*eca53ba6SRoland Levillain processor   : 1
207*eca53ba6SRoland Levillain processor   : 2
208*eca53ba6SRoland Levillain processor   : 3
209*eca53ba6SRoland Levillain processor   : 4
210*eca53ba6SRoland Levillain processor   : 5
211*eca53ba6SRoland Levillain processor   : 6
212*eca53ba6SRoland Levillain processor   : 7
213*eca53ba6SRoland Levillain Features    : fp asimd evtstrm aes pmull sha1 sha2 crc32
214*eca53ba6SRoland Levillain CPU implementer : 0x41
215*eca53ba6SRoland Levillain CPU architecture: AArch64
216*eca53ba6SRoland Levillain CPU variant : 0x0
217*eca53ba6SRoland Levillain CPU part    : 0xd03
218*eca53ba6SRoland Levillain CPU revision    : 3)");
219*eca53ba6SRoland Levillain   const auto info = GetAarch64Info();
220*eca53ba6SRoland Levillain   EXPECT_EQ(info.implementer, 0x41);
221*eca53ba6SRoland Levillain   EXPECT_EQ(info.variant, 0x0);
222*eca53ba6SRoland Levillain   EXPECT_EQ(info.part, 0xd03);
223*eca53ba6SRoland Levillain   EXPECT_EQ(info.revision, 3);
224*eca53ba6SRoland Levillain 
225*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.fp);
226*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.asimd);
227*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.evtstrm);
228*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.aes);
229*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.pmull);
230*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.sha1);
231*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.sha2);
232*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.crc32);
233*eca53ba6SRoland Levillain 
234*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.atomics);
235*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.fphp);
236*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimdhp);
237*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.cpuid);
238*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimdrdm);
239*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.jscvt);
240*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.fcma);
241*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.lrcpc);
242*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dcpop);
243*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha3);
244*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sm3);
245*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sm4);
246*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimddp);
247*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha512);
248*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sve);
249*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimdfhm);
250*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dit);
251*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.uscat);
252*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.ilrcpc);
253*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.flagm);
254*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.ssbs);
255*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sb);
256*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.paca);
257*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.pacg);
258*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dcpodp);
259*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sve2);
260*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sveaes);
261*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svepmull);
262*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svebitperm);
263*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svesha3);
264*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svesm4);
265*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.flagm2);
266*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.frint);
267*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svei8mm);
268*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svef32mm);
269*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svef64mm);
270*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.svebf16);
271*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.i8mm);
272*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.bf16);
273*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dgh);
274*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.rng);
275*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.bti);
276*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.mte);
277*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.ecv);
278*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.afp);
279*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.rpres);
280*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.mte3);
281*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sme);
282*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smei16i64);
283*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smef64f64);
284*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smei8i32);
285*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smef16f32);
286*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smeb16f32);
287*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smef32f32);
288*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smefa64);
289*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.wfxt);
290*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.ebf16);
291*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sveebf16);
292*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.cssc);
293*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.rprfm);
294*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sve2p1);
295*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sme2);
296*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sme2p1);
297*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smei16i32);
298*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smebi32i32);
299*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smeb16b16);
300*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.smef16f16);
301*eca53ba6SRoland Levillain }
302*eca53ba6SRoland Levillain #elif defined(CPU_FEATURES_OS_MACOS)
TEST_F(CpuidAarch64Test,FromDarwinSysctlFromName)303*eca53ba6SRoland Levillain TEST_F(CpuidAarch64Test, FromDarwinSysctlFromName) {
304*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.floatingpoint");
305*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.neon");
306*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.AdvSIMD_HPFPCvt");
307*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_FP16");
308*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_LSE");
309*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.armv8_crc32");
310*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_FHM");
311*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA512");
312*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA3");
313*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.amx_version");
314*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.ucnormal_mem");
315*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByName("hw.optional.arm64");
316*eca53ba6SRoland Levillain 
317*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByNameValue("hw.cputype", 16777228);
318*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByNameValue("hw.cpusubtype", 2);
319*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByNameValue("hw.cpu64bit", 1);
320*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByNameValue("hw.cpufamily", 458787763);
321*eca53ba6SRoland Levillain   cpu().SetDarwinSysCtlByNameValue("hw.cpusubfamily", 2);
322*eca53ba6SRoland Levillain 
323*eca53ba6SRoland Levillain   const auto info = GetAarch64Info();
324*eca53ba6SRoland Levillain 
325*eca53ba6SRoland Levillain   EXPECT_EQ(info.implementer, 0x100000C);
326*eca53ba6SRoland Levillain   EXPECT_EQ(info.variant, 2);
327*eca53ba6SRoland Levillain   EXPECT_EQ(info.part, 0x1B588BB3);
328*eca53ba6SRoland Levillain   EXPECT_EQ(info.revision, 2);
329*eca53ba6SRoland Levillain 
330*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.fp);
331*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimd);
332*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.evtstrm);
333*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.aes);
334*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.pmull);
335*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha1);
336*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha2);
337*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.crc32);
338*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.atomics);
339*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.fphp);
340*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimdhp);
341*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.cpuid);
342*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimdrdm);
343*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.jscvt);
344*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.fcma);
345*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.lrcpc);
346*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dcpop);
347*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.sha3);
348*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sm3);
349*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sm4);
350*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimddp);
351*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.sha512);
352*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sve);
353*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.asimdfhm);
354*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.dit);
355*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.uscat);
356*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.ilrcpc);
357*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.flagm);
358*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.ssbs);
359*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sb);
360*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.paca);
361*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.pacg);
362*eca53ba6SRoland Levillain }
363*eca53ba6SRoland Levillain #elif defined(CPU_FEATURES_OS_WINDOWS)
TEST_F(CpuidAarch64Test,WINDOWS_AARCH64_RPI4)364*eca53ba6SRoland Levillain TEST_F(CpuidAarch64Test, WINDOWS_AARCH64_RPI4) {
365*eca53ba6SRoland Levillain   cpu().SetWindowsNativeSystemInfoProcessorRevision(0x03);
366*eca53ba6SRoland Levillain   cpu().SetWindowsIsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE);
367*eca53ba6SRoland Levillain   cpu().SetWindowsIsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE);
368*eca53ba6SRoland Levillain   cpu().SetWindowsIsProcessorFeaturePresent(
369*eca53ba6SRoland Levillain       PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);
370*eca53ba6SRoland Levillain 
371*eca53ba6SRoland Levillain   const auto info = GetAarch64Info();
372*eca53ba6SRoland Levillain 
373*eca53ba6SRoland Levillain   EXPECT_EQ(info.revision, 0x03);
374*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.fp);
375*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.asimd);
376*eca53ba6SRoland Levillain   EXPECT_TRUE(info.features.crc32);
377*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.aes);
378*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha1);
379*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.sha2);
380*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.pmull);
381*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.atomics);
382*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.asimddp);
383*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.jscvt);
384*eca53ba6SRoland Levillain   EXPECT_FALSE(info.features.lrcpc);
385*eca53ba6SRoland Levillain }
386*eca53ba6SRoland Levillain #endif  // CPU_FEATURES_OS_WINDOWS
387*eca53ba6SRoland Levillain }  // namespace
388*eca53ba6SRoland Levillain }  // namespace cpu_features
389