blob: 477bef8e23a09e57798d8a75ce9c2d10dd70569f [file] [log] [blame]
Carl Shapiroa5d5cfd2011-06-21 12:46:59 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_CONSTANTS_X86_H_
4#define ART_SRC_CONSTANTS_X86_H_
5
6#include "src/globals.h"
7#include "src/logging.h"
8#include "src/macros.h"
9
10namespace android {
11namespace runtime {
12
13enum Register {
14 EAX = 0,
15 ECX = 1,
16 EDX = 2,
17 EBX = 3,
18 ESP = 4,
19 EBP = 5,
20 ESI = 6,
21 EDI = 7,
22 kNumberOfCpuRegisters = 8,
23 kFirstByteUnsafeRegister = 4,
24 kNoRegister = -1 // Signals an illegal register.
25};
26
27
28enum ByteRegister {
29 AL = 0,
30 CL = 1,
31 DL = 2,
32 BL = 3,
33 AH = 4,
34 CH = 5,
35 DH = 6,
36 BH = 7,
37 kNoByteRegister = -1 // Signals an illegal register.
38};
39
40
41enum XmmRegister {
42 XMM0 = 0,
43 XMM1 = 1,
44 XMM2 = 2,
45 XMM3 = 3,
46 XMM4 = 4,
47 XMM5 = 5,
48 XMM6 = 6,
49 XMM7 = 7,
50 kNumberOfXmmRegisters = 8,
51 kNoXmmRegister = -1 // Signals an illegal register.
52};
53
54
55enum ScaleFactor {
56 TIMES_1 = 0,
57 TIMES_2 = 1,
58 TIMES_4 = 2,
59 TIMES_8 = 3
60};
61
62
63enum Condition {
64 OVERFLOW = 0,
65 NO_OVERFLOW = 1,
66 BELOW = 2,
67 ABOVE_EQUAL = 3,
68 EQUAL = 4,
69 NOT_EQUAL = 5,
70 BELOW_EQUAL = 6,
71 ABOVE = 7,
72 SIGN = 8,
73 NOT_SIGN = 9,
74 PARITY_EVEN = 10,
75 PARITY_ODD = 11,
76 LESS = 12,
77 GREATER_EQUAL = 13,
78 LESS_EQUAL = 14,
79 GREATER = 15,
80
81 ZERO = EQUAL,
82 NOT_ZERO = NOT_EQUAL,
83 NEGATIVE = SIGN,
84 POSITIVE = NOT_SIGN
85};
86
87
88class Instr {
89 public:
90 static const uint8_t kHltInstruction = 0xF4;
91 // We prefer not to use the int3 instruction since it conflicts with gdb.
92 static const uint8_t kBreakPointInstruction = kHltInstruction;
93 static const int kBreakPointInstructionSize = 1;
94
95 bool IsBreakPoint() {
96 CHECK_EQ(kBreakPointInstructionSize, 1);
97 return (*reinterpret_cast<const uint8_t*>(this)) == kBreakPointInstruction;
98 }
99
100 // Instructions are read out of a code stream. The only way to get a
101 // reference to an instruction is to convert a pointer. There is no way
102 // to allocate or create instances of class Instr.
103 // Use the At(pc) function to create references to Instr.
104 static Instr* At(uintptr_t pc) { return reinterpret_cast<Instr*>(pc); }
105
106 private:
107 DISALLOW_IMPLICIT_CONSTRUCTORS(Instr);
108};
109
110} } // namespace android::runtime
111
112#endif // ART_CONSTANTS_IA32_H_