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