Bug 488775 - TM: widen LIR instructions. r=graydon,edwsmith
[mozilla-central.git] / js / src / nanojit / LIRopcode.tbl
blob4982187eb5cf8d794119cc0d34a67fbdac460326
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  * vim: set ts=8 sw=4 et tw=0 ft=C:
3  *
4  * ***** BEGIN LICENSE BLOCK *****
5  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6  *
7  * The contents of this file are subject to the Mozilla Public License Version
8  * 1.1 (the "License"); you may not use this file except in compliance with
9  * the License. You may obtain a copy of the License at
10  * http://www.mozilla.org/MPL/
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is SpiderMonkey nanojit.
18  *
19  * The Initial Developer of the Original Code is
20  * the Mozilla Corporation.
21  * Portions created by the Initial Developer are Copyright (C) 2008
22  * the Initial Developer. All Rights Reserved.
23  *
24  * Contributor(s):
25  *   Jeff Walden <jwalden+code@mit.edu>
26  *
27  * Alternatively, the contents of this file may be used under the terms of
28  * either of the GNU General Public License Version 2 or later (the "GPL"),
29  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30  * in which case the provisions of the GPL or the LGPL are applicable instead
31  * of those above. If you wish to allow use of your version of this file only
32  * under the terms of either the GPL or the LGPL, and not to allow others to
33  * use your version of this file under the terms of the MPL, indicate your
34  * decision by deleting the provisions above and replace them with the notice
35  * and other provisions required by the GPL or the LGPL. If you do not delete
36  * the provisions above, a recipient may use your version of this file under
37  * the terms of any one of the MPL, the GPL or the LGPL.
38  *
39  * ***** END LICENSE BLOCK ***** */
42  * Definitions of LIR opcodes.  If you need to allocate an opcode, look
43  * for a name of the form unused* and claim it.
44  *
45  * Includers must define OPDEF and OPDEF64 macros of the following forms:
46  *
47  * #define   OPDEF(op,val,operands) ...
48  * #define OPDEF64(op,val,operands) ...
49  *
50  * Selected arguments can then be used within the macro expansions.
51  *
52  * Field        Description
53  * op           Bytecode name, token-pasted after "LIR_" to form an LOpcode
54  * val          Bytecode value, which is the LOpcode enumerator value
55  * operands     Number of operands for this instruction
56  *
57  * This file is best viewed with 128 columns:
58 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678
59  */
61 /*    op    val name        operands */
63 /* special operations (must be 0..N) */
64 OPDEF(start,     0, 0)
65 OPDEF(unused0a,  1, 0)
66 OPDEF(skip,      2, 0)
67 OPDEF(unused0b,  3, 0)
68 OPDEF(unused0c,  4, 0)
70 OPDEF(unused1,   5, 2)
71 OPDEF(unused2,   6, 2)
72 OPDEF(unused3,   7, 2)
73 OPDEF(unused4,   8, 2)
75 /* non-pure operations */
76 OPDEF(addp,      9, 2)
77 OPDEF(param,    10, 0)
78 OPDEF(unused4b, 11, 2)
79 OPDEF(ld,       12, 2) // 32-bit load
80 OPDEF(alloc,    13, 0) // alloca some stack space
81 OPDEF(sti,      14, 2) // 32-bit store
82 OPDEF(ret,      15, 1)
83 OPDEF(live,     16, 1) // extend live range of reference
84 OPDEF(calli,    17, 0) // indirect call
85 OPDEF(call,     18, 0) // subroutine call returning a 32-bit value
87 /* guards */
88 OPDEF(loop,     19, 0) // loop fragment
89 OPDEF(x,        20, 0) // exit always
91 /* branches */
92 OPDEF(j,        21, 0) // jump always
93 OPDEF(jt,       22, 1) // jump true
94 OPDEF(jf,       23, 1) // jump false
95 OPDEF(label,    24, 0) // a jump target
96 OPDEF(ji,       25, 2) // jump indirect
97 /* operators */
100  * NB: Opcodes ldcs through uge must remain continuous to aid in
101  *     common-subexpression-elimination detection code.
102  */
104 OPDEF(ldcs, 26, 2) // non-volatile 16-bit load
107  * feq though fge must only be used on float arguments.  They return integers.
108  * For all except feq, (op ^ 1) is the op which flips the
109  * left and right sides of the comparison, so (lt ^ 1) == gt, or the operator
110  * "<" is xored with 1 to get ">".  Similarly, (op ^ 3) is the complement of
111  * op, so (lt ^ 1) == ge, or the complement of the operator "<" is ">=" xored
112  * with 3.  NB: These opcodes must remain continuous so that comparison-opcode
113  * detection works correctly.
114  */
115 OPDEF(feq,      27, 2) // floating-point equality [2 float inputs]
116 OPDEF(flt,      28, 2) // floating-point less than: arg1 < arg2
117 OPDEF(fgt,      29, 2) // floating-point greater than: arg1 > arg2
118 OPDEF(fle,      30, 2) // arg1 <= arg2, both floating-point
119 OPDEF(fge,      31, 2) // arg1 >= arg2, both floating-point
121 OPDEF(unused5,  32, 0)
122 OPDEF(int,      33, 0) // constant 32-bit integer
123 OPDEF(cmov,     34, 2) // conditional move (op1=cond, op2=cond(iftrue,iffalse))
124 OPDEF(ldc,      35, 2) // non-volatile load
126 // neg through ush are all integer operations
127 OPDEF(neg,      36, 1) // numeric negation [ 1 integer input / integer output ]
128 OPDEF(add,      37, 2) // integer addition [ 2 operand integer intputs / integer output ]
129 OPDEF(sub,      38, 2) // integer subtraction
130 OPDEF(mul,      39, 2) // integer multiplication
131 #if defined(NANOJIT_64BIT)
132 OPDEF(callh,    40, 0)
133 #else
134 OPDEF(callh,    40, 1)
135 #endif
136 OPDEF(and,      41, 2)
137 OPDEF(or,       42, 2)
138 OPDEF(xor,      43, 2)
139 OPDEF(not,      44, 1)
140 OPDEF(lsh,      45, 2)
141 OPDEF(rsh,      46, 2) // >>
142 OPDEF(ush,      47, 2) // >>>
144 // conditional guards, op^1 to complement.  Only things that are
145 // isCond() can be passed to these.
146 OPDEF(xt,       48, 1) // exit if true   0x30 0011 0000
147 OPDEF(xf,       49, 1) // exit if false  0x31 0011 0001
149 // qlo and qhi take a single quad argument and return its low and high
150 // 32 bits respectively as 32-bit integers.
151 OPDEF(qlo,      50, 1)
152 OPDEF(qhi,      51, 1)
154 OPDEF(ldcb,     52, 2) // non-volatile 8-bit load
156 OPDEF(ov,       53, 1)
157 OPDEF(cs,       54, 1)
159 // Integer (all sizes) relational operators.  (op ^ 1) is the op which flips the
160 // left and right sides of the comparison, so (lt ^ 1) == gt, or the operator
161 // "<" is xored with 1 to get ">".  Similarly, (op ^ 3) is the complement of
162 // op, so (lt ^ 1) == ge, or the complement of the operator "<" is ">=" xored
163 // with 3.  'u' prefix indicates the unsigned integer variant.
164 // NB: These opcodes must remain continuous so that comparison-opcode detection
165 // works correctly.
166 OPDEF(eq,       55, 2) // integer equality
167 OPDEF(lt,       56, 2) // 0x38 0011 1000
168 OPDEF(gt,       57, 2) // 0x39 0011 1001
169 OPDEF(le,       58, 2) // 0x3A 0011 1010
170 OPDEF(ge,       59, 2) // 0x3B 0011 1011
171 OPDEF(ult,      60, 2) // 0x3C 0011 1100
172 OPDEF(ugt,      61, 2) // 0x3D 0011 1101
173 OPDEF(ule,      62, 2) // 0x3E 0011 1110
174 OPDEF(uge,      63, 2) // 0x3F 0011 1111
176 OPDEF64(2,          0, 2) // wraps a pair of refs
177 OPDEF64(file,       1, 2)
178 OPDEF64(line,       2, 2)
179 OPDEF64(xbarrier,   3, 1) // memory barrier (dummy guard)
180 OPDEF64(xtbl,       4, 1) // exit via indirect jump
182 OPDEF64(unused5_64,   5, 2)
183 OPDEF64(unused6_64,   6, 2)
184 OPDEF64(unused7_64,   7, 2)
185 OPDEF64(unused8_64,   8, 2)
186 OPDEF64(unused9_64,   9, 2)
187 OPDEF64(unused10_64, 10, 2)
189 OPDEF64(unused11_64, 11, 2)
190 OPDEF64(ldq, LIR_ld, 2) // quad load
192 OPDEF64(unused13_64, 13, 2)
194 OPDEF64(stqi,   LIR_sti, 2) // quad store
195 OPDEF64(fret,   LIR_ret, 1)
197 OPDEF64(unused16_64, 16, 2)
199 OPDEF64(fcalli,      LIR_calli, 0)
200 OPDEF64(fcall,       LIR_call, 0) // subroutine call returning quad
202 OPDEF64(unused19_64, 19, 2)
203 OPDEF64(unused20_64, 20, 2)
204 OPDEF64(unused21_64, 21, 2)
205 OPDEF64(unused22_64, 22, 2)
206 OPDEF64(unused23_64, 23, 2)
207 OPDEF64(qiand,       24, 2)
208 OPDEF64(qiadd,       25, 2)
209 OPDEF64(unused26_64, 26, 2)
210 OPDEF64(unused27_64, 27, 2)
211 OPDEF64(unused28_64, 28, 2)
212 OPDEF64(unused29_64, 29, 2)
213 OPDEF64(unused30_64, 30, 2)
214 OPDEF64(unused31_64, 31, 2)
215 OPDEF64(unused32_64, 32, 2)
217 OPDEF64(quad,  LIR_int,  0) // quad constant value
218 OPDEF64(qcmov, LIR_cmov, 2)
219 OPDEF64(ldqc,  LIR_ldc,  2)
222 /* floating-point arithmetic operations */
223 OPDEF64(fneg,   LIR_neg, 1)
224 OPDEF64(fadd,   LIR_add, 2)
225 OPDEF64(fsub,   LIR_sub, 2)
226 OPDEF64(fmul,   LIR_mul, 2)
227 OPDEF64(fdiv,   40,      2)
229 OPDEF64(qjoin, 41,      2)
230 OPDEF64(i2f,   42,      1) // convert an integer to a float
231 OPDEF64(u2f,   43,      1) // convert an unsigned integer to a float
232 OPDEF64(qior,  44,      2)
233 OPDEF64(qilsh, LIR_lsh, 2)
235 OPDEF64(unused46_64, 46, 2)
236 OPDEF64(unused47_64, 47, 2)
237 OPDEF64(unused48_64, 48, 2)
238 OPDEF64(unused49_64, 49, 2)
239 OPDEF64(unused50_64, 50, 2)
240 OPDEF64(unused51_64, 51, 2)
241 OPDEF64(unused52_64, 52, 2)
242 OPDEF64(unused53_64, 53, 2)
243 OPDEF64(unused54_64, 54, 2)
244 OPDEF64(unused55_64, 55, 2)
245 OPDEF64(unused56_64, 56, 2)
246 OPDEF64(unused57_64, 57, 2)
247 OPDEF64(unused58_64, 58, 2)
248 OPDEF64(unused59_64, 59, 2)
249 OPDEF64(unused60_64, 60, 2)
250 OPDEF64(unused61_64, 61, 2)
251 OPDEF64(unused62_64, 62, 2)
252 OPDEF64(unused63_64, 63, 2)