aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorBenjamin Maxwell <benjamin.maxwell@arm.com>2023-12-05 11:29:31 +0000
committerGitHub <noreply@github.com>2023-12-05 11:29:31 +0000
commit17de468df1af6479f31bb8c02973e01702f7b240 (patch)
treea2c40165fa61a88d5934d883ad8108b134a651ff /llvm/lib/Transforms/Utils/Local.cpp
parent77249546aa5114b36734123fe5bb65310e516aea (diff)
downloadllvm-17de468df1af6479f31bb8c02973e01702f7b240.zip
llvm-17de468df1af6479f31bb8c02973e01702f7b240.tar.gz
llvm-17de468df1af6479f31bb8c02973e01702f7b240.tar.bz2
[mlir][llvm] Add llvm.target_features features attribute (#71510)
This patch adds a target_features (TargetFeaturesAttr) to the LLVM dialect to allow setting and querying the features in use on a function. The motivation for this comes from the Arm SME dialect where we would like a convenient way to check what variants of an operation are available based on the CPU features. Intended usage: The target_features attribute is populated manually or by a pass: ```mlir func.func @example() attributes { target_features = #llvm.target_features<["+sme", "+sve", "+sme-f64f64"]> } { // ... } ``` Then within a later rewrite the attribute can be checked, and used to make lowering decisions. ```c++ // Finds the "target_features" attribute on the parent // FunctionOpInterface. auto targetFeatures = LLVM::TargetFeaturesAttr::featuresAt(op); // Check a feature. // Returns false if targetFeatures is null or the feature is not in // the list. if (!targetFeatures.contains("+sme-f64f64")) return failure(); ``` For now, this is rather simple just checks if the exact feature is in the list, though it could be possible to extend with implied features using information from LLVM.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
0 files changed, 0 insertions, 0 deletions