Coverage Report

Created: 2018-07-19 20:53

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