clang  10.0.0svn
TargetInfo.cpp
Go to the documentation of this file.
1 //===--- TargetInfo.cpp - Information about Target machine ----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the TargetInfo and TargetInfoImpl interfaces.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/Basic/TargetInfo.h"
15 #include "clang/Basic/CharInfo.h"
16 #include "clang/Basic/Diagnostic.h"
18 #include "llvm/ADT/APFloat.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/Support/ErrorHandling.h"
21 #include "llvm/Support/TargetParser.h"
22 #include <cstdlib>
23 using namespace clang;
24 
25 static const LangASMap DefaultAddrSpaceMap = {0};
26 
27 // TargetInfo Constructor.
28 TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {
29  // Set defaults. Defaults are set for a 32-bit RISC platform, like PPC or
30  // SPARC. These should be overridden by concrete targets as needed.
31  BigEndian = !T.isLittleEndian();
32  TLSSupported = true;
33  VLASupported = true;
34  NoAsmVariants = false;
35  HasLegalHalfType = false;
36  HasFloat128 = false;
37  HasFloat16 = 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  HasAArch64SVETypes = 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.LongDoubleSize) {
378  if (Opts.LongDoubleSize == DoubleWidth) {
382  } else if (Opts.LongDoubleSize == 128) {
384  LongDoubleFormat = &llvm::APFloat::IEEEquad();
385  }
386  }
387 
388  if (Opts.NewAlignOverride)
389  NewAlign = Opts.NewAlignOverride * getCharWidth();
390 
391  // Each unsigned fixed point type has the same number of fractional bits as
392  // its corresponding signed type.
393  PaddingOnUnsignedFixedPoint |= Opts.PaddingOnUnsignedFixedPoint;
394  CheckFixedPointBits();
395 }
396 
398  llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
399  const std::vector<std::string> &FeatureVec) const {
400  for (const auto &F : FeatureVec) {
401  StringRef Name = F;
402  // Apply the feature via the target.
403  bool Enabled = Name[0] == '+';
404  setFeatureEnabled(Features, Name.substr(1), Enabled);
405  }
406  return true;
407 }
408 
410 TargetInfo::getCallingConvKind(bool ClangABICompat4) const {
412  (ClangABICompat4 || getTriple().getOS() == llvm::Triple::PS4))
413  return CCK_ClangABI4OrPS4;
414  return CCK_Default;
415 }
416 
418  switch (TK) {
419  case OCLTK_Image:
420  case OCLTK_Pipe:
421  return LangAS::opencl_global;
422 
423  case OCLTK_Sampler:
425 
426  default:
427  return LangAS::Default;
428  }
429 }
430 
431 //===----------------------------------------------------------------------===//
432 
433 
434 static StringRef removeGCCRegisterPrefix(StringRef Name) {
435  if (Name[0] == '%' || Name[0] == '#')
436  Name = Name.substr(1);
437 
438  return Name;
439 }
440 
441 /// isValidClobber - Returns whether the passed in string is
442 /// a valid clobber in an inline asm statement. This is used by
443 /// Sema.
444 bool TargetInfo::isValidClobber(StringRef Name) const {
445  return (isValidGCCRegisterName(Name) ||
446  Name == "memory" || Name == "cc");
447 }
448 
449 /// isValidGCCRegisterName - Returns whether the passed in string
450 /// is a valid register name according to GCC. This is used by Sema for
451 /// inline asm statements.
452 bool TargetInfo::isValidGCCRegisterName(StringRef Name) const {
453  if (Name.empty())
454  return false;
455 
456  // Get rid of any register prefix.
457  Name = removeGCCRegisterPrefix(Name);
458  if (Name.empty())
459  return false;
460 
462 
463  // If we have a number it maps to an entry in the register name array.
464  if (isDigit(Name[0])) {
465  unsigned n;
466  if (!Name.getAsInteger(0, n))
467  return n < Names.size();
468  }
469 
470  // Check register names.
471  if (llvm::is_contained(Names, Name))
472  return true;
473 
474  // Check any additional names that we have.
475  for (const AddlRegName &ARN : getGCCAddlRegNames())
476  for (const char *AN : ARN.Names) {
477  if (!AN)
478  break;
479  // Make sure the register that the additional name is for is within
480  // the bounds of the register names from above.
481  if (AN == Name && ARN.RegNum < Names.size())
482  return true;
483  }
484 
485  // Now check aliases.
486  for (const GCCRegAlias &GRA : getGCCRegAliases())
487  for (const char *A : GRA.Aliases) {
488  if (!A)
489  break;
490  if (A == Name)
491  return true;
492  }
493 
494  return false;
495 }
496 
498  bool ReturnCanonical) const {
499  assert(isValidGCCRegisterName(Name) && "Invalid register passed in");
500 
501  // Get rid of any register prefix.
502  Name = removeGCCRegisterPrefix(Name);
503 
505 
506  // First, check if we have a number.
507  if (isDigit(Name[0])) {
508  unsigned n;
509  if (!Name.getAsInteger(0, n)) {
510  assert(n < Names.size() && "Out of bounds register number!");
511  return Names[n];
512  }
513  }
514 
515  // Check any additional names that we have.
516  for (const AddlRegName &ARN : getGCCAddlRegNames())
517  for (const char *AN : ARN.Names) {
518  if (!AN)
519  break;
520  // Make sure the register that the additional name is for is within
521  // the bounds of the register names from above.
522  if (AN == Name && ARN.RegNum < Names.size())
523  return ReturnCanonical ? Names[ARN.RegNum] : Name;
524  }
525 
526  // Now check aliases.
527  for (const GCCRegAlias &RA : getGCCRegAliases())
528  for (const char *A : RA.Aliases) {
529  if (!A)
530  break;
531  if (A == Name)
532  return RA.Register;
533  }
534 
535  return Name;
536 }
537 
539  const char *Name = Info.getConstraintStr().c_str();
540  // An output constraint must start with '=' or '+'
541  if (*Name != '=' && *Name != '+')
542  return false;
543 
544  if (*Name == '+')
545  Info.setIsReadWrite();
546 
547  Name++;
548  while (*Name) {
549  switch (*Name) {
550  default:
551  if (!validateAsmConstraint(Name, Info)) {
552  // FIXME: We temporarily return false
553  // so we can add more constraints as we hit it.
554  // Eventually, an unknown constraint should just be treated as 'g'.
555  return false;
556  }
557  break;
558  case '&': // early clobber.
559  Info.setEarlyClobber();
560  break;
561  case '%': // commutative.
562  // FIXME: Check that there is a another register after this one.
563  break;
564  case 'r': // general register.
565  Info.setAllowsRegister();
566  break;
567  case 'm': // memory operand.
568  case 'o': // offsetable memory operand.
569  case 'V': // non-offsetable memory operand.
570  case '<': // autodecrement memory operand.
571  case '>': // autoincrement memory operand.
572  Info.setAllowsMemory();
573  break;
574  case 'g': // general register, memory operand or immediate integer.
575  case 'X': // any operand.
576  Info.setAllowsRegister();
577  Info.setAllowsMemory();
578  break;
579  case ',': // multiple alternative constraint. Pass it.
580  // Handle additional optional '=' or '+' modifiers.
581  if (Name[1] == '=' || Name[1] == '+')
582  Name++;
583  break;
584  case '#': // Ignore as constraint.
585  while (Name[1] && Name[1] != ',')
586  Name++;
587  break;
588  case '?': // Disparage slightly code.
589  case '!': // Disparage severely.
590  case '*': // Ignore for choosing register preferences.
591  case 'i': // Ignore i,n,E,F as output constraints (match from the other
592  // chars)
593  case 'n':
594  case 'E':
595  case 'F':
596  break; // Pass them.
597  }
598 
599  Name++;
600  }
601 
602  // Early clobber with a read-write constraint which doesn't permit registers
603  // is invalid.
604  if (Info.earlyClobber() && Info.isReadWrite() && !Info.allowsRegister())
605  return false;
606 
607  // If a constraint allows neither memory nor register operands it contains
608  // only modifiers. Reject it.
609  return Info.allowsMemory() || Info.allowsRegister();
610 }
611 
612 bool TargetInfo::resolveSymbolicName(const char *&Name,
613  ArrayRef<ConstraintInfo> OutputConstraints,
614  unsigned &Index) const {
615  assert(*Name == '[' && "Symbolic name did not start with '['");
616  Name++;
617  const char *Start = Name;
618  while (*Name && *Name != ']')
619  Name++;
620 
621  if (!*Name) {
622  // Missing ']'
623  return false;
624  }
625 
626  std::string SymbolicName(Start, Name - Start);
627 
628  for (Index = 0; Index != OutputConstraints.size(); ++Index)
629  if (SymbolicName == OutputConstraints[Index].getName())
630  return true;
631 
632  return false;
633 }
634 
636  MutableArrayRef<ConstraintInfo> OutputConstraints,
637  ConstraintInfo &Info) const {
638  const char *Name = Info.ConstraintStr.c_str();
639 
640  if (!*Name)
641  return false;
642 
643  while (*Name) {
644  switch (*Name) {
645  default:
646  // Check if we have a matching constraint
647  if (*Name >= '0' && *Name <= '9') {
648  const char *DigitStart = Name;
649  while (Name[1] >= '0' && Name[1] <= '9')
650  Name++;
651  const char *DigitEnd = Name;
652  unsigned i;
653  if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
654  .getAsInteger(10, i))
655  return false;
656 
657  // Check if matching constraint is out of bounds.
658  if (i >= OutputConstraints.size()) return false;
659 
660  // A number must refer to an output only operand.
661  if (OutputConstraints[i].isReadWrite())
662  return false;
663 
664  // If the constraint is already tied, it must be tied to the
665  // same operand referenced to by the number.
666  if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
667  return false;
668 
669  // The constraint should have the same info as the respective
670  // output constraint.
671  Info.setTiedOperand(i, OutputConstraints[i]);
672  } else if (!validateAsmConstraint(Name, Info)) {
673  // FIXME: This error return is in place temporarily so we can
674  // add more constraints as we hit it. Eventually, an unknown
675  // constraint should just be treated as 'g'.
676  return false;
677  }
678  break;
679  case '[': {
680  unsigned Index = 0;
681  if (!resolveSymbolicName(Name, OutputConstraints, Index))
682  return false;
683 
684  // If the constraint is already tied, it must be tied to the
685  // same operand referenced to by the number.
686  if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
687  return false;
688 
689  // A number must refer to an output only operand.
690  if (OutputConstraints[Index].isReadWrite())
691  return false;
692 
693  Info.setTiedOperand(Index, OutputConstraints[Index]);
694  break;
695  }
696  case '%': // commutative
697  // FIXME: Fail if % is used with the last operand.
698  break;
699  case 'i': // immediate integer.
700  break;
701  case 'n': // immediate integer with a known value.
702  Info.setRequiresImmediate();
703  break;
704  case 'I': // Various constant constraints with target-specific meanings.
705  case 'J':
706  case 'K':
707  case 'L':
708  case 'M':
709  case 'N':
710  case 'O':
711  case 'P':
712  if (!validateAsmConstraint(Name, Info))
713  return false;
714  break;
715  case 'r': // general register.
716  Info.setAllowsRegister();
717  break;
718  case 'm': // memory operand.
719  case 'o': // offsettable memory operand.
720  case 'V': // non-offsettable memory operand.
721  case '<': // autodecrement memory operand.
722  case '>': // autoincrement memory operand.
723  Info.setAllowsMemory();
724  break;
725  case 'g': // general register, memory operand or immediate integer.
726  case 'X': // any operand.
727  Info.setAllowsRegister();
728  Info.setAllowsMemory();
729  break;
730  case 'E': // immediate floating point.
731  case 'F': // immediate floating point.
732  case 'p': // address operand.
733  break;
734  case ',': // multiple alternative constraint. Ignore comma.
735  break;
736  case '#': // Ignore as constraint.
737  while (Name[1] && Name[1] != ',')
738  Name++;
739  break;
740  case '?': // Disparage slightly code.
741  case '!': // Disparage severely.
742  case '*': // Ignore for choosing register preferences.
743  break; // Pass them.
744  }
745 
746  Name++;
747  }
748 
749  return true;
750 }
751 
752 void TargetInfo::CheckFixedPointBits() const {
753  // Check that the number of fractional and integral bits (and maybe sign) can
754  // fit into the bits given for a fixed point type.
756  assert(AccumScale + getAccumIBits() + 1 <= AccumWidth);
763 
764  assert(getShortFractScale() + 1 <= ShortFractWidth);
765  assert(getFractScale() + 1 <= FractWidth);
766  assert(getLongFractScale() + 1 <= LongFractWidth);
768  assert(getUnsignedFractScale() <= FractWidth);
770 
771  // Each unsigned fract type has either the same number of fractional bits
772  // as, or one more fractional bit than, its corresponding signed fract type.
775  assert(getFractScale() == getUnsignedFractScale() ||
779 
780  // When arranged in order of increasing rank (see 6.3.1.3a), the number of
781  // fractional bits is nondecreasing for each of the following sets of
782  // fixed-point types:
783  // - signed fract types
784  // - unsigned fract types
785  // - signed accum types
786  // - unsigned accum types.
787  assert(getLongFractScale() >= getFractScale() &&
794 
795  // When arranged in order of increasing rank (see 6.3.1.3a), the number of
796  // integral bits is nondecreasing for each of the following sets of
797  // fixed-point types:
798  // - signed accum types
799  // - unsigned accum types
800  assert(getLongAccumIBits() >= getAccumIBits() &&
804 
805  // Each signed accum type has at least as many integral bits as its
806  // corresponding unsigned accum type.
808  assert(getAccumIBits() >= getUnsignedAccumIBits());
810 }
811 
813  auto *Target = static_cast<TransferrableTargetInfo*>(this);
814  auto *Src = static_cast<const TransferrableTargetInfo*>(Aux);
815  *Target = *Src;
816 }
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:579
unsigned getLongAccumIBits() const
Definition: TargetInfo.h:453
unsigned char LargeArrayMinWidth
Definition: TargetInfo.h:62
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:400
const llvm::fltSemantics * FloatFormat
Definition: TargetInfo.h:100
virtual bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const =0
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:991
unsigned getLongAlign() const
Definition: TargetInfo.h:401
virtual IntType getLeastIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return the smallest integer type with at least the specified width.
Definition: TargetInfo.cpp:245
virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const
Get address space for OpenCL type.
Definition: TargetInfo.cpp:417
bool validateInputConstraint(MutableArrayRef< ConstraintInfo > OutputConstraints, ConstraintInfo &info) const
Definition: TargetInfo.cpp:635
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1297
unsigned getAccumIBits() const
Definition: TargetInfo.h:448
TargetInfo(const llvm::Triple &T)
Definition: TargetInfo.cpp:28
unsigned getCharWidth() const
Definition: TargetInfo.h:382
unsigned short SimdDefaultAlign
Definition: TargetInfo.h:178
unsigned getShortAccumIBits() const
Definition: TargetInfo.h:441
void setRequiresImmediate(int Min, int Max)
Definition: TargetInfo.h:896
static const LangASMap DefaultAddrSpaceMap
Definition: TargetInfo.cpp:25
unsigned getCharAlign() const
Definition: TargetInfo.h:383
unsigned UseSignedCharForObjCBool
Whether Objective-C&#39;s built-in boolean type should be signed char.
Definition: TargetInfo.h:134
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Definition: AddressSpaces.h:25
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:1095
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Definition: TargetInfo.h:1060
unsigned getIntAlign() const
Definition: TargetInfo.h:396
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:497
const char * MCountName
Definition: TargetInfo.h:180
unsigned getUnsignedLongAccumIBits() const
Definition: TargetInfo.h:483
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:49
static bool isTypeSigned(IntType T)
Returns true if the type is signed; false otherwise.
Definition: TargetInfo.cpp:303
unsigned char MaxAtomicPromoteWidth
Definition: TargetInfo.h:177
const llvm::fltSemantics * HalfFormat
Definition: TargetInfo.h:100
unsigned char SSERegParmMax
Definition: TargetInfo.h:181
const llvm::fltSemantics * Float128Format
Definition: TargetInfo.h:100
The Microsoft ABI is the ABI used by Microsoft Visual Studio (and compatible compilers).
Definition: TargetCXXABI.h:112
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:387
Defines the Diagnostic-related interfaces.
unsigned HasAArch64SVETypes
Definition: TargetInfo.h:196
VersionTuple PlatformMinVersion
Definition: TargetInfo.h:186
unsigned ComplexLongDoubleUsesFP2Ret
Definition: TargetInfo.h:190
unsigned getLongLongAlign() const
Definition: TargetInfo.h:406
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
Definition: TargetInfo.h:149
virtual bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
Definition: TargetInfo.cpp:452
unsigned RealTypeUsesObjCFPRet
Definition: TargetInfo.h:189
Provides definitions for the various language-specific address spaces.
virtual bool checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const
Check if the target supports CFProtection branch.
Definition: TargetInfo.cpp:140
StringRef PlatformName
Definition: TargetInfo.h:185
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
Definition: TargetInfo.cpp:410
bool isValidClobber(StringRef Name) const
Returns whether the passed in string is a valid clobber in an inline asm statement.
Definition: TargetInfo.cpp:444
unsigned char DefaultAlignForAttributeAligned
Definition: TargetInfo.h:93
const llvm::fltSemantics & getLongDoubleFormat() const
Definition: TargetInfo.h:592
unsigned HasBuiltinMSVaList
Definition: TargetInfo.h:192
Exposes information about the current target.
Definition: TargetInfo.h:161
unsigned HasAlignMac68kSupport
Definition: TargetInfo.h:188
unsigned char RegParmMax
Definition: TargetInfo.h:181
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:397
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:395
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
Definition: TargetInfo.h:141
static StringRef removeGCCRegisterPrefix(StringRef Name)
Definition: TargetInfo.cpp:434
unsigned getShortAlign() const
Return the alignment of &#39;signed short&#39; and &#39;unsigned short&#39; for this target.
Definition: TargetInfo.h:391
unsigned getDoubleWidth() const
getDoubleWidth/Align/Format - Return the size/align/format of &#39;double&#39;.
Definition: TargetInfo.h:584
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
const llvm::fltSemantics * LongDoubleFormat
Definition: TargetInfo.h:100
const LangASMap * AddrSpaceMap
Definition: TargetInfo.h:183
unsigned IsRenderScriptTarget
Definition: TargetInfo.h:194
unsigned UseExplicitBitFieldAlignment
Whether explicit bit field alignment attributes are honored.
Definition: TargetInfo.h:152
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:405
unsigned getUnsignedAccumScale() const
getUnsignedAccumScale/IBits - Return the number of fractional/integral bits in a &#39;unsigned _Accum&#39; ty...
Definition: TargetInfo.h:470
bool validateOutputConstraint(ConstraintInfo &Info) const
Definition: TargetInfo.cpp:538
virtual ArrayRef< AddlRegName > getGCCAddlRegNames() const
Definition: TargetInfo.h:1388
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:33
virtual ArrayRef< GCCRegAlias > getGCCRegAliases() const =0
unsigned getUnsignedAccumIBits() const
Definition: TargetInfo.h:473
void set(Kind kind)
Definition: TargetCXXABI.h:127
unsigned getUnsignedLongAccumScale() const
getUnsignedLongAccumScale/IBits - Return the number of fractional/integral bits in a &#39;unsigned long _...
Definition: TargetInfo.h:480
IntType
===-— Target Data Type Query Methods ----------------------------—===//
Definition: TargetInfo.h:104
RealType getRealTypeByWidth(unsigned BitWidth) const
Return floating point type with specified width.
Definition: TargetInfo.cpp:260
unsigned getUnsignedShortAccumIBits() const
Definition: TargetInfo.h:462
Dataflow Directional Tag Classes.
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield...
Definition: TargetInfo.h:156
static const char * getTypeFormatModifier(IntType T)
Return the printf format modifier for the specified integer type enum.
Definition: TargetInfo.cpp:196
static std::string getName(const CallEvent &Call)
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:53
unsigned getLongFractScale() const
getLongFractScale - Return the number of fractional bits in a &#39;signed long _Fract&#39; type...
Definition: TargetInfo.h:499
unsigned getUnsignedFractScale() const
getUnsignedFractScale - Return the number of fractional bits in a &#39;unsigned _Fract&#39; type...
Definition: TargetInfo.h:510
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand...
Definition: TargetInfo.h:874
Fields controlling how types are laid out in memory; these may need to be copied for targets like AMD...
Definition: TargetInfo.h:54
const std::string & getConstraintStr() const
Definition: TargetInfo.h:858
unsigned getUnsignedShortAccumScale() const
getUnsignedShortAccumScale/IBits - Return the number of fractional/integral bits in a &#39;unsigned short...
Definition: TargetInfo.h:459
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:93
bool resolveSymbolicName(const char *&Name, ArrayRef< ConstraintInfo > OutputConstraints, unsigned &Index) const
Definition: TargetInfo.cpp:612
virtual uint64_t getMaxPointerWidth() const
Return the maximum width of pointers on this target.
Definition: TargetInfo.h:368
unsigned getShortFractScale() const
getShortFractScale - Return the number of fractional bits in a &#39;signed short _Fract&#39; type...
Definition: TargetInfo.h:491
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
Definition: TargetInfo.h:530
void copyAuxTarget(const TargetInfo *Aux)
Copy type and layout related info.
Definition: TargetInfo.cpp:812
unsigned getUnsignedLongFractScale() const
getUnsignedLongFractScale - Return the number of fractional bits in a &#39;unsigned long _Fract&#39; type...
Definition: TargetInfo.h:516
unsigned getFractScale() const
getFractScale - Return the number of fractional bits in a &#39;signed _Fract&#39; type.
Definition: TargetInfo.h:495
unsigned getUnsignedShortFractScale() const
getUnsignedShortFractScale - Return the number of fractional bits in a &#39;unsigned short _Fract&#39; type...
Definition: TargetInfo.h:503
const llvm::fltSemantics * DoubleFormat
Definition: TargetInfo.h:100
TargetCXXABI TheCXXABI
Definition: TargetInfo.h:182
Defines the clang::TargetInfo interface.
unsigned char MaxAtomicInlineWidth
Definition: TargetInfo.h:177
void setTiedOperand(unsigned N, ConstraintInfo &Output)
Indicate that this is an input operand that is tied to the specified output operand.
Definition: TargetInfo.h:919
virtual ArrayRef< const char * > getGCCRegNames() const =0
bool UseAddrSpaceMapMangling
Specify if mangling based on address space map should be used or not for language specific address sp...
Definition: TargetInfo.h:267
unsigned short MaxVectorAlign
Definition: TargetInfo.h:97