18 #include "llvm/ADT/StringRef.h" 19 #include "llvm/ADT/StringSwitch.h" 25 #define BUILTIN(ID, TYPE, ATTRS) \ 26 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 27 #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ 28 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE}, 29 #define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ 30 {#ID, TYPE, ATTRS, HEADER, LANGS, FEATURE}, 31 #include "clang/Basic/BuiltinsX86.def" 33 #define BUILTIN(ID, TYPE, ATTRS) \ 34 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, 35 #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ 36 {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE}, 37 #define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ 38 {#ID, TYPE, ATTRS, HEADER, LANGS, FEATURE}, 39 #include "clang/Basic/BuiltinsX86_64.def" 43 "ax",
"dx",
"cx",
"bx",
"si",
"di",
"bp",
"sp",
44 "st",
"st(1)",
"st(2)",
"st(3)",
"st(4)",
"st(5)",
"st(6)",
"st(7)",
45 "argp",
"flags",
"fpcr",
"fpsr",
"dirflag",
"frame",
"xmm0",
"xmm1",
46 "xmm2",
"xmm3",
"xmm4",
"xmm5",
"xmm6",
"xmm7",
"mm0",
"mm1",
47 "mm2",
"mm3",
"mm4",
"mm5",
"mm6",
"mm7",
"r8",
"r9",
48 "r10",
"r11",
"r12",
"r13",
"r14",
"r15",
"xmm8",
"xmm9",
49 "xmm10",
"xmm11",
"xmm12",
"xmm13",
"xmm14",
"xmm15",
"ymm0",
"ymm1",
50 "ymm2",
"ymm3",
"ymm4",
"ymm5",
"ymm6",
"ymm7",
"ymm8",
"ymm9",
51 "ymm10",
"ymm11",
"ymm12",
"ymm13",
"ymm14",
"ymm15",
"xmm16",
"xmm17",
52 "xmm18",
"xmm19",
"xmm20",
"xmm21",
"xmm22",
"xmm23",
"xmm24",
"xmm25",
53 "xmm26",
"xmm27",
"xmm28",
"xmm29",
"xmm30",
"xmm31",
"ymm16",
"ymm17",
54 "ymm18",
"ymm19",
"ymm20",
"ymm21",
"ymm22",
"ymm23",
"ymm24",
"ymm25",
55 "ymm26",
"ymm27",
"ymm28",
"ymm29",
"ymm30",
"ymm31",
"zmm0",
"zmm1",
56 "zmm2",
"zmm3",
"zmm4",
"zmm5",
"zmm6",
"zmm7",
"zmm8",
"zmm9",
57 "zmm10",
"zmm11",
"zmm12",
"zmm13",
"zmm14",
"zmm15",
"zmm16",
"zmm17",
58 "zmm18",
"zmm19",
"zmm20",
"zmm21",
"zmm22",
"zmm23",
"zmm24",
"zmm25",
59 "zmm26",
"zmm27",
"zmm28",
"zmm29",
"zmm30",
"zmm31",
"k0",
"k1",
60 "k2",
"k3",
"k4",
"k5",
"k6",
"k7",
61 "cr0",
"cr2",
"cr3",
"cr4",
"cr8",
62 "dr0",
"dr1",
"dr2",
"dr3",
"dr6",
"dr7",
63 "bnd0",
"bnd1",
"bnd2",
"bnd3",
67 {{
"al",
"ah",
"eax",
"rax"}, 0},
68 {{
"bl",
"bh",
"ebx",
"rbx"}, 3},
69 {{
"cl",
"ch",
"ecx",
"rcx"}, 2},
70 {{
"dl",
"dh",
"edx",
"rdx"}, 1},
75 {{
"r8d",
"r8w",
"r8b"}, 38},
76 {{
"r9d",
"r9w",
"r9b"}, 39},
77 {{
"r10d",
"r10w",
"r10b"}, 40},
78 {{
"r11d",
"r11w",
"r11b"}, 41},
79 {{
"r12d",
"r12w",
"r12b"}, 42},
80 {{
"r13d",
"r13w",
"r13b"}, 43},
81 {{
"r14d",
"r14w",
"r14b"}, 44},
82 {{
"r15d",
"r15w",
"r15b"}, 45},
88 using namespace clang;
105 const std::vector<std::string> &FeaturesVec)
const {
108 if (getTriple().getArch() == llvm::Triple::x86_64)
109 setFeatureEnabledImpl(Features,
"sse2",
true);
111 const CPUKind
Kind = getCPUKind(CPU);
114 if (Kind != CK_Lakemont)
115 setFeatureEnabledImpl(Features,
"x87",
true);
131 setFeatureEnabledImpl(Features,
"mmx",
true);
135 setFeatureEnabledImpl(Features,
"vaes",
true);
136 setFeatureEnabledImpl(Features,
"gfni",
true);
137 setFeatureEnabledImpl(Features,
"vpclmulqdq",
true);
138 setFeatureEnabledImpl(Features,
"avx512bitalg",
true);
139 setFeatureEnabledImpl(Features,
"avx512vnni",
true);
140 setFeatureEnabledImpl(Features,
"avx512vbmi2",
true);
141 setFeatureEnabledImpl(Features,
"avx512vpopcntdq",
true);
144 setFeatureEnabledImpl(Features,
"avx512ifma",
true);
145 setFeatureEnabledImpl(Features,
"avx512vbmi",
true);
146 setFeatureEnabledImpl(Features,
"sha",
true);
148 case CK_SkylakeServer:
149 setFeatureEnabledImpl(Features,
"avx512f",
true);
150 setFeatureEnabledImpl(Features,
"avx512cd",
true);
151 setFeatureEnabledImpl(Features,
"avx512dq",
true);
152 setFeatureEnabledImpl(Features,
"avx512bw",
true);
153 setFeatureEnabledImpl(Features,
"avx512vl",
true);
154 setFeatureEnabledImpl(Features,
"pku",
true);
155 if (Kind != CK_Cannonlake)
156 setFeatureEnabledImpl(Features,
"clwb",
true);
158 case CK_SkylakeClient:
159 setFeatureEnabledImpl(Features,
"xsavec",
true);
160 setFeatureEnabledImpl(Features,
"xsaves",
true);
161 setFeatureEnabledImpl(Features,
"mpx",
true);
162 setFeatureEnabledImpl(Features,
"sgx",
true);
163 setFeatureEnabledImpl(Features,
"clflushopt",
true);
164 setFeatureEnabledImpl(Features,
"rtm",
true);
167 setFeatureEnabledImpl(Features,
"rdseed",
true);
168 setFeatureEnabledImpl(Features,
"adx",
true);
169 setFeatureEnabledImpl(Features,
"prfchw",
true);
172 setFeatureEnabledImpl(Features,
"avx2",
true);
173 setFeatureEnabledImpl(Features,
"lzcnt",
true);
174 setFeatureEnabledImpl(Features,
"bmi",
true);
175 setFeatureEnabledImpl(Features,
"bmi2",
true);
176 setFeatureEnabledImpl(Features,
"fma",
true);
177 setFeatureEnabledImpl(Features,
"movbe",
true);
180 setFeatureEnabledImpl(Features,
"rdrnd",
true);
181 setFeatureEnabledImpl(Features,
"f16c",
true);
182 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
185 setFeatureEnabledImpl(Features,
"avx",
true);
186 setFeatureEnabledImpl(Features,
"xsave",
true);
187 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
190 setFeatureEnabledImpl(Features,
"aes",
true);
191 setFeatureEnabledImpl(Features,
"pclmul",
true);
194 setFeatureEnabledImpl(Features,
"sse4.2",
true);
197 setFeatureEnabledImpl(Features,
"sse4.1",
true);
200 setFeatureEnabledImpl(Features,
"ssse3",
true);
205 setFeatureEnabledImpl(Features,
"sse3",
true);
206 setFeatureEnabledImpl(Features,
"cx16",
true);
211 setFeatureEnabledImpl(Features,
"sse2",
true);
215 setFeatureEnabledImpl(Features,
"sse",
true);
216 setFeatureEnabledImpl(Features,
"fxsr",
true);
220 setFeatureEnabledImpl(Features,
"sha",
true);
221 setFeatureEnabledImpl(Features,
"rdrnd",
true);
222 setFeatureEnabledImpl(Features,
"rdseed",
true);
223 setFeatureEnabledImpl(Features,
"xsave",
true);
224 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
225 setFeatureEnabledImpl(Features,
"xsavec",
true);
226 setFeatureEnabledImpl(Features,
"xsaves",
true);
227 setFeatureEnabledImpl(Features,
"clflushopt",
true);
228 setFeatureEnabledImpl(Features,
"mpx",
true);
229 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
232 setFeatureEnabledImpl(Features,
"aes",
true);
233 setFeatureEnabledImpl(Features,
"pclmul",
true);
234 setFeatureEnabledImpl(Features,
"sse4.2",
true);
235 setFeatureEnabledImpl(Features,
"prfchw",
true);
238 setFeatureEnabledImpl(Features,
"movbe",
true);
239 setFeatureEnabledImpl(Features,
"ssse3",
true);
240 setFeatureEnabledImpl(Features,
"fxsr",
true);
241 setFeatureEnabledImpl(Features,
"cx16",
true);
246 setFeatureEnabledImpl(Features,
"avx512vpopcntdq",
true);
249 setFeatureEnabledImpl(Features,
"avx512f",
true);
250 setFeatureEnabledImpl(Features,
"avx512cd",
true);
251 setFeatureEnabledImpl(Features,
"avx512er",
true);
252 setFeatureEnabledImpl(Features,
"avx512pf",
true);
253 setFeatureEnabledImpl(Features,
"prfchw",
true);
254 setFeatureEnabledImpl(Features,
"prefetchwt1",
true);
255 setFeatureEnabledImpl(Features,
"fxsr",
true);
256 setFeatureEnabledImpl(Features,
"rdseed",
true);
257 setFeatureEnabledImpl(Features,
"adx",
true);
258 setFeatureEnabledImpl(Features,
"lzcnt",
true);
259 setFeatureEnabledImpl(Features,
"bmi",
true);
260 setFeatureEnabledImpl(Features,
"bmi2",
true);
261 setFeatureEnabledImpl(Features,
"rtm",
true);
262 setFeatureEnabledImpl(Features,
"fma",
true);
263 setFeatureEnabledImpl(Features,
"rdrnd",
true);
264 setFeatureEnabledImpl(Features,
"f16c",
true);
265 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
266 setFeatureEnabledImpl(Features,
"aes",
true);
267 setFeatureEnabledImpl(Features,
"pclmul",
true);
268 setFeatureEnabledImpl(Features,
"cx16",
true);
269 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
270 setFeatureEnabledImpl(Features,
"xsave",
true);
271 setFeatureEnabledImpl(Features,
"movbe",
true);
278 setFeatureEnabledImpl(Features,
"3dnow",
true);
282 setFeatureEnabledImpl(Features,
"sse4a",
true);
283 setFeatureEnabledImpl(Features,
"lzcnt",
true);
284 setFeatureEnabledImpl(Features,
"popcnt",
true);
287 setFeatureEnabledImpl(Features,
"sse3",
true);
290 setFeatureEnabledImpl(Features,
"sse2",
true);
293 setFeatureEnabledImpl(Features,
"sse",
true);
294 setFeatureEnabledImpl(Features,
"fxsr",
true);
298 setFeatureEnabledImpl(Features,
"3dnowa",
true);
302 setFeatureEnabledImpl(Features,
"avx",
true);
303 setFeatureEnabledImpl(Features,
"aes",
true);
304 setFeatureEnabledImpl(Features,
"pclmul",
true);
305 setFeatureEnabledImpl(Features,
"bmi",
true);
306 setFeatureEnabledImpl(Features,
"f16c",
true);
307 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
308 setFeatureEnabledImpl(Features,
"movbe",
true);
311 setFeatureEnabledImpl(Features,
"ssse3",
true);
312 setFeatureEnabledImpl(Features,
"sse4a",
true);
313 setFeatureEnabledImpl(Features,
"lzcnt",
true);
314 setFeatureEnabledImpl(Features,
"popcnt",
true);
315 setFeatureEnabledImpl(Features,
"prfchw",
true);
316 setFeatureEnabledImpl(Features,
"cx16",
true);
317 setFeatureEnabledImpl(Features,
"fxsr",
true);
321 setFeatureEnabledImpl(Features,
"adx",
true);
322 setFeatureEnabledImpl(Features,
"aes",
true);
323 setFeatureEnabledImpl(Features,
"avx2",
true);
324 setFeatureEnabledImpl(Features,
"bmi",
true);
325 setFeatureEnabledImpl(Features,
"bmi2",
true);
326 setFeatureEnabledImpl(Features,
"clflushopt",
true);
327 setFeatureEnabledImpl(Features,
"clzero",
true);
328 setFeatureEnabledImpl(Features,
"cx16",
true);
329 setFeatureEnabledImpl(Features,
"f16c",
true);
330 setFeatureEnabledImpl(Features,
"fma",
true);
331 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
332 setFeatureEnabledImpl(Features,
"fxsr",
true);
333 setFeatureEnabledImpl(Features,
"lzcnt",
true);
334 setFeatureEnabledImpl(Features,
"mwaitx",
true);
335 setFeatureEnabledImpl(Features,
"movbe",
true);
336 setFeatureEnabledImpl(Features,
"pclmul",
true);
337 setFeatureEnabledImpl(Features,
"popcnt",
true);
338 setFeatureEnabledImpl(Features,
"prfchw",
true);
339 setFeatureEnabledImpl(Features,
"rdrnd",
true);
340 setFeatureEnabledImpl(Features,
"rdseed",
true);
341 setFeatureEnabledImpl(Features,
"sha",
true);
342 setFeatureEnabledImpl(Features,
"sse4a",
true);
343 setFeatureEnabledImpl(Features,
"xsave",
true);
344 setFeatureEnabledImpl(Features,
"xsavec",
true);
345 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
346 setFeatureEnabledImpl(Features,
"xsaves",
true);
350 setFeatureEnabledImpl(Features,
"avx2",
true);
351 setFeatureEnabledImpl(Features,
"bmi2",
true);
352 setFeatureEnabledImpl(Features,
"mwaitx",
true);
355 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
356 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
359 setFeatureEnabledImpl(Features,
"bmi",
true);
360 setFeatureEnabledImpl(Features,
"fma",
true);
361 setFeatureEnabledImpl(Features,
"f16c",
true);
362 setFeatureEnabledImpl(Features,
"tbm",
true);
366 setFeatureEnabledImpl(Features,
"xop",
true);
367 setFeatureEnabledImpl(Features,
"lwp",
true);
368 setFeatureEnabledImpl(Features,
"lzcnt",
true);
369 setFeatureEnabledImpl(Features,
"aes",
true);
370 setFeatureEnabledImpl(Features,
"pclmul",
true);
371 setFeatureEnabledImpl(Features,
"prfchw",
true);
372 setFeatureEnabledImpl(Features,
"cx16",
true);
373 setFeatureEnabledImpl(Features,
"fxsr",
true);
374 setFeatureEnabledImpl(Features,
"xsave",
true);
384 auto I = Features.find(
"sse4.2");
385 if (I != Features.end() && I->getValue() &&
386 std::find(FeaturesVec.begin(), FeaturesVec.end(),
"-popcnt") ==
388 Features[
"popcnt"] =
true;
391 I = Features.find(
"3dnow");
392 if (I != Features.end() && I->getValue() &&
393 std::find(FeaturesVec.begin(), FeaturesVec.end(),
"-prfchw") ==
395 Features[
"prfchw"] =
true;
399 I = Features.find(
"sse");
400 if (I != Features.end() && I->getValue() &&
401 std::find(FeaturesVec.begin(), FeaturesVec.end(),
"-mmx") ==
403 Features[
"mmx"] =
true;
409 X86SSEEnum
Level,
bool Enabled) {
413 Features[
"avx512f"] = Features[
"fma"] = Features[
"f16c"] =
true;
416 Features[
"avx2"] =
true;
419 Features[
"avx"] =
true;
420 Features[
"xsave"] =
true;
423 Features[
"sse4.2"] =
true;
426 Features[
"sse4.1"] =
true;
429 Features[
"ssse3"] =
true;
432 Features[
"sse3"] =
true;
435 Features[
"sse2"] =
true;
438 Features[
"sse"] =
true;
449 Features[
"sse"] =
false;
452 Features[
"sse2"] = Features[
"pclmul"] = Features[
"aes"] = Features[
"sha"] =
453 Features[
"gfni"] =
false;
456 Features[
"sse3"] =
false;
457 setXOPLevel(Features, NoXOP,
false);
460 Features[
"ssse3"] =
false;
463 Features[
"sse4.1"] =
false;
466 Features[
"sse4.2"] =
false;
469 Features[
"fma"] = Features[
"avx"] = Features[
"f16c"] = Features[
"xsave"] =
470 Features[
"xsaveopt"] = Features[
"vaes"] = Features[
"vpclmulqdq"] =
false;
471 setXOPLevel(Features, FMA4,
false);
474 Features[
"avx2"] =
false;
477 Features[
"avx512f"] = Features[
"avx512cd"] = Features[
"avx512er"] =
478 Features[
"avx512pf"] = Features[
"avx512dq"] = Features[
"avx512bw"] =
479 Features[
"avx512vl"] = Features[
"avx512vbmi"] =
480 Features[
"avx512ifma"] = Features[
"avx512vpopcntdq"] =
481 Features[
"avx512bitalg"] = Features[
"avx512vnni"] =
482 Features[
"avx512vbmi2"] =
false;
488 MMX3DNowEnum
Level,
bool Enabled) {
492 Features[
"3dnowa"] =
true;
495 Features[
"3dnow"] =
true;
498 Features[
"mmx"] =
true;
509 Features[
"mmx"] =
false;
512 Features[
"3dnow"] =
false;
515 Features[
"3dnowa"] =
false;
525 Features[
"xop"] =
true;
528 Features[
"fma4"] =
true;
529 setSSELevel(Features, AVX,
true);
532 Features[
"sse4a"] =
true;
533 setSSELevel(Features, SSE3,
true);
544 Features[
"sse4a"] =
false;
547 Features[
"fma4"] =
false;
550 Features[
"xop"] =
false;
556 StringRef Name,
bool Enabled) {
561 Features[Name] = Enabled;
564 setMMXLevel(Features, MMX, Enabled);
565 }
else if (Name ==
"sse") {
566 setSSELevel(Features, SSE1, Enabled);
567 }
else if (Name ==
"sse2") {
568 setSSELevel(Features, SSE2, Enabled);
569 }
else if (Name ==
"sse3") {
570 setSSELevel(Features, SSE3, Enabled);
571 }
else if (Name ==
"ssse3") {
572 setSSELevel(Features, SSSE3, Enabled);
573 }
else if (Name ==
"sse4.2") {
574 setSSELevel(Features, SSE42, Enabled);
575 }
else if (Name ==
"sse4.1") {
576 setSSELevel(Features, SSE41, Enabled);
577 }
else if (Name ==
"3dnow") {
578 setMMXLevel(Features, AMD3DNow, Enabled);
579 }
else if (Name ==
"3dnowa") {
580 setMMXLevel(Features, AMD3DNowAthlon, Enabled);
581 }
else if (Name ==
"aes") {
583 setSSELevel(Features, SSE2, Enabled);
585 Features[
"vaes"] =
false;
586 }
else if (Name ==
"vaes") {
588 setSSELevel(Features, AVX, Enabled);
589 Features[
"aes"] =
true;
591 }
else if (Name ==
"pclmul") {
593 setSSELevel(Features, SSE2, Enabled);
595 Features[
"vpclmulqdq"] =
false;
596 }
else if (Name ==
"vpclmulqdq") {
598 setSSELevel(Features, AVX, Enabled);
599 Features[
"pclmul"] =
true;
601 }
else if (Name ==
"gfni") {
603 setSSELevel(Features, SSE2, Enabled);
604 }
else if (Name ==
"avx") {
605 setSSELevel(Features, AVX, Enabled);
606 }
else if (Name ==
"avx2") {
607 setSSELevel(Features, AVX2, Enabled);
608 }
else if (Name ==
"avx512f") {
609 setSSELevel(Features, AVX512F, Enabled);
610 }
else if (Name ==
"avx512cd" || Name ==
"avx512er" || Name ==
"avx512pf" ||
611 Name ==
"avx512dq" || Name ==
"avx512bw" || Name ==
"avx512vl" ||
612 Name ==
"avx512vbmi" || Name ==
"avx512ifma" ||
613 Name ==
"avx512vpopcntdq" || Name ==
"avx512bitalg" ||
614 Name ==
"avx512vnni" || Name ==
"avx512vbmi2") {
616 setSSELevel(Features, AVX512F, Enabled);
618 if ((Name.startswith(
"avx512vbmi") || Name ==
"avx512bitalg") && Enabled)
619 Features[
"avx512bw"] =
true;
621 if (Name ==
"avx512bw" && !Enabled)
622 Features[
"avx512vbmi"] = Features[
"avx512vbmi2"] =
623 Features[
"avx512bitalg"] =
false;
624 }
else if (Name ==
"fma") {
626 setSSELevel(Features, AVX, Enabled);
628 setSSELevel(Features, AVX512F, Enabled);
629 }
else if (Name ==
"fma4") {
630 setXOPLevel(Features, FMA4, Enabled);
631 }
else if (Name ==
"xop") {
632 setXOPLevel(Features, XOP, Enabled);
633 }
else if (Name ==
"sse4a") {
634 setXOPLevel(Features, SSE4A, Enabled);
635 }
else if (Name ==
"f16c") {
637 setSSELevel(Features, AVX, Enabled);
639 setSSELevel(Features, AVX512F, Enabled);
640 }
else if (Name ==
"sha") {
642 setSSELevel(Features, SSE2, Enabled);
643 }
else if (Name ==
"sse4") {
649 setSSELevel(Features, SSE42, Enabled);
651 setSSELevel(Features, SSE41, Enabled);
652 }
else if (Name ==
"xsave") {
654 Features[
"xsaveopt"] =
false;
655 }
else if (Name ==
"xsaveopt" || Name ==
"xsavec" || Name ==
"xsaves") {
657 Features[
"xsave"] =
true;
665 for (
const auto &Feature : Features) {
666 if (Feature[0] !=
'+')
669 if (Feature ==
"+aes") {
671 }
else if (Feature ==
"+vaes") {
673 }
else if (Feature ==
"+pclmul") {
675 }
else if (Feature ==
"+vpclmulqdq") {
676 HasVPCLMULQDQ =
true;
677 }
else if (Feature ==
"+lzcnt") {
679 }
else if (Feature ==
"+rdrnd") {
681 }
else if (Feature ==
"+fsgsbase") {
683 }
else if (Feature ==
"+bmi") {
685 }
else if (Feature ==
"+bmi2") {
687 }
else if (Feature ==
"+popcnt") {
689 }
else if (Feature ==
"+rtm") {
691 }
else if (Feature ==
"+prfchw") {
693 }
else if (Feature ==
"+rdseed") {
695 }
else if (Feature ==
"+adx") {
697 }
else if (Feature ==
"+tbm") {
699 }
else if (Feature ==
"+lwp") {
701 }
else if (Feature ==
"+fma") {
703 }
else if (Feature ==
"+f16c") {
705 }
else if (Feature ==
"+gfni") {
707 }
else if (Feature ==
"+avx512cd") {
709 }
else if (Feature ==
"+avx512vpopcntdq") {
710 HasAVX512VPOPCNTDQ =
true;
711 }
else if (Feature ==
"+avx512vnni") {
712 HasAVX512VNNI =
true;
713 }
else if (Feature ==
"+avx512er") {
715 }
else if (Feature ==
"+avx512pf") {
717 }
else if (Feature ==
"+avx512dq") {
719 }
else if (Feature ==
"+avx512bitalg") {
720 HasAVX512BITALG =
true;
721 }
else if (Feature ==
"+avx512bw") {
723 }
else if (Feature ==
"+avx512vl") {
725 }
else if (Feature ==
"+avx512vbmi") {
726 HasAVX512VBMI =
true;
727 }
else if (Feature ==
"+avx512vbmi2") {
728 HasAVX512VBMI2 =
true;
729 }
else if (Feature ==
"+avx512ifma") {
730 HasAVX512IFMA =
true;
731 }
else if (Feature ==
"+sha") {
733 }
else if (Feature ==
"+mpx") {
735 }
else if (Feature ==
"+shstk") {
737 }
else if (Feature ==
"+ibt") {
739 }
else if (Feature ==
"+movbe") {
741 }
else if (Feature ==
"+sgx") {
743 }
else if (Feature ==
"+cx16") {
745 }
else if (Feature ==
"+fxsr") {
747 }
else if (Feature ==
"+xsave") {
749 }
else if (Feature ==
"+xsaveopt") {
751 }
else if (Feature ==
"+xsavec") {
753 }
else if (Feature ==
"+xsaves") {
755 }
else if (Feature ==
"+mwaitx") {
757 }
else if (Feature ==
"+pku") {
759 }
else if (Feature ==
"+clflushopt") {
760 HasCLFLUSHOPT =
true;
761 }
else if (Feature ==
"+clwb") {
763 }
else if (Feature ==
"+prefetchwt1") {
764 HasPREFETCHWT1 =
true;
765 }
else if (Feature ==
"+clzero") {
767 }
else if (Feature ==
"+retpoline") {
769 }
else if (Feature ==
"+retpoline-external-thunk") {
770 HasRetpolineExternalThunk =
true;
773 X86SSEEnum
Level = llvm::StringSwitch<X86SSEEnum>(Feature)
774 .Case(
"+avx512f", AVX512F)
777 .Case(
"+sse4.2", SSE42)
778 .Case(
"+sse4.1", SSE41)
779 .Case(
"+ssse3", SSSE3)
784 SSELevel =
std::max(SSELevel, Level);
786 MMX3DNowEnum ThreeDNowLevel = llvm::StringSwitch<MMX3DNowEnum>(Feature)
787 .Case(
"+3dnowa", AMD3DNowAthlon)
788 .Case(
"+3dnow", AMD3DNow)
790 .Default(NoMMX3DNow);
791 MMX3DNowLevel =
std::max(MMX3DNowLevel, ThreeDNowLevel);
793 XOPEnum XLevel = llvm::StringSwitch<XOPEnum>(Feature)
796 .Case(
"+sse4a", SSE4A)
798 XOPLevel =
std::max(XOPLevel, XLevel);
803 if ((FPMath == FP_SSE && SSELevel < SSE1) ||
804 (FPMath == FP_387 && SSELevel >= SSE1)) {
805 Diags.
Report(diag::err_target_unsupported_fpmath)
806 << (FPMath == FP_SSE ?
"sse" :
"387");
820 if (getTriple().getArch() == llvm::Triple::x86_64) {
825 if (getTriple().getArchName() ==
"x86_64h") {
897 case CK_SkylakeClient:
898 case CK_SkylakeServer:
921 if (CPU != CK_K6_2) {
935 if (SSELevel != NoSSE) {
1058 if (HasAVX512VPOPCNTDQ)
1068 if (HasAVX512BITALG)
1097 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
1148 if (Opts.MicrosoftExt && getTriple().getArch() == llvm::Triple::x86) {
1170 switch (MMX3DNowLevel) {
1171 case AMD3DNowAthlon:
1184 if (CPU >= CK_i486) {
1185 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
1186 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
1187 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
1190 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
1197 return llvm::StringSwitch<bool>(Name)
1198 .Case(
"3dnow",
true)
1199 .Case(
"3dnowa",
true)
1204 .Case(
"avx512f",
true)
1205 .Case(
"avx512cd",
true)
1206 .Case(
"avx512vpopcntdq",
true)
1207 .Case(
"avx512vnni",
true)
1208 .Case(
"avx512er",
true)
1209 .Case(
"avx512pf",
true)
1210 .Case(
"avx512dq",
true)
1211 .Case(
"avx512bitalg",
true)
1212 .Case(
"avx512bw",
true)
1213 .Case(
"avx512vl",
true)
1214 .Case(
"avx512vbmi",
true)
1215 .Case(
"avx512vbmi2",
true)
1216 .Case(
"avx512ifma",
true)
1219 .Case(
"clflushopt",
true)
1221 .Case(
"clzero",
true)
1226 .Case(
"fsgsbase",
true)
1230 .Case(
"lzcnt",
true)
1232 .Case(
"movbe",
true)
1234 .Case(
"mwaitx",
true)
1235 .Case(
"pclmul",
true)
1237 .Case(
"popcnt",
true)
1238 .Case(
"prefetchwt1",
true)
1239 .Case(
"prfchw",
true)
1240 .Case(
"rdrnd",
true)
1241 .Case(
"rdseed",
true)
1245 .Case(
"shstk",
true)
1249 .Case(
"ssse3",
true)
1251 .Case(
"sse4.1",
true)
1252 .Case(
"sse4.2",
true)
1253 .Case(
"sse4a",
true)
1256 .Case(
"vpclmulqdq",
true)
1259 .Case(
"xsave",
true)
1260 .Case(
"xsavec",
true)
1261 .Case(
"xsaves",
true)
1262 .Case(
"xsaveopt",
true)
1267 return llvm::StringSwitch<bool>(Feature)
1268 .Case(
"adx", HasADX)
1269 .Case(
"aes", HasAES)
1270 .Case(
"avx", SSELevel >= AVX)
1271 .Case(
"avx2", SSELevel >= AVX2)
1272 .Case(
"avx512f", SSELevel >= AVX512F)
1273 .Case(
"avx512cd", HasAVX512CD)
1274 .Case(
"avx512vpopcntdq", HasAVX512VPOPCNTDQ)
1275 .Case(
"avx512vnni", HasAVX512VNNI)
1276 .Case(
"avx512er", HasAVX512ER)
1277 .Case(
"avx512pf", HasAVX512PF)
1278 .Case(
"avx512dq", HasAVX512DQ)
1279 .Case(
"avx512bitalg", HasAVX512BITALG)
1280 .Case(
"avx512bw", HasAVX512BW)
1281 .Case(
"avx512vl", HasAVX512VL)
1282 .Case(
"avx512vbmi", HasAVX512VBMI)
1283 .Case(
"avx512vbmi2", HasAVX512VBMI2)
1284 .Case(
"avx512ifma", HasAVX512IFMA)
1285 .Case(
"bmi", HasBMI)
1286 .Case(
"bmi2", HasBMI2)
1287 .Case(
"clflushopt", HasCLFLUSHOPT)
1288 .Case(
"clwb", HasCLWB)
1289 .Case(
"clzero", HasCLZERO)
1290 .Case(
"cx16", HasCX16)
1291 .Case(
"f16c", HasF16C)
1292 .Case(
"fma", HasFMA)
1293 .Case(
"fma4", XOPLevel >= FMA4)
1294 .Case(
"fsgsbase", HasFSGSBASE)
1295 .Case(
"fxsr", HasFXSR)
1296 .Case(
"gfni", HasGFNI)
1297 .Case(
"ibt", HasIBT)
1298 .Case(
"lwp", HasLWP)
1299 .Case(
"lzcnt", HasLZCNT)
1300 .Case(
"mm3dnow", MMX3DNowLevel >= AMD3DNow)
1301 .Case(
"mm3dnowa", MMX3DNowLevel >= AMD3DNowAthlon)
1302 .Case(
"mmx", MMX3DNowLevel >= MMX)
1303 .Case(
"movbe", HasMOVBE)
1304 .Case(
"mpx", HasMPX)
1305 .Case(
"mwaitx", HasMWAITX)
1306 .Case(
"pclmul", HasPCLMUL)
1307 .Case(
"pku", HasPKU)
1308 .Case(
"popcnt", HasPOPCNT)
1309 .Case(
"prefetchwt1", HasPREFETCHWT1)
1310 .Case(
"prfchw", HasPRFCHW)
1311 .Case(
"rdrnd", HasRDRND)
1312 .Case(
"rdseed", HasRDSEED)
1313 .Case(
"retpoline", HasRetpoline)
1314 .Case(
"retpoline-external-thunk", HasRetpolineExternalThunk)
1315 .Case(
"rtm", HasRTM)
1316 .Case(
"sgx", HasSGX)
1317 .Case(
"sha", HasSHA)
1318 .Case(
"shstk", HasSHSTK)
1319 .Case(
"sse", SSELevel >= SSE1)
1320 .Case(
"sse2", SSELevel >= SSE2)
1321 .Case(
"sse3", SSELevel >= SSE3)
1322 .Case(
"ssse3", SSELevel >= SSSE3)
1323 .Case(
"sse4.1", SSELevel >= SSE41)
1324 .Case(
"sse4.2", SSELevel >= SSE42)
1325 .Case(
"sse4a", XOPLevel >= SSE4A)
1326 .Case(
"tbm", HasTBM)
1327 .Case(
"vaes", HasVAES)
1328 .Case(
"vpclmulqdq", HasVPCLMULQDQ)
1330 .Case(
"x86_32", getTriple().getArch() == llvm::Triple::x86)
1331 .Case(
"x86_64", getTriple().getArch() == llvm::Triple::x86_64)
1332 .Case(
"xop", XOPLevel >= XOP)
1333 .Case(
"xsave", HasXSAVE)
1334 .Case(
"xsavec", HasXSAVEC)
1335 .Case(
"xsaves", HasXSAVES)
1336 .Case(
"xsaveopt", HasXSAVEOPT)
1346 return llvm::StringSwitch<bool>(FeatureStr)
1348 #include "llvm/Support/X86TargetParser.def" 1357 return llvm::StringSwitch<bool>(FeatureStr)
1358 #define
X86_VENDOR(ENUM, STRING) .Case(STRING,
true)
1359 #define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) \ 1360 .Cases(STR, ALIAS, true) 1361 #define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true) 1362 #define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true) 1363 #include "llvm/Support/X86TargetParser.def" 1453 unsigned Size)
const {
1455 while (Constraint[0] ==
'=' || Constraint[0] ==
'+' || Constraint[0] ==
'&')
1456 Constraint = Constraint.substr(1);
1458 return validateOperandSize(Constraint, Size);
1462 unsigned Size)
const {
1463 return validateOperandSize(Constraint, Size);
1467 unsigned Size)
const {
1468 switch (Constraint[0]) {
1481 switch (Constraint[1]) {
1491 if (SSELevel >= SSE1)
1492 return Size <= 128U;
1498 if (SSELevel < SSE2)
1504 if (SSELevel >= AVX512F)
1506 return Size <= 512U;
1507 else if (SSELevel >= AVX)
1509 return Size <= 256U;
1510 return Size <= 128U;
1518 switch (*Constraint) {
1520 return std::string(
"{ax}");
1522 return std::string(
"{bx}");
1524 return std::string(
"{cx}");
1526 return std::string(
"{dx}");
1528 return std::string(
"{si}");
1530 return std::string(
"{di}");
1532 return std::string(
"im");
1534 return std::string(
"{st}");
1536 return std::string(
"{st(1)}");
1538 switch (Constraint[1]) {
1554 return std::string(
"^") + std::string(Constraint++, 2);
1558 return std::string(1, *Constraint);
1562 bool X86TargetInfo::checkCPUKind(CPUKind
Kind)
const {
1571 #define PROC(ENUM, STRING, IS64BIT) \ 1573 return IS64BIT || getTriple().getArch() == llvm::Triple::x86; 1574 #include "clang/Basic/X86Target.def" 1576 llvm_unreachable(
"Unhandled CPU kind");
1579 X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU)
const {
1580 return llvm::StringSwitch<CPUKind>(CPU)
1581 #define
PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM)
1582 #define PROC_ALIAS(ENUM, ALIAS) .Case(ALIAS, CK_##ENUM) 1583 #include "clang/Basic/X86Target.def" 1584 .Default(CK_Generic);
void DefineStd(MacroBuilder &Builder, StringRef MacroName, const LangOptions &Opts)
DefineStd - Define a macro name and standard variants.
static bool hasFeature(StringRef Feature, const LangOptions &LangOpts, const TargetInfo &Target)
Determine whether a translation unit built using the current language options has the given feature...
bool setFPMath(StringRef Name) override
Use the specified unit for FP math.
const Builtin::Info BuiltinInfoX86[]
static void setMMXLevel(llvm::StringMap< bool > &Features, MMX3DNowEnum Level, bool Enabled)
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
bool validateOutputSize(StringRef Constraint, unsigned Size) const override
ArrayRef< TargetInfo::AddlRegName > getGCCAddlRegNames() const override
void setRequiresImmediate(int Min, int Max)
virtual bool validateOperandSize(StringRef Constraint, unsigned Size) const
static void setXOPLevel(llvm::StringMap< bool > &Features, XOPEnum Level, bool Enabled)
const TargetInfo::AddlRegName AddlRegNames[]
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
bool validateCpuSupports(StringRef Name) const override
#define X86_FEATURE_COMPAT(VAL, ENUM, STR)
Concrete class used by the front-end to report problems and issues.
Defines the Diagnostic-related interfaces.
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override
static const char *const GCCRegNames[]
bool isValidFeatureName(StringRef Name) const override
Determine whether this TargetInfo supports the given feature.
#define X86_VENDOR(ENUM, STRING)
virtual bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeatureVec) const
Initialize the map with the default set of target features for the CPU this should include all legal ...
std::string ConstraintStr
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
static void setSSELevel(llvm::StringMap< bool > &Features, X86SSEEnum Level, bool Enabled)
Enumerates target-specific builtins in their own namespaces within namespace clang.
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
std::string convertConstraint(const char *&Constraint) const override
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Dataflow Directional Tag Classes.
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
handleTargetFeatures - Perform initialization based on the user configured set of features...
bool validateInputSize(StringRef Constraint, unsigned Size) const override
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
X86TargetInfo::getTargetDefines - Return the set of the X86-specific macro definitions for this parti...
#define PROC(ENUM, STRING, IS64BIT)
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
void defineCPUMacros(MacroBuilder &Builder, StringRef CPUName, bool Tuning)
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".
static void setFeatureEnabledImpl(llvm::StringMap< bool > &Features, StringRef Name, bool Enabled)
bool validateCpuIs(StringRef Name) const override
ArrayRef< const char * > getGCCRegNames() const override
Defines enum values for all the target-independent builtin functions.
bool initFeatureMap(llvm::StringMap< bool > &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector< std::string > &FeaturesVec) const override
Initialize the map with the default set of target features for the CPU this should include all legal ...