clang  9.0.0
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 
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.LongDoubleSize) {
377  if (Opts.LongDoubleSize == DoubleWidth) {
381  } else if (Opts.LongDoubleSize == 128) {
383  LongDoubleFormat = &llvm::APFloat::IEEEquad();
384  }
385  }
386 
387  if (Opts.NewAlignOverride)
388  NewAlign = Opts.NewAlignOverride * getCharWidth();
389 
390  // Each unsigned fixed point type has the same number of fractional bits as
391  // its corresponding signed type.
392  PaddingOnUnsignedFixedPoint |= Opts.PaddingOnUnsignedFixedPoint;
393  CheckFixedPointBits();
394 }
395 
397  llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
398  const std::vector<std::string> &FeatureVec) const {
399  for (const auto &F : FeatureVec) {
400  StringRef Name = F;
401  // Apply the feature via the target.
402  bool Enabled = Name[0] == '+';
403  setFeatureEnabled(Features, Name.substr(1), Enabled);
404  }
405  return true;
406 }
407 
409 TargetInfo::getCallingConvKind(bool ClangABICompat4) const {
411  (ClangABICompat4 || getTriple().getOS() == llvm::Triple::PS4))
412  return CCK_ClangABI4OrPS4;
413  return CCK_Default;
414 }
415 
417  switch (TK) {
418  case OCLTK_Image:
419  case OCLTK_Pipe:
420  return LangAS::opencl_global;
421 
422  case OCLTK_Sampler:
424 
425  default:
426  return LangAS::Default;
427  }
428 }
429 
430 //===----------------------------------------------------------------------===//
431 
432 
433 static StringRef removeGCCRegisterPrefix(StringRef Name) {
434  if (Name[0] == '%' || Name[0] == '#')
435  Name = Name.substr(1);
436 
437  return Name;
438 }
439 
440 /// isValidClobber - Returns whether the passed in string is
441 /// a valid clobber in an inline asm statement. This is used by
442 /// Sema.
443 bool TargetInfo::isValidClobber(StringRef Name) const {
444  return (isValidGCCRegisterName(Name) ||
445  Name == "memory" || Name == "cc");
446 }
447 
448 /// isValidGCCRegisterName - Returns whether the passed in string
449 /// is a valid register name according to GCC. This is used by Sema for
450 /// inline asm statements.
451 bool TargetInfo::isValidGCCRegisterName(StringRef Name) const {
452  if (Name.empty())
453  return false;
454 
455  // Get rid of any register prefix.
456  Name = removeGCCRegisterPrefix(Name);
457  if (Name.empty())
458  return false;
459 
461 
462  // If we have a number it maps to an entry in the register name array.
463  if (isDigit(Name[0])) {
464  unsigned n;
465  if (!Name.getAsInteger(0, n))
466  return n < Names.size();
467  }
468 
469  // Check register names.
470  if (llvm::is_contained(Names, Name))
471  return true;
472 
473  // Check any additional names that we have.
474  for (const AddlRegName &ARN : getGCCAddlRegNames())
475  for (const char *AN : ARN.Names) {
476  if (!AN)
477  break;
478  // Make sure the register that the additional name is for is within
479  // the bounds of the register names from above.
480  if (AN == Name && ARN.RegNum < Names.size())
481  return true;
482  }
483 
484  // Now check aliases.
485  for (const GCCRegAlias &GRA : getGCCRegAliases())
486  for (const char *A : GRA.Aliases) {
487  if (!A)
488  break;
489  if (A == Name)
490  return true;
491  }
492 
493  return false;
494 }
495 
497  bool ReturnCanonical) const {
498  assert(isValidGCCRegisterName(Name) && "Invalid register passed in");
499 
500  // Get rid of any register prefix.
501  Name = removeGCCRegisterPrefix(Name);
502 
504 
505  // First, check if we have a number.
506  if (isDigit(Name[0])) {
507  unsigned n;
508  if (!Name.getAsInteger(0, n)) {
509  assert(n < Names.size() && "Out of bounds register number!");
510  return Names[n];
511  }
512  }
513 
514  // Check any additional names that we have.
515  for (const AddlRegName &ARN : getGCCAddlRegNames())
516  for (const char *AN : ARN.Names) {
517  if (!AN)
518  break;
519  // Make sure the register that the additional name is for is within
520  // the bounds of the register names from above.
521  if (AN == Name && ARN.RegNum < Names.size())
522  return ReturnCanonical ? Names[ARN.RegNum] : Name;
523  }
524 
525  // Now check aliases.
526  for (const GCCRegAlias &RA : getGCCRegAliases())
527  for (const char *A : RA.Aliases) {
528  if (!A)
529  break;
530  if (A == Name)
531  return RA.Register;
532  }
533 
534  return Name;
535 }
536 
538  const char *Name = Info.getConstraintStr().c_str();
539  // An output constraint must start with '=' or '+'
540  if (*Name != '=' && *Name != '+')
541  return false;
542 
543  if (*Name == '+')
544  Info.setIsReadWrite();
545 
546  Name++;
547  while (*Name) {
548  switch (*Name) {
549  default:
550  if (!validateAsmConstraint(Name, Info)) {
551  // FIXME: We temporarily return false
552  // so we can add more constraints as we hit it.
553  // Eventually, an unknown constraint should just be treated as 'g'.
554  return false;
555  }
556  break;
557  case '&': // early clobber.
558  Info.setEarlyClobber();
559  break;
560  case '%': // commutative.
561  // FIXME: Check that there is a another register after this one.
562  break;
563  case 'r': // general register.
564  Info.setAllowsRegister();
565  break;
566  case 'm': // memory operand.
567  case 'o': // offsetable memory operand.
568  case 'V': // non-offsetable memory operand.
569  case '<': // autodecrement memory operand.
570  case '>': // autoincrement memory operand.
571  Info.setAllowsMemory();
572  break;
573  case 'g': // general register, memory operand or immediate integer.
574  case 'X': // any operand.
575  Info.setAllowsRegister();
576  Info.setAllowsMemory();
577  break;
578  case ',': // multiple alternative constraint. Pass it.
579  // Handle additional optional '=' or '+' modifiers.
580  if (Name[1] == '=' || Name[1] == '+')
581  Name++;
582  break;
583  case '#': // Ignore as constraint.
584  while (Name[1] && Name[1] != ',')
585  Name++;
586  break;
587  case '?': // Disparage slightly code.
588  case '!': // Disparage severely.
589  case '*': // Ignore for choosing register preferences.
590  case 'i': // Ignore i,n,E,F as output constraints (match from the other
591  // chars)
592  case 'n':
593  case 'E':
594  case 'F':
595  break; // Pass them.
596  }
597 
598  Name++;
599  }
600 
601  // Early clobber with a read-write constraint which doesn't permit registers
602  // is invalid.
603  if (Info.earlyClobber() && Info.isReadWrite() && !Info.allowsRegister())
604  return false;
605 
606  // If a constraint allows neither memory nor register operands it contains
607  // only modifiers. Reject it.
608  return Info.allowsMemory() || Info.allowsRegister();
609 }
610 
611 bool TargetInfo::resolveSymbolicName(const char *&Name,
612  ArrayRef<ConstraintInfo> OutputConstraints,
613  unsigned &Index) const {
614  assert(*Name == '[' && "Symbolic name did not start with '['");
615  Name++;
616  const char *Start = Name;
617  while (*Name && *Name != ']')
618  Name++;
619 
620  if (!*Name) {
621  // Missing ']'
622  return false;
623  }
624 
625  std::string SymbolicName(Start, Name - Start);
626 
627  for (Index = 0; Index != OutputConstraints.size(); ++Index)
628  if (SymbolicName == OutputConstraints[Index].getName())
629  return true;
630 
631  return false;
632 }
633 
635  MutableArrayRef<ConstraintInfo> OutputConstraints,
636  ConstraintInfo &Info) const {
637  const char *Name = Info.ConstraintStr.c_str();
638 
639  if (!*Name)
640  return false;
641 
642  while (*Name) {
643  switch (*Name) {
644  default:
645  // Check if we have a matching constraint
646  if (*Name >= '0' && *Name <= '9') {
647  const char *DigitStart = Name;
648  while (Name[1] >= '0' && Name[1] <= '9')
649  Name++;
650  const char *DigitEnd = Name;
651  unsigned i;
652  if (StringRef(DigitStart, DigitEnd - DigitStart + 1)
653  .getAsInteger(10, i))
654  return false;
655 
656  // Check if matching constraint is out of bounds.
657  if (i >= OutputConstraints.size()) return false;
658 
659  // A number must refer to an output only operand.
660  if (OutputConstraints[i].isReadWrite())
661  return false;
662 
663  // If the constraint is already tied, it must be tied to the
664  // same operand referenced to by the number.
665  if (Info.hasTiedOperand() && Info.getTiedOperand() != i)
666  return false;
667 
668  // The constraint should have the same info as the respective
669  // output constraint.
670  Info.setTiedOperand(i, OutputConstraints[i]);
671  } else if (!validateAsmConstraint(Name, Info)) {
672  // FIXME: This error return is in place temporarily so we can
673  // add more constraints as we hit it. Eventually, an unknown
674  // constraint should just be treated as 'g'.
675  return false;
676  }
677  break;
678  case '[': {
679  unsigned Index = 0;
680  if (!resolveSymbolicName(Name, OutputConstraints, Index))
681  return false;
682 
683  // If the constraint is already tied, it must be tied to the
684  // same operand referenced to by the number.
685  if (Info.hasTiedOperand() && Info.getTiedOperand() != Index)
686  return false;
687 
688  // A number must refer to an output only operand.
689  if (OutputConstraints[Index].isReadWrite())
690  return false;
691 
692  Info.setTiedOperand(Index, OutputConstraints[Index]);
693  break;
694  }
695  case '%': // commutative
696  // FIXME: Fail if % is used with the last operand.
697  break;
698  case 'i': // immediate integer.
699  break;
700  case 'n': // immediate integer with a known value.
701  Info.setRequiresImmediate();
702  break;
703  case 'I': // Various constant constraints with target-specific meanings.
704  case 'J':
705  case 'K':
706  case 'L':
707  case 'M':
708  case 'N':
709  case 'O':
710  case 'P':
711  if (!validateAsmConstraint(Name, Info))
712  return false;
713  break;
714  case 'r': // general register.
715  Info.setAllowsRegister();
716  break;
717  case 'm': // memory operand.
718  case 'o': // offsettable memory operand.
719  case 'V': // non-offsettable memory operand.
720  case '<': // autodecrement memory operand.
721  case '>': // autoincrement memory operand.
722  Info.setAllowsMemory();
723  break;
724  case 'g': // general register, memory operand or immediate integer.
725  case 'X': // any operand.
726  Info.setAllowsRegister();
727  Info.setAllowsMemory();
728  break;
729  case 'E': // immediate floating point.
730  case 'F': // immediate floating point.
731  case 'p': // address operand.
732  break;
733  case ',': // multiple alternative constraint. Ignore comma.
734  break;
735  case '#': // Ignore as constraint.
736  while (Name[1] && Name[1] != ',')
737  Name++;
738  break;
739  case '?': // Disparage slightly code.
740  case '!': // Disparage severely.
741  case '*': // Ignore for choosing register preferences.
742  break; // Pass them.
743  }
744 
745  Name++;
746  }
747 
748  return true;
749 }
750 
751 void TargetInfo::CheckFixedPointBits() const {
752  // Check that the number of fractional and integral bits (and maybe sign) can
753  // fit into the bits given for a fixed point type.
755  assert(AccumScale + getAccumIBits() + 1 <= AccumWidth);
762 
763  assert(getShortFractScale() + 1 <= ShortFractWidth);
764  assert(getFractScale() + 1 <= FractWidth);
765  assert(getLongFractScale() + 1 <= LongFractWidth);
767  assert(getUnsignedFractScale() <= FractWidth);
769 
770  // Each unsigned fract type has either the same number of fractional bits
771  // as, or one more fractional bit than, its corresponding signed fract type.
774  assert(getFractScale() == getUnsignedFractScale() ||
778 
779  // When arranged in order of increasing rank (see 6.3.1.3a), the number of
780  // fractional bits is nondecreasing for each of the following sets of
781  // fixed-point types:
782  // - signed fract types
783  // - unsigned fract types
784  // - signed accum types
785  // - unsigned accum types.
786  assert(getLongFractScale() >= getFractScale() &&
793 
794  // When arranged in order of increasing rank (see 6.3.1.3a), the number of
795  // integral bits is nondecreasing for each of the following sets of
796  // fixed-point types:
797  // - signed accum types
798  // - unsigned accum types
799  assert(getLongAccumIBits() >= getAccumIBits() &&
803 
804  // Each signed accum type has at least as many integral bits as its
805  // corresponding unsigned accum type.
807  assert(getAccumIBits() >= getUnsignedAccumIBits());
809 }
810 
812  auto *Target = static_cast<TransferrableTargetInfo*>(this);
813  auto *Src = static_cast<const TransferrableTargetInfo*>(Aux);
814  *Target = *Src;
815 }
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:577
unsigned getLongAccumIBits() const
Definition: TargetInfo.h:451
unsigned char LargeArrayMinWidth
Definition: TargetInfo.h:62
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:398
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:985
unsigned getLongAlign() const
Definition: TargetInfo.h:399
virtual IntType getLeastIntTypeByWidth(unsigned BitWidth, bool IsSigned) const
Return the smallest integer type with at least the specified width.
Definition: TargetInfo.cpp:244
virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const
Get address space for OpenCL type.
Definition: TargetInfo.cpp:416
bool validateInputConstraint(MutableArrayRef< ConstraintInfo > OutputConstraints, ConstraintInfo &info) const
Definition: TargetInfo.cpp:634
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1297
unsigned getAccumIBits() const
Definition: TargetInfo.h:446
TargetInfo(const llvm::Triple &T)
Definition: TargetInfo.cpp:28
unsigned getCharWidth() const
Definition: TargetInfo.h:380
unsigned short SimdDefaultAlign
Definition: TargetInfo.h:178
unsigned getShortAccumIBits() const
Definition: TargetInfo.h:439
void setRequiresImmediate(int Min, int Max)
Definition: TargetInfo.h:890
static const LangASMap DefaultAddrSpaceMap
Definition: TargetInfo.cpp:25
unsigned getCharAlign() const
Definition: TargetInfo.h:381
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:1089
long i
Definition: xmmintrin.h:1456
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Definition: TargetInfo.h:1054
unsigned getIntAlign() const
Definition: TargetInfo.h:394
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:496
const char * MCountName
Definition: TargetInfo.h:180
unsigned getUnsignedLongAccumIBits() const
Definition: TargetInfo.h:481
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:302
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:385
Defines the Diagnostic-related interfaces.
VersionTuple PlatformMinVersion
Definition: TargetInfo.h:186
unsigned ComplexLongDoubleUsesFP2Ret
Definition: TargetInfo.h:190
unsigned getLongLongAlign() const
Definition: TargetInfo.h:404
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:451
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:139
StringRef PlatformName
Definition: TargetInfo.h:185
virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const
Definition: TargetInfo.cpp:409
bool isValidClobber(StringRef Name) const
Returns whether the passed in string is a valid clobber in an inline asm statement.
Definition: TargetInfo.cpp:443
unsigned char DefaultAlignForAttributeAligned
Definition: TargetInfo.h:93
const llvm::fltSemantics & getLongDoubleFormat() const
Definition: TargetInfo.h:590
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:396
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:393
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:433
unsigned getShortAlign() const
Return the alignment of &#39;signed short&#39; and &#39;unsigned short&#39; for this target.
Definition: TargetInfo.h:389
unsigned getDoubleWidth() const
getDoubleWidth/Align/Format - Return the size/align/format of &#39;double&#39;.
Definition: TargetInfo.h:582
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
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:403
unsigned getUnsignedAccumScale() const
getUnsignedAccumScale/IBits - Return the number of fractional/integral bits in a &#39;unsigned _Accum&#39; ty...
Definition: TargetInfo.h:468
bool validateOutputConstraint(ConstraintInfo &Info) const
Definition: TargetInfo.cpp:537
virtual ArrayRef< AddlRegName > getGCCAddlRegNames() const
Definition: TargetInfo.h:1381
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:33
virtual ArrayRef< GCCRegAlias > getGCCRegAliases() const =0
unsigned getUnsignedAccumIBits() const
Definition: TargetInfo.h:471
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:478
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:259
unsigned getUnsignedShortAccumIBits() const
Definition: TargetInfo.h:460
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:195
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:497
unsigned getUnsignedFractScale() const
getUnsignedFractScale - Return the number of fractional bits in a &#39;unsigned _Fract&#39; type...
Definition: TargetInfo.h:508
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand...
Definition: TargetInfo.h:868
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:852
unsigned getUnsignedShortAccumScale() const
getUnsignedShortAccumScale/IBits - Return the number of fractional/integral bits in a &#39;unsigned short...
Definition: TargetInfo.h:457
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:93
bool resolveSymbolicName(const char *&Name, ArrayRef< ConstraintInfo > OutputConstraints, unsigned &Index) const
Definition: TargetInfo.cpp:611
virtual uint64_t getMaxPointerWidth() const
Return the maximum width of pointers on this target.
Definition: TargetInfo.h:366
unsigned getShortFractScale() const
getShortFractScale - Return the number of fractional bits in a &#39;signed short _Fract&#39; type...
Definition: TargetInfo.h:489
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
Definition: TargetInfo.h:528
void copyAuxTarget(const TargetInfo *Aux)
Copy type and layout related info.
Definition: TargetInfo.cpp:811
unsigned getUnsignedLongFractScale() const
getUnsignedLongFractScale - Return the number of fractional bits in a &#39;unsigned long _Fract&#39; type...
Definition: TargetInfo.h:514
unsigned getFractScale() const
getFractScale - Return the number of fractional bits in a &#39;signed _Fract&#39; type.
Definition: TargetInfo.h:493
unsigned getUnsignedShortFractScale() const
getUnsignedShortFractScale - Return the number of fractional bits in a &#39;unsigned short _Fract&#39; type...
Definition: TargetInfo.h:501
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:913
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:265
unsigned short MaxVectorAlign
Definition: TargetInfo.h:97