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#pragma once
6
7#include "compiler.h"
8#include "phase.h"
9
10class StackLevelSetter : public Phase
11{
12public:
13 StackLevelSetter(Compiler* compiler);
14
15 virtual void DoPhase() override;
16
17private:
18 void ProcessBlock(BasicBlock* block);
19
20#if !FEATURE_FIXED_OUT_ARGS
21 void SetThrowHelperBlocks(GenTree* node, BasicBlock* block);
22 void SetThrowHelperBlock(SpecialCodeKind kind, BasicBlock* block);
23#endif // !FEATURE_FIXED_OUT_ARGS
24
25 unsigned PopArgumentsFromCall(GenTreeCall* call);
26 void AddStackLevel(unsigned value);
27 void SubStackLevel(unsigned value);
28
29 void CheckArgCnt();
30 void CheckAdditionalArgs();
31
32private:
33 unsigned currentStackLevel; // current number of stack slots used by arguments.
34 unsigned maxStackLevel; // max number of stack slots for arguments.
35
36 CompAllocator memAllocator;
37
38 typedef JitHashTable<GenTreePutArgStk*, JitPtrKeyFuncs<GenTreePutArgStk>, unsigned> PutArgNumSlotsMap;
39 PutArgNumSlotsMap putArgNumSlots; // The hash table keeps stack slot sizes for active GT_PUTARG_STK nodes.
40
41#if !FEATURE_FIXED_OUT_ARGS
42 bool framePointerRequired; // Is frame pointer required based on the analysis made by this phase.
43 bool throwHelperBlocksUsed; // Were any throw helper blocks created for this method.
44#endif // !FEATURE_FIXED_OUT_ARGS
45};
46