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