1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ART_RUNTIME_ARCH_MIPS64_INSTRUCTION_SET_FEATURES_MIPS64_H_
18 #define ART_RUNTIME_ARCH_MIPS64_INSTRUCTION_SET_FEATURES_MIPS64_H_
19 
20 #include "arch/instruction_set_features.h"
21 
22 namespace art {
23 
24 // Instruction set features relevant to the MIPS64 architecture.
25 class Mips64InstructionSetFeatures FINAL : public InstructionSetFeatures {
26  public:
27   // Process a CPU variant string like "r4000" and create InstructionSetFeatures.
28   static const Mips64InstructionSetFeatures* FromVariant(const std::string& variant,
29                                                         std::string* error_msg);
30 
31   // Parse a bitmap and create an InstructionSetFeatures.
32   static const Mips64InstructionSetFeatures* FromBitmap(uint32_t bitmap);
33 
34   // Turn C pre-processor #defines into the equivalent instruction set features.
35   static const Mips64InstructionSetFeatures* FromCppDefines();
36 
37   // Process /proc/cpuinfo and use kRuntimeISA to produce InstructionSetFeatures.
38   static const Mips64InstructionSetFeatures* FromCpuInfo();
39 
40   // Process the auxiliary vector AT_HWCAP entry and use kRuntimeISA to produce
41   // InstructionSetFeatures.
42   static const Mips64InstructionSetFeatures* FromHwcap();
43 
44   // Use assembly tests of the current runtime (ie kRuntimeISA) to determine the
45   // InstructionSetFeatures. This works around kernel bugs in AT_HWCAP and /proc/cpuinfo.
46   static const Mips64InstructionSetFeatures* FromAssembly();
47 
48   bool Equals(const InstructionSetFeatures* other) const OVERRIDE;
49 
GetInstructionSet()50   InstructionSet GetInstructionSet() const OVERRIDE {
51     return kMips64;
52   }
53 
54   uint32_t AsBitmap() const OVERRIDE;
55 
56   std::string GetFeatureString() const OVERRIDE;
57 
~Mips64InstructionSetFeatures()58   virtual ~Mips64InstructionSetFeatures() {}
59 
60  protected:
61   // Parse a vector of the form "fpu32", "mips2" adding these to a new Mips64InstructionSetFeatures.
62   virtual const InstructionSetFeatures*
63       AddFeaturesFromSplitString(const bool smp, const std::vector<std::string>& features,
64                                  std::string* error_msg) const OVERRIDE;
65 
66  private:
Mips64InstructionSetFeatures(bool smp)67   explicit Mips64InstructionSetFeatures(bool smp) : InstructionSetFeatures(smp) {
68   }
69 
70   // Bitmap positions for encoding features as a bitmap.
71   enum {
72     kSmpBitfield = 1,
73   };
74 
75   DISALLOW_COPY_AND_ASSIGN(Mips64InstructionSetFeatures);
76 };
77 
78 }  // namespace art
79 
80 #endif  // ART_RUNTIME_ARCH_MIPS64_INSTRUCTION_SET_FEATURES_MIPS64_H_
81