blob: 969c37194fe86a9e463e5e9b5c7a415719bb4027 [file] [log] [blame]
buzbee7520ee72010-09-17 16:01:49 -07001/*
2 * Copyright (C) 2010 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#include "Dalvik.h"
18#include "compiler/CompilerInternals.h"
19
20#ifndef _DALVIK_VM_COMPILER_CODEGEN_X86_X86LIR_H
21#define _DALVIK_VM_COMPILER_CODEGEN_X86_X86LIR_H
22
23/*
24 * For both JIT & interpreter:
25 * esi is Dalvik FP
26 * ebp is native FP
27 * esp is native SP
28 *
29 * For interpreter:
30 * edx is Dalvik PC (rPC)
31 * ebx is rINST
32 *
33 * For JIT:
34 * eax, edx, ecx are scratch & caller-save
35 * ebx, edi are scratch & callee-save
36 *
37 * Calling conventions:
38 * 32-bit return in eax
39 * 64-bit return in edx:eax
40 * fp on top of fp stack st(0)
41 * Parameters passed on stack, pushed left to right
42 * On entry to target, first parm is at 4(%esp).
43 * For performance, we'll maintain 16-byte stack alignment
44 *
45 * When transitioning from code cache to interp:
46 * materialize Dalvik PC of target in rPC/%edx
47 * Preload rINST/%ebx such that high 24 bits are zero and
48 * bl contains the non-opcode 8-bits of the 16-bit Dalvik
49 * instruction at (rPC)
50 */
51
52/* Keys for target-specific scheduling and other optimizations here */
53typedef enum X86TargetOptHints {
54 kMaxHoistDistance,
55} X86TargetOptHints;
56
57 /*
58 * Data structure tracking the mapping between a Dalvik register (pair) and a
59 * native register (pair). The idea is to reuse the previously loaded value
60 * if possible, otherwise to keep the value in a native register as long as
61 * possible.
62 */
63typedef struct RegisterInfo {
64 int reg; // Reg number
65 bool inUse; // Has it been allocated?
66 bool pair; // Part of a register pair?
67 int partner; // If pair, other reg of pair
68 bool live; // Is there an associated SSA name?
69 bool dirty; // If live, is it dirty?
70 int sReg; // Name of live value
71 struct LIR *defStart; // Starting inst in last def sequence
72 struct LIR *defEnd; // Ending inst in last def sequence
73} RegisterInfo;
74
75typedef struct RegisterPool {
76 BitVector *nullCheckedRegs; // Track which registers have been null-checked
77 int numCoreTemps;
78 RegisterInfo *coreTemps;
79 int nextCoreTemp;
80 int numFPTemps;
81 RegisterInfo *FPTemps;
82 int nextFPTemp;
83 int numCoreRegs;
84 RegisterInfo *coreRegs;
85 int numFPRegs;
86 RegisterInfo *FPRegs;
87} RegisterPool;
88
89typedef enum OpSize {
90 kWord,
91 kLong,
92 kSingle,
93 kDouble,
94 kUnsignedHalf,
95 kSignedHalf,
96 kUnsignedByte,
97 kSignedByte,
98} OpSize;
99
100typedef enum OpKind {
101 kOpMov,
102 kOpMvn,
103 kOpCmp,
104 kOpLsl,
105 kOpLsr,
106 kOpAsr,
107 kOpRor,
108 kOpNot,
109 kOpAnd,
110 kOpOr,
111 kOpXor,
112 kOpNeg,
113 kOpAdd,
114 kOpAdc,
115 kOpSub,
116 kOpSbc,
117 kOpRsub,
118 kOpMul,
119 kOpDiv,
120 kOpRem,
121 kOpBic,
122 kOpCmn,
123 kOpTst,
124 kOpBkpt,
125 kOpBlx,
126 kOpPush,
127 kOpPop,
128 kOp2Char,
129 kOp2Short,
130 kOp2Byte,
131 kOpCondBr,
132 kOpUncondBr,
133} OpKind;
134
135typedef struct X86LIR {
136 LIR generic;
137 //X86OpCode opCode;
138 int operands[4]; // [0..3] = [dest, src1, src2, extra]
139 bool isNop; // LIR is optimized away
140 bool branchInsertSV;// mark for insertion of branch before this instruction,
141 // used to identify mem ops for self verification mode
142 int age; // default is 0, set lazily by the optimizer
143 int aliasInfo; // For Dalvik register access & litpool disambiguation
144 u8 useMask; // Resource mask for use
145 u8 defMask; // Resource mask for def
146} X86LIR;
147
148/* Utility macros to traverse the LIR/X86LIR list */
149#define NEXT_LIR(lir) ((X86LIR *) lir->generic.next)
150#define PREV_LIR(lir) ((X86LIR *) lir->generic.prev)
151
152#define NEXT_LIR_LVALUE(lir) (lir)->generic.next
153#define PREV_LIR_LVALUE(lir) (lir)->generic.prev
154
155#define CHAIN_CELL_OFFSET_TAG 0xcdab
156
157#define CHAIN_CELL_NORMAL_SIZE 12
158#define CHAIN_CELL_PREDICTED_SIZE 16
159
160#endif /* _DALVIK_VM_COMPILER_CODEGEN_X86_X86LIR_H */