public void Emt_MatchAnyConstant()
        {
            var c = Constant.Word32(4);

            Create(ExpressionMatcher.AnyConstant("c"));
            Assert.IsTrue(matcher.Match(c));
            Assert.AreEqual("0x00000004", matcher.CapturedExpression("c").ToString());
        }
Exemple #2
0
        public void MatchAssignment()
        {
            var ax      = RegW("ax");
            var pattern = m.Assign(ax, m.IAdd(ax, ExpressionMatcher.AnyConstant("c")));

            var instrmatcher = new InstructionMatcher(pattern);

            Assert.IsTrue(instrmatcher.Match(
                              m.Assign(ax, m.IAdd(ax, m.Word16(42)))));

            Assert.AreEqual("0x002A", instrmatcher.CapturedExpressions("c").ToString());
        }
Exemple #3
0
        private static PredicateCheck CreateFrom(IExpression expression)
        {
            Contract.Requires(expression != null);

            var matcher = new ExpressionMatcher(expression);

            return(matcher.Match(
                       equality => (PredicateCheck)EqualityExpressionPredicateCheck.TryCreate(equality),
                       unaryOperator => MethodCallPredicateCheck.TryCreate(unaryOperator),
                       invocation => MethodCallPredicateCheck.TryCreate(invocation),
                       csharpExpression => null));
        }
Exemple #4
0
 public AmigaOSPlatform(IServiceProvider services, IProcessorArchitecture arch)
     : base(services, arch, "amigaOS")
 {
     this.a6Pattern = new RtlInstructionMatcher(
         new RtlCall(
             new BinaryExpression(
                 Operator.IAdd,
                 PrimitiveType.Word32,
                 ExpressionMatcher.AnyId("addrReg"),
                 ExpressionMatcher.AnyConstant("offset")),
             4,
             InstrClass.Transfer));
 }
Exemple #5
0
        static LongAddRewriter()
        {
            condm = new InstructionMatcher(
                new Assignment(
                    ExpressionMatcher.AnyId("grf"),
                    new ConditionOf(
                        ExpressionMatcher.AnyExpression("exp"))));

            addPattern = new InstructionMatcher(
                new Assignment(
                    ExpressionMatcher.AnyId("dst"),
                    new BinaryExpression(
                        ExpressionMatcher.AnyOperator("op"),
                        VoidType.Instance,
                        ExpressionMatcher.AnyExpression("left"),
                        ExpressionMatcher.AnyExpression("right"))));

            adcPattern = new InstructionMatcher(
                new Assignment(
                    ExpressionMatcher.AnyId("dst"),
                    new BinaryExpression(
                        ExpressionMatcher.AnyOperator("op1"),
                        VoidType.Instance,
                        new BinaryExpression(
                            ExpressionMatcher.AnyOperator("op2"),
                            VoidType.Instance,
                            ExpressionMatcher.AnyExpression("left"),
                            ExpressionMatcher.AnyExpression("right")),
                        ExpressionMatcher.AnyExpression("cf"))));

            memOffset = new ExpressionMatcher(
                new MemoryAccess(
                    new BinaryExpression(
                        ExpressionMatcher.AnyOperator("op"),
                        VoidType.Instance,
                        ExpressionMatcher.AnyExpression("base"),
                        ExpressionMatcher.AnyConstant("offset")),
                    ExpressionMatcher.AnyDataType("dt")));

            segMemOffset = new ExpressionMatcher(
                new SegmentedAccess(
                    null,
                    ExpressionMatcher.AnyId(),
                    new BinaryExpression(
                        ExpressionMatcher.AnyOperator("op"),
                        VoidType.Instance,
                        ExpressionMatcher.AnyExpression("base"),
                        ExpressionMatcher.AnyConstant("offset")),
                    ExpressionMatcher.AnyDataType("dt")));
        }
 private void Create(Expression pattern)
 {
     matcher = new ExpressionMatcher(pattern);
 }
 private Operator AnyOp(string label)
 {
     return(ExpressionMatcher.AnyOperator(label));
 }
 private Expression AnyId(string label)
 {
     return(ExpressionMatcher.AnyId(label));
 }
 private Expression AnyC(string p)
 {
     return(ExpressionMatcher.AnyConstant(p));
 }
Exemple #10
0
 public RtlInstructionMatcher(RtlInstruction pattern)
 {
     this.pattern = pattern;
     this.matcher = new ExpressionMatcher(null !);
 }
 private void Create(Expression pattern)
 {
     matcher = new ExpressionMatcher(pattern);
 }
Exemple #12
0
        static LongAddRewriter()
        {
            condm = new InstructionMatcher(
                new Assignment(
                    ExpressionMatcher.AnyId("grf"),
                    new ConditionOf(
                        ExpressionMatcher.AnyExpression("exp"))));

            addPattern = new InstructionMatcher(
                new Assignment(
                    ExpressionMatcher.AnyId("dst"),
                    new BinaryExpression(
                        ExpressionMatcher.AnyOperator("op"),
                        VoidType.Instance,
                        ExpressionMatcher.AnyExpression("left"),
                        ExpressionMatcher.AnyExpression("right"))));

            adcPattern = new InstructionMatcher(
                new Assignment(
                    ExpressionMatcher.AnyId("dst"),
                    new BinaryExpression(
                        ExpressionMatcher.AnyOperator("op1"),
                        VoidType.Instance,
                        new BinaryExpression(
                            ExpressionMatcher.AnyOperator("op2"),
                            VoidType.Instance,
                            ExpressionMatcher.AnyExpression("left"),
                            ExpressionMatcher.AnyExpression("right")),
                        ExpressionMatcher.AnyExpression("cf"))));

            memOffset = new ExpressionMatcher(
                new MemoryAccess(
                    new BinaryExpression(
                        ExpressionMatcher.AnyOperator("op"),
                        VoidType.Instance,
                        ExpressionMatcher.AnyExpression("base"),
                        ExpressionMatcher.AnyConstant("offset")),
                    ExpressionMatcher.AnyDataType("dt")));

            segMemOffset = new ExpressionMatcher(
                new SegmentedAccess(
                    null,
                    ExpressionMatcher.AnyId(),
                    new BinaryExpression(
                        ExpressionMatcher.AnyOperator("op"),
                        VoidType.Instance,
                        ExpressionMatcher.AnyExpression("base"),
                        ExpressionMatcher.AnyConstant("offset")),
                    ExpressionMatcher.AnyDataType("dt")));
        }