1 //===--- TargetInfo.cpp - Information about Target machine ----------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  This file implements the TargetInfo and TargetInfoImpl interfaces.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "clang/Basic/TargetInfo.h"
15 #include "clang/Basic/AddressSpaces.h"
16 #include "clang/Basic/CharInfo.h"
17 #include "clang/Basic/Diagnostic.h"
18 #include "clang/Basic/LangOptions.h"
19 #include "llvm/ADT/APFloat.h"
20 #include "llvm/ADT/STLExtras.h"
21 #include "llvm/Support/ErrorHandling.h"
22 #include "llvm/Support/TargetParser.h"
23 #include <cstdlib>
24 using namespace clang;
25 
26 static const LangASMap DefaultAddrSpaceMap = {0};
27 
28 // TargetInfo Constructor.
29 TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
30   // Set defaults.  Defaults are set for a 32-bit RISC platform, like PPC or
31   // SPARC.  These should be overridden by concrete targets as needed.
32   BigEndian = !T.isLittleEndian();
33   TLSSupported = true;
34   VLASupported = true;
35   NoAsmVariants = false;
36   HasLegalHalfType = false;
37   HasFloat128 = false;
38   PointerWidth = PointerAlign = 32;
39   BoolWidth = BoolAlign = 8;
40   IntWidth = IntAlign = 32;
41   LongWidth = LongAlign = 32;
42   LongLongWidth = LongLongAlign = 64;
43   SuitableAlign = 64;
44   DefaultAlignForAttributeAligned = 128;
45   MinGlobalAlign = 0;
46   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
47   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
48   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
49   if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
50     NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
51   else
52     NewAlign = 0; // Infer from basic type alignment.
53   HalfWidth = 16;
54   HalfAlign = 16;
55   FloatWidth = 32;
56   FloatAlign = 32;
57   DoubleWidth = 64;
58   DoubleAlign = 64;
59   LongDoubleWidth = 64;
60   LongDoubleAlign = 64;
61   Float128Align = 128;
62   LargeArrayMinWidth = 0;
63   LargeArrayAlign = 0;
64   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;
65   MaxVectorAlign = 0;
66   MaxTLSAlign = 0;
67   SimdDefaultAlign = 0;
68   SizeType = UnsignedLong;
69   PtrDiffType = SignedLong;
70   IntMaxType = SignedLongLong;
71   IntPtrType = SignedLong;
72   WCharType = SignedInt;
73   WIntType = SignedInt;
74   Char16Type = UnsignedShort;
75   Char32Type = UnsignedInt;
76   Int64Type = SignedLongLong;
77   SigAtomicType = SignedInt;
78   ProcessIDType = SignedInt;
79   UseSignedCharForObjCBool = true;
80   UseBitFieldTypeAlignment = true;
81   UseZeroLengthBitfieldAlignment = false;
82   UseExplicitBitFieldAlignment = true;
83   ZeroLengthBitfieldBoundary = 0;
84   HalfFormat = &llvm::APFloat::IEEEhalf();
85   FloatFormat = &llvm::APFloat::IEEEsingle();
86   DoubleFormat = &llvm::APFloat::IEEEdouble();
87   LongDoubleFormat = &llvm::APFloat::IEEEdouble();
88   Float128Format = &llvm::APFloat::IEEEquad();
89   MCountName = "mcount";
90   RegParmMax = 0;
91   SSERegParmMax = 0;
92   HasAlignMac68kSupport = false;
93   HasBuiltinMSVaList = false;
94   IsRenderScriptTarget = false;
95 
96   // Default to no types using fpret.
97   RealTypeUsesObjCFPRet = 0;
98 
99   // Default to not using fp2ret for __Complex long double
100   ComplexLongDoubleUsesFP2Ret = false;
101 
102   // Set the C++ ABI based on the triple.
103   TheCXXABI.set(Triple.isKnownWindowsMSVCEnvironment()
104                     ? TargetCXXABI::Microsoft
105                     : TargetCXXABI::GenericItanium);
106 
107   // Default to an empty address space map.
108   AddrSpaceMap = &DefaultAddrSpaceMap;
109   UseAddrSpaceMapMangling = false;
110 
111   // Default to an unknown platform name.
112   PlatformName = "unknown";
113   PlatformMinVersion = VersionTuple();
114 }
115 
116 // Out of line virtual dtor for TargetInfo.
117 TargetInfo::~TargetInfo() {}
118 
119 bool
120 TargetInfo::checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const {
121   Diags.Report(diag::err_opt_not_valid_on_target) << "cf-protection=branch";
122   return false;
123 }
124 
125 bool
126 TargetInfo::checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const {
127   Diags.Report(diag::err_opt_not_valid_on_target) << "cf-protection=return";
128   return false;
129 }
130 
131 /// getTypeName - Return the user string for the specified integer type enum.
132 /// For example, SignedShort -> "short".
133 const char *TargetInfo::getTypeName(IntType T) {
134   switch (T) {
135   default: llvm_unreachable("not an integer!");
136   case SignedChar:       return "signed char";
137   case UnsignedChar:     return "unsigned char";
138   case SignedShort:      return "short";
139   case UnsignedShort:    return "unsigned short";
140   case SignedInt:        return "int";
141   case UnsignedInt:      return "unsigned int";
142   case SignedLong:       return "long int";
143   case UnsignedLong:     return "long unsigned int";
144   case SignedLongLong:   return "long long int";
145   case UnsignedLongLong: return "long long unsigned int";
146   }
147 }
148 
149 /// getTypeConstantSuffix - Return the constant suffix for the specified
150 /// integer type enum. For example, SignedLong -> "L".
151 const char *TargetInfo::getTypeConstantSuffix(IntType T) const {
152   switch (T) {
153   default: llvm_unreachable("not an integer!");
154   case SignedChar:
155   case SignedShort:
156   case SignedInt:        return "";
157   case SignedLong:       return "L";
158   case SignedLongLong:   return "LL";
159   case UnsignedChar:
160     if (getCharWidth() < getIntWidth())
161       return "";
162     LLVM_FALLTHROUGH;
163   case UnsignedShort:
164     if (getShortWidth() < getIntWidth())
165       return "";
166     LLVM_FALLTHROUGH;
167   case UnsignedInt:      return "U";
168   case UnsignedLong:     return "UL";
169   case UnsignedLongLong: return "ULL";
170   }
171 }
172 
173 /// getTypeFormatModifier - Return the printf format modifier for the
174 /// specified integer type enum. For example, SignedLong -> "l".
175 
176 const char *TargetInfo::getTypeFormatModifier(IntType T) {
177   switch (T) {
178   default: llvm_unreachable("not an integer!");
179   case SignedChar:
180   case UnsignedChar:     return "hh";
181   case SignedShort:
182   case UnsignedShort:    return "h";
183   case SignedInt:
184   case UnsignedInt:      return "";
185   case SignedLong:
186   case UnsignedLong:     return "l";
187   case SignedLongLong:
188   case UnsignedLongLong: return "ll";
189   }
190 }
191 
192 /// getTypeWidth - Return the width (in bits) of the specified integer type
193 /// enum. For example, SignedInt -> getIntWidth().
194 unsigned TargetInfo::getTypeWidth(IntType T) const {
195   switch (T) {
196   default: llvm_unreachable("not an integer!");
197   case SignedChar:
198   case UnsignedChar:     return getCharWidth();
199   case SignedShort:
200   case UnsignedShort:    return getShortWidth();
201   case SignedInt:
202   case UnsignedInt:      return getIntWidth();
203   case SignedLong:
204   case UnsignedLong:     return getLongWidth();
205   case SignedLongLong:
206   case UnsignedLongLong: return getLongLongWidth();
207   };
208 }
209 
210 TargetInfo::IntType TargetInfo::getIntTypeByWidth(
211     unsigned BitWidth, bool IsSigned) const {
212   if (getCharWidth() == BitWidth)
213     return IsSigned ? SignedChar : UnsignedChar;
214   if (getShortWidth() == BitWidth)
215     return IsSigned ? SignedShort : UnsignedShort;
216   if (getIntWidth() == BitWidth)
217     return IsSigned ? SignedInt : UnsignedInt;
218   if (getLongWidth() == BitWidth)
219     return IsSigned ? SignedLong : UnsignedLong;
220   if (getLongLongWidth() == BitWidth)
221     return IsSigned ? SignedLongLong : UnsignedLongLong;
222   return NoInt;
223 }
224 
225 TargetInfo::IntType TargetInfo::getLeastIntTypeByWidth(unsigned BitWidth,
226                                                        bool IsSigned) const {
227   if (getCharWidth() >= BitWidth)
228     return IsSigned ? SignedChar : UnsignedChar;
229   if (getShortWidth() >= BitWidth)
230     return IsSigned ? SignedShort : UnsignedShort;
231   if (getIntWidth() >= BitWidth)
232     return IsSigned ? SignedInt : UnsignedInt;
233   if (getLongWidth() >= BitWidth)
234     return IsSigned ? SignedLong : UnsignedLong;
235   if (getLongLongWidth() >= BitWidth)
236     return IsSigned ? SignedLongLong : UnsignedLongLong;
237   return NoInt;
238 }
239 
240 TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth) const {
241   if (getFloatWidth() == BitWidth)
242     return Float;
243   if (getDoubleWidth() == BitWidth)
244     return Double;
245 
246   switch (BitWidth) {
247   case 96:
248     if (&getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended())
249       return LongDouble;
250     break;
251   case 128:
252     if (&getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble() ||
253         &getLongDoubleFormat() == &llvm::APFloat::IEEEquad())
254       return LongDouble;
255     if (hasFloat128Type())
256       return Float128;
257     break;
258   }
259 
260   return NoFloat;
261 }
262 
263 /// getTypeAlign - Return the alignment (in bits) of the specified integer type
264 /// enum. For example, SignedInt -> getIntAlign().
265 unsigned TargetInfo::getTypeAlign(IntType T) const {
266   switch (T) {
267   default: llvm_unreachable("not an integer!");
268   case SignedChar:
269   case UnsignedChar:     return getCharAlign();
270   case SignedShort:
271   case UnsignedShort:    return getShortAlign();
272   case SignedInt:
273   case UnsignedInt:      return getIntAlign();
274   case SignedLong:
275   case UnsignedLong:     return getLongAlign();
276   case SignedLongLong:
277   case UnsignedLongLong: return getLongLongAlign();
278   };
279 }
280 
281 /// isTypeSigned - Return whether an integer types is signed. Returns true if
282 /// the type is signed; false otherwise.
283 bool TargetInfo::isTypeSigned(IntType T) {
284   switch (T) {
285   default: llvm_unreachable("not an integer!");
286   case SignedChar:
287   case SignedShort:
288   case SignedInt:
289   case SignedLong:
290   case SignedLongLong:
291     return true;
292   case UnsignedChar:
293   case UnsignedShort:
294   case UnsignedInt:
295   case UnsignedLong:
296   case UnsignedLongLong:
297     return false;
298   };
299 }
300 
301 /// adjust - Set forced language options.
302 /// Apply changes to the target information with respect to certain
303 /// language options which change the target configuration and adjust
304 /// the language based on the target options where applicable.
305 void TargetInfo::adjust(LangOptions &Opts) {
306   if (Opts.NoBitFieldTypeAlign)
307     UseBitFieldTypeAlignment = false;
308 
309   switch (Opts.WCharSize) {
310   default: llvm_unreachable("invalid wchar_t width");
311   case 0: break;
312   case 1: WCharType = Opts.WCharIsSigned ? SignedChar : UnsignedChar; break;
313   case 2: WCharType = Opts.WCharIsSigned ? SignedShort : UnsignedShort; break;
314   case 4: WCharType = Opts.WCharIsSigned ? SignedInt : UnsignedInt; break;
315   }
316 
317   if (Opts.AlignDouble) {
318     DoubleAlign = LongLongAlign = 64;
319     LongDoubleAlign = 64;
320   }
321 
322   if (Opts.OpenCL) {
323     // OpenCL C requires specific widths for types, irrespective of
324     // what these normally are for the target.
325     // We also define long long and long double here, although the
326     // OpenCL standard only mentions these as "reserved".
327     IntWidth = IntAlign = 32;
328     LongWidth = LongAlign = 64;
329     LongLongWidth = LongLongAlign = 128;
330     HalfWidth = HalfAlign = 16;
331     FloatWidth = FloatAlign = 32;
332 
333     // Embedded 32-bit targets (OpenCL EP) might have double C type
334     // defined as float. Let's not override this as it might lead
335     // to generating illegal code that uses 64bit doubles.
336     if (DoubleWidth != FloatWidth) {
337       DoubleWidth = DoubleAlign = 64;
338       DoubleFormat = &llvm::APFloat::IEEEdouble();
339     }
340     LongDoubleWidth = LongDoubleAlign = 128;
341 
342     unsigned MaxPointerWidth = getMaxPointerWidth();
343     assert(MaxPointerWidth == 32 || MaxPointerWidth == 64);
344     bool Is32BitArch = MaxPointerWidth == 32;
345     SizeType = Is32BitArch ? UnsignedInt : UnsignedLong;
346     PtrDiffType = Is32BitArch ? SignedInt : SignedLong;
347     IntPtrType = Is32BitArch ? SignedInt : SignedLong;
348 
349     IntMaxType = SignedLongLong;
350     Int64Type = SignedLong;
351 
352     HalfFormat = &llvm::APFloat::IEEEhalf();
353     FloatFormat = &llvm::APFloat::IEEEsingle();
354     LongDoubleFormat = &llvm::APFloat::IEEEquad();
355   }
356 
357   if (Opts.NewAlignOverride)
358     NewAlign = Opts.NewAlignOverride * getCharWidth();
359 }
360 
361 bool TargetInfo::initFeatureMap(
362     llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
363     const std::vector<std::string> &FeatureVec) const {
364   for (const auto &F : FeatureVec) {
365     StringRef Name = F;
366     // Apply the feature via the target.
367     bool Enabled = Name[0] == '+';
368     setFeatureEnabled(Features, Name.substr(1), Enabled);
369   }
370   return true;
371 }
372 
373 TargetInfo::CallingConvKind
374 TargetInfo::getCallingConvKind(bool ClangABICompat4) const {
375   if (getCXXABI() != TargetCXXABI::Microsoft &&
376       (ClangABICompat4 || getTriple().getOS() == llvm::Triple::PS4))
377     return CCK_ClangABI4OrPS4;
378   return CCK_Default;
379 }
380 
381 LangAS TargetInfo::getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const {
382   switch (TK) {
383   case OCLTK_Image:
384   case OCLTK_Pipe:
385     return LangAS::opencl_global;
386 
387   case OCLTK_Sampler:
388     return LangAS::opencl_constant;
389 
390   default:
391     return LangAS::Default;
392   }
393 }
394 
395 //===----------------------------------------------------------------------===//
396 
397 
398 static StringRef removeGCCRegisterPrefix(StringRef Name) {
399   if (Name[0] == '%' || Name[0] == '#')
400     Name = Name.substr(1);
401 
402   return Name;
403 }
404 
405 /// isValidClobber - Returns whether the passed in string is
406 /// a valid clobber in an inline asm statement. This is used by
407 /// Sema.
408 bool TargetInfo::isValidClobber(StringRef Name) const {
409   return (isValidGCCRegisterName(Name) ||
410           Name == "memory" || Name == "cc");
411 }
412 
413 /// isValidGCCRegisterName - Returns whether the passed in string
414 /// is a valid register name according to GCC. This is used by Sema for
415 /// inline asm statements.
416 bool TargetInfo::isValidGCCRegisterName(StringRef Name) const {
417   if (Name.empty())
418     return false;
419 
420   // Get rid of any register prefix.
421   Name = removeGCCRegisterPrefix(Name);
422   if (Name.empty())
423     return false;
424 
425   ArrayRef<const char *> Names = getGCCRegNames();
426 
427   // If we have a number it maps to an entry in the register name array.
428   if (isDigit(Name[0])) {
429     unsigned n;
430     if (!Name.getAsInteger(0, n))
431       return n < Names.size();
432   }
433 
434   // Check register names.
435   if (std::find(Names.begin(), Names.end(), Name) != Names.end())
436     return true;
437 
438   // Check any additional names that we have.
439   for (const AddlRegName &ARN : getGCCAddlRegNames())
440     for (const char *AN : ARN.Names) {
441       if (!AN)
442         break;
443       // Make sure the register that the additional name is for is within
444       // the bounds of the register names from above.
445       if (AN == Name && ARN.RegNum < Names.size())
446         return true;
447     }
448 
449   // Now check aliases.
450   for (const GCCRegAlias &GRA : getGCCRegAliases())
451     for (const char *A : GRA.Aliases) {
452       if (!A)
453         break;
454       if (A == Name)
455         return true;
456     }
457 
458   return false;
459 }
460 
461 StringRef TargetInfo::getNormalizedGCCRegisterName(StringRef Name,
462                                                    bool ReturnCanonical) const {
463   assert(isValidGCCRegisterName(Name) && "Invalid register passed in");
464 
465   // Get rid of any register prefix.
466   Name = removeGCCRegisterPrefix(Name);
467 
468   ArrayRef<const char *> Names = getGCCRegNames();
469 
470   // First, check if we have a number.
471   if (isDigit(Name[0])) {
472     unsigned n;
473     if (!Name.getAsInteger(0, n)) {
474       assert(n < Names.size() && "Out of bounds register number!");
475       return Names[n];
476     }
477   }
478 
479   // Check any additional names that we have.
480   for (const AddlRegName &ARN : getGCCAddlRegNames())
481     for (const char *AN : ARN.Names) {
482       if (!AN)
483         break;
484       // Make sure the register that the additional name is for is within
485       // the bounds of the register names from above.
486       if (AN == Name && ARN.RegNum < Names.size())
487         return ReturnCanonical ? Names[ARN.RegNum] : Name;
488     }
489 
490   // Now check aliases.
491   for (const GCCRegAlias &RA : getGCCRegAliases())
492     for (const char *A : RA.Aliases) {
493       if (!A)
494         break;
495       if (A == Name)
496         return RA.Register;
497     }
498 
499   return Name;
500 }
501 
502 bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
503   const char *Name = Info.getConstraintStr().c_str();
504   // An output constraint must start with '=' or '+'
505   if (*Name != '=' && *Name != '+')
506     return false;
507 
508   if (*Name == '+')
509     Info.setIsReadWrite();
510 
511   Name++;
512   while (*Name) {
513     switch (*Name) {
514     default:
515       if (!validateAsmConstraint(Name, Info)) {
516         // FIXME: We temporarily return false
517         // so we can add more constraints as we hit it.
518         // Eventually, an unknown constraint should just be treated as 'g'.
519         return false;
520       }
521       break;
522     case '&': // early clobber.
523       Info.setEarlyClobber();
524       break;
525     case '%': // commutative.
526       // FIXME: Check that there is a another register after this one.
527       break;
528     case 'r': // general register.
529       Info.setAllowsRegister();
530       break;
531     case 'm': // memory operand.
532     case 'o': // offsetable memory operand.
533     case 'V': // non-offsetable memory operand.
534     case '<': // autodecrement memory operand.
535     case '>': // autoincrement memory operand.
536       Info.setAllowsMemory();
537       break;
538     case 'g': // general register, memory operand or immediate integer.
539     case 'X': // any operand.
540       Info.setAllowsRegister();
541       Info.setAllowsMemory();
542       break;
543     case ',': // multiple alternative constraint.  Pass it.
544       // Handle additional optional '=' or '+' modifiers.
545       if (Name[1] == '=' || Name[1] == '+')
546         Name++;
547       break;
548     case '#': // Ignore as constraint.
549       while (Name[1] && Name[1] != ',')
550         Name++;
551       break;
552     case '?': // Disparage slightly code.
553     case '!': // Disparage severely.
554     case '*': // Ignore for choosing register preferences.
555     case 'i': // Ignore i,n,E,F as output constraints (match from the other
556               // chars)
557     case 'n':
558     case 'E':
559     case 'F':
560       break;  // Pass them.
561     }
562 
563     Name++;
564   }
565 
566   // Early clobber with a read-write constraint which doesn't permit registers
567   // is invalid.
568   if (Info.earlyClobber() && Info.isReadWrite() && !Info.allowsRegister())
569     return false;
570 
571   // If a constraint allows neither memory nor register operands it contains
572   // only modifiers. Reject it.
573   return Info.allowsMemory() || Info.allowsRegister();
574 }
575 
576 bool TargetInfo::resolveSymbolicName(const char *&Name,
577                                      ArrayRef<ConstraintInfo> OutputConstraints,
578                                      unsigned &Index) const {
579   assert(*Name == '[' && "Symbolic name did not start with '['");
580   Name++;
581   const char *Start = Name;
582   while (*Name && *Name != ']')
583     Name++;
584 
585   if (!*Name) {
586     // Missing ']'
587     return false;
588   }
589 
590   std::string SymbolicName(Start, Name - Start);
591 
592   for (Index = 0; Index != OutputConstraints.size(); ++Index)
593     if (SymbolicName == OutputConstraints[Index].getName())
594       return true;
595 
596   return false;
597 }
598 
599 bool TargetInfo::validateInputConstraint(
600                               MutableArrayRef<ConstraintInfo> OutputConstraints,
601                               ConstraintInfo &Info) const {
602   const char *Name = Info.ConstraintStr.c_str();
603 
604   if (!*Name)
605     return false;
606 
607   while (*Name) {
608     switch (*Name) {
609     default:
610       // Check if we have a matching constraint
611       if (*Name >= '0' && *Name <= '9') {
612         const char *DigitStart = Name;
613         while (Name[1] >= '0' && Name[1] <= '9')
614           Name++;
615         const char *DigitEnd = Name;
616         unsigned i;
617         if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
618                 .getAsInteger(10, i))
619           return false;
620 
621         // Check if matching constraint is out of bounds.
622         if (i >= OutputConstraints.size()) return false;
623 
624         // A number must refer to an output only operand.
625         if (OutputConstraints[i].isReadWrite())
626           return false;
627 
628         // If the constraint is already tied, it must be tied to the
629         // same operand referenced to by the number.
630         if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
631           return false;
632 
633         // The constraint should have the same info as the respective
634         // output constraint.
635         Info.setTiedOperand(i, OutputConstraints[i]);
636       } else if (!validateAsmConstraint(Name, Info)) {
637         // FIXME: This error return is in place temporarily so we can
638         // add more constraints as we hit it.  Eventually, an unknown
639         // constraint should just be treated as 'g'.
640         return false;
641       }
642       break;
643     case '[': {
644       unsigned Index = 0;
645       if (!resolveSymbolicName(Name, OutputConstraints, Index))
646         return false;
647 
648       // If the constraint is already tied, it must be tied to the
649       // same operand referenced to by the number.
650       if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
651         return false;
652 
653       // A number must refer to an output only operand.
654       if (OutputConstraints[Index].isReadWrite())
655         return false;
656 
657       Info.setTiedOperand(Index, OutputConstraints[Index]);
658       break;
659     }
660     case '%': // commutative
661       // FIXME: Fail if % is used with the last operand.
662       break;
663     case 'i': // immediate integer.
664     case 'n': // immediate integer with a known value.
665       break;
666     case 'I':  // Various constant constraints with target-specific meanings.
667     case 'J':
668     case 'K':
669     case 'L':
670     case 'M':
671     case 'N':
672     case 'O':
673     case 'P':
674       if (!validateAsmConstraint(Name, Info))
675         return false;
676       break;
677     case 'r': // general register.
678       Info.setAllowsRegister();
679       break;
680     case 'm': // memory operand.
681     case 'o': // offsettable memory operand.
682     case 'V': // non-offsettable memory operand.
683     case '<': // autodecrement memory operand.
684     case '>': // autoincrement memory operand.
685       Info.setAllowsMemory();
686       break;
687     case 'g': // general register, memory operand or immediate integer.
688     case 'X': // any operand.
689       Info.setAllowsRegister();
690       Info.setAllowsMemory();
691       break;
692     case 'E': // immediate floating point.
693     case 'F': // immediate floating point.
694     case 'p': // address operand.
695       break;
696     case ',': // multiple alternative constraint.  Ignore comma.
697       break;
698     case '#': // Ignore as constraint.
699       while (Name[1] && Name[1] != ',')
700         Name++;
701       break;
702     case '?': // Disparage slightly code.
703     case '!': // Disparage severely.
704     case '*': // Ignore for choosing register preferences.
705       break;  // Pass them.
706     }
707 
708     Name++;
709   }
710 
711   return true;
712 }
713