blob: 6b1749fc75005965e9e6908cc869ce965070031b [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- X86.td - Target definition file for the Intel X86 --*- tablegen -*-===//
Michael J. Spencerb88784c2011-04-14 14:33:36 +00002//
John Criswell29265fe2003-10-21 15:17:13 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Michael J. Spencerb88784c2011-04-14 14:33:36 +00007//
John Criswell29265fe2003-10-21 15:17:13 +00008//===----------------------------------------------------------------------===//
Chris Lattner5da8e802003-08-03 15:47:49 +00009//
Craig Topper271064e2011-10-11 06:44:02 +000010// This is a target description file for the Intel i386 architecture, referred
11// to here as the "X86" architecture.
Chris Lattner5da8e802003-08-03 15:47:49 +000012//
13//===----------------------------------------------------------------------===//
14
Chris Lattner25510802003-08-04 04:59:56 +000015// Get the target-independent interfaces which we are implementing...
Chris Lattner5da8e802003-08-03 15:47:49 +000016//
Evan Cheng977e7be2008-11-24 07:34:46 +000017include "llvm/Target/Target.td"
Chris Lattner5da8e802003-08-03 15:47:49 +000018
19//===----------------------------------------------------------------------===//
Anitha Boyapati426feb62012-08-16 03:50:04 +000020// X86 Subtarget state
Evan Cheng13bcc6c2011-07-07 21:06:52 +000021//
22
23def Mode64Bit : SubtargetFeature<"64bit-mode", "In64BitMode", "true",
24 "64-bit mode (x86_64)">;
Craig Topper3c80d622014-01-06 04:55:54 +000025def Mode32Bit : SubtargetFeature<"32bit-mode", "In32BitMode", "true",
26 "32-bit mode (80386)">;
27def Mode16Bit : SubtargetFeature<"16bit-mode", "In16BitMode", "true",
28 "16-bit mode (i8086)">;
Evan Cheng13bcc6c2011-07-07 21:06:52 +000029
30//===----------------------------------------------------------------------===//
Anitha Boyapati426feb62012-08-16 03:50:04 +000031// X86 Subtarget features
Bill Wendlinge6182262007-05-04 20:38:40 +000032//===----------------------------------------------------------------------===//
Chris Lattnercc8c5812009-09-02 05:53:04 +000033
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +000034def FeatureX87 : SubtargetFeature<"x87","HasX87", "true",
35 "Enable X87 float instructions">;
36
Craig Topper505f38a2018-01-10 22:07:16 +000037def FeatureNOPL : SubtargetFeature<"nopl", "HasNOPL", "true",
38 "Enable NOPL instruction">;
39
Chris Lattnercc8c5812009-09-02 05:53:04 +000040def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true",
41 "Enable conditional move instructions">;
42
Benjamin Kramer2f489232010-12-04 20:32:23 +000043def FeaturePOPCNT : SubtargetFeature<"popcnt", "HasPOPCNT", "true",
44 "Support POPCNT instruction">;
45
Craig Topper09b65982015-10-16 06:03:09 +000046def FeatureFXSR : SubtargetFeature<"fxsr", "HasFXSR", "true",
47 "Support fxsave/fxrestore instructions">;
48
Amjad Aboud1db6d7a2015-10-12 11:47:46 +000049def FeatureXSAVE : SubtargetFeature<"xsave", "HasXSAVE", "true",
50 "Support xsave instructions">;
51
52def FeatureXSAVEOPT: SubtargetFeature<"xsaveopt", "HasXSAVEOPT", "true",
53 "Support xsaveopt instructions">;
54
55def FeatureXSAVEC : SubtargetFeature<"xsavec", "HasXSAVEC", "true",
56 "Support xsavec instructions">;
57
58def FeatureXSAVES : SubtargetFeature<"xsaves", "HasXSAVES", "true",
59 "Support xsaves instructions">;
60
Bill Wendlinge6182262007-05-04 20:38:40 +000061def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1",
Craig Topper128915f2018-08-26 18:29:33 +000062 "Enable SSE instructions">;
Bill Wendlinge6182262007-05-04 20:38:40 +000063def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2",
64 "Enable SSE2 instructions",
65 [FeatureSSE1]>;
66def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
67 "Enable SSE3 instructions",
68 [FeatureSSE2]>;
69def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
70 "Enable SSSE3 instructions",
71 [FeatureSSE3]>;
Rafael Espindola94a2c562013-08-23 20:21:34 +000072def FeatureSSE41 : SubtargetFeature<"sse4.1", "X86SSELevel", "SSE41",
Nate Begemane14fdfa2008-02-03 07:18:54 +000073 "Enable SSE 4.1 instructions",
74 [FeatureSSSE3]>;
Rafael Espindola94a2c562013-08-23 20:21:34 +000075def FeatureSSE42 : SubtargetFeature<"sse4.2", "X86SSELevel", "SSE42",
Nate Begemane14fdfa2008-02-03 07:18:54 +000076 "Enable SSE 4.2 instructions",
Craig Topper7bd33052011-12-29 15:51:45 +000077 [FeatureSSE41]>;
Eric Christopher57a6e132015-11-14 03:04:00 +000078// The MMX subtarget feature is separate from the rest of the SSE features
79// because it's important (for odd compatibility reasons) to be able to
80// turn it off explicitly while allowing SSE+ to be on.
81def FeatureMMX : SubtargetFeature<"mmx","X863DNowLevel", "MMX",
82 "Enable MMX instructions">;
Bill Wendlinge6182262007-05-04 20:38:40 +000083def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
Michael J. Spencer30088ba2011-04-15 00:32:41 +000084 "Enable 3DNow! instructions",
85 [FeatureMMX]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000086def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
Bill Wendlingf985c492007-05-06 07:56:19 +000087 "Enable 3DNow! Athlon instructions",
88 [Feature3DNow]>;
Dan Gohman74037512009-02-03 00:04:43 +000089// All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied
90// feature, because SSE2 can be disabled (e.g. for compiling OS kernels)
Craig Topperb7b353b2018-08-30 06:01:05 +000091// without disabling 64-bit mode. Nothing should imply this feature bit. It
92// is used to enforce that only 64-bit capable CPUs are used in 64-bit mode.
Bill Wendlingf985c492007-05-06 07:56:19 +000093def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true",
Craig Topper128915f2018-08-26 18:29:33 +000094 "Support 64-bit instructions">;
Nick Lewycky3be42b82013-10-05 20:11:44 +000095def FeatureCMPXCHG16B : SubtargetFeature<"cx16", "HasCmpxchg16b", "true",
Craig Topperb7b353b2018-08-30 06:01:05 +000096 "64-bit with cmpxchg16b">;
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +000097def FeatureSlowSHLD : SubtargetFeature<"slow-shld", "IsSHLDSlow", "true",
98 "SHLD instruction is slow">;
Zvi Rackover8bc7e4d2016-12-06 19:35:20 +000099def FeatureSlowPMULLD : SubtargetFeature<"slow-pmulld", "IsPMULLDSlow", "true",
100 "PMULLD instruction is slow">;
Craig Topperc10de9a2018-10-25 17:29:00 +0000101def FeatureSlowPMADDWD : SubtargetFeature<"slow-pmaddwd", "IsPMADDWDSlow",
102 "true",
103 "PMADDWD is slower than PMULLD">;
Sanjay Patel30145672015-09-01 20:51:51 +0000104// FIXME: This should not apply to CPUs that do not have SSE.
105def FeatureSlowUAMem16 : SubtargetFeature<"slow-unaligned-mem-16",
106 "IsUAMem16Slow", "true",
107 "Slow unaligned 16-byte memory access">;
Sanjay Patel501890e2014-11-21 17:40:04 +0000108def FeatureSlowUAMem32 : SubtargetFeature<"slow-unaligned-mem-32",
Sanjay Patel9e916dc2015-08-21 20:17:26 +0000109 "IsUAMem32Slow", "true",
110 "Slow unaligned 32-byte memory access">;
Stefanus Du Toit96180b52009-05-26 21:04:35 +0000111def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
Craig Toppera5d1fc22011-12-30 07:16:00 +0000112 "Support SSE 4a instructions",
113 [FeatureSSE3]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000114
Craig Topperf287a452012-01-09 09:02:13 +0000115def FeatureAVX : SubtargetFeature<"avx", "X86SSELevel", "AVX",
116 "Enable AVX instructions",
117 [FeatureSSE42]>;
118def FeatureAVX2 : SubtargetFeature<"avx2", "X86SSELevel", "AVX2",
Craig Topper228d9132011-10-30 19:57:21 +0000119 "Enable AVX2 instructions",
120 [FeatureAVX]>;
Craig Toppercb6c3862017-11-06 22:49:01 +0000121def FeatureFMA : SubtargetFeature<"fma", "HasFMA", "true",
122 "Enable three-operand fused multiple-add",
123 [FeatureAVX]>;
Craig Topper428a4e62017-11-06 22:49:04 +0000124def FeatureF16C : SubtargetFeature<"f16c", "HasF16C", "true",
125 "Support 16-bit floating point conversion instructions",
126 [FeatureAVX]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000127def FeatureAVX512 : SubtargetFeature<"avx512f", "X86SSELevel", "AVX512F",
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000128 "Enable AVX-512 instructions",
Craig Topper428a4e62017-11-06 22:49:04 +0000129 [FeatureAVX2, FeatureFMA, FeatureF16C]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000130def FeatureERI : SubtargetFeature<"avx512er", "HasERI", "true",
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000131 "Enable AVX-512 Exponential and Reciprocal Instructions",
132 [FeatureAVX512]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000133def FeatureCDI : SubtargetFeature<"avx512cd", "HasCDI", "true",
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000134 "Enable AVX-512 Conflict Detection Instructions",
135 [FeatureAVX512]>;
Oren Ben Simhon7bf27f02017-05-25 13:45:23 +0000136def FeatureVPOPCNTDQ : SubtargetFeature<"avx512vpopcntdq", "HasVPOPCNTDQ",
137 "true", "Enable AVX-512 Population Count Instructions",
138 [FeatureAVX512]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000139def FeaturePFI : SubtargetFeature<"avx512pf", "HasPFI", "true",
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000140 "Enable AVX-512 PreFetch Instructions",
141 [FeatureAVX512]>;
Craig Toppere2685982017-12-22 02:30:30 +0000142def FeaturePREFETCHWT1 : SubtargetFeature<"prefetchwt1", "HasPREFETCHWT1",
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000143 "true",
144 "Prefetch with Intent to Write and T1 Hint">;
Robert Khasanovbfa01312014-07-21 14:54:21 +0000145def FeatureDQI : SubtargetFeature<"avx512dq", "HasDQI", "true",
146 "Enable AVX-512 Doubleword and Quadword Instructions",
147 [FeatureAVX512]>;
148def FeatureBWI : SubtargetFeature<"avx512bw", "HasBWI", "true",
149 "Enable AVX-512 Byte and Word Instructions",
150 [FeatureAVX512]>;
151def FeatureVLX : SubtargetFeature<"avx512vl", "HasVLX", "true",
152 "Enable AVX-512 Vector Length eXtensions",
153 [FeatureAVX512]>;
Michael Zuckerman97b6a6922016-01-17 13:42:12 +0000154def FeatureVBMI : SubtargetFeature<"avx512vbmi", "HasVBMI", "true",
Craig Topper5c842be2016-11-09 04:50:48 +0000155 "Enable AVX-512 Vector Byte Manipulation Instructions",
156 [FeatureBWI]>;
Coby Tayree71e37cc2017-11-21 09:48:44 +0000157def FeatureVBMI2 : SubtargetFeature<"avx512vbmi2", "HasVBMI2", "true",
158 "Enable AVX-512 further Vector Byte Manipulation Instructions",
159 [FeatureBWI]>;
Craig Topper3bb3f732016-02-08 01:23:15 +0000160def FeatureIFMA : SubtargetFeature<"avx512ifma", "HasIFMA", "true",
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000161 "Enable AVX-512 Integer Fused Multiple-Add",
162 [FeatureAVX512]>;
Asaf Badouh5acf66f2015-12-15 13:35:29 +0000163def FeaturePKU : SubtargetFeature<"pku", "HasPKU", "true",
164 "Enable protection keys">;
Coby Tayree3880f2a2017-11-21 10:04:28 +0000165def FeatureVNNI : SubtargetFeature<"avx512vnni", "HasVNNI", "true",
166 "Enable AVX-512 Vector Neural Network Instructions",
167 [FeatureAVX512]>;
Coby Tayree5c7fe5d2017-11-21 10:32:42 +0000168def FeatureBITALG : SubtargetFeature<"avx512bitalg", "HasBITALG", "true",
169 "Enable AVX-512 Bit Algorithms",
170 [FeatureBWI]>;
Benjamin Kramera0396e42012-05-31 14:34:17 +0000171def FeaturePCLMUL : SubtargetFeature<"pclmul", "HasPCLMUL", "true",
172 "Enable packed carry-less multiplication instructions",
Craig Topper29dd1482012-05-01 05:28:32 +0000173 [FeatureSSE2]>;
Coby Tayreed8b17be2017-11-26 09:36:41 +0000174def FeatureGFNI : SubtargetFeature<"gfni", "HasGFNI", "true",
175 "Enable Galois Field Arithmetic Instructions",
176 [FeatureSSE2]>;
Coby Tayree7ca5e5872017-11-21 09:30:33 +0000177def FeatureVPCLMULQDQ : SubtargetFeature<"vpclmulqdq", "HasVPCLMULQDQ", "true",
178 "Enable vpclmulqdq instructions",
179 [FeatureAVX, FeaturePCLMUL]>;
David Greene8f6f72c2009-06-26 22:46:54 +0000180def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
Craig Toppera5d1fc22011-12-30 07:16:00 +0000181 "Enable four-operand fused multiple-add",
Craig Topperbae0e9e2012-05-01 06:54:48 +0000182 [FeatureAVX, FeatureSSE4A]>;
Craig Toppera5d1fc22011-12-30 07:16:00 +0000183def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
Craig Topper43518cc2012-05-01 05:41:41 +0000184 "Enable XOP instructions",
Anitha Boyapatiaf3e9832012-08-16 04:04:02 +0000185 [FeatureFMA4]>;
Sanjay Patelffd039b2015-02-03 17:13:04 +0000186def FeatureSSEUnalignedMem : SubtargetFeature<"sse-unaligned-mem",
187 "HasSSEUnalignedMem", "true",
188 "Allow unaligned memory operands with SSE instructions">;
Eric Christopher2ef63182010-04-02 21:54:27 +0000189def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
Craig Topper29dd1482012-05-01 05:28:32 +0000190 "Enable AES instructions",
191 [FeatureSSE2]>;
Coby Tayree2a1c02f2017-11-21 09:11:41 +0000192def FeatureVAES : SubtargetFeature<"vaes", "HasVAES", "true",
193 "Promote selected AES instructions to AVX512/AVX registers",
194 [FeatureAVX, FeatureAES]>;
Yunzhong Gaodd36e932013-09-24 18:21:52 +0000195def FeatureTBM : SubtargetFeature<"tbm", "HasTBM", "true",
196 "Enable TBM instructions">;
Simon Pilgrim99b925b2017-05-03 15:51:39 +0000197def FeatureLWP : SubtargetFeature<"lwp", "HasLWP", "true",
198 "Enable LWP instructions">;
Craig Topper786bdb92011-10-03 17:28:23 +0000199def FeatureMOVBE : SubtargetFeature<"movbe", "HasMOVBE", "true",
200 "Support MOVBE instruction">;
Rafael Espindola94a2c562013-08-23 20:21:34 +0000201def FeatureRDRAND : SubtargetFeature<"rdrnd", "HasRDRAND", "true",
Craig Topper786bdb92011-10-03 17:28:23 +0000202 "Support RDRAND instruction">;
Craig Topper228d9132011-10-30 19:57:21 +0000203def FeatureFSGSBase : SubtargetFeature<"fsgsbase", "HasFSGSBase", "true",
204 "Support FS/GS Base instructions">;
Craig Topper271064e2011-10-11 06:44:02 +0000205def FeatureLZCNT : SubtargetFeature<"lzcnt", "HasLZCNT", "true",
206 "Support LZCNT instruction">;
Craig Topper3657fe42011-10-14 03:21:46 +0000207def FeatureBMI : SubtargetFeature<"bmi", "HasBMI", "true",
208 "Support BMI instructions">;
Craig Topperaea148c2011-10-16 07:55:05 +0000209def FeatureBMI2 : SubtargetFeature<"bmi2", "HasBMI2", "true",
210 "Support BMI2 instructions">;
Michael Liao73cffdd2012-11-08 07:28:54 +0000211def FeatureRTM : SubtargetFeature<"rtm", "HasRTM", "true",
212 "Support RTM instructions">;
Kay Tiong Khoof809c642013-02-14 19:08:21 +0000213def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",
214 "Support ADX instructions">;
Ben Langmuir16501752013-09-12 15:51:31 +0000215def FeatureSHA : SubtargetFeature<"sha", "HasSHA", "true",
216 "Enable SHA instructions",
217 [FeatureSSE2]>;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000218def FeatureSHSTK : SubtargetFeature<"shstk", "HasSHSTK", "true",
219 "Support CET Shadow-Stack instructions">;
Michael Liao5173ee02013-03-26 17:47:11 +0000220def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
221 "Support PRFCHW instructions">;
Michael Liaoa486a112013-03-28 23:41:26 +0000222def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
223 "Support RDSEED instruction">;
Hans Wennborg5000ce82015-12-04 23:00:33 +0000224def FeatureLAHFSAHF : SubtargetFeature<"sahf", "HasLAHFSAHF", "true",
225 "Support LAHF and SAHF instructions">;
Ashutosh Nema348af9c2016-05-18 11:59:12 +0000226def FeatureMWAITX : SubtargetFeature<"mwaitx", "HasMWAITX", "true",
227 "Enable MONITORX/MWAITX timer functionality">;
Craig Topper50f3d142017-02-09 04:27:34 +0000228def FeatureCLZERO : SubtargetFeature<"clzero", "HasCLZERO", "true",
229 "Enable Cache Line Zero">;
Gabor Buella604be442018-04-13 07:35:08 +0000230def FeatureCLDEMOTE : SubtargetFeature<"cldemote", "HasCLDEMOTE", "true",
231 "Enable Cache Demote">;
Gabor Buellaa832b222018-05-10 07:26:05 +0000232def FeaturePTWRITE : SubtargetFeature<"ptwrite", "HasPTWRITE", "true",
233 "Support ptwrite instruction">;
Elena Demikhovskyf7e641c2015-06-03 10:30:57 +0000234def FeatureMPX : SubtargetFeature<"mpx", "HasMPX", "true",
235 "Support MPX instructions">;
Sanjay Patel53d1d8b2015-10-12 15:24:01 +0000236def FeatureLEAForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
Evan Cheng1b81fdd2012-02-07 22:50:41 +0000237 "Use LEA for adjusting the stack pointer">;
Alexey Volkovfd1731d2014-11-21 11:19:34 +0000238def FeatureSlowDivide32 : SubtargetFeature<"idivl-to-divb",
239 "HasSlowDivide32", "true",
240 "Use 8-bit divide for positive values less than 256">;
Nikolai Bozhenov6bdf92c2017-01-12 19:34:15 +0000241def FeatureSlowDivide64 : SubtargetFeature<"idivq-to-divl",
Alexey Volkovfd1731d2014-11-21 11:19:34 +0000242 "HasSlowDivide64", "true",
Nikolai Bozhenov6bdf92c2017-01-12 19:34:15 +0000243 "Use 32-bit divide for positive values less than 2^32">;
Preston Gurda01daac2013-01-08 18:27:24 +0000244def FeaturePadShortFunctions : SubtargetFeature<"pad-short-functions",
245 "PadShortFunctions", "true",
246 "Pad short functions">;
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000247def FeatureINVPCID : SubtargetFeature<"invpcid", "HasINVPCID", "true",
248 "Invalidate Process-Context Identifier">;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000249def FeatureSGX : SubtargetFeature<"sgx", "HasSGX", "true",
250 "Enable Software Guard Extensions">;
251def FeatureCLFLUSHOPT : SubtargetFeature<"clflushopt", "HasCLFLUSHOPT", "true",
252 "Flush A Cache Line Optimized">;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000253def FeatureCLWB : SubtargetFeature<"clwb", "HasCLWB", "true",
254 "Cache Line Write Back">;
Gabor Buella2ef36f32018-04-11 20:01:57 +0000255def FeatureWBNOINVD : SubtargetFeature<"wbnoinvd", "HasWBNOINVD", "true",
256 "Write Back No Invalidate">;
Craig Topper84b26b92018-01-18 23:52:31 +0000257def FeatureRDPID : SubtargetFeature<"rdpid", "HasRDPID", "true",
258 "Support RDPID instructions">;
Gabor Buella31fa8022018-04-20 18:42:47 +0000259def FeatureWAITPKG : SubtargetFeature<"waitpkg", "HasWAITPKG", "true",
260 "Wait and pause enhancements">;
Craig Topper62c47a22017-08-29 05:14:27 +0000261// On some processors, instructions that implicitly take two memory operands are
262// slow. In practice, this means that CALL, PUSH, and POP with memory operands
263// should be avoided in favor of a MOV + register CALL/PUSH/POP.
264def FeatureSlowTwoMemOps : SubtargetFeature<"slow-two-mem-ops",
265 "SlowTwoMemOps", "true",
266 "Two memory operand instructions are slow">;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000267def FeatureLEAUsesAG : SubtargetFeature<"lea-uses-ag", "LEAUsesAG", "true",
268 "LEA instruction needs inputs at AG stage">;
Alexey Volkov6226de62014-05-20 08:55:50 +0000269def FeatureSlowLEA : SubtargetFeature<"slow-lea", "SlowLEA", "true",
270 "LEA instruction with certain arguments is slow">;
Lama Saba2ea271b2017-05-18 08:11:50 +0000271def FeatureSlow3OpsLEA : SubtargetFeature<"slow-3ops-lea", "Slow3OpsLEA", "true",
272 "LEA instruction with 3 ops or certain registers is slow">;
Alexey Volkov5260dba2014-06-09 11:40:41 +0000273def FeatureSlowIncDec : SubtargetFeature<"slow-incdec", "SlowIncDec", "true",
274 "INC and DEC instructions are slower than ADD and SUB">;
Eric Christopher824f42f2015-05-12 01:26:05 +0000275def FeatureSoftFloat
276 : SubtargetFeature<"soft-float", "UseSoftFloat", "true",
277 "Use software floating point features.">;
Marina Yatsina77a21db2018-01-22 10:07:01 +0000278def FeaturePOPCNTFalseDeps : SubtargetFeature<"false-deps-popcnt",
279 "HasPOPCNTFalseDeps", "true",
280 "POPCNT has a false dependency on dest register">;
281def FeatureLZCNTFalseDeps : SubtargetFeature<"false-deps-lzcnt-tzcnt",
282 "HasLZCNTFalseDeps", "true",
283 "LZCNT/TZCNT have a false dependency on dest register">;
Gabor Buella2b5e9602018-05-08 06:47:36 +0000284def FeaturePCONFIG : SubtargetFeature<"pconfig", "HasPCONFIG", "true",
285 "platform configuration instruction">;
Simon Pilgrimfd5df632017-12-19 13:16:43 +0000286// On recent X86 (port bound) processors, its preferable to combine to a single shuffle
287// using a variable mask over multiple fixed shuffles.
288def FeatureFastVariableShuffle
289 : SubtargetFeature<"fast-variable-shuffle",
290 "HasFastVariableShuffle",
291 "true", "Shuffles with variable masks are fast">;
Amjad Aboud4f977512017-03-03 09:03:24 +0000292// On some X86 processors, there is no performance hazard to writing only the
293// lower parts of a YMM or ZMM register without clearing the upper part.
294def FeatureFastPartialYMMorZMMWrite
295 : SubtargetFeature<"fast-partial-ymm-or-zmm-write",
296 "HasFastPartialYMMorZMMWrite",
297 "true", "Partial writes to YMM/ZMM registers are fast">;
Nikolai Bozhenovf6795302016-08-04 12:47:28 +0000298// FeatureFastScalarFSQRT should be enabled if scalar FSQRT has shorter latency
299// than the corresponding NR code. FeatureFastVectorFSQRT should be enabled if
300// vector FSQRT has higher throughput than the corresponding NR code.
301// The idea is that throughput bound code is likely to be vectorized, so for
302// vectorized code we should care about the throughput of SQRT operations.
303// But if the code is scalar that probably means that the code has some kind of
304// dependency and we should care more about reducing the latency.
305def FeatureFastScalarFSQRT
306 : SubtargetFeature<"fast-scalar-fsqrt", "HasFastScalarFSQRT",
307 "true", "Scalar SQRT is fast (disable Newton-Raphson)">;
308def FeatureFastVectorFSQRT
309 : SubtargetFeature<"fast-vector-fsqrt", "HasFastVectorFSQRT",
310 "true", "Vector SQRT is fast (disable Newton-Raphson)">;
Pierre Gousseaub6d652a2016-10-14 16:41:38 +0000311// If lzcnt has equivalent latency/throughput to most simple integer ops, it can
312// be used to replace test/set sequences.
313def FeatureFastLZCNT
314 : SubtargetFeature<
315 "fast-lzcnt", "HasFastLZCNT", "true",
316 "LZCNT instructions are as fast as most simple integer ops">;
Simon Pilgrim02bdac52018-01-29 21:24:31 +0000317// If the target can efficiently decode NOPs upto 11-bytes in length.
318def FeatureFast11ByteNOP
319 : SubtargetFeature<
320 "fast-11bytenop", "HasFast11ByteNOP", "true",
321 "Target can quickly decode up to 11 byte NOPs">;
322// If the target can efficiently decode NOPs upto 15-bytes in length.
323def FeatureFast15ByteNOP
324 : SubtargetFeature<
325 "fast-15bytenop", "HasFast15ByteNOP", "true",
326 "Target can quickly decode up to 15 byte NOPs">;
Craig Topperd88389a2017-02-21 06:39:13 +0000327// Sandy Bridge and newer processors can use SHLD with the same source on both
328// inputs to implement rotate to avoid the partial flag update of the normal
329// rotate instructions.
330def FeatureFastSHLDRotate
331 : SubtargetFeature<
332 "fast-shld-rotate", "HasFastSHLDRotate", "true",
333 "SHLD can be used as a faster rotate">;
334
Clement Courbet203fc172017-04-21 09:20:50 +0000335// Ivy Bridge and newer processors have enhanced REP MOVSB and STOSB (aka
336// "string operations"). See "REP String Enhancement" in the Intel Software
Clement Courbet41b43332017-04-21 09:21:05 +0000337// Development Manual. This feature essentially means that REP MOVSB will copy
Clement Courbet203fc172017-04-21 09:20:50 +0000338// using the largest available size instead of copying bytes one by one, making
339// it at least as fast as REPMOVS{W,D,Q}.
340def FeatureERMSB
Clement Courbet1ce3b822017-04-21 09:20:39 +0000341 : SubtargetFeature<
Clement Courbet203fc172017-04-21 09:20:50 +0000342 "ermsb", "HasERMSB", "true",
Clement Courbet1ce3b822017-04-21 09:20:39 +0000343 "REP MOVS/STOS are fast">;
344
Craig Topper641e2af2017-08-30 04:34:48 +0000345// Sandy Bridge and newer processors have many instructions that can be
346// fused with conditional branches and pass through the CPU as a single
347// operation.
348def FeatureMacroFusion
349 : SubtargetFeature<"macrofusion", "HasMacroFusion", "true",
350 "Various instructions can be fused with conditional branches">;
351
Craig Topperea37e202017-11-25 18:09:37 +0000352// Gather is available since Haswell (AVX2 set). So technically, we can
353// generate Gathers on all AVX2 processors. But the overhead on HSW is high.
354// Skylake Client processor has faster Gathers than HSW and performance is
355// similar to Skylake Server (AVX-512).
356def FeatureHasFastGather
357 : SubtargetFeature<"fast-gather", "HasFastGather", "true",
358 "Indicates if gather is reasonably fast.">;
359
Craig Topper0d797a32018-01-20 00:26:08 +0000360def FeaturePrefer256Bit
361 : SubtargetFeature<"prefer-256-bit", "Prefer256Bit", "true",
362 "Prefer 256-bit AVX instructions">;
363
Chandler Carruthae0cafe2018-08-23 06:06:38 +0000364// Lower indirect calls using a special construct called a `retpoline` to
365// mitigate potential Spectre v2 attacks against them.
366def FeatureRetpolineIndirectCalls
367 : SubtargetFeature<
368 "retpoline-indirect-calls", "UseRetpolineIndirectCalls", "true",
369 "Remove speculation of indirect calls from the generated code.">;
370
371// Lower indirect branches and switches either using conditional branch trees
372// or using a special construct called a `retpoline` to mitigate potential
373// Spectre v2 attacks against them.
374def FeatureRetpolineIndirectBranches
375 : SubtargetFeature<
376 "retpoline-indirect-branches", "UseRetpolineIndirectBranches", "true",
377 "Remove speculation of indirect branches from the generated code.">;
378
379// Deprecated umbrella feature for enabling both `retpoline-indirect-calls` and
380// `retpoline-indirect-branches` above.
Chandler Carruthc58f2162018-01-22 22:05:25 +0000381def FeatureRetpoline
Chandler Carruthae0cafe2018-08-23 06:06:38 +0000382 : SubtargetFeature<"retpoline", "DeprecatedUseRetpoline", "true",
Chandler Carruthc58f2162018-01-22 22:05:25 +0000383 "Remove speculation of indirect branches from the "
384 "generated code, either by avoiding them entirely or "
Chandler Carruthae0cafe2018-08-23 06:06:38 +0000385 "lowering them with a speculation blocking construct.",
386 [FeatureRetpolineIndirectCalls,
387 FeatureRetpolineIndirectBranches]>;
Chandler Carruthc58f2162018-01-22 22:05:25 +0000388
389// Rely on external thunks for the emitted retpoline calls. This allows users
390// to provide their own custom thunk definitions in highly specialized
391// environments such as a kernel that does boot-time hot patching.
392def FeatureRetpolineExternalThunk
393 : SubtargetFeature<
394 "retpoline-external-thunk", "UseRetpolineExternalThunk", "true",
Chandler Carruthae0cafe2018-08-23 06:06:38 +0000395 "When lowering an indirect call or branch using a `retpoline`, rely "
396 "on the specified user provided thunk rather than emitting one "
397 "ourselves. Only has effect when combined with some other retpoline "
398 "feature.", [FeatureRetpolineIndirectCalls]>;
Chandler Carruthc58f2162018-01-22 22:05:25 +0000399
Gabor Buellac8ded042018-05-01 10:01:16 +0000400// Direct Move instructions.
401def FeatureMOVDIRI : SubtargetFeature<"movdiri", "HasMOVDIRI", "true",
402 "Support movdiri instruction">;
403def FeatureMOVDIR64B : SubtargetFeature<"movdir64b", "HasMOVDIR64B", "true",
404 "Support movdir64b instruction">;
405
Craig Topper17098292018-09-30 03:01:46 +0000406def FeatureFastBEXTR : SubtargetFeature<"fast-bextr", "HasFastBEXTR", "true",
407 "Indicates that the BEXTR instruction is implemented as a single uop "
408 "with good throughput.">;
409
Sanjay Patele28c8ec2018-10-12 16:41:02 +0000410// Combine vector math operations with shuffles into horizontal math
411// instructions if a CPU implements horizontal operations (introduced with
412// SSE3) with better latency/throughput than the alternative sequence.
413def FeatureFastHorizontalOps
414 : SubtargetFeature<
415 "fast-hops", "HasFastHorizontalOps", "true",
416 "Prefer horizontal vector math instructions (haddp, phsub, etc.) over "
417 "normal vector instructions with shuffles", [FeatureSSE3]>;
418
Rong Xu3d2efdf2018-10-09 22:03:40 +0000419// Merge branches using three-way conditional code.
420def FeatureMergeToThreeWayBranch : SubtargetFeature<"merge-to-threeway-branch",
421 "ThreewayBranchProfitable", "true",
422 "Merge branches to a three-way "
423 "conditional branch">;
424
Evan Chengff1beda2006-10-06 09:17:41 +0000425//===----------------------------------------------------------------------===//
Craig Topper57c28152017-12-10 17:42:36 +0000426// Register File Description
427//===----------------------------------------------------------------------===//
428
429include "X86RegisterInfo.td"
430include "X86RegisterBanks.td"
431
432//===----------------------------------------------------------------------===//
433// Instruction Descriptions
Evan Chengff1beda2006-10-06 09:17:41 +0000434//===----------------------------------------------------------------------===//
435
Andrew Trick8523b162012-02-01 23:20:51 +0000436include "X86Schedule.td"
Craig Topper57c28152017-12-10 17:42:36 +0000437include "X86InstrInfo.td"
Andrea Di Biagiob6022aa2018-07-19 16:42:15 +0000438include "X86SchedPredicates.td"
Craig Topper57c28152017-12-10 17:42:36 +0000439
440def X86InstrInfo : InstrInfo;
441
442//===----------------------------------------------------------------------===//
443// X86 processors supported.
444//===----------------------------------------------------------------------===//
445
446include "X86ScheduleAtom.td"
447include "X86SchedSandyBridge.td"
448include "X86SchedHaswell.td"
449include "X86SchedBroadwell.td"
450include "X86ScheduleSLM.td"
451include "X86ScheduleZnver1.td"
Roman Lebedeva5baf862018-10-27 20:46:30 +0000452include "X86ScheduleBdVer2.td"
Craig Topper57c28152017-12-10 17:42:36 +0000453include "X86ScheduleBtVer2.td"
454include "X86SchedSkylakeClient.td"
455include "X86SchedSkylakeServer.td"
Andrew Trick8523b162012-02-01 23:20:51 +0000456
457def ProcIntelAtom : SubtargetFeature<"atom", "X86ProcFamily", "IntelAtom",
458 "Intel Atom processors">;
Preston Gurd3fe264d2013-09-13 19:23:28 +0000459def ProcIntelSLM : SubtargetFeature<"slm", "X86ProcFamily", "IntelSLM",
460 "Intel Silvermont processors">;
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000461def ProcIntelGLM : SubtargetFeature<"glm", "X86ProcFamily", "IntelGLM",
462 "Intel Goldmont processors">;
Gabor Buella8f1646b2018-04-16 07:47:35 +0000463def ProcIntelGLP : SubtargetFeature<"glp", "X86ProcFamily", "IntelGLP",
464 "Intel Goldmont Plus processors">;
465def ProcIntelTRM : SubtargetFeature<"tremont", "X86ProcFamily", "IntelTRM",
466 "Intel Tremont processors">;
Andrew Trick8523b162012-02-01 23:20:51 +0000467
Evan Chengff1beda2006-10-06 09:17:41 +0000468class Proc<string Name, list<SubtargetFeature> Features>
Andrew Trick87255e32012-07-07 04:00:00 +0000469 : ProcessorModel<Name, GenericModel, Features>;
Andrew Trick8523b162012-02-01 23:20:51 +0000470
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000471def : Proc<"generic", [FeatureX87, FeatureSlowUAMem16]>;
472def : Proc<"i386", [FeatureX87, FeatureSlowUAMem16]>;
473def : Proc<"i486", [FeatureX87, FeatureSlowUAMem16]>;
474def : Proc<"i586", [FeatureX87, FeatureSlowUAMem16]>;
475def : Proc<"pentium", [FeatureX87, FeatureSlowUAMem16]>;
476def : Proc<"pentium-mmx", [FeatureX87, FeatureSlowUAMem16, FeatureMMX]>;
Craig Topper38373222017-11-01 22:15:49 +0000477
Craig Topper505f38a2018-01-10 22:07:16 +0000478def : Proc<"i686", [FeatureX87, FeatureSlowUAMem16, FeatureCMOV]>;
479def : Proc<"pentiumpro", [FeatureX87, FeatureSlowUAMem16, FeatureCMOV,
480 FeatureNOPL]>;
Craig Topper38373222017-11-01 22:15:49 +0000481
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000482def : Proc<"pentium2", [FeatureX87, FeatureSlowUAMem16, FeatureMMX,
Craig Topper505f38a2018-01-10 22:07:16 +0000483 FeatureCMOV, FeatureFXSR, FeatureNOPL]>;
Craig Topper38373222017-11-01 22:15:49 +0000484
485foreach P = ["pentium3", "pentium3m"] in {
486 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureMMX, FeatureSSE1,
Craig Topper128915f2018-08-26 18:29:33 +0000487 FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Craig Topper38373222017-11-01 22:15:49 +0000488}
Mitch Bodarte60465d2016-04-27 22:52:35 +0000489
490// Enable the PostRAScheduler for SSE2 and SSE3 class cpus.
491// The intent is to enable it for pentium4 which is the current default
492// processor in a vanilla 32-bit clang compilation when no specific
493// architecture is specified. This generally gives a nice performance
494// increase on silvermont, with largely neutral behavior on other
495// contemporary large core processors.
496// pentium-m, pentium4m, prescott and nocona are included as a preventative
497// measure to avoid performance surprises, in case clang's default cpu
498// changes slightly.
499
500def : ProcessorModel<"pentium-m", GenericPostRAModel,
501 [FeatureX87, FeatureSlowUAMem16, FeatureMMX,
Craig Topper128915f2018-08-26 18:29:33 +0000502 FeatureSSE2, FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Mitch Bodarte60465d2016-04-27 22:52:35 +0000503
Craig Topper38373222017-11-01 22:15:49 +0000504foreach P = ["pentium4", "pentium4m"] in {
505 def : ProcessorModel<P, GenericPostRAModel,
506 [FeatureX87, FeatureSlowUAMem16, FeatureMMX,
Craig Topper128915f2018-08-26 18:29:33 +0000507 FeatureSSE2, FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Craig Topper38373222017-11-01 22:15:49 +0000508}
Chandler Carruth32908d72014-05-07 17:37:03 +0000509
Andrey Turetskiy958eb462016-04-01 10:16:15 +0000510// Intel Quark.
511def : Proc<"lakemont", []>;
512
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000513// Intel Core Duo.
Craig Topper09b65982015-10-16 06:03:09 +0000514def : ProcessorModel<"yonah", SandyBridgeModel,
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000515 [FeatureX87, FeatureSlowUAMem16, FeatureMMX, FeatureSSE3,
Craig Topper128915f2018-08-26 18:29:33 +0000516 FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000517
518// NetBurst.
Mitch Bodarte60465d2016-04-27 22:52:35 +0000519def : ProcessorModel<"prescott", GenericPostRAModel,
520 [FeatureX87, FeatureSlowUAMem16, FeatureMMX, FeatureSSE3,
Craig Topper128915f2018-08-26 18:29:33 +0000521 FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Mitch Bodarte60465d2016-04-27 22:52:35 +0000522def : ProcessorModel<"nocona", GenericPostRAModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000523 FeatureX87,
Eric Christopher11e59832015-10-08 20:10:06 +0000524 FeatureSlowUAMem16,
Craig Topper128915f2018-08-26 18:29:33 +0000525 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000526 FeatureMMX,
527 FeatureSSE3,
Craig Topper09b65982015-10-16 06:03:09 +0000528 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000529 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000530 Feature64Bit,
Craig Topper27381172017-10-15 16:57:33 +0000531 FeatureCMPXCHG16B
Eric Christopher11e59832015-10-08 20:10:06 +0000532]>;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000533
534// Intel Core 2 Solo/Duo.
Eric Christopher11e59832015-10-08 20:10:06 +0000535def : ProcessorModel<"core2", SandyBridgeModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000536 FeatureX87,
Eric Christopher11e59832015-10-08 20:10:06 +0000537 FeatureSlowUAMem16,
Craig Topper128915f2018-08-26 18:29:33 +0000538 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000539 FeatureMMX,
540 FeatureSSSE3,
Craig Topper09b65982015-10-16 06:03:09 +0000541 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000542 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000543 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000544 FeatureCMPXCHG16B,
Craig Topper641e2af2017-08-30 04:34:48 +0000545 FeatureLAHFSAHF,
546 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000547]>;
548def : ProcessorModel<"penryn", SandyBridgeModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000549 FeatureX87,
Eric Christopher11e59832015-10-08 20:10:06 +0000550 FeatureSlowUAMem16,
Craig Topper128915f2018-08-26 18:29:33 +0000551 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000552 FeatureMMX,
553 FeatureSSE41,
Craig Topper09b65982015-10-16 06:03:09 +0000554 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000555 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000556 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000557 FeatureCMPXCHG16B,
Craig Topper641e2af2017-08-30 04:34:48 +0000558 FeatureLAHFSAHF,
559 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000560]>;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000561
Chandler Carruthaf8924032014-12-09 10:58:36 +0000562// Atom CPUs.
563class BonnellProc<string Name> : ProcessorModel<Name, AtomModel, [
Eric Christopher11e59832015-10-08 20:10:06 +0000564 ProcIntelAtom,
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000565 FeatureX87,
Eric Christopher11e59832015-10-08 20:10:06 +0000566 FeatureSlowUAMem16,
Craig Topper128915f2018-08-26 18:29:33 +0000567 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000568 FeatureMMX,
569 FeatureSSSE3,
Craig Topper09b65982015-10-16 06:03:09 +0000570 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000571 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000572 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000573 FeatureCMPXCHG16B,
574 FeatureMOVBE,
Sanjay Patel53d1d8b2015-10-12 15:24:01 +0000575 FeatureLEAForSP,
Eric Christopher11e59832015-10-08 20:10:06 +0000576 FeatureSlowDivide32,
577 FeatureSlowDivide64,
Craig Topper62c47a22017-08-29 05:14:27 +0000578 FeatureSlowTwoMemOps,
Eric Christopher11e59832015-10-08 20:10:06 +0000579 FeatureLEAUsesAG,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000580 FeaturePadShortFunctions,
581 FeatureLAHFSAHF
Eric Christopher11e59832015-10-08 20:10:06 +0000582]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000583def : BonnellProc<"bonnell">;
584def : BonnellProc<"atom">; // Pin the generic name to the baseline.
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000585
Chandler Carruthaf8924032014-12-09 10:58:36 +0000586class SilvermontProc<string Name> : ProcessorModel<Name, SLMModel, [
Eric Christopher11e59832015-10-08 20:10:06 +0000587 ProcIntelSLM,
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000588 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000589 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000590 FeatureMMX,
591 FeatureSSE42,
Craig Topper09b65982015-10-16 06:03:09 +0000592 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000593 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000594 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000595 FeatureCMPXCHG16B,
596 FeatureMOVBE,
597 FeaturePOPCNT,
598 FeaturePCLMUL,
Eric Christopher11e59832015-10-08 20:10:06 +0000599 FeatureSlowDivide64,
Craig Topper62c47a22017-08-29 05:14:27 +0000600 FeatureSlowTwoMemOps,
Eric Christopher11e59832015-10-08 20:10:06 +0000601 FeaturePRFCHW,
602 FeatureSlowLEA,
603 FeatureSlowIncDec,
Zvi Rackover8bc7e4d2016-12-06 19:35:20 +0000604 FeatureSlowPMULLD,
Craig Topperb207dd62018-01-26 19:34:14 +0000605 FeatureRDRAND,
Craig Topperbc895a32018-04-19 19:25:24 +0000606 FeatureLAHFSAHF,
607 FeaturePOPCNTFalseDeps
Eric Christopher11e59832015-10-08 20:10:06 +0000608]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000609def : SilvermontProc<"silvermont">;
610def : SilvermontProc<"slm">; // Legacy alias.
611
Gabor Buella8f1646b2018-04-16 07:47:35 +0000612class ProcessorFeatures<list<SubtargetFeature> Inherited,
613 list<SubtargetFeature> NewFeatures> {
614 list<SubtargetFeature> Value = !listconcat(Inherited, NewFeatures);
615}
616
617class ProcModel<string Name, SchedMachineModel Model,
618 list<SubtargetFeature> ProcFeatures,
619 list<SubtargetFeature> OtherFeatures> :
620 ProcessorModel<Name, Model, !listconcat(ProcFeatures, OtherFeatures)>;
621
622def GLMFeatures : ProcessorFeatures<[], [
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000623 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000624 FeatureCMOV,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000625 FeatureMMX,
626 FeatureSSE42,
627 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000628 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000629 Feature64Bit,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000630 FeatureCMPXCHG16B,
631 FeatureMOVBE,
632 FeaturePOPCNT,
633 FeaturePCLMUL,
634 FeatureAES,
635 FeaturePRFCHW,
Craig Topper62c47a22017-08-29 05:14:27 +0000636 FeatureSlowTwoMemOps,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000637 FeatureSlowLEA,
638 FeatureSlowIncDec,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000639 FeatureLAHFSAHF,
640 FeatureMPX,
641 FeatureSHA,
Craig Toppera4c5caf2017-07-04 05:33:19 +0000642 FeatureRDRAND,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000643 FeatureRDSEED,
644 FeatureXSAVE,
645 FeatureXSAVEOPT,
646 FeatureXSAVEC,
647 FeatureXSAVES,
Michael Zuckermanac1d20d2017-09-25 13:45:31 +0000648 FeatureCLFLUSHOPT,
649 FeatureFSGSBase
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000650]>;
Gabor Buella8f1646b2018-04-16 07:47:35 +0000651
652class GoldmontProc<string Name> : ProcModel<Name, SLMModel,
Craig Topperbc895a32018-04-19 19:25:24 +0000653 GLMFeatures.Value, [
654 ProcIntelGLM,
655 FeaturePOPCNTFalseDeps
656]>;
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000657def : GoldmontProc<"goldmont">;
658
Gabor Buellaa832b222018-05-10 07:26:05 +0000659def GLPFeatures : ProcessorFeatures<GLMFeatures.Value, [
660 FeaturePTWRITE,
Gabor Buella8f1646b2018-04-16 07:47:35 +0000661 FeatureRDPID,
662 FeatureSGX
663]>;
Gabor Buellaa832b222018-05-10 07:26:05 +0000664
665class GoldmontPlusProc<string Name> : ProcModel<Name, SLMModel,
666 GLPFeatures.Value, [
667 ProcIntelGLP
668]>;
Gabor Buella8f1646b2018-04-16 07:47:35 +0000669def : GoldmontPlusProc<"goldmont-plus">;
670
671class TremontProc<string Name> : ProcModel<Name, SLMModel,
Gabor Buellaa832b222018-05-10 07:26:05 +0000672 GLPFeatures.Value, [
Gabor Buella8f1646b2018-04-16 07:47:35 +0000673 ProcIntelTRM,
674 FeatureCLDEMOTE,
675 FeatureGFNI,
Gabor Buellac8ded042018-05-01 10:01:16 +0000676 FeatureMOVDIRI,
677 FeatureMOVDIR64B,
Gabor Buella31fa8022018-04-20 18:42:47 +0000678 FeatureWAITPKG
Gabor Buella8f1646b2018-04-16 07:47:35 +0000679]>;
680def : TremontProc<"tremont">;
681
Eric Christopher2ef63182010-04-02 21:54:27 +0000682// "Arrandale" along with corei3 and corei5
Craig Topper3611d9b2015-03-30 06:31:11 +0000683class NehalemProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000684 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000685 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000686 FeatureMMX,
687 FeatureSSE42,
Craig Topper09b65982015-10-16 06:03:09 +0000688 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000689 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000690 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000691 FeatureCMPXCHG16B,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000692 FeaturePOPCNT,
Craig Topper641e2af2017-08-30 04:34:48 +0000693 FeatureLAHFSAHF,
694 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000695]>;
Craig Topper3611d9b2015-03-30 06:31:11 +0000696def : NehalemProc<"nehalem">;
697def : NehalemProc<"corei7">;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000698
Eric Christopher2ef63182010-04-02 21:54:27 +0000699// Westmere is a similar machine to nehalem with some additional features.
700// Westmere is the corei3/i5/i7 path from nehalem to sandybridge
Chandler Carruthaf8924032014-12-09 10:58:36 +0000701class WestmereProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000702 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000703 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000704 FeatureMMX,
705 FeatureSSE42,
Craig Topper09b65982015-10-16 06:03:09 +0000706 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000707 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000708 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000709 FeatureCMPXCHG16B,
Eric Christopher11e59832015-10-08 20:10:06 +0000710 FeaturePOPCNT,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000711 FeaturePCLMUL,
Craig Topper641e2af2017-08-30 04:34:48 +0000712 FeatureLAHFSAHF,
713 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000714]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000715def : WestmereProc<"westmere">;
716
Nate Begeman8b08f522010-12-10 00:26:57 +0000717// SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
718// rather than a superset.
Craig Topperf730a6b2016-02-13 21:35:37 +0000719def SNBFeatures : ProcessorFeatures<[], [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000720 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000721 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000722 FeatureMMX,
723 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +0000724 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000725 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000726 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000727 FeatureCMPXCHG16B,
Eric Christopher11e59832015-10-08 20:10:06 +0000728 FeaturePOPCNT,
Nikolai Bozhenov6bdf92c2017-01-12 19:34:15 +0000729 FeatureSlowDivide64,
Craig Topper0ee35692015-10-14 05:37:38 +0000730 FeaturePCLMUL,
731 FeatureXSAVE,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000732 FeatureXSAVEOPT,
Nikolai Bozhenovf6795302016-08-04 12:47:28 +0000733 FeatureLAHFSAHF,
Lama Saba2ea271b2017-05-18 08:11:50 +0000734 FeatureSlow3OpsLEA,
Craig Topperd88389a2017-02-21 06:39:13 +0000735 FeatureFastScalarFSQRT,
Craig Topper641e2af2017-08-30 04:34:48 +0000736 FeatureFastSHLDRotate,
Craig Topperef1f7162017-08-30 05:00:35 +0000737 FeatureSlowIncDec,
Rong Xu3d2efdf2018-10-09 22:03:40 +0000738 FeatureMergeToThreeWayBranch,
Craig Topper641e2af2017-08-30 04:34:48 +0000739 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000740]>;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000741
Craig Topperf730a6b2016-02-13 21:35:37 +0000742class SandyBridgeProc<string Name> : ProcModel<Name, SandyBridgeModel,
743 SNBFeatures.Value, [
Marina Yatsina77a21db2018-01-22 10:07:01 +0000744 FeatureSlowUAMem32,
745 FeaturePOPCNTFalseDeps
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000746]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000747def : SandyBridgeProc<"sandybridge">;
748def : SandyBridgeProc<"corei7-avx">; // Legacy alias.
Evan Chengff1beda2006-10-06 09:17:41 +0000749
Craig Topperf730a6b2016-02-13 21:35:37 +0000750def IVBFeatures : ProcessorFeatures<SNBFeatures.Value, [
Eric Christopher11e59832015-10-08 20:10:06 +0000751 FeatureRDRAND,
752 FeatureF16C,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000753 FeatureFSGSBase
754]>;
755
Craig Topperf730a6b2016-02-13 21:35:37 +0000756class IvyBridgeProc<string Name> : ProcModel<Name, SandyBridgeModel,
757 IVBFeatures.Value, [
Marina Yatsina77a21db2018-01-22 10:07:01 +0000758 FeatureSlowUAMem32,
759 FeaturePOPCNTFalseDeps
Eric Christopher11e59832015-10-08 20:10:06 +0000760]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000761def : IvyBridgeProc<"ivybridge">;
762def : IvyBridgeProc<"core-avx-i">; // Legacy alias.
Craig Topper3657fe42011-10-14 03:21:46 +0000763
Craig Topperf730a6b2016-02-13 21:35:37 +0000764def HSWFeatures : ProcessorFeatures<IVBFeatures.Value, [
Eric Christopher11e59832015-10-08 20:10:06 +0000765 FeatureAVX2,
Eric Christopher11e59832015-10-08 20:10:06 +0000766 FeatureBMI,
767 FeatureBMI2,
Clement Courbet203fc172017-04-21 09:20:50 +0000768 FeatureERMSB,
Eric Christopher11e59832015-10-08 20:10:06 +0000769 FeatureFMA,
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000770 FeatureINVPCID,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000771 FeatureLZCNT,
Simon Pilgrimfd5df632017-12-19 13:16:43 +0000772 FeatureMOVBE,
773 FeatureFastVariableShuffle
Eric Christopher11e59832015-10-08 20:10:06 +0000774]>;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000775
Craig Topperf730a6b2016-02-13 21:35:37 +0000776class HaswellProc<string Name> : ProcModel<Name, HaswellModel,
Mohammed Agabariae9aebf22017-09-13 09:00:27 +0000777 HSWFeatures.Value, [
Marina Yatsina77a21db2018-01-22 10:07:01 +0000778 FeaturePOPCNTFalseDeps,
779 FeatureLZCNTFalseDeps
Craig Topper54541c42017-10-13 16:04:08 +0000780]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000781def : HaswellProc<"haswell">;
782def : HaswellProc<"core-avx2">; // Legacy alias.
783
Craig Topperf730a6b2016-02-13 21:35:37 +0000784def BDWFeatures : ProcessorFeatures<HSWFeatures.Value, [
Eric Christopher11e59832015-10-08 20:10:06 +0000785 FeatureADX,
Craig Topper67885f52017-12-22 02:41:12 +0000786 FeatureRDSEED,
787 FeaturePRFCHW
Eric Christopher11e59832015-10-08 20:10:06 +0000788]>;
Gadi Haber323f2e12017-10-24 20:19:47 +0000789class BroadwellProc<string Name> : ProcModel<Name, BroadwellModel,
Craig Topper54541c42017-10-13 16:04:08 +0000790 BDWFeatures.Value, [
Marina Yatsina77a21db2018-01-22 10:07:01 +0000791 FeaturePOPCNTFalseDeps,
792 FeatureLZCNTFalseDeps
Craig Topper54541c42017-10-13 16:04:08 +0000793]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000794def : BroadwellProc<"broadwell">;
795
Craig Topperf730a6b2016-02-13 21:35:37 +0000796def SKLFeatures : ProcessorFeatures<BDWFeatures.Value, [
Erich Keane911ddd62018-09-10 21:12:19 +0000797 FeatureAES,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000798 FeatureMPX,
799 FeatureXSAVEC,
800 FeatureXSAVES,
Nikolai Bozhenovf6795302016-08-04 12:47:28 +0000801 FeatureCLFLUSHOPT,
802 FeatureFastVectorFSQRT
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000803]>;
804
Gadi Haber6f8fbf42017-09-19 06:19:27 +0000805class SkylakeClientProc<string Name> : ProcModel<Name, SkylakeClientModel,
Mohammed Agabariae9aebf22017-09-13 09:00:27 +0000806 SKLFeatures.Value, [
Marina Yatsina77a21db2018-01-22 10:07:01 +0000807 FeatureHasFastGather,
Gabor Buella3eab22d2018-04-10 13:58:57 +0000808 FeaturePOPCNTFalseDeps,
809 FeatureSGX
Craig Topper5805fb32017-10-13 16:06:06 +0000810]>;
Sanjoy Dasaa63dc02016-02-21 17:12:03 +0000811def : SkylakeClientProc<"skylake">;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000812
Craig Topper7bb8c2e2018-10-24 19:24:44 +0000813def KNLFeatures : ProcessorFeatures<[], [
814 FeatureX87,
815 FeatureCMOV,
816 FeatureMMX,
817 FeatureFXSR,
818 FeatureNOPL,
819 Feature64Bit,
820 FeatureCMPXCHG16B,
821 FeaturePOPCNT,
822 FeatureSlowDivide64,
823 FeaturePCLMUL,
824 FeatureXSAVE,
825 FeatureXSAVEOPT,
826 FeatureLAHFSAHF,
827 FeatureSlow3OpsLEA,
Craig Topper7bb8c2e2018-10-24 19:24:44 +0000828 FeatureSlowIncDec,
Craig Topper220fd332018-10-29 18:17:01 +0000829 FeatureAES,
Craig Topper7bb8c2e2018-10-24 19:24:44 +0000830 FeatureRDRAND,
831 FeatureF16C,
832 FeatureFSGSBase,
Eric Christopher11e59832015-10-08 20:10:06 +0000833 FeatureAVX512,
834 FeatureERI,
835 FeatureCDI,
836 FeaturePFI,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000837 FeaturePREFETCHWT1,
838 FeatureADX,
839 FeatureRDSEED,
Eric Christopher11e59832015-10-08 20:10:06 +0000840 FeatureMOVBE,
841 FeatureLZCNT,
842 FeatureBMI,
843 FeatureBMI2,
Craig Topper67885f52017-12-22 02:41:12 +0000844 FeatureFMA,
845 FeaturePRFCHW
Craig Topper5d692912017-10-13 18:10:17 +0000846]>;
847
848// FIXME: define KNL model
849class KnightsLandingProc<string Name> : ProcModel<Name, HaswellModel,
850 KNLFeatures.Value, [
Craig Topper62c47a22017-08-29 05:14:27 +0000851 FeatureSlowTwoMemOps,
Craig Topperea37e202017-11-25 18:09:37 +0000852 FeatureFastPartialYMMorZMMWrite,
Craig Topperc10de9a2018-10-25 17:29:00 +0000853 FeatureHasFastGather,
854 FeatureSlowPMADDWD
Eric Christopher11e59832015-10-08 20:10:06 +0000855]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000856def : KnightsLandingProc<"knl">;
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000857
Craig Topper5d692912017-10-13 18:10:17 +0000858class KnightsMillProc<string Name> : ProcModel<Name, HaswellModel,
859 KNLFeatures.Value, [
Craig Topper5d692912017-10-13 18:10:17 +0000860 FeatureSlowTwoMemOps,
Craig Topper6fae2ee2017-10-25 17:10:32 +0000861 FeatureFastPartialYMMorZMMWrite,
Craig Topperea37e202017-11-25 18:09:37 +0000862 FeatureHasFastGather,
Craig Topperc10de9a2018-10-25 17:29:00 +0000863 FeatureSlowPMADDWD,
Craig Topper6fae2ee2017-10-25 17:10:32 +0000864 FeatureVPOPCNTDQ
Craig Topper5d692912017-10-13 18:10:17 +0000865]>;
866def : KnightsMillProc<"knm">; // TODO Add AVX5124FMAPS/AVX5124VNNIW features
867
Craig Topperf730a6b2016-02-13 21:35:37 +0000868def SKXFeatures : ProcessorFeatures<SKLFeatures.Value, [
Eric Christopher11e59832015-10-08 20:10:06 +0000869 FeatureAVX512,
870 FeatureCDI,
871 FeatureDQI,
872 FeatureBWI,
873 FeatureVLX,
Asaf Badouh5acf66f2015-12-15 13:35:29 +0000874 FeaturePKU,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000875 FeatureCLWB
Eric Christopher11e59832015-10-08 20:10:06 +0000876]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000877
Gadi Haber684944b2017-10-08 12:52:54 +0000878class SkylakeServerProc<string Name> : ProcModel<Name, SkylakeServerModel,
Mohammed Agabariae9aebf22017-09-13 09:00:27 +0000879 SKXFeatures.Value, [
Craig Toppera8f87a32018-01-29 21:56:48 +0000880 FeatureHasFastGather,
881 FeaturePOPCNTFalseDeps
Craig Toppera1f9c9dd2017-10-15 16:41:15 +0000882]>;
Sanjoy Dasaa63dc02016-02-21 17:12:03 +0000883def : SkylakeServerProc<"skylake-avx512">;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000884def : SkylakeServerProc<"skx">; // Legacy alias.
885
Craig Topper5fb34b52018-11-27 18:05:00 +0000886def CLXFeatures : ProcessorFeatures<SKXFeatures.Value, [
887 FeatureVNNI
888]>;
889
890class CascadelakeProc<string Name> : ProcModel<Name, SkylakeServerModel,
891 CLXFeatures.Value, [
892 FeatureHasFastGather,
893 FeaturePOPCNTFalseDeps
894]>;
895def : CascadelakeProc<"cascadelake">;
896
Craig Topperd710ada2018-02-21 00:15:48 +0000897def CNLFeatures : ProcessorFeatures<SKLFeatures.Value, [
898 FeatureAVX512,
899 FeatureCDI,
900 FeatureDQI,
901 FeatureBWI,
902 FeatureVLX,
903 FeaturePKU,
Elena Demikhovsky9242ea82016-01-18 13:00:31 +0000904 FeatureVBMI,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000905 FeatureIFMA,
Gabor Buella3eab22d2018-04-10 13:58:57 +0000906 FeatureSHA,
907 FeatureSGX
Elena Demikhovsky9242ea82016-01-18 13:00:31 +0000908]>;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000909
Craig Topper9a94dfc2017-11-19 01:25:30 +0000910class CannonlakeProc<string Name> : ProcModel<Name, SkylakeServerModel,
Mohammed Agabariae9aebf22017-09-13 09:00:27 +0000911 CNLFeatures.Value, [
Craig Topperea37e202017-11-25 18:09:37 +0000912 FeatureHasFastGather
Craig Topper5805fb32017-10-13 16:06:06 +0000913]>;
Elena Demikhovsky9242ea82016-01-18 13:00:31 +0000914def : CannonlakeProc<"cannonlake">;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000915
Craig Topper81037f32017-11-19 01:12:00 +0000916def ICLFeatures : ProcessorFeatures<CNLFeatures.Value, [
Craig Toppera8905702017-11-21 21:05:18 +0000917 FeatureBITALG,
918 FeatureVAES,
919 FeatureVBMI2,
920 FeatureVNNI,
921 FeatureVPCLMULQDQ,
Coby Tayreed8b17be2017-11-26 09:36:41 +0000922 FeatureVPOPCNTDQ,
Craig Topper55cfa892017-12-27 22:04:04 +0000923 FeatureGFNI,
Craig Topper84b26b92018-01-18 23:52:31 +0000924 FeatureCLWB,
925 FeatureRDPID
Craig Topper81037f32017-11-19 01:12:00 +0000926]>;
927
Gabor Buella213edc42018-04-10 18:59:13 +0000928class IcelakeClientProc<string Name> : ProcModel<Name, SkylakeServerModel,
929 ICLFeatures.Value, [
Craig Topperea37e202017-11-25 18:09:37 +0000930 FeatureHasFastGather
Craig Topper81037f32017-11-19 01:12:00 +0000931]>;
Gabor Buella213edc42018-04-10 18:59:13 +0000932def : IcelakeClientProc<"icelake-client">;
933
934class IcelakeServerProc<string Name> : ProcModel<Name, SkylakeServerModel,
935 ICLFeatures.Value, [
Gabor Buella2b5e9602018-05-08 06:47:36 +0000936 FeaturePCONFIG,
Gabor Buella2ef36f32018-04-11 20:01:57 +0000937 FeatureWBNOINVD,
Gabor Buella213edc42018-04-10 18:59:13 +0000938 FeatureHasFastGather
939]>;
940def : IcelakeServerProc<"icelake-server">;
Craig Topper81037f32017-11-19 01:12:00 +0000941
Chandler Carruthaf8924032014-12-09 10:58:36 +0000942// AMD CPUs.
Robert Khasanovbfa01312014-07-21 14:54:21 +0000943
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000944def : Proc<"k6", [FeatureX87, FeatureSlowUAMem16, FeatureMMX]>;
945def : Proc<"k6-2", [FeatureX87, FeatureSlowUAMem16, Feature3DNow]>;
946def : Proc<"k6-3", [FeatureX87, FeatureSlowUAMem16, Feature3DNow]>;
Craig Topper38373222017-11-01 22:15:49 +0000947
948foreach P = ["athlon", "athlon-tbird"] in {
Craig Topperb68a78b2018-08-26 18:29:27 +0000949 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureCMOV, Feature3DNowA,
Craig Topper505f38a2018-01-10 22:07:16 +0000950 FeatureNOPL, FeatureSlowSHLD]>;
Craig Topper38373222017-11-01 22:15:49 +0000951}
952
953foreach P = ["athlon-4", "athlon-xp", "athlon-mp"] in {
Craig Topper128915f2018-08-26 18:29:33 +0000954 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureCMOV, FeatureSSE1,
Craig Topper505f38a2018-01-10 22:07:16 +0000955 Feature3DNowA, FeatureFXSR, FeatureNOPL, FeatureSlowSHLD]>;
Craig Topper38373222017-11-01 22:15:49 +0000956}
957
958foreach P = ["k8", "opteron", "athlon64", "athlon-fx"] in {
959 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureSSE2, Feature3DNowA,
Craig Topper128915f2018-08-26 18:29:33 +0000960 FeatureFXSR, FeatureNOPL, Feature64Bit, FeatureSlowSHLD,
961 FeatureCMOV]>;
Craig Topper38373222017-11-01 22:15:49 +0000962}
963
964foreach P = ["k8-sse3", "opteron-sse3", "athlon64-sse3"] in {
965 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureSSE3, Feature3DNowA,
Craig Topper128915f2018-08-26 18:29:33 +0000966 FeatureFXSR, FeatureNOPL, FeatureCMPXCHG16B, FeatureSlowSHLD,
Craig Topperb7b353b2018-08-30 06:01:05 +0000967 FeatureCMOV, Feature64Bit]>;
Craig Topper38373222017-11-01 22:15:49 +0000968}
969
970foreach P = ["amdfam10", "barcelona"] in {
971 def : Proc<P, [FeatureX87, FeatureSSE4A, Feature3DNowA, FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000972 FeatureNOPL, FeatureCMPXCHG16B, FeatureLZCNT, FeaturePOPCNT,
Craig Topperb7b353b2018-08-30 06:01:05 +0000973 FeatureSlowSHLD, FeatureLAHFSAHF, FeatureCMOV, Feature64Bit]>;
Craig Topper38373222017-11-01 22:15:49 +0000974}
Sanjay Patel9e916dc2015-08-21 20:17:26 +0000975
Benjamin Kramer077ae1d2012-01-10 11:50:02 +0000976// Bobcat
Eric Christopher11e59832015-10-08 20:10:06 +0000977def : Proc<"btver1", [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000978 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000979 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000980 FeatureMMX,
981 FeatureSSSE3,
982 FeatureSSE4A,
Craig Topper09b65982015-10-16 06:03:09 +0000983 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000984 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000985 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000986 FeatureCMPXCHG16B,
987 FeaturePRFCHW,
988 FeatureLZCNT,
989 FeaturePOPCNT,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000990 FeatureSlowSHLD,
Simon Pilgrim02bdac52018-01-29 21:24:31 +0000991 FeatureLAHFSAHF,
992 FeatureFast15ByteNOP
Eric Christopher11e59832015-10-08 20:10:06 +0000993]>;
Sanjay Patel1191adf2014-09-09 20:07:07 +0000994
Benjamin Kramerb44c4272013-05-03 10:20:08 +0000995// Jaguar
Eric Christopher11e59832015-10-08 20:10:06 +0000996def : ProcessorModel<"btver2", BtVer2Model, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000997 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000998 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000999 FeatureMMX,
1000 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +00001001 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001002 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +00001003 FeatureSSE4A,
Craig Topperb7b353b2018-08-30 06:01:05 +00001004 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +00001005 FeatureCMPXCHG16B,
1006 FeaturePRFCHW,
1007 FeatureAES,
1008 FeaturePCLMUL,
1009 FeatureBMI,
1010 FeatureF16C,
1011 FeatureMOVBE,
1012 FeatureLZCNT,
Pierre Gousseaub6d652a2016-10-14 16:41:38 +00001013 FeatureFastLZCNT,
Eric Christopher11e59832015-10-08 20:10:06 +00001014 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +00001015 FeatureXSAVE,
1016 FeatureXSAVEOPT,
Hans Wennborg5000ce82015-12-04 23:00:33 +00001017 FeatureSlowSHLD,
Yunzhong Gao0de36ec2016-02-12 23:37:57 +00001018 FeatureLAHFSAHF,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001019 FeatureFast15ByteNOP,
Craig Topper17098292018-09-30 03:01:46 +00001020 FeatureFastBEXTR,
Sanjay Patele28c8ec2018-10-12 16:41:02 +00001021 FeatureFastPartialYMMorZMMWrite,
1022 FeatureFastHorizontalOps
Eric Christopher11e59832015-10-08 20:10:06 +00001023]>;
Sanjay Patele57f3c02014-11-28 18:40:18 +00001024
Benjamin Kramer077ae1d2012-01-10 11:50:02 +00001025// Bulldozer
Roman Lebedeva5baf862018-10-27 20:46:30 +00001026def : ProcessorModel<"bdver1", BdVer2Model, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001027 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +00001028 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +00001029 FeatureXOP,
1030 FeatureFMA4,
Craig Topperb7b353b2018-08-30 06:01:05 +00001031 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +00001032 FeatureCMPXCHG16B,
1033 FeatureAES,
1034 FeaturePRFCHW,
1035 FeaturePCLMUL,
1036 FeatureMMX,
1037 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +00001038 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001039 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +00001040 FeatureSSE4A,
1041 FeatureLZCNT,
1042 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +00001043 FeatureXSAVE,
Simon Pilgrim99b925b2017-05-03 15:51:39 +00001044 FeatureLWP,
Hans Wennborg5000ce82015-12-04 23:00:33 +00001045 FeatureSlowSHLD,
Craig Topper641e2af2017-08-30 04:34:48 +00001046 FeatureLAHFSAHF,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001047 FeatureFast11ByteNOP,
Craig Topper641e2af2017-08-30 04:34:48 +00001048 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +00001049]>;
Benjamin Kramerb44c4272013-05-03 10:20:08 +00001050// Piledriver
Roman Lebedeva5baf862018-10-27 20:46:30 +00001051def : ProcessorModel<"bdver2", BdVer2Model, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001052 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +00001053 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +00001054 FeatureXOP,
1055 FeatureFMA4,
Craig Topperb7b353b2018-08-30 06:01:05 +00001056 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +00001057 FeatureCMPXCHG16B,
1058 FeatureAES,
1059 FeaturePRFCHW,
1060 FeaturePCLMUL,
1061 FeatureMMX,
1062 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +00001063 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001064 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +00001065 FeatureSSE4A,
1066 FeatureF16C,
1067 FeatureLZCNT,
1068 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +00001069 FeatureXSAVE,
Eric Christopher11e59832015-10-08 20:10:06 +00001070 FeatureBMI,
1071 FeatureTBM,
Simon Pilgrim99b925b2017-05-03 15:51:39 +00001072 FeatureLWP,
Eric Christopher11e59832015-10-08 20:10:06 +00001073 FeatureFMA,
Hans Wennborg5000ce82015-12-04 23:00:33 +00001074 FeatureSlowSHLD,
Craig Topper641e2af2017-08-30 04:34:48 +00001075 FeatureLAHFSAHF,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001076 FeatureFast11ByteNOP,
Craig Topper17098292018-09-30 03:01:46 +00001077 FeatureFastBEXTR,
Craig Topper641e2af2017-08-30 04:34:48 +00001078 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +00001079]>;
Benjamin Kramerd114def2013-11-04 10:29:20 +00001080
1081// Steamroller
Eric Christopher11e59832015-10-08 20:10:06 +00001082def : Proc<"bdver3", [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001083 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +00001084 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +00001085 FeatureXOP,
1086 FeatureFMA4,
Craig Topperb7b353b2018-08-30 06:01:05 +00001087 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +00001088 FeatureCMPXCHG16B,
1089 FeatureAES,
1090 FeaturePRFCHW,
1091 FeaturePCLMUL,
1092 FeatureMMX,
1093 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +00001094 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001095 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +00001096 FeatureSSE4A,
1097 FeatureF16C,
1098 FeatureLZCNT,
1099 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +00001100 FeatureXSAVE,
Eric Christopher11e59832015-10-08 20:10:06 +00001101 FeatureBMI,
1102 FeatureTBM,
Simon Pilgrim99b925b2017-05-03 15:51:39 +00001103 FeatureLWP,
Eric Christopher11e59832015-10-08 20:10:06 +00001104 FeatureFMA,
Craig Topper0ee35692015-10-14 05:37:38 +00001105 FeatureXSAVEOPT,
Eric Christopher11e59832015-10-08 20:10:06 +00001106 FeatureSlowSHLD,
Hans Wennborg5000ce82015-12-04 23:00:33 +00001107 FeatureFSGSBase,
Craig Topper641e2af2017-08-30 04:34:48 +00001108 FeatureLAHFSAHF,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001109 FeatureFast11ByteNOP,
Craig Topper17098292018-09-30 03:01:46 +00001110 FeatureFastBEXTR,
Craig Topper641e2af2017-08-30 04:34:48 +00001111 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +00001112]>;
Benjamin Kramerd114def2013-11-04 10:29:20 +00001113
Benjamin Kramer60045732014-05-02 15:47:07 +00001114// Excavator
Eric Christopher11e59832015-10-08 20:10:06 +00001115def : Proc<"bdver4", [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001116 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +00001117 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +00001118 FeatureMMX,
1119 FeatureAVX2,
Craig Topper09b65982015-10-16 06:03:09 +00001120 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001121 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +00001122 FeatureXOP,
1123 FeatureFMA4,
Craig Topperb7b353b2018-08-30 06:01:05 +00001124 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +00001125 FeatureCMPXCHG16B,
1126 FeatureAES,
1127 FeaturePRFCHW,
1128 FeaturePCLMUL,
1129 FeatureF16C,
1130 FeatureLZCNT,
1131 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +00001132 FeatureXSAVE,
Eric Christopher11e59832015-10-08 20:10:06 +00001133 FeatureBMI,
1134 FeatureBMI2,
1135 FeatureTBM,
Simon Pilgrim99b925b2017-05-03 15:51:39 +00001136 FeatureLWP,
Eric Christopher11e59832015-10-08 20:10:06 +00001137 FeatureFMA,
Craig Topper0ee35692015-10-14 05:37:38 +00001138 FeatureXSAVEOPT,
Simon Pilgrim381a0ad2016-07-24 16:00:53 +00001139 FeatureSlowSHLD,
Hans Wennborg5000ce82015-12-04 23:00:33 +00001140 FeatureFSGSBase,
Ashutosh Nema348af9c2016-05-18 11:59:12 +00001141 FeatureLAHFSAHF,
Craig Topper17098292018-09-30 03:01:46 +00001142 FeatureFastBEXTR,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001143 FeatureFast11ByteNOP,
Craig Topper641e2af2017-08-30 04:34:48 +00001144 FeatureMWAITX,
1145 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +00001146]>;
Benjamin Kramer60045732014-05-02 15:47:07 +00001147
Craig Topper106b5b62017-07-19 02:45:14 +00001148// Znver1
1149def: ProcessorModel<"znver1", Znver1Model, [
Craig Topperd55b8312017-01-10 06:01:16 +00001150 FeatureADX,
1151 FeatureAES,
1152 FeatureAVX2,
1153 FeatureBMI,
1154 FeatureBMI2,
1155 FeatureCLFLUSHOPT,
Craig Topper50f3d142017-02-09 04:27:34 +00001156 FeatureCLZERO,
Craig Topper128915f2018-08-26 18:29:33 +00001157 FeatureCMOV,
Craig Topperb7b353b2018-08-30 06:01:05 +00001158 Feature64Bit,
Craig Topperd55b8312017-01-10 06:01:16 +00001159 FeatureCMPXCHG16B,
1160 FeatureF16C,
1161 FeatureFMA,
1162 FeatureFSGSBase,
1163 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001164 FeatureNOPL,
Craig Topperd55b8312017-01-10 06:01:16 +00001165 FeatureFastLZCNT,
1166 FeatureLAHFSAHF,
1167 FeatureLZCNT,
Craig Topper17098292018-09-30 03:01:46 +00001168 FeatureFastBEXTR,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001169 FeatureFast15ByteNOP,
Craig Topper641e2af2017-08-30 04:34:48 +00001170 FeatureMacroFusion,
Craig Topperd55b8312017-01-10 06:01:16 +00001171 FeatureMMX,
1172 FeatureMOVBE,
1173 FeatureMWAITX,
1174 FeaturePCLMUL,
1175 FeaturePOPCNT,
1176 FeaturePRFCHW,
1177 FeatureRDRAND,
1178 FeatureRDSEED,
1179 FeatureSHA,
Craig Topperd55b8312017-01-10 06:01:16 +00001180 FeatureSSE4A,
1181 FeatureSlowSHLD,
1182 FeatureX87,
1183 FeatureXSAVE,
1184 FeatureXSAVEC,
1185 FeatureXSAVEOPT,
1186 FeatureXSAVES]>;
1187
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001188def : Proc<"geode", [FeatureX87, FeatureSlowUAMem16, Feature3DNowA]>;
Evan Chengff1beda2006-10-06 09:17:41 +00001189
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001190def : Proc<"winchip-c6", [FeatureX87, FeatureSlowUAMem16, FeatureMMX]>;
1191def : Proc<"winchip2", [FeatureX87, FeatureSlowUAMem16, Feature3DNow]>;
1192def : Proc<"c3", [FeatureX87, FeatureSlowUAMem16, Feature3DNow]>;
1193def : Proc<"c3-2", [FeatureX87, FeatureSlowUAMem16, FeatureMMX,
Craig Topper128915f2018-08-26 18:29:33 +00001194 FeatureSSE1, FeatureFXSR, FeatureCMOV]>;
Evan Chengff1beda2006-10-06 09:17:41 +00001195
Chandler Carruth32908d72014-05-07 17:37:03 +00001196// We also provide a generic 64-bit specific x86 processor model which tries to
1197// be good for modern chips without enabling instruction set encodings past the
1198// basic SSE2 and 64-bit ones. It disables slow things from any mainstream and
1199// modern 64-bit x86 chip, and enables features that are generally beneficial.
Michael Liao5bf95782014-12-04 05:20:33 +00001200//
Chandler Carruth32908d72014-05-07 17:37:03 +00001201// We currently use the Sandy Bridge model as the default scheduling model as
1202// we use it across Nehalem, Westmere, Sandy Bridge, and Ivy Bridge which
1203// covers a huge swath of x86 processors. If there are specific scheduling
1204// knobs which need to be tuned differently for AMD chips, we might consider
1205// forming a common base for them.
Chandler Carruth98c51cb2017-08-21 08:45:22 +00001206def : ProcessorModel<"x86-64", SandyBridgeModel, [
1207 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +00001208 FeatureCMOV,
Chandler Carruth98c51cb2017-08-21 08:45:22 +00001209 FeatureMMX,
1210 FeatureSSE2,
1211 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001212 FeatureNOPL,
Chandler Carruth98c51cb2017-08-21 08:45:22 +00001213 Feature64Bit,
1214 FeatureSlow3OpsLEA,
Craig Topper641e2af2017-08-30 04:34:48 +00001215 FeatureSlowIncDec,
1216 FeatureMacroFusion
Chandler Carruth98c51cb2017-08-21 08:45:22 +00001217]>;
Chandler Carruth32908d72014-05-07 17:37:03 +00001218
Evan Chengff1beda2006-10-06 09:17:41 +00001219//===----------------------------------------------------------------------===//
Chris Lattner5d00a0b2007-02-26 18:17:14 +00001220// Calling Conventions
1221//===----------------------------------------------------------------------===//
1222
1223include "X86CallingConv.td"
1224
1225
1226//===----------------------------------------------------------------------===//
Jim Grosbach4cf25f52010-10-30 13:48:28 +00001227// Assembly Parser
Chris Lattner5d00a0b2007-02-26 18:17:14 +00001228//===----------------------------------------------------------------------===//
1229
Devang Patel85d684a2012-01-09 19:13:28 +00001230def ATTAsmParserVariant : AsmParserVariant {
Daniel Dunbar00331992009-07-29 00:02:19 +00001231 int Variant = 0;
Daniel Dunbare4318712009-08-11 20:59:47 +00001232
Chad Rosier9f7a2212013-04-18 22:35:36 +00001233 // Variant name.
1234 string Name = "att";
1235
Daniel Dunbare4318712009-08-11 20:59:47 +00001236 // Discard comments in assembly strings.
1237 string CommentDelimiter = "#";
1238
1239 // Recognize hard coded registers.
1240 string RegisterPrefix = "%";
Daniel Dunbar00331992009-07-29 00:02:19 +00001241}
1242
Devang Patel67bf992a2012-01-10 17:51:54 +00001243def IntelAsmParserVariant : AsmParserVariant {
1244 int Variant = 1;
1245
Chad Rosier9f7a2212013-04-18 22:35:36 +00001246 // Variant name.
1247 string Name = "intel";
1248
Devang Patel67bf992a2012-01-10 17:51:54 +00001249 // Discard comments in assembly strings.
1250 string CommentDelimiter = ";";
1251
1252 // Recognize hard coded registers.
1253 string RegisterPrefix = "";
1254}
1255
Jim Grosbach4cf25f52010-10-30 13:48:28 +00001256//===----------------------------------------------------------------------===//
1257// Assembly Printers
1258//===----------------------------------------------------------------------===//
1259
Chris Lattner56832602004-10-03 20:36:57 +00001260// The X86 target supports two different syntaxes for emitting machine code.
1261// This is controlled by the -x86-asm-syntax={att|intel}
1262def ATTAsmWriter : AsmWriter {
Chris Lattner1cbd3de2009-09-13 19:30:11 +00001263 string AsmWriterClassName = "ATTInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +00001264 int Variant = 0;
1265}
1266def IntelAsmWriter : AsmWriter {
Chris Lattner13306a12009-09-20 07:47:59 +00001267 string AsmWriterClassName = "IntelInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +00001268 int Variant = 1;
1269}
1270
Chris Lattnera8c3cff2003-08-03 18:19:37 +00001271def X86 : Target {
Chris Lattnera8c3cff2003-08-03 18:19:37 +00001272 // Information about the instructions...
Chris Lattner25510802003-08-04 04:59:56 +00001273 let InstructionSet = X86InstrInfo;
Devang Patel67bf992a2012-01-10 17:51:54 +00001274 let AssemblyParserVariants = [ATTAsmParserVariant, IntelAsmParserVariant];
Chris Lattner56832602004-10-03 20:36:57 +00001275 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
Geoff Berryf8bf2ec2018-02-23 18:25:08 +00001276 let AllowRegisterRenaming = 1;
Chris Lattnera8c3cff2003-08-03 18:19:37 +00001277}
Clement Courbetb4493792018-04-10 08:16:37 +00001278
1279//===----------------------------------------------------------------------===//
1280// Pfm Counters
1281//===----------------------------------------------------------------------===//
1282
1283include "X86PfmCounters.td"