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