[clang] 57d83c3 - [PowerPC] Enable paired vector type and intrinsics when MMA is disabled
Baptiste Saleil via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 15 13:14:37 PST 2020
Author: Baptiste Saleil
Date: 2020-12-15T15:14:11-06:00
New Revision: 57d83c3a90c427ad0975803feb5b348d1ad34e29
URL: https://github.com/llvm/llvm-project/commit/57d83c3a90c427ad0975803feb5b348d1ad34e29
DIFF: https://github.com/llvm/llvm-project/commit/57d83c3a90c427ad0975803feb5b348d1ad34e29.diff
LOG: [PowerPC] Enable paired vector type and intrinsics when MMA is disabled
This patch enables the Clang type __vector_pair and its associated LLVM
intrinsics even when MMA is disabled. With this patch, the type is now controlled
by the PPC paired-vector-memops option. The builtins and intrinsics will be
renamed to drop the mma prefix in another patch.
Differential Revision: https://reviews.llvm.org/D91819
Added:
clang/test/AST/ast-dump-ppc-types.c
llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll
Modified:
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/AST/TypeProperties.td
clang/include/clang/Basic/PPCTypes.def
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/NSAPI.cpp
clang/lib/AST/PrintfFormatString.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CodeGenTypes.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReader.cpp
clang/tools/libclang/CIndex.cpp
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
Removed:
clang/test/AST/ast-dump-ppc-mma-types.c
################################################################################
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 71f824b69bc8..ff84eb52e96e 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1007,7 +1007,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
#define SVE_TYPE(Name, Id, SingletonId) \
CanQualType SingletonId;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
CanQualType Id##Ty;
#include "clang/Basic/PPCTypes.def"
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 99cfa3ae76f5..945ea7a600c0 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2489,7 +2489,7 @@ class BuiltinType : public Type {
#define SVE_TYPE(Name, Id, SingletonId) Id,
#include "clang/Basic/AArch64SVEACLETypes.def"
// PPC MMA Types
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) Id,
+#define PPC_VECTOR_TYPE(Name, Id, Size) Id,
#include "clang/Basic/PPCTypes.def"
// All other builtin types
#define BUILTIN_TYPE(Id, SingletonId) Id,
diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td
index b582395c44a6..ffcc8290938f 100644
--- a/clang/include/clang/AST/TypeProperties.td
+++ b/clang/include/clang/AST/TypeProperties.td
@@ -765,7 +765,7 @@ let Class = BuiltinType in {
case BuiltinType::ID: return ctx.SINGLETON_ID;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(NAME, ID, SIZE) \
+#define PPC_VECTOR_TYPE(NAME, ID, SIZE) \
case BuiltinType::ID: return ctx.ID##Ty;
#include "clang/Basic/PPCTypes.def"
diff --git a/clang/include/clang/Basic/PPCTypes.def b/clang/include/clang/Basic/PPCTypes.def
index 86656f3568f8..9e2cb2aedc9f 100644
--- a/clang/include/clang/Basic/PPCTypes.def
+++ b/clang/include/clang/Basic/PPCTypes.def
@@ -7,14 +7,32 @@
//===----------------------------------------------------------------------===//
//
// This file defines PPC types.
-// Custom code should define this macro:
+// Custom code should define one of these macros:
//
-// PPC_MMA_VECTOR_TYPE(Name, Id, Size) - A MMA vector type of a given size
+// PPC_VECTOR_TYPE(Name, Id, Size) - A PPC vector type of a given size
// (in bits).
//
+// PPC_VECTOR_MMA_TYPE(Name, Id, Size) - A PPC MMA vector type of a given
+// size (in bits).
+//
+// PPC_VECTOR_VSX_TYPE(Name, Id, Size) - A PPC VSX vector type of a given
+// size (in bits).
+//
//===----------------------------------------------------------------------===//
-PPC_MMA_VECTOR_TYPE(__vector_quad, VectorQuad, 512)
-PPC_MMA_VECTOR_TYPE(__vector_pair, VectorPair, 256)
+#if defined(PPC_VECTOR_TYPE)
+ #define PPC_VECTOR_MMA_TYPE(Name, Id, Size) PPC_VECTOR_TYPE(Name, Id, Size)
+ #define PPC_VECTOR_VSX_TYPE(Name, Id, Size) PPC_VECTOR_TYPE(Name, Id, Size)
+#elif defined(PPC_VECTOR_MMA_TYPE)
+ #define PPC_VECTOR_VSX_TYPE(Name, Id, Size)
+#elif defined(PPC_VECTOR_VSX_TYPE)
+ #define PPC_VECTOR_MMA_TYPE(Name, Id, Size)
+#endif
+
+
+PPC_VECTOR_MMA_TYPE(__vector_quad, VectorQuad, 512)
+PPC_VECTOR_VSX_TYPE(__vector_pair, VectorPair, 256)
-#undef PPC_MMA_VECTOR_TYPE
+#undef PPC_VECTOR_MMA_TYPE
+#undef PPC_VECTOR_VSX_TYPE
+#undef PPC_VECTOR_TYPE
diff --git a/clang/include/clang/Serialization/ASTBitCodes.h b/clang/include/clang/Serialization/ASTBitCodes.h
index 4e14d6f5e3b6..b4fd9e95d28f 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1081,7 +1081,7 @@ class TypeIdx {
#define SVE_TYPE(Name, Id, SingletonId) PREDEF_TYPE_##Id##_ID,
#include "clang/Basic/AArch64SVEACLETypes.def"
// \brief PowerPC MMA types with auto numeration
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) PREDEF_TYPE_##Id##_ID,
+#define PPC_VECTOR_TYPE(Name, Id, Size) PREDEF_TYPE_##Id##_ID,
#include "clang/Basic/PPCTypes.def"
};
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 057574ec2b82..44545f00b146 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1423,8 +1423,14 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
#include "clang/Basic/AArch64SVEACLETypes.def"
}
- if (Target.getTriple().isPPC64() && Target.hasFeature("mma")) {
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+ if (Target.getTriple().isPPC64() &&
+ Target.hasFeature("paired-vector-memops")) {
+ if (Target.hasFeature("mma")) {
+#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
+ InitBuiltinType(Id##Ty, BuiltinType::Id);
+#include "clang/Basic/PPCTypes.def"
+ }
+#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
InitBuiltinType(Id##Ty, BuiltinType::Id);
#include "clang/Basic/PPCTypes.def"
}
@@ -2154,11 +2160,11 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
Align = 16; \
break;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
- Width = Size; \
- Align = Size; \
- break;
+ Width = Size; \
+ Align = Size; \
+ break;
#include "clang/Basic/PPCTypes.def"
}
break;
@@ -7232,7 +7238,7 @@ static char getObjCEncodingForPrimitiveType(const ASTContext *C,
case BuiltinType::OCLReserveID:
case BuiltinType::OCLSampler:
case BuiltinType::Dependent:
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
#define BUILTIN_TYPE(KIND, ID)
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 10fa6990624d..9c0a7320e5f2 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -1031,7 +1031,7 @@ ExpectedType ASTNodeImporter::VisitBuiltinType(const BuiltinType *T) {
case BuiltinType::Id: \
return Importer.getToContext().SingletonId;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
return Importer.getToContext().Id##Ty;
#include "clang/Basic/PPCTypes.def"
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 0865b8b85138..56181bbe1166 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -10968,7 +10968,7 @@ EvaluateBuiltinClassifyType(QualType T, const LangOptions &LangOpts) {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
return GCCTypeClass::None;
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index f2e9bc727ac6..73c8f17a5d36 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -2858,7 +2858,7 @@ void CXXNameMangler::mangleType(const BuiltinType *T) {
<< type_name; \
break;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
type_name = #Name; \
Out << 'u' << type_name.size() << type_name; \
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index 286000faf2a4..df6c566abc7d 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -2395,7 +2395,7 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers,
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::ShortAccum:
diff --git a/clang/lib/AST/NSAPI.cpp b/clang/lib/AST/NSAPI.cpp
index 505702127d50..cf4b42d25148 100644
--- a/clang/lib/AST/NSAPI.cpp
+++ b/clang/lib/AST/NSAPI.cpp
@@ -474,7 +474,7 @@ NSAPI::getNSNumberFactoryMethodKind(QualType T) const {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::BoundMember:
diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp
index de64a8d60eba..a1abaf2f0943 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/lib/AST/PrintfFormatString.cpp
@@ -791,7 +791,7 @@ bool PrintfSpecifier::fixType(QualType QT, const LangOptions &LangOpt,
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
#define SIGNED_TYPE(Id, SingletonId)
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index aa623b000fb5..af39b80ef9e4 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3084,7 +3084,7 @@ StringRef BuiltinType::getName(const PrintingPolicy &Policy) const {
case Id: \
return Name;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case Id: \
return #Name;
#include "clang/Basic/PPCTypes.def"
@@ -4107,7 +4107,7 @@ bool Type::canHaveNullability(bool ResultIfUnknown) const {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::BuiltinFn:
diff --git a/clang/lib/AST/TypeLoc.cpp b/clang/lib/AST/TypeLoc.cpp
index c8d6300bc423..222b1abac510 100644
--- a/clang/lib/AST/TypeLoc.cpp
+++ b/clang/lib/AST/TypeLoc.cpp
@@ -403,7 +403,7 @@ TypeSpecifierType BuiltinTypeLoc::getWrittenTypeSpec() const {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::BuiltinFn:
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 97337e00180e..5d48315223f9 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -754,7 +754,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
}
// It doesn't make sense to generate debug info for PowerPC MMA vector types.
// So we return a safe type here to avoid generating an error.
-#define PPC_MMA_VECTOR_TYPE(Name, Id, size) \
+#define PPC_VECTOR_TYPE(Name, Id, size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
return CreateType(cast<const BuiltinType>(CGM.getContext().IntTy));
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 2804b0ee8dd2..7537ac12f1c8 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -595,7 +595,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
Info.EC.getKnownMinValue() *
Info.NumVectors);
}
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
ResultType = \
llvm::FixedVectorType::get(ConvertType(Context.BoolTy), Size); \
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index 63f76df69d08..50fb30a95cbb 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -3178,7 +3178,7 @@ static bool TypeInfoIsInStandardLibrary(const BuiltinType *Ty) {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::ShortAccum:
diff --git a/clang/lib/Index/USRGeneration.cpp b/clang/lib/Index/USRGeneration.cpp
index f114f436a580..abaeb1a4232f 100644
--- a/clang/lib/Index/USRGeneration.cpp
+++ b/clang/lib/Index/USRGeneration.cpp
@@ -729,7 +729,7 @@ void USRGenerator::VisitType(QualType T) {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
case BuiltinType::ShortAccum:
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 829ab2253614..83df76b967c4 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -372,8 +372,13 @@ void Sema::Initialize() {
}
if (Context.getTargetInfo().getTriple().isPPC64() &&
- Context.getTargetInfo().hasFeature("mma")) {
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+ Context.getTargetInfo().hasFeature("paired-vector-memops")) {
+ if (Context.getTargetInfo().hasFeature("mma")) {
+#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
+ addImplicitTypedef(#Name, Context.Id##Ty);
+#include "clang/Basic/PPCTypes.def"
+ }
+#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
addImplicitTypedef(#Name, Context.Id##Ty);
#include "clang/Basic/PPCTypes.def"
}
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 8d4c90c7812f..5fef59bed5af 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3198,7 +3198,7 @@ static QualType DecodePPCMMATypeFromStr(ASTContext &Context, const char *&Str,
Str = End;
QualType Type;
switch (size) {
- #define PPC_MMA_VECTOR_TYPE(typeName, Id, size) \
+ #define PPC_VECTOR_TYPE(typeName, Id, size) \
case size: Type = Context.Id##Ty; break;
#include "clang/Basic/PPCTypes.def"
default: llvm_unreachable("Invalid PowerPC MMA vector type");
@@ -3316,7 +3316,7 @@ bool Sema::CheckPPCMMAType(QualType Type, SourceLocation TypeLoc) {
return false;
QualType CoreType = Type.getCanonicalType().getUnqualifiedType();
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) || CoreType == Context.Id##Ty
+#define PPC_VECTOR_TYPE(Name, Id, Size) || CoreType == Context.Id##Ty
if (false
#include "clang/Basic/PPCTypes.def"
) {
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 0e829230d6a8..ca1939222cf0 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6055,7 +6055,7 @@ static bool isPlaceholderToRemoveAsArg(QualType type) {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
#define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
@@ -19349,7 +19349,7 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
#define SVE_TYPE(Name, Id, SingletonId) \
case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
#define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
diff --git a/clang/lib/Serialization/ASTCommon.cpp b/clang/lib/Serialization/ASTCommon.cpp
index f1a02ad0a59d..fec6dd5cf17d 100644
--- a/clang/lib/Serialization/ASTCommon.cpp
+++ b/clang/lib/Serialization/ASTCommon.cpp
@@ -237,7 +237,7 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
ID = PREDEF_TYPE_##Id##_ID; \
break;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case BuiltinType::Id: \
ID = PREDEF_TYPE_##Id##_ID; \
break;
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index c2ddd8e3df70..02b454bad174 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7025,7 +7025,7 @@ QualType ASTReader::GetType(TypeID ID) {
T = Context.SingletonId; \
break;
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) \
+#define PPC_VECTOR_TYPE(Name, Id, Size) \
case PREDEF_TYPE_##Id##_ID: \
T = Context.Id##Ty; \
break;
diff --git a/clang/test/AST/ast-dump-ppc-mma-types.c b/clang/test/AST/ast-dump-ppc-types.c
similarity index 77%
rename from clang/test/AST/ast-dump-ppc-mma-types.c
rename to clang/test/AST/ast-dump-ppc-types.c
index 4e81f4253a70..013f935376a6 100644
--- a/clang/test/AST/ast-dump-ppc-mma-types.c
+++ b/clang/test/AST/ast-dump-ppc-types.c
@@ -3,6 +3,9 @@
// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu future \
// RUN: -target-feature -mma -ast-dump %s | FileCheck %s \
// RUN: --check-prefix=CHECK-NO-MMA
+// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu future \
+// RUN: -target-feature -paired-vector-memops -ast-dump %s | FileCheck %s \
+// RUN: --check-prefix=CHECK-NO-PAIRED
// RUN: %clang_cc1 -triple powerpc64le-unknown-unknown -target-cpu pwr9 \
// RUN: -ast-dump %s | FileCheck %s --check-prefix=CHECK-PWR9
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck %s \
@@ -13,9 +16,8 @@
// RUN: --check-prefix=CHECK-RISCV64
// This test case checks that the PowerPC __vector_pair and __vector_quad types
-// are correctly defined. These types should only be defined on PowerPC targets
-// supporting the mma feature. We also added checks on a couple of other targets
-// to ensure the types are target-dependent.
+// are correctly defined. We also added checks on a couple of other targets to
+// ensure the types are target-dependent.
// CHECK: TypedefDecl {{.*}} implicit __vector_quad '__vector_quad'
// CHECK-NEXT: -BuiltinType {{.*}} '__vector_quad'
@@ -23,7 +25,10 @@
// CHECK-NEXT: -BuiltinType {{.*}} '__vector_pair'
// CHECK-NO-MMA-NOT: __vector_quad
-// CHECK-NO-MMA-NOT: __vector_pair
+// CHECK-NO-MMA: __vector_pair
+
+// CHECK-NO-PAIRED-NOT: __vector_quad
+// CHECK-NO-PAIRED-NOT: __vector_pair
// CHECK-PWR9-NOT: __vector_quad
// CHECK-PWR9-NOT: __vector_pair
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index aa888a380048..d5c860a745c0 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -1546,7 +1546,7 @@ bool CursorVisitor::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
case BuiltinType::OCLReserveID:
#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
-#define PPC_MMA_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
+#define PPC_VECTOR_TYPE(Name, Id, Size) case BuiltinType::Id:
#include "clang/Basic/PPCTypes.def"
#define BUILTIN_TYPE(Id, SingletonId)
#define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
diff --git a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
index 8af365bf3243..a4ade0f82292 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrPrefix.td
@@ -1600,13 +1600,9 @@ def Extracts {
let Predicates = [MMA] in {
def : Pat<(v512i1 (PPCAccBuild v4i32:$vs1, v4i32:$vs0, v4i32:$vs3, v4i32:$vs2)),
(XXMTACC Concats.VecsToVecQuad)>;
- def : Pat<(v256i1 (PPCPairBuild v4i32:$vs1, v4i32:$vs0)),
- Concats.VecsToVecPair0>;
def : Pat<(v512i1 (int_ppc_mma_assemble_acc v16i8:$vs1, v16i8:$vs0,
v16i8:$vs3, v16i8:$vs2)),
(XXMTACC Concats.VecsToVecQuad)>;
- def : Pat<(v256i1 (int_ppc_mma_assemble_pair v16i8:$vs1, v16i8:$vs0)),
- Concats.VecsToVecPair0>;
def : Pat<(v512i1 (PPCxxmfacc v512i1:$AS)), (XXMFACC acc:$AS)>;
def : Pat<(v4i32 (PPCAccExtractVsx acc:$v, (i64 0))),
Extracts.Vec0>;
@@ -1616,6 +1612,13 @@ let Predicates = [MMA] in {
Extracts.Vec2>;
def : Pat<(v4i32 (PPCAccExtractVsx acc:$v, (i64 3))),
Extracts.Vec3>;
+}
+
+let Predicates = [PairedVectorMemops] in {
+ def : Pat<(v256i1 (PPCPairBuild v4i32:$vs1, v4i32:$vs0)),
+ Concats.VecsToVecPair0>;
+ def : Pat<(v256i1 (int_ppc_mma_assemble_pair v16i8:$vs1, v16i8:$vs0)),
+ Concats.VecsToVecPair0>;
def : Pat<(v4i32 (PPCPairExtractVsx vsrpevenrc:$v, (i64 0))),
(v4i32 (EXTRACT_SUBREG $v, sub_vsx0))>;
def : Pat<(v4i32 (PPCPairExtractVsx vsrpevenrc:$v, (i64 1))),
diff --git a/llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll b/llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll
new file mode 100644
index 000000000000..f09f8ac780e0
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll
@@ -0,0 +1,59 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -O3 \
+; RUN: -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr -mattr=-mma \
+; RUN: < %s | FileCheck %s
+
+; This test is to check that the paired vector intrinsics are available even
+; when MMA is disabled.
+
+define <16 x i8> @test1(<256 x i1>* %ptr) {
+; CHECK-LABEL: test1:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: lxv v3, 0(r3)
+; CHECK-NEXT: lxv v2, 16(r3)
+; CHECK-NEXT: vaddubm v2, v3, v2
+; CHECK-NEXT: blr
+entry:
+ %0 = load <256 x i1>, <256 x i1>* %ptr, align 32
+ %1 = tail call { <16 x i8>, <16 x i8> } @llvm.ppc.mma.disassemble.pair(<256 x i1> %0)
+ %2 = extractvalue { <16 x i8>, <16 x i8> } %1, 0
+ %3 = extractvalue { <16 x i8>, <16 x i8> } %1, 1
+ %add = add <16 x i8> %2, %3
+ ret <16 x i8> %add
+}
+
+declare { <16 x i8>, <16 x i8> } @llvm.ppc.mma.disassemble.pair(<256 x i1>)
+
+define void @test2(<16 x i8> %v1, <16 x i8> %v2, <256 x i1>* %ptr) {
+; CHECK-LABEL: test2:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: vmr v4, v3
+; CHECK-NEXT: vmr v5, v2
+; CHECK-NEXT: stxv v4, 16(r7)
+; CHECK-NEXT: stxv v5, 0(r7)
+; CHECK-NEXT: blr
+entry:
+ %0 = tail call <256 x i1> @llvm.ppc.mma.assemble.pair(<16 x i8> %v2, <16 x i8> %v1)
+ store <256 x i1> %0, <256 x i1>* %ptr, align 32
+ ret void
+}
+
+declare <256 x i1> @llvm.ppc.mma.assemble.pair(<16 x i8>, <16 x i8>)
+
+define void @test3(<256 x i1>* %ptr) {
+; CHECK-LABEL: test3:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: lxvp vsp0, 0(r3)
+; CHECK-NEXT: stxvp vsp0, 32(r3)
+; CHECK-NEXT: blr
+entry:
+ %0 = bitcast <256 x i1>* %ptr to i8*
+ %1 = tail call <256 x i1> @llvm.ppc.mma.lxvp(i8* %0)
+ %add.ptr1 = getelementptr inbounds <256 x i1>, <256 x i1>* %ptr, i64 1
+ %2 = bitcast <256 x i1>* %add.ptr1 to i8*
+ tail call void @llvm.ppc.mma.stxvp(<256 x i1> %1, i8* %2)
+ ret void
+}
+
+declare <256 x i1> @llvm.ppc.mma.lxvp(i8*)
+declare void @llvm.ppc.mma.stxvp(<256 x i1>, i8*)
More information about the cfe-commits
mailing list