blob: e5d5d929be9b8930c35ce22dad29080ec6236010 [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">;
Sanjay Patel30145672015-09-01 20:51:51 +0000101// FIXME: This should not apply to CPUs that do not have SSE.
102def FeatureSlowUAMem16 : SubtargetFeature<"slow-unaligned-mem-16",
103 "IsUAMem16Slow", "true",
104 "Slow unaligned 16-byte memory access">;
Sanjay Patel501890e2014-11-21 17:40:04 +0000105def FeatureSlowUAMem32 : SubtargetFeature<"slow-unaligned-mem-32",
Sanjay Patel9e916dc2015-08-21 20:17:26 +0000106 "IsUAMem32Slow", "true",
107 "Slow unaligned 32-byte memory access">;
Stefanus Du Toit96180b52009-05-26 21:04:35 +0000108def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
Craig Toppera5d1fc22011-12-30 07:16:00 +0000109 "Support SSE 4a instructions",
110 [FeatureSSE3]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000111
Craig Topperf287a452012-01-09 09:02:13 +0000112def FeatureAVX : SubtargetFeature<"avx", "X86SSELevel", "AVX",
113 "Enable AVX instructions",
114 [FeatureSSE42]>;
115def FeatureAVX2 : SubtargetFeature<"avx2", "X86SSELevel", "AVX2",
Craig Topper228d9132011-10-30 19:57:21 +0000116 "Enable AVX2 instructions",
117 [FeatureAVX]>;
Craig Toppercb6c3862017-11-06 22:49:01 +0000118def FeatureFMA : SubtargetFeature<"fma", "HasFMA", "true",
119 "Enable three-operand fused multiple-add",
120 [FeatureAVX]>;
Craig Topper428a4e62017-11-06 22:49:04 +0000121def FeatureF16C : SubtargetFeature<"f16c", "HasF16C", "true",
122 "Support 16-bit floating point conversion instructions",
123 [FeatureAVX]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000124def FeatureAVX512 : SubtargetFeature<"avx512f", "X86SSELevel", "AVX512F",
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000125 "Enable AVX-512 instructions",
Craig Topper428a4e62017-11-06 22:49:04 +0000126 [FeatureAVX2, FeatureFMA, FeatureF16C]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000127def FeatureERI : SubtargetFeature<"avx512er", "HasERI", "true",
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000128 "Enable AVX-512 Exponential and Reciprocal Instructions",
129 [FeatureAVX512]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000130def FeatureCDI : SubtargetFeature<"avx512cd", "HasCDI", "true",
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000131 "Enable AVX-512 Conflict Detection Instructions",
132 [FeatureAVX512]>;
Oren Ben Simhon7bf27f02017-05-25 13:45:23 +0000133def FeatureVPOPCNTDQ : SubtargetFeature<"avx512vpopcntdq", "HasVPOPCNTDQ",
134 "true", "Enable AVX-512 Population Count Instructions",
135 [FeatureAVX512]>;
Craig Topper5c94bb82013-08-21 03:57:57 +0000136def FeaturePFI : SubtargetFeature<"avx512pf", "HasPFI", "true",
Elena Demikhovsky003e7d72013-07-28 08:28:38 +0000137 "Enable AVX-512 PreFetch Instructions",
138 [FeatureAVX512]>;
Craig Toppere2685982017-12-22 02:30:30 +0000139def FeaturePREFETCHWT1 : SubtargetFeature<"prefetchwt1", "HasPREFETCHWT1",
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000140 "true",
141 "Prefetch with Intent to Write and T1 Hint">;
Robert Khasanovbfa01312014-07-21 14:54:21 +0000142def FeatureDQI : SubtargetFeature<"avx512dq", "HasDQI", "true",
143 "Enable AVX-512 Doubleword and Quadword Instructions",
144 [FeatureAVX512]>;
145def FeatureBWI : SubtargetFeature<"avx512bw", "HasBWI", "true",
146 "Enable AVX-512 Byte and Word Instructions",
147 [FeatureAVX512]>;
148def FeatureVLX : SubtargetFeature<"avx512vl", "HasVLX", "true",
149 "Enable AVX-512 Vector Length eXtensions",
150 [FeatureAVX512]>;
Michael Zuckerman97b6a6922016-01-17 13:42:12 +0000151def FeatureVBMI : SubtargetFeature<"avx512vbmi", "HasVBMI", "true",
Craig Topper5c842be2016-11-09 04:50:48 +0000152 "Enable AVX-512 Vector Byte Manipulation Instructions",
153 [FeatureBWI]>;
Coby Tayree71e37cc2017-11-21 09:48:44 +0000154def FeatureVBMI2 : SubtargetFeature<"avx512vbmi2", "HasVBMI2", "true",
155 "Enable AVX-512 further Vector Byte Manipulation Instructions",
156 [FeatureBWI]>;
Craig Topper3bb3f732016-02-08 01:23:15 +0000157def FeatureIFMA : SubtargetFeature<"avx512ifma", "HasIFMA", "true",
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000158 "Enable AVX-512 Integer Fused Multiple-Add",
159 [FeatureAVX512]>;
Asaf Badouh5acf66f2015-12-15 13:35:29 +0000160def FeaturePKU : SubtargetFeature<"pku", "HasPKU", "true",
161 "Enable protection keys">;
Coby Tayree3880f2a2017-11-21 10:04:28 +0000162def FeatureVNNI : SubtargetFeature<"avx512vnni", "HasVNNI", "true",
163 "Enable AVX-512 Vector Neural Network Instructions",
164 [FeatureAVX512]>;
Coby Tayree5c7fe5d2017-11-21 10:32:42 +0000165def FeatureBITALG : SubtargetFeature<"avx512bitalg", "HasBITALG", "true",
166 "Enable AVX-512 Bit Algorithms",
167 [FeatureBWI]>;
Benjamin Kramera0396e42012-05-31 14:34:17 +0000168def FeaturePCLMUL : SubtargetFeature<"pclmul", "HasPCLMUL", "true",
169 "Enable packed carry-less multiplication instructions",
Craig Topper29dd1482012-05-01 05:28:32 +0000170 [FeatureSSE2]>;
Coby Tayreed8b17be2017-11-26 09:36:41 +0000171def FeatureGFNI : SubtargetFeature<"gfni", "HasGFNI", "true",
172 "Enable Galois Field Arithmetic Instructions",
173 [FeatureSSE2]>;
Coby Tayree7ca5e5872017-11-21 09:30:33 +0000174def FeatureVPCLMULQDQ : SubtargetFeature<"vpclmulqdq", "HasVPCLMULQDQ", "true",
175 "Enable vpclmulqdq instructions",
176 [FeatureAVX, FeaturePCLMUL]>;
David Greene8f6f72c2009-06-26 22:46:54 +0000177def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
Craig Toppera5d1fc22011-12-30 07:16:00 +0000178 "Enable four-operand fused multiple-add",
Craig Topperbae0e9e2012-05-01 06:54:48 +0000179 [FeatureAVX, FeatureSSE4A]>;
Craig Toppera5d1fc22011-12-30 07:16:00 +0000180def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
Craig Topper43518cc2012-05-01 05:41:41 +0000181 "Enable XOP instructions",
Anitha Boyapatiaf3e9832012-08-16 04:04:02 +0000182 [FeatureFMA4]>;
Sanjay Patelffd039b2015-02-03 17:13:04 +0000183def FeatureSSEUnalignedMem : SubtargetFeature<"sse-unaligned-mem",
184 "HasSSEUnalignedMem", "true",
185 "Allow unaligned memory operands with SSE instructions">;
Eric Christopher2ef63182010-04-02 21:54:27 +0000186def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
Craig Topper29dd1482012-05-01 05:28:32 +0000187 "Enable AES instructions",
188 [FeatureSSE2]>;
Coby Tayree2a1c02f2017-11-21 09:11:41 +0000189def FeatureVAES : SubtargetFeature<"vaes", "HasVAES", "true",
190 "Promote selected AES instructions to AVX512/AVX registers",
191 [FeatureAVX, FeatureAES]>;
Yunzhong Gaodd36e932013-09-24 18:21:52 +0000192def FeatureTBM : SubtargetFeature<"tbm", "HasTBM", "true",
193 "Enable TBM instructions">;
Simon Pilgrim99b925b2017-05-03 15:51:39 +0000194def FeatureLWP : SubtargetFeature<"lwp", "HasLWP", "true",
195 "Enable LWP instructions">;
Craig Topper786bdb92011-10-03 17:28:23 +0000196def FeatureMOVBE : SubtargetFeature<"movbe", "HasMOVBE", "true",
197 "Support MOVBE instruction">;
Rafael Espindola94a2c562013-08-23 20:21:34 +0000198def FeatureRDRAND : SubtargetFeature<"rdrnd", "HasRDRAND", "true",
Craig Topper786bdb92011-10-03 17:28:23 +0000199 "Support RDRAND instruction">;
Craig Topper228d9132011-10-30 19:57:21 +0000200def FeatureFSGSBase : SubtargetFeature<"fsgsbase", "HasFSGSBase", "true",
201 "Support FS/GS Base instructions">;
Craig Topper271064e2011-10-11 06:44:02 +0000202def FeatureLZCNT : SubtargetFeature<"lzcnt", "HasLZCNT", "true",
203 "Support LZCNT instruction">;
Craig Topper3657fe42011-10-14 03:21:46 +0000204def FeatureBMI : SubtargetFeature<"bmi", "HasBMI", "true",
205 "Support BMI instructions">;
Craig Topperaea148c2011-10-16 07:55:05 +0000206def FeatureBMI2 : SubtargetFeature<"bmi2", "HasBMI2", "true",
207 "Support BMI2 instructions">;
Michael Liao73cffdd2012-11-08 07:28:54 +0000208def FeatureRTM : SubtargetFeature<"rtm", "HasRTM", "true",
209 "Support RTM instructions">;
Kay Tiong Khoof809c642013-02-14 19:08:21 +0000210def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",
211 "Support ADX instructions">;
Ben Langmuir16501752013-09-12 15:51:31 +0000212def FeatureSHA : SubtargetFeature<"sha", "HasSHA", "true",
213 "Enable SHA instructions",
214 [FeatureSSE2]>;
Oren Ben Simhonfa582b02017-11-26 13:02:45 +0000215def FeatureSHSTK : SubtargetFeature<"shstk", "HasSHSTK", "true",
216 "Support CET Shadow-Stack instructions">;
Michael Liao5173ee02013-03-26 17:47:11 +0000217def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
218 "Support PRFCHW instructions">;
Michael Liaoa486a112013-03-28 23:41:26 +0000219def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
220 "Support RDSEED instruction">;
Hans Wennborg5000ce82015-12-04 23:00:33 +0000221def FeatureLAHFSAHF : SubtargetFeature<"sahf", "HasLAHFSAHF", "true",
222 "Support LAHF and SAHF instructions">;
Ashutosh Nema348af9c2016-05-18 11:59:12 +0000223def FeatureMWAITX : SubtargetFeature<"mwaitx", "HasMWAITX", "true",
224 "Enable MONITORX/MWAITX timer functionality">;
Craig Topper50f3d142017-02-09 04:27:34 +0000225def FeatureCLZERO : SubtargetFeature<"clzero", "HasCLZERO", "true",
226 "Enable Cache Line Zero">;
Gabor Buella604be442018-04-13 07:35:08 +0000227def FeatureCLDEMOTE : SubtargetFeature<"cldemote", "HasCLDEMOTE", "true",
228 "Enable Cache Demote">;
Gabor Buellaa832b222018-05-10 07:26:05 +0000229def FeaturePTWRITE : SubtargetFeature<"ptwrite", "HasPTWRITE", "true",
230 "Support ptwrite instruction">;
Elena Demikhovskyf7e641c2015-06-03 10:30:57 +0000231def FeatureMPX : SubtargetFeature<"mpx", "HasMPX", "true",
232 "Support MPX instructions">;
Sanjay Patel53d1d8b2015-10-12 15:24:01 +0000233def FeatureLEAForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
Evan Cheng1b81fdd2012-02-07 22:50:41 +0000234 "Use LEA for adjusting the stack pointer">;
Alexey Volkovfd1731d2014-11-21 11:19:34 +0000235def FeatureSlowDivide32 : SubtargetFeature<"idivl-to-divb",
236 "HasSlowDivide32", "true",
237 "Use 8-bit divide for positive values less than 256">;
Nikolai Bozhenov6bdf92c2017-01-12 19:34:15 +0000238def FeatureSlowDivide64 : SubtargetFeature<"idivq-to-divl",
Alexey Volkovfd1731d2014-11-21 11:19:34 +0000239 "HasSlowDivide64", "true",
Nikolai Bozhenov6bdf92c2017-01-12 19:34:15 +0000240 "Use 32-bit divide for positive values less than 2^32">;
Preston Gurda01daac2013-01-08 18:27:24 +0000241def FeaturePadShortFunctions : SubtargetFeature<"pad-short-functions",
242 "PadShortFunctions", "true",
243 "Pad short functions">;
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000244def FeatureINVPCID : SubtargetFeature<"invpcid", "HasINVPCID", "true",
245 "Invalidate Process-Context Identifier">;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000246def FeatureSGX : SubtargetFeature<"sgx", "HasSGX", "true",
247 "Enable Software Guard Extensions">;
248def FeatureCLFLUSHOPT : SubtargetFeature<"clflushopt", "HasCLFLUSHOPT", "true",
249 "Flush A Cache Line Optimized">;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000250def FeatureCLWB : SubtargetFeature<"clwb", "HasCLWB", "true",
251 "Cache Line Write Back">;
Gabor Buella2ef36f32018-04-11 20:01:57 +0000252def FeatureWBNOINVD : SubtargetFeature<"wbnoinvd", "HasWBNOINVD", "true",
253 "Write Back No Invalidate">;
Craig Topper84b26b92018-01-18 23:52:31 +0000254def FeatureRDPID : SubtargetFeature<"rdpid", "HasRDPID", "true",
255 "Support RDPID instructions">;
Gabor Buella31fa8022018-04-20 18:42:47 +0000256def FeatureWAITPKG : SubtargetFeature<"waitpkg", "HasWAITPKG", "true",
257 "Wait and pause enhancements">;
Craig Topper62c47a22017-08-29 05:14:27 +0000258// On some processors, instructions that implicitly take two memory operands are
259// slow. In practice, this means that CALL, PUSH, and POP with memory operands
260// should be avoided in favor of a MOV + register CALL/PUSH/POP.
261def FeatureSlowTwoMemOps : SubtargetFeature<"slow-two-mem-ops",
262 "SlowTwoMemOps", "true",
263 "Two memory operand instructions are slow">;
Preston Gurd8b7ab4b2013-04-25 20:29:37 +0000264def FeatureLEAUsesAG : SubtargetFeature<"lea-uses-ag", "LEAUsesAG", "true",
265 "LEA instruction needs inputs at AG stage">;
Alexey Volkov6226de62014-05-20 08:55:50 +0000266def FeatureSlowLEA : SubtargetFeature<"slow-lea", "SlowLEA", "true",
267 "LEA instruction with certain arguments is slow">;
Lama Saba2ea271b2017-05-18 08:11:50 +0000268def FeatureSlow3OpsLEA : SubtargetFeature<"slow-3ops-lea", "Slow3OpsLEA", "true",
269 "LEA instruction with 3 ops or certain registers is slow">;
Alexey Volkov5260dba2014-06-09 11:40:41 +0000270def FeatureSlowIncDec : SubtargetFeature<"slow-incdec", "SlowIncDec", "true",
271 "INC and DEC instructions are slower than ADD and SUB">;
Eric Christopher824f42f2015-05-12 01:26:05 +0000272def FeatureSoftFloat
273 : SubtargetFeature<"soft-float", "UseSoftFloat", "true",
274 "Use software floating point features.">;
Marina Yatsina77a21db2018-01-22 10:07:01 +0000275def FeaturePOPCNTFalseDeps : SubtargetFeature<"false-deps-popcnt",
276 "HasPOPCNTFalseDeps", "true",
277 "POPCNT has a false dependency on dest register">;
278def FeatureLZCNTFalseDeps : SubtargetFeature<"false-deps-lzcnt-tzcnt",
279 "HasLZCNTFalseDeps", "true",
280 "LZCNT/TZCNT have a false dependency on dest register">;
Gabor Buella2b5e9602018-05-08 06:47:36 +0000281def FeaturePCONFIG : SubtargetFeature<"pconfig", "HasPCONFIG", "true",
282 "platform configuration instruction">;
Simon Pilgrimfd5df632017-12-19 13:16:43 +0000283// On recent X86 (port bound) processors, its preferable to combine to a single shuffle
284// using a variable mask over multiple fixed shuffles.
285def FeatureFastVariableShuffle
286 : SubtargetFeature<"fast-variable-shuffle",
287 "HasFastVariableShuffle",
288 "true", "Shuffles with variable masks are fast">;
Amjad Aboud4f977512017-03-03 09:03:24 +0000289// On some X86 processors, there is no performance hazard to writing only the
290// lower parts of a YMM or ZMM register without clearing the upper part.
291def FeatureFastPartialYMMorZMMWrite
292 : SubtargetFeature<"fast-partial-ymm-or-zmm-write",
293 "HasFastPartialYMMorZMMWrite",
294 "true", "Partial writes to YMM/ZMM registers are fast">;
Nikolai Bozhenovf6795302016-08-04 12:47:28 +0000295// FeatureFastScalarFSQRT should be enabled if scalar FSQRT has shorter latency
296// than the corresponding NR code. FeatureFastVectorFSQRT should be enabled if
297// vector FSQRT has higher throughput than the corresponding NR code.
298// The idea is that throughput bound code is likely to be vectorized, so for
299// vectorized code we should care about the throughput of SQRT operations.
300// But if the code is scalar that probably means that the code has some kind of
301// dependency and we should care more about reducing the latency.
302def FeatureFastScalarFSQRT
303 : SubtargetFeature<"fast-scalar-fsqrt", "HasFastScalarFSQRT",
304 "true", "Scalar SQRT is fast (disable Newton-Raphson)">;
305def FeatureFastVectorFSQRT
306 : SubtargetFeature<"fast-vector-fsqrt", "HasFastVectorFSQRT",
307 "true", "Vector SQRT is fast (disable Newton-Raphson)">;
Pierre Gousseaub6d652a2016-10-14 16:41:38 +0000308// If lzcnt has equivalent latency/throughput to most simple integer ops, it can
309// be used to replace test/set sequences.
310def FeatureFastLZCNT
311 : SubtargetFeature<
312 "fast-lzcnt", "HasFastLZCNT", "true",
313 "LZCNT instructions are as fast as most simple integer ops">;
Simon Pilgrim02bdac52018-01-29 21:24:31 +0000314// If the target can efficiently decode NOPs upto 11-bytes in length.
315def FeatureFast11ByteNOP
316 : SubtargetFeature<
317 "fast-11bytenop", "HasFast11ByteNOP", "true",
318 "Target can quickly decode up to 11 byte NOPs">;
319// If the target can efficiently decode NOPs upto 15-bytes in length.
320def FeatureFast15ByteNOP
321 : SubtargetFeature<
322 "fast-15bytenop", "HasFast15ByteNOP", "true",
323 "Target can quickly decode up to 15 byte NOPs">;
Craig Topperd88389a2017-02-21 06:39:13 +0000324// Sandy Bridge and newer processors can use SHLD with the same source on both
325// inputs to implement rotate to avoid the partial flag update of the normal
326// rotate instructions.
327def FeatureFastSHLDRotate
328 : SubtargetFeature<
329 "fast-shld-rotate", "HasFastSHLDRotate", "true",
330 "SHLD can be used as a faster rotate">;
331
Clement Courbet203fc172017-04-21 09:20:50 +0000332// Ivy Bridge and newer processors have enhanced REP MOVSB and STOSB (aka
333// "string operations"). See "REP String Enhancement" in the Intel Software
Clement Courbet41b43332017-04-21 09:21:05 +0000334// Development Manual. This feature essentially means that REP MOVSB will copy
Clement Courbet203fc172017-04-21 09:20:50 +0000335// using the largest available size instead of copying bytes one by one, making
336// it at least as fast as REPMOVS{W,D,Q}.
337def FeatureERMSB
Clement Courbet1ce3b822017-04-21 09:20:39 +0000338 : SubtargetFeature<
Clement Courbet203fc172017-04-21 09:20:50 +0000339 "ermsb", "HasERMSB", "true",
Clement Courbet1ce3b822017-04-21 09:20:39 +0000340 "REP MOVS/STOS are fast">;
341
Craig Topper641e2af2017-08-30 04:34:48 +0000342// Sandy Bridge and newer processors have many instructions that can be
343// fused with conditional branches and pass through the CPU as a single
344// operation.
345def FeatureMacroFusion
346 : SubtargetFeature<"macrofusion", "HasMacroFusion", "true",
347 "Various instructions can be fused with conditional branches">;
348
Craig Topperea37e202017-11-25 18:09:37 +0000349// Gather is available since Haswell (AVX2 set). So technically, we can
350// generate Gathers on all AVX2 processors. But the overhead on HSW is high.
351// Skylake Client processor has faster Gathers than HSW and performance is
352// similar to Skylake Server (AVX-512).
353def FeatureHasFastGather
354 : SubtargetFeature<"fast-gather", "HasFastGather", "true",
355 "Indicates if gather is reasonably fast.">;
356
Craig Topper0d797a32018-01-20 00:26:08 +0000357def FeaturePrefer256Bit
358 : SubtargetFeature<"prefer-256-bit", "Prefer256Bit", "true",
359 "Prefer 256-bit AVX instructions">;
360
Chandler Carruthae0cafe2018-08-23 06:06:38 +0000361// Lower indirect calls using a special construct called a `retpoline` to
362// mitigate potential Spectre v2 attacks against them.
363def FeatureRetpolineIndirectCalls
364 : SubtargetFeature<
365 "retpoline-indirect-calls", "UseRetpolineIndirectCalls", "true",
366 "Remove speculation of indirect calls from the generated code.">;
367
368// Lower indirect branches and switches either using conditional branch trees
369// or using a special construct called a `retpoline` to mitigate potential
370// Spectre v2 attacks against them.
371def FeatureRetpolineIndirectBranches
372 : SubtargetFeature<
373 "retpoline-indirect-branches", "UseRetpolineIndirectBranches", "true",
374 "Remove speculation of indirect branches from the generated code.">;
375
376// Deprecated umbrella feature for enabling both `retpoline-indirect-calls` and
377// `retpoline-indirect-branches` above.
Chandler Carruthc58f2162018-01-22 22:05:25 +0000378def FeatureRetpoline
Chandler Carruthae0cafe2018-08-23 06:06:38 +0000379 : SubtargetFeature<"retpoline", "DeprecatedUseRetpoline", "true",
Chandler Carruthc58f2162018-01-22 22:05:25 +0000380 "Remove speculation of indirect branches from the "
381 "generated code, either by avoiding them entirely or "
Chandler Carruthae0cafe2018-08-23 06:06:38 +0000382 "lowering them with a speculation blocking construct.",
383 [FeatureRetpolineIndirectCalls,
384 FeatureRetpolineIndirectBranches]>;
Chandler Carruthc58f2162018-01-22 22:05:25 +0000385
386// Rely on external thunks for the emitted retpoline calls. This allows users
387// to provide their own custom thunk definitions in highly specialized
388// environments such as a kernel that does boot-time hot patching.
389def FeatureRetpolineExternalThunk
390 : SubtargetFeature<
391 "retpoline-external-thunk", "UseRetpolineExternalThunk", "true",
Chandler Carruthae0cafe2018-08-23 06:06:38 +0000392 "When lowering an indirect call or branch using a `retpoline`, rely "
393 "on the specified user provided thunk rather than emitting one "
394 "ourselves. Only has effect when combined with some other retpoline "
395 "feature.", [FeatureRetpolineIndirectCalls]>;
Chandler Carruthc58f2162018-01-22 22:05:25 +0000396
Gabor Buellac8ded042018-05-01 10:01:16 +0000397// Direct Move instructions.
398def FeatureMOVDIRI : SubtargetFeature<"movdiri", "HasMOVDIRI", "true",
399 "Support movdiri instruction">;
400def FeatureMOVDIR64B : SubtargetFeature<"movdir64b", "HasMOVDIR64B", "true",
401 "Support movdir64b instruction">;
402
Evan Chengff1beda2006-10-06 09:17:41 +0000403//===----------------------------------------------------------------------===//
Craig Topper57c28152017-12-10 17:42:36 +0000404// Register File Description
405//===----------------------------------------------------------------------===//
406
407include "X86RegisterInfo.td"
408include "X86RegisterBanks.td"
409
410//===----------------------------------------------------------------------===//
411// Instruction Descriptions
Evan Chengff1beda2006-10-06 09:17:41 +0000412//===----------------------------------------------------------------------===//
413
Andrew Trick8523b162012-02-01 23:20:51 +0000414include "X86Schedule.td"
Craig Topper57c28152017-12-10 17:42:36 +0000415include "X86InstrInfo.td"
Andrea Di Biagiob6022aa2018-07-19 16:42:15 +0000416include "X86SchedPredicates.td"
Craig Topper57c28152017-12-10 17:42:36 +0000417
418def X86InstrInfo : InstrInfo;
419
420//===----------------------------------------------------------------------===//
421// X86 processors supported.
422//===----------------------------------------------------------------------===//
423
424include "X86ScheduleAtom.td"
425include "X86SchedSandyBridge.td"
426include "X86SchedHaswell.td"
427include "X86SchedBroadwell.td"
428include "X86ScheduleSLM.td"
429include "X86ScheduleZnver1.td"
430include "X86ScheduleBtVer2.td"
431include "X86SchedSkylakeClient.td"
432include "X86SchedSkylakeServer.td"
Andrew Trick8523b162012-02-01 23:20:51 +0000433
434def ProcIntelAtom : SubtargetFeature<"atom", "X86ProcFamily", "IntelAtom",
435 "Intel Atom processors">;
Preston Gurd3fe264d2013-09-13 19:23:28 +0000436def ProcIntelSLM : SubtargetFeature<"slm", "X86ProcFamily", "IntelSLM",
437 "Intel Silvermont processors">;
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000438def ProcIntelGLM : SubtargetFeature<"glm", "X86ProcFamily", "IntelGLM",
439 "Intel Goldmont processors">;
Gabor Buella8f1646b2018-04-16 07:47:35 +0000440def ProcIntelGLP : SubtargetFeature<"glp", "X86ProcFamily", "IntelGLP",
441 "Intel Goldmont Plus processors">;
442def ProcIntelTRM : SubtargetFeature<"tremont", "X86ProcFamily", "IntelTRM",
443 "Intel Tremont processors">;
Mohammed Agabariae9aebf22017-09-13 09:00:27 +0000444def ProcIntelHSW : SubtargetFeature<"haswell", "X86ProcFamily",
445 "IntelHaswell", "Intel Haswell processors">;
446def ProcIntelBDW : SubtargetFeature<"broadwell", "X86ProcFamily",
447 "IntelBroadwell", "Intel Broadwell processors">;
448def ProcIntelSKL : SubtargetFeature<"skylake", "X86ProcFamily",
449 "IntelSkylake", "Intel Skylake processors">;
450def ProcIntelKNL : SubtargetFeature<"knl", "X86ProcFamily",
451 "IntelKNL", "Intel Knights Landing processors">;
452def ProcIntelSKX : SubtargetFeature<"skx", "X86ProcFamily",
453 "IntelSKX", "Intel Skylake Server processors">;
454def ProcIntelCNL : SubtargetFeature<"cannonlake", "X86ProcFamily",
455 "IntelCannonlake", "Intel Cannonlake processors">;
Gabor Buella213edc42018-04-10 18:59:13 +0000456def ProcIntelICL : SubtargetFeature<"icelake-client", "X86ProcFamily",
457 "IntelIcelakeClient", "Intel Icelake processors">;
458def ProcIntelICX : SubtargetFeature<"icelake-server", "X86ProcFamily",
459 "IntelIcelakeServer", "Intel Icelake Server processors">;
Andrew Trick8523b162012-02-01 23:20:51 +0000460
Evan Chengff1beda2006-10-06 09:17:41 +0000461class Proc<string Name, list<SubtargetFeature> Features>
Andrew Trick87255e32012-07-07 04:00:00 +0000462 : ProcessorModel<Name, GenericModel, Features>;
Andrew Trick8523b162012-02-01 23:20:51 +0000463
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000464def : Proc<"generic", [FeatureX87, FeatureSlowUAMem16]>;
465def : Proc<"i386", [FeatureX87, FeatureSlowUAMem16]>;
466def : Proc<"i486", [FeatureX87, FeatureSlowUAMem16]>;
467def : Proc<"i586", [FeatureX87, FeatureSlowUAMem16]>;
468def : Proc<"pentium", [FeatureX87, FeatureSlowUAMem16]>;
469def : Proc<"pentium-mmx", [FeatureX87, FeatureSlowUAMem16, FeatureMMX]>;
Craig Topper38373222017-11-01 22:15:49 +0000470
Craig Topper505f38a2018-01-10 22:07:16 +0000471def : Proc<"i686", [FeatureX87, FeatureSlowUAMem16, FeatureCMOV]>;
472def : Proc<"pentiumpro", [FeatureX87, FeatureSlowUAMem16, FeatureCMOV,
473 FeatureNOPL]>;
Craig Topper38373222017-11-01 22:15:49 +0000474
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000475def : Proc<"pentium2", [FeatureX87, FeatureSlowUAMem16, FeatureMMX,
Craig Topper505f38a2018-01-10 22:07:16 +0000476 FeatureCMOV, FeatureFXSR, FeatureNOPL]>;
Craig Topper38373222017-11-01 22:15:49 +0000477
478foreach P = ["pentium3", "pentium3m"] in {
479 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureMMX, FeatureSSE1,
Craig Topper128915f2018-08-26 18:29:33 +0000480 FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Craig Topper38373222017-11-01 22:15:49 +0000481}
Mitch Bodarte60465d2016-04-27 22:52:35 +0000482
483// Enable the PostRAScheduler for SSE2 and SSE3 class cpus.
484// The intent is to enable it for pentium4 which is the current default
485// processor in a vanilla 32-bit clang compilation when no specific
486// architecture is specified. This generally gives a nice performance
487// increase on silvermont, with largely neutral behavior on other
488// contemporary large core processors.
489// pentium-m, pentium4m, prescott and nocona are included as a preventative
490// measure to avoid performance surprises, in case clang's default cpu
491// changes slightly.
492
493def : ProcessorModel<"pentium-m", GenericPostRAModel,
494 [FeatureX87, FeatureSlowUAMem16, FeatureMMX,
Craig Topper128915f2018-08-26 18:29:33 +0000495 FeatureSSE2, FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Mitch Bodarte60465d2016-04-27 22:52:35 +0000496
Craig Topper38373222017-11-01 22:15:49 +0000497foreach P = ["pentium4", "pentium4m"] in {
498 def : ProcessorModel<P, GenericPostRAModel,
499 [FeatureX87, FeatureSlowUAMem16, FeatureMMX,
Craig Topper128915f2018-08-26 18:29:33 +0000500 FeatureSSE2, FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Craig Topper38373222017-11-01 22:15:49 +0000501}
Chandler Carruth32908d72014-05-07 17:37:03 +0000502
Andrey Turetskiy958eb462016-04-01 10:16:15 +0000503// Intel Quark.
504def : Proc<"lakemont", []>;
505
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000506// Intel Core Duo.
Craig Topper09b65982015-10-16 06:03:09 +0000507def : ProcessorModel<"yonah", SandyBridgeModel,
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000508 [FeatureX87, FeatureSlowUAMem16, FeatureMMX, FeatureSSE3,
Craig Topper128915f2018-08-26 18:29:33 +0000509 FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000510
511// NetBurst.
Mitch Bodarte60465d2016-04-27 22:52:35 +0000512def : ProcessorModel<"prescott", GenericPostRAModel,
513 [FeatureX87, FeatureSlowUAMem16, FeatureMMX, FeatureSSE3,
Craig Topper128915f2018-08-26 18:29:33 +0000514 FeatureFXSR, FeatureNOPL, FeatureCMOV]>;
Mitch Bodarte60465d2016-04-27 22:52:35 +0000515def : ProcessorModel<"nocona", GenericPostRAModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000516 FeatureX87,
Eric Christopher11e59832015-10-08 20:10:06 +0000517 FeatureSlowUAMem16,
Craig Topper128915f2018-08-26 18:29:33 +0000518 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000519 FeatureMMX,
520 FeatureSSE3,
Craig Topper09b65982015-10-16 06:03:09 +0000521 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000522 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000523 Feature64Bit,
Craig Topper27381172017-10-15 16:57:33 +0000524 FeatureCMPXCHG16B
Eric Christopher11e59832015-10-08 20:10:06 +0000525]>;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000526
527// Intel Core 2 Solo/Duo.
Eric Christopher11e59832015-10-08 20:10:06 +0000528def : ProcessorModel<"core2", SandyBridgeModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000529 FeatureX87,
Eric Christopher11e59832015-10-08 20:10:06 +0000530 FeatureSlowUAMem16,
Craig Topper128915f2018-08-26 18:29:33 +0000531 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000532 FeatureMMX,
533 FeatureSSSE3,
Craig Topper09b65982015-10-16 06:03:09 +0000534 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000535 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000536 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000537 FeatureCMPXCHG16B,
Craig Topper641e2af2017-08-30 04:34:48 +0000538 FeatureLAHFSAHF,
539 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000540]>;
541def : ProcessorModel<"penryn", SandyBridgeModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000542 FeatureX87,
Eric Christopher11e59832015-10-08 20:10:06 +0000543 FeatureSlowUAMem16,
Craig Topper128915f2018-08-26 18:29:33 +0000544 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000545 FeatureMMX,
546 FeatureSSE41,
Craig Topper09b65982015-10-16 06:03:09 +0000547 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000548 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000549 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000550 FeatureCMPXCHG16B,
Craig Topper641e2af2017-08-30 04:34:48 +0000551 FeatureLAHFSAHF,
552 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000553]>;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000554
Chandler Carruthaf8924032014-12-09 10:58:36 +0000555// Atom CPUs.
556class BonnellProc<string Name> : ProcessorModel<Name, AtomModel, [
Eric Christopher11e59832015-10-08 20:10:06 +0000557 ProcIntelAtom,
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000558 FeatureX87,
Eric Christopher11e59832015-10-08 20:10:06 +0000559 FeatureSlowUAMem16,
Craig Topper128915f2018-08-26 18:29:33 +0000560 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000561 FeatureMMX,
562 FeatureSSSE3,
Craig Topper09b65982015-10-16 06:03:09 +0000563 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000564 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000565 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000566 FeatureCMPXCHG16B,
567 FeatureMOVBE,
Sanjay Patel53d1d8b2015-10-12 15:24:01 +0000568 FeatureLEAForSP,
Eric Christopher11e59832015-10-08 20:10:06 +0000569 FeatureSlowDivide32,
570 FeatureSlowDivide64,
Craig Topper62c47a22017-08-29 05:14:27 +0000571 FeatureSlowTwoMemOps,
Eric Christopher11e59832015-10-08 20:10:06 +0000572 FeatureLEAUsesAG,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000573 FeaturePadShortFunctions,
574 FeatureLAHFSAHF
Eric Christopher11e59832015-10-08 20:10:06 +0000575]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000576def : BonnellProc<"bonnell">;
577def : BonnellProc<"atom">; // Pin the generic name to the baseline.
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000578
Chandler Carruthaf8924032014-12-09 10:58:36 +0000579class SilvermontProc<string Name> : ProcessorModel<Name, SLMModel, [
Eric Christopher11e59832015-10-08 20:10:06 +0000580 ProcIntelSLM,
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000581 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000582 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000583 FeatureMMX,
584 FeatureSSE42,
Craig Topper09b65982015-10-16 06:03:09 +0000585 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000586 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000587 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000588 FeatureCMPXCHG16B,
589 FeatureMOVBE,
590 FeaturePOPCNT,
591 FeaturePCLMUL,
Eric Christopher11e59832015-10-08 20:10:06 +0000592 FeatureSlowDivide64,
Craig Topper62c47a22017-08-29 05:14:27 +0000593 FeatureSlowTwoMemOps,
Eric Christopher11e59832015-10-08 20:10:06 +0000594 FeaturePRFCHW,
595 FeatureSlowLEA,
596 FeatureSlowIncDec,
Zvi Rackover8bc7e4d2016-12-06 19:35:20 +0000597 FeatureSlowPMULLD,
Craig Topperb207dd62018-01-26 19:34:14 +0000598 FeatureRDRAND,
Craig Topperbc895a32018-04-19 19:25:24 +0000599 FeatureLAHFSAHF,
600 FeaturePOPCNTFalseDeps
Eric Christopher11e59832015-10-08 20:10:06 +0000601]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000602def : SilvermontProc<"silvermont">;
603def : SilvermontProc<"slm">; // Legacy alias.
604
Gabor Buella8f1646b2018-04-16 07:47:35 +0000605class ProcessorFeatures<list<SubtargetFeature> Inherited,
606 list<SubtargetFeature> NewFeatures> {
607 list<SubtargetFeature> Value = !listconcat(Inherited, NewFeatures);
608}
609
610class ProcModel<string Name, SchedMachineModel Model,
611 list<SubtargetFeature> ProcFeatures,
612 list<SubtargetFeature> OtherFeatures> :
613 ProcessorModel<Name, Model, !listconcat(ProcFeatures, OtherFeatures)>;
614
615def GLMFeatures : ProcessorFeatures<[], [
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000616 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000617 FeatureCMOV,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000618 FeatureMMX,
619 FeatureSSE42,
620 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000621 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000622 Feature64Bit,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000623 FeatureCMPXCHG16B,
624 FeatureMOVBE,
625 FeaturePOPCNT,
626 FeaturePCLMUL,
627 FeatureAES,
628 FeaturePRFCHW,
Craig Topper62c47a22017-08-29 05:14:27 +0000629 FeatureSlowTwoMemOps,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000630 FeatureSlowLEA,
631 FeatureSlowIncDec,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000632 FeatureLAHFSAHF,
633 FeatureMPX,
634 FeatureSHA,
Craig Toppera4c5caf2017-07-04 05:33:19 +0000635 FeatureRDRAND,
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000636 FeatureRDSEED,
637 FeatureXSAVE,
638 FeatureXSAVEOPT,
639 FeatureXSAVEC,
640 FeatureXSAVES,
Michael Zuckermanac1d20d2017-09-25 13:45:31 +0000641 FeatureCLFLUSHOPT,
642 FeatureFSGSBase
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000643]>;
Gabor Buella8f1646b2018-04-16 07:47:35 +0000644
645class GoldmontProc<string Name> : ProcModel<Name, SLMModel,
Craig Topperbc895a32018-04-19 19:25:24 +0000646 GLMFeatures.Value, [
647 ProcIntelGLM,
648 FeaturePOPCNTFalseDeps
649]>;
Michael Zuckerman4bcb9c32017-06-29 10:00:33 +0000650def : GoldmontProc<"goldmont">;
651
Gabor Buellaa832b222018-05-10 07:26:05 +0000652def GLPFeatures : ProcessorFeatures<GLMFeatures.Value, [
653 FeaturePTWRITE,
Gabor Buella8f1646b2018-04-16 07:47:35 +0000654 FeatureRDPID,
655 FeatureSGX
656]>;
Gabor Buellaa832b222018-05-10 07:26:05 +0000657
658class GoldmontPlusProc<string Name> : ProcModel<Name, SLMModel,
659 GLPFeatures.Value, [
660 ProcIntelGLP
661]>;
Gabor Buella8f1646b2018-04-16 07:47:35 +0000662def : GoldmontPlusProc<"goldmont-plus">;
663
664class TremontProc<string Name> : ProcModel<Name, SLMModel,
Gabor Buellaa832b222018-05-10 07:26:05 +0000665 GLPFeatures.Value, [
Gabor Buella8f1646b2018-04-16 07:47:35 +0000666 ProcIntelTRM,
667 FeatureCLDEMOTE,
668 FeatureGFNI,
Gabor Buellac8ded042018-05-01 10:01:16 +0000669 FeatureMOVDIRI,
670 FeatureMOVDIR64B,
Gabor Buella31fa8022018-04-20 18:42:47 +0000671 FeatureWAITPKG
Gabor Buella8f1646b2018-04-16 07:47:35 +0000672]>;
673def : TremontProc<"tremont">;
674
Eric Christopher2ef63182010-04-02 21:54:27 +0000675// "Arrandale" along with corei3 and corei5
Craig Topper3611d9b2015-03-30 06:31:11 +0000676class NehalemProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000677 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000678 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000679 FeatureMMX,
680 FeatureSSE42,
Craig Topper09b65982015-10-16 06:03:09 +0000681 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000682 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000683 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000684 FeatureCMPXCHG16B,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000685 FeaturePOPCNT,
Craig Topper641e2af2017-08-30 04:34:48 +0000686 FeatureLAHFSAHF,
687 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000688]>;
Craig Topper3611d9b2015-03-30 06:31:11 +0000689def : NehalemProc<"nehalem">;
690def : NehalemProc<"corei7">;
Jakob Stoklund Olesen1ac7e662013-03-26 22:19:12 +0000691
Eric Christopher2ef63182010-04-02 21:54:27 +0000692// Westmere is a similar machine to nehalem with some additional features.
693// Westmere is the corei3/i5/i7 path from nehalem to sandybridge
Chandler Carruthaf8924032014-12-09 10:58:36 +0000694class WestmereProc<string Name> : ProcessorModel<Name, SandyBridgeModel, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000695 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000696 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000697 FeatureMMX,
698 FeatureSSE42,
Craig Topper09b65982015-10-16 06:03:09 +0000699 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000700 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000701 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000702 FeatureCMPXCHG16B,
Eric Christopher11e59832015-10-08 20:10:06 +0000703 FeaturePOPCNT,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000704 FeaturePCLMUL,
Craig Topper641e2af2017-08-30 04:34:48 +0000705 FeatureLAHFSAHF,
706 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000707]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000708def : WestmereProc<"westmere">;
709
Nate Begeman8b08f522010-12-10 00:26:57 +0000710// SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
711// rather than a superset.
Craig Topperf730a6b2016-02-13 21:35:37 +0000712def SNBFeatures : ProcessorFeatures<[], [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000713 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000714 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000715 FeatureMMX,
716 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +0000717 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000718 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000719 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000720 FeatureCMPXCHG16B,
Eric Christopher11e59832015-10-08 20:10:06 +0000721 FeaturePOPCNT,
Nikolai Bozhenov6bdf92c2017-01-12 19:34:15 +0000722 FeatureSlowDivide64,
Craig Topper0ee35692015-10-14 05:37:38 +0000723 FeaturePCLMUL,
724 FeatureXSAVE,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000725 FeatureXSAVEOPT,
Nikolai Bozhenovf6795302016-08-04 12:47:28 +0000726 FeatureLAHFSAHF,
Lama Saba2ea271b2017-05-18 08:11:50 +0000727 FeatureSlow3OpsLEA,
Craig Topperd88389a2017-02-21 06:39:13 +0000728 FeatureFastScalarFSQRT,
Craig Topper641e2af2017-08-30 04:34:48 +0000729 FeatureFastSHLDRotate,
Craig Topperef1f7162017-08-30 05:00:35 +0000730 FeatureSlowIncDec,
Craig Topper641e2af2017-08-30 04:34:48 +0000731 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +0000732]>;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000733
Craig Topperf730a6b2016-02-13 21:35:37 +0000734class SandyBridgeProc<string Name> : ProcModel<Name, SandyBridgeModel,
735 SNBFeatures.Value, [
Marina Yatsina77a21db2018-01-22 10:07:01 +0000736 FeatureSlowUAMem32,
737 FeaturePOPCNTFalseDeps
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000738]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000739def : SandyBridgeProc<"sandybridge">;
740def : SandyBridgeProc<"corei7-avx">; // Legacy alias.
Evan Chengff1beda2006-10-06 09:17:41 +0000741
Craig Topperf730a6b2016-02-13 21:35:37 +0000742def IVBFeatures : ProcessorFeatures<SNBFeatures.Value, [
Eric Christopher11e59832015-10-08 20:10:06 +0000743 FeatureRDRAND,
744 FeatureF16C,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000745 FeatureFSGSBase
746]>;
747
Craig Topperf730a6b2016-02-13 21:35:37 +0000748class IvyBridgeProc<string Name> : ProcModel<Name, SandyBridgeModel,
749 IVBFeatures.Value, [
Marina Yatsina77a21db2018-01-22 10:07:01 +0000750 FeatureSlowUAMem32,
751 FeaturePOPCNTFalseDeps
Eric Christopher11e59832015-10-08 20:10:06 +0000752]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000753def : IvyBridgeProc<"ivybridge">;
754def : IvyBridgeProc<"core-avx-i">; // Legacy alias.
Craig Topper3657fe42011-10-14 03:21:46 +0000755
Craig Topperf730a6b2016-02-13 21:35:37 +0000756def HSWFeatures : ProcessorFeatures<IVBFeatures.Value, [
Eric Christopher11e59832015-10-08 20:10:06 +0000757 FeatureAVX2,
Eric Christopher11e59832015-10-08 20:10:06 +0000758 FeatureBMI,
759 FeatureBMI2,
Clement Courbet203fc172017-04-21 09:20:50 +0000760 FeatureERMSB,
Eric Christopher11e59832015-10-08 20:10:06 +0000761 FeatureFMA,
Gabor Buellad2f1ab12018-05-25 06:32:05 +0000762 FeatureINVPCID,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000763 FeatureLZCNT,
Simon Pilgrimfd5df632017-12-19 13:16:43 +0000764 FeatureMOVBE,
765 FeatureFastVariableShuffle
Eric Christopher11e59832015-10-08 20:10:06 +0000766]>;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000767
Craig Topperf730a6b2016-02-13 21:35:37 +0000768class HaswellProc<string Name> : ProcModel<Name, HaswellModel,
Mohammed Agabariae9aebf22017-09-13 09:00:27 +0000769 HSWFeatures.Value, [
Marina Yatsina77a21db2018-01-22 10:07:01 +0000770 ProcIntelHSW,
771 FeaturePOPCNTFalseDeps,
772 FeatureLZCNTFalseDeps
Craig Topper54541c42017-10-13 16:04:08 +0000773]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000774def : HaswellProc<"haswell">;
775def : HaswellProc<"core-avx2">; // Legacy alias.
776
Craig Topperf730a6b2016-02-13 21:35:37 +0000777def BDWFeatures : ProcessorFeatures<HSWFeatures.Value, [
Eric Christopher11e59832015-10-08 20:10:06 +0000778 FeatureADX,
Craig Topper67885f52017-12-22 02:41:12 +0000779 FeatureRDSEED,
780 FeaturePRFCHW
Eric Christopher11e59832015-10-08 20:10:06 +0000781]>;
Gadi Haber323f2e12017-10-24 20:19:47 +0000782class BroadwellProc<string Name> : ProcModel<Name, BroadwellModel,
Craig Topper54541c42017-10-13 16:04:08 +0000783 BDWFeatures.Value, [
Marina Yatsina77a21db2018-01-22 10:07:01 +0000784 ProcIntelBDW,
785 FeaturePOPCNTFalseDeps,
786 FeatureLZCNTFalseDeps
Craig Topper54541c42017-10-13 16:04:08 +0000787]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000788def : BroadwellProc<"broadwell">;
789
Craig Topperf730a6b2016-02-13 21:35:37 +0000790def SKLFeatures : ProcessorFeatures<BDWFeatures.Value, [
Erich Keane911ddd62018-09-10 21:12:19 +0000791 FeatureAES,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000792 FeatureMPX,
Eric Christopher58297412017-03-29 07:40:44 +0000793 FeatureRTM,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000794 FeatureXSAVEC,
795 FeatureXSAVES,
Nikolai Bozhenovf6795302016-08-04 12:47:28 +0000796 FeatureCLFLUSHOPT,
797 FeatureFastVectorFSQRT
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000798]>;
799
Gadi Haber6f8fbf42017-09-19 06:19:27 +0000800class SkylakeClientProc<string Name> : ProcModel<Name, SkylakeClientModel,
Mohammed Agabariae9aebf22017-09-13 09:00:27 +0000801 SKLFeatures.Value, [
Craig Topperea37e202017-11-25 18:09:37 +0000802 ProcIntelSKL,
Marina Yatsina77a21db2018-01-22 10:07:01 +0000803 FeatureHasFastGather,
Gabor Buella3eab22d2018-04-10 13:58:57 +0000804 FeaturePOPCNTFalseDeps,
805 FeatureSGX
Craig Topper5805fb32017-10-13 16:06:06 +0000806]>;
Sanjoy Dasaa63dc02016-02-21 17:12:03 +0000807def : SkylakeClientProc<"skylake">;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000808
Craig Topper5d692912017-10-13 18:10:17 +0000809def KNLFeatures : ProcessorFeatures<IVBFeatures.Value, [
Eric Christopher11e59832015-10-08 20:10:06 +0000810 FeatureAVX512,
811 FeatureERI,
812 FeatureCDI,
813 FeaturePFI,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000814 FeaturePREFETCHWT1,
815 FeatureADX,
816 FeatureRDSEED,
Eric Christopher11e59832015-10-08 20:10:06 +0000817 FeatureMOVBE,
818 FeatureLZCNT,
819 FeatureBMI,
820 FeatureBMI2,
Craig Topper67885f52017-12-22 02:41:12 +0000821 FeatureFMA,
822 FeaturePRFCHW
Craig Topper5d692912017-10-13 18:10:17 +0000823]>;
824
825// FIXME: define KNL model
826class KnightsLandingProc<string Name> : ProcModel<Name, HaswellModel,
827 KNLFeatures.Value, [
828 ProcIntelKNL,
Craig Topper62c47a22017-08-29 05:14:27 +0000829 FeatureSlowTwoMemOps,
Craig Topperea37e202017-11-25 18:09:37 +0000830 FeatureFastPartialYMMorZMMWrite,
831 FeatureHasFastGather
Eric Christopher11e59832015-10-08 20:10:06 +0000832]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000833def : KnightsLandingProc<"knl">;
Elena Demikhovsky8cfb43f2013-07-24 11:02:47 +0000834
Craig Topper5d692912017-10-13 18:10:17 +0000835class KnightsMillProc<string Name> : ProcModel<Name, HaswellModel,
836 KNLFeatures.Value, [
837 ProcIntelKNL,
838 FeatureSlowTwoMemOps,
Craig Topper6fae2ee2017-10-25 17:10:32 +0000839 FeatureFastPartialYMMorZMMWrite,
Craig Topperea37e202017-11-25 18:09:37 +0000840 FeatureHasFastGather,
Craig Topper6fae2ee2017-10-25 17:10:32 +0000841 FeatureVPOPCNTDQ
Craig Topper5d692912017-10-13 18:10:17 +0000842]>;
843def : KnightsMillProc<"knm">; // TODO Add AVX5124FMAPS/AVX5124VNNIW features
844
Craig Topperf730a6b2016-02-13 21:35:37 +0000845def SKXFeatures : ProcessorFeatures<SKLFeatures.Value, [
Eric Christopher11e59832015-10-08 20:10:06 +0000846 FeatureAVX512,
847 FeatureCDI,
848 FeatureDQI,
849 FeatureBWI,
850 FeatureVLX,
Asaf Badouh5acf66f2015-12-15 13:35:29 +0000851 FeaturePKU,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000852 FeatureCLWB
Eric Christopher11e59832015-10-08 20:10:06 +0000853]>;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000854
Gadi Haber684944b2017-10-08 12:52:54 +0000855class SkylakeServerProc<string Name> : ProcModel<Name, SkylakeServerModel,
Mohammed Agabariae9aebf22017-09-13 09:00:27 +0000856 SKXFeatures.Value, [
Craig Topperea37e202017-11-25 18:09:37 +0000857 ProcIntelSKX,
Craig Toppera8f87a32018-01-29 21:56:48 +0000858 FeatureHasFastGather,
859 FeaturePOPCNTFalseDeps
Craig Toppera1f9c9dd2017-10-15 16:41:15 +0000860]>;
Sanjoy Dasaa63dc02016-02-21 17:12:03 +0000861def : SkylakeServerProc<"skylake-avx512">;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000862def : SkylakeServerProc<"skx">; // Legacy alias.
863
Craig Topperd710ada2018-02-21 00:15:48 +0000864def CNLFeatures : ProcessorFeatures<SKLFeatures.Value, [
865 FeatureAVX512,
866 FeatureCDI,
867 FeatureDQI,
868 FeatureBWI,
869 FeatureVLX,
870 FeaturePKU,
Elena Demikhovsky9242ea82016-01-18 13:00:31 +0000871 FeatureVBMI,
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000872 FeatureIFMA,
Gabor Buella3eab22d2018-04-10 13:58:57 +0000873 FeatureSHA,
874 FeatureSGX
Elena Demikhovsky9242ea82016-01-18 13:00:31 +0000875]>;
Elena Demikhovsky29cde352016-01-24 10:41:28 +0000876
Craig Topper9a94dfc2017-11-19 01:25:30 +0000877class CannonlakeProc<string Name> : ProcModel<Name, SkylakeServerModel,
Mohammed Agabariae9aebf22017-09-13 09:00:27 +0000878 CNLFeatures.Value, [
Craig Topperea37e202017-11-25 18:09:37 +0000879 ProcIntelCNL,
880 FeatureHasFastGather
Craig Topper5805fb32017-10-13 16:06:06 +0000881]>;
Elena Demikhovsky9242ea82016-01-18 13:00:31 +0000882def : CannonlakeProc<"cannonlake">;
Chandler Carruthaf8924032014-12-09 10:58:36 +0000883
Craig Topper81037f32017-11-19 01:12:00 +0000884def ICLFeatures : ProcessorFeatures<CNLFeatures.Value, [
Craig Toppera8905702017-11-21 21:05:18 +0000885 FeatureBITALG,
886 FeatureVAES,
887 FeatureVBMI2,
888 FeatureVNNI,
889 FeatureVPCLMULQDQ,
Coby Tayreed8b17be2017-11-26 09:36:41 +0000890 FeatureVPOPCNTDQ,
Craig Topper55cfa892017-12-27 22:04:04 +0000891 FeatureGFNI,
Craig Topper84b26b92018-01-18 23:52:31 +0000892 FeatureCLWB,
893 FeatureRDPID
Craig Topper81037f32017-11-19 01:12:00 +0000894]>;
895
Gabor Buella213edc42018-04-10 18:59:13 +0000896class IcelakeClientProc<string Name> : ProcModel<Name, SkylakeServerModel,
897 ICLFeatures.Value, [
Craig Topperea37e202017-11-25 18:09:37 +0000898 ProcIntelICL,
899 FeatureHasFastGather
Craig Topper81037f32017-11-19 01:12:00 +0000900]>;
Gabor Buella213edc42018-04-10 18:59:13 +0000901def : IcelakeClientProc<"icelake-client">;
902
903class IcelakeServerProc<string Name> : ProcModel<Name, SkylakeServerModel,
904 ICLFeatures.Value, [
905 ProcIntelICX,
Gabor Buella2b5e9602018-05-08 06:47:36 +0000906 FeaturePCONFIG,
Gabor Buella2ef36f32018-04-11 20:01:57 +0000907 FeatureWBNOINVD,
Gabor Buella213edc42018-04-10 18:59:13 +0000908 FeatureHasFastGather
909]>;
910def : IcelakeServerProc<"icelake-server">;
Craig Topper81037f32017-11-19 01:12:00 +0000911
Chandler Carruthaf8924032014-12-09 10:58:36 +0000912// AMD CPUs.
Robert Khasanovbfa01312014-07-21 14:54:21 +0000913
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000914def : Proc<"k6", [FeatureX87, FeatureSlowUAMem16, FeatureMMX]>;
915def : Proc<"k6-2", [FeatureX87, FeatureSlowUAMem16, Feature3DNow]>;
916def : Proc<"k6-3", [FeatureX87, FeatureSlowUAMem16, Feature3DNow]>;
Craig Topper38373222017-11-01 22:15:49 +0000917
918foreach P = ["athlon", "athlon-tbird"] in {
Craig Topperb68a78b2018-08-26 18:29:27 +0000919 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureCMOV, Feature3DNowA,
Craig Topper505f38a2018-01-10 22:07:16 +0000920 FeatureNOPL, FeatureSlowSHLD]>;
Craig Topper38373222017-11-01 22:15:49 +0000921}
922
923foreach P = ["athlon-4", "athlon-xp", "athlon-mp"] in {
Craig Topper128915f2018-08-26 18:29:33 +0000924 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureCMOV, FeatureSSE1,
Craig Topper505f38a2018-01-10 22:07:16 +0000925 Feature3DNowA, FeatureFXSR, FeatureNOPL, FeatureSlowSHLD]>;
Craig Topper38373222017-11-01 22:15:49 +0000926}
927
928foreach P = ["k8", "opteron", "athlon64", "athlon-fx"] in {
929 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureSSE2, Feature3DNowA,
Craig Topper128915f2018-08-26 18:29:33 +0000930 FeatureFXSR, FeatureNOPL, Feature64Bit, FeatureSlowSHLD,
931 FeatureCMOV]>;
Craig Topper38373222017-11-01 22:15:49 +0000932}
933
934foreach P = ["k8-sse3", "opteron-sse3", "athlon64-sse3"] in {
935 def : Proc<P, [FeatureX87, FeatureSlowUAMem16, FeatureSSE3, Feature3DNowA,
Craig Topper128915f2018-08-26 18:29:33 +0000936 FeatureFXSR, FeatureNOPL, FeatureCMPXCHG16B, FeatureSlowSHLD,
Craig Topperb7b353b2018-08-30 06:01:05 +0000937 FeatureCMOV, Feature64Bit]>;
Craig Topper38373222017-11-01 22:15:49 +0000938}
939
940foreach P = ["amdfam10", "barcelona"] in {
941 def : Proc<P, [FeatureX87, FeatureSSE4A, Feature3DNowA, FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000942 FeatureNOPL, FeatureCMPXCHG16B, FeatureLZCNT, FeaturePOPCNT,
Craig Topperb7b353b2018-08-30 06:01:05 +0000943 FeatureSlowSHLD, FeatureLAHFSAHF, FeatureCMOV, Feature64Bit]>;
Craig Topper38373222017-11-01 22:15:49 +0000944}
Sanjay Patel9e916dc2015-08-21 20:17:26 +0000945
Benjamin Kramer077ae1d2012-01-10 11:50:02 +0000946// Bobcat
Eric Christopher11e59832015-10-08 20:10:06 +0000947def : Proc<"btver1", [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000948 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000949 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000950 FeatureMMX,
951 FeatureSSSE3,
952 FeatureSSE4A,
Craig Topper09b65982015-10-16 06:03:09 +0000953 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000954 FeatureNOPL,
Craig Topperb7b353b2018-08-30 06:01:05 +0000955 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000956 FeatureCMPXCHG16B,
957 FeaturePRFCHW,
958 FeatureLZCNT,
959 FeaturePOPCNT,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000960 FeatureSlowSHLD,
Simon Pilgrim02bdac52018-01-29 21:24:31 +0000961 FeatureLAHFSAHF,
962 FeatureFast15ByteNOP
Eric Christopher11e59832015-10-08 20:10:06 +0000963]>;
Sanjay Patel1191adf2014-09-09 20:07:07 +0000964
Benjamin Kramerb44c4272013-05-03 10:20:08 +0000965// Jaguar
Eric Christopher11e59832015-10-08 20:10:06 +0000966def : ProcessorModel<"btver2", BtVer2Model, [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000967 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000968 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000969 FeatureMMX,
970 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +0000971 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +0000972 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +0000973 FeatureSSE4A,
Craig Topperb7b353b2018-08-30 06:01:05 +0000974 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +0000975 FeatureCMPXCHG16B,
976 FeaturePRFCHW,
977 FeatureAES,
978 FeaturePCLMUL,
979 FeatureBMI,
980 FeatureF16C,
981 FeatureMOVBE,
982 FeatureLZCNT,
Pierre Gousseaub6d652a2016-10-14 16:41:38 +0000983 FeatureFastLZCNT,
Eric Christopher11e59832015-10-08 20:10:06 +0000984 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +0000985 FeatureXSAVE,
986 FeatureXSAVEOPT,
Hans Wennborg5000ce82015-12-04 23:00:33 +0000987 FeatureSlowSHLD,
Yunzhong Gao0de36ec2016-02-12 23:37:57 +0000988 FeatureLAHFSAHF,
Simon Pilgrim02bdac52018-01-29 21:24:31 +0000989 FeatureFast15ByteNOP,
Amjad Aboud4f977512017-03-03 09:03:24 +0000990 FeatureFastPartialYMMorZMMWrite
Eric Christopher11e59832015-10-08 20:10:06 +0000991]>;
Sanjay Patele57f3c02014-11-28 18:40:18 +0000992
Benjamin Kramer077ae1d2012-01-10 11:50:02 +0000993// Bulldozer
Eric Christopher11e59832015-10-08 20:10:06 +0000994def : Proc<"bdver1", [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +0000995 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +0000996 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +0000997 FeatureXOP,
998 FeatureFMA4,
Craig Topperb7b353b2018-08-30 06:01:05 +0000999 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +00001000 FeatureCMPXCHG16B,
1001 FeatureAES,
1002 FeaturePRFCHW,
1003 FeaturePCLMUL,
1004 FeatureMMX,
1005 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +00001006 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001007 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +00001008 FeatureSSE4A,
1009 FeatureLZCNT,
1010 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +00001011 FeatureXSAVE,
Simon Pilgrim99b925b2017-05-03 15:51:39 +00001012 FeatureLWP,
Hans Wennborg5000ce82015-12-04 23:00:33 +00001013 FeatureSlowSHLD,
Craig Topper641e2af2017-08-30 04:34:48 +00001014 FeatureLAHFSAHF,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001015 FeatureFast11ByteNOP,
Craig Topper641e2af2017-08-30 04:34:48 +00001016 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +00001017]>;
Benjamin Kramerb44c4272013-05-03 10:20:08 +00001018// Piledriver
Eric Christopher11e59832015-10-08 20:10:06 +00001019def : Proc<"bdver2", [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001020 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +00001021 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +00001022 FeatureXOP,
1023 FeatureFMA4,
Craig Topperb7b353b2018-08-30 06:01:05 +00001024 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +00001025 FeatureCMPXCHG16B,
1026 FeatureAES,
1027 FeaturePRFCHW,
1028 FeaturePCLMUL,
1029 FeatureMMX,
1030 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +00001031 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001032 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +00001033 FeatureSSE4A,
1034 FeatureF16C,
1035 FeatureLZCNT,
1036 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +00001037 FeatureXSAVE,
Eric Christopher11e59832015-10-08 20:10:06 +00001038 FeatureBMI,
1039 FeatureTBM,
Simon Pilgrim99b925b2017-05-03 15:51:39 +00001040 FeatureLWP,
Eric Christopher11e59832015-10-08 20:10:06 +00001041 FeatureFMA,
Hans Wennborg5000ce82015-12-04 23:00:33 +00001042 FeatureSlowSHLD,
Craig Topper641e2af2017-08-30 04:34:48 +00001043 FeatureLAHFSAHF,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001044 FeatureFast11ByteNOP,
Craig Topper641e2af2017-08-30 04:34:48 +00001045 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +00001046]>;
Benjamin Kramerd114def2013-11-04 10:29:20 +00001047
1048// Steamroller
Eric Christopher11e59832015-10-08 20:10:06 +00001049def : Proc<"bdver3", [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001050 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +00001051 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +00001052 FeatureXOP,
1053 FeatureFMA4,
Craig Topperb7b353b2018-08-30 06:01:05 +00001054 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +00001055 FeatureCMPXCHG16B,
1056 FeatureAES,
1057 FeaturePRFCHW,
1058 FeaturePCLMUL,
1059 FeatureMMX,
1060 FeatureAVX,
Craig Topper09b65982015-10-16 06:03:09 +00001061 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001062 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +00001063 FeatureSSE4A,
1064 FeatureF16C,
1065 FeatureLZCNT,
1066 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +00001067 FeatureXSAVE,
Eric Christopher11e59832015-10-08 20:10:06 +00001068 FeatureBMI,
1069 FeatureTBM,
Simon Pilgrim99b925b2017-05-03 15:51:39 +00001070 FeatureLWP,
Eric Christopher11e59832015-10-08 20:10:06 +00001071 FeatureFMA,
Craig Topper0ee35692015-10-14 05:37:38 +00001072 FeatureXSAVEOPT,
Eric Christopher11e59832015-10-08 20:10:06 +00001073 FeatureSlowSHLD,
Hans Wennborg5000ce82015-12-04 23:00:33 +00001074 FeatureFSGSBase,
Craig Topper641e2af2017-08-30 04:34:48 +00001075 FeatureLAHFSAHF,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001076 FeatureFast11ByteNOP,
Craig Topper641e2af2017-08-30 04:34:48 +00001077 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +00001078]>;
Benjamin Kramerd114def2013-11-04 10:29:20 +00001079
Benjamin Kramer60045732014-05-02 15:47:07 +00001080// Excavator
Eric Christopher11e59832015-10-08 20:10:06 +00001081def : Proc<"bdver4", [
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001082 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +00001083 FeatureCMOV,
Eric Christopher11e59832015-10-08 20:10:06 +00001084 FeatureMMX,
1085 FeatureAVX2,
Craig Topper09b65982015-10-16 06:03:09 +00001086 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001087 FeatureNOPL,
Eric Christopher11e59832015-10-08 20:10:06 +00001088 FeatureXOP,
1089 FeatureFMA4,
Craig Topperb7b353b2018-08-30 06:01:05 +00001090 Feature64Bit,
Eric Christopher11e59832015-10-08 20:10:06 +00001091 FeatureCMPXCHG16B,
1092 FeatureAES,
1093 FeaturePRFCHW,
1094 FeaturePCLMUL,
1095 FeatureF16C,
1096 FeatureLZCNT,
1097 FeaturePOPCNT,
Craig Topper0ee35692015-10-14 05:37:38 +00001098 FeatureXSAVE,
Eric Christopher11e59832015-10-08 20:10:06 +00001099 FeatureBMI,
1100 FeatureBMI2,
1101 FeatureTBM,
Simon Pilgrim99b925b2017-05-03 15:51:39 +00001102 FeatureLWP,
Eric Christopher11e59832015-10-08 20:10:06 +00001103 FeatureFMA,
Craig Topper0ee35692015-10-14 05:37:38 +00001104 FeatureXSAVEOPT,
Simon Pilgrim381a0ad2016-07-24 16:00:53 +00001105 FeatureSlowSHLD,
Hans Wennborg5000ce82015-12-04 23:00:33 +00001106 FeatureFSGSBase,
Ashutosh Nema348af9c2016-05-18 11:59:12 +00001107 FeatureLAHFSAHF,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001108 FeatureFast11ByteNOP,
Craig Topper641e2af2017-08-30 04:34:48 +00001109 FeatureMWAITX,
1110 FeatureMacroFusion
Eric Christopher11e59832015-10-08 20:10:06 +00001111]>;
Benjamin Kramer60045732014-05-02 15:47:07 +00001112
Craig Topper106b5b62017-07-19 02:45:14 +00001113// Znver1
1114def: ProcessorModel<"znver1", Znver1Model, [
Craig Topperd55b8312017-01-10 06:01:16 +00001115 FeatureADX,
1116 FeatureAES,
1117 FeatureAVX2,
1118 FeatureBMI,
1119 FeatureBMI2,
1120 FeatureCLFLUSHOPT,
Craig Topper50f3d142017-02-09 04:27:34 +00001121 FeatureCLZERO,
Craig Topper128915f2018-08-26 18:29:33 +00001122 FeatureCMOV,
Craig Topperb7b353b2018-08-30 06:01:05 +00001123 Feature64Bit,
Craig Topperd55b8312017-01-10 06:01:16 +00001124 FeatureCMPXCHG16B,
1125 FeatureF16C,
1126 FeatureFMA,
1127 FeatureFSGSBase,
1128 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001129 FeatureNOPL,
Craig Topperd55b8312017-01-10 06:01:16 +00001130 FeatureFastLZCNT,
1131 FeatureLAHFSAHF,
1132 FeatureLZCNT,
Simon Pilgrim02bdac52018-01-29 21:24:31 +00001133 FeatureFast15ByteNOP,
Craig Topper641e2af2017-08-30 04:34:48 +00001134 FeatureMacroFusion,
Craig Topperd55b8312017-01-10 06:01:16 +00001135 FeatureMMX,
1136 FeatureMOVBE,
1137 FeatureMWAITX,
1138 FeaturePCLMUL,
1139 FeaturePOPCNT,
1140 FeaturePRFCHW,
1141 FeatureRDRAND,
1142 FeatureRDSEED,
1143 FeatureSHA,
Craig Topperd55b8312017-01-10 06:01:16 +00001144 FeatureSSE4A,
1145 FeatureSlowSHLD,
1146 FeatureX87,
1147 FeatureXSAVE,
1148 FeatureXSAVEC,
1149 FeatureXSAVEOPT,
1150 FeatureXSAVES]>;
1151
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001152def : Proc<"geode", [FeatureX87, FeatureSlowUAMem16, Feature3DNowA]>;
Evan Chengff1beda2006-10-06 09:17:41 +00001153
Andrey Turetskiy6a3d5612016-03-23 11:13:54 +00001154def : Proc<"winchip-c6", [FeatureX87, FeatureSlowUAMem16, FeatureMMX]>;
1155def : Proc<"winchip2", [FeatureX87, FeatureSlowUAMem16, Feature3DNow]>;
1156def : Proc<"c3", [FeatureX87, FeatureSlowUAMem16, Feature3DNow]>;
1157def : Proc<"c3-2", [FeatureX87, FeatureSlowUAMem16, FeatureMMX,
Craig Topper128915f2018-08-26 18:29:33 +00001158 FeatureSSE1, FeatureFXSR, FeatureCMOV]>;
Evan Chengff1beda2006-10-06 09:17:41 +00001159
Chandler Carruth32908d72014-05-07 17:37:03 +00001160// We also provide a generic 64-bit specific x86 processor model which tries to
1161// be good for modern chips without enabling instruction set encodings past the
1162// basic SSE2 and 64-bit ones. It disables slow things from any mainstream and
1163// modern 64-bit x86 chip, and enables features that are generally beneficial.
Michael Liao5bf95782014-12-04 05:20:33 +00001164//
Chandler Carruth32908d72014-05-07 17:37:03 +00001165// We currently use the Sandy Bridge model as the default scheduling model as
1166// we use it across Nehalem, Westmere, Sandy Bridge, and Ivy Bridge which
1167// covers a huge swath of x86 processors. If there are specific scheduling
1168// knobs which need to be tuned differently for AMD chips, we might consider
1169// forming a common base for them.
Chandler Carruth98c51cb2017-08-21 08:45:22 +00001170def : ProcessorModel<"x86-64", SandyBridgeModel, [
1171 FeatureX87,
Craig Topper128915f2018-08-26 18:29:33 +00001172 FeatureCMOV,
Chandler Carruth98c51cb2017-08-21 08:45:22 +00001173 FeatureMMX,
1174 FeatureSSE2,
1175 FeatureFXSR,
Craig Topper505f38a2018-01-10 22:07:16 +00001176 FeatureNOPL,
Chandler Carruth98c51cb2017-08-21 08:45:22 +00001177 Feature64Bit,
1178 FeatureSlow3OpsLEA,
Craig Topper641e2af2017-08-30 04:34:48 +00001179 FeatureSlowIncDec,
1180 FeatureMacroFusion
Chandler Carruth98c51cb2017-08-21 08:45:22 +00001181]>;
Chandler Carruth32908d72014-05-07 17:37:03 +00001182
Evan Chengff1beda2006-10-06 09:17:41 +00001183//===----------------------------------------------------------------------===//
Chris Lattner5d00a0b2007-02-26 18:17:14 +00001184// Calling Conventions
1185//===----------------------------------------------------------------------===//
1186
1187include "X86CallingConv.td"
1188
1189
1190//===----------------------------------------------------------------------===//
Jim Grosbach4cf25f52010-10-30 13:48:28 +00001191// Assembly Parser
Chris Lattner5d00a0b2007-02-26 18:17:14 +00001192//===----------------------------------------------------------------------===//
1193
Devang Patel85d684a2012-01-09 19:13:28 +00001194def ATTAsmParserVariant : AsmParserVariant {
Daniel Dunbar00331992009-07-29 00:02:19 +00001195 int Variant = 0;
Daniel Dunbare4318712009-08-11 20:59:47 +00001196
Chad Rosier9f7a2212013-04-18 22:35:36 +00001197 // Variant name.
1198 string Name = "att";
1199
Daniel Dunbare4318712009-08-11 20:59:47 +00001200 // Discard comments in assembly strings.
1201 string CommentDelimiter = "#";
1202
1203 // Recognize hard coded registers.
1204 string RegisterPrefix = "%";
Daniel Dunbar00331992009-07-29 00:02:19 +00001205}
1206
Devang Patel67bf992a2012-01-10 17:51:54 +00001207def IntelAsmParserVariant : AsmParserVariant {
1208 int Variant = 1;
1209
Chad Rosier9f7a2212013-04-18 22:35:36 +00001210 // Variant name.
1211 string Name = "intel";
1212
Devang Patel67bf992a2012-01-10 17:51:54 +00001213 // Discard comments in assembly strings.
1214 string CommentDelimiter = ";";
1215
1216 // Recognize hard coded registers.
1217 string RegisterPrefix = "";
1218}
1219
Jim Grosbach4cf25f52010-10-30 13:48:28 +00001220//===----------------------------------------------------------------------===//
1221// Assembly Printers
1222//===----------------------------------------------------------------------===//
1223
Chris Lattner56832602004-10-03 20:36:57 +00001224// The X86 target supports two different syntaxes for emitting machine code.
1225// This is controlled by the -x86-asm-syntax={att|intel}
1226def ATTAsmWriter : AsmWriter {
Chris Lattner1cbd3de2009-09-13 19:30:11 +00001227 string AsmWriterClassName = "ATTInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +00001228 int Variant = 0;
1229}
1230def IntelAsmWriter : AsmWriter {
Chris Lattner13306a12009-09-20 07:47:59 +00001231 string AsmWriterClassName = "IntelInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +00001232 int Variant = 1;
1233}
1234
Chris Lattnera8c3cff2003-08-03 18:19:37 +00001235def X86 : Target {
Chris Lattnera8c3cff2003-08-03 18:19:37 +00001236 // Information about the instructions...
Chris Lattner25510802003-08-04 04:59:56 +00001237 let InstructionSet = X86InstrInfo;
Devang Patel67bf992a2012-01-10 17:51:54 +00001238 let AssemblyParserVariants = [ATTAsmParserVariant, IntelAsmParserVariant];
Chris Lattner56832602004-10-03 20:36:57 +00001239 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
Geoff Berryf8bf2ec2018-02-23 18:25:08 +00001240 let AllowRegisterRenaming = 1;
Chris Lattnera8c3cff2003-08-03 18:19:37 +00001241}
Clement Courbetb4493792018-04-10 08:16:37 +00001242
1243//===----------------------------------------------------------------------===//
1244// Pfm Counters
1245//===----------------------------------------------------------------------===//
1246
1247include "X86PfmCounters.td"