Coverage Report

Created: 2021-09-21 08:58

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Basic/Targets/X86.h
Line
Count
Source (jump to first uncovered line)
1
//===--- X86.h - Declare X86 target feature support -------------*- 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
// This file declares X86 TargetInfo objects.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
14
#define LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
15
16
#include "OSTargets.h"
17
#include "clang/Basic/TargetInfo.h"
18
#include "clang/Basic/TargetOptions.h"
19
#include "llvm/ADT/Triple.h"
20
#include "llvm/Support/Compiler.h"
21
#include "llvm/Support/X86TargetParser.h"
22
23
namespace clang {
24
namespace targets {
25
26
static const unsigned X86AddrSpaceMap[] = {
27
    0,   // Default
28
    0,   // opencl_global
29
    0,   // opencl_local
30
    0,   // opencl_constant
31
    0,   // opencl_private
32
    0,   // opencl_generic
33
    0,   // opencl_global_device
34
    0,   // opencl_global_host
35
    0,   // cuda_device
36
    0,   // cuda_constant
37
    0,   // cuda_shared
38
    0,   // sycl_global
39
    0,   // sycl_global_device
40
    0,   // sycl_global_host
41
    0,   // sycl_local
42
    0,   // sycl_private
43
    270, // ptr32_sptr
44
    271, // ptr32_uptr
45
    272  // ptr64
46
};
47
48
// X86 target abstract base class; x86-32 and x86-64 are very close, so
49
// most of the implementation can be shared.
50
class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
51
52
  enum X86SSEEnum {
53
    NoSSE,
54
    SSE1,
55
    SSE2,
56
    SSE3,
57
    SSSE3,
58
    SSE41,
59
    SSE42,
60
    AVX,
61
    AVX2,
62
    AVX512F
63
  } SSELevel = NoSSE;
64
  enum MMX3DNowEnum {
65
    NoMMX3DNow,
66
    MMX,
67
    AMD3DNow,
68
    AMD3DNowAthlon
69
  } MMX3DNowLevel = NoMMX3DNow;
70
  enum XOPEnum { NoXOP, SSE4A, FMA4, XOP } XOPLevel = NoXOP;
71
  enum AddrSpace { ptr32_sptr = 270, ptr32_uptr = 271, ptr64 = 272 };
72
73
  bool HasAES = false;
74
  bool HasVAES = false;
75
  bool HasPCLMUL = false;
76
  bool HasVPCLMULQDQ = false;
77
  bool HasGFNI = false;
78
  bool HasLZCNT = false;
79
  bool HasRDRND = false;
80
  bool HasFSGSBASE = false;
81
  bool HasBMI = false;
82
  bool HasBMI2 = false;
83
  bool HasPOPCNT = false;
84
  bool HasRTM = false;
85
  bool HasPRFCHW = false;
86
  bool HasRDSEED = false;
87
  bool HasADX = false;
88
  bool HasTBM = false;
89
  bool HasLWP = false;
90
  bool HasFMA = false;
91
  bool HasF16C = false;
92
  bool HasAVX512CD = false;
93
  bool HasAVX512VPOPCNTDQ = false;
94
  bool HasAVX512VNNI = false;
95
  bool HasAVX512FP16 = false;
96
  bool HasAVX512BF16 = false;
97
  bool HasAVX512ER = false;
98
  bool HasAVX512PF = false;
99
  bool HasAVX512DQ = false;
100
  bool HasAVX512BITALG = false;
101
  bool HasAVX512BW = false;
102
  bool HasAVX512VL = false;
103
  bool HasAVX512VBMI = false;
104
  bool HasAVX512VBMI2 = false;
105
  bool HasAVX512IFMA = false;
106
  bool HasAVX512VP2INTERSECT = false;
107
  bool HasSHA = false;
108
  bool HasSHSTK = false;
109
  bool HasSGX = false;
110
  bool HasCX8 = false;
111
  bool HasCX16 = false;
112
  bool HasFXSR = false;
113
  bool HasXSAVE = false;
114
  bool HasXSAVEOPT = false;
115
  bool HasXSAVEC = false;
116
  bool HasXSAVES = false;
117
  bool HasMWAITX = false;
118
  bool HasCLZERO = false;
119
  bool HasCLDEMOTE = false;
120
  bool HasPCONFIG = false;
121
  bool HasPKU = false;
122
  bool HasCLFLUSHOPT = false;
123
  bool HasCLWB = false;
124
  bool HasMOVBE = false;
125
  bool HasPREFETCHWT1 = false;
126
  bool HasRDPID = false;
127
  bool HasRetpolineExternalThunk = false;
128
  bool HasLAHFSAHF = false;
129
  bool HasWBNOINVD = false;
130
  bool HasWAITPKG = false;
131
  bool HasMOVDIRI = false;
132
  bool HasMOVDIR64B = false;
133
  bool HasPTWRITE = false;
134
  bool HasINVPCID = false;
135
  bool HasENQCMD = false;
136
  bool HasKL = false;      // For key locker
137
  bool HasWIDEKL = false; // For wide key locker
138
  bool HasHRESET = false;
139
  bool HasAVXVNNI = false;
140
  bool HasAMXTILE = false;
141
  bool HasAMXINT8 = false;
142
  bool HasAMXBF16 = false;
143
  bool HasSERIALIZE = false;
144
  bool HasTSXLDTRK = false;
145
  bool HasUINTR = false;
146
  bool HasCRC32 = false;
147
148
protected:
149
  llvm::X86::CPUKind CPU = llvm::X86::CK_None;
150
151
  enum FPMathKind { FP_Default, FP_SSE, FP_387 } FPMath = FP_Default;
152
153
public:
154
  X86TargetInfo(const llvm::Triple &Triple, const TargetOptions &)
155
95.3k
      : TargetInfo(Triple) {
156
95.3k
    LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
157
95.3k
    AddrSpaceMap = &X86AddrSpaceMap;
158
95.3k
    HasStrictFP = true;
159
160
95.3k
    bool IsWinCOFF =
161
95.3k
        getTriple().isOSWindows() && 
getTriple().isOSBinFormatCOFF()8.44k
;
162
95.3k
    if (IsWinCOFF)
163
8.43k
      MaxVectorAlign = MaxTLSAlign = 8192u * getCharWidth();
164
95.3k
  }
165
166
33.4k
  const char *getLongDoubleMangling() const override {
167
33.4k
    return LongDoubleFormat == &llvm::APFloat::IEEEquad() ? 
"g"14
:
"e"33.4k
;
168
33.4k
  }
169
170
87.1k
  unsigned getFloatEvalMethod() const override {
171
    // X87 evaluates with 80 bits "long double" precision.
172
87.1k
    return SSELevel == NoSSE ? 
24.55k
:
082.5k
;
173
87.1k
  }
174
175
  ArrayRef<const char *> getGCCRegNames() const override;
176
177
2.32k
  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
178
2.32k
    return None;
179
2.32k
  }
180
181
  ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
182
183
2
  bool isSPRegName(StringRef RegName) const override {
184
2
    return RegName.equals("esp") || RegName.equals("rsp");
185
2
  }
186
187
  bool validateCpuSupports(StringRef Name) const override;
188
189
  bool validateCpuIs(StringRef Name) const override;
190
191
  bool validateCPUSpecificCPUDispatch(StringRef Name) const override;
192
193
  char CPUSpecificManglingCharacter(StringRef Name) const override;
194
195
  void getCPUSpecificCPUDispatchFeatures(
196
      StringRef Name,
197
      llvm::SmallVectorImpl<StringRef> &Features) const override;
198
199
  Optional<unsigned> getCPUCacheLineSize() const override;
200
201
  bool validateAsmConstraint(const char *&Name,
202
                             TargetInfo::ConstraintInfo &info) const override;
203
204
  bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
205
34
                                      bool &HasSizeMismatch) const override {
206
    // esp and ebp are the only 32-bit registers the x86 backend can currently
207
    // handle.
208
34
    if (RegName.equals("esp") || 
RegName.equals("ebp")1
) {
209
      // Check that the register size is 32-bit.
210
33
      HasSizeMismatch = RegSize != 32;
211
33
      return true;
212
33
    }
213
214
1
    return false;
215
34
  }
