Exemple #1
0
        public static Instruction CreateBinaryInstruction(
            string mnemonic, OperationNode op, int exUnit,
            ValueNode vres, RegisterSet vresRegs,
            ValueNode v1, RegisterSet v1Regs,
            ValueNode v2, RegisterSet v2Regs)
        {
            InstructionPattern ip = new InstructionPattern();

            ip.AddNode(op);
            ip.AddNode(vres);
            ip.AddNode(v1);
            ip.AddNode(v2);
            ip.AddEdge(op, vres);
            ip.AddEdge(v1, op);
            ip.AddEdge(v2, op);

            ip.OperandValues.Add(v1);
            ip.OperandValues.Add(v2);
            ip.ResultValue = vres;

            Instruction i = new Instruction(mnemonic, ip);

            i.ExecutionUnit = exUnit;
            i.ResultRegisters = vresRegs;
            i.OperandsRegisters[0] = v1Regs;
            i.OperandsRegisters[1] = v2Regs;

            return i;
        }
Exemple #2
0
 public void CheckInvalidPatternTest()
 {
     Assert.AreEqual(-1,
                     InstructionPattern.CheckPattern(new object[] { ASM.push }, 0));
     Assert.AreEqual(-1,
                     InstructionPattern.CheckPattern(new object[] { ASM.mov, ASM.mov }, 0));
     Assert.AreEqual(-1,
                     InstructionPattern.CheckPattern(new object[] { ASM.mov, 42, REG.EAX, }, 0));
 }
Exemple #3
0
        public void CheckPatternTest()
        {
            Assert.AreEqual(2,
                            InstructionPattern.CheckPattern(new object[] { ASM.mov, REG.EAX, 10 }, 0));
            Assert.AreEqual(2,
                            InstructionPattern.CheckPattern(new object[] { ASM.ret, ASM.ret, ASM.ret, ASM.mov, REG.EAX, 10 }, 3));

            Assert.AreEqual(0,
                            InstructionPattern.CheckPattern(new object[] { ASM.ret }, 0));
            Assert.AreEqual(1,
                            InstructionPattern.CheckPattern(new object[] { ASM.push, 1 }, 0));
            Assert.AreEqual(1,
                            InstructionPattern.CheckPattern(new object[] { ASM.push, REG.EAX }, 0));
            Assert.AreEqual(1,
                            InstructionPattern.CheckPattern(new object[] { ASM.push, REG.EAX.Ptr }, 0));
        }
Exemple #4
0
        public void PrototypeDifference()
        {
            var firstProtoLes  = "result = intrinsic(\"arith.convert\", Intermediate, #(Intermediate))(X);";
            var secondProtoLes = "result = intrinsic(\"arith.convert\", Intermediate, #(From))(Y);";

            var firstProto = InstructionPattern.Parse(
                Les2LanguageService.Value.Parse(firstProtoLes).Single(),
                null);

            var secondProto = InstructionPattern.Parse(
                Les2LanguageService.Value.Parse(secondProtoLes).Single(),
                null);

            Assert.IsTrue(InstructionPatternPrototypeComparer.Instance.Equals(firstProto, firstProto));
            Assert.IsTrue(InstructionPatternPrototypeComparer.Instance.Equals(secondProto, secondProto));
            Assert.IsFalse(InstructionPatternPrototypeComparer.Instance.Equals(firstProto, secondProto));
            Assert.IsFalse(InstructionPatternPrototypeComparer.Instance.Equals(secondProto, firstProto));
        }
Exemple #5
0
        public static Instruction CreateLeftTernaryInstruction(
            string mnemonic, OperationNode op1, OperationNode op2, int exUnit,
            ValueNode vres, RegisterSet vresRegs,
            ValueNode v1, RegisterSet v1Regs,
            ValueNode v2, RegisterSet v2Regs,
            ValueNode v3, RegisterSet v3Regs)
        {
            InstructionPattern ip = new InstructionPattern();

            ip.AddNode(op1);
            ip.AddNode(op2);
            ip.AddNode(vres);
            ip.AddNode(v1);
            ip.AddNode(v2);
            ip.AddNode(v3);

            ValueNode iv1 = new RegisterValueNode(v1.Datatype);

            ip.AddNode(iv1);

            ip.AddEdge(v1, op1);
            ip.AddEdge(v2, op1);
            ip.AddEdge(op1, iv1);
            ip.AddEdge(iv1, op2);
            ip.AddEdge(v3, op2);
            ip.AddEdge(op2, vres);

            ip.OperandValues.Add(v1);
            ip.OperandValues.Add(v2);
            ip.OperandValues.Add(v3);
            ip.ResultValue = vres;

            Instruction i = new Instruction(mnemonic, ip);

            i.ExecutionUnit = exUnit;
            i.ResultRegisters = vresRegs;
            i.OperandsRegisters[0] = v1Regs;
            i.OperandsRegisters[1] = v2Regs;
            i.OperandsRegisters[2] = v3Regs;

            return i;
        }