eopXD updated this revision to Diff 523861. eopXD added a comment. Rebase.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D147916/new/ https://reviews.llvm.org/D147916 Files: clang/include/clang/Basic/riscv_vector.td clang/lib/Sema/SemaChecking.cpp clang/lib/Support/RISCVVIntrinsicUtils.cpp clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c =================================================================== --- clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c +++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c @@ -339,3 +339,8 @@ // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}} return __riscv_vget_v_f16m8_f16m4(src, 2); } + +vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src) { + // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}} + return __riscv_vget_v_i32m1x2_i32m1(src, 2); +} Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c =================================================================== --- /dev/null +++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c @@ -0,0 +1,20 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2 +// REQUIRES: riscv-registered-target +// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \ +// RUN: -target-feature +experimental-zvfh -disable-O0-optnone \ +// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \ +// RUN: FileCheck --check-prefix=CHECK-RV64 %s + +#include <riscv_vector.h> + +// CHECK-RV64-LABEL: define dso_local <vscale x 2 x i32> @test_vget_v_i32m1x2_i32m1 +// CHECK-RV64-SAME: (<vscale x 2 x i32> [[SRC_COERCE0:%.*]], <vscale x 2 x i32> [[SRC_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-RV64-NEXT: entry: +// CHECK-RV64-NEXT: [[TMP0:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } poison, <vscale x 2 x i32> [[SRC_COERCE0]], 0 +// CHECK-RV64-NEXT: [[TMP1:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], <vscale x 2 x i32> [[SRC_COERCE1]], 1 +// CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP1]], 0 +// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP2]] +// +vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src) { + return __riscv_vget_v_i32m1x2_i32m1(src, 0); +} Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp =================================================================== --- clang/lib/Support/RISCVVIntrinsicUtils.cpp +++ clang/lib/Support/RISCVVIntrinsicUtils.cpp @@ -332,6 +332,8 @@ } if (isVector()) ShortStr += LMUL.str(); + if (isTuple()) + ShortStr += "x" + utostr(NF); } void RVVType::applyBasicType() { Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -4519,9 +4519,12 @@ ASTContext::BuiltinVectorTypeInfo VecInfo = Context.getBuiltinVectorTypeInfo(cast<BuiltinType>( TheCall->getArg(0)->getType().getCanonicalType().getTypePtr())); - unsigned MaxIndex = - (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) / - (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors); + unsigned MaxIndex; + if (VecInfo.NumVectors != 1) // vget for tuple type + MaxIndex = VecInfo.NumVectors; + else // vget for non-tuple type + MaxIndex = (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) / + (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors); return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1); } case RISCVVector::BI__builtin_rvv_vset_v: { Index: clang/include/clang/Basic/riscv_vector.td =================================================================== --- clang/include/clang/Basic/riscv_vector.td +++ clang/include/clang/Basic/riscv_vector.td @@ -2536,6 +2536,11 @@ let Name = "vget_v", MaskedPolicyScheme = NonePolicy, ManualCodegen = [{ { + if (isa<StructType>(Ops[0]->getType())) // For tuple type + // Extract value from index (operand 1) of vtuple (operand 0) + return Builder.CreateExtractValue( + Ops[0], + {cast<ConstantInt>(Ops[1])->getZExtValue()}); auto *VecTy = cast<ScalableVectorType>(ResultType); auto *OpVecTy = cast<ScalableVectorType>(Ops[0]->getType()); // Mask to only valid indices. @@ -2553,6 +2558,12 @@ def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilxfd", dst_lmul # "v">; def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "UvUvKz", "csil", dst_lmul # "Uv">; } + foreach nf = [2] in { + let Log2LMUL = [0] in { + defvar T = "(Tuple:" # nf # ")"; + def : RVVBuiltin<T # "vv", "v" # T # "vKz", "i", "v">; + } + } } let Name = "vset_v", Log2LMUL = [0, 1, 2], MaskedPolicyScheme = NonePolicy,
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c =================================================================== --- clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c +++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c @@ -339,3 +339,8 @@ // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}} return __riscv_vget_v_f16m8_f16m4(src, 2); } + +vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src) { + // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}} + return __riscv_vget_v_i32m1x2_i32m1(src, 2); +} Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c =================================================================== --- /dev/null +++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c @@ -0,0 +1,20 @@ +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2 +// REQUIRES: riscv-registered-target +// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \ +// RUN: -target-feature +experimental-zvfh -disable-O0-optnone \ +// RUN: -emit-llvm %s -o - | opt -S -passes=mem2reg | \ +// RUN: FileCheck --check-prefix=CHECK-RV64 %s + +#include <riscv_vector.h> + +// CHECK-RV64-LABEL: define dso_local <vscale x 2 x i32> @test_vget_v_i32m1x2_i32m1 +// CHECK-RV64-SAME: (<vscale x 2 x i32> [[SRC_COERCE0:%.*]], <vscale x 2 x i32> [[SRC_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] { +// CHECK-RV64-NEXT: entry: +// CHECK-RV64-NEXT: [[TMP0:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } poison, <vscale x 2 x i32> [[SRC_COERCE0]], 0 +// CHECK-RV64-NEXT: [[TMP1:%.*]] = insertvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP0]], <vscale x 2 x i32> [[SRC_COERCE1]], 1 +// CHECK-RV64-NEXT: [[TMP2:%.*]] = extractvalue { <vscale x 2 x i32>, <vscale x 2 x i32> } [[TMP1]], 0 +// CHECK-RV64-NEXT: ret <vscale x 2 x i32> [[TMP2]] +// +vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src) { + return __riscv_vget_v_i32m1x2_i32m1(src, 0); +} Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp =================================================================== --- clang/lib/Support/RISCVVIntrinsicUtils.cpp +++ clang/lib/Support/RISCVVIntrinsicUtils.cpp @@ -332,6 +332,8 @@ } if (isVector()) ShortStr += LMUL.str(); + if (isTuple()) + ShortStr += "x" + utostr(NF); } void RVVType::applyBasicType() { Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -4519,9 +4519,12 @@ ASTContext::BuiltinVectorTypeInfo VecInfo = Context.getBuiltinVectorTypeInfo(cast<BuiltinType>( TheCall->getArg(0)->getType().getCanonicalType().getTypePtr())); - unsigned MaxIndex = - (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) / - (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors); + unsigned MaxIndex; + if (VecInfo.NumVectors != 1) // vget for tuple type + MaxIndex = VecInfo.NumVectors; + else // vget for non-tuple type + MaxIndex = (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) / + (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors); return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1); } case RISCVVector::BI__builtin_rvv_vset_v: { Index: clang/include/clang/Basic/riscv_vector.td =================================================================== --- clang/include/clang/Basic/riscv_vector.td +++ clang/include/clang/Basic/riscv_vector.td @@ -2536,6 +2536,11 @@ let Name = "vget_v", MaskedPolicyScheme = NonePolicy, ManualCodegen = [{ { + if (isa<StructType>(Ops[0]->getType())) // For tuple type + // Extract value from index (operand 1) of vtuple (operand 0) + return Builder.CreateExtractValue( + Ops[0], + {cast<ConstantInt>(Ops[1])->getZExtValue()}); auto *VecTy = cast<ScalableVectorType>(ResultType); auto *OpVecTy = cast<ScalableVectorType>(Ops[0]->getType()); // Mask to only valid indices. @@ -2553,6 +2558,12 @@ def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilxfd", dst_lmul # "v">; def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "UvUvKz", "csil", dst_lmul # "Uv">; } + foreach nf = [2] in { + let Log2LMUL = [0] in { + defvar T = "(Tuple:" # nf # ")"; + def : RVVBuiltin<T # "vv", "v" # T # "vKz", "i", "v">; + } + } } let Name = "vset_v", Log2LMUL = [0, 1, 2], MaskedPolicyScheme = NonePolicy,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits