/// <summary> /// Decodes and emits the given R-format instruction /// </summary> /// <param name="index">The index of the instruction</param> /// <param name="instructionData">The instruction data</param> /// <param name="generatorData">The method generator data</param> /// <param name="emiter">The executor</param> private void DecodeAndEmitRFormat(int index, int instructionData, MethodGeneratorData generatorData, InstructionEmiter emiter) { //Decode it RFormatInstruction instruction = RFormatInstruction.Decode(instructionData); //Find the R-format emiter RFormatInstructionEmiter opxEmiter = null; //Check if maskers exists if (emiter.RFormatOpxMaskers.Count == 0) { if (emiter.RFormatInstructionEmiters.TryGetValue(instruction.OpxCode, out opxEmiter)) { opxEmiter(index, instruction, generatorData); } } else { //Loop until an executor is found foreach (int currentMask in emiter.RFormatOpxMaskers) { int opxCode = instruction.OpxCode & currentMask; if (emiter.RFormatInstructionEmiters.TryGetValue(opxCode, out opxEmiter)) { opxEmiter(index, instruction, generatorData); break; } } } }
/// <summary> /// Adds the given R-format emiter to the list of instruction emiter /// </summary> /// <param name="opCode">The op code</param> /// <param name="opxCode">The opx code</param> /// <param name="emiter">The emiter</param> /// <param name="opxMask">The opx mask</param> public void AddRFormatEmiter(OperationCodes opCode, int opxCode, RFormatInstructionEmiter emiter, int opxMask = -1) { InstructionEmiter newEmiter = null; //Check if an emiter exist if (this.instructionEmiters.ContainsKey(opCode)) { //Get it newEmiter = this.instructionEmiters[opCode]; } else { //Create an new one newEmiter = new InstructionEmiter() { InstructionFormat = InstructionFormat.RFormat, RFormatInstructionEmiters = new Dictionary <int, RFormatInstructionEmiter>(), RFormatOpxMaskers = new List <int>() }; this.instructionEmiters.Add(opCode, newEmiter); } //Check if an opx code emiter exists if (!newEmiter.RFormatInstructionEmiters.ContainsKey(opxCode)) { newEmiter.RFormatInstructionEmiters.Add(opxCode, emiter); if (opxMask != -1) { newEmiter.RFormatOpxMaskers.Add(opxMask); } } }