public PerformanceStore(string path) { this._data = new List <PerformanceItem>(); if (Settings.Default.PerformanceInfo_On) { MicroArch selectedMicroarchitures = AsmDudeToolsStatic.Get_MicroArch_Switched_On(); if (selectedMicroarchitures != MicroArch.NONE) { var translations = this.Load_Instruction_Translation(path + "Instructions-Translations.tsv"); if (selectedMicroarchitures.HasFlag(MicroArch.IvyBridge)) { this.AddData(MicroArch.IvyBridge, path + "IvyBridge.tsv", translations); } if (selectedMicroarchitures.HasFlag(MicroArch.Haswell)) { this.AddData(MicroArch.Haswell, path + "Haswell.tsv", translations); } if (selectedMicroarchitures.HasFlag(MicroArch.Broadwell)) { this.AddData(MicroArch.Broadwell, path + "Broadwell.tsv", translations); } if (selectedMicroarchitures.HasFlag(MicroArch.Skylake)) { this.AddData(MicroArch.Skylake, path + "Skylake.tsv", translations); } if (selectedMicroarchitures.HasFlag(MicroArch.SkylakeX)) { this.AddData(MicroArch.SkylakeX, path + "SkylakeX.tsv", translations); } } } }
public void AddData(MicroArch microArch, string filename) { AsmDudeToolsStatic.Output_INFO("PerformanceStore:AddData: microArch=" + microArch + "; filename=" + filename); try { System.IO.StreamReader file = new System.IO.StreamReader(filename); string line; while ((line = file.ReadLine()) != null) { if ((line.Trim().Length > 0) && (!line.StartsWith(";"))) { string[] columns = line.Split('\t'); if (columns.Length == 5) { { // handle instruction foreach (string mnemonicStr in columns[0].Split(' ')) { if (mnemonicStr.Length > 0) { Mnemonic mnemonic = AsmSourceTools.ParseMnemonic(mnemonicStr); if (mnemonic == Mnemonic.UNKNOWN) { AsmDudeToolsStatic.Output_WARNING("PerformanceStore:LoadData: microArch=" + microArch + ": unknown mnemonic " + mnemonicStr + " in line: " + line); } else { PerformanceItem item = new PerformanceItem(); item._microArch = microArch; item._instr = mnemonic; item._args = columns[1]; item._latency = columns[2]; item._throughput = columns[3]; item._remark = columns[4]; this._data.Add(item); } } } } } else { AsmDudeToolsStatic.Output_WARNING("PerformanceStore:AddData: found " + columns.Length + " columns; funky line" + line); } } } file.Close(); } catch (FileNotFoundException) { AsmDudeToolsStatic.Output_ERROR("PerformanceStore:LoadData: could not find file \"" + filename + "\"."); } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR("PerformanceStore:LoadData: error while reading file \"" + filename + "\"." + e); } }
public void SetPerformanceInfo(Mnemonic mnemonic, AsmDudeTools asmDudeTools) { if (Settings.Default.PerformanceInfo_On) { this.PerformanceExpander.IsExpanded = !Settings.Default.PerformanceInfo_IsDefaultCollapsed; bool empty = true; bool first = true; FontFamily family = new FontFamily("Consolas"); string format = "{0,-14}{1,-24}{2,-7}{3,-9}{4,-20}{5,-9}{6,-11}{7,-10}"; MicroArch selectedMicroarchitures = AsmDudeToolsStatic.Get_MicroArch_Switched_On(); foreach (PerformanceItem item in asmDudeTools.Performance_Store.GetPerformance(mnemonic, selectedMicroarchitures)) { empty = false; if (first) { first = false; this.Performance.Inlines.Add(new Run(string.Format( format, string.Empty, string.Empty, "µOps", "µOps", "µOps", string.Empty, string.Empty, string.Empty)) { FontFamily = family, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Bold, Foreground = this._foreground, }); this.Performance.Inlines.Add(new Run(string.Format( "\n" + format, "Architecture", "Instruction", "Fused", "Unfused", "Port", "Latency", "Throughput", string.Empty)) { FontFamily = family, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Bold, Foreground = this._foreground, }); } this.Performance.Inlines.Add(new Run(string.Format( "\n" + format, item._microArch + " ", item._instr + " " + item._args + " ", item._mu_Ops_Fused + " ", item._mu_Ops_Merged + " ", item._mu_Ops_Port + " ", item._latency + " ", item._throughput + " ", item._remark)) { FontFamily = family, Foreground = this._foreground, }); } this.PerformanceExpander.Visibility = empty ? Visibility.Collapsed : Visibility.Visible; this.PerformanceBorder.Visibility = empty ? Visibility.Collapsed : Visibility.Visible; } }
public IEnumerable <PerformanceItem> GetPerformance(Mnemonic mnemonic, MicroArch selectedArchitectures) { foreach (PerformanceItem item in this._data) { if ((item._instr == mnemonic) && selectedArchitectures.HasFlag(item._microArch)) { yield return(item); } } }
public IReadOnlyList <PerformanceItem> GetPerformance(Mnemonic mnemonic, MicroArch selectedArchitectures) { List <PerformanceItem> result = new List <PerformanceItem>(); foreach (PerformanceItem item in this._data) { if ((item._instr == mnemonic) && selectedArchitectures.HasFlag(item._microArch)) { result.Add(item); } } if (result.Count == 0) { AsmDudeToolsStatic.Output_INFO("PerformanceStore:GetPerformance: mnemonic " + mnemonic + " has no performance info"); } return(result.AsReadOnly()); }
private void AddData(MicroArch microArch, string filename, IDictionary <string, IList <Mnemonic> > translations) { //AsmDudeToolsStatic.Output_INFO("PerformanceStore:AddData_New: microArch=" + microArch + "; filename=" + filename); try { StreamReader file = new StreamReader(filename); string line; int lineNumber = 0; while ((line = file.ReadLine()) != null) { if ((line.Trim().Length > 0) && (!line.StartsWith(";"))) { string[] columns = line.Split('\t'); if (columns.Length == 8) { { // handle instruction string mnemonicKey = columns[0].Trim(); if (!translations.TryGetValue(mnemonicKey, out IList <Mnemonic> mnemonics)) { mnemonics = new List <Mnemonic>(); foreach (string mnemonicStr in mnemonicKey.Split(' ')) { Mnemonic mnemonic = AsmSourceTools.ParseMnemonic(mnemonicStr); if (mnemonic == Mnemonic.NONE) { // check if the mnemonicStr can be translated to a list of mnemonics if (translations.TryGetValue(mnemonicStr, out IList <Mnemonic> mnemonics2)) { foreach (Mnemonic m in mnemonics2) { mnemonics.Add(m); } } else { AsmDudeToolsStatic.Output_WARNING("PerformanceStore:AddData: microArch=" + microArch + ": unknown mnemonic " + mnemonicStr + " in line " + lineNumber + " with content \"" + line + "\"."); } } else { mnemonics.Add(mnemonic); } } } foreach (Mnemonic m in mnemonics) { this._data.Add(new PerformanceItem() { _microArch = microArch, _instr = m, _args = columns[1], _mu_Ops_Fused = columns[2], _mu_Ops_Merged = columns[3], _mu_Ops_Port = columns[4], _latency = columns[5], _throughput = columns[6], _remark = columns[7] }); } } } else { AsmDudeToolsStatic.Output_WARNING("PerformanceStore:AddData: found " + columns.Length + " columns; funky line" + line); } } lineNumber++; } file.Close(); } catch (FileNotFoundException) { AsmDudeToolsStatic.Output_ERROR("PerformanceStore:LoadData: could not find file \"" + filename + "\"."); } catch (Exception e) { AsmDudeToolsStatic.Output_ERROR("PerformanceStore:LoadData: error while reading file \"" + filename + "\"." + e); } }
/// <summary> /// Determine which pieces of Quickinfo content should be displayed /// </summary> public void AugmentQuickInfoSession(IQuickInfoSession session, IList <object> quickInfoContent, out ITrackingSpan applicableToSpan) { //AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession"); applicableToSpan = null; try { DateTime time1 = DateTime.Now; ITextSnapshot snapshot = this._sourceBuffer.CurrentSnapshot; var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot); if (triggerPoint == null) { AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: trigger point is null"); return; } string keyword = ""; IEnumerable <IMappingTagSpan <AsmTokenTag> > enumerator = this._aggregator.GetTags(new SnapshotSpan(triggerPoint, triggerPoint)); //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: enumerator.Count="+ enumerator.Count()); if (enumerator.Count() > 0) { if (false) { // TODO: multiple tags at the provided triggerPoint is most likely the result of a bug in AsmTokenTagger, but it seems harmless... if (enumerator.Count() > 1) { foreach (IMappingTagSpan <AsmTokenTag> v in enumerator) { AsmDudeToolsStatic.Output(string.Format("WARNING: {0}:AugmentQuickInfoSession. more than one tag! \"{1}\"", ToString(), v.Span.GetSpans(this._sourceBuffer).First().GetText())); } } } IMappingTagSpan <AsmTokenTag> asmTokenTag = enumerator.First(); SnapshotSpan tagSpan = asmTokenTag.Span.GetSpans(this._sourceBuffer).First(); keyword = tagSpan.GetText(); int lineNumber = tagSpan.Snapshot.GetLineNumberFromPosition(tagSpan.Start); //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: keyword=\""+ keyword + "\"; type=" + asmTokenTag.Tag.type +"; file="+AsmDudeToolsStatic.GetFileName(session.TextView.TextBuffer)); string keywordUpper = keyword.ToUpper(); applicableToSpan = snapshot.CreateTrackingSpan(tagSpan, SpanTrackingMode.EdgeExclusive); TextBlock description = null; switch (asmTokenTag.Tag.Type) { case AsmTokenType.Misc: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Keyword ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Misc)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Directive: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Directive ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Directive)))); string descr = this._asmDudeTools.Get_Description(keywordUpper); if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Register: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Register ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Register)))); string register_Descr = this._asmDudeTools.Get_Description(keywordUpper); if (register_Descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + register_Descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } if (this._asmSimulator.Is_Enabled) { IState_R state = this._asmSimulator.GetState(lineNumber, true); string msg = this._asmSimulator.GetRegisterValue(RegisterTools.ParseRn(keyword), state); if (msg.Length == 0) { msg = "Calculating register content"; } description.Inlines.Add(new Run(AsmSourceTools.Linewrap("\n" + msg, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Mnemonic: case AsmTokenType.Jump: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Mnemonic ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Opcode)))); Mnemonic mmemonic = AsmSourceTools.ParseMnemonic(keywordUpper); { string archStr = ":" + ArchTools.ToString(this._asmDudeTools.Mnemonic_Store.GetArch(mmemonic)) + " "; string descr = this._asmDudeTools.Mnemonic_Store.GetDescription(mmemonic); description.Inlines.Add(new Run(AsmSourceTools.Linewrap(archStr + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } { // show performance information MicroArch selectedMicroarchitures = AsmDudeToolsStatic.Get_MicroArch_Switched_On(); IReadOnlyList <PerformanceItem> performanceData = this._asmDudeTools.Performance_Store.GetPerformance(mmemonic, selectedMicroarchitures); if (performanceData.Count > 0) { FontFamily family = new FontFamily("Consolas"); IList <Run> list = new List <Run>(); description.Inlines.Add(new Run(string.Format("\n\n{0,-15}{1,-24}{2,-10}{3,-10}\n", "Architecture", "Instruction", "Latency", "Throughput")) { FontFamily = family, FontStyle = FontStyles.Italic, FontWeight = FontWeights.Bold, Foreground = this._foreground }); foreach (PerformanceItem item in performanceData) { description.Inlines.Add(new Run(string.Format("{0,-15}{1,-24}{2,-10}{3,-10}{4,-10}\n", item._microArch, item._instr + " " + item._args, item._latency, item._throughput, item._remark)) { FontFamily = family, Foreground = this._foreground }); } } } break; } case AsmTokenType.Label: { string label = keyword; string labelPrefix = asmTokenTag.Tag.Misc; string full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(labelPrefix, label, AsmDudeToolsStatic.Used_Assembler); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", this._foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Description(full_Qualified_Label); if (descr.Length == 0) { descr = Get_Label_Description(label); } if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.LabelDef: { string label = keyword; string extra_Tag_Info = asmTokenTag.Tag.Misc; string full_Qualified_Label; if ((extra_Tag_Info != null) && extra_Tag_Info.Equals(AsmTokenTag.MISC_KEYWORD_PROTO)) { full_Qualified_Label = label; } else { full_Qualified_Label = AsmDudeToolsStatic.Make_Full_Qualified_Label(extra_Tag_Info, label, AsmDudeToolsStatic.Used_Assembler); } AsmDudeToolsStatic.Output_INFO("AsmQuickInfoSource:AugmentQuickInfoSession: found label def " + full_Qualified_Label); description = new TextBlock(); description.Inlines.Add(Make_Run1("Label ", this._foreground)); description.Inlines.Add(Make_Run2(full_Qualified_Label, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Label)))); string descr = Get_Label_Def_Description(full_Qualified_Label, label); if (descr.Length > 0) { description.Inlines.Add(new Run(AsmSourceTools.Linewrap(": " + descr, AsmDudePackage.maxNumberOfCharsInToolTips)) { Foreground = this._foreground }); } break; } case AsmTokenType.Constant: { description = new TextBlock(); description.Inlines.Add(Make_Run1("Constant ", this._foreground)); description.Inlines.Add(Make_Run2(keyword, new SolidColorBrush(AsmDudeToolsStatic.ConvertColor(Settings.Default.SyntaxHighlighting_Constant)))); break; } default: //description = new TextBlock(); //description.Inlines.Add(makeRun1("Unused tagType " + asmTokenTag.Tag.type)); break; } if (description != null) { description.FontSize = AsmDudeToolsStatic.Get_Font_Size() + 2; description.FontFamily = AsmDudeToolsStatic.Get_Font_Type(); //AsmDudeToolsStatic.Output(string.Format("INFO: {0}:AugmentQuickInfoSession; setting description fontSize={1}; fontFamily={2}", this.ToString(), description.FontSize, description.FontFamily)); quickInfoContent.Add(description); } } //AsmDudeToolsStatic.Output("INFO: AsmQuickInfoSource:AugmentQuickInfoSession: applicableToSpan=\"" + applicableToSpan + "\"; quickInfoContent,Count=" + quickInfoContent.Count); AsmDudeToolsStatic.Print_Speed_Warning(time1, "QuickInfo"); } catch (Exception e) { AsmDudeToolsStatic.Output(string.Format("ERROR: {0}:AugmentQuickInfoSession; e={1}", ToString(), e.ToString())); } }