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)">;
26 //===----------------------------------------------------------------------===//
27 // X86 Subtarget features
28 //===----------------------------------------------------------------------===//
30 def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true",
31 "Enable conditional move instructions">;
33 def FeaturePOPCNT : SubtargetFeature<"popcnt", "HasPOPCNT", "true",
34 "Support POPCNT instruction">;
37 def FeatureMMX : SubtargetFeature<"mmx","X86SSELevel", "MMX",
38 "Enable MMX instructions">;
39 def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1",
40 "Enable SSE instructions",
41 // SSE codegen depends on cmovs, and all
42 // SSE1+ processors support them.
43 [FeatureMMX, FeatureCMOV]>;
44 def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2",
45 "Enable SSE2 instructions",
47 def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
48 "Enable SSE3 instructions",
50 def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
51 "Enable SSSE3 instructions",
53 def FeatureSSE41 : SubtargetFeature<"sse4.1", "X86SSELevel", "SSE41",
54 "Enable SSE 4.1 instructions",
56 def FeatureSSE42 : SubtargetFeature<"sse4.2", "X86SSELevel", "SSE42",
57 "Enable SSE 4.2 instructions",
59 def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
60 "Enable 3DNow! instructions",
62 def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
63 "Enable 3DNow! Athlon instructions",
65 // All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied
66 // feature, because SSE2 can be disabled (e.g. for compiling OS kernels)
67 // without disabling 64-bit mode.
68 def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true",
69 "Support 64-bit instructions",
71 def FeatureCMPXCHG16B : SubtargetFeature<"cmpxchg16b", "HasCmpxchg16b", "true",
72 "64-bit with cmpxchg16b",
74 def FeatureSlowBTMem : SubtargetFeature<"slow-bt-mem", "IsBTMemSlow", "true",
75 "Bit testing of memory is slow">;
76 def FeatureFastUAMem : SubtargetFeature<"fast-unaligned-mem",
77 "IsUAMemFast", "true",
78 "Fast unaligned memory access">;
79 def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
80 "Support SSE 4a instructions",
83 def FeatureAVX : SubtargetFeature<"avx", "X86SSELevel", "AVX",
84 "Enable AVX instructions",
86 def FeatureAVX2 : SubtargetFeature<"avx2", "X86SSELevel", "AVX2",
87 "Enable AVX2 instructions",
89 def FeatureAVX512 : SubtargetFeature<"avx512f", "X86SSELevel", "AVX512F",
90 "Enable AVX-512 instructions",
92 def FeatureERI : SubtargetFeature<"avx512er", "HasERI", "true",
93 "Enable AVX-512 Exponential and Reciprocal Instructions",
95 def FeatureCDI : SubtargetFeature<"avx512cd", "HasCDI", "true",
96 "Enable AVX-512 Conflict Detection Instructions",
98 def FeaturePFI : SubtargetFeature<"avx512pf", "HasPFI", "true",
99 "Enable AVX-512 PreFetch Instructions",
102 def FeaturePCLMUL : SubtargetFeature<"pclmul", "HasPCLMUL", "true",
103 "Enable packed carry-less multiplication instructions",
105 def FeatureFMA : SubtargetFeature<"fma", "HasFMA", "true",
106 "Enable three-operand fused multiple-add",
108 def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
109 "Enable four-operand fused multiple-add",
110 [FeatureAVX, FeatureSSE4A]>;
111 def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
112 "Enable XOP instructions",
114 def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem",
115 "HasVectorUAMem", "true",
116 "Allow unaligned memory operands on vector/SIMD instructions">;
117 def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
118 "Enable AES instructions",
120 def FeatureMOVBE : SubtargetFeature<"movbe", "HasMOVBE", "true",
121 "Support MOVBE instruction">;
122 def FeatureRDRAND : SubtargetFeature<"rdrnd", "HasRDRAND", "true",
123 "Support RDRAND instruction">;
124 def FeatureF16C : SubtargetFeature<"f16c", "HasF16C", "true",
125 "Support 16-bit floating point conversion instructions">;
126 def FeatureFSGSBase : SubtargetFeature<"fsgsbase", "HasFSGSBase", "true",
127 "Support FS/GS Base instructions">;
128 def FeatureLZCNT : SubtargetFeature<"lzcnt", "HasLZCNT", "true",
129 "Support LZCNT instruction">;
130 def FeatureBMI : SubtargetFeature<"bmi", "HasBMI", "true",
131 "Support BMI instructions">;
132 def FeatureBMI2 : SubtargetFeature<"bmi2", "HasBMI2", "true",
133 "Support BMI2 instructions">;
134 def FeatureRTM : SubtargetFeature<"rtm", "HasRTM", "true",
135 "Support RTM instructions">;
136 def FeatureHLE : SubtargetFeature<"hle", "HasHLE", "true",
138 def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",
139 "Support ADX instructions">;
140 def FeatureSHA : SubtargetFeature<"sha", "HasSHA", "true",
141 "Enable SHA instructions",
143 def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
144 "Support PRFCHW instructions">;
145 def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
146 "Support RDSEED instruction">;
147 def FeatureLeaForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
148 "Use LEA for adjusting the stack pointer">;
149 def FeatureSlowDivide : SubtargetFeature<"idiv-to-divb",
150 "HasSlowDivide", "true",
151 "Use small divide for positive values less than 256">;
152 def FeaturePadShortFunctions : SubtargetFeature<"pad-short-functions",
153 "PadShortFunctions", "true",
154 "Pad short functions">;
155 def FeatureCallRegIndirect : SubtargetFeature<"call-reg-indirect",
156 "CallRegIndirect", "true",
157 "Call register indirect">;
158 def FeatureLEAUsesAG : SubtargetFeature<"lea-uses-ag", "LEAUsesAG", "true",
159 "LEA instruction needs inputs at AG stage">;
161 //===----------------------------------------------------------------------===//
162 // X86 processors supported.
163 //===----------------------------------------------------------------------===//
165 include "X86Schedule.td"
167 def ProcIntelAtom : SubtargetFeature<"atom", "X86ProcFamily", "IntelAtom",
168 "Intel Atom processors">;
170 class Proc<string Name, list<SubtargetFeature> Features>
171 : ProcessorModel<Name, GenericModel, Features>;
173 def : Proc<"generic", []>;
174 def : Proc<"i386", []>;
175 def : Proc<"i486", []>;
176 def : Proc<"i586", []>;
177 def : Proc<"pentium", []>;
178 def : Proc<"pentium-mmx", [FeatureMMX]>;
179 def : Proc<"i686", []>;
180 def : Proc<"pentiumpro", [FeatureCMOV]>;
181 def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
182 def : Proc<"pentium3", [FeatureSSE1]>;
183 def : Proc<"pentium3m", [FeatureSSE1, FeatureSlowBTMem]>;
184 def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
185 def : Proc<"pentium4", [FeatureSSE2]>;
186 def : Proc<"pentium4m", [FeatureSSE2, FeatureSlowBTMem]>;
187 def : Proc<"x86-64", [FeatureSSE2, Feature64Bit, FeatureSlowBTMem,
190 def : ProcessorModel<"yonah", SandyBridgeModel,
191 [FeatureSSE3, FeatureSlowBTMem]>;
194 def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
195 def : Proc<"nocona", [FeatureSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
197 // Intel Core 2 Solo/Duo.
198 def : ProcessorModel<"core2", SandyBridgeModel,
199 [FeatureSSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
200 def : ProcessorModel<"penryn", SandyBridgeModel,
201 [FeatureSSE41, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
204 def : ProcessorModel<"atom", AtomModel,
205 [ProcIntelAtom, FeatureSSSE3, FeatureCMPXCHG16B,
206 FeatureMOVBE, FeatureSlowBTMem, FeatureLeaForSP,
208 FeatureCallRegIndirect,
210 FeaturePadShortFunctions]>;
213 def : ProcessorModel<"slm", AtomModel,
214 [ProcIntelAtom, FeatureSSE42, FeatureCMPXCHG16B,
215 FeatureMOVBE, FeatureSlowBTMem, FeatureLeaForSP,
217 FeatureCallRegIndirect,
219 FeaturePadShortFunctions]>;
221 // "Arrandale" along with corei3 and corei5
222 def : ProcessorModel<"corei7", SandyBridgeModel,
223 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
224 FeatureFastUAMem, FeaturePOPCNT, FeatureAES]>;
226 def : ProcessorModel<"nehalem", SandyBridgeModel,
227 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
228 FeatureFastUAMem, FeaturePOPCNT]>;
229 // Westmere is a similar machine to nehalem with some additional features.
230 // Westmere is the corei3/i5/i7 path from nehalem to sandybridge
231 def : ProcessorModel<"westmere", SandyBridgeModel,
232 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
233 FeatureFastUAMem, FeaturePOPCNT, FeatureAES,
236 // SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
237 // rather than a superset.
238 def : ProcessorModel<"corei7-avx", SandyBridgeModel,
239 [FeatureAVX, FeatureCMPXCHG16B, FeatureFastUAMem,
240 FeaturePOPCNT, FeatureAES, FeaturePCLMUL]>;
242 def : ProcessorModel<"core-avx-i", SandyBridgeModel,
243 [FeatureAVX, FeatureCMPXCHG16B, FeatureFastUAMem,
244 FeaturePOPCNT, FeatureAES, FeaturePCLMUL, FeatureRDRAND,
245 FeatureF16C, FeatureFSGSBase]>;
248 def : ProcessorModel<"core-avx2", HaswellModel,
249 [FeatureAVX2, FeatureCMPXCHG16B, FeatureFastUAMem,
250 FeaturePOPCNT, FeatureAES, FeaturePCLMUL, FeatureRDRAND,
251 FeatureF16C, FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT,
252 FeatureBMI, FeatureBMI2, FeatureFMA, FeatureRTM,
256 // FIXME: define KNL model
257 def : ProcessorModel<"knl", HaswellModel,
258 [FeatureAVX512, FeatureERI, FeatureCDI, FeaturePFI,
259 FeatureCMPXCHG16B, FeatureFastUAMem, FeaturePOPCNT,
260 FeatureAES, FeaturePCLMUL, FeatureRDRAND, FeatureF16C,
261 FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT, FeatureBMI,
262 FeatureBMI2, FeatureFMA, FeatureRTM, FeatureHLE]>;
264 def : Proc<"k6", [FeatureMMX]>;
265 def : Proc<"k6-2", [Feature3DNow]>;
266 def : Proc<"k6-3", [Feature3DNow]>;
267 def : Proc<"athlon", [Feature3DNowA, FeatureSlowBTMem]>;
268 def : Proc<"athlon-tbird", [Feature3DNowA, FeatureSlowBTMem]>;
269 def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
270 def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
271 def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
272 def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
274 def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
276 def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
278 def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
280 def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
282 def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
284 def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
286 def : Proc<"amdfam10", [FeatureSSE4A,
287 Feature3DNowA, FeatureCMPXCHG16B, FeatureLZCNT,
288 FeaturePOPCNT, FeatureSlowBTMem]>;
290 def : Proc<"btver1", [FeatureSSSE3, FeatureSSE4A, FeatureCMPXCHG16B,
291 FeatureLZCNT, FeaturePOPCNT]>;
293 def : Proc<"btver2", [FeatureAVX, FeatureSSE4A, FeatureCMPXCHG16B,
294 FeatureAES, FeaturePCLMUL, FeatureBMI,
295 FeatureF16C, FeatureMOVBE, FeatureLZCNT,
298 def : Proc<"bdver1", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
299 FeatureAES, FeaturePCLMUL,
300 FeatureLZCNT, FeaturePOPCNT]>;
302 def : Proc<"bdver2", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
303 FeatureAES, FeaturePCLMUL,
304 FeatureF16C, FeatureLZCNT,
305 FeaturePOPCNT, FeatureBMI, FeatureFMA]>;
306 def : Proc<"geode", [Feature3DNowA]>;
308 def : Proc<"winchip-c6", [FeatureMMX]>;
309 def : Proc<"winchip2", [Feature3DNow]>;
310 def : Proc<"c3", [Feature3DNow]>;
311 def : Proc<"c3-2", [FeatureSSE1]>;
313 //===----------------------------------------------------------------------===//
314 // Register File Description
315 //===----------------------------------------------------------------------===//
317 include "X86RegisterInfo.td"
319 //===----------------------------------------------------------------------===//
320 // Instruction Descriptions
321 //===----------------------------------------------------------------------===//
323 include "X86InstrInfo.td"
325 def X86InstrInfo : InstrInfo;
327 //===----------------------------------------------------------------------===//
328 // Calling Conventions
329 //===----------------------------------------------------------------------===//
331 include "X86CallingConv.td"
334 //===----------------------------------------------------------------------===//
336 //===----------------------------------------------------------------------===//
338 def ATTAsmParser : AsmParser {
339 string AsmParserClassName = "AsmParser";
342 def ATTAsmParserVariant : AsmParserVariant {
348 // Discard comments in assembly strings.
349 string CommentDelimiter = "#";
351 // Recognize hard coded registers.
352 string RegisterPrefix = "%";
355 def IntelAsmParserVariant : AsmParserVariant {
359 string Name = "intel";
361 // Discard comments in assembly strings.
362 string CommentDelimiter = ";";
364 // Recognize hard coded registers.
365 string RegisterPrefix = "";
368 //===----------------------------------------------------------------------===//
370 //===----------------------------------------------------------------------===//
372 // The X86 target supports two different syntaxes for emitting machine code.
373 // This is controlled by the -x86-asm-syntax={att|intel}
374 def ATTAsmWriter : AsmWriter {
375 string AsmWriterClassName = "ATTInstPrinter";
377 bit isMCAsmWriter = 1;
379 def IntelAsmWriter : AsmWriter {
380 string AsmWriterClassName = "IntelInstPrinter";
382 bit isMCAsmWriter = 1;
386 // Information about the instructions...
387 let InstructionSet = X86InstrInfo;
388 let AssemblyParsers = [ATTAsmParser];
389 let AssemblyParserVariants = [ATTAsmParserVariant, IntelAsmParserVariant];
390 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];