blob: 7b0d4a1e8bb535fcce0495bb660283b9b3484a55 [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">;
Michael Kuperstein454d1452015-07-23 12:23:45 +0000184// TODO: This feature ought to be renamed.
185// What it really refers to are CPUs where instruction that cause MSROM
186// lookups are expensive, so alternative sequences should be preferred.
187// The best examples of this are the memory forms of CALL and PUSH
188// instructions, which should be avoided in favor of a MOV + register CALL/PUSH.
Preston Gurd663e6f92013-03-27 19:14:02 +0000189def FeatureCallRegIndirect : SubtargetFeature<"call-reg-indirect",
190 "CallRegIndirect", "true",
191 "Call register indirect">;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000192def FeatureLEAUsesAG : SubtargetFeature<"lea-uses-ag", "LEAUsesAG", "true",
193 "LEA instruction needs inputs at AG stage">;
Alexey Volkov6226de62014-05-20 08:55:50 +0000194def FeatureSlowLEA : SubtargetFeature<"slow-lea", "SlowLEA", "true",
195 "LEA instruction with certain arguments is slow">;
Alexey Volkov5260dba2014-06-09 11:40:41 +0000196def FeatureSlowIncDec : SubtargetFeature<"slow-incdec", "SlowIncDec", "true",
197 "INC and DEC instructions are slower than ADD and SUB">;
Eric Christopher824f42f2015-05-12 01:26:05 +0000198def FeatureSoftFloat
199 : SubtargetFeature<"soft-float", "UseSoftFloat", "true",
200 "Use software floating point features.">;
David Greene8f6f72c2009-06-26 22:46:54 +0000201
Evan Chengff1beda2006-10-06 09:17:41 +0000202//===----------------------------------------------------------------------===//
203// X86 processors supported.
204//===----------------------------------------------------------------------===//
205
Andrew Trick8523b162012-02-01 23:20:51 +0000206include "X86Schedule.td"
207
208def ProcIntelAtom : SubtargetFeature<"atom", "X86ProcFamily", "IntelAtom",
209 "Intel Atom processors">;
Preston Gurd3fe264d2013-09-13 19:23:28 +0000210def ProcIntelSLM : SubtargetFeature<"slm", "X86ProcFamily", "IntelSLM",
211 "Intel Silvermont processors">;
Andrew Trick8523b162012-02-01 23:20:51 +0000212
Evan Chengff1beda2006-10-06 09:17:41 +0000213class Proc<string Name, list<SubtargetFeature> Features>
Andrew Trick87255e32012-07-07 04:00:00 +0000214 : ProcessorModel<Name, GenericModel, Features>;
Andrew Trick8523b162012-02-01 23:20:51 +0000215
Evan Chengff1beda2006-10-06 09:17:41 +0000216def : Proc<"generic", []>;
217def : Proc<"i386", []>;
218def : Proc<"i486", []>;
Dale Johannesen28106752008-10-14 22:06:33 +0000219def : Proc<"i586", []>;
Evan Chengff1beda2006-10-06 09:17:41 +0000220def : Proc<"pentium", []>;
221def : Proc<"pentium-mmx", [FeatureMMX]>;
222def : Proc<"i686", []>;
Chris Lattnercc8c5812009-09-02 05:53:04 +0000223def : Proc<"pentiumpro", [FeatureCMOV]>;
224def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000225def : Proc<"pentium3", [FeatureSSE1]>;
Michael J. Spencer99737382011-05-03 03:42:50 +0000226def : Proc<"pentium3m", [FeatureSSE1, FeatureSlowBTMem]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +0000227def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000228def : Proc<"pentium4", [FeatureSSE2]>;
Michael J. Spencer99737382011-05-03 03:42:50 +0000229def : Proc<"pentium4m", [FeatureSSE2, FeatureSlowBTMem]>;
Chandler Carruth32908d72014-05-07 17:37:03 +0000230
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000231// Intel Core Duo.
232def : ProcessorModel<"yonah", SandyBridgeModel,
233 [FeatureSSE3, FeatureSlowBTMem]>;
234
235// NetBurst.
236def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
237def : Proc<"nocona", [FeatureSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
238
239// Intel Core 2 Solo/Duo.
240def : ProcessorModel<"core2", SandyBridgeModel,
241 [FeatureSSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
242def : ProcessorModel<"penryn", SandyBridgeModel,
243 [FeatureSSE41, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
244
Chandler Carruthaf8924032014-12-09 10:58:36 +0000245// Atom CPUs.
246class BonnellProc<string Name> : ProcessorModel<Name, AtomModel, [
247 ProcIntelAtom,
248 FeatureSSSE3,
249 FeatureCMPXCHG16B,
250 FeatureMOVBE,
251 FeatureSlowBTMem,
252 FeatureLeaForSP,
253 FeatureSlowDivide32,
254 FeatureSlowDivide64,
255 FeatureCallRegIndirect,
256 FeatureLEAUsesAG,
257 FeaturePadShortFunctions
258 ]>;
259def : BonnellProc<"bonnell">;
260def : BonnellProc<"atom">; // Pin the generic name to the baseline.
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000261
Chandler Carruthaf8924032014-12-09 10:58:36 +0000262class SilvermontProc<string Name> : ProcessorModel<Name, SLMModel, [
263 ProcIntelSLM,
264 FeatureSSE42,
265 FeatureCMPXCHG16B,
266 FeatureMOVBE,
267 FeaturePOPCNT,
268 FeaturePCLMUL,
269 FeatureAES,
270 FeatureSlowDivide64,
271 FeatureCallRegIndirect,
272 FeaturePRFCHW,
273 FeatureSlowLEA,
274 FeatureSlowIncDec,
275 FeatureSlowBTMem,
276 FeatureFastUAMem
277 ]>;
278def : SilvermontProc<"silvermont">;
279def : SilvermontProc<"slm">; // Legacy alias.
280
Eric Christopher2ef63182010-04-02 21:54:27 +0000281// "Arrandale" along with corei3 and corei5
Craig Topper3611d9b2015-03-30 06:31:11 +0000282class NehalemProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
283 FeatureSSE42,
284 FeatureCMPXCHG16B,
285 FeatureSlowBTMem,
286 FeatureFastUAMem,
287 FeaturePOPCNT
288 ]>;
289def : NehalemProc<"nehalem">;
290def : NehalemProc<"corei7">;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000291
Eric Christopher2ef63182010-04-02 21:54:27 +0000292// Westmere is a similar machine to nehalem with some additional features.
293// Westmere is the corei3/i5/i7 path from nehalem to sandybridge
Chandler Carruthaf8924032014-12-09 10:58:36 +0000294class WestmereProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
295 FeatureSSE42,
296 FeatureCMPXCHG16B,
297 FeatureSlowBTMem,
298 FeatureFastUAMem,
299 FeaturePOPCNT,
300 FeatureAES,
301 FeaturePCLMUL
302 ]>;
303def : WestmereProc<"westmere">;
304
Nate Begeman8b08f522010-12-10 00:26:57 +0000305// SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
306// rather than a superset.
Chandler Carruthaf8924032014-12-09 10:58:36 +0000307class SandyBridgeProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
308 FeatureAVX,
309 FeatureCMPXCHG16B,
310 FeatureFastUAMem,
311 FeatureSlowUAMem32,
312 FeaturePOPCNT,
313 FeatureAES,
314 FeaturePCLMUL
315 ]>;
316def : SandyBridgeProc<"sandybridge">;
317def : SandyBridgeProc<"corei7-avx">; // Legacy alias.
Evan Chengff1beda2006-10-06 09:17:41 +0000318
Chandler Carruthaf8924032014-12-09 10:58:36 +0000319class IvyBridgeProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
320 FeatureAVX,
321 FeatureCMPXCHG16B,
322 FeatureFastUAMem,
323 FeatureSlowUAMem32,
324 FeaturePOPCNT,
325 FeatureAES,
326 FeaturePCLMUL,
327 FeatureRDRAND,
328 FeatureF16C,
329 FeatureFSGSBase
330 ]>;
331def : IvyBridgeProc<"ivybridge">;
332def : IvyBridgeProc<"core-avx-i">; // Legacy alias.
Craig Topper3657fe42011-10-14 03:21:46 +0000333
Chandler Carruthaf8924032014-12-09 10:58:36 +0000334class HaswellProc<string Name> : ProcessorModel<Name, HaswellModel, [
335 FeatureAVX2,
336 FeatureCMPXCHG16B,
337 FeatureFastUAMem,
338 FeaturePOPCNT,
339 FeatureAES,
340 FeaturePCLMUL,
341 FeatureRDRAND,
342 FeatureF16C,
343 FeatureFSGSBase,
344 FeatureMOVBE,
345 FeatureLZCNT,
346 FeatureBMI,
347 FeatureBMI2,
348 FeatureFMA,
349 FeatureRTM,
350 FeatureHLE,
351 FeatureSlowIncDec
352 ]>;
353def : HaswellProc<"haswell">;
354def : HaswellProc<"core-avx2">; // Legacy alias.
355
356class BroadwellProc<string Name> : ProcessorModel<Name, HaswellModel, [
357 FeatureAVX2,
358 FeatureCMPXCHG16B,
359 FeatureFastUAMem,
360 FeaturePOPCNT,
361 FeatureAES,
362 FeaturePCLMUL,
363 FeatureRDRAND,
364 FeatureF16C,
365 FeatureFSGSBase,
366 FeatureMOVBE,
367 FeatureLZCNT,
368 FeatureBMI,
369 FeatureBMI2,
370 FeatureFMA,
371 FeatureRTM,
372 FeatureHLE,
373 FeatureADX,
374 FeatureRDSEED,
Chandler Carruthaf8924032014-12-09 10:58:36 +0000375 FeatureSlowIncDec
376 ]>;
377def : BroadwellProc<"broadwell">;
378
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000379// FIXME: define KNL model
Chandler Carruthaf8924032014-12-09 10:58:36 +0000380class KnightsLandingProc<string Name> : ProcessorModel<Name, HaswellModel,
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000381 [FeatureAVX512, FeatureERI, FeatureCDI, FeaturePFI,
382 FeatureCMPXCHG16B, FeatureFastUAMem, FeaturePOPCNT,
383 FeatureAES, FeaturePCLMUL, FeatureRDRAND, FeatureF16C,
384 FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT, FeatureBMI,
Elena Demikhovsky678bd5b2014-07-02 14:11:05 +0000385 FeatureBMI2, FeatureFMA, FeatureRTM, FeatureHLE,
Elena Demikhovskyf7e641c2015-06-03 10:30:57 +0000386 FeatureSlowIncDec, FeatureMPX]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000387def : KnightsLandingProc<"knl">;
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000388
Robert Khasanovbfa01312014-07-21 14:54:21 +0000389// FIXME: define SKX model
Chandler Carruthaf8924032014-12-09 10:58:36 +0000390class SkylakeProc<string Name> : ProcessorModel<Name, HaswellModel,
Robert Khasanovbfa01312014-07-21 14:54:21 +0000391 [FeatureAVX512, FeatureCDI,
392 FeatureDQI, FeatureBWI, FeatureVLX,
393 FeatureCMPXCHG16B, FeatureFastUAMem, FeaturePOPCNT,
394 FeatureAES, FeaturePCLMUL, FeatureRDRAND, FeatureF16C,
395 FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT, FeatureBMI,
396 FeatureBMI2, FeatureFMA, FeatureRTM, FeatureHLE,
Elena Demikhovskyf7e641c2015-06-03 10:30:57 +0000397 FeatureSlowIncDec, FeatureMPX]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000398def : SkylakeProc<"skylake">;
399def : SkylakeProc<"skx">; // Legacy alias.
400
401
402// AMD CPUs.
Robert Khasanovbfa01312014-07-21 14:54:21 +0000403
Evan Chengff1beda2006-10-06 09:17:41 +0000404def : Proc<"k6", [FeatureMMX]>;
Michael J. Spencer30088ba2011-04-15 00:32:41 +0000405def : Proc<"k6-2", [Feature3DNow]>;
406def : Proc<"k6-3", [Feature3DNow]>;
Alexey Volkovbb2f0472014-03-07 08:28:44 +0000407def : Proc<"athlon", [Feature3DNowA, FeatureSlowBTMem,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000408 FeatureSlowSHLD]>;
409def : Proc<"athlon-tbird", [Feature3DNowA, FeatureSlowBTMem,
410 FeatureSlowSHLD]>;
Michael Liao5bf95782014-12-04 05:20:33 +0000411def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000412 FeatureSlowSHLD]>;
413def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
414 FeatureSlowSHLD]>;
415def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
416 FeatureSlowSHLD]>;
Dan Gohman74037512009-02-03 00:04:43 +0000417def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000418 FeatureSlowBTMem, FeatureSlowSHLD]>;
Dan Gohman74037512009-02-03 00:04:43 +0000419def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000420 FeatureSlowBTMem, FeatureSlowSHLD]>;
Dan Gohman74037512009-02-03 00:04:43 +0000421def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000422 FeatureSlowBTMem, FeatureSlowSHLD]>;
Dan Gohman74037512009-02-03 00:04:43 +0000423def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000424 FeatureSlowBTMem, FeatureSlowSHLD]>;
Eli Friedman5e570422011-08-26 21:21:21 +0000425def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000426 FeatureSlowBTMem, FeatureSlowSHLD]>;
Eli Friedman5e570422011-08-26 21:21:21 +0000427def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000428 FeatureSlowBTMem, FeatureSlowSHLD]>;
Eli Friedman5e570422011-08-26 21:21:21 +0000429def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000430 FeatureSlowBTMem, FeatureSlowSHLD]>;
Craig Topperbae0e9e2012-05-01 06:54:48 +0000431def : Proc<"amdfam10", [FeatureSSE4A,
Benjamin Kramer5feb3da2011-11-30 15:48:16 +0000432 Feature3DNowA, FeatureCMPXCHG16B, FeatureLZCNT,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000433 FeaturePOPCNT, FeatureSlowBTMem,
434 FeatureSlowSHLD]>;
Chandler Carruthf57ac3b2014-12-09 14:25:55 +0000435def : Proc<"barcelona", [FeatureSSE4A,
436 Feature3DNowA, FeatureCMPXCHG16B, FeatureLZCNT,
437 FeaturePOPCNT, FeatureSlowBTMem,
438 FeatureSlowSHLD]>;
Benjamin Kramer077ae1d2012-01-10 11:50:02 +0000439// Bobcat
440def : Proc<"btver1", [FeatureSSSE3, FeatureSSE4A, FeatureCMPXCHG16B,
Ekaterina Romanovad5fa5542013-11-21 23:21:26 +0000441 FeaturePRFCHW, FeatureLZCNT, FeaturePOPCNT,
442 FeatureSlowSHLD]>;
Sanjay Patel1191adf2014-09-09 20:07:07 +0000443
Benjamin Kramerb44c4272013-05-03 10:20:08 +0000444// Jaguar
Sanjay Patel1191adf2014-09-09 20:07:07 +0000445def : ProcessorModel<"btver2", BtVer2Model,
446 [FeatureAVX, FeatureSSE4A, FeatureCMPXCHG16B,
447 FeaturePRFCHW, FeatureAES, FeaturePCLMUL,
448 FeatureBMI, FeatureF16C, FeatureMOVBE,
Sanjay Patele57f3c02014-11-28 18:40:18 +0000449 FeatureLZCNT, FeaturePOPCNT, FeatureFastUAMem,
Sanjay Patel667a7e22015-06-04 01:32:35 +0000450 FeatureSlowSHLD]>;
Sanjay Patele57f3c02014-11-28 18:40:18 +0000451
452// TODO: We should probably add 'FeatureFastUAMem' to all of the AMD chips.
Sanjay Patel1191adf2014-09-09 20:07:07 +0000453
Benjamin Kramer077ae1d2012-01-10 11:50:02 +0000454// Bulldozer
Craig Topperbae0e9e2012-05-01 06:54:48 +0000455def : Proc<"bdver1", [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, FeatureLZCNT,
458 FeaturePOPCNT, FeatureSlowSHLD]>;
Benjamin Kramerb44c4272013-05-03 10:20:08 +0000459// Piledriver
Craig Topperbae0e9e2012-05-01 06:54:48 +0000460def : Proc<"bdver2", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
Yunzhong Gaodfc277f2013-10-16 19:04:11 +0000461 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
Andrea Di Biagiof5b34e52014-11-04 21:18:09 +0000462 FeatureAVX, FeatureSSE4A, FeatureF16C,
463 FeatureLZCNT, FeaturePOPCNT, FeatureBMI,
464 FeatureTBM, FeatureFMA, FeatureSlowSHLD]>;
Benjamin Kramerd114def2013-11-04 10:29:20 +0000465
466// Steamroller
467def : Proc<"bdver3", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
468 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
Andrea Di Biagiof5b34e52014-11-04 21:18:09 +0000469 FeatureAVX, FeatureSSE4A, FeatureF16C,
470 FeatureLZCNT, FeaturePOPCNT, FeatureBMI,
471 FeatureTBM, FeatureFMA, FeatureSlowSHLD,
472 FeatureFSGSBase]>;
Benjamin Kramerd114def2013-11-04 10:29:20 +0000473
Benjamin Kramer60045732014-05-02 15:47:07 +0000474// Excavator
475def : Proc<"bdver4", [FeatureAVX2, FeatureXOP, FeatureFMA4,
476 FeatureCMPXCHG16B, FeatureAES, FeaturePRFCHW,
477 FeaturePCLMUL, FeatureF16C, FeatureLZCNT,
478 FeaturePOPCNT, FeatureBMI, FeatureBMI2,
Andrea Di Biagiof5b34e52014-11-04 21:18:09 +0000479 FeatureTBM, FeatureFMA, FeatureSSE4A,
480 FeatureFSGSBase]>;
Benjamin Kramer60045732014-05-02 15:47:07 +0000481
Roman Divackyfd690092012-09-12 14:36:02 +0000482def : Proc<"geode", [Feature3DNowA]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000483
484def : Proc<"winchip-c6", [FeatureMMX]>;
Michael J. Spencer30088ba2011-04-15 00:32:41 +0000485def : Proc<"winchip2", [Feature3DNow]>;
486def : Proc<"c3", [Feature3DNow]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000487def : Proc<"c3-2", [FeatureSSE1]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000488
Chandler Carruth32908d72014-05-07 17:37:03 +0000489// We also provide a generic 64-bit specific x86 processor model which tries to
490// be good for modern chips without enabling instruction set encodings past the
491// basic SSE2 and 64-bit ones. It disables slow things from any mainstream and
492// modern 64-bit x86 chip, and enables features that are generally beneficial.
Michael Liao5bf95782014-12-04 05:20:33 +0000493//
Chandler Carruth32908d72014-05-07 17:37:03 +0000494// We currently use the Sandy Bridge model as the default scheduling model as
495// we use it across Nehalem, Westmere, Sandy Bridge, and Ivy Bridge which
496// covers a huge swath of x86 processors. If there are specific scheduling
497// knobs which need to be tuned differently for AMD chips, we might consider
498// forming a common base for them.
499def : ProcessorModel<"x86-64", SandyBridgeModel,
500 [FeatureSSE2, Feature64Bit, FeatureSlowBTMem,
501 FeatureFastUAMem]>;
502
Evan Chengff1beda2006-10-06 09:17:41 +0000503//===----------------------------------------------------------------------===//
Chris Lattner5da8e802003-08-03 15:47:49 +0000504// Register File Description
505//===----------------------------------------------------------------------===//
506
507include "X86RegisterInfo.td"
508
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000509//===----------------------------------------------------------------------===//
510// Instruction Descriptions
511//===----------------------------------------------------------------------===//
512
Chris Lattner59a4a912003-08-03 21:54:21 +0000513include "X86InstrInfo.td"
514
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000515def X86InstrInfo : InstrInfo;
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000516
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000517//===----------------------------------------------------------------------===//
518// Calling Conventions
519//===----------------------------------------------------------------------===//
520
521include "X86CallingConv.td"
522
523
524//===----------------------------------------------------------------------===//
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000525// Assembly Parser
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000526//===----------------------------------------------------------------------===//
527
Daniel Dunbar00331992009-07-29 00:02:19 +0000528def ATTAsmParser : AsmParser {
Devang Patel4a6e7782012-01-12 18:03:40 +0000529 string AsmParserClassName = "AsmParser";
Devang Patel85d684a2012-01-09 19:13:28 +0000530}
531
532def ATTAsmParserVariant : AsmParserVariant {
Daniel Dunbar00331992009-07-29 00:02:19 +0000533 int Variant = 0;
Daniel Dunbare4318712009-08-11 20:59:47 +0000534
Chad Rosier9f7a2212013-04-18 22:35:36 +0000535 // Variant name.
536 string Name = "att";
537
Daniel Dunbare4318712009-08-11 20:59:47 +0000538 // Discard comments in assembly strings.
539 string CommentDelimiter = "#";
540
541 // Recognize hard coded registers.
542 string RegisterPrefix = "%";
Daniel Dunbar00331992009-07-29 00:02:19 +0000543}
544
Devang Patel67bf992a2012-01-10 17:51:54 +0000545def IntelAsmParserVariant : AsmParserVariant {
546 int Variant = 1;
547
Chad Rosier9f7a2212013-04-18 22:35:36 +0000548 // Variant name.
549 string Name = "intel";
550
Devang Patel67bf992a2012-01-10 17:51:54 +0000551 // Discard comments in assembly strings.
552 string CommentDelimiter = ";";
553
554 // Recognize hard coded registers.
555 string RegisterPrefix = "";
556}
557
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000558//===----------------------------------------------------------------------===//
559// Assembly Printers
560//===----------------------------------------------------------------------===//
561
Chris Lattner56832602004-10-03 20:36:57 +0000562// The X86 target supports two different syntaxes for emitting machine code.
563// This is controlled by the -x86-asm-syntax={att|intel}
564def ATTAsmWriter : AsmWriter {
Chris Lattner1cbd3de2009-09-13 19:30:11 +0000565 string AsmWriterClassName = "ATTInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000566 int Variant = 0;
567}
568def IntelAsmWriter : AsmWriter {
Chris Lattner13306a12009-09-20 07:47:59 +0000569 string AsmWriterClassName = "IntelInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000570 int Variant = 1;
571}
572
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000573def X86 : Target {
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000574 // Information about the instructions...
Chris Lattner25510802003-08-04 04:59:56 +0000575 let InstructionSet = X86InstrInfo;
Daniel Dunbar00331992009-07-29 00:02:19 +0000576 let AssemblyParsers = [ATTAsmParser];
Devang Patel67bf992a2012-01-10 17:51:54 +0000577 let AssemblyParserVariants = [ATTAsmParserVariant, IntelAsmParserVariant];
Chris Lattner56832602004-10-03 20:36:57 +0000578 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000579}