1 //===-- X86.td - Target definition file for the Intel X86 --*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This is a target description file for the Intel i386 architecture, referred
11 // to here as the "X86" architecture.
13 //===----------------------------------------------------------------------===//
15 // Get the target-independent interfaces which we are implementing...
17 include "llvm/Target/Target.td"
19 //===----------------------------------------------------------------------===//
20 // X86 Subtarget state
23 def Mode64Bit : SubtargetFeature<"64bit-mode", "In64BitMode", "true",
24 "64-bit mode (x86_64)">;
25 def Mode32Bit : SubtargetFeature<"32bit-mode", "In32BitMode", "true",
26 "32-bit mode (80386)">;
27 def Mode16Bit : SubtargetFeature<"16bit-mode", "In16BitMode", "true",
28 "16-bit mode (i8086)">;
30 //===----------------------------------------------------------------------===//
31 // X86 Subtarget features
32 //===----------------------------------------------------------------------===//
34 def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true",
35 "Enable conditional move instructions">;
37 def FeaturePOPCNT : SubtargetFeature<"popcnt", "HasPOPCNT", "true",
38 "Support POPCNT instruction">;
41 def FeatureMMX : SubtargetFeature<"mmx","X86SSELevel", "MMX",
42 "Enable MMX instructions">;
43 def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1",
44 "Enable SSE instructions",
45 // SSE codegen depends on cmovs, and all
46 // SSE1+ processors support them.
47 [FeatureMMX, FeatureCMOV]>;
48 def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2",
49 "Enable SSE2 instructions",
51 def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
52 "Enable SSE3 instructions",
54 def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
55 "Enable SSSE3 instructions",
57 def FeatureSSE41 : SubtargetFeature<"sse4.1", "X86SSELevel", "SSE41",
58 "Enable SSE 4.1 instructions",
60 def FeatureSSE42 : SubtargetFeature<"sse4.2", "X86SSELevel", "SSE42",
61 "Enable SSE 4.2 instructions",
63 def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
64 "Enable 3DNow! instructions",
66 def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
67 "Enable 3DNow! Athlon instructions",
69 // 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.
72 def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true",
73 "Support 64-bit instructions",
75 def FeatureCMPXCHG16B : SubtargetFeature<"cx16", "HasCmpxchg16b", "true",
76 "64-bit with cmpxchg16b",
78 def FeatureSlowBTMem : SubtargetFeature<"slow-bt-mem", "IsBTMemSlow", "true",
79 "Bit testing of memory is slow">;
80 def FeatureSlowSHLD : SubtargetFeature<"slow-shld", "IsSHLDSlow", "true",
81 "SHLD instruction is slow">;
82 def FeatureFastUAMem : SubtargetFeature<"fast-unaligned-mem",
83 "IsUAMemFast", "true",
84 "Fast unaligned memory access">;
85 def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
86 "Support SSE 4a instructions",
89 def FeatureAVX : SubtargetFeature<"avx", "X86SSELevel", "AVX",
90 "Enable AVX instructions",
92 def FeatureAVX2 : SubtargetFeature<"avx2", "X86SSELevel", "AVX2",
93 "Enable AVX2 instructions",
95 def FeatureAVX512 : SubtargetFeature<"avx512f", "X86SSELevel", "AVX512F",
96 "Enable AVX-512 instructions",
98 def FeatureERI : SubtargetFeature<"avx512er", "HasERI", "true",
99 "Enable AVX-512 Exponential and Reciprocal Instructions",
101 def FeatureCDI : SubtargetFeature<"avx512cd", "HasCDI", "true",
102 "Enable AVX-512 Conflict Detection Instructions",
104 def FeaturePFI : SubtargetFeature<"avx512pf", "HasPFI", "true",
105 "Enable AVX-512 PreFetch Instructions",
107 def FeatureDQI : SubtargetFeature<"avx512dq", "HasDQI", "true",
108 "Enable AVX-512 Doubleword and Quadword Instructions",
110 def FeatureBWI : SubtargetFeature<"avx512bw", "HasBWI", "true",
111 "Enable AVX-512 Byte and Word Instructions",
113 def FeatureVLX : SubtargetFeature<"avx512vl", "HasVLX", "true",
114 "Enable AVX-512 Vector Length eXtensions",
116 def FeaturePCLMUL : SubtargetFeature<"pclmul", "HasPCLMUL", "true",
117 "Enable packed carry-less multiplication instructions",
119 def FeatureFMA : SubtargetFeature<"fma", "HasFMA", "true",
120 "Enable three-operand fused multiple-add",
122 def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
123 "Enable four-operand fused multiple-add",
124 [FeatureAVX, FeatureSSE4A]>;
125 def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
126 "Enable XOP instructions",
128 def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem",
129 "HasVectorUAMem", "true",
130 "Allow unaligned memory operands on vector/SIMD instructions">;
131 def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
132 "Enable AES instructions",
134 def FeatureTBM : SubtargetFeature<"tbm", "HasTBM", "true",
135 "Enable TBM instructions">;
136 def FeatureMOVBE : SubtargetFeature<"movbe", "HasMOVBE", "true",
137 "Support MOVBE instruction">;
138 def FeatureRDRAND : SubtargetFeature<"rdrnd", "HasRDRAND", "true",
139 "Support RDRAND instruction">;
140 def FeatureF16C : SubtargetFeature<"f16c", "HasF16C", "true",
141 "Support 16-bit floating point conversion instructions",
143 def FeatureFSGSBase : SubtargetFeature<"fsgsbase", "HasFSGSBase", "true",
144 "Support FS/GS Base instructions">;
145 def FeatureLZCNT : SubtargetFeature<"lzcnt", "HasLZCNT", "true",
146 "Support LZCNT instruction">;
147 def FeatureBMI : SubtargetFeature<"bmi", "HasBMI", "true",
148 "Support BMI instructions">;
149 def FeatureBMI2 : SubtargetFeature<"bmi2", "HasBMI2", "true",
150 "Support BMI2 instructions">;
151 def FeatureRTM : SubtargetFeature<"rtm", "HasRTM", "true",
152 "Support RTM instructions">;
153 def FeatureHLE : SubtargetFeature<"hle", "HasHLE", "true",
155 def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",
156 "Support ADX instructions">;
157 def FeatureSHA : SubtargetFeature<"sha", "HasSHA", "true",
158 "Enable SHA instructions",
160 def FeatureSGX : SubtargetFeature<"sgx", "HasSGX", "true",
161 "Support SGX instructions">;
162 def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
163 "Support PRFCHW instructions">;
164 def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
165 "Support RDSEED instruction">;
166 def FeatureSMAP : SubtargetFeature<"smap", "HasSMAP", "true",
167 "Support SMAP instructions">;
168 def FeatureLeaForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
169 "Use LEA for adjusting the stack pointer">;
170 def FeatureSlowDivide : SubtargetFeature<"idiv-to-divb",
171 "HasSlowDivide", "true",
172 "Use small divide for positive values less than 256">;
173 def FeaturePadShortFunctions : SubtargetFeature<"pad-short-functions",
174 "PadShortFunctions", "true",
175 "Pad short functions">;
176 def FeatureCallRegIndirect : SubtargetFeature<"call-reg-indirect",
177 "CallRegIndirect", "true",
178 "Call register indirect">;
179 def FeatureLEAUsesAG : SubtargetFeature<"lea-uses-ag", "LEAUsesAG", "true",
180 "LEA instruction needs inputs at AG stage">;
181 def FeatureSlowLEA : SubtargetFeature<"slow-lea", "SlowLEA", "true",
182 "LEA instruction with certain arguments is slow">;
183 def FeatureSlowIncDec : SubtargetFeature<"slow-incdec", "SlowIncDec", "true",
184 "INC and DEC instructions are slower than ADD and SUB">;
185 def FeatureUseSqrtEst : SubtargetFeature<"use-sqrt-est", "UseSqrtEst", "true",
186 "Use RSQRT* to optimize square root calculations">;
187 def FeatureUseRecipEst : SubtargetFeature<"use-recip-est", "UseReciprocalEst",
188 "true", "Use RCP* to optimize division calculations">;
190 //===----------------------------------------------------------------------===//
191 // X86 processors supported.
192 //===----------------------------------------------------------------------===//
194 include "X86Schedule.td"
196 def ProcIntelAtom : SubtargetFeature<"atom", "X86ProcFamily", "IntelAtom",
197 "Intel Atom processors">;
198 def ProcIntelSLM : SubtargetFeature<"slm", "X86ProcFamily", "IntelSLM",
199 "Intel Silvermont processors">;
201 class Proc<string Name, list<SubtargetFeature> Features>
202 : ProcessorModel<Name, GenericModel, Features>;
204 def : Proc<"generic", []>;
205 def : Proc<"i386", []>;
206 def : Proc<"i486", []>;
207 def : Proc<"i586", []>;
208 def : Proc<"pentium", []>;
209 def : Proc<"pentium-mmx", [FeatureMMX]>;
210 def : Proc<"i686", []>;
211 def : Proc<"pentiumpro", [FeatureCMOV]>;
212 def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
213 def : Proc<"pentium3", [FeatureSSE1]>;
214 def : Proc<"pentium3m", [FeatureSSE1, FeatureSlowBTMem]>;
215 def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
216 def : Proc<"pentium4", [FeatureSSE2]>;
217 def : Proc<"pentium4m", [FeatureSSE2, FeatureSlowBTMem]>;
220 def : ProcessorModel<"yonah", SandyBridgeModel,
221 [FeatureSSE3, FeatureSlowBTMem]>;
224 def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
225 def : Proc<"nocona", [FeatureSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
227 // Intel Core 2 Solo/Duo.
228 def : ProcessorModel<"core2", SandyBridgeModel,
229 [FeatureSSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
230 def : ProcessorModel<"penryn", SandyBridgeModel,
231 [FeatureSSE41, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
234 def : ProcessorModel<"atom", AtomModel,
235 [ProcIntelAtom, FeatureSSSE3, FeatureCMPXCHG16B,
236 FeatureMOVBE, FeatureSlowBTMem, FeatureLeaForSP,
238 FeatureCallRegIndirect,
240 FeaturePadShortFunctions]>;
243 def : ProcessorModel<"slm", SLMModel, [ProcIntelSLM,
244 FeatureSSE42, FeatureCMPXCHG16B,
245 FeatureMOVBE, FeaturePOPCNT,
246 FeaturePCLMUL, FeatureAES,
247 FeatureCallRegIndirect,
249 FeatureSlowLEA, FeatureSlowIncDec,
250 FeatureSlowBTMem, FeatureFastUAMem]>;
251 // "Arrandale" along with corei3 and corei5
252 def : ProcessorModel<"corei7", SandyBridgeModel,
253 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
254 FeatureFastUAMem, FeaturePOPCNT, FeatureAES]>;
256 def : ProcessorModel<"nehalem", SandyBridgeModel,
257 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
258 FeatureFastUAMem, FeaturePOPCNT]>;
259 // Westmere is a similar machine to nehalem with some additional features.
260 // Westmere is the corei3/i5/i7 path from nehalem to sandybridge
261 def : ProcessorModel<"westmere", SandyBridgeModel,
262 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
263 FeatureFastUAMem, FeaturePOPCNT, FeatureAES,
266 // SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
267 // rather than a superset.
268 def : ProcessorModel<"corei7-avx", SandyBridgeModel,
269 [FeatureAVX, FeatureCMPXCHG16B, FeatureFastUAMem,
270 FeaturePOPCNT, FeatureAES, FeaturePCLMUL]>;
272 def : ProcessorModel<"core-avx-i", SandyBridgeModel,
273 [FeatureAVX, FeatureCMPXCHG16B, FeatureFastUAMem,
274 FeaturePOPCNT, FeatureAES, FeaturePCLMUL, FeatureRDRAND,
275 FeatureF16C, FeatureFSGSBase]>;
278 def : ProcessorModel<"core-avx2", HaswellModel,
279 [FeatureAVX2, FeatureCMPXCHG16B, FeatureFastUAMem,
280 FeaturePOPCNT, FeatureAES, FeaturePCLMUL, FeatureRDRAND,
281 FeatureF16C, FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT,
282 FeatureBMI, FeatureBMI2, FeatureFMA, FeatureRTM,
286 def : ProcessorModel<"broadwell", HaswellModel,
287 [FeatureAVX2, FeatureCMPXCHG16B, FeatureFastUAMem,
288 FeaturePOPCNT, FeatureAES, FeaturePCLMUL, FeatureRDRAND,
289 FeatureF16C, FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT,
290 FeatureBMI, FeatureBMI2, FeatureFMA, FeatureRTM,
291 FeatureHLE, FeatureADX, FeatureRDSEED, FeatureSMAP]>;
293 // FIXME: define KNL model
294 def : ProcessorModel<"knl", HaswellModel,
295 [FeatureAVX512, FeatureERI, FeatureCDI, FeaturePFI,
296 FeatureCMPXCHG16B, FeatureFastUAMem, FeaturePOPCNT,
297 FeatureAES, FeaturePCLMUL, FeatureRDRAND, FeatureF16C,
298 FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT, FeatureBMI,
299 FeatureBMI2, FeatureFMA, FeatureRTM, FeatureHLE,
303 // FIXME: define SKX model
304 def : ProcessorModel<"skx", HaswellModel,
305 [FeatureAVX512, FeatureCDI,
306 FeatureDQI, FeatureBWI, FeatureVLX,
307 FeatureCMPXCHG16B, FeatureFastUAMem, FeaturePOPCNT,
308 FeatureAES, FeaturePCLMUL, FeatureRDRAND, FeatureF16C,
309 FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT, FeatureBMI,
310 FeatureBMI2, FeatureFMA, FeatureRTM, FeatureHLE,
311 FeatureSlowIncDec, FeatureSGX]>;
313 def : Proc<"k6", [FeatureMMX]>;
314 def : Proc<"k6-2", [Feature3DNow]>;
315 def : Proc<"k6-3", [Feature3DNow]>;
316 def : Proc<"athlon", [Feature3DNowA, FeatureSlowBTMem,
318 def : Proc<"athlon-tbird", [Feature3DNowA, FeatureSlowBTMem,
320 def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
322 def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
324 def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
326 def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
327 FeatureSlowBTMem, FeatureSlowSHLD]>;
328 def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
329 FeatureSlowBTMem, FeatureSlowSHLD]>;
330 def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
331 FeatureSlowBTMem, FeatureSlowSHLD]>;
332 def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
333 FeatureSlowBTMem, FeatureSlowSHLD]>;
334 def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
335 FeatureSlowBTMem, FeatureSlowSHLD]>;
336 def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
337 FeatureSlowBTMem, FeatureSlowSHLD]>;
338 def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
339 FeatureSlowBTMem, FeatureSlowSHLD]>;
340 def : Proc<"amdfam10", [FeatureSSE4A,
341 Feature3DNowA, FeatureCMPXCHG16B, FeatureLZCNT,
342 FeaturePOPCNT, FeatureSlowBTMem,
345 def : Proc<"btver1", [FeatureSSSE3, FeatureSSE4A, FeatureCMPXCHG16B,
346 FeaturePRFCHW, FeatureLZCNT, FeaturePOPCNT,
350 def : ProcessorModel<"btver2", BtVer2Model,
351 [FeatureAVX, FeatureSSE4A, FeatureCMPXCHG16B,
352 FeaturePRFCHW, FeatureAES, FeaturePCLMUL,
353 FeatureBMI, FeatureF16C, FeatureMOVBE,
354 FeatureLZCNT, FeaturePOPCNT, FeatureSlowSHLD,
355 FeatureUseSqrtEst, FeatureUseRecipEst]>;
358 def : Proc<"bdver1", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
359 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
360 FeatureAVX, FeatureSSE4A, FeatureLZCNT,
361 FeaturePOPCNT, FeatureSlowSHLD]>;
363 def : Proc<"bdver2", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
364 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
365 FeatureAVX, FeatureSSE4A, FeatureF16C,
366 FeatureLZCNT, FeaturePOPCNT, FeatureBMI,
367 FeatureTBM, FeatureFMA, FeatureSlowSHLD]>;
370 def : Proc<"bdver3", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
371 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
372 FeatureAVX, FeatureSSE4A, FeatureF16C,
373 FeatureLZCNT, FeaturePOPCNT, FeatureBMI,
374 FeatureTBM, FeatureFMA, FeatureSlowSHLD,
378 def : Proc<"bdver4", [FeatureAVX2, FeatureXOP, FeatureFMA4,
379 FeatureCMPXCHG16B, FeatureAES, FeaturePRFCHW,
380 FeaturePCLMUL, FeatureF16C, FeatureLZCNT,
381 FeaturePOPCNT, FeatureBMI, FeatureBMI2,
382 FeatureTBM, FeatureFMA, FeatureSSE4A,
385 def : Proc<"geode", [Feature3DNowA]>;
387 def : Proc<"winchip-c6", [FeatureMMX]>;
388 def : Proc<"winchip2", [Feature3DNow]>;
389 def : Proc<"c3", [Feature3DNow]>;
390 def : Proc<"c3-2", [FeatureSSE1]>;
392 // We also provide a generic 64-bit specific x86 processor model which tries to
393 // be good for modern chips without enabling instruction set encodings past the
394 // basic SSE2 and 64-bit ones. It disables slow things from any mainstream and
395 // modern 64-bit x86 chip, and enables features that are generally beneficial.
397 // We currently use the Sandy Bridge model as the default scheduling model as
398 // we use it across Nehalem, Westmere, Sandy Bridge, and Ivy Bridge which
399 // covers a huge swath of x86 processors. If there are specific scheduling
400 // knobs which need to be tuned differently for AMD chips, we might consider
401 // forming a common base for them.
402 def : ProcessorModel<"x86-64", SandyBridgeModel,
403 [FeatureSSE2, Feature64Bit, FeatureSlowBTMem,
406 //===----------------------------------------------------------------------===//
407 // Register File Description
408 //===----------------------------------------------------------------------===//
410 include "X86RegisterInfo.td"
412 //===----------------------------------------------------------------------===//
413 // Instruction Descriptions
414 //===----------------------------------------------------------------------===//
416 include "X86InstrInfo.td"
418 def X86InstrInfo : InstrInfo;
420 //===----------------------------------------------------------------------===//
421 // Calling Conventions
422 //===----------------------------------------------------------------------===//
424 include "X86CallingConv.td"
427 //===----------------------------------------------------------------------===//
429 //===----------------------------------------------------------------------===//
431 def ATTAsmParser : AsmParser {
432 string AsmParserClassName = "AsmParser";
435 def ATTAsmParserVariant : AsmParserVariant {
441 // Discard comments in assembly strings.
442 string CommentDelimiter = "#";
444 // Recognize hard coded registers.
445 string RegisterPrefix = "%";
448 def IntelAsmParserVariant : AsmParserVariant {
452 string Name = "intel";
454 // Discard comments in assembly strings.
455 string CommentDelimiter = ";";
457 // Recognize hard coded registers.
458 string RegisterPrefix = "";
461 //===----------------------------------------------------------------------===//
463 //===----------------------------------------------------------------------===//
465 // The X86 target supports two different syntaxes for emitting machine code.
466 // This is controlled by the -x86-asm-syntax={att|intel}
467 def ATTAsmWriter : AsmWriter {
468 string AsmWriterClassName = "ATTInstPrinter";
471 def IntelAsmWriter : AsmWriter {
472 string AsmWriterClassName = "IntelInstPrinter";
477 // Information about the instructions...
478 let InstructionSet = X86InstrInfo;
479 let AssemblyParsers = [ATTAsmParser];
480 let AssemblyParserVariants = [ATTAsmParserVariant, IntelAsmParserVariant];
481 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];