aboutsummaryrefslogtreecommitdiff
path: root/ARMeilleure/IntermediateRepresentation/OperandHelper.cs
blob: 4a930e03f42ccd628f978b3c075cf12128f4ad62 (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
using ARMeilleure.State;
using System;

namespace ARMeilleure.IntermediateRepresentation
{
    static class OperandHelper
    {
        public static Operand Const(OperandType type, long value)
        {
            return type == OperandType.I32 ? new Operand((int)value) : new Operand(value);
        }

        public static Operand Const(bool value)
        {
            return new Operand(value ? 1 : 0);
        }

        public static Operand Const(int value)
        {
            return new Operand(value);
        }

        public static Operand Const(uint value)
        {
            return new Operand(value);
        }

        public static Operand Const(long value)
        {
            return new Operand(value);
        }

        public static Operand Const(ulong value)
        {
            return new Operand(value);
        }

        public static Operand ConstF(float value)
        {
            return new Operand(value);
        }

        public static Operand ConstF(double value)
        {
            return new Operand(value);
        }

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

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

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

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