clang  7.0.0svn
TargetInfo.h
Go to the documentation of this file.
1 //===--- TargetInfo.h - Expose information about the target -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// Defines the clang::TargetInfo interface.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_BASIC_TARGETINFO_H
16 #define LLVM_CLANG_BASIC_TARGETINFO_H
17 
19 #include "clang/Basic/LLVM.h"
20 #include "clang/Basic/Specifiers.h"
23 #include "llvm/ADT/APInt.h"
24 #include "llvm/ADT/IntrusiveRefCntPtr.h"
25 #include "llvm/ADT/Optional.h"
26 #include "llvm/ADT/SmallSet.h"
27 #include "llvm/ADT/StringMap.h"
28 #include "llvm/ADT/StringRef.h"
29 #include "llvm/ADT/Triple.h"
30 #include "llvm/IR/DataLayout.h"
31 #include "llvm/Support/DataTypes.h"
32 #include "llvm/Support/VersionTuple.h"
33 #include <cassert>
34 #include <string>
35 #include <vector>
36 
37 namespace llvm {
38 struct fltSemantics;
39 }
40 
41 namespace clang {
42 class DiagnosticsEngine;
43 class LangOptions;
44 class CodeGenOptions;
45 class MacroBuilder;
46 class QualType;
47 class SourceLocation;
48 class SourceManager;
49 
50 namespace Builtin { struct Info; }
51 
52 /// Exposes information about the current target.
53 ///
54 class TargetInfo : public RefCountedBase<TargetInfo> {
55  std::shared_ptr<TargetOptions> TargetOpts;
56  llvm::Triple Triple;
57 protected:
58  // Target values set by the ctor of the actual target implementation. Default
59  // values are specified by the TargetInfo constructor.
60  bool BigEndian;
63  bool NoAsmVariants; // True if {|} are normal characters.
64  bool HasLegalHalfType; // True if the backend supports operations on the half
65  // LLVM IR type.
67  unsigned char PointerWidth, PointerAlign;
68  unsigned char BoolWidth, BoolAlign;
69  unsigned char IntWidth, IntAlign;
70  unsigned char HalfWidth, HalfAlign;
71  unsigned char FloatWidth, FloatAlign;
72  unsigned char DoubleWidth, DoubleAlign;
73  unsigned char LongDoubleWidth, LongDoubleAlign, Float128Align;
74  unsigned char LargeArrayMinWidth, LargeArrayAlign;
75  unsigned char LongWidth, LongAlign;
76  unsigned char LongLongWidth, LongLongAlign;
77  unsigned char ShortAccumWidth, ShortAccumAlign;
78  unsigned char AccumWidth, AccumAlign;
79  unsigned char LongAccumWidth, LongAccumAlign;
80  unsigned char ShortFractWidth, ShortFractAlign;
81  unsigned char FractWidth, FractAlign;
82  unsigned char LongFractWidth, LongFractAlign;
83  unsigned char SuitableAlign;
85  unsigned char MinGlobalAlign;
86  unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
87  unsigned short MaxVectorAlign;
88  unsigned short MaxTLSAlign;
89  unsigned short SimdDefaultAlign;
90  unsigned short NewAlign;
91  std::unique_ptr<llvm::DataLayout> DataLayout;
92  const char *MCountName;
93  const llvm::fltSemantics *HalfFormat, *FloatFormat, *DoubleFormat,
94  *LongDoubleFormat, *Float128Format;
95  unsigned char RegParmMax, SSERegParmMax;
98 
99  mutable StringRef PlatformName;
100  mutable VersionTuple PlatformMinVersion;
101 
102  unsigned HasAlignMac68kSupport : 1;
103  unsigned RealTypeUsesObjCFPRet : 3;
105 
106  unsigned HasBuiltinMSVaList : 1;
107 
108  unsigned IsRenderScriptTarget : 1;
109 
110  // TargetInfo Constructor. Default initializes all fields.
111  TargetInfo(const llvm::Triple &T);
112 
113  void resetDataLayout(StringRef DL) {
114  DataLayout.reset(new llvm::DataLayout(DL));
115  }
116 
117 public:
118  /// Construct a target for the given options.
119  ///
120  /// \param Opts - The options to use to initialize the target. The target may
121  /// modify the options to canonicalize the target feature information to match
122  /// what the backend expects.
123  static TargetInfo *
124  CreateTargetInfo(DiagnosticsEngine &Diags,
125  const std::shared_ptr<TargetOptions> &Opts);
126 
127  virtual ~TargetInfo();
128 
129  /// Retrieve the target options.
131  assert(TargetOpts && "Missing target options");
132  return *TargetOpts;
133  }
134 
135  ///===---- Target Data Type Query Methods -------------------------------===//
136  enum IntType {
137  NoInt = 0,
147  UnsignedLongLong
148  };
149 
150  enum RealType {
151  NoFloat = 255,
152  Float = 0,
155  Float128
156  };
157 
158  /// The different kinds of __builtin_va_list types defined by
159  /// the target implementation.
161  /// typedef char* __builtin_va_list;
162  CharPtrBuiltinVaList = 0,
163 
164  /// typedef void* __builtin_va_list;
166 
167  /// __builtin_va_list as defined by the AArch64 ABI
168  /// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf
170 
171  /// __builtin_va_list as defined by the PNaCl ABI:
172  /// http://www.chromium.org/nativeclient/pnacl/bitcode-abi#TOC-Machine-Types
174 
175  /// __builtin_va_list as defined by the Power ABI:
176  /// https://www.power.org
177  /// /resources/downloads/Power-Arch-32-bit-ABI-supp-1.0-Embedded.pdf
179 
180  /// __builtin_va_list as defined by the x86-64 ABI:
181  /// http://refspecs.linuxbase.org/elf/x86_64-abi-0.21.pdf
183 
184  /// __builtin_va_list as defined by ARM AAPCS ABI
185  /// http://infocenter.arm.com
186  // /help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf
188 
189  // typedef struct __va_list_tag
190  // {
191  // long __gpr;
192  // long __fpr;
193  // void *__overflow_arg_area;
194  // void *__reg_save_area;
195  // } va_list[1];
196  SystemZBuiltinVaList
197  };
198 
199 protected:
200  IntType SizeType, IntMaxType, PtrDiffType, IntPtrType, WCharType,
201  WIntType, Char16Type, Char32Type, Int64Type, SigAtomicType,
202  ProcessIDType;
203 
204  /// Whether Objective-C's built-in boolean type should be signed char.
205  ///
206  /// Otherwise, when this flag is not set, the normal built-in boolean type is
207  /// used.
209 
210  /// Control whether the alignment of bit-field types is respected when laying
211  /// out structures. If true, then the alignment of the bit-field type will be
212  /// used to (a) impact the alignment of the containing structure, and (b)
213  /// ensure that the individual bit-field will not straddle an alignment
214  /// boundary.
216 
217  /// Whether zero length bitfields (e.g., int : 0;) force alignment of
218  /// the next bitfield.
219  ///
220  /// If the alignment of the zero length bitfield is greater than the member
221  /// that follows it, `bar', `bar' will be aligned as the type of the
222  /// zero-length bitfield.
224 
225  /// Whether explicit bit field alignment attributes are honored.
227 
228  /// If non-zero, specifies a fixed alignment value for bitfields that follow
229  /// zero length bitfield, regardless of the zero length bitfield type.
231 
232  /// Specify if mangling based on address space map should be used or
233  /// not for language specific address spaces
235 
236 public:
237  IntType getSizeType() const { return SizeType; }
239  switch (SizeType) {
240  case UnsignedShort:
241  return SignedShort;
242  case UnsignedInt:
243  return SignedInt;
244  case UnsignedLong:
245  return SignedLong;
246  case UnsignedLongLong:
247  return SignedLongLong;
248  default:
249  llvm_unreachable("Invalid SizeType");
250  }
251  }
252  IntType getIntMaxType() const { return IntMaxType; }
254  return getCorrespondingUnsignedType(IntMaxType);
255  }
256  IntType getPtrDiffType(unsigned AddrSpace) const {
257  return AddrSpace == 0 ? PtrDiffType : getPtrDiffTypeV(AddrSpace);
258  }
259  IntType getUnsignedPtrDiffType(unsigned AddrSpace) const {
260  return getCorrespondingUnsignedType(getPtrDiffType(AddrSpace));
261  }
262  IntType getIntPtrType() const { return IntPtrType; }
264  return getCorrespondingUnsignedType(IntPtrType);
265  }
266  IntType getWCharType() const { return WCharType; }
267  IntType getWIntType() const { return WIntType; }
268  IntType getChar16Type() const { return Char16Type; }
269  IntType getChar32Type() const { return Char32Type; }
270  IntType getInt64Type() const { return Int64Type; }
272  return getCorrespondingUnsignedType(Int64Type);
273  }
274  IntType getSigAtomicType() const { return SigAtomicType; }
275  IntType getProcessIDType() const { return ProcessIDType; }
276 
278  switch (T) {
279  case SignedChar:
280  return UnsignedChar;
281  case SignedShort:
282  return UnsignedShort;
283  case SignedInt:
284  return UnsignedInt;
285  case SignedLong:
286  return UnsignedLong;
287  case SignedLongLong:
288  return UnsignedLongLong;
289  default:
290  llvm_unreachable("Unexpected signed integer type");
291  }
292  }
293 
294  /// Return the width (in bits) of the specified integer type enum.
295  ///
296  /// For example, SignedInt -> getIntWidth().
297  unsigned getTypeWidth(IntType T) const;
298 
299  /// Return integer type with specified width.
300  virtual IntType getIntTypeByWidth(unsigned BitWidth, bool IsSigned) const;
301 
302  /// Return the smallest integer type with at least the specified width.
303  virtual IntType getLeastIntTypeByWidth(unsigned BitWidth,
304  bool IsSigned) const;
305 
306  /// Return floating point type with specified width.
307  RealType getRealTypeByWidth(unsigned BitWidth) const;
308 
309  /// Return the alignment (in bits) of the specified integer type enum.
310  ///
311  /// For example, SignedInt -> getIntAlign().
312  unsigned getTypeAlign(IntType T) const;
313 
314  /// Returns true if the type is signed; false otherwise.
315  static bool isTypeSigned(IntType T);
316 
317  /// Return the width of pointers on this target, for the
318  /// specified address space.
319  uint64_t getPointerWidth(unsigned AddrSpace) const {
320  return AddrSpace == 0 ? PointerWidth : getPointerWidthV(AddrSpace);
321  }
322  uint64_t getPointerAlign(unsigned AddrSpace) const {
323  return AddrSpace == 0 ? PointerAlign : getPointerAlignV(AddrSpace);
324  }
325 
326  /// Return the maximum width of pointers on this target.
327  virtual uint64_t getMaxPointerWidth() const {
328  return PointerWidth;
329  }
330 
331  /// Get integer value for null pointer.
332  /// \param AddrSpace address space of pointee in source language.
333  virtual uint64_t getNullPointerValue(LangAS AddrSpace) const { return 0; }
334 
335  /// Return the size of '_Bool' and C++ 'bool' for this target, in bits.
336  unsigned getBoolWidth() const { return BoolWidth; }
337 
338  /// Return the alignment of '_Bool' and C++ 'bool' for this target.
339  unsigned getBoolAlign() const { return BoolAlign; }
340 
341  unsigned getCharWidth() const { return 8; } // FIXME
342  unsigned getCharAlign() const { return 8; } // FIXME
343 
344  /// Return the size of 'signed short' and 'unsigned short' for this
345  /// target, in bits.
346  unsigned getShortWidth() const { return 16; } // FIXME
347 
348  /// Return the alignment of 'signed short' and 'unsigned short' for
349  /// this target.
350  unsigned getShortAlign() const { return 16; } // FIXME
351 
352  /// getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for
353  /// this target, in bits.
354  unsigned getIntWidth() const { return IntWidth; }
355  unsigned getIntAlign() const { return IntAlign; }
356 
357  /// getLongWidth/Align - Return the size of 'signed long' and 'unsigned long'
358  /// for this target, in bits.
359  unsigned getLongWidth() const { return LongWidth; }
360  unsigned getLongAlign() const { return LongAlign; }
361 
362  /// getLongLongWidth/Align - Return the size of 'signed long long' and
363  /// 'unsigned long long' for this target, in bits.
364  unsigned getLongLongWidth() const { return LongLongWidth; }
365  unsigned getLongLongAlign() const { return LongLongAlign; }
366 
367  /// getShortAccumWidth/Align - Return the size of 'signed short _Accum' and
368  /// 'unsigned short _Accum' for this target, in bits.
369  unsigned getShortAccumWidth() const { return ShortAccumWidth; }
370  unsigned getShortAccumAlign() const { return ShortAccumAlign; }
371 
372  /// getAccumWidth/Align - Return the size of 'signed _Accum' and
373  /// 'unsigned _Accum' for this target, in bits.
374  unsigned getAccumWidth() const { return AccumWidth; }
375  unsigned getAccumAlign() const { return AccumAlign; }
376 
377  /// getLongAccumWidth/Align - Return the size of 'signed long _Accum' and
378  /// 'unsigned long _Accum' for this target, in bits.
379  unsigned getLongAccumWidth() const { return LongAccumWidth; }
380  unsigned getLongAccumAlign() const { return LongAccumAlign; }
381 
382  /// getShortFractWidth/Align - Return the size of 'signed short _Fract' and
383  /// 'unsigned short _Fract' for this target, in bits.
384  unsigned getShortFractWidth() const { return ShortFractWidth; }
385  unsigned getShortFractAlign() const { return ShortFractAlign; }
386 
387  /// getFractWidth/Align - Return the size of 'signed _Fract' and
388  /// 'unsigned _Fract' for this target, in bits.
389  unsigned getFractWidth() const { return FractWidth; }
390  unsigned getFractAlign() const { return FractAlign; }
391 
392  /// getLongFractWidth/Align - Return the size of 'signed long _Fract' and
393  /// 'unsigned long _Fract' for this target, in bits.
394  unsigned getLongFractWidth() const { return LongFractWidth; }
395  unsigned getLongFractAlign() const { return LongFractAlign; }
396 
397  /// Determine whether the __int128 type is supported on this target.
398  virtual bool hasInt128Type() const {
399  return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128;
400  } // FIXME
401 
402  /// Determine whether _Float16 is supported on this target.
403  virtual bool hasLegalHalfType() const { return HasLegalHalfType; }
404 
405  /// Determine whether the __float128 type is supported on this target.
406  virtual bool hasFloat128Type() const { return HasFloat128; }
407 
408  /// Return the alignment that is suitable for storing any
409  /// object with a fundamental alignment requirement.
410  unsigned getSuitableAlign() const { return SuitableAlign; }
411 
412  /// Return the default alignment for __attribute__((aligned)) on
413  /// this target, to be used if no alignment value is specified.
415  return DefaultAlignForAttributeAligned;
416  }
417 
418  /// getMinGlobalAlign - Return the minimum alignment of a global variable,
419  /// unless its alignment is explicitly reduced via attributes.
420  unsigned getMinGlobalAlign() const { return MinGlobalAlign; }
421 
422  /// Return the largest alignment for which a suitably-sized allocation with
423  /// '::operator new(size_t)' is guaranteed to produce a correctly-aligned
424  /// pointer.
425  unsigned getNewAlign() const {
426  return NewAlign ? NewAlign : std::max(LongDoubleAlign, LongLongAlign);
427  }
428 
429  /// getWCharWidth/Align - Return the size of 'wchar_t' for this target, in
430  /// bits.
431  unsigned getWCharWidth() const { return getTypeWidth(WCharType); }
432  unsigned getWCharAlign() const { return getTypeAlign(WCharType); }
433 
434  /// getChar16Width/Align - Return the size of 'char16_t' for this target, in
435  /// bits.
436  unsigned getChar16Width() const { return getTypeWidth(Char16Type); }
437  unsigned getChar16Align() const { return getTypeAlign(Char16Type); }
438 
439  /// getChar32Width/Align - Return the size of 'char32_t' for this target, in
440  /// bits.
441  unsigned getChar32Width() const { return getTypeWidth(Char32Type); }
442  unsigned getChar32Align() const { return getTypeAlign(Char32Type); }
443 
444  /// getHalfWidth/Align/Format - Return the size/align/format of 'half'.
445  unsigned getHalfWidth() const { return HalfWidth; }
446  unsigned getHalfAlign() const { return HalfAlign; }
447  const llvm::fltSemantics &getHalfFormat() const { return *HalfFormat; }
448 
449  /// getFloatWidth/Align/Format - Return the size/align/format of 'float'.
450  unsigned getFloatWidth() const { return FloatWidth; }
451  unsigned getFloatAlign() const { return FloatAlign; }
452  const llvm::fltSemantics &getFloatFormat() const { return *FloatFormat; }
453 
454  /// getDoubleWidth/Align/Format - Return the size/align/format of 'double'.
455  unsigned getDoubleWidth() const { return DoubleWidth; }
456  unsigned getDoubleAlign() const { return DoubleAlign; }
457  const llvm::fltSemantics &getDoubleFormat() const { return *DoubleFormat; }
458 
459  /// getLongDoubleWidth/Align/Format - Return the size/align/format of 'long
460  /// double'.
461  unsigned getLongDoubleWidth() const { return LongDoubleWidth; }
462  unsigned getLongDoubleAlign() const { return LongDoubleAlign; }
463  const llvm::fltSemantics &getLongDoubleFormat() const {
464  return *LongDoubleFormat;
465  }
466 
467  /// getFloat128Width/Align/Format - Return the size/align/format of
468  /// '__float128'.
469  unsigned getFloat128Width() const { return 128; }
470  unsigned getFloat128Align() const { return Float128Align; }
471  const llvm::fltSemantics &getFloat128Format() const {
472  return *Float128Format;
473  }
474 
475  /// Return true if the 'long double' type should be mangled like
476  /// __float128.
477  virtual bool useFloat128ManglingForLongDouble() const { return false; }
478 
479  /// Return the value for the C99 FLT_EVAL_METHOD macro.
480  virtual unsigned getFloatEvalMethod() const { return 0; }
481 
482  // getLargeArrayMinWidth/Align - Return the minimum array size that is
483  // 'large' and its alignment.
484  unsigned getLargeArrayMinWidth() const { return LargeArrayMinWidth; }
485  unsigned getLargeArrayAlign() const { return LargeArrayAlign; }
486 
487  /// Return the maximum width lock-free atomic operation which will
488  /// ever be supported for the given target
489  unsigned getMaxAtomicPromoteWidth() const { return MaxAtomicPromoteWidth; }
490  /// Return the maximum width lock-free atomic operation which can be
491  /// inlined given the supported features of the given target.
492  unsigned getMaxAtomicInlineWidth() const { return MaxAtomicInlineWidth; }
493  /// Set the maximum inline or promote width lock-free atomic operation
494  /// for the given target.
495  virtual void setMaxAtomicWidth() {}
496  /// Returns true if the given target supports lock-free atomic
497  /// operations at the specified width and alignment.
498  virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits,
499  uint64_t AlignmentInBits) const {
500  return AtomicSizeInBits <= AlignmentInBits &&
501  AtomicSizeInBits <= getMaxAtomicInlineWidth() &&
502  (AtomicSizeInBits <= getCharWidth() ||
503  llvm::isPowerOf2_64(AtomicSizeInBits / getCharWidth()));
504  }
505 
506  /// Return the maximum vector alignment supported for the given target.
507  unsigned getMaxVectorAlign() const { return MaxVectorAlign; }
508  /// Return default simd alignment for the given target. Generally, this
509  /// value is type-specific, but this alignment can be used for most of the
510  /// types for the given target.
511  unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; }
512 
513  /// Return the size of intmax_t and uintmax_t for this target, in bits.
514  unsigned getIntMaxTWidth() const {
515  return getTypeWidth(IntMaxType);
516  }
517 
518  // Return the size of unwind_word for this target.
519  virtual unsigned getUnwindWordWidth() const { return getPointerWidth(0); }
520 
521  /// Return the "preferred" register width on this target.
522  virtual unsigned getRegisterWidth() const {
523  // Currently we assume the register width on the target matches the pointer
524  // width, we can introduce a new variable for this if/when some target wants
525  // it.
526  return PointerWidth;
527  }
528 
529  /// Returns the name of the mcount instrumentation function.
530  const char *getMCountName() const {
531  return MCountName;
532  }
533 
534  /// Check if the Objective-C built-in boolean type should be signed
535  /// char.
536  ///
537  /// Otherwise, if this returns false, the normal built-in boolean type
538  /// should also be used for Objective-C.
540  return UseSignedCharForObjCBool;
541  }
543  UseSignedCharForObjCBool = false;
544  }
545 
546  /// Check whether the alignment of bit-field types is respected
547  /// when laying out structures.
549  return UseBitFieldTypeAlignment;
550  }
551 
552  /// Check whether zero length bitfields should force alignment of
553  /// the next member.
555  return UseZeroLengthBitfieldAlignment;
556  }
557 
558  /// Get the fixed alignment value in bits for a member that follows
559  /// a zero length bitfield.
560  unsigned getZeroLengthBitfieldBoundary() const {
561  return ZeroLengthBitfieldBoundary;
562  }
563 
564  /// Check whether explicit bitfield alignment attributes should be
565  // honored, as in "__attribute__((aligned(2))) int b : 1;".
567  return UseExplicitBitFieldAlignment;
568  }
569 
570  /// Check whether this target support '\#pragma options align=mac68k'.
571  bool hasAlignMac68kSupport() const {
572  return HasAlignMac68kSupport;
573  }
574 
575  /// Return the user string for the specified integer type enum.
576  ///
577  /// For example, SignedShort -> "short".
578  static const char *getTypeName(IntType T);
579 
580  /// Return the constant suffix for the specified integer type enum.
581  ///
582  /// For example, SignedLong -> "L".
583  const char *getTypeConstantSuffix(IntType T) const;
584 
585  /// Return the printf format modifier for the specified
586  /// integer type enum.
587  ///
588  /// For example, SignedLong -> "l".
589  static const char *getTypeFormatModifier(IntType T);
590 
591  /// Check whether the given real type should use the "fpret" flavor of
592  /// Objective-C message passing on this target.
594  return RealTypeUsesObjCFPRet & (1 << T);
595  }
596 
597  /// Check whether _Complex long double should use the "fp2ret" flavor
598  /// of Objective-C message passing on this target.
600  return ComplexLongDoubleUsesFP2Ret;
601  }
602 
603  /// Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used
604  /// to convert to and from __fp16.
605  /// FIXME: This function should be removed once all targets stop using the
606  /// conversion intrinsics.
607  virtual bool useFP16ConversionIntrinsics() const {
608  return true;
609  }
610 
611  /// Specify if mangling based on address space map should be used or
612  /// not for language specific address spaces
614  return UseAddrSpaceMapMangling;
615  }
616 
617  ///===---- Other target property query methods --------------------------===//
618 
619  /// Appends the target-specific \#define values for this
620  /// target set to the specified buffer.
621  virtual void getTargetDefines(const LangOptions &Opts,
622  MacroBuilder &Builder) const = 0;
623 
624 
625  /// Return information about target-specific builtins for
626  /// the current primary target, and info about which builtins are non-portable
627  /// across the current set of primary and secondary targets.
628  virtual ArrayRef<Builtin::Info> getTargetBuiltins() const = 0;
629 
630  /// The __builtin_clz* and __builtin_ctz* built-in
631  /// functions are specified to have undefined results for zero inputs, but
632  /// on targets that support these operations in a way that provides
633  /// well-defined results for zero without loss of performance, it is a good
634  /// idea to avoid optimizing based on that undef behavior.
635  virtual bool isCLZForZeroUndef() const { return true; }
636 
637  /// Returns the kind of __builtin_va_list type that should be used
638  /// with this target.
639  virtual BuiltinVaListKind getBuiltinVaListKind() const = 0;
640 
641  /// Returns whether or not type \c __builtin_ms_va_list type is
642  /// available on this target.
643  bool hasBuiltinMSVaList() const { return HasBuiltinMSVaList; }
644 
645  /// Returns true for RenderScript.
646  bool isRenderScriptTarget() const { return IsRenderScriptTarget; }
647 
648  /// Returns whether the passed in string is a valid clobber in an
649  /// inline asm statement.
650  ///
651  /// This is used by Sema.
652  bool isValidClobber(StringRef Name) const;
653 
654  /// Returns whether the passed in string is a valid register name
655  /// according to GCC.
656  ///
657  /// This is used by Sema for inline asm statements.
658  virtual bool isValidGCCRegisterName(StringRef Name) const;
659 
660  /// Returns the "normalized" GCC register name.
661  ///
662  /// ReturnCannonical true will return the register name without any additions
663  /// such as "{}" or "%" in it's canonical form, for example:
664  /// ReturnCanonical = true and Name = "rax", will return "ax".
665  StringRef getNormalizedGCCRegisterName(StringRef Name,
666  bool ReturnCanonical = false) const;
667 
668  /// Extracts a register from the passed constraint (if it is a
669  /// single-register constraint) and the asm label expression related to a
670  /// variable in the input or output list of an inline asm statement.
671  ///
672  /// This function is used by Sema in order to diagnose conflicts between
673  /// the clobber list and the input/output lists.
674  virtual StringRef getConstraintRegister(StringRef Constraint,
675  StringRef Expression) const {
676  return "";
677  }
678 
679  struct ConstraintInfo {
680  enum {
681  CI_None = 0x00,
682  CI_AllowsMemory = 0x01,
683  CI_AllowsRegister = 0x02,
684  CI_ReadWrite = 0x04, // "+r" output constraint (read and write).
685  CI_HasMatchingInput = 0x08, // This output operand has a matching input.
686  CI_ImmediateConstant = 0x10, // This operand must be an immediate constant
687  CI_EarlyClobber = 0x20, // "&" output constraint (early clobber).
688  };
689  unsigned Flags;
691  struct {
692  int Min;
693  int Max;
694  } ImmRange;
695  llvm::SmallSet<int, 4> ImmSet;
696 
697  std::string ConstraintStr; // constraint: "=rm"
698  std::string Name; // Operand name: [foo] with no []'s.
699  public:
700  ConstraintInfo(StringRef ConstraintStr, StringRef Name)
701  : Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
702  Name(Name.str()) {
703  ImmRange.Min = ImmRange.Max = 0;
704  }
705 
706  const std::string &getConstraintStr() const { return ConstraintStr; }
707  const std::string &getName() const { return Name; }
708  bool isReadWrite() const { return (Flags & CI_ReadWrite) != 0; }
709  bool earlyClobber() { return (Flags & CI_EarlyClobber) != 0; }
710  bool allowsRegister() const { return (Flags & CI_AllowsRegister) != 0; }
711  bool allowsMemory() const { return (Flags & CI_AllowsMemory) != 0; }
712 
713  /// Return true if this output operand has a matching
714  /// (tied) input operand.
715  bool hasMatchingInput() const { return (Flags & CI_HasMatchingInput) != 0; }
716 
717  /// Return true if this input operand is a matching
718  /// constraint that ties it to an output operand.
719  ///
720  /// If this returns true then getTiedOperand will indicate which output
721  /// operand this is tied to.
722  bool hasTiedOperand() const { return TiedOperand != -1; }
723  unsigned getTiedOperand() const {
724  assert(hasTiedOperand() && "Has no tied operand!");
725  return (unsigned)TiedOperand;
726  }
727 
729  return (Flags & CI_ImmediateConstant) != 0;
730  }
731  bool isValidAsmImmediate(const llvm::APInt &Value) const {
732  return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) ||
733  ImmSet.count(Value.getZExtValue()) != 0;
734  }
735 
736  void setIsReadWrite() { Flags |= CI_ReadWrite; }
737  void setEarlyClobber() { Flags |= CI_EarlyClobber; }
738  void setAllowsMemory() { Flags |= CI_AllowsMemory; }
739  void setAllowsRegister() { Flags |= CI_AllowsRegister; }
740  void setHasMatchingInput() { Flags |= CI_HasMatchingInput; }
741  void setRequiresImmediate(int Min, int Max) {
742  Flags |= CI_ImmediateConstant;
743  ImmRange.Min = Min;
744  ImmRange.Max = Max;
745  }
747  Flags |= CI_ImmediateConstant;
748  for (int Exact : Exacts)
749  ImmSet.insert(Exact);
750  }
751  void setRequiresImmediate(int Exact) {
752  Flags |= CI_ImmediateConstant;
753  ImmSet.insert(Exact);
754  }
756  Flags |= CI_ImmediateConstant;
757  ImmRange.Min = INT_MIN;
758  ImmRange.Max = INT_MAX;
759  }
760 
761  /// Indicate that this is an input operand that is tied to
762  /// the specified output operand.
763  ///
764  /// Copy over the various constraint information from the output.
765  void setTiedOperand(unsigned N, ConstraintInfo &Output) {
766  Output.setHasMatchingInput();
767  Flags = Output.Flags;
768  TiedOperand = N;
769  // Don't copy Name or constraint string.
770  }
771  };
772 
773  /// Validate register name used for global register variables.
774  ///
775  /// This function returns true if the register passed in RegName can be used
776  /// for global register variables on this target. In addition, it returns
777  /// true in HasSizeMismatch if the size of the register doesn't match the
778  /// variable size passed in RegSize.
779  virtual bool validateGlobalRegisterVariable(StringRef RegName,
780  unsigned RegSize,
781  bool &HasSizeMismatch) const {
782  HasSizeMismatch = false;
783  return true;
784  }
785 
786  // validateOutputConstraint, validateInputConstraint - Checks that
787  // a constraint is valid and provides information about it.
788  // FIXME: These should return a real error instead of just true/false.
789  bool validateOutputConstraint(ConstraintInfo &Info) const;
790  bool validateInputConstraint(MutableArrayRef<ConstraintInfo> OutputConstraints,
791  ConstraintInfo &info) const;
792 
793  virtual bool validateOutputSize(StringRef /*Constraint*/,
794  unsigned /*Size*/) const {
795  return true;
796  }
797 
798  virtual bool validateInputSize(StringRef /*Constraint*/,
799  unsigned /*Size*/) const {
800  return true;
801  }
802  virtual bool
803  validateConstraintModifier(StringRef /*Constraint*/,
804  char /*Modifier*/,
805  unsigned /*Size*/,
806  std::string &/*SuggestedModifier*/) const {
807  return true;
808  }
809  virtual bool
810  validateAsmConstraint(const char *&Name,
811  TargetInfo::ConstraintInfo &info) const = 0;
812 
813  bool resolveSymbolicName(const char *&Name,
814  ArrayRef<ConstraintInfo> OutputConstraints,
815  unsigned &Index) const;
816 
817  // Constraint parm will be left pointing at the last character of
818  // the constraint. In practice, it won't be changed unless the
819  // constraint is longer than one character.
820  virtual std::string convertConstraint(const char *&Constraint) const {
821  // 'p' defaults to 'r', but can be overridden by targets.
822  if (*Constraint == 'p')
823  return std::string("r");
824  return std::string(1, *Constraint);
825  }
826 
827  /// Returns a string of target-specific clobbers, in LLVM format.
828  virtual const char *getClobbers() const = 0;
829 
830  /// Returns true if NaN encoding is IEEE 754-2008.
831  /// Only MIPS allows a different encoding.
832  virtual bool isNan2008() const {
833  return true;
834  }
835 
836  /// Returns the target triple of the primary target.
837  const llvm::Triple &getTriple() const {
838  return Triple;
839  }
840 
841  const llvm::DataLayout &getDataLayout() const {
842  assert(DataLayout && "Uninitialized DataLayout!");
843  return *DataLayout;
844  }
845 
846  struct GCCRegAlias {
847  const char * const Aliases[5];
848  const char * const Register;
849  };
850 
851  struct AddlRegName {
852  const char * const Names[5];
853  const unsigned RegNum;
854  };
855 
856  /// Does this target support "protected" visibility?
857  ///
858  /// Any target which dynamic libraries will naturally support
859  /// something like "default" (meaning that the symbol is visible
860  /// outside this shared object) and "hidden" (meaning that it isn't)
861  /// visibilities, but "protected" is really an ELF-specific concept
862  /// with weird semantics designed around the convenience of dynamic
863  /// linker implementations. Which is not to suggest that there's
864  /// consistent target-independent semantics for "default" visibility
865  /// either; the entire thing is pretty badly mangled.
866  virtual bool hasProtectedVisibility() const { return true; }
867 
868  /// An optional hook that targets can implement to perform semantic
869  /// checking on attribute((section("foo"))) specifiers.
870  ///
871  /// In this case, "foo" is passed in to be checked. If the section
872  /// specifier is invalid, the backend should return a non-empty string
873  /// that indicates the problem.
874  ///
875  /// This hook is a simple quality of implementation feature to catch errors
876  /// and give good diagnostics in cases when the assembler or code generator
877  /// would otherwise reject the section specifier.
878  ///
879  virtual std::string isValidSectionSpecifier(StringRef SR) const {
880  return "";
881  }
882 
883  /// Set forced language options.
884  ///
885  /// Apply changes to the target information with respect to certain
886  /// language options which change the target configuration and adjust
887  /// the language based on the target options where applicable.
888  virtual void adjust(LangOptions &Opts);
889 
890  /// Adjust target options based on codegen options.
891  virtual void adjustTargetOptions(const CodeGenOptions &CGOpts,
892  TargetOptions &TargetOpts) const {}
893 
894  /// Initialize the map with the default set of target features for the
895  /// CPU this should include all legal feature strings on the target.
896  ///
897  /// \return False on error (invalid features).
898  virtual bool initFeatureMap(llvm::StringMap<bool> &Features,
899  DiagnosticsEngine &Diags, StringRef CPU,
900  const std::vector<std::string> &FeatureVec) const;
901 
902  /// Get the ABI currently in use.
903  virtual StringRef getABI() const { return StringRef(); }
904 
905  /// Get the C++ ABI currently in use.
907  return TheCXXABI;
908  }
909 
910  /// Target the specified CPU.
911  ///
912  /// \return False on error (invalid CPU name).
913  virtual bool setCPU(const std::string &Name) {
914  return false;
915  }
916 
917  /// Fill a SmallVectorImpl with the valid values to setCPU.
918  virtual void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const {}
919 
920  /// brief Determine whether this TargetInfo supports the given CPU name.
921  virtual bool isValidCPUName(StringRef Name) const {
922  return true;
923  }
924 
925  /// Use the specified ABI.
926  ///
927  /// \return False on error (invalid ABI name).
928  virtual bool setABI(const std::string &Name) {
929  return false;
930  }
931 
932  /// Use the specified unit for FP math.
933  ///
934  /// \return False on error (invalid unit name).
935  virtual bool setFPMath(StringRef Name) {
936  return false;
937  }
938 
939  /// Enable or disable a specific target feature;
940  /// the feature name must be valid.
941  virtual void setFeatureEnabled(llvm::StringMap<bool> &Features,
942  StringRef Name,
943  bool Enabled) const {
944  Features[Name] = Enabled;
945  }
946 
947  /// Determine whether this TargetInfo supports the given feature.
948  virtual bool isValidFeatureName(StringRef Feature) const {
949  return true;
950  }
951 
952  /// Perform initialization based on the user configured
953  /// set of features (e.g., +sse4).
954  ///
955  /// The list is guaranteed to have at most one entry per feature.
956  ///
957  /// The target may modify the features list, to change which options are
958  /// passed onwards to the backend.
959  /// FIXME: This part should be fixed so that we can change handleTargetFeatures
960  /// to merely a TargetInfo initialization routine.
961  ///
962  /// \return False on error.
963  virtual bool handleTargetFeatures(std::vector<std::string> &Features,
964  DiagnosticsEngine &Diags) {
965  return true;
966  }
967 
968  /// Determine whether the given target has the given feature.
969  virtual bool hasFeature(StringRef Feature) const {
970  return false;
971  }
972 
973  /// Identify whether this taret supports multiversioning of functions,
974  /// which requires support for cpu_supports and cpu_is functionality.
975  virtual bool supportsMultiVersioning() const { return false; }
976 
977  // Validate the contents of the __builtin_cpu_supports(const char*)
978  // argument.
979  virtual bool validateCpuSupports(StringRef Name) const { return false; }
980 
981  // Return the target-specific priority for features/cpus/vendors so
982  // that they can be properly sorted for checking.
983  virtual unsigned multiVersionSortPriority(StringRef Name) const {
984  return 0;
985  }
986 
987  // Validate the contents of the __builtin_cpu_is(const char*)
988  // argument.
989  virtual bool validateCpuIs(StringRef Name) const { return false; }
990 
991  // Returns maximal number of args passed in registers.
992  unsigned getRegParmMax() const {
993  assert(RegParmMax < 7 && "RegParmMax value is larger than AST can handle");
994  return RegParmMax;
995  }
996 
997  /// Whether the target supports thread-local storage.
998  bool isTLSSupported() const {
999  return TLSSupported;
1000  }
1001 
1002  /// Return the maximum alignment (in bits) of a TLS variable
1003  ///
1004  /// Gets the maximum alignment (in bits) of a TLS variable on this target.
1005  /// Returns zero if there is no such constraint.
1006  unsigned short getMaxTLSAlign() const {
1007  return MaxTLSAlign;
1008  }
1009 
1010  /// Whether target supports variable-length arrays.
1011  bool isVLASupported() const { return VLASupported; }
1012 
1013  /// Whether the target supports SEH __try.
1014  bool isSEHTrySupported() const {
1015  return getTriple().isOSWindows() &&
1016  (getTriple().getArch() == llvm::Triple::x86 ||
1017  getTriple().getArch() == llvm::Triple::x86_64);
1018  }
1019 
1020  /// Return true if {|} are normal characters in the asm string.
1021  ///
1022  /// If this returns false (the default), then {abc|xyz} is syntax
1023  /// that says that when compiling for asm variant #0, "abc" should be
1024  /// generated, but when compiling for asm variant #1, "xyz" should be
1025  /// generated.
1026  bool hasNoAsmVariants() const {
1027  return NoAsmVariants;
1028  }
1029 
1030  /// Return the register number that __builtin_eh_return_regno would
1031  /// return with the specified argument.
1032  /// This corresponds with TargetLowering's getExceptionPointerRegister
1033  /// and getExceptionSelectorRegister in the backend.
1034  virtual int getEHDataRegisterNumber(unsigned RegNo) const {
1035  return -1;
1036  }
1037 
1038  /// Return the section to use for C++ static initialization functions.
1039  virtual const char *getStaticInitSectionSpecifier() const {
1040  return nullptr;
1041  }
1042 
1043  const LangASMap &getAddressSpaceMap() const { return *AddrSpaceMap; }
1044 
1045  /// Return an AST address space which can be used opportunistically
1046  /// for constant global memory. It must be possible to convert pointers into
1047  /// this address space to LangAS::Default. If no such address space exists,
1048  /// this may return None, and such optimizations will be disabled.
1050  return LangAS::Default;
1051  }
1052 
1053  /// Retrieve the name of the platform as it is used in the
1054  /// availability attribute.
1055  StringRef getPlatformName() const { return PlatformName; }
1056 
1057  /// Retrieve the minimum desired version of the platform, to
1058  /// which the program should be compiled.
1059  VersionTuple getPlatformMinVersion() const { return PlatformMinVersion; }
1060 
1061  bool isBigEndian() const { return BigEndian; }
1062  bool isLittleEndian() const { return !BigEndian; }
1063 
1067  CCMT_NonMember
1068  };
1069 
1070  /// Gets the default calling convention for the given target and
1071  /// declaration context.
1073  // Not all targets will specify an explicit calling convention that we can
1074  // express. This will always do the right thing, even though it's not
1075  // an explicit calling convention.
1076  return CC_C;
1077  }
1078 
1083  };
1084 
1085  /// Determines whether a given calling convention is valid for the
1086  /// target. A calling convention can either be accepted, produce a warning
1087  /// and be substituted with the default calling convention, or (someday)
1088  /// produce an error (such as using thiscall on a non-instance function).
1090  switch (CC) {
1091  default:
1092  return CCCR_Warning;
1093  case CC_C:
1094  return CCCR_OK;
1095  }
1096  }
1097 
1101  CCK_MicrosoftX86_64
1102  };
1103 
1104  virtual CallingConvKind getCallingConvKind(bool ClangABICompat4) const;
1105 
1106  /// Controls if __builtin_longjmp / __builtin_setjmp can be lowered to
1107  /// llvm.eh.sjlj.longjmp / llvm.eh.sjlj.setjmp.
1108  virtual bool hasSjLjLowering() const {
1109  return false;
1110  }
1111 
1112  /// Check if the target supports CFProtection branch.
1113  virtual bool
1114  checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const;
1115 
1116  /// Check if the target supports CFProtection branch.
1117  virtual bool
1118  checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const;
1119 
1120  /// Whether target allows to overalign ABI-specified preferred alignment
1121  virtual bool allowsLargerPreferedTypeAlignment() const { return true; }
1122 
1123  /// Set supported OpenCL extensions and optional core features.
1124  virtual void setSupportedOpenCLOpts() {}
1125 
1126  /// Set supported OpenCL extensions as written on command line
1127  virtual void setOpenCLExtensionOpts() {
1128  for (const auto &Ext : getTargetOpts().OpenCLExtensionsAsWritten) {
1129  getTargetOpts().SupportedOpenCLOptions.support(Ext);
1130  }
1131  }
1132 
1133  /// Get supported OpenCL extensions and optional core features.
1135  return getTargetOpts().SupportedOpenCLOptions;
1136  }
1137 
1138  /// Get const supported OpenCL extensions and optional core features.
1140  return getTargetOpts().SupportedOpenCLOptions;
1141  }
1142 
1152  };
1153 
1154  /// Get address space for OpenCL type.
1155  virtual LangAS getOpenCLTypeAddrSpace(OpenCLTypeKind TK) const;
1156 
1157  /// \returns Target specific vtbl ptr address space.
1158  virtual unsigned getVtblPtrAddressSpace() const {
1159  return 0;
1160  }
1161 
1162  /// \returns If a target requires an address within a target specific address
1163  /// space \p AddressSpace to be converted in order to be used, then return the
1164  /// corresponding target specific DWARF address space.
1165  ///
1166  /// \returns Otherwise return None and no conversion will be emitted in the
1167  /// DWARF.
1168  virtual Optional<unsigned> getDWARFAddressSpace(unsigned AddressSpace) const {
1169  return None;
1170  }
1171 
1172  /// Check the target is valid after it is fully initialized.
1173  virtual bool validateTarget(DiagnosticsEngine &Diags) const {
1174  return true;
1175  }
1176 
1177 protected:
1178  virtual uint64_t getPointerWidthV(unsigned AddrSpace) const {
1179  return PointerWidth;
1180  }
1181  virtual uint64_t getPointerAlignV(unsigned AddrSpace) const {
1182  return PointerAlign;
1183  }
1184  virtual enum IntType getPtrDiffTypeV(unsigned AddrSpace) const {
1185  return PtrDiffType;
1186  }
1187  virtual ArrayRef<const char *> getGCCRegNames() const = 0;
1188  virtual ArrayRef<GCCRegAlias> getGCCRegAliases() const = 0;
1190  return None;
1191  }
1192 };
1193 
1194 } // end namespace clang
1195 
1196 #endif
unsigned getRegParmMax() const
Definition: TargetInfo.h:992
TargetOptions & getTargetOpts() const
Retrieve the target options.
Definition: TargetInfo.h:130
IntType getInt64Type() const
Definition: TargetInfo.h:270
unsigned getHalfWidth() const
getHalfWidth/Align/Format - Return the size/align/format of &#39;half&#39;.
Definition: TargetInfo.h:445
unsigned getFloatWidth() const
getFloatWidth/Align/Format - Return the size/align/format of &#39;float&#39;.
Definition: TargetInfo.h:450
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled...
Definition: TargetInfo.h:1059
unsigned getLongFractAlign() const
Definition: TargetInfo.h:395
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
Definition: TargetInfo.h:643
The basic abstraction for the target C++ ABI.
Definition: TargetCXXABI.h:24
unsigned getBoolWidth() const
Return the size of &#39;_Bool&#39; and C++ &#39;bool&#39; for this target, in bits.
Definition: TargetInfo.h:336
unsigned getLongWidth() const
getLongWidth/Align - Return the size of &#39;signed long&#39; and &#39;unsigned long&#39; for this target...
Definition: TargetInfo.h:359
OpenCL supported extensions and optional core features.
Definition: OpenCLOptions.h:23
unsigned getSuitableAlign() const
Return the alignment that is suitable for storing any object with a fundamental alignment requirement...
Definition: TargetInfo.h:410
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Definition: Dominators.h:30
bool isBigEndian() const
Definition: TargetInfo.h:1061
virtual unsigned getVtblPtrAddressSpace() const
Definition: TargetInfo.h:1158
unsigned getMaxVectorAlign() const
Return the maximum vector alignment supported for the given target.
Definition: TargetInfo.h:507
unsigned short MaxVectorAlign
Definition: TargetInfo.h:87
unsigned getLargeArrayAlign() const
Definition: TargetInfo.h:485
unsigned getFloat128Align() const
Definition: TargetInfo.h:470
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Definition: TargetInfo.h:837
__builtin_va_list as defined by the PNaCl ABI: http://www.chromium.org/nativeclient/pnacl/bitcode-abi...
Definition: TargetInfo.h:173
unsigned getLongAlign() const
Definition: TargetInfo.h:360
virtual bool isValidFeatureName(StringRef Feature) const
Determine whether this TargetInfo supports the given feature.
Definition: TargetInfo.h:948
virtual void setMaxAtomicWidth()
Set the maximum inline or promote width lock-free atomic operation for the given target.
Definition: TargetInfo.h:495
unsigned char IntWidth
Definition: TargetInfo.h:69
unsigned char LongLongWidth
Definition: TargetInfo.h:76
unsigned getDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
Definition: TargetInfo.h:414
unsigned getFractWidth() const
getFractWidth/Align - Return the size of &#39;signed _Fract&#39; and &#39;unsigned _Fract&#39; for this target...
Definition: TargetInfo.h:389
__builtin_va_list as defined by the x86-64 ABI: http://refspecs.linuxbase.org/elf/x86_64-abi-0.21.pdf
Definition: TargetInfo.h:182
unsigned getCharWidth() const
Definition: TargetInfo.h:341
unsigned char ShortFractWidth
Definition: TargetInfo.h:80
virtual CallingConvCheckResult checkCallingConvention(CallingConv CC) const
Determines whether a given calling convention is valid for the target.
Definition: TargetInfo.h:1089
unsigned short SimdDefaultAlign
Definition: TargetInfo.h:89
unsigned getLargeArrayMinWidth() const
Definition: TargetInfo.h:484
llvm::SmallSet< int, 4 > ImmSet
Definition: TargetInfo.h:695
virtual void adjustTargetOptions(const CodeGenOptions &CGOpts, TargetOptions &TargetOpts) const
Adjust target options based on codegen options.
Definition: TargetInfo.h:891
void setRequiresImmediate(int Min, int Max)
Definition: TargetInfo.h:741
const char *const Register
Definition: TargetInfo.h:848
Options for controlling the target.
Definition: TargetOptions.h:26
unsigned getCharAlign() const
Definition: TargetInfo.h:342
unsigned getWCharAlign() const
Definition: TargetInfo.h:432
const llvm::fltSemantics & getHalfFormat() const
Definition: TargetInfo.h:447
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
Definition: AddressSpaces.h:26
__builtin_va_list as defined by the AArch64 ABI http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055a/IHI0055A_aapcs64.pdf
Definition: TargetInfo.h:169
virtual bool isCLZForZeroUndef() const
The __builtin_clz* and __builtin_ctz* built-in functions are specified to have undefined results for ...
Definition: TargetInfo.h:635
unsigned char LongDoubleWidth
Definition: TargetInfo.h:73
unsigned char LargeArrayMinWidth
Definition: TargetInfo.h:74
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:941
unsigned getAccumAlign() const
Definition: TargetInfo.h:375
unsigned ZeroLengthBitfieldBoundary
If non-zero, specifies a fixed alignment value for bitfields that follow zero length bitfield...
Definition: TargetInfo.h:230
unsigned getZeroLengthBitfieldBoundary() const
Get the fixed alignment value in bits for a member that follows a zero length bitfield.
Definition: TargetInfo.h:560
unsigned getLongDoubleAlign() const
Definition: TargetInfo.h:462
unsigned char AccumWidth
Definition: TargetInfo.h:78
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
Definition: TargetInfo.h:319
unsigned char MinGlobalAlign
Definition: TargetInfo.h:85
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
Definition: TargetInfo.h:906
unsigned getIntAlign() const
Definition: TargetInfo.h:355
IntType getUnsignedPtrDiffType(unsigned AddrSpace) const
Definition: TargetInfo.h:259
unsigned getChar32Width() const
getChar32Width/Align - Return the size of &#39;char32_t&#39; for this target, in bits.
Definition: TargetInfo.h:441
virtual bool validateConstraintModifier(StringRef, char, unsigned, std::string &) const
Definition: TargetInfo.h:803
IntType getChar32Type() const
Definition: TargetInfo.h:269
const char * MCountName
Definition: TargetInfo.h:92
const std::string & getName() const
Definition: TargetInfo.h:707
virtual bool useFloat128ManglingForLongDouble() const
Return true if the &#39;long double&#39; type should be mangled like __float128.
Definition: TargetInfo.h:477
unsigned getNewAlign() const
Return the largest alignment for which a suitably-sized allocation with &#39;::operator new(size_t)&#39; is g...
Definition: TargetInfo.h:425
IntType getSizeType() const
Definition: TargetInfo.h:237
bool hasNoAsmVariants() const
Return true if {|} are normal characters in the asm string.
Definition: TargetInfo.h:1026
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
virtual void setOpenCLExtensionOpts()
Set supported OpenCL extensions as written on command line.
Definition: TargetInfo.h:1127
unsigned getMaxAtomicPromoteWidth() const
Return the maximum width lock-free atomic operation which will ever be supported for the given target...
Definition: TargetInfo.h:489
virtual bool hasLegalHalfType() const
Determine whether _Float16 is supported on this target.
Definition: TargetInfo.h:403
virtual StringRef getABI() const
Get the ABI currently in use.
Definition: TargetInfo.h:903
virtual std::string isValidSectionSpecifier(StringRef SR) const
An optional hook that targets can implement to perform semantic checking on attribute((section("foo")...
Definition: TargetInfo.h:879
unsigned char MaxAtomicPromoteWidth
Definition: TargetInfo.h:86
bool hasMatchingInput() const
Return true if this output operand has a matching (tied) input operand.
Definition: TargetInfo.h:715
unsigned char DefaultAlignForAttributeAligned
Definition: TargetInfo.h:84
const LangASMap & getAddressSpaceMap() const
Definition: TargetInfo.h:1043
unsigned char PointerWidth
Definition: TargetInfo.h:67
unsigned char SSERegParmMax
Definition: TargetInfo.h:95
unsigned char FloatWidth
Definition: TargetInfo.h:71
virtual bool hasBuiltinAtomic(uint64_t AtomicSizeInBits, uint64_t AlignmentInBits) const
Returns true if the given target supports lock-free atomic operations at the specified width and alig...
Definition: TargetInfo.h:498
virtual bool validateTarget(DiagnosticsEngine &Diags) const
Check the target is valid after it is fully initialized.
Definition: TargetInfo.h:1173
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
virtual StringRef getConstraintRegister(StringRef Constraint, StringRef Expression) const
Extracts a register from the passed constraint (if it is a single-register constraint) and the asm la...
Definition: TargetInfo.h:674
unsigned getShortWidth() const
Return the size of &#39;signed short&#39; and &#39;unsigned short&#39; for this target, in bits.
Definition: TargetInfo.h:346
unsigned getChar16Align() const
Definition: TargetInfo.h:437
unsigned getFractAlign() const
Definition: TargetInfo.h:390
unsigned char DoubleWidth
Definition: TargetInfo.h:72
VersionTuple PlatformMinVersion
Definition: TargetInfo.h:100
virtual unsigned getRegisterWidth() const
Return the "preferred" register width on this target.
Definition: TargetInfo.h:522
bool useZeroLengthBitfieldAlignment() const
Check whether zero length bitfields should force alignment of the next member.
Definition: TargetInfo.h:554
unsigned char LongWidth
Definition: TargetInfo.h:75
unsigned ComplexLongDoubleUsesFP2Ret
Definition: TargetInfo.h:104
unsigned getLongLongAlign() const
Definition: TargetInfo.h:365
bool isSEHTrySupported() const
Whether the target supports SEH __try.
Definition: TargetInfo.h:1014
unsigned RealTypeUsesObjCFPRet
Definition: TargetInfo.h:103
bool isLittleEndian() const
Definition: TargetInfo.h:1062
Provides definitions for the various language-specific address spaces.
unsigned getMinGlobalAlign() const
getMinGlobalAlign - Return the minimum alignment of a global variable, unless its alignment is explic...
Definition: TargetInfo.h:420
StringRef PlatformName
Definition: TargetInfo.h:99
unsigned char LongAccumWidth
Definition: TargetInfo.h:79
bool useExplicitBitFieldAlignment() const
Check whether explicit bitfield alignment attributes should be.
Definition: TargetInfo.h:566
const llvm::fltSemantics & getDoubleFormat() const
Definition: TargetInfo.h:457
const llvm::fltSemantics & getLongDoubleFormat() const
Definition: TargetInfo.h:463
typedef void* __builtin_va_list;
Definition: TargetInfo.h:165
unsigned HasBuiltinMSVaList
Definition: TargetInfo.h:106
void setRequiresImmediate(int Exact)
Definition: TargetInfo.h:751
Exposes information about the current target.
Definition: TargetInfo.h:54
Defines the TargetCXXABI class, which abstracts details of the C++ ABI that we&#39;re targeting...
unsigned HasAlignMac68kSupport
Definition: TargetInfo.h:102
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
Definition: Types.cpp:39
unsigned getShortFractAlign() const
Definition: TargetInfo.h:385
virtual bool hasProtectedVisibility() const
Does this target support "protected" visibility?
Definition: TargetInfo.h:866
IntType getSignedSizeType() const
Definition: TargetInfo.h:238
IntType getUIntPtrType() const
Definition: TargetInfo.h:263
const FunctionProtoType * T
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:354
bool useObjCFPRetForRealType(RealType T) const
Check whether the given real type should use the "fpret" flavor of Objective-C message passing on thi...
Definition: TargetInfo.h:593
unsigned char LongFractWidth
Definition: TargetInfo.h:82
virtual bool hasSjLjLowering() const
Controls if __builtin_longjmp / __builtin_setjmp can be lowered to llvm.eh.sjlj.longjmp / llvm...
Definition: TargetInfo.h:1108
unsigned getShortAccumWidth() const
getShortAccumWidth/Align - Return the size of &#39;signed short _Accum&#39; and &#39;unsigned short _Accum&#39; for t...
Definition: TargetInfo.h:369
unsigned getAccumWidth() const
getAccumWidth/Align - Return the size of &#39;signed _Accum&#39; and &#39;unsigned _Accum&#39; for this target...
Definition: TargetInfo.h:374
unsigned getLongAccumWidth() const
getLongAccumWidth/Align - Return the size of &#39;signed long _Accum&#39; and &#39;unsigned long _Accum&#39; for this...
Definition: TargetInfo.h:379
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
Definition: TargetInfo.h:1006
unsigned short NewAlign
Definition: TargetInfo.h:90
IntType getChar16Type() const
Definition: TargetInfo.h:268
virtual void fillValidCPUList(SmallVectorImpl< StringRef > &Values) const
Fill a SmallVectorImpl with the valid values to setCPU.
Definition: TargetInfo.h:918
virtual bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags)
Perform initialization based on the user configured set of features (e.g., +sse4).
Definition: TargetInfo.h:963
virtual bool validateCpuSupports(StringRef Name) const
Definition: TargetInfo.h:979
virtual Optional< unsigned > getDWARFAddressSpace(unsigned AddressSpace) const
Definition: TargetInfo.h:1168
#define INT_MIN
Definition: limits.h:67
unsigned getShortAlign() const
Return the alignment of &#39;signed short&#39; and &#39;unsigned short&#39; for this target.
Definition: TargetInfo.h:350
virtual bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const
Validate register name used for global register variables.
Definition: TargetInfo.h:779
void resetDataLayout(StringRef DL)
Definition: TargetInfo.h:113
bool hasAlignMac68kSupport() const
Check whether this target support &#39;#pragma options align=mac68k&#39;.
Definition: TargetInfo.h:571
unsigned getDoubleAlign() const
Definition: TargetInfo.h:456
bool useAddressSpaceMapMangling() const
Specify if mangling based on address space map should be used or not for language specific address sp...
Definition: TargetInfo.h:613
IntType getUIntMaxType() const
Definition: TargetInfo.h:253
unsigned getDoubleWidth() const
getDoubleWidth/Align/Format - Return the size/align/format of &#39;double&#39;.
Definition: TargetInfo.h:455
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:236
virtual bool allowsLargerPreferedTypeAlignment() const
Whether target allows to overalign ABI-specified preferred alignment.
Definition: TargetInfo.h:1121
unsigned UseExplicitBitFieldAlignment
Whether explicit bit field alignment attributes are honored.
Definition: TargetInfo.h:226
unsigned getWCharWidth() const
getWCharWidth/Align - Return the size of &#39;wchar_t&#39; for this target, in bits.
Definition: TargetInfo.h:431
unsigned getLongAccumAlign() const
Definition: TargetInfo.h:380
virtual bool useFP16ConversionIntrinsics() const
Check whether llvm intrinsics such as llvm.convert.to.fp16 should be used to convert to and from __fp...
Definition: TargetInfo.h:607
virtual uint64_t getPointerAlignV(unsigned AddrSpace) const
Definition: TargetInfo.h:1181
virtual bool supportsMultiVersioning() const
Identify whether this taret supports multiversioning of functions, which requires support for cpu_sup...
Definition: TargetInfo.h:975
IntType getPtrDiffType(unsigned AddrSpace) const
Definition: TargetInfo.h:256
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
Definition: TargetInfo.h:514
IntType getSigAtomicType() const
Definition: TargetInfo.h:274
virtual bool setABI(const std::string &Name)
Use the specified ABI.
Definition: TargetInfo.h:928
virtual bool isNan2008() const
Returns true if NaN encoding is IEEE 754-2008.
Definition: TargetInfo.h:832
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
Definition: TargetInfo.h:1055
const LangASMap * AddrSpaceMap
Definition: TargetInfo.h:97
unsigned getMaxAtomicInlineWidth() const
Return the maximum width lock-free atomic operation which can be inlined given the supported features...
Definition: TargetInfo.h:492
unsigned getShortAccumAlign() const
Definition: TargetInfo.h:370
IntType getWIntType() const
Definition: TargetInfo.h:267
unsigned IsRenderScriptTarget
Definition: TargetInfo.h:108
virtual int getEHDataRegisterNumber(unsigned RegNo) const
Return the register number that __builtin_eh_return_regno would return with the specified argument...
Definition: TargetInfo.h:1034
unsigned getChar16Width() const
getChar16Width/Align - Return the size of &#39;char16_t&#39; for this target, in bits.
Definition: TargetInfo.h:436
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:364
IntType getIntMaxType() const
Definition: TargetInfo.h:252
unsigned getFloat128Width() const
getFloat128Width/Align/Format - Return the size/align/format of &#39;__float128&#39;.
Definition: TargetInfo.h:469
Defines the clang::TargetOptions class.
unsigned getHalfAlign() const
Definition: TargetInfo.h:446
virtual uint64_t getPointerWidthV(unsigned AddrSpace) const
Definition: TargetInfo.h:1178
const llvm::DataLayout & getDataLayout() const
Definition: TargetInfo.h:841
virtual ArrayRef< AddlRegName > getGCCAddlRegNames() const
Definition: TargetInfo.h:1189
virtual unsigned getFloatEvalMethod() const
Return the value for the C99 FLT_EVAL_METHOD macro.
Definition: TargetInfo.h:480
__builtin_va_list as defined by the Power ABI: https://www.power.org /resources/downloads/Power-Arch-...
Definition: TargetInfo.h:178
bool useObjCFP2RetForComplexLongDouble() const
Check whether _Complex long double should use the "fp2ret" flavor of Objective-C message passing on t...
Definition: TargetInfo.h:599
bool useBitFieldTypeAlignment() const
Check whether the alignment of bit-field types is respected when laying out structures.
Definition: TargetInfo.h:548
IntType getUInt64Type() const
Definition: TargetInfo.h:271
unsigned UseZeroLengthBitfieldAlignment
Whether zero length bitfields (e.g., int : 0;) force alignment of the next bitfield.
Definition: TargetInfo.h:223
virtual bool validateCpuIs(StringRef Name) const
Definition: TargetInfo.h:989
bool isVLASupported() const
Whether target supports variable-length arrays.
Definition: TargetInfo.h:1011
bool isValidAsmImmediate(const llvm::APInt &Value) const
Definition: TargetInfo.h:731
unsigned getLongDoubleWidth() const
getLongDoubleWidth/Align/Format - Return the size/align/format of &#39;long double&#39;.
Definition: TargetInfo.h:461
__builtin_va_list as defined by ARM AAPCS ABI http://infocenter.arm.com
Definition: TargetInfo.h:187
unsigned char SuitableAlign
Definition: TargetInfo.h:83
Defines various enumerations that describe declaration and type specifiers.
const llvm::fltSemantics & getFloat128Format() const
Definition: TargetInfo.h:471
IntType
===-— Target Data Type Query Methods ----------------------------—===//
Definition: TargetInfo.h:136
Dataflow Directional Tag Classes.
unsigned char BoolWidth
Definition: TargetInfo.h:68
ConstraintInfo(StringRef ConstraintStr, StringRef Name)
Definition: TargetInfo.h:700
unsigned[(unsigned) LangAS::FirstTargetAddressSpace] LangASMap
The type of a lookup table which maps from language-specific address spaces to target-specific ones...
Definition: AddressSpaces.h:54
unsigned UseSignedCharForObjCBool
Whether Objective-C&#39;s built-in boolean type should be signed char.
Definition: TargetInfo.h:208
bool hasTiedOperand() const
Return true if this input operand is a matching constraint that ties it to an output operand...
Definition: TargetInfo.h:722
unsigned getShortFractWidth() const
getShortFractWidth/Align - Return the size of &#39;signed short _Fract&#39; and &#39;unsigned short _Fract&#39; for t...
Definition: TargetInfo.h:384
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
Definition: TargetInfo.h:969
const std::string & getConstraintStr() const
Definition: TargetInfo.h:706
unsigned getLongFractWidth() const
getLongFractWidth/Align - Return the size of &#39;signed long _Fract&#39; and &#39;unsigned long _Fract&#39; for this...
Definition: TargetInfo.h:394
virtual llvm::Optional< LangAS > getConstantAddressSpace() const
Return an AST address space which can be used opportunistically for constant global memory...
Definition: TargetInfo.h:1049
unsigned char ShortAccumWidth
Definition: TargetInfo.h:77
bool useSignedCharForObjCBool() const
Check if the Objective-C built-in boolean type should be signed char.
Definition: TargetInfo.h:539
virtual unsigned multiVersionSortPriority(StringRef Name) const
Definition: TargetInfo.h:983
unsigned getBoolAlign() const
Return the alignment of &#39;_Bool&#39; and C++ &#39;bool&#39; for this target.
Definition: TargetInfo.h:339
virtual const char * getStaticInitSectionSpecifier() const
Return the section to use for C++ static initialization functions.
Definition: TargetInfo.h:1039
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
virtual bool isValidCPUName(StringRef Name) const
brief Determine whether this TargetInfo supports the given CPU name.
Definition: TargetInfo.h:921
virtual uint64_t getMaxPointerWidth() const
Return the maximum width of pointers on this target.
Definition: TargetInfo.h:327
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
Definition: TargetInfo.h:406
void setRequiresImmediate(llvm::ArrayRef< int > Exacts)
Definition: TargetInfo.h:746
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:160
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
Definition: TargetInfo.h:398
virtual CallingConv getDefaultCallingConv(CallingConvMethodType MT) const
Gets the default calling convention for the given target and declaration context. ...
Definition: TargetInfo.h:1072
static IntType getCorrespondingUnsignedType(IntType T)
Definition: TargetInfo.h:277
unsigned getFloatAlign() const
Definition: TargetInfo.h:451
virtual bool setCPU(const std::string &Name)
Target the specified CPU.
Definition: TargetInfo.h:913
virtual bool validateOutputSize(StringRef, unsigned) const
Definition: TargetInfo.h:793
const llvm::fltSemantics & getFloatFormat() const
Definition: TargetInfo.h:452
bool isRenderScriptTarget() const
Returns true for RenderScript.
Definition: TargetInfo.h:646
#define INT_MAX
Definition: limits.h:62
bool isTLSSupported() const
Whether the target supports thread-local storage.
Definition: TargetInfo.h:998
IntType getWCharType() const
Definition: TargetInfo.h:266
static unsigned getCharWidth(tok::TokenKind kind, const TargetInfo &Target)
TargetCXXABI TheCXXABI
Definition: TargetInfo.h:96
uint64_t getPointerAlign(unsigned AddrSpace) const
Definition: TargetInfo.h:322
unsigned getSimdDefaultAlign() const
Return default simd alignment for the given target.
Definition: TargetInfo.h:511
__DEVICE__ int max(int __a, int __b)
const llvm::fltSemantics * LongDoubleFormat
Definition: TargetInfo.h:93
virtual void setSupportedOpenCLOpts()
Set supported OpenCL extensions and optional core features.
Definition: TargetInfo.h:1124
IntType getIntPtrType() const
Definition: TargetInfo.h:262
void setTiedOperand(unsigned N, ConstraintInfo &Output)
Indicate that this is an input operand that is tied to the specified output operand.
Definition: TargetInfo.h:765
unsigned short MaxTLSAlign
Definition: TargetInfo.h:88
virtual bool validateInputSize(StringRef, unsigned) const
Definition: TargetInfo.h:798
unsigned getChar32Align() const
Definition: TargetInfo.h:442
const OpenCLOptions & getSupportedOpenCLOpts() const
Get const supported OpenCL extensions and optional core features.
Definition: TargetInfo.h:1139
virtual bool setFPMath(StringRef Name)
Use the specified unit for FP math.
Definition: TargetInfo.h:935
unsigned UseBitFieldTypeAlignment
Control whether the alignment of bit-field types is respected when laying out structures.
Definition: TargetInfo.h:215
virtual uint64_t getNullPointerValue(LangAS AddrSpace) const
Get integer value for null pointer.
Definition: TargetInfo.h:333
unsigned char FractWidth
Definition: TargetInfo.h:81
IntType getProcessIDType() const
Definition: TargetInfo.h:275
std::unique_ptr< llvm::DataLayout > DataLayout
Definition: TargetInfo.h:91
OpenCLOptions & getSupportedOpenCLOpts()
Get supported OpenCL extensions and optional core features.
Definition: TargetInfo.h:1134
const char * getMCountName() const
Returns the name of the mcount instrumentation function.
Definition: TargetInfo.h:530
void noSignedCharForObjCBool()
Definition: TargetInfo.h:542
virtual std::string convertConstraint(const char *&Constraint) const
Definition: TargetInfo.h:820
unsigned char HalfWidth
Definition: TargetInfo.h:70
bool UseAddrSpaceMapMangling
Specify if mangling based on address space map should be used or not for language specific address sp...
Definition: TargetInfo.h:234
virtual unsigned getUnwindWordWidth() const
Definition: TargetInfo.h:519