blob: 852267400bba1adba4ed0c262c5130b0c7c35a37 [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
34def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true",
35 "Enable conditional move instructions">;
36
Benjamin Kramer2f489232010-12-04 20:32:23 +000037def FeaturePOPCNT : SubtargetFeature<"popcnt", "HasPOPCNT", "true",
38 "Support POPCNT instruction">;
39
David Greene206351a2010-01-11 16:29:42 +000040
Bill Wendlinge6182262007-05-04 20:38:40 +000041def FeatureMMX : SubtargetFeature<"mmx","X86SSELevel", "MMX",
42 "Enable MMX instructions">;
43def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1",
44 "Enable SSE instructions",
Chris Lattnercc8c5812009-09-02 05:53:04 +000045 // SSE codegen depends on cmovs, and all
Michael J. Spencerb88784c2011-04-14 14:33:36 +000046 // SSE1+ processors support them.
Chris Lattnercc8c5812009-09-02 05:53:04 +000047 [FeatureMMX, FeatureCMOV]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000048def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2",
49 "Enable SSE2 instructions",
50 [FeatureSSE1]>;
51def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
52 "Enable SSE3 instructions",
53 [FeatureSSE2]>;
54def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
55 "Enable SSSE3 instructions",
56 [FeatureSSE3]>;
Rafael Espindola94a2c562013-08-23 20:21:34 +000057def FeatureSSE41 : SubtargetFeature<"sse4.1", "X86SSELevel", "SSE41",
Nate Begemane14fdfa2008-02-03 07:18:54 +000058 "Enable SSE 4.1 instructions",
59 [FeatureSSSE3]>;
Rafael Espindola94a2c562013-08-23 20:21:34 +000060def FeatureSSE42 : SubtargetFeature<"sse4.2", "X86SSELevel", "SSE42",
Nate Begemane14fdfa2008-02-03 07:18:54 +000061 "Enable SSE 4.2 instructions",
Craig Topper7bd33052011-12-29 15:51:45 +000062 [FeatureSSE41]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000063def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
Michael J. Spencer30088ba2011-04-15 00:32:41 +000064 "Enable 3DNow! instructions",
65 [FeatureMMX]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000066def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
Bill Wendlingf985c492007-05-06 07:56:19 +000067 "Enable 3DNow! Athlon instructions",
68 [Feature3DNow]>;
Dan Gohman74037512009-02-03 00:04:43 +000069// All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied
70// feature, because SSE2 can be disabled (e.g. for compiling OS kernels)
71// without disabling 64-bit mode.
Bill Wendlingf985c492007-05-06 07:56:19 +000072def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true",
Chris Lattner77f7dba2010-03-14 22:24:34 +000073 "Support 64-bit instructions",
74 [FeatureCMOV]>;
Nick Lewycky3be42b82013-10-05 20:11:44 +000075def FeatureCMPXCHG16B : SubtargetFeature<"cx16", "HasCmpxchg16b", "true",
Eli Friedman5e570422011-08-26 21:21:21 +000076 "64-bit with cmpxchg16b",
77 [Feature64Bit]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +000078def FeatureSlowBTMem : SubtargetFeature<"slow-bt-mem", "IsBTMemSlow", "true",
79 "Bit testing of memory is slow">;
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +000080def FeatureSlowSHLD : SubtargetFeature<"slow-shld", "IsSHLDSlow", "true",
81 "SHLD instruction is slow">;
Sanjay Patele57f3c02014-11-28 18:40:18 +000082// FIXME: This is a 16-byte (SSE/AVX) feature; we should rename it to make that
83// explicit. Also, it seems this would be the default state for most chips
84// going forward, so it would probably be better to negate the logic and
85// match the 32-byte "slow mem" feature below.
Evan Cheng738b0f92010-04-01 05:58:17 +000086def FeatureFastUAMem : SubtargetFeature<"fast-unaligned-mem",
87 "IsUAMemFast", "true",
88 "Fast unaligned memory access">;
Sanjay Patel501890e2014-11-21 17:40:04 +000089def FeatureSlowUAMem32 : SubtargetFeature<"slow-unaligned-mem-32",
90 "IsUAMem32Slow", "true",
91 "Slow unaligned 32-byte memory access">;
Stefanus Du Toit96180b52009-05-26 21:04:35 +000092def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
Craig Toppera5d1fc22011-12-30 07:16:00 +000093 "Support SSE 4a instructions",
94 [FeatureSSE3]>;
Evan Chengff1beda2006-10-06 09:17:41 +000095
Craig Topperf287a452012-01-09 09:02:13 +000096def FeatureAVX : SubtargetFeature<"avx", "X86SSELevel", "AVX",
97 "Enable AVX instructions",
98 [FeatureSSE42]>;
99def FeatureAVX2 : SubtargetFeature<"avx2", "X86SSELevel", "AVX2",
Craig Topper228d9132011-10-30 19:57:21 +0000100 "Enable AVX2 instructions",
101 [FeatureAVX]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000102def FeatureAVX512 : SubtargetFeature<"avx512f", "X86SSELevel", "AVX512F",
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000103 "Enable AVX-512 instructions",
104 [FeatureAVX2]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000105def FeatureERI : SubtargetFeature<"avx512er", "HasERI", "true",
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000106 "Enable AVX-512 Exponential and Reciprocal Instructions",
107 [FeatureAVX512]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000108def FeatureCDI : SubtargetFeature<"avx512cd", "HasCDI", "true",
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000109 "Enable AVX-512 Conflict Detection Instructions",
110 [FeatureAVX512]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000111def FeaturePFI : SubtargetFeature<"avx512pf", "HasPFI", "true",
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000112 "Enable AVX-512 PreFetch Instructions",
113 [FeatureAVX512]>;
Robert Khasanovbfa01312014-07-21 14:54:21 +0000114def FeatureDQI : SubtargetFeature<"avx512dq", "HasDQI", "true",
115 "Enable AVX-512 Doubleword and Quadword Instructions",
116 [FeatureAVX512]>;
117def FeatureBWI : SubtargetFeature<"avx512bw", "HasBWI", "true",
118 "Enable AVX-512 Byte and Word Instructions",
119 [FeatureAVX512]>;
120def FeatureVLX : SubtargetFeature<"avx512vl", "HasVLX", "true",
121 "Enable AVX-512 Vector Length eXtensions",
122 [FeatureAVX512]>;
Benjamin Kramera0396e42012-05-31 14:34:17 +0000123def FeaturePCLMUL : SubtargetFeature<"pclmul", "HasPCLMUL", "true",
124 "Enable packed carry-less multiplication instructions",
Craig Topper29dd1482012-05-01 05:28:32 +0000125 [FeatureSSE2]>;
Craig Topper79dbb0c2012-06-03 18:58:46 +0000126def FeatureFMA : SubtargetFeature<"fma", "HasFMA", "true",
Craig Toppere1bd0512011-12-29 19:46:19 +0000127 "Enable three-operand fused multiple-add",
128 [FeatureAVX]>;
David Greene8f6f72c2009-06-26 22:46:54 +0000129def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
Craig Toppera5d1fc22011-12-30 07:16:00 +0000130 "Enable four-operand fused multiple-add",
Craig Topperbae0e9e2012-05-01 06:54:48 +0000131 [FeatureAVX, FeatureSSE4A]>;
Craig Toppera5d1fc22011-12-30 07:16:00 +0000132def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
Craig Topper43518cc2012-05-01 05:41:41 +0000133 "Enable XOP instructions",
Anitha Boyapatiaf3e9832012-08-16 04:04:02 +0000134 [FeatureFMA4]>;
Sanjay Patelffd039b2015-02-03 17:13:04 +0000135def FeatureSSEUnalignedMem : SubtargetFeature<"sse-unaligned-mem",
136 "HasSSEUnalignedMem", "true",
137 "Allow unaligned memory operands with SSE instructions">;
Eric Christopher2ef63182010-04-02 21:54:27 +0000138def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
Craig Topper29dd1482012-05-01 05:28:32 +0000139 "Enable AES instructions",
140 [FeatureSSE2]>;
Yunzhong Gaodd36e932013-09-24 18:21:52 +0000141def FeatureTBM : SubtargetFeature<"tbm", "HasTBM", "true",
142 "Enable TBM instructions">;
Craig Topper786bdb92011-10-03 17:28:23 +0000143def FeatureMOVBE : SubtargetFeature<"movbe", "HasMOVBE", "true",
144 "Support MOVBE instruction">;
Rafael Espindola94a2c562013-08-23 20:21:34 +0000145def FeatureRDRAND : SubtargetFeature<"rdrnd", "HasRDRAND", "true",
Craig Topper786bdb92011-10-03 17:28:23 +0000146 "Support RDRAND instruction">;
Craig Topperfe9179f2011-10-09 07:31:39 +0000147def FeatureF16C : SubtargetFeature<"f16c", "HasF16C", "true",
Craig Toppera6d204e2013-09-16 04:29:58 +0000148 "Support 16-bit floating point conversion instructions",
149 [FeatureAVX]>;
Craig Topper228d9132011-10-30 19:57:21 +0000150def FeatureFSGSBase : SubtargetFeature<"fsgsbase", "HasFSGSBase", "true",
151 "Support FS/GS Base instructions">;
Craig Topper271064e2011-10-11 06:44:02 +0000152def FeatureLZCNT : SubtargetFeature<"lzcnt", "HasLZCNT", "true",
153 "Support LZCNT instruction">;
Craig Topper3657fe42011-10-14 03:21:46 +0000154def FeatureBMI : SubtargetFeature<"bmi", "HasBMI", "true",
155 "Support BMI instructions">;
Craig Topperaea148c2011-10-16 07:55:05 +0000156def FeatureBMI2 : SubtargetFeature<"bmi2", "HasBMI2", "true",
157 "Support BMI2 instructions">;
Michael Liao73cffdd2012-11-08 07:28:54 +0000158def FeatureRTM : SubtargetFeature<"rtm", "HasRTM", "true",
159 "Support RTM instructions">;
Michael Liaoe344ec92013-03-26 22:46:02 +0000160def FeatureHLE : SubtargetFeature<"hle", "HasHLE", "true",
161 "Support HLE">;
Kay Tiong Khoof809c642013-02-14 19:08:21 +0000162def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",
163 "Support ADX instructions">;
Ben Langmuir16501752013-09-12 15:51:31 +0000164def FeatureSHA : SubtargetFeature<"sha", "HasSHA", "true",
165 "Enable SHA instructions",
166 [FeatureSSE2]>;
Michael Liao5173ee02013-03-26 17:47:11 +0000167def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
168 "Support PRFCHW instructions">;
Michael Liaoa486a112013-03-28 23:41:26 +0000169def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
170 "Support RDSEED instruction">;
Elena Demikhovskyf7e641c2015-06-03 10:30:57 +0000171def FeatureMPX : SubtargetFeature<"mpx", "HasMPX", "true",
172 "Support MPX instructions">;
Evan Cheng1b81fdd2012-02-07 22:50:41 +0000173def FeatureLeaForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
174 "Use LEA for adjusting the stack pointer">;
Alexey Volkovfd1731d2014-11-21 11:19:34 +0000175def FeatureSlowDivide32 : SubtargetFeature<"idivl-to-divb",
176 "HasSlowDivide32", "true",
177 "Use 8-bit divide for positive values less than 256">;
178def FeatureSlowDivide64 : SubtargetFeature<"idivq-to-divw",
179 "HasSlowDivide64", "true",
180 "Use 16-bit divide for positive values less than 65536">;
Preston Gurda01daac2013-01-08 18:27:24 +0000181def FeaturePadShortFunctions : SubtargetFeature<"pad-short-functions",
182 "PadShortFunctions", "true",
183 "Pad short functions">;
Preston Gurd663e6f92013-03-27 19:14:02 +0000184def FeatureCallRegIndirect : SubtargetFeature<"call-reg-indirect",
185 "CallRegIndirect", "true",
186 "Call register indirect">;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000187def FeatureLEAUsesAG : SubtargetFeature<"lea-uses-ag", "LEAUsesAG", "true",
188 "LEA instruction needs inputs at AG stage">;
Alexey Volkov6226de62014-05-20 08:55:50 +0000189def FeatureSlowLEA : SubtargetFeature<"slow-lea", "SlowLEA", "true",
190 "LEA instruction with certain arguments is slow">;
Alexey Volkov5260dba2014-06-09 11:40:41 +0000191def FeatureSlowIncDec : SubtargetFeature<"slow-incdec", "SlowIncDec", "true",
192 "INC and DEC instructions are slower than ADD and SUB">;
Eric Christopher824f42f2015-05-12 01:26:05 +0000193def FeatureSoftFloat
194 : SubtargetFeature<"soft-float", "UseSoftFloat", "true",
195 "Use software floating point features.">;
David Greene8f6f72c2009-06-26 22:46:54 +0000196
Evan Chengff1beda2006-10-06 09:17:41 +0000197//===----------------------------------------------------------------------===//
198// X86 processors supported.
199//===----------------------------------------------------------------------===//
200
Andrew Trick8523b162012-02-01 23:20:51 +0000201include "X86Schedule.td"
202
203def ProcIntelAtom : SubtargetFeature<"atom", "X86ProcFamily", "IntelAtom",
204 "Intel Atom processors">;
Preston Gurd3fe264d2013-09-13 19:23:28 +0000205def ProcIntelSLM : SubtargetFeature<"slm", "X86ProcFamily", "IntelSLM",
206 "Intel Silvermont processors">;
Andrew Trick8523b162012-02-01 23:20:51 +0000207
Evan Chengff1beda2006-10-06 09:17:41 +0000208class Proc<string Name, list<SubtargetFeature> Features>
Andrew Trick87255e32012-07-07 04:00:00 +0000209 : ProcessorModel<Name, GenericModel, Features>;
Andrew Trick8523b162012-02-01 23:20:51 +0000210
Evan Chengff1beda2006-10-06 09:17:41 +0000211def : Proc<"generic", []>;
212def : Proc<"i386", []>;
213def : Proc<"i486", []>;
Dale Johannesen28106752008-10-14 22:06:33 +0000214def : Proc<"i586", []>;
Evan Chengff1beda2006-10-06 09:17:41 +0000215def : Proc<"pentium", []>;
216def : Proc<"pentium-mmx", [FeatureMMX]>;
217def : Proc<"i686", []>;
Chris Lattnercc8c5812009-09-02 05:53:04 +0000218def : Proc<"pentiumpro", [FeatureCMOV]>;
219def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000220def : Proc<"pentium3", [FeatureSSE1]>;
Michael J. Spencer99737382011-05-03 03:42:50 +0000221def : Proc<"pentium3m", [FeatureSSE1, FeatureSlowBTMem]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +0000222def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000223def : Proc<"pentium4", [FeatureSSE2]>;
Michael J. Spencer99737382011-05-03 03:42:50 +0000224def : Proc<"pentium4m", [FeatureSSE2, FeatureSlowBTMem]>;
Chandler Carruth32908d72014-05-07 17:37:03 +0000225
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000226// Intel Core Duo.
227def : ProcessorModel<"yonah", SandyBridgeModel,
228 [FeatureSSE3, FeatureSlowBTMem]>;
229
230// NetBurst.
231def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
232def : Proc<"nocona", [FeatureSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
233
234// Intel Core 2 Solo/Duo.
235def : ProcessorModel<"core2", SandyBridgeModel,
236 [FeatureSSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
237def : ProcessorModel<"penryn", SandyBridgeModel,
238 [FeatureSSE41, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
239
Chandler Carruthaf8924032014-12-09 10:58:36 +0000240// Atom CPUs.
241class BonnellProc<string Name> : ProcessorModel<Name, AtomModel, [
242 ProcIntelAtom,
243 FeatureSSSE3,
244 FeatureCMPXCHG16B,
245 FeatureMOVBE,
246 FeatureSlowBTMem,
247 FeatureLeaForSP,
248 FeatureSlowDivide32,
249 FeatureSlowDivide64,
250 FeatureCallRegIndirect,
251 FeatureLEAUsesAG,
252 FeaturePadShortFunctions
253 ]>;
254def : BonnellProc<"bonnell">;
255def : BonnellProc<"atom">; // Pin the generic name to the baseline.
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000256
Chandler Carruthaf8924032014-12-09 10:58:36 +0000257class SilvermontProc<string Name> : ProcessorModel<Name, SLMModel, [
258 ProcIntelSLM,
259 FeatureSSE42,
260 FeatureCMPXCHG16B,
261 FeatureMOVBE,
262 FeaturePOPCNT,
263 FeaturePCLMUL,
264 FeatureAES,
265 FeatureSlowDivide64,
266 FeatureCallRegIndirect,
267 FeaturePRFCHW,
268 FeatureSlowLEA,
269 FeatureSlowIncDec,
270 FeatureSlowBTMem,
271 FeatureFastUAMem
272 ]>;
273def : SilvermontProc<"silvermont">;
274def : SilvermontProc<"slm">; // Legacy alias.
275
Eric Christopher2ef63182010-04-02 21:54:27 +0000276// "Arrandale" along with corei3 and corei5
Craig Topper3611d9b2015-03-30 06:31:11 +0000277class NehalemProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
278 FeatureSSE42,
279 FeatureCMPXCHG16B,
280 FeatureSlowBTMem,
281 FeatureFastUAMem,
282 FeaturePOPCNT
283 ]>;
284def : NehalemProc<"nehalem">;
285def : NehalemProc<"corei7">;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000286
Eric Christopher2ef63182010-04-02 21:54:27 +0000287// Westmere is a similar machine to nehalem with some additional features.
288// Westmere is the corei3/i5/i7 path from nehalem to sandybridge
Chandler Carruthaf8924032014-12-09 10:58:36 +0000289class WestmereProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
290 FeatureSSE42,
291 FeatureCMPXCHG16B,
292 FeatureSlowBTMem,
293 FeatureFastUAMem,
294 FeaturePOPCNT,
295 FeatureAES,
296 FeaturePCLMUL
297 ]>;
298def : WestmereProc<"westmere">;
299
Nate Begeman8b08f522010-12-10 00:26:57 +0000300// SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
301// rather than a superset.
Chandler Carruthaf8924032014-12-09 10:58:36 +0000302class SandyBridgeProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
303 FeatureAVX,
304 FeatureCMPXCHG16B,
305 FeatureFastUAMem,
306 FeatureSlowUAMem32,
307 FeaturePOPCNT,
308 FeatureAES,
309 FeaturePCLMUL
310 ]>;
311def : SandyBridgeProc<"sandybridge">;
312def : SandyBridgeProc<"corei7-avx">; // Legacy alias.
Evan Chengff1beda2006-10-06 09:17:41 +0000313
Chandler Carruthaf8924032014-12-09 10:58:36 +0000314class IvyBridgeProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
315 FeatureAVX,
316 FeatureCMPXCHG16B,
317 FeatureFastUAMem,
318 FeatureSlowUAMem32,
319 FeaturePOPCNT,
320 FeatureAES,
321 FeaturePCLMUL,
322 FeatureRDRAND,
323 FeatureF16C,
324 FeatureFSGSBase
325 ]>;
326def : IvyBridgeProc<"ivybridge">;
327def : IvyBridgeProc<"core-avx-i">; // Legacy alias.
Craig Topper3657fe42011-10-14 03:21:46 +0000328
Chandler Carruthaf8924032014-12-09 10:58:36 +0000329class HaswellProc<string Name> : ProcessorModel<Name, HaswellModel, [
330 FeatureAVX2,
331 FeatureCMPXCHG16B,
332 FeatureFastUAMem,
333 FeaturePOPCNT,
334 FeatureAES,
335 FeaturePCLMUL,
336 FeatureRDRAND,
337 FeatureF16C,
338 FeatureFSGSBase,
339 FeatureMOVBE,
340 FeatureLZCNT,
341 FeatureBMI,
342 FeatureBMI2,
343 FeatureFMA,
344 FeatureRTM,
345 FeatureHLE,
346 FeatureSlowIncDec
347 ]>;
348def : HaswellProc<"haswell">;
349def : HaswellProc<"core-avx2">; // Legacy alias.
350
351class BroadwellProc<string Name> : ProcessorModel<Name, HaswellModel, [
352 FeatureAVX2,
353 FeatureCMPXCHG16B,
354 FeatureFastUAMem,
355 FeaturePOPCNT,
356 FeatureAES,
357 FeaturePCLMUL,
358 FeatureRDRAND,
359 FeatureF16C,
360 FeatureFSGSBase,
361 FeatureMOVBE,
362 FeatureLZCNT,
363 FeatureBMI,
364 FeatureBMI2,
365 FeatureFMA,
366 FeatureRTM,
367 FeatureHLE,
368 FeatureADX,
369 FeatureRDSEED,
Chandler Carruthaf8924032014-12-09 10:58:36 +0000370 FeatureSlowIncDec
371 ]>;
372def : BroadwellProc<"broadwell">;
373
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000374// FIXME: define KNL model
Chandler Carruthaf8924032014-12-09 10:58:36 +0000375class KnightsLandingProc<string Name> : ProcessorModel<Name, HaswellModel,
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000376 [FeatureAVX512, FeatureERI, FeatureCDI, FeaturePFI,
377 FeatureCMPXCHG16B, FeatureFastUAMem, FeaturePOPCNT,
378 FeatureAES, FeaturePCLMUL, FeatureRDRAND, FeatureF16C,
379 FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT, FeatureBMI,
Elena Demikhovsky678bd5b2014-07-02 14:11:05 +0000380 FeatureBMI2, FeatureFMA, FeatureRTM, FeatureHLE,
Elena Demikhovskyf7e641c2015-06-03 10:30:57 +0000381 FeatureSlowIncDec, FeatureMPX]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000382def : KnightsLandingProc<"knl">;
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000383
Robert Khasanovbfa01312014-07-21 14:54:21 +0000384// FIXME: define SKX model
Chandler Carruthaf8924032014-12-09 10:58:36 +0000385class SkylakeProc<string Name> : ProcessorModel<Name, HaswellModel,
Robert Khasanovbfa01312014-07-21 14:54:21 +0000386 [FeatureAVX512, FeatureCDI,
387 FeatureDQI, FeatureBWI, FeatureVLX,
388 FeatureCMPXCHG16B, FeatureFastUAMem, FeaturePOPCNT,
389 FeatureAES, FeaturePCLMUL, FeatureRDRAND, FeatureF16C,
390 FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT, FeatureBMI,
391 FeatureBMI2, FeatureFMA, FeatureRTM, FeatureHLE,
Elena Demikhovskyf7e641c2015-06-03 10:30:57 +0000392 FeatureSlowIncDec, FeatureMPX]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000393def : SkylakeProc<"skylake">;
394def : SkylakeProc<"skx">; // Legacy alias.
395
396
397// AMD CPUs.
Robert Khasanovbfa01312014-07-21 14:54:21 +0000398
Evan Chengff1beda2006-10-06 09:17:41 +0000399def : Proc<"k6", [FeatureMMX]>;
Michael J. Spencer30088ba2011-04-15 00:32:41 +0000400def : Proc<"k6-2", [Feature3DNow]>;
401def : Proc<"k6-3", [Feature3DNow]>;
Alexey Volkovbb2f0472014-03-07 08:28:44 +0000402def : Proc<"athlon", [Feature3DNowA, FeatureSlowBTMem,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000403 FeatureSlowSHLD]>;
404def : Proc<"athlon-tbird", [Feature3DNowA, FeatureSlowBTMem,
405 FeatureSlowSHLD]>;
Michael Liao5bf95782014-12-04 05:20:33 +0000406def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000407 FeatureSlowSHLD]>;
408def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
409 FeatureSlowSHLD]>;
410def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
411 FeatureSlowSHLD]>;
Dan Gohman74037512009-02-03 00:04:43 +0000412def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000413 FeatureSlowBTMem, FeatureSlowSHLD]>;
Dan Gohman74037512009-02-03 00:04:43 +0000414def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000415 FeatureSlowBTMem, FeatureSlowSHLD]>;
Dan Gohman74037512009-02-03 00:04:43 +0000416def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000417 FeatureSlowBTMem, FeatureSlowSHLD]>;
Dan Gohman74037512009-02-03 00:04:43 +0000418def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000419 FeatureSlowBTMem, FeatureSlowSHLD]>;
Eli Friedman5e570422011-08-26 21:21:21 +0000420def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000421 FeatureSlowBTMem, FeatureSlowSHLD]>;
Eli Friedman5e570422011-08-26 21:21:21 +0000422def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000423 FeatureSlowBTMem, FeatureSlowSHLD]>;
Eli Friedman5e570422011-08-26 21:21:21 +0000424def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000425 FeatureSlowBTMem, FeatureSlowSHLD]>;
Craig Topperbae0e9e2012-05-01 06:54:48 +0000426def : Proc<"amdfam10", [FeatureSSE4A,
Benjamin Kramer5feb3da2011-11-30 15:48:16 +0000427 Feature3DNowA, FeatureCMPXCHG16B, FeatureLZCNT,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000428 FeaturePOPCNT, FeatureSlowBTMem,
429 FeatureSlowSHLD]>;
Chandler Carruthf57ac3b2014-12-09 14:25:55 +0000430def : Proc<"barcelona", [FeatureSSE4A,
431 Feature3DNowA, FeatureCMPXCHG16B, FeatureLZCNT,
432 FeaturePOPCNT, FeatureSlowBTMem,
433 FeatureSlowSHLD]>;
Benjamin Kramer077ae1d2012-01-10 11:50:02 +0000434// Bobcat
435def : Proc<"btver1", [FeatureSSSE3, FeatureSSE4A, FeatureCMPXCHG16B,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000436 FeaturePRFCHW, FeatureLZCNT, FeaturePOPCNT,
437 FeatureSlowSHLD]>;
Sanjay Patel1191adf2014-09-09 20:07:07 +0000438
Benjamin Kramerb44c4272013-05-03 10:20:08 +0000439// Jaguar
Sanjay Patel1191adf2014-09-09 20:07:07 +0000440def : ProcessorModel<"btver2", BtVer2Model,
441 [FeatureAVX, FeatureSSE4A, FeatureCMPXCHG16B,
442 FeaturePRFCHW, FeatureAES, FeaturePCLMUL,
443 FeatureBMI, FeatureF16C, FeatureMOVBE,
Sanjay Patele57f3c02014-11-28 18:40:18 +0000444 FeatureLZCNT, FeaturePOPCNT, FeatureFastUAMem,
Sanjay Patel667a7e22015-06-04 01:32:35 +0000445 FeatureSlowSHLD]>;
Sanjay Patele57f3c02014-11-28 18:40:18 +0000446
447// TODO: We should probably add 'FeatureFastUAMem' to all of the AMD chips.
Sanjay Patel1191adf2014-09-09 20:07:07 +0000448
Benjamin Kramer077ae1d2012-01-10 11:50:02 +0000449// Bulldozer
Craig Topperbae0e9e2012-05-01 06:54:48 +0000450def : Proc<"bdver1", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
Yunzhong Gaodfc277f2013-10-16 19:04:11 +0000451 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
Andrea Di Biagiof5b34e52014-11-04 21:18:09 +0000452 FeatureAVX, FeatureSSE4A, FeatureLZCNT,
453 FeaturePOPCNT, FeatureSlowSHLD]>;
Benjamin Kramerb44c4272013-05-03 10:20:08 +0000454// Piledriver
Craig Topperbae0e9e2012-05-01 06:54:48 +0000455def : Proc<"bdver2", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
Yunzhong Gaodfc277f2013-10-16 19:04:11 +0000456 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
Andrea Di Biagiof5b34e52014-11-04 21:18:09 +0000457 FeatureAVX, FeatureSSE4A, FeatureF16C,
458 FeatureLZCNT, FeaturePOPCNT, FeatureBMI,
459 FeatureTBM, FeatureFMA, FeatureSlowSHLD]>;
Benjamin Kramerd114def2013-11-04 10:29:20 +0000460
461// Steamroller
462def : Proc<"bdver3", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
463 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
Andrea Di Biagiof5b34e52014-11-04 21:18:09 +0000464 FeatureAVX, FeatureSSE4A, FeatureF16C,
465 FeatureLZCNT, FeaturePOPCNT, FeatureBMI,
466 FeatureTBM, FeatureFMA, FeatureSlowSHLD,
467 FeatureFSGSBase]>;
Benjamin Kramerd114def2013-11-04 10:29:20 +0000468
Benjamin Kramer60045732014-05-02 15:47:07 +0000469// Excavator
470def : Proc<"bdver4", [FeatureAVX2, FeatureXOP, FeatureFMA4,
471 FeatureCMPXCHG16B, FeatureAES, FeaturePRFCHW,
472 FeaturePCLMUL, FeatureF16C, FeatureLZCNT,
473 FeaturePOPCNT, FeatureBMI, FeatureBMI2,
Andrea Di Biagiof5b34e52014-11-04 21:18:09 +0000474 FeatureTBM, FeatureFMA, FeatureSSE4A,
475 FeatureFSGSBase]>;
Benjamin Kramer60045732014-05-02 15:47:07 +0000476
Roman Divackyfd690092012-09-12 14:36:02 +0000477def : Proc<"geode", [Feature3DNowA]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000478
479def : Proc<"winchip-c6", [FeatureMMX]>;
Michael J. Spencer30088ba2011-04-15 00:32:41 +0000480def : Proc<"winchip2", [Feature3DNow]>;
481def : Proc<"c3", [Feature3DNow]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000482def : Proc<"c3-2", [FeatureSSE1]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000483
Chandler Carruth32908d72014-05-07 17:37:03 +0000484// We also provide a generic 64-bit specific x86 processor model which tries to
485// be good for modern chips without enabling instruction set encodings past the
486// basic SSE2 and 64-bit ones. It disables slow things from any mainstream and
487// modern 64-bit x86 chip, and enables features that are generally beneficial.
Michael Liao5bf95782014-12-04 05:20:33 +0000488//
Chandler Carruth32908d72014-05-07 17:37:03 +0000489// We currently use the Sandy Bridge model as the default scheduling model as
490// we use it across Nehalem, Westmere, Sandy Bridge, and Ivy Bridge which
491// covers a huge swath of x86 processors. If there are specific scheduling
492// knobs which need to be tuned differently for AMD chips, we might consider
493// forming a common base for them.
494def : ProcessorModel<"x86-64", SandyBridgeModel,
495 [FeatureSSE2, Feature64Bit, FeatureSlowBTMem,
496 FeatureFastUAMem]>;
497
Evan Chengff1beda2006-10-06 09:17:41 +0000498//===----------------------------------------------------------------------===//
Chris Lattner5da8e802003-08-03 15:47:49 +0000499// Register File Description
500//===----------------------------------------------------------------------===//
501
502include "X86RegisterInfo.td"
503
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000504//===----------------------------------------------------------------------===//
505// Instruction Descriptions
506//===----------------------------------------------------------------------===//
507
Chris Lattner59a4a912003-08-03 21:54:21 +0000508include "X86InstrInfo.td"
509
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000510def X86InstrInfo : InstrInfo;
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000511
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000512//===----------------------------------------------------------------------===//
513// Calling Conventions
514//===----------------------------------------------------------------------===//
515
516include "X86CallingConv.td"
517
518
519//===----------------------------------------------------------------------===//
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000520// Assembly Parser
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000521//===----------------------------------------------------------------------===//
522
Daniel Dunbar00331992009-07-29 00:02:19 +0000523def ATTAsmParser : AsmParser {
Devang Patel4a6e7782012-01-12 18:03:40 +0000524 string AsmParserClassName = "AsmParser";
Devang Patel85d684a2012-01-09 19:13:28 +0000525}
526
527def ATTAsmParserVariant : AsmParserVariant {
Daniel Dunbar00331992009-07-29 00:02:19 +0000528 int Variant = 0;
Daniel Dunbare4318712009-08-11 20:59:47 +0000529
Chad Rosier9f7a2212013-04-18 22:35:36 +0000530 // Variant name.
531 string Name = "att";
532
Daniel Dunbare4318712009-08-11 20:59:47 +0000533 // Discard comments in assembly strings.
534 string CommentDelimiter = "#";
535
536 // Recognize hard coded registers.
537 string RegisterPrefix = "%";
Daniel Dunbar00331992009-07-29 00:02:19 +0000538}
539
Devang Patel67bf992a2012-01-10 17:51:54 +0000540def IntelAsmParserVariant : AsmParserVariant {
541 int Variant = 1;
542
Chad Rosier9f7a2212013-04-18 22:35:36 +0000543 // Variant name.
544 string Name = "intel";
545
Devang Patel67bf992a2012-01-10 17:51:54 +0000546 // Discard comments in assembly strings.
547 string CommentDelimiter = ";";
548
549 // Recognize hard coded registers.
550 string RegisterPrefix = "";
551}
552
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000553//===----------------------------------------------------------------------===//
554// Assembly Printers
555//===----------------------------------------------------------------------===//
556
Chris Lattner56832602004-10-03 20:36:57 +0000557// The X86 target supports two different syntaxes for emitting machine code.
558// This is controlled by the -x86-asm-syntax={att|intel}
559def ATTAsmWriter : AsmWriter {
Chris Lattner1cbd3de2009-09-13 19:30:11 +0000560 string AsmWriterClassName = "ATTInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000561 int Variant = 0;
562}
563def IntelAsmWriter : AsmWriter {
Chris Lattner13306a12009-09-20 07:47:59 +0000564 string AsmWriterClassName = "IntelInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000565 int Variant = 1;
566}
567
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000568def X86 : Target {
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000569 // Information about the instructions...
Chris Lattner25510802003-08-04 04:59:56 +0000570 let InstructionSet = X86InstrInfo;
Daniel Dunbar00331992009-07-29 00:02:19 +0000571 let AssemblyParsers = [ATTAsmParser];
Devang Patel67bf992a2012-01-10 17:51:54 +0000572 let AssemblyParserVariants = [ATTAsmParserVariant, IntelAsmParserVariant];
Chris Lattner56832602004-10-03 20:36:57 +0000573 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000574}