[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea closed https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/jroelofs approved this pull request. https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
labrinea wrote: I've left out the bf16 and i8mm dependencies fixup as they deserve a separate patch. I will be merging this until the end of today if no one objects. https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/113281 >From 2b416dd0071d45be3f92671f0cb238091689a9dd Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Mon, 21 Oct 2024 17:15:47 +0100 Subject: [PATCH 1/4] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- clang/lib/AST/ASTContext.cpp | 6 +- clang/lib/Basic/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 47 --- clang/test/CodeGen/aarch64-targetattr.c | 4 +- clang/test/CodeGen/attr-target-version.c | 58 - .../Preprocessor/aarch64-target-features.c| 4 +- clang/test/Sema/attr-target-clones-aarch64.c | 2 +- .../llvm/TargetParser/AArch64TargetParser.h | 18 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 116 +- llvm/lib/Target/AArch64/AArch64Features.td| 4 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 17 ++- 11 files changed, 144 insertions(+), 134 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mebf16() #[[default]] { __attribute__((target_version("ebf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { @@ -48,7 +48,7 @@ __attribute__((target_version("flagm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mflagm2() #[[flagm2:[0-9]+
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/113281 >From 2b416dd0071d45be3f92671f0cb238091689a9dd Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Mon, 21 Oct 2024 17:15:47 +0100 Subject: [PATCH 1/4] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- clang/lib/AST/ASTContext.cpp | 6 +- clang/lib/Basic/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 47 --- clang/test/CodeGen/aarch64-targetattr.c | 4 +- clang/test/CodeGen/attr-target-version.c | 58 - .../Preprocessor/aarch64-target-features.c| 4 +- clang/test/Sema/attr-target-clones-aarch64.c | 2 +- .../llvm/TargetParser/AArch64TargetParser.h | 18 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 116 +- llvm/lib/Target/AArch64/AArch64Features.td| 4 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 17 ++- 11 files changed, 144 insertions(+), 134 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mebf16() #[[default]] { __attribute__((target_version("ebf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { @@ -48,7 +48,7 @@ __attribute__((target_version("flagm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mflagm2() #[[flagm2:[0-9]+
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea edited https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/113281 >From 2b416dd0071d45be3f92671f0cb238091689a9dd Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Mon, 21 Oct 2024 17:15:47 +0100 Subject: [PATCH 1/4] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- clang/lib/AST/ASTContext.cpp | 6 +- clang/lib/Basic/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 47 --- clang/test/CodeGen/aarch64-targetattr.c | 4 +- clang/test/CodeGen/attr-target-version.c | 58 - .../Preprocessor/aarch64-target-features.c| 4 +- clang/test/Sema/attr-target-clones-aarch64.c | 2 +- .../llvm/TargetParser/AArch64TargetParser.h | 18 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 116 +- llvm/lib/Target/AArch64/AArch64Features.td| 4 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 17 ++- 11 files changed, 144 insertions(+), 134 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mebf16() #[[default]] { __attribute__((target_version("ebf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { @@ -48,7 +48,7 @@ __attribute__((target_version("flagm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mflagm2() #[[flagm2:[0-9]+
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/113281 >From 2b416dd0071d45be3f92671f0cb238091689a9dd Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Mon, 21 Oct 2024 17:15:47 +0100 Subject: [PATCH 1/3] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- clang/lib/AST/ASTContext.cpp | 6 +- clang/lib/Basic/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 47 --- clang/test/CodeGen/aarch64-targetattr.c | 4 +- clang/test/CodeGen/attr-target-version.c | 58 - .../Preprocessor/aarch64-target-features.c| 4 +- clang/test/Sema/attr-target-clones-aarch64.c | 2 +- .../llvm/TargetParser/AArch64TargetParser.h | 18 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 116 +- llvm/lib/Target/AArch64/AArch64Features.td| 4 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 17 ++- 11 files changed, 144 insertions(+), 134 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mebf16() #[[default]] { __attribute__((target_version("ebf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { @@ -48,7 +48,7 @@ __attribute__((target_version("flagm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mflagm2() #[[flagm2:[0-9]+
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/113281 >From 2b416dd0071d45be3f92671f0cb238091689a9dd Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Mon, 21 Oct 2024 17:15:47 +0100 Subject: [PATCH 1/3] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- clang/lib/AST/ASTContext.cpp | 6 +- clang/lib/Basic/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 47 --- clang/test/CodeGen/aarch64-targetattr.c | 4 +- clang/test/CodeGen/attr-target-version.c | 58 - .../Preprocessor/aarch64-target-features.c| 4 +- clang/test/Sema/attr-target-clones-aarch64.c | 2 +- .../llvm/TargetParser/AArch64TargetParser.h | 18 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 116 +- llvm/lib/Target/AArch64/AArch64Features.td| 4 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 17 ++- 11 files changed, 144 insertions(+), 134 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mebf16() #[[default]] { __attribute__((target_version("ebf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { @@ -48,7 +48,7 @@ __attribute__((target_version("flagm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mflagm2() #[[flagm2:[0-9]+
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea edited https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/113281 >From 2b416dd0071d45be3f92671f0cb238091689a9dd Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Mon, 21 Oct 2024 17:15:47 +0100 Subject: [PATCH 1/3] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- clang/lib/AST/ASTContext.cpp | 6 +- clang/lib/Basic/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 47 --- clang/test/CodeGen/aarch64-targetattr.c | 4 +- clang/test/CodeGen/attr-target-version.c | 58 - .../Preprocessor/aarch64-target-features.c| 4 +- clang/test/Sema/attr-target-clones-aarch64.c | 2 +- .../llvm/TargetParser/AArch64TargetParser.h | 18 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 116 +- llvm/lib/Target/AArch64/AArch64Features.td| 4 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 17 ++- 11 files changed, 144 insertions(+), 134 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mebf16() #[[default]] { __attribute__((target_version("ebf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { @@ -48,7 +48,7 @@ __attribute__((target_version("flagm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mflagm2() #[[flagm2:[0-9]+
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea ready_for_review https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/113281 >From 2b416dd0071d45be3f92671f0cb238091689a9dd Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Mon, 21 Oct 2024 17:15:47 +0100 Subject: [PATCH 1/2] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- clang/lib/AST/ASTContext.cpp | 6 +- clang/lib/Basic/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 47 --- clang/test/CodeGen/aarch64-targetattr.c | 4 +- clang/test/CodeGen/attr-target-version.c | 58 - .../Preprocessor/aarch64-target-features.c| 4 +- clang/test/Sema/attr-target-clones-aarch64.c | 2 +- .../llvm/TargetParser/AArch64TargetParser.h | 18 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 116 +- llvm/lib/Target/AArch64/AArch64Features.td| 4 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 17 ++- 11 files changed, 144 insertions(+), 134 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mebf16() #[[default]] { __attribute__((target_version("ebf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { @@ -48,7 +48,7 @@ __attribute__((target_version("flagm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mflagm2() #[[flagm2:[0-9]+
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
labrinea wrote: Thanks. IMHO this counts as supporting evidence to why some FMV features are obsolete and should be unified with others or removed from the ACLE spec. https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/jthackray approved this pull request. Looks like a good improvement. https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
@@ -68,19 +68,13 @@ struct ExtensionInfo { #include "llvm/TargetParser/AArch64TargetParserDef.inc" struct FMVInfo { - StringRef Name; // The target_version/target_clones spelling. - CPUFeatures Bit;// Index of the bit in the FMV feature bitset. - StringRef Features; // List of SubtargetFeatures to enable. - unsigned Priority; // FMV priority. - FMVInfo(StringRef Name, CPUFeatures Bit, StringRef Features, + StringRef Name;// The target_version/target_clones spelling. + CPUFeatures Bit; // Index of the bit in the FMV feature bitset. + std::optional ID; // The architecture extension to enable. + unsigned Priority; // FMV priority. + FMVInfo(StringRef Name, CPUFeatures Bit, std::optional ID, unsigned Priority) - : Name(Name), Bit(Bit), Features(Features), Priority(Priority){}; - - SmallVector getImpliedFeatures() { jthackray wrote: Good to see this gone, much cleaner :) https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea updated https://github.com/llvm/llvm-project/pull/113281 >From 2b416dd0071d45be3f92671f0cb238091689a9dd Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Mon, 21 Oct 2024 17:15:47 +0100 Subject: [PATCH 1/2] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- clang/lib/AST/ASTContext.cpp | 6 +- clang/lib/Basic/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 47 --- clang/test/CodeGen/aarch64-targetattr.c | 4 +- clang/test/CodeGen/attr-target-version.c | 58 - .../Preprocessor/aarch64-target-features.c| 4 +- clang/test/Sema/attr-target-clones-aarch64.c | 2 +- .../llvm/TargetParser/AArch64TargetParser.h | 18 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 116 +- llvm/lib/Target/AArch64/AArch64Features.td| 4 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 17 ++- 11 files changed, 144 insertions(+), 134 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mebf16() #[[default]] { __attribute__((target_version("ebf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { @@ -48,7 +48,7 @@ __attribute__((target_version("flagm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mflagm2() #[[flagm2:[0-9]+
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea created https://github.com/llvm/llvm-project/pull/113281 Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 >From 2b416dd0071d45be3f92671f0cb238091689a9dd Mon Sep 17 00:00:00 2001 From: Alexandros Lamprineas Date: Mon, 21 Oct 2024 17:15:47 +0100 Subject: [PATCH] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- clang/lib/AST/ASTContext.cpp | 6 +- clang/lib/Basic/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 47 --- clang/test/CodeGen/aarch64-targetattr.c | 4 +- clang/test/CodeGen/attr-target-version.c | 58 - .../Preprocessor/aarch64-target-features.c| 4 +- clang/test/Sema/attr-target-clones-aarch64.c | 2 +- .../llvm/TargetParser/AArch64TargetParser.h | 18 +-- llvm/lib/Target/AArch64/AArch64FMV.td | 116 +- llvm/lib/Target/AArch64/AArch64Features.td| 4 +- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 17 ++- 11 files changed, 144 insertions(+), 134 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dp
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 34d4f660fe57132d17d2e37b72ccfc1d07269de9 2b416dd0071d45be3f92671f0cb238091689a9dd --extensions h,c,cpp -- clang/lib/AST/ASTContext.cpp clang/lib/Basic/Targets/AArch64.cpp clang/test/CodeGen/aarch64-fmv-dependencies.c clang/test/CodeGen/aarch64-targetattr.c clang/test/CodeGen/attr-target-version.c clang/test/Preprocessor/aarch64-target-features.c clang/test/Sema/attr-target-clones-aarch64.c llvm/include/llvm/TargetParser/AArch64TargetParser.h llvm/utils/TableGen/ARMTargetDefEmitter.cpp `` View the diff from clang-format here. ``diff diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h index db64919d1f..d7b1ba511f 100644 --- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h +++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h @@ -74,7 +74,7 @@ struct FMVInfo { unsigned Priority; // FMV priority. FMVInfo(StringRef Name, CPUFeatures Bit, std::optional ID, unsigned Priority) - : Name(Name), Bit(Bit), ID(ID), Priority(Priority){}; + : Name(Name), Bit(Bit), ID(ID), Priority(Priority) {}; }; const std::vector &getFMVInfo(); `` https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea edited https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
llvmbot wrote: @llvm/pr-subscribers-backend-aarch64 Author: Alexandros Lamprineas (labrinea) Changes Currently we maintain a hand written list of subtarget features which we are implied for a given FMV feature. It is more robust to expand such dependencies using ExtensionDependency from TargetParser, since that is generated by tablegen. For this to work each FMV feature must have a corresponding SubtargetFeature in place. There are a few FMV features which don't satisfy this criteria. We are reviewing them in the ACLE specification. I have also added the missing dependences: * FEAT_DPB2 -> FEAT_DPB * FEAT_FlagM2 -> FEAT_FlagM Blocked on https://github.com/ARM-software/acle/pull/315 --- Patch is 41.94 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/113281.diff 11 Files Affected: - (modified) clang/lib/AST/ASTContext.cpp (+4-2) - (modified) clang/lib/Basic/Targets/AArch64.cpp (+1-1) - (modified) clang/test/CodeGen/aarch64-fmv-dependencies.c (+23-24) - (modified) clang/test/CodeGen/aarch64-targetattr.c (+2-2) - (modified) clang/test/CodeGen/attr-target-version.c (+29-29) - (modified) clang/test/Preprocessor/aarch64-target-features.c (+2-2) - (modified) clang/test/Sema/attr-target-clones-aarch64.c (+1-1) - (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+6-12) - (modified) llvm/lib/Target/AArch64/AArch64FMV.td (+58-58) - (modified) llvm/lib/Target/AArch64/AArch64Features.td (+2-2) - (modified) llvm/utils/TableGen/ARMTargetDefEmitter.cpp (+16-1) ``diff diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 4bf8ddd762e9a5..fa7c682b9303ef 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -14251,10 +14251,12 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl &FMVFeatStrings) { std::vector BackendFeats; + llvm::AArch64::ExtensionSet FeatureBits; for (StringRef F : FMVFeatStrings) if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) - for (StringRef F : FMVExt->getImpliedFeatures()) -BackendFeats.push_back(F.str()); + if (FMVExt->ID) +FeatureBits.enable(*FMVExt->ID); + FeatureBits.toLLVMFeatureList(BackendFeats); return BackendFeats; } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 3dbba2b4d25bd6..d5b932f76ed9ad 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -722,7 +722,7 @@ unsigned AArch64TargetInfo::multiVersionFeatureCost() const { bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { // FMV extensions which imply no backend features do not affect codegen. if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) -return !Ext->Features.empty(); +return Ext->ID.has_value(); return false; } diff --git a/clang/test/CodeGen/aarch64-fmv-dependencies.c b/clang/test/CodeGen/aarch64-fmv-dependencies.c index 9aca1b7a9daf6e..bc73d16501e50e 100644 --- a/clang/test/CodeGen/aarch64-fmv-dependencies.c +++ b/clang/test/CodeGen/aarch64-fmv-dependencies.c @@ -3,10 +3,10 @@ // RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -emit-llvm -S -o - %s | FileCheck %s -// CHECK: define dso_local i32 @fmv._Maes() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Maes() #[[aes:[0-9]+]] { __attribute__((target_version("aes"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mbf16() #[[bf16:[0-9]+]] { __attribute__((target_version("bf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mbti() #[[bti:[0-9]+]] { @@ -15,7 +15,7 @@ __attribute__((target_version("bti"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mcrc() #[[crc:[0-9]+]] { __attribute__((target_version("crc"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mdgh() #[[ATTR0:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mdgh() #[[default:[0-9]+]] { __attribute__((target_version("dgh"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdit() #[[dit:[0-9]+]] { @@ -30,7 +30,7 @@ __attribute__((target_version("dpb"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mdpb2() #[[dpb2:[0-9]+]] { __attribute__((target_version("dpb2"))) int fmv(void) { return 0; } -// CHECK: define dso_local i32 @fmv._Mebf16() #[[bf16_ebf16:[0-9]+]] { +// CHECK: define dso_local i32 @fmv._Mebf16() #[[default]] { __attribute__((target_version("ebf16"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mf32mm() #[[f32mm:[0-9]+]] { @@ -48,7 +48,7 @@ __attribute__((target_version("flagm"))) int fmv(void) { return 0; } // CHECK: define dso_local i32 @fmv._Mflagm2() #[[flagm2:[0-9]+]] { __attribute__((target_version("flagm2"
[clang] [llvm] [FMV][AArch64] Expand feature dependencies using AArch64::ExtensionSet. (PR #113281)
https://github.com/labrinea converted_to_draft https://github.com/llvm/llvm-project/pull/113281 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits