This is an archive of the discontinued LLVM Phabricator instance.

[x86/asm] Let EmitMSInlineAsmStr() handle variants too
ClosedPublic

Authored by thakis on Nov 15 2021, 12:33 PM.

Details

Summary

This is preparation for D113707, where I want to make -masm=intel
emit asm inteldialect instructions.

{movq %rbx, %rax|mov rax, rbx} is supposed to evaluate to the bit
between { and | for att and to the bit between | and } for intel.
Since intel will become asm inteldialect, which alls EmitMSInlineAsmStr(),
EmitMSInlineAsmStr() has to support variants as well.

(clang translates {...|...} to $(...$|...$). I'm not sure why
it doesn't just send along only the first ... or the second ...
to LLVM, but given the notes in PR23933 let's not do a big
reorganization in this codepath.)

This makes EmitMSInlineAsmStr() and EmitGCCInlineAsmStr()
even more alike.

Diff Detail

Event Timeline

thakis created this revision.Nov 15 2021, 12:33 PM
thakis requested review of this revision.Nov 15 2021, 12:33 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 15 2021, 12:33 PM
thakis updated this revision to Diff 387417.Nov 15 2021, 3:15 PM

clang-format

hans accepted this revision.Nov 17 2021, 6:12 AM

lgtm

At what point does EmitGCCInlineAsmStr and EmitMSInlineAsmStr become similar enough that they could just take the desired variant as a parameter?

llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
141

Maybe this should be const?

This revision is now accepted and ready to land.Nov 17 2021, 6:12 AM

lgtm

At what point does EmitGCCInlineAsmStr and EmitMSInlineAsmStr become similar enough that they could just take the desired variant as a parameter?

That's an excellent question. I think we (I) should merge them again. Some of the remaining differences might be more bugs. I'll look into this.

This revision was automatically updated to reflect the committed changes.