diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-01-06 04:26:34 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2015-01-06 04:26:34 +0000 |
commit | a2823578e6c502bcf83343df3036231874852cc6 (patch) | |
tree | f23244499ebd0d91fd46a7d1a35c2a7ff25e954a /clang/lib/Basic/Targets.cpp | |
parent | 0f2c4ac6497329a19b877d56be15c9cebbeaf026 (diff) | |
download | bcm5719-llvm-a2823578e6c502bcf83343df3036231874852cc6.tar.gz bcm5719-llvm-a2823578e6c502bcf83343df3036231874852cc6.zip |
Sema: analyze I,J,K,M,N,O constraints
Add additional constraint checking for target specific behaviour for inline
assembly constraints. We would previously silently let all arguments through
for these constraints. In cases where the constraints were violated, we could
end up failing to select instructions and triggering assertions or worse,
silently ignoring instructions.
llvm-svn: 225244
Diffstat (limited to 'clang/lib/Basic/Targets.cpp')
-rw-r--r-- | clang/lib/Basic/Targets.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp index 8c79a18d08b..c74bb936e3a 100644 --- a/clang/lib/Basic/Targets.cpp +++ b/clang/lib/Basic/Targets.cpp @@ -3102,6 +3102,28 @@ X86TargetInfo::validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const { switch (*Name) { default: return false; + case 'I': + Info.setRequiresImmediate(0, 31); + return true; + case 'J': + Info.setRequiresImmediate(0, 63); + return true; + case 'K': + Info.setRequiresImmediate(-128, 127); + return true; + case 'L': + // FIXME: properly analyze this constraint: + // must be one of 0xff, 0xffff, or 0xffffffff + return true; + case 'M': + Info.setRequiresImmediate(0, 3); + return true; + case 'N': + Info.setRequiresImmediate(0, 255); + return true; + case 'O': + Info.setRequiresImmediate(0, 127); + return true; case 'Y': // first letter of a pair: switch (*(Name+1)) { default: return false; @@ -4289,6 +4311,13 @@ public: case 'P': // VFP Floating point register double precision Info.setAllowsRegister(); return true; + case 'I': + case 'J': + case 'K': + case 'L': + case 'M': + // FIXME + return true; case 'Q': // A memory address that is a single base register. Info.setAllowsMemory(); return true; @@ -5152,6 +5181,16 @@ public: bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override { // FIXME: Implement! + switch (*Name) { + case 'I': // Signed 13-bit constant + case 'J': // Zero + case 'K': // 32-bit constant with the low 12 bits clear + case 'L': // A constant in the range supported by movcc (11-bit signed imm) + case 'M': // A constant in the range supported by movrcc (19-bit signed imm) + case 'N': // Same as 'K' but zext (required for SIMode) + case 'O': // The constant 4096 + return true; + } return false; } const char *getClobbers() const override { @@ -5444,6 +5483,13 @@ namespace { bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override { + // FIXME: implement + switch (*Name) { + case 'K': // the constant 1 + case 'L': // constant -1^20 .. 1^19 + case 'M': // constant 1-4: + return true; + } // No target constraints for now. return false; } @@ -5740,6 +5786,15 @@ public: case 'x': // hilo register pair Info.setAllowsRegister(); return true; + case 'I': // Signed 16-bit constant + case 'J': // Integer 0 + case 'K': // Unsigned 16-bit constant + case 'L': // Signed 32-bit constant, lower 16-bit zeros (for lui) + case 'M': // Constants not loadable via lui, addiu, or ori + case 'N': // Constant -1 to -65535 + case 'O': // A signed 15-bit constant + case 'P': // A constant between 1 go 65535 + return true; case 'R': // An address that can be used in a non-macro load or store Info.setAllowsMemory(); return true; |