コード例 #1
0
        private void HandleLoadVar(XILSInstr xilsi)
        {
            var bb        = _cfg.GetBasicBlockContaining(xilsi.Index);
            var lastStore = bb.Range
                            .Take(xilsi.Index - bb.StartIndex)
                            .Where(
                i => i.Name == InstructionCodes.StoreVar &&
                i.StaticOperand.Equals(xilsi.StaticOperand))
                            .LastOrDefault();

            if (lastStore == null)
            {
                Emit(xilsi);
            }
            else
            {
                var preds = xilsi.Preds.Union(
                    new OrderDependency[] { new OrderDependency(lastStore.Index, OrderDependency.EKind.BeginAfter) })
                            .ToArray();
                Emit(xilsi.Command.CreateStk(preds, xilsi.OperandTypes, xilsi.ResultTypes));
            }
        }
コード例 #2
0
        private void Init()
        {
            int numInstrs = _func.Instructions.Length;

            _predsBack = new ScheduleDependency <XIL3Instr> [numInstrs][];
            _succsBack = new ScheduleDependency <XIL3Instr> [numInstrs][];
            var tmp         = new List <ScheduleDependency <XIL3Instr> > [numInstrs];
            var rslot2instr = new Dictionary <int, XIL3Instr>();

            foreach (XIL3Instr i in _func.Instructions)
            {
                foreach (int rslot in i.ResultSlots)
                {
                    rslot2instr[rslot] = i;
                }
                var bb = _cfg.GetBasicBlockContaining(i.Index);
                _predsBack[i.Index] = i.Preds
                                      .Select(p => ToScheduleDependency(i, p))
                                      .Concat(i.OperandSlots.Select(s =>
                                                                    new ScheduleDependency <XIL3Instr>(
                                                                        rslot2instr[s],
                                                                        Latency[rslot2instr[s]],
                                                                        int.MaxValue)))
                                      .Distinct()
                                      .Where(_ => bb.Contains(_.Task)) // only admit predecessors from same basic block
                                      .ToArray();
                tmp[i.Index] = new List <ScheduleDependency <XIL3Instr> >();
            }
            foreach (XIL3Instr i in _func.Instructions)
            {
                foreach (var sdep in _predsBack[i.Index])
                {
                    tmp[sdep.Task.Index].Add(new ScheduleDependency <XIL3Instr>(i, sdep.MinDelay, sdep.MaxDelay));
                }
            }
            foreach (XIL3Instr i in _func.Instructions)
            {
                _succsBack[i.Index] = tmp[i.Index].ToArray();
            }
            _preds = PropMaps.CreateForArray <XIL3Instr, ScheduleDependency <XIL3Instr>[]>(_predsBack, i => i.Index, EAccess.ReadOnly);
            _succs = PropMaps.CreateForArray <XIL3Instr, ScheduleDependency <XIL3Instr>[]>(_succsBack, i => i.Index, EAccess.ReadOnly);
        }
コード例 #3
0
        protected override void ProcessInstruction(XILSInstr i)
        {
            var bb = _cfg.GetBasicBlockContaining(i.Index);

            if (bb.StartIndex != _lastBB)
            {
                _lastBB = bb.StartIndex;
                Flush();
            }
            InstrQueue iq;
            var        inew = i;

            if (_seqQs.TryGetValue(i.Name, out iq))
            {
                if (iq.OldestInstr != null)
                {
                    var newPreds = RemapPreds(i.Preds).Union(new InstructionDependency[] {
                        new OrderDependency(iq.OldestInstr.Index, OrderDependency.EKind.BeginAfter)
                    }).ToArray();
                    inew = new XILSInstr(i.Command, newPreds, i.OperandTypes, i.ResultTypes);
                    Emit(inew);
                }
                else
                {
                    base.ProcessInstruction(inew);
                }
                var nop = DefaultInstructionSet.Instance.Nop(1).CreateStk(RemapPreds(new InstructionDependency[] {
                    new OrderDependency(i.Index, OrderDependency.EKind.BeginAfter)
                }), 0);
                Emit(nop);
                iq.Enqueue(nop);
            }
            else
            {
                base.ProcessInstruction(inew);
            }
        }