Coverage Report

Created: 2022-01-25 06:29

/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
  bool HasX87 = false;
148
149
protected:
150
  llvm::X86::CPUKind CPU = llvm::X86::CK_None;
151
152
  enum FPMathKind { FP_Default, FP_SSE, FP_387 } FPMath = FP_Default;
153
154
public:
155
  X86TargetInfo(const llvm::Triple &Triple, const TargetOptions &)
156
85.7k
      : TargetInfo(Triple) {
157
85.7k
    LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
158
85.7k
    AddrSpaceMap = &X86AddrSpaceMap;
159
85.7k
    HasStrictFP = true;
160
161
85.7k
    bool IsWinCOFF =
162
85.7k
        getTriple().isOSWindows() && 
getTriple().isOSBinFormatCOFF()8.81k
;
163
85.7k
    if (IsWinCOFF)
164
8.81k
      MaxVectorAlign = MaxTLSAlign = 8192u * getCharWidth();
165
85.7k
  }
166
167
86.6k
  const char *getLongDoubleMangling() const override {
168
86.6k
    return LongDoubleFormat == &llvm::APFloat::IEEEquad() ? 
"g"14
:
"e"86.6k
;
169
86.6k
  }
170
171
77.5k
  unsigned getFloatEvalMethod() const override {
172
    // X87 evaluates with 80 bits "long double" precision.
173
77.5k
    return SSELevel == NoSSE ? 
24.56k
:
073.0k
;
174
77.5k
  }
175
176
  ArrayRef<const char *> getGCCRegNames() const override;
177
178
2.29k
  ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override {
179
2.29k
    return None;
180
2.29k
  }
181
182
  ArrayRef<TargetInfo::AddlRegName> getGCCAddlRegNames() const override;
183
184
2
  bool isSPRegName(StringRef RegName) const override {
185
2
    return RegName.equals("esp") || RegName.equals("rsp");
186
2
  }
187
188
  bool validateCpuSupports(StringRef Name) const override;
189
190
  bool validateCpuIs(StringRef Name) const override;
191
192
  bool validateCPUSpecificCPUDispatch(StringRef Name) const override;
193
194
  char CPUSpecificManglingCharacter(StringRef Name) const override;
195
196
  void getCPUSpecificCPUDispatchFeatures(
197
      StringRef Name,
198
      llvm::SmallVectorImpl<StringRef> &Features) const override;
199
200
  Optional<unsigned> getCPUCacheLineSize() const override;
201
202
  bool validateAsmConstraint(const char *&Name,
203
                             TargetInfo::ConstraintInfo &info) const override;
204
205
  bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
206
34
                                      bool &HasSizeMismatch) const override {
207
    // esp and ebp are the only 32-bit registers the x86 backend can currently
208
    // handle.
209
34
    if (RegName.equals("esp") || 
RegName.equals("ebp")1
) {
210
      // Check that the register size is 32-bit.
211
33
      HasSizeMismatch = RegSize != 32;
212
33
      return true;
213
33
    }
214
215
1
    return false;
216
34
  }
217
218
  bool validateOutputSize(const llvm::StringMap<bool> &FeatureMap,
219
                          StringRef Constraint, unsigned Size) const override;
220
221
  bool validateInputSize(const llvm::StringMap<bool> &FeatureMap,
222
                         StringRef Constraint, unsigned Size) const override;
223
224
  virtual bool
225
0
  checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override {
226
0
    return true;
227
0
  };
228
229
  virtual bool
230
4
  checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const override {
231
4
    return true;
232
4
  };
233
234
  virtual bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap,
235
                                   StringRef Constraint, unsigned Size) const;
236
237
  std::string convertConstraint(const char *&Constraint) const override;
238
908
  const char *getClobbers() const override {
239
908
    return "~{dirflag},~{fpsr},~{flags}";
240
908
  }
241
242
  StringRef getConstraintRegister(StringRef Constraint,
243
11.4k
                                  StringRef Expression) const override {
244
11.4k
    StringRef::iterator I, E;
245
17.3k
    for (I = Constraint.begin(), E = Constraint.end(); I != E; 
++I5.84k
) {
246
17.1k
      if (isalpha(*I) || 
*I == '@'5.86k
)
247
11.3k
        break;
248
17.1k
    }
249
11.4k
    if (I == E)
250
151
      return "";
251
11.3k
    switch (*I) {
252
    // For the register constraints, return the matching register name
253
2.61k
    case 'a':
254
2.61k
      return "ax";
255
2.17k
    case 'b':
256
2.17k
      return "bx";
257
2.32k
    case 'c':
258
2.32k
      return "cx";
259
2.22k
    case 'd':
260
2.22k
      return "dx";
261
44
    case 'S':
262
44
      return "si";
263
108
    case 'D':
264
108
      return "di";
265
    // In case the constraint is 'r' we need to return Expression
266
1.03k
    case 'r':
267
1.03k
      return Expression;
268
    // Double letters Y<x> constraints
269
26
    case 'Y':
270
26
      if ((++I != E) && ((*I == '0') || (*I == 'z')))
271
10
        return "xmm0";
272
16
      break;
273
786
    default:
274
786
      break;
275
11.3k
    }
276
802
    return "";
277
11.3k
  }
278
279
4.62M
  bool useFP16ConversionIntrinsics() const override {
280
4.62M
    return false;
281
4.62M
  }
282
283
  void getTargetDefines(const LangOptions &Opts,
284
                        MacroBuilder &Builder) const override;
285
286
  void setFeatureEnabled(llvm::StringMap<bool> &Features, StringRef Name,
287
                         bool Enabled) const final;
288
289
  bool
290
  initFeatureMap(llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags,
291
                 StringRef CPU,
292
                 const std::vector<std::string> &FeaturesVec) const override;
293
294
  bool isValidFeatureName(StringRef Name) const override;
295
296
  bool hasFeature(StringRef Feature) const final;
297
298
  bool handleTargetFeatures(std::vector<std::string> &Features,
299
                            DiagnosticsEngine &Diags) override;