216
217
  bool validateOutputSize(const llvm::StringMap<bool> &FeatureMap,
218
                          StringRef Constraint, unsigned Size) const override;
219
220
  bool validateInputSize(const llvm::StringMap<bool> &FeatureMap,
221
                         StringRef Constraint, unsigned Size) const override;
222
223
  virtual bool
224
0
  checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override {
225
0
    return true;
226
0
  };
227
228
  virtual bool
229
4
  checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const override {
230
4
    return true;
231
4
  };
232
233
  virtual bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap,
234
                                   StringRef Constraint, unsigned Size) const;
235
236
  std::string convertConstraint(const char *&Constraint) const override;
237
818
  const char *getClobbers() const override {
238
818
    return "~{dirflag},~{fpsr},~{flags}";
239
818
  }
240
241
  StringRef getConstraintRegister(StringRef Constraint,
242
11.4k
                                  StringRef Expression) const override {
243
11.4k
    StringRef::iterator I, E;
244
17.2k
    for (I = Constraint.begin(), E = Constraint.end(); I != E; 
++I5.74k
) {
245
17.0k
      if (isalpha(*I) || 
*I == '@'5.77k
)
246
11.3k
        break;
247
17.0k
    }
248
11.4k
    if (I == E)
249
155
      return "";
250
11.3k
    switch (*I) {
251
    // For the register constraints, return the matching register name
252
2.55k
    case 'a':
253
2.55k
      return "ax";
254
2.12k
    case 'b':
255
2.12k
      return "bx";
256
2.26k
    case 'c':
257
2.26k
      return "cx";
258
2.16k
    case 'd':
259
2.16k
      return "dx";
260
40
    case 'S':
261
40
      return "si";
262
96
    case 'D':
263
96
      return "di";
264
    // In case the constraint is 'r' we need to return Expression
265
1.25k
    case 'r':
266
1.25k
      return Expression;
267
    // Double letters Y<x> constraints
268
26
    case 'Y':
269
26
      if ((++I != E) && ((*I == '0') || (*I == 'z')))
270
10
        return "xmm0";
271
16
      break;
272
797
    default:
273
797
      break;
274
11.3k
    }
275
813
    return "";
276
11.3k
  }
277
278
4.61M
  bool useFP16ConversionIntrinsics() const override {
279
4.61M
    return false;
280
4.61M
  }
281
282
  void getTargetDefines(const LangOptions &Opts,
283
                        MacroBuilder &Builder) const override;
284
285
  void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
286
                         bool Enabled) const final;
287
288
  bool
289
  initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
290
                 StringRef CPU,
291
                 const std::vector<std::string> &FeaturesVec) const override;
292
293
  bool isValidFeatureName(StringRef Name) const override;
294
295
  bool hasFeature(StringRef Feature) const final;
296
297
  bool handleTargetFeatures(std::vector<std::string> &Features,
298
                            DiagnosticsEngine &Diags) override;
299
300
181k
  StringRef getABI() const override {
301
181k
    if (getTriple().getArch() == llvm::Triple::x86_64 && 
SSELevel >= AVX512F172k
)
302
249
      return "avx512";
303
181k
    if (getTriple().getArch() == llvm::Triple::x86_64 && 
SSELevel >= AVX171k
)
304
150
      return "avx";
305
181k
    if (getTriple().getArch() == llvm::Triple::x86 &&
306
181k
        
MMX3DNowLevel == NoMMX3DNow9.38k
)
307
9.30k
      return "no-mmx";
308
171k
    return "";
309
181k
  }
310
311
1.12M
  bool supportsTargetAttributeTune() const override {
312
1.12M
    return true;
313
1.12M
  }
314
315
504
  bool isValidCPUName(StringRef Name) const override {
316
504
    bool Only64Bit = getTriple().getArch() != llvm::Triple::x86;
317
504
    return llvm::X86::parseArchX86(Name, Only64Bit) != llvm::X86::CK_None;
318
504
  }
319
320
34.5k
  bool isValidTuneCPUName(StringRef Name) const override {
321
34.5k
    if (Name == "generic")
322
34.5k
      return true;
323
324
    // Allow 32-bit only CPUs regardless of 64-bit mode unlike isValidCPUName.
325
    // NOTE: gcc rejects 32-bit mtune CPUs in 64-bit mode. But being lenient
326
    // since mtune was ignored by clang for so long.
327
7
    return llvm::X86::parseTuneCPU(Name) != llvm::X86::CK_None;
328
34.5k
  }
329
330
  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
331
  void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values) const override;
332
333
34.9k
  bool setCPU(const std::string &Name) override {
334
34.9k
    bool Only64Bit = getTriple().getArch() != llvm::Triple::x86;
335
34.9k
    CPU = llvm::X86::parseArchX86(Name, Only64Bit);
336
34.9k
    return CPU != llvm::X86::CK_None;
337
34.9k
  }
338
339
  unsigned multiVersionSortPriority(StringRef Name) const override;
340
341
  bool setFPMath(StringRef Name) override;
342
343
31
  bool supportsExtendIntArgs() const override {
344
31
    return getTriple().getArch() != llvm::Triple::x86;
345
31
  }
