blob: 3b3e2c95fe9a1283470a9e9afc93700c5debad2b [file] [log] [blame]
Ian Rogersd582fa42014-11-05 23:46:43 -08001/*
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_ARM64_INSTRUCTION_SET_FEATURES_ARM64_H_
18#define ART_RUNTIME_ARCH_ARM64_INSTRUCTION_SET_FEATURES_ARM64_H_
19
20#include "arch/instruction_set_features.h"
21
22namespace art {
23
24// Instruction set features relevant to the ARM64 architecture.
25class Arm64InstructionSetFeatures FINAL : public InstructionSetFeatures {
26 public:
27 // Process a CPU variant string like "krait" or "cortex-a15" and create InstructionSetFeatures.
28 static const Arm64InstructionSetFeatures* FromVariant(const std::string& variant,
29 std::string* error_msg);
30
31 // Parse a bitmap and create an InstructionSetFeatures.
32 static const Arm64InstructionSetFeatures* FromBitmap(uint32_t bitmap);
33
34 // Turn C pre-processor #defines into the equivalent instruction set features.
35 static const Arm64InstructionSetFeatures* FromCppDefines();
36
37 // Process /proc/cpuinfo and use kRuntimeISA to produce InstructionSetFeatures.
38 static const Arm64InstructionSetFeatures* FromCpuInfo();
39
40 // Process the auxiliary vector AT_HWCAP entry and use kRuntimeISA to produce
41 // InstructionSetFeatures.
42 static const Arm64InstructionSetFeatures* 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 Arm64InstructionSetFeatures* FromAssembly();
47
48 bool Equals(const InstructionSetFeatures* other) const OVERRIDE;
49
50 InstructionSet GetInstructionSet() const OVERRIDE {
51 return kArm64;
52 }
53
54 uint32_t AsBitmap() const OVERRIDE;
55
56 // Return a string of the form "a53" or "none".
57 std::string GetFeatureString() const OVERRIDE;
58
59 // Generate code addressing Cortex-A53 erratum 835769?
60 bool NeedFixCortexA53_835769() const {
61 return fix_cortex_a53_835769_;
62 }
63
Vladimir Marko20f85592015-03-19 10:07:02 +000064 // Generate code addressing Cortex-A53 erratum 843419?
65 bool NeedFixCortexA53_843419() const {
66 return fix_cortex_a53_843419_;
67 }
68
Serban Constantinescu579885a2015-02-22 20:51:33 +000069 // TODO: Tune this on a per CPU basis. For now, we pessimistically assume
70 // that all ARM64 CPUs prefer explicit memory barriers over acquire-release.
71 //
72 // NOTE: This should not be the case! However we want to exercise the
73 // explicit memory barriers code paths in the Optimizing Compiler.
74 bool PreferAcquireRelease() const {
75 return false;
76 }
77
Ian Rogersd582fa42014-11-05 23:46:43 -080078 virtual ~Arm64InstructionSetFeatures() {}
79
80 protected:
81 // Parse a vector of the form "a53" adding these to a new ArmInstructionSetFeatures.
82 const InstructionSetFeatures*
83 AddFeaturesFromSplitString(const bool smp, const std::vector<std::string>& features,
84 std::string* error_msg) const OVERRIDE;
85
86 private:
Vladimir Marko20f85592015-03-19 10:07:02 +000087 explicit Arm64InstructionSetFeatures(bool smp,
88 bool needs_a53_835769_fix,
89 bool needs_a53_843419_fix)
90 : InstructionSetFeatures(smp),
91 fix_cortex_a53_835769_(needs_a53_835769_fix),
92 fix_cortex_a53_843419_(needs_a53_843419_fix) {
Ian Rogersd582fa42014-11-05 23:46:43 -080093 }
94
95 // Bitmap positions for encoding features as a bitmap.
96 enum {
97 kSmpBitfield = 1,
98 kA53Bitfield = 2,
99 };
100
101 const bool fix_cortex_a53_835769_;
Vladimir Marko20f85592015-03-19 10:07:02 +0000102 const bool fix_cortex_a53_843419_;
Ian Rogersd582fa42014-11-05 23:46:43 -0800103
104 DISALLOW_COPY_AND_ASSIGN(Arm64InstructionSetFeatures);
105};
106
107} // namespace art
108
109#endif // ART_RUNTIME_ARCH_ARM64_INSTRUCTION_SET_FEATURES_ARM64_H_