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 | */ |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 16 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 17 | #ifndef ART_COMPILER_UTILS_X86_CONSTANTS_X86_H_ |
| 18 | #define ART_COMPILER_UTILS_X86_CONSTANTS_X86_H_ |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 19 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 20 | #include <iosfwd> |
Elliott Hughes | 07ed66b | 2012-12-12 18:34:25 -0800 | [diff] [blame] | 21 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 22 | #include "arch/x86/registers_x86.h" |
Elliott Hughes | 07ed66b | 2012-12-12 18:34:25 -0800 | [diff] [blame] | 23 | #include "base/logging.h" |
Elliott Hughes | 7616005 | 2012-12-12 16:31:20 -0800 | [diff] [blame] | 24 | #include "base/macros.h" |
Brian Carlstrom | 578bbdc | 2011-07-21 14:07:47 -0700 | [diff] [blame] | 25 | #include "globals.h" |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 26 | |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 27 | namespace art { |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 28 | namespace x86 { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 29 | |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 30 | enum ByteRegister { |
| 31 | AL = 0, |
| 32 | CL = 1, |
| 33 | DL = 2, |
| 34 | BL = 3, |
| 35 | AH = 4, |
| 36 | CH = 5, |
| 37 | DH = 6, |
| 38 | BH = 7, |
| 39 | kNoByteRegister = -1 // Signals an illegal register. |
| 40 | }; |
| 41 | |
| 42 | |
| 43 | enum XmmRegister { |
| 44 | XMM0 = 0, |
| 45 | XMM1 = 1, |
| 46 | XMM2 = 2, |
| 47 | XMM3 = 3, |
| 48 | XMM4 = 4, |
| 49 | XMM5 = 5, |
| 50 | XMM6 = 6, |
| 51 | XMM7 = 7, |
| 52 | kNumberOfXmmRegisters = 8, |
| 53 | kNoXmmRegister = -1 // Signals an illegal register. |
| 54 | }; |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 55 | std::ostream& operator<<(std::ostream& os, const XmmRegister& reg); |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 56 | |
Ian Rogers | b033c75 | 2011-07-20 12:22:35 -0700 | [diff] [blame] | 57 | enum X87Register { |
| 58 | ST0 = 0, |
| 59 | ST1 = 1, |
| 60 | ST2 = 2, |
| 61 | ST3 = 3, |
| 62 | ST4 = 4, |
| 63 | ST5 = 5, |
| 64 | ST6 = 6, |
| 65 | ST7 = 7, |
| 66 | kNumberOfX87Registers = 8, |
| 67 | kNoX87Register = -1 // Signals an illegal register. |
| 68 | }; |
| 69 | std::ostream& operator<<(std::ostream& os, const X87Register& reg); |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 70 | |
| 71 | enum ScaleFactor { |
| 72 | TIMES_1 = 0, |
| 73 | TIMES_2 = 1, |
| 74 | TIMES_4 = 2, |
| 75 | TIMES_8 = 3 |
| 76 | }; |
| 77 | |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 78 | enum Condition { |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame] | 79 | kOverflow = 0, |
| 80 | kNoOverflow = 1, |
| 81 | kBelow = 2, |
| 82 | kAboveEqual = 3, |
| 83 | kEqual = 4, |
| 84 | kNotEqual = 5, |
| 85 | kBelowEqual = 6, |
| 86 | kAbove = 7, |
| 87 | kSign = 8, |
| 88 | kNotSign = 9, |
| 89 | kParityEven = 10, |
| 90 | kParityOdd = 11, |
| 91 | kLess = 12, |
| 92 | kGreaterEqual = 13, |
| 93 | kLessEqual = 14, |
| 94 | kGreater = 15, |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 95 | |
Elliott Hughes | 18c0753 | 2011-08-18 15:50:51 -0700 | [diff] [blame] | 96 | kZero = kEqual, |
| 97 | kNotZero = kNotEqual, |
| 98 | kNegative = kSign, |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 99 | kPositive = kNotSign, |
Vladimir Marko | 961ea12 | 2016-08-11 14:16:57 +0100 | [diff] [blame] | 100 | kCarrySet = kBelow, |
| 101 | kCarryClear = kAboveEqual, |
Calin Juravle | ddb7df2 | 2014-11-25 20:56:51 +0000 | [diff] [blame] | 102 | kUnordered = kParityEven |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | |
| 106 | class Instr { |
| 107 | public: |
| 108 | static const uint8_t kHltInstruction = 0xF4; |
| 109 | // We prefer not to use the int3 instruction since it conflicts with gdb. |
| 110 | static const uint8_t kBreakPointInstruction = kHltInstruction; |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 111 | |
| 112 | bool IsBreakPoint() { |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 113 | return (*reinterpret_cast<const uint8_t*>(this)) == kBreakPointInstruction; |
| 114 | } |
| 115 | |
| 116 | // Instructions are read out of a code stream. The only way to get a |
| 117 | // reference to an instruction is to convert a pointer. There is no way |
| 118 | // to allocate or create instances of class Instr. |
| 119 | // Use the At(pc) function to create references to Instr. |
| 120 | static Instr* At(uintptr_t pc) { return reinterpret_cast<Instr*>(pc); } |
| 121 | |
| 122 | private: |
| 123 | DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); |
| 124 | }; |
| 125 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 126 | } // namespace x86 |
Carl Shapiro | 6b6b5f0 | 2011-06-21 15:05:09 -0700 | [diff] [blame] | 127 | } // namespace art |
Carl Shapiro | a5d5cfd | 2011-06-21 12:46:59 -0700 | [diff] [blame] | 128 | |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 129 | #endif // ART_COMPILER_UTILS_X86_CONSTANTS_X86_H_ |