summaryrefslogtreecommitdiff
path: root/src/jit/decomposelongs.h
blob: c008fa255c0ed759f19d1a1f76c9a4624f1ebaa8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX                                                                           XX
XX                               DecomposeLongs                              XX
XX                                                                           XX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

#ifndef _DECOMPOSELONGS_H_
#define _DECOMPOSELONGS_H_

#include "compiler.h"

class DecomposeLongs
{
public:
    DecomposeLongs(Compiler* compiler) : m_compiler(compiler)
    {
    }

    void PrepareForDecomposition();
    void DecomposeBlock(BasicBlock* block);

    static void DecomposeRange(Compiler* compiler, unsigned blockWeight, LIR::Range& range);

private:
    inline LIR::Range& Range() const
    {
        return *m_range;
    }

    // Driver functions
    void     DecomposeRangeHelper();
    GenTree* DecomposeNode(GenTree* tree);

    // Per-node type decompose cases
    GenTree* DecomposeLclVar(LIR::Use& use);
    GenTree* DecomposeLclFld(LIR::Use& use);
    GenTree* DecomposeStoreLclVar(LIR::Use& use);
    GenTree* DecomposeStoreLclFld(LIR::Use& use);
    GenTree* DecomposeCast(LIR::Use& use);
    GenTree* DecomposeCnsLng(LIR::Use& use);
    GenTree* DecomposeFieldList(GenTreeFieldList* listNode, GenTreeOp* longNode);
    GenTree* DecomposeCall(LIR::Use& use);
    GenTree* DecomposeInd(LIR::Use& use);
    GenTree* DecomposeStoreInd(LIR::Use& use);
    GenTree* DecomposeNot(LIR::Use& use);
    GenTree* DecomposeNeg(LIR::Use& use);
    GenTree* DecomposeArith(LIR::Use& use);
    GenTree* DecomposeShift(LIR::Use& use);
    GenTree* DecomposeRotate(LIR::Use& use);
    GenTree* DecomposeMul(LIR::Use& use);
    GenTree* DecomposeUMod(LIR::Use& use);
    GenTree* DecomposeSimd(LIR::Use& use);
    GenTree* DecomposeSimdGetItem(LIR::Use& use);

    // Helper functions
    GenTree* FinalizeDecomposition(LIR::Use& use, GenTree* loResult, GenTree* hiResult, GenTree* insertResultAfter);
    GenTree* RepresentOpAsLocalVar(GenTree* op, GenTree* user, GenTree** edge);
    GenTree* EnsureIntSized(GenTree* node, bool signExtend);

    GenTree* StoreNodeToVar(LIR::Use& use);
    static genTreeOps GetHiOper(genTreeOps oper);
    static genTreeOps GetLoOper(genTreeOps oper);

    // Data
    Compiler*   m_compiler;
    unsigned    m_blockWeight;
    LIR::Range* m_range;
};

#endif // _DECOMPOSELONGS_H_