blob: 6a19abfb4ff910030e093e7e215f941042d2090a [file] [log] [blame]
Chris Lattner1e27fe12006-10-14 07:06:20 +00001//===--- TargetInfo.cpp - Information about Target machine ----------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner5b12ab82007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattner1e27fe12006-10-14 07:06:20 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the TargetInfo and TargetInfoImpl interfaces.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang/Basic/TargetInfo.h"
John Thompsoned4e2952009-11-05 20:14:16 +000015#include "clang/Basic/LangOptions.h"
Chris Lattnerec0a6d92007-09-22 18:29:59 +000016#include "llvm/ADT/APFloat.h"
Anders Carlsson290aa852007-11-25 00:25:21 +000017#include "llvm/ADT/STLExtras.h"
Nick Lewycky2e998b72010-12-19 20:49:25 +000018#include <cctype>
Chris Lattnerc4f02b62008-04-06 04:02:29 +000019#include <cstdlib>
Chris Lattner1e27fe12006-10-14 07:06:20 +000020using namespace clang;
21
Chris Lattner1df27862008-03-08 08:59:43 +000022// TargetInfo Constructor.
23TargetInfo::TargetInfo(const std::string &T) : Triple(T) {
Daniel Dunbar3d9289c2010-04-15 06:18:39 +000024 // Set defaults. Defaults are set for a 32-bit RISC platform, like PPC or
25 // SPARC. These should be overridden by concrete targets as needed.
Eli Friedmand88c8a12009-04-19 21:38:35 +000026 TLSSupported = true;
Chris Lattner1a8f3942010-04-23 16:29:58 +000027 NoAsmVariants = false;
Chris Lattner5e2ef0c2008-05-09 06:08:39 +000028 PointerWidth = PointerAlign = 32;
Chris Lattnerb781dc792008-05-08 05:58:21 +000029 IntWidth = IntAlign = 32;
Chris Lattner5a9aaaf2008-05-09 05:50:02 +000030 LongWidth = LongAlign = 32;
31 LongLongWidth = LongLongAlign = 64;
Eli Friedmanb5366062008-05-20 14:21:01 +000032 FloatWidth = 32;
33 FloatAlign = 32;
Nate Begeman65bea232008-04-18 17:17:24 +000034 DoubleWidth = 64;
Eli Friedmanb5366062008-05-20 14:21:01 +000035 DoubleAlign = 64;
36 LongDoubleWidth = 64;
37 LongDoubleAlign = 64;
Rafael Espindolae971b9a2010-06-04 23:15:27 +000038 LargeArrayMinWidth = 0;
39 LargeArrayAlign = 0;
Anders Carlsson2a79a902008-10-31 16:05:19 +000040 SizeType = UnsignedLong;
Eli Friedmand50881c2008-11-02 02:43:55 +000041 PtrDiffType = SignedLong;
Sanjiv Guptad7959242008-10-31 09:52:39 +000042 IntMaxType = SignedLongLong;
43 UIntMaxType = UnsignedLongLong;
Chris Lattner7e4c81c2009-02-13 22:28:55 +000044 IntPtrType = SignedLong;
Eli Friedmand50881c2008-11-02 02:43:55 +000045 WCharType = SignedInt;
Chris Lattner67204922009-10-21 04:59:34 +000046 WIntType = SignedInt;
Alisdair Mereditha9ad47d2009-07-14 06:30:34 +000047 Char16Type = UnsignedShort;
48 Char32Type = UnsignedInt;
Eli Friedman2857ccb2009-07-01 03:36:11 +000049 Int64Type = SignedLongLong;
Edward O'Callaghan847f2a12009-11-21 00:49:54 +000050 SigAtomicType = SignedInt;
Daniel Dunbar1da65112010-04-15 15:06:18 +000051 UseBitFieldTypeAlignment = true;
Chris Lattner1df27862008-03-08 08:59:43 +000052 FloatFormat = &llvm::APFloat::IEEEsingle;
53 DoubleFormat = &llvm::APFloat::IEEEdouble;
54 LongDoubleFormat = &llvm::APFloat::IEEEdouble;
Eli Friedman873f65a2008-08-21 00:13:15 +000055 DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-"
Chris Lattner5c67237f2009-11-07 18:59:41 +000056 "i64:64:64-f32:32:32-f64:64:64-n32";
Chris Lattnerf37bafc2008-10-05 19:22:37 +000057 UserLabelPrefix = "_";
Daniel Dunbarbd606522010-05-27 00:35:16 +000058 HasAlignMac68kSupport = false;
Daniel Dunbar6f2e8392010-07-14 23:39:36 +000059
60 // Default to no types using fpret.
61 RealTypeUsesObjCFPRet = 0;
John McCall86353412010-08-21 22:46:04 +000062
63 // Default to using the Itanium ABI.
64 CXXABI = CXXABI_Itanium;
Chris Lattner1df27862008-03-08 08:59:43 +000065}
66
Chris Lattnerc3a669b2008-03-08 08:24:01 +000067// Out of line virtual dtor for TargetInfo.
68TargetInfo::~TargetInfo() {}
Chris Lattner2194ddc2006-10-14 18:32:26 +000069
Chris Lattnera91c30f2009-02-06 05:04:11 +000070/// getTypeName - Return the user string for the specified integer type enum.
71/// For example, SignedShort -> "short".
72const char *TargetInfo::getTypeName(IntType T) {
73 switch (T) {
74 default: assert(0 && "not an integer!");
75 case SignedShort: return "short";
76 case UnsignedShort: return "unsigned short";
77 case SignedInt: return "int";
78 case UnsignedInt: return "unsigned int";
79 case SignedLong: return "long int";
80 case UnsignedLong: return "long unsigned int";
81 case SignedLongLong: return "long long int";
82 case UnsignedLongLong: return "long long unsigned int";
83 }
84}
85
Chris Lattner72cdcac2009-10-21 06:24:21 +000086/// getTypeConstantSuffix - Return the constant suffix for the specified
87/// integer type enum. For example, SignedLong -> "L".
88const char *TargetInfo::getTypeConstantSuffix(IntType T) {
89 switch (T) {
90 default: assert(0 && "not an integer!");
91 case SignedShort:
92 case SignedInt: return "";
93 case SignedLong: return "L";
94 case SignedLongLong: return "LL";
95 case UnsignedShort:
96 case UnsignedInt: return "U";
97 case UnsignedLong: return "UL";
98 case UnsignedLongLong: return "ULL";
99 }
100}
101
Michael J. Spencerfeb799c2010-10-18 07:10:59 +0000102/// getTypeWidth - Return the width (in bits) of the specified integer type
Chris Lattner72cdcac2009-10-21 06:24:21 +0000103/// enum. For example, SignedInt -> getIntWidth().
104unsigned TargetInfo::getTypeWidth(IntType T) const {
105 switch (T) {
106 default: assert(0 && "not an integer!");
Chris Lattnere4a8c642009-11-05 21:21:32 +0000107 case SignedShort:
Chris Lattner72cdcac2009-10-21 06:24:21 +0000108 case UnsignedShort: return getShortWidth();
Chris Lattnere4a8c642009-11-05 21:21:32 +0000109 case SignedInt:
Chris Lattner72cdcac2009-10-21 06:24:21 +0000110 case UnsignedInt: return getIntWidth();
Chris Lattnere4a8c642009-11-05 21:21:32 +0000111 case SignedLong:
Chris Lattner72cdcac2009-10-21 06:24:21 +0000112 case UnsignedLong: return getLongWidth();
Chris Lattnere4a8c642009-11-05 21:21:32 +0000113 case SignedLongLong:
Chris Lattner72cdcac2009-10-21 06:24:21 +0000114 case UnsignedLongLong: return getLongLongWidth();
115 };
116}
117
Michael J. Spencerfeb799c2010-10-18 07:10:59 +0000118/// getTypeAlign - Return the alignment (in bits) of the specified integer type
Chris Lattnere4a8c642009-11-05 21:21:32 +0000119/// enum. For example, SignedInt -> getIntAlign().
120unsigned TargetInfo::getTypeAlign(IntType T) const {
121 switch (T) {
122 default: assert(0 && "not an integer!");
123 case SignedShort:
124 case UnsignedShort: return getShortAlign();
125 case SignedInt:
126 case UnsignedInt: return getIntAlign();
127 case SignedLong:
128 case UnsignedLong: return getLongAlign();
129 case SignedLongLong:
130 case UnsignedLongLong: return getLongLongAlign();
131 };
132}
133
Chris Lattnerc0c04392009-10-25 22:49:18 +0000134/// isTypeSigned - Return whether an integer types is signed. Returns true if
Chris Lattner72cdcac2009-10-21 06:24:21 +0000135/// the type is signed; false otherwise.
Chris Lattnerc0c04392009-10-25 22:49:18 +0000136bool TargetInfo::isTypeSigned(IntType T) const {
Chris Lattner72cdcac2009-10-21 06:24:21 +0000137 switch (T) {
138 default: assert(0 && "not an integer!");
139 case SignedShort:
140 case SignedInt:
141 case SignedLong:
Michael J. Spencerfeb799c2010-10-18 07:10:59 +0000142 case SignedLongLong:
Chris Lattner72cdcac2009-10-21 06:24:21 +0000143 return true;
144 case UnsignedShort:
145 case UnsignedInt:
146 case UnsignedLong:
Michael J. Spencerfeb799c2010-10-18 07:10:59 +0000147 case UnsignedLongLong:
Chris Lattner72cdcac2009-10-21 06:24:21 +0000148 return false;
149 };
150}
151
John Thompsoned4e2952009-11-05 20:14:16 +0000152/// setForcedLangOptions - Set forced language options.
153/// Apply changes to the target information with respect to certain
154/// language options which change the target configuration.
155void TargetInfo::setForcedLangOptions(LangOptions &Opts) {
Daniel Dunbar9302f602010-04-15 15:06:22 +0000156 if (Opts.NoBitFieldTypeAlign)
157 UseBitFieldTypeAlignment = false;
158 if (Opts.ShortWChar)
John Thompsoned4e2952009-11-05 20:14:16 +0000159 WCharType = UnsignedShort;
John Thompsoned4e2952009-11-05 20:14:16 +0000160}
Chris Lattner72cdcac2009-10-21 06:24:21 +0000161
Chris Lattnerec0a6d92007-09-22 18:29:59 +0000162//===----------------------------------------------------------------------===//
Chris Lattnerec0a6d92007-09-22 18:29:59 +0000163
Chris Lattner10a5b382007-01-29 05:24:35 +0000164
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000165static llvm::StringRef removeGCCRegisterPrefix(llvm::StringRef Name) {
Anders Carlsson3ed4aea2008-02-06 00:11:32 +0000166 if (Name[0] == '%' || Name[0] == '#')
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000167 Name = Name.substr(1);
Michael J. Spencerfeb799c2010-10-18 07:10:59 +0000168
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000169 return Name;
Anders Carlsson3ed4aea2008-02-06 00:11:32 +0000170}
171
Anders Carlsson5fa3f342007-11-24 23:38:12 +0000172/// isValidGCCRegisterName - Returns whether the passed in string
173/// is a valid register name according to GCC. This is used by Sema for
174/// inline asm statements.
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000175bool TargetInfo::isValidGCCRegisterName(llvm::StringRef Name) const {
176 if (Name.empty())
177 return false;
Michael J. Spencerfeb799c2010-10-18 07:10:59 +0000178
Anders Carlsson290aa852007-11-25 00:25:21 +0000179 const char * const *Names;
180 unsigned NumNames;
Mike Stump11289f42009-09-09 15:08:12 +0000181
Anders Carlsson290aa852007-11-25 00:25:21 +0000182 // Get rid of any register prefix.
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000183 Name = removeGCCRegisterPrefix(Name);
Anders Carlsson3ed4aea2008-02-06 00:11:32 +0000184
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000185 if (Name == "memory" || Name == "cc")
Anders Carlsson290aa852007-11-25 00:25:21 +0000186 return true;
Mike Stump11289f42009-09-09 15:08:12 +0000187
Chris Lattnerc3a669b2008-03-08 08:24:01 +0000188 getGCCRegNames(Names, NumNames);
Mike Stump11289f42009-09-09 15:08:12 +0000189
Anders Carlsson290aa852007-11-25 00:25:21 +0000190 // If we have a number it maps to an entry in the register name array.
191 if (isdigit(Name[0])) {
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000192 int n;
193 if (!Name.getAsInteger(0, n))
Anders Carlsson290aa852007-11-25 00:25:21 +0000194 return n >= 0 && (unsigned)n < NumNames;
195 }
196
197 // Check register names.
198 for (unsigned i = 0; i < NumNames; i++) {
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000199 if (Name == Names[i])
Anders Carlsson290aa852007-11-25 00:25:21 +0000200 return true;
201 }
Mike Stump11289f42009-09-09 15:08:12 +0000202
Anders Carlsson290aa852007-11-25 00:25:21 +0000203 // Now check aliases.
Chris Lattnerc3a669b2008-03-08 08:24:01 +0000204 const GCCRegAlias *Aliases;
Anders Carlsson290aa852007-11-25 00:25:21 +0000205 unsigned NumAliases;
Mike Stump11289f42009-09-09 15:08:12 +0000206
Chris Lattnerc3a669b2008-03-08 08:24:01 +0000207 getGCCRegAliases(Aliases, NumAliases);
Anders Carlsson290aa852007-11-25 00:25:21 +0000208 for (unsigned i = 0; i < NumAliases; i++) {
209 for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
210 if (!Aliases[i].Aliases[j])
211 break;
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000212 if (Aliases[i].Aliases[j] == Name)
Anders Carlsson290aa852007-11-25 00:25:21 +0000213 return true;
214 }
215 }
Mike Stump11289f42009-09-09 15:08:12 +0000216
Anders Carlsson5fa3f342007-11-24 23:38:12 +0000217 return false;
218}
Anders Carlssonf511f642007-11-27 04:11:28 +0000219
Michael J. Spencerfeb799c2010-10-18 07:10:59 +0000220llvm::StringRef
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000221TargetInfo::getNormalizedGCCRegisterName(llvm::StringRef Name) const {
Anders Carlssonf511f642007-11-27 04:11:28 +0000222 assert(isValidGCCRegisterName(Name) && "Invalid register passed in");
Mike Stump11289f42009-09-09 15:08:12 +0000223
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000224 // Get rid of any register prefix.
225 Name = removeGCCRegisterPrefix(Name);
Mike Stump11289f42009-09-09 15:08:12 +0000226
Anders Carlssonf511f642007-11-27 04:11:28 +0000227 const char * const *Names;
228 unsigned NumNames;
229
Chris Lattnerc3a669b2008-03-08 08:24:01 +0000230 getGCCRegNames(Names, NumNames);
Anders Carlssonf511f642007-11-27 04:11:28 +0000231
232 // First, check if we have a number.
233 if (isdigit(Name[0])) {
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000234 int n;
235 if (!Name.getAsInteger(0, n)) {
Mike Stump11289f42009-09-09 15:08:12 +0000236 assert(n >= 0 && (unsigned)n < NumNames &&
Anders Carlssonf511f642007-11-27 04:11:28 +0000237 "Out of bounds register number!");
238 return Names[n];
239 }
240 }
Mike Stump11289f42009-09-09 15:08:12 +0000241
Anders Carlssonf511f642007-11-27 04:11:28 +0000242 // Now check aliases.
Chris Lattnerc3a669b2008-03-08 08:24:01 +0000243 const GCCRegAlias *Aliases;
Anders Carlssonf511f642007-11-27 04:11:28 +0000244 unsigned NumAliases;
Mike Stump11289f42009-09-09 15:08:12 +0000245
Chris Lattnerc3a669b2008-03-08 08:24:01 +0000246 getGCCRegAliases(Aliases, NumAliases);
Anders Carlssonf511f642007-11-27 04:11:28 +0000247 for (unsigned i = 0; i < NumAliases; i++) {
248 for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
249 if (!Aliases[i].Aliases[j])
250 break;
Anders Carlssonc7c5baa2010-01-30 19:12:25 +0000251 if (Aliases[i].Aliases[j] == Name)
Anders Carlssonf511f642007-11-27 04:11:28 +0000252 return Aliases[i].Register;
253 }
254 }
Mike Stump11289f42009-09-09 15:08:12 +0000255
Anders Carlssonf511f642007-11-27 04:11:28 +0000256 return Name;
257}
258
Chris Lattnerc3f4c7b2009-04-26 17:19:08 +0000259bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
260 const char *Name = Info.getConstraintStr().c_str();
Anders Carlssonf511f642007-11-27 04:11:28 +0000261 // An output constraint must start with '=' or '+'
262 if (*Name != '=' && *Name != '+')
263 return false;
264
265 if (*Name == '+')
Chris Lattnerd9725f72009-04-26 07:16:29 +0000266 Info.setIsReadWrite();
Anders Carlssonf511f642007-11-27 04:11:28 +0000267
268 Name++;
269 while (*Name) {
270 switch (*Name) {
271 default:
Chris Lattnerd9725f72009-04-26 07:16:29 +0000272 if (!validateAsmConstraint(Name, Info)) {
Ted Kremenekb44485b2008-04-24 16:36:38 +0000273 // FIXME: We temporarily return false
Anders Carlssonf511f642007-11-27 04:11:28 +0000274 // so we can add more constraints as we hit it.
275 // Eventually, an unknown constraint should just be treated as 'g'.
Ted Kremenekb44485b2008-04-24 16:36:38 +0000276 return false;
Anders Carlssonf511f642007-11-27 04:11:28 +0000277 }
278 case '&': // early clobber.
279 break;
Chris Lattnerf3154712009-10-13 04:32:07 +0000280 case '%': // commutative.
281 // FIXME: Check that there is a another register after this one.
282 break;
Anders Carlssonf511f642007-11-27 04:11:28 +0000283 case 'r': // general register.
Chris Lattnerd9725f72009-04-26 07:16:29 +0000284 Info.setAllowsRegister();
Anders Carlssonf511f642007-11-27 04:11:28 +0000285 break;
286 case 'm': // memory operand.
Dale Johannesen8499f472010-09-07 18:40:41 +0000287 case 'o': // offsetable memory operand.
288 case 'V': // non-offsetable memory operand.
289 case '<': // autodecrement memory operand.
290 case '>': // autoincrement memory operand.
Chris Lattnerd9725f72009-04-26 07:16:29 +0000291 Info.setAllowsMemory();
Anders Carlssonf511f642007-11-27 04:11:28 +0000292 break;
293 case 'g': // general register, memory operand or immediate integer.
Anders Carlssone70cde12009-01-18 02:12:04 +0000294 case 'X': // any operand.
Chris Lattnerd9725f72009-04-26 07:16:29 +0000295 Info.setAllowsRegister();
296 Info.setAllowsMemory();
Anders Carlssonf511f642007-11-27 04:11:28 +0000297 break;
John Thompsona5c7d702010-08-10 19:20:14 +0000298 case ',': // multiple alternative constraint. Pass it.
John Thompson46667af2010-08-11 00:58:20 +0000299 // Handle additional optional '=' or '+' modifiers.
John Thompson12240612010-09-18 01:15:13 +0000300 if (Name[1] == '=' || Name[1] == '+')
John Thompson46667af2010-08-11 00:58:20 +0000301 Name++;
John Thompsona5c7d702010-08-10 19:20:14 +0000302 break;
303 case '?': // Disparage slightly code.
Dale Johannesen8499f472010-09-07 18:40:41 +0000304 case '!': // Disparage severely.
John Thompsona5c7d702010-08-10 19:20:14 +0000305 break; // Pass them.
Anders Carlssonf511f642007-11-27 04:11:28 +0000306 }
Mike Stump11289f42009-09-09 15:08:12 +0000307
Anders Carlssonf511f642007-11-27 04:11:28 +0000308 Name++;
309 }
Mike Stump11289f42009-09-09 15:08:12 +0000310
Anders Carlssonf511f642007-11-27 04:11:28 +0000311 return true;
312}
313
Anders Carlssona79203b2009-01-18 01:56:57 +0000314bool TargetInfo::resolveSymbolicName(const char *&Name,
Chris Lattnerc16d4762009-04-26 17:57:12 +0000315 ConstraintInfo *OutputConstraints,
316 unsigned NumOutputs,
Chris Lattnerd9725f72009-04-26 07:16:29 +0000317 unsigned &Index) const {
Anders Carlssona79203b2009-01-18 01:56:57 +0000318 assert(*Name == '[' && "Symbolic name did not start with '['");
Anders Carlssona79203b2009-01-18 01:56:57 +0000319 Name++;
320 const char *Start = Name;
321 while (*Name && *Name != ']')
322 Name++;
Mike Stump11289f42009-09-09 15:08:12 +0000323
Anders Carlssona79203b2009-01-18 01:56:57 +0000324 if (!*Name) {
325 // Missing ']'
326 return false;
327 }
Mike Stump11289f42009-09-09 15:08:12 +0000328
Anders Carlssona79203b2009-01-18 01:56:57 +0000329 std::string SymbolicName(Start, Name - Start);
Mike Stump11289f42009-09-09 15:08:12 +0000330
Chris Lattnerc16d4762009-04-26 17:57:12 +0000331 for (Index = 0; Index != NumOutputs; ++Index)
332 if (SymbolicName == OutputConstraints[Index].getName())
Anders Carlssona79203b2009-01-18 01:56:57 +0000333 return true;
Anders Carlssona79203b2009-01-18 01:56:57 +0000334
335 return false;
336}
337
Chris Lattnerc16d4762009-04-26 17:57:12 +0000338bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
339 unsigned NumOutputs,
Chris Lattnerd9725f72009-04-26 07:16:29 +0000340 ConstraintInfo &Info) const {
Chris Lattnerc3f4c7b2009-04-26 17:19:08 +0000341 const char *Name = Info.ConstraintStr.c_str();
342
Anders Carlssonf511f642007-11-27 04:11:28 +0000343 while (*Name) {
344 switch (*Name) {
345 default:
346 // Check if we have a matching constraint
347 if (*Name >= '0' && *Name <= '9') {
348 unsigned i = *Name - '0';
Mike Stump11289f42009-09-09 15:08:12 +0000349
Anders Carlssonf511f642007-11-27 04:11:28 +0000350 // Check if matching constraint is out of bounds.
351 if (i >= NumOutputs)
352 return false;
Mike Stump11289f42009-09-09 15:08:12 +0000353
Anders Carlssonda1f5fc2010-11-03 02:22:29 +0000354 // A number must refer to an output only operand.
355 if (OutputConstraints[i].isReadWrite())
356 return false;
357
Anders Carlsson2d5f8b42010-11-03 02:54:51 +0000358 // If the constraint is already tied, it must be tied to the
359 // same operand referenced to by the number.
360 if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
361 return false;
362
Mike Stump11289f42009-09-09 15:08:12 +0000363 // The constraint should have the same info as the respective
Anders Carlsson570c3572009-01-27 20:38:24 +0000364 // output constraint.
Chris Lattner4c92b512009-04-26 18:05:25 +0000365 Info.setTiedOperand(i, OutputConstraints[i]);
Chris Lattnerd9725f72009-04-26 07:16:29 +0000366 } else if (!validateAsmConstraint(Name, Info)) {
Daniel Dunbar81128e02008-08-25 09:46:27 +0000367 // FIXME: This error return is in place temporarily so we can
368 // add more constraints as we hit it. Eventually, an unknown
369 // constraint should just be treated as 'g'.
370 return false;
Anders Carlssona79203b2009-01-18 01:56:57 +0000371 }
372 break;
373 case '[': {
374 unsigned Index = 0;
Chris Lattnerc16d4762009-04-26 17:57:12 +0000375 if (!resolveSymbolicName(Name, OutputConstraints, NumOutputs, Index))
Anders Carlssona79203b2009-01-18 01:56:57 +0000376 return false;
Mike Stump11289f42009-09-09 15:08:12 +0000377
Anders Carlsson2d5f8b42010-11-03 02:54:51 +0000378 // If the constraint is already tied, it must be tied to the
379 // same operand referenced to by the number.
380 if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
381 return false;
382
Eli Friedman854f1102010-08-11 23:03:37 +0000383 Info.setTiedOperand(Index, OutputConstraints[Index]);
Anders Carlssona79203b2009-01-18 01:56:57 +0000384 break;
Mike Stump11289f42009-09-09 15:08:12 +0000385 }
Anders Carlsson050f4942007-12-08 19:32:57 +0000386 case '%': // commutative
387 // FIXME: Fail if % is used with the last operand.
388 break;
Anders Carlssonf511f642007-11-27 04:11:28 +0000389 case 'i': // immediate integer.
Anders Carlssona3a96af2008-03-09 06:02:02 +0000390 case 'n': // immediate integer with a known value.
Anders Carlssonf511f642007-11-27 04:11:28 +0000391 break;
Chris Lattnerdbcc5ca2009-05-06 04:33:31 +0000392 case 'I': // Various constant constraints with target-specific meanings.
393 case 'J':
394 case 'K':
395 case 'L':
396 case 'M':
397 case 'N':
398 case 'O':
399 case 'P':
400 break;
Anders Carlssonf511f642007-11-27 04:11:28 +0000401 case 'r': // general register.
Chris Lattnerd9725f72009-04-26 07:16:29 +0000402 Info.setAllowsRegister();
Anders Carlssonf511f642007-11-27 04:11:28 +0000403 break;
404 case 'm': // memory operand.
Dale Johannesen8499f472010-09-07 18:40:41 +0000405 case 'o': // offsettable memory operand.
406 case 'V': // non-offsettable memory operand.
407 case '<': // autodecrement memory operand.
408 case '>': // autoincrement memory operand.
Chris Lattnerd9725f72009-04-26 07:16:29 +0000409 Info.setAllowsMemory();
Anders Carlssonf511f642007-11-27 04:11:28 +0000410 break;
411 case 'g': // general register, memory operand or immediate integer.
Anders Carlssone70cde12009-01-18 02:12:04 +0000412 case 'X': // any operand.
Chris Lattnerd9725f72009-04-26 07:16:29 +0000413 Info.setAllowsRegister();
414 Info.setAllowsMemory();
Anders Carlssonf511f642007-11-27 04:11:28 +0000415 break;
John Thompsonc467aa22010-09-21 22:04:54 +0000416 case 'E': // immediate floating point.
417 case 'F': // immediate floating point.
418 case 'p': // address operand.
419 break;
John Thompsona5c7d702010-08-10 19:20:14 +0000420 case ',': // multiple alternative constraint. Ignore comma.
421 break;
422 case '?': // Disparage slightly code.
423 case '!': // Disparage severly.
424 break; // Pass them.
Anders Carlssonf511f642007-11-27 04:11:28 +0000425 }
Mike Stump11289f42009-09-09 15:08:12 +0000426
Anders Carlssonf511f642007-11-27 04:11:28 +0000427 Name++;
428 }
Mike Stump11289f42009-09-09 15:08:12 +0000429
Anders Carlssonf511f642007-11-27 04:11:28 +0000430 return true;
431}