Пример #1
0
 protected static ulong GetVectorE1(V128 vector) => vector.Extract <ulong>(1);
Пример #2
0
 private static SimdValue V128ToSimdValue(V128 value)
 {
     return(new SimdValue(value.Extract <ulong>(0), value.Extract <ulong>(1)));
 }
Пример #3
0
 public static V128 CompareAndSwap128(IntPtr address, V128 expected, V128 desired)
 {
     return(GetCompareAndSwap128()(address, expected, desired));
 }
Пример #4
0
        protected void SetContext(ulong x0      = 0,
                                  ulong x1      = 0,
                                  ulong x2      = 0,
                                  ulong x3      = 0,
                                  ulong x31     = 0,
                                  V128 v0       = default,
                                  V128 v1       = default,
                                  V128 v2       = default,
                                  V128 v3       = default,
                                  V128 v4       = default,
                                  V128 v5       = default,
                                  V128 v30      = default,
                                  V128 v31      = default,
                                  bool overflow = false,
                                  bool carry    = false,
                                  bool zero     = false,
                                  bool negative = false,
                                  int fpcr      = 0,
                                  int fpsr      = 0)
        {
            _context.SetX(0, x0);
            _context.SetX(1, x1);
            _context.SetX(2, x2);
            _context.SetX(3, x3);
            _context.SetX(31, x31);

            _context.SetV(0, v0);
            _context.SetV(1, v1);
            _context.SetV(2, v2);
            _context.SetV(3, v3);
            _context.SetV(4, v4);
            _context.SetV(5, v5);
            _context.SetV(30, v30);
            _context.SetV(31, v31);

            _context.SetPstateFlag(PState.VFlag, overflow);
            _context.SetPstateFlag(PState.CFlag, carry);
            _context.SetPstateFlag(PState.ZFlag, zero);
            _context.SetPstateFlag(PState.NFlag, negative);

            _context.Fpcr = (FPCR)fpcr;
            _context.Fpsr = (FPSR)fpsr;

            if (_unicornAvailable)
            {
                _unicornEmu.X[0] = x0;
                _unicornEmu.X[1] = x1;
                _unicornEmu.X[2] = x2;
                _unicornEmu.X[3] = x3;
                _unicornEmu.SP   = x31;

                _unicornEmu.Q[0]  = V128ToSimdValue(v0);
                _unicornEmu.Q[1]  = V128ToSimdValue(v1);
                _unicornEmu.Q[2]  = V128ToSimdValue(v2);
                _unicornEmu.Q[3]  = V128ToSimdValue(v3);
                _unicornEmu.Q[4]  = V128ToSimdValue(v4);
                _unicornEmu.Q[5]  = V128ToSimdValue(v5);
                _unicornEmu.Q[30] = V128ToSimdValue(v30);
                _unicornEmu.Q[31] = V128ToSimdValue(v31);

                _unicornEmu.OverflowFlag = overflow;
                _unicornEmu.CarryFlag    = carry;
                _unicornEmu.ZeroFlag     = zero;
                _unicornEmu.NegativeFlag = negative;

                _unicornEmu.Fpcr = fpcr;
                _unicornEmu.Fpsr = fpsr;
            }
        }
Пример #5
0
        protected void SetContext(uint r0         = 0,
                                  uint r1         = 0,
                                  uint r2         = 0,
                                  uint r3         = 0,
                                  uint sp         = 0,
                                  V128 v0         = default,
                                  V128 v1         = default,
                                  V128 v2         = default,
                                  V128 v3         = default,
                                  V128 v4         = default,
                                  V128 v5         = default,
                                  V128 v14        = default,
                                  V128 v15        = default,
                                  bool saturation = false,
                                  bool overflow   = false,
                                  bool carry      = false,
                                  bool zero       = false,
                                  bool negative   = false,
                                  int fpscr       = 0)
        {
            _context.SetX(0, r0);
            _context.SetX(1, r1);
            _context.SetX(2, r2);
            _context.SetX(3, r3);
            _context.SetX(13, sp);

            _context.SetV(0, v0);
            _context.SetV(1, v1);
            _context.SetV(2, v2);
            _context.SetV(3, v3);
            _context.SetV(4, v4);
            _context.SetV(5, v5);
            _context.SetV(14, v14);
            _context.SetV(15, v15);

            _context.SetPstateFlag(PState.QFlag, saturation);
            _context.SetPstateFlag(PState.VFlag, overflow);
            _context.SetPstateFlag(PState.CFlag, carry);
            _context.SetPstateFlag(PState.ZFlag, zero);
            _context.SetPstateFlag(PState.NFlag, negative);

            SetFpscr((uint)fpscr);

            if (_unicornAvailable)
            {
                _unicornEmu.R[0] = r0;
                _unicornEmu.R[1] = r1;
                _unicornEmu.R[2] = r2;
                _unicornEmu.R[3] = r3;
                _unicornEmu.SP   = sp;

                _unicornEmu.Q[0]  = V128ToSimdValue(v0);
                _unicornEmu.Q[1]  = V128ToSimdValue(v1);
                _unicornEmu.Q[2]  = V128ToSimdValue(v2);
                _unicornEmu.Q[3]  = V128ToSimdValue(v3);
                _unicornEmu.Q[4]  = V128ToSimdValue(v4);
                _unicornEmu.Q[5]  = V128ToSimdValue(v5);
                _unicornEmu.Q[14] = V128ToSimdValue(v14);
                _unicornEmu.Q[15] = V128ToSimdValue(v15);

                _unicornEmu.QFlag        = saturation;
                _unicornEmu.OverflowFlag = overflow;
                _unicornEmu.CarryFlag    = carry;
                _unicornEmu.ZeroFlag     = zero;
                _unicornEmu.NegativeFlag = negative;

                _unicornEmu.Fpscr = fpscr;
            }
        }