Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm] Adopt WithMarkup in the MIPS backend #65384

Merged
merged 1 commit into from
Sep 6, 2023

Conversation

JDevlieghere
Copy link
Member

Adopt the new markup overload, introduced in 77d1032, in the MIPS backend.

Adopt the new markup overload, introduced in 77d1032, in the MIPS
backend.
@@ -213,12 +213,11 @@ void MipsInstPrinter::printMemOperand(const MCInst *MI, int opNum,
break;
}

O << markup("<mem:");
WithMarkup M = markup(O, Markup::Memory);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useless here because printOperand will change the color yet again and reset it to the default before returning.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It keeps the original behavior, but if you're saying that's wrong then I'm happy to update it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I was thinking about colors and forgot about the "<mem:" part.
I don't know what the markup has beed used for and whether nested tags are allowed. I was trying to say that the memory operand will not have Memory style. Instead, it will be displayed as Immediate + Register or Register + Register (and default-style parentheses). If that's OK from lldb's point of view, I don't see other issues.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LLDB uses the ANSI escape characters for coloring, not the markup annotations so for LLDB this becomes a NOOP as you pointed out. I don't know who relies on the markup annotations but it's probably best to keep the existing behavior to avoid breaking any tools that might be relying on it.

Copy link
Contributor

@s-barannikov s-barannikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine to me as long as the memory operands are printed the way lldb wants, though I have no relation to the MIPS backend.


Here is the proposal for annotated assembly output and the initial implementation.

PS I wouldn't mind if the support for marked-up disassembly was removed in favor of colored up disassembly. I doubt that there are any tools that actually parse the markup.

Copy link
Collaborator

@dsandersllvm dsandersllvm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but as noted the WithMarkup bit isn't very clear. I think that'd be better being explicit markup()'s just like the rest

@@ -213,12 +213,11 @@ void MipsInstPrinter::printMemOperand(const MCInst *MI, int opNum,
break;
}

O << markup("<mem:");
WithMarkup M = markup(O, Markup::Memory);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with WithMarkup but I don't think it's very clear that this (I assume) affects the stream until it's destroyed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, something like make_scoped_markup would've been clearer at the cost of being more verbose. Given that most uses use operator << I decided to prioritize readability for those cases.

@JDevlieghere JDevlieghere merged commit c473215 into llvm:main Sep 6, 2023
2 checks passed
@JDevlieghere JDevlieghere deleted the mips-markup branch September 6, 2023 19:51
Guzhu-AMD pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Sep 7, 2023
Local branch amd-gfx 1b3f7c5 Merged main:ddbcc10b9e26 into amd-gfx:632a231f2ac6
Remote branch main c473215 [llvm] Adopt WithMarkup in the MIPS backend (llvm#65384)
avillega pushed a commit to avillega/llvm-project that referenced this pull request Sep 11, 2023
Adopt the new markup overload, introduced in 77d1032, in the MIPS
backend.
JDevlieghere added a commit to apple/llvm-project that referenced this pull request Sep 14, 2023
Adopt the new markup overload, introduced in 77d1032, in the MIPS
backend.

(cherry picked from commit c473215)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants