diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2014-08-22 06:05:21 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2014-08-22 06:05:21 +0000 |
commit | 987f1864caeb3b685e03d78c7316b97c506b649f (patch) | |
tree | 296cf883168550c66c87af1a4588cd53dd262dc6 /clang/lib/Basic/Targets.cpp | |
parent | 118da50a2aa6eb6464cf39e81b165f171fa13802 (diff) | |
download | bcm5719-llvm-987f1864caeb3b685e03d78c7316b97c506b649f.tar.gz bcm5719-llvm-987f1864caeb3b685e03d78c7316b97c506b649f.zip |
[AArch64, inline-asm] Improve diagnostic that is printed when the size of a
variable that has regiser constraint "r" is not 64-bit.
General register operands are output using 64-bit "x" register names, regardless
of the size of the variable, unless the asm operand is prefixed with the "%w"
modifier. This surprises and confuses many users who aren't familiar with
aarch64 inline assembly rules.
With this commit, a note and fixit hint are printed which tell the users that
they need modifier "%w" in order to output a "w" register instead of an "x"
register.
<rdar://problem/12764785>
llvm-svn: 216260
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index d1eba5af470..2e655897220 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -4145,8 +4145,10 @@ public: } return R; } - bool validateConstraintModifier(StringRef Constraint, const char Modifier, - unsigned Size) const override { + bool + validateConstraintModifier(StringRef Constraint, const char Modifier, + unsigned Size, + std::string &SuggestedModifier) const override { bool isOutput = (Constraint[0] == '='); bool isInOut = (Constraint[0] == '+'); @@ -4592,9 +4594,10 @@ public: return false; } - virtual bool validateConstraintModifier(StringRef Constraint, - const char Modifier, - unsigned Size) const { + bool + validateConstraintModifier(StringRef Constraint, const char Modifier, + unsigned Size, + std::string &SuggestedModifier) const override { // Strip off constraint modifiers. while (Constraint[0] == '=' || Constraint[0] == '+' || Constraint[0] == '&') Constraint = Constraint.substr(1); @@ -4613,7 +4616,11 @@ public: default: // By default an 'r' constraint will be in the 'x' // registers. - return Size == 64; + if (Size == 64) + return true; + + SuggestedModifier = "w"; + return false; } } } |