[PATCH] D131352: [LoongArch] Add codegen support for bswap
Lu Weining via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 7 18:59:45 PDT 2022
SixWeining added inline comments.
================
Comment at: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp:68
+ // LA32 does not natively support any of the bswap ops.
+ if (Subtarget.is64Bit()) {
----------------
As [[ https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-Vol1-EN/basic-integer-instructions/overview-of-basic-integer-instructions.adoc#overview-of-basic-integer-instructions | Table 1 ]] described, `revb.2h` is available on LA32.
So for `i16`, we can use it.
================
Comment at: llvm/test/CodeGen/LoongArch/bswap.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=loongarch32 -verify-machineinstrs < %s \
+; RUN: | FileCheck %s -check-prefix=LA32
----------------
The standard way is to use two dashes.
```
llc --help | grep mtriple
--mtriple=<string> - Override target triple for module
```
And ` --verify-machineinstrs`:
```
llc --help-hidden | grep verify-machineinstrs
--verify-machineinstrs - Verify generated machine code
```
And `--check-prefix`:
```
FileCheck --help | grep check-prefix
--check-prefix=<string> - Prefix to use from check file (defaults to 'CHECK')
```
================
Comment at: llvm/test/CodeGen/LoongArch/bswap.ll:33-39
+; LA32-NEXT: srli.w $a1, $a0, 16
+; LA32-NEXT: srli.w $a2, $a0, 24
+; LA32-NEXT: bstrins.w $a2, $a1, 15, 8
+; LA32-NEXT: bstrpick.w $a1, $a0, 23, 8
+; LA32-NEXT: slli.w $a0, $a0, 24
+; LA32-NEXT: bstrins.w $a0, $a1, 23, 16
+; LA32-NEXT: or $a0, $a0, $a2
----------------
How about:
```
revb.2h $a0, $a0
rotri.w $a0, 16
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131352/new/
https://reviews.llvm.org/D131352
More information about the llvm-commits
mailing list