2 * opcodes.c: CIL instruction information
5 * Paolo Molaro (lupus@ximian.com)
7 * Copyright 2002-2003 Ximian, Inc (http://www.ximian.com)
8 * Copyright 2004-2009 Novell, Inc (http://www.novell.com)
9 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
11 #include <mono/metadata/opcodes.h>
12 #include <stddef.h> /* for NULL */
15 #define MONO_PREFIX1_OFFSET MONO_CEE_ARGLIST
16 #define MONO_CUSTOM_PREFIX_OFFSET MONO_CEE_MONO_ICALL
18 #define OPDEF(a,b,c,d,e,f,g,h,i,j) \
19 { Mono ## e, MONO_FLOW_ ## j, MONO_ ## a },
22 mono_opcodes [MONO_CEE_LAST + 1] = {
23 #include "mono/cil/opcode.def"
29 #ifdef HAVE_ARRAY_ELEM_INIT
30 #define MSGSTRFIELD(line) MSGSTRFIELD1(line)
31 #define MSGSTRFIELD1(line) str##line
32 static const struct msgstr_t {
33 #define OPDEF(a,b,c,d,e,f,g,h,i,j) char MSGSTRFIELD(__LINE__) [sizeof (b)];
34 #include "mono/cil/opcode.def"
37 #define OPDEF(a,b,c,d,e,f,g,h,i,j) b,
38 #include "mono/cil/opcode.def"
41 static const int16_t opidx [] = {
42 #define OPDEF(a,b,c,d,e,f,g,h,i,j) [MONO_ ## a] = offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)),
43 #include "mono/cil/opcode.def"
48 mono_opcode_name (int opcode)
50 return (const char*)&opstr + opidx [opcode];
54 #define OPDEF(a,b,c,d,e,f,g,h,i,j) b,
55 static const char* const
56 mono_opcode_names [MONO_CEE_LAST + 1] = {
57 #include "mono/cil/opcode.def"
62 mono_opcode_name (int opcode)
64 return mono_opcode_names [opcode];
70 mono_opcode_value (const mono_byte **ip, const mono_byte *end)
73 const mono_byte *p = *ip;
76 return (MonoOpcodeEnum)-1;
80 return (MonoOpcodeEnum)-1;
81 res = (MonoOpcodeEnum)(*p + MONO_PREFIX1_OFFSET);
82 } else if (*p == MONO_CUSTOM_PREFIX) {
85 return (MonoOpcodeEnum)-1;
86 res = (MonoOpcodeEnum)(*p + MONO_CUSTOM_PREFIX_OFFSET);
88 res = (MonoOpcodeEnum)*p;