1 | // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 | // for details. All rights reserved. Use of this source code is governed by a |
3 | // BSD-style license that can be found in the LICENSE file. |
4 | |
5 | #ifndef RUNTIME_VM_CONSTANTS_X86_H_ |
6 | #define RUNTIME_VM_CONSTANTS_X86_H_ |
7 | |
8 | #include "platform/assert.h" |
9 | |
10 | namespace dart { |
11 | |
12 | enum Condition { |
13 | OVERFLOW = 0, |
14 | NO_OVERFLOW = 1, |
15 | BELOW = 2, |
16 | ABOVE_EQUAL = 3, |
17 | EQUAL = 4, |
18 | NOT_EQUAL = 5, |
19 | BELOW_EQUAL = 6, |
20 | ABOVE = 7, |
21 | SIGN = 8, |
22 | NOT_SIGN = 9, |
23 | PARITY_EVEN = 10, |
24 | PARITY_ODD = 11, |
25 | LESS = 12, |
26 | GREATER_EQUAL = 13, |
27 | LESS_EQUAL = 14, |
28 | GREATER = 15, |
29 | |
30 | ZERO = EQUAL, |
31 | NOT_ZERO = NOT_EQUAL, |
32 | NEGATIVE = SIGN, |
33 | POSITIVE = NOT_SIGN, |
34 | CARRY = BELOW, |
35 | NOT_CARRY = ABOVE_EQUAL, |
36 | |
37 | // Platform-independent variants declared for all platforms |
38 | // EQUAL, |
39 | // NOT_EQUAL, |
40 | // LESS, |
41 | // LESS_EQUAL, |
42 | // GREATER_EQUAL, |
43 | // GREATER, |
44 | UNSIGNED_LESS = BELOW, |
45 | UNSIGNED_LESS_EQUAL = BELOW_EQUAL, |
46 | UNSIGNED_GREATER = ABOVE, |
47 | UNSIGNED_GREATER_EQUAL = ABOVE_EQUAL, |
48 | |
49 | kInvalidCondition = 16 |
50 | }; |
51 | |
52 | static inline Condition InvertCondition(Condition c) { |
53 | COMPILE_ASSERT((OVERFLOW ^ NO_OVERFLOW) == 1); |
54 | COMPILE_ASSERT((BELOW ^ ABOVE_EQUAL) == 1); |
55 | COMPILE_ASSERT((EQUAL ^ NOT_EQUAL) == 1); |
56 | COMPILE_ASSERT((BELOW_EQUAL ^ ABOVE) == 1); |
57 | COMPILE_ASSERT((SIGN ^ NOT_SIGN) == 1); |
58 | COMPILE_ASSERT((PARITY_EVEN ^ PARITY_ODD) == 1); |
59 | COMPILE_ASSERT((LESS ^ GREATER_EQUAL) == 1); |
60 | COMPILE_ASSERT((LESS_EQUAL ^ GREATER) == 1); |
61 | ASSERT(c != kInvalidCondition); |
62 | return static_cast<Condition>(c ^ 1); |
63 | } |
64 | |
65 | #define X86_ZERO_OPERAND_1_BYTE_INSTRUCTIONS(F) \ |
66 | F(ret, 0xC3) \ |
67 | F(leave, 0xC9) \ |
68 | F(hlt, 0xF4) \ |
69 | F(cld, 0xFC) \ |
70 | F(int3, 0xCC) \ |
71 | F(pushad, 0x60) \ |
72 | F(popad, 0x61) \ |
73 | F(pushfd, 0x9C) \ |
74 | F(popfd, 0x9D) \ |
75 | F(sahf, 0x9E) \ |
76 | F(cdq, 0x99) \ |
77 | F(fwait, 0x9B) \ |
78 | F(movsb, 0xA4) \ |
79 | F(movs, 0xA5) /* Size suffix added in code */ \ |
80 | F(cmpsb, 0xA6) \ |
81 | F(cmps, 0xA7) /* Size suffix added in code */ |
82 | |
83 | // clang-format off |
84 | #define X86_ALU_CODES(F) \ |
85 | F(and, 4) \ |
86 | F(or, 1) \ |
87 | F(xor, 6) \ |
88 | F(add, 0) \ |
89 | F(adc, 2) \ |
90 | F(sub, 5) \ |
91 | F(sbb, 3) \ |
92 | F(cmp, 7) |
93 | |
94 | #define XMM_ALU_CODES(F) \ |
95 | F(bad0, 0) \ |
96 | F(sqrt, 1) \ |
97 | F(rsqrt, 2) \ |
98 | F(rcp, 3) \ |
99 | F(and, 4) \ |
100 | F(bad1, 5) \ |
101 | F(or, 6) \ |
102 | F(xor, 7) \ |
103 | F(add, 8) \ |
104 | F(mul, 9) \ |
105 | F(bad2, 0xA) \ |
106 | F(bad3, 0xB) \ |
107 | F(sub, 0xC) \ |
108 | F(min, 0xD) \ |
109 | F(div, 0xE) \ |
110 | F(max, 0xF) |
111 | // clang-format on |
112 | |
113 | // Table 3-1, first part |
114 | #define XMM_CONDITIONAL_CODES(F) \ |
115 | F(eq, 0) \ |
116 | F(lt, 1) \ |
117 | F(le, 2) \ |
118 | F(unord, 3) \ |
119 | F(neq, 4) \ |
120 | F(nlt, 5) \ |
121 | F(nle, 6) \ |
122 | F(ord, 7) |
123 | |
124 | #define X86_CONDITIONAL_SUFFIXES(F) \ |
125 | F(o, OVERFLOW) \ |
126 | F(no, NO_OVERFLOW) \ |
127 | F(c, CARRY) \ |
128 | F(nc, NOT_CARRY) \ |
129 | F(z, ZERO) \ |
130 | F(nz, NOT_ZERO) \ |
131 | F(na, BELOW_EQUAL) \ |
132 | F(a, ABOVE) \ |
133 | F(s, SIGN) \ |
134 | F(ns, NOT_SIGN) \ |
135 | F(pe, PARITY_EVEN) \ |
136 | F(po, PARITY_ODD) \ |
137 | F(l, LESS) \ |
138 | F(ge, GREATER_EQUAL) \ |
139 | F(le, LESS_EQUAL) \ |
140 | F(g, GREATER) \ |
141 | /* Some alternative names */ \ |
142 | F(e, EQUAL) \ |
143 | F(ne, NOT_EQUAL) |
144 | |
145 | } // namespace dart |
146 | |
147 | #endif // RUNTIME_VM_CONSTANTS_X86_H_ |
148 | |