00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "global.h"
00022 #include "ilopc.h"
00023
00024 ILOpcodeTabEntry il_opcode_table[MAX_IL_OPCODE] = {
00025
00026 {"nop", IL_OPCODE_ARGS_NONE, 1},
00027 {"break", IL_OPCODE_ARGS_NONE, 1},
00028
00029 {"ldarg.0", IL_OPCODE_ARGS_NONE, 1},
00030 {"ldarg.1", IL_OPCODE_ARGS_NONE, 1},
00031 {"ldarg.2", IL_OPCODE_ARGS_NONE, 1},
00032 {"ldarg.3", IL_OPCODE_ARGS_NONE, 1},
00033 {"ldloc.0", IL_OPCODE_ARGS_NONE, 1},
00034 {"ldloc.1", IL_OPCODE_ARGS_NONE, 1},
00035 {"ldloc.2", IL_OPCODE_ARGS_NONE, 1},
00036 {"ldloc.3", IL_OPCODE_ARGS_NONE, 1},
00037 {"stloc.0", IL_OPCODE_ARGS_NONE, 1},
00038 {"stloc.1", IL_OPCODE_ARGS_NONE, 1},
00039 {"stloc.2", IL_OPCODE_ARGS_NONE, 1},
00040 {"stloc.3", IL_OPCODE_ARGS_NONE, 1},
00041
00042 {"ldarg.s", IL_OPCODE_ARGS_SHORT_ARG, 2},
00043 {"ldarga.s", IL_OPCODE_ARGS_SHORT_ARG, 2},
00044 {"starg.s", IL_OPCODE_ARGS_SHORT_ARG, 2},
00045 {"ldloc.s", IL_OPCODE_ARGS_SHORT_VAR, 2},
00046 {"ldloca.s", IL_OPCODE_ARGS_SHORT_VAR, 2},
00047 {"stloc.s", IL_OPCODE_ARGS_SHORT_VAR, 2},
00048
00049 {"ldnull", IL_OPCODE_ARGS_NONE, 1},
00050 {"ldc.i4.m1", IL_OPCODE_ARGS_NONE, 1},
00051 {"ldc.i4.0", IL_OPCODE_ARGS_NONE, 1},
00052 {"ldc.i4.1", IL_OPCODE_ARGS_NONE, 1},
00053 {"ldc.i4.2", IL_OPCODE_ARGS_NONE, 1},
00054 {"ldc.i4.3", IL_OPCODE_ARGS_NONE, 1},
00055 {"ldc.i4.4", IL_OPCODE_ARGS_NONE, 1},
00056 {"ldc.i4.5", IL_OPCODE_ARGS_NONE, 1},
00057 {"ldc.i4.6", IL_OPCODE_ARGS_NONE, 1},
00058 {"ldc.i4.7", IL_OPCODE_ARGS_NONE, 1},
00059 {"ldc.i4.8", IL_OPCODE_ARGS_NONE, 1},
00060 {"ldc.i4.s", IL_OPCODE_ARGS_INT8, 2},
00061 {"ldc.i4", IL_OPCODE_ARGS_INT32, 5},
00062 {"ldc.i8", IL_OPCODE_ARGS_INT64, 9},
00063 {"ldc.r4", IL_OPCODE_ARGS_FLOAT32, 5},
00064 {"ldc.r8", IL_OPCODE_ARGS_FLOAT64, 9},
00065
00066 {"ldptr", IL_OPCODE_ARGS_INT32, 5},
00067
00068 {"dup", IL_OPCODE_ARGS_NONE, 1},
00069 {"pop", IL_OPCODE_ARGS_NONE, 1},
00070
00071 {"jmp", IL_OPCODE_ARGS_CALL, 5},
00072 {"call", IL_OPCODE_ARGS_CALL, 5},
00073 {"calli", IL_OPCODE_ARGS_CALLI, 5},
00074 {"ret", IL_OPCODE_ARGS_NONE, 1},
00075
00076 {"br.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00077 {"brfalse.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00078 {"brtrue.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00079 {"beq.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00080 {"bge.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00081 {"bgt.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00082 {"ble.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00083 {"blt.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00084 {"bne.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00085 {"bge.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00086 {"bgt.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00087 {"ble.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00088 {"blt.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00089 {"br", IL_OPCODE_ARGS_LONG_JUMP, 5},
00090 {"brfalse", IL_OPCODE_ARGS_LONG_JUMP, 5},
00091 {"brtrue", IL_OPCODE_ARGS_LONG_JUMP, 5},
00092 {"beq", IL_OPCODE_ARGS_LONG_JUMP, 5},
00093 {"bge", IL_OPCODE_ARGS_LONG_JUMP, 5},
00094 {"bgt", IL_OPCODE_ARGS_LONG_JUMP, 5},
00095 {"ble", IL_OPCODE_ARGS_LONG_JUMP, 5},
00096 {"blt", IL_OPCODE_ARGS_LONG_JUMP, 5},
00097 {"bne.un", IL_OPCODE_ARGS_LONG_JUMP, 5},
00098 {"bge.un", IL_OPCODE_ARGS_LONG_JUMP, 5},
00099 {"bgt.un", IL_OPCODE_ARGS_LONG_JUMP, 5},
00100 {"ble.un", IL_OPCODE_ARGS_LONG_JUMP, 5},
00101 {"blt.un", IL_OPCODE_ARGS_LONG_JUMP, 5},
00102
00103 {"switch", IL_OPCODE_ARGS_SWITCH, 1},
00104
00105 {"ldind.i1", IL_OPCODE_ARGS_NONE, 1},
00106 {"ldind.u1", IL_OPCODE_ARGS_NONE, 1},
00107 {"ldind.i2", IL_OPCODE_ARGS_NONE, 1},
00108 {"ldind.u2", IL_OPCODE_ARGS_NONE, 1},
00109 {"ldind.i4", IL_OPCODE_ARGS_NONE, 1},
00110 {"ldind.u4", IL_OPCODE_ARGS_NONE, 1},
00111 {"ldind.i8", IL_OPCODE_ARGS_NONE, 1},
00112 {"ldind.i", IL_OPCODE_ARGS_NONE, 1},
00113 {"ldind.r4", IL_OPCODE_ARGS_NONE, 1},
00114 {"ldind.r8", IL_OPCODE_ARGS_NONE, 1},
00115 {"ldind.ref", IL_OPCODE_ARGS_NONE, 1},
00116 {"stind.ref", IL_OPCODE_ARGS_NONE, 1},
00117 {"stind.i1", IL_OPCODE_ARGS_NONE, 1},
00118 {"stind.i2", IL_OPCODE_ARGS_NONE, 1},
00119 {"stind.i4", IL_OPCODE_ARGS_NONE, 1},
00120 {"stind.i8", IL_OPCODE_ARGS_NONE, 1},
00121 {"stind.r4", IL_OPCODE_ARGS_NONE, 1},
00122 {"stind.r8", IL_OPCODE_ARGS_NONE, 1},
00123
00124 {"add", IL_OPCODE_ARGS_NONE, 1},
00125 {"sub", IL_OPCODE_ARGS_NONE, 1},
00126 {"mul", IL_OPCODE_ARGS_NONE, 1},
00127 {"div", IL_OPCODE_ARGS_NONE, 1},
00128 {"div.un", IL_OPCODE_ARGS_NONE, 1},
00129 {"rem", IL_OPCODE_ARGS_NONE, 1},
00130 {"rem.un", IL_OPCODE_ARGS_NONE, 1},
00131 {"and", IL_OPCODE_ARGS_NONE, 1},
00132 {"or", IL_OPCODE_ARGS_NONE, 1},
00133 {"xor", IL_OPCODE_ARGS_NONE, 1},
00134 {"shl", IL_OPCODE_ARGS_NONE, 1},
00135 {"shr", IL_OPCODE_ARGS_NONE, 1},
00136 {"shr.un", IL_OPCODE_ARGS_NONE, 1},
00137 {"neg", IL_OPCODE_ARGS_NONE, 1},
00138 {"not", IL_OPCODE_ARGS_NONE, 1},
00139
00140 {"conv.i1", IL_OPCODE_ARGS_NONE, 1},
00141 {"conv.i2", IL_OPCODE_ARGS_NONE, 1},
00142 {"conv.i4", IL_OPCODE_ARGS_NONE, 1},
00143 {"conv.i8", IL_OPCODE_ARGS_NONE, 1},
00144 {"conv.r4", IL_OPCODE_ARGS_NONE, 1},
00145 {"conv.r8", IL_OPCODE_ARGS_NONE, 1},
00146 {"conv.u4", IL_OPCODE_ARGS_NONE, 1},
00147 {"conv.u8", IL_OPCODE_ARGS_NONE, 1},
00148
00149 {"callvirt", IL_OPCODE_ARGS_CALLVIRT, 5},
00150 {"cpobj", IL_OPCODE_ARGS_TOKEN, 5},
00151 {"ldobj", IL_OPCODE_ARGS_TOKEN, 5},
00152 {"ldstr", IL_OPCODE_ARGS_STRING, 5},
00153
00154 {"newobj", IL_OPCODE_ARGS_NEW, 5},
00155 {"castclass", IL_OPCODE_ARGS_TOKEN, 5},
00156 {"isinst", IL_OPCODE_ARGS_TOKEN, 5},
00157
00158 {"conv.r.un", IL_OPCODE_ARGS_NONE, 1},
00159 {"ann.data.s", IL_OPCODE_ARGS_ANN_DATA, 1},
00160
00161 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00162
00163 {"unbox", IL_OPCODE_ARGS_TOKEN, 5},
00164
00165 {"throw", IL_OPCODE_ARGS_NONE, 1},
00166
00167 {"ldfld", IL_OPCODE_ARGS_TOKEN, 5},
00168 {"ldflda", IL_OPCODE_ARGS_TOKEN, 5},
00169 {"stfld", IL_OPCODE_ARGS_TOKEN, 5},
00170 {"ldsfld", IL_OPCODE_ARGS_TOKEN, 5},
00171 {"ldsflda", IL_OPCODE_ARGS_TOKEN, 5},
00172 {"stsfld", IL_OPCODE_ARGS_TOKEN, 5},
00173 {"stobj", IL_OPCODE_ARGS_TOKEN, 5},
00174
00175 {"conv.ovf.i1.un", IL_OPCODE_ARGS_NONE, 1},
00176 {"conv.ovf.i2.un", IL_OPCODE_ARGS_NONE, 1},
00177 {"conv.ovf.i4.un", IL_OPCODE_ARGS_NONE, 1},
00178 {"conv.ovf.i8.un", IL_OPCODE_ARGS_NONE, 1},
00179 {"conv.ovf.u1.un", IL_OPCODE_ARGS_NONE, 1},
00180 {"conv.ovf.u2.un", IL_OPCODE_ARGS_NONE, 1},
00181 {"conv.ovf.u4.un", IL_OPCODE_ARGS_NONE, 1},
00182 {"conv.ovf.u8.un", IL_OPCODE_ARGS_NONE, 1},
00183 {"conv.ovf.i.un", IL_OPCODE_ARGS_NONE, 1},
00184 {"conv.ovf.u.un", IL_OPCODE_ARGS_NONE, 1},
00185
00186 {"box", IL_OPCODE_ARGS_TOKEN, 5},
00187
00188 {"newarr", IL_OPCODE_ARGS_TOKEN, 5},
00189 {"ldlen", IL_OPCODE_ARGS_NONE, 1},
00190 {"ldelema", IL_OPCODE_ARGS_TOKEN, 5},
00191 {"ldelem.i1", IL_OPCODE_ARGS_NONE, 1},
00192 {"ldelem.u1", IL_OPCODE_ARGS_NONE, 1},
00193 {"ldelem.i2", IL_OPCODE_ARGS_NONE, 1},
00194 {"ldelem.u2", IL_OPCODE_ARGS_NONE, 1},
00195 {"ldelem.i4", IL_OPCODE_ARGS_NONE, 1},
00196 {"ldelem.u4", IL_OPCODE_ARGS_NONE, 1},
00197 {"ldelem.i8", IL_OPCODE_ARGS_NONE, 1},
00198 {"ldelem.i", IL_OPCODE_ARGS_NONE, 1},
00199 {"ldelem.r4", IL_OPCODE_ARGS_NONE, 1},
00200 {"ldelem.r8", IL_OPCODE_ARGS_NONE, 1},
00201 {"ldelem.ref", IL_OPCODE_ARGS_NONE, 1},
00202
00203 {"stelem.i", IL_OPCODE_ARGS_NONE, 1},
00204 {"stelem.i1", IL_OPCODE_ARGS_NONE, 1},
00205 {"stelem.i2", IL_OPCODE_ARGS_NONE, 1},
00206 {"stelem.i4", IL_OPCODE_ARGS_NONE, 1},
00207 {"stelem.i8", IL_OPCODE_ARGS_NONE, 1},
00208 {"stelem.r4", IL_OPCODE_ARGS_NONE, 1},
00209 {"stelem.r8", IL_OPCODE_ARGS_NONE, 1},
00210 {"stelem.ref", IL_OPCODE_ARGS_NONE, 1},
00211
00212 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00213 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00214 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00215 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00216 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00217 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00218 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00219 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00220 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00221 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00222 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00223 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00224 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00225 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00226 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00227 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00228
00229 {"conv.ovf.i1", IL_OPCODE_ARGS_NONE, 1},
00230 {"conv.ovf.u1", IL_OPCODE_ARGS_NONE, 1},
00231 {"conv.ovf.i2", IL_OPCODE_ARGS_NONE, 1},
00232 {"conv.ovf.u2", IL_OPCODE_ARGS_NONE, 1},
00233 {"conv.ovf.i4", IL_OPCODE_ARGS_NONE, 1},
00234 {"conv.ovf.u4", IL_OPCODE_ARGS_NONE, 1},
00235 {"conv.ovf.i8", IL_OPCODE_ARGS_NONE, 1},
00236 {"conv.ovf.u8", IL_OPCODE_ARGS_NONE, 1},
00237
00238 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00239 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00240 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00241 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00242 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00243 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00244 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00245
00246 {"refanyval", IL_OPCODE_ARGS_TOKEN, 5},
00247 {"ckfinite", IL_OPCODE_ARGS_NONE, 1},
00248
00249 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00250 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00251
00252 {"mkrefany", IL_OPCODE_ARGS_TOKEN, 5},
00253
00254 {"ann.call", IL_OPCODE_ARGS_TOKEN, 5},
00255 {"ann.catch", IL_OPCODE_ARGS_NONE, 1},
00256 {"ann.dead", IL_OPCODE_ARGS_ANN_DEAD, 3},
00257 {"ann.hoisted", IL_OPCODE_ARGS_NONE, 1},
00258 {"ann.hoisted_call", IL_OPCODE_ARGS_TOKEN, 5},
00259 {"ann.lab", IL_OPCODE_ARGS_NONE, 1},
00260 {"ann.def", IL_OPCODE_ARGS_NONE, 1},
00261 {"ann.ref.s", IL_OPCODE_ARGS_ANN_REF, 2},
00262 {"ann.phi", IL_OPCODE_ARGS_ANN_PHI, 1},
00263
00264 {"ldtoken", IL_OPCODE_ARGS_TOKEN, 5},
00265
00266 {"conv.u2", IL_OPCODE_ARGS_NONE, 1},
00267 {"conv.u1", IL_OPCODE_ARGS_NONE, 1},
00268 {"conv.i", IL_OPCODE_ARGS_NONE, 1},
00269 {"conv.ovf.i", IL_OPCODE_ARGS_NONE, 1},
00270 {"conv.ovf.u", IL_OPCODE_ARGS_NONE, 1},
00271
00272 {"add.ovf", IL_OPCODE_ARGS_NONE, 1},
00273 {"add.ovf.un", IL_OPCODE_ARGS_NONE, 1},
00274 {"mul.ovf", IL_OPCODE_ARGS_NONE, 1},
00275 {"mul.ovf.un", IL_OPCODE_ARGS_NONE, 1},
00276 {"sub.ovf", IL_OPCODE_ARGS_NONE, 1},
00277 {"sub.ovf.un", IL_OPCODE_ARGS_NONE, 1},
00278
00279 {"endfinally", IL_OPCODE_ARGS_NONE, 1},
00280
00281 {"leave", IL_OPCODE_ARGS_LONG_JUMP, 5},
00282 {"leave.s", IL_OPCODE_ARGS_SHORT_JUMP, 2},
00283
00284 {"stdind.i", IL_OPCODE_ARGS_NONE, 1},
00285
00286 {"conv.u", IL_OPCODE_ARGS_NONE, 1},
00287
00288 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00289 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00290 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00291 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00292 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00293 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00294 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00295 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00296 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00297 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00298 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00299 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00300 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00301 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00302 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00303
00304 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00305 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00306 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00307 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00308 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00309 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00310 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00311 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00312 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00313 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00314 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00315 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00316 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00317 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00318
00319 {NULL, IL_OPCODE_ARGS_PREFIX, 3},
00320
00321 {NULL, IL_OPCODE_ARGS_INVALID, 1},
00322 };
00323
00324 ILOpcodeTabEntry il_prefix_opcode_table[MAX_IL_OPCODE_PREFIX] = {
00325 {"arglist", IL_OPCODE_ARGS_NONE, 2},
00326
00327 {"ceq", IL_OPCODE_ARGS_NONE, 2},
00328 {"cgt", IL_OPCODE_ARGS_NONE, 2},
00329 {"cgt.un", IL_OPCODE_ARGS_NONE, 2},
00330 {"clt", IL_OPCODE_ARGS_NONE, 2},
00331 {"clt.un", IL_OPCODE_ARGS_NONE, 2},
00332
00333 {"ldftn", IL_OPCODE_ARGS_TOKEN, 6},
00334 {"ldvirtftn", IL_OPCODE_ARGS_TOKEN, 6},
00335
00336 {"jmpi", IL_OPCODE_ARGS_CALLI, 6},
00337
00338 {"ldarg", IL_OPCODE_ARGS_LONG_VAR, 4},
00339 {"ldarga", IL_OPCODE_ARGS_LONG_VAR, 4},
00340 {"starg", IL_OPCODE_ARGS_LONG_VAR, 4},
00341 {"ldloc", IL_OPCODE_ARGS_LONG_VAR, 4},
00342 {"ldloca", IL_OPCODE_ARGS_LONG_VAR, 4},
00343 {"stloc", IL_OPCODE_ARGS_LONG_VAR, 4},
00344
00345 {"localloc", IL_OPCODE_ARGS_NONE, 2},
00346
00347 {NULL, IL_OPCODE_ARGS_INVALID, 2},
00348
00349 {"endfilter", IL_OPCODE_ARGS_NONE, 2},
00350 {"unaligned.", IL_OPCODE_ARGS_UINT8, 3},
00351 {"volatile.", IL_OPCODE_ARGS_NONE, 2},
00352 {"tail.", IL_OPCODE_ARGS_NONE, 2},
00353 {"initobj", IL_OPCODE_ARGS_TOKEN, 6},
00354 {"ann.live", IL_OPCODE_ARGS_ANN_LIVE, 4},
00355 {"cpblk", IL_OPCODE_ARGS_NONE, 2},
00356 {"initblk", IL_OPCODE_ARGS_NONE, 2},
00357 {"ann.ref", IL_OPCODE_ARGS_ANN_REF, 4},
00358 {"rethrow", IL_OPCODE_ARGS_NONE, 2},
00359
00360 {NULL, IL_OPCODE_ARGS_INVALID, 2},
00361
00362 {"sizeof", IL_OPCODE_ARGS_TOKEN, 6},
00363 {"refanytype", IL_OPCODE_ARGS_NONE, 2},
00364
00365 {NULL, IL_OPCODE_ARGS_INVALID, 2},
00366 {NULL, IL_OPCODE_ARGS_INVALID, 2},
00367 {NULL, IL_OPCODE_ARGS_INVALID, 2},
00368 {NULL, IL_OPCODE_ARGS_INVALID, 2},
00369
00370 {"ann.data", IL_OPCODE_ARGS_ANN_DATA, 1},
00371 {"ann.arg", IL_OPCODE_ARGS_ANN_ARG, 4},
00372 };