diff options
author | Craig Topper <craig.topper@intel.com> | 2019-12-06 15:08:32 -0800 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2019-12-06 15:30:59 -0800 |
commit | e1578fd2b79fe5af5f80c0c166a8abd0f816c022 (patch) | |
tree | 3c574452f50c324277fbd0ebad71b5c2cfbcc3ae /clang/lib/Basic/Targets/X86.cpp | |
parent | 60573ae6fe509b618dc6a2c5c55d921bccd77608 (diff) | |
download | bcm5719-llvm-e1578fd2b79fe5af5f80c0c166a8abd0f816c022.tar.gz bcm5719-llvm-e1578fd2b79fe5af5f80c0c166a8abd0f816c022.zip |
[Sema][X86] Consider target attribute into the checks in validateOutputSize and validateInputSize.
The validateOutputSize and validateInputSize need to check whether
AVX or AVX512 are enabled. But this can be affected by the
target attribute so we need to factor that in.
This patch copies some of the code from CodeGen to create an
appropriate feature map that we can pass to the function. Probably
need some refactoring here to share more code with Codegen. Is
there a good place to do that? Also need to support the cpu_specific
attribute as well.
Differential Revision: https://reviews.llvm.org/D68627
Diffstat (limited to 'clang/lib/Basic/Targets/X86.cpp')
-rw-r--r-- | clang/lib/Basic/Targets/X86.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 51f2006ddbd..d099d3742f0 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -1731,21 +1731,24 @@ bool X86TargetInfo::validateAsmConstraint( } } -bool X86TargetInfo::validateOutputSize(StringRef Constraint, +bool X86TargetInfo::validateOutputSize(const llvm::StringMap<bool> &FeatureMap, + StringRef Constraint, unsigned Size) const { // Strip off constraint modifiers. while (Constraint[0] == '=' || Constraint[0] == '+' || Constraint[0] == '&') Constraint = Constraint.substr(1); - return validateOperandSize(Constraint, Size); + return validateOperandSize(FeatureMap, Constraint, Size); } -bool X86TargetInfo::validateInputSize(StringRef Constraint, +bool X86TargetInfo::validateInputSize(const llvm::StringMap<bool> &FeatureMap, + StringRef Constraint, unsigned Size) const { - return validateOperandSize(Constraint, Size); + return validateOperandSize(FeatureMap, Constraint, Size); } -bool X86TargetInfo::validateOperandSize(StringRef Constraint, +bool X86TargetInfo::validateOperandSize(const llvm::StringMap<bool> &FeatureMap, + StringRef Constraint, unsigned Size) const { switch (Constraint[0]) { default: @@ -1770,7 +1773,7 @@ bool X86TargetInfo::validateOperandSize(StringRef Constraint, case 'z': case '0': // XMM0 - if (SSELevel >= SSE1) + if (FeatureMap.lookup("sse")) return Size <= 128U; return false; case 'i': @@ -1784,10 +1787,10 @@ bool X86TargetInfo::validateOperandSize(StringRef Constraint, LLVM_FALLTHROUGH; case 'v': case 'x': - if (SSELevel >= AVX512F) + if (FeatureMap.lookup("avx512f")) // 512-bit zmm registers can be used if target supports AVX512F. return Size <= 512U; - else if (SSELevel >= AVX) + else if (FeatureMap.lookup("avx")) // 256-bit ymm registers can be used if target supports AVX. return Size <= 256U; return Size <= 128U; |