300
301
166k
  StringRef getABI() const override {
302
166k
    if (getTriple().getArch() == llvm::Triple::x86_64 && 
SSELevel >= AVX512F156k
)
303
265
      return "avx512";
304
165k
    if (getTriple().getArch() == llvm::Triple::x86_64 && 
SSELevel >= AVX156k
)
305
151
      return "avx";
306
165k
    if (getTriple().getArch() == llvm::Triple::x86 &&
307
165k
        
MMX3DNowLevel == NoMMX3DNow9.43k
)
308
9.35k
      return "no-mmx";
309
156k
    return "";
310
165k
  }
311
312
1.14M
  bool supportsTargetAttributeTune() const override {
313
1.14M
    return true;
314
1.14M
  }
315
316
524
  bool isValidCPUName(StringRef Name) const override {
317
524
    bool Only64Bit = getTriple().getArch() != llvm::Triple::x86;
318
524
    return llvm::X86::parseArchX86(Name, Only64Bit) != llvm::X86::CK_None;
319
524
  }
320
321
35.6k
  bool isValidTuneCPUName(StringRef Name) const override {
322
35.6k
    if (Name == "generic")
323
35.6k
      return true;
324
325
    // Allow 32-bit only CPUs regardless of 64-bit mode unlike isValidCPUName.
326
    // NOTE: gcc rejects 32-bit mtune CPUs in 64-bit mode. But being lenient
327
    // since mtune was ignored by clang for so long.
328
4
    return llvm::X86::parseTuneCPU(Name) != llvm::X86::CK_None;
329
35.6k
  }
330
331
  void fillValidCPUList(SmallVectorImpl<StringRef> &Values) const override;
332
  void fillValidTuneCPUList(SmallVectorImpl<StringRef> &Values) const override;
333
334
35.9k
  bool setCPU(const std::string &Name) override {
335
35.9k
    bool Only64Bit = getTriple().getArch() != llvm::Triple::x86;
336
35.9k
    CPU = llvm::X86::parseArchX86(Name, Only64Bit);
337
35.9k
    return CPU != llvm::X86::CK_None;
338
35.9k
  }
339
340
  unsigned multiVersionSortPriority(StringRef Name) const override;
341
342
  bool setFPMath(StringRef Name) override;
343
344
31
  bool supportsExtendIntArgs() const override {
345
31
    return getTriple().getArch() != llvm::Triple::x86;
346
31
  }
347
348
7.22k
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
349
    // Most of the non-ARM calling conventions are i386 conventions.
350
7.22k
    switch (CC) {
351
67
    case CC_X86ThisCall:
352
240
    case CC_X86FastCall:
353
462
    case CC_X86StdCall:
354
570
    case CC_X86VectorCall:
355
632
    case CC_X86RegCall:
356
891
    case CC_C:
357
897
    case CC_PreserveMost:
358
903
    case CC_Swift:
359
917
    case CC_X86Pascal:
360
920
    case CC_IntelOclBicc:
361
920
    case CC_OpenCLKernel:
362
920
      return CCCR_OK;
363
6.29k
    case CC_SwiftAsync:
364
6.29k
      return CCCR_Error;
365
10
    default:
366
10
      return CCCR_Warning;
367
7.22k
    }
368
7.22k
  }
369
370
59
  bool checkArithmeticFenceSupported() const override { return true; }
371
372
590k
  CallingConv getDefaultCallingConv() const override {
373
590k
    return CC_C;
374
590k
  }
375
376
8
  bool hasSjLjLowering() const override { return true; }
377
378
85.6k
  void setSupportedOpenCLOpts() override { supportAllOpenCLOpts(); }
379
380
323
  uint64_t getPointerWidthV(unsigned AddrSpace) const override {
381
323
    if (AddrSpace == ptr32_sptr || 
AddrSpace == ptr32_uptr317
)
382
14
      return 32;
383
309
    if (AddrSpace == ptr64)
384
4
      return 64;
385
305
    return PointerWidth;
386
309
  }
387
388
160
  uint64_t getPointerAlignV(unsigned AddrSpace) const override {
389
160
    return getPointerWidthV(AddrSpace);
390
160
  }
