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