Ian Rogers | 8afeb85 | 2014-04-02 14:55:49 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
Andreas Gampe | af13ad9 | 2014-04-11 12:07:48 -0700 | [diff] [blame^] | 19 | #include "globals.h" |
| 20 | #include "base/logging.h" // Logging is required for FATAL in the helper functions. |
| 21 | |
Ian Rogers | 8afeb85 | 2014-04-02 14:55:49 -0700 | [diff] [blame] | 22 | namespace art { |
| 23 | |
Andreas Gampe | af13ad9 | 2014-04-11 12:07:48 -0700 | [diff] [blame^] | 24 | size_t GetInstructionSetPointerSize(InstructionSet isa) { |
| 25 | switch (isa) { |
| 26 | case kArm: |
| 27 | // Fall-through. |
| 28 | case kThumb2: |
| 29 | return kArmPointerSize; |
| 30 | case kArm64: |
| 31 | return kArm64PointerSize; |
| 32 | case kX86: |
| 33 | return kX86PointerSize; |
| 34 | case kX86_64: |
| 35 | return kX86_64PointerSize; |
| 36 | case kMips: |
| 37 | return kMipsPointerSize; |
| 38 | case kNone: |
| 39 | LOG(FATAL) << "ISA kNone does not have pointer size."; |
| 40 | return 0; |
| 41 | default: |
| 42 | LOG(FATAL) << "Unknown ISA " << isa; |
| 43 | return 0; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | size_t GetInstructionSetAlignment(InstructionSet isa) { |
| 48 | switch (isa) { |
| 49 | case kArm: |
| 50 | // Fall-through. |
| 51 | case kThumb2: |
| 52 | return kArmAlignment; |
| 53 | case kArm64: |
| 54 | return kArm64Alignment; |
| 55 | case kX86: |
| 56 | // Fall-through. |
| 57 | case kX86_64: |
| 58 | return kX86Alignment; |
| 59 | case kMips: |
| 60 | return kMipsAlignment; |
| 61 | case kNone: |
| 62 | LOG(FATAL) << "ISA kNone does not have alignment."; |
| 63 | return 0; |
| 64 | default: |
| 65 | LOG(FATAL) << "Unknown ISA " << isa; |
| 66 | return 0; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | bool Is64BitInstructionSet(InstructionSet isa) { |
| 71 | switch (isa) { |
| 72 | case kArm: |
| 73 | case kThumb2: |
| 74 | case kX86: |
| 75 | case kMips: |
| 76 | return false; |
| 77 | |
| 78 | case kArm64: |
| 79 | case kX86_64: |
| 80 | return true; |
| 81 | |
| 82 | case kNone: |
| 83 | LOG(FATAL) << "ISA kNone does not have bit width."; |
| 84 | return 0; |
| 85 | default: |
| 86 | LOG(FATAL) << "Unknown ISA " << isa; |
| 87 | return 0; |
| 88 | } |
| 89 | } |
| 90 | |
Ian Rogers | 8afeb85 | 2014-04-02 14:55:49 -0700 | [diff] [blame] | 91 | std::string InstructionSetFeatures::GetFeatureString() const { |
| 92 | std::string result; |
| 93 | if ((mask_ & kHwDiv) != 0) { |
| 94 | result += "div"; |
| 95 | } |
| 96 | if (result.size() == 0) { |
| 97 | result = "none"; |
| 98 | } |
| 99 | return result; |
| 100 | } |
| 101 | |
| 102 | } // namespace art |