391
};
392
393
// X86-32 generic target
394
class LLVM_LIBRARY_VISIBILITY X86_32TargetInfo : public X86TargetInfo {
395
public:
396
  X86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
397
14.6k
      : X86TargetInfo(Triple, Opts) {
398
14.6k
    DoubleAlign = LongLongAlign = 32;
399
14.6k
    LongDoubleWidth = 96;
400
14.6k
    LongDoubleAlign = 32;
401
14.6k
    SuitableAlign = 128;
402
14.6k
    resetDataLayout(
403
14.6k
        Triple.isOSBinFormatMachO()
404
14.6k
            ? "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
405
395
              "f80:32-n8:16:32-S128"
406
14.6k
            : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
407
14.2k
              "f80:32-n8:16:32-S128",
408
14.6k
        Triple.isOSBinFormatMachO() ? 
"_"395
:
""14.2k
);
409
14.6k
    SizeType = UnsignedInt;
410
14.6k
    PtrDiffType = SignedInt;
411
14.6k
    IntPtrType = SignedInt;
412
14.6k
    RegParmMax = 3;
413
414
    // Use fpret for all types.
415
14.6k
    RealTypeUsesObjCFPRet =
416
14.6k
        ((1 << (int)FloatModeKind::Float) | (1 << (int)FloatModeKind::Double) |
417
14.6k
         (1 << (int)FloatModeKind::LongDouble));
418
419
    // x86-32 has atomics up to 8 bytes
420
14.6k
    MaxAtomicPromoteWidth = 64;
421
14.6k
    MaxAtomicInlineWidth = 32;
422
14.6k
  }
clang::targets::X86_32TargetInfo::X86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
397
1.55k
      : X86TargetInfo(Triple, Opts) {
398
1.55k
    DoubleAlign = LongLongAlign = 32;
399
1.55k
    LongDoubleWidth = 96;
400
1.55k
    LongDoubleAlign = 32;
401
1.55k
    SuitableAlign = 128;
402
1.55k
    resetDataLayout(
403
1.55k
        Triple.isOSBinFormatMachO()
404
1.55k
            ? "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
405
394
              "f80:32-n8:16:32-S128"
406
1.55k
            : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
407
1.15k
              "f80:32-n8:16:32-S128",
408
1.55k
        Triple.isOSBinFormatMachO() ? 
"_"394
:
""1.15k
);
409
1.55k
    SizeType = UnsignedInt;
410
1.55k
    PtrDiffType = SignedInt;
411
1.55k
    IntPtrType = SignedInt;
412
1.55k
    RegParmMax = 3;
413
414
    // Use fpret for all types.
415
1.55k
    RealTypeUsesObjCFPRet =
416
1.55k
        ((1 << (int)FloatModeKind::Float) | (1 << (int)FloatModeKind::Double) |
417
1.55k
         (1 << (int)FloatModeKind::LongDouble));
418
419
    // x86-32 has atomics up to 8 bytes
420
1.55k
    MaxAtomicPromoteWidth = 64;
421
1.55k
    MaxAtomicInlineWidth = 32;
422
1.55k
  }
clang::targets::X86_32TargetInfo::X86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
397
13.0k
      : X86TargetInfo(Triple, Opts) {
398
13.0k
    DoubleAlign = LongLongAlign = 32;
399
13.0k
    LongDoubleWidth = 96;
400
13.0k
    LongDoubleAlign = 32;
401
13.0k
    SuitableAlign = 128;
402
13.0k
    resetDataLayout(
403
13.0k
        Triple.isOSBinFormatMachO()
404
13.0k
            ? "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
405
1
              "f80:32-n8:16:32-S128"
406
13.0k
            : "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
407
13.0k
              "f80:32-n8:16:32-S128",
408
13.0k
        Triple.isOSBinFormatMachO() ? 
"_"1
:
""13.0k
);
409
13.0k
    SizeType = UnsignedInt;
410
13.0k
    PtrDiffType = SignedInt;
411
13.0k
    IntPtrType = SignedInt;
412
13.0k
    RegParmMax = 3;
413
414
    // Use fpret for all types.
415
13.0k
    RealTypeUsesObjCFPRet =
416
13.0k
        ((1 << (int)FloatModeKind::Float) | (1 << (int)FloatModeKind::Double) |
417
13.0k
         (1 << (int)FloatModeKind::LongDouble));
418
419
    // x86-32 has atomics up to 8 bytes
420
13.0k
    MaxAtomicPromoteWidth = 64;
421
13.0k
    MaxAtomicInlineWidth = 32;
422
13.0k
  }
423
424
14.4k
  BuiltinVaListKind getBuiltinVaListKind() const override {
425
14.4k
    return TargetInfo::CharPtrBuiltinVaList;
426
14.4k
  }
427
428
2
  int getEHDataRegisterNumber(unsigned RegNo) const override {
429
2
    if (RegNo == 0)
430
2
      return 0;
431
0
    if (RegNo == 1)
432
0
      return 2;
433
0
    return -1;
434
0
  }
435
436
  bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap,
437
3.02k
                           StringRef Constraint, unsigned Size) const override {
438
3.02k
    switch (Constraint[0]) {
439
773
    default:
440
773
      break;
441
773
    case 'R':
442
13
    case 'q':
443
19
    case 'Q':
444
637
    case 'a':
445
1.12k
    case 'b':
446
1.67k
    case 'c':
447
2.17k
    case 'd':
448
2.18k
    case 'S':
449
2.24k
    case 'D':
450
2.24k
      return Size <= 32;
451
6
    case 'A':
452
6
      return Size <= 64;
453
3.02k
    }
454
455
773
    return X86TargetInfo::validateOperandSize(FeatureMap, Constraint, Size);
456
3.02k
  }
457
458
14.6k
  void setMaxAtomicWidth() override {
459
14.6k
    if (hasFeature("cx8"))
460
14.5k
      MaxAtomicInlineWidth = 64;
461
14.6k
  }
462
463
  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
464
465
314
  bool hasBitIntType() const override { return true; }
