aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Cpu/LightningJit/Arm32/InstInfoForTable.cs
blob: 25739d564696dec8652799e474e85041a820c5ac (plain) (blame)
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
78
79
using Ryujinx.Cpu.LightningJit.Table;
using System;

namespace Ryujinx.Cpu.LightningJit.Arm32
{
    readonly struct InstInfoForTable : IInstInfo
    {
        public uint Encoding { get; }
        public uint EncodingMask { get; }
        public InstEncoding[] Constraints { get; }
        public InstMeta Meta { get; }
        public IsaVersion Version => Meta.Version;
        public IsaFeature Feature => Meta.Feature;

        public InstInfoForTable(
            uint encoding,
            uint encodingMask,
            InstEncoding[] constraints,
            InstName name,
            Action<CodeGenContext, uint> emitFunc,
            IsaVersion isaVersion,
            IsaFeature isaFeature,
            InstFlags flags)
        {
            Encoding = encoding;
            EncodingMask = encodingMask;
            Constraints = constraints;
            Meta = new(name, emitFunc, isaVersion, isaFeature, flags);
        }

        public InstInfoForTable(
            uint encoding,
            uint encodingMask,
            InstEncoding[] constraints,
            InstName name,
            Action<CodeGenContext, uint> emitFunc,
            IsaVersion isaVersion,
            InstFlags flags) : this(encoding, encodingMask, constraints, name, emitFunc, isaVersion, IsaFeature.None, flags)
        {
        }

        public InstInfoForTable(
            uint encoding,
            uint encodingMask,
            InstName name,
            Action<CodeGenContext, uint> emitFunc,
            IsaVersion isaVersion,
            IsaFeature isaFeature,
            InstFlags flags) : this(encoding, encodingMask, null, name, emitFunc, isaVersion, isaFeature, flags)
        {
        }

        public InstInfoForTable(
            uint encoding,
            uint encodingMask,
            InstName name,
            Action<CodeGenContext, uint> emitFunc,
            IsaVersion isaVersion,
            InstFlags flags) : this(encoding, encodingMask, null, name, emitFunc, isaVersion, IsaFeature.None, flags)
        {
        }

        public bool IsConstrained(uint encoding)
        {
            if (Constraints != null)
            {
                foreach (InstEncoding constraint in Constraints)
                {
                    if ((encoding & constraint.EncodingMask) == constraint.Encoding)
                    {
                        return true;
                    }
                }
            }

            return false;
        }
    }
}