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