346
347
6.95k
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
348
    // Most of the non-ARM calling conventions are i386 conventions.
349
6.95k
    switch (CC) {
350
67
    case CC_X86ThisCall:
351
240
    case CC_X86FastCall:
352
461
    case CC_X86StdCall:
353
569
    case CC_X86VectorCall:
354
631
    case CC_X86RegCall:
355
886
    case CC_C:
356
892
    case CC_PreserveMost:
357
898
    case CC_Swift:
358
912
    case CC_X86Pascal:
359
915
    case CC_IntelOclBicc:
360
915
    case CC_OpenCLKernel:
361
915
      return CCCR_OK;
362
6.02k
    case CC_SwiftAsync:
363
6.02k
      return CCCR_Error;
364
10
    default:
365
10
      return CCCR_Warning;
366
6.95k
    }
367
6.95k
  }
368
369
59
  bool checkArithmeticFenceSupported() const override { return true; }
370
371
574k
  CallingConv getDefaultCallingConv() const override {
372
574k
    return CC_C;
373
574k
  }
374
375
8
  bool hasSjLjLowering() const override { return true; }
376
377
95.2k
  void setSupportedOpenCLOpts() override { supportAllOpenCLOpts(); }
378
379
329
  uint64_t getPointerWidthV(unsigned AddrSpace) const override {
380
329
    if (AddrSpace == ptr32_sptr || 
AddrSpace == ptr32_uptr323
)
381
14
      return 32;
382
315
    if (AddrSpace == ptr64)
383
4
      return 64;
384
311
    return PointerWidth;
385
315
  }
386
387
162
  uint64_t getPointerAlignV(unsigned AddrSpace) const override {
388
162
    return getPointerWidthV(AddrSpace);
389
162
  }
390
};
391
392
// X86-32 generic target
393
class LLVM_LIBRARY_VISIBILITY X86_32TargetInfo : public X86TargetInfo {
394
public:
395
  X86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
396
14.3k
      : X86TargetInfo(Triple, Opts) {
397
14.3k
    DoubleAlign = LongLongAlign = 32;
398
14.3k
    LongDoubleWidth = 96;
399
14.3k
    LongDoubleAlign = 32;
400
14.3k
    SuitableAlign = 128;
401
14.3k
    resetDataLayout(
402
14.3k
        Triple.isOSBinFormatMachO()
403
14.3k
            ? "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
404
386
              "f80:32-n8:16:32-S128"
405
14.3k
            : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
406
13.9k
              "f80:32-n8:16:32-S128",
407
14.3k
        Triple.isOSBinFormatMachO() ? 
"_"386
:
""13.9k
);
408
14.3k
    SizeType = UnsignedInt;
409
14.3k
    PtrDiffType = SignedInt;
410
14.3k
    IntPtrType = SignedInt;
411
14.3k
    RegParmMax = 3;
412
413
    // Use fpret for all types.
414
14.3k
    RealTypeUsesObjCFPRet =
415
14.3k
        ((1 << TargetInfo::Float) | (1 << TargetInfo::Double) |
416
14.3k
         (1 << TargetInfo::LongDouble));
417
418
    // x86-32 has atomics up to 8 bytes
419
14.3k
    MaxAtomicPromoteWidth = 64;
420
14.3k
    MaxAtomicInlineWidth = 32;
421
14.3k
  }
clang::targets::X86_32TargetInfo::X86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
396
1.59k
      : X86TargetInfo(Triple, Opts) {
397
1.59k
    DoubleAlign = LongLongAlign = 32;
398
1.59k
    LongDoubleWidth = 96;
399
1.59k
    LongDoubleAlign = 32;
400
1.59k
    SuitableAlign = 128;
401
1.59k
    resetDataLayout(
402
1.59k
        Triple.isOSBinFormatMachO()
403
1.59k
            ? "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
404
385
              "f80:32-n8:16:32-S128"
405
1.59k
            : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
406
1.21k
              "f80:32-n8:16:32-S128",
407
1.59k
        Triple.isOSBinFormatMachO() ? 
"_"385
:
""1.21k
);
408
1.59k
    SizeType = UnsignedInt;
409
1.59k
    PtrDiffType = SignedInt;
410
1.59k
    IntPtrType = SignedInt;
411
1.59k
    RegParmMax = 3;
412
413
    // Use fpret for all types.
414
1.59k
    RealTypeUsesObjCFPRet =
415
1.59k
        ((1 << TargetInfo::Float) | (1 << TargetInfo::Double) |
416
1.59k
         (1 << TargetInfo::LongDouble));
417
418
    // x86-32 has atomics up to 8 bytes
419
1.59k
    MaxAtomicPromoteWidth = 64;
420
1.59k
    MaxAtomicInlineWidth = 32;
421
1.59k
  }
clang::targets::X86_32TargetInfo::X86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
396
12.7k
      : X86TargetInfo(Triple, Opts) {
397
12.7k
    DoubleAlign = LongLongAlign = 32;
398
12.7k
    LongDoubleWidth = 96;
399
12.7k
    LongDoubleAlign = 32;
400
12.7k
    SuitableAlign = 128;
401
12.7k
    resetDataLayout(
402
12.7k
        Triple.isOSBinFormatMachO()
403
12.7k
            ? "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
404
1
              "f80:32-n8:16:32-S128"
405
12.7k
            : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
406
12.7k
              "f80:32-n8:16:32-S128",
407
12.7k
        Triple.isOSBinFormatMachO() ? 
"_"1
:
""12.7k
);
408
12.7k
    SizeType = UnsignedInt;
409
12.7k
    PtrDiffType = SignedInt;
410
12.7k
    IntPtrType = SignedInt;
411
12.7k
    RegParmMax = 3;
412
413
    // Use fpret for all types.
414
12.7k
    RealTypeUsesObjCFPRet =
415
12.7k
        ((1 << TargetInfo::Float) | (1 << TargetInfo::Double) |
416
12.7k
         (1 << TargetInfo::LongDouble));
417
418
    // x86-32 has atomics up to 8 bytes
419
12.7k
    MaxAtomicPromoteWidth = 64;
420
12.7k
    MaxAtomicInlineWidth = 32;
421
12.7k
  }
422
423
13.9k
  BuiltinVaListKind getBuiltinVaListKind() const override {
424
13.9k
    return TargetInfo::CharPtrBuiltinVaList;
425
13.9k
  }
426
427
2
  int getEHDataRegisterNumber(unsigned RegNo) const override {
428
2
    if (RegNo == 0)
429
2
      return 0;
430
0
    if (RegNo == 1)
431
0
      return 2;
432
0
    return -1;
433
0
  }
434
435
  bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap,
436
2.90k
                           StringRef Constraint, unsigned Size) const override {
437
2.90k
    switch (Constraint[0]) {
438
778
    default:
439
778
      break;
440
778
    case 'R':
441
13
    case 'q':
442
19
    case 'Q':
443
605
    case 'a':
444
1.07k
    case 'b':
445
1.59k
    case 'c':
446
2.06k
    case 'd':
447
2.07k
    case 'S':
448
2.12k
    case 'D':
449
2.12k
      return Size <= 32;
450
6
    case 'A':
451
6
      return Size <= 64;
452
2.90k
    }
453
454
778
    return X86TargetInfo::validateOperandSize(FeatureMap, Constraint, Size);
455
2.90k
  }
456
457
14.2k
  void setMaxAtomicWidth() override {
458
14.2k
    if (hasFeature("cx8"))
459
14.2k
      MaxAtomicInlineWidth = 64;
460
14.2k
  }
461
462
  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
463
464
94
  bool hasExtIntType() const override { return true; }
465
};
466
467
class LLVM_LIBRARY_VISIBILITY NetBSDI386TargetInfo
468
    : public NetBSDTargetInfo<X86_32TargetInfo> {
469
public:
470
  NetBSDI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
471
7
      : NetBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
clang::targets::NetBSDI386TargetInfo::NetBSDI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
471
7
      : NetBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
Unexecuted instantiation: clang::targets::NetBSDI386TargetInfo::NetBSDI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
472
473
7
  unsigned getFloatEvalMethod() const override {
474
7
    unsigned Major, Minor, Micro;
475
7
    getTriple().getOSVersion(Major, Minor, Micro);
476
    // New NetBSD uses the default rounding mode.
477
7
    if (Major >= 7 || (Major == 6 && 
Minor == 992
&&
Micro >= 260
) || Major == 0)
478
5
      return X86_32TargetInfo::getFloatEvalMethod();
479
    // NetBSD before 6.99.26 defaults to "double" rounding.
480
2
    return 1;
481
7
  }
482
};
483
484
class LLVM_LIBRARY_VISIBILITY OpenBSDI386TargetInfo
485
    : public OpenBSDTargetInfo<X86_32TargetInfo> {
486
public:
487
  OpenBSDI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
488
4
      : OpenBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {
489
4
    SizeType = UnsignedLong;
490
4
    IntPtrType = SignedLong;
491
4
    PtrDiffType = SignedLong;
492
4
  }
clang::targets::OpenBSDI386TargetInfo::OpenBSDI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
488
4
      : OpenBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {
489
4
    SizeType = UnsignedLong;
490
4
    IntPtrType = SignedLong;
491
4
    PtrDiffType = SignedLong;
492
4
  }
Unexecuted instantiation: clang::targets::OpenBSDI386TargetInfo::OpenBSDI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
493
};
494
495
class LLVM_LIBRARY_VISIBILITY DarwinI386TargetInfo
496
    : public DarwinTargetInfo<X86_32TargetInfo> {
497
public:
498
  DarwinI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
499
385
      : DarwinTargetInfo<X86_32TargetInfo>(Triple, Opts) {
500
385
    LongDoubleWidth = 128;
501
385
    LongDoubleAlign = 128;
502
385
    SuitableAlign = 128;
503
385
    MaxVectorAlign = 256;
504
    // The watchOS simulator uses the builtin bool type for Objective-C.
505
385
    llvm::Triple T = llvm::Triple(Triple);
506
385
    if (T.isWatchOS())
507
13
      UseSignedCharForObjCBool = false;
508
385
    SizeType = UnsignedLong;
509
385
    IntPtrType = SignedLong;
510
385
    resetDataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
511
385
                    "f80:128-n8:16:32-S128", "_");
512
385
    HasAlignMac68kSupport = true;
513
385
  }
clang::targets::DarwinI386TargetInfo::DarwinI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
499
385
      : DarwinTargetInfo<X86_32TargetInfo>(Triple, Opts) {
500
385
    LongDoubleWidth = 128;
501
385
    LongDoubleAlign = 128;
502
385
    SuitableAlign = 128;
503
385
    MaxVectorAlign = 256;
504
    // The watchOS simulator uses the builtin bool type for Objective-C.
505
385
    llvm::Triple T = llvm::Triple(Triple);
506
385
    if (T.isWatchOS())
507
13
      UseSignedCharForObjCBool = false;
508
385
    SizeType = UnsignedLong;
509
385
    IntPtrType = SignedLong;
510
385
    resetDataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
511
385
                    "f80:128-n8:16:32-S128", "_");
512
385
    HasAlignMac68kSupport = true;
513
385
  }
Unexecuted instantiation: clang::targets::DarwinI386TargetInfo::DarwinI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
514
515
  bool handleTargetFeatures(std::vector<std::string> &Features,
516
383
                            DiagnosticsEngine &Diags) override {
517
383
    if (!DarwinTargetInfo<X86_32TargetInfo>::handleTargetFeatures(Features,
518
383
                                                                  Diags))
519
0
      return false;
520
    // We now know the features we have: we can decide how to align vectors.
521
383
    MaxVectorAlign =
522
383
        hasFeature("avx512f") ? 
5121
:
hasFeature("avx")382
?
2562
:
128380
;
523
383
    return true;
524
383
  }
