Пример #1
0
 public Avr32Rewriter(Avr32Architecture arch, EndianImageReader rdr, ProcessorState state, IStorageBinder binder, IRewriterHost host)
 {
     this.arch   = arch;
     this.rdr    = rdr;
     this.state  = state;
     this.binder = binder;
     this.host   = host;
     this.dasm   = new Avr32Disassembler(arch, rdr).GetEnumerator();
     this.instr  = null !;
     this.m      = null !;
 }
Пример #2
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));
            }
        }