From 57d83c3a90c427ad0975803feb5b348d1ad34e29 Mon Sep 17 00:00:00 2001 From: Baptiste Saleil Date: Tue, 15 Dec 2020 15:08:09 -0600 Subject: [PATCH] [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 --- clang/include/clang/AST/ASTContext.h | 2 +- clang/include/clang/AST/Type.h | 2 +- clang/include/clang/AST/TypeProperties.td | 2 +- clang/include/clang/Basic/PPCTypes.def | 28 ++++++++-- clang/include/clang/Serialization/ASTBitCodes.h | 2 +- clang/lib/AST/ASTContext.cpp | 20 +++++--- clang/lib/AST/ASTImporter.cpp | 2 +- clang/lib/AST/ExprConstant.cpp | 2 +- clang/lib/AST/ItaniumMangle.cpp | 2 +- clang/lib/AST/MicrosoftMangle.cpp | 2 +- clang/lib/AST/NSAPI.cpp | 2 +- clang/lib/AST/PrintfFormatString.cpp | 2 +- clang/lib/AST/Type.cpp | 4 +- clang/lib/AST/TypeLoc.cpp | 2 +- clang/lib/CodeGen/CGDebugInfo.cpp | 2 +- clang/lib/CodeGen/CodeGenTypes.cpp | 2 +- clang/lib/CodeGen/ItaniumCXXABI.cpp | 2 +- clang/lib/Index/USRGeneration.cpp | 2 +- clang/lib/Sema/Sema.cpp | 9 +++- clang/lib/Sema/SemaChecking.cpp | 4 +- clang/lib/Sema/SemaExpr.cpp | 4 +- clang/lib/Serialization/ASTCommon.cpp | 2 +- clang/lib/Serialization/ASTReader.cpp | 2 +- ...t-dump-ppc-mma-types.c => ast-dump-ppc-types.c} | 13 +++-- clang/tools/libclang/CIndex.cpp | 2 +- llvm/lib/Target/PowerPC/PPCInstrPrefix.td | 11 ++-- .../paired-vector-intrinsics-without-mma.ll | 59 ++++++++++++++++++++++ 27 files changed, 142 insertions(+), 46 deletions(-) rename clang/test/AST/{ast-dump-ppc-mma-types.c => ast-dump-ppc-types.c} (77%) create mode 100644 llvm/test/CodeGen/PowerPC/paired-vector-intrinsics-without-mma.ll diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 71f824b..ff84eb5 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1007,7 +1007,7 @@ public: #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 99cfa3a..945ea7a 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -2489,7 +2489,7 @@ public: #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 b582395c..ffcc829 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 86656f3..9e2cb2a 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 4e14d6f..b4fd9e9 100644 --- a/clang/include/clang/Serialization/ASTBitCodes.h +++ b/clang/include/clang/Serialization/ASTBitCodes.h @@ -1081,7 +1081,7 @@ public: #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 057574e..44545f0 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 10fa6990..9c0a732 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 0865b8b..56181bb 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 f2e9bc7..73c8f17 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 286000f..df6c566 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 5057021..cf4b42d 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 de64a8d..a1abaf2 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 aa623b0..af39b80 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 c8d6300..222b1ab 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 97337e0..5d48315 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(CGM.getContext().IntTy)); diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp index 2804b0e..7537ac1 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 63f76df..50fb30a 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 f114f43..abaeb1a 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 829ab22..83df76b 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 8d4c90c..5fef59b 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 0e82923..ca19392 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 f1a02ad..fec6dd5 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 c2ddd8e..02b454b 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 4e81f42..013f935 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 aa888a3..d5c860a 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 8af365b..a4ade0f 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 0000000..f09f8ac --- /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*) -- 2.7.4