private void Emit(XILInstr xili, object backRef, InstructionDependency[] preds, int numOperands, params TypeDescriptor[] resultTypes) { Contract.Requires(xili != null && preds != null && numOperands >= 0 && resultTypes != null && resultTypes.All(t => t != null)); xili.BackRef = backRef; TypeDescriptor[] operandTypes = new TypeDescriptor[numOperands]; for (int i = numOperands - 1; i >= 0; i--) { operandTypes[i] = _typeStack.Pop(); } for (int i = 0; i < resultTypes.Length; i++) { _typeStack.Push(resultTypes[i]); } Emit(xili.CreateStk(preds, operandTypes, 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); }