This is an archive of the discontinued LLVM Phabricator instance.

[LoongArch] Add definition for LSX instructions
ClosedPublic

Authored by wangleiat on Jun 29 2023, 10:05 PM.

Details

Summary

This patch adds the definition for the LSX registers and instructions.
It also adds handling for new immediate operands in the AsmParser. This
patch ensures that llvm-mc and llvm-objdump correctly handle the LSX
instructions.

We expand those pseudo-instructions vrepli.{b,h,w,d} in the
MCCodeEmitter. This increases the readability of the output when
generating assembly files.

Diff Detail

Event Timeline

wangleiat created this revision.Jun 29 2023, 10:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2023, 10:05 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
wangleiat requested review of this revision.Jun 29 2023, 10:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 29 2023, 10:05 PM

There will be separate test patches in the future.

wangleiat added a subscriber: leecheechen.
xen0n added inline comments.Jun 29 2023, 10:19 PM
llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
275

This may have to become generic when we add xvldi later, so I'd recommend adding a template argument for substituting the LoongArch::VLDI at call site. Doing so will also let the name make sense because there isn't a ldi per se. (You may also name this expandToVectorLDI or expandVectorREPLI instead for maximum clarity.)

wangleiat added inline comments.Jun 29 2023, 10:39 PM
llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMCCodeEmitter.cpp
275

This may have to become generic when we add xvldi later, so I'd recommend adding a template argument for substituting the LoongArch::VLDI at call site. Doing so will also let the name make sense because there isn't a ldi per se. (You may also name this expandToVectorLDI or expandVectorREPLI instead for maximum clarity.)

Thank you very much for your feedback and great suggestions. I will make the necessary changes right away.

Address @xen0n's comments.

wangleiat updated this revision to Diff 536650.Jul 2 2023, 8:08 PM

specify instruction properties.

SixWeining accepted this revision.Jul 6 2023, 4:30 AM
This revision is now accepted and ready to land.Jul 6 2023, 4:30 AM
This revision was automatically updated to reflect the committed changes.