blob: c0fde466c13b5bc5516aa62abff3d5abf1a7d08a [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)
buzbeef0504cd2012-11-13 16:31:10 -080034 * s0 (rMIPS_SUSPEND) is reserved [holds suspend-check counter]
35 * s1 (rMIPS_SELF) is reserved [holds current &Thread]
buzbeee3acd072012-02-25 17:03:10 -080036 * 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 */
buzbeef0504cd2012-11-13 16:31:10 -080091#define MIPS_FP_REG_OFFSET 32
buzbeee3acd072012-02-25 17:03:10 -080092/* Offset to distinguish DP FP regs */
buzbeef0504cd2012-11-13 16:31:10 -080093#define MIPS_FP_DOUBLE 64
buzbeee3acd072012-02-25 17:03:10 -080094/* Offset to distingish the extra regs */
buzbeef0504cd2012-11-13 16:31:10 -080095#define MIPS_EXTRA_REG_OFFSET 128
buzbeee3acd072012-02-25 17:03:10 -080096/* Reg types */
buzbeef0504cd2012-11-13 16:31:10 -080097#define MIPS_REGTYPE(x) (x & (MIPS_FP_REG_OFFSET | MIPS_FP_DOUBLE))
98#define MIPS_FPREG(x) ((x & MIPS_FP_REG_OFFSET) == MIPS_FP_REG_OFFSET)
99#define MIPS_EXTRAREG(x) ((x & MIPS_EXTRA_REG_OFFSET) == MIPS_EXTRA_REG_OFFSET)
100#define MIPS_DOUBLEREG(x) ((x & MIPS_FP_DOUBLE) == MIPS_FP_DOUBLE)
101#define MIPS_SINGLEREG(x) (MIPS_FPREG(x) && !MIPS_DOUBLEREG(x))
buzbeee3acd072012-02-25 17:03:10 -0800102/*
103 * Note: the low register of a floating point pair is sufficient to
104 * create the name of a double, but require both names to be passed to
105 * allow for asserts to verify that the pair is consecutive if significant
106 * rework is done in this area. Also, it is a good reminder in the calling
107 * code that reg locations always describe doubles as a pair of singles.
108 */
buzbeef0504cd2012-11-13 16:31:10 -0800109#define MIPS_S2D(x,y) ((x) | MIPS_FP_DOUBLE)
buzbeee3acd072012-02-25 17:03:10 -0800110/* Mask to strip off fp flags */
buzbeef0504cd2012-11-13 16:31:10 -0800111#define MIPS_FP_REG_MASK (MIPS_FP_REG_OFFSET-1)
buzbeee3acd072012-02-25 17:03:10 -0800112
113#ifdef HAVE_LITTLE_ENDIAN
114#define LOWORD_OFFSET 0
115#define HIWORD_OFFSET 4
116#define r_ARG0 r_A0
117#define r_ARG1 r_A1
118#define r_ARG2 r_A2
119#define r_ARG3 r_A3
120#define r_RESULT0 r_V0
121#define r_RESULT1 r_V1
122#else
123#define LOWORD_OFFSET 4
124#define HIWORD_OFFSET 0
125#define r_ARG0 r_A1
126#define r_ARG1 r_A0
127#define r_ARG2 r_A3
128#define r_ARG3 r_A2
129#define r_RESULT0 r_V1
130#define r_RESULT1 r_V0
131#endif
132
133/* These are the same for both big and little endian. */
134#define r_FARG0 r_F12
135#define r_FARG1 r_F13
jeffhaofc6a30e2012-10-18 18:24:15 -0700136#define r_FARG2 r_F14
137#define r_FARG3 r_F15
buzbeee3acd072012-02-25 17:03:10 -0800138#define r_FRESULT0 r_F0
139#define r_FRESULT1 r_F1
140
buzbeeb046e162012-10-30 15:48:42 -0700141/* Regs not used for Mips */
buzbeef0504cd2012-11-13 16:31:10 -0800142#define rMIPS_LR INVALID_REG
143#define rMIPS_PC INVALID_REG
buzbeeb046e162012-10-30 15:48:42 -0700144
buzbeee3acd072012-02-25 17:03:10 -0800145/* RegisterLocation templates return values (r_V0, or r_V0/r_V1) */
buzbeef0504cd2012-11-13 16:31:10 -0800146#define MIPS_LOC_C_RETURN {kLocPhysReg, 0, 0, 0, 0, 0, 0, 0, 1, r_V0, INVALID_REG, \
147 INVALID_SREG, INVALID_SREG}
148#define MIPS_LOC_C_RETURN_FLOAT {kLocPhysReg, 0, 0, 0, 0, 0, 0, 0, 1, r_FRESULT0, \
149 INVALID_REG, INVALID_SREG, INVALID_SREG}
150#define MIPS_LOC_C_RETURN_WIDE {kLocPhysReg, 1, 0, 0, 0, 0, 0, 0, 1, r_RESULT0, \
151 r_RESULT1, INVALID_SREG, INVALID_SREG}
152#define MIPS_LOC_C_RETURN_DOUBLE {kLocPhysReg, 1, 0, 0, 0, 0, 0, 0, 1, r_FRESULT0,\
jeffhao4f8f04a2012-10-02 18:10:35 -0700153 r_FRESULT1, INVALID_SREG, INVALID_SREG}
buzbeee3acd072012-02-25 17:03:10 -0800154
buzbeeec137432012-11-13 12:13:16 -0800155enum MipsResourceEncodingPos {
156 kMipsGPReg0 = 0,
157 kMipsRegSP = 29,
158 kMipsRegLR = 31,
159 kMipsFPReg0 = 32, /* only 16 fp regs supported currently */
160 kMipsFPRegEnd = 48,
161 kMipsRegHI = kMipsFPRegEnd,
162 kMipsRegLO,
163 kMipsRegPC,
164 kMipsRegEnd = 51,
Elliott Hughes719ace42012-03-09 18:06:03 -0800165};
buzbeee3acd072012-02-25 17:03:10 -0800166
buzbeeec137432012-11-13 12:13:16 -0800167#define ENCODE_MIPS_REG_LIST(N) ((u8) N)
168#define ENCODE_MIPS_REG_SP (1ULL << kMipsRegSP)
169#define ENCODE_MIPS_REG_LR (1ULL << kMipsRegLR)
170#define ENCODE_MIPS_REG_PC (1ULL << kMipsRegPC)
buzbeee3acd072012-02-25 17:03:10 -0800171
buzbeee3acd072012-02-25 17:03:10 -0800172/*
buzbeee3acd072012-02-25 17:03:10 -0800173 * Annotate special-purpose core registers:
174 */
175
buzbeef0504cd2012-11-13 16:31:10 -0800176enum MipsNativeRegisterPool {
Bill Buzbeea114add2012-05-03 15:00:40 -0700177 r_ZERO = 0,
178 r_AT = 1,
179 r_V0 = 2,
180 r_V1 = 3,
181 r_A0 = 4,
182 r_A1 = 5,
183 r_A2 = 6,
184 r_A3 = 7,
185 r_T0 = 8,
186 r_T1 = 9,
187 r_T2 = 10,
188 r_T3 = 11,
189 r_T4 = 12,
190 r_T5 = 13,
191 r_T6 = 14,
192 r_T7 = 15,
193 r_S0 = 16,
194 r_S1 = 17,
195 r_S2 = 18,
196 r_S3 = 19,
197 r_S4 = 20,
198 r_S5 = 21,
199 r_S6 = 22,
200 r_S7 = 23,
201 r_T8 = 24,
202 r_T9 = 25,
203 r_K0 = 26,
204 r_K1 = 27,
205 r_GP = 28,
206 r_SP = 29,
207 r_FP = 30,
208 r_RA = 31,
buzbeee3acd072012-02-25 17:03:10 -0800209
buzbeef0504cd2012-11-13 16:31:10 -0800210 r_F0 = 0 + MIPS_FP_REG_OFFSET,
Bill Buzbeea114add2012-05-03 15:00:40 -0700211 r_F1,
212 r_F2,
213 r_F3,
214 r_F4,
215 r_F5,
216 r_F6,
217 r_F7,
218 r_F8,
219 r_F9,
220 r_F10,
221 r_F11,
222 r_F12,
223 r_F13,
224 r_F14,
225 r_F15,
buzbeee3acd072012-02-25 17:03:10 -0800226#if 0 /* only 16 fp regs supported currently */
Bill Buzbeea114add2012-05-03 15:00:40 -0700227 r_F16,
228 r_F17,
229 r_F18,
230 r_F19,
231 r_F20,
232 r_F21,
233 r_F22,
234 r_F23,
235 r_F24,
236 r_F25,
237 r_F26,
238 r_F27,
239 r_F28,
240 r_F29,
241 r_F30,
242 r_F31,
buzbeee3acd072012-02-25 17:03:10 -0800243#endif
buzbeef0504cd2012-11-13 16:31:10 -0800244 r_DF0 = r_F0 + MIPS_FP_DOUBLE,
245 r_DF1 = r_F2 + MIPS_FP_DOUBLE,
246 r_DF2 = r_F4 + MIPS_FP_DOUBLE,
247 r_DF3 = r_F6 + MIPS_FP_DOUBLE,
248 r_DF4 = r_F8 + MIPS_FP_DOUBLE,
249 r_DF5 = r_F10 + MIPS_FP_DOUBLE,
250 r_DF6 = r_F12 + MIPS_FP_DOUBLE,
251 r_DF7 = r_F14 + MIPS_FP_DOUBLE,
buzbeee3acd072012-02-25 17:03:10 -0800252#if 0 /* only 16 fp regs supported currently */
buzbeef0504cd2012-11-13 16:31:10 -0800253 r_DF8 = r_F16 + MIPS_FP_DOUBLE,
254 r_DF9 = r_F18 + MIPS_FP_DOUBLE,
255 r_DF10 = r_F20 + MIPS_FP_DOUBLE,
256 r_DF11 = r_F22 + MIPS_FP_DOUBLE,
257 r_DF12 = r_F24 + MIPS_FP_DOUBLE,
258 r_DF13 = r_F26 + MIPS_FP_DOUBLE,
259 r_DF14 = r_F28 + MIPS_FP_DOUBLE,
260 r_DF15 = r_F30 + MIPS_FP_DOUBLE,
buzbeee3acd072012-02-25 17:03:10 -0800261#endif
buzbeef0504cd2012-11-13 16:31:10 -0800262 r_HI = MIPS_EXTRA_REG_OFFSET,
Bill Buzbeea114add2012-05-03 15:00:40 -0700263 r_LO,
264 r_PC,
Elliott Hughes719ace42012-03-09 18:06:03 -0800265};
buzbeee3acd072012-02-25 17:03:10 -0800266
buzbee5de34942012-03-01 14:51:57 -0800267/*
268 * Target-independent aliases
269 */
270
buzbeef0504cd2012-11-13 16:31:10 -0800271#define rMIPS_SUSPEND r_S0
272#define rMIPS_SELF r_S1
273#define rMIPS_SP r_SP
274#define rMIPS_ARG0 r_ARG0
275#define rMIPS_ARG1 r_ARG1
276#define rMIPS_ARG2 r_ARG2
277#define rMIPS_ARG3 r_ARG3
278#define rMIPS_FARG0 r_FARG0
279#define rMIPS_FARG1 r_FARG1
280#define rMIPS_FARG2 r_FARG2
281#define rMIPS_FARG3 r_FARG3
282#define rMIPS_RET0 r_RESULT0
283#define rMIPS_RET1 r_RESULT1
284#define rMIPS_INVOKE_TGT r_T9
285#define rMIPS_COUNT INVALID_REG
buzbee5de34942012-03-01 14:51:57 -0800286
buzbeee3acd072012-02-25 17:03:10 -0800287/* Shift encodings */
Elliott Hughes719ace42012-03-09 18:06:03 -0800288enum MipsShiftEncodings {
Bill Buzbeea114add2012-05-03 15:00:40 -0700289 kMipsLsl = 0x0,
290 kMipsLsr = 0x1,
291 kMipsAsr = 0x2,
292 kMipsRor = 0x3
Elliott Hughes719ace42012-03-09 18:06:03 -0800293};
buzbeee3acd072012-02-25 17:03:10 -0800294
buzbeea2ebdd72012-03-04 14:57:06 -0800295// MIPS sync kinds (Note: support for kinds other than kSYNC0 may not exist)
296#define kSYNC0 0x00
297#define kSYNC_WMB 0x04
298#define kSYNC_MB 0x01
299#define kSYNC_ACQUIRE 0x11
300#define kSYNC_RELEASE 0x12
301#define kSYNC_RMB 0x13
302
303// TODO: Use smaller hammer when appropriate for target CPU
304#define kST kSYNC0
305#define kSY kSYNC0
buzbeee3acd072012-02-25 17:03:10 -0800306
buzbee31a4a6f2012-02-28 15:36:15 -0800307#define isPseudoOpcode(opCode) ((int)(opCode) < 0)
buzbeee3acd072012-02-25 17:03:10 -0800308
309/*
310 * The following enum defines the list of supported Thumb instructions by the
Ian Rogersde797832012-03-06 10:18:10 -0800311 * assembler. Their corresponding EncodingMap positions will be defined in
312 * Assemble.cc.
buzbeee3acd072012-02-25 17:03:10 -0800313 */
Elliott Hughes719ace42012-03-09 18:06:03 -0800314enum MipsOpCode {
buzbeeb046e162012-10-30 15:48:42 -0700315 kMipsFirst = 0,
Bill Buzbeea114add2012-05-03 15:00:40 -0700316 kMips32BitData = kMipsFirst, /* data [31..0] */
317 kMipsAddiu, /* addiu t,s,imm16 [001001] s[25..21] t[20..16] imm16[15..0] */
318 kMipsAddu, /* add d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100001] */
319 kMipsAnd, /* and d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100100] */
320 kMipsAndi, /* andi t,s,imm16 [001100] s[25..21] t[20..16] imm16[15..0] */
321 kMipsB, /* b o [0001000000000000] o[15..0] */
322 kMipsBal, /* bal o [0000010000010001] o[15..0] */
323 /* NOTE: the code tests the range kMipsBeq thru kMipsBne, so
324 adding an instruction in this range may require updates */
325 kMipsBeq, /* beq s,t,o [000100] s[25..21] t[20..16] o[15..0] */
326 kMipsBeqz, /* beqz s,o [000100] s[25..21] [00000] o[15..0] */
327 kMipsBgez, /* bgez s,o [000001] s[25..21] [00001] o[15..0] */
328 kMipsBgtz, /* bgtz s,o [000111] s[25..21] [00000] o[15..0] */
329 kMipsBlez, /* blez s,o [000110] s[25..21] [00000] o[15..0] */
330 kMipsBltz, /* bltz s,o [000001] s[25..21] [00000] o[15..0] */
331 kMipsBnez, /* bnez s,o [000101] s[25..21] [00000] o[15..0] */
332 kMipsBne, /* bne s,t,o [000101] s[25..21] t[20..16] o[15..0] */
333 kMipsDiv, /* div s,t [000000] s[25..21] t[20..16] [0000000000011010] */
buzbeee3acd072012-02-25 17:03:10 -0800334#if __mips_isa_rev>=2
Bill Buzbeea114add2012-05-03 15:00:40 -0700335 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 -0800336#endif
Bill Buzbeea114add2012-05-03 15:00:40 -0700337 kMipsJal, /* jal t [000011] t[25..0] */
338 kMipsJalr, /* jalr d,s [000000] s[25..21] [00000] d[15..11]
339 hint[10..6] [001001] */
340 kMipsJr, /* jr s [000000] s[25..21] [0000000000] hint[10..6] [001000] */
341 kMipsLahi, /* lui t,imm16 [00111100000] t[20..16] imm16[15..0] load addr hi */
342 kMipsLalo, /* ori t,s,imm16 [001001] s[25..21] t[20..16] imm16[15..0] load addr lo */
343 kMipsLui, /* lui t,imm16 [00111100000] t[20..16] imm16[15..0] */
344 kMipsLb, /* lb t,o(b) [100000] b[25..21] t[20..16] o[15..0] */
345 kMipsLbu, /* lbu t,o(b) [100100] b[25..21] t[20..16] o[15..0] */
346 kMipsLh, /* lh t,o(b) [100001] b[25..21] t[20..16] o[15..0] */
347 kMipsLhu, /* lhu t,o(b) [100101] b[25..21] t[20..16] o[15..0] */
348 kMipsLw, /* lw t,o(b) [100011] b[25..21] t[20..16] o[15..0] */
349 kMipsMfhi, /* mfhi d [0000000000000000] d[15..11] [00000010000] */
350 kMipsMflo, /* mflo d [0000000000000000] d[15..11] [00000010010] */
351 kMipsMove, /* move d,s [000000] s[25..21] [00000] d[15..11] [00000100101] */
352 kMipsMovz, /* movz d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000001010] */
353 kMipsMul, /* mul d,s,t [011100] s[25..21] t[20..16] d[15..11] [00000000010] */
354 kMipsNop, /* nop [00000000000000000000000000000000] */
355 kMipsNor, /* nor d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100111] */
356 kMipsOr, /* or d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100101] */
357 kMipsOri, /* ori t,s,imm16 [001001] s[25..21] t[20..16] imm16[15..0] */
358 kMipsPref, /* pref h,o(b) [101011] b[25..21] h[20..16] o[15..0] */
359 kMipsSb, /* sb t,o(b) [101000] b[25..21] t[20..16] o[15..0] */
buzbeee3acd072012-02-25 17:03:10 -0800360#if __mips_isa_rev>=2
Bill Buzbeea114add2012-05-03 15:00:40 -0700361 kMipsSeb, /* seb d,t [01111100000] t[20..16] d[15..11] [10000100000] */
362 kMipsSeh, /* seh d,t [01111100000] t[20..16] d[15..11] [11000100000] */
buzbeee3acd072012-02-25 17:03:10 -0800363#endif
Bill Buzbeea114add2012-05-03 15:00:40 -0700364 kMipsSh, /* sh t,o(b) [101001] b[25..21] t[20..16] o[15..0] */
365 kMipsSll, /* sll d,t,a [00000000000] t[20..16] d[15..11] a[10..6] [000000] */
366 kMipsSllv, /* sllv d,t,s [000000] s[25..21] t[20..16] d[15..11] [00000000100] */
367 kMipsSlt, /* slt d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000101010] */
368 kMipsSlti, /* slti t,s,imm16 [001010] s[25..21] t[20..16] imm16[15..0] */
369 kMipsSltu, /* sltu d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000101011] */
370 kMipsSra, /* sra d,s,imm5 [00000000000] t[20..16] d[15..11] imm5[10..6] [000011] */
371 kMipsSrav, /* srav d,t,s [000000] s[25..21] t[20..16] d[15..11] [00000000111] */
372 kMipsSrl, /* srl d,t,a [00000000000] t[20..16] d[20..16] a[10..6] [000010] */
373 kMipsSrlv, /* srlv d,t,s [000000] s[25..21] t[20..16] d[15..11] [00000000110] */
374 kMipsSubu, /* subu d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100011] */
375 kMipsSw, /* sw t,o(b) [101011] b[25..21] t[20..16] o[15..0] */
376 kMipsXor, /* xor d,s,t [000000] s[25..21] t[20..16] d[15..11] [00000100110] */
377 kMipsXori, /* xori t,s,imm16 [001110] s[25..21] t[20..16] imm16[15..0] */
buzbeee3acd072012-02-25 17:03:10 -0800378#ifdef __mips_hard_float
Bill Buzbeea114add2012-05-03 15:00:40 -0700379 kMipsFadds, /* add.s d,s,t [01000110000] t[20..16] s[15..11] d[10..6] [000000] */
380 kMipsFsubs, /* sub.s d,s,t [01000110000] t[20..16] s[15..11] d[10..6] [000001] */
381 kMipsFmuls, /* mul.s d,s,t [01000110000] t[20..16] s[15..11] d[10..6] [000010] */
382 kMipsFdivs, /* div.s d,s,t [01000110000] t[20..16] s[15..11] d[10..6] [000011] */
383 kMipsFaddd, /* add.d d,s,t [01000110001] t[20..16] s[15..11] d[10..6] [000000] */
384 kMipsFsubd, /* sub.d d,s,t [01000110001] t[20..16] s[15..11] d[10..6] [000001] */
385 kMipsFmuld, /* mul.d d,s,t [01000110001] t[20..16] s[15..11] d[10..6] [000010] */
386 kMipsFdivd, /* div.d d,s,t [01000110001] t[20..16] s[15..11] d[10..6] [000011] */
387 kMipsFcvtsd,/* cvt.s.d d,s [01000110001] [00000] s[15..11] d[10..6] [100000] */
388 kMipsFcvtsw,/* cvt.s.w d,s [01000110100] [00000] s[15..11] d[10..6] [100000] */
389 kMipsFcvtds,/* cvt.d.s d,s [01000110000] [00000] s[15..11] d[10..6] [100001] */
390 kMipsFcvtdw,/* cvt.d.w d,s [01000110100] [00000] s[15..11] d[10..6] [100001] */
391 kMipsFcvtws,/* cvt.w.d d,s [01000110000] [00000] s[15..11] d[10..6] [100100] */
392 kMipsFcvtwd,/* cvt.w.d d,s [01000110001] [00000] s[15..11] d[10..6] [100100] */
393 kMipsFmovs, /* mov.s d,s [01000110000] [00000] s[15..11] d[10..6] [000110] */
394 kMipsFmovd, /* mov.d d,s [01000110001] [00000] s[15..11] d[10..6] [000110] */
395 kMipsFlwc1, /* lwc1 t,o(b) [110001] b[25..21] t[20..16] o[15..0] */
396 kMipsFldc1, /* ldc1 t,o(b) [110101] b[25..21] t[20..16] o[15..0] */
397 kMipsFswc1, /* swc1 t,o(b) [111001] b[25..21] t[20..16] o[15..0] */
398 kMipsFsdc1, /* sdc1 t,o(b) [111101] b[25..21] t[20..16] o[15..0] */
399 kMipsMfc1, /* mfc1 t,s [01000100000] t[20..16] s[15..11] [00000000000] */
400 kMipsMtc1, /* mtc1 t,s [01000100100] t[20..16] s[15..11] [00000000000] */
buzbeee3acd072012-02-25 17:03:10 -0800401#endif
Bill Buzbeea114add2012-05-03 15:00:40 -0700402 kMipsDelta, /* Psuedo for ori t, s, <label>-<label> */
403 kMipsDeltaHi, /* Pseudo for lui t, high16(<label>-<label>) */
404 kMipsDeltaLo, /* Pseudo for ori t, s, low16(<label>-<label>) */
405 kMipsCurrPC, /* jal to .+8 to materialize pc */
406 kMipsSync, /* sync kind [000000] [0000000000000000] s[10..6] [001111] */
407 kMipsUndefined, /* undefined [011001xxxxxxxxxxxxxxxx] */
408 kMipsLast
Elliott Hughes719ace42012-03-09 18:06:03 -0800409};
buzbeee3acd072012-02-25 17:03:10 -0800410
411/* Bit flags describing the behavior of each native opcode */
buzbeee3acd072012-02-25 17:03:10 -0800412/* Instruction assembly fieldLoc kind */
Elliott Hughes719ace42012-03-09 18:06:03 -0800413enum MipsEncodingKind {
Bill Buzbeea114add2012-05-03 15:00:40 -0700414 kFmtUnused,
415 kFmtBitBlt, /* Bit string using end/start */
416 kFmtDfp, /* Double FP reg */
417 kFmtSfp, /* Single FP reg */
418 kFmtBlt5_2, /* Same 5-bit field to 2 locations */
Elliott Hughes719ace42012-03-09 18:06:03 -0800419};
buzbeee3acd072012-02-25 17:03:10 -0800420
Ian Rogerscad96062012-03-04 10:33:52 -0800421/* Struct used to define the snippet positions for each MIPS opcode */
Elliott Hughes719ace42012-03-09 18:06:03 -0800422struct MipsEncodingMap {
Bill Buzbeea114add2012-05-03 15:00:40 -0700423 u4 skeleton;
424 struct {
425 MipsEncodingKind kind;
426 int end; /* end for kFmtBitBlt, 1-bit slice end for FP regs */
427 int start; /* start for kFmtBitBlt, 4-bit slice end for FP regs */
428 } fieldLoc[4];
429 MipsOpCode opcode;
buzbeeec137432012-11-13 12:13:16 -0800430 uint64_t flags;
Bill Buzbeea114add2012-05-03 15:00:40 -0700431 const char *name;
432 const char* fmt;
433 int size; /* Size in bytes */
Elliott Hughes719ace42012-03-09 18:06:03 -0800434};
buzbeee3acd072012-02-25 17:03:10 -0800435
436/* Keys for target-specific scheduling and other optimization hints */
Elliott Hughes719ace42012-03-09 18:06:03 -0800437enum MipsTargetOptHints {
Bill Buzbeea114add2012-05-03 15:00:40 -0700438 kMaxHoistDistance,
Elliott Hughes719ace42012-03-09 18:06:03 -0800439};
buzbeee3acd072012-02-25 17:03:10 -0800440
441extern MipsEncodingMap EncodingMap[kMipsLast];
442
buzbeee3acd072012-02-25 17:03:10 -0800443#define IS_UIMM16(v) ((0 <= (v)) && ((v) <= 65535))
444#define IS_SIMM16(v) ((-32768 <= (v)) && ((v) <= 32766))
445#define IS_SIMM16_2WORD(v) ((-32764 <= (v)) && ((v) <= 32763)) /* 2 offsets must fit */
446
447} // namespace art
448
449#endif // ART_COMPILER_COMPILER_CODEGEN_MIPS_MIPSLIR_H_