2 /* -----------------------------------------------------------------------------
3 * $Id: Bytecodes.h,v 1.17 2000/10/09 11:20:16 daan Exp $
5 * (c) The GHC Team, 1998-1999
7 * Bytecode definitions.
9 * ---------------------------------------------------------------------------*/
11 /* --------------------------------------------------------------------------
15 * o INTERNAL_ERROR is never generated by the compiler and usually
16 * indicates an error in the heap.
17 * PANIC is generated by the compiler whenever it tests an "irrefutable"
18 * pattern which fails. If we don't see too many of these, we could
19 * optimise out the redundant test.
21 * o If you add any new instructions, you have to check that each enumeration
22 * has at most 256 entries in it --- some of the lists are very close to
24 * ------------------------------------------------------------------------*/
27 Ins(i_INTERNAL_ERROR), \
30 Ins(i_STK_CHECK_big), \
34 Ins(i_ALLOC_CONSTR), \
35 Ins(i_ALLOC_CONSTR_big), \
55 Ins(i_ALLOC_ROW_big), \
57 Ins(i_PACK_ROW_big), \
59 Ins(i_CONST_ROW_TRIV), \
62 Ins(i_PACK_INJ_VAR), \
63 Ins(i_PACK_INJ_VAR_big), \
64 Ins(i_PACK_INJ_CONST_8), \
65 Ins(i_PACK_INJ_REL_8), \
67 Ins(i_TEST_INJ_VAR), \
68 Ins(i_TEST_INJ_VAR_big), \
69 Ins(i_TEST_INJ_CONST_8), \
70 Ins(i_TEST_INJ_REL_8), \
72 Ins(i_CONST_WORD_8), \
73 Ins(i_ADD_WORD_VAR), \
74 Ins(i_ADD_WORD_VAR_big), \
75 Ins(i_ADD_WORD_VAR_8), \
80 Ins(i_CONST_INT_big), \
84 Ins(i_CONST_INTEGER), \
85 Ins(i_CONST_INTEGER_big), \
87 Ins(i_VAR_WORD_big), \
89 Ins(i_CONST_WORD_big), \
93 Ins(i_VAR_ADDR_big), \
95 Ins(i_CONST_ADDR_big), \
99 Ins(i_VAR_CHAR_big), \
101 Ins(i_CONST_CHAR_big), \
103 Ins(i_UNPACK_CHAR), \
105 Ins(i_VAR_FLOAT_big), \
106 Ins(i_CONST_FLOAT), \
107 Ins(i_CONST_FLOAT_big), \
109 Ins(i_UNPACK_FLOAT), \
111 Ins(i_VAR_DOUBLE_big), \
112 Ins(i_CONST_DOUBLE), \
113 Ins(i_CONST_DOUBLE_big), \
114 Ins(i_PACK_DOUBLE), \
115 Ins(i_UNPACK_DOUBLE), \
117 Ins(i_VAR_STABLE_big), \
118 Ins(i_PACK_STABLE), \
119 Ins(i_UNPACK_STABLE), \
127 #define BIGGEST_OPCODE ((int)(i_VV))
130 typedef enum { INSTRLIST } Instr;
136 { i_INTERNAL_ERROR1 /* Instruction 0 raises an internal error */
141 /* Char# operations */
151 /* Int# operations */
175 /* Word# operations */
201 /* Addr# operations */
211 /* Stable# operations */
215 /* Stateless Addr operations */
220 , i_indexFloatOffAddr
221 , i_indexDoubleOffAddr
222 , i_indexStableOffAddr
229 , i_readDoubleOffAddr
230 , i_readStableOffAddr
236 , i_writeFloatOffAddr
237 , i_writeDoubleOffAddr
238 , i_writeStableOffAddr
240 /* Integer operations */
257 /* Float# operations */
294 , i_isDenormalizedFloat
295 , i_isNegativeZeroFloat
298 /* Double# operations */
337 , i_isDenormalizedDouble
338 , i_isNegativeZeroDouble
341 /* If you add a new primop to this table, check you don't
342 * overflow the 256 limit. That is MAX_Primop1 <= 255.
343 * Current value (30/10/98) = 0xc8
345 , MAX_Primop1 = i_isIEEEDouble
350 { i_INTERNAL_ERROR2 /* Instruction 0 raises an internal error */
355 /* row primitives. */
370 /* Prim[Mutable]Array operations */
372 , i_unsafeFreezeArray
381 /* Prim[Mutable]ByteArray operations */
382 , i_sameMutableByteArray
383 , i_unsafeFreezeByteArray
394 /* {write,read,index}IntegerArray not provided */
410 #ifdef PROVIDE_STABLE
417 /* {write,read,index}ForeignObjArray not provided */
419 #ifdef PROVIDE_PTREQUALITY
420 , i_reallyUnsafePtrEquality
422 #ifdef PROVIDE_COERCE
426 #ifdef PROVIDE_FOREIGN
427 /* ForeignObj# operations */
430 , indexCharOffForeignObj
431 , indexIntOffForeignObj
432 , indexInt64OffForeignObj
433 , indexWordOffForeignObj
434 , indexAddrOffForeignObj
435 , indexFloatOffForeignObj
436 , indexDoubleOffForeignObj
437 , indexStablePtrOffForeignObj
440 /* Weak# operations */
444 /* StablePtr# operations */
449 /* foreign export dynamic support */
450 , i_createAdjThunkARCH
452 /* misc handy hacks */
456 #ifdef PROVIDE_CONCURRENT
457 /* Concurrency operations */
483 /* If you add a new primop to this table, check you don't
484 * overflow the 256 limit. That is MAX_Primop2 <= 255.
485 * Current value (1 oct 2000) = 0x48
487 , MAX_Primop2 = i_ccall_stdcall_IO
490 typedef unsigned int InstrPtr; /* offset of instruction within BCO */
492 /*-------------------------------------------------------------------------*/