| 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. |
| 4 | |
| 5 | // |
| 6 | // Common headers used both in smgen.exe and the JIT. |
| 7 | // |
| 8 | |
| 9 | #ifndef __sm_common_h__ |
| 10 | #define __sm_common_h__ |
| 11 | |
| 12 | #include "smopenum.h" |
| 13 | |
| 14 | #define NUM_SM_STATES 250 |
| 15 | |
| 16 | typedef BYTE SM_STATE_ID; |
| 17 | |
| 18 | static_assert_no_msg(sizeof(SM_STATE_ID) == 1); // To conserve memory, we don't want to have more than 256 states. |
| 19 | |
| 20 | #define SM_STATE_ID_START 1 |
| 21 | |
| 22 | static_assert_no_msg(SM_STATE_ID_START == 1); // Make sure nobody changes it. We rely on this to map the SM_OPCODE |
| 23 | // to single-opcode states. For example, in GetWeightForOpcode(). |
| 24 | |
| 25 | struct JumpTableCell |
| 26 | { |
| 27 | SM_STATE_ID srcState; |
| 28 | SM_STATE_ID destState; |
| 29 | }; |
| 30 | |
| 31 | struct SMState |
| 32 | { |
| 33 | bool term; // does this state terminate a code sequence? |
| 34 | BYTE length; // the length of currently matched opcodes |
| 35 | SM_STATE_ID longestTermState; // the ID of the longest matched terminate state |
| 36 | |
| 37 | SM_STATE_ID prevState; // previous state |
| 38 | SM_OPCODE opc; // opcode that leads from the previous state to current state |
| 39 | |
| 40 | unsigned short jumpTableByteOffset; |
| 41 | }; |
| 42 | |
| 43 | // |
| 44 | // Code sequences |
| 45 | // |
| 46 | |
| 47 | #define MAX_CODE_SEQUENCE_LENGTH 7 |
| 48 | #define CODE_SEQUENCE_END ((SM_OPCODE)(SM_COUNT + 1)) |
| 49 | |
| 50 | #endif /* __sm_common_h__ */ |
| 51 | |