Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2/11][POC][Clang][RISCV] Define RVV tuple types
For the cover letter of this patch-set, please checkout D146872. Depends on D146872. This is the 2nd patch of the patch-set. This patch originates from D97264. This patch further allows local variable declaration and function parameter passing by adjustment in clang lowering. Test cases are provided to demonstrate the LLVM IR generated. Note: This patch is currently only a proof-of-concept with only a single RVV tuple type declared here, the rest will be added when the concept of this patch-set is accepted. Authored-by: eop Chen <eop.chen@sifive.com> Co-Authored-by: Hsiangkai Wang <kai.wang@sifive.com> Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D146873
- Loading branch information
Showing
5 changed files
with
153 additions
and
26 deletions.
There are no files selected for viewing
This file contains 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 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 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
90 changes: 90 additions & 0 deletions
90
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type.c
This file contains 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,90 @@ | ||
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2 | ||
// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -O0 \ | ||
// RUN: -emit-llvm %s -o - | FileCheck %s --check-prefix=O0 | ||
// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -disable-O0-optnone \ | ||
// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck %s --check-prefix=AFTER_MEM2REG | ||
|
||
|
||
#include <riscv_vector.h> | ||
|
||
// Declare local variable | ||
// O0-LABEL: define dso_local void @foo | ||
// O0-SAME: () #[[ATTR0:[0-9]+]] { | ||
// O0-NEXT: entry: | ||
// O0-NEXT: [[V_TUPLE:%.*]] = alloca { <vscale x 2 x i32>, <vscale x 2 x i32> }, align 4 | ||
// O0-NEXT: ret void | ||
// | ||
// AFTER_MEM2REG-LABEL: define dso_local void @foo | ||
// AFTER_MEM2REG-SAME: () #[[ATTR0:[0-9]+]] { | ||
// AFTER_MEM2REG-NEXT: entry: | ||
// AFTER_MEM2REG-NEXT: ret void | ||
// | ||
void foo() { | ||
__rvv_int32m1x2_t v_tuple; | ||
} | ||
|
||
// Declare local variable and return | ||
// O0-LABEL: define dso_local { <vscale x 2 x i32>, <vscale x 2 x i32> } @bar | ||
// O0-SAME: () #[[ATTR0]] { | ||
// O0-NEXT: entry: | ||
// O0-NEXT: [[V_TUPLE:%.*]] = alloca { <vscale x 2 x i32>, <vscale x 2 x i32> }, align 4 | ||
// O0-NEXT: [[TMP0:%.*]] = load { <vscale x 2 x i32>, <vscale x 2 x i32> }, ptr [[V_TUPLE]], align 4 | ||
// O0-NEXT: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]] | ||
// | ||
// AFTER_MEM2REG-LABEL: define dso_local { <vscale x 2 x i32>, <vscale x 2 x i32> } @bar | ||
// AFTER_MEM2REG-SAME: () #[[ATTR0]] { | ||
// AFTER_MEM2REG-NEXT: entry: | ||
// AFTER_MEM2REG-NEXT: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } undef | ||
// | ||
__rvv_int32m1x2_t bar() { | ||
__rvv_int32m1x2_t v_tuple; | ||
return v_tuple; | ||
} | ||
|
||
// Pass as function parameter | ||
// O0-LABEL: define dso_local void @baz | ||
// O0-SAME: (<vscale x 2 x i32> [[V_TUPLE_COERCE0:%.*]], <vscale x 2 x i32> [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] { | ||
// O0-NEXT: entry: | ||
// O0-NEXT: [[V_TUPLE:%.*]] = alloca { <vscale x 2 x i32>, <vscale x 2 x i32> }, align 4 | ||
// O0-NEXT: [[V_TUPLE_ADDR:%.*]] = alloca { <vscale x 2 x i32>, <vscale x 2 x i32> }, align 4 | ||
// O0-NEXT: [[TMP0:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } poison, <vscale x 2 x i32> [[V_TUPLE_COERCE0]], 0 | ||
// O0-NEXT: [[TMP1:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], <vscale x 2 x i32> [[V_TUPLE_COERCE1]], 1 | ||
// O0-NEXT: store { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP1]], ptr [[V_TUPLE]], align 4 | ||
// O0-NEXT: [[V_TUPLE1:%.*]] = load { <vscale x 2 x i32>, <vscale x 2 x i32> }, ptr [[V_TUPLE]], align 4 | ||
// O0-NEXT: store { <vscale x 2 x i32>, <vscale x 2 x i32> } [[V_TUPLE1]], ptr [[V_TUPLE_ADDR]], align 4 | ||
// O0-NEXT: ret void | ||
// | ||
// AFTER_MEM2REG-LABEL: define dso_local void @baz | ||
// AFTER_MEM2REG-SAME: (<vscale x 2 x i32> [[V_TUPLE_COERCE0:%.*]], <vscale x 2 x i32> [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] { | ||
// AFTER_MEM2REG-NEXT: entry: | ||
// AFTER_MEM2REG-NEXT: [[TMP0:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } poison, <vscale x 2 x i32> [[V_TUPLE_COERCE0]], 0 | ||
// AFTER_MEM2REG-NEXT: [[TMP1:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], <vscale x 2 x i32> [[V_TUPLE_COERCE1]], 1 | ||
// AFTER_MEM2REG-NEXT: ret void | ||
// | ||
void baz(__rvv_int32m1x2_t v_tuple) { | ||
} | ||
|
||
// Pass as function parameter and return | ||
// O0-LABEL: define dso_local { <vscale x 2 x i32>, <vscale x 2 x i32> } @qux | ||
// O0-SAME: (<vscale x 2 x i32> [[V_TUPLE_COERCE0:%.*]], <vscale x 2 x i32> [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] { | ||
// O0-NEXT: entry: | ||
// O0-NEXT: [[V_TUPLE:%.*]] = alloca { <vscale x 2 x i32>, <vscale x 2 x i32> }, align 4 | ||
// O0-NEXT: [[V_TUPLE_ADDR:%.*]] = alloca { <vscale x 2 x i32>, <vscale x 2 x i32> }, align 4 | ||
// O0-NEXT: [[TMP0:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } poison, <vscale x 2 x i32> [[V_TUPLE_COERCE0]], 0 | ||
// O0-NEXT: [[TMP1:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], <vscale x 2 x i32> [[V_TUPLE_COERCE1]], 1 | ||
// O0-NEXT: store { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP1]], ptr [[V_TUPLE]], align 4 | ||
// O0-NEXT: [[V_TUPLE1:%.*]] = load { <vscale x 2 x i32>, <vscale x 2 x i32> }, ptr [[V_TUPLE]], align 4 | ||
// O0-NEXT: store { <vscale x 2 x i32>, <vscale x 2 x i32> } [[V_TUPLE1]], ptr [[V_TUPLE_ADDR]], align 4 | ||
// O0-NEXT: [[TMP2:%.*]] = load { <vscale x 2 x i32>, <vscale x 2 x i32> }, ptr [[V_TUPLE_ADDR]], align 4 | ||
// O0-NEXT: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP2]] | ||
// | ||
// AFTER_MEM2REG-LABEL: define dso_local { <vscale x 2 x i32>, <vscale x 2 x i32> } @qux | ||
// AFTER_MEM2REG-SAME: (<vscale x 2 x i32> [[V_TUPLE_COERCE0:%.*]], <vscale x 2 x i32> [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] { | ||
// AFTER_MEM2REG-NEXT: entry: | ||
// AFTER_MEM2REG-NEXT: [[TMP0:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } poison, <vscale x 2 x i32> [[V_TUPLE_COERCE0]], 0 | ||
// AFTER_MEM2REG-NEXT: [[TMP1:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], <vscale x 2 x i32> [[V_TUPLE_COERCE1]], 1 | ||
// AFTER_MEM2REG-NEXT: ret { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP1]] | ||
// | ||
__rvv_int32m1x2_t qux(__rvv_int32m1x2_t v_tuple) { | ||
return v_tuple; | ||
} |
This file contains 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