/// <summary> /// The default branch handler is applied to any branching instruction when there is no more specific handler registered. /// </summary> /// <param name="i">instruction to process</param> virtual protected void ProcessBranch(XILSInstr i) { BranchLabel label = (BranchLabel)i.StaticOperand; BranchLabel newLabel = Retarget(label); XILInstr xi = new XILInstr(i.Name, newLabel); var preds = RemapPreds(i.Preds); Emit(xi.CreateStk(preds, i.OperandTypes, i.ResultTypes)); }
protected override void ProcessDefault(XILSInstr i) { XILInstr cmd = i.Command; if (cmd.Name.Equals(InstructionCodes.LdConst)) { object value = cmd.Operand; object lvalue = TypeLowering.Instance.ConvertToHardwareType(value); cmd = DefaultInstructionSet.Instance.LdConst(lvalue); } base.ProcessDefault( cmd.CreateStk( i.Preds, ReduceTypes(i.OperandTypes), ReduceTypes(i.ResultTypes))); }
/// <summary> /// Tries to map the given XIL instruction to any suitable functional unit. This call will not create any actual hardware. It is used by the /// scheduler to query basic instruction metrics, namely initiation interval and latency. /// </summary> /// <param name="instr">XIL instruction</param> /// <param name="operandTypes">operand types of XIL instruction</param> /// <param name="resultTypes">result types of XIL instruction</param> /// <param name="binder">binder service</param> /// <returns>a hardware mapping for the supplied instruction or null if no such exists</returns> public IXILMapping TryMap(XILInstr instr, TypeDescriptor[] operandTypes, TypeDescriptor[] resultTypes, IAutoBinder binder) { var xilsi = instr.CreateStk(new InstructionDependency[0], operandTypes, resultTypes); IXILMapping mapping; if (_xilMappings.TryGetValue(xilsi, out mapping)) { return mapping; } IEnumerable<IXILMapper> mappers = _xmm.LookupMappers(instr); foreach (IXILMapper mapper in mappers) { var tas = _taMapLookup.Get(mapper); foreach (var ta in tas) { var mappings = mapper.TryMap(ta, instr, operandTypes, resultTypes); if (mappings.Any()) { mapping = mappings.First(); _xilMappings[xilsi] = mapping; return mapping; } } } foreach (IXILMapper mapper in mappers) { mapping = mapper.TryAllocate(_host, instr, operandTypes, resultTypes, _targetProject); if (mapping != null) { _taMapLookup.Add(mapper, mapping.TASite); _xilMappings[xilsi] = mapping; return mapping; } } return null; }