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