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 setFeatureEnabledImpl(Features,
"clwb",
true);
157 case CK_SkylakeClient:
158 setFeatureEnabledImpl(Features,
"xsavec",
true);
159 setFeatureEnabledImpl(Features,
"xsaves",
true);
160 setFeatureEnabledImpl(Features,
"mpx",
true);
161 setFeatureEnabledImpl(Features,
"sgx",
true);
162 setFeatureEnabledImpl(Features,
"clflushopt",
true);
163 setFeatureEnabledImpl(Features,
"rtm",
true);
166 setFeatureEnabledImpl(Features,
"rdseed",
true);
167 setFeatureEnabledImpl(Features,
"adx",
true);
168 setFeatureEnabledImpl(Features,
"prfchw",
true);
171 setFeatureEnabledImpl(Features,
"avx2",
true);
172 setFeatureEnabledImpl(Features,
"lzcnt",
true);
173 setFeatureEnabledImpl(Features,
"bmi",
true);
174 setFeatureEnabledImpl(Features,
"bmi2",
true);
175 setFeatureEnabledImpl(Features,
"fma",
true);
176 setFeatureEnabledImpl(Features,
"movbe",
true);
179 setFeatureEnabledImpl(Features,
"rdrnd",
true);
180 setFeatureEnabledImpl(Features,
"f16c",
true);
181 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
184 setFeatureEnabledImpl(Features,
"avx",
true);
185 setFeatureEnabledImpl(Features,
"xsave",
true);
186 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
189 setFeatureEnabledImpl(Features,
"aes",
true);
190 setFeatureEnabledImpl(Features,
"pclmul",
true);
193 setFeatureEnabledImpl(Features,
"sse4.2",
true);
196 setFeatureEnabledImpl(Features,
"sse4.1",
true);
199 setFeatureEnabledImpl(Features,
"ssse3",
true);
204 setFeatureEnabledImpl(Features,
"sse3",
true);
205 setFeatureEnabledImpl(Features,
"cx16",
true);
210 setFeatureEnabledImpl(Features,
"sse2",
true);
214 setFeatureEnabledImpl(Features,
"sse",
true);
215 setFeatureEnabledImpl(Features,
"fxsr",
true);
219 setFeatureEnabledImpl(Features,
"sha",
true);
220 setFeatureEnabledImpl(Features,
"rdrnd",
true);
221 setFeatureEnabledImpl(Features,
"rdseed",
true);
222 setFeatureEnabledImpl(Features,
"xsave",
true);
223 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
224 setFeatureEnabledImpl(Features,
"xsavec",
true);
225 setFeatureEnabledImpl(Features,
"xsaves",
true);
226 setFeatureEnabledImpl(Features,
"clflushopt",
true);
227 setFeatureEnabledImpl(Features,
"mpx",
true);
228 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
231 setFeatureEnabledImpl(Features,
"aes",
true);
232 setFeatureEnabledImpl(Features,
"pclmul",
true);
233 setFeatureEnabledImpl(Features,
"sse4.2",
true);
234 setFeatureEnabledImpl(Features,
"prfchw",
true);
237 setFeatureEnabledImpl(Features,
"movbe",
true);
238 setFeatureEnabledImpl(Features,
"ssse3",
true);
239 setFeatureEnabledImpl(Features,
"fxsr",
true);
240 setFeatureEnabledImpl(Features,
"cx16",
true);
245 setFeatureEnabledImpl(Features,
"avx512vpopcntdq",
true);
248 setFeatureEnabledImpl(Features,
"avx512f",
true);
249 setFeatureEnabledImpl(Features,
"avx512cd",
true);
250 setFeatureEnabledImpl(Features,
"avx512er",
true);
251 setFeatureEnabledImpl(Features,
"avx512pf",
true);
252 setFeatureEnabledImpl(Features,
"prfchw",
true);
253 setFeatureEnabledImpl(Features,
"prefetchwt1",
true);
254 setFeatureEnabledImpl(Features,
"fxsr",
true);
255 setFeatureEnabledImpl(Features,
"rdseed",
true);
256 setFeatureEnabledImpl(Features,
"adx",
true);
257 setFeatureEnabledImpl(Features,
"lzcnt",
true);
258 setFeatureEnabledImpl(Features,
"bmi",
true);
259 setFeatureEnabledImpl(Features,
"bmi2",
true);
260 setFeatureEnabledImpl(Features,
"rtm",
true);
261 setFeatureEnabledImpl(Features,
"fma",
true);
262 setFeatureEnabledImpl(Features,
"rdrnd",
true);
263 setFeatureEnabledImpl(Features,
"f16c",
true);
264 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
265 setFeatureEnabledImpl(Features,
"aes",
true);
266 setFeatureEnabledImpl(Features,
"pclmul",
true);
267 setFeatureEnabledImpl(Features,
"cx16",
true);
268 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
269 setFeatureEnabledImpl(Features,
"xsave",
true);
270 setFeatureEnabledImpl(Features,
"movbe",
true);
277 setFeatureEnabledImpl(Features,
"3dnow",
true);
281 setFeatureEnabledImpl(Features,
"sse4a",
true);
282 setFeatureEnabledImpl(Features,
"lzcnt",
true);
283 setFeatureEnabledImpl(Features,
"popcnt",
true);
286 setFeatureEnabledImpl(Features,
"sse3",
true);
289 setFeatureEnabledImpl(Features,
"sse2",
true);
292 setFeatureEnabledImpl(Features,
"sse",
true);
293 setFeatureEnabledImpl(Features,
"fxsr",
true);
297 setFeatureEnabledImpl(Features,
"3dnowa",
true);
301 setFeatureEnabledImpl(Features,
"avx",
true);
302 setFeatureEnabledImpl(Features,
"aes",
true);
303 setFeatureEnabledImpl(Features,
"pclmul",
true);
304 setFeatureEnabledImpl(Features,
"bmi",
true);
305 setFeatureEnabledImpl(Features,
"f16c",
true);
306 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
307 setFeatureEnabledImpl(Features,
"movbe",
true);
310 setFeatureEnabledImpl(Features,
"ssse3",
true);
311 setFeatureEnabledImpl(Features,
"sse4a",
true);
312 setFeatureEnabledImpl(Features,
"lzcnt",
true);
313 setFeatureEnabledImpl(Features,
"popcnt",
true);
314 setFeatureEnabledImpl(Features,
"prfchw",
true);
315 setFeatureEnabledImpl(Features,
"cx16",
true);
316 setFeatureEnabledImpl(Features,
"fxsr",
true);
320 setFeatureEnabledImpl(Features,
"adx",
true);
321 setFeatureEnabledImpl(Features,
"aes",
true);
322 setFeatureEnabledImpl(Features,
"avx2",
true);
323 setFeatureEnabledImpl(Features,
"bmi",
true);
324 setFeatureEnabledImpl(Features,
"bmi2",
true);
325 setFeatureEnabledImpl(Features,
"clflushopt",
true);
326 setFeatureEnabledImpl(Features,
"clzero",
true);
327 setFeatureEnabledImpl(Features,
"cx16",
true);
328 setFeatureEnabledImpl(Features,
"f16c",
true);
329 setFeatureEnabledImpl(Features,
"fma",
true);
330 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
331 setFeatureEnabledImpl(Features,
"fxsr",
true);
332 setFeatureEnabledImpl(Features,
"lzcnt",
true);
333 setFeatureEnabledImpl(Features,
"mwaitx",
true);
334 setFeatureEnabledImpl(Features,
"movbe",
true);
335 setFeatureEnabledImpl(Features,
"pclmul",
true);
336 setFeatureEnabledImpl(Features,
"popcnt",
true);
337 setFeatureEnabledImpl(Features,
"prfchw",
true);
338 setFeatureEnabledImpl(Features,
"rdrnd",
true);
339 setFeatureEnabledImpl(Features,
"rdseed",
true);
340 setFeatureEnabledImpl(Features,
"sha",
true);
341 setFeatureEnabledImpl(Features,
"sse4a",
true);
342 setFeatureEnabledImpl(Features,
"xsave",
true);
343 setFeatureEnabledImpl(Features,
"xsavec",
true);
344 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
345 setFeatureEnabledImpl(Features,
"xsaves",
true);
349 setFeatureEnabledImpl(Features,
"avx2",
true);
350 setFeatureEnabledImpl(Features,
"bmi2",
true);
351 setFeatureEnabledImpl(Features,
"mwaitx",
true);
354 setFeatureEnabledImpl(Features,
"fsgsbase",
true);
355 setFeatureEnabledImpl(Features,
"xsaveopt",
true);
358 setFeatureEnabledImpl(Features,
"bmi",
true);
359 setFeatureEnabledImpl(Features,
"fma",
true);
360 setFeatureEnabledImpl(Features,
"f16c",
true);
361 setFeatureEnabledImpl(Features,
"tbm",
true);
365 setFeatureEnabledImpl(Features,
"xop",
true);
366 setFeatureEnabledImpl(Features,
"lwp",
true);
367 setFeatureEnabledImpl(Features,
"lzcnt",
true);
368 setFeatureEnabledImpl(Features,
"aes",
true);
369 setFeatureEnabledImpl(Features,
"pclmul",
true);
370 setFeatureEnabledImpl(Features,
"prfchw",
true);
371 setFeatureEnabledImpl(Features,
"cx16",
true);
372 setFeatureEnabledImpl(Features,
"fxsr",
true);
373 setFeatureEnabledImpl(Features,
"xsave",
true);
383 auto I = Features.find(
"sse4.2");
384 if (I != Features.end() && I->getValue() &&
385 std::find(FeaturesVec.begin(), FeaturesVec.end(),
"-popcnt") ==
387 Features[
"popcnt"] =
true;
390 I = Features.find(
"3dnow");
391 if (I != Features.end() && I->getValue() &&
392 std::find(FeaturesVec.begin(), FeaturesVec.end(),
"-prfchw") ==
394 Features[
"prfchw"] =
true;
398 I = Features.find(
"sse");
399 if (I != Features.end() && I->getValue() &&
400 std::find(FeaturesVec.begin(), FeaturesVec.end(),
"-mmx") ==
402 Features[
"mmx"] =
true;
408 X86SSEEnum
Level,
bool Enabled) {
412 Features[
"avx512f"] = Features[
"fma"] = Features[
"f16c"] =
true;
415 Features[
"avx2"] =
true;
418 Features[
"avx"] =
true;
419 Features[
"xsave"] =
true;
422 Features[
"sse4.2"] =
true;
425 Features[
"sse4.1"] =
true;
428 Features[
"ssse3"] =
true;
431 Features[
"sse3"] =
true;
434 Features[
"sse2"] =
true;
437 Features[
"sse"] =
true;
448 Features[
"sse"] =
false;
451 Features[
"sse2"] = Features[
"pclmul"] = Features[
"aes"] = Features[
"sha"] =
452 Features[
"gfni"] =
false;
455 Features[
"sse3"] =
false;
456 setXOPLevel(Features, NoXOP,
false);
459 Features[
"ssse3"] =
false;
462 Features[
"sse4.1"] =
false;
465 Features[
"sse4.2"] =
false;
468 Features[
"fma"] = Features[
"avx"] = Features[
"f16c"] = Features[
"xsave"] =
469 Features[
"xsaveopt"] = Features[
"vaes"] = Features[
"vpclmulqdq"] =
false;
470 setXOPLevel(Features, FMA4,
false);
473 Features[
"avx2"] =
false;
476 Features[
"avx512f"] = Features[
"avx512cd"] = Features[
"avx512er"] =
477 Features[
"avx512pf"] = Features[
"avx512dq"] = Features[
"avx512bw"] =
478 Features[
"avx512vl"] = Features[
"avx512vbmi"] =
479 Features[
"avx512ifma"] = Features[
"avx512vpopcntdq"] =
480 Features[
"avx512bitalg"] = Features[
"avx512vnni"] =
481 Features[
"avx512vbmi2"] =
false;
487 MMX3DNowEnum
Level,
bool Enabled) {
491 Features[
"3dnowa"] =
true;
494 Features[
"3dnow"] =
true;
497 Features[
"mmx"] =
true;
508 Features[
"mmx"] =
false;
511 Features[
"3dnow"] =
false;
514 Features[
"3dnowa"] =
false;
524 Features[
"xop"] =
true;
527 Features[
"fma4"] =
true;
528 setSSELevel(Features, AVX,
true);
531 Features[
"sse4a"] =
true;
532 setSSELevel(Features, SSE3,
true);
543 Features[
"sse4a"] =
false;
546 Features[
"fma4"] =
false;
549 Features[
"xop"] =
false;
555 StringRef Name,
bool Enabled) {
560 Features[Name] = Enabled;
563 setMMXLevel(Features, MMX, Enabled);
564 }
else if (Name ==
"sse") {
565 setSSELevel(Features, SSE1, Enabled);
566 }
else if (Name ==
"sse2") {
567 setSSELevel(Features, SSE2, Enabled);
568 }
else if (Name ==
"sse3") {
569 setSSELevel(Features, SSE3, Enabled);
570 }
else if (Name ==
"ssse3") {
571 setSSELevel(Features, SSSE3, Enabled);
572 }
else if (Name ==
"sse4.2") {
573 setSSELevel(Features, SSE42, Enabled);
574 }
else if (Name ==
"sse4.1") {
575 setSSELevel(Features, SSE41, Enabled);
576 }
else if (Name ==
"3dnow") {
577 setMMXLevel(Features, AMD3DNow, Enabled);
578 }
else if (Name ==
"3dnowa") {
579 setMMXLevel(Features, AMD3DNowAthlon, Enabled);
580 }
else if (Name ==
"aes") {
582 setSSELevel(Features, SSE2, Enabled);
584 Features[
"vaes"] =
false;
585 }
else if (Name ==
"vaes") {
587 setSSELevel(Features, AVX, Enabled);
588 Features[
"aes"] =
true;
590 }
else if (Name ==
"pclmul") {
592 setSSELevel(Features, SSE2, Enabled);
594 Features[
"vpclmulqdq"] =
false;
595 }
else if (Name ==
"vpclmulqdq") {
597 setSSELevel(Features, AVX, Enabled);
598 Features[
"pclmul"] =
true;
600 }
else if (Name ==
"gfni") {
602 setSSELevel(Features, SSE2, Enabled);
603 }
else if (Name ==
"avx") {
604 setSSELevel(Features, AVX, Enabled);
605 }
else if (Name ==
"avx2") {
606 setSSELevel(Features, AVX2, Enabled);
607 }
else if (Name ==
"avx512f") {
608 setSSELevel(Features, AVX512F, Enabled);
609 }
else if (Name ==
"avx512cd" || Name ==
"avx512er" || Name ==
"avx512pf" ||
610 Name ==
"avx512dq" || Name ==
"avx512bw" || Name ==
"avx512vl" ||
611 Name ==
"avx512vbmi" || Name ==
"avx512ifma" ||
612 Name ==
"avx512vpopcntdq" || Name ==
"avx512bitalg" ||
613 Name ==
"avx512vnni" || Name ==
"avx512vbmi2") {
615 setSSELevel(Features, AVX512F, Enabled);
617 if ((Name.startswith(
"avx512vbmi") || Name ==
"avx512bitalg") && Enabled)
618 Features[
"avx512bw"] =
true;
620 if (Name ==
"avx512bw" && !Enabled)
621 Features[
"avx512vbmi"] = Features[
"avx512vbmi2"] =
622 Features[
"avx512bitalg"] =
false;
623 }
else if (Name ==
"fma") {
625 setSSELevel(Features, AVX, Enabled);
627 setSSELevel(Features, AVX512F, Enabled);
628 }
else if (Name ==
"fma4") {
629 setXOPLevel(Features, FMA4, Enabled);
630 }
else if (Name ==
"xop") {
631 setXOPLevel(Features, XOP, Enabled);
632 }
else if (Name ==
"sse4a") {
633 setXOPLevel(Features, SSE4A, Enabled);
634 }
else if (Name ==
"f16c") {
636 setSSELevel(Features, AVX, Enabled);
638 setSSELevel(Features, AVX512F, Enabled);
639 }
else if (Name ==
"sha") {
641 setSSELevel(Features, SSE2, Enabled);
642 }
else if (Name ==
"sse4") {
648 setSSELevel(Features, SSE42, Enabled);
650 setSSELevel(Features, SSE41, Enabled);
651 }
else if (Name ==
"xsave") {
653 Features[
"xsaveopt"] =
false;
654 }
else if (Name ==
"xsaveopt" || Name ==
"xsavec" || Name ==
"xsaves") {
656 Features[
"xsave"] =
true;
664 for (
const auto &Feature : Features) {
665 if (Feature[0] !=
'+')
668 if (Feature ==
"+aes") {
670 }
else if (Feature ==
"+vaes") {
672 }
else if (Feature ==
"+pclmul") {
674 }
else if (Feature ==
"+vpclmulqdq") {
675 HasVPCLMULQDQ =
true;
676 }
else if (Feature ==
"+lzcnt") {
678 }
else if (Feature ==
"+rdrnd") {
680 }
else if (Feature ==
"+fsgsbase") {
682 }
else if (Feature ==
"+bmi") {
684 }
else if (Feature ==
"+bmi2") {
686 }
else if (Feature ==
"+popcnt") {
688 }
else if (Feature ==
"+rtm") {
690 }
else if (Feature ==
"+prfchw") {
692 }
else if (Feature ==
"+rdseed") {
694 }
else if (Feature ==
"+adx") {
696 }
else if (Feature ==
"+tbm") {
698 }
else if (Feature ==
"+lwp") {
700 }
else if (Feature ==
"+fma") {
702 }
else if (Feature ==
"+f16c") {
704 }
else if (Feature ==
"+gfni") {
706 }
else if (Feature ==
"+avx512cd") {
708 }
else if (Feature ==
"+avx512vpopcntdq") {
709 HasAVX512VPOPCNTDQ =
true;
710 }
else if (Feature ==
"+avx512vnni") {
711 HasAVX512VNNI =
true;
712 }
else if (Feature ==
"+avx512er") {
714 }
else if (Feature ==
"+avx512pf") {
716 }
else if (Feature ==
"+avx512dq") {
718 }
else if (Feature ==
"+avx512bitalg") {
719 HasAVX512BITALG =
true;
720 }
else if (Feature ==
"+avx512bw") {
722 }
else if (Feature ==
"+avx512vl") {
724 }
else if (Feature ==
"+avx512vbmi") {
725 HasAVX512VBMI =
true;
726 }
else if (Feature ==
"+avx512vbmi2") {
727 HasAVX512VBMI2 =
true;
728 }
else if (Feature ==
"+avx512ifma") {
729 HasAVX512IFMA =
true;
730 }
else if (Feature ==
"+sha") {
732 }
else if (Feature ==
"+mpx") {
734 }
else if (Feature ==
"+shstk") {
736 }
else if (Feature ==
"+ibt") {
738 }
else if (Feature ==
"+movbe") {
740 }
else if (Feature ==
"+sgx") {
742 }
else if (Feature ==
"+cx16") {
744 }
else if (Feature ==
"+fxsr") {
746 }
else if (Feature ==
"+xsave") {
748 }
else if (Feature ==
"+xsaveopt") {
750 }
else if (Feature ==
"+xsavec") {
752 }
else if (Feature ==
"+xsaves") {
754 }
else if (Feature ==
"+mwaitx") {
756 }
else if (Feature ==
"+pku") {
758 }
else if (Feature ==
"+clflushopt") {
759 HasCLFLUSHOPT =
true;
760 }
else if (Feature ==
"+clwb") {
762 }
else if (Feature ==
"+prefetchwt1") {
763 HasPREFETCHWT1 =
true;
764 }
else if (Feature ==
"+clzero") {
766 }
else if (Feature ==
"+retpoline") {
768 }
else if (Feature ==
"+retpoline-external-thunk") {
769 HasRetpolineExternalThunk =
true;
772 X86SSEEnum
Level = llvm::StringSwitch<X86SSEEnum>(Feature)
773 .Case(
"+avx512f", AVX512F)
776 .Case(
"+sse4.2", SSE42)
777 .Case(
"+sse4.1", SSE41)
778 .Case(
"+ssse3", SSSE3)
783 SSELevel =
std::max(SSELevel, Level);
785 MMX3DNowEnum ThreeDNowLevel = llvm::StringSwitch<MMX3DNowEnum>(Feature)
786 .Case(
"+3dnowa", AMD3DNowAthlon)
787 .Case(
"+3dnow", AMD3DNow)
789 .Default(NoMMX3DNow);
790 MMX3DNowLevel =
std::max(MMX3DNowLevel, ThreeDNowLevel);
792 XOPEnum XLevel = llvm::StringSwitch<XOPEnum>(Feature)
795 .Case(
"+sse4a", SSE4A)
797 XOPLevel =
std::max(XOPLevel, XLevel);
802 if ((FPMath == FP_SSE && SSELevel < SSE1) ||
803 (FPMath == FP_387 && SSELevel >= SSE1)) {
804 Diags.
Report(diag::err_target_unsupported_fpmath)
805 << (FPMath == FP_SSE ?
"sse" :
"387");
819 if (getTriple().getArch() == llvm::Triple::x86_64) {
824 if (getTriple().getArchName() ==
"x86_64h") {
896 case CK_SkylakeClient:
897 case CK_SkylakeServer:
920 if (CPU != CK_K6_2) {
934 if (SSELevel != NoSSE) {
1057 if (HasAVX512VPOPCNTDQ)
1067 if (HasAVX512BITALG)
1096 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_16");
1147 if (Opts.MicrosoftExt && getTriple().getArch() == llvm::Triple::x86) {
1169 switch (MMX3DNowLevel) {
1170 case AMD3DNowAthlon:
1183 if (CPU >= CK_i486) {
1184 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
1185 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
1186 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
1189 Builder.
defineMacro(
"__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
1196 return llvm::StringSwitch<bool>(Name)
1197 .Case(
"3dnow",
true)
1198 .Case(
"3dnowa",
true)
1203 .Case(
"avx512f",
true)
1204 .Case(
"avx512cd",
true)
1205 .Case(
"avx512vpopcntdq",
true)
1206 .Case(
"avx512vnni",
true)
1207 .Case(
"avx512er",
true)
1208 .Case(
"avx512pf",
true)
1209 .Case(
"avx512dq",
true)
1210 .Case(
"avx512bitalg",
true)
1211 .Case(
"avx512bw",
true)
1212 .Case(
"avx512vl",
true)
1213 .Case(
"avx512vbmi",
true)
1214 .Case(
"avx512vbmi2",
true)
1215 .Case(
"avx512ifma",
true)
1218 .Case(
"clflushopt",
true)
1220 .Case(
"clzero",
true)
1225 .Case(
"fsgsbase",
true)
1229 .Case(
"lzcnt",
true)
1231 .Case(
"movbe",
true)
1233 .Case(
"mwaitx",
true)
1234 .Case(
"pclmul",
true)
1236 .Case(
"popcnt",
true)
1237 .Case(
"prefetchwt1",
true)
1238 .Case(
"prfchw",
true)
1239 .Case(
"rdrnd",
true)
1240 .Case(
"rdseed",
true)
1244 .Case(
"shstk",
true)
1248 .Case(
"ssse3",
true)
1250 .Case(
"sse4.1",
true)
1251 .Case(
"sse4.2",
true)
1252 .Case(
"sse4a",
true)
1255 .Case(
"vpclmulqdq",
true)
1258 .Case(
"xsave",
true)
1259 .Case(
"xsavec",
true)
1260 .Case(
"xsaves",
true)
1261 .Case(
"xsaveopt",
true)
1266 return llvm::StringSwitch<bool>(Feature)
1267 .Case(
"adx", HasADX)
1268 .Case(
"aes", HasAES)
1269 .Case(
"avx", SSELevel >= AVX)
1270 .Case(
"avx2", SSELevel >= AVX2)
1271 .Case(
"avx512f", SSELevel >= AVX512F)
1272 .Case(
"avx512cd", HasAVX512CD)
1273 .Case(
"avx512vpopcntdq", HasAVX512VPOPCNTDQ)
1274 .Case(
"avx512vnni", HasAVX512VNNI)
1275 .Case(
"avx512er", HasAVX512ER)
1276 .Case(
"avx512pf", HasAVX512PF)
1277 .Case(
"avx512dq", HasAVX512DQ)
1278 .Case(
"avx512bitalg", HasAVX512BITALG)
1279 .Case(
"avx512bw", HasAVX512BW)
1280 .Case(
"avx512vl", HasAVX512VL)
1281 .Case(
"avx512vbmi", HasAVX512VBMI)
1282 .Case(
"avx512vbmi2", HasAVX512VBMI2)
1283 .Case(
"avx512ifma", HasAVX512IFMA)
1284 .Case(
"bmi", HasBMI)
1285 .Case(
"bmi2", HasBMI2)
1286 .Case(
"clflushopt", HasCLFLUSHOPT)
1287 .Case(
"clwb", HasCLWB)
1288 .Case(
"clzero", HasCLZERO)
1289 .Case(
"cx16", HasCX16)
1290 .Case(
"f16c", HasF16C)
1291 .Case(
"fma", HasFMA)
1292 .Case(
"fma4", XOPLevel >= FMA4)
1293 .Case(
"fsgsbase", HasFSGSBASE)
1294 .Case(
"fxsr", HasFXSR)
1295 .Case(
"gfni", HasGFNI)
1296 .Case(
"ibt", HasIBT)
1297 .Case(
"lwp", HasLWP)
1298 .Case(
"lzcnt", HasLZCNT)
1299 .Case(
"mm3dnow", MMX3DNowLevel >= AMD3DNow)
1300 .Case(
"mm3dnowa", MMX3DNowLevel >= AMD3DNowAthlon)
1301 .Case(
"mmx", MMX3DNowLevel >= MMX)
1302 .Case(
"movbe", HasMOVBE)
1303 .Case(
"mpx", HasMPX)
1304 .Case(
"mwaitx", HasMWAITX)
1305 .Case(
"pclmul", HasPCLMUL)
1306 .Case(
"pku", HasPKU)
1307 .Case(
"popcnt", HasPOPCNT)
1308 .Case(
"prefetchwt1", HasPREFETCHWT1)
1309 .Case(
"prfchw", HasPRFCHW)
1310 .Case(
"rdrnd", HasRDRND)
1311 .Case(
"rdseed", HasRDSEED)
1312 .Case(
"retpoline", HasRetpoline)
1313 .Case(
"retpoline-external-thunk", HasRetpolineExternalThunk)
1314 .Case(
"rtm", HasRTM)
1315 .Case(
"sgx", HasSGX)
1316 .Case(
"sha", HasSHA)
1317 .Case(
"shstk", HasSHSTK)
1318 .Case(
"sse", SSELevel >= SSE1)
1319 .Case(
"sse2", SSELevel >= SSE2)
1320 .Case(
"sse3", SSELevel >= SSE3)
1321 .Case(
"ssse3", SSELevel >= SSSE3)
1322 .Case(
"sse4.1", SSELevel >= SSE41)
1323 .Case(
"sse4.2", SSELevel >= SSE42)
1324 .Case(
"sse4a", XOPLevel >= SSE4A)
1325 .Case(
"tbm", HasTBM)
1326 .Case(
"vaes", HasVAES)
1327 .Case(
"vpclmulqdq", HasVPCLMULQDQ)
1329 .Case(
"x86_32", getTriple().getArch() == llvm::Triple::x86)
1330 .Case(
"x86_64", getTriple().getArch() == llvm::Triple::x86_64)
1331 .Case(
"xop", XOPLevel >= XOP)
1332 .Case(
"xsave", HasXSAVE)
1333 .Case(
"xsavec", HasXSAVEC)
1334 .Case(
"xsaves", HasXSAVES)
1335 .Case(
"xsaveopt", HasXSAVEOPT)
1345 return llvm::StringSwitch<bool>(FeatureStr)
1347 #include "llvm/Support/X86TargetParser.def" 1356 return llvm::StringSwitch<bool>(FeatureStr)
1357 #define
X86_VENDOR(ENUM, STRING) .Case(STRING,
true)
1358 #define X86_CPU_TYPE_COMPAT_WITH_ALIAS(ARCHNAME, ENUM, STR, ALIAS) \ 1359 .Cases(STR, ALIAS, true) 1360 #define X86_CPU_TYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true) 1361 #define X86_CPU_SUBTYPE_COMPAT(ARCHNAME, ENUM, STR) .Case(STR, true) 1362 #include "llvm/Support/X86TargetParser.def" 1452 unsigned Size)
const {
1454 while (Constraint[0] ==
'=' || Constraint[0] ==
'+' || Constraint[0] ==
'&')
1455 Constraint = Constraint.substr(1);
1457 return validateOperandSize(Constraint, Size);
1461 unsigned Size)
const {
1462 return validateOperandSize(Constraint, Size);
1466 unsigned Size)
const {
1467 switch (Constraint[0]) {
1480 switch (Constraint[1]) {
1490 if (SSELevel >= SSE1)
1491 return Size <= 128U;
1497 if (SSELevel < SSE2)
1503 if (SSELevel >= AVX512F)
1505 return Size <= 512U;
1506 else if (SSELevel >= AVX)
1508 return Size <= 256U;
1509 return Size <= 128U;
1517 switch (*Constraint) {
1519 return std::string(
"{ax}");
1521 return std::string(
"{bx}");
1523 return std::string(
"{cx}");
1525 return std::string(
"{dx}");
1527 return std::string(
"{si}");
1529 return std::string(
"{di}");
1531 return std::string(
"im");
1533 return std::string(
"{st}");
1535 return std::string(
"{st(1)}");
1537 switch (Constraint[1]) {
1553 return std::string(
"^") + std::string(Constraint++, 2);
1557 return std::string(1, *Constraint);
1561 bool X86TargetInfo::checkCPUKind(CPUKind
Kind)
const {
1570 #define PROC(ENUM, STRING, IS64BIT) \ 1572 return IS64BIT || getTriple().getArch() == llvm::Triple::x86; 1573 #include "clang/Basic/X86Target.def" 1575 llvm_unreachable(
"Unhandled CPU kind");
1578 X86TargetInfo::CPUKind X86TargetInfo::getCPUKind(StringRef CPU)
const {
1579 return llvm::StringSwitch<CPUKind>(CPU)
1580 #define
PROC(ENUM, STRING, IS64BIT) .Case(STRING, CK_##ENUM)
1581 #define PROC_ALIAS(ENUM, ALIAS) .Case(ALIAS, CK_##ENUM) 1582 #include "clang/Basic/X86Target.def" 1583 .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 ...