• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/macros.h"
26 #include "globals.h"
27 
28 namespace art {
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 
44 enum XmmRegister {
45   XMM0 = 0,
46   XMM1 = 1,
47   XMM2 = 2,
48   XMM3 = 3,
49   XMM4 = 4,
50   XMM5 = 5,
51   XMM6 = 6,
52   XMM7 = 7,
53   kNumberOfXmmRegisters = 8,
54   kNoXmmRegister = -1  // Signals an illegal register.
55 };
56 std::ostream& operator<<(std::ostream& os, const XmmRegister& reg);
57 
58 enum X87Register {
59   ST0 = 0,
60   ST1 = 1,
61   ST2 = 2,
62   ST3 = 3,
63   ST4 = 4,
64   ST5 = 5,
65   ST6 = 6,
66   ST7 = 7,
67   kNumberOfX87Registers = 8,
68   kNoX87Register = -1  // Signals an illegal register.
69 };
70 std::ostream& operator<<(std::ostream& os, const X87Register& reg);
71 
72 enum ScaleFactor {
73   TIMES_1 = 0,
74   TIMES_2 = 1,
75   TIMES_4 = 2,
76   TIMES_8 = 3
77 };
78 
79 enum Condition {
80   kOverflow     =  0,
81   kNoOverflow   =  1,
82   kBelow        =  2,
83   kAboveEqual   =  3,
84   kEqual        =  4,
85   kNotEqual     =  5,
86   kBelowEqual   =  6,
87   kAbove        =  7,
88   kSign         =  8,
89   kNotSign      =  9,
90   kParityEven   = 10,
91   kParityOdd    = 11,
92   kLess         = 12,
93   kGreaterEqual = 13,
94   kLessEqual    = 14,
95   kGreater      = 15,
96 
97   kZero         = kEqual,
98   kNotZero      = kNotEqual,
99   kNegative     = kSign,
100   kPositive     = kNotSign,
101   kCarrySet     = kBelow,
102   kCarryClear   = kAboveEqual,
103   kUnordered    = kParityEven
104 };
105 
106 
107 class Instr {
108  public:
109   static const uint8_t kHltInstruction = 0xF4;
110   // We prefer not to use the int3 instruction since it conflicts with gdb.
111   static const uint8_t kBreakPointInstruction = kHltInstruction;
112 
IsBreakPoint()113   bool IsBreakPoint() {
114     return (*reinterpret_cast<const uint8_t*>(this)) == kBreakPointInstruction;
115   }
116 
117   // Instructions are read out of a code stream. The only way to get a
118   // reference to an instruction is to convert a pointer. There is no way
119   // to allocate or create instances of class Instr.
120   // Use the At(pc) function to create references to Instr.
At(uintptr_t pc)121   static Instr* At(uintptr_t pc) { return reinterpret_cast<Instr*>(pc); }
122 
123  private:
124   DISALLOW_IMPLICIT_CONSTRUCTORS(Instr);
125 };
126 
127 }  // namespace x86
128 }  // namespace art
129 
130 #endif  // ART_COMPILER_UTILS_X86_CONSTANTS_X86_H_
131