This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Support inline asm operand modifier 'z'
ClosedPublic

Authored by SixWeining on Oct 27 2022, 5:44 AM.

Details

Summary

Print $zero register if operand is zero, otherwise print it normally.

Clang is highly compatible [1] with GCC inline assembly extensions,
allowing the same set of constraints, modifiers and operands as GCC
inline assembly. This patch tries to make it compatible regarding
LoongArch specific operand modifiers.

GCC supports many modifiers [2], but it seems that only x86 and msp430
are documented [3][4]. I don't know if any other modifiers are being
used except the 'z' in Linux [5].

[1]: https://clang.llvm.org/compatibility.html#inline-asm
[2]: https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/loongarch.cc#L4884-L4911
[3]: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#x86Operandmodifiers
[4]: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#msp430Operandmodifiers
[5]: https://github.com/torvalds/linux/blob/master/arch/loongarch/include/asm/cmpxchg.h#L17

Diff Detail

Event Timeline

SixWeining created this revision.Oct 27 2022, 5:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 5:44 AM
SixWeining requested review of this revision.Oct 27 2022, 5:44 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptOct 27 2022, 5:44 AM
xen0n accepted this revision.Oct 29 2022, 1:56 AM

Inching closer to ClangBuiltLinux on LoongArch it seems!

llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
64

nit: "if any"

This revision is now accepted and ready to land.Oct 29 2022, 1:56 AM
xen0n added a comment.Oct 29 2022, 2:05 AM

Ah. There's a typo in the name of the testcase file...

Ah. There's a typo in the name of the testcase file...

:(-

Fix testcase file name.

This revision was landed with ongoing or failed builds.Oct 30 2022, 6:59 PM
This revision was automatically updated to reflect the committed changes.

Inching closer to ClangBuiltLinux on LoongArch it seems!

Cool! Stay in touch when this is closer to working and we'll wire up support in CI to keep the build green.