blob: 5b6039647c83b18b3fc70e46872d99fccf920a47 [file] [log] [blame]
Ian Rogers8afeb852014-04-02 14:55:49 -07001/*
2 * Copyright (C) 2011 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#include "instruction_set.h"
18
19namespace art {
20
Narayan Kamath11d9f062014-04-23 20:24:57 +010021const char* GetInstructionSetString(const InstructionSet isa) {
22 switch (isa) {
23 case kArm:
24 case kThumb2:
25 return "arm";
26 case kArm64:
27 return "arm64";
28 case kX86:
29 return "x86";
30 case kX86_64:
31 return "x86_64";
32 case kMips:
33 return "mips";
34 case kNone:
35 return "none";
36 default:
37 LOG(FATAL) << "Unknown ISA " << isa;
38 return nullptr;
39 }
40}
41
42InstructionSet GetInstructionSetFromString(const char* isa_str) {
43 CHECK(isa_str != nullptr);
44
45 if (!strcmp("arm", isa_str)) {
46 return kArm;
47 } else if (!strcmp("arm64", isa_str)) {
48 return kArm64;
49 } else if (!strcmp("x86", isa_str)) {
50 return kX86;
51 } else if (!strcmp("x86_64", isa_str)) {
52 return kX86_64;
53 } else if (!strcmp("mips", isa_str)) {
54 return kMips;
55 } else if (!strcmp("none", isa_str)) {
56 return kNone;
57 }
58
59 LOG(FATAL) << "Unknown ISA " << isa_str;
60 return kNone;
61}
62
Andreas Gampeaf13ad92014-04-11 12:07:48 -070063size_t GetInstructionSetAlignment(InstructionSet isa) {
64 switch (isa) {
65 case kArm:
66 // Fall-through.
67 case kThumb2:
68 return kArmAlignment;
69 case kArm64:
70 return kArm64Alignment;
71 case kX86:
72 // Fall-through.
73 case kX86_64:
74 return kX86Alignment;
75 case kMips:
76 return kMipsAlignment;
77 case kNone:
78 LOG(FATAL) << "ISA kNone does not have alignment.";
79 return 0;
80 default:
81 LOG(FATAL) << "Unknown ISA " << isa;
82 return 0;
83 }
84}
85
Ian Rogers8afeb852014-04-02 14:55:49 -070086std::string InstructionSetFeatures::GetFeatureString() const {
87 std::string result;
88 if ((mask_ & kHwDiv) != 0) {
89 result += "div";
90 }
91 if (result.size() == 0) {
92 result = "none";
93 }
94 return result;
95}
96
97} // namespace art