466
};
467
468
class LLVM_LIBRARY_VISIBILITY NetBSDI386TargetInfo
469
    : public NetBSDTargetInfo<X86_32TargetInfo> {
470
public:
471
  NetBSDI386TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
472
7
      : NetBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
clang::targets::NetBSDI386TargetInfo::NetBSDI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
472
7
      : NetBSDTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
Unexecuted instantiation: clang::targets::NetBSDI386TargetInfo::NetBSDI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
473
474
7
  unsigned getFloatEvalMethod() const override {
475
7
    VersionTuple OsVersion = getTriple().getOSVersion();
476
    // New NetBSD uses the default rounding mode.
477
7
    if (OsVersion >= VersionTuple(6, 99, 26) || OsVersion.getMajor() == 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
394
      : DarwinTargetInfo<X86_32TargetInfo>(Triple, Opts) {
500
394
    LongDoubleWidth = 128;
501
394
    LongDoubleAlign = 128;
502
394
    SuitableAlign = 128;
503
394
    MaxVectorAlign = 256;
504
    // The watchOS simulator uses the builtin bool type for Objective-C.
505
394
    llvm::Triple T = llvm::Triple(Triple);
506
394
    if (T.isWatchOS())
507
13
      UseSignedCharForObjCBool = false;
508
394
    SizeType = UnsignedLong;
509
394
    IntPtrType = SignedLong;
510
394
    resetDataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
511
394
                    "f80:128-n8:16:32-S128", "_");
512
394
    HasAlignMac68kSupport = true;
513
394
  }
clang::targets::DarwinI386TargetInfo::DarwinI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
499
394
      : DarwinTargetInfo<X86_32TargetInfo>(Triple, Opts) {
500
394
    LongDoubleWidth = 128;
501
394
    LongDoubleAlign = 128;
502
394
    SuitableAlign = 128;
503
394
    MaxVectorAlign = 256;
504
    // The watchOS simulator uses the builtin bool type for Objective-C.
505
394
    llvm::Triple T = llvm::Triple(Triple);
506
394
    if (T.isWatchOS())
507
13
      UseSignedCharForObjCBool = false;
508
394
    SizeType = UnsignedLong;
509
394
    IntPtrType = SignedLong;
510
394
    resetDataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-"
511
394
                    "f80:128-n8:16:32-S128", "_");
512
394
    HasAlignMac68kSupport = true;
513
394
  }
Unexecuted instantiation: clang::targets::DarwinI386TargetInfo::DarwinI386TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
514
515
  bool handleTargetFeatures(std::vector<std::string> &Features,
516
392
                            DiagnosticsEngine &Diags) override {
517
392
    if (!DarwinTargetInfo<X86_32TargetInfo>::handleTargetFeatures(Features,
518
392
                                                                  Diags))
519
0
      return false;
520
    // We now know the features we have: we can decide how to align vectors.
521
392
    MaxVectorAlign =
522
392
        hasFeature("avx512f") ? 
5121
:
hasFeature("avx")391
?
2562
:
128389
;
523
392
    return true;
524
392
  }
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
670
      : WindowsTargetInfo<X86_32TargetInfo>(Triple, Opts) {
533
670
    DoubleAlign = LongLongAlign = 64;
534
670
    bool IsWinCOFF =
535
670
        getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
536
670
    bool IsMSVC = getTriple().isWindowsMSVCEnvironment();
537
670
    std::string Layout = IsWinCOFF ? 
"e-m:x"668
:
"e-m:e"2
;
538
670
    Layout += "-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-";
539
670
    Layout += IsMSVC ? 
"f80:128"536
:
"f80:32"134
;
540
670
    Layout += "-n8:16:32-a:0:32-S32";
541
670
    resetDataLayout(Layout, IsWinCOFF ? 
"_"668
:
""2
);
542
670
  }
543
};
544
545
// x86-32 Windows Visual Studio target
546
class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32TargetInfo
547
    : public WindowsX86_32TargetInfo {
548
public:
549
  MicrosoftX86_32TargetInfo(const llvm::Triple &Triple,
550
                            const TargetOptions &Opts)
551
558
      : WindowsX86_32TargetInfo(Triple, Opts) {
552
558
    LongDoubleWidth = LongDoubleAlign = 64;
553
558
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
554
558
  }
clang::targets::MicrosoftX86_32TargetInfo::MicrosoftX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
551
558
      : WindowsX86_32TargetInfo(Triple, Opts) {
552
558
    LongDoubleWidth = LongDoubleAlign = 64;
553
558
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
554
558
  }
Unexecuted instantiation: clang::targets::MicrosoftX86_32TargetInfo::MicrosoftX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
555
556
  void getTargetDefines(const LangOptions &Opts,
557
553
                        MacroBuilder &Builder) const override {
558
553
    WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
559
    // The value of the following reflects processor type.
560
    // 300=386, 400=486, 500=Pentium, 600=Blend (default)
561
    // We lost the original triple, so we use the default.
562
553
    Builder.defineMacro("_M_IX86", "600");
563
553
  }
564
};
565
566
// x86-32 MinGW target
567
class LLVM_LIBRARY_VISIBILITY MinGWX86_32TargetInfo
568
    : public WindowsX86_32TargetInfo {
569
public:
570
  MinGWX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
571
112
      : WindowsX86_32TargetInfo(Triple, Opts) {
572
112
    HasFloat128 = true;
573
112
  }
clang::targets::MinGWX86_32TargetInfo::MinGWX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
571
112
      : WindowsX86_32TargetInfo(Triple, Opts) {
572
112
    HasFloat128 = true;
573
112
  }
Unexecuted instantiation: clang::targets::MinGWX86_32TargetInfo::MinGWX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
574
575
  void getTargetDefines(const LangOptions &Opts,
576
112
                        MacroBuilder &Builder) const override {
577
112
    WindowsX86_32TargetInfo::getTargetDefines(Opts, Builder);
578
112
    Builder.defineMacro("_X86_");
579
112
  }
580
};
581
582
// x86-32 Cygwin target
583
class LLVM_LIBRARY_VISIBILITY CygwinX86_32TargetInfo : public X86_32TargetInfo {
584
public:
585
  CygwinX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
586
11
      : X86_32TargetInfo(Triple, Opts) {
587
11
    this->WCharType = TargetInfo::UnsignedShort;
588
11
    DoubleAlign = LongLongAlign = 64;
589
11
    resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:"
590
11
                    "32-n8:16:32-a:0:32-S32",
591
11
                    "_");
592
11
  }
clang::targets::CygwinX86_32TargetInfo::CygwinX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
586
11
      : X86_32TargetInfo(Triple, Opts) {
587
11
    this->WCharType = TargetInfo::UnsignedShort;
588
11
    DoubleAlign = LongLongAlign = 64;
589
11
    resetDataLayout("e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:"
590
11
                    "32-n8:16:32-a:0:32-S32",
591
11
                    "_");
592
11
  }
Unexecuted instantiation: clang::targets::CygwinX86_32TargetInfo::CygwinX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
593
594
  void getTargetDefines(const LangOptions &Opts,
595
11
                        MacroBuilder &Builder) const override {
596
11
    X86_32TargetInfo::getTargetDefines(Opts, Builder);
597
11
    Builder.defineMacro("_X86_");
598
11
    Builder.defineMacro("__CYGWIN__");
599
11
    Builder.defineMacro("__CYGWIN32__");
600
11
    addCygMingDefines(Opts, Builder);
601
11
    DefineStd(Builder, "unix", Opts);
602
11
    if (Opts.CPlusPlus)
603
5
      Builder.defineMacro("_GNU_SOURCE");
604
11
  }
