blob: b8e5801651e54981238287e21ff68b58a459ced8 [file] [log] [blame]
buzbeee3acd072012-02-25 17:03:10 -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_COMPILER_COMPILER_CODEGEN_MIPS_MIPSLIR_H_
18#define ART_COMPILER_COMPILER_CODEGEN_MIPS_MIPSLIR_H_
19
20#include "../../Dalvik.h"
21#include "../../CompilerInternals.h"
22
23namespace art {
24
buzbeee3acd072012-02-25 17:03:10 -080025/*
26 * Runtime register conventions.
27 *
28 * zero is always the value 0
29 * at is scratch (normally used as temp reg by assembler)
30 * v0, v1 are scratch (normally hold subroutine return values)
31 * a0-a3 are scratch (normally hold subroutine arguments)
32 * t0-t8 are scratch
33 * t9 is scratch (normally used for function calls)
34 * s0 (rSUSPEND) is reserved [holds suspend-check counter]
35 * s1 (rSELF) is reserved [holds current &Thread]
36 * s2-s7 are callee save (promotion target)
37 * k0, k1 are reserved for use by interrupt handlers
38 * gp is reserved for global pointer
39 * sp is reserved
40 * s8 is callee save (promotion target)
41 * ra is scratch (normally holds the return addr)
42 *
43 * Preserved across C calls: s0-s8
44 * Trashed across C calls: at, v0-v1, a0-a3, t0-t9, gp, ra
45 *
46 * Floating pointer registers
47 * NOTE: there are 32 fp registers (16 df pairs), but currently
48 * only support 16 fp registers (8 df pairs).
49 * f0-f15
50 * df0-df7, where df0={f0,f1}, df1={f2,f3}, ... , df7={f14,f15}
51 *
52 * f0-f15 (df0-df7) trashed across C calls
53 *
54 * For mips32 code use:
55 * a0-a3 to hold operands
56 * v0-v1 to hold results
57 * t0-t9 for temps
58 *
59 * All jump/branch instructions have a delay slot after it.
60 *
61 * Stack frame diagram (stack grows down, higher addresses at top):
62 *
63 * +------------------------+
64 * | IN[ins-1] | {Note: resides in caller's frame}
65 * | . |
66 * | IN[0] |
67 * | caller's Method* |
68 * +========================+ {Note: start of callee's frame}
69 * | spill region | {variable sized - will include lr if non-leaf.}
70 * +------------------------+
71 * | ...filler word... | {Note: used as 2nd word of V[locals-1] if long]
72 * +------------------------+
73 * | V[locals-1] |
74 * | V[locals-2] |
75 * | . |
76 * | . |
77 * | V[1] |
78 * | V[0] |
79 * +------------------------+
80 * | 0 to 3 words padding |
81 * +------------------------+
82 * | OUT[outs-1] |
83 * | OUT[outs-2] |
84 * | . |
85 * | OUT[0] |
86 * | curMethod* | <<== sp w/ 16-byte alignment
87 * +========================+
88 */
89
90/* Offset to distingish FP regs */
91#define FP_REG_OFFSET 32
92/* Offset to distinguish DP FP regs */
93#define FP_DOUBLE 64
94/* Offset to distingish the extra regs */
95#define EXTRA_REG_OFFSET 128
96/* Reg types */
97#define REGTYPE(x) (x & (FP_REG_OFFSET | FP_DOUBLE))
98#define FPREG(x) ((x & FP_REG_OFFSET) == FP_REG_OFFSET)
99#define EXTRAREG(x) ((x & EXTRA_REG_OFFSET) == EXTRA_REG_OFFSET)
100#define LOWREG(x) ((x & 0x1f) == x)
101#define DOUBLEREG(x) ((x & FP_DOUBLE) == FP_DOUBLE)
102#define SINGLEREG(x) (FPREG(x) && !DOUBLEREG(x))
103/*
104 * Note: the low register of a floating point pair is sufficient to
105 * create the name of a double, but require both names to be passed to
106 * allow for asserts to verify that the pair is consecutive if significant
107 * rework is done in this area. Also, it is a good reminder in the calling
108 * code that reg locations always describe doubles as a pair of singles.
109 */
110#define S2D(x,y) ((x) | FP_DOUBLE)
111/* Mask to strip off fp flags */
112#define FP_REG_MASK (FP_REG_OFFSET-1)
113/* non-existent Dalvik register */
114#define vNone (-1)
115/* non-existant physical register */
116#define rNone (-1)
117
118#ifdef HAVE_LITTLE_ENDIAN
119#define LOWORD_OFFSET 0
120#define HIWORD_OFFSET 4
121#define r_ARG0 r_A0
122#define r_ARG1 r_A1
123#define r_ARG2 r_A2
124#define r_ARG3 r_A3
125#define r_RESULT0 r_V0
126#define r_RESULT1 r_V1
127#else
128#define LOWORD_OFFSET 4
129#define HIWORD_OFFSET 0
130#define r_ARG0 r_A1
131#define r_ARG1 r_A0
132#define r_ARG2 r_A3
133#define r_ARG3 r_A2
134#define r_RESULT0 r_V1
135#define r_RESULT1 r_V0
136#endif
137
138/* These are the same for both big and little endian. */
139#define r_FARG0 r_F12
140#define r_FARG1 r_F13
jeffhaofc6a30e2012-10-18 18:24:15 -0700141#define r_FARG2 r_F14
142#define r_FARG3 r_F15
buzbeee3acd072012-02-25 17:03:10 -0800143#define r_FRESULT0 r_F0
144#define r_FRESULT1 r_F1
145
buzbeeb046e162012-10-30 15:48:42 -0700146/* Regs not used for Mips */
147#define rLR INVALID_REG
148
buzbeee3acd072012-02-25 17:03:10 -0800149/* RegisterLocation templates return values (r_V0, or r_V0/r_V1) */
buzbee2cfc6392012-05-07 14:51:40 -0700150#define LOC_C_RETURN {kLocPhysReg, 0, 0, 0, 0, 0, 0, 0, 1, r_V0, INVALID_REG, \
151 INVALID_SREG, INVALID_SREG}
jeffhao4f8f04a2012-10-02 18:10:35 -0700152#define LOC_C_RETURN_FLOAT {kLocPhysReg, 0, 0, 0, 0, 0, 0, 0, 1, r_FRESULT0, \
153 INVALID_REG, INVALID_SREG, INVALID_SREG}
buzbee2cfc6392012-05-07 14:51:40 -0700154#define LOC_C_RETURN_WIDE {kLocPhysReg, 1, 0, 0, 0, 0, 0, 0, 1, r_RESULT0, \
155 r_RESULT1, INVALID_SREG, INVALID_SREG}
jeffhao4f8f04a2012-10-02 18:10:35 -0700156#define LOC_C_RETURN_WIDE_DOUBLE {kLocPhysReg, 1, 0, 0, 0, 0, 0, 0, 1, r_FRESULT0,\
157 r_FRESULT1, INVALID_SREG, INVALID_SREG}
buzbeee3acd072012-02-25 17:03:10 -0800158
buzbee07131ca2012-11-07 16:13:14 -0800159enum MipsResourceEncodingPos {
160 kMipsGPReg0 = 0,
161 kMipsRegSP = 29,
162 kMipsRegLR = 31,
163 kMipsFPReg0 = 32, /* only 16 fp regs supported currently */
164 kMipsFPRegEnd = 48,
165 kMipsRegHI = kMipsFPRegEnd,
166 kMipsRegLO,
167 kMipsRegPC,
168 kMipsRegEnd = 51,
Elliott Hughes719ace42012-03-09 18:06:03 -0800169};
buzbeee3acd072012-02-25 17:03:10 -0800170
buzbee07131ca2012-11-07 16:13:14 -0800171#define ENCODE_MIPS_REG_LIST(N) ((u8) N)
172#define ENCODE_MIPS_REG_SP (1ULL << kMipsRegSP)
173#define ENCODE_MIPS_REG_LR (1ULL << kMipsRegLR)
174#define ENCODE_MIPS_REG_PC (1ULL << kMipsRegPC)
buzbeee3acd072012-02-25 17:03:10 -0800175
buzbeee3acd072012-02-25 17:03:10 -0800176/*
buzbeee3acd072012-02-25 17:03:10 -0800177 * Annotate special-purpose core registers:
178 */
179
Elliott Hughes719ace42012-03-09 18:06:03 -0800180enum NativeRegisterPool {
Bill Buzbeea114add2012-05-03 15:00:40 -0700181 r_ZERO = 0,
182 r_AT = 1,
183 r_V0 = 2,
184 r_V1 = 3,
185 r_A0 = 4,
186 r_A1 = 5,
187 r_A2 = 6,
188 r_A3 = 7,
189 r_T0 = 8,
190 r_T1 = 9,
191 r_T2 = 10,
192 r_T3 = 11,
193 r_T4 = 12,
194 r_T5 = 13,
195 r_T6 = 14,
196 r_T7 = 15,
197 r_S0 = 16,
198 r_S1 = 17,
199 r_S2 = 18,
200 r_S3 = 19,
201 r_S4 = 20,
202 r_S5 = 21,
203 r_S6 = 22,
204 r_S7 = 23,
205 r_T8 = 24,
206 r_T9 = 25,
207 r_K0 = 26,
208 r_K1 = 27,
209 r_GP = 28,
210 r_SP = 29,
211 r_FP = 30,
212 r_RA = 31,
buzbeee3acd072012-02-25 17:03:10 -0800213
Bill Buzbeea114add2012-05-03 15:00:40 -0700214 r_F0 = 0 + FP_REG_OFFSET,
215 r_F1,
216 r_F2,
217 r_F3,
218 r_F4,
219 r_F5,
220 r_F6,
221 r_F7,
222 r_F8,
223 r_F9,
224 r_F10,
225 r_F11,
226 r_F12,
227 r_F13,
228 r_F14,
229 r_F15,
buzbeee3acd072012-02-25 17:03:10 -0800230#if 0 /* only 16 fp regs supported currently */
Bill Buzbeea114add2012-05-03 15:00:40 -0700231 r_F16,
232 r_F17,
233 r_F18,
234 r_F19,
235 r_F20,
236 r_F21,
237 r_F22,
238 r_F23,
239 r_F24,
240 r_F25,
241 r_F26,
242 r_F27,
243 r_F28,
244 r_F29,
245 r_F30,
246 r_F31,
buzbeee3acd072012-02-25 17:03:10 -0800247#endif
Bill Buzbeea114add2012-05-03 15:00:40 -0700248 r_DF0 = r_F0 + FP_DOUBLE,
249 r_DF1 = r_F2 + FP_DOUBLE,
250 r_DF2 = r_F4 + FP_DOUBLE,
251 r_DF3 = r_F6 + FP_DOUBLE,
252 r_DF4 = r_F8 + FP_DOUBLE,
253 r_DF5 = r_F10 + FP_DOUBLE,
254 r_DF6 = r_F12 + FP_DOUBLE,
255 r_DF7 = r_F14 + FP_DOUBLE,
buzbeee3acd072012-02-25 17:03:10 -0800256#if 0 /* only 16 fp regs supported currently */
Bill Buzbeea114add2012-05-03 15:00:40 -0700257 r_DF8 = r_F16 + FP_DOUBLE,
258 r_DF9 = r_F18 + FP_DOUBLE,
259 r_DF10 = r_F20 + FP_DOUBLE,
260 r_DF11 = r_F22 + FP_DOUBLE,
261 r_DF12 = r_F24 + FP_DOUBLE,
262 r_DF13 = r_F26 + FP_DOUBLE,
263 r_DF14 = r_F28 + FP_DOUBLE,
264 r_DF15 = r_F30 + FP_DOUBLE,
buzbeee3acd072012-02-25 17:03:10 -0800265#endif
Bill Buzbeea114add2012-05-03 15:00:40 -0700266 r_HI = EXTRA_REG_OFFSET,
267 r_LO,
268 r_PC,
Elliott Hughes719ace42012-03-09 18:06:03 -0800269};
buzbeee3acd072012-02-25 17:03:10 -0800270
buzbee5de34942012-03-01 14:51:57 -0800271/*
272 * Target-independent aliases
273 */
274
275#define rSUSPEND r_S0
276#define rSELF r_S1
277#define rSP r_SP
278#define rARG0 r_ARG0
279#define rARG1 r_ARG1
280#define rARG2 r_ARG2
281#define rARG3 r_ARG3
jeffhao30a33172012-10-22 18:16:22 -0700282#define rFARG0 r_FARG0
283#define rFARG1 r_FARG1
284#define rFARG2 r_FARG2
285#define rFARG3 r_FARG3
buzbee5de34942012-03-01 14:51:57 -0800286#define rRET0 r_RESULT0
287#define rRET1 r_RESULT1
jeffhaofa147e22012-10-12 17:03:32 -0700288#define rINVOKE_TGT r_T9
buzbeeb046e162012-10-30 15:48:42 -0700289#define rCOUNT INVALID_REG
buzbee5de34942012-03-01 14:51:57 -0800290
buzbeee3acd072012-02-25 17:03:10 -0800291/* Shift encodings */
Elliott Hughes719ace42012-03-09 18:06:03 -0800292enum MipsShiftEncodings {
Bill Buzbeea114add2012-05-03 15:00:40 -0700293 kMipsLsl = 0x0,
294 kMipsLsr = 0x1,
295 kMipsAsr = 0x2,
296 kMipsRor = 0x3
Elliott Hughes719ace42012-03-09 18:06:03 -0800297};
buzbeee3acd072012-02-25 17:03:10 -0800298
buzbeea2ebdd72012-03-04 14:57:06 -0800299// MIPS sync kinds (Note: support for kinds other than kSYNC0 may not exist)
300#define kSYNC0 0x00
301#define kSYNC_WMB 0x04
302#define kSYNC_MB 0x01
303#define kSYNC_ACQUIRE 0x11
304#define kSYNC_RELEASE 0x12
305#define kSYNC_RMB 0x13
306
307// TODO: Use smaller hammer when appropriate for target CPU
308#define kST kSYNC0
309#define kSY kSYNC0
buzbeee3acd072012-02-25 17:03:10 -0800310
buzbee31a4a6f2012-02-28 15:36:15 -0800311#define isPseudoOpcode(opCode) ((int)(opCode) < 0)
buzbeee3acd072012-02-25 17:03:10 -0800312
313/*
314 * The following enum defines the list of supported Thumb instructions by the
Ian Rogersde797832012-03-06 10:18:10 -0800315 * assembler. Their corresponding EncodingMap positions will be defined in
316 * Assemble.cc.
buzbeee3acd072012-02-25 17:03:10 -0800317 */
Elliott Hughes719ace42012-03-09 18:06:03 -0800318enum MipsOpCode {
buzbeeb046e162012-10-30 15:48:42 -0700319 kMipsFirst = 0,
Bill Buzbeea114add2012-05-03 15:00:40 -0700320 kMips32BitData = kMipsFirst, /* data [31..0] */
321 kMipsAddiu, /* addiu t,s,imm16 [001001] s[25..21] t[20..16] imm16[15..0] */
322 kMipsAddu, /* add d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100001] */
323 kMipsAnd, /* and d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100100] */
324 kMipsAndi, /* andi t,s,imm16 [001100] s[25..21] t[20..16] imm16[15..0] */
325 kMipsB, /* b o [0001000000000000] o[15..0] */
326 kMipsBal, /* bal o [0000010000010001] o[15..0] */
327 /* NOTE: the code tests the range kMipsBeq thru kMipsBne, so
328 adding an instruction in this range may require updates */
329 kMipsBeq, /* beq s,t,o [000100] s[25..21] t[20..16] o[15..0] */
330 kMipsBeqz, /* beqz s,o [000100] s[25..21] [00000] o[15..0] */
331 kMipsBgez, /* bgez s,o [000001] s[25..21] [00001] o[15..0] */
332 kMipsBgtz, /* bgtz s,o [000111] s[25..21] [00000] o[15..0] */
333 kMipsBlez, /* blez s,o [000110] s[25..21] [00000] o[15..0] */
334 kMipsBltz, /* bltz s,o [000001] s[25..21] [00000] o[15..0] */
335 kMipsBnez, /* bnez s,o [000101] s[25..21] [00000] o[15..0] */
336 kMipsBne, /* bne s,t,o [000101] s[25..21] t[20..16] o[15..0] */
337 kMipsDiv, /* div s,t [000000] s[25..21] t[20..16] [0000000000011010] */
buzbeee3acd072012-02-25 17:03:10 -0800338#if __mips_isa_rev>=2
Bill Buzbeea114add2012-05-03 15:00:40 -0700339 kMipsExt, /* ext t,s,p,z [011111] s[25..21] t[20..16] z[15..11] p[10..6] [000000] */
buzbeee3acd072012-02-25 17:03:10 -0800340#endif
Bill Buzbeea114add2012-05-03 15:00:40 -0700341 kMipsJal, /* jal t [000011] t[25..0] */
342 kMipsJalr, /* jalr d,s [000000] s[25..21] [00000] d[15..11]
343 hint[10..6] [001001] */
344 kMipsJr, /* jr s [000000] s[25..21] [0000000000] hint[10..6] [001000] */
345 kMipsLahi, /* lui t,imm16 [00111100000] t[20..16] imm16[15..0] load addr hi */
346 kMipsLalo, /* ori t,s,imm16 [001001] s[25..21] t[20..16] imm16[15..0] load addr lo */
347 kMipsLui, /* lui t,imm16 [00111100000] t[20..16] imm16[15..0] */
348 kMipsLb, /* lb t,o(b) [100000] b[25..21] t[20..16] o[15..0] */
349 kMipsLbu, /* lbu t,o(b) [100100] b[25..21] t[20..16] o[15..0] */
350 kMipsLh, /* lh t,o(b) [100001] b[25..21] t[20..16] o[15..0] */
351 kMipsLhu, /* lhu t,o(b) [100101] b[25..21] t[20..16] o[15..0] */
352 kMipsLw, /* lw t,o(b) [100011] b[25..21] t[20..16] o[15..0] */
353 kMipsMfhi, /* mfhi d [0000000000000000] d[15..11] [00000010000] */
354 kMipsMflo, /* mflo d [0000000000000000] d[15..11] [00000010010] */
355 kMipsMove, /* move d,s [000000] s[25..21] [00000] d[15..11] [00000100101] */
356 kMipsMovz, /* movz d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000001010] */
357 kMipsMul, /* mul d,s,t [011100] s[25..21] t[20..16] d[15..11] [00000000010] */
358 kMipsNop, /* nop [00000000000000000000000000000000] */
359 kMipsNor, /* nor d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100111] */
360 kMipsOr, /* or d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100101] */
361 kMipsOri, /* ori t,s,imm16 [001001] s[25..21] t[20..16] imm16[15..0] */
362 kMipsPref, /* pref h,o(b) [101011] b[25..21] h[20..16] o[15..0] */
363 kMipsSb, /* sb t,o(b) [101000] b[25..21] t[20..16] o[15..0] */
buzbeee3acd072012-02-25 17:03:10 -0800364#if __mips_isa_rev>=2
Bill Buzbeea114add2012-05-03 15:00:40 -0700365 kMipsSeb, /* seb d,t [01111100000] t[20..16] d[15..11] [10000100000] */
366 kMipsSeh, /* seh d,t [01111100000] t[20..16] d[15..11] [11000100000] */
buzbeee3acd072012-02-25 17:03:10 -0800367#endif
Bill Buzbeea114add2012-05-03 15:00:40 -0700368 kMipsSh, /* sh t,o(b) [101001] b[25..21] t[20..16] o[15..0] */
369 kMipsSll, /* sll d,t,a [00000000000] t[20..16] d[15..11] a[10..6] [000000] */
370 kMipsSllv, /* sllv d,t,s [000000] s[25..21] t[20..16] d[15..11] [00000000100] */
371 kMipsSlt, /* slt d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000101010] */
372 kMipsSlti, /* slti t,s,imm16 [001010] s[25..21] t[20..16] imm16[15..0] */
373 kMipsSltu, /* sltu d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000101011] */
374 kMipsSra, /* sra d,s,imm5 [00000000000] t[20..16] d[15..11] imm5[10..6] [000011] */
375 kMipsSrav, /* srav d,t,s [000000] s[25..21] t[20..16] d[15..11] [00000000111] */
376 kMipsSrl, /* srl d,t,a [00000000000] t[20..16] d[20..16] a[10..6] [000010] */
377 kMipsSrlv, /* srlv d,t,s [000000] s[25..21] t[20..16] d[15..11] [00000000110] */
378 kMipsSubu, /* subu d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100011] */
379 kMipsSw, /* sw t,o(b) [101011] b[25..21] t[20..16] o[15..0] */
380 kMipsXor, /* xor d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100110] */
381 kMipsXori, /* xori t,s,imm16 [001110] s[25..21] t[20..16] imm16[15..0] */
buzbeee3acd072012-02-25 17:03:10 -0800382#ifdef __mips_hard_float
Bill Buzbeea114add2012-05-03 15:00:40 -0700383 kMipsFadds, /* add.s d,s,t [01000110000] t[20..16] s[15..11] d[10..6] [000000] */
384 kMipsFsubs, /* sub.s d,s,t [01000110000] t[20..16] s[15..11] d[10..6] [000001] */
385 kMipsFmuls, /* mul.s d,s,t [01000110000] t[20..16] s[15..11] d[10..6] [000010] */
386 kMipsFdivs, /* div.s d,s,t [01000110000] t[20..16] s[15..11] d[10..6] [000011] */
387 kMipsFaddd, /* add.d d,s,t [01000110001] t[20..16] s[15..11] d[10..6] [000000] */
388 kMipsFsubd, /* sub.d d,s,t [01000110001] t[20..16] s[15..11] d[10..6] [000001] */
389 kMipsFmuld, /* mul.d d,s,t [01000110001] t[20..16] s[15..11] d[10..6] [000010] */
390 kMipsFdivd, /* div.d d,s,t [01000110001] t[20..16] s[15..11] d[10..6] [000011] */
391 kMipsFcvtsd,/* cvt.s.d d,s [01000110001] [00000] s[15..11] d[10..6] [100000] */
392 kMipsFcvtsw,/* cvt.s.w d,s [01000110100] [00000] s[15..11] d[10..6] [100000] */
393 kMipsFcvtds,/* cvt.d.s d,s [01000110000] [00000] s[15..11] d[10..6] [100001] */
394 kMipsFcvtdw,/* cvt.d.w d,s [01000110100] [00000] s[15..11] d[10..6] [100001] */
395 kMipsFcvtws,/* cvt.w.d d,s [01000110000] [00000] s[15..11] d[10..6] [100100] */
396 kMipsFcvtwd,/* cvt.w.d d,s [01000110001] [00000] s[15..11] d[10..6] [100100] */
397 kMipsFmovs, /* mov.s d,s [01000110000] [00000] s[15..11] d[10..6] [000110] */
398 kMipsFmovd, /* mov.d d,s [01000110001] [00000] s[15..11] d[10..6] [000110] */
399 kMipsFlwc1, /* lwc1 t,o(b) [110001] b[25..21] t[20..16] o[15..0] */
400 kMipsFldc1, /* ldc1 t,o(b) [110101] b[25..21] t[20..16] o[15..0] */
401 kMipsFswc1, /* swc1 t,o(b) [111001] b[25..21] t[20..16] o[15..0] */
402 kMipsFsdc1, /* sdc1 t,o(b) [111101] b[25..21] t[20..16] o[15..0] */
403 kMipsMfc1, /* mfc1 t,s [01000100000] t[20..16] s[15..11] [00000000000] */
404 kMipsMtc1, /* mtc1 t,s [01000100100] t[20..16] s[15..11] [00000000000] */
buzbeee3acd072012-02-25 17:03:10 -0800405#endif
Bill Buzbeea114add2012-05-03 15:00:40 -0700406 kMipsDelta, /* Psuedo for ori t, s, <label>-<label> */
407 kMipsDeltaHi, /* Pseudo for lui t, high16(<label>-<label>) */
408 kMipsDeltaLo, /* Pseudo for ori t, s, low16(<label>-<label>) */
409 kMipsCurrPC, /* jal to .+8 to materialize pc */
410 kMipsSync, /* sync kind [000000] [0000000000000000] s[10..6] [001111] */
411 kMipsUndefined, /* undefined [011001xxxxxxxxxxxxxxxx] */
412 kMipsLast
Elliott Hughes719ace42012-03-09 18:06:03 -0800413};
buzbeee3acd072012-02-25 17:03:10 -0800414
415/* Bit flags describing the behavior of each native opcode */
buzbeee3acd072012-02-25 17:03:10 -0800416/* Instruction assembly fieldLoc kind */
Elliott Hughes719ace42012-03-09 18:06:03 -0800417enum MipsEncodingKind {
Bill Buzbeea114add2012-05-03 15:00:40 -0700418 kFmtUnused,
419 kFmtBitBlt, /* Bit string using end/start */
420 kFmtDfp, /* Double FP reg */
421 kFmtSfp, /* Single FP reg */
422 kFmtBlt5_2, /* Same 5-bit field to 2 locations */
Elliott Hughes719ace42012-03-09 18:06:03 -0800423};
buzbeee3acd072012-02-25 17:03:10 -0800424
Ian Rogerscad96062012-03-04 10:33:52 -0800425/* Struct used to define the snippet positions for each MIPS opcode */
Elliott Hughes719ace42012-03-09 18:06:03 -0800426struct MipsEncodingMap {
Bill Buzbeea114add2012-05-03 15:00:40 -0700427 u4 skeleton;
428 struct {
429 MipsEncodingKind kind;
430 int end; /* end for kFmtBitBlt, 1-bit slice end for FP regs */
431 int start; /* start for kFmtBitBlt, 4-bit slice end for FP regs */
432 } fieldLoc[4];
433 MipsOpCode opcode;
buzbee07131ca2012-11-07 16:13:14 -0800434 uint64_t flags;
Bill Buzbeea114add2012-05-03 15:00:40 -0700435 const char *name;
436 const char* fmt;
437 int size; /* Size in bytes */
Elliott Hughes719ace42012-03-09 18:06:03 -0800438};
buzbeee3acd072012-02-25 17:03:10 -0800439
440/* Keys for target-specific scheduling and other optimization hints */
Elliott Hughes719ace42012-03-09 18:06:03 -0800441enum MipsTargetOptHints {
Bill Buzbeea114add2012-05-03 15:00:40 -0700442 kMaxHoistDistance,
Elliott Hughes719ace42012-03-09 18:06:03 -0800443};
buzbeee3acd072012-02-25 17:03:10 -0800444
445extern MipsEncodingMap EncodingMap[kMipsLast];
446
buzbeee3acd072012-02-25 17:03:10 -0800447#define IS_UIMM16(v) ((0 <= (v)) && ((v) <= 65535))
448#define IS_SIMM16(v) ((-32768 <= (v)) && ((v) <= 32766))
449#define IS_SIMM16_2WORD(v) ((-32764 <= (v)) && ((v) <= 32763)) /* 2 offsets must fit */
450
451} // namespace art
452
453#endif // ART_COMPILER_COMPILER_CODEGEN_MIPS_MIPSLIR_H_