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 class Mips64InstructionSetFeatures; 25 using Mips64FeaturesUniquePtr = std::unique_ptr<const Mips64InstructionSetFeatures>; 26 27 // Instruction set features relevant to the MIPS64 architecture. 28 class Mips64InstructionSetFeatures final : public InstructionSetFeatures { 29 public: 30 // Process a CPU variant string like "r4000" and create InstructionSetFeatures. 31 static Mips64FeaturesUniquePtr FromVariant(const std::string& variant, 32 std::string* error_msg); 33 34 // Parse a bitmap and create an InstructionSetFeatures. 35 static Mips64FeaturesUniquePtr FromBitmap(uint32_t bitmap); 36 37 // Turn C pre-processor #defines into the equivalent instruction set features. 38 static Mips64FeaturesUniquePtr FromCppDefines(); 39 40 // Process /proc/cpuinfo and use kRuntimeISA to produce InstructionSetFeatures. 41 static Mips64FeaturesUniquePtr FromCpuInfo(); 42 43 // Process the auxiliary vector AT_HWCAP entry and use kRuntimeISA to produce 44 // InstructionSetFeatures. 45 static Mips64FeaturesUniquePtr FromHwcap(); 46 47 // Use assembly tests of the current runtime (ie kRuntimeISA) to determine the 48 // InstructionSetFeatures. This works around kernel bugs in AT_HWCAP and /proc/cpuinfo. 49 static Mips64FeaturesUniquePtr FromAssembly(); 50 51 bool Equals(const InstructionSetFeatures* other) const override; 52 GetInstructionSet()53 InstructionSet GetInstructionSet() const override { 54 return InstructionSet::kMips64; 55 } 56 57 uint32_t AsBitmap() const override; 58 59 std::string GetFeatureString() const override; 60 61 // Does it have MSA (MIPS SIMD Architecture) support. HasMsa()62 bool HasMsa() const { 63 return msa_; 64 } 65 ~Mips64InstructionSetFeatures()66 virtual ~Mips64InstructionSetFeatures() {} 67 68 protected: 69 // Parse a vector of the form "fpu32", "mips2" adding these to a new Mips64InstructionSetFeatures. 70 std::unique_ptr<const InstructionSetFeatures> 71 AddFeaturesFromSplitString(const std::vector<std::string>& features, 72 std::string* error_msg) const override; 73 74 private: Mips64InstructionSetFeatures(bool msa)75 explicit Mips64InstructionSetFeatures(bool msa) : InstructionSetFeatures(), msa_(msa) { 76 } 77 78 // Bitmap positions for encoding features as a bitmap. 79 enum { 80 kMsaBitfield = 1, 81 }; 82 83 const bool msa_; 84 85 DISALLOW_COPY_AND_ASSIGN(Mips64InstructionSetFeatures); 86 }; 87 88 } // namespace art 89 90 #endif // ART_RUNTIME_ARCH_MIPS64_INSTRUCTION_SET_FEATURES_MIPS64_H_ 91