Coverage Report

Created: 2022-07-16 07:03

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