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