525
};
526
527
// x86-32 Windows target
528
class LLVM_LIBRARY_VISIBILITY WindowsX86_32TargetInfo
529
    : public WindowsTargetInfo<X86_32TargetInfo> {
530
public:
531
  WindowsX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
532
647
      : WindowsTargetInfo<X86_32TargetInfo>(Triple, Opts) {
533
647
    DoubleAlign = LongLongAlign = 64;
534
647
    bool IsWinCOFF =
535
647
        getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
536
647
    resetDataLayout(IsWinCOFF ? "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:"
537
645
                                "64-i64:64-f80:32-n8:16:32-a:0:32-S32"
538
647
                              : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:"
539
2
                                "64-i64:64-f80:32-n8:16:32-a:0:32-S32",
540
647
                    IsWinCOFF ? 
"_"645
:
""2
);
541
647
  }
542
};
543
544
// x86-32 Windows Visual Studio target
545
class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32TargetInfo
546
    : public WindowsX86_32TargetInfo {
547
public:
548
  MicrosoftX86_32TargetInfo(const llvm::Triple &Triple,
549
                            const TargetOptions &Opts)
550
537
      : WindowsX86_32TargetInfo(Triple, Opts) {
551
537
    LongDoubleWidth = LongDoubleAlign = 64;
552
537
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
553
537
  }
clang::targets::MicrosoftX86_32TargetInfo::MicrosoftX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
550
537
      : WindowsX86_32TargetInfo(Triple, Opts) {
551
537
    LongDoubleWidth = LongDoubleAlign = 64;
552
537
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
553
537
  }
Unexecuted instantiation: clang::targets::MicrosoftX86_32TargetInfo::MicrosoftX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
554
555
  void getTargetDefines(const LangOptions &Opts,
556
532
                        MacroBuilder &Builder) const override {
557
532
    WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
558
    // The value of the following reflects processor type.
559
    // 300=386, 400=486, 500=Pentium, 600=Blend (default)
560
    // We lost the original triple, so we use the default.
561
532
    Builder.defineMacro("_M_IX86", "600");
562
532
  }
563
};
564
565
// x86-32 MinGW target
566
class LLVM_LIBRARY_VISIBILITY MinGWX86_32TargetInfo
567
    : public WindowsX86_32TargetInfo {
568
public:
569
  MinGWX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
570
110
      : WindowsX86_32TargetInfo(Triple, Opts) {
571
110
    HasFloat128 = true;
572
110
  }
clang::targets::MinGWX86_32TargetInfo::MinGWX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
570
110
      : WindowsX86_32TargetInfo(Triple, Opts) {
571
110
    HasFloat128 = true;
572
110
  }
Unexecuted instantiation: clang::targets::MinGWX86_32TargetInfo::MinGWX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
573
574
  void getTargetDefines(const LangOptions &Opts,
575
110
                        MacroBuilder &Builder) const override {
576
110
    WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
577
110
    Builder.defineMacro("_X86_");
578
110
  }
579
};
580
581
// x86-32 Cygwin target
582
class LLVM_LIBRARY_VISIBILITY CygwinX86_32TargetInfo : public X86_32TargetInfo {
583
public:
584
  CygwinX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
585
11
      : X86_32TargetInfo(Triple, Opts) {
586
11
    this->WCharType = TargetInfo::UnsignedShort;
587
11
    DoubleAlign = LongLongAlign = 64;
588
11
    resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:"
589
11
                    "32-n8:16:32-a:0:32-S32",
590
11
                    "_");
591
11
  }
clang::targets::CygwinX86_32TargetInfo::CygwinX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
585
11
      : X86_32TargetInfo(Triple, Opts) {
586
11
    this->WCharType = TargetInfo::UnsignedShort;
587
11
    DoubleAlign = LongLongAlign = 64;
588
11
    resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:"
589
11
                    "32-n8:16:32-a:0:32-S32",
590
11
                    "_");
591
11
  }
Unexecuted instantiation: clang::targets::CygwinX86_32TargetInfo::CygwinX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
592
593
  void getTargetDefines(const LangOptions &Opts,
594
11
                        MacroBuilder &Builder) const override {
595
11
    X86_32TargetInfo::getTargetDefines(Opts, Builder);
596
11
    Builder.defineMacro("_X86_");
597
11
    Builder.defineMacro("__CYGWIN__");
598
11
    Builder.defineMacro("__CYGWIN32__");
599
11
    addCygMingDefines(Opts, Builder);
600
11
    DefineStd(Builder, "unix", Opts);
601
11
    if (Opts.CPlusPlus)
602
5
      Builder.defineMacro("_GNU_SOURCE");
603
11
  }
604
};
605
606
// x86-32 Haiku target
607
class LLVM_LIBRARY_VISIBILITY HaikuX86_32TargetInfo
608
    : public HaikuTargetInfo<X86_32TargetInfo> {
609
public:
610
  HaikuX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
611
3
      : HaikuTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
clang::targets::HaikuX86_32TargetInfo::HaikuX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
611
3
      : HaikuTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
Unexecuted instantiation: clang::targets::HaikuX86_32TargetInfo::HaikuX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
612
613
  void getTargetDefines(const LangOptions &Opts,
614
3
                        MacroBuilder &Builder) const override {
615
3
    HaikuTargetInfo<X86_32TargetInfo>::getTargetDefines(Opts, Builder);
616
3
    Builder.defineMacro("__INTEL__");
617
3
  }
618
};
619
620
// X86-32 MCU target
621
class LLVM_LIBRARY_VISIBILITY MCUX86_32TargetInfo : public X86_32TargetInfo {
622
public:
623
  MCUX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
624
6
      : X86_32TargetInfo(Triple, Opts) {
625
6
    LongDoubleWidth = 64;
626
6
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
627
6
    resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:32-f64:"
628
6
                    "32-f128:32-n8:16:32-a:0:32-S32");
629
6
    WIntType = UnsignedInt;
630
6
  }
clang::targets::MCUX86_32TargetInfo::MCUX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
624
6
      : X86_32TargetInfo(Triple, Opts) {
625
6
    LongDoubleWidth = 64;
626
6
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
627
6
    resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:32-f64:"
628
6
                    "32-f128:32-n8:16:32-a:0:32-S32");
629
6
    WIntType = UnsignedInt;
630
6
  }
Unexecuted instantiation: clang::targets::MCUX86_32TargetInfo::MCUX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
631
632
17
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
633
    // On MCU we support only C calling convention.
634
17
    return CC == CC_C ? 
CCCR_OK4
:
CCCR_Warning13
;
635
17
  }
636
637
  void getTargetDefines(const LangOptions &Opts,
638
6
                        MacroBuilder &Builder) const override {
639
6
    X86_32TargetInfo::getTargetDefines(Opts, Builder);
640
6
    Builder.defineMacro("__iamcu");
641
6
    Builder.defineMacro("__iamcu__");
642
6
  }
643
644
67
  bool allowsLargerPreferedTypeAlignment() const override { return false; }
