aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Graphics.Shader/IntermediateRepresentation/OperandHelper.cs
blob: f883135520f19ccc72d0f7adec7dd0b91ba0bc9a (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
using Ryujinx.Graphics.Shader.Decoders;
using System;

namespace Ryujinx.Graphics.Shader.IntermediateRepresentation
{
    static class OperandHelper
    {
        public static Operand Argument(int value)
        {
            return new Operand(OperandType.Argument, value);
        }

        public static Operand Cbuf(int slot, int offset)
        {
            return new Operand(slot, offset);
        }

        public static Operand Const(int value)
        {
            return new Operand(OperandType.Constant, value);
        }

        public static Operand ConstF(float value)
        {
            return new Operand(OperandType.Constant, BitConverter.SingleToInt32Bits(value));
        }

        public static Operand Label()
        {
            return new Operand(OperandType.Label);
        }

        public static Operand Local()
        {
            return new Operand(OperandType.LocalVariable);
        }

        public static Operand Register(int index, RegisterType type)
        {
            return Register(new Register(index, type));
        }

        public static Operand Register(Register reg)
        {
            if (reg.IsRZ)
            {
                return Const(0);
            }
            else if (reg.IsPT)
            {
                return Const(IrConsts.True);
            }

            return new Operand(reg);
        }

        public static Operand Undef()
        {
            return new Operand(OperandType.Undefined);
        }
    }
}