3 * CIL instruction information
6 * Paolo Molaro (lupus@ximian.com)
8 * Copyright 2002-2003 Ximian, Inc (http://www.ximian.com)
9 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
10 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
12 #include <mono/metadata/opcodes.h>
13 #include <stddef.h> /* for NULL */
16 #define MONO_PREFIX1_OFFSET MONO_CEE_ARGLIST
17 #define MONO_CUSTOM_PREFIX_OFFSET MONO_CEE_MONO_ICALL
19 #define OPDEF(a,b,c,d,e,f,g,h,i,j) \
20 { Mono ## e, MONO_FLOW_ ## j, MONO_ ## a },
23 mono_opcodes [MONO_CEE_LAST + 1] = {
24 #include "mono/cil/opcode.def"
30 #ifdef HAVE_ARRAY_ELEM_INIT
31 #define MSGSTRFIELD(line) MSGSTRFIELD1(line)
32 #define MSGSTRFIELD1(line) str##line
33 static const struct msgstr_t {
34 #define OPDEF(a,b,c,d,e,f,g,h,i,j) char MSGSTRFIELD(__LINE__) [sizeof (b)];
35 #include "mono/cil/opcode.def"
38 #define OPDEF(a,b,c,d,e,f,g,h,i,j) b,
39 #include "mono/cil/opcode.def"
42 static const int16_t opidx [] = {
43 #define OPDEF(a,b,c,d,e,f,g,h,i,j) [MONO_ ## a] = offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)),
44 #include "mono/cil/opcode.def"
52 mono_opcode_name (int opcode)
54 return (const char*)&opstr + opidx [opcode];
58 #define OPDEF(a,b,c,d,e,f,g,h,i,j) b,
59 static const char* const
60 mono_opcode_names [MONO_CEE_LAST + 1] = {
61 #include "mono/cil/opcode.def"
66 mono_opcode_name (int opcode)
68 return mono_opcode_names [opcode];
74 mono_opcode_value (const mono_byte **ip, const mono_byte *end)
77 const mono_byte *p = *ip;
80 return (MonoOpcodeEnum)-1;
84 return (MonoOpcodeEnum)-1;
85 res = (MonoOpcodeEnum)(*p + MONO_PREFIX1_OFFSET);
86 } else if (*p == MONO_CUSTOM_PREFIX) {
89 return (MonoOpcodeEnum)-1;
90 res = (MonoOpcodeEnum)(*p + MONO_CUSTOM_PREFIX_OFFSET);
92 res = (MonoOpcodeEnum)*p;