xref: /aosp_15_r20/external/cpu_features/include/cpuinfo_mips.h (revision eca53ba6d2e951e174b64682eaf56a36b8204c89)
1 // Copyright 2017 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_
16 #define CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_
17 
18 #include "cpu_features_cache_info.h"
19 #include "cpu_features_macros.h"
20 
21 CPU_FEATURES_START_CPP_NAMESPACE
22 
23 typedef struct {
24   int msa : 1;    // MIPS SIMD Architecture
25                   // https://www.mips.com/products/architectures/ase/simd/
26   int eva : 1;    // Enhanced Virtual Addressing
27                   // https://www.mips.com/products/architectures/mips64/
28   int r6 : 1;     // True if is release 6 of the processor.
29   int mips16 : 1; // Compressed instructions
30   int mdmx : 1;   // MIPS Digital Media Extension
31   int mips3d : 1; // 3D graphics acceleration
32                   // MIPS(r) Architecture for Programmers, Volume IV-c
33   int smart : 1;  // Smart-card cryptography
34                   // MIPS(r) Architecture for Programmers, Volume IV-d
35   int dsp : 1;    // Digital Signal Processing
36                   // MIPS(r) Architecture for Programmers, Volume IV-e
37                   // https://www.mips.com/products/architectures/ase/dsp/
38 
39   // Make sure to update MipsFeaturesEnum below if you add a field here.
40 } MipsFeatures;
41 
42 typedef struct {
43   MipsFeatures features;
44 } MipsInfo;
45 
46 MipsInfo GetMipsInfo(void);
47 
48 ////////////////////////////////////////////////////////////////////////////////
49 // Introspection functions
50 
51 typedef enum {
52   MIPS_MSA,
53   MIPS_EVA,
54   MIPS_R6,
55   MIPS_MIPS16,
56   MIPS_MDMX,
57   MIPS_MIPS3D,
58   MIPS_SMART,
59   MIPS_DSP,
60   MIPS_LAST_,
61 } MipsFeaturesEnum;
62 
63 int GetMipsFeaturesEnumValue(const MipsFeatures* features,
64                              MipsFeaturesEnum value);
65 
66 const char* GetMipsFeaturesEnumName(MipsFeaturesEnum);
67 
68 CPU_FEATURES_END_CPP_NAMESPACE
69 
70 #if !defined(CPU_FEATURES_ARCH_MIPS)
71 #error "Including cpuinfo_mips.h from a non-mips target."
72 #endif
73 
74 #endif  // CPU_FEATURES_INCLUDE_CPUINFO_MIPS_H_
75