blob: aee7447fafbd03e1a8d9e805420ba3a8a71ccf7d [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
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 Rogersb033c752011-07-20 12:22:35 -070016
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_INSTRUCTION_SET_H_
18#define ART_RUNTIME_INSTRUCTION_SET_H_
Ian Rogersb033c752011-07-20 12:22:35 -070019
Ian Rogersc8b306f2012-02-17 21:34:44 -080020#include <iosfwd>
Dave Allison70202782013-10-22 17:52:19 -070021#include <string>
22
23#include "base/macros.h"
Ian Rogersc8b306f2012-02-17 21:34:44 -080024
buzbeec143c552011-08-20 17:38:58 -070025namespace art {
26
27enum InstructionSet {
28 kNone,
29 kArm,
30 kThumb2,
Shih-wei Liao6edfde42012-03-01 15:49:12 -080031 kX86,
32 kMips
buzbeec143c552011-08-20 17:38:58 -070033};
34
Dave Allison70202782013-10-22 17:52:19 -070035enum InstructionFeatures {
36 kHwDiv = 1 // Supports hardware divide.
37};
38
39// This is a bitmask of supported features per architecture.
40class PACKED(4) InstructionSetFeatures {
41 public:
42 InstructionSetFeatures() : mask_(0) {}
43 explicit InstructionSetFeatures(uint32_t mask) : mask_(mask) {}
44
45 bool HasDivideInstruction() const {
46 return (mask_ & kHwDiv) != 0;
47 }
48
49 void SetHasDivideInstruction(bool v) {
50 mask_ = (mask_ & ~kHwDiv) | (v ? kHwDiv : 0);
51 }
52
53 std::string GetFeatureString() const {
54 std::string result;
55 if ((mask_ & kHwDiv) != 0) {
56 result += "div";
57 }
58 if (result.size() == 0) {
59 result = "none";
60 }
61 return result;
62 }
63
64 uint32_t get_mask() const {
65 return mask_;
66 }
67
68 // Other features in here.
69
70 bool operator==(const InstructionSetFeatures &peer) const {
71 return mask_ == peer.mask_;
72 }
73
74 bool operator!=(const InstructionSetFeatures &peer) const {
75 return mask_ != peer.mask_;
76 }
77
78 private:
79 uint32_t mask_;
80};
81
Elliott Hughesed64e8d2012-03-02 20:37:45 -080082std::ostream& operator<<(std::ostream& os, const InstructionSet& rhs);
83
buzbeec143c552011-08-20 17:38:58 -070084} // namespace art
85
Brian Carlstromfc0e3212013-07-17 14:40:12 -070086#endif // ART_RUNTIME_INSTRUCTION_SET_H_