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 #ifndef ART_COMPILER_UTILS_X86_CONSTANTS_X86_H_ 18 #define ART_COMPILER_UTILS_X86_CONSTANTS_X86_H_ 19 20 #include <iosfwd> 21 22 #include <android-base/logging.h> 23 24 #include "arch/x86/registers_x86.h" 25 #include "base/globals.h" 26 #include "base/macros.h" 27 28 namespace art HIDDEN { 29 namespace x86 { 30 31 enum ByteRegister { 32 AL = 0, 33 CL = 1, 34 DL = 2, 35 BL = 3, 36 AH = 4, 37 CH = 5, 38 DH = 6, 39 BH = 7, 40 kNoByteRegister = -1 // Signals an illegal register. 41 }; 42 43 enum X87Register { 44 ST0 = 0, 45 ST1 = 1, 46 ST2 = 2, 47 ST3 = 3, 48 ST4 = 4, 49 ST5 = 5, 50 ST6 = 6, 51 ST7 = 7, 52 kNumberOfX87Registers = 8, 53 kNoX87Register = -1 // Signals an illegal register. 54 }; 55 std::ostream& operator<<(std::ostream& os, const X87Register& reg); 56 57 enum Condition { 58 kOverflow = 0, 59 kNoOverflow = 1, 60 kBelow = 2, 61 kAboveEqual = 3, 62 kEqual = 4, 63 kNotEqual = 5, 64 kBelowEqual = 6, 65 kAbove = 7, 66 kSign = 8, 67 kNotSign = 9, 68 kParityEven = 10, 69 kParityOdd = 11, 70 kLess = 12, 71 kGreaterEqual = 13, 72 kLessEqual = 14, 73 kGreater = 15, 74 75 kZero = kEqual, 76 kNotZero = kNotEqual, 77 kNegative = kSign, 78 kPositive = kNotSign, 79 kCarrySet = kBelow, 80 kCarryClear = kAboveEqual, 81 kUnordered = kParityEven 82 }; 83 84 85 class Instr { 86 public: 87 static const uint8_t kHltInstruction = 0xF4; 88 // We prefer not to use the int3 instruction since it conflicts with gdb. 89 static const uint8_t kBreakPointInstruction = kHltInstruction; 90 IsBreakPoint()91 bool IsBreakPoint() { 92 return (*reinterpret_cast<const uint8_t*>(this)) == kBreakPointInstruction; 93 } 94 95 // Instructions are read out of a code stream. The only way to get a 96 // reference to an instruction is to convert a pointer. There is no way 97 // to allocate or create instances of class Instr. 98 // Use the At(pc) function to create references to Instr. At(uintptr_t pc)99 static Instr* At(uintptr_t pc) { return reinterpret_cast<Instr*>(pc); } 100 101 private: 102 DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); 103 }; 104 105 } // namespace x86 106 } // namespace art 107 108 #endif // ART_COMPILER_UTILS_X86_CONSTANTS_X86_H_ 109