1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
5 /***************************************************************************/
7 /***************************************************************************/
10 #include <cor.h> // for debugMacros.h
11 #include "debugmacros.h" // for ASSERTE
15 OpInfo::OpInfoData OpInfo::table[] = {
17 #define OPDEF(c,s,pop,push,args,type,l,s1,s2,ctrl) \
18 { s, (OPCODE_FORMAT) (args + type), FLOW_ ## ctrl, pop, push, c },
20 // Kind of a workaround, get the prefixes (IInternal) to return InlineOpcode instead of InlineNone
21 #define IInternal (InlineOpcode - InlineNone)
53 /***************************************************************************/
54 /* parse instruction at 'instrPtr', into its opcode (OpInfo), and its
55 (inline)args, 'args' 'instrPtr' is updated */
57 /***************************************************************************/
58 const BYTE* OpInfo::fetch(const BYTE* instrPtr, OpArgsVal* args) {
60 data = &table[*instrPtr++];
62 _ASSERTE(data - table == data->opcode);
63 switch(data->format) {
67 _ASSERTE(*instrPtr + 256 < (int) (sizeof(table) / sizeof(OpInfoData)));
68 data = &table[256 + *instrPtr++];
72 args->i = *instrPtr; instrPtr +=1;
75 args->i = GET_UNALIGNED_VAL16(instrPtr); instrPtr +=2;
78 case ShortInlineBrTarget:
79 args->i = *instrPtr; instrPtr +=1;
82 DWORD f = GET_UNALIGNED_VAL32(instrPtr); instrPtr +=4;
83 args->r = *((float*) (&f));
95 args->i = GET_UNALIGNED_VAL32(instrPtr); instrPtr +=4;
98 args->i8 = GET_UNALIGNED_VAL64(instrPtr); instrPtr +=8;
101 __int64 d = GET_UNALIGNED_VAL64(instrPtr); instrPtr +=8;
102 args->r = *((double*) (&d));
105 args->switch_.count = GET_UNALIGNED_VAL32(instrPtr); instrPtr +=4;
106 args->switch_.targets = (int*) instrPtr; instrPtr += (4 * args->switch_.count);
109 args->phi.count = GET_UNALIGNED_VAL32(instrPtr); instrPtr +=1;
110 args->phi.vars = (unsigned short*) instrPtr; instrPtr += (2 * args->phi.count);
114 _ASSERTE(!"BadType");
116 __assume(0); // we are really certain the default case does not happen