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",
108 def FeaturePCLMUL : SubtargetFeature<"pclmul", "HasPCLMUL", "true",
109 "Enable packed carry-less multiplication instructions",
111 def FeatureFMA : SubtargetFeature<"fma", "HasFMA", "true",
112 "Enable three-operand fused multiple-add",
114 def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
115 "Enable four-operand fused multiple-add",
116 [FeatureAVX, FeatureSSE4A]>;
117 def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
118 "Enable XOP instructions",
120 def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem",
121 "HasVectorUAMem", "true",
122 "Allow unaligned memory operands on vector/SIMD instructions">;
123 def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
124 "Enable AES instructions",
126 def FeatureTBM : SubtargetFeature<"tbm", "HasTBM", "true",
127 "Enable TBM instructions">;
128 def FeatureMOVBE : SubtargetFeature<"movbe", "HasMOVBE", "true",
129 "Support MOVBE instruction">;
130 def FeatureRDRAND : SubtargetFeature<"rdrnd", "HasRDRAND", "true",
131 "Support RDRAND instruction">;
132 def FeatureF16C : SubtargetFeature<"f16c", "HasF16C", "true",
133 "Support 16-bit floating point conversion instructions",
135 def FeatureFSGSBase : SubtargetFeature<"fsgsbase", "HasFSGSBase", "true",
136 "Support FS/GS Base instructions">;
137 def FeatureLZCNT : SubtargetFeature<"lzcnt", "HasLZCNT", "true",
138 "Support LZCNT instruction">;
139 def FeatureBMI : SubtargetFeature<"bmi", "HasBMI", "true",
140 "Support BMI instructions">;
141 def FeatureBMI2 : SubtargetFeature<"bmi2", "HasBMI2", "true",
142 "Support BMI2 instructions">;
143 def FeatureRTM : SubtargetFeature<"rtm", "HasRTM", "true",
144 "Support RTM instructions">;
145 def FeatureHLE : SubtargetFeature<"hle", "HasHLE", "true",
147 def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",
148 "Support ADX instructions">;
149 def FeatureSHA : SubtargetFeature<"sha", "HasSHA", "true",
150 "Enable SHA instructions",
152 def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
153 "Support PRFCHW instructions">;
154 def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
155 "Support RDSEED instruction">;
156 def FeatureLeaForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
157 "Use LEA for adjusting the stack pointer">;
158 def FeatureSlowDivide : SubtargetFeature<"idiv-to-divb",
159 "HasSlowDivide", "true",
160 "Use small divide for positive values less than 256">;
161 def FeaturePadShortFunctions : SubtargetFeature<"pad-short-functions",
162 "PadShortFunctions", "true",
163 "Pad short functions">;
164 def FeatureCallRegIndirect : SubtargetFeature<"call-reg-indirect",
165 "CallRegIndirect", "true",
166 "Call register indirect">;
167 def FeatureLEAUsesAG : SubtargetFeature<"lea-uses-ag", "LEAUsesAG", "true",
168 "LEA instruction needs inputs at AG stage">;
169 def FeatureSlowLEA : SubtargetFeature<"slow-lea", "SlowLEA", "true",
170 "LEA instruction with certain arguments is slow">;
172 //===----------------------------------------------------------------------===//
173 // X86 processors supported.
174 //===----------------------------------------------------------------------===//
176 include "X86Schedule.td"
178 def ProcIntelAtom : SubtargetFeature<"atom", "X86ProcFamily", "IntelAtom",
179 "Intel Atom processors">;
180 def ProcIntelSLM : SubtargetFeature<"slm", "X86ProcFamily", "IntelSLM",
181 "Intel Silvermont processors">;
183 class Proc<string Name, list<SubtargetFeature> Features>
184 : ProcessorModel<Name, GenericModel, Features>;
186 def : Proc<"generic", []>;
187 def : Proc<"i386", []>;
188 def : Proc<"i486", []>;
189 def : Proc<"i586", []>;
190 def : Proc<"pentium", []>;
191 def : Proc<"pentium-mmx", [FeatureMMX]>;
192 def : Proc<"i686", []>;
193 def : Proc<"pentiumpro", [FeatureCMOV]>;
194 def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
195 def : Proc<"pentium3", [FeatureSSE1]>;
196 def : Proc<"pentium3m", [FeatureSSE1, FeatureSlowBTMem]>;
197 def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
198 def : Proc<"pentium4", [FeatureSSE2]>;
199 def : Proc<"pentium4m", [FeatureSSE2, FeatureSlowBTMem]>;
202 def : ProcessorModel<"yonah", SandyBridgeModel,
203 [FeatureSSE3, FeatureSlowBTMem]>;
206 def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
207 def : Proc<"nocona", [FeatureSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
209 // Intel Core 2 Solo/Duo.
210 def : ProcessorModel<"core2", SandyBridgeModel,
211 [FeatureSSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
212 def : ProcessorModel<"penryn", SandyBridgeModel,
213 [FeatureSSE41, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
216 def : ProcessorModel<"atom", AtomModel,
217 [ProcIntelAtom, FeatureSSSE3, FeatureCMPXCHG16B,
218 FeatureMOVBE, FeatureSlowBTMem, FeatureLeaForSP,
220 FeatureCallRegIndirect,
222 FeaturePadShortFunctions]>;
225 def : ProcessorModel<"slm", SLMModel, [ProcIntelSLM,
226 FeatureSSE42, FeatureCMPXCHG16B,
227 FeatureMOVBE, FeaturePOPCNT,
228 FeaturePCLMUL, FeatureAES,
229 FeatureCallRegIndirect,
232 FeatureSlowBTMem, FeatureFastUAMem]>;
233 // "Arrandale" along with corei3 and corei5
234 def : ProcessorModel<"corei7", SandyBridgeModel,
235 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
236 FeatureFastUAMem, FeaturePOPCNT, FeatureAES]>;
238 def : ProcessorModel<"nehalem", SandyBridgeModel,
239 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
240 FeatureFastUAMem, FeaturePOPCNT]>;
241 // Westmere is a similar machine to nehalem with some additional features.
242 // Westmere is the corei3/i5/i7 path from nehalem to sandybridge
243 def : ProcessorModel<"westmere", SandyBridgeModel,
244 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
245 FeatureFastUAMem, FeaturePOPCNT, FeatureAES,
248 // SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
249 // rather than a superset.
250 def : ProcessorModel<"corei7-avx", SandyBridgeModel,
251 [FeatureAVX, FeatureCMPXCHG16B, FeatureFastUAMem,
252 FeaturePOPCNT, FeatureAES, FeaturePCLMUL]>;
254 def : ProcessorModel<"core-avx-i", SandyBridgeModel,
255 [FeatureAVX, FeatureCMPXCHG16B, FeatureFastUAMem,
256 FeaturePOPCNT, FeatureAES, FeaturePCLMUL, FeatureRDRAND,
257 FeatureF16C, FeatureFSGSBase]>;
260 def : ProcessorModel<"core-avx2", HaswellModel,
261 [FeatureAVX2, FeatureCMPXCHG16B, FeatureFastUAMem,
262 FeaturePOPCNT, FeatureAES, FeaturePCLMUL, FeatureRDRAND,
263 FeatureF16C, FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT,
264 FeatureBMI, FeatureBMI2, FeatureFMA, FeatureRTM,
268 // FIXME: define KNL model
269 def : ProcessorModel<"knl", HaswellModel,
270 [FeatureAVX512, FeatureERI, FeatureCDI, FeaturePFI,
271 FeatureCMPXCHG16B, FeatureFastUAMem, FeaturePOPCNT,
272 FeatureAES, FeaturePCLMUL, FeatureRDRAND, FeatureF16C,
273 FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT, FeatureBMI,
274 FeatureBMI2, FeatureFMA, FeatureRTM, FeatureHLE]>;
276 def : Proc<"k6", [FeatureMMX]>;
277 def : Proc<"k6-2", [Feature3DNow]>;
278 def : Proc<"k6-3", [Feature3DNow]>;
279 def : Proc<"athlon", [Feature3DNowA, FeatureSlowBTMem,
281 def : Proc<"athlon-tbird", [Feature3DNowA, FeatureSlowBTMem,
283 def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
285 def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
287 def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem,
289 def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
290 FeatureSlowBTMem, FeatureSlowSHLD]>;
291 def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
292 FeatureSlowBTMem, FeatureSlowSHLD]>;
293 def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
294 FeatureSlowBTMem, FeatureSlowSHLD]>;
295 def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
296 FeatureSlowBTMem, FeatureSlowSHLD]>;
297 def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
298 FeatureSlowBTMem, FeatureSlowSHLD]>;
299 def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
300 FeatureSlowBTMem, FeatureSlowSHLD]>;
301 def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
302 FeatureSlowBTMem, FeatureSlowSHLD]>;
303 def : Proc<"amdfam10", [FeatureSSE4A,
304 Feature3DNowA, FeatureCMPXCHG16B, FeatureLZCNT,
305 FeaturePOPCNT, FeatureSlowBTMem,
308 def : Proc<"btver1", [FeatureSSSE3, FeatureSSE4A, FeatureCMPXCHG16B,
309 FeaturePRFCHW, FeatureLZCNT, FeaturePOPCNT,
312 def : Proc<"btver2", [FeatureAVX, FeatureSSE4A, FeatureCMPXCHG16B,
313 FeaturePRFCHW, FeatureAES, FeaturePCLMUL,
314 FeatureBMI, FeatureF16C, FeatureMOVBE,
315 FeatureLZCNT, FeaturePOPCNT, FeatureSlowSHLD]>;
317 def : Proc<"bdver1", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
318 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
319 FeatureLZCNT, FeaturePOPCNT, FeatureSlowSHLD]>;
321 def : Proc<"bdver2", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
322 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
323 FeatureF16C, FeatureLZCNT,
324 FeaturePOPCNT, FeatureBMI, FeatureTBM,
325 FeatureFMA, FeatureSlowSHLD]>;
328 def : Proc<"bdver3", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
329 FeatureAES, FeaturePRFCHW, FeaturePCLMUL,
330 FeatureF16C, FeatureLZCNT,
331 FeaturePOPCNT, FeatureBMI, FeatureTBM,
332 FeatureFMA, FeatureFSGSBase]>;
335 def : Proc<"bdver4", [FeatureAVX2, FeatureXOP, FeatureFMA4,
336 FeatureCMPXCHG16B, FeatureAES, FeaturePRFCHW,
337 FeaturePCLMUL, FeatureF16C, FeatureLZCNT,
338 FeaturePOPCNT, FeatureBMI, FeatureBMI2,
339 FeatureTBM, FeatureFMA, FeatureFSGSBase]>;
341 def : Proc<"geode", [Feature3DNowA]>;
343 def : Proc<"winchip-c6", [FeatureMMX]>;
344 def : Proc<"winchip2", [Feature3DNow]>;
345 def : Proc<"c3", [Feature3DNow]>;
346 def : Proc<"c3-2", [FeatureSSE1]>;
348 // We also provide a generic 64-bit specific x86 processor model which tries to
349 // be good for modern chips without enabling instruction set encodings past the
350 // basic SSE2 and 64-bit ones. It disables slow things from any mainstream and
351 // modern 64-bit x86 chip, and enables features that are generally beneficial.
353 // We currently use the Sandy Bridge model as the default scheduling model as
354 // we use it across Nehalem, Westmere, Sandy Bridge, and Ivy Bridge which
355 // covers a huge swath of x86 processors. If there are specific scheduling
356 // knobs which need to be tuned differently for AMD chips, we might consider
357 // forming a common base for them.
358 def : ProcessorModel<"x86-64", SandyBridgeModel,
359 [FeatureSSE2, Feature64Bit, FeatureSlowBTMem,
362 //===----------------------------------------------------------------------===//
363 // Register File Description
364 //===----------------------------------------------------------------------===//
366 include "X86RegisterInfo.td"
368 //===----------------------------------------------------------------------===//
369 // Instruction Descriptions
370 //===----------------------------------------------------------------------===//
372 include "X86InstrInfo.td"
374 def X86InstrInfo : InstrInfo;
376 //===----------------------------------------------------------------------===//
377 // Calling Conventions
378 //===----------------------------------------------------------------------===//
380 include "X86CallingConv.td"
383 //===----------------------------------------------------------------------===//
385 //===----------------------------------------------------------------------===//
387 def ATTAsmParser : AsmParser {
388 string AsmParserClassName = "AsmParser";
391 def ATTAsmParserVariant : AsmParserVariant {
397 // Discard comments in assembly strings.
398 string CommentDelimiter = "#";
400 // Recognize hard coded registers.
401 string RegisterPrefix = "%";
404 def IntelAsmParserVariant : AsmParserVariant {
408 string Name = "intel";
410 // Discard comments in assembly strings.
411 string CommentDelimiter = ";";
413 // Recognize hard coded registers.
414 string RegisterPrefix = "";
417 //===----------------------------------------------------------------------===//
419 //===----------------------------------------------------------------------===//
421 // The X86 target supports two different syntaxes for emitting machine code.
422 // This is controlled by the -x86-asm-syntax={att|intel}
423 def ATTAsmWriter : AsmWriter {
424 string AsmWriterClassName = "ATTInstPrinter";
427 def IntelAsmWriter : AsmWriter {
428 string AsmWriterClassName = "IntelInstPrinter";
433 // Information about the instructions...
434 let InstructionSet = X86InstrInfo;
435 let AssemblyParsers = [ATTAsmParser];
436 let AssemblyParserVariants = [ATTAsmParserVariant, IntelAsmParserVariant];
437 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];