Fix reading Time zone rules using Julian days (#17672)
[platform/upstream/coreclr.git] / src / jit / sm.h
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 // State machine header used ONLY in the JIT.
7 //
8
9 #ifndef __sm_h__
10 #define __sm_h__
11
12 #include "smcommon.h"
13
14 extern const SMState*       gp_SMStates;
15 extern const JumpTableCell* gp_SMJumpTableCells;
16 extern const short*         gp_StateWeights;
17
18 class CodeSeqSM // Represent a particualr run of the state machine
19                 // For example, it maintains the array of counts for the terminated states.
20                 // These counts should be stored in per method based for them to be correct
21                 // under multithreadeded environment.
22 {
23 public:
24     Compiler* pComp;
25
26     const SMState*       States;
27     const JumpTableCell* JumpTableCells;
28     const short*         StateWeights; // Weight for each state. Including non-terminate states.
29
30     SM_STATE_ID curState;
31
32     int NativeSize; // This is a signed integer!
33
34     void Start(Compiler* comp);
35     void Reset();
36     void End();
37     void Run(SM_OPCODE opcode DEBUGARG(int level));
38
39     SM_STATE_ID GetDestState(SM_STATE_ID srcState, SM_OPCODE opcode);
40
41     // Matched a termination state
42     inline void TermStateMatch(SM_STATE_ID stateID DEBUGARG(bool verbose))
43     {
44         assert(States[stateID].term);
45 #ifdef DEBUG
46 #ifndef SMGEN_COMPILE
47         if (verbose)
48         {
49             printf("weight=%3d : state %3d [ %s ]\n", StateWeights[stateID], stateID, StateDesc(stateID));
50         }
51 #endif // SMGEN_COMPILE
52 #endif // DEBUG
53
54         NativeSize += StateWeights[stateID];
55     }
56
57     // Given an SM opcode retrieve the weight for this single opcode state.
58     // For example, ID for single opcode state SM_NOSHOW is 2.
59     inline short GetWeightForOpcode(SM_OPCODE opcode)
60     {
61         SM_STATE_ID stateID = ((SM_STATE_ID)opcode) + SM_STATE_ID_START + 1;
62         return StateWeights[stateID];
63     }
64
65 #ifdef DEBUG
66     const char* StateDesc(SM_STATE_ID stateID);
67 #endif
68
69     static SM_OPCODE MapToSMOpcode(OPCODE opcode);
70 };
71
72 #endif /* __sm_h__ */