645
};
646
647
// x86-32 RTEMS target
648
class LLVM_LIBRARY_VISIBILITY RTEMSX86_32TargetInfo : public X86_32TargetInfo {
649
public:
650
  RTEMSX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
651
0
      : X86_32TargetInfo(Triple, Opts) {
652
0
    SizeType = UnsignedLong;
653
0
    IntPtrType = SignedLong;
654
0
    PtrDiffType = SignedLong;
655
0
  }
Unexecuted instantiation: clang::targets::RTEMSX86_32TargetInfo::RTEMSX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Unexecuted instantiation: clang::targets::RTEMSX86_32TargetInfo::RTEMSX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
656
657
  void getTargetDefines(const LangOptions &Opts,
658
0
                        MacroBuilder &Builder) const override {
659
0
    X86_32TargetInfo::getTargetDefines(Opts, Builder);
660
0
    Builder.defineMacro("__INTEL__");
661
0
    Builder.defineMacro("__rtems__");
662
0
  }
663
};
664
665
// x86-64 generic target
666
class LLVM_LIBRARY_VISIBILITY X86_64TargetInfo : public X86TargetInfo {
667
public:
668
  X86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
669
81.0k
      : X86TargetInfo(Triple, Opts) {
670
81.0k
    const bool IsX32 = getTriple().isX32();
671
81.0k
    bool IsWinCOFF =
672
81.0k
        getTriple().isOSWindows() && 
getTriple().isOSBinFormatCOFF()7.78k
;
673
81.0k
    LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 
3210
:
6480.9k
;
674
81.0k
    LongDoubleWidth = 128;
675
81.0k
    LongDoubleAlign = 128;
676
81.0k
    LargeArrayMinWidth = 128;
677
81.0k
    LargeArrayAlign = 128;
678
81.0k
    SuitableAlign = 128;
679
81.0k
    SizeType = IsX32 ? 
UnsignedInt10
:
UnsignedLong80.9k
;
680
81.0k
    PtrDiffType = IsX32 ? 
SignedInt10
:
SignedLong80.9k
;
681
81.0k
    IntPtrType = IsX32 ? 
SignedInt10
:
SignedLong80.9k
;
682
81.0k
    IntMaxType = IsX32 ? 
SignedLongLong10
:
SignedLong80.9k
;
683
81.0k
    Int64Type = IsX32 ? 
SignedLongLong10
:
SignedLong80.9k
;
684
81.0k
    RegParmMax = 6;
685
686
    // Pointers are 32-bit in x32.
687
81.0k
    resetDataLayout(IsX32 ? "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-"
688
10
                            "i64:64-f80:128-n8:16:32:64-S128"
689
81.0k
                          : 
IsWinCOFF80.9k
? "e-m:w-p270:32:32-p271:32:32-p272:64:"
690
7.78k
                                        "64-i64:64-f80:128-n8:16:32:64-S128"
691
80.9k
                                      : "e-m:e-p270:32:32-p271:32:32-p272:64:"
692
73.2k
                                        "64-i64:64-f80:128-n8:16:32:64-S128");
693
694
    // Use fpret only for long double.
695
81.0k
    RealTypeUsesObjCFPRet = (1 << TargetInfo::LongDouble);
696
697
    // Use fp2ret for _Complex long double.
698
81.0k
    ComplexLongDoubleUsesFP2Ret = true;
699
700
    // Make __builtin_ms_va_list available.
701
81.0k
    HasBuiltinMSVaList = true;
702
703
    // x86-64 has atomics up to 16 bytes.
704
81.0k
    MaxAtomicPromoteWidth = 128;
705
81.0k
    MaxAtomicInlineWidth = 64;
706
81.0k
  }
clang::targets::X86_64TargetInfo::X86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
669
79.6k
      : X86TargetInfo(Triple, Opts) {
670
79.6k
    const bool IsX32 = getTriple().isX32();
671
79.6k
    bool IsWinCOFF =
672
79.6k
        getTriple().isOSWindows() && 
getTriple().isOSBinFormatCOFF()7.78k
;
673
79.6k
    LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 
328
:
6479.6k
;
674
79.6k
    LongDoubleWidth = 128;
675
79.6k
    LongDoubleAlign = 128;
676
79.6k
    LargeArrayMinWidth = 128;
677
79.6k
    LargeArrayAlign = 128;
678
79.6k
    SuitableAlign = 128;
679
79.6k
    SizeType = IsX32 ? 
UnsignedInt8
:
UnsignedLong79.6k
;
680
79.6k
    PtrDiffType = IsX32 ? 
SignedInt8
:
SignedLong79.6k
;
681
79.6k
    IntPtrType = IsX32 ? 
SignedInt8
:
SignedLong79.6k
;
682
79.6k
    IntMaxType = IsX32 ? 
SignedLongLong8
:
SignedLong79.6k
;
683
79.6k
    Int64Type = IsX32 ? 
SignedLongLong8
:
SignedLong79.6k
;
684
79.6k
    RegParmMax = 6;
685
686
    // Pointers are 32-bit in x32.
687
79.6k
    resetDataLayout(IsX32 ? "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-"
688
8
                            "i64:64-f80:128-n8:16:32:64-S128"
689
79.6k
                          : 
IsWinCOFF79.6k
? "e-m:w-p270:32:32-p271:32:32-p272:64:"
690
7.78k
                                        "64-i64:64-f80:128-n8:16:32:64-S128"
691
79.6k
                                      : "e-m:e-p270:32:32-p271:32:32-p272:64:"
692
71.8k
                                        "64-i64:64-f80:128-n8:16:32:64-S128");
693
694
    // Use fpret only for long double.
695
79.6k
    RealTypeUsesObjCFPRet = (1 << TargetInfo::LongDouble);
696
697
    // Use fp2ret for _Complex long double.
698
79.6k
    ComplexLongDoubleUsesFP2Ret = true;
699
700
    // Make __builtin_ms_va_list available.
701
79.6k
    HasBuiltinMSVaList = true;
702
703
    // x86-64 has atomics up to 16 bytes.
704
79.6k
    MaxAtomicPromoteWidth = 128;
705
79.6k
    MaxAtomicInlineWidth = 64;
706
79.6k
  }
clang::targets::X86_64TargetInfo::X86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
669
1.38k
      : X86TargetInfo(Triple, Opts) {
670
1.38k
    const bool IsX32 = getTriple().isX32();
671
1.38k
    bool IsWinCOFF =
672
1.38k
        getTriple().isOSWindows() && 
getTriple().isOSBinFormatCOFF()0
;
673
1.38k
    LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 
322
:
641.37k
;
674
1.38k
    LongDoubleWidth = 128;
675
1.38k
    LongDoubleAlign = 128;
676
1.38k
    LargeArrayMinWidth = 128;
677
1.38k
    LargeArrayAlign = 128;
678
1.38k
    SuitableAlign = 128;
679
1.38k
    SizeType = IsX32 ? 
UnsignedInt2
:
UnsignedLong1.37k
;
680
1.38k
    PtrDiffType = IsX32 ? 
SignedInt2
:
SignedLong1.37k
;
681
1.38k
    IntPtrType = IsX32 ? 
SignedInt2
:
SignedLong1.37k
;
682
1.38k
    IntMaxType = IsX32 ? 
SignedLongLong2
:
SignedLong1.37k
;
683
1.38k
    Int64Type = IsX32 ? 
SignedLongLong2
:
SignedLong1.37k
;
684
1.38k
    RegParmMax = 6;
685
686
    // Pointers are 32-bit in x32.
687
1.38k
    resetDataLayout(IsX32 ? "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-"
688
2
                            "i64:64-f80:128-n8:16:32:64-S128"
689
1.38k
                          : 
IsWinCOFF1.37k
? "e-m:w-p270:32:32-p271:32:32-p272:64:"
690
0
                                        "64-i64:64-f80:128-n8:16:32:64-S128"
691
1.37k
                                      : "e-m:e-p270:32:32-p271:32:32-p272:64:"
692
1.37k
                                        "64-i64:64-f80:128-n8:16:32:64-S128");
693
694
    // Use fpret only for long double.
695
1.38k
    RealTypeUsesObjCFPRet = (1 << TargetInfo::LongDouble);
696
697
    // Use fp2ret for _Complex long double.
698
1.38k
    ComplexLongDoubleUsesFP2Ret = true;
699
700
    // Make __builtin_ms_va_list available.
701
1.38k
    HasBuiltinMSVaList = true;
702
703
    // x86-64 has atomics up to 16 bytes.
704
1.38k
    MaxAtomicPromoteWidth = 128;
705
1.38k
    MaxAtomicInlineWidth = 64;
706
1.38k
  }
707
708
64.3k
  BuiltinVaListKind getBuiltinVaListKind() const override {
709
64.3k
    return TargetInfo::X86_64ABIBuiltinVaList;
710
64.3k
  }
711
712
0
  int getEHDataRegisterNumber(unsigned RegNo) const override {
713
0
    if (RegNo == 0)
714
0
      return 0;
715
0
    if (RegNo == 1)
716
0
      return 1;
717
0
    return -1;
718
0
  }
719
720
466k
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
721
466k
    switch (CC) {
722
95
    case CC_C:
723
457
    case CC_Swift:
724
465k
    case CC_SwiftAsync:
725
465k
    case CC_X86VectorCall:
726
465k
    case CC_IntelOclBicc:
727
465k
    case CC_Win64:
728
465k
    case CC_PreserveMost:
729
465k
    case CC_PreserveAll:
730
465k
    case CC_X86RegCall:
731
465k
    case CC_OpenCLKernel:
732
465k
      return CCCR_OK;
733
116
    default:
734
116
      return CCCR_Warning;
735
466k
    }
736
466k
  }
