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<"sse41", "X86SSELevel", "SSE41",
54 "Enable SSE 4.1 instructions",
56 def FeatureSSE42 : SubtargetFeature<"sse42", "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 FeaturePCLMUL : SubtargetFeature<"pclmul", "HasPCLMUL", "true",
90 "Enable packed carry-less multiplication instructions",
92 def FeatureFMA : SubtargetFeature<"fma", "HasFMA", "true",
93 "Enable three-operand fused multiple-add",
95 def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
96 "Enable four-operand fused multiple-add",
97 [FeatureAVX, FeatureSSE4A]>;
98 def FeatureXOP : SubtargetFeature<"xop", "HasXOP", "true",
99 "Enable XOP instructions",
101 def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem",
102 "HasVectorUAMem", "true",
103 "Allow unaligned memory operands on vector/SIMD instructions">;
104 def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
105 "Enable AES instructions",
107 def FeatureMOVBE : SubtargetFeature<"movbe", "HasMOVBE", "true",
108 "Support MOVBE instruction">;
109 def FeatureRDRAND : SubtargetFeature<"rdrand", "HasRDRAND", "true",
110 "Support RDRAND instruction">;
111 def FeatureF16C : SubtargetFeature<"f16c", "HasF16C", "true",
112 "Support 16-bit floating point conversion instructions">;
113 def FeatureFSGSBase : SubtargetFeature<"fsgsbase", "HasFSGSBase", "true",
114 "Support FS/GS Base instructions">;
115 def FeatureLZCNT : SubtargetFeature<"lzcnt", "HasLZCNT", "true",
116 "Support LZCNT instruction">;
117 def FeatureBMI : SubtargetFeature<"bmi", "HasBMI", "true",
118 "Support BMI instructions">;
119 def FeatureBMI2 : SubtargetFeature<"bmi2", "HasBMI2", "true",
120 "Support BMI2 instructions">;
121 def FeatureRTM : SubtargetFeature<"rtm", "HasRTM", "true",
122 "Support RTM instructions">;
123 def FeatureHLE : SubtargetFeature<"hle", "HasHLE", "true",
125 def FeatureADX : SubtargetFeature<"adx", "HasADX", "true",
126 "Support ADX instructions">;
127 def FeaturePRFCHW : SubtargetFeature<"prfchw", "HasPRFCHW", "true",
128 "Support PRFCHW instructions">;
129 def FeatureRDSEED : SubtargetFeature<"rdseed", "HasRDSEED", "true",
130 "Support RDSEED instruction">;
131 def FeatureLeaForSP : SubtargetFeature<"lea-sp", "UseLeaForSP", "true",
132 "Use LEA for adjusting the stack pointer">;
133 def FeatureSlowDivide : SubtargetFeature<"idiv-to-divb",
134 "HasSlowDivide", "true",
135 "Use small divide for positive values less than 256">;
136 def FeaturePadShortFunctions : SubtargetFeature<"pad-short-functions",
137 "PadShortFunctions", "true",
138 "Pad short functions">;
139 def FeatureCallRegIndirect : SubtargetFeature<"call-reg-indirect",
140 "CallRegIndirect", "true",
141 "Call register indirect">;
143 //===----------------------------------------------------------------------===//
144 // X86 processors supported.
145 //===----------------------------------------------------------------------===//
147 include "X86Schedule.td"
149 def ProcIntelAtom : SubtargetFeature<"atom", "X86ProcFamily", "IntelAtom",
150 "Intel Atom processors">;
152 class Proc<string Name, list<SubtargetFeature> Features>
153 : ProcessorModel<Name, GenericModel, Features>;
155 def : Proc<"generic", []>;
156 def : Proc<"i386", []>;
157 def : Proc<"i486", []>;
158 def : Proc<"i586", []>;
159 def : Proc<"pentium", []>;
160 def : Proc<"pentium-mmx", [FeatureMMX]>;
161 def : Proc<"i686", []>;
162 def : Proc<"pentiumpro", [FeatureCMOV]>;
163 def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
164 def : Proc<"pentium3", [FeatureSSE1]>;
165 def : Proc<"pentium3m", [FeatureSSE1, FeatureSlowBTMem]>;
166 def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
167 def : Proc<"pentium4", [FeatureSSE2]>;
168 def : Proc<"pentium4m", [FeatureSSE2, FeatureSlowBTMem]>;
169 def : Proc<"x86-64", [FeatureSSE2, Feature64Bit, FeatureSlowBTMem,
172 def : ProcessorModel<"yonah", SandyBridgeModel,
173 [FeatureSSE3, FeatureSlowBTMem]>;
176 def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
177 def : Proc<"nocona", [FeatureSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
179 // Intel Core 2 Solo/Duo.
180 def : ProcessorModel<"core2", SandyBridgeModel,
181 [FeatureSSSE3, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
182 def : ProcessorModel<"penryn", SandyBridgeModel,
183 [FeatureSSE41, FeatureCMPXCHG16B, FeatureSlowBTMem]>;
186 def : ProcessorModel<"atom", AtomModel,
187 [ProcIntelAtom, FeatureSSSE3, FeatureCMPXCHG16B,
188 FeatureMOVBE, FeatureSlowBTMem, FeatureLeaForSP,
190 FeatureCallRegIndirect,
191 FeaturePadShortFunctions]>;
193 // "Arrandale" along with corei3 and corei5
194 def : ProcessorModel<"corei7", SandyBridgeModel,
195 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
196 FeatureFastUAMem, FeaturePOPCNT, FeatureAES]>;
198 def : ProcessorModel<"nehalem", SandyBridgeModel,
199 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
200 FeatureFastUAMem, FeaturePOPCNT]>;
201 // Westmere is a similar machine to nehalem with some additional features.
202 // Westmere is the corei3/i5/i7 path from nehalem to sandybridge
203 def : ProcessorModel<"westmere", SandyBridgeModel,
204 [FeatureSSE42, FeatureCMPXCHG16B, FeatureSlowBTMem,
205 FeatureFastUAMem, FeaturePOPCNT, FeatureAES,
208 // SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
209 // rather than a superset.
210 def : ProcessorModel<"corei7-avx", SandyBridgeModel,
211 [FeatureAVX, FeatureCMPXCHG16B, FeatureFastUAMem,
212 FeaturePOPCNT, FeatureAES, FeaturePCLMUL]>;
214 def : ProcessorModel<"core-avx-i", SandyBridgeModel,
215 [FeatureAVX, FeatureCMPXCHG16B, FeatureFastUAMem,
216 FeaturePOPCNT, FeatureAES, FeaturePCLMUL, FeatureRDRAND,
217 FeatureF16C, FeatureFSGSBase]>;
220 def : ProcessorModel<"core-avx2", HaswellModel,
221 [FeatureAVX2, FeatureCMPXCHG16B, FeatureFastUAMem,
222 FeaturePOPCNT, FeatureAES, FeaturePCLMUL, FeatureRDRAND,
223 FeatureF16C, FeatureFSGSBase, FeatureMOVBE, FeatureLZCNT,
224 FeatureBMI, FeatureBMI2, FeatureFMA, FeatureRTM,
227 def : Proc<"k6", [FeatureMMX]>;
228 def : Proc<"k6-2", [Feature3DNow]>;
229 def : Proc<"k6-3", [Feature3DNow]>;
230 def : Proc<"athlon", [Feature3DNowA, FeatureSlowBTMem]>;
231 def : Proc<"athlon-tbird", [Feature3DNowA, FeatureSlowBTMem]>;
232 def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
233 def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
234 def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
235 def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
237 def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
239 def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
241 def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
243 def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
245 def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
247 def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, FeatureCMPXCHG16B,
249 def : Proc<"amdfam10", [FeatureSSE4A,
250 Feature3DNowA, FeatureCMPXCHG16B, FeatureLZCNT,
251 FeaturePOPCNT, FeatureSlowBTMem]>;
253 def : Proc<"btver1", [FeatureSSSE3, FeatureSSE4A, FeatureCMPXCHG16B,
254 FeatureLZCNT, FeaturePOPCNT]>;
256 def : Proc<"bdver1", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
257 FeatureAES, FeaturePCLMUL,
258 FeatureLZCNT, FeaturePOPCNT]>;
259 // Enhanced Bulldozer
260 def : Proc<"bdver2", [FeatureXOP, FeatureFMA4, FeatureCMPXCHG16B,
261 FeatureAES, FeaturePCLMUL,
262 FeatureF16C, FeatureLZCNT,
263 FeaturePOPCNT, FeatureBMI, FeatureFMA]>;
264 def : Proc<"geode", [Feature3DNowA]>;
266 def : Proc<"winchip-c6", [FeatureMMX]>;
267 def : Proc<"winchip2", [Feature3DNow]>;
268 def : Proc<"c3", [Feature3DNow]>;
269 def : Proc<"c3-2", [FeatureSSE1]>;
271 //===----------------------------------------------------------------------===//
272 // Register File Description
273 //===----------------------------------------------------------------------===//
275 include "X86RegisterInfo.td"
277 //===----------------------------------------------------------------------===//
278 // Instruction Descriptions
279 //===----------------------------------------------------------------------===//
281 include "X86InstrInfo.td"
283 def X86InstrInfo : InstrInfo;
285 //===----------------------------------------------------------------------===//
286 // Calling Conventions
287 //===----------------------------------------------------------------------===//
289 include "X86CallingConv.td"
292 //===----------------------------------------------------------------------===//
294 //===----------------------------------------------------------------------===//
296 def ATTAsmParser : AsmParser {
297 string AsmParserClassName = "AsmParser";
300 def ATTAsmParserVariant : AsmParserVariant {
303 // Discard comments in assembly strings.
304 string CommentDelimiter = "#";
306 // Recognize hard coded registers.
307 string RegisterPrefix = "%";
310 def IntelAsmParserVariant : AsmParserVariant {
313 // Discard comments in assembly strings.
314 string CommentDelimiter = ";";
316 // Recognize hard coded registers.
317 string RegisterPrefix = "";
320 //===----------------------------------------------------------------------===//
322 //===----------------------------------------------------------------------===//
324 // The X86 target supports two different syntaxes for emitting machine code.
325 // This is controlled by the -x86-asm-syntax={att|intel}
326 def ATTAsmWriter : AsmWriter {
327 string AsmWriterClassName = "ATTInstPrinter";
329 bit isMCAsmWriter = 1;
331 def IntelAsmWriter : AsmWriter {
332 string AsmWriterClassName = "IntelInstPrinter";
334 bit isMCAsmWriter = 1;
338 // Information about the instructions...
339 let InstructionSet = X86InstrInfo;
340 let AssemblyParsers = [ATTAsmParser];
341 let AssemblyParserVariants = [ATTAsmParserVariant, IntelAsmParserVariant];
342 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];