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 | 9d1ee1175de34aca8fce8cdca268e7a3287327ed (patch) | |
| tree | 41ca6a12ed50d989909f749c13c3f2cb503175a4 /clang/lib/Basic | |
| parent | 3750e7776bb6fd102fb6b351feadcfebd1659ff3 (diff) | |
| download | bcm5719-llvm-9d1ee1175de34aca8fce8cdca268e7a3287327ed.tar.gz bcm5719-llvm-9d1ee1175de34aca8fce8cdca268e7a3287327ed.zip | |
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>
llvm-svn: 166737
Diffstat (limited to 'clang/lib/Basic')
| -rw-r--r-- | clang/lib/Basic/Targets.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 9b758d1c212..1ab151e5efd 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/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 ""; |

