TargetInfo.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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. #include "clang/Basic/TargetInfo.h"
  14. #include "clang/Basic/AddressSpaces.h"
  15. #include "clang/Basic/CharInfo.h"
  16. #include "clang/Basic/LangOptions.h"
  17. #include "llvm/ADT/APFloat.h"
  18. #include "llvm/ADT/STLExtras.h"
  19. #include "llvm/Support/ErrorHandling.h"
  20. #include <cstdlib>
  21. using namespace clang;
  22. static const LangAS::Map DefaultAddrSpaceMap = { 0 };
  23. // TargetInfo Constructor.
  24. TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
  25. // Set defaults. Defaults are set for a 32-bit RISC platform, like PPC or
  26. // SPARC. These should be overridden by concrete targets as needed.
  27. BigEndian = true;
  28. TLSSupported = true;
  29. NoAsmVariants = false;
  30. PointerWidth = PointerAlign = 32;
  31. BoolWidth = BoolAlign = 8;
  32. IntWidth = IntAlign = 32;
  33. LongWidth = LongAlign = 32;
  34. LongLongWidth = LongLongAlign = 64;
  35. SuitableAlign = 64;
  36. DefaultAlignForAttributeAligned = 128;
  37. MinGlobalAlign = 0;
  38. HalfWidth = 16;
  39. HalfAlign = 16;
  40. FloatWidth = 32;
  41. FloatAlign = 32;
  42. DoubleWidth = 64;
  43. DoubleAlign = 64;
  44. LongDoubleWidth = 64;
  45. LongDoubleAlign = 64;
  46. LargeArrayMinWidth = 0;
  47. LargeArrayAlign = 0;
  48. MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;
  49. MaxVectorAlign = 0;
  50. MaxTLSAlign = 0;
  51. SimdDefaultAlign = 0;
  52. SizeType = UnsignedLong;
  53. PtrDiffType = SignedLong;
  54. IntMaxType = SignedLongLong;
  55. IntPtrType = SignedLong;
  56. WCharType = SignedInt;
  57. WIntType = SignedInt;
  58. Char16Type = UnsignedShort;
  59. Char32Type = UnsignedInt;
  60. Int64Type = SignedLongLong;
  61. SigAtomicType = SignedInt;
  62. ProcessIDType = SignedInt;
  63. UseSignedCharForObjCBool = true;
  64. UseBitFieldTypeAlignment = true;
  65. UseZeroLengthBitfieldAlignment = false;
  66. ZeroLengthBitfieldBoundary = 0;
  67. HalfFormat = &llvm::APFloat::IEEEhalf;
  68. FloatFormat = &llvm::APFloat::IEEEsingle;
  69. DoubleFormat = &llvm::APFloat::IEEEdouble;
  70. LongDoubleFormat = &llvm::APFloat::IEEEdouble;
  71. DescriptionString = nullptr;
  72. UserLabelPrefix = "_";
  73. MCountName = "mcount";
  74. RegParmMax = 0;
  75. SSERegParmMax = 0;
  76. HasAlignMac68kSupport = false;
  77. // Default to no types using fpret.
  78. RealTypeUsesObjCFPRet = 0;
  79. // Default to not using fp2ret for __Complex long double
  80. ComplexLongDoubleUsesFP2Ret = false;
  81. // Set the C++ ABI based on the triple.
  82. TheCXXABI.set(Triple.isKnownWindowsMSVCEnvironment()
  83. ? TargetCXXABI::Microsoft
  84. : TargetCXXABI::GenericItanium);
  85. // Default to an empty address space map.
  86. AddrSpaceMap = &DefaultAddrSpaceMap;
  87. UseAddrSpaceMapMangling = false;
  88. // Default to an unknown platform name.
  89. PlatformName = "unknown";
  90. PlatformMinVersion = VersionTuple();
  91. }
  92. // Out of line virtual dtor for TargetInfo.
  93. TargetInfo::~TargetInfo() {}
  94. /// getTypeName - Return the user string for the specified integer type enum.
  95. /// For example, SignedShort -> "short".
  96. const char *TargetInfo::getTypeName(IntType T) {
  97. switch (T) {
  98. default: llvm_unreachable("not an integer!");
  99. case SignedChar: return "signed char";
  100. case UnsignedChar: return "unsigned char";
  101. case SignedShort: return "short";
  102. case UnsignedShort: return "unsigned short";
  103. case SignedInt: return "int";
  104. case UnsignedInt: return "unsigned int";
  105. case SignedLong: return "long int";
  106. case UnsignedLong: return "long unsigned int";
  107. case SignedLongLong: return "long long int";
  108. case UnsignedLongLong: return "long long unsigned int";
  109. }
  110. }
  111. /// getTypeConstantSuffix - Return the constant suffix for the specified
  112. /// integer type enum. For example, SignedLong -> "L".
  113. const char *TargetInfo::getTypeConstantSuffix(IntType T) const {
  114. switch (T) {
  115. default: llvm_unreachable("not an integer!");
  116. case SignedChar:
  117. case SignedShort:
  118. case SignedInt: return "";
  119. case SignedLong: return "L";
  120. case SignedLongLong: return "LL";
  121. case UnsignedChar:
  122. if (getCharWidth() < getIntWidth())
  123. return "";
  124. case UnsignedShort:
  125. if (getShortWidth() < getIntWidth())
  126. return "";
  127. case UnsignedInt: return "U";
  128. case UnsignedLong: return "UL";
  129. case UnsignedLongLong: return "ULL";
  130. }
  131. }
  132. /// getTypeFormatModifier - Return the printf format modifier for the
  133. /// specified integer type enum. For example, SignedLong -> "l".
  134. const char *TargetInfo::getTypeFormatModifier(IntType T) {
  135. switch (T) {
  136. default: llvm_unreachable("not an integer!");
  137. case SignedChar:
  138. case UnsignedChar: return "hh";
  139. case SignedShort:
  140. case UnsignedShort: return "h";
  141. case SignedInt:
  142. case UnsignedInt: return "";
  143. case SignedLong:
  144. case UnsignedLong: return "l";
  145. case SignedLongLong:
  146. case UnsignedLongLong: return "ll";
  147. }
  148. }
  149. /// getTypeWidth - Return the width (in bits) of the specified integer type
  150. /// enum. For example, SignedInt -> getIntWidth().
  151. unsigned TargetInfo::getTypeWidth(IntType T) const {
  152. switch (T) {
  153. default: llvm_unreachable("not an integer!");
  154. case SignedChar:
  155. case UnsignedChar: return getCharWidth();
  156. case SignedShort:
  157. case UnsignedShort: return getShortWidth();
  158. case SignedInt:
  159. case UnsignedInt: return getIntWidth();
  160. case SignedLong:
  161. case UnsignedLong: return getLongWidth();
  162. case SignedLongLong:
  163. case UnsignedLongLong: return getLongLongWidth();
  164. };
  165. }
  166. TargetInfo::IntType TargetInfo::getIntTypeByWidth(
  167. unsigned BitWidth, bool IsSigned) const {
  168. if (getCharWidth() == BitWidth)
  169. return IsSigned ? SignedChar : UnsignedChar;
  170. if (getShortWidth() == BitWidth)
  171. return IsSigned ? SignedShort : UnsignedShort;
  172. if (getIntWidth() == BitWidth)
  173. return IsSigned ? SignedInt : UnsignedInt;
  174. if (getLongWidth() == BitWidth)
  175. return IsSigned ? SignedLong : UnsignedLong;
  176. if (getLongLongWidth() == BitWidth)
  177. return IsSigned ? SignedLongLong : UnsignedLongLong;
  178. return NoInt;
  179. }
  180. TargetInfo::IntType TargetInfo::getLeastIntTypeByWidth(unsigned BitWidth,
  181. bool IsSigned) const {
  182. if (getCharWidth() >= BitWidth)
  183. return IsSigned ? SignedChar : UnsignedChar;
  184. if (getShortWidth() >= BitWidth)
  185. return IsSigned ? SignedShort : UnsignedShort;
  186. if (getIntWidth() >= BitWidth)
  187. return IsSigned ? SignedInt : UnsignedInt;
  188. if (getLongWidth() >= BitWidth)
  189. return IsSigned ? SignedLong : UnsignedLong;
  190. if (getLongLongWidth() >= BitWidth)
  191. return IsSigned ? SignedLongLong : UnsignedLongLong;
  192. return NoInt;
  193. }
  194. TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth) const {
  195. if (getFloatWidth() == BitWidth)
  196. return Float;
  197. if (getDoubleWidth() == BitWidth)
  198. return Double;
  199. switch (BitWidth) {
  200. case 96:
  201. if (&getLongDoubleFormat() == &llvm::APFloat::x87DoubleExtended)
  202. return LongDouble;
  203. break;
  204. case 128:
  205. if (&getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble ||
  206. &getLongDoubleFormat() == &llvm::APFloat::IEEEquad)
  207. return LongDouble;
  208. break;
  209. }
  210. return NoFloat;
  211. }
  212. /// getTypeAlign - Return the alignment (in bits) of the specified integer type
  213. /// enum. For example, SignedInt -> getIntAlign().
  214. unsigned TargetInfo::getTypeAlign(IntType T) const {
  215. switch (T) {
  216. default: llvm_unreachable("not an integer!");
  217. case SignedChar:
  218. case UnsignedChar: return getCharAlign();
  219. case SignedShort:
  220. case UnsignedShort: return getShortAlign();
  221. case SignedInt:
  222. case UnsignedInt: return getIntAlign();
  223. case SignedLong:
  224. case UnsignedLong: return getLongAlign();
  225. case SignedLongLong:
  226. case UnsignedLongLong: return getLongLongAlign();
  227. };
  228. }
  229. /// isTypeSigned - Return whether an integer types is signed. Returns true if
  230. /// the type is signed; false otherwise.
  231. bool TargetInfo::isTypeSigned(IntType T) {
  232. switch (T) {
  233. default: llvm_unreachable("not an integer!");
  234. case SignedChar:
  235. case SignedShort:
  236. case SignedInt:
  237. case SignedLong:
  238. case SignedLongLong:
  239. return true;
  240. case UnsignedChar:
  241. case UnsignedShort:
  242. case UnsignedInt:
  243. case UnsignedLong:
  244. case UnsignedLongLong:
  245. return false;
  246. };
  247. }
  248. /// adjust - Set forced language options.
  249. /// Apply changes to the target information with respect to certain
  250. /// language options which change the target configuration.
  251. void TargetInfo::adjust(const LangOptions &Opts) {
  252. if (Opts.NoBitFieldTypeAlign)
  253. UseBitFieldTypeAlignment = false;
  254. if (Opts.ShortWChar)
  255. WCharType = UnsignedShort;
  256. if (Opts.OpenCL) {
  257. // OpenCL C requires specific widths for types, irrespective of
  258. // what these normally are for the target.
  259. // We also define long long and long double here, although the
  260. // OpenCL standard only mentions these as "reserved".
  261. IntWidth = IntAlign = 32;
  262. LongWidth = LongAlign = 64;
  263. LongLongWidth = LongLongAlign = 128;
  264. HalfWidth = HalfAlign = 16;
  265. FloatWidth = FloatAlign = 32;
  266. // Embedded 32-bit targets (OpenCL EP) might have double C type
  267. // defined as float. Let's not override this as it might lead
  268. // to generating illegal code that uses 64bit doubles.
  269. if (DoubleWidth != FloatWidth) {
  270. DoubleWidth = DoubleAlign = 64;
  271. DoubleFormat = &llvm::APFloat::IEEEdouble;
  272. }
  273. LongDoubleWidth = LongDoubleAlign = 128;
  274. assert(PointerWidth == 32 || PointerWidth == 64);
  275. bool Is32BitArch = PointerWidth == 32;
  276. SizeType = Is32BitArch ? UnsignedInt : UnsignedLong;
  277. PtrDiffType = Is32BitArch ? SignedInt : SignedLong;
  278. IntPtrType = Is32BitArch ? SignedInt : SignedLong;
  279. IntMaxType = SignedLongLong;
  280. Int64Type = SignedLong;
  281. HalfFormat = &llvm::APFloat::IEEEhalf;
  282. FloatFormat = &llvm::APFloat::IEEEsingle;
  283. LongDoubleFormat = &llvm::APFloat::IEEEquad;
  284. }
  285. }
  286. //===----------------------------------------------------------------------===//
  287. static StringRef removeGCCRegisterPrefix(StringRef Name) {
  288. if (Name[0] == '%' || Name[0] == '#')
  289. Name = Name.substr(1);
  290. return Name;
  291. }
  292. /// isValidClobber - Returns whether the passed in string is
  293. /// a valid clobber in an inline asm statement. This is used by
  294. /// Sema.
  295. bool TargetInfo::isValidClobber(StringRef Name) const {
  296. return (isValidGCCRegisterName(Name) ||
  297. Name == "memory" || Name == "cc");
  298. }
  299. /// isValidGCCRegisterName - Returns whether the passed in string
  300. /// is a valid register name according to GCC. This is used by Sema for
  301. /// inline asm statements.
  302. bool TargetInfo::isValidGCCRegisterName(StringRef Name) const {
  303. if (Name.empty())
  304. return false;
  305. const char * const *Names;
  306. unsigned NumNames;
  307. // Get rid of any register prefix.
  308. Name = removeGCCRegisterPrefix(Name);
  309. if (Name.empty())
  310. return false;
  311. getGCCRegNames(Names, NumNames);
  312. // If we have a number it maps to an entry in the register name array.
  313. if (isDigit(Name[0])) {
  314. int n;
  315. if (!Name.getAsInteger(0, n))
  316. return n >= 0 && (unsigned)n < NumNames;
  317. }
  318. // Check register names.
  319. for (unsigned i = 0; i < NumNames; i++) {
  320. if (Name == Names[i])
  321. return true;
  322. }
  323. // Check any additional names that we have.
  324. const AddlRegName *AddlNames;
  325. unsigned NumAddlNames;
  326. getGCCAddlRegNames(AddlNames, NumAddlNames);
  327. for (unsigned i = 0; i < NumAddlNames; i++)
  328. for (unsigned j = 0; j < llvm::array_lengthof(AddlNames[i].Names); j++) {
  329. if (!AddlNames[i].Names[j])
  330. break;
  331. // Make sure the register that the additional name is for is within
  332. // the bounds of the register names from above.
  333. if (AddlNames[i].Names[j] == Name && AddlNames[i].RegNum < NumNames)
  334. return true;
  335. }
  336. // Now check aliases.
  337. const GCCRegAlias *Aliases;
  338. unsigned NumAliases;
  339. getGCCRegAliases(Aliases, NumAliases);
  340. for (unsigned i = 0; i < NumAliases; i++) {
  341. for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
  342. if (!Aliases[i].Aliases[j])
  343. break;
  344. if (Aliases[i].Aliases[j] == Name)
  345. return true;
  346. }
  347. }
  348. return false;
  349. }
  350. StringRef
  351. TargetInfo::getNormalizedGCCRegisterName(StringRef Name) const {
  352. assert(isValidGCCRegisterName(Name) && "Invalid register passed in");
  353. // Get rid of any register prefix.
  354. Name = removeGCCRegisterPrefix(Name);
  355. const char * const *Names;
  356. unsigned NumNames;
  357. getGCCRegNames(Names, NumNames);
  358. // First, check if we have a number.
  359. if (isDigit(Name[0])) {
  360. int n;
  361. if (!Name.getAsInteger(0, n)) {
  362. assert(n >= 0 && (unsigned)n < NumNames &&
  363. "Out of bounds register number!");
  364. return Names[n];
  365. }
  366. }
  367. // Check any additional names that we have.
  368. const AddlRegName *AddlNames;
  369. unsigned NumAddlNames;
  370. getGCCAddlRegNames(AddlNames, NumAddlNames);
  371. for (unsigned i = 0; i < NumAddlNames; i++)
  372. for (unsigned j = 0; j < llvm::array_lengthof(AddlNames[i].Names); j++) {
  373. if (!AddlNames[i].Names[j])
  374. break;
  375. // Make sure the register that the additional name is for is within
  376. // the bounds of the register names from above.
  377. if (AddlNames[i].Names[j] == Name && AddlNames[i].RegNum < NumNames)
  378. return Name;
  379. }
  380. // Now check aliases.
  381. const GCCRegAlias *Aliases;
  382. unsigned NumAliases;
  383. getGCCRegAliases(Aliases, NumAliases);
  384. for (unsigned i = 0; i < NumAliases; i++) {
  385. for (unsigned j = 0 ; j < llvm::array_lengthof(Aliases[i].Aliases); j++) {
  386. if (!Aliases[i].Aliases[j])
  387. break;
  388. if (Aliases[i].Aliases[j] == Name)
  389. return Aliases[i].Register;
  390. }
  391. }
  392. return Name;
  393. }
  394. bool TargetInfo::validateOutputConstraint(ConstraintInfo &Info) const {
  395. const char *Name = Info.getConstraintStr().c_str();
  396. // An output constraint must start with '=' or '+'
  397. if (*Name != '=' && *Name != '+')
  398. return false;
  399. if (*Name == '+')
  400. Info.setIsReadWrite();
  401. Name++;
  402. while (*Name) {
  403. switch (*Name) {
  404. default:
  405. if (!validateAsmConstraint(Name, Info)) {
  406. // FIXME: We temporarily return false
  407. // so we can add more constraints as we hit it.
  408. // Eventually, an unknown constraint should just be treated as 'g'.
  409. return false;
  410. }
  411. break;
  412. case '&': // early clobber.
  413. Info.setEarlyClobber();
  414. break;
  415. case '%': // commutative.
  416. // FIXME: Check that there is a another register after this one.
  417. break;
  418. case 'r': // general register.
  419. Info.setAllowsRegister();
  420. break;
  421. case 'm': // memory operand.
  422. case 'o': // offsetable memory operand.
  423. case 'V': // non-offsetable memory operand.
  424. case '<': // autodecrement memory operand.
  425. case '>': // autoincrement memory operand.
  426. Info.setAllowsMemory();
  427. break;
  428. case 'g': // general register, memory operand or immediate integer.
  429. case 'X': // any operand.
  430. Info.setAllowsRegister();
  431. Info.setAllowsMemory();
  432. break;
  433. case ',': // multiple alternative constraint. Pass it.
  434. // Handle additional optional '=' or '+' modifiers.
  435. if (Name[1] == '=' || Name[1] == '+')
  436. Name++;
  437. break;
  438. case '#': // Ignore as constraint.
  439. while (Name[1] && Name[1] != ',')
  440. Name++;
  441. break;
  442. case '?': // Disparage slightly code.
  443. case '!': // Disparage severely.
  444. case '*': // Ignore for choosing register preferences.
  445. break; // Pass them.
  446. }
  447. Name++;
  448. }
  449. // Early clobber with a read-write constraint which doesn't permit registers
  450. // is invalid.
  451. if (Info.earlyClobber() && Info.isReadWrite() && !Info.allowsRegister())
  452. return false;
  453. // If a constraint allows neither memory nor register operands it contains
  454. // only modifiers. Reject it.
  455. return Info.allowsMemory() || Info.allowsRegister();
  456. }
  457. bool TargetInfo::resolveSymbolicName(const char *&Name,
  458. ConstraintInfo *OutputConstraints,
  459. unsigned NumOutputs,
  460. unsigned &Index) const {
  461. assert(*Name == '[' && "Symbolic name did not start with '['");
  462. Name++;
  463. const char *Start = Name;
  464. while (*Name && *Name != ']')
  465. Name++;
  466. if (!*Name) {
  467. // Missing ']'
  468. return false;
  469. }
  470. std::string SymbolicName(Start, Name - Start);
  471. for (Index = 0; Index != NumOutputs; ++Index)
  472. if (SymbolicName == OutputConstraints[Index].getName())
  473. return true;
  474. return false;
  475. }
  476. bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
  477. unsigned NumOutputs,
  478. ConstraintInfo &Info) const {
  479. const char *Name = Info.ConstraintStr.c_str();
  480. if (!*Name)
  481. return false;
  482. while (*Name) {
  483. switch (*Name) {
  484. default:
  485. // Check if we have a matching constraint
  486. if (*Name >= '0' && *Name <= '9') {
  487. const char *DigitStart = Name;
  488. while (Name[1] >= '0' && Name[1] <= '9')
  489. Name++;
  490. const char *DigitEnd = Name;
  491. unsigned i;
  492. if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
  493. .getAsInteger(10, i))
  494. return false;
  495. // Check if matching constraint is out of bounds.
  496. if (i >= NumOutputs) return false;
  497. // A number must refer to an output only operand.
  498. if (OutputConstraints[i].isReadWrite())
  499. return false;
  500. // If the constraint is already tied, it must be tied to the
  501. // same operand referenced to by the number.
  502. if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
  503. return false;
  504. // The constraint should have the same info as the respective
  505. // output constraint.
  506. Info.setTiedOperand(i, OutputConstraints[i]);
  507. } else if (!validateAsmConstraint(Name, Info)) {
  508. // FIXME: This error return is in place temporarily so we can
  509. // add more constraints as we hit it. Eventually, an unknown
  510. // constraint should just be treated as 'g'.
  511. return false;
  512. }
  513. break;
  514. case '[': {
  515. unsigned Index = 0;
  516. if (!resolveSymbolicName(Name, OutputConstraints, NumOutputs, Index))
  517. return false;
  518. // If the constraint is already tied, it must be tied to the
  519. // same operand referenced to by the number.
  520. if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
  521. return false;
  522. // A number must refer to an output only operand.
  523. if (OutputConstraints[Index].isReadWrite())
  524. return false;
  525. Info.setTiedOperand(Index, OutputConstraints[Index]);
  526. break;
  527. }
  528. case '%': // commutative
  529. // FIXME: Fail if % is used with the last operand.
  530. break;
  531. case 'i': // immediate integer.
  532. case 'n': // immediate integer with a known value.
  533. break;
  534. case 'I': // Various constant constraints with target-specific meanings.
  535. case 'J':
  536. case 'K':
  537. case 'L':
  538. case 'M':
  539. case 'N':
  540. case 'O':
  541. case 'P':
  542. if (!validateAsmConstraint(Name, Info))
  543. return false;
  544. break;
  545. case 'r': // general register.
  546. Info.setAllowsRegister();
  547. break;
  548. case 'm': // memory operand.
  549. case 'o': // offsettable memory operand.
  550. case 'V': // non-offsettable memory operand.
  551. case '<': // autodecrement memory operand.
  552. case '>': // autoincrement memory operand.
  553. Info.setAllowsMemory();
  554. break;
  555. case 'g': // general register, memory operand or immediate integer.
  556. case 'X': // any operand.
  557. Info.setAllowsRegister();
  558. Info.setAllowsMemory();
  559. break;
  560. case 'E': // immediate floating point.
  561. case 'F': // immediate floating point.
  562. case 'p': // address operand.
  563. break;
  564. case ',': // multiple alternative constraint. Ignore comma.
  565. break;
  566. case '#': // Ignore as constraint.
  567. while (Name[1] && Name[1] != ',')
  568. Name++;
  569. break;
  570. case '?': // Disparage slightly code.
  571. case '!': // Disparage severely.
  572. case '*': // Ignore for choosing register preferences.
  573. break; // Pass them.
  574. }
  575. Name++;
  576. }
  577. return true;
  578. }
  579. bool TargetCXXABI::tryParse(llvm::StringRef name) {
  580. const Kind unknown = static_cast<Kind>(-1);
  581. Kind kind = llvm::StringSwitch<Kind>(name)
  582. .Case("arm", GenericARM)
  583. .Case("ios", iOS)
  584. .Case("itanium", GenericItanium)
  585. .Case("microsoft", Microsoft)
  586. .Case("mips", GenericMIPS)
  587. .Default(unknown);
  588. if (kind == unknown) return false;
  589. set(kind);
  590. return true;
  591. }