Skip to content

Commit

Permalink
Suggestion to inline rfp/rrv assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
TollyH committed Jun 1, 2024
1 parent db559a2 commit ae694ed
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions AssemblerWarnings.Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public partial class AssemblerWarnings
{ 0023, Strings_AssemblerWarnings.Suggestion_0023 },
{ 0024, Strings_AssemblerWarnings.Suggestion_0024 },
{ 0025, Strings_AssemblerWarnings.Suggestion_0025 },
{ 0026, Strings_AssemblerWarnings.Suggestion_0026 },
};

public static Dictionary<int, string> GetMessagesForSeverity(WarningSeverity severity)
Expand Down
13 changes: 13 additions & 0 deletions AssemblerWarnings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ public AssemblerWarnings(bool usingV1Format)
#endif
{ 0024, Analyzer_Rolling_Suggestion_0024 },
{ 0025, Analyzer_Rolling_Suggestion_0025 },
{ 0026, Analyzer_Rolling_Suggestion_0026 },
};

nonFatalErrorFinalAnalyzers = new Dictionary<int, FinalWarningAnalyzer>();
Expand Down Expand Up @@ -1245,6 +1246,18 @@ private bool Analyzer_Rolling_Suggestion_0025()
return newBytes.Length > 0 && consecutiveDatCount > 0 && consecutiveDatCount % 8 == 0;
}

private bool Analyzer_Rolling_Suggestion_0026()
{
// Suggestion 0026: Assignment to the rfp/rrv register can be inlined.
return newBytes.Length > 0 && lastMnemonic.Equals("MVQ", StringComparison.OrdinalIgnoreCase)
&& ((mnemonic.Equals("CAL", StringComparison.OrdinalIgnoreCase)
&& operands.Length == 1
&& lastOperands[0].Equals("rfp", StringComparison.OrdinalIgnoreCase))
|| (mnemonic.Equals("RET", StringComparison.OrdinalIgnoreCase)
&& operands.Length == 0
&& lastOperands[0].Equals("rrv", StringComparison.OrdinalIgnoreCase)));
}

#if DISPLACEMENT
[GeneratedRegex(@"\[.*(?:[0-9]?\.[0-9]|[0-9]\.[0-9]?)")]
private static partial Regex FloatingPointDisplacementRegex();
Expand Down
9 changes: 9 additions & 0 deletions Resources/Localization/Strings.AssemblerWarnings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Resources/Localization/Strings.AssemblerWarnings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,7 @@
<data name="Suggestion_0025" xml:space="preserve">
<value>Use the %NUM directive instead of 8 consecutive %DAT directives.</value>
</data>
<data name="Suggestion_0026" xml:space="preserve">
<value>Assignment to the rfp/rrv register can be inlined.</value>
</data>
</root>

0 comments on commit ae694ed

Please sign in to comment.