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