Elliott Hughes | 2faa5f1 | 2012-01-30 14:42:07 -0800 | [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 | */ |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 16 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_INSTRUCTION_SET_H_ |
| 18 | #define ART_RUNTIME_INSTRUCTION_SET_H_ |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 19 | |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 20 | #include <iosfwd> |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 21 | #include <string> |
| 22 | |
| 23 | #include "base/macros.h" |
Ian Rogers | c8b306f | 2012-02-17 21:34:44 -0800 | [diff] [blame] | 24 | |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 25 | namespace art { |
| 26 | |
| 27 | enum InstructionSet { |
| 28 | kNone, |
| 29 | kArm, |
| 30 | kThumb2, |
Shih-wei Liao | 6edfde4 | 2012-03-01 15:49:12 -0800 | [diff] [blame] | 31 | kX86, |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame^] | 32 | kX86_64, |
Shih-wei Liao | 6edfde4 | 2012-03-01 15:49:12 -0800 | [diff] [blame] | 33 | kMips |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
Dave Allison | 7020278 | 2013-10-22 17:52:19 -0700 | [diff] [blame] | 36 | enum InstructionFeatures { |
| 37 | kHwDiv = 1 // Supports hardware divide. |
| 38 | }; |
| 39 | |
| 40 | // This is a bitmask of supported features per architecture. |
| 41 | class PACKED(4) InstructionSetFeatures { |
| 42 | public: |
| 43 | InstructionSetFeatures() : mask_(0) {} |
| 44 | explicit InstructionSetFeatures(uint32_t mask) : mask_(mask) {} |
| 45 | |
| 46 | bool HasDivideInstruction() const { |
| 47 | return (mask_ & kHwDiv) != 0; |
| 48 | } |
| 49 | |
| 50 | void SetHasDivideInstruction(bool v) { |
| 51 | mask_ = (mask_ & ~kHwDiv) | (v ? kHwDiv : 0); |
| 52 | } |
| 53 | |
| 54 | std::string GetFeatureString() const { |
| 55 | std::string result; |
| 56 | if ((mask_ & kHwDiv) != 0) { |
| 57 | result += "div"; |
| 58 | } |
| 59 | if (result.size() == 0) { |
| 60 | result = "none"; |
| 61 | } |
| 62 | return result; |
| 63 | } |
| 64 | |
| 65 | uint32_t get_mask() const { |
| 66 | return mask_; |
| 67 | } |
| 68 | |
| 69 | // Other features in here. |
| 70 | |
| 71 | bool operator==(const InstructionSetFeatures &peer) const { |
| 72 | return mask_ == peer.mask_; |
| 73 | } |
| 74 | |
| 75 | bool operator!=(const InstructionSetFeatures &peer) const { |
| 76 | return mask_ != peer.mask_; |
| 77 | } |
| 78 | |
| 79 | private: |
| 80 | uint32_t mask_; |
| 81 | }; |
| 82 | |
Elliott Hughes | ed64e8d | 2012-03-02 20:37:45 -0800 | [diff] [blame] | 83 | std::ostream& operator<<(std::ostream& os, const InstructionSet& rhs); |
| 84 | |
buzbee | c143c55 | 2011-08-20 17:38:58 -0700 | [diff] [blame] | 85 | } // namespace art |
| 86 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 87 | #endif // ART_RUNTIME_INSTRUCTION_SET_H_ |