private ScheduleDependency <XIL3Instr> ToScheduleDependency(XIL3Instr instr, InstructionDependency dep)
        {
            var predInstr = _func.Instructions[dep.PredIndex];
            var odep      = dep as OrderDependency;
            var tdep      = dep as TimeDependency;

            if (odep != null)
            {
                switch (odep.Kind)
                {
                case OrderDependency.EKind.BeginAfter:
                    return(new ScheduleDependency <XIL3Instr>(predInstr, Latency[predInstr], int.MaxValue));

                case OrderDependency.EKind.CompleteAfter:
                    return(new ScheduleDependency <XIL3Instr>(predInstr, Latency[predInstr] - Latency[instr], int.MaxValue));

                default:
                    throw new NotImplementedException();
                }
            }
            else if (tdep != null)
            {
                return(new ScheduleDependency <XIL3Instr>(predInstr, tdep.MinDelay, tdep.MaxDelay));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
Example #2
0
        public void VisitFieldRef(FieldRef fieldRef)
        {
            InstructionDependency[] preds;
            switch (_litMode)
            {
            case ELiteralAcceptMode.Read:
                preds = _storesInCurBB.Get(fieldRef)
                        .Select(_ => new OrderDependency(_, OrderDependency.EKind.BeginAfter))
                        .ToArray();
                _readsInCurBB.Add(fieldRef, NextInstructionIndex);
                Emit(ISet.LoadVar(fieldRef), _curExpr, preds, 0, fieldRef.Type);
                break;

            case ELiteralAcceptMode.Write:
            {
                preds = _storesInCurBB.Get(fieldRef)
                        .Union(_readsInCurBB.Get(fieldRef))
                        .Select(_ => new OrderDependency(_, OrderDependency.EKind.BeginAfter))
                        .ToArray();
                if (preds.Any())
                {
                    int idx = NextInstructionIndex;
                    Emit(DefaultInstructionSet.Instance.Nop(0), _curExpr, preds, 0);
                    preds = new InstructionDependency[] { new OrderDependency(idx, OrderDependency.EKind.BeginAfter) };
                }
                _storesInCurBB.Add(fieldRef, NextInstructionIndex);
                Emit(ISet.StoreVar(fieldRef), _curExpr, preds, 1);
            }
            break;
            }
        }
Example #3
0
        private void HandleStoreVar(XILSInstr i)
        {
            int      readPoint;
            Variable local = i.StaticOperand as Variable;

            if (DflowAnalyzer.IsReadAfterWrite(i.Index, out readPoint))
            {
                var preds = RemapPreds(i.Preds);

                // keep expression on the stack, but bury it at the very bottom.
                for (int j = 1; j < _resultStack.Count; j++)
                {
                    var resultTypes = TypeStack.Reverse().Skip(1).Concat(TypeStack.Skip(_resultStack.Count - 1)).ToArray();
                    Emit(DefaultInstructionSet.Instance.Dig(_resultStack.Count - 1).CreateStk(
                             preds,
                             TypeStack.Reverse().ToArray(),
                             resultTypes));
                    preds = new InstructionDependency[0];
                }
                _read2write[readPoint] = _resultStack[0];
            }
            else if (local == null)
            {
                ProcessDefault(i);
            }
            else if (DflowAnalyzer.EliminableLocals.Contains(local.LocalIndex))
            {
                Emit(DefaultInstructionSet.Instance.Pop().CreateStk(1, local.Type));
            }
            else
            {
                ProcessDefault(i);
            }
        }
Example #4
0
        public void VisitVariable(Variable variable)
        {
            if (variable.Type.HasIntrinsicTypeOverride &&
                variable.Type.IntrinsicTypeOverride == EIntrinsicTypes.Tuple)
            {
                var itemVars = Unpick(variable);
                foreach (var itemVar in itemVars.Reverse())
                {
                    VisitVariable(itemVar);
                }
            }
            else
            {
                InstructionDependency[] preds;
                switch (_litMode)
                {
                case ELiteralAcceptMode.Read:
                    preds = _storesInCurBB.Get(variable).Select(
                        _ => new OrderDependency(_, OrderDependency.EKind.BeginAfter)).ToArray();
                    _readsInCurBB.Add(variable, NextInstructionIndex);
                    Emit(ISet.LoadVar(variable), _curExpr, preds, 0, variable.Type);
                    break;

                case ELiteralAcceptMode.Write:
                {
                    preds = _storesInCurBB.Get(variable)
                            .Union(_readsInCurBB.Get(variable))
                            .Select(_ => new OrderDependency(_, OrderDependency.EKind.BeginAfter))
                            .ToArray();
                    if (preds.Any())
                    {
                        int idx = NextInstructionIndex;
                        Emit(DefaultInstructionSet.Instance.Nop(0), _curExpr, preds, 0);
                        preds = new InstructionDependency[] { new OrderDependency(idx, OrderDependency.EKind.BeginAfter) };
                    }
                    _storesInCurBB.Add(variable, NextInstructionIndex);
                    Debug.Assert(variable.Type.Equals(_typeStack.Peek()));
                    Emit(ISet.StoreVar(variable), _curExpr, preds, 1);
                }
                break;
                }
            }
        }