605
};
606
607
// x86-32 Haiku target
608
class LLVM_LIBRARY_VISIBILITY HaikuX86_32TargetInfo
609
    : public HaikuTargetInfo<X86_32TargetInfo> {
610
public:
611
  HaikuX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
612
3
      : HaikuTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
clang::targets::HaikuX86_32TargetInfo::HaikuX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
612
3
      : HaikuTargetInfo<X86_32TargetInfo>(Triple, Opts) {}
Unexecuted instantiation: clang::targets::HaikuX86_32TargetInfo::HaikuX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
613
614
  void getTargetDefines(const LangOptions &Opts,
615
3
                        MacroBuilder &Builder) const override {
616
3
    HaikuTargetInfo<X86_32TargetInfo>::getTargetDefines(Opts, Builder);
617
3
    Builder.defineMacro("__INTEL__");
618
3
  }
619
};
620
621
// X86-32 MCU target
622
class LLVM_LIBRARY_VISIBILITY MCUX86_32TargetInfo : public X86_32TargetInfo {
623
public:
624
  MCUX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
625
6
      : X86_32TargetInfo(Triple, Opts) {
626
6
    LongDoubleWidth = 64;
627
6
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
628
6
    resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:32-f64:"
629
6
                    "32-f128:32-n8:16:32-a:0:32-S32");
630
6
    WIntType = UnsignedInt;
631
6
  }
clang::targets::MCUX86_32TargetInfo::MCUX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
625
6
      : X86_32TargetInfo(Triple, Opts) {
626
6
    LongDoubleWidth = 64;
627
6
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
628
6
    resetDataLayout("e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:32-f64:"
629
6
                    "32-f128:32-n8:16:32-a:0:32-S32");
630
6
    WIntType = UnsignedInt;
631
6
  }
Unexecuted instantiation: clang::targets::MCUX86_32TargetInfo::MCUX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
632
633
17
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
634
    // On MCU we support only C calling convention.
635
17
    return CC == CC_C ? 
CCCR_OK4
:
CCCR_Warning13
;
636
17
  }
637
638
  void getTargetDefines(const LangOptions &Opts,
639
6
                        MacroBuilder &Builder) const override {
640
6
    X86_32TargetInfo::getTargetDefines(Opts, Builder);
641
6
    Builder.defineMacro("__iamcu");
642
6
    Builder.defineMacro("__iamcu__");
643
6
  }
644
645
67
  bool allowsLargerPreferedTypeAlignment() const override { return false; }
