diff options
author | Craig Topper <craig.topper@intel.com> | 2019-12-23 10:38:38 -0800 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2019-12-23 11:23:30 -0800 |
commit | d35bcbbb5dab0e29b21a586505f5b274377cc41b (patch) | |
tree | b399b117ee4e29e3cc28cd3277a64c4d92a6481b /clang/lib/Basic | |
parent | e028cee66a23da568ba62c6323c6a29f4c7f63ae (diff) | |
download | bcm5719-llvm-d35bcbbb5dab0e29b21a586505f5b274377cc41b.tar.gz bcm5719-llvm-d35bcbbb5dab0e29b21a586505f5b274377cc41b.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 moves some of the code from CodeGen to create an
appropriate feature map that we can pass to the function.
Differential Revision: https://reviews.llvm.org/D68627
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r-- | clang/lib/Basic/Targets/X86.cpp | 19 | ||||
-rw-r--r-- | clang/lib/Basic/Targets/X86.h | 15 |
2 files changed, 20 insertions, 14 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; diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index 604198b0047..5b5e284e514 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -194,9 +194,11 @@ public: return false; } - bool validateOutputSize(StringRef Constraint, unsigned Size) const override; + bool validateOutputSize(const llvm::StringMap<bool> &FeatureMap, + StringRef Constraint, unsigned Size) const override; - bool validateInputSize(StringRef Constraint, unsigned Size) const override; + bool validateInputSize(const llvm::StringMap<bool> &FeatureMap, + StringRef Constraint, unsigned Size) const override; virtual bool checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override { @@ -208,8 +210,8 @@ public: return true; }; - - virtual bool validateOperandSize(StringRef Constraint, unsigned Size) const; + virtual bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap, + StringRef Constraint, unsigned Size) const; std::string convertConstraint(const char *&Constraint) const override; const char *getClobbers() const override { @@ -397,7 +399,8 @@ public: return -1; } - bool validateOperandSize(StringRef Constraint, unsigned Size) const override { + bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap, + StringRef Constraint, unsigned Size) const override { switch (Constraint[0]) { default: break; @@ -415,7 +418,7 @@ public: return Size <= 64; } - return X86TargetInfo::validateOperandSize(Constraint, Size); + return X86TargetInfo::validateOperandSize(FeatureMap, Constraint, Size); } void setMaxAtomicWidth() override { |