2006-10-14 15:06:20 +08:00
|
|
|
//===--- TargetInfo.cpp - Information about Target machine ----------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 03:59:25 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2006-10-14 15:06:20 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the TargetInfo and TargetInfoImpl interfaces.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "clang/Basic/TargetInfo.h"
|
2009-11-06 04:14:16 +08:00
|
|
|
#include "clang/Basic/LangOptions.h"
|
2007-09-23 02:29:59 +08:00
|
|
|
#include "llvm/ADT/APFloat.h"
|
2007-11-25 08:25:21 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2010-12-20 04:49:25 +08:00
|
|
|
#include <cctype>
|
2008-04-06 12:02:29 +08:00
|
|
|
#include <cstdlib>
|
2006-10-14 15:06:20 +08:00
|
|
|
using namespace clang;
|
|
|
|
|
2008-03-08 16:59:43 +08:00
|
|
|
// TargetInfo Constructor.
|
|
|
|
TargetInfo::TargetInfo(const std::string &T) : Triple(T) {
|
2010-04-15 14:18:39 +08:00
|
|
|
// Set defaults. Defaults are set for a 32-bit RISC platform, like PPC or
|
|
|
|
// SPARC. These should be overridden by concrete targets as needed.
|
2009-04-20 05:38:35 +08:00
|
|
|
TLSSupported = true;
|
2010-04-24 00:29:58 +08:00
|
|
|
NoAsmVariants = false;
|
2008-05-09 14:08:39 +08:00
|
|
|
PointerWidth = PointerAlign = 32;
|
2011-01-06 16:27:10 +08:00
|
|
|
BoolWidth = BoolAlign = 8;
|
2008-05-08 13:58:21 +08:00
|
|
|
IntWidth = IntAlign = 32;
|
2008-05-09 13:50:02 +08:00
|
|
|
LongWidth = LongAlign = 32;
|
|
|
|
LongLongWidth = LongLongAlign = 64;
|
2008-05-20 22:21:01 +08:00
|
|
|
FloatWidth = 32;
|
|
|
|
FloatAlign = 32;
|
2008-04-19 01:17:24 +08:00
|
|
|
DoubleWidth = 64;
|
2008-05-20 22:21:01 +08:00
|
|
|
DoubleAlign = 64;
|
|
|
|
LongDoubleWidth = 64;
|
|
|
|
LongDoubleAlign = 64;
|
2010-06-05 07:15:27 +08:00
|
|
|
LargeArrayMinWidth = 0;
|
|
|
|
LargeArrayAlign = 0;
|
2008-11-01 00:05:19 +08:00
|
|
|
SizeType = UnsignedLong;
|
2008-11-02 10:43:55 +08:00
|
|
|
PtrDiffType = SignedLong;
|
2008-10-31 17:52:39 +08:00
|
|
|
IntMaxType = SignedLongLong;
|
|
|
|
UIntMaxType = UnsignedLongLong;
|
2009-02-14 06:28:55 +08:00
|
|
|
IntPtrType = SignedLong;
|
2008-11-02 10:43:55 +08:00
|
|
|
WCharType = SignedInt;
|
2009-10-21 12:59:34 +08:00
|
|
|
WIntType = SignedInt;
|
2009-07-14 14:30:34 +08:00
|
|
|
Char16Type = UnsignedShort;
|
|
|
|
Char32Type = UnsignedInt;
|
2009-07-01 11:36:11 +08:00
|
|
|
Int64Type = SignedLongLong;
|
2009-11-21 08:49:54 +08:00
|
|
|
SigAtomicType = SignedInt;
|
2010-04-15 23:06:18 +08:00
|
|
|
UseBitFieldTypeAlignment = true;
|
2008-03-08 16:59:43 +08:00
|
|
|
FloatFormat = &llvm::APFloat::IEEEsingle;
|
|
|
|
DoubleFormat = &llvm::APFloat::IEEEdouble;
|
|
|
|
LongDoubleFormat = &llvm::APFloat::IEEEdouble;
|
2008-08-21 08:13:15 +08:00
|
|
|
DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
|
2009-11-08 02:59:41 +08:00
|
|
|
"i64:64:64-f32:32:32-f64:64:64-n32";
|
2008-10-06 03:22:37 +08:00
|
|
|
UserLabelPrefix = "_";
|
2011-02-11 00:52:03 +08:00
|
|
|
MCountName = "mcount";
|
2010-05-27 08:35:16 +08:00
|
|
|
HasAlignMac68kSupport = false;
|
2010-07-15 07:39:36 +08:00
|
|
|
|
|
|
|
// Default to no types using fpret.
|
|
|
|
RealTypeUsesObjCFPRet = 0;
|
2010-08-22 06:46:04 +08:00
|
|
|
|
|
|
|
// Default to using the Itanium ABI.
|
|
|
|
CXXABI = CXXABI_Itanium;
|
2007-09-23 02:29:59 +08:00
|
|
|
}
|
|
|
|
|
2008-03-08 16:59:43 +08:00
|
|
|
// Out of line virtual dtor for TargetInfo.
|
|
|
|
TargetInfo::~TargetInfo() {}
|
2007-09-23 02:29:59 +08:00
|
|
|
|
2009-02-06 13:04:11 +08:00
|
|
|
/// getTypeName - Return the user string for the specified integer type enum.
|
|
|
|
/// For example, SignedShort -> "short".
|
|
|
|
const char *TargetInfo::getTypeName(IntType T) {
|
|
|
|
switch (T) {
|
|
|
|
default: assert(0 && "not an integer!");
|
|
|
|
case SignedShort: return "short";
|
|
|
|
case UnsignedShort: return "unsigned short";
|
|
|
|
case SignedInt: return "int";
|
|
|
|
case UnsignedInt: return "unsigned int";
|
|
|
|
case SignedLong: return "long int";
|
|
|
|
case UnsignedLong: return "long unsigned int";
|
|
|
|
case SignedLongLong: return "long long int";
|
|
|
|
case UnsignedLongLong: return "long long unsigned int";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-21 14:24:21 +08:00
|
|
|
/// getTypeConstantSuffix - Return the constant suffix for the specified
|
|
|
|
/// integer type enum. For example, SignedLong -> "L".
|
|
|
|
const char *TargetInfo::getTypeConstantSuffix(IntType T) {
|
|
|
|
switch (T) {
|
|
|
|
default: assert(0 && "not an integer!");
|
|
|
|
case SignedShort:
|
|
|
|
case SignedInt: return "";
|
|
|
|
case SignedLong: return "L";
|
|
|
|
case SignedLongLong: return "LL";
|
|
|
|
case UnsignedShort:
|
|
|
|
case UnsignedInt: return "U";
|
|
|
|
case UnsignedLong: return "UL";
|
|
|
|
case UnsignedLongLong: return "ULL";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-18 15:10:59 +08:00
|
|
|
/// getTypeWidth - Return the width (in bits) of the specified integer type
|
2009-10-21 14:24:21 +08:00
|
|
|
/// enum. For example, SignedInt -> getIntWidth().
|
|
|
|
unsigned TargetInfo::getTypeWidth(IntType T) const {
|
|
|
|
switch (T) {
|
|
|
|
default: assert(0 && "not an integer!");
|
2009-11-06 05:21:32 +08:00
|
|
|
case SignedShort:
|
2009-10-21 14:24:21 +08:00
|
|
|
case UnsignedShort: return getShortWidth();
|
2009-11-06 05:21:32 +08:00
|
|
|
case SignedInt:
|
2009-10-21 14:24:21 +08:00
|
|
|
case UnsignedInt: return getIntWidth();
|
2009-11-06 05:21:32 +08:00
|
|
|
case SignedLong:
|
2009-10-21 14:24:21 +08:00
|
|
|
case UnsignedLong: return getLongWidth();
|
2009-11-06 05:21:32 +08:00
|
|
|
case SignedLongLong:
|
2009-10-21 14:24:21 +08:00
|
|
|
case UnsignedLongLong: return getLongLongWidth();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2010-10-18 15:10:59 +08:00
|
|
|
/// getTypeAlign - Return the alignment (in bits) of the specified integer type
|
2009-11-06 05:21:32 +08:00
|
|
|
/// enum. For example, SignedInt -> getIntAlign().
|
|
|
|
unsigned TargetInfo::getTypeAlign(IntType T) const {
|
|
|
|
switch (T) {
|
|
|
|
default: assert(0 && "not an integer!");
|
|
|
|
case SignedShort:
|
|
|
|
case UnsignedShort: return getShortAlign();
|
|
|
|
case SignedInt:
|
|
|
|
case UnsignedInt: return getIntAlign();
|
|
|
|
case SignedLong:
|
|
|
|
case UnsignedLong: return getLongAlign();
|
|
|
|
case SignedLongLong:
|
|
|
|
case UnsignedLongLong: return getLongLongAlign();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2009-10-26 06:49:18 +08:00
|
|
|
/// isTypeSigned - Return whether an integer types is signed. Returns true if
|
2009-10-21 14:24:21 +08:00
|
|
|
/// the type is signed; false otherwise.
|
2010-12-26 07:25:43 +08:00
|
|
|
bool TargetInfo::isTypeSigned(IntType T) {
|
2009-10-21 14:24:21 +08:00
|
|
|
switch (T) {
|
|
|
|
default: assert(0 && "not an integer!");
|
|
|
|
case SignedShort:
|
|
|
|
case SignedInt:
|
|
|
|
case SignedLong:
|
2010-10-18 15:10:59 +08:00
|
|
|
case SignedLongLong:
|
2009-10-21 14:24:21 +08:00
|
|
|
return true;
|
|
|
|
case UnsignedShort:
|
|
|
|
case UnsignedInt:
|
|
|
|
case UnsignedLong:
|
2010-10-18 15:10:59 +08:00
|
|
|
case UnsignedLongLong:
|
2009-10-21 14:24:21 +08:00
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2009-11-06 04:14:16 +08:00
|
|
|
/// setForcedLangOptions - Set forced language options.
|
|
|
|
/// Apply changes to the target information with respect to certain
|
|
|
|
/// language options which change the target configuration.
|
|
|
|
void TargetInfo::setForcedLangOptions(LangOptions &Opts) {
|
2010-04-15 23:06:22 +08:00
|
|
|
if (Opts.NoBitFieldTypeAlign)
|
|
|
|
UseBitFieldTypeAlignment = false;
|
|
|
|
if (Opts.ShortWChar)
|
2009-11-06 04:14:16 +08:00
|
|
|
WCharType = UnsignedShort;
|
|
|
|
}
|
2009-10-21 14:24:21 +08:00
|
|
|
|
2007-09-23 02:29:59 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2007-01-29 13:24:35 +08:00
|
|
|
|
2010-01-31 03:12:25 +08:00
|
|
|
static llvm::StringRef removeGCCRegisterPrefix(llvm::StringRef Name) {
|
2008-02-06 08:11:32 +08:00
|
|
|
if (Name[0] == '%' || Name[0] == '#')
|
2010-01-31 03:12:25 +08:00
|
|
|
Name = Name.substr(1);
|
2010-10-18 15:10:59 +08:00
|
|
|
|
2010-01-31 03:12:25 +08:00
|
|
|
return Name;
|
2008-02-06 08:11:32 +08:00
|
|
|
}
|
|
|
|
|
2007-11-25 07:38:12 +08:00
|
|
|
/// isValidGCCRegisterName - Returns whether the passed in string
|
|
|
|
/// is a valid register name according to GCC. This is used by Sema for
|
|
|
|
/// inline asm statements.
|
2010-01-31 03:12:25 +08:00
|
|
|
bool TargetInfo::isValidGCCRegisterName(llvm::StringRef Name) const {
|
|
|
|
if (Name.empty())
|
|
|
|
return false;
|
2010-10-18 15:10:59 +08:00
|
|
|
|
2007-11-25 08:25:21 +08:00
|
|
|
const char * const *Names;
|
|
|
|
unsigned NumNames;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-25 08:25:21 +08:00
|
|
|
// Get rid of any register prefix.
|
2010-01-31 03:12:25 +08:00
|
|
|
Name = removeGCCRegisterPrefix(Name);
|
2008-02-06 08:11:32 +08:00
|
|
|
|
2010-01-31 03:12:25 +08:00
|
|
|
if (Name == "memory" || Name == "cc")
|
2007-11-25 08:25:21 +08:00
|
|
|
return true;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-03-08 16:24:01 +08:00
|
|
|
getGCCRegNames(Names, NumNames);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-25 08:25:21 +08:00
|
|
|
// If we have a number it maps to an entry in the register name array.
|
|
|
|
if (isdigit(Name[0])) {
|
2010-01-31 03:12:25 +08:00
|
|
|
int n;
|
|
|
|
if (!Name.getAsInteger(0, n))
|
2007-11-25 08:25:21 +08:00
|
|
|
return n >= 0 && (unsigned)n < NumNames;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check register names.
|
|
|
|
for (unsigned i = 0; i < NumNames; i++) {
|
2010-01-31 03:12:25 +08:00
|
|
|
if (Name == Names[i])
|
2007-11-25 08:25:21 +08:00
|
|
|
return true;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-25 08:25:21 +08:00
|
|
|
// Now check aliases.
|
2008-03-08 16:24:01 +08:00
|
|
|
const GCCRegAlias *Aliases;
|
2007-11-25 08:25:21 +08:00
|
|
|
unsigned NumAliases;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-03-08 16:24:01 +08:00
|
|
|
getGCCRegAliases(Aliases, NumAliases);
|
2007-11-25 08:25:21 +08:00
|
|
|
for (unsigned i = 0; i < NumAliases; i++) {
|
|
|
|
for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
|
|
|
|
if (!Aliases[i].Aliases[j])
|
|
|
|
break;
|
2010-01-31 03:12:25 +08:00
|
|
|
if (Aliases[i].Aliases[j] == Name)
|
2007-11-25 08:25:21 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-25 07:38:12 +08:00
|
|
|
return false;
|
|
|
|
}
|
2007-11-27 12:11:28 +08:00
|
|
|
|
2010-10-18 15:10:59 +08:00
|
|
|
llvm::StringRef
|
2010-01-31 03:12:25 +08:00
|
|
|
TargetInfo::getNormalizedGCCRegisterName(llvm::StringRef Name) const {
|
2007-11-27 12:11:28 +08:00
|
|
|
assert(isValidGCCRegisterName(Name) && "Invalid register passed in");
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-01-31 03:12:25 +08:00
|
|
|
// Get rid of any register prefix.
|
|
|
|
Name = removeGCCRegisterPrefix(Name);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-27 12:11:28 +08:00
|
|
|
const char * const *Names;
|
|
|
|
unsigned NumNames;
|
|
|
|
|
2008-03-08 16:24:01 +08:00
|
|
|
getGCCRegNames(Names, NumNames);
|
2007-11-27 12:11:28 +08:00
|
|
|
|
|
|
|
// First, check if we have a number.
|
|
|
|
if (isdigit(Name[0])) {
|
2010-01-31 03:12:25 +08:00
|
|
|
int n;
|
|
|
|
if (!Name.getAsInteger(0, n)) {
|
2009-09-09 23:08:12 +08:00
|
|
|
assert(n >= 0 && (unsigned)n < NumNames &&
|
2007-11-27 12:11:28 +08:00
|
|
|
"Out of bounds register number!");
|
|
|
|
return Names[n];
|
|
|
|
}
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-27 12:11:28 +08:00
|
|
|
// Now check aliases.
|
2008-03-08 16:24:01 +08:00
|
|
|
const GCCRegAlias *Aliases;
|
2007-11-27 12:11:28 +08:00
|
|
|
unsigned NumAliases;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2008-03-08 16:24:01 +08:00
|
|
|
getGCCRegAliases(Aliases, NumAliases);
|
2007-11-27 12:11:28 +08:00
|
|
|
for (unsigned i = 0; i < NumAliases; i++) {
|
|
|
|
for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
|
|
|
|
if (!Aliases[i].Aliases[j])
|
|
|
|
break;
|
2010-01-31 03:12:25 +08:00
|
|
|
if (Aliases[i].Aliases[j] == Name)
|
2007-11-27 12:11:28 +08:00
|
|
|
return Aliases[i].Register;
|
|
|
|
}
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-27 12:11:28 +08:00
|
|
|
return Name;
|
|
|
|
}
|
|
|
|
|
2009-04-27 01:19:08 +08:00
|
|
|
bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
|
|
|
|
const char *Name = Info.getConstraintStr().c_str();
|
2007-11-27 12:11:28 +08:00
|
|
|
// An output constraint must start with '=' or '+'
|
|
|
|
if (*Name != '=' && *Name != '+')
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (*Name == '+')
|
2009-04-26 15:16:29 +08:00
|
|
|
Info.setIsReadWrite();
|
2007-11-27 12:11:28 +08:00
|
|
|
|
|
|
|
Name++;
|
|
|
|
while (*Name) {
|
|
|
|
switch (*Name) {
|
|
|
|
default:
|
2009-04-26 15:16:29 +08:00
|
|
|
if (!validateAsmConstraint(Name, Info)) {
|
2008-04-25 00:36:38 +08:00
|
|
|
// FIXME: We temporarily return false
|
2007-11-27 12:11:28 +08:00
|
|
|
// so we can add more constraints as we hit it.
|
|
|
|
// Eventually, an unknown constraint should just be treated as 'g'.
|
2008-04-25 00:36:38 +08:00
|
|
|
return false;
|
2007-11-27 12:11:28 +08:00
|
|
|
}
|
|
|
|
case '&': // early clobber.
|
|
|
|
break;
|
2009-10-13 12:32:07 +08:00
|
|
|
case '%': // commutative.
|
|
|
|
// FIXME: Check that there is a another register after this one.
|
|
|
|
break;
|
2007-11-27 12:11:28 +08:00
|
|
|
case 'r': // general register.
|
2009-04-26 15:16:29 +08:00
|
|
|
Info.setAllowsRegister();
|
2007-11-27 12:11:28 +08:00
|
|
|
break;
|
|
|
|
case 'm': // memory operand.
|
2010-09-08 02:40:41 +08:00
|
|
|
case 'o': // offsetable memory operand.
|
|
|
|
case 'V': // non-offsetable memory operand.
|
|
|
|
case '<': // autodecrement memory operand.
|
|
|
|
case '>': // autoincrement memory operand.
|
2009-04-26 15:16:29 +08:00
|
|
|
Info.setAllowsMemory();
|
2007-11-27 12:11:28 +08:00
|
|
|
break;
|
|
|
|
case 'g': // general register, memory operand or immediate integer.
|
2009-01-18 10:12:04 +08:00
|
|
|
case 'X': // any operand.
|
2009-04-26 15:16:29 +08:00
|
|
|
Info.setAllowsRegister();
|
|
|
|
Info.setAllowsMemory();
|
2007-11-27 12:11:28 +08:00
|
|
|
break;
|
2010-08-11 03:20:14 +08:00
|
|
|
case ',': // multiple alternative constraint. Pass it.
|
2010-08-11 08:58:20 +08:00
|
|
|
// Handle additional optional '=' or '+' modifiers.
|
2010-09-18 09:15:13 +08:00
|
|
|
if (Name[1] == '=' || Name[1] == '+')
|
2010-08-11 08:58:20 +08:00
|
|
|
Name++;
|
2010-08-11 03:20:14 +08:00
|
|
|
break;
|
|
|
|
case '?': // Disparage slightly code.
|
2010-09-08 02:40:41 +08:00
|
|
|
case '!': // Disparage severely.
|
2010-08-11 03:20:14 +08:00
|
|
|
break; // Pass them.
|
2007-11-27 12:11:28 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-27 12:11:28 +08:00
|
|
|
Name++;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-27 12:11:28 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-01-18 09:56:57 +08:00
|
|
|
bool TargetInfo::resolveSymbolicName(const char *&Name,
|
2009-04-27 01:57:12 +08:00
|
|
|
ConstraintInfo *OutputConstraints,
|
|
|
|
unsigned NumOutputs,
|
2009-04-26 15:16:29 +08:00
|
|
|
unsigned &Index) const {
|
2009-01-18 09:56:57 +08:00
|
|
|
assert(*Name == '[' && "Symbolic name did not start with '['");
|
|
|
|
Name++;
|
|
|
|
const char *Start = Name;
|
|
|
|
while (*Name && *Name != ']')
|
|
|
|
Name++;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-01-18 09:56:57 +08:00
|
|
|
if (!*Name) {
|
|
|
|
// Missing ']'
|
|
|
|
return false;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-01-18 09:56:57 +08:00
|
|
|
std::string SymbolicName(Start, Name - Start);
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2009-04-27 01:57:12 +08:00
|
|
|
for (Index = 0; Index != NumOutputs; ++Index)
|
|
|
|
if (SymbolicName == OutputConstraints[Index].getName())
|
2009-01-18 09:56:57 +08:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-04-27 01:57:12 +08:00
|
|
|
bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
|
|
|
|
unsigned NumOutputs,
|
2009-04-26 15:16:29 +08:00
|
|
|
ConstraintInfo &Info) const {
|
2009-04-27 01:19:08 +08:00
|
|
|
const char *Name = Info.ConstraintStr.c_str();
|
|
|
|
|
2007-11-27 12:11:28 +08:00
|
|
|
while (*Name) {
|
|
|
|
switch (*Name) {
|
|
|
|
default:
|
|
|
|
// Check if we have a matching constraint
|
|
|
|
if (*Name >= '0' && *Name <= '9') {
|
|
|
|
unsigned i = *Name - '0';
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-27 12:11:28 +08:00
|
|
|
// Check if matching constraint is out of bounds.
|
|
|
|
if (i >= NumOutputs)
|
|
|
|
return false;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-11-03 10:22:29 +08:00
|
|
|
// A number must refer to an output only operand.
|
|
|
|
if (OutputConstraints[i].isReadWrite())
|
|
|
|
return false;
|
|
|
|
|
2010-11-03 10:54:51 +08:00
|
|
|
// If the constraint is already tied, it must be tied to the
|
|
|
|
// same operand referenced to by the number.
|
|
|
|
if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
|
|
|
|
return false;
|
|
|
|
|
2009-09-09 23:08:12 +08:00
|
|
|
// The constraint should have the same info as the respective
|
2009-01-28 04:38:24 +08:00
|
|
|
// output constraint.
|
2009-04-27 02:05:25 +08:00
|
|
|
Info.setTiedOperand(i, OutputConstraints[i]);
|
2009-04-26 15:16:29 +08:00
|
|
|
} else if (!validateAsmConstraint(Name, Info)) {
|
2008-08-25 17:46:27 +08:00
|
|
|
// FIXME: This error return is in place temporarily so we can
|
|
|
|
// add more constraints as we hit it. Eventually, an unknown
|
|
|
|
// constraint should just be treated as 'g'.
|
|
|
|
return false;
|
2009-01-18 09:56:57 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '[': {
|
|
|
|
unsigned Index = 0;
|
2009-04-27 01:57:12 +08:00
|
|
|
if (!resolveSymbolicName(Name, OutputConstraints, NumOutputs, Index))
|
2009-01-18 09:56:57 +08:00
|
|
|
return false;
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2010-11-03 10:54:51 +08:00
|
|
|
// If the constraint is already tied, it must be tied to the
|
|
|
|
// same operand referenced to by the number.
|
|
|
|
if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
|
|
|
|
return false;
|
|
|
|
|
2010-08-12 07:03:37 +08:00
|
|
|
Info.setTiedOperand(Index, OutputConstraints[Index]);
|
2009-01-18 09:56:57 +08:00
|
|
|
break;
|
2009-09-09 23:08:12 +08:00
|
|
|
}
|
2007-12-09 03:32:57 +08:00
|
|
|
case '%': // commutative
|
|
|
|
// FIXME: Fail if % is used with the last operand.
|
|
|
|
break;
|
2007-11-27 12:11:28 +08:00
|
|
|
case 'i': // immediate integer.
|
2008-03-09 14:02:02 +08:00
|
|
|
case 'n': // immediate integer with a known value.
|
2007-11-27 12:11:28 +08:00
|
|
|
break;
|
2009-05-06 12:33:31 +08:00
|
|
|
case 'I': // Various constant constraints with target-specific meanings.
|
|
|
|
case 'J':
|
|
|
|
case 'K':
|
|
|
|
case 'L':
|
|
|
|
case 'M':
|
|
|
|
case 'N':
|
|
|
|
case 'O':
|
|
|
|
case 'P':
|
|
|
|
break;
|
2007-11-27 12:11:28 +08:00
|
|
|
case 'r': // general register.
|
2009-04-26 15:16:29 +08:00
|
|
|
Info.setAllowsRegister();
|
2007-11-27 12:11:28 +08:00
|
|
|
break;
|
|
|
|
case 'm': // memory operand.
|
2010-09-08 02:40:41 +08:00
|
|
|
case 'o': // offsettable memory operand.
|
|
|
|
case 'V': // non-offsettable memory operand.
|
|
|
|
case '<': // autodecrement memory operand.
|
|
|
|
case '>': // autoincrement memory operand.
|
2009-04-26 15:16:29 +08:00
|
|
|
Info.setAllowsMemory();
|
2007-11-27 12:11:28 +08:00
|
|
|
break;
|
|
|
|
case 'g': // general register, memory operand or immediate integer.
|
2009-01-18 10:12:04 +08:00
|
|
|
case 'X': // any operand.
|
2009-04-26 15:16:29 +08:00
|
|
|
Info.setAllowsRegister();
|
|
|
|
Info.setAllowsMemory();
|
2007-11-27 12:11:28 +08:00
|
|
|
break;
|
2010-09-22 06:04:54 +08:00
|
|
|
case 'E': // immediate floating point.
|
|
|
|
case 'F': // immediate floating point.
|
|
|
|
case 'p': // address operand.
|
|
|
|
break;
|
2010-08-11 03:20:14 +08:00
|
|
|
case ',': // multiple alternative constraint. Ignore comma.
|
|
|
|
break;
|
|
|
|
case '?': // Disparage slightly code.
|
|
|
|
case '!': // Disparage severly.
|
|
|
|
break; // Pass them.
|
2007-11-27 12:11:28 +08:00
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-27 12:11:28 +08:00
|
|
|
Name++;
|
|
|
|
}
|
2009-09-09 23:08:12 +08:00
|
|
|
|
2007-11-27 12:11:28 +08:00
|
|
|
return true;
|
|
|
|
}
|