[clang] 4c8b8e0 - [PowerPC] Allow MMA built-ins to accept non-void pointers and arrays
Ahsan Saghir via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 16 07:14:46 PST 2021
Author: Ahsan Saghir
Date: 2021-11-16T09:14:41-06:00
New Revision: 4c8b8e0154f075e463428acc0640388c40d60097
URL: https://github.com/llvm/llvm-project/commit/4c8b8e0154f075e463428acc0640388c40d60097
DIFF: https://github.com/llvm/llvm-project/commit/4c8b8e0154f075e463428acc0640388c40d60097.diff
LOG: [PowerPC] Allow MMA built-ins to accept non-void pointers and arrays
Calls to MMA builtins that take pointer to void
do not accept other pointers/arrays whereas normal
functions with the same parameter do. This patch
allows MMA built-ins to accept non-void pointers
and arrays.
Reviewed By: nemanjai
Differential Revision: https://reviews.llvm.org/D113306
Added:
Modified:
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/ppc-pair-mma-types.c
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 18e429cf3efd2..849423c8b9bae 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -15171,8 +15171,12 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
SmallVector<Value*, 4> Ops;
- for (unsigned i = 0, e = E->getNumArgs(); i != e; i++)
- Ops.push_back(EmitScalarExpr(E->getArg(i)));
+ for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
+ if (E->getArg(i)->getType()->isArrayType())
+ Ops.push_back(EmitArrayToPointerDecay(E->getArg(i)).getPointer());
+ else
+ Ops.push_back(EmitScalarExpr(E->getArg(i)));
+ }
Intrinsic::ID ID = Intrinsic::not_intrinsic;
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 6b38877bee114..3fe7303cb4458 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -7553,11 +7553,11 @@ bool Sema::SemaBuiltinPPCMMACall(CallExpr *TheCall, unsigned BuiltinID,
StrippedRVType = StrippedRVType.getCanonicalType().getUnqualifiedType();
// The only case where the argument type and expected type are allowed to
- // mismatch is if the argument type is a non-void pointer and expected type
- // is a void pointer.
+ // mismatch is if the argument type is a non-void pointer (or array) and
+ // expected type is a void pointer.
if (StrippedRVType != ExpectedType)
if (!(ExpectedType->isVoidPointerType() &&
- StrippedRVType->isPointerType()))
+ (StrippedRVType->isPointerType() || StrippedRVType->isArrayType())))
return Diag(Arg->getBeginLoc(),
diag::err_typecheck_convert_incompatible)
<< PassedType << ExpectedType << 1 << 0 << 0;
diff --git a/clang/test/Sema/ppc-pair-mma-types.c b/clang/test/Sema/ppc-pair-mma-types.c
index 5f259b9780ae2..2ad1079bd966b 100644
--- a/clang/test/Sema/ppc-pair-mma-types.c
+++ b/clang/test/Sema/ppc-pair-mma-types.c
@@ -339,20 +339,20 @@ void testBuiltinTypes3(vector int v, __vector_pair *vp2, signed long l, unsigned
void testRestrictQualifiedPointer1(int *__restrict acc) {
vector float arr[4];
- __builtin_mma_disassemble_acc((void *)arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}}
+ __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int *restrict' to parameter of incompatible type '__vector_quad *'}}
}
void testRestrictQualifiedPointer2(__vector_quad *__restrict acc) {
vector float arr[4];
- __builtin_mma_disassemble_acc((void *)arr, acc);
+ __builtin_mma_disassemble_acc(arr, acc);
}
void testVolatileQualifiedPointer1(int *__volatile acc) {
vector float arr[4];
- __builtin_mma_disassemble_acc((void *)arr, acc); // expected-error {{passing 'int *volatile' to parameter of incompatible type '__vector_quad *'}}
+ __builtin_mma_disassemble_acc(arr, acc); // expected-error {{passing 'int *volatile' to parameter of incompatible type '__vector_quad *'}}
}
void testVolatileQualifiedPointer2(__vector_quad *__volatile acc) {
vector float arr[4];
- __builtin_mma_disassemble_acc((void *)arr, acc);
+ __builtin_mma_disassemble_acc(arr, acc);
}
More information about the cfe-commits
mailing list