Пример #1
0
        private void EmitUnitTest()
        {
            m.Invalid();
            iclass = InstrClass.Invalid;

            if (seenMnemonics.Contains(instr.Mnemonic))
            {
                return;
            }
            seenMnemonics.Add(instr.Mnemonic);
            host.Warn(
                instr.Address,
                "M6809 instruction '{0}' is not supported yet.",
                instr.Mnemonic.ToString());

            var r2 = rdr.Clone();

            r2.Offset -= instr.Length;
            var hexBytes = string.Join("", r2.ReadBytes(instr.Length).Select(b => $"{b:X2}"));

            var sb = new StringBuilder();

            sb.AppendLine($"        [Test]");
            sb.AppendLine($"        public void M6809Rw_{instr.Mnemonic}()");
            sb.AppendLine("        {");
            sb.AppendLine($"            RewriteCode(\"{hexBytes}\"); // {instr}");
            sb.AppendLine($"            AssertCode(");
            sb.AppendLine($"                \"0|L--|0100({instr.Length}): 1 instructions\",");
            sb.AppendLine($"                \"1|L--|@@@\");");
            sb.AppendLine("        }");
            Debug.WriteLine(sb.ToString());
            Console.WriteLine(sb.ToString());
        }
Пример #2
0
 private void NotImplementedInstruction()
 {
     host.Warn(
         instrCur.Address,
         "MicroBlaze instruction '{0}' is not supported yet.",
         instrCur.Mnemonic);
     EmitUnitTest();
 }
Пример #3
0
        private void EmitUnitTest()
        {
            host.Warn(
                instrCur.Address,
                "MicroBlaze instruction '{0}' is not supported yet.",
                instrCur.Mnemonic);
            var testGenSvc = arch.Services.GetService <ITestGenerationService>();

            testGenSvc?.ReportMissingRewriter("MicroBlazeRw", instrCur, instrCur.Mnemonic.ToString(), rdr, "");
        }
Пример #4
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr  = dasm.Current;
                this.iclass = instr.InstructionClass;
                var rtls = new List <RtlInstruction>();
                this.m = new RtlEmitter(rtls);
                switch (instr.Mnemonic)
                {
                default:
                    host.Warn(instr.Address, "Cr16 instruction {0} not supported yet.", this.instr);
                    EmitUnitTest();
                    goto case Mnemonic.Invalid;

                case Mnemonic.Invalid: m.Invalid(); iclass = InstrClass.Invalid; break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, this.iclass));
            }
        }
Пример #5
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr           = dasm.Current;
                this.rtlInstructions = new List <RtlInstruction>();
                this.iclass          = instr.InstructionClass;
                m = new RtlEmitter(this.rtlInstructions);
                switch (instr.Mnemonic)
                {
                default:
                    host.Warn(
                        instr.Address,
                        "PDP-11 instruction {0} is not supported yet.",
                        instr.Mnemonic);
                    iclass = InstrClass.Invalid;
                    m.Invalid();
                    break;

                case Mnemonic.illegal: iclass = InstrClass.Invalid; m.Invalid(); break;

                case Mnemonic.adc: RewriteAdcSbc(m.IAdd); break;

                case Mnemonic.add: RewriteAdd(); break;

                case Mnemonic.addb: RewriteAdd(); break;

                case Mnemonic.ash: RewriteShift(); break;

                case Mnemonic.ashc: RewriteAshc(); break;

                case Mnemonic.asl: RewriteAsl(); break;

                case Mnemonic.aslb: RewriteAsl(); break;

                case Mnemonic.asr: RewriteAsr(); break;

                case Mnemonic.asrb: RewriteAsr(); break;

                case Mnemonic.bcc: RewriteBxx(ConditionCode.UGE, FlagM.CF); break;

                case Mnemonic.bcs: RewriteBxx(ConditionCode.ULT, FlagM.CF); break;

                case Mnemonic.beq: RewriteBxx(ConditionCode.EQ, FlagM.ZF); break;

                case Mnemonic.bge: RewriteBxx(ConditionCode.GE, FlagM.VF | FlagM.NF); break;

                case Mnemonic.bgt: RewriteBxx(ConditionCode.GT, FlagM.ZF | FlagM.NF | FlagM.VF); break;

                case Mnemonic.bhi: RewriteBxx(ConditionCode.UGT, FlagM.ZF | FlagM.CF); break;

                case Mnemonic.bvs: RewriteBxx(ConditionCode.OV, FlagM.VF); break;

                case Mnemonic.bic: RewriteBic(); break;

                case Mnemonic.bicb: RewriteBic(); break;

                case Mnemonic.bis: RewriteBis(); break;

                case Mnemonic.bisb: RewriteBis(); break;

                case Mnemonic.bit: RewriteBit(); break;

                case Mnemonic.bitb: RewriteBit(); break;

                case Mnemonic.ble: RewriteBxx(ConditionCode.LE, FlagM.ZF | FlagM.NF | FlagM.VF); break;

                case Mnemonic.blos: RewriteBxx(ConditionCode.ULE, FlagM.ZF | FlagM.CF); break;

                case Mnemonic.blt: RewriteBxx(ConditionCode.LT, FlagM.NF | FlagM.VF); break;

                case Mnemonic.bmi: RewriteBxx(ConditionCode.LT, FlagM.NF); break;

                case Mnemonic.bne: RewriteBxx(ConditionCode.NE, FlagM.ZF); break;

                case Mnemonic.bpl: RewriteBxx(ConditionCode.GT, FlagM.NF); break;

                case Mnemonic.bpt: RewriteBpt(); break;

                case Mnemonic.br: RewriteBr(); break;

                case Mnemonic.clr: RewriteClr(instr, m.Word16(0)); break;

                case Mnemonic.clrb: RewriteClr(instr, m.Byte(0)); break;

                case Mnemonic.clrflags: RewriteClrSetFlags(Constant.False); break;

                case Mnemonic.cmp: RewriteCmp(); break;

                case Mnemonic.cmpb: RewriteCmp(); break;

                case Mnemonic.com: RewriteCom(); break;

                case Mnemonic.comb: RewriteCom(); break;

                case Mnemonic.dec: RewriteIncDec(m.ISub); break;

                case Mnemonic.decb: RewriteIncDec(m.ISub); break;

                case Mnemonic.div: RewriteDiv(); break;

                case Mnemonic.emt: RewriteEmt(); break;

                case Mnemonic.halt: RewriteHalt(); break;

                case Mnemonic.iot: RewriteIot(); break;

                case Mnemonic.inc: RewriteIncDec(m.IAdd); break;

                case Mnemonic.incb: RewriteIncDec(m.IAdd); break;

                case Mnemonic.jmp: RewriteJmp(); break;

                case Mnemonic.jsr: RewriteJsr(); break;

                case Mnemonic.mark: RewriteMark(); break;

                case Mnemonic.mfpd: RewriteMfpd(); break;

                case Mnemonic.mfpi: RewriteMfpi(); break;

                case Mnemonic.mov: RewriteMov(); break;

                case Mnemonic.movb: RewriteMov(); break;

                case Mnemonic.mtpi: RewriteMtpi(); break;

                case Mnemonic.mul: RewriteMul(); break;

                case Mnemonic.neg: RewriteNeg(); break;

                case Mnemonic.negb: RewriteNeg(); break;

                case Mnemonic.nop: m.Nop(); break;

                case Mnemonic.reset: RewriteReset(); break;

                case Mnemonic.rol: RewriteRotate(PseudoProcedure.Rol); break;

                case Mnemonic.rolb: RewriteRotate(PseudoProcedure.Rol); break;

                case Mnemonic.ror: RewriteRotate(PseudoProcedure.Ror); break;

                case Mnemonic.rorb: RewriteRotate(PseudoProcedure.Ror); break;

                case Mnemonic.rti: RewriteRti(); break;

                case Mnemonic.rts: RewriteRts(); break;

                case Mnemonic.rtt: RewriteRtt(); break;

                case Mnemonic.sbc: RewriteAdcSbc(m.ISub); break;

                case Mnemonic.sbcb: RewriteAdcSbc(m.ISub); break;

                case Mnemonic.setflags: RewriteClrSetFlags(Constant.True); break;

                case Mnemonic.stcdi: RewriteStcdi(); break;

                case Mnemonic.sob: RewriteSob(); break;

                case Mnemonic.stexp: RewriteStexp(); break;

                case Mnemonic.sub: RewriteSub(); break;

                case Mnemonic.swab: RewriteSwab(); break;

                case Mnemonic.sxt: RewriteSxt(); break;

                case Mnemonic.trap: RewriteTrap(); break;

                case Mnemonic.tst: RewriteTst(); break;

                case Mnemonic.tstb: RewriteTst(); break;

                case Mnemonic.wait: RewriteWait(); break;

                case Mnemonic.xor: RewriteXor(); break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));
            }
        }
Пример #6
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                instr = dasm.Current;
                var addr = instr.Address;
                var len  = instr.Length;
                rtlInstructions = new List <RtlInstruction>();
                rtlc            = instr.InstructionClass;
                m   = new RtlEmitter(rtlInstructions);
                orw = new OperandRewriter(arch, this.m, this.binder, instr.dataWidth);
                switch (instr.Mnemonic)
                {
                default:
                    host.Warn(
                        instr.Address,
                        "M68k instruction '{0}' is not supported yet.",
                        instr.Mnemonic);
                    m.Invalid();
                    break;

                case Mnemonic.illegal: RewriteIllegal(); break;

                case Mnemonic.abcd: RewriteAbcd(); break;

                case Mnemonic.add: RewriteBinOp((s, d) => m.IAdd(d, s), FlagM.CVZNX); break;

                case Mnemonic.adda: RewriteBinOp((s, d) => m.IAdd(d, s)); break;

                case Mnemonic.addi: RewriteArithmetic((s, d) => m.IAdd(d, s)); break;

                case Mnemonic.addq: RewriteAddSubq((s, d) => m.IAdd(d, s)); break;

                case Mnemonic.addx: RewriteAddSubx(m.IAdd); break;

                case Mnemonic.and: RewriteLogical((s, d) => m.And(d, s)); break;

                case Mnemonic.andi: RewriteLogical((s, d) => m.And(d, s)); break;

                case Mnemonic.asl: RewriteArithmetic((s, d) => m.Shl(d, s)); break;

                case Mnemonic.asr: RewriteShift((s, d) => m.Sar(d, s)); break;

/*
 *
 * Mnemonic Condition Encoding Test
 * T* True 0000 1
 * F* False 0001 0
 * HI High 0010 C L Z
 * LS Low or Same 0011 C V Z
 * VC Overflow Clear 1000 V
 * VS Overflow Set 1001 V
 */
                case Mnemonic.bclr: RewriteBclrBset("__bclr"); break;

                case Mnemonic.bcc: RewriteBcc(ConditionCode.UGE, FlagM.CF); break;

                case Mnemonic.bcs: RewriteBcc(ConditionCode.ULT, FlagM.CF); break;

                case Mnemonic.beq: RewriteBcc(ConditionCode.EQ, FlagM.ZF); break;

                case Mnemonic.bge: RewriteBcc(ConditionCode.GE, FlagM.NF | FlagM.VF); break;

                case Mnemonic.bgt: RewriteBcc(ConditionCode.GT, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Mnemonic.bhi: RewriteBcc(ConditionCode.UGT, FlagM.CF | FlagM.ZF); break;

                case Mnemonic.ble: RewriteBcc(ConditionCode.LE, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Mnemonic.bls: RewriteBcc(ConditionCode.ULE, FlagM.CF | FlagM.ZF); break;

                case Mnemonic.blt: RewriteBcc(ConditionCode.LT, FlagM.NF | FlagM.VF); break;

                case Mnemonic.bmi: RewriteBcc(ConditionCode.LT, FlagM.NF); break;

                case Mnemonic.bne: RewriteBcc(ConditionCode.NE, FlagM.ZF); break;

                case Mnemonic.bpl: RewriteBcc(ConditionCode.GT, FlagM.NF); break;

                case Mnemonic.bvc: RewriteBcc(ConditionCode.NO, FlagM.VF); break;

                case Mnemonic.bvs: RewriteBcc(ConditionCode.OV, FlagM.VF); break;

                case Mnemonic.bchg: RewriteBchg(); break;

                case Mnemonic.bkpt: RewriteBkpt(); break;

                case Mnemonic.bra: RewriteBra(); break;

                case Mnemonic.bset: RewriteBclrBset("__bset"); break;

                case Mnemonic.bsr: RewriteBsr(); break;

                case Mnemonic.btst: RewriteBtst(); break;

                case Mnemonic.callm: RewriteCallm(); break;

                case Mnemonic.cas: RewriteCas(); break;

                case Mnemonic.clr: RewriteClr(); break;

                case Mnemonic.chk: RewriteChk(); break;

                case Mnemonic.chk2: RewriteChk2(); break;

                case Mnemonic.cmp: RewriteCmp(); break;

                case Mnemonic.cmp2: RewriteCmp2(); break;

                case Mnemonic.cmpa: RewriteCmp(); break;

                case Mnemonic.cmpi: RewriteCmp(); break;

                case Mnemonic.cmpm: RewriteCmp(); break;

                case Mnemonic.dbcc: RewriteDbcc(ConditionCode.UGE, FlagM.CF); break;

                case Mnemonic.dbcs: RewriteDbcc(ConditionCode.ULT, FlagM.CF); break;

                case Mnemonic.dbeq: RewriteDbcc(ConditionCode.EQ, FlagM.ZF); break;

                case Mnemonic.dbge: RewriteDbcc(ConditionCode.GE, FlagM.NF | FlagM.VF); break;

                case Mnemonic.dbgt: RewriteDbcc(ConditionCode.GE, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Mnemonic.dbhi: RewriteDbcc(ConditionCode.UGT, FlagM.CF | FlagM.ZF); break;

                case Mnemonic.dble: RewriteDbcc(ConditionCode.GT, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Mnemonic.dbls: RewriteDbcc(ConditionCode.ULE, FlagM.CF | FlagM.ZF); break;

                case Mnemonic.dblt: RewriteDbcc(ConditionCode.LT, FlagM.NF | FlagM.VF); break;

                case Mnemonic.dbmi: RewriteDbcc(ConditionCode.LT, FlagM.NF); break;

                case Mnemonic.dbne: RewriteDbcc(ConditionCode.NE, FlagM.ZF); break;

                case Mnemonic.dbpl: RewriteDbcc(ConditionCode.GT, FlagM.NF); break;

                case Mnemonic.dbt: RewriteDbcc(ConditionCode.ALWAYS, 0); break;

                case Mnemonic.dbra: RewriteDbcc(ConditionCode.None, 0); break;

                case Mnemonic.divs: RewriteDiv(m.SDiv, PrimitiveType.Int16); break;

                case Mnemonic.divsl: RewriteDiv(m.SDiv, PrimitiveType.Int32); break;

                case Mnemonic.divu: RewriteDiv(m.UDiv, PrimitiveType.UInt16); break;

                case Mnemonic.divul: RewriteDiv(m.UDiv, PrimitiveType.UInt32); break;

                case Mnemonic.eor: RewriteLogical((s, d) => m.Xor(d, s)); break;

                case Mnemonic.eori: RewriteLogical((s, d) => m.Xor(d, s)); break;

                case Mnemonic.exg: RewriteExg(); break;

                case Mnemonic.ext: RewriteExt(); break;

                case Mnemonic.extb: RewriteExtb(); break;

                case Mnemonic.fadd: RewriteFBinOp((s, d) => m.FAdd(d, s)); break;

                //$REVIEW: the following don't respect NaN, but NaN typically doesn't exist in HLLs.
                case Mnemonic.fbf: m.Nop(); break;

                case Mnemonic.fblt: RewriteFbcc(ConditionCode.LT); break;

                case Mnemonic.fbgl: RewriteFbcc(ConditionCode.NE); break;

                case Mnemonic.fbgt: RewriteFbcc(ConditionCode.GT); break;

                case Mnemonic.fbgle: RewriteFbcc(ConditionCode.NE); break;    //$BUG: should be !is_nan

                case Mnemonic.fbne: RewriteFbcc(ConditionCode.NE); break;

                case Mnemonic.fbnge: RewriteFbcc(ConditionCode.LT); break;

                case Mnemonic.fbngl: RewriteFbcc(ConditionCode.EQ); break;

                case Mnemonic.fbngle: RewriteFbcc(ConditionCode.EQ); break;   //$BUG: should be is_nan

                case Mnemonic.fbnlt: RewriteFbcc(ConditionCode.GE); break;

                case Mnemonic.fbnle: RewriteFbcc(ConditionCode.GT); break;

                case Mnemonic.fbogl: RewriteFbcc(ConditionCode.NE); break;

                case Mnemonic.fbole: RewriteFbcc(ConditionCode.LE); break;

                case Mnemonic.fbolt: RewriteFbcc(ConditionCode.LT); break;

                case Mnemonic.fbogt: RewriteFbcc(ConditionCode.GT); break;

                case Mnemonic.fbor: RewriteFbcc(ConditionCode.EQ); break;     //$REVIEW: is this correct?

                case Mnemonic.fbseq: RewriteFbcc(ConditionCode.EQ); break;

                case Mnemonic.fbsf: RewriteFbcc(ConditionCode.NEVER); break;

                case Mnemonic.fbsne: RewriteFbcc(ConditionCode.NE); break;

                case Mnemonic.fbst: RewriteFbcc(ConditionCode.ALWAYS); break;

                case Mnemonic.fbuge: RewriteFbcc(ConditionCode.GE); break;

                case Mnemonic.fbugt: RewriteFbcc(ConditionCode.GT); break;

                case Mnemonic.fbult: RewriteFbcc(ConditionCode.LT); break;

                case Mnemonic.fbun: RewriteFbcc(ConditionCode.IS_NAN); break;

                case Mnemonic.fasin: RewriteFasin(); break;

                case Mnemonic.fintrz: RewriteFintrz(); break;

                case Mnemonic.fcmp: RewriteFcmp(); break;

                case Mnemonic.fdiv: RewriteFBinOp((s, d) => m.FDiv(d, s)); break;

                case Mnemonic.fmove: RewriteFmove(); break;

                case Mnemonic.fmovecr: RewriteFmovecr(); break;

                case Mnemonic.fmovem: RewriteMovem(i => Registers.GetRegister(i + Registers.fp0.Number)); break;

                case Mnemonic.fmul: RewriteFBinOp((s, d) => m.FMul(d, s)); break;

                case Mnemonic.fneg: RewriteFUnaryOp(m.Neg); break;

                case Mnemonic.fsqrt: RewriteFsqrt(); break;

                case Mnemonic.fsub: RewriteFBinOp((s, d) => m.FSub(d, s)); break;

                case Mnemonic.ftan: RewriteFtan(); break;

                case Mnemonic.jmp: RewriteJmp(); break;

                case Mnemonic.jsr: RewriteJsr(); break;

                case Mnemonic.lea: RewriteLea(); break;

                case Mnemonic.link: RewriteLink(); break;

                case Mnemonic.lsl: RewriteShift((s, d) => m.Shl(d, s)); break;

                case Mnemonic.lsr: RewriteShift((s, d) => m.Shr(d, s)); break;

                case Mnemonic.move: RewriteMove(true); break;

                case Mnemonic.move16: RewriteMove16(); break;

                case Mnemonic.movea: RewriteMove(false); break;

                case Mnemonic.movep: RewriteMovep(); break;

                case Mnemonic.moveq: RewriteMoveq(); break;

                case Mnemonic.moves: RewriteMoves(); break;

                case Mnemonic.movem: RewriteMovem(Registers.GetRegister); break;

                case Mnemonic.muls: RewriteMul((s, d) => m.SMul(d, s)); break;

                case Mnemonic.mulu: RewriteMul((s, d) => m.UMul(d, s)); break;

                case Mnemonic.nbcd: RewriteNbcd(); break;

                case Mnemonic.neg: RewriteUnary(s => m.Neg(s), AllConditions); break;

                case Mnemonic.negx: RewriteUnary(RewriteNegx, AllConditions); break;

                case Mnemonic.nop: m.Nop(); break;

                case Mnemonic.not: RewriteUnary(s => m.Comp(s), LogicalConditions); break;

                case Mnemonic.or: RewriteLogical((s, d) => m.Or(d, s)); break;

                case Mnemonic.ori: RewriteLogical((s, d) => m.Or(d, s)); break;

                case Mnemonic.pack: RewritePack(); break;

                case Mnemonic.pea: RewritePea(); break;

                case Mnemonic.pflushr: RewritePflushr(); break;

                case Mnemonic.ptest: RewritePtest(); break;

                case Mnemonic.rol: RewriteRotation(PseudoProcedure.Rol); break;

                case Mnemonic.ror: RewriteRotation(PseudoProcedure.Ror);  break;

                case Mnemonic.roxl: RewriteRotationX(PseudoProcedure.RolC);  break;

                case Mnemonic.roxr: RewriteRotationX(PseudoProcedure.RorC);  break;

                case Mnemonic.rtd: RewriteRtd(); break;

                case Mnemonic.rte: RewriteRte(); break;

                case Mnemonic.rtm: RewriteRtm(); break;

                case Mnemonic.rts: RewriteRts(); break;

                case Mnemonic.sbcd: RewriteSbcd(); break;

                case Mnemonic.scc: RewriteScc(ConditionCode.UGE, FlagM.CF); break;

                case Mnemonic.scs: RewriteScc(ConditionCode.ULT, FlagM.CF); break;

                case Mnemonic.seq: RewriteScc(ConditionCode.EQ, FlagM.ZF); break;

                case Mnemonic.sge: RewriteScc(ConditionCode.GE, FlagM.NF | FlagM.VF); break;

                case Mnemonic.sgt: RewriteScc(ConditionCode.GT, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Mnemonic.shi: RewriteScc(ConditionCode.UGT, FlagM.CF | FlagM.ZF); break;

                case Mnemonic.sle: RewriteScc(ConditionCode.LE, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Mnemonic.sls: RewriteScc(ConditionCode.ULE, FlagM.CF | FlagM.ZF); break;

                case Mnemonic.slt: RewriteScc(ConditionCode.LT, FlagM.NF | FlagM.ZF); break;

                case Mnemonic.smi: RewriteScc(ConditionCode.LT, FlagM.NF); break;

                case Mnemonic.sne: RewriteScc(ConditionCode.NE, FlagM.ZF); break;

                case Mnemonic.spl: RewriteScc(ConditionCode.GT, FlagM.NF); break;

                case Mnemonic.svc: RewriteScc(ConditionCode.NO, FlagM.VF); break;

                case Mnemonic.svs: RewriteScc(ConditionCode.OV, FlagM.VF); break;

                case Mnemonic.st: orw.RewriteMoveDst(instr.Operands[0], instr.Address, PrimitiveType.Bool, Constant.True()); break;

                case Mnemonic.sf: orw.RewriteMoveDst(instr.Operands[0], instr.Address, PrimitiveType.Bool, Constant.False()); break;

                case Mnemonic.stop: RewriteStop(); break;

                case Mnemonic.sub: RewriteArithmetic((s, d) => m.ISub(d, s)); break;

                case Mnemonic.suba: RewriteBinOp((s, d) => m.ISub(d, s)); break;

                case Mnemonic.subi: RewriteArithmetic((s, d) => m.ISub(d, s)); break;

                case Mnemonic.subq: RewriteAddSubq((s, d) => m.ISub(d, s)); break;

                case Mnemonic.subx: RewriteArithmetic((s, d) => m.ISub(m.ISub(d, s), binder.EnsureFlagGroup(Registers.ccr, (uint)FlagM.XF, "X", PrimitiveType.Bool))); break;

                case Mnemonic.swap: RewriteSwap(); break;

                case Mnemonic.trap: RewriteTrap(); break;

                case Mnemonic.trapcc: RewriteTrapCc(ConditionCode.UGE, FlagM.CF); break;

                case Mnemonic.trapcs: RewriteTrapCc(ConditionCode.ULT, FlagM.CF); break;

                case Mnemonic.trapeq: RewriteTrapCc(ConditionCode.EQ, FlagM.ZF); break;

                case Mnemonic.trapf: RewriteTrapCc(ConditionCode.NEVER, 0); break;

                case Mnemonic.trapge: RewriteTrapCc(ConditionCode.GE, FlagM.NF | FlagM.VF); break;

                case Mnemonic.trapgt: RewriteTrapCc(ConditionCode.GT, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Mnemonic.traphi: RewriteTrapCc(ConditionCode.UGT, FlagM.CF | FlagM.ZF); break;

                case Mnemonic.traple: RewriteTrapCc(ConditionCode.LE, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Mnemonic.traplt: RewriteTrapCc(ConditionCode.LT, FlagM.CF | FlagM.VF); break;

                case Mnemonic.trapls: RewriteTrapCc(ConditionCode.ULE, FlagM.VF | FlagM.ZF); break;

                case Mnemonic.trapmi: RewriteTrapCc(ConditionCode.LT, FlagM.NF); break;

                case Mnemonic.trapne: RewriteTrapCc(ConditionCode.NE, FlagM.ZF); break;

                case Mnemonic.trappl: RewriteTrapCc(ConditionCode.GT, FlagM.NF); break;

                case Mnemonic.trapvc: RewriteTrapCc(ConditionCode.NO, FlagM.VF); break;

                case Mnemonic.trapvs: RewriteTrapCc(ConditionCode.OV, FlagM.VF); break;

                case Mnemonic.tas: RewriteTas(); break;

                case Mnemonic.tst: RewriteTst(); break;

                case Mnemonic.unlk: RewriteUnlk(); break;

                case Mnemonic.unpk: RewriteUnpk(); break;
                }
                yield return(new RtlInstructionCluster(
                                 addr,
                                 len,
                                 rtlInstructions.ToArray())
                {
                    Class = rtlc
                });
            }
            yield break;
        }
Пример #7
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr  = dasm.Current;
                this.iclass = this.instr.InstructionClass;
                var instrs = new List <RtlInstruction>();
                this.m = new RtlEmitter(instrs);
                switch (this.instr.Mnemonic)
                {
                default:
                    EmitUnitTest();
                    host.Warn(
                        dasm.Current.Address,
                        "AVR32 instruction '{0}' is not supported yet.",
                        instr.Mnemonic);
                    goto case Mnemonic.invalid;

                case Mnemonic.invalid: m.Invalid(); break;

                case Mnemonic.abs: RewriteAbs(); break;

                case Mnemonic.acall: RewriteAcall(); break;

                case Mnemonic.acr: RewriteAcr(); break;

                case Mnemonic.adc: RewriteAdc(); break;

                case Mnemonic.add: RewriteAdd(); break;

                case Mnemonic.andh: RewriteAndh(); break;

                case Mnemonic.andl: RewriteAndl(); break;

                case Mnemonic.and: RewriteLogical(m.And); break;

                case Mnemonic.andnot: RewriteLogical((a, b) => m.And(a, m.Comp(b))); break;

                case Mnemonic.asr: RewriteShift(m.Sar); break;

                case Mnemonic.bfexts: RewriteBfexts(); break;

                case Mnemonic.bfextu: RewriteBfextu(); break;

                case Mnemonic.bld: RewriteBld(); break;

                case Mnemonic.br: RewriteBranch(); break;

                case Mnemonic.bst: RewriteBst(); break;

                case Mnemonic.casts_b: RewriteCast(PrimitiveType.SByte, PrimitiveType.Int32); break;

                case Mnemonic.casts_h: RewriteCast(PrimitiveType.Int16, PrimitiveType.Int32); break;

                case Mnemonic.castu_b: RewriteCast(PrimitiveType.Byte, PrimitiveType.Word32); break;

                case Mnemonic.castu_h: RewriteCast(PrimitiveType.Word16, PrimitiveType.Word32); break;

                case Mnemonic.cbr: RewriteCbr(); break;

                case Mnemonic.com: RewriteCom(); break;

                case Mnemonic.clz: RewriteClz(); break;

                case Mnemonic.cp_b: RewriteCp_b(); break;

                case Mnemonic.cp_w: RewriteCp_w(); break;

                case Mnemonic.cpc: RewriteCpc(); break;

                case Mnemonic.divs: RewriteDiv(m.SDiv); break;

                case Mnemonic.divu: RewriteDiv(m.UDiv); break;

                case Mnemonic.eor: RewriteLogical(m.Xor); break;

                case Mnemonic.eorh: RewriteOrh(m.Xor); break;

                case Mnemonic.eorl: RewriteOrh(m.Xor); break;

                case Mnemonic.icall: RewriteCall(); break;

                case Mnemonic.ld_d: RewriteLd(PrimitiveType.Word64, PrimitiveType.Word64); break;

                case Mnemonic.ld_sb: RewriteLd(PrimitiveType.SByte, PrimitiveType.Int32); break;

                case Mnemonic.ld_sh: RewriteLd(PrimitiveType.Int16, PrimitiveType.Int32); break;

                case Mnemonic.ld_ub: RewriteLd(PrimitiveType.Byte, PrimitiveType.Word32); break;

                case Mnemonic.ld_uh: RewriteLd(PrimitiveType.Word16, PrimitiveType.Word32); break;

                case Mnemonic.ld_w: RewriteLd(PrimitiveType.Word32, PrimitiveType.Word32); break;

                case Mnemonic.lddpc: RewriteLddpc(); break;

                case Mnemonic.lddsp: RewriteLddsp(); break;

                case Mnemonic.ldm: RewriteLdm(); break;

                case Mnemonic.lsl: RewriteShift(m.Shl); break;

                case Mnemonic.lsr: RewriteShift(m.Shr); break;

                case Mnemonic.macs_d: RewriteMac_d(m.SMul); break;

                case Mnemonic.macu_d: RewriteMac_d(m.UMul); break;

                case Mnemonic.max: RewriteMax(); break;

                case Mnemonic.mcall: RewriteCall(); break;

                case Mnemonic.min: RewriteMin(); break;

                case Mnemonic.mov: RewriteMov(); break;

                case Mnemonic.movh: RewriteMovh(); break;

                case Mnemonic.mul: RewriteMul(); break;

                case Mnemonic.muls_d: RewriteMul_d(m.SMul); break;

                case Mnemonic.mulu_d: RewriteMul_d(m.UMul); break;

                case Mnemonic.mustr: RewriteMustr(); break;

                case Mnemonic.neg: RewriteNeg(); break;

                case Mnemonic.nop: m.Nop(); break;

                case Mnemonic.or: RewriteLogical(m.Or); break;

                case Mnemonic.orh: RewriteOrh(m.Or); break;

                case Mnemonic.orl: RewriteOrl(m.Or); break;

                case Mnemonic.popm: RewritePopm(); break;

                case Mnemonic.pushm: RewritePushm(); break;

                case Mnemonic.ret: RewriteRet(); break;

                case Mnemonic.rcall: RewriteCall(); break;

                case Mnemonic.rjmp: RewriteGoto(); break;

                case Mnemonic.rol: RewriteRol(); break;

                case Mnemonic.ror: RewriteRor(); break;

                case Mnemonic.rsub: RewriteRsub(); break;

                case Mnemonic.sats: RewriteSat("__sats", PrimitiveType.Int32); break;

                case Mnemonic.satu: RewriteSat("__satu", PrimitiveType.UInt32); break;

                case Mnemonic.satsub_w: RewriteSatsubW(); break;

                case Mnemonic.sbc: RewriteSbc(); break;

                case Mnemonic.sbr: RewriteSbr(); break;

                case Mnemonic.scr: RewriteScr(); break;

                case Mnemonic.sr: RewriteSr(); break;

                case Mnemonic.stm: RewriteStm(); break;

                case Mnemonic.st_b: RewriteSt(PrimitiveType.Byte); break;

                case Mnemonic.st_h: RewriteSt(PrimitiveType.Word16); break;

                case Mnemonic.st_w: RewriteSt(PrimitiveType.Word32); break;

                case Mnemonic.st_d: RewriteSt(PrimitiveType.Word64); break;

                case Mnemonic.stcond: RewriteStcond(); break;

                case Mnemonic.stdsp: RewriteStdsp(); break;

                case Mnemonic.sub: RewriteSub(); break;

                case Mnemonic.subf: RewriteSub(); break;

                case Mnemonic.tst: RewriteTst(); break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));
            }
        }
Пример #8
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                iclass = InstrClass.Linear;
                var instrs = new List <RtlInstruction>();
                m          = new RtlEmitter(instrs);
                this.instr = dasm.Current;
                switch (instr.Mnemonic)
                {
                default:
                    host.Warn(
                        instr.Address,
                        string.Format(
                            "TLCS-900 instruction '{0}' not supported yet.",
                            instr.Mnemonic));
                    EmitUnitTest();
                    Invalid();
                    break;

                case Mnemonic.invalid:
                    Invalid();
                    break;

                case Mnemonic.adc: RewriteAdcSbc(m.IAdd, "****0*"); break;

                case Mnemonic.add: RewriteBinOp(m.IAdd, "***V0*"); break;

                case Mnemonic.and: RewriteBinOp(m.And, "**1*00"); break;

                case Mnemonic.bit: RewriteBit(); break;

                case Mnemonic.bs1b: RewriteBs1b(); break;

                case Mnemonic.call: RewriteCall(); break;

                case Mnemonic.calr: RewriteCall(); break;

                case Mnemonic.ccf: RewriteCcf(); break;

                case Mnemonic.chg: RewriteChg(); break;

                case Mnemonic.cp: RewriteCp("SZHV1C"); break;

                case Mnemonic.daa: RewriteDaa("****-*"); break;

                case Mnemonic.dec: RewriteIncDec(m.ISub, "****1-"); break;

                case Mnemonic.decf: RewriteDecf(); break;

                case Mnemonic.div: RewriteDiv(m.UDiv, "---V--"); break;

                case Mnemonic.divs: RewriteDiv(m.SDiv, "---V--"); break;

                case Mnemonic.djnz: RewriteDjnz(); break;

                case Mnemonic.ei: RewriteEi(); break;

                case Mnemonic.ex: RewriteEx(); break;

                case Mnemonic.halt: RewriteHalt(); break;

                case Mnemonic.inc: RewriteIncDec(m.IAdd, "****0-"); break;

                case Mnemonic.incf: RewriteIncf(); break;

                case Mnemonic.lda: RewriteLda(); break;

                case Mnemonic.jp: RewriteJp(); break;

                case Mnemonic.jr: RewriteJp(); break;

                case Mnemonic.ld: RewriteLd(); break;

                case Mnemonic.ldf: RewriteLdf(); break;

                case Mnemonic.ldir: RewriteLdir(PrimitiveType.Byte, "--000-"); break;

                case Mnemonic.ldirw: RewriteLdir(PrimitiveType.Word16, "--000-"); break;

                case Mnemonic.mul: RewriteMul(m.UMul); break;

                case Mnemonic.muls: RewriteMul(m.SMul); break;

                case Mnemonic.nop: m.Nop(); break;

                case Mnemonic.or: RewriteBinOp(m.Or, "**0*00"); break;

                case Mnemonic.pop: RewritePop(); break;

                case Mnemonic.push: RewritePush(); break;

                case Mnemonic.rcf: RewriteRcf(); break;

                case Mnemonic.res: RewriteRes(); break;

                case Mnemonic.ret: RewriteRet(); break;

                case Mnemonic.retd: RewriteRetd(); break;

                case Mnemonic.reti: RewriteReti(); break;

                case Mnemonic.sbc: RewriteAdcSbc(m.ISub, "****1*"); break;

                case Mnemonic.scc: RewriteScc(); break;

                case Mnemonic.scf: RewriteScf(); break;

                case Mnemonic.set: RewriteSet(); break;

                case Mnemonic.sla: RewriteShift(m.Shl, "**0*0*"); break;

                case Mnemonic.sll: RewriteShift(m.Shl, "**0*0*"); break;

                case Mnemonic.srl: RewriteShift(m.Shr, "**0*0*"); break;

                case Mnemonic.sub: RewriteBinOp(m.ISub, "***V1*"); break;

                case Mnemonic.swi: RewriteSwi(); break;

                case Mnemonic.xor: RewriteBinOp(m.Xor, "**0*00"); break;

                case Mnemonic.zcf: RewriteZcf(); break;
                }
                yield return(new RtlInstructionCluster(instr.Address, instr.Length, instrs.ToArray())
                {
                    Class = iclass
                });
            }
        }
Пример #9
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                var rtlInstrs = new List <RtlInstruction>();
                this.m    = new RtlEmitter(rtlInstrs);
                this.rtlc = instr.InstructionClass;
                switch (instr.Opcode)
                {
                case Opcode.mov:
                case Opcode.rev:
                case Opcode.revw:
                case Opcode.tbl:
                    host.Warn(
                        instr.Address,
                        "M6812 instruction '{0}' is not supported yet.",
                        instr.Opcode);
                    goto case Opcode.invalid;

                case Opcode.invalid:
                    this.rtlc = InstrClass.Invalid;
                    m.Invalid();
                    break;

                case Opcode.aba: RewriteAba(); break;

                case Opcode.adca: RewriteAdcSbc(Registers.a, m.IAdd); break;

                case Opcode.adcb: RewriteAdcSbc(Registers.b, m.IAdd); break;

                case Opcode.adda: RewriteArithmetic(Registers.a, m.IAdd); break;

                case Opcode.addb: RewriteArithmetic(Registers.b, m.IAdd); break;

                case Opcode.addd: RewriteArithmetic(Registers.d, m.IAdd); break;

                case Opcode.anda: RewriteLogical(Registers.a, m.And); break;

                case Opcode.andb: RewriteLogical(Registers.b, m.And); break;

                case Opcode.andcc: RewriteAndcc(); break;

                case Opcode.asr: RewriteShiftMem(m.Sar); break;

                case Opcode.asra: RewriteArithmetic(Registers.a, m.Sar); break;

                case Opcode.asrb: RewriteArithmetic(Registers.b, m.Sar); break;

                case Opcode.bcc: RewriteBcc(ConditionCode.UGE, FlagM.CF); break;

                case Opcode.bclr: RewriteBclr(); break;

                case Opcode.bcs: RewriteBcc(ConditionCode.ULT, FlagM.CF); break;

                case Opcode.beq: RewriteBcc(ConditionCode.EQ, FlagM.ZF); break;

                case Opcode.bge: RewriteBcc(ConditionCode.GE, FlagM.NF | FlagM.VF); break;

                case Opcode.bgt: RewriteBcc(ConditionCode.GT, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Opcode.bhi: RewriteBcc(ConditionCode.UGT, FlagM.CF | FlagM.ZF); break;

                case Opcode.ble: RewriteBcc(ConditionCode.LE, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Opcode.blt: RewriteBcc(ConditionCode.LT, FlagM.CF | FlagM.ZF); break;

                case Opcode.bls: RewriteBcc(ConditionCode.ULE, FlagM.VF | FlagM.ZF); break;

                case Opcode.bmi: RewriteBcc(ConditionCode.LT, FlagM.NF); break;

                case Opcode.bne: RewriteBcc(ConditionCode.NE, FlagM.ZF); break;

                case Opcode.bpl: RewriteBcc(ConditionCode.GT, FlagM.NF); break;

                case Opcode.bvc: RewriteBcc(ConditionCode.NO, FlagM.VF); break;

                case Opcode.bvs: RewriteBcc(ConditionCode.OV, FlagM.VF); break;

                case Opcode.bgnd: RewriteBgnd(); break;

                case Opcode.bita: RewriteBit(Registers.a); break;

                case Opcode.bitb: RewriteBit(Registers.b); break;

                case Opcode.bra: RewriteBra(); break;

                case Opcode.brclr: RewriteBrclr(); break;

                case Opcode.brn: m.Nop(); break;

                case Opcode.brset: RewriteBrset(); break;

                case Opcode.bset: RewriteBset(); break;

                case Opcode.bsr: RewriteBsr(); break;

                case Opcode.call: RewriteCall(); break;

                case Opcode.cba: RewriteCba(); break;

                case Opcode.clr: RewriteClr(); break;

                case Opcode.clra: RewriteClr(Registers.a); break;

                case Opcode.clrb: RewriteClr(Registers.b); break;

                case Opcode.cmpa: RewriteCmp(Registers.a); break;

                case Opcode.cmpb: RewriteCmp(Registers.b); break;

                case Opcode.com: RewriteCom(); break;

                case Opcode.coma: RewriteCom(Registers.a); break;

                case Opcode.comb: RewriteCom(Registers.b); break;

                case Opcode.cpd: RewriteCmp(Registers.d); break;

                case Opcode.cps: RewriteCmp(Registers.sp); break;

                case Opcode.cpx: RewriteCmp(Registers.x); break;

                case Opcode.cpy: RewriteCmp(Registers.y); break;

                case Opcode.daa: RewriteDaa(); break;

                case Opcode.dbeq: RewriteDb(m.Eq0); break;

                case Opcode.dbne: RewriteDb(m.Ne0); break;

                case Opcode.dec: RewriteIncDec(m.ISub); break;

                case Opcode.deca: RewriteIncDec(Registers.a, m.ISub); break;

                case Opcode.decb: RewriteIncDec(Registers.b, m.ISub); break;

                case Opcode.dex: RewriteIncDecXY(Registers.x, m.ISub); break;

                case Opcode.dey: RewriteIncDecXY(Registers.y, m.ISub); break;

                case Opcode.ediv: RewriteEdiv(m.UDiv, m.Remainder); break;

                case Opcode.edivs: RewriteEdiv(m.SDiv, m.Remainder); break;

                case Opcode.emacs: RewriteEmacs(); break;

                case Opcode.emaxd: RewriteEmaxmind("__umax"); break;

                case Opcode.emaxm: RewriteEmaxminm("__umax"); break;

                case Opcode.emind: RewriteEmaxmind("__umin"); break;

                case Opcode.eminm: RewriteEmaxminm("__umin"); break;

                case Opcode.emul: RewriteEmul(m.UMul); break;

                case Opcode.emuls: RewriteEmul(m.SMul); break;

                case Opcode.eora: RewriteLogical(Registers.a, m.Xor); break;

                case Opcode.eorb: RewriteLogical(Registers.b, m.Xor); break;

                case Opcode.etbl: RewriteEtbl(); break;

                case Opcode.fdiv: RewriteFdiv(); break;

                case Opcode.ibeq: RewriteIb(m.Eq0); break;

                case Opcode.ibne: RewriteIb(m.Ne0); break;

                case Opcode.idiv: RewriteIdiv(m.UDiv); break;

                case Opcode.idivs: RewriteIdiv(m.SDiv); break;

                case Opcode.inc: RewriteIncDec(m.IAdd); break;

                case Opcode.inca: RewriteIncDec(Registers.a, m.IAdd); break;

                case Opcode.incb: RewriteIncDec(Registers.b, m.IAdd); break;

                case Opcode.inx: RewriteIncDecXY(Registers.x, m.IAdd); break;

                case Opcode.iny: RewriteIncDecXY(Registers.y, m.IAdd); break;

                case Opcode.jmp: RewriteJmp(); break;

                case Opcode.jsr: RewriteJsr(); break;

                case Opcode.lbcc: RewriteBcc(ConditionCode.UGE, FlagM.CF); break;

                case Opcode.lbcs: RewriteBcc(ConditionCode.ULT, FlagM.CF); break;

                case Opcode.lbeq: RewriteBcc(ConditionCode.EQ, FlagM.ZF); break;

                case Opcode.lbge: RewriteBcc(ConditionCode.GE, FlagM.NF | FlagM.VF); break;

                case Opcode.lbgt: RewriteBcc(ConditionCode.GT, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Opcode.lbhi: RewriteBcc(ConditionCode.UGT, FlagM.CF | FlagM.ZF); break;

                case Opcode.lble: RewriteBcc(ConditionCode.LE, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Opcode.lblt: RewriteBcc(ConditionCode.LT, FlagM.CF | FlagM.ZF); break;

                case Opcode.lbls: RewriteBcc(ConditionCode.ULE, FlagM.VF | FlagM.ZF); break;

                case Opcode.lbmi: RewriteBcc(ConditionCode.LT, FlagM.NF); break;

                case Opcode.lbne: RewriteBcc(ConditionCode.NE, FlagM.ZF); break;

                case Opcode.lbpl: RewriteBcc(ConditionCode.GT, FlagM.NF); break;

                case Opcode.lbra: RewriteBra(); break;

                case Opcode.lbrn: m.Nop(); break;

                case Opcode.lbvc: RewriteBcc(ConditionCode.NO, FlagM.VF); break;

                case Opcode.lbvs: RewriteBcc(ConditionCode.OV, FlagM.VF); break;

                case Opcode.ldaa: RewriteLd(Registers.a); break;

                case Opcode.ldab: RewriteLd(Registers.b); break;

                case Opcode.ldd: RewriteLd(Registers.d); break;

                case Opcode.lds: RewriteLd(Registers.sp); break;

                case Opcode.ldx: RewriteLd(Registers.x); break;

                case Opcode.ldy: RewriteLd(Registers.y); break;

                case Opcode.leas: RewriteLea(Registers.sp); break;

                case Opcode.leax: RewriteLea(Registers.x); break;

                case Opcode.leay: RewriteLea(Registers.y); break;

                case Opcode.lsl: RewriteShiftMem(m.Shl); break;

                case Opcode.lsla: RewriteArithmetic(Registers.a, m.Shl); break;

                case Opcode.lslb: RewriteArithmetic(Registers.b, m.Shl); break;

                case Opcode.lsld: RewriteArithmetic(Registers.d, m.Shl); break;

                case Opcode.lsr: RewriteShiftMem(m.Shr); break;

                case Opcode.lsra: RewriteArithmetic(Registers.a, m.Shr); break;

                case Opcode.lsrb: RewriteArithmetic(Registers.b, m.Shr); break;

                case Opcode.lsrd: RewriteArithmetic(Registers.d, m.Shr); break;

                case Opcode.maxa: RewriteMaxmina("__umax_b"); break;

                case Opcode.maxm: RewriteMaxminm("__umax_b"); break;

                case Opcode.mem: RewriteMem(); break;

                case Opcode.mina: RewriteMaxmina("__umin_b"); break;

                case Opcode.minm: RewriteMaxminm("__umin_b"); break;

                case Opcode.mul: RewriteMul(); break;

                case Opcode.neg: RewriteNeg(); break;

                case Opcode.nega: RewriteNeg(Registers.a); break;

                case Opcode.negb: RewriteNeg(Registers.b); break;

                case Opcode.nop: m.Nop(); break;

                case Opcode.oraa: RewriteLogical(Registers.a, m.Or); break;

                case Opcode.orab: RewriteLogical(Registers.b, m.Or); break;

                case Opcode.orcc: RewriteOrcc(); break;

                case Opcode.psha: RewritePsh(Registers.a); break;

                case Opcode.pshb: RewritePsh(Registers.b); break;

                case Opcode.pshc: RewritePsh(Registers.ccr); break;

                case Opcode.pshd: RewritePsh(Registers.d); break;

                case Opcode.pshx: RewritePsh(Registers.x); break;

                case Opcode.pshy: RewritePsh(Registers.y); break;

                case Opcode.pula: RewritePul(Registers.a); break;

                case Opcode.pulb: RewritePul(Registers.b); break;

                case Opcode.pulc: RewritePul(Registers.ccr); break;

                case Opcode.puld: RewritePul(Registers.d); break;

                case Opcode.pulx: RewritePul(Registers.x); break;

                case Opcode.puly: RewritePul(Registers.y); break;

                case Opcode.rol: RewriteShiftMem(Rol); break;

                case Opcode.rola: RewriteArithmetic(Registers.a, Rol); break;

                case Opcode.rolb: RewriteArithmetic(Registers.b, Rol); break;

                case Opcode.ror: RewriteShiftMem(Ror); break;

                case Opcode.rora: RewriteArithmetic(Registers.a, Ror); break;

                case Opcode.rorb: RewriteArithmetic(Registers.a, Ror); break;

                case Opcode.rtc: RewriteRtc(); break;

                case Opcode.rti: RewriteRti(); break;

                case Opcode.rts: RewriteRts(); break;

                case Opcode.sba: RewriteSba(); break;

                case Opcode.sbca: RewriteAdcSbc(Registers.a, m.ISub); break;

                case Opcode.sbcb: RewriteAdcSbc(Registers.b, m.ISub); break;

                case Opcode.sex: RewriteSex(); break;

                case Opcode.staa: RewriteSt(Registers.a); break;

                case Opcode.stab: RewriteSt(Registers.b); break;

                case Opcode.std: RewriteSt(Registers.d); break;

                case Opcode.stop: RewriteStop(); break;

                case Opcode.sts: RewriteSt(Registers.sp); break;

                case Opcode.stx: RewriteSt(Registers.x); break;

                case Opcode.sty: RewriteSt(Registers.y); break;

                case Opcode.suba: RewriteSub(Registers.a); break;

                case Opcode.subb: RewriteSub(Registers.b); break;

                case Opcode.subd: RewriteSub(Registers.d); break;

                case Opcode.swi: RewriteSwi(); break;

                case Opcode.tab: RewriteTab(); break;

                case Opcode.tba: RewriteTba(); break;

                case Opcode.tbeq: RewriteTb(m.Eq0); break;

                case Opcode.tbne: RewriteTb(m.Ne0); break;

                case Opcode.tfr: RewriteTfr(); break;

                case Opcode.trap: RewriteTrap(); break;

                case Opcode.tst: RewriteTst(); break;

                case Opcode.tsta: RewriteTst(Registers.a); break;

                case Opcode.tstb: RewriteTst(Registers.b); break;

                case Opcode.wai: RewriteWai(); break;

                case Opcode.wav: RewriteWav(); break;
                }
                yield return(new RtlInstructionCluster(
                                 instr.Address,
                                 instr.Length,
                                 rtlInstrs.ToArray())
                {
                    Class = rtlc
                });
            }
        }
Пример #10
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                var rtls = new List <RtlInstruction>();
                this.m      = new RtlEmitter(rtls);
                this.iclass = InstrClass.Linear;
                switch (instr.Mnemonic)
                {
                default:
                    host.Warn(
                        instr.Address,
                        string.Format(
                            "i8051 instruction '{0}' not supported yet.",
                            instr.Mnemonic));
                    goto case Mnemonic.Invalid;

                case Mnemonic.Invalid:
                case Mnemonic.reserved:
                    Invalid();
                    break;

                case Mnemonic.acall: RewriteCall(); break;

                case Mnemonic.add: RewriteBinop(m.IAdd, Registers.CAOP); break;

                case Mnemonic.addc: RewriteAddcSubb(m.IAdd); break;

                case Mnemonic.ajmp: RewriteJump(); break;

                case Mnemonic.anl: RewriteLogical(m.And); break;

                case Mnemonic.cjne: RewriteCjne(); break;

                case Mnemonic.clr: RewriteClr(); break;

                case Mnemonic.dec: RewriteIncDec(m.ISub); break;

                case Mnemonic.djnz: RewriteDjnz(); break;

                case Mnemonic.inc: RewriteIncDec(m.IAdd); break;

                case Mnemonic.jb: RewriteJb(m.Ne0); break;

                case Mnemonic.jbc: RewriteJbc(); break;

                case Mnemonic.jc: RewriteJc(ConditionCode.ULT); break;

                case Mnemonic.jmp: RewriteJump(); break;

                case Mnemonic.jnb: RewriteJb(m.Eq0); break;

                case Mnemonic.jnc: RewriteJc(ConditionCode.UGE); break;

                case Mnemonic.jnz: RewriteJz(m.Ne0); break;

                case Mnemonic.jz: RewriteJz(m.Eq0); break;

                case Mnemonic.lcall: RewriteCall(); break;

                case Mnemonic.ljmp: RewriteJump(); break;

                case Mnemonic.mov: RewriteMov(); break;

                case Mnemonic.movc: RewriteMovc(); break;

                case Mnemonic.movx: RewriteMovx(); break;

                case Mnemonic.mul: RewriteMul(); break;

                case Mnemonic.nop: m.Nop(); break;

                case Mnemonic.orl: RewriteLogical(m.Or); break;

                case Mnemonic.pop: RewritePop(); break;

                case Mnemonic.push: RewritePush(); break;

                case Mnemonic.ret: RewriteRet(); break;

                case Mnemonic.reti: RewriteRet(); break;

                case Mnemonic.rl: RewriteRotate(IntrinsicProcedure.Rol); break;

                case Mnemonic.rr: RewriteRotate(IntrinsicProcedure.Ror); break;

                case Mnemonic.setb: RewriteSetb(); break;

                case Mnemonic.sjmp: RewriteJump(); break;

                case Mnemonic.subb: RewriteAddcSubb(m.ISub); break;

                case Mnemonic.swap: RewriteSwap(); break;

                case Mnemonic.xrl: RewriteLogical(m.Xor); break;

                case Mnemonic.xch: RewriteXch(); break;

                case Mnemonic.cpl:
                case Mnemonic.da:
                case Mnemonic.div:
                case Mnemonic.rrc:
                case Mnemonic.rlc:
                case Mnemonic.xchd:
                    EmitUnitTest();
                    Invalid();
                    break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));
            }
        }
Пример #11
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                iclass     = instr.InstructionClass;
                try
                {
                    switch (instr.Mnemonic)
                    {
                    default:
                        EmitUnitTest();
                        host.Warn(
                            instr.Address,
                            "AArch64 instruction {0} is not supported yet.",
                            instr);
                        goto case Mnemonic.Invalid;

                    case Mnemonic.Invalid:
                        iclass = InstrClass.Invalid;
                        m.Invalid();
                        break;

                    case Mnemonic.abs: RewriteSimdUnary("__abs_{0}", Domain.SignedInt); break;

                    case Mnemonic.adc: RewriteAdcSbc(m.IAdd); break;

                    case Mnemonic.adcs: RewriteAdcSbc(m.IAdd, this.NZCV); break;

                    case Mnemonic.add: RewriteMaybeSimdBinary(m.IAdd, "__add_{0}"); break;

                    case Mnemonic.addhn: RewriteSimdBinary("__addhn_{0}", Domain.None); break;

                    case Mnemonic.addhn2: RewriteSimdBinary("__addhn2_{0}", Domain.None); break;

                    case Mnemonic.addp: RewriteSimdBinary("__addp_{0}", Domain.None); break;

                    case Mnemonic.adds: RewriteBinary(m.IAdd, this.NZCV); break;

                    case Mnemonic.addv: RewriteAddv(); break;

                    case Mnemonic.adr: RewriteUnary(n => n); break;

                    case Mnemonic.asrv: RewriteBinary(m.Sar); break;

                    case Mnemonic.adrp: RewriteAdrp(); break;

                    case Mnemonic.and: RewriteBinary(m.And); break;

                    case Mnemonic.ands: RewriteBinary(m.And, this.NZ00); break;

                    case Mnemonic.asr: RewriteBinary(m.Sar); break;

                    case Mnemonic.b: RewriteB(); break;

                    case Mnemonic.bfm: RewriteBfm(); break;

                    case Mnemonic.bic: RewriteLogical((a, b) => m.And(a, m.Comp(b))); break;

                    case Mnemonic.bics: RewriteBinary((a, b) => m.And(a, m.Comp(b)), NZ00); break;

                    case Mnemonic.bif: RewriteSimdBinary("__bif_{0}", Domain.None); break;

                    case Mnemonic.bit: RewriteSimdBinary("__bit_{0}", Domain.None); break;

                    case Mnemonic.bl: RewriteBl(); break;

                    case Mnemonic.blr: RewriteBlr(); break;

                    case Mnemonic.br: RewriteBr(); break;

                    case Mnemonic.brk: RewriteBrk(); break;

                    case Mnemonic.bsl: RewriteBsl(); break;

                    case Mnemonic.cbnz: RewriteCb(m.Ne0); break;

                    case Mnemonic.cbz: RewriteCb(m.Eq0); break;

                    case Mnemonic.ccmn: RewriteCcmn(); break;

                    case Mnemonic.ccmp: RewriteCcmp(); break;

                    case Mnemonic.cls: RewriteSimdUnary("__cls_{0}", Domain.None); break;

                    case Mnemonic.clz: RewriteClz(); break;

                    case Mnemonic.cmp: RewriteCmp(); break;

                    case Mnemonic.cmeq: RewriteCm("__cmeq_{0}", Domain.None); break;

                    case Mnemonic.cmge: RewriteCm("__cmge_{0}", Domain.SignedInt); break;

                    case Mnemonic.cmgt: RewriteCm("__cmgt_{0}", Domain.SignedInt); break;

                    case Mnemonic.cmhi: RewriteCm("__cmhi_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.cmhs: RewriteCm("__cmhs_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.cmle: RewriteCm("__cmle_{0}", Domain.SignedInt); break;

                    case Mnemonic.cmlt: RewriteCm("__cmlt_{0}", Domain.SignedInt); break;

                    case Mnemonic.cmtst: RewriteCm("__cmtst_{0}", Domain.None); break;

                    case Mnemonic.cnt: RewriteSimdUnary("__cnt_{0}", Domain.None); break;

                    case Mnemonic.csel: RewriteCsel(); break;

                    case Mnemonic.csinc: RewriteCsinc(); break;

                    case Mnemonic.csinv: RewriteCsinv(); break;

                    case Mnemonic.csneg: RewriteCsneg(); break;

                    case Mnemonic.dmb: RewriteDmb(); break;

                    case Mnemonic.dsb: RewriteDsb(); break;

                    case Mnemonic.dup: RewriteDup(); break;

                    case Mnemonic.eor: RewriteBinary(m.Xor); break;

                    case Mnemonic.eon: RewriteBinary((a, b) => m.Xor(a, m.Comp(b))); break;

                    case Mnemonic.eret: RewriteEret(); break;

                    case Mnemonic.ext: RewriteExt(); break;

                    case Mnemonic.extr: RewriteExtr(); break;

                    case Mnemonic.fabs: RewriteFabs(); break;

                    case Mnemonic.fadd: RewriteFadd(); break;

                    case Mnemonic.fcmp: RewriteFcmp(); break;

                    case Mnemonic.fcmpe: RewriteFcmp(); break;  //$REVIEW: this leaves out the 'e'xception part.

                    case Mnemonic.fcsel: RewriteFcsel(); break;

                    case Mnemonic.fcvt: RewriteFcvt(); break;

                    case Mnemonic.fcvtms: RewriteFcvtms(); break;

                    case Mnemonic.fcvtps: RewriteFcvtps(); break;

                    case Mnemonic.fcvtzs: RewriteFcvtzs(); break;

                    case Mnemonic.fdiv: RewriteMaybeSimdBinary(m.FDiv, "__fdiv_{0}", Domain.Real); break;

                    case Mnemonic.fmadd: RewriteIntrinsicFTernary("__fmaddf", "__fmadd"); break;

                    case Mnemonic.fmsub: RewriteIntrinsicFTernary("__fmsubf", "__fmsub"); break;

                    case Mnemonic.fmax: RewriteIntrinsicFBinary("fmaxf", "fmax"); break;

                    case Mnemonic.fmin: RewriteIntrinsicFBinary("fminf", "fmin"); break;

                    case Mnemonic.fmov: RewriteFmov(); break;

                    case Mnemonic.fmul: RewriteFmul(); break;

                    case Mnemonic.fneg: RewriteUnary(m.FNeg); break;

                    case Mnemonic.fnmul: RewriteFnmul(); break;

                    case Mnemonic.fsqrt: RewriteFsqrt(); break;

                    case Mnemonic.fsub: RewriteMaybeSimdBinary(m.FSub, "__fsub_{0}", Domain.Real); break;

                    case Mnemonic.hlt: RewriteHlt(); break;

                    case Mnemonic.isb: RewriteIsb(); break;

                    case Mnemonic.ld1: RewriteLdN("__ld1"); break;

                    case Mnemonic.ld1r: RewriteLdNr("__ld1r"); break;

                    case Mnemonic.ld2: RewriteLdN("__ld2"); break;

                    case Mnemonic.ld3: RewriteLdN("__ld3"); break;

                    case Mnemonic.ld4: RewriteLdN("__ld4"); break;

                    case Mnemonic.ldnp: RewriteLoadStorePair(true); break;

                    case Mnemonic.ldp: RewriteLoadStorePair(true); break;

                    case Mnemonic.ldarh: RewriteLoadAcquire("__load_acquire_{0}", PrimitiveType.Word16); break;

                    case Mnemonic.ldaxrh: RewriteLoadAcquire("__load_acquire_exclusive_{0}", PrimitiveType.Word16); break;

                    case Mnemonic.ldpsw: RewriteLoadStorePair(true, PrimitiveType.Int32, PrimitiveType.Int64); break;

                    case Mnemonic.ldr: RewriteLdr(null); break;

                    case Mnemonic.ldrb: RewriteLdr(PrimitiveType.Byte); break;

                    case Mnemonic.ldrh: RewriteLdr(PrimitiveType.Word16); break;

                    case Mnemonic.ldrsb: RewriteLdr(PrimitiveType.SByte); break;

                    case Mnemonic.ldrsh: RewriteLdr(PrimitiveType.Int16); break;

                    case Mnemonic.ldrsw: RewriteLdr(PrimitiveType.Int32, PrimitiveType.Int64); break;

                    case Mnemonic.ldxr: RewriteLdx(instr.Operands[0].Width); break;

                    case Mnemonic.lslv: RewriteBinary(m.Shl); break;

                    case Mnemonic.lsrv: RewriteBinary(m.Shr); break;

                    case Mnemonic.ldur: RewriteLdr(null); break;

                    case Mnemonic.ldurb: RewriteLdr(PrimitiveType.Byte); break;

                    case Mnemonic.ldurh: RewriteLdr(PrimitiveType.Word16); break;

                    case Mnemonic.ldursb: RewriteLdr(PrimitiveType.SByte); break;

                    case Mnemonic.ldursh: RewriteLdr(PrimitiveType.Int16); break;

                    case Mnemonic.ldursw: RewriteLdr(PrimitiveType.Int32); break;

                    case Mnemonic.lsl: RewriteBinary(m.Shl); break;

                    case Mnemonic.lsr: RewriteBinary(m.Shr); break;

                    case Mnemonic.madd: RewriteMaddSub(m.IAdd); break;

                    case Mnemonic.mla: RewriteSimdTrinary(Domain.None); break;

                    case Mnemonic.mls: RewriteSimdTrinary(Domain.None); break;

                    case Mnemonic.mneg: RewriteBinary((a, b) => m.Neg(m.IMul(a, b))); break;

                    case Mnemonic.mov: RewriteMov(); break;

                    case Mnemonic.movi: RewriteMovi(); break;

                    case Mnemonic.movk: RewriteMovk(); break;

                    case Mnemonic.movn: RewriteMovn(); break;

                    case Mnemonic.movz: RewriteMovz(); break;

                    case Mnemonic.mrs: RewriteMrs(); break;

                    case Mnemonic.msr: RewriteMsr(); break;

                    case Mnemonic.msub: RewriteMaddSub(m.ISub); break;

                    case Mnemonic.mul: RewriteMaybeSimdBinary(m.IMul, "__mul_{0}"); break;

                    case Mnemonic.mvn: RewriteUnary(m.Comp); break;

                    case Mnemonic.mvni: RewriteLogical((a, b) => ((BigConstant)b).Complement()); break;

                    case Mnemonic.neg: RewriteSimdUnary("__neg_{0}", Domain.SignedInt); break;

                    case Mnemonic.nop: m.Nop(); break;

                    case Mnemonic.not: RewriteMaybeSimdUnary(m.Comp, "__not_{0}"); break;

                    case Mnemonic.orr: RewriteLogical(m.Or); break;

                    case Mnemonic.orn: RewriteBinary((a, b) => m.Or(a, m.Comp(b))); break;

                    case Mnemonic.pmul: RewriteSimdBinary("__pmul_{0}", Domain.None); break;

                    case Mnemonic.pmull: RewriteSimdBinary("__pmull_{0}", Domain.None); break;

                    case Mnemonic.pmull2: RewriteSimdBinary("__pmull2_{0}", Domain.None); break;

                    case Mnemonic.prfm: RewritePrfm(); break;

                    case Mnemonic.raddhn: RewriteSimdBinary("__raddhn_{0}", Domain.None); break;

                    case Mnemonic.raddhn2: RewriteSimdBinary("__raddhn2_{0}", Domain.None); break;

                    case Mnemonic.rbit: RewriteRbit(); break;

                    case Mnemonic.ret: RewriteRet(); break;

                    case Mnemonic.rev: RewriteRev(); break;

                    case Mnemonic.rev16: RewriteRev16(); break;

                    case Mnemonic.rev32: RewriteRev32(); break;

                    case Mnemonic.rev64: RewriteSimdUnary("__rev64_{0}", Domain.None); break;

                    case Mnemonic.ror: RewriteRor(); break;

                    case Mnemonic.rorv: RewriteRor(); break;

                    case Mnemonic.rshrn: RewriteSimdBinary("__rshrn_{0}", Domain.None); break;

                    case Mnemonic.rshrn2: RewriteSimdBinary("__rshrn2_{0}", Domain.None); break;

                    case Mnemonic.rsubhn: RewriteSimdBinary("__rsubhn_{0}", Domain.None); break;

                    case Mnemonic.rsubhn2: RewriteSimdBinary("__rsubhn2_{0}", Domain.None); break;

                    case Mnemonic.saba: RewriteSimdBinary("__saba_{0}", Domain.None); break;

                    case Mnemonic.sabal: RewriteSimdBinary("__sabal_{0}", Domain.None); break;

                    case Mnemonic.sabal2: RewriteSimdBinary("__sabal2_{0}", Domain.None); break;

                    case Mnemonic.sabd: RewriteSimdBinary("__sabd_{0}", Domain.None); break;

                    case Mnemonic.sabdl: RewriteSimdBinary("__sabdl_{0}", Domain.None); break;

                    case Mnemonic.sabdl2: RewriteSimdBinary("__sabdl2_{0}", Domain.None); break;

                    case Mnemonic.sadalp: RewriteSimdBinary("__sadalp_{0}", Domain.SignedInt); break;

                    case Mnemonic.saddl: RewriteSimdBinary("__saddl_{0}", Domain.SignedInt); break;

                    case Mnemonic.saddl2: RewriteSimdBinary("__saddl2_{0}", Domain.SignedInt); break;

                    case Mnemonic.saddlp: RewriteSimdUnary("__saddlp_{0}", Domain.SignedInt); break;

                    case Mnemonic.saddlv: RewriteSimdUnary("__saddlv_{0}", Domain.SignedInt); break;

                    case Mnemonic.saddw: RewriteSimdBinary("__saddw_{0}", Domain.SignedInt); break;

                    case Mnemonic.saddw2: RewriteSimdBinary("__saddw2_{0}", Domain.SignedInt); break;

                    case Mnemonic.sbc: RewriteAdcSbc(m.ISub); break;

                    case Mnemonic.sbcs: RewriteAdcSbc(m.ISub, NZCV); break;

                    case Mnemonic.sbfiz: RewriteSbfiz(); break;

                    case Mnemonic.sbfm: RewriteUSbfm("__sbfm"); break;

                    case Mnemonic.scvtf: RewriteScvtf(); break;

                    case Mnemonic.sdiv: RewriteBinary(m.SDiv); break;

                    case Mnemonic.shadd: RewriteSimdBinary("__shadd_{0}", Domain.SignedInt); break;

                    case Mnemonic.shl: RewriteSimdBinary("__shl_{0}", Domain.None); break;

                    case Mnemonic.shll: RewriteSimdBinary("__shll_{0}", Domain.None); break;

                    case Mnemonic.shll2: RewriteSimdBinary("__shll2_{0}", Domain.None); break;

                    case Mnemonic.shrn: RewriteShrn(); break;

                    case Mnemonic.shsub: RewriteSimdBinary("__shsub_{0}", Domain.SignedInt); break;

                    case Mnemonic.sli: RewriteSimdBinary("__sli_{0}", Domain.None); break;

                    case Mnemonic.smaddl: RewriteMaddl(PrimitiveType.Int64, m.SMul); break;

                    case Mnemonic.smax: RewriteSimdBinary("__smax_{0}", Domain.SignedInt); break;

                    case Mnemonic.smaxp: RewriteSimdBinary("__smaxp_{0}", Domain.SignedInt); break;

                    case Mnemonic.smaxv: RewriteSimdReduce("__smaxv_{0}", Domain.SignedInt); break;

                    case Mnemonic.smc: RewriteSmc(); break;

                    case Mnemonic.smin: RewriteSimdBinary("__smin_{0}", Domain.SignedInt); break;

                    case Mnemonic.sminp: RewriteSimdBinary("__sminp_{0}", Domain.SignedInt); break;

                    case Mnemonic.sminv: RewriteSimdUnary("__sminv_{0}", Domain.SignedInt); break;

                    case Mnemonic.smlal: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.smlal2: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.smlsl: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.smlsl2: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.smov: RewriteVectorElementToScalar(Domain.SignedInt); break;

                    case Mnemonic.smsubl: RewriteSmsubl(); break;

                    case Mnemonic.smull: RewriteMull(PrimitiveType.Int32, PrimitiveType.Int64, m.SMul); break;

                    case Mnemonic.smull2: RewriteSimdBinary("__smull2_{0}", Domain.SignedInt); break;

                    case Mnemonic.smulh: RewriteMulh(PrimitiveType.Int64, PrimitiveType.Int128, m.SMul); break;

                    case Mnemonic.sqabs: RewriteSimdUnary("__sqabs_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqadd: RewriteSimdBinary("__sqadd_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqdmulh: RewriteMaybeSimdBinary(Domain.SignedInt); break;

                    case Mnemonic.sqdmull: RewriteSimdBinary("__sqdmull_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqdmull2: RewriteSimdBinary("__sqdmull2_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqdmlal: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.sqdmlal2: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.sqdmlsl: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.sqdmlsl2: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.sqneg: RewriteSimdUnary("__sqneg_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqrdmlah: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.sqrdmlsh: RewriteSimdTrinary(Domain.SignedInt); break;

                    case Mnemonic.sqrdmulh: RewriteSimdBinary("__sqrdmulh_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqrshl: RewriteSimdBinary("__sqrshl_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqrshrn: RewriteSimdBinary("__sqrshrn_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqrshrn2: RewriteSimdBinary("__sqrshrn2_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqrshrun: RewriteSimdBinary("__sqrshrun_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqrshrun2: RewriteSimdBinary("__sqrshrun2_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqshl: RewriteSimdBinary("__sqshl_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqshlu: RewriteSimdBinary("__sqshlu_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqshrn: RewriteSimdBinary("__sqshrn_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqshrn2: RewriteSimdBinary("__sqshrn2_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqsub: RewriteSimdBinary("__sqsub_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqxtn: RewriteSimdUnary("__sqxtn_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqxtn2: RewriteSimdUnary("__sqxtn2_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqxtun: RewriteSimdUnary("__sqxtun_{0}", Domain.SignedInt); break;

                    case Mnemonic.sqxtun2: RewriteSimdUnary("__sqxtun2_{0}", Domain.SignedInt); break;

                    case Mnemonic.sri: RewriteSimdBinary("__sri_{0}", Domain.SignedInt); break;

                    case Mnemonic.srhadd: RewriteSimdBinary("__srhadd_{0}", Domain.SignedInt); break;

                    case Mnemonic.srshl: RewriteSimdBinary("__srshl_{0}", Domain.SignedInt); break;

                    case Mnemonic.srshr: RewriteSimdBinary("__srshr_{0}", Domain.SignedInt); break;

                    case Mnemonic.srsra: RewriteSimdBinary("__srsra_{0}", Domain.SignedInt); break;

                    case Mnemonic.sshl: RewriteSimdBinary("__sshl_{0}", Domain.SignedInt); break;

                    case Mnemonic.sshll: RewriteSimdBinary("__sshll_{0}", Domain.SignedInt); break;

                    case Mnemonic.sshll2: RewriteSimdBinary("__sshll2_{0}", Domain.SignedInt); break;

                    case Mnemonic.sshr: RewriteSimdWithScalar("__sshr_{0}", Domain.SignedInt); break;

                    case Mnemonic.ssra: RewriteSimdBinary("__ssra_{0}", Domain.SignedInt); break;

                    case Mnemonic.ssubl: RewriteSimdBinary("__ssubl_{0}", Domain.SignedInt); break;

                    case Mnemonic.ssubl2: RewriteSimdBinary("__ssubl2_{0}", Domain.SignedInt); break;

                    case Mnemonic.ssubw: RewriteSimdBinary("__ssubw_{0}", Domain.SignedInt); break;

                    case Mnemonic.ssubw2: RewriteSimdBinary("__ssubw2_{0}", Domain.SignedInt); break;

                    case Mnemonic.subhn: RewriteSimdBinary("__subhn_{0}", Domain.SignedInt); break;

                    case Mnemonic.subhn2: RewriteSimdBinary("__subhn2_{0}", Domain.SignedInt); break;

                    case Mnemonic.suqadd: RewriteSimdBinary("__suqadd_{0}", Domain.SignedInt); break;

                    case Mnemonic.st1: RewriteStN("__st1"); break;

                    case Mnemonic.st2: RewriteStN("__st2"); break;

                    case Mnemonic.st3: RewriteStN("__st3"); break;

                    case Mnemonic.st4: RewriteStN("__st4"); break;

                    case Mnemonic.stlr: RewriteStlr(instr.Operands[0].Width); break;

                    case Mnemonic.stlrh: RewriteStlr(PrimitiveType.Word16); break;

                    case Mnemonic.stp: RewriteLoadStorePair(false); break;

                    case Mnemonic.str: RewriteStr(null); break;

                    case Mnemonic.strb: RewriteStr(PrimitiveType.Byte); break;

                    case Mnemonic.strh: RewriteStr(PrimitiveType.Word16); break;

                    case Mnemonic.stur: RewriteStr(null); break;

                    case Mnemonic.sturb: RewriteStr(PrimitiveType.Byte); break;

                    case Mnemonic.sturh: RewriteStr(PrimitiveType.Word16); break;

                    case Mnemonic.stxr: RewriteStx(instr.Operands[1].Width); break;

                    case Mnemonic.stxrb: RewriteStx(PrimitiveType.Byte); break;

                    case Mnemonic.sub: RewriteBinary(m.ISub); break;

                    case Mnemonic.subs: RewriteBinary(m.ISub, NZCV); break;

                    case Mnemonic.svc: RewriteSvc(); break;

                    case Mnemonic.sxtb: RewriteUSxt(Domain.SignedInt, 8); break;

                    case Mnemonic.sxth: RewriteUSxt(Domain.SignedInt, 16); break;

                    case Mnemonic.sxtl: RewriteSimdUnary("__sxtl_{0}", Domain.SignedInt); break;

                    case Mnemonic.sxtw: RewriteUSxt(Domain.SignedInt, 32); break;

                    case Mnemonic.tbnz: RewriteTb(m.Ne0); break;

                    case Mnemonic.tbl: RewriteTbl(); break;

                    case Mnemonic.tbx: RewriteTbx(); break;

                    case Mnemonic.tbz: RewriteTb(m.Eq0); break;

                    case Mnemonic.test: RewriteTest(); break;

                    case Mnemonic.trn1: RewriteSimdBinary("__trn1_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.trn2: RewriteSimdBinary("__trn2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uaba: RewriteSimdBinary("__uaba_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uabal: RewriteSimdBinary("__uabal_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uabal2: RewriteSimdBinary("__uabal2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uabd: RewriteSimdBinary("__uabd_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uabdl: RewriteSimdBinary("__uabdl_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uabdl2: RewriteSimdBinary("__uabdl2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uadalp: RewriteSimdBinary("__uadalp_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uaddl: RewriteSimdBinary("__uaddl_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uaddl2: RewriteSimdBinary("__uaddl2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uaddlp: RewriteSimdBinary("__uaddlp_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uaddlv: RewriteSimdUnary("__uaddlv_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uaddw: RewriteUaddw(); break;

                    case Mnemonic.uaddw2: RewriteSimdBinary("__uaddw_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.ubfm: RewriteUSbfm("__ubfm"); break;

                    case Mnemonic.ucvtf: RewriteIcvt("__ucvtf_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.udiv: RewriteBinary(m.UDiv); break;

                    case Mnemonic.uhadd: RewriteSimdBinary("__uhadd_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uhsub: RewriteSimdBinary("__uhsub_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.umaddl: RewriteMaddl(PrimitiveType.UInt64, m.UMul); break;

                    case Mnemonic.umax: RewriteSimdBinary("__umax_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.umaxp: RewriteSimdBinary("__umaxp_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.umaxv: RewriteSimdUnary("__umaxv_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.umin: RewriteSimdBinary("__umin_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uminp: RewriteSimdBinary("__uminp_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uminv: RewriteSimdUnary("__uminv_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.umlal: RewriteSimdTrinary(Domain.UnsignedInt); break;

                    case Mnemonic.umlal2: RewriteSimdTrinary(Domain.UnsignedInt); break;

                    case Mnemonic.umlsl: RewriteSimdTrinary(Domain.UnsignedInt); break;

                    case Mnemonic.umlsl2: RewriteSimdTrinary(Domain.UnsignedInt); break;

                    case Mnemonic.umov: RewriteVectorElementToScalar(Domain.UnsignedInt); break;

                    case Mnemonic.umulh: RewriteMulh(PrimitiveType.UInt64, m.UMul); break;

                    case Mnemonic.umull: RewriteMull(PrimitiveType.UInt32, PrimitiveType.UInt64, m.UMul); break;

                    case Mnemonic.umull2: RewriteSimdBinary("__umull2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqadd: RewriteSimdBinary("__uqadd_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqrshl: RewriteSimdBinary("__uqrshl_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqrshrn: RewriteSimdBinary("__uqrshrn_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqrshrn2: RewriteSimdBinary("__uqrshrn2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqshl: RewriteSimdBinary("__uqshl_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqshrn: RewriteSimdBinary("__uqshrn_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqshrn2: RewriteSimdBinary("__uqshrn2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqsub: RewriteSimdBinary("__uqsub_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqxtn: RewriteSimdUnary("__uqxtn_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uqxtn2: RewriteSimdUnary("__uqxtn2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.urecpe: RewriteSimdUnary("__urecpe_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.urhadd: RewriteSimdBinary("__urhadd_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.urshl: RewriteSimdBinary("__urshl_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.urshr: RewriteSimdBinary("__urshr_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.ursqrte: RewriteSimdUnary("__ursqrte_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.ursra: RewriteSimdBinary("__ursra_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.ushl: RewriteMaybeSimdBinary(m.Shr, "__ushl_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.ushll: RewriteMaybeSimdBinary(m.Shr, "__ushll_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.ushll2: RewriteMaybeSimdBinary(m.Shr, "__ushll2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.ushr: RewriteMaybeSimdBinary(m.Shr, "__ushr_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.usqadd: RewriteSimdBinary("__usqadd_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.usra: RewriteSimdBinary("__usra_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.usubl: RewriteSimdBinary("__usubl_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.usubl2: RewriteSimdBinary("__usubl2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.usubw: RewriteSimdBinary("__usubw_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.usubw2: RewriteSimdBinary("__usubw2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uxtb: RewriteUSxt(Domain.UnsignedInt, 8); break;

                    case Mnemonic.uxth: RewriteUSxt(Domain.UnsignedInt, 16); break;

                    case Mnemonic.uxtl: RewriteSimdUnary("__uxtl_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uxtl2: RewriteSimdUnary("__uxtl2_{0}", Domain.UnsignedInt); break;

                    case Mnemonic.uxtw: RewriteUSxt(Domain.UnsignedInt, 32); break;

                    case Mnemonic.uzp1: RewriteSimdBinary("__uzp1_{0}", Domain.None); break;

                    case Mnemonic.uzp2: RewriteSimdBinary("__uzp2_{0}", Domain.None); break;

                    case Mnemonic.xtn: RewriteSimdUnary("__xtn_{0}", Domain.None); break;

                    case Mnemonic.xtn2: RewriteSimdUnary("__xtn2_{0}", Domain.None); break;

                    case Mnemonic.zip1: RewriteSimdBinary("__zip1_{0}", Domain.None); break;

                    case Mnemonic.zip2: RewriteSimdBinary("__zip2_{0}", Domain.None); break;
                    }
                } catch (Exception e)
                {
                    EmitUnitTest(e.Message);
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));

                cluster.Clear();
            }
        }
Пример #12
0
        /// <summary>
        /// Iterator that yields one RtlIntructionCluster for each x86 instruction.
        /// </summary>
        /// <returns></returns>
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                instrCur = dasm.Current;
                var addr = instrCur.Address;
                this.rtlInstructions = new List <RtlInstruction>();
                this.iclass          = instrCur.InstructionClass;
                m   = new RtlEmitter(rtlInstructions);
                orw = arch.ProcessorMode.CreateOperandRewriter(arch, m, binder, host);
                switch (instrCur.Mnemonic)
                {
                default:
                    EmitUnitTest();
                    host.Warn(
                        dasm.Current.Address,
                        "x86 instruction '{0}' is not supported yet.",
                        instrCur.Mnemonic);
                    goto case Mnemonic.illegal;

                case Mnemonic.illegal: iclass = InstrClass.Invalid; m.Invalid(); break;

                case Mnemonic.aaa: RewriteAaa(); break;

                case Mnemonic.aad: RewriteAad(); break;

                case Mnemonic.aam: RewriteAam(); break;

                case Mnemonic.aas: RewriteAas(); break;

                case Mnemonic.adc: RewriteAdcSbb(m.IAdd); break;

                case Mnemonic.add: RewriteAddSub(Operator.IAdd); break;

                case Mnemonic.addss: RewriteScalarBinop(m.FAdd, PrimitiveType.Real32, false); break;

                case Mnemonic.vaddss: RewriteScalarBinop(m.FAdd, PrimitiveType.Real32, true); break;

                case Mnemonic.addsd: RewriteScalarBinop(m.FAdd, PrimitiveType.Real64, false); break;

                case Mnemonic.vaddsd: RewriteScalarBinop(m.FAdd, PrimitiveType.Real64, true); break;

                case Mnemonic.addps: RewritePackedBinop("__addps", PrimitiveType.Real32); break;

                case Mnemonic.addpd: RewritePackedBinop("__addpd", PrimitiveType.Real64); break;

                case Mnemonic.aesimc: RewriteAesimc(); break;

                case Mnemonic.and: RewriteLogical(Operator.And); break;

                case Mnemonic.andnps: RewriteAndnps(); break;

                case Mnemonic.andpd: RewritePackedBinop("__andpd", PrimitiveType.Real64); break;

                case Mnemonic.andps: RewritePackedBinop("__andps", PrimitiveType.Real32); break;

                case Mnemonic.arpl: RewriteArpl(); break;

                case Mnemonic.bound: RewriteBound(); break;

                case Mnemonic.bsf: RewriteBsf(); break;

                case Mnemonic.bsr: RewriteBsr(); break;

                case Mnemonic.bswap: RewriteBswap(); break;

                case Mnemonic.bt: RewriteBt(); break;

                case Mnemonic.btc: RewriteBtc(); break;

                case Mnemonic.btr: RewriteBtr(); break;

                case Mnemonic.bts: RewriteBts(); break;

                case Mnemonic.call: RewriteCall(instrCur.Operands[0], instrCur.Operands[0].Width); break;

                case Mnemonic.cbw: RewriteCbw(); break;

                case Mnemonic.cdq: RewriteCdq(); break;

                case Mnemonic.cdqe: RewriteCdqe(); break;

                case Mnemonic.cqo: RewriteCqo(); break;

                case Mnemonic.clc: RewriteSetFlag(FlagM.CF, Constant.False()); break;

                case Mnemonic.cld: RewriteSetFlag(FlagM.DF, Constant.False()); break;

                case Mnemonic.cli: RewriteCli(); break;

                case Mnemonic.clts: RewriteClts(); break;

                case Mnemonic.cmc: m.Assign(orw.FlagGroup(FlagM.CF), m.Not(orw.FlagGroup(FlagM.CF))); break;

                case Mnemonic.cmova: RewriteConditionalMove(ConditionCode.UGT, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovbe: RewriteConditionalMove(ConditionCode.ULE, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovc: RewriteConditionalMove(ConditionCode.ULT, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovge: RewriteConditionalMove(ConditionCode.GE, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovg: RewriteConditionalMove(ConditionCode.GT, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovl: RewriteConditionalMove(ConditionCode.LT, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovle: RewriteConditionalMove(ConditionCode.LE, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovnc: RewriteConditionalMove(ConditionCode.UGE, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovno: RewriteConditionalMove(ConditionCode.NO, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovns: RewriteConditionalMove(ConditionCode.NS, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovnz: RewriteConditionalMove(ConditionCode.NE, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovo: RewriteConditionalMove(ConditionCode.OV, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovpe: RewriteConditionalMove(ConditionCode.PE, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovpo: RewriteConditionalMove(ConditionCode.PO, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovs: RewriteConditionalMove(ConditionCode.SG, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmovz: RewriteConditionalMove(ConditionCode.EQ, instrCur.Operands[0], instrCur.Operands[1]); break;

                case Mnemonic.cmpxchg: RewriteCmpxchg(); break;

                case Mnemonic.cmpxchg8b: RewriteCmpxchgNb("__cmpxchg8b", Registers.edx, Registers.eax, Registers.ecx, Registers.ebx); break;

                case Mnemonic.cmpxchg16b: RewriteCmpxchgNb("__cmpxchg16b", Registers.rdx, Registers.rax, Registers.rcx, Registers.rbx); break;

                case Mnemonic.cmp: RewriteCmp(); break;

                case Mnemonic.cmps: RewriteStringInstruction(); break;

                case Mnemonic.cmppd: RewriteCmpp("__cmppd", PrimitiveType.Real64); break;

                case Mnemonic.cmpps: RewriteCmpp("__cmpps", PrimitiveType.Real32); break;

                case Mnemonic.cmpsb: RewriteStringInstruction(); break;

                case Mnemonic.comisd: RewriteComis(PrimitiveType.Real64); break;

                case Mnemonic.comiss: RewriteComis(PrimitiveType.Real32); break;

                case Mnemonic.cpuid: RewriteCpuid(); break;

                case Mnemonic.cvtpi2ps: RewriteCvtPackedToReal(PrimitiveType.Real32); break;

                case Mnemonic.cvtps2pi: RewriteCvtps2pi("__cvtps2pi", PrimitiveType.Real32, PrimitiveType.Int32); break;

                case Mnemonic.cvtps2pd: RewriteCvtps2pi("__cvtps2pd", PrimitiveType.Real32, PrimitiveType.Real64); break;

                case Mnemonic.cvtdq2ps: RewriteCvtps2pi("__cvtdq2ps", PrimitiveType.Int64, PrimitiveType.Real32); break;

                case Mnemonic.cvtsd2si: RewriteCvts2si(PrimitiveType.Real64); break;

                case Mnemonic.cvtsd2ss: RewriteCvtToReal(PrimitiveType.Real32); break;

                case Mnemonic.cvtsi2ss:
                case Mnemonic.vcvtsi2ss: RewriteCvtToReal(PrimitiveType.Real32); break;

                case Mnemonic.cvtsi2sd:
                case Mnemonic.vcvtsi2sd: RewriteCvtToReal(PrimitiveType.Real64); break;

                case Mnemonic.cvtss2sd: RewriteCvtToReal(PrimitiveType.Real64); break;

                case Mnemonic.cvtss2si: RewriteCvts2si(PrimitiveType.Real32); break;

                case Mnemonic.cvttsd2si: RewriteCvtts2si(PrimitiveType.Real64); break;

                case Mnemonic.cvttss2si: RewriteCvtts2si(PrimitiveType.Real32); break;

                case Mnemonic.cvttps2pi: RewriteCvttps2pi(); break;

                case Mnemonic.cwd: RewriteCwd(); break;

                case Mnemonic.cwde: RewriteCwde(); break;

                case Mnemonic.daa: EmitDaaDas("__daa"); break;

                case Mnemonic.das: EmitDaaDas("__das"); break;

                case Mnemonic.dec: RewriteIncDec(-1); break;

                case Mnemonic.div: RewriteDivide(m.UDiv, Domain.UnsignedInt); break;

                case Mnemonic.divps: RewritePackedBinop("__divps", PrimitiveType.Real32); break;

                case Mnemonic.divsd: RewriteScalarBinop(m.FDiv, PrimitiveType.Real64, false); break;

                case Mnemonic.vdivsd: RewriteScalarBinop(m.FDiv, PrimitiveType.Real64, true); break;

                case Mnemonic.divss: RewriteScalarBinop(m.FDiv, PrimitiveType.Real32, false); break;

                case Mnemonic.vdivss: RewriteScalarBinop(m.FDiv, PrimitiveType.Real32, true); break;

                case Mnemonic.f2xm1: RewriteF2xm1(); break;

                case Mnemonic.emms: RewriteEmms(); break;

                case Mnemonic.enter: RewriteEnter(); break;

                case Mnemonic.fabs: RewriteFabs(); break;

                case Mnemonic.fadd: EmitCommonFpuInstruction(m.FAdd, false, false); break;

                case Mnemonic.faddp: EmitCommonFpuInstruction(m.FAdd, false, true); break;

                case Mnemonic.fbld: RewriteFbld(); break;

                case Mnemonic.fbstp: RewriteFbstp(); break;

                case Mnemonic.fchs: EmitFchs(); break;

                case Mnemonic.fclex: RewriteFclex(); break;

                case Mnemonic.fcmovb: RewriteFcmov(FlagM.CF, ConditionCode.GE); break;

                case Mnemonic.fcmovbe: RewriteFcmov(FlagM.CF | FlagM.ZF, ConditionCode.GT); break;

                case Mnemonic.fcmove: RewriteFcmov(FlagM.ZF, ConditionCode.NE); break;

                case Mnemonic.fcmovnb: RewriteFcmov(FlagM.CF | FlagM.ZF, ConditionCode.GE); break;

                case Mnemonic.fcmovnbe: RewriteFcmov(FlagM.CF | FlagM.ZF, ConditionCode.LE); break;

                case Mnemonic.fcmovne: RewriteFcmov(FlagM.ZF, ConditionCode.EQ); break;

                case Mnemonic.fcmovnu: RewriteFcmov(FlagM.PF, ConditionCode.IS_NAN); break;

                case Mnemonic.fcmovu: RewriteFcmov(FlagM.PF, ConditionCode.NOT_NAN); break;

                case Mnemonic.fcom: RewriteFcom(0); break;

                case Mnemonic.fcomi: RewriteFcomi(false); break;

                case Mnemonic.fcomip: RewriteFcomi(true); break;

                case Mnemonic.fcomp: RewriteFcom(1); break;

                case Mnemonic.fcompp: RewriteFcom(2); break;

                case Mnemonic.fcos: RewriteFUnary("cos"); break;

                case Mnemonic.fdecstp: RewriteFdecstp(); break;

                case Mnemonic.fdiv: EmitCommonFpuInstruction(m.FDiv, false, false); break;

                case Mnemonic.fdivp: EmitCommonFpuInstruction(m.FDiv, false, true); break;

                case Mnemonic.femms: RewriteFemms(); break;

                case Mnemonic.ffree: RewriteFfree(false); break;

                case Mnemonic.ffreep: RewriteFfree(true); break;

                case Mnemonic.fiadd: EmitCommonFpuInstruction(m.FAdd, false, false, PrimitiveType.Real64); break;

                case Mnemonic.ficom: RewriteFicom(false); break;

                case Mnemonic.ficomp: RewriteFicom(true); break;

                case Mnemonic.fimul: EmitCommonFpuInstruction(m.FMul, false, false, PrimitiveType.Real64); break;

                case Mnemonic.fisub: EmitCommonFpuInstruction(m.FSub, false, false, PrimitiveType.Real64); break;

                case Mnemonic.fisubr: EmitCommonFpuInstruction(m.FSub, true, false, PrimitiveType.Real64); break;

                case Mnemonic.fidiv: EmitCommonFpuInstruction(m.FDiv, false, false, PrimitiveType.Real64); break;

                case Mnemonic.fidivr: EmitCommonFpuInstruction(m.FDiv, true, false, PrimitiveType.Real64); break;

                case Mnemonic.fdivr: EmitCommonFpuInstruction(m.FDiv, true, false); break;

                case Mnemonic.fdivrp: EmitCommonFpuInstruction(m.FDiv, true, true); break;

                case Mnemonic.fild: RewriteFild(); break;

                case Mnemonic.fincstp: RewriteFincstp(); break;

                case Mnemonic.fist: RewriteFist(false); break;

                case Mnemonic.fistp: RewriteFist(true); break;

                case Mnemonic.fisttp: RewriteFistt(true); break;

                case Mnemonic.fld: RewriteFld(); break;

                case Mnemonic.fld1: RewriteFldConst(1.0); break;

                case Mnemonic.fldcw: RewriteFldcw(); break;

                case Mnemonic.fldenv: RewriteFldenv(); break;

                case Mnemonic.fldl2e: RewriteFldConst(Constant.LgE()); break;

                case Mnemonic.fldl2t: RewriteFldConst(Constant.Lg10()); break;

                case Mnemonic.fldlg2: RewriteFldConst(Constant.Log2()); break;

                case Mnemonic.fldln2: RewriteFldConst(Constant.Ln2()); break;

                case Mnemonic.fldpi: RewriteFldConst(Constant.Pi()); break;

                case Mnemonic.fldz: RewriteFldConst(0.0); break;

                case Mnemonic.fmul: EmitCommonFpuInstruction(m.FMul, false, false); break;

                case Mnemonic.fmulp: EmitCommonFpuInstruction(m.FMul, false, true); break;

                case Mnemonic.fninit: RewriteFninit(); break;

                case Mnemonic.fnop: m.Nop(); break;

                case Mnemonic.fnsetpm: m.Nop(); break;

                case Mnemonic.fpatan: RewriteFpatan(); break;

                case Mnemonic.fprem: RewriteFprem(); break;

                case Mnemonic.fprem1: RewriteFprem1(); break;

                case Mnemonic.fptan: RewriteFptan(); break;

                case Mnemonic.frndint: RewriteFUnary("__rndint"); break;

                case Mnemonic.frstor: RewriteFrstor(); break;

                case Mnemonic.fsave: RewriteFsave(); break;

                case Mnemonic.fscale: RewriteFscale(); break;

                case Mnemonic.fsin: RewriteFUnary("sin"); break;

                case Mnemonic.fsincos: RewriteFsincos(); break;

                case Mnemonic.fsqrt: RewriteFUnary("sqrt"); break;

                case Mnemonic.fst: RewriteFst(false); break;

                case Mnemonic.fstenv: RewriteFstenv(); break;

                case Mnemonic.fstcw: RewriterFstcw(); break;

                case Mnemonic.fstp: RewriteFst(true); break;

                case Mnemonic.fstsw: RewriteFstsw(); break;

                case Mnemonic.fsub: EmitCommonFpuInstruction(m.FSub, false, false); break;

                case Mnemonic.fsubp: EmitCommonFpuInstruction(m.FSub, false, true); break;

                case Mnemonic.fsubr: EmitCommonFpuInstruction(m.FSub, true, false); break;

                case Mnemonic.fsubrp: EmitCommonFpuInstruction(m.FSub, true, true); break;

                case Mnemonic.ftst: RewriteFtst(); break;

                case Mnemonic.fucom: RewriteFcom(0); break;

                case Mnemonic.fucomp: RewriteFcom(1); break;

                case Mnemonic.fucompp: RewriteFcom(2); break;

                case Mnemonic.fucomi: RewriteFcomi(false); break;

                case Mnemonic.fucomip: RewriteFcomi(true); break;

                case Mnemonic.fxam: RewriteFxam(); break;

                case Mnemonic.fxch: RewriteExchange(); break;

                case Mnemonic.fxtract: RewriteFxtract(); break;

                case Mnemonic.fyl2x: RewriteFyl2x(); break;

                case Mnemonic.fyl2xp1: RewriteFyl2xp1(); break;

                case Mnemonic.getsec: RewriteGetsec(); break;

                case Mnemonic.hlt: RewriteHlt(); break;

                case Mnemonic.icebp: RewriteIcebp(); break;

                case Mnemonic.idiv: RewriteDivide(m.SDiv, Domain.SignedInt); break;

                case Mnemonic.@in: RewriteIn(); break;

                case Mnemonic.imul: RewriteMultiply(Operator.SMul, Domain.SignedInt); break;

                case Mnemonic.inc: RewriteIncDec(1); break;

                case Mnemonic.insb: RewriteStringInstruction(); break;

                case Mnemonic.ins: RewriteStringInstruction(); break;

                case Mnemonic.invlpg: RewriteInvlpg(); break;

                case Mnemonic.@int: RewriteInt(); break;

                case Mnemonic.into: RewriteInto(); break;

                case Mnemonic.invd: RewriteInvd(); break;

                case Mnemonic.iret: RewriteIret(); break;

                case Mnemonic.jmp: RewriteJmp(); break;

                case Mnemonic.jmpe: RewriteJmpe(); break;

                case Mnemonic.ja: RewriteConditionalGoto(ConditionCode.UGT, instrCur.Operands[0]); break;

                case Mnemonic.jbe: RewriteConditionalGoto(ConditionCode.ULE, instrCur.Operands[0]); break;

                case Mnemonic.jc: RewriteConditionalGoto(ConditionCode.ULT, instrCur.Operands[0]); break;

                case Mnemonic.jcxz: RewriteJcxz(Registers.cx); break;

                case Mnemonic.jecxz: RewriteJcxz(Registers.ecx); break;

                case Mnemonic.jge: RewriteConditionalGoto(ConditionCode.GE, instrCur.Operands[0]); break;

                case Mnemonic.jg: RewriteConditionalGoto(ConditionCode.GT, instrCur.Operands[0]); break;

                case Mnemonic.jl: RewriteConditionalGoto(ConditionCode.LT, instrCur.Operands[0]); break;

                case Mnemonic.jle: RewriteConditionalGoto(ConditionCode.LE, instrCur.Operands[0]); break;

                case Mnemonic.jnc: RewriteConditionalGoto(ConditionCode.UGE, instrCur.Operands[0]); break;

                case Mnemonic.jno: RewriteConditionalGoto(ConditionCode.NO, instrCur.Operands[0]); break;

                case Mnemonic.jns: RewriteConditionalGoto(ConditionCode.NS, instrCur.Operands[0]); break;

                case Mnemonic.jnz: RewriteConditionalGoto(ConditionCode.NE, instrCur.Operands[0]); break;

                case Mnemonic.jo: RewriteConditionalGoto(ConditionCode.OV, instrCur.Operands[0]); break;

                case Mnemonic.jpe: RewriteConditionalGoto(ConditionCode.PE, instrCur.Operands[0]); break;

                case Mnemonic.jpo: RewriteConditionalGoto(ConditionCode.PO, instrCur.Operands[0]); break;

                case Mnemonic.jrcxz: RewriteJcxz(Registers.rcx); break;

                case Mnemonic.js: RewriteConditionalGoto(ConditionCode.SG, instrCur.Operands[0]); break;

                case Mnemonic.jz: RewriteConditionalGoto(ConditionCode.EQ, instrCur.Operands[0]); break;

                case Mnemonic.lahf: RewriteLahf(); break;

                case Mnemonic.lar: RewriteLar(); break;

                case Mnemonic.lds: RewriteLxs(Registers.ds); break;

                case Mnemonic.ldmxcsr: RewriteLdmxcsr(); break;

                case Mnemonic.stmxcsr: RewriteStmxcsr(); break;

                case Mnemonic.lea: RewriteLea(); break;

                case Mnemonic.leave: RewriteLeave(); break;

                case Mnemonic.les: RewriteLxs(Registers.es); break;

                case Mnemonic.lfence: RewriteLfence(); break;

                case Mnemonic.lfs: RewriteLxs(Registers.fs); break;

                case Mnemonic.lgs: RewriteLxs(Registers.gs); break;

                case Mnemonic.lgdt: RewriteLxdt("__lgdt"); break;

                case Mnemonic.lidt: RewriteLxdt("__lidt"); break;

                case Mnemonic.lldt: RewriteLxdt("__lldt"); break;

                case Mnemonic.lmsw: RewriteLmsw(); break;

                case Mnemonic.@lock: RewriteLock(); break;

                case Mnemonic.lods: RewriteStringInstruction(); break;

                case Mnemonic.lodsb: RewriteStringInstruction(); break;

                case Mnemonic.loop: RewriteLoop(0, ConditionCode.EQ); break;

                case Mnemonic.loope: RewriteLoop(FlagM.ZF, ConditionCode.EQ); break;

                case Mnemonic.loopne: RewriteLoop(FlagM.ZF, ConditionCode.NE); break;

                case Mnemonic.lsl: RewriteLsl(); break;

                case Mnemonic.lss: RewriteLxs(Registers.ss); break;

                case Mnemonic.ltr: RewriteLtr(); break;

                case Mnemonic.maskmovq: RewriteMaskmovq(); break;

                case Mnemonic.maxps: RewritePackedBinop("__maxps", PrimitiveType.Real32); break;

                case Mnemonic.mfence: RewriteMfence(); break;

                case Mnemonic.minpd: RewritePackedBinop("__minpd", PrimitiveType.Real64); break;

                case Mnemonic.minps: RewritePackedBinop("__minps", PrimitiveType.Real32); break;

                case Mnemonic.mov: RewriteMov(); break;

                case Mnemonic.movapd:
                case Mnemonic.movaps:
                case Mnemonic.vmovapd:
                case Mnemonic.vmovaps: RewriteMov(); break;

                case Mnemonic.vmread: RewriteVmread(); break;

                case Mnemonic.vmwrite: RewriteVmwrite(); break;

                case Mnemonic.movbe: RewriteMovbe(); break;

                case Mnemonic.movd: RewriteMovzx(); break;

                case Mnemonic.movdqa:
                case Mnemonic.vmovdqa:
                    RewriteMov(); break;

                case Mnemonic.movhpd: RewritePackedUnaryop("__movhpd", PrimitiveType.Real64, PrimitiveType.Real64); break;

                case Mnemonic.movhps: RewritePackedUnaryop("__movhps", PrimitiveType.Real32, PrimitiveType.Real64); break;

                case Mnemonic.movlpd: RewritePackedUnaryop("__movlpd", PrimitiveType.Real64, PrimitiveType.Real64); break;

                case Mnemonic.movlps: RewritePackedUnaryop("__movlps", PrimitiveType.Real32, PrimitiveType.Real64); break;

                case Mnemonic.movlhps: RewriteMovlhps(); break;

                case Mnemonic.movmskpd: RewriteMovmsk("__movmskpd", PrimitiveType.Real64); break;

                case Mnemonic.movmskps: RewriteMovmsk("__movmskps", PrimitiveType.Real32); break;

                case Mnemonic.movnti: RewriteMov(); break;

                case Mnemonic.movntps: RewriteMov(); break;

                case Mnemonic.movntq: RewriteMov(); break;

                case Mnemonic.movq: RewriteMov(); break;

                case Mnemonic.movs: RewriteStringInstruction(); break;

                case Mnemonic.movsb: RewriteStringInstruction(); break;

                case Mnemonic.movsd:
                case Mnemonic.vmovsd: RewriteMovssd(PrimitiveType.Real64); break;

                case Mnemonic.movss:
                case Mnemonic.vmovss: RewriteMovssd(PrimitiveType.Real32); break;

                case Mnemonic.movsx: RewriteMovsx(); break;

                case Mnemonic.movsxd: RewriteMovsx(); break;

                case Mnemonic.movups: RewriteMov(); break;

                case Mnemonic.movupd: RewriteMov(); break;

                case Mnemonic.movzx: RewriteMovzx(); break;

                case Mnemonic.mul: RewriteMultiply(Operator.UMul, Domain.UnsignedInt); break;

                case Mnemonic.mulpd: RewritePackedBinop("__mulpd", PrimitiveType.Real64); break;

                case Mnemonic.mulps: RewritePackedBinop("__mulps", PrimitiveType.Real32); break;

                case Mnemonic.mulsd: RewriteScalarBinop(m.FMul, PrimitiveType.Real64, false); break;

                case Mnemonic.vmulsd: RewriteScalarBinop(m.FMul, PrimitiveType.Real64, true); break;

                case Mnemonic.mulss: RewriteScalarBinop(m.FMul, PrimitiveType.Real32, false); break;

                case Mnemonic.vmulss: RewriteScalarBinop(m.FMul, PrimitiveType.Real32, true); break;

                case Mnemonic.neg: RewriteNeg(); break;

                case Mnemonic.nop: m.Nop(); break;

                case Mnemonic.not: RewriteNot(); break;

                case Mnemonic.or: RewriteLogical(BinaryOperator.Or); break;

                case Mnemonic.orpd: RewritePackedBinop("__orpd", PrimitiveType.Real64); break;

                case Mnemonic.orps: RewritePackedBinop("__orps", PrimitiveType.Real32); break;

                case Mnemonic.@out: RewriteOut(); break;

                case Mnemonic.@outs: RewriteStringInstruction(); break;

                case Mnemonic.@outsb: RewriteStringInstruction(); break;

                case Mnemonic.packssdw: RewritePackedBinop("__packssdw", PrimitiveType.Int32, new ArrayType(PrimitiveType.Int16, 0)); break;

                case Mnemonic.packuswb: RewritePackedBinop("__packuswb", PrimitiveType.UInt16, new ArrayType(PrimitiveType.UInt8, 0)); break;

                case Mnemonic.paddb: RewritePackedBinop("__paddb", PrimitiveType.Byte); break;

                case Mnemonic.paddd: RewritePackedBinop("__paddd", PrimitiveType.Word32); break;

                case Mnemonic.paddq:
                case Mnemonic.vpaddq: RewritePackedBinop("__paddq", PrimitiveType.Word64); break;

                case Mnemonic.paddsw: RewritePackedBinop("__paddsw", PrimitiveType.Word16); break;

                case Mnemonic.paddsb: RewritePackedBinop("__paddsb", PrimitiveType.SByte); break;

                case Mnemonic.paddusb: RewritePackedBinop("__paddusb", PrimitiveType.Byte); break;

                case Mnemonic.paddusw: RewritePackedBinop("__paddsw", PrimitiveType.Word16); break;

                case Mnemonic.paddw: RewritePackedBinop("__paddw", PrimitiveType.Word16); break;

                case Mnemonic.pand:
                case Mnemonic.vpand: RewritePackedLogical("__pand"); break;

                case Mnemonic.pandn:
                case Mnemonic.vpandn: RewritePackedLogical("__pandn"); break;

                case Mnemonic.pause: RewritePause(); break;

                case Mnemonic.palignr: RewritePalignr(); break;

                case Mnemonic.pavgb: RewritePavg("__pavgb", PrimitiveType.Byte); break;

                case Mnemonic.pavgw: RewritePavg("__pavgw", PrimitiveType.Byte); break;

                case Mnemonic.pcmpeqb: RewritePcmp("__pcmpeqb", PrimitiveType.Byte); break;

                case Mnemonic.pcmpeqd: RewritePcmp("__pcmpeqd", PrimitiveType.Word32); break;

                case Mnemonic.pcmpeqw: RewritePcmp("__pcmpeqw", PrimitiveType.Word16); break;

                case Mnemonic.pcmpgtb: RewritePcmp("__pcmpgtb", PrimitiveType.Byte); break;

                case Mnemonic.pcmpgtd: RewritePcmp("__pcmpgtd", PrimitiveType.Word32); break;

                case Mnemonic.pcmpgtw: RewritePcmp("__pcmpgtw", PrimitiveType.Word16); break;

                case Mnemonic.pextrw:
                case Mnemonic.vextrw:  RewritePextrw(); break;

                case Mnemonic.pinsrw:
                case Mnemonic.vpinsrw: RewritePinsrw(); break;

                case Mnemonic.pmaddwd: RewritePackedBinop("__pmaddwd", PrimitiveType.Word16, new ArrayType(PrimitiveType.Word32, 0)); break;

                case Mnemonic.pmaxsw: RewritePackedBinop("__pmaxsw", PrimitiveType.Int16); break;

                case Mnemonic.pmaxub: RewritePackedBinop("__pmaxub", PrimitiveType.UInt8); break;

                case Mnemonic.pminsw: RewritePackedBinop("__pminsw", PrimitiveType.Int16); break;

                case Mnemonic.pminub: RewritePackedBinop("__pminub", PrimitiveType.UInt8); break;

                case Mnemonic.pmovmskb: RewriteMovmsk("__pmovmskb", PrimitiveType.Byte); break;

                case Mnemonic.pmulhuw: RewritePackedBinop("__pmulhuw", PrimitiveType.UInt16, new ArrayType(PrimitiveType.UInt16, 8)); break;

                case Mnemonic.pmulhw: RewritePackedBinop("__pmulhw", PrimitiveType.Int16, new ArrayType(PrimitiveType.Int16, 8)); break;

                case Mnemonic.pmullw:
                case Mnemonic.vpmullw: RewritePackedBinop("__pmullw", PrimitiveType.Int16, new ArrayType(PrimitiveType.Int16, 8)); break;

                case Mnemonic.pmuludq: RewritePackedBinop("__pmuludq", PrimitiveType.UInt32, new ArrayType(PrimitiveType.UInt64, 0)); break;

                case Mnemonic.prefetchw: RewritePrefetch("__prefetchw"); break;

                case Mnemonic.psadbw: RewritePackedBinop("__psadbw", PrimitiveType.Byte, PrimitiveType.Word16); break;

                case Mnemonic.pslld: RewritePackedBinop("__pslld", PrimitiveType.Word32); break;

                case Mnemonic.psllq:
                case Mnemonic.vpsllq: RewritePackedBinop("__psllq", PrimitiveType.Word64); break;

                case Mnemonic.psllw: RewritePackedBinop("__psllw", PrimitiveType.Word16); break;

                case Mnemonic.psrad: RewritePackedBinop("__psrad", PrimitiveType.Int32); break;

                case Mnemonic.psraw: RewritePackedBinop("__psraw", PrimitiveType.Int16); break;

                case Mnemonic.psrlq: RewritePackedBinop("__psrlq", PrimitiveType.Word64); break;

                case Mnemonic.pop: RewritePop(); break;

                case Mnemonic.popa: RewritePopa(); break;

                case Mnemonic.popf: RewritePopf(); break;

                case Mnemonic.por: RewritePackedLogical("__por"); break;

                case Mnemonic.prefetchnta: RewritePrefetch("__prefetchnta"); break;

                case Mnemonic.prefetcht0: RewritePrefetch("__prefetcht0"); break;

                case Mnemonic.prefetcht1: RewritePrefetch("__prefetcht1"); break;

                case Mnemonic.prefetcht2: RewritePrefetch("__prefetcht2"); break;

                case Mnemonic.pshufd: RewritePshuf("__pshufd", PrimitiveType.Word32); break;

                case Mnemonic.pshufw: RewritePshuf("__pshufw", PrimitiveType.Word16); break;

                case Mnemonic.psrld: RewritePackedShift("__psrld", PrimitiveType.Word32); break;

                case Mnemonic.psrlw: RewritePackedShift("__psrlw", PrimitiveType.Word16); break;

                case Mnemonic.psubb: RewritePackedBinop("__psubb", PrimitiveType.Byte); break;

                case Mnemonic.psubd:
                case Mnemonic.vpsubd: RewritePackedBinop("__psubd", PrimitiveType.Word32); break;

                case Mnemonic.psubq: RewritePackedBinop("__psubq", PrimitiveType.Word64); break;

                case Mnemonic.psubsb: RewritePackedBinop("__psubsb", PrimitiveType.SByte); break;

                case Mnemonic.psubsw: RewritePackedBinop("__psubsw", PrimitiveType.Word16); break;

                case Mnemonic.psubusb: RewritePackedBinop("__psubusb", PrimitiveType.UInt8); break;

                case Mnemonic.psubusw: RewritePackedBinop("__psubusw", PrimitiveType.UInt16); break;

                case Mnemonic.psubw: RewritePackedBinop("__psubw", PrimitiveType.Word16); break;

                case Mnemonic.punpckhbw: RewritePunpckhbw(); break;

                case Mnemonic.punpckhdq: RewritePunpckhdq(); break;

                case Mnemonic.punpckhwd: RewritePunpckhwd(); break;

                case Mnemonic.punpcklbw: RewritePunpcklbw(); break;

                case Mnemonic.punpckldq: RewritePunpckldq(); break;

                case Mnemonic.punpcklwd: RewritePunpcklwd(); break;

                case Mnemonic.push: RewritePush(); break;

                case Mnemonic.pusha: RewritePusha(); break;

                case Mnemonic.pushf: RewritePushf(); break;

                case Mnemonic.pxor:
                case Mnemonic.vpxor: RewritePxor(); break;

                case Mnemonic.rcl: RewriteRotation(PseudoProcedure.RolC, true, true); break;

                case Mnemonic.rcpps: RewritePackedUnaryop("__rcpps", PrimitiveType.Real32); break;

                case Mnemonic.rcr: RewriteRotation(PseudoProcedure.RorC, true, false); break;

                case Mnemonic.rol: RewriteRotation(PseudoProcedure.Rol, false, true); break;

                case Mnemonic.ror: RewriteRotation(PseudoProcedure.Ror, false, false); break;

                case Mnemonic.rdmsr: RewriteRdmsr(); break;

                case Mnemonic.rdpmc: RewriteRdpmc(); break;

                case Mnemonic.rdtsc: RewriteRdtsc(); break;

                case Mnemonic.ret: RewriteRet(); break;

                case Mnemonic.retf: RewriteRet(); break;

                case Mnemonic.rsm: RewriteRsm(); break;

                case Mnemonic.rsqrtps: RewritePackedUnaryop("__rsqrtps", PrimitiveType.Real32); break;

                case Mnemonic.sahf: m.Assign(orw.FlagGroup(X86Instruction.DefCc(instrCur.Mnemonic)), orw.AluRegister(Registers.ah)); break;

                case Mnemonic.sar: RewriteBinOp(Operator.Sar); break;

                case Mnemonic.sbb: RewriteAdcSbb(m.ISub); break;

                case Mnemonic.scas: RewriteStringInstruction(); break;

                case Mnemonic.scasb: RewriteStringInstruction(); break;

                case Mnemonic.seta: RewriteSet(ConditionCode.UGT); break;

                case Mnemonic.setc: RewriteSet(ConditionCode.ULT); break;

                case Mnemonic.setbe: RewriteSet(ConditionCode.ULE); break;

                case Mnemonic.setg: RewriteSet(ConditionCode.GT); break;

                case Mnemonic.setge: RewriteSet(ConditionCode.GE); break;

                case Mnemonic.setl: RewriteSet(ConditionCode.LT); break;

                case Mnemonic.setle: RewriteSet(ConditionCode.LE); break;

                case Mnemonic.setnc: RewriteSet(ConditionCode.UGE); break;

                case Mnemonic.setno: RewriteSet(ConditionCode.NO); break;

                case Mnemonic.setns: RewriteSet(ConditionCode.NS); break;

                case Mnemonic.setnz: RewriteSet(ConditionCode.NE); break;

                case Mnemonic.setpe: RewriteSet(ConditionCode.PE); break;

                case Mnemonic.setpo: RewriteSet(ConditionCode.PO); break;

                case Mnemonic.seto: RewriteSet(ConditionCode.OV); break;

                case Mnemonic.sets: RewriteSet(ConditionCode.SG); break;

                case Mnemonic.setz: RewriteSet(ConditionCode.EQ); break;

                case Mnemonic.sfence: RewriteSfence(); break;

                case Mnemonic.sgdt: RewriteSxdt("__sgdt"); break;

                case Mnemonic.sha1msg2: RewriteSha1msg2(); break;

                case Mnemonic.shl: RewriteBinOp(BinaryOperator.Shl); break;

                case Mnemonic.shld: RewriteShxd("__shld"); break;

                case Mnemonic.shr: RewriteBinOp(BinaryOperator.Shr); break;

                case Mnemonic.shrd: RewriteShxd("__shrd"); break;

                case Mnemonic.sidt: RewriteSxdt("__sidt"); break;

                case Mnemonic.shufps:
                case Mnemonic.vshufps: RewritePackedTernaryop("__shufps", PrimitiveType.Real32); break;

                case Mnemonic.sldt: RewriteSxdt("__sldt"); break;

                case Mnemonic.smsw: RewriteSmsw(); break;

                case Mnemonic.sqrtps: RewritePackedUnaryop("__sqrtps", PrimitiveType.Real32); break;

                case Mnemonic.sqrtsd: RewriteSqrtsd(); break;

                case Mnemonic.stc: RewriteSetFlag(FlagM.CF, Constant.True()); break;

                case Mnemonic.std: RewriteSetFlag(FlagM.DF, Constant.True()); break;

                case Mnemonic.sti: RewriteSti(); break;

                case Mnemonic.stos: RewriteStringInstruction(); break;

                case Mnemonic.stosb: RewriteStringInstruction(); break;

                case Mnemonic.str: RewriteStr(); break;

                case Mnemonic.sub: RewriteAddSub(BinaryOperator.ISub); break;

                case Mnemonic.subsd: RewriteScalarBinop(m.FSub, PrimitiveType.Real64, false); break;

                case Mnemonic.vsubsd: RewriteScalarBinop(m.FSub, PrimitiveType.Real64, true); break;

                case Mnemonic.subss: RewriteScalarBinop(m.FSub, PrimitiveType.Real32, false); break;

                case Mnemonic.vsubss: RewriteScalarBinop(m.FSub, PrimitiveType.Real32, true); break;

                case Mnemonic.subpd: RewritePackedBinop("__subpd", PrimitiveType.Real64); break;

                case Mnemonic.subps: RewritePackedBinop("__subps", PrimitiveType.Real32); break;

                case Mnemonic.syscall: RewriteSyscall(); break;

                case Mnemonic.sysenter: RewriteSysenter(); break;

                case Mnemonic.sysexit: RewriteSysexit(); break;

                case Mnemonic.sysret: RewriteSysret(); break;

                case Mnemonic.ucomiss: RewriteComis(PrimitiveType.Real32); break;

                case Mnemonic.ucomisd: RewriteComis(PrimitiveType.Real64); break;

                case Mnemonic.unpckhps: RewriteUnpckhps(); break;

                case Mnemonic.ud0: iclass = InstrClass.Invalid; m.Invalid(); break;

                case Mnemonic.ud1: iclass = InstrClass.Invalid; m.Invalid(); break;

                case Mnemonic.ud2: iclass = InstrClass.Invalid; m.Invalid(); break;

                case Mnemonic.unpcklpd: RewritePackedBinop("__unpcklpd", PrimitiveType.Real64); break;

                case Mnemonic.unpcklps: RewritePackedBinop("__unpcklps", PrimitiveType.Real32); break;

                case Mnemonic.verr: RewriteVerrw("__verify_readable"); break;

                case Mnemonic.verw: RewriteVerrw("__verify_writeable"); break;

                case Mnemonic.test: RewriteTest(); break;

                case Mnemonic.wait: RewriteWait(); break;

                case Mnemonic.wbinvd: RewriteWbinvd(); break;

                case Mnemonic.wrmsr: RewriteWrsmr(); break;

                case Mnemonic.xadd: RewriteXadd(); break;

                case Mnemonic.xchg: RewriteExchange(); break;

                case Mnemonic.xgetbv: RewriteXgetbv(); break;

                case Mnemonic.xsetbv: RewriteXsetbv(); break;

                case Mnemonic.xlat: RewriteXlat(); break;

                case Mnemonic.xor: RewriteLogical(BinaryOperator.Xor); break;

                case Mnemonic.xorpd:
                case Mnemonic.vxorpd: RewritePackedBinop("__xorpd", PrimitiveType.Word64); break;

                case Mnemonic.xorps: RewritePackedBinop("__xorps", PrimitiveType.Word32); break;

                case Mnemonic.BOR_exp: RewriteFUnary("exp"); break;

                case Mnemonic.BOR_ln: RewriteFUnary("log"); break;
                }
                var len = (int)(dasm.Current.Address - addr) + dasm.Current.Length;
                yield return(m.MakeCluster(addr, len, iclass));
            }
        }
Пример #13
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                instrCur = dasm.Current;
                var addr            = instrCur.Address;
                var rtlInstructions = new List <RtlInstruction>();
                rtlc = InstrClass.Linear;
                m    = new RtlEmitter(rtlInstructions);
                switch (instrCur.Mnemonic)
                {
                default:
                    EmitUnitTest();
                    host.Warn(
                        instrCur.Address,
                        "SPARC instruction '{0}' is not supported yet.",
                        instrCur.Mnemonic);
                    goto case Mnemonic.illegal;

                case Mnemonic.illegal:
                    rtlc = InstrClass.Invalid;
                    m.Invalid();
                    break;

                case Mnemonic.add: RewriteAlu(m.IAdd, false); break;

                case Mnemonic.addcc: RewriteAluCc(m.IAdd, false); break;

                case Mnemonic.addx: RewriteAddxSubx(m.IAdd, false); break;

                case Mnemonic.addxcc: RewriteAddxSubx(m.IAdd, true); break;

                case Mnemonic.and: RewriteAlu(m.And, false); break;

                case Mnemonic.andcc: RewriteAluCc(m.And, false); break;

                case Mnemonic.andn: RewriteAlu(m.And, true); break;

                case Mnemonic.ba: RewriteBranch(Constant.True()); break;

                case Mnemonic.bn: RewriteBranch(Constant.False()); break;

                case Mnemonic.bne: RewriteBranch(m.Test(ConditionCode.NE, Grf(FlagM.ZF))); break;

                case Mnemonic.be: RewriteBranch(m.Test(ConditionCode.EQ, Grf(FlagM.ZF))); break;

                case Mnemonic.bg: RewriteBranch(m.Test(ConditionCode.GT, Grf(FlagM.ZF | FlagM.NF | FlagM.VF))); break;

                case Mnemonic.bge: RewriteBranch(m.Test(ConditionCode.GE, Grf(FlagM.NF | FlagM.VF))); break;

                case Mnemonic.bgu: RewriteBranch(m.Test(ConditionCode.UGE, Grf(FlagM.CF | FlagM.ZF))); break;

                case Mnemonic.bl: RewriteBranch(m.Test(ConditionCode.LT, Grf(FlagM.ZF | FlagM.NF | FlagM.VF))); break;

                case Mnemonic.ble: RewriteBranch(m.Test(ConditionCode.LE, Grf(FlagM.ZF | FlagM.NF | FlagM.VF))); break;

                case Mnemonic.bleu: RewriteBranch(m.Test(ConditionCode.ULE, Grf(FlagM.CF | FlagM.ZF))); break;

                case Mnemonic.bcc: RewriteBranch(m.Test(ConditionCode.UGE, Grf(FlagM.CF))); break;

                case Mnemonic.bcs: RewriteBranch(m.Test(ConditionCode.ULT, Grf(FlagM.CF))); break;

                case Mnemonic.bneg: RewriteBranch(m.Test(ConditionCode.LT, Grf(FlagM.NF))); break;

                case Mnemonic.bpos: RewriteBranch(m.Test(ConditionCode.GE, Grf(FlagM.NF))); break;
                //                    Z
                //case Opcode.bgu  not (C or Z)
                //case Opcode.bleu (C or Z)
                //case Opcode.bcc  not C
                //case Opcode.bcs   C
                //case Opcode.bpos not N
                //case Opcode.bneg N
                //case Opcode.bvc  not V
                //case Opcode.bvs  V

                case Mnemonic.call: RewriteCall(); break;

                case Mnemonic.fabss: RewriteFabss(); break;

                case Mnemonic.fadds: RewriteFadds(); break;

                case Mnemonic.fbne: RewriteBranch(m.Test(ConditionCode.NE, Grf(FlagM.LF | FlagM.GF))); break;

                case Mnemonic.fba: RewriteBranch(Constant.True()); break;

                case Mnemonic.fbn: RewriteBranch(Constant.False()); break;

                case Mnemonic.fbu: RewriteBranch(m.Test(ConditionCode.NE, Grf(FlagM.UF))); break;

                case Mnemonic.fbg: RewriteBranch(m.Test(ConditionCode.GT, Grf(FlagM.GF))); break;

                case Mnemonic.fbug: RewriteBranch(m.Test(ConditionCode.GT, Grf(FlagM.GF | FlagM.UF))); break;

                //case Opcode.fbug  : on Unordered or Greater G or U
                //case Opcode.fbl   : on Less L
                case Mnemonic.fbul: RewriteBranch(m.Test(ConditionCode.LT, Grf(FlagM.GF | FlagM.UF))); break;

                //case Opcode.fbul  : on Unordered or Less L or U
                //case Opcode.fblg  : on Less or Greater L or G
                //case Opcode.fbne  : on Not Equal L or G or U
                //case Opcode.fbe   : on Equal E
                case Mnemonic.fbue: RewriteBranch(m.Test(ConditionCode.EQ, Grf(FlagM.EF | FlagM.UF))); break;

                case Mnemonic.fbuge: RewriteBranch(m.Test(ConditionCode.GE, Grf(FlagM.EF | FlagM.GF | FlagM.UF))); break;

                //case Opcode.fble  : on Less or Equal E or L
                //case Opcode.fbule : on Unordered or Less or Equal E or L or U
                case Mnemonic.fbule: RewriteBranch(m.Test(ConditionCode.LE, Grf(FlagM.EF | FlagM.LF | FlagM.UF))); break;

                case Mnemonic.fbge: RewriteBranch(m.Test(ConditionCode.GE, Grf(FlagM.EF | FlagM.GF))); break;
                //                case Opcode.FBO   : on Ordered E or L or G


                case Mnemonic.fcmpes: RewriteFcmpes(); break;

                case Mnemonic.fcmpd: RewriteFcmpd(); break;

                case Mnemonic.fcmpq: RewriteFcmpq(); break;

                case Mnemonic.fcmps: RewriteFcmps(); break;

                case Mnemonic.fdivd: RewriteFdivs(); break;

                case Mnemonic.fdivs: RewriteFdivd(); break;

                case Mnemonic.fdtos: RewriteFdtos(); break;

                case Mnemonic.fitod: RewriteFitod(); break;

                case Mnemonic.fitoq: RewriteFitoq(); break;

                case Mnemonic.fitos: RewriteFitos(); break;

                case Mnemonic.fmovs: RewriteFmovs(); break;

                case Mnemonic.fmuls: RewriteFmuls(); break;

                case Mnemonic.fnegs: RewriteFmovs(); break;

                case Mnemonic.fstod: RewriteFstod(); break;

                case Mnemonic.fsubs: RewriteFsubs(); break;

                case Mnemonic.jmpl: RewriteJmpl(); break;

                case Mnemonic.ld: RewriteLoad(PrimitiveType.Word32); break;

                case Mnemonic.lddf: RewriteLoad(PrimitiveType.Real64); break;

                case Mnemonic.ldf: RewriteLoad(PrimitiveType.Real32); break;

                case Mnemonic.ldd: RewriteLoad(PrimitiveType.Word64); break;

                case Mnemonic.ldsb: RewriteLoad(PrimitiveType.SByte); break;

                case Mnemonic.ldsh: RewriteLoad(PrimitiveType.Int16); break;

                case Mnemonic.ldstub: RewriteLdstub(); break;

                case Mnemonic.ldub: RewriteLoad(PrimitiveType.Byte); break;

                case Mnemonic.lduh: RewriteLoad(PrimitiveType.Word16); break;

                case Mnemonic.ldfsr: RewriteLoad(PrimitiveType.Word32); break;

                case Mnemonic.mulscc: RewriteMulscc(); break;

                case Mnemonic.or: RewriteAlu(m.Or, false); break;

                case Mnemonic.orcc: RewriteAluCc(m.Or, false); break;

                case Mnemonic.restore: RewriteRestore(); break;

                case Mnemonic.rett: RewriteRett(); break;

                case Mnemonic.save: RewriteSave(); break;

                case Mnemonic.sethi: RewriteSethi(); break;

                case Mnemonic.sdiv: RewriteAlu(m.SDiv, false); break;

                case Mnemonic.sdivcc: RewriteAlu(m.SDiv, false); break;

                case Mnemonic.sll: RewriteAlu(m.Shl, false); break;

                case Mnemonic.smul: RewriteAlu(m.SMul, false); break;

                case Mnemonic.smulcc: RewriteAluCc(m.SMul, false); break;

                case Mnemonic.sra: RewriteAlu(m.Sar, false); break;

                case Mnemonic.srl: RewriteAlu(m.Shr, false); break;

                case Mnemonic.st: RewriteStore(PrimitiveType.Word32); break;

                case Mnemonic.stb: RewriteStore(PrimitiveType.Byte); break;

                case Mnemonic.std: RewriteStore(PrimitiveType.Word64); break;

                case Mnemonic.stdf: RewriteStore(PrimitiveType.Real64); break;

                case Mnemonic.stf: RewriteStore(PrimitiveType.Real32); break;

                case Mnemonic.sth: RewriteStore(PrimitiveType.Word16); break;

                case Mnemonic.stfsr: RewriteStore(PrimitiveType.Word32); break;

                case Mnemonic.sub: RewriteAlu(m.ISub, false); break;

                case Mnemonic.subcc: RewriteAluCc(m.ISub, false); break;

                case Mnemonic.subx: RewriteAddxSubx(m.ISub, false); break;

                case Mnemonic.subxcc: RewriteAddxSubx(m.ISub, true); break;

                case Mnemonic.ta: RewriteTrap(Constant.True()); break;

                case Mnemonic.tn: RewriteTrap(Constant.False()); break;

                case Mnemonic.tne: RewriteTrap(m.Test(ConditionCode.NE, Grf(FlagM.ZF))); break;

                case Mnemonic.te: RewriteTrap(m.Test(ConditionCode.EQ, Grf(FlagM.ZF))); break;

                case Mnemonic.udiv: RewriteAlu(m.UDiv, false); break;

                case Mnemonic.udivcc: RewriteAluCc(m.UDiv, false); break;

                case Mnemonic.umul: RewriteAlu(m.UMul, false); break;

                case Mnemonic.umulcc: RewriteAluCc(m.UMul, false); break;

                case Mnemonic.unimp: m.Invalid(); break;

                case Mnemonic.xor: RewriteAlu(m.Xor, false); break;

                case Mnemonic.xorcc: RewriteAlu(m.Xor, true); break;

                case Mnemonic.xnor: RewriteAlu(XNor, false); break;

                case Mnemonic.xnorcc: RewriteAlu(XNor, true); break;
                }
                yield return(new RtlInstructionCluster(addr, 4, rtlInstructions.ToArray())
                {
                    Class = rtlc
                });
            }
        }
Пример #14
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                iclass     = instr.InstructionClass;
                var instrs = new List <RtlInstruction>();
                this.m = new RtlEmitter(instrs);
                switch (instr.Mnemonic)
                {
                default:
                    EmitUnitTest();
                    Invalid();
                    host.Warn(
                        instr.Address,
                        string.Format(
                            "TLCS-90 instruction '{0}' not supported yet.",
                            instr.Mnemonic));

                    break;

                case Mnemonic.invalid: m.Invalid(); break;

                case Mnemonic.adc: RewriteAdcSbc(m.IAdd, "**-**V0*"); break;

                case Mnemonic.add: RewriteBinOp(m.IAdd, "**-***0*"); break;

                case Mnemonic.and: RewriteBinOp(m.And, "**-10*00"); break;

                case Mnemonic.bit: RewriteBit("*--I**0-"); break;

                case Mnemonic.call: RewriteCall(); break;

                case Mnemonic.callr: RewriteCall(); break;

                case Mnemonic.ccf: RewriteCcf(); break;

                case Mnemonic.cp: RewriteCp(); break;

                case Mnemonic.cpl: RewriteCpl("---1--1-"); break;

                case Mnemonic.daa: RewriteDaa(); break;

                case Mnemonic.dec: RewriteIncDec(m.ISub, false); break;

                case Mnemonic.decx: RewriteIncDec(m.ISub, true); break;

                case Mnemonic.di: RewriteDi(); break;

                case Mnemonic.div: RewriteDiv(); break;

                case Mnemonic.djnz: RewriteDjnz(); break;

                case Mnemonic.ei: RewriteEi(); break;

                case Mnemonic.ex: RewriteEx(); break;

                case Mnemonic.exx: RewriteExx(); break;

                case Mnemonic.halt: RewriteHalt(); break;

                case Mnemonic.inc: RewriteIncDec(m.IAdd, false); break;

                case Mnemonic.incw: RewriteIncwDecw(m.IAdd); break;

                case Mnemonic.incx: RewriteIncDec(m.IAdd, true); break;

                case Mnemonic.jp: RewriteJp(); break;

                case Mnemonic.jr: RewriteJp(); break;

                case Mnemonic.ld: RewriteLd(); break;

                case Mnemonic.ldar: RewriteLdar(); break;

                case Mnemonic.ldir: RewriteLdir("---0-00-"); break;

                case Mnemonic.ldw: RewriteLd(); break;

                case Mnemonic.mul: RewriteMul(); break;

                case Mnemonic.neg: RewriteNeg(); break;

                case Mnemonic.nop: m.Nop(); break;

                case Mnemonic.or: RewriteBinOp(m.Or, "**-00*00"); break;

                case Mnemonic.pop: RewritePop(); break;

                case Mnemonic.push: RewritePush(); break;

                case Mnemonic.rcf: RewriteRcf(); break;

                case Mnemonic.res: RewriteSetRes(false); break;

                case Mnemonic.ret: RewriteRet(); break;

                case Mnemonic.reti: RewriteReti(); break;

                case Mnemonic.rl: RewriteRotation(IntrinsicProcedure.RolC, true); break;

                case Mnemonic.rlc: RewriteRotation(IntrinsicProcedure.Rol, false); break;

                case Mnemonic.rr: RewriteRotation(IntrinsicProcedure.RorC, true); break;

                case Mnemonic.rrc: RewriteRotation(IntrinsicProcedure.Ror, false); break;

                case Mnemonic.sbc: RewriteAdcSbc(m.ISub, "**-**V1*"); break;

                case Mnemonic.scf: RewriteScf(); break;

                case Mnemonic.set: RewriteSetRes(true); break;

                case Mnemonic.tset: RewriteTset("*--I**0-"); break;

                case Mnemonic.sla: RewriteShift(m.Shl); break;

                case Mnemonic.sll: RewriteShift(m.Shl); break;

                case Mnemonic.sra: RewriteShift(m.Sar); break;

                case Mnemonic.srl: RewriteShift(m.Shr); break;

                case Mnemonic.sub: RewriteBinOp(m.ISub, "**-**V1*"); break;

                case Mnemonic.swi: RewriteSwi(); break;

                case Mnemonic.xor: RewriteBinOp(m.Xor, "**-10*00"); break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));
            }
        }
Пример #15
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                var instr           = dasm.Current;
                var rtlInstructions = new List <RtlInstruction>();
                this.iclass = instr.InstructionClass;
                this.m      = new RtlEmitter(rtlInstructions);
                switch (instr.Mnemonic)
                {
                default:
                    host.Warn(
                        instr.Address,
                        string.Format("MIPS instruction '{0}' is not supported yet.", instr));
                    EmitUnitTest(instr);
                    goto case Mnemonic.illegal;

                case Mnemonic.illegal:
                    iclass = InstrClass.Invalid; m.Invalid(); break;

                case Mnemonic.addi: RewriteBinary(instr, m.IAdd); break;

                case Mnemonic.addiu: RewriteBinary(instr, m.IAdd); break;

                case Mnemonic.addu: RewriteBinary(instr, m.IAdd); break;

                case Mnemonic.b: RewriteB(instr); break;

                case Mnemonic.beqz: RewriteBeqz(instr); break;

                case Mnemonic.bnez: RewriteBnez(instr); break;

                case Mnemonic.cmpi: RewriteCmp(instr); break;

                case Mnemonic.jal: RewriteJal(instr); break;

                case Mnemonic.jalx: RewriteJalx(instr); break;

                case Mnemonic.lb: RewriteLoad(instr, PrimitiveType.SByte); break;

                case Mnemonic.lbu: RewriteLoad(instr, PrimitiveType.Byte); break;

                case Mnemonic.lh: RewriteLoad(instr, PrimitiveType.Int16); break;

                case Mnemonic.lhu: RewriteLoad(instr, PrimitiveType.UInt16); break;

                case Mnemonic.la: RewriteMove(instr); break;

                case Mnemonic.li: RewriteMove(instr); break;

                case Mnemonic.lw: RewriteLoad(instr, PrimitiveType.Word32); break;

                case Mnemonic.mfhi: RewriteMf(instr, arch.hi); break;

                case Mnemonic.mflo: RewriteMf(instr, arch.lo); break;

                case Mnemonic.move: RewriteMove(instr); break;

                case Mnemonic.neg: RewriteUnary(instr, m.Neg); break;

                case Mnemonic.save: RewriteSave(instr); break;

                case Mnemonic.sb: RewriteStore(instr); break;

                case Mnemonic.sh: RewriteStore(instr); break;

                case Mnemonic.sll: RewriteBinary(instr, m.Shl); break;

                case Mnemonic.sllv: RewriteBinary(instr, m.Shl); break;

                case Mnemonic.slt: RewriteScc(instr, m.Lt); break;

                case Mnemonic.slti: RewriteScc(instr, m.Lt); break;

                case Mnemonic.sltiu: RewriteScc(instr, m.Ult); break;

                case Mnemonic.sra: RewriteBinary(instr, m.Sar); break;

                case Mnemonic.srav: RewriteBinary(instr, m.Sar); break;

                case Mnemonic.srl: RewriteBinary(instr, m.Shr); break;

                case Mnemonic.srlv: RewriteBinary(instr, m.Shr); break;

                case Mnemonic.subu: RewriteBinary(instr, m.ISub); break;

                case Mnemonic.sw: RewriteStore(instr); break;

                case Mnemonic.xor: RewriteBinary(instr, m.Xor); break;
                }
                yield return(new RtlInstructionCluster(instr.Address, instr.Length, rtlInstructions.ToArray())
                {
                    Class = iclass,
                });
            }
        }
Пример #16
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                var addr = dasm.Current.Address;
                var len  = dasm.Current.Length;
                this.rtlInstructions = new List <RtlInstruction>();
                this.rtlc            = RtlClass.Linear;
                this.m = new RtlEmitter(rtlInstructions);

                switch (instr.opcode)
                {
                default:
                    host.Warn(
                        instr.Address,
                        "Risc-V instruction '{0}' not supported yet.",
                        instr.opcode);
                    rtlc = RtlClass.Invalid;
                    m.Invalid();
                    break;

                case Opcode.invalid: rtlc = RtlClass.Invalid; m.Invalid(); break;

                case Opcode.add: RewriteAdd(); break;

                case Opcode.addi: RewriteAdd(); break;

                case Opcode.addiw: RewriteAddw(); break;

                case Opcode.addw: RewriteAddw(); break;

                case Opcode.and: RewriteAnd(); break;

                case Opcode.andi: RewriteAnd(); break;

                case Opcode.auipc: RewriteAuipc(); break;

                case Opcode.beq: RewriteBranch(m.Eq); break;

                case Opcode.bge: RewriteBranch(m.Ge); break;

                case Opcode.bgeu: RewriteBranch(m.Uge); break;

                case Opcode.blt: RewriteBranch(m.Lt); break;

                case Opcode.bltu: RewriteBranch(m.Ult); break;

                case Opcode.bne: RewriteBranch(m.Ne); break;

                case Opcode.fcvt_d_s: RewriteFcvt(PrimitiveType.Real64); break;

                case Opcode.feq_s: RewriteFcmp(PrimitiveType.Real32, m.FEq); break;

                case Opcode.fmadd_s: RewriteFmadd(PrimitiveType.Real32, m.FAdd); break;

                case Opcode.fmv_d_x: RewriteFcvt(PrimitiveType.Real64); break;

                case Opcode.fmv_s_x: RewriteFcvt(PrimitiveType.Real32); break;

                case Opcode.flw: RewriteFload(PrimitiveType.Real32); break;

                case Opcode.jal: RewriteJal(); break;

                case Opcode.jalr: RewriteJalr(); break;

                case Opcode.lb: RewriteLoad(PrimitiveType.SByte); break;

                case Opcode.lbu: RewriteLoad(PrimitiveType.Byte); break;

                case Opcode.ld: RewriteLoad(PrimitiveType.Word64); break;

                case Opcode.lh: RewriteLoad(PrimitiveType.Int16); break;

                case Opcode.lhu: RewriteLoad(PrimitiveType.UInt16); break;

                case Opcode.lui: RewriteLui(); break;

                case Opcode.lw: RewriteLoad(PrimitiveType.Int32); break;

                case Opcode.lwu: RewriteLoad(PrimitiveType.UInt32); break;

                case Opcode.or: RewriteOr(); break;

                case Opcode.ori: RewriteOr(); break;

                case Opcode.sb: RewriteStore(PrimitiveType.Byte); break;

                case Opcode.sd: RewriteStore(PrimitiveType.Word64); break;

                case Opcode.sh: RewriteStore(PrimitiveType.Word16); break;

                case Opcode.sw: RewriteStore(PrimitiveType.Word32); break;

                case Opcode.slli: RewriteShift(m.Shl); break;

                case Opcode.slliw: RewriteShiftw(m.Shl); break;

                case Opcode.sllw: RewriteShiftw(m.Shl); break;

                case Opcode.slt: RewriteSlt(false); break;

                case Opcode.sltu: RewriteSlt(true); break;

                case Opcode.srai: RewriteShift(m.Sar); break;

                case Opcode.sraiw: RewriteShiftw(m.Sar); break;

                case Opcode.srli: RewriteShift(m.Shr); break;

                case Opcode.srliw: RewriteShiftw(m.Shr); break;

                case Opcode.sub: RewriteSub(); break;

                case Opcode.subw: RewriteSubw(); break;

                case Opcode.xor: RewriteXor(); break;

                case Opcode.xori: RewriteXor(); break;
                }
                yield return(new RtlInstructionCluster(
                                 addr,
                                 len,
                                 rtlInstructions.ToArray())
                {
                    Class = rtlc,
                });
            }
        }
Пример #17
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                var addr            = dasm.Current.Address;
                var len             = dasm.Current.Length;
                var rtlInstructions = new List <RtlInstruction>();
                this.iclass = this.instr.InstructionClass;
                this.m      = new RtlEmitter(rtlInstructions);

                switch (instr.Mnemonic)
                {
                default:
                    host.Warn(
                        instr.Address,
                        "Risc-V instruction '{0}' not supported yet.",
                        instr.Mnemonic);
                    EmitUnitTest();
                    iclass = InstrClass.Invalid;
                    m.Invalid();
                    break;

                case Mnemonic.invalid: iclass = InstrClass.Invalid; m.Invalid(); break;

                case Mnemonic.add: RewriteAdd(); break;

                case Mnemonic.addi: RewriteAdd(); break;

                case Mnemonic.addiw: RewriteAddw(); break;

                case Mnemonic.addw: RewriteAddw(); break;

                case Mnemonic.and: RewriteBinOp(m.And); break;

                case Mnemonic.andi: RewriteBinOp(m.And); break;

                case Mnemonic.auipc: RewriteAuipc(); break;

                case Mnemonic.beq: RewriteBranch(m.Eq); break;

                case Mnemonic.bge: RewriteBranch(m.Ge); break;

                case Mnemonic.bgeu: RewriteBranch(m.Uge); break;

                case Mnemonic.blt: RewriteBranch(m.Lt); break;

                case Mnemonic.bltu: RewriteBranch(m.Ult); break;

                case Mnemonic.bne: RewriteBranch(m.Ne); break;

                case Mnemonic.c_add: RewriteCompressedBinOp(m.IAdd); break;

                case Mnemonic.c_addi: RewriteCompressedBinOp(m.IAdd); break;

                case Mnemonic.c_addi16sp: RewriteAddi16sp(); break;

                case Mnemonic.c_addi4spn: RewriteAddi4spn(); break;

                case Mnemonic.c_addiw: RewriteCompressedAdd(PrimitiveType.Word32); break;

                case Mnemonic.c_addw: RewriteCompressedAdd(PrimitiveType.Word32); break;

                case Mnemonic.c_and: RewriteCompressedBinOp(m.And); break;

                case Mnemonic.c_andi: RewriteCompressedBinOp(m.And); break;

                case Mnemonic.c_beqz: RewriteCompressedBranch(m.Eq); break;

                case Mnemonic.c_bnez: RewriteCompressedBranch(m.Ne); break;

                case Mnemonic.c_fld: RewriteFload(PrimitiveType.Real64); break;

                case Mnemonic.c_fldsp: RewriteLxsp(PrimitiveType.Real64); break;

                case Mnemonic.c_fsd: RewriteStore(PrimitiveType.Real64); break;

                case Mnemonic.c_fsdsp: RewriteSxsp(PrimitiveType.Real64); break;

                case Mnemonic.c_j: RewriteCompressedJ(); break;

                case Mnemonic.c_jalr: RewriteCompressedJalr(); break;

                case Mnemonic.c_jr: RewriteCompressedJr(); break;

                case Mnemonic.c_ld: RewriteLoad(PrimitiveType.Word64); break;

                case Mnemonic.c_li: RewriteLi(); break;

                case Mnemonic.c_ldsp: RewriteLxsp(PrimitiveType.Word64); break;

                case Mnemonic.c_lui: RewriteLui(); break;

                case Mnemonic.c_lw: RewriteLoad(PrimitiveType.Word32); break;

                case Mnemonic.c_lwsp: RewriteLxsp(PrimitiveType.Word32); break;

                case Mnemonic.c_mv: RewriteCompressedMv(); break;

                case Mnemonic.c_or: RewriteCompressedBinOp(m.Or); break;

                case Mnemonic.c_slli: RewriteCompressedBinOp(SllI); break;

                case Mnemonic.c_srai: RewriteCompressedBinOp(SraI); break;

                case Mnemonic.c_srli: RewriteCompressedBinOp(SrlI); break;

                case Mnemonic.c_sub: RewriteCompressedBinOp(m.ISub); break;

                case Mnemonic.c_sd: RewriteStore(PrimitiveType.Word64); break;

                case Mnemonic.c_sdsp: RewriteSxsp(PrimitiveType.Word64); break;

                case Mnemonic.c_subw: RewriteCompressedBinOp(m.ISub, PrimitiveType.Word32); break;

                case Mnemonic.c_sw: RewriteStore(PrimitiveType.Word32); break;

                case Mnemonic.c_swsp: RewriteSxsp(PrimitiveType.Word32); break;

                case Mnemonic.c_xor: RewriteCompressedBinOp(m.Xor); break;

                case Mnemonic.divuw: RewriteBinOp(m.UDiv, PrimitiveType.Word32); break;

                case Mnemonic.divw: RewriteBinOp(m.SDiv, PrimitiveType.Word32); break;

                case Mnemonic.fcvt_d_s: RewriteFcvt(PrimitiveType.Real64); break;

                case Mnemonic.feq_s: RewriteFcmp(PrimitiveType.Real32, m.FEq); break;

                case Mnemonic.fmadd_s: RewriteFmadd(PrimitiveType.Real32, m.FAdd); break;

                case Mnemonic.fmv_d_x: RewriteFcvt(PrimitiveType.Real64); break;

                case Mnemonic.fmv_w_x: RewriteFcvt(PrimitiveType.Real32); break;

                case Mnemonic.fld: RewriteFload(PrimitiveType.Real64); break;

                case Mnemonic.flw: RewriteFload(PrimitiveType.Real32); break;

                case Mnemonic.fsd: RewriteStore(PrimitiveType.Real64); break;

                case Mnemonic.fsw: RewriteStore(PrimitiveType.Real32); break;

                case Mnemonic.jal: RewriteJal(); break;

                case Mnemonic.jalr: RewriteJalr(); break;

                case Mnemonic.lb: RewriteLoad(PrimitiveType.SByte); break;

                case Mnemonic.lbu: RewriteLoad(PrimitiveType.Byte); break;

                case Mnemonic.ld: RewriteLoad(PrimitiveType.Word64); break;

                case Mnemonic.lh: RewriteLoad(PrimitiveType.Int16); break;

                case Mnemonic.lhu: RewriteLoad(PrimitiveType.UInt16); break;

                case Mnemonic.lui: RewriteLui(); break;

                case Mnemonic.lw: RewriteLoad(PrimitiveType.Int32); break;

                case Mnemonic.lwu: RewriteLoad(PrimitiveType.UInt32); break;

                case Mnemonic.mulw: RewriteBinOp(m.IMul, PrimitiveType.Word32); break;

                case Mnemonic.or: RewriteOr(); break;

                case Mnemonic.ori: RewriteOr(); break;

                //$TODO: Reko has no unsigned modulus operator
                case Mnemonic.remuw: RewriteBinOp(m.Mod, PrimitiveType.Word32); break;

                case Mnemonic.remw: RewriteBinOp(m.Mod, PrimitiveType.Word32); break;

                case Mnemonic.sb: RewriteStore(PrimitiveType.Byte); break;

                case Mnemonic.sd: RewriteStore(PrimitiveType.Word64); break;

                case Mnemonic.sh: RewriteStore(PrimitiveType.Word16); break;

                case Mnemonic.sw: RewriteStore(PrimitiveType.Word32); break;

                case Mnemonic.sll: RewriteBinOp(m.Shl); break;

                case Mnemonic.slli: RewriteShift(m.Shl); break;

                case Mnemonic.slliw: RewriteShiftw(m.Shl); break;

                case Mnemonic.sllw: RewriteShiftw(m.Shl); break;

                case Mnemonic.slt: RewriteSlt(false); break;

                case Mnemonic.sltiu: RewriteSlti(true); break;

                case Mnemonic.sltu: RewriteSlt(true); break;

                case Mnemonic.srai: RewriteShift(m.Sar); break;

                case Mnemonic.sraiw: RewriteShiftw(m.Sar); break;

                case Mnemonic.srl: RewriteBinOp(m.Shr); break;

                case Mnemonic.srli: RewriteShift(m.Shr); break;

                case Mnemonic.srliw: RewriteShiftw(SrlI); break;

                case Mnemonic.sub: RewriteSub(); break;

                case Mnemonic.subw: RewriteSubw(); break;

                case Mnemonic.xor: RewriteXor(); break;

                case Mnemonic.xori: RewriteXor(); break;
                }
                yield return(m.MakeCluster(addr, len, iclass));
            }
        }
Пример #18
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                di = dasm.Current;
                var addr = di.Address;
                var len  = di.Length;
                rtlInstructions = new List <RtlInstruction>();
                rtlc            = RtlClass.Linear;
                m   = new RtlEmitter(rtlInstructions);
                orw = new OperandRewriter(arch, this.m, this.binder, di.dataWidth);
                switch (di.code)
                {
                default:
                    host.Warn(
                        di.Address,
                        "Rewriting M68k opcode '{0}' is not supported yet.",
                        di.code);
                    m.Invalid();
                    break;

                case Opcode.illegal: RewriteIllegal(); break;

                case Opcode.add: RewriteBinOp((s, d) => m.IAdd(d, s), FlagM.CVZNX); break;

                case Opcode.adda: RewriteBinOp((s, d) => m.IAdd(d, s)); break;

                case Opcode.addi: RewriteArithmetic((s, d) => m.IAdd(d, s)); break;

                case Opcode.addq: RewriteAddSubq((s, d) => m.IAdd(d, s)); break;

                case Opcode.addx: RewriteAddSubx(m.IAdd); break;

                case Opcode.and: RewriteLogical((s, d) => m.And(d, s)); break;

                case Opcode.andi: RewriteLogical((s, d) => m.And(d, s)); break;

                case Opcode.asl: RewriteArithmetic((s, d) => m.Shl(d, s)); break;

                case Opcode.asr: RewriteShift((s, d) => m.Sar(d, s)); break;

/*
 *
 * Mnemonic Condition Encoding Test
 * T* True 0000 1
 * F* False 0001 0
 * HI High 0010 C L Z
 * LS Low or Same 0011 C V Z
 * VC Overflow Clear 1000 V
 * VS Overflow Set 1001 V
 */
                case Opcode.bclr: RewriteBclrBset("__bclr"); break;

                case Opcode.bcc: RewriteBcc(ConditionCode.UGE, FlagM.CF); break;

                case Opcode.bcs: RewriteBcc(ConditionCode.ULT, FlagM.CF); break;

                case Opcode.beq: RewriteBcc(ConditionCode.EQ, FlagM.ZF); break;

                case Opcode.bge: RewriteBcc(ConditionCode.GE, FlagM.NF | FlagM.VF); break;

                case Opcode.bgt: RewriteBcc(ConditionCode.GT, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Opcode.bhi: RewriteBcc(ConditionCode.UGT, FlagM.CF | FlagM.ZF); break;

                case Opcode.ble: RewriteBcc(ConditionCode.LE, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Opcode.blt: RewriteBcc(ConditionCode.LT, FlagM.CF | FlagM.ZF); break;

                case Opcode.bls: RewriteBcc(ConditionCode.ULE, FlagM.VF | FlagM.ZF); break;

                case Opcode.bmi: RewriteBcc(ConditionCode.LT, FlagM.NF); break;

                case Opcode.bne: RewriteBcc(ConditionCode.NE, FlagM.ZF); break;

                case Opcode.bpl: RewriteBcc(ConditionCode.GT, FlagM.NF); break;

                case Opcode.bvs: RewriteBcc(ConditionCode.OV, FlagM.VF); break;

                case Opcode.bchg: RewriteBchg(); break;

                case Opcode.bra: RewriteBra(); break;

                case Opcode.bset: RewriteBclrBset("__bset"); break;

                case Opcode.bsr: RewriteBsr(); break;

                case Opcode.btst: RewriteBtst(); break;

                case Opcode.cas: RewriteCas(); break;

                case Opcode.clr: RewriteClr(); break;

                case Opcode.chk: RewriteChk(); break;

                case Opcode.chk2: RewriteChk2(); break;

                case Opcode.cmp: RewriteCmp(); break;

                case Opcode.cmp2: RewriteCmp2(); break;

                case Opcode.cmpa: RewriteCmp(); break;

                case Opcode.cmpi: RewriteCmp(); break;

                case Opcode.cmpm: RewriteCmp(); break;

                case Opcode.dbeq: RewriteDbcc(ConditionCode.EQ, FlagM.ZF); break;

                case Opcode.dble: RewriteDbcc(ConditionCode.GT, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Opcode.dbhi: RewriteDbcc(ConditionCode.ULE, FlagM.CF | FlagM.ZF); break;

                case Opcode.dbne: RewriteDbcc(ConditionCode.NE, FlagM.ZF); break;

                case Opcode.dbra: RewriteDbcc(ConditionCode.None, 0); break;

                case Opcode.divs: RewriteDiv(m.SDiv, PrimitiveType.Int16); break;

                case Opcode.divsl: RewriteDiv(m.SDiv, PrimitiveType.Int32); break;

                case Opcode.divu: RewriteDiv(m.UDiv, PrimitiveType.UInt16); break;

                case Opcode.eor: RewriteLogical((s, d) => m.Xor(d, s)); break;

                case Opcode.eori: RewriteLogical((s, d) => m.Xor(d, s)); break;

                case Opcode.exg: RewriteExg(); break;

                case Opcode.ext: RewriteExt(); break;

                case Opcode.extb: RewriteExtb(); break;

                case Opcode.fadd: RewriteFBinOp((s, d) => m.FAdd(d, s)); break;

                //$REVIEW: the following don't respect NaN, but NaN typically doesn't exist in HLLs.
                case Opcode.fbf: m.Nop(); break;

                case Opcode.fbnge: RewriteFbcc(ConditionCode.LT); break;

                case Opcode.fbnlt: RewriteFbcc(ConditionCode.GE); break;

                case Opcode.fbnle: RewriteFbcc(ConditionCode.GT); break;

                case Opcode.fbogl: RewriteFbcc(ConditionCode.NE); break;

                case Opcode.fbult: RewriteFbcc(ConditionCode.LT); break;

                case Opcode.fbun: RewriteFbcc(ConditionCode.IS_NAN); break;

                case Opcode.fcmp: RewriteFcmp(); break;

                case Opcode.fdiv: RewriteFBinOp((s, d) => m.FDiv(d, s)); break;

                case Opcode.fmove: RewriteFmove(); break;

                case Opcode.fmovecr: RewriteFmovecr(); break;

                case Opcode.fmovem: RewriteMovem(i => arch.GetRegister(i + Registers.fp0.Number)); break;

                case Opcode.fmul: RewriteFBinOp((s, d) => m.FMul(d, s)); break;

                case Opcode.fneg: RewriteFUnaryOp(m.Neg); break;

                case Opcode.fsub: RewriteFBinOp((s, d) => m.FSub(d, s)); break;

                case Opcode.jmp: RewriteJmp(); break;

                case Opcode.jsr: RewriteJsr(); break;

                case Opcode.lea: RewriteLea(); break;

                case Opcode.link: RewriteLink(); break;

                case Opcode.lsl: RewriteShift((s, d) => m.Shl(d, s)); break;

                case Opcode.lsr: RewriteShift((s, d) => m.Shr(d, s)); break;

                case Opcode.move: RewriteMove(true); break;

                case Opcode.movea: RewriteMove(false); break;

                case Opcode.movep: RewriteMovep(); break;

                case Opcode.moveq: RewriteMoveq(); break;

                case Opcode.movem: RewriteMovem(arch.GetRegister); break;

                case Opcode.muls: RewriteMul((s, d) => m.SMul(d, s)); break;

                case Opcode.mulu: RewriteMul((s, d) => m.UMul(d, s)); break;

                case Opcode.neg: RewriteUnary(s => m.Neg(s), AllConditions); break;

                case Opcode.negx: RewriteUnary(RewriteNegx, AllConditions); break;

                case Opcode.nop: m.Nop(); break;

                case Opcode.not: RewriteUnary(s => m.Comp(s), LogicalConditions); break;

                case Opcode.or: RewriteLogical((s, d) => m.Or(d, s)); break;

                case Opcode.ori: RewriteLogical((s, d) => m.Or(d, s)); break;

                case Opcode.pea: RewritePea(); break;

                case Opcode.rol: RewriteRotation(PseudoProcedure.Rol); break;

                case Opcode.ror: RewriteRotation(PseudoProcedure.Ror);  break;

                case Opcode.roxl: RewriteRotationX(PseudoProcedure.RolC);  break;

                case Opcode.roxr: RewriteRotationX(PseudoProcedure.RorC);  break;

                case Opcode.rts: RewriteRts(); break;

                case Opcode.scc: RewriteScc(ConditionCode.UGE, FlagM.CF); break;

                case Opcode.scs: RewriteScc(ConditionCode.ULT, FlagM.CF); break;

                case Opcode.seq: RewriteScc(ConditionCode.EQ, FlagM.ZF); break;

                case Opcode.sge: RewriteScc(ConditionCode.GE, FlagM.NF | FlagM.VF); break;

                case Opcode.sgt: RewriteScc(ConditionCode.GT, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Opcode.shi: RewriteScc(ConditionCode.UGT, FlagM.CF | FlagM.ZF); break;

                case Opcode.sle: RewriteScc(ConditionCode.LE, FlagM.NF | FlagM.VF | FlagM.ZF); break;

                case Opcode.slt: RewriteScc(ConditionCode.LT, FlagM.CF | FlagM.ZF); break;

                case Opcode.sls: RewriteScc(ConditionCode.ULE, FlagM.VF | FlagM.ZF); break;

                case Opcode.smi: RewriteScc(ConditionCode.LT, FlagM.NF); break;

                case Opcode.sne: RewriteScc(ConditionCode.NE, FlagM.ZF); break;

                case Opcode.spl: RewriteScc(ConditionCode.GT, FlagM.NF); break;

                case Opcode.st: orw.RewriteMoveDst(di.op1, di.Address, PrimitiveType.Bool, Constant.True()); break;

                case Opcode.sf: orw.RewriteMoveDst(di.op1, di.Address, PrimitiveType.Bool, Constant.False()); break;

                case Opcode.stop: RewriteStop(); break;

                case Opcode.sub: RewriteArithmetic((s, d) => m.ISub(d, s)); break;

                case Opcode.suba: RewriteArithmetic((s, d) => m.ISub(d, s)); break;

                case Opcode.subi: RewriteArithmetic((s, d) => m.ISub(d, s)); break;

                case Opcode.subq: RewriteAddSubq((s, d) => m.ISub(d, s)); break;

                case Opcode.subx: RewriteArithmetic((s, d) => m.ISub(m.ISub(d, s), binder.EnsureFlagGroup(Registers.ccr, (uint)FlagM.XF, "X", PrimitiveType.Bool))); break;

                case Opcode.swap: RewriteSwap(); break;

                case Opcode.trap: RewriteTrap(); break;

                case Opcode.tst: RewriteTst(); break;

                case Opcode.unlk: RewriteUnlk(); break;
                }
                yield return(new RtlInstructionCluster(
                                 addr,
                                 len,
                                 rtlInstructions.ToArray())
                {
                    Class = rtlc
                });
            }
            yield break;
        }
Пример #19
0
        /// <summary>
        /// Iterator that yields one RtlIntructionCluster for each x86 instruction.
        /// </summary>
        /// <returns></returns>
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                instrCur = dasm.Current;
                var addr = instrCur.Address;
                this.len             = instrCur.Length;
                this.rtlInstructions = new List <RtlInstruction>();
                this.rtlc            = RtlClass.Linear;
                m   = new RtlEmitter(rtlInstructions);
                orw = arch.ProcessorMode.CreateOperandRewriter(arch, m, frame, host);
                switch (instrCur.code)
                {
                default:
                    host.Warn(
                        dasm.Current.Address,
                        "Rewriting x86 opcode '{0}' is not supported yet.",
                        instrCur.code);
                    goto case Opcode.illegal;

                case Opcode.illegal: rtlc = RtlClass.Invalid; m.Invalid(); break;

                case Opcode.aaa: RewriteAaa(); break;

                case Opcode.aad: RewriteAad(); break;

                case Opcode.aam: RewriteAam(); break;

                case Opcode.aas: RewriteAas(); break;

                case Opcode.adc: RewriteAdcSbb(m.IAdd); break;

                case Opcode.add: RewriteAddSub(Operator.IAdd); break;

                case Opcode.addss: RewriteScalarBinop(m.FAdd, PrimitiveType.Real32); break;

                case Opcode.addsd: RewriteScalarBinop(m.FAdd, PrimitiveType.Real64); break;

                case Opcode.addps: RewritePackedBinop("__addps", PrimitiveType.Real32); break;

                case Opcode.and: RewriteLogical(Operator.And); break;

                case Opcode.arpl: RewriteArpl(); break;

                case Opcode.bound: RewriteBound(); break;

                case Opcode.bsr: RewriteBsr(); break;

                case Opcode.bswap: RewriteBswap(); break;

                case Opcode.bt: RewriteBt(); break;

                case Opcode.btr: RewriteBtr(); break;

                case Opcode.bts: RewriteBts(); break;

                case Opcode.call: RewriteCall(instrCur.op1, instrCur.op1.Width); break;

                case Opcode.cbw: RewriteCbw(); break;

                case Opcode.clc: RewriteSetFlag(FlagM.CF, Constant.False()); break;

                case Opcode.cld: RewriteSetFlag(FlagM.DF, Constant.False()); break;

                case Opcode.cli: RewriteCli(); break;

                case Opcode.cmc: m.Assign(orw.FlagGroup(FlagM.CF), m.Not(orw.FlagGroup(FlagM.CF))); break;

                case Opcode.cmova: RewriteConditionalMove(ConditionCode.UGT, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovbe: RewriteConditionalMove(ConditionCode.ULE, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovc: RewriteConditionalMove(ConditionCode.ULT, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovge: RewriteConditionalMove(ConditionCode.GE, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovg: RewriteConditionalMove(ConditionCode.GT, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovl: RewriteConditionalMove(ConditionCode.LT, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovle: RewriteConditionalMove(ConditionCode.LE, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovnc: RewriteConditionalMove(ConditionCode.UGE, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovno: RewriteConditionalMove(ConditionCode.NO, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovns: RewriteConditionalMove(ConditionCode.NS, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovnz: RewriteConditionalMove(ConditionCode.NE, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovo: RewriteConditionalMove(ConditionCode.OV, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovpe: RewriteConditionalMove(ConditionCode.PE, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovpo: RewriteConditionalMove(ConditionCode.PO, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovs: RewriteConditionalMove(ConditionCode.SG, instrCur.op1, instrCur.op2); break;

                case Opcode.cmovz: RewriteConditionalMove(ConditionCode.EQ, instrCur.op1, instrCur.op2); break;

                case Opcode.cmpxchg: RewriteCmpxchg(); break;

                case Opcode.cmp: RewriteCmp(); break;

                case Opcode.cmps: RewriteStringInstruction(); break;

                case Opcode.cmpsb: RewriteStringInstruction(); break;

                case Opcode.cpuid: RewriteCpuid(); break;

                case Opcode.cvtpi2ps: RewriteCvtPackedToReal(PrimitiveType.Real32); break;

                case Opcode.cvtsi2sd: RewriteCvtToReal(PrimitiveType.Real64); break;

                case Opcode.cvtsi2ss: RewriteCvtToReal(PrimitiveType.Real32); break;

                case Opcode.cvttsd2si: RewriteCvtts2si(PrimitiveType.Real64); break;

                case Opcode.cvttss2si: RewriteCvtts2si(PrimitiveType.Real32); break;

                case Opcode.cvttps2pi: RewriteCvttps2pi(); break;

                case Opcode.cwd: RewriteCwd(); break;

                case Opcode.daa: EmitDaaDas("__daa"); break;

                case Opcode.das: EmitDaaDas("__das"); break;

                case Opcode.dec: RewriteIncDec(-1); break;

                case Opcode.div: RewriteDivide(m.UDiv, Domain.UnsignedInt); break;

                case Opcode.divps: RewritePackedBinop("__divps", PrimitiveType.Real32); break;

                case Opcode.divsd: RewriteScalarBinop(m.FDiv, PrimitiveType.Real64); break;

                case Opcode.divss: RewriteScalarBinop(m.FDiv, PrimitiveType.Real32); break;

                case Opcode.f2xm1: RewriteF2xm1(); break;

                case Opcode.enter: RewriteEnter(); break;

                case Opcode.fabs: RewriteFabs(); break;

                case Opcode.fadd: EmitCommonFpuInstruction(m.FAdd, false, false); break;

                case Opcode.faddp: EmitCommonFpuInstruction(m.FAdd, false, true); break;

                case Opcode.fbld: RewriteFbld(); break;

                case Opcode.fbstp: RewriteFbstp(); break;

                case Opcode.fchs: EmitFchs(); break;

                case Opcode.fclex: RewriteFclex(); break;

                case Opcode.fcom: RewriteFcom(0); break;

                case Opcode.fcomp: RewriteFcom(1); break;

                case Opcode.fcompp: RewriteFcom(2); break;

                case Opcode.fcos: RewriteFUnary("cos"); break;

                case Opcode.fdecstp: RewriteFdecstp(); break;

                case Opcode.fdiv: EmitCommonFpuInstruction(m.FDiv, false, false); break;

                case Opcode.fdivp: EmitCommonFpuInstruction(m.FDiv, false, true); break;

                case Opcode.ffree: RewriteFfree(); break;

                case Opcode.fiadd: EmitCommonFpuInstruction(m.FAdd, false, false, PrimitiveType.Real64); break;

                case Opcode.ficom: RewriteFicom(false); break;

                case Opcode.ficomp: RewriteFicom(true); break;

                case Opcode.fimul: EmitCommonFpuInstruction(m.FMul, false, false, PrimitiveType.Real64); break;

                case Opcode.fisub: EmitCommonFpuInstruction(m.FSub, false, false, PrimitiveType.Real64); break;

                case Opcode.fisubr: EmitCommonFpuInstruction(m.FSub, true, false, PrimitiveType.Real64); break;

                case Opcode.fidiv: EmitCommonFpuInstruction(m.FDiv, false, false, PrimitiveType.Real64); break;

                case Opcode.fidivr: EmitCommonFpuInstruction(m.FDiv, true, false, PrimitiveType.Real64); break;

                case Opcode.fdivr: EmitCommonFpuInstruction(m.FDiv, true, false); break;

                case Opcode.fdivrp: EmitCommonFpuInstruction(m.FDiv, true, true); break;

                case Opcode.fild: RewriteFild(); break;

                case Opcode.fincstp: RewriteFincstp(); break;

                case Opcode.fist: RewriteFist(false); break;

                case Opcode.fistp: RewriteFist(true); break;

                case Opcode.fld: RewriteFld(); break;

                case Opcode.fld1: RewriteFldConst(1.0); break;

                case Opcode.fldcw: RewriteFldcw(); break;

                case Opcode.fldenv: RewriteFldenv(); break;

                case Opcode.fldl2e: RewriteFldConst(Constant.LgE()); break;

                case Opcode.fldl2t: RewriteFldConst(Constant.Lg10()); break;

                case Opcode.fldlg2: RewriteFldConst(Constant.Log2()); break;

                case Opcode.fldln2: RewriteFldConst(Constant.Ln2()); break;

                case Opcode.fldpi: RewriteFldConst(Constant.Pi()); break;

                case Opcode.fldz: RewriteFldConst(0.0); break;

                case Opcode.fmul: EmitCommonFpuInstruction(m.FMul, false, false); break;

                case Opcode.fmulp: EmitCommonFpuInstruction(m.FMul, false, true); break;

                case Opcode.fpatan: RewriteFpatan(); break;

                case Opcode.fprem: RewriteFprem(); break;

                case Opcode.fptan: RewriteFptan(); break;

                case Opcode.frndint: RewriteFUnary("__rndint"); break;

                case Opcode.frstor: RewriteFrstor(); break;

                case Opcode.fsave: RewriteFsave(); break;

                case Opcode.fscale: RewriteFscale(); break;

                case Opcode.fsin: RewriteFUnary("sin"); break;

                case Opcode.fsincos: RewriteFsincos(); break;

                case Opcode.fsqrt: RewriteFUnary("sqrt"); break;

                case Opcode.fst: RewriteFst(false); break;

                case Opcode.fstenv: RewriteFstenv(); break;

                case Opcode.fstcw: RewriterFstcw(); break;

                case Opcode.fstp: RewriteFst(true); break;

                case Opcode.fstsw: RewriteFstsw(); break;

                case Opcode.fsub: EmitCommonFpuInstruction(m.FSub, false, false); break;

                case Opcode.fsubp: EmitCommonFpuInstruction(m.FSub, false, true); break;

                case Opcode.fsubr: EmitCommonFpuInstruction(m.FSub, true, false); break;

                case Opcode.fsubrp: EmitCommonFpuInstruction(m.FSub, true, true); break;

                case Opcode.ftst: RewriteFtst(); break;

                case Opcode.fucomi: RewrteFucomi(false); break;

                case Opcode.fucomip: RewrteFucomi(true); break;

                case Opcode.fucompp: RewriteFcom(2); break;

                case Opcode.fxam: RewriteFxam(); break;

                case Opcode.fxch: RewriteExchange(); break;

                case Opcode.fyl2x: RewriteFyl2x(); break;

                case Opcode.fyl2xp1: RewriteFyl2xp1(); break;

                case Opcode.hlt: RewriteHlt(); break;

                case Opcode.idiv: RewriteDivide(m.SDiv, Domain.SignedInt); break;

                case Opcode.@in: RewriteIn(); break;

                case Opcode.imul: RewriteMultiply(Operator.SMul, Domain.SignedInt); break;

                case Opcode.inc: RewriteIncDec(1); break;

                case Opcode.insb: RewriteStringInstruction(); break;

                case Opcode.ins: RewriteStringInstruction(); break;

                case Opcode.@int: RewriteInt(); break;

                case Opcode.into: RewriteInto(); break;

                case Opcode.iret: RewriteIret(); break;

                case Opcode.jmp: RewriteJmp(); break;

                case Opcode.ja: RewriteConditionalGoto(ConditionCode.UGT, instrCur.op1); break;

                case Opcode.jbe: RewriteConditionalGoto(ConditionCode.ULE, instrCur.op1); break;

                case Opcode.jc: RewriteConditionalGoto(ConditionCode.ULT, instrCur.op1); break;

                case Opcode.jcxz: RewriteJcxz(); break;

                case Opcode.jge: RewriteConditionalGoto(ConditionCode.GE, instrCur.op1); break;

                case Opcode.jg: RewriteConditionalGoto(ConditionCode.GT, instrCur.op1); break;

                case Opcode.jl: RewriteConditionalGoto(ConditionCode.LT, instrCur.op1); break;

                case Opcode.jle: RewriteConditionalGoto(ConditionCode.LE, instrCur.op1); break;

                case Opcode.jnc: RewriteConditionalGoto(ConditionCode.UGE, instrCur.op1); break;

                case Opcode.jno: RewriteConditionalGoto(ConditionCode.NO, instrCur.op1); break;

                case Opcode.jns: RewriteConditionalGoto(ConditionCode.NS, instrCur.op1); break;

                case Opcode.jnz: RewriteConditionalGoto(ConditionCode.NE, instrCur.op1); break;

                case Opcode.jo: RewriteConditionalGoto(ConditionCode.OV, instrCur.op1); break;

                case Opcode.jpe: RewriteConditionalGoto(ConditionCode.PE, instrCur.op1); break;

                case Opcode.jpo: RewriteConditionalGoto(ConditionCode.PO, instrCur.op1); break;

                case Opcode.js: RewriteConditionalGoto(ConditionCode.SG, instrCur.op1); break;

                case Opcode.jz: RewriteConditionalGoto(ConditionCode.EQ, instrCur.op1); break;

                case Opcode.lahf: RewriteLahf(); break;

                case Opcode.lds: RewriteLxs(Registers.ds); break;

                case Opcode.lea: RewriteLea(); break;

                case Opcode.leave: RewriteLeave(); break;

                case Opcode.les: RewriteLxs(Registers.es); break;

                case Opcode.lfs: RewriteLxs(Registers.fs); break;

                case Opcode.lgs: RewriteLxs(Registers.gs); break;

                case Opcode.@lock: RewriteLock(); break;

                case Opcode.lods: RewriteStringInstruction(); break;

                case Opcode.lodsb: RewriteStringInstruction(); break;

                case Opcode.loop: RewriteLoop(0, ConditionCode.EQ); break;

                case Opcode.loope: RewriteLoop(FlagM.ZF, ConditionCode.EQ); break;

                case Opcode.loopne: RewriteLoop(FlagM.ZF, ConditionCode.NE); break;

                case Opcode.lss: RewriteLxs(Registers.ss); break;

                case Opcode.mov: RewriteMov(); break;

                case Opcode.movaps: RewriteMov(); break;

                case Opcode.movd: RewriteMovzx(); break;

                case Opcode.movdqa: RewriteMov(); break;

                case Opcode.movlhps: RewriteMovlhps(); break;

                case Opcode.movq: RewriteMov(); break;

                case Opcode.movs: RewriteStringInstruction(); break;

                case Opcode.movsb: RewriteStringInstruction(); break;

                case Opcode.movsd: RewriteMovssd(PrimitiveType.Real64); break;

                case Opcode.movss: RewriteMovssd(PrimitiveType.Real32); break;

                case Opcode.movsx: RewriteMovsx(); break;

                case Opcode.movups: RewriteMov(); break;

                case Opcode.movupd: RewriteMov(); break;

                case Opcode.movzx: RewriteMovzx(); break;

                case Opcode.mul: RewriteMultiply(Operator.UMul, Domain.UnsignedInt); break;

                case Opcode.mulpd: RewritePackedBinop("__mulpd", PrimitiveType.Real64); break;

                case Opcode.mulps: RewritePackedBinop("__mulps", PrimitiveType.Real32); break;

                case Opcode.mulss: RewriteScalarBinop(m.FMul, PrimitiveType.Real32); break;

                case Opcode.mulsd: RewriteScalarBinop(m.FMul, PrimitiveType.Real64); break;

                case Opcode.neg: RewriteNeg(); break;

                case Opcode.nop: m.Nop(); break;

                case Opcode.not: RewriteNot(); break;

                case Opcode.or: RewriteLogical(BinaryOperator.Or); break;

                case Opcode.@out: RewriteOut(); break;

                case Opcode.@outs: RewriteStringInstruction(); break;

                case Opcode.@outsb: RewriteStringInstruction(); break;

                case Opcode.palignr: RewritePalignr(); break;

                case Opcode.pcmpeqb: RewritePcmpeqb(); break;

                case Opcode.pop: RewritePop(); break;

                case Opcode.popa: RewritePopa(); break;

                case Opcode.popf: RewritePopf(); break;

                case Opcode.pshufd: RewritePshufd(); break;

                case Opcode.punpcklbw: RewritePunpcklbw(); break;

                case Opcode.punpcklwd: RewritePunpcklwd(); break;

                case Opcode.push: RewritePush(); break;

                case Opcode.pusha: RewritePusha(); break;

                case Opcode.pushf: RewritePushf(); break;

                case Opcode.pxor: RewritePxor(); break;

                case Opcode.rcl: RewriteRotation(PseudoProcedure.RolC, true, true); break;

                case Opcode.rcr: RewriteRotation(PseudoProcedure.RorC, true, false); break;

                case Opcode.rol: RewriteRotation(PseudoProcedure.Rol, false, true); break;

                case Opcode.ror: RewriteRotation(PseudoProcedure.Ror, false, false); break;

                case Opcode.rdtsc: RewriteRdtsc(); break;

                case Opcode.ret: RewriteRet(); break;

                case Opcode.retf: RewriteRet(); break;

                case Opcode.sahf: m.Assign(orw.FlagGroup(X86Instruction.DefCc(instrCur.code)), orw.AluRegister(Registers.ah)); break;

                case Opcode.sar: RewriteBinOp(Operator.Sar); break;

                case Opcode.sbb: RewriteAdcSbb(m.ISub); break;

                case Opcode.scas: RewriteStringInstruction(); break;

                case Opcode.scasb: RewriteStringInstruction(); break;

                case Opcode.seta: RewriteSet(ConditionCode.UGT); break;

                case Opcode.setc: RewriteSet(ConditionCode.ULT); break;

                case Opcode.setbe: RewriteSet(ConditionCode.ULE); break;

                case Opcode.setg: RewriteSet(ConditionCode.GT); break;

                case Opcode.setge: RewriteSet(ConditionCode.GE); break;

                case Opcode.setl: RewriteSet(ConditionCode.LT); break;

                case Opcode.setle: RewriteSet(ConditionCode.LE); break;

                case Opcode.setnc: RewriteSet(ConditionCode.UGE); break;

                case Opcode.setno: RewriteSet(ConditionCode.NO); break;

                case Opcode.setns: RewriteSet(ConditionCode.NS); break;

                case Opcode.setnz: RewriteSet(ConditionCode.NE); break;

                case Opcode.setpe: RewriteSet(ConditionCode.PE); break;

                case Opcode.setpo: RewriteSet(ConditionCode.PO); break;

                case Opcode.seto: RewriteSet(ConditionCode.OV); break;

                case Opcode.sets: RewriteSet(ConditionCode.SG); break;

                case Opcode.setz: RewriteSet(ConditionCode.EQ); break;

                case Opcode.shl: RewriteBinOp(BinaryOperator.Shl); break;

                case Opcode.shld: RewriteShxd("__shld"); break;

                case Opcode.shr: RewriteBinOp(BinaryOperator.Shr); break;

                case Opcode.shrd: RewriteShxd("__shrd"); break;

                case Opcode.stc: RewriteSetFlag(FlagM.CF, Constant.True()); break;

                case Opcode.std: RewriteSetFlag(FlagM.DF, Constant.True()); break;

                case Opcode.sti: RewriteSti(); break;

                case Opcode.stos: RewriteStringInstruction(); break;

                case Opcode.stosb: RewriteStringInstruction(); break;

                case Opcode.sub: RewriteAddSub(BinaryOperator.ISub); break;

                case Opcode.subsd: RewriteScalarBinop(m.FSub, PrimitiveType.Real64); break;

                case Opcode.subss: RewriteScalarBinop(m.FSub, PrimitiveType.Real32); break;

                case Opcode.subps: RewritePackedBinop("__subps", PrimitiveType.Real32); break;

                case Opcode.ucomiss: RewriteComis(PrimitiveType.Real32); break;

                case Opcode.ucomisd: RewriteComis(PrimitiveType.Real64); break;

                case Opcode.test: RewriteTest(); break;

                case Opcode.wait: RewriteWait(); break;

                case Opcode.xadd: RewriteXadd(); break;

                case Opcode.xchg: RewriteExchange(); break;

                case Opcode.xgetbv: RewriteXgetbv(); break;

                case Opcode.xsetbv: RewriteXsetbv(); break;

                case Opcode.xlat: RewriteXlat(); break;

                case Opcode.xor: RewriteLogical(BinaryOperator.Xor); break;

                case Opcode.BOR_exp: RewriteFUnary("exp"); break;

                case Opcode.BOR_ln: RewriteFUnary("log"); break;
                }
                yield return(new RtlInstructionCluster(addr, len, rtlInstructions.ToArray())
                {
                    Class = rtlc
                });
            }
        }
Пример #20
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr  = dasm.Current;
                this.iclass = InstrClass.Linear;
                var instrs = new List <RtlInstruction>();
                this.m = new RtlEmitter(instrs);
                switch (instr.Mnemonic)
                {
                default:
                    host.Warn(instr.Address, "zSeries instruction {0} not implemented yet.", instr);
                    EmitUnitTest();
                    goto case Mnemonic.invalid;

                case Mnemonic.invalid:
                    iclass = InstrClass.Invalid;
                    m.Invalid();
                    break;

                case Mnemonic.aghi: RewriteAhi(PrimitiveType.Word64); break;

                case Mnemonic.ahi: RewriteAhi(PrimitiveType.Word32); break;

                case Mnemonic.agr: RewriteAgr(); break;

                case Mnemonic.ar: RewriteAr(); break;

                case Mnemonic.basr: RewriteBasr(); break;

                case Mnemonic.ber: RewriteBranch(ConditionCode.EQ); break;

                case Mnemonic.bler: RewriteBranch(ConditionCode.LE); break;

                case Mnemonic.br: RewriteBr(); break;

                case Mnemonic.brasl: RewriteBrasl(); break;

                case Mnemonic.brctg: RewriteBrctg(); break;

                case Mnemonic.cghi: RewriteCghi(); break;

                case Mnemonic.cgr: RewriteCgr(); break;

                case Mnemonic.chi: RewriteChi(); break;

                case Mnemonic.clc: RewriteClc(); break;

                case Mnemonic.clg: RewriteClg(); break;

                case Mnemonic.clgr: RewriteClgr(); break;

                case Mnemonic.cli: RewriteCli(); break;

                case Mnemonic.j: RewriteJ(); break;

                case Mnemonic.je: RewriteJcc(ConditionCode.EQ); break;

                case Mnemonic.jg: RewriteJcc(ConditionCode.GT); break;

                case Mnemonic.jh: RewriteJcc(ConditionCode.UGT); break;

                case Mnemonic.jl: RewriteJcc(ConditionCode.LT); break;

                case Mnemonic.jhe: RewriteJcc(ConditionCode.UGE); break;

                case Mnemonic.jne: RewriteJcc(ConditionCode.NE); break;

                case Mnemonic.la: RewriteLa(); break;

                case Mnemonic.larl: RewriteLarl(); break;

                case Mnemonic.l: RewriteL(PrimitiveType.Word32); break;

                case Mnemonic.lay: RewriteLay(); break;

                case Mnemonic.ldgr: RewriteLdgr(); break;

                case Mnemonic.lg: RewriteL(PrimitiveType.Word64); break;

                case Mnemonic.lgdr: RewriteLgdr(); break;

                case Mnemonic.lgf: RewriteLgf(); break;

                case Mnemonic.lgfr: RewriteLgfr(); break;

                case Mnemonic.lghi: RewriteLghi(); break;

                case Mnemonic.lgr: RewriteLgr(); break;

                case Mnemonic.lgrl: RewriteLgrl(); break;

                case Mnemonic.lhi: RewriteLhi(); break;

                case Mnemonic.lmg: RewriteLmg(); break;

                case Mnemonic.lr: RewriteLr(); break;

                case Mnemonic.ltg: RewriteLtg(); break;

                case Mnemonic.ltgr: RewriteLtgr(); break;

                case Mnemonic.mvi: RewriteMvi(); break;

                case Mnemonic.mvz: RewriteMvz(); break;

                case Mnemonic.nc: RewriteNc(); break;

                case Mnemonic.ngr: RewriteNgr(); break;

                case Mnemonic.nopr: m.Nop(); break;

                case Mnemonic.sgr: RewriteSgr(); break;

                case Mnemonic.sll: RewriteSll(); break;

                case Mnemonic.sllg: RewriteSllg(); break;

                case Mnemonic.srag: RewriteSrag(); break;

                case Mnemonic.srlg: RewriteSrlg(); break;

                case Mnemonic.st: RewriteSt(PrimitiveType.Word32); break;

                case Mnemonic.stg: RewriteSt(PrimitiveType.Word64); break;

                case Mnemonic.stgrl: RewriteSt(PrimitiveType.Word64); break;

                case Mnemonic.stmg: RewriteStmg(); break;

                case Mnemonic.xc: RewriteXc(); break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));
            }
        }
Пример #21
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr  = dasm.Current;
                this.iclass = instr.InstructionClass;
                var instrs = new List <RtlInstruction>();
                this.m = new RtlEmitter(instrs);
                switch (instr.Mnemonic)
                {
                default:
                    host.Warn(instr.Address, "zSeries instruction {0} not implemented yet.", instr);
                    EmitUnitTest();
                    goto case Mnemonic.invalid;

                case Mnemonic.invalid:
                    iclass = InstrClass.Invalid;
                    m.Invalid();
                    break;

                case Mnemonic.a: RewriteA(PrimitiveType.Int32); break;

                case Mnemonic.ad: RewriteFAdd(LongHexFloat); break;

                case Mnemonic.adr: RewriteFAddReg(PrimitiveType.Real64); break;

                case Mnemonic.ae: RewriteFAdd(ShortHexFloat); break;

                case Mnemonic.aeb: RewriteFAdd(PrimitiveType.Real32); break;

                case Mnemonic.aer: RewriteFAddReg(ShortHexFloat); break;

                case Mnemonic.aghi: RewriteAhi2(PrimitiveType.Word64); break;

                case Mnemonic.aghik: RewriteAhi3(PrimitiveType.Word64); break;

                case Mnemonic.ahi: RewriteAhi2(PrimitiveType.Word32); break;

                case Mnemonic.ahik: RewriteAhi3(PrimitiveType.Word32); break;

                case Mnemonic.agr: RewriteAr(PrimitiveType.Int64); break;

                case Mnemonic.agsi: RewriteAsi(PrimitiveType.Int64); break;

                case Mnemonic.al: RewriteA(PrimitiveType.Word32); break;

                case Mnemonic.alcr: RewriteAdcSbcReg(m.IAdd, PrimitiveType.Word32); break;

                case Mnemonic.alcgr: RewriteAdcSbcReg(m.IAdd, PrimitiveType.Word64); break;

                case Mnemonic.algfr: RewriteAlugfr(m.IAdd, PrimitiveType.Word32, PrimitiveType.Word64); break;

                case Mnemonic.algr: RewriteAr(PrimitiveType.Word64); break;

                case Mnemonic.alr: RewriteAr(PrimitiveType.Word32); break;

                case Mnemonic.ar: RewriteAr(PrimitiveType.Int32); break;

                case Mnemonic.asi: RewriteAsi(PrimitiveType.Int32); break;

                case Mnemonic.aur: RewriteFAddReg(ShortHexFloat); break;

                case Mnemonic.awr: RewriteFAddReg(LongHexFloat); break;

                case Mnemonic.axr: RewriteFpuRegPair(m.FAdd, ExtendedHexFloat); break;

                case Mnemonic.b:   RewriteUnconditionalBranch(); break;

                case Mnemonic.bal: RewriteBranchAndLink(); break;

                case Mnemonic.balr: RewriteBranchAndLinkReg(); break;

                case Mnemonic.bas: RewriteBranchAndLink(); break;

                case Mnemonic.bct: RewriteBranchOnCount(PrimitiveType.Word32); break;

                case Mnemonic.bctr: RewriteBranchOnCount(PrimitiveType.Word32); break;

                case Mnemonic.bctgr: RewriteBranchOnCount(PrimitiveType.Word64); break;

                case Mnemonic.bh: RewriteBranchEa(ConditionCode.UGT); break;

                case Mnemonic.bnl: RewriteBranchEa(ConditionCode.GE); break;

                case Mnemonic.bl:  RewriteBranchEa(ConditionCode.LT); break;

                case Mnemonic.blh: RewriteBranchEa(ConditionCode.NE); break;    //$REVIEW where are these mnemonics defined?

                case Mnemonic.bne: RewriteBranchEa(ConditionCode.NE); break;

                case Mnemonic.bnh: RewriteBranchEa(ConditionCode.ULE); break;

                case Mnemonic.be:  RewriteBranchEa(ConditionCode.EQ); break;

                case Mnemonic.bnle: RewriteBranchEa(ConditionCode.GT); break;

                case Mnemonic.bhe: RewriteBranchEa(ConditionCode.UGE); break;

                case Mnemonic.bnlh: RewriteBranchEa(ConditionCode.NE); break;

                case Mnemonic.ble: RewriteBranchEa(ConditionCode.LE); break;

                case Mnemonic.bnhe: RewriteBranchEa(ConditionCode.ULT); break;

                case Mnemonic.bno: RewriteBranchEa(ConditionCode.NO); break;

                case Mnemonic.bo: RewriteBranchEa(ConditionCode.OV); break;

                case Mnemonic.basr: RewriteBasr(); break;

                case Mnemonic.bassm: RewriteBassm(); break;

                case Mnemonic.ber: RewriteBranch(ConditionCode.EQ); break;

                case Mnemonic.bler: RewriteBranch(ConditionCode.LE); break;

                case Mnemonic.bner: RewriteBranch(ConditionCode.NE); break;

                case Mnemonic.bprp: RewriteBprp(); break;

                case Mnemonic.br: RewriteBr(); break;

                case Mnemonic.brasl: RewriteBrasl(); break;

                case Mnemonic.brctg: RewriteBrctg(); break;

                case Mnemonic.brxh: RewriteBranchOnIndex(m.Gt); break;

                case Mnemonic.brxle: RewriteBranchOnIndex(m.Le); break;

                case Mnemonic.bsm: RewriteBsm(); break;

                case Mnemonic.bxh: RewriteBranchOnIndex(m.Gt); break;

                case Mnemonic.bxle: RewriteBranchOnIndex(m.Le); break;

                case Mnemonic.c: RewriteC(PrimitiveType.Int32); break;

                case Mnemonic.cd: RewriteCmpFloatMem(PrimitiveType.Real64); break;

                case Mnemonic.cdb: RewriteCmpFloatMem(PrimitiveType.Real64); break;

                case Mnemonic.cdr: RewriteCmpFloat(PrimitiveType.Real64); break;

                case Mnemonic.ceb: RewriteCmpFloatMem(PrimitiveType.Real32); break;

                case Mnemonic.cer: RewriteCmpFloat(PrimitiveType.Real32); break;

                case Mnemonic.cghi: RewriteCghi(); break;

                case Mnemonic.cgij: RewriteCij(PrimitiveType.Int64); break;

                case Mnemonic.cgr: RewriteCr(m.ISub, PrimitiveType.Int64); break;

                case Mnemonic.cgrj: RewriteCrj(PrimitiveType.Int64); break;

                case Mnemonic.ch: RewriteCmpH(PrimitiveType.Int32, PrimitiveType.Int16); break;

                case Mnemonic.chi: RewriteChi(); break;

                case Mnemonic.cij: RewriteCij(PrimitiveType.Int32); break;

                case Mnemonic.cl: RewriteCl(PrimitiveType.Word32); break;

                case Mnemonic.clc: RewriteClc(); break;

                case Mnemonic.clcl: RewriteClcl(PrimitiveType.Word128); break;

                case Mnemonic.clcle: RewriteClcl(PrimitiveType.Word128); break;

                case Mnemonic.clg: RewriteCl(PrimitiveType.Word64); break;

                case Mnemonic.clgij: RewriteClij(PrimitiveType.Word64); break;

                case Mnemonic.clgr: RewriteCr(m.USub, PrimitiveType.Word64); break;

                case Mnemonic.clgrl: RewriteClrl(PrimitiveType.Word64); break;

                case Mnemonic.clgrj: RewriteClrj(PrimitiveType.Word64); break;

                case Mnemonic.clfi: RewriteClfi(PrimitiveType.UInt32); break;

                case Mnemonic.cli: RewriteCli(); break;

                case Mnemonic.clij: RewriteClij(PrimitiveType.Word32); break;

                case Mnemonic.cliy: RewriteCli(); break;

                case Mnemonic.clr: RewriteCr(m.USub, PrimitiveType.Word32); break;

                case Mnemonic.clrj: RewriteClrj(PrimitiveType.Word32); break;

                case Mnemonic.clrl: RewriteClrl(PrimitiveType.Word32); break;

                case Mnemonic.cr: RewriteCr(m.ISub, PrimitiveType.Int32); break;

                case Mnemonic.crj: RewriteCrj(PrimitiveType.Int32); break;

                case Mnemonic.cs: RewriteCs(PrimitiveType.Word32); break;

                case Mnemonic.csg: RewriteCs(PrimitiveType.Word64); break;

                case Mnemonic.cvb: RewriteCvb(PrimitiveType.Int32); break;

                case Mnemonic.cvd: RewriteCvd(PrimitiveType.Int32); break;

                case Mnemonic.d: RewriteD(); break;

                case Mnemonic.ddr: RewriteFDivR(PrimitiveType.Real64); break;

                case Mnemonic.der: RewriteFDivR(PrimitiveType.Real32); break;

                case Mnemonic.dlgr: RewriteDlr(PrimitiveType.UInt64); break;

                case Mnemonic.dlr: RewriteDlr(PrimitiveType.UInt32); break;

                case Mnemonic.dp: RewriteDp(); break;

                case Mnemonic.dr: RewriteDr(); break;

                case Mnemonic.dsgr: RewriteDsgr(PrimitiveType.Int64); break;

                case Mnemonic.ex: RewriteEx(); break;

                case Mnemonic.exrl: RewriteEx(); break;

                case Mnemonic.hdr: RewriteHalveR(PrimitiveType.Real64, Constant.Real64(2)); break;

                case Mnemonic.her: RewriteHalveR(PrimitiveType.Real32, Constant.Real32(2)); break;

                case Mnemonic.ic: RewriteIc(); break;

                case Mnemonic.j: RewriteJ(); break;

                case Mnemonic.je: RewriteJcc(ConditionCode.EQ); break;

                case Mnemonic.jg: RewriteJcc(ConditionCode.GT); break;

                case Mnemonic.jh: RewriteJcc(ConditionCode.UGT); break;

                case Mnemonic.jl: RewriteJcc(ConditionCode.LT); break;

                case Mnemonic.jle: RewriteJcc(ConditionCode.LE); break;

                case Mnemonic.jhe: RewriteJcc(ConditionCode.UGE); break;

                case Mnemonic.jne: RewriteJcc(ConditionCode.NE); break;

                case Mnemonic.jnh: RewriteJcc(ConditionCode.ULE); break;

                case Mnemonic.jnl: RewriteJcc(ConditionCode.GE); break;

                case Mnemonic.jo: RewriteJcc(ConditionCode.OV); break;

                case Mnemonic.la: RewriteLa(); break;

                case Mnemonic.larl: RewriteLarl(); break;

                case Mnemonic.l: RewriteL(PrimitiveType.Word32); break;

                case Mnemonic.laa: RewriteLaa(m.IAdd, PrimitiveType.Int32); break;

                case Mnemonic.lay: RewriteLay(); break;

                case Mnemonic.lbr: RewriteLr(PrimitiveType.SByte, PrimitiveType.Int32); break;

                case Mnemonic.lcdr: RewriteLcr(LongHexFloat, m.FNeg); break;

                case Mnemonic.lcer: RewriteLcr(ShortHexFloat, m.FNeg); break;

                case Mnemonic.lcr: RewriteLcr(PrimitiveType.Int32, m.Neg); break;

                case Mnemonic.lcgr: RewriteLcr(PrimitiveType.Int64, m.Neg); break;

                case Mnemonic.ld: RewriteL(PrimitiveType.Word64); break;

                case Mnemonic.ldeb: RewriteFConvert(PrimitiveType.Real32, PrimitiveType.Real64); break;

                case Mnemonic.ldxr: RewriteLdxr(); break;

                case Mnemonic.ldr: RewriteLreg(PrimitiveType.Word64); break;

                case Mnemonic.le: RewriteL(PrimitiveType.Real32); break;

                case Mnemonic.ler: RewriteLreg(PrimitiveType.Real32); break;

                case Mnemonic.ledr: RewriteFConvertReg(PrimitiveType.Real64, PrimitiveType.Real32); break;

                case Mnemonic.ldgr: RewriteLdgr(); break;

                case Mnemonic.lg: RewriteL(PrimitiveType.Word64); break;

                case Mnemonic.lgfrl: RewriteL(PrimitiveType.Int32, PrimitiveType.Int64); break;

                case Mnemonic.lh: RewriteL(PrimitiveType.Word16); break;

                case Mnemonic.lhrl: RewriteL(PrimitiveType.Int16, PrimitiveType.Int32); break;

                case Mnemonic.lgdr: RewriteLgdr(); break;

                case Mnemonic.lgf: RewriteLgf(); break;

                case Mnemonic.lgfr: RewriteLgfr(); break;

                case Mnemonic.lghi: RewriteLghi(); break;

                case Mnemonic.lgr: RewriteLreg(PrimitiveType.Word64); break;

                case Mnemonic.lgrl: RewriteLgrl(); break;

                case Mnemonic.lhi: RewriteLhi(); break;

                case Mnemonic.llcr: RewriteLr(PrimitiveType.Byte, PrimitiveType.Word32); break;

                case Mnemonic.llgcr: RewriteLr(PrimitiveType.Byte, PrimitiveType.Word64); break;

                case Mnemonic.llgfr: RewriteLr(PrimitiveType.Word32, PrimitiveType.Word64); break;

                case Mnemonic.llgfrl: RewriteLl(PrimitiveType.Word32); break;

                case Mnemonic.llill: RewriteLli(PrimitiveType.Word16, 0); break;

                case Mnemonic.lmg: RewriteLmg(); break;

                case Mnemonic.lndr: RewriteFNegR(LongHexFloat); break;

                case Mnemonic.lner: RewriteFNegR(ShortHexFloat); break;

                case Mnemonic.lngr: RewriteLnr(PrimitiveType.Int64); break;

                case Mnemonic.lnr: RewriteLnr(PrimitiveType.Int32); break;

                case Mnemonic.locg: RewriteLoc(PrimitiveType.Word64, ConditionCode.ALWAYS); break;

                case Mnemonic.locgre: RewriteLoc(PrimitiveType.Word64, ConditionCode.EQ); break;

                case Mnemonic.locgrh: RewriteLoc(PrimitiveType.Word64, ConditionCode.UGT); break;

                case Mnemonic.locgrle: RewriteLoc(PrimitiveType.Word64, ConditionCode.LE); break;

                case Mnemonic.locgrne: RewriteLoc(PrimitiveType.Word64, ConditionCode.NE); break;

                case Mnemonic.locgrnhe: RewriteLoc(PrimitiveType.Word64, ConditionCode.ULE); break;

                case Mnemonic.locgrnl: RewriteLoc(PrimitiveType.Word64, ConditionCode.GE); break;

                case Mnemonic.locgrnle: RewriteLoc(PrimitiveType.Word64, ConditionCode.GT); break;

                case Mnemonic.lpdr: RewriteLpr("fabs", LongHexFloat); break;

                case Mnemonic.lper: RewriteLpr("fabsf", ShortHexFloat); break;

                case Mnemonic.lpgr: RewriteLpr("abs", PrimitiveType.Int64); break;

                case Mnemonic.lpr: RewriteLpr("abs", PrimitiveType.Int32); break;

                case Mnemonic.lr: RewriteLr(PrimitiveType.Word32, PrimitiveType.Word32); break;

                case Mnemonic.lra: RewriteLra(); break;

                case Mnemonic.lrl: RewriteL(PrimitiveType.Word32); break;

                case Mnemonic.lrvgr: RewriteLrv(PrimitiveType.Word64); break;

                case Mnemonic.lrvr: RewriteLrv(PrimitiveType.Word32); break;

                case Mnemonic.lt: RewriteLt(PrimitiveType.Word32); break;

                case Mnemonic.ltdr: RewriteLtdr(PrimitiveType.Real64, Constant.Real64(0.0)); break;

                case Mnemonic.lter: RewriteLtdr(PrimitiveType.Real32, Constant.Real32(0.0F)); break;

                case Mnemonic.ltg: RewriteLt(PrimitiveType.Word64); break;

                case Mnemonic.ltgr: RewriteLtr(PrimitiveType.Word64); break;

                case Mnemonic.ltr: RewriteLtr(PrimitiveType.Word32); break;

                case Mnemonic.m: RewriteM(PrimitiveType.Int32, PrimitiveType.Int64); break;

                case Mnemonic.md: RewriteFMul(LongHexFloat, LongHexFloat); break;

                case Mnemonic.mdb: RewriteFMul(PrimitiveType.Real64, PrimitiveType.Real64); break;

                case Mnemonic.mde: RewriteFMul(ShortHexFloat, LongHexFloat); break;

                case Mnemonic.mdr: RewriteFMulReg(LongHexFloat, LongHexFloat); break;

                case Mnemonic.medr: RewriteFMulReg(ShortHexFloat, LongHexFloat); break;

                case Mnemonic.meeb: RewriteFMul(PrimitiveType.Real32, PrimitiveType.Real32); break;

                case Mnemonic.meer: RewriteFMulReg(ShortHexFloat, ShortHexFloat); break;

                case Mnemonic.mh: RewriteAluH(m.SMul, PrimitiveType.Int32, PrimitiveType.Int16); break;

                case Mnemonic.mlgr: RewriteMr(m.UMul, PrimitiveType.UInt64, PrimitiveType.UInt128); break;

                case Mnemonic.mr: RewriteMr(m.SMul, PrimitiveType.Int32, PrimitiveType.Int64); break;

                case Mnemonic.msgr: RewriteMulR(PrimitiveType.Int64); break;

                case Mnemonic.mvcle: RewriteMvcle(); break;

                case Mnemonic.mvhi: RewriteMvi(PrimitiveType.Word16); break;

                case Mnemonic.mvi: RewriteMvi(PrimitiveType.Byte); break;

                case Mnemonic.mvz: RewriteMvz(); break;

                case Mnemonic.mxd: RewriteFMul(LongHexFloat, ExtendedHexFloat); break;

                case Mnemonic.mxdr: RewriteFMulReg(LongHexFloat, ExtendedHexFloat); break;

                case Mnemonic.mxr: RewriteFpuRegPair(m.FMul, ExtendedHexFloat); break;

                case Mnemonic.nc: RewriteNc(); break;

                case Mnemonic.ngr: RewriteLogicR(PrimitiveType.Word64, m.And); break;

                case Mnemonic.n: RewriteLogic(PrimitiveType.Word32, m.And); break;

                case Mnemonic.ni: RewriteNi(); break;

                case Mnemonic.nop: m.Nop(); break;

                case Mnemonic.nopr: m.Nop(); break;

                case Mnemonic.nr: RewriteLogicR(PrimitiveType.Word32, m.And); break;

                case Mnemonic.o: RewriteLogic(PrimitiveType.Word32, m.Or); break;

                case Mnemonic.ogr: RewriteLogicR(PrimitiveType.Word64, m.Or); break;

                case Mnemonic.oi: RewriteOi(); break;

                case Mnemonic.or: RewriteLogicR(PrimitiveType.Word32, m.Or); break;

                case Mnemonic.risbg: RewriteRisbg("__risbg"); break;

                case Mnemonic.risbgn: RewriteRisbg("__risbgn"); break;

                case Mnemonic.rllg: RewriteShift3(PrimitiveType.Word64, Rol); break;

                case Mnemonic.s: RewriteS(PrimitiveType.Int32); break;

                case Mnemonic.sh: RewriteAluH(m.ISub, PrimitiveType.Int32, PrimitiveType.Int16); break;

                case Mnemonic.sl: RewriteS(PrimitiveType.Word32); break;

                case Mnemonic.sd: RewriteFSub(LongHexFloat); break;

                case Mnemonic.sdb: RewriteFSub(PrimitiveType.Real64); break;

                case Mnemonic.sdr: RewriteFSubReg(LongHexFloat); break;

                case Mnemonic.se: RewriteFSub(ShortHexFloat); break;

                case Mnemonic.seb: RewriteFSub(PrimitiveType.Real32); break;

                case Mnemonic.ser: RewriteFSubReg(ShortHexFloat); break;

                case Mnemonic.sr: RewriteSub2(PrimitiveType.Int32); break;

                case Mnemonic.sgfr: RewriteAlugfr(m.ISub, PrimitiveType.Int32, PrimitiveType.Int64); break;

                case Mnemonic.sgr: RewriteSub2(PrimitiveType.Int64); break;

                case Mnemonic.sla: RewriteShift2(PrimitiveType.Int32, m.Shl); break;

                case Mnemonic.slgfr: RewriteAlugfr(m.USub, PrimitiveType.Word32, PrimitiveType.Word64); break;

                case Mnemonic.slgr: RewriteSub2(PrimitiveType.Word64); break;

                case Mnemonic.slfi: RewriteSub2(PrimitiveType.Word32); break;

                case Mnemonic.sll: RewriteShift2(PrimitiveType.Word32, m.Shl); break;  //$TODO: CC's are handled unsigned.

                case Mnemonic.slr: RewriteSub2(PrimitiveType.Word32); break;

                case Mnemonic.slrk: RewriteAlu3(m.USub, PrimitiveType.Word32); break;

                case Mnemonic.sllg: RewriteShift3(PrimitiveType.Word64, m.Shl); break;

                case Mnemonic.sllk: RewriteShift3(PrimitiveType.Word32, m.Shl); break;

                case Mnemonic.sra: RewriteShift2(PrimitiveType.Int32, m.Sar); break;

                case Mnemonic.srag: RewriteShift3(PrimitiveType.Int64, m.Sar); break;

                case Mnemonic.srak: RewriteShift3(PrimitiveType.Int32, m.Sar); break;

                case Mnemonic.srl: RewriteShift2(PrimitiveType.Word32, m.Shr); break;

                case Mnemonic.srlk: RewriteShift3(PrimitiveType.Word32, m.Shr); break;

                case Mnemonic.srlg: RewriteShift3(PrimitiveType.Word64, m.Shr); break;

                case Mnemonic.srp: RewriteSrp(); break;

                case Mnemonic.st: RewriteSt(PrimitiveType.Word32); break;

                case Mnemonic.stc: RewriteSt(PrimitiveType.Byte); break;

                case Mnemonic.stctl: RewriteStctl(PrimitiveType.Word32); break;

                case Mnemonic.std: RewriteSt(PrimitiveType.Word64); break;

                case Mnemonic.ste: RewriteSt(PrimitiveType.Word32); break;

                case Mnemonic.stg: RewriteSt(PrimitiveType.Word64); break;

                case Mnemonic.sth: RewriteSt(PrimitiveType.Word16); break;

                case Mnemonic.strl: RewriteSt(PrimitiveType.Word32); break;

                case Mnemonic.stgrl: RewriteSt(PrimitiveType.Word64); break;

                case Mnemonic.stmg: RewriteStmg(); break;

                case Mnemonic.su: RewriteFSub(ShortHexFloat); break;

                case Mnemonic.sur: RewriteSur(ShortHexFloat); break;

                case Mnemonic.swr: RewriteSur(LongHexFloat); break;

                case Mnemonic.svc: RewriteSvc(); break;

                case Mnemonic.sxr: RewriteFpuRegPair(m.FSub, ExtendedHexFloat); break;

                case Mnemonic.ts: RewriteTs(); break;

                case Mnemonic.x: RewriteXor2(PrimitiveType.Word32); break;

                case Mnemonic.xgr: RewriteLogicR(PrimitiveType.Word64, m.Xor); break;

                case Mnemonic.xr: RewriteLogicR(PrimitiveType.Word32, m.Xor); break;

                case Mnemonic.xc: RewriteXc(); break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));
            }
        }
Пример #22
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                var instrs = new List <RtlInstruction>();
                this.m      = new RtlEmitter(instrs);
                this.iclass = instr.InstructionClass;
                switch (instr.Mnemonic)
                {
                default:
                    EmitUnitTest();
                    Invalid();
                    host.Warn(
                        instr.Address,
                        string.Format(
                            "Alpha AXP instruction '{0}' not supported yet.",
                            instr.Mnemonic));

                    break;

                case Mnemonic.invalid:
                    Invalid();
                    break;

                case Mnemonic.addf_c: RewriteFpuOp(m.FAdd); break;

                case Mnemonic.adds: RewriteFpuOp(m.FAdd); break;

                case Mnemonic.adds_c: RewriteFpuOp(m.FAdd); break;

                case Mnemonic.addl: RewriteBin(addl); break;

                case Mnemonic.addl_v: RewriteBinOv(addl); break;

                case Mnemonic.addt: RewriteFpuOp(m.FAdd); break;

                case Mnemonic.addq: RewriteBin(addq); break;

                case Mnemonic.addq_v: RewriteBinOv(addq); break;

                case Mnemonic.and: RewriteBin(and); break;

                case Mnemonic.beq: RewriteBranch(m.Eq0); break;

                case Mnemonic.bge: RewriteBranch(m.Ge0); break;

                case Mnemonic.bgt: RewriteBranch(m.Gt0); break;

                case Mnemonic.bic: RewriteBin(bic); break;

                case Mnemonic.bis: RewriteBin(bis); break;

                case Mnemonic.blbc: RewriteBranch(lbc); break;

                case Mnemonic.blbs: RewriteBranch(lbs); break;

                case Mnemonic.ble: RewriteBranch(m.Le0); break;

                case Mnemonic.blt: RewriteBranch(m.Lt0); break;

                case Mnemonic.bne: RewriteBranch(m.Ne0); break;

                case Mnemonic.br: RewriteBr(); break;

                case Mnemonic.bsr: RewriteBr(); break;

                case Mnemonic.cmovlt: RewriteCmov(m.Lt0); break;

                case Mnemonic.cmovne: RewriteCmov(m.Ne0); break;

                case Mnemonic.cmovge: RewriteCmov(m.Ge0); break;

                case Mnemonic.cmovlbc: RewriteCmov(lbc); break;

                case Mnemonic.cmovlbs: RewriteCmov(lbs); break;

                case Mnemonic.cmpbge: RewriteInstrinsic("__cmpbge"); break;

                case Mnemonic.cmpeq: RewriteCmp(m.Eq); break;

                case Mnemonic.cmple: RewriteCmp(m.Le); break;

                case Mnemonic.cmplt: RewriteCmp(m.Lt); break;

                case Mnemonic.cmpteq: RewriteCmpt(m.Eq); break;

                case Mnemonic.cmptle: RewriteCmpt(m.Le); break;

                case Mnemonic.cmptlt: RewriteCmpt(m.Lt); break;

                case Mnemonic.cmpule: RewriteCmp(m.Ule); break;

                case Mnemonic.cmpult: RewriteCmp(m.Ult); break;

                case Mnemonic.cpys: RewriteCpys("__cpys"); break;

                case Mnemonic.cpyse: RewriteCpys("__cpyse"); break;

                case Mnemonic.cpysn: RewriteCpys("__cpysn"); break;

                case Mnemonic.cvtlq: RewriteCvt(PrimitiveType.Int32, PrimitiveType.Int64); break;

                case Mnemonic.cvtql: RewriteCvt(PrimitiveType.Int64, PrimitiveType.Int32); break;

                case Mnemonic.cvtqs: RewriteCvt(PrimitiveType.Int64, PrimitiveType.Real32); break;

                case Mnemonic.cvtqt: RewriteCvt(PrimitiveType.Int64, PrimitiveType.Real64); break;

                case Mnemonic.cvttq_c: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Int64); break;

                case Mnemonic.cvtts: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Real32); break;

                case Mnemonic.divs: RewriteFpuOp(m.FDiv); break;

                case Mnemonic.divt: RewriteFpuOp(m.FDiv); break;

                case Mnemonic.extbl: RewriteInstrinsic("__extbl"); break;

                case Mnemonic.extlh: RewriteInstrinsic("__extlh"); break;

                case Mnemonic.extll: RewriteInstrinsic("__extll"); break;

                case Mnemonic.extqh: RewriteInstrinsic("__extqh"); break;

                case Mnemonic.extql: RewriteInstrinsic("__extql"); break;

                case Mnemonic.extwh: RewriteInstrinsic("__extwh"); break;

                case Mnemonic.extwl: RewriteInstrinsic("__extwl"); break;

                case Mnemonic.fbeq: RewriteFBranch(Operator.Feq); break;

                case Mnemonic.fbge: RewriteFBranch(Operator.Fge); break;

                case Mnemonic.fbgt: RewriteFBranch(Operator.Fgt); break;

                case Mnemonic.fble: RewriteFBranch(Operator.Fle); break;

                case Mnemonic.fblt: RewriteFBranch(Operator.Flt); break;

                case Mnemonic.fbne: RewriteFBranch(Operator.Fne); break;

                case Mnemonic.fcmoveq: RewriteFCmov(Operator.Feq); break;

                case Mnemonic.fcmovle: RewriteFCmov(Operator.Fle); break;

                case Mnemonic.fcmovlt: RewriteFCmov(Operator.Flt); break;

                case Mnemonic.fcmovne: RewriteFCmov(Operator.Fne); break;

                case Mnemonic.halt: RewriteHalt(); break;

                case Mnemonic.implver: RewriteInstrinsic("__implver"); break;

                case Mnemonic.insbl: RewriteInstrinsic("__insbl"); break;

                case Mnemonic.inslh: RewriteInstrinsic("__inslh"); break;

                case Mnemonic.insll: RewriteInstrinsic("__insll"); break;

                case Mnemonic.insqh: RewriteInstrinsic("__insqh"); break;

                case Mnemonic.insql: RewriteInstrinsic("__insql"); break;

                case Mnemonic.inswl: RewriteInstrinsic("__inswl"); break;

                case Mnemonic.jmp: RewriteJmp(); break;

                case Mnemonic.jsr: RewriteJmp(); break;

                case Mnemonic.jsr_coroutine: RewriteJmp(); break;

                case Mnemonic.lda: RewriteLda(0); break;

                case Mnemonic.ldah: RewriteLda(16); break;

                case Mnemonic.ldbu: RewriteLd(PrimitiveType.Byte, PrimitiveType.Word64); break;

                case Mnemonic.ldf: RewriteLd(PrimitiveType.Real32, PrimitiveType.Real64); break;

                case Mnemonic.ldg: RewriteLd(PrimitiveType.Real64, PrimitiveType.Real64); break;

                case Mnemonic.ldl: RewriteLd(PrimitiveType.Int32, PrimitiveType.Word64); break;

                case Mnemonic.ldl_l: RewriteLoadInstrinsic("__ldl_l", PrimitiveType.Word32); break;

                case Mnemonic.ldq_l: RewriteLoadInstrinsic("__ldq_l", PrimitiveType.Word64); break;

                case Mnemonic.ldq: RewriteLd(PrimitiveType.Word64, PrimitiveType.Word64); break;

                case Mnemonic.ldq_u: RewriteLd(PrimitiveType.Word64, PrimitiveType.Word64); break;

                case Mnemonic.lds: RewriteLd(PrimitiveType.Real32, PrimitiveType.Real64); break;

                case Mnemonic.ldt: RewriteLd(PrimitiveType.Real64, PrimitiveType.Real64); break;

                case Mnemonic.ldwu: RewriteLd(PrimitiveType.UInt16, PrimitiveType.Word64); break;

                case Mnemonic.mskbl: RewriteInstrinsic("__mskbl"); break;

                case Mnemonic.msklh: RewriteInstrinsic("__msklh"); break;

                case Mnemonic.mskll: RewriteInstrinsic("__mskll"); break;

                case Mnemonic.mskqh: RewriteInstrinsic("__mskqh"); break;

                case Mnemonic.mskql: RewriteInstrinsic("__mskql"); break;

                case Mnemonic.mskwl: RewriteInstrinsic("__mskwl"); break;

                case Mnemonic.mull: RewriteBin(mull); break;

                case Mnemonic.mulq: RewriteBin(mulq); break;

                case Mnemonic.muls: RewriteFpuOp(m.FMul); break;

                case Mnemonic.mult: RewriteFpuOp(m.FMul); break;

                case Mnemonic.mult_c: RewriteFpuOp(m.FMul); break;

                case Mnemonic.ornot: RewriteBin(ornot); break;

                case Mnemonic.ret: RewriteJmp(); break;

                case Mnemonic.s4addl: RewriteBin(s4addl); break;

                case Mnemonic.s4addq: RewriteBin(s4addq); break;

                case Mnemonic.s8addl: RewriteBin(s8addl); break;

                case Mnemonic.s8addq: RewriteBin(s8addq); break;

                case Mnemonic.s4subl: RewriteBin(s4subl); break;

                case Mnemonic.s4subq: RewriteBin(s4subq); break;

                case Mnemonic.s8subl: RewriteBin(s8subl); break;

                case Mnemonic.s8subq: RewriteBin(s8subq); break;

                case Mnemonic.sll: RewriteBin(sll); break;

                case Mnemonic.src: RewriteInstrinsic("__src"); break;

                case Mnemonic.srl: RewriteBin(srl); break;

                case Mnemonic.stb: RewriteSt(PrimitiveType.Byte); break;

                case Mnemonic.stf: RewriteSt(PrimitiveType.Real32); break;

                case Mnemonic.stl: RewriteSt(PrimitiveType.Word32); break;

                case Mnemonic.stl_c: RewriteStoreInstrinsic("__stl_c", PrimitiveType.Word32); break;

                case Mnemonic.stq_c: RewriteStoreInstrinsic("__stq_c", PrimitiveType.Word64); break;

                case Mnemonic.stq_u: RewriteStoreInstrinsic("__stq_u", PrimitiveType.Word64); break;

                case Mnemonic.stg: RewriteSt(PrimitiveType.Real64); break;

                case Mnemonic.stw: RewriteSt(PrimitiveType.Word16); break;

                case Mnemonic.sts: RewriteSt(PrimitiveType.Real32); break;

                case Mnemonic.stt: RewriteSt(PrimitiveType.Real64); break;

                case Mnemonic.stq: RewriteSt(PrimitiveType.Word64); break;

                case Mnemonic.subf_s: RewriteFpuOp(m.FSub); break;

                case Mnemonic.subf_uc: RewriteFpuOp(m.FSub); break;

                case Mnemonic.subl: RewriteBin(subl); break;

                case Mnemonic.subl_v: RewriteBinOv(subl); break;

                case Mnemonic.subq: RewriteBin(subq); break;

                case Mnemonic.subq_v: RewriteBinOv(subq); break;

                case Mnemonic.subs: RewriteFpuOp(m.FSub); break;

                case Mnemonic.subt: RewriteFpuOp(m.FSub); break;

                case Mnemonic.trapb: RewriteTrapb(); break;

                case Mnemonic.umulh: RewriteBin(umulh); break;

                case Mnemonic.xor: RewriteBin(xor); break;

                case Mnemonic.zap: RewriteInstrinsic("__zap"); break;

                case Mnemonic.zapnot: RewriteInstrinsic("__zapnot"); break;
                }
                yield return(m.MakeCluster(instr.Address, instr.Length, iclass));
            }
        }
Пример #23
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                var rtls = new List <RtlInstruction>();
                this.m    = new RtlEmitter(rtls);
                this.rtlc = InstrClass.Linear;
                switch (instr.Opcode)
                {
                default:
                    host.Warn(
                        instr.Address,
                        string.Format(
                            "i8051 instruction '{0}' not supported yet.",
                            instr.Opcode));
                    goto case Opcode.Invalid;

                case Opcode.Invalid:
                case Opcode.reserved:
                    Invalid();
                    break;

                case Opcode.acall: RewriteCall(); break;

                case Opcode.add: RewriteBinop(m.IAdd, FlagM.C | FlagM.AC | FlagM.OV | FlagM.P); break;

                case Opcode.addc: RewriteAddcSubb(m.IAdd); break;

                case Opcode.ajmp: RewriteJump(); break;

                case Opcode.anl: RewriteLogical(m.And); break;

                case Opcode.cjne: RewriteCjne(); break;

                case Opcode.clr: RewriteClr(); break;

                case Opcode.dec: RewriteIncDec(m.ISub); break;

                case Opcode.djnz: RewriteDjnz(); break;

                case Opcode.inc: RewriteIncDec(m.IAdd); break;

                case Opcode.jb: RewriteJb(m.Ne0); break;

                case Opcode.jbc: RewriteJbc(); break;

                case Opcode.jc: RewriteJc(e => e); break;

                case Opcode.jmp: RewriteJump(); break;

                case Opcode.jnb: RewriteJb(m.Eq0); break;

                case Opcode.jnc: RewriteJc(m.Not); break;

                case Opcode.jnz: RewriteJz(m.Ne0); break;

                case Opcode.jz: RewriteJz(m.Eq0); break;

                case Opcode.lcall: RewriteCall(); break;

                case Opcode.ljmp: RewriteJump(); break;

                case Opcode.mov: RewriteMov(); break;

                case Opcode.movc: RewriteMovc(); break;

                case Opcode.movx: RewriteMovx(); break;

                case Opcode.mul: RewriteMul(); break;

                case Opcode.nop: m.Nop(); break;

                case Opcode.orl: RewriteLogical(m.Or); break;

                case Opcode.pop: RewritePop(); break;

                case Opcode.push: RewritePush(); break;

                case Opcode.ret: RewriteRet(); break;

                case Opcode.reti: RewriteRet(); break;

                case Opcode.rl: RewriteRotate(PseudoProcedure.Rol); break;

                case Opcode.rr: RewriteRotate(PseudoProcedure.Ror); break;

                case Opcode.setb: RewriteSetb(); break;

                case Opcode.sjmp: RewriteJump(); break;

                case Opcode.subb: RewriteAddcSubb(m.ISub); break;

                case Opcode.swap: RewriteSwap(); break;

                case Opcode.xrl: RewriteLogical(m.Xor); break;

                case Opcode.xch: RewriteXch(); break;

                case Opcode.cpl:
                case Opcode.da:
                case Opcode.div:
                case Opcode.rrc:
                case Opcode.rlc:
                case Opcode.xchd:
                    EmitUnitTest();
                    Invalid();
                    break;
                }
                yield return(new RtlInstructionCluster(instr.Address, instr.Length, rtls.ToArray())
                {
                    Class = rtlc
                });
            }
        }
Пример #24
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                this.instr = dasm.Current;
                var cluster = new List <RtlInstruction>();
                m    = new RtlEmitter(cluster);
                rtlc = instr.InstructionClass;
                switch (instr.Mnemonic)
                {
                default:
                    EmitUnitTest();
                    host.Warn(
                        instr.Address,
                        "AArch64 instruction {0} is not supported yet.",
                        instr);
                    goto case Mnemonic.Invalid;

                case Mnemonic.Invalid:
                    rtlc = InstrClass.Invalid;
                    m.Invalid();
                    break;

                case Mnemonic.add: RewriteMaybeSimdBinary(m.IAdd, "__add_{0}"); break;

                case Mnemonic.adds: RewriteBinary(m.IAdd, this.NZCV); break;

                case Mnemonic.addv: RewriteAddv(); break;

                case Mnemonic.adr: RewriteUnary(n => n); break;

                case Mnemonic.asrv: RewriteBinary(m.Sar); break;

                case Mnemonic.bic: RewriteBinary((a, b) => m.And(a, m.Comp(b))); break;

                case Mnemonic.adrp: RewriteAdrp(); break;

                case Mnemonic.and: RewriteBinary(m.And); break;

                case Mnemonic.ands: RewriteBinary(m.And, this.NZ00); break;

                case Mnemonic.asr: RewriteBinary(m.Sar); break;

                case Mnemonic.b: RewriteB(); break;

                case Mnemonic.bfm: RewriteBfm(); break;

                case Mnemonic.bl: RewriteBl(); break;

                case Mnemonic.blr: RewriteBlr(); break;

                case Mnemonic.br: RewriteBr(); break;

                case Mnemonic.cbnz: RewriteCb(m.Ne0); break;

                case Mnemonic.cbz: RewriteCb(m.Eq0); break;

                case Mnemonic.ccmn: RewriteCcmn(); break;

                case Mnemonic.ccmp: RewriteCcmp(); break;

                case Mnemonic.clz: RewriteClz(); break;

                case Mnemonic.cmp: RewriteCmp(); break;

                case Mnemonic.cmeq: RewriteCmeq(); break;

                case Mnemonic.csel: RewriteCsel(); break;

                case Mnemonic.csinc: RewriteCsinc(); break;

                case Mnemonic.csinv: RewriteCsinv(); break;

                case Mnemonic.csneg: RewriteCsneg(); break;

                case Mnemonic.dsb: RewriteDsb(); break;

                case Mnemonic.dup: RewriteDup(); break;

                case Mnemonic.eor: RewriteBinary(m.Xor); break;

                case Mnemonic.fabs: RewriteFabs(); break;

                case Mnemonic.fadd: RewriteFadd(); break;

                case Mnemonic.fcmp: RewriteFcmp(); break;

                case Mnemonic.fcsel: RewriteFcsel(); break;

                case Mnemonic.fcvt: RewriteFcvt(); break;

                case Mnemonic.fcvtms: RewriteFcvtms(); break;

                case Mnemonic.fcvtps: RewriteFcvtps(); break;

                case Mnemonic.fcvtzs: RewriteFcvtzs(); break;

                case Mnemonic.fdiv: RewriteMaybeSimdBinary(m.FDiv, "__fdiv_{0}", Domain.Real); break;

                case Mnemonic.fmadd: RewriteIntrinsicFTernary("__fmaddf", "__fmadd"); break;

                case Mnemonic.fmsub: RewriteIntrinsicFTernary("__fmsubf", "__fmsub"); break;

                case Mnemonic.fmax: RewriteIntrinsicFBinary("fmaxf", "fmax"); break;

                case Mnemonic.fmin: RewriteIntrinsicFBinary("fminf", "fmin"); break;

                case Mnemonic.fmov: RewriteFmov(); break;

                case Mnemonic.fmul: RewriteFmul(); break;

                case Mnemonic.fneg: RewriteUnary(m.FNeg); break;

                case Mnemonic.fnmul: RewriteFnmul(); break;

                case Mnemonic.fsqrt: RewriteFsqrt(); break;

                case Mnemonic.fsub: RewriteMaybeSimdBinary(m.FSub, "__fsub_{0}", Domain.Real); break;

                case Mnemonic.isb: RewriteIsb(); break;

                case Mnemonic.ld1r: RewriteLdNr("__ld1r"); break;

                case Mnemonic.ld2: RewriteLdN("__ld2"); break;

                case Mnemonic.ld3: RewriteLdN("__ld3"); break;

                case Mnemonic.ld4: RewriteLdN("__ld4"); break;

                case Mnemonic.ldp: RewriteLoadStorePair(true); break;

                case Mnemonic.ldpsw: RewriteLoadStorePair(true, PrimitiveType.Int32, PrimitiveType.Int64); break;

                case Mnemonic.ldr: RewriteLdr(null); break;

                case Mnemonic.ldrb: RewriteLdr(PrimitiveType.Byte); break;

                case Mnemonic.ldrh: RewriteLdr(PrimitiveType.Word16); break;

                case Mnemonic.ldrsb: RewriteLdr(PrimitiveType.SByte); break;

                case Mnemonic.ldrsh: RewriteLdr(PrimitiveType.Int16); break;

                case Mnemonic.ldrsw: RewriteLdr(PrimitiveType.Int32); break;

                case Mnemonic.lslv: RewriteBinary(m.Shl); break;

                case Mnemonic.lsrv: RewriteBinary(m.Shr); break;

                case Mnemonic.ldur: RewriteLdr(null); break;

                case Mnemonic.ldurb: RewriteLdr(PrimitiveType.Byte); break;

                case Mnemonic.ldurh: RewriteLdr(PrimitiveType.Word16); break;

                case Mnemonic.ldursb: RewriteLdr(PrimitiveType.SByte); break;

                case Mnemonic.ldursh: RewriteLdr(PrimitiveType.Int16); break;

                case Mnemonic.ldursw: RewriteLdr(PrimitiveType.Int32); break;

                case Mnemonic.lsl: RewriteBinary(m.Shl); break;

                case Mnemonic.lsr: RewriteBinary(m.Shr); break;

                case Mnemonic.madd: RewriteMaddSub(m.IAdd); break;

                case Mnemonic.mneg: RewriteBinary((a, b) => m.Neg(m.IMul(a, b))); break;

                case Mnemonic.msub: RewriteMaddSub(m.ISub); break;

                case Mnemonic.mov: RewriteMov(); break;

                case Mnemonic.movi: RewriteMovi(); break;

                case Mnemonic.movk: RewriteMovk(); break;

                case Mnemonic.movn: RewriteMovn(); break;

                case Mnemonic.movz: RewriteMovz(); break;

                case Mnemonic.mrs: RewriteMrs(); break;

                case Mnemonic.msr: RewriteMsr(); break;

                case Mnemonic.mul: RewriteMaybeSimdBinary(m.IMul, "__mul_{0}"); break;

                case Mnemonic.mvn: RewriteUnary(m.Comp); break;

                case Mnemonic.nop: m.Nop(); break;

                case Mnemonic.not: RewriteMaybeSimdUnary(m.Comp, "__not_{0}"); break;

                case Mnemonic.orr: RewriteBinary(m.Or); break;

                case Mnemonic.orn: RewriteBinary((a, b) => m.Or(a, m.Comp(b))); break;

                case Mnemonic.prfm: RewritePrfm(); break;

                case Mnemonic.ret: RewriteRet(); break;

                case Mnemonic.rev16: RewriteRev16(); break;

                case Mnemonic.ror: RewriteRor(); break;

                case Mnemonic.rorv: RewriteRor(); break;

                case Mnemonic.sbfiz: RewriteSbfiz(); break;

                case Mnemonic.sbfm: RewriteUSbfm("__sbfm"); break;

                case Mnemonic.scvtf: RewriteScvtf(); break;

                case Mnemonic.sdiv: RewriteBinary(m.SDiv); break;

                case Mnemonic.shrn: RewriteShrn(); break;

                case Mnemonic.smaddl: RewriteMaddl(PrimitiveType.Int64, m.SMul); break;

                case Mnemonic.smax: RewriteSmax(); break;

                case Mnemonic.smaxv: RewriteSmaxv(); break;

                case Mnemonic.smc: RewriteSmc(); break;

                case Mnemonic.smull: RewriteMull(PrimitiveType.Int64, m.SMul); break;

                case Mnemonic.st1: RewriteStN("__st1"); break;

                case Mnemonic.st2: RewriteStN("__st2"); break;

                case Mnemonic.st3: RewriteStN("__st3"); break;

                case Mnemonic.st4: RewriteStN("__st4"); break;

                case Mnemonic.stp: RewriteLoadStorePair(false); break;

                case Mnemonic.str: RewriteStr(null); break;

                case Mnemonic.strb: RewriteStr(PrimitiveType.Byte); break;

                case Mnemonic.strh: RewriteStr(PrimitiveType.Word16); break;

                case Mnemonic.stur: RewriteStr(null); break;

                case Mnemonic.sturb: RewriteStr(PrimitiveType.Byte); break;

                case Mnemonic.sturh: RewriteStr(PrimitiveType.Word16); break;

                case Mnemonic.sub: RewriteBinary(m.ISub); break;

                case Mnemonic.subs: RewriteBinary(m.ISub, NZCV); break;

                case Mnemonic.svc: RewriteSvc(); break;

                case Mnemonic.sxtb: RewriteUSxt(Domain.SignedInt, 8); break;

                case Mnemonic.sxth: RewriteUSxt(Domain.SignedInt, 16); break;

                case Mnemonic.sxtl: RewriteSimdUnary("__sxtl_{0}", Domain.SignedInt); break;

                case Mnemonic.sxtw: RewriteUSxt(Domain.SignedInt, 32); break;

                case Mnemonic.tbnz: RewriteTb(m.Ne0); break;

                case Mnemonic.tbz: RewriteTb(m.Eq0); break;

                case Mnemonic.test: RewriteTest(); break;

                case Mnemonic.uaddw: RewriteUaddw(); break;

                case Mnemonic.ubfm: RewriteUSbfm("__ubfm"); break;

                case Mnemonic.ucvtf: RewriteIcvt(Domain.UnsignedInt); break;

                case Mnemonic.udiv: RewriteBinary(m.UDiv); break;

                case Mnemonic.umaddl: RewriteMaddl(PrimitiveType.UInt64, m.UMul); break;

                case Mnemonic.umlal: RewriteUmlal(); break;

                case Mnemonic.umull: RewriteMull(PrimitiveType.UInt64, m.UMul); break;

                case Mnemonic.umulh: RewriteMulh(PrimitiveType.UInt64, m.UMul); break;

                case Mnemonic.uxtb: RewriteUSxt(Domain.UnsignedInt, 8); break;

                case Mnemonic.uxth: RewriteUSxt(Domain.UnsignedInt, 16); break;

                case Mnemonic.uxtl: RewriteSimdUnary("__uxtl_{0}", Domain.UnsignedInt); break;

                case Mnemonic.uxtw: RewriteUSxt(Domain.UnsignedInt, 32); break;

                case Mnemonic.xtn: RewriteSimdUnary("__xtn_{0}", Domain.None); break;
                }
                yield return(new RtlInstructionCluster(instr.Address, instr.Length, cluster.ToArray())
                {
                    Class = rtlc,
                });
            }
        }
Пример #25
0
        public IEnumerator <RtlInstructionCluster> GetEnumerator()
        {
            while (dasm.MoveNext())
            {
                var addr = dasm.Current.Address;
                var len  = dasm.Current.Length;
                rtlInstructions = new List <RtlInstruction>();
                rtlc            = dasm.Current.IClass;
                m = new RtlEmitter(rtlInstructions);
                switch (dasm.Current.Opcode)
                {
                default:
                    //EmitUnitTest();
                    //emitter.SideEffect(Constant.String(
                    //    dasm.Current.ToString(),
                    //    StringType.NullTerminated(PrimitiveType.Char)));
                    host.Warn(
                        dasm.Current.Address,
                        "VAX instruction {0} not supported yet.",
                        dasm.Current.Opcode);
                    m.Invalid();
                    break;

                case Opcode.Invalid: m.Invalid(); break;

                case Opcode.Reserved: m.Invalid(); break;

                case Opcode.acbb: RewriteAcbi(PrimitiveType.Byte); break;

                case Opcode.acbd: RewriteAcbf(PrimitiveType.Real64); break;

                case Opcode.acbf: RewriteAcbf(PrimitiveType.Real32); break;

                case Opcode.acbg: RewriteAcbf(PrimitiveType.Real64); break;

                case Opcode.acbh: RewriteAcbf(PrimitiveType.Real128); break;

                case Opcode.acbl: RewriteAcbi(PrimitiveType.Word32); break;

                case Opcode.acbw: RewriteAcbi(PrimitiveType.Word16); break;

                case Opcode.adawi: RewriteAlu2(PrimitiveType.Word16, Adawi, AllFlags); break;

                case Opcode.addb2: RewriteAlu2(PrimitiveType.Byte, m.IAdd, AllFlags); break;

                case Opcode.addb3: RewriteAlu3(PrimitiveType.Byte, m.IAdd, AllFlags); break;

                case Opcode.addd2: RewriteFpu2(PrimitiveType.Real64, m.FAdd, NZ00); break;

                case Opcode.addd3: RewriteFpu3(PrimitiveType.Real64, m.FAdd, NZ00); break;

                case Opcode.addf2: RewriteFpu2(PrimitiveType.Real32, m.FAdd, NZ00); break;

                case Opcode.addf3: RewriteFpu3(PrimitiveType.Real32, m.FAdd, NZ00); break;

                case Opcode.addl2: RewriteAlu2(PrimitiveType.Word32, m.IAdd, AllFlags); break;

                case Opcode.addl3: RewriteAlu3(PrimitiveType.Word32, m.IAdd, AllFlags); break;

                case Opcode.addp4: RewriteP4("vax_addp4"); break;

                case Opcode.addp6: RewriteP6("vax_addp6"); break;

                case Opcode.addw2: RewriteAlu2(PrimitiveType.Word16, m.IAdd, AllFlags); break;

                case Opcode.addw3: RewriteAlu3(PrimitiveType.Word16, m.IAdd, AllFlags); break;

                case Opcode.adwc: RewriteAdwc(); break;

                case Opcode.aobleq: RewriteAob(m.Le); break;

                case Opcode.aoblss: RewriteAob(m.Lt); break;

                case Opcode.ashl: RewriteAsh(PrimitiveType.Word32); break;

                case Opcode.ashp: RewriteAshp(); break;

                case Opcode.ashq: RewriteAsh(PrimitiveType.Word64); break;

                case Opcode.bbc: RewriteBb(false); break;

                case Opcode.bbcc: RewriteBbxx(false, false); break;

                case Opcode.bbcci: RewriteBbxxi(false); break;

                case Opcode.bbcs: RewriteBbxx(false, true); break;

                case Opcode.bbs: RewriteBb(true); break;

                case Opcode.bbsc: RewriteBbxx(true, false); break;

                case Opcode.bbss: RewriteBbxx(true, true); break;

                case Opcode.bbssi: RewriteBbxxi(true); break;

                case Opcode.beql: RewriteBranch(ConditionCode.EQ, FlagM.ZF); break;

                case Opcode.bgeq: RewriteBranch(ConditionCode.GE, FlagM.NF); break;

                case Opcode.bgequ: RewriteBranch(ConditionCode.UGE, FlagM.CF); break;

                case Opcode.bgtr: RewriteBranch(ConditionCode.GT, FlagM.ZF | FlagM.NF); break;

                case Opcode.bgtru: RewriteBranch(ConditionCode.UGT, FlagM.ZF | FlagM.CF); break;

                case Opcode.bleq: RewriteBranch(ConditionCode.LE, FlagM.ZF | FlagM.NF); break;

                case Opcode.blequ: RewriteBranch(ConditionCode.ULE, FlagM.ZF | FlagM.CF); break;

                case Opcode.blss: RewriteBranch(ConditionCode.LT, FlagM.NF); break;

                case Opcode.blssu: RewriteBranch(ConditionCode.ULT, FlagM.CF); break;

                case Opcode.bneq: RewriteBranch(ConditionCode.NE, FlagM.ZF); break;

                case Opcode.bvc: RewriteBranch(ConditionCode.NO, FlagM.VF); break;

                case Opcode.bvs: RewriteBranch(ConditionCode.OV, FlagM.VF); break;

                case Opcode.bicb2: RewriteAlu2(PrimitiveType.Byte, Bic, NZ00); break;

                case Opcode.bicb3: RewriteAlu3(PrimitiveType.Byte, Bic, NZ00); break;

                case Opcode.bicl2: RewriteAlu2(PrimitiveType.Word32, Bic, NZ00); break;

                case Opcode.bicl3: RewriteAlu3(PrimitiveType.Word32, Bic, NZ00); break;

                case Opcode.bicpsw: RewriteBicpsw(); break;

                case Opcode.bicw2: RewriteAlu2(PrimitiveType.Word16, Bic, NZ00); break;

                case Opcode.bicw3: RewriteAlu3(PrimitiveType.Word16, Bic, NZ00); break;

                case Opcode.bisb2: RewriteAlu2(PrimitiveType.Byte, m.Or, NZ00); break;

                case Opcode.bisb3: RewriteAlu3(PrimitiveType.Byte, m.Or, NZ00); break;

                case Opcode.bispsw: RewriteBispsw(); break;

                case Opcode.bisl2: RewriteAlu2(PrimitiveType.Word32, m.Or, NZ00); break;

                case Opcode.bisl3: RewriteAlu3(PrimitiveType.Word32, m.Or, NZ00); break;

                case Opcode.bisw2: RewriteAlu2(PrimitiveType.Word16, m.Or, NZ00); break;

                case Opcode.bisw3: RewriteAlu3(PrimitiveType.Word16, m.Or, NZ00); break;

                case Opcode.bitb: RewriteBit(PrimitiveType.Byte); break;

                case Opcode.bitw: RewriteBit(PrimitiveType.Byte); break;

                case Opcode.bitl: RewriteBit(PrimitiveType.Byte); break;

                case Opcode.blbc: RewriteBlb(m.Eq0); break;

                case Opcode.blbs: RewriteBlb(m.Ne0); break;

                case Opcode.bpt: RewriteBpt(); break;

                case Opcode.brb: RewriteBranch(); break;

                case Opcode.brw: RewriteBranch(); break;

                case Opcode.bsbb: RewriteBsb(); break;

                case Opcode.bsbw: RewriteBsb(); break;

                case Opcode.caseb: goto default;

                case Opcode.casel: goto default;

                case Opcode.chme: RewriteChm("vax_chme"); break;

                case Opcode.chmk: RewriteChm("vax_chmk"); break;

                case Opcode.chms: RewriteChm("vax_chms"); break;

                case Opcode.chmu: RewriteChm("vax_chmu"); break;

                case Opcode.clrb: RewriteClr(PrimitiveType.Byte); break;

                case Opcode.clrh: RewriteClr(PrimitiveType.Word128); break;

                case Opcode.clrl: RewriteClr(PrimitiveType.Word32); break;

                case Opcode.clrq: RewriteClr(PrimitiveType.Word64); break;

                case Opcode.clrw: RewriteClr(PrimitiveType.Word16); break;

                case Opcode.cmpb: RewriteCmp(PrimitiveType.Byte); break;

                case Opcode.cmpd: RewriteCmp(PrimitiveType.Real64); break;

                case Opcode.cmpf: RewriteCmp(PrimitiveType.Real32); break;

                case Opcode.cmpg: RewriteCmp(PrimitiveType.Real64); break;

                case Opcode.cmph: RewriteCmp(PrimitiveType.Real128); break;

                case Opcode.cmpl: RewriteCmp(PrimitiveType.Word32); break;

                case Opcode.cmpw: RewriteCmp(PrimitiveType.Word16); break;

                case Opcode.cmpp3: RewriteCmpp3(); break;

                case Opcode.cmpp4: RewriteCmpp4(); break;

                case Opcode.cmpv: goto default;

                case Opcode.cmpzv: goto default;

                case Opcode.cvtbd: RewriteCvt(PrimitiveType.SByte, PrimitiveType.Real64); break;

                case Opcode.cvtbf: RewriteCvt(PrimitiveType.SByte, PrimitiveType.Real32); break;

                case Opcode.cvtbg: RewriteCvt(PrimitiveType.SByte, PrimitiveType.Real64); break;

                case Opcode.cvtbh: RewriteCvt(PrimitiveType.SByte, PrimitiveType.Real128); break;

                case Opcode.cvtbl: RewriteCvt(PrimitiveType.SByte, PrimitiveType.Int32); break;

                case Opcode.cvtbw: RewriteCvt(PrimitiveType.SByte, PrimitiveType.Int16); break;

                case Opcode.cvtdb: RewriteCvt(PrimitiveType.Real64, PrimitiveType.SByte); break;

                case Opcode.cvtdf: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Real32); break;

                case Opcode.cvtdh: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Real128); break;

                case Opcode.cvtdl: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Int32); break;

                case Opcode.cvtdw: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Int16); break;

                case Opcode.cvtfb: RewriteCvt(PrimitiveType.Real32, PrimitiveType.SByte); break;

                case Opcode.cvtfd: RewriteCvt(PrimitiveType.Real32, PrimitiveType.Real64); break;

                case Opcode.cvtfg: RewriteCvt(PrimitiveType.Real32, PrimitiveType.Real64); break;

                case Opcode.cvtfh: RewriteCvt(PrimitiveType.Real32, PrimitiveType.Real128); break;

                case Opcode.cvtfl: RewriteCvt(PrimitiveType.Real32, PrimitiveType.Int32); break;

                case Opcode.cvtfw: RewriteCvt(PrimitiveType.Real32, PrimitiveType.Int16); break;

                case Opcode.cvtgb: RewriteCvt(PrimitiveType.Real64, PrimitiveType.SByte); break;

                case Opcode.cvtgf: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Real32); break;

                case Opcode.cvtgh: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Real128); break;

                case Opcode.cvtgl: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Int32); break;

                case Opcode.cvtgw: RewriteCvt(PrimitiveType.Real64, PrimitiveType.Int16); break;

                case Opcode.cvthb: RewriteCvt(PrimitiveType.Real128, PrimitiveType.SByte); break;

                case Opcode.cvthd: RewriteCvt(PrimitiveType.Real128, PrimitiveType.Real64); break;

                case Opcode.cvthf: RewriteCvt(PrimitiveType.Real128, PrimitiveType.Real32); break;

                case Opcode.cvthg: RewriteCvt(PrimitiveType.Real128, PrimitiveType.Real64); break;

                case Opcode.cvthl: RewriteCvt(PrimitiveType.Real128, PrimitiveType.Int32); break;

                case Opcode.cvthw: RewriteCvt(PrimitiveType.Real128, PrimitiveType.Int16); break;

                case Opcode.cvtps: RewriteCvtComplex("__cvtps"); break;

                case Opcode.cvtrdl: RewriteCvtr(PrimitiveType.Real64, PrimitiveType.Int32); break;

                case Opcode.cvtrfl: RewriteCvtr(PrimitiveType.Real32, PrimitiveType.Int32); break;

                case Opcode.cvtrgl: RewriteCvtr(PrimitiveType.Real64, PrimitiveType.Int32); break;

                case Opcode.cvtrhl: RewriteCvtr(PrimitiveType.Real128, PrimitiveType.Int32); break;

                case Opcode.cvtlb: RewriteCvt(PrimitiveType.Int32, PrimitiveType.SByte); break;

                case Opcode.cvtld: RewriteCvt(PrimitiveType.Int32, PrimitiveType.Real64); break;

                case Opcode.cvtlf: RewriteCvt(PrimitiveType.Int32, PrimitiveType.Real32); break;

                case Opcode.cvtlg: RewriteCvt(PrimitiveType.Int32, PrimitiveType.Real64); break;

                case Opcode.cvtlh: RewriteCvt(PrimitiveType.Int32, PrimitiveType.Real128); break;

                case Opcode.cvtlp: goto default;

                case Opcode.cvtlw: RewriteCvt(PrimitiveType.Int32, PrimitiveType.Int16); break;

                case Opcode.cvtpl: goto default;

                case Opcode.cvtpt: goto default;

                case Opcode.cvtsp: RewriteCvtComplex("__cvtsp"); break;

                case Opcode.cvttp: goto default;

                case Opcode.cvtwb: RewriteCvt(PrimitiveType.Int16, PrimitiveType.SByte); break;

                case Opcode.cvtwd: RewriteCvt(PrimitiveType.Int16, PrimitiveType.Real64); break;

                case Opcode.cvtwf: RewriteCvt(PrimitiveType.Int16, PrimitiveType.Real32); break;

                case Opcode.cvtwg: RewriteCvt(PrimitiveType.Int16, PrimitiveType.Real64); break;

                case Opcode.cvtwh: RewriteCvt(PrimitiveType.Int16, PrimitiveType.Real128); break;

                case Opcode.cvtwl: RewriteCvt(PrimitiveType.Int16, PrimitiveType.Int32); break;;

                case Opcode.decb: RewriteIncDec(PrimitiveType.Byte, Dec); break;

                case Opcode.decl: RewriteIncDec(PrimitiveType.Word32, Dec); break;

                case Opcode.decw: RewriteIncDec(PrimitiveType.Word16, Dec); break;

                case Opcode.divb2: RewriteAlu2(PrimitiveType.Byte, m.SDiv, AllFlags); break;

                case Opcode.divb3: RewriteAlu3(PrimitiveType.Byte, m.SDiv, AllFlags); break;

                case Opcode.divd2: RewriteFpu2(PrimitiveType.Real64, m.FDiv, AllFlags); break;

                case Opcode.divd3: RewriteFpu3(PrimitiveType.Real64, m.FDiv, AllFlags); break;

                case Opcode.divf2: RewriteFpu2(PrimitiveType.Real32, m.FDiv, AllFlags); break;

                case Opcode.divf3: RewriteFpu3(PrimitiveType.Real32, m.FDiv, AllFlags); break;

                case Opcode.divl2: RewriteAlu2(PrimitiveType.Word32, m.SDiv, AllFlags); break;

                case Opcode.divl3: RewriteAlu3(PrimitiveType.Word32, m.SDiv, AllFlags); break;

                case Opcode.divp: RewriteDivp(); break;

                case Opcode.divw2: RewriteAlu2(PrimitiveType.Word16, m.SDiv, AllFlags); break;

                case Opcode.divw3: RewriteAlu3(PrimitiveType.Word16, m.SDiv, AllFlags); break;

                case Opcode.emodd: RewriteEmod("emodd", PrimitiveType.Real64, PrimitiveType.Byte); break;    //$TODO: VAX floating point types

                case Opcode.emodf: RewriteEmod("emodf", PrimitiveType.Real32, PrimitiveType.Byte); break;    //$TODO: VAX floating point types

                case Opcode.emodg: RewriteEmod("emodg", PrimitiveType.Real64, PrimitiveType.Word16); break;  //$TODO: VAX floating point types

                case Opcode.emodh: RewriteEmod("emodh", PrimitiveType.Real128, PrimitiveType.Word16); break; //$TODO: VAX floating point types

                case Opcode.ffc: RewriteFfx("__ffc"); break;

                case Opcode.ffs: RewriteFfx("__ffs"); break;

                case Opcode.halt: RewriteHalt(); break;

                case Opcode.incb: RewriteIncDec(PrimitiveType.Byte, Inc); break;

                case Opcode.incl: RewriteIncDec(PrimitiveType.Word32, Inc); break;

                case Opcode.incw: RewriteIncDec(PrimitiveType.Word16, Inc); break;

                case Opcode.insque: RewriteInsque(); break;

                case Opcode.jmp: RewriteJmp(); break;

                case Opcode.jsb: RewriteJsb(); break;

                case Opcode.mcomb: RewriteAluUnary2(PrimitiveType.Byte, m.Comp, NZ00); break;

                case Opcode.mcoml: RewriteAluUnary2(PrimitiveType.Word32, m.Comp, NZ00); break;

                case Opcode.mcomw: RewriteAluUnary2(PrimitiveType.Word16, m.Comp, NZ00); break;

                case Opcode.mnegb: RewriteAluUnary2(PrimitiveType.Byte, m.Neg, AllFlags); break;

                case Opcode.mnegd: RewriteAluUnary2(PrimitiveType.Real64, m.FNeg, NZ00); break;

                case Opcode.mnegf: RewriteAluUnary2(PrimitiveType.Real32, m.FNeg, NZ00); break;

                case Opcode.mnegg: RewriteAluUnary2(PrimitiveType.Real64, m.FNeg, NZ00); break;

                case Opcode.mnegh: RewriteAluUnary2(PrimitiveType.Word128, m.FNeg, NZ00); break;

                case Opcode.mnegl: RewriteAluUnary2(PrimitiveType.Word32, m.Neg, AllFlags); break;

                case Opcode.mnegw: RewriteAluUnary2(PrimitiveType.Word16, m.Neg, AllFlags); break;

                case Opcode.movab: RewriteMova(PrimitiveType.Byte); break;

                case Opcode.movah: RewriteMova(PrimitiveType.Real128); break;

                case Opcode.moval: RewriteMova(PrimitiveType.Word32); break;

                case Opcode.movaq: RewriteMova(PrimitiveType.Word64); break;

                case Opcode.movaw: RewriteMova(PrimitiveType.Word16); break;

                case Opcode.movb:   RewriteAluUnary2(PrimitiveType.Byte, Copy, NZ00); break;

                case Opcode.movc3:  goto default;

                case Opcode.movc5:  goto default;

                case Opcode.movd:   RewriteAluUnary2(PrimitiveType.Real64, Copy, NZ00); break;

                case Opcode.movf:   RewriteAluUnary2(PrimitiveType.Real32, Copy, NZ00); break;

                case Opcode.movg:   RewriteAluUnary2(PrimitiveType.Real64, Copy, NZ00); break;

                case Opcode.movh:   RewriteAluUnary2(PrimitiveType.Real128, Copy, NZ00); break;

                case Opcode.movl:   RewriteAluUnary2(PrimitiveType.Word32, Copy, NZ00); break;

                case Opcode.movo:   RewriteAluUnary2(PrimitiveType.Word128, Copy, NZ00); break;

                case Opcode.movp: goto default;

                case Opcode.movq:   RewriteAluUnary2(PrimitiveType.Word64, Copy, NZ00); break;

                case Opcode.movw:   RewriteAluUnary2(PrimitiveType.Word16, Copy, NZ00); break;

                case Opcode.movzbl: RewriteMovz(PrimitiveType.Byte, PrimitiveType.UInt32); break;

                case Opcode.movzbw: RewriteMovz(PrimitiveType.Byte, PrimitiveType.UInt16); break;

                case Opcode.movzwl: RewriteMovz(PrimitiveType.Word16, PrimitiveType.UInt32); break;

                case Opcode.mulb2: RewriteAlu2(PrimitiveType.Byte, m.IMul, AllFlags); break;

                case Opcode.mulb3: RewriteAlu3(PrimitiveType.Byte, m.IMul, AllFlags); break;

                case Opcode.muld2: RewriteAlu2(PrimitiveType.Real64, m.FMul, AllFlags); break;

                case Opcode.muld3: RewriteAlu3(PrimitiveType.Real64, m.FMul, AllFlags); break;

                case Opcode.mulf2: RewriteAlu2(PrimitiveType.Real32, m.FMul, AllFlags); break;

                case Opcode.mulf3: RewriteAlu3(PrimitiveType.Real32, m.FMul, AllFlags); break;

                case Opcode.mulg2: RewriteAlu2(PrimitiveType.Real64, m.FMul, AllFlags); break;

                case Opcode.mulg3: RewriteAlu3(PrimitiveType.Real64, m.FMul, AllFlags); break;

                case Opcode.mulh2: RewriteAlu2(PrimitiveType.Real128, m.FMul, AllFlags); break;

                case Opcode.mulh3: RewriteAlu3(PrimitiveType.Real128, m.FMul, AllFlags); break;

                case Opcode.mull2: RewriteAlu2(PrimitiveType.Word32, m.IMul, AllFlags); break;

                case Opcode.mull3: RewriteAlu3(PrimitiveType.Word32, m.IMul, AllFlags); break;

                case Opcode.mulp: RewriteMulp(); break;

                case Opcode.mulw2: RewriteAlu2(PrimitiveType.Word16, m.IMul, AllFlags); break;

                case Opcode.mulw3: RewriteAlu3(PrimitiveType.Word16, m.IMul, AllFlags); break;

                case Opcode.nop: m.Nop(); break;

                case Opcode.polyd: RewritePoly(PrimitiveType.Real64); break;

                case Opcode.polyf: RewritePoly(PrimitiveType.Real32); break;

                case Opcode.polyg: RewritePoly(PrimitiveType.Real64); break;

                case Opcode.polyh: RewritePoly(PrimitiveType.Real128); break;

                case Opcode.popr:  goto default;

                case Opcode.prober: goto default;

                case Opcode.probew: goto default;

                case Opcode.pushr:  goto default;

                case Opcode.pushab: RewritePusha(); break;

                case Opcode.pushal: RewritePusha(); break;

                case Opcode.pushah: RewritePusha(); break;

                case Opcode.pushaw: RewritePusha(); break;

                case Opcode.pushaq: RewritePusha(); break;

                case Opcode.pushl: RewritePush(PrimitiveType.Word32); break;

                case Opcode.rei: RewriteRei(); break;

                case Opcode.ret: RewriteRet(); break;

                case Opcode.rotl: RewriteAlu3(PrimitiveType.Word32, Rotl, NZ00); break;

                case Opcode.rsb: RewriteRsb(); break;

                case Opcode.sbwc: RewriteSbwc(); break;

                case Opcode.scanc: RewriteScanc(); break;

                case Opcode.sobgeq: RewriteSob(m.Ge); break;

                case Opcode.sobgtr: RewriteSob(m.Gt); break;

                case Opcode.subb2: RewriteAlu2(PrimitiveType.Byte, m.ISub, AllFlags); break;

                case Opcode.subb3: RewriteAlu3(PrimitiveType.Byte, m.ISub, AllFlags); break;

                case Opcode.subd2: RewriteAlu2(PrimitiveType.Real64, m.FSub, NZ00); break;

                case Opcode.subd3: RewriteAlu3(PrimitiveType.Real64, m.FSub, NZ00); break;

                case Opcode.subf2: RewriteAlu2(PrimitiveType.Real32, m.FSub, NZ00); break;

                case Opcode.subf3: RewriteAlu3(PrimitiveType.Real32, m.FSub, NZ00); break;

                case Opcode.subg2: RewriteAlu2(PrimitiveType.Real64, m.FSub, NZ00); break;

                case Opcode.subg3: RewriteAlu3(PrimitiveType.Real64, m.FSub, NZ00); break;

                case Opcode.subh2: RewriteAlu2(PrimitiveType.Real128, m.FSub, NZ00); break;

                case Opcode.subh3: RewriteAlu3(PrimitiveType.Real128, m.FSub, NZ00); break;

                case Opcode.subl2: RewriteAlu2(PrimitiveType.Word32, m.ISub, AllFlags); break;

                case Opcode.subl3: RewriteAlu3(PrimitiveType.Word32, m.ISub, AllFlags); break;

                case Opcode.subp4: RewriteP4("vax_subp4"); break;

                case Opcode.subp6: RewriteP6("vax_subp6"); break;

                case Opcode.subw2: RewriteAlu2(PrimitiveType.Word16, m.ISub, AllFlags); break;

                case Opcode.subw3: RewriteAlu3(PrimitiveType.Word16, m.ISub, AllFlags); break;

                case Opcode.tstb: RewriteTst(PrimitiveType.Byte, ICmp0); break;

                case Opcode.tstd: RewriteTst(PrimitiveType.Real64, FCmp0); break;

                case Opcode.tstf: RewriteTst(PrimitiveType.Real32, FCmp0); break;

                case Opcode.tstg: RewriteTst(PrimitiveType.Real64, FCmp0); break;

                case Opcode.tsth: RewriteTst(PrimitiveType.Real128, FCmp0); break;

                case Opcode.tstl: RewriteTst(PrimitiveType.Word32, ICmp0); break;

                case Opcode.tstw: RewriteTst(PrimitiveType.Word16, ICmp0); break;

                case Opcode.xorb2: RewriteAlu2(PrimitiveType.Byte, m.Xor, NZ00); break;

                case Opcode.xorb3: RewriteAlu3(PrimitiveType.Byte, m.Xor, NZ00); break;

                case Opcode.xorl2: RewriteAlu2(PrimitiveType.Word32, m.Xor, NZ00); break;

                case Opcode.xorl3: RewriteAlu3(PrimitiveType.Word32, m.Xor, NZ00); break;

                case Opcode.xorw2: RewriteAlu2(PrimitiveType.Word16, m.Xor, NZ00); break;

                case Opcode.xorw3: RewriteAlu3(PrimitiveType.Word16, m.Xor, NZ00); break;

                case Opcode.ldpctx: goto default;

                case Opcode.svpctx: goto default;

                case Opcode.editpc: goto default;

                case Opcode.matchc: goto default;

                case Opcode.index: goto default;

                case Opcode.locc: goto default;

                case Opcode.crc: goto default;

                case Opcode.skpc: goto default;

                case Opcode.remque: goto default;

                case Opcode.spanc: goto default;

                case Opcode.insqhi: goto default;

                case Opcode.insqti: goto default;

                case Opcode.movtc: goto default;

                case Opcode.remqhi: goto default;

                case Opcode.movtuc: goto default;

                case Opcode.remqti: goto default;


                case Opcode.emul: goto default;

                case Opcode.ediv: goto default;

                case Opcode.casew: goto default;

                case Opcode.extv: goto default;

                case Opcode.extzv: goto default;

                case Opcode.insv: goto default;

                case Opcode.mtpr: goto default;

                case Opcode.callg: goto default;

                case Opcode.mfpr: goto default;

                case Opcode.calls: goto default;

                case Opcode.movpsl: goto default;

                case Opcode.xfc: goto default;

                case Opcode.mfvp: goto default;

                case Opcode.vldl: goto default;

                case Opcode.vgathl: goto default;

                case Opcode.vldq: goto default;

                case Opcode.vgathq: goto default;

                case Opcode.addg2: goto default;

                case Opcode.addg3: goto default;

                case Opcode.divg2: goto default;

                case Opcode.divg3: goto default;

                case Opcode.addh2: goto default;

                case Opcode.addh3: goto default;

                case Opcode.divh2: goto default;

                case Opcode.divh3: goto default;

                case Opcode.vstl: goto default;

                case Opcode.vscatl: goto default;

                case Opcode.vstq: goto default;

                case Opcode.vscatq: goto default;

                case Opcode.vvmull: goto default;

                case Opcode.vsmull: goto default;

                case Opcode.vvmulg: goto default;

                case Opcode.vsmulg: goto default;

                case Opcode.vvmulf: goto default;

                case Opcode.vsmulf: goto default;

                case Opcode.vvmuld: goto default;

                case Opcode.vsmuld: goto default;

                case Opcode.vsync: goto default;

                case Opcode.mtvp: goto default;

                case Opcode.vvdivg: goto default;

                case Opcode.vsdivg: goto default;

                case Opcode.vvdivf: goto default;

                case Opcode.vsdivf: goto default;

                case Opcode.vvdivd: goto default;

                case Opcode.vsdivd: goto default;

                case Opcode.vvaddl: goto default;

                case Opcode.vsaddl: goto default;

                case Opcode.vvaddg: goto default;

                case Opcode.vsaddg: goto default;

                case Opcode.vvaddf: goto default;

                case Opcode.vsaddf: goto default;

                case Opcode.vvaddd: goto default;

                case Opcode.vsaddd: goto default;

                case Opcode.vvsubl: goto default;

                case Opcode.vssubl: goto default;

                case Opcode.vvsubg: goto default;

                case Opcode.vssubg: goto default;

                case Opcode.vvsubf: goto default;

                case Opcode.vssubf: goto default;

                case Opcode.vvsubd: goto default;

                case Opcode.vssubd: goto default;

                case Opcode.vvcmpl: goto default;

                case Opcode.vvsrll: goto default;

                case Opcode.vscmpl: goto default;

                case Opcode.vssrll: goto default;

                case Opcode.vvcmpg: goto default;

                case Opcode.vscmpg: goto default;

                case Opcode.vvcmpf: goto default;

                case Opcode.vvslll: goto default;

                case Opcode.vscmpf: goto default;

                case Opcode.vsslll: goto default;

                case Opcode.vvcmpd: goto default;

                case Opcode.vscmpd: goto default;

                case Opcode.vvbisl: goto default;

                case Opcode.vvxorl: goto default;

                case Opcode.vsbisl: goto default;

                case Opcode.vsxorl: goto default;

                case Opcode.vvbicl: goto default;

                case Opcode.vvcvt: goto default;

                case Opcode.vsbicl: goto default;

                case Opcode.iota: goto default;

                case Opcode.vvmerge: goto default;

                case Opcode.vsmerge: goto default;

                case Opcode.bugl: goto default;

                case Opcode.bugw: goto default;
                }
                yield return(new RtlInstructionCluster(
                                 addr,
                                 len,
                                 rtlInstructions.ToArray())
                {
                    Class = rtlc
                });
            }
        }