737
738
7.64M
  CallingConv getDefaultCallingConv() const override {
739
7.64M
    return CC_C;
740
7.64M
  }
741
742
  // for x32 we need it here explicitly
743
339k
  bool hasInt128Type() const override { return true; }
744
745
7
  unsigned getUnwindWordWidth() const override { return 64; }
746
747
1
  unsigned getRegisterWidth() const override { return 64; }
748
749
  bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
750
31
                                      bool &HasSizeMismatch) const override {
751
    // rsp and rbp are the only 64-bit registers the x86 backend can currently
752
    // handle.
753
31
    if (RegName.equals("rsp") || 
RegName.equals("rbp")28
) {
754
      // Check that the register size is 64-bit.
755
3
      HasSizeMismatch = RegSize != 64;
756
3
      return true;
757
3
    }
758
759
    // Check if the register is a 32-bit register the backend can handle.
760
28
    return X86TargetInfo::validateGlobalRegisterVariable(RegName, RegSize,
761
28
                                                         HasSizeMismatch);
762
31
  }
763
764
80.9k
  void setMaxAtomicWidth() override {
765
80.9k
    if (hasFeature("cx16"))
766
16.5k
      MaxAtomicInlineWidth = 128;
767
80.9k
  }
768
769
  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
770
771
490
  bool hasExtIntType() const override { return true; }
772
};
773
774
// x86-64 Windows target
775
class LLVM_LIBRARY_VISIBILITY WindowsX86_64TargetInfo
776
    : public WindowsTargetInfo<X86_64TargetInfo> {
777
public:
778
  WindowsX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
779
7.78k
      : WindowsTargetInfo<X86_64TargetInfo>(Triple, Opts) {
780
7.78k
    LongWidth = LongAlign = 32;
781
7.78k
    DoubleAlign = LongLongAlign = 64;
782
7.78k
    IntMaxType = SignedLongLong;
783
7.78k
    Int64Type = SignedLongLong;
784
7.78k
    SizeType = UnsignedLongLong;
785
7.78k
    PtrDiffType = SignedLongLong;
786
7.78k
    IntPtrType = SignedLongLong;
787
7.78k
  }
788
789
7.72k
  BuiltinVaListKind getBuiltinVaListKind() const override {
790
7.72k
    return TargetInfo::CharPtrBuiltinVaList;
791
7.72k
  }
792
793
2.08k
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
794
2.08k
    switch (CC) {
795
69
    case CC_X86StdCall:
796
75
    case CC_X86ThisCall:
797
145
    case CC_X86FastCall:
798
145
      return CCCR_Ignore;
799
95
    case CC_C:
800
183
    case CC_X86VectorCall:
801
183
    case CC_IntelOclBicc:
802
194
    case CC_PreserveMost:
803
199
    case CC_PreserveAll:
804
216
    case CC_X86_64SysV:
805
279
    case CC_Swift:
806
1.91k
    case CC_SwiftAsync:
807
1.94k
    case CC_X86RegCall:
808
1.94k
    case CC_OpenCLKernel:
809
1.94k
      return CCCR_OK;
810
0
    default:
811
0
      return CCCR_Warning;
812
2.08k
    }
813
2.08k
  }
