Coverage Report

Created: 2022-05-14 11:35

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