diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-10-25 23:28:48 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-10-25 23:28:48 +0000 |
commit | 50d46caf00c743312e0ea1f87a693d504b12ef51 (patch) | |
tree | c85a7b3c95f7b2562d03eaf1b95373a2ad5d284c /lib/Basic/Targets.cpp | |
parent | d6f833091fbacc73980b9c4018363455b6aa82a7 (diff) |
Recommit Eric's code to validate ASM string's constraints and modifiers.
This code checks the ASM string to see if the output size is able to fit within
the variable specified as the output. For instance, scalar-to-vector conversions
may not really work. It's on by default, but can be turned off with a flag if
you think you know what you're doing.
This is placed under a flag ('-Wasm-operand-widths') and flag group ('-Wasm').
<rdar://problem/12284092>
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166737 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Basic/Targets.cpp')
-rw-r--r-- | lib/Basic/Targets.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 9b758d1c21..1ab151e5ef 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -3315,6 +3315,30 @@ public: } return R; } + virtual bool validateConstraintModifier(StringRef Constraint, + const char Modifier, + unsigned Size) const { + // Strip off constraint modifiers. + while (Constraint[0] == '=' || + Constraint[0] == '+' || + Constraint[0] == '&') + Constraint = Constraint.substr(1); + + switch (Constraint[0]) { + default: break; + case 'r': { + switch (Modifier) { + default: + return Size == 32; + case 'q': + // A register of size 32 cannot fit a vector type. + return false; + } + } + } + + return true; + } virtual const char *getClobbers() const { // FIXME: Is this really right? return ""; |