-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[RISCV][llvm] Support fixed-length vector inline assembly constraints #150724
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
clang/test/CodeGen/RISCV/riscv-inline-asm-fixed-length-vector.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // REQUIRES: riscv-registered-target | ||
|
|
||
| // RUN: %clang_cc1 -triple riscv32 -target-feature +v \ | ||
| // RUN: -mvscale-min=2 -mvscale-max=2 -O2 -emit-llvm %s -o - \ | ||
| // RUN: | FileCheck %s | ||
| // RUN: %clang_cc1 -triple riscv64 -target-feature +v \ | ||
| // RUN: -mvscale-min=2 -mvscale-max=2 -O2 -emit-llvm %s -o - \ | ||
| // RUN: | FileCheck %s | ||
|
|
||
| // Test RISC-V V-extension fixed-length vector inline assembly constraints. | ||
| #include <riscv_vector.h> | ||
| #include <stdbool.h> | ||
|
|
||
| typedef vbool1_t fixed_bool1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); | ||
| typedef vint32m1_t fixed_i32m1_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen))); | ||
| typedef vint8mf2_t fixed_i8mf2_t __attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2))); | ||
|
|
||
| typedef bool bx2 __attribute__((ext_vector_type(16))); | ||
| typedef int i32x2 __attribute__((ext_vector_type(2))); | ||
| typedef char i8x4 __attribute__((ext_vector_type(4))); | ||
|
|
||
| fixed_i32m1_t test_vr(fixed_i32m1_t a) { | ||
| // CHECK-LABEL: define{{.*}} @test_vr | ||
| // CHECK: %0 = tail call <4 x i32> asm sideeffect "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"(<4 x i32> %a, <4 x i32> %a) | ||
| fixed_i32m1_t ret; | ||
| asm volatile ("vadd.vv %0, %1, %2" : "=vr"(ret) : "vr"(a), "vr"(a)); | ||
| return ret; | ||
| } | ||
|
|
||
| i32x2 test_vr2(i32x2 a) { | ||
| // CHECK-LABEL: define{{.*}} @test_vr2 | ||
| // CHECK: %1 = tail call <2 x i32> asm sideeffect "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"(<2 x i32> %0, <2 x i32> %0) | ||
| i32x2 ret; | ||
| asm volatile ("vadd.vv %0, %1, %2" : "=vr"(ret) : "vr"(a), "vr"(a)); | ||
| return ret; | ||
| } | ||
|
|
||
| fixed_i8mf2_t test_vd(fixed_i8mf2_t a) { | ||
| // CHECK-LABEL: define{{.*}} @test_vd | ||
| // CHECK: %0 = tail call <8 x i8> asm sideeffect "vadd.vv $0, $1, $2", "=^vd,^vr,^vr"(<8 x i8> %a, <8 x i8> %a) | ||
| fixed_i8mf2_t ret; | ||
| asm volatile ("vadd.vv %0, %1, %2" : "=vd"(ret) : "vr"(a), "vr"(a)); | ||
| return ret; | ||
| } | ||
|
|
||
| i8x4 test_vd2(i8x4 a) { | ||
| // CHECK-LABEL: define{{.*}} @test_vd2 | ||
| // CHECK: %1 = tail call <4 x i8> asm sideeffect "vadd.vv $0, $1, $2", "=^vd,^vr,^vr"(<4 x i8> %0, <4 x i8> %0) | ||
| i8x4 ret; | ||
| asm volatile ("vadd.vv %0, %1, %2" : "=vd"(ret) : "vr"(a), "vr"(a)); | ||
| return ret; | ||
| } | ||
|
|
||
| fixed_bool1_t test_vm(fixed_bool1_t a) { | ||
| // CHECK-LABEL: define{{.*}} @test_vm | ||
| // CHECK: %1 = tail call <16 x i8> asm sideeffect "vmand.mm $0, $1, $2", "=^vm,^vm,^vm"(<16 x i8> %a, <16 x i8> %a) | ||
| fixed_bool1_t ret; | ||
| asm volatile ("vmand.mm %0, %1, %2" : "=vm"(ret) : "vm"(a), "vm"(a)); | ||
| return ret; | ||
| } | ||
|
|
||
| void test_vm2(bx2 a) { | ||
| // CHECK-LABEL: define{{.*}} @test_vm2 | ||
| // CHECK: tail call void asm sideeffect "dummy $0", "^vm"(<16 x i1> %a1) | ||
| asm volatile ("dummy %0" :: "vm"(a)); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py | ||
| ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s \ | ||
| ; RUN: | FileCheck -check-prefix=RV32I %s | ||
| ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s \ | ||
| ; RUN: | FileCheck -check-prefix=RV64I %s | ||
|
|
||
| define <1 x i8> @constraint_vr_fixed(<1 x i8> %0, <1 x i8> %1) nounwind { | ||
| ; RV32I-LABEL: constraint_vr_fixed: | ||
| ; RV32I: # %bb.0: | ||
| ; RV32I-NEXT: #APP | ||
| ; RV32I-NEXT: vadd.vv v8, v8, v9 | ||
| ; RV32I-NEXT: #NO_APP | ||
| ; RV32I-NEXT: ret | ||
| ; | ||
| ; RV64I-LABEL: constraint_vr_fixed: | ||
| ; RV64I: # %bb.0: | ||
| ; RV64I-NEXT: #APP | ||
| ; RV64I-NEXT: vadd.vv v8, v8, v9 | ||
| ; RV64I-NEXT: #NO_APP | ||
| ; RV64I-NEXT: ret | ||
| %a = tail call <1 x i8> asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vr"( | ||
| <1 x i8> %0, <1 x i8> %1) | ||
| ret <1 x i8> %a | ||
| } | ||
|
|
||
| define <4 x i32> @constraint_vd_fixed(<4 x i32> %0, <4 x i32> %1) nounwind { | ||
| ; RV32I-LABEL: constraint_vd_fixed: | ||
| ; RV32I: # %bb.0: | ||
| ; RV32I-NEXT: #APP | ||
| ; RV32I-NEXT: vadd.vv v8, v8, v9 | ||
| ; RV32I-NEXT: #NO_APP | ||
| ; RV32I-NEXT: ret | ||
| ; | ||
| ; RV64I-LABEL: constraint_vd_fixed: | ||
| ; RV64I: # %bb.0: | ||
| ; RV64I-NEXT: #APP | ||
| ; RV64I-NEXT: vadd.vv v8, v8, v9 | ||
| ; RV64I-NEXT: #NO_APP | ||
| ; RV64I-NEXT: ret | ||
| %a = tail call <4 x i32> asm "vadd.vv $0, $1, $2", "=^vd,^vr,^vr"( | ||
| <4 x i32> %0, <4 x i32> %1) | ||
| ret <4 x i32> %a | ||
| } | ||
|
|
||
| define <16 x i1> @constraint_vm_fixed(<16 x i1> %0, <16 x i1> %1) nounwind { | ||
| ; RV32I-LABEL: constraint_vm_fixed: | ||
| ; RV32I: # %bb.0: | ||
| ; RV32I-NEXT: vsetivli zero, 1, e8, m1, ta, ma | ||
| ; RV32I-NEXT: vmv1r.v v9, v0 | ||
| ; RV32I-NEXT: vmv1r.v v0, v8 | ||
| ; RV32I-NEXT: #APP | ||
| ; RV32I-NEXT: vadd.vv v0, v9, v0 | ||
| ; RV32I-NEXT: #NO_APP | ||
| ; RV32I-NEXT: ret | ||
| ; | ||
| ; RV64I-LABEL: constraint_vm_fixed: | ||
| ; RV64I: # %bb.0: | ||
| ; RV64I-NEXT: vsetivli zero, 1, e8, m1, ta, ma | ||
| ; RV64I-NEXT: vmv1r.v v9, v0 | ||
| ; RV64I-NEXT: vmv1r.v v0, v8 | ||
| ; RV64I-NEXT: #APP | ||
| ; RV64I-NEXT: vadd.vv v0, v9, v0 | ||
| ; RV64I-NEXT: #NO_APP | ||
| ; RV64I-NEXT: ret | ||
| %a = tail call <16 x i1> asm "vadd.vv $0, $1, $2", "=^vr,^vr,^vm"( | ||
| <16 x i1> %0, <16 x i1> %1) | ||
| ret <16 x i1> %a | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.