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