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