646
};
647
648
// x86-32 RTEMS target
649
class LLVM_LIBRARY_VISIBILITY RTEMSX86_32TargetInfo : public X86_32TargetInfo {
650
public:
651
  RTEMSX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
652
0
      : X86_32TargetInfo(Triple, Opts) {
653
0
    SizeType = UnsignedLong;
654
0
    IntPtrType = SignedLong;
655
0
    PtrDiffType = SignedLong;
656
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&)
657
658
  void getTargetDefines(const LangOptions &Opts,
659
0
                        MacroBuilder &Builder) const override {
660
0
    X86_32TargetInfo::getTargetDefines(Opts, Builder);
661
0
    Builder.defineMacro("__INTEL__");
662
0
    Builder.defineMacro("__rtems__");
663
0
  }
664
};
665
666
// x86-64 generic target
667
class LLVM_LIBRARY_VISIBILITY X86_64TargetInfo : public X86TargetInfo {
668
public:
669
  X86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
670
71.0k
      : X86TargetInfo(Triple, Opts) {
671
71.0k
    const bool IsX32 = getTriple().isX32();
672
71.0k
    bool IsWinCOFF =
673
71.0k
        getTriple().isOSWindows() && 
getTriple().isOSBinFormatCOFF()8.13k
;
674
71.0k
    LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 
3210
:
6471.0k
;
675
71.0k
    LongDoubleWidth = 128;
676
71.0k
    LongDoubleAlign = 128;
677
71.0k
    LargeArrayMinWidth = 128;
678
71.0k
    LargeArrayAlign = 128;
679
71.0k
    SuitableAlign = 128;
680
71.0k
    SizeType = IsX32 ? 
UnsignedInt10
:
UnsignedLong71.0k
;
681
71.0k
    PtrDiffType = IsX32 ? 
SignedInt10
:
SignedLong71.0k
;
682
71.0k
    IntPtrType = IsX32 ? 
SignedInt10
:
SignedLong71.0k
;
683
71.0k
    IntMaxType = IsX32 ? 
SignedLongLong10
:
SignedLong71.0k
;
684
71.0k
    Int64Type = IsX32 ? 
SignedLongLong10
:
SignedLong71.0k
;
685
71.0k
    RegParmMax = 6;
686
687
    // Pointers are 32-bit in x32.
688
71.0k
    resetDataLayout(IsX32 ? "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-"
689
10
                            "i64:64-f80:128-n8:16:32:64-S128"
690
71.0k
                          : 
IsWinCOFF71.0k
? "e-m:w-p270:32:32-p271:32:32-p272:64:"
691
8.13k
                                        "64-i64:64-f80:128-n8:16:32:64-S128"
692
71.0k
                                      : "e-m:e-p270:32:32-p271:32:32-p272:64:"
693
62.9k
                                        "64-i64:64-f80:128-n8:16:32:64-S128");
694
695
    // Use fpret only for long double.
696
71.0k
    RealTypeUsesObjCFPRet = (1 << (int)FloatModeKind::LongDouble);
697
698
    // Use fp2ret for _Complex long double.
699
71.0k
    ComplexLongDoubleUsesFP2Ret = true;
700
701
    // Make __builtin_ms_va_list available.
702
71.0k
    HasBuiltinMSVaList = true;
703
704
    // x86-64 has atomics up to 16 bytes.
705
71.0k
    MaxAtomicPromoteWidth = 128;
706
71.0k
    MaxAtomicInlineWidth = 64;
707
71.0k
  }
clang::targets::X86_64TargetInfo::X86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
670
69.6k
      : X86TargetInfo(Triple, Opts) {
671
69.6k
    const bool IsX32 = getTriple().isX32();
672
69.6k
    bool IsWinCOFF =
673
69.6k
        getTriple().isOSWindows() && 
getTriple().isOSBinFormatCOFF()8.13k
;
674
69.6k
    LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 
328
:
6469.6k
;
675
69.6k
    LongDoubleWidth = 128;
676
69.6k
    LongDoubleAlign = 128;
677
69.6k
    LargeArrayMinWidth = 128;
678
69.6k
    LargeArrayAlign = 128;
679
69.6k
    SuitableAlign = 128;
680
69.6k
    SizeType = IsX32 ? 
UnsignedInt8
:
UnsignedLong69.6k
;
681
69.6k
    PtrDiffType = IsX32 ? 
SignedInt8
:
SignedLong69.6k
;
682
69.6k
    IntPtrType = IsX32 ? 
SignedInt8
:
SignedLong69.6k
;
683
69.6k
    IntMaxType = IsX32 ? 
SignedLongLong8
:
SignedLong69.6k
;
684
69.6k
    Int64Type = IsX32 ? 
SignedLongLong8
:
SignedLong69.6k
;
685
69.6k
    RegParmMax = 6;
686
687
    // Pointers are 32-bit in x32.
688
69.6k
    resetDataLayout(IsX32 ? "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-"
689
8
                            "i64:64-f80:128-n8:16:32:64-S128"
690
69.6k
                          : 
IsWinCOFF69.6k
? "e-m:w-p270:32:32-p271:32:32-p272:64:"
691
8.13k
                                        "64-i64:64-f80:128-n8:16:32:64-S128"
692
69.6k
                                      : "e-m:e-p270:32:32-p271:32:32-p272:64:"
693
61.5k
                                        "64-i64:64-f80:128-n8:16:32:64-S128");
694
695
    // Use fpret only for long double.
696
69.6k
    RealTypeUsesObjCFPRet = (1 << (int)FloatModeKind::LongDouble);
697
698
    // Use fp2ret for _Complex long double.
699
69.6k
    ComplexLongDoubleUsesFP2Ret = true;
700
701
    // Make __builtin_ms_va_list available.
702
69.6k
    HasBuiltinMSVaList = true;
703
704
    // x86-64 has atomics up to 16 bytes.
705
69.6k
    MaxAtomicPromoteWidth = 128;
706
69.6k
    MaxAtomicInlineWidth = 64;
707
69.6k
  }
clang::targets::X86_64TargetInfo::X86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
670
1.40k
      : X86TargetInfo(Triple, Opts) {
671
1.40k
    const bool IsX32 = getTriple().isX32();
672
1.40k
    bool IsWinCOFF =
673
1.40k
        getTriple().isOSWindows() && 
getTriple().isOSBinFormatCOFF()0
;
674
1.40k
    LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 
322
:
641.39k
;
675
1.40k
    LongDoubleWidth = 128;
676
1.40k
    LongDoubleAlign = 128;
677
1.40k
    LargeArrayMinWidth = 128;
678
1.40k
    LargeArrayAlign = 128;
679
1.40k
    SuitableAlign = 128;
680
1.40k
    SizeType = IsX32 ? 
UnsignedInt2
:
UnsignedLong1.39k
;
681
1.40k
    PtrDiffType = IsX32 ? 
SignedInt2
:
SignedLong1.39k
;
682
1.40k
    IntPtrType = IsX32 ? 
SignedInt2
:
SignedLong1.39k
;
683
1.40k
    IntMaxType = IsX32 ? 
SignedLongLong2
:
SignedLong1.39k
;
684
1.40k
    Int64Type = IsX32 ? 
SignedLongLong2
:
SignedLong1.39k
;
685
1.40k
    RegParmMax = 6;
686
687
    // Pointers are 32-bit in x32.
688
1.40k
    resetDataLayout(IsX32 ? "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-"
689
2
                            "i64:64-f80:128-n8:16:32:64-S128"
690
1.40k
                          : 
IsWinCOFF1.39k
? "e-m:w-p270:32:32-p271:32:32-p272:64:"
691
0
                                        "64-i64:64-f80:128-n8:16:32:64-S128"
692
1.39k
                                      : "e-m:e-p270:32:32-p271:32:32-p272:64:"
693
1.39k
                                        "64-i64:64-f80:128-n8:16:32:64-S128");
694
695
    // Use fpret only for long double.
696
1.40k
    RealTypeUsesObjCFPRet = (1 << (int)FloatModeKind::LongDouble);
697
698
    // Use fp2ret for _Complex long double.
699
1.40k
    ComplexLongDoubleUsesFP2Ret = true;
700
701
    // Make __builtin_ms_va_list available.
702
1.40k
    HasBuiltinMSVaList = true;
703
704
    // x86-64 has atomics up to 16 bytes.
705
1.40k
    MaxAtomicPromoteWidth = 128;
706
1.40k
    MaxAtomicInlineWidth = 64;
707
1.40k
  }
708
709
54.1k
  BuiltinVaListKind getBuiltinVaListKind() const override {
710
54.1k
    return TargetInfo::X86_64ABIBuiltinVaList;
711
54.1k
  }
712
713
0
  int getEHDataRegisterNumber(unsigned RegNo) const override {
714
0
    if (RegNo == 0)
715
0
      return 0;
716
0
    if (RegNo == 1)
717
0
      return 1;
718
0
    return -1;
719
0
  }
720
721
467k
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
722
467k
    switch (CC) {
723
100
    case CC_C:
724
462
    case CC_Swift:
725
466k
    case CC_SwiftAsync:
726
466k
    case CC_X86VectorCall:
727
466k
    case CC_IntelOclBicc:
728
466k
    case CC_Win64:
729
466k
    case CC_PreserveMost:
730
466k
    case CC_PreserveAll:
731
466k
    case CC_X86RegCall:
732
466k
    case CC_OpenCLKernel:
733
466k
      return CCCR_OK;
734
127
    default:
735
127
      return CCCR_Warning;
736
467k
    }
737
467k
  }
738
739
7.92M
  CallingConv getDefaultCallingConv() const override {
740
7.92M
    return CC_C;
741
7.92M
  }
742
743
  // for x32 we need it here explicitly
744
310k
  bool hasInt128Type() const override { return true; }
745
746
7
  unsigned getUnwindWordWidth() const override { return 64; }
747
748
1
  unsigned getRegisterWidth() const override { return 64; }
749
750
  bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize,
751
30
                                      bool &HasSizeMismatch) const override {
752
    // rsp and rbp are the only 64-bit registers the x86 backend can currently
753
    // handle.
754
30
    if (RegName.equals("rsp") || 
RegName.equals("rbp")28
) {
755
      // Check that the register size is 64-bit.
756
2
      HasSizeMismatch = RegSize != 64;
757
2
      return true;
758
2
    }
759
760
    // Check if the register is a 32-bit register the backend can handle.
761
28
    return X86TargetInfo::validateGlobalRegisterVariable(RegName, RegSize,
762
28
                                                         HasSizeMismatch);
763
30
  }
764
765
71.0k
  void setMaxAtomicWidth() override {
766
71.0k
    if (hasFeature("cx16"))
767
16.9k
      MaxAtomicInlineWidth = 128;
768
71.0k
  }
769
770
  ArrayRef<Builtin::Info> getTargetBuiltins() const override;
771
772
506
  bool hasBitIntType() const override { return true; }
773
};
774
775
// x86-64 Windows target
776
class LLVM_LIBRARY_VISIBILITY WindowsX86_64TargetInfo
777
    : public WindowsTargetInfo<X86_64TargetInfo> {
778
public:
779
  WindowsX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
780
8.12k
      : WindowsTargetInfo<X86_64TargetInfo>(Triple, Opts) {
781
8.12k
    LongWidth = LongAlign = 32;
782
8.12k
    DoubleAlign = LongLongAlign = 64;
783
8.12k
    IntMaxType = SignedLongLong;
784
8.12k
    Int64Type = SignedLongLong;
785
8.12k
    SizeType = UnsignedLongLong;
786
8.12k
    PtrDiffType = SignedLongLong;
787
8.12k
    IntPtrType = SignedLongLong;
788
8.12k
  }
789
790
8.06k
  BuiltinVaListKind getBuiltinVaListKind() const override {
791
8.06k
    return TargetInfo::CharPtrBuiltinVaList;
792
8.06k
  }
793
794
2.23k
  CallingConvCheckResult checkCallingConvention(CallingConv CC) const override {
795
2.23k
    switch (CC) {
796
77
    case CC_X86StdCall:
797
83
    case CC_X86ThisCall:
798
161
    case CC_X86FastCall:
799
161
      return CCCR_Ignore;
800
111
    case CC_C:
801
207
    case CC_X86VectorCall:
802
207
    case CC_IntelOclBicc:
803
218
    case CC_PreserveMost:
804
223
    case CC_PreserveAll:
805
240
    case CC_X86_64SysV:
806
303
    case CC_Swift:
807
2.04k
    case CC_SwiftAsync:
808
2.07k
    case CC_X86RegCall:
809
2.07k
    case CC_OpenCLKernel:
810
2.07k
      return CCCR_OK;
811
0
    default:
812
0
      return CCCR_Warning;
813
2.23k
    }
814
2.23k
  }
815
};
816
817
// x86-64 Windows Visual Studio target
818
class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64TargetInfo
819
    : public WindowsX86_64TargetInfo {
820
public:
821
  MicrosoftX86_64TargetInfo(const llvm::Triple &Triple,
822
                            const TargetOptions &Opts)
823
8.07k
      : WindowsX86_64TargetInfo(Triple, Opts) {
824
8.07k
    LongDoubleWidth = LongDoubleAlign = 64;
825
8.07k
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
826
8.07k
  }
clang::targets::MicrosoftX86_64TargetInfo::MicrosoftX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
823
8.07k
      : WindowsX86_64TargetInfo(Triple, Opts) {
824
8.07k
    LongDoubleWidth = LongDoubleAlign = 64;
825
8.07k
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
826
8.07k
  }
Unexecuted instantiation: clang::targets::MicrosoftX86_64TargetInfo::MicrosoftX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
827
828
  void getTargetDefines(const LangOptions &Opts,
829
8.07k
                        MacroBuilder &Builder) const override {
830
8.07k
    WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
831
8.07k
    Builder.defineMacro("_M_X64", "100");
832
8.07k
    Builder.defineMacro("_M_AMD64", "100");
833
8.07k
  }
834
835
  TargetInfo::CallingConvKind
836
9.16k
  getCallingConvKind(bool ClangABICompat4) const override {
837
9.16k
    return CCK_MicrosoftWin64;
838
9.16k
  }
839
};
840
841
// x86-64 MinGW target
842
class LLVM_LIBRARY_VISIBILITY MinGWX86_64TargetInfo
843
    : public WindowsX86_64TargetInfo {
844
public:
845
  MinGWX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
846
52
      : WindowsX86_64TargetInfo(Triple, Opts) {
847
    // Mingw64 rounds long double size and alignment up to 16 bytes, but sticks
848
    // with x86 FP ops. Weird.
849
52
    LongDoubleWidth = LongDoubleAlign = 128;
850
52
    LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
851
52
    HasFloat128 = true;
852
52
  }
clang::targets::MinGWX86_64TargetInfo::MinGWX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
846
52
      : WindowsX86_64TargetInfo(Triple, Opts) {
847
    // Mingw64 rounds long double size and alignment up to 16 bytes, but sticks
848
    // with x86 FP ops. Weird.
849
52
    LongDoubleWidth = LongDoubleAlign = 128;
850
52
    LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
851
52
    HasFloat128 = true;
852
52
  }
Unexecuted instantiation: clang::targets::MinGWX86_64TargetInfo::MinGWX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
853
};
854
855
// x86-64 Cygwin target
856
class LLVM_LIBRARY_VISIBILITY CygwinX86_64TargetInfo : public X86_64TargetInfo {
857
public:
858
  CygwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
859
3
      : X86_64TargetInfo(Triple, Opts) {
860
3
    this->WCharType = TargetInfo::UnsignedShort;
861
3
    TLSSupported = false;
862
3
  }
clang::targets::CygwinX86_64TargetInfo::CygwinX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
859
3
      : X86_64TargetInfo(Triple, Opts) {
860
3
    this->WCharType = TargetInfo::UnsignedShort;
861
3
    TLSSupported = false;
862
3
  }
Unexecuted instantiation: clang::targets::CygwinX86_64TargetInfo::CygwinX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
863
864
  void getTargetDefines(const LangOptions &Opts,
865
3
                        MacroBuilder &Builder) const override {
866
3
    X86_64TargetInfo::getTargetDefines(Opts, Builder);
867
3
    Builder.defineMacro("__x86_64__");
868
3
    Builder.defineMacro("__CYGWIN__");
869
3
    Builder.defineMacro("__CYGWIN64__");
870
3
    addCygMingDefines(Opts, Builder);
871
3
    DefineStd(Builder, "unix", Opts);
872
3
    if (Opts.CPlusPlus)
873
0
      Builder.defineMacro("_GNU_SOURCE");
874
3
  }
875
};
876
877
class LLVM_LIBRARY_VISIBILITY DarwinX86_64TargetInfo
878
    : public DarwinTargetInfo<X86_64TargetInfo> {
879
public:
880
  DarwinX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
881
57.9k
      : DarwinTargetInfo<X86_64TargetInfo>(Triple, Opts) {
882
57.9k
    Int64Type = SignedLongLong;
883
    // The 64-bit iOS simulator uses the builtin bool type for Objective-C.
884
57.9k
    llvm::Triple T = llvm::Triple(Triple);
885
57.9k
    if (T.isiOS())
886
93
      UseSignedCharForObjCBool = false;
887
57.9k
    resetDataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:"
888
57.9k
                    "16:32:64-S128", "_");
889
57.9k
  }
clang::targets::DarwinX86_64TargetInfo::DarwinX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
881
57.9k
      : DarwinTargetInfo<X86_64TargetInfo>(Triple, Opts) {
882
57.9k
    Int64Type = SignedLongLong;
883
    // The 64-bit iOS simulator uses the builtin bool type for Objective-C.
884
57.9k
    llvm::Triple T = llvm::Triple(Triple);
885
57.9k
    if (T.isiOS())
886
93
      UseSignedCharForObjCBool = false;
887
57.9k
    resetDataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:"
888
57.9k
                    "16:32:64-S128", "_");
889
57.9k
  }
Unexecuted instantiation: clang::targets::DarwinX86_64TargetInfo::DarwinX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
890
891
  bool handleTargetFeatures(std::vector<std::string> &Features,
892
57.9k
                            DiagnosticsEngine &Diags) override {
893
57.9k
    if (!DarwinTargetInfo<X86_64TargetInfo>::handleTargetFeatures(Features,
894
57.9k
                                                                  Diags))
895
0
      return false;
896
    // We now know the features we have: we can decide how to align vectors.
897
57.9k
    MaxVectorAlign =
898
57.9k
        hasFeature("avx512f") ? 
51253
:
hasFeature("avx")57.9k
?
25627
:
12857.8k
;
899
57.9k
    return true;
900
57.9k
  }
901
};
902
903
class LLVM_LIBRARY_VISIBILITY OpenBSDX86_64TargetInfo
904
    : public OpenBSDTargetInfo<X86_64TargetInfo> {
905
public:
906
  OpenBSDX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
907
7
      : OpenBSDTargetInfo<X86_64TargetInfo>(Triple, Opts) {
908
7
    IntMaxType = SignedLongLong;
909
7
    Int64Type = SignedLongLong;
910
7
  }
clang::targets::OpenBSDX86_64TargetInfo::OpenBSDX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
907
7
      : OpenBSDTargetInfo<X86_64TargetInfo>(Triple, Opts) {
908
7
    IntMaxType = SignedLongLong;
909
7
    Int64Type = SignedLongLong;
910
7
  }
Unexecuted instantiation: clang::targets::OpenBSDX86_64TargetInfo::OpenBSDX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
911
};
912
913
// x86_32 Android target
914
class LLVM_LIBRARY_VISIBILITY AndroidX86_32TargetInfo
915
    : public LinuxTargetInfo<X86_32TargetInfo> {
916
public:
917
  AndroidX86_32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
918
4
      : LinuxTargetInfo<X86_32TargetInfo>(Triple, Opts) {
919
4
    SuitableAlign = 32;
920
4
    LongDoubleWidth = 64;
921
4
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
922
4
  }
clang::targets::AndroidX86_32TargetInfo::AndroidX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
918
4
      : LinuxTargetInfo<X86_32TargetInfo>(Triple, Opts) {
919
4
    SuitableAlign = 32;
920
4
    LongDoubleWidth = 64;
921
4
    LongDoubleFormat = &llvm::APFloat::IEEEdouble();
922
4
  }
Unexecuted instantiation: clang::targets::AndroidX86_32TargetInfo::AndroidX86_32TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
923
};
924
925
// x86_64 Android target
926
class LLVM_LIBRARY_VISIBILITY AndroidX86_64TargetInfo
927
    : public LinuxTargetInfo<X86_64TargetInfo> {
928
public:
929
  AndroidX86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
930
6
      : LinuxTargetInfo<X86_64TargetInfo>(Triple, Opts) {
931
6
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
932
6
  }
clang::targets::AndroidX86_64TargetInfo::AndroidX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
Line
Count
Source
930
6
      : LinuxTargetInfo<X86_64TargetInfo>(Triple, Opts) {
931
6
    LongDoubleFormat = &llvm::APFloat::IEEEquad();
932
6
  }
Unexecuted instantiation: clang::targets::AndroidX86_64TargetInfo::AndroidX86_64TargetInfo(llvm::Triple const&, clang::TargetOptions const&)
933
};
934
} // namespace targets
935
} // namespace clang
936
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_X86_H