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