[llvm] [RISCV][GlobalISel] Vector Extension vadd Legalizer (PR #71400)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 6 11:21:27 PST 2023


================
@@ -0,0 +1,14 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+v -stop-after=irtranslator | FileCheck %s --check-prefixes=CHECK,RV32
+; RUN: llc -mtriple=riscv64 -mattr=+v --stop-after=irtranslator | FileCheck %s --check-prefixes=CHECK,RV64
+
+define <vscale x 1 x i8> @vadd_vv_mask_nxv1i8(<vscale x 1 x i8> %va, <vscale x 1 x i8> %vb, <vscale x 1 x i1> %mask) {
----------------
michaelmaitland wrote:

I usually generate test checks using `update_mir_test_checks` or `update_llc_test_checks`. Something like this:

```
llvm/utils/update_mir_test_checks.py --llc-binary=build/bin/llc llvm/test/CodeGen/RISCV/GlobalISel/irtranslator/my-test.ll
```

In your case, the compiler may return an error when you try to use the update_test_checks scripts since you haven't implemented the functionality yet. I usually don't worry about having CHECKs before the functionality is implemented. It is a good idea to know roughly what code you want the test case to generate before you implement it. You can get an idea by seeing what SDAG does.`build/bin/llc -mtriple=riscv32 -mattr=+v mytest.ll` gives something like:

```
add_nxv1i8:
  vsetvli a0, zero, e8, mf8, ta, ma
  vadd.vv v8, v8, v9
  ret
```

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/389 has discussion on a formal ABI for RVV. The proposal is currently implemented in LLVM. I wouldn't worry too much about it in the scope of this patch since thats really the job of lowerFormalArguments and lowerReturnVal to get right.

[This](https://github.com/llvm/llvm-project/pull/69150/files#diff-71fc37c9622563fba94f20b47cf3b5e6fa5060d7a60d10b8129336e8a6398c42) PR might give you a good idea what tests should look like for a legalizer patch. It is unlikely that you will be able to add a test that goes from LLVM IR -> RISC-V ASM in this PR since other gisel-passes may need some work. For example, if you run that test case with -global-isel, you will see that it currently fails in IRTranslator to convert the LLVM add to G_ADD. Once you implement that functionality, you might see it fail in the legalizer, and once you fix that, you might see it fail in instruction-select.

https://github.com/llvm/llvm-project/pull/71400


More information about the llvm-commits mailing list