Ejemplo n.º 1
0
        public void ArmArch_CreateRewriter()
        {
            this.arch = new Arm32Architecture(new ServiceContainer(), "arm32");
            var mem = new MemoryArea(Address.Ptr32(0x00123400), new byte[] { 0x03, 0x10, 0x12, 0xE0 });

            var rdr = mem.CreateLeReader(0);
            var rw  = arch.CreateRewriter(rdr, new AArch32ProcessorState(arch), new StorageBinder(), null);
            var rtl = rw.First().Instructions[0];

            Assert.AreEqual("r1 = r2 & r3", rtl.ToString());
        }
Ejemplo n.º 2
0
        public void ArmArch_CreateDisassembler()
        {
            this.arch = new Arm32Architecture(new ServiceContainer(), "arm32");
            var mem = new MemoryArea(Address.Ptr32(0x00123400), new byte[] { 0x03, 0x10, 0x12, 0xE0 });

            var rdr  = mem.CreateLeReader(0);
            var dasm = arch.CreateDisassembler(rdr);
            var str  = dasm.First().ToString();

            Assert.AreEqual("ands\tr1,r2,r3", str);
        }
Ejemplo n.º 3
0
        private void RewriteVectorUnaryOp(string fnNameFormat, ArmVectorData elemType)
        {
            var src1        = this.Operand(Src1());
            var dst         = this.Operand(Dst(), PrimitiveType.Word32, true);
            var dstType     = Dst().Width;
            var srcType     = Src1().Width;
            var srcElemSize = Arm32Architecture.VectorElementDataType(elemType);
            var celemSrc    = srcType.BitSize / srcElemSize.BitSize;
            var arrSrc      = new ArrayType(srcType, celemSrc);
            var arrDst      = new ArrayType(dstType, celemSrc);
            var fnName      = string.Format(fnNameFormat, VectorElementTypeName(elemType));
            var intrinsic   = host.Intrinsic(fnName, true, arrDst, src1);

            m.Assign(dst, intrinsic);
        }
Ejemplo n.º 4
0
        private void RewriteVmul()
        {
            var src1        = this.Operand(Src1());
            var src2        = this.Operand(Src2());
            var dst         = this.Operand(Dst(), PrimitiveType.Word32, true);
            var dstType     = Dst().Width;
            var srcType     = Src1().Width;
            var srcElemSize = Arm32Architecture.VectorElementDataType(instr.vector_data);
            var celemSrc    = srcType.BitSize / srcElemSize.BitSize;
            var arrSrc      = new ArrayType(srcType, celemSrc);
            var arrDst      = new ArrayType(dstType, celemSrc);
            var fnName      = $"__vmul_{VectorElementTypeName(instr.vector_data)}";
            var intrinsic   = host.Intrinsic(fnName, true, arrDst, src1, src2);

            m.Assign(dst, m.Fn(intrinsic));
        }
Ejemplo n.º 5
0
        private void RewriteVectorBinOp(string fnNameFormat, ArmVectorData elemType)
        {
            var src1        = this.Operand(Src1());
            var src2        = this.Operand(Src2());
            var dst         = this.Operand(Dst(), PrimitiveType.Word32, true);
            var dstType     = Dst().Width;
            var srcType     = Src1().Width;
            var srcElemSize = Arm32Architecture.VectorElementDataType(elemType);
            //$BUG: some instructions are returned with srcElemnSize == 0!
            var celemSrc  = srcType.BitSize / (srcElemSize.BitSize != 0 ? srcElemSize.BitSize : 8);
            var arrSrc    = new ArrayType(srcType, celemSrc);
            var arrDst    = new ArrayType(dstType, celemSrc);
            var fnName    = string.Format(fnNameFormat, VectorElementType(elemType));
            var intrinsic = host.PseudoProcedure(fnName, arrDst, src1, src2);

            m.Assign(dst, intrinsic);
        }
Ejemplo n.º 6
0
        private void RewriteVmov()
        {
            //if (instr.ops.Length > 2) throw new NotImplementedException();
            var dst = this.Operand(Dst(), PrimitiveType.Word32, true);
            var src = this.Operand(Src1());

            if (instr.vector_data != ArmVectorData.INVALID && !(src is ArrayAccess))
            {
                var dt          = Arm32Architecture.VectorElementDataType(instr.vector_data);
                var dstType     = Dst().Width;
                var srcType     = Src1().Width;
                var srcElemSize = Arm32Architecture.VectorElementDataType(instr.vector_data);
                var celemSrc    = dstType.BitSize / srcElemSize.BitSize;
                var arrDst      = new ArrayType(dstType, celemSrc);

                if (Src1() is ImmediateOperand imm)
                {
                    if (dst.DataType.BitSize == 128)
                    {
                        src = m.Seq(src, src);
                    }
                    m.Assign(dst, src);
                    return;
                }

                var fname     = $"__vmov_{VectorElementTypeName(instr.vector_data)}";
                var intrinsic = host.Intrinsic(fname, true, Dst().Width, src);
                m.Assign(dst, m.Fn(intrinsic));
            }
            else
            {
                if (dst.DataType.BitSize != src.DataType.BitSize)
                {
                    src = m.Convert(src, src.DataType, dst.DataType);
                }
                m.Assign(dst, src);
            }
        }
Ejemplo n.º 7
0
 public void Setup()
 {
     arch = new Arm32Architecture(new ServiceContainer(), "arm32", new Dictionary <string, object>());
 }
Ejemplo n.º 8
0
 public void Setup()
 {
     arch = new Arm32Architecture("arm32");
 }
Ejemplo n.º 9
0
 public void Setup()
 {
     arch = new Arm32Architecture(new ServiceContainer(), "arm32");
 }