814
};
815
816
// x86-64 Windows Visual Studio target
817
class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64TargetInfo
818
    : public WindowsX86_64TargetInfo {
819
public:
820
  MicrosoftX86_64TargetInfo(const llvm::Triple &Triple,
821
                            const TargetOptions &Opts)
822
7.72k
      : WindowsX86_64TargetInfo(Triple, Opts) {
823
7.72k
    LongDoubleWidth = LongDoubleAlign = 64;
824
7.72k
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
825
7.72k
  }
clang::targets::MicrosoftX86_64TargetInfo::MicrosoftX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
822
7.72k
      : WindowsX86_64TargetInfo(Triple, Opts) {
823
7.72k
    LongDoubleWidth = LongDoubleAlign = 64;
824
7.72k
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
825
7.72k
  }
Unexecuted instantiation: clang::targets::MicrosoftX86_64TargetInfo::MicrosoftX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
826
827
  void getTargetDefines(const LangOptions &Opts,
828
7.72k
                        MacroBuilder &Builder) const override {
829
7.72k
    WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
830
7.72k
    Builder.defineMacro("_M_X64", "100");
831
7.72k
    Builder.defineMacro("_M_AMD64", "100");
832
7.72k
  }
833
834
  TargetInfo::CallingConvKind
835
8.94k
  getCallingConvKind(bool ClangABICompat4) const override {
836
8.94k
    return CCK_MicrosoftWin64;
837
8.94k
  }
838
};
839
840
// x86-64 MinGW target
841
class LLVM_LIBRARY_VISIBILITY MinGWX86_64TargetInfo
842
    : public WindowsX86_64TargetInfo {
843
public:
844
  MinGWX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
845
53
      : WindowsX86_64TargetInfo(Triple, Opts) {
846
    // Mingw64 rounds long double size and alignment up to 16 bytes, but sticks
847
    // with x86 FP ops. Weird.
848
53
    LongDoubleWidth = LongDoubleAlign = 128;
849
53
    LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
850
53
    HasFloat128 = true;
851
53
  }
clang::targets::MinGWX86_64TargetInfo::MinGWX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
845
53
      : WindowsX86_64TargetInfo(Triple, Opts) {
846
    // Mingw64 rounds long double size and alignment up to 16 bytes, but sticks
847
    // with x86 FP ops. Weird.
848
53
    LongDoubleWidth = LongDoubleAlign = 128;
849
53
    LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
850
53
    HasFloat128 = true;
851
53
  }
Unexecuted instantiation: clang::targets::MinGWX86_64TargetInfo::MinGWX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
852
};
853
854
// x86-64 Cygwin target
855
class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo {
856
public:
857
  CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
858
3
      : X86_64TargetInfo(Triple, Opts) {
859
3
    this->WCharType = TargetInfo::UnsignedShort;
860
3
    TLSSupported = false;
861
3
  }
clang::targets::CygwinX86_64TargetInfo::CygwinX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
858
3
      : X86_64TargetInfo(Triple, Opts) {
859
3
    this->WCharType = TargetInfo::UnsignedShort;
860
3
    TLSSupported = false;
861
3
  }
Unexecuted instantiation: clang::targets::CygwinX86_64TargetInfo::CygwinX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
862
863
  void getTargetDefines(const LangOptions &Opts,
864
3
                        MacroBuilder &Builder) const override {
865
3
    X86_64TargetInfo::getTargetDefines(Opts, Builder);
866
3
    Builder.defineMacro("__x86_64__");
867
3
    Builder.defineMacro("__CYGWIN__");
868
3
    Builder.defineMacro("__CYGWIN64__");
869
3
    addCygMingDefines(Opts, Builder);
870
3
    DefineStd(Builder, "unix", Opts);
871
3
    if (Opts.CPlusPlus)
872
0
      Builder.defineMacro("_GNU_SOURCE");
873
3
  }
874
};
875
876
class LLVM_LIBRARY_VISIBILITY DarwinX86_64TargetInfo
877
    : public DarwinTargetInfo<X86_64TargetInfo> {
878
public:
879
  DarwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
880
68.2k
      : DarwinTargetInfo<X86_64TargetInfo>(Triple, Opts) {
881
68.2k
    Int64Type = SignedLongLong;
882
    // The 64-bit iOS simulator uses the builtin bool type for Objective-C.
883
68.2k
    llvm::Triple T = llvm::Triple(Triple);
884
68.2k
    if (T.isiOS())
885
83
      UseSignedCharForObjCBool = false;
886
68.2k
    resetDataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:"
887
68.2k
                    "16:32:64-S128", "_");
888
68.2k
  }
clang::targets::DarwinX86_64TargetInfo::DarwinX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
880
68.2k
      : DarwinTargetInfo<X86_64TargetInfo>(Triple, Opts) {
881
68.2k
    Int64Type = SignedLongLong;
882
    // The 64-bit iOS simulator uses the builtin bool type for Objective-C.
883
68.2k
    llvm::Triple T = llvm::Triple(Triple);
884
68.2k
    if (T.isiOS())
885
83
      UseSignedCharForObjCBool = false;
886
68.2k
    resetDataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:"
887
68.2k
                    "16:32:64-S128", "_");
888
68.2k
  }
Unexecuted instantiation: clang::targets::DarwinX86_64TargetInfo::DarwinX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
889
890
  bool handleTargetFeatures(std::vector<std::string> &Features,
891
68.2k
                            DiagnosticsEngine &Diags) override {
892
68.2k
    if (!DarwinTargetInfo<X86_64TargetInfo>::handleTargetFeatures(Features,
893
68.2k
                                                                  Diags))
894
0
      return false;
895
    // We now know the features we have: we can decide how to align vectors.
896
68.2k
    MaxVectorAlign =
897
68.2k
        hasFeature("avx512f") ? 
51253
:
hasFeature("avx")68.1k
?
25627
:
12868.1k
;
898
68.2k
    return true;
899
68.2k
  }
900
};
901
902
class LLVM_LIBRARY_VISIBILITY OpenBSDX86_64TargetInfo
903
    : public OpenBSDTargetInfo<X86_64TargetInfo> {
904
public:
905
  OpenBSDX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
906
7
      : OpenBSDTargetInfo<X86_64TargetInfo>(Triple, Opts) {
907
7
    IntMaxType = SignedLongLong;
908
7
    Int64Type = SignedLongLong;
909
7
  }
clang::targets::OpenBSDX86_64TargetInfo::OpenBSDX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
906
7
      : OpenBSDTargetInfo<X86_64TargetInfo>(Triple, Opts) {
907
7
    IntMaxType = SignedLongLong;
908
7
    Int64Type = SignedLongLong;
909
7
  }
Unexecuted instantiation: clang::targets::OpenBSDX86_64TargetInfo::OpenBSDX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
910
};
911
912
// x86_32 Android target
913
class LLVM_LIBRARY_VISIBILITY AndroidX86_32TargetInfo
914
    : public LinuxTargetInfo<X86_32TargetInfo> {
915
public:
916
  AndroidX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
917
4
      : LinuxTargetInfo<X86_32TargetInfo>(Triple, Opts) {
918
4
    SuitableAlign = 32;
919
4
    LongDoubleWidth = 64;
920
4
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
921
4
  }
clang::targets::AndroidX86_32TargetInfo::AndroidX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
917
4
      : LinuxTargetInfo<X86_32TargetInfo>(Triple, Opts) {
918
4
    SuitableAlign = 32;
919
4
    LongDoubleWidth = 64;
920
4
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
921
4
  }
Unexecuted instantiation: clang::targets::AndroidX86_32TargetInfo::AndroidX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
922
};
923
924
// x86_64 Android target
925
class LLVM_LIBRARY_VISIBILITY AndroidX86_64TargetInfo
926
    : public LinuxTargetInfo<X86_64TargetInfo> {
927
public:
928
  AndroidX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
929
5
      : LinuxTargetInfo<X86_64TargetInfo>(Triple, Opts) {
930
5
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
931
5
  }
clang::targets::AndroidX86_64TargetInfo::AndroidX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
929
5
      : LinuxTargetInfo<X86_64TargetInfo>(Triple, Opts) {
930
5
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
931
5
  }
Unexecuted instantiation: clang::targets::AndroidX86_64TargetInfo::AndroidX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
932
};
933
} // namespace targets
934
} // namespace clang
935
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_X86_H