예제 #1
0
        public void VpEquality2()
        {
            // Makes sure that
            // y = x - 2
            // if (y == 0) ...
            // doesn't get munged into
            // y = x - 2
            // if (x == 2)

            var x    = m.Reg32("x");
            var y    = m.Reg32("y");
            var stmX = m.Assign(x, m.LoadDw(Constant.Word32(0x1000300)));
            var stmY = m.Assign(y, m.ISub(x, 2));
            var stm  = m.BranchIf(m.Eq(y, 0), "test");

            Assert.AreEqual("x = Mem2[0x01000300:word32]", stmX.ToString());
            Assert.AreEqual("y = x - 0x00000002", stmY.ToString());
            Assert.AreEqual("branch y == 0x00000000 test", stm.ToString());

            var vp = new ValuePropagator(arch, m.Ssa, listener);

            vp.Transform(stm);
            Assert.AreEqual("branch x == 0x00000002 test", stm.Instruction.ToString());
        }
예제 #2
0
        public void UfuserMipsLittleEndianUnalignedWordLoad()
        {
            var r4 = m.Reg32("r4");
            var r8 = m.Reg32("r8");

            __lwl(r8, m.LoadDw(m.IAdd(r4, 0x2B)));
            __lwr(r8, m.LoadDw(m.IAdd(r4, 0x28)));
            var ssa  = RunTest(m);
            var sExp =
                #region Expected
                @"r8:r8
    def:  def r8
    uses: r8_3 = r8
r4:r4
    def:  def r4
    uses: r8_5 = Mem3[r4 + 0x00000028:word32]
Mem2:Global memory
    def:  def Mem2
r8_3: orig: r8
    def:  r8_3 = r8
Mem3:Global memory
    def:  def Mem3
    uses: r8_5 = Mem3[r4 + 0x00000028:word32]
r8_5: orig: r8
    def:  r8_5 = Mem3[r4 + 0x00000028:word32]
// SsaProcedureBuilder
// Return size: 0
void SsaProcedureBuilder()
SsaProcedureBuilder_entry:
	def r8
	def r4
	def Mem2
	def Mem3
	// succ:  l1
l1:
	r8_5 = Mem3[r4 + 0x00000028:word32]
SsaProcedureBuilder_exit:
";

            #endregion
            AssertStringsEqual(sExp, ssa);
        }