Coverage Report

Created: 2020-09-22 08:39

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