예제 #1
0
        private static void InsertInst(
            int XMask,
            int Value,
            AInst Inst,
            AExecutionMode Mode)
        {
            InstInfo Info = new InstInfo(XMask, Value, Inst);

            if (Mode == AExecutionMode.AArch64)
            {
                AllInstA64.Add(Info);
            }
            else
            {
                AllInstA32.Add(Info);
            }
        }
예제 #2
0
        private static void InsertTop(
            int XMask,
            int Value,
            AInst Inst,
            AExecutionMode Mode)
        {
            TreeNode Node = new TreeNode(XMask, Value, Inst);

            if (Mode == AExecutionMode.AArch64)
            {
                Node.Next = InstHeadA64;

                InstHeadA64 = Node;
            }
            else
            {
                Node.Next = InstHeadA32;

                InstHeadA32 = Node;
            }
        }
예제 #3
0
        private static void Set(string Encoding, AInst Inst, AExecutionMode Mode)
        {
            int Bit   = Encoding.Length - 1;
            int Value = 0;
            int XMask = 0;
            int XBits = 0;

            int[] XPos = new int[Encoding.Length];

            int Blacklisted = 0;

            for (int Index = 0; Index < Encoding.Length; Index++, Bit--)
            {
                //Note: < and > are used on special encodings.
                //The < means that we should never have ALL bits with the '<' set.
                //So, when the encoding has <<, it means that 00, 01, and 10 are valid,
                //but not 11. <<< is 000, 001, ..., 110 but NOT 111, and so on...
                //For >, the invalid value is zero. So, for >> 01, 10 and 11 are valid,
                //but 00 isn't.
                char Chr = Encoding[Index];

                if (Chr == '1')
                {
                    Value |= 1 << Bit;
                }
                else if (Chr == 'x')
                {
                    XMask |= 1 << Bit;
                }
                else if (Chr == '>')
                {
                    XPos[XBits++] = Bit;
                }
                else if (Chr == '<')
                {
                    XPos[XBits++] = Bit;

                    Blacklisted |= 1 << Bit;
                }
                else if (Chr != '0')
                {
                    throw new ArgumentException(nameof(Encoding));
                }
            }

            XMask = ~XMask;

            if (XBits == 0)
            {
                InsertInst(XMask, Value, Inst, Mode);

                return;
            }

            for (int Index = 0; Index < (1 << XBits); Index++)
            {
                int Mask = 0;

                for (int X = 0; X < XBits; X++)
                {
                    Mask |= ((Index >> X) & 1) << XPos[X];
                }

                if (Mask != Blacklisted)
                {
                    InsertInst(XMask, Value | Mask, Inst, Mode);
                }
            }
        }