blob: 65c34d2df68b31ec35021f320b638ec3e07619de [file] [log] [blame]
buzbeecbd6d442012-11-17 14:11:25 -08001/*
2 * Copyright (C) 2012 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_SRC_COMPILER_COMPILERENUMS_H_
18#define ART_SRC_COMPILER_COMPILERENUMS_H_
19
20#include "dex_instruction.h"
21
22namespace art {
23
24enum RegisterClass {
25 kCoreReg,
26 kFPReg,
27 kAnyReg,
28};
29
30enum SpecialTargetRegister {
31 kSelf, // Thread
32 kSuspend, // Used to reduce suspend checks
33 kLr,
34 kPc,
35 kSp,
36 kArg0,
37 kArg1,
38 kArg2,
39 kArg3,
40 kFArg0,
41 kFArg1,
42 kFArg2,
43 kFArg3,
44 kRet0,
45 kRet1,
46 kInvokeTgt,
47 kCount
48};
49
50enum RegLocationType {
51 kLocDalvikFrame = 0, // Normal Dalvik register
52 kLocPhysReg,
53 kLocCompilerTemp,
54 kLocInvalid
55};
56
57enum BBType {
58 kEntryBlock,
59 kDalvikByteCode,
60 kExitBlock,
61 kExceptionHandling,
62 kDead,
63};
64
65/*
buzbeefa57c472012-11-21 12:06:18 -080066 * Def/Use encoding in 64-bit use_mask/def_mask. Low positions used for target-specific
buzbeecbd6d442012-11-17 14:11:25 -080067 * registers (and typically use the register number as the position). High positions
68 * reserved for common and abstract resources.
69 */
70
71enum ResourceEncodingPos {
72 kMustNotAlias = 63,
73 kHeapRef = 62, // Default memory reference type
74 kLiteral = 61, // Literal pool memory reference
buzbeefa57c472012-11-21 12:06:18 -080075 kDalvikReg = 60, // Dalvik v_reg memory reference
buzbeecbd6d442012-11-17 14:11:25 -080076 kFPStatus = 59,
77 kCCode = 58,
78 kLowestCommonResource = kCCode
79};
80
81/* Shared pseudo opcodes - must be < 0 */
82enum LIRPseudoOpcode {
83 kPseudoExportedPC = -18,
84 kPseudoSafepointPC = -17,
85 kPseudoIntrinsicRetry = -16,
86 kPseudoSuspendTarget = -15,
87 kPseudoThrowTarget = -14,
88 kPseudoCaseLabel = -13,
89 kPseudoMethodEntry = -12,
90 kPseudoMethodExit = -11,
91 kPseudoBarrier = -10,
92 kPseudoExtended = -9,
93 kPseudoSSARep = -8,
94 kPseudoEntryBlock = -7,
95 kPseudoExitBlock = -6,
96 kPseudoTargetLabel = -5,
97 kPseudoDalvikByteCodeBoundary = -4,
98 kPseudoPseudoAlign4 = -3,
99 kPseudoEHBlockLabel = -2,
100 kPseudoNormalBlockLabel = -1,
101};
102
103enum ExtendedMIROpcode {
104 kMirOpFirst = kNumPackedOpcodes,
105 kMirOpPhi = kMirOpFirst,
106 kMirOpCopy,
107 kMirOpFusedCmplFloat,
108 kMirOpFusedCmpgFloat,
109 kMirOpFusedCmplDouble,
110 kMirOpFusedCmpgDouble,
111 kMirOpFusedCmpLong,
112 kMirOpNop,
113 kMirOpNullCheck,
114 kMirOpRangeCheck,
115 kMirOpDivZeroCheck,
116 kMirOpCheck,
117 kMirOpLast,
118};
119
120enum MIROptimizationFlagPositons {
121 kMIRIgnoreNullCheck = 0,
122 kMIRNullCheckOnly,
123 kMIRIgnoreRangeCheck,
124 kMIRRangeCheckOnly,
125 kMIRInlined, // Invoke is inlined (ie dead)
126 kMIRInlinedPred, // Invoke is inlined via prediction
127 kMIRCallee, // Instruction is inlined from callee
128 kMIRIgnoreSuspendCheck,
129 kMIRDup,
130 kMIRMark, // Temporary node mark
131};
132
buzbeefa57c472012-11-21 12:06:18 -0800133/* For successor_block_list */
buzbeecbd6d442012-11-17 14:11:25 -0800134enum BlockListType {
135 kNotUsed = 0,
136 kCatch,
137 kPackedSwitch,
138 kSparseSwitch,
139};
140
141enum AssemblerStatus {
142 kSuccess,
143 kRetryAll,
144};
145
146enum OpSize {
147 kWord,
148 kLong,
149 kSingle,
150 kDouble,
151 kUnsignedHalf,
152 kSignedHalf,
153 kUnsignedByte,
154 kSignedByte,
155};
156
157std::ostream& operator<<(std::ostream& os, const OpSize& kind);
158
159enum OpKind {
160 kOpMov,
161 kOpMvn,
162 kOpCmp,
163 kOpLsl,
164 kOpLsr,
165 kOpAsr,
166 kOpRor,
167 kOpNot,
168 kOpAnd,
169 kOpOr,
170 kOpXor,
171 kOpNeg,
172 kOpAdd,
173 kOpAdc,
174 kOpSub,
175 kOpSbc,
176 kOpRsub,
177 kOpMul,
178 kOpDiv,
179 kOpRem,
180 kOpBic,
181 kOpCmn,
182 kOpTst,
183 kOpBkpt,
184 kOpBlx,
185 kOpPush,
186 kOpPop,
187 kOp2Char,
188 kOp2Short,
189 kOp2Byte,
190 kOpCondBr,
191 kOpUncondBr,
192 kOpBx,
193 kOpInvalid,
194};
195
196std::ostream& operator<<(std::ostream& os, const OpKind& kind);
197
198enum ConditionCode {
199 kCondEq, // equal
200 kCondNe, // not equal
201 kCondCs, // carry set (unsigned less than)
202 kCondUlt = kCondCs,
203 kCondCc, // carry clear (unsigned greater than or same)
204 kCondUge = kCondCc,
205 kCondMi, // minus
206 kCondPl, // plus, positive or zero
207 kCondVs, // overflow
208 kCondVc, // no overflow
209 kCondHi, // unsigned greater than
210 kCondLs, // unsigned lower or same
211 kCondGe, // signed greater than or equal
212 kCondLt, // signed less than
213 kCondGt, // signed greater than
214 kCondLe, // signed less than or equal
215 kCondAl, // always
216 kCondNv, // never
217};
218
219std::ostream& operator<<(std::ostream& os, const ConditionCode& kind);
220
221// Target specific condition encodings
222enum ArmConditionCode {
223 kArmCondEq = 0x0, // 0000
224 kArmCondNe = 0x1, // 0001
225 kArmCondCs = 0x2, // 0010
226 kArmCondCc = 0x3, // 0011
227 kArmCondMi = 0x4, // 0100
228 kArmCondPl = 0x5, // 0101
229 kArmCondVs = 0x6, // 0110
230 kArmCondVc = 0x7, // 0111
231 kArmCondHi = 0x8, // 1000
232 kArmCondLs = 0x9, // 1001
233 kArmCondGe = 0xa, // 1010
234 kArmCondLt = 0xb, // 1011
235 kArmCondGt = 0xc, // 1100
236 kArmCondLe = 0xd, // 1101
237 kArmCondAl = 0xe, // 1110
238 kArmCondNv = 0xf, // 1111
239};
240
241std::ostream& operator<<(std::ostream& os, const ArmConditionCode& kind);
242
243enum X86ConditionCode {
244 kX86CondO = 0x0, // overflow
245 kX86CondNo = 0x1, // not overflow
246
247 kX86CondB = 0x2, // below
248 kX86CondNae = kX86CondB, // not-above-equal
249 kX86CondC = kX86CondB, // carry
250
251 kX86CondNb = 0x3, // not-below
252 kX86CondAe = kX86CondNb, // above-equal
253 kX86CondNc = kX86CondNb, // not-carry
254
255 kX86CondZ = 0x4, // zero
256 kX86CondEq = kX86CondZ, // equal
257
258 kX86CondNz = 0x5, // not-zero
259 kX86CondNe = kX86CondNz, // not-equal
260
261 kX86CondBe = 0x6, // below-equal
262 kX86CondNa = kX86CondBe, // not-above
263
264 kX86CondNbe = 0x7, // not-below-equal
265 kX86CondA = kX86CondNbe,// above
266
267 kX86CondS = 0x8, // sign
268 kX86CondNs = 0x9, // not-sign
269
270 kX86CondP = 0xa, // 8-bit parity even
271 kX86CondPE = kX86CondP,
272
273 kX86CondNp = 0xb, // 8-bit parity odd
274 kX86CondPo = kX86CondNp,
275
276 kX86CondL = 0xc, // less-than
277 kX86CondNge = kX86CondL, // not-greater-equal
278
279 kX86CondNl = 0xd, // not-less-than
280 kX86CondGe = kX86CondNl, // not-greater-equal
281
282 kX86CondLe = 0xe, // less-than-equal
283 kX86CondNg = kX86CondLe, // not-greater
284
285 kX86CondNle = 0xf, // not-less-than
286 kX86CondG = kX86CondNle,// greater
287};
288
289std::ostream& operator<<(std::ostream& os, const X86ConditionCode& kind);
290
291enum ThrowKind {
292 kThrowNullPointer,
293 kThrowDivZero,
294 kThrowArrayBounds,
295 kThrowNoSuchMethod,
296 kThrowStackOverflow,
297};
298
299enum SpecialCaseHandler {
300 kNoHandler,
301 kNullMethod,
302 kConstFunction,
303 kIGet,
304 kIGetBoolean,
305 kIGetObject,
306 kIGetByte,
307 kIGetChar,
308 kIGetShort,
309 kIGetWide,
310 kIPut,
311 kIPutBoolean,
312 kIPutObject,
313 kIPutByte,
314 kIPutChar,
315 kIPutShort,
316 kIPutWide,
317 kIdentity,
318};
319
320enum DividePattern {
321 DivideNone,
322 Divide3,
323 Divide5,
324 Divide7,
325};
326
327std::ostream& operator<<(std::ostream& os, const DividePattern& pattern);
328
329/* Customized node traversal orders for different needs */
330enum DataFlowAnalysisMode {
331 kAllNodes = 0, // All nodes
332 kReachableNodes, // All reachable nodes
333 kPreOrderDFSTraversal, // Depth-First-Search / Pre-Order
334 kPostOrderDFSTraversal, // Depth-First-Search / Post-Order
335 kPostOrderDOMTraversal, // Dominator tree / Post-Order
336 kReversePostOrderTraversal, // Depth-First-Search / reverse Post-Order
337};
338
339std::ostream& operator<<(std::ostream& os, const DataFlowAnalysisMode& mode);
340
buzbee1bc37c62012-11-20 13:35:41 -0800341// Memory barrier types (see "The JSR-133 Cookbook for Compiler Writers")
342enum MemBarrierKind {
343 kLoadStore,
344 kLoadLoad,
345 kStoreStore,
346 kStoreLoad
347};
348
349std::ostream& operator<<(std::ostream& os, const MemBarrierKind& kind);
350
buzbeecbd6d442012-11-17 14:11:25 -0800351} // namespace art
352
353#endif // ART_SRC_COMPILER_COMPILERENUMS_H_