Make FMA3 imply AVX needs to be enabled. Particularly because 256-bit types aren...
[oota-llvm.git] / lib / Target / X86 / X86.td
1 //===- X86.td - Target definition file for the Intel X86 ---*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This is a target description file for the Intel i386 architecture, referred
11 // to here as the "X86" architecture.
12 //
13 //===----------------------------------------------------------------------===//
14
15 // Get the target-independent interfaces which we are implementing...
16 //
17 include "llvm/Target/Target.td"
18
19 //===----------------------------------------------------------------------===//
20 // X86 Subtarget state.
21 //
22
23 def Mode64Bit : SubtargetFeature<"64bit-mode", "In64BitMode", "true",
24                                   "64-bit mode (x86_64)">;
25
26 //===----------------------------------------------------------------------===//
27 // X86 Subtarget features.
28 //===----------------------------------------------------------------------===//
29
30 def FeatureCMOV    : SubtargetFeature<"cmov","HasCMov", "true",
31                                       "Enable conditional move instructions">;
32
33 def FeaturePOPCNT   : SubtargetFeature<"popcnt", "HasPOPCNT", "true",
34                                        "Support POPCNT instruction">;
35
36
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",
46                                       [FeatureSSE1]>;
47 def FeatureSSE3    : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
48                                       "Enable SSE3 instructions",
49                                       [FeatureSSE2]>;
50 def FeatureSSSE3   : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
51                                       "Enable SSSE3 instructions",
52                                       [FeatureSSE3]>;
53 def FeatureSSE41   : SubtargetFeature<"sse41", "X86SSELevel", "SSE41",
54                                       "Enable SSE 4.1 instructions",
55                                       [FeatureSSSE3]>;
56 def FeatureSSE42   : SubtargetFeature<"sse42", "X86SSELevel", "SSE42",
57                                       "Enable SSE 4.2 instructions",
58                                       [FeatureSSE41]>;
59 def Feature3DNow   : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
60                                       "Enable 3DNow! instructions",
61                                       [FeatureMMX]>;
62 def Feature3DNowA  : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
63                                       "Enable 3DNow! Athlon instructions",
64                                       [Feature3DNow]>;
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",
70                                       [FeatureCMOV]>;
71 def FeatureCMPXCHG16B : SubtargetFeature<"cmpxchg16b", "HasCmpxchg16b", "true",
72                                       "64-bit with cmpxchg16b",
73                                       [Feature64Bit]>;
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">;
81
82 def FeatureAVX     : SubtargetFeature<"avx", "HasAVX", "true",
83                                       "Enable AVX instructions">;
84 def FeatureAVX2    : SubtargetFeature<"avx2", "HasAVX2", "true",
85                                       "Enable AVX2 instructions",
86                                       [FeatureAVX]>;
87 def FeatureCLMUL   : SubtargetFeature<"clmul", "HasCLMUL", "true",
88                                "Enable carry-less multiplication instructions">;
89 def FeatureFMA3    : SubtargetFeature<"fma3", "HasFMA3", "true",
90                                       "Enable three-operand fused multiple-add",
91                                       [FeatureAVX]>;
92 def FeatureFMA4    : SubtargetFeature<"fma4", "HasFMA4", "true",
93                                       "Enable four-operand fused multiple-add">;
94 def FeatureXOP    : SubtargetFeature<"xop", "HasXOP", "true",
95                                       "Enable XOP instructions">;
96 def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem",
97                                           "HasVectorUAMem", "true",
98                  "Allow unaligned memory operands on vector/SIMD instructions">;
99 def FeatureAES     : SubtargetFeature<"aes", "HasAES", "true",
100                                       "Enable AES instructions">;
101 def FeatureMOVBE   : SubtargetFeature<"movbe", "HasMOVBE", "true",
102                                       "Support MOVBE instruction">;
103 def FeatureRDRAND  : SubtargetFeature<"rdrand", "HasRDRAND", "true",
104                                       "Support RDRAND instruction">;
105 def FeatureF16C    : SubtargetFeature<"f16c", "HasF16C", "true",
106                        "Support 16-bit floating point conversion instructions">;
107 def FeatureFSGSBase : SubtargetFeature<"fsgsbase", "HasFSGSBase", "true",
108                                        "Support FS/GS Base instructions">;
109 def FeatureLZCNT   : SubtargetFeature<"lzcnt", "HasLZCNT", "true",
110                                       "Support LZCNT instruction">;
111 def FeatureBMI     : SubtargetFeature<"bmi", "HasBMI", "true",
112                                       "Support BMI instructions">;
113 def FeatureBMI2    : SubtargetFeature<"bmi2", "HasBMI2", "true",
114                                       "Support BMI2 instructions">;
115
116 //===----------------------------------------------------------------------===//
117 // X86 processors supported.
118 //===----------------------------------------------------------------------===//
119
120 class Proc<string Name, list<SubtargetFeature> Features>
121  : Processor<Name, NoItineraries, Features>;
122
123 def : Proc<"generic",         []>;
124 def : Proc<"i386",            []>;
125 def : Proc<"i486",            []>;
126 def : Proc<"i586",            []>;
127 def : Proc<"pentium",         []>;
128 def : Proc<"pentium-mmx",     [FeatureMMX]>;
129 def : Proc<"i686",            []>;
130 def : Proc<"pentiumpro",      [FeatureCMOV]>;
131 def : Proc<"pentium2",        [FeatureMMX, FeatureCMOV]>;
132 def : Proc<"pentium3",        [FeatureSSE1]>;
133 def : Proc<"pentium3m",       [FeatureSSE1, FeatureSlowBTMem]>;
134 def : Proc<"pentium-m",       [FeatureSSE2, FeatureSlowBTMem]>;
135 def : Proc<"pentium4",        [FeatureSSE2]>;
136 def : Proc<"pentium4m",       [FeatureSSE2, FeatureSlowBTMem]>;
137 def : Proc<"x86-64",          [FeatureSSE2, Feature64Bit, FeatureSlowBTMem]>;
138 def : Proc<"yonah",           [FeatureSSE3, FeatureSlowBTMem]>;
139 def : Proc<"prescott",        [FeatureSSE3, FeatureSlowBTMem]>;
140 def : Proc<"nocona",          [FeatureSSE3, FeatureCMPXCHG16B,
141                                FeatureSlowBTMem]>;
142 def : Proc<"core2",           [FeatureSSSE3, FeatureCMPXCHG16B,
143                                FeatureSlowBTMem]>;
144 def : Proc<"penryn",          [FeatureSSE41, FeatureCMPXCHG16B,
145                                FeatureSlowBTMem]>;
146 def : Proc<"atom",            [FeatureSSE3, FeatureCMPXCHG16B, FeatureMOVBE,
147                                FeatureSlowBTMem]>;
148 // "Arrandale" along with corei3 and corei5
149 def : Proc<"corei7",          [FeatureSSE42, FeatureCMPXCHG16B,
150                                FeatureSlowBTMem, FeatureFastUAMem,
151                                FeaturePOPCNT, FeatureAES]>;
152 def : Proc<"nehalem",         [FeatureSSE42,  FeatureCMPXCHG16B,
153                                FeatureSlowBTMem, FeatureFastUAMem,
154                                FeaturePOPCNT]>;
155 // Westmere is a similar machine to nehalem with some additional features.
156 // Westmere is the corei3/i5/i7 path from nehalem to sandybridge
157 def : Proc<"westmere",        [FeatureSSE42, FeatureCMPXCHG16B,
158                                FeatureSlowBTMem, FeatureFastUAMem,
159                                FeaturePOPCNT, FeatureAES, FeatureCLMUL]>;
160 // Sandy Bridge
161 // SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
162 // rather than a superset.
163 // FIXME: Disabling AVX for now since it's not ready.
164 def : Proc<"corei7-avx",      [FeatureSSE42, FeatureCMPXCHG16B, FeaturePOPCNT,
165                                FeatureAES, FeatureCLMUL]>;
166 // Ivy Bridge
167 def : Proc<"core-avx-i",      [FeatureSSE42, FeatureCMPXCHG16B, FeaturePOPCNT,
168                                FeatureAES, FeatureCLMUL,
169                                FeatureRDRAND, FeatureF16C, FeatureFSGSBase]>;
170
171 // Haswell
172 // FIXME: Disabling AVX/AVX2/FMA3 for now since it's not ready.
173 def : Proc<"core-avx2",       [FeatureSSE42, FeatureCMPXCHG16B, FeaturePOPCNT,
174                                FeatureAES, FeatureCLMUL, FeatureRDRAND,
175                                FeatureF16C, FeatureFSGSBase,
176                                FeatureMOVBE, FeatureLZCNT, FeatureBMI,
177                                FeatureBMI2]>;
178
179 def : Proc<"k6",              [FeatureMMX]>;
180 def : Proc<"k6-2",            [Feature3DNow]>;
181 def : Proc<"k6-3",            [Feature3DNow]>;
182 def : Proc<"athlon",          [Feature3DNowA, FeatureSlowBTMem]>;
183 def : Proc<"athlon-tbird",    [Feature3DNowA, FeatureSlowBTMem]>;
184 def : Proc<"athlon-4",        [FeatureSSE1,   Feature3DNowA, FeatureSlowBTMem]>;
185 def : Proc<"athlon-xp",       [FeatureSSE1,   Feature3DNowA, FeatureSlowBTMem]>;
186 def : Proc<"athlon-mp",       [FeatureSSE1,   Feature3DNowA, FeatureSlowBTMem]>;
187 def : Proc<"k8",              [FeatureSSE2,   Feature3DNowA, Feature64Bit,
188                                FeatureSlowBTMem]>;
189 def : Proc<"opteron",         [FeatureSSE2,   Feature3DNowA, Feature64Bit,
190                                FeatureSlowBTMem]>;
191 def : Proc<"athlon64",        [FeatureSSE2,   Feature3DNowA, Feature64Bit,
192                                FeatureSlowBTMem]>;
193 def : Proc<"athlon-fx",       [FeatureSSE2,   Feature3DNowA, Feature64Bit,
194                                FeatureSlowBTMem]>;
195 def : Proc<"k8-sse3",         [FeatureSSE3,   Feature3DNowA, FeatureCMPXCHG16B,
196                                FeatureSlowBTMem]>;
197 def : Proc<"opteron-sse3",    [FeatureSSE3,   Feature3DNowA, FeatureCMPXCHG16B,
198                                FeatureSlowBTMem]>;
199 def : Proc<"athlon64-sse3",   [FeatureSSE3,   Feature3DNowA, FeatureCMPXCHG16B,
200                                FeatureSlowBTMem]>;
201 def : Proc<"amdfam10",        [FeatureSSE3,   FeatureSSE4A,
202                                Feature3DNowA, FeatureCMPXCHG16B, FeatureLZCNT,
203                                FeaturePOPCNT, FeatureSlowBTMem]>;
204 // FIXME: Disabling AVX for now since it's not ready.
205 def : Proc<"bdver1",          [FeatureSSE42, FeatureSSE4A, FeatureCMPXCHG16B,
206                                FeatureAES, FeatureCLMUL, FeatureFMA4,
207                                FeatureXOP, FeatureLZCNT, FeaturePOPCNT]>;
208 def : Proc<"bdver2",          [FeatureSSE42, FeatureSSE4A, FeatureCMPXCHG16B,
209                                FeatureAES, FeatureCLMUL, FeatureFMA4,
210                                FeatureXOP, FeatureF16C, FeatureLZCNT,
211                                FeaturePOPCNT, FeatureBMI]>;
212
213 def : Proc<"winchip-c6",      [FeatureMMX]>;
214 def : Proc<"winchip2",        [Feature3DNow]>;
215 def : Proc<"c3",              [Feature3DNow]>;
216 def : Proc<"c3-2",            [FeatureSSE1]>;
217
218 //===----------------------------------------------------------------------===//
219 // Register File Description
220 //===----------------------------------------------------------------------===//
221
222 include "X86RegisterInfo.td"
223
224 //===----------------------------------------------------------------------===//
225 // Instruction Descriptions
226 //===----------------------------------------------------------------------===//
227
228 include "X86InstrInfo.td"
229
230 def X86InstrInfo : InstrInfo;
231
232 //===----------------------------------------------------------------------===//
233 // Calling Conventions
234 //===----------------------------------------------------------------------===//
235
236 include "X86CallingConv.td"
237
238
239 //===----------------------------------------------------------------------===//
240 // Assembly Parser
241 //===----------------------------------------------------------------------===//
242
243 // Currently the X86 assembly parser only supports ATT syntax.
244 def ATTAsmParser : AsmParser {
245   string AsmParserClassName = "ATTAsmParser";
246   int Variant = 0;
247
248   // Discard comments in assembly strings.
249   string CommentDelimiter = "#";
250
251   // Recognize hard coded registers.
252   string RegisterPrefix = "%";
253 }
254
255 //===----------------------------------------------------------------------===//
256 // Assembly Printers
257 //===----------------------------------------------------------------------===//
258
259 // The X86 target supports two different syntaxes for emitting machine code.
260 // This is controlled by the -x86-asm-syntax={att|intel}
261 def ATTAsmWriter : AsmWriter {
262   string AsmWriterClassName  = "ATTInstPrinter";
263   int Variant = 0;
264   bit isMCAsmWriter = 1;
265 }
266 def IntelAsmWriter : AsmWriter {
267   string AsmWriterClassName  = "IntelInstPrinter";
268   int Variant = 1;
269   bit isMCAsmWriter = 1;
270 }
271
272 def X86 : Target {
273   // Information about the instructions...
274   let InstructionSet = X86InstrInfo;
275
276   let AssemblyParsers = [ATTAsmParser];
277
278   let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
279 }