Ejemplo n.º 1
0
        // Process a instruction dependency
        private void ProcessInsnDependency(string[] cols)
        {
            ulong id   = ulong.Parse(cols[1]);
            Insn  insn = GetAliveInsn(id);

            if (insn == null)
            {
                m_errors.Add(string.Format("Dpendencies of an unknown instruction ({0}) are dumped at line {1}.", id, m_currentLine));
                return;
            }

            Insn.Relation rel = new Insn.Relation();
            rel.id = ulong.Parse(cols[2]);

            if (cols.Length > 3)
            {
                rel.type = int.Parse(cols[3]);
            }
            else
            {
                rel.type = 0;                   // wakeup
            }

            insn.AddProducer(rel);
        }
Ejemplo n.º 2
0
        // loader からデータを読みだして配列を作成、MainForm::insnsに置き換え
        // この時AddConsumerしている
        private void LoadInsns()
        {
            if (loader == null)
            {
                return;
            }


            coordinateSystem.SetInsnRange(loginfo.MinInsnId, loginfo.MaxInsnId);
            insns            = new Insn[coordinateSystem.ViewInsnCount];
            dependencyRanges = new DependencyRange[coordinateSystem.ViewInsnCount];

            long  cycleFrom = long.MaxValue;
            long  cycleTo   = long.MinValue;
            ulong idFrom    = coordinateSystem.IdFrom;
            ulong idTo      = coordinateSystem.IdTo;

            for (ulong id = idFrom; id <= idTo; id++)
            {
                Insn insn = null;

                try
                {
                    //insn = db.Read(id);
                    insn = loader.GetInsnFromDB(id);
                }
                catch (ArgumentOutOfRangeException)
                {
                    insn = null;
                }
                insns[id - idFrom]            = insn;
                dependencyRanges[id - idFrom] = new DependencyRange(id, id);
                if (insn == null)
                {
                    continue;
                }
                if (cycleFrom > insn.StartCycle)
                {
                    cycleFrom = insn.StartCycle;
                }
                if (cycleTo < insn.EndCycle)
                {
                    cycleTo = insn.EndCycle;
                }
            }

            if (cycleFrom == long.MaxValue)
            {
                cycleTo = cycleFrom = 0;
            }

            coordinateSystem.SetCycleRange(cycleFrom, cycleTo);

            // Extract dependencies.
            foreach (Insn consinsn in insns)
            {
                if (consinsn == null)
                {
                    continue;
                }

                foreach (Insn.Relation r in consinsn.Producers)
                {
                    Insn prodinsn = GetInsn(r.id);
                    if (prodinsn != null)
                    {
                        Insn.Relation rel = new Insn.Relation();
                        rel.id   = consinsn.Id;
                        rel.type = r.type;
                        prodinsn.AddConsumer(rel);

                        // i を横切る依存関係のうち最大と最小の範囲を登録
                        ulong front = Math.Min(r.id, consinsn.Id);
                        ulong back  = Math.Max(r.id, consinsn.Id);
                        for (ulong i = front; i <= back; i++)
                        {
                            dependencyRanges[i - idFrom].SetRange(front, back);
                        }
                    }
                }
            }

            // Extract execution stages.
            // Stage names including "X" are regarded as execution stages.
            for (int i = 0; i < loginfo.SegmentCount; ++i)
            {
                foreach (var stageName in loginfo.StageNames[i])
                {
                    if (stageName.Contains("X"))
                    {
                        int id = loginfo.GetStageId(i, stageName);
                        if (id >= 0)
                        {
                            ExecStageInfo info;
                            info.lane = i;
                            info.id   = id;
                            ExecStageId.Add(info);
                        }
                    }
                }
            }
        }