blob: 00ff97ea4e865d2dd53322989621342d8c9f10b9 [file] [log] [blame]
Arnold Schwaighofer1f0da1f2007-10-12 21:30:57 +00001//===- X86.td - Target definition file for the Intel X86 ---*- tablegen -*-===//
Michael J. Spencerb88784c2011-04-14 14:33:36 +00002//
John Criswell29265fe2003-10-21 15:17:13 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Michael J. Spencerb88784c2011-04-14 14:33:36 +00007//
John Criswell29265fe2003-10-21 15:17:13 +00008//===----------------------------------------------------------------------===//
Chris Lattner5da8e802003-08-03 15:47:49 +00009//
10// This is a target description file for the Intel i386 architecture, refered to
11// here as the "X86" architecture.
12//
13//===----------------------------------------------------------------------===//
14
Chris Lattner25510802003-08-04 04:59:56 +000015// Get the target-independent interfaces which we are implementing...
Chris Lattner5da8e802003-08-03 15:47:49 +000016//
Evan Cheng977e7be2008-11-24 07:34:46 +000017include "llvm/Target/Target.td"
Chris Lattner5da8e802003-08-03 15:47:49 +000018
19//===----------------------------------------------------------------------===//
Evan Chengff1beda2006-10-06 09:17:41 +000020// X86 Subtarget features.
Bill Wendlinge6182262007-05-04 20:38:40 +000021//===----------------------------------------------------------------------===//
Chris Lattnercc8c5812009-09-02 05:53:04 +000022
23def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true",
24 "Enable conditional move instructions">;
25
Benjamin Kramer2f489232010-12-04 20:32:23 +000026def FeaturePOPCNT : SubtargetFeature<"popcnt", "HasPOPCNT", "true",
27 "Support POPCNT instruction">;
28
David Greene206351a2010-01-11 16:29:42 +000029
Bill Wendlinge6182262007-05-04 20:38:40 +000030def FeatureMMX : SubtargetFeature<"mmx","X86SSELevel", "MMX",
31 "Enable MMX instructions">;
32def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1",
33 "Enable SSE instructions",
Chris Lattnercc8c5812009-09-02 05:53:04 +000034 // SSE codegen depends on cmovs, and all
Michael J. Spencerb88784c2011-04-14 14:33:36 +000035 // SSE1+ processors support them.
Chris Lattnercc8c5812009-09-02 05:53:04 +000036 [FeatureMMX, FeatureCMOV]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000037def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2",
38 "Enable SSE2 instructions",
39 [FeatureSSE1]>;
40def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
41 "Enable SSE3 instructions",
42 [FeatureSSE2]>;
43def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
44 "Enable SSSE3 instructions",
45 [FeatureSSE3]>;
Nate Begemane14fdfa2008-02-03 07:18:54 +000046def FeatureSSE41 : SubtargetFeature<"sse41", "X86SSELevel", "SSE41",
47 "Enable SSE 4.1 instructions",
48 [FeatureSSSE3]>;
49def FeatureSSE42 : SubtargetFeature<"sse42", "X86SSELevel", "SSE42",
50 "Enable SSE 4.2 instructions",
Benjamin Kramer2f489232010-12-04 20:32:23 +000051 [FeatureSSE41, FeaturePOPCNT]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000052def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
53 "Enable 3DNow! instructions">;
54def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
Bill Wendlingf985c492007-05-06 07:56:19 +000055 "Enable 3DNow! Athlon instructions",
56 [Feature3DNow]>;
Dan Gohman74037512009-02-03 00:04:43 +000057// All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied
58// feature, because SSE2 can be disabled (e.g. for compiling OS kernels)
59// without disabling 64-bit mode.
Bill Wendlingf985c492007-05-06 07:56:19 +000060def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true",
Chris Lattner77f7dba2010-03-14 22:24:34 +000061 "Support 64-bit instructions",
62 [FeatureCMOV]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +000063def FeatureSlowBTMem : SubtargetFeature<"slow-bt-mem", "IsBTMemSlow", "true",
64 "Bit testing of memory is slow">;
Evan Cheng738b0f92010-04-01 05:58:17 +000065def FeatureFastUAMem : SubtargetFeature<"fast-unaligned-mem",
66 "IsUAMemFast", "true",
67 "Fast unaligned memory access">;
Stefanus Du Toit96180b52009-05-26 21:04:35 +000068def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
Benjamin Kramer2f489232010-12-04 20:32:23 +000069 "Support SSE 4a instructions",
70 [FeaturePOPCNT]>;
Evan Chengff1beda2006-10-06 09:17:41 +000071
David Greene8f6f72c2009-06-26 22:46:54 +000072def FeatureAVX : SubtargetFeature<"avx", "HasAVX", "true",
73 "Enable AVX instructions">;
Bruno Cardoso Lopesd618c8a2010-07-23 01:22:45 +000074def FeatureCLMUL : SubtargetFeature<"clmul", "HasCLMUL", "true",
75 "Enable carry-less multiplication instructions">;
David Greene8f6f72c2009-06-26 22:46:54 +000076def FeatureFMA3 : SubtargetFeature<"fma3", "HasFMA3", "true",
Sean Callanan04d8cb72009-12-18 00:01:26 +000077 "Enable three-operand fused multiple-add">;
David Greene8f6f72c2009-06-26 22:46:54 +000078def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
79 "Enable four-operand fused multiple-add">;
David Greene206351a2010-01-11 16:29:42 +000080def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem",
81 "HasVectorUAMem", "true",
82 "Allow unaligned memory operands on vector/SIMD instructions">;
Eric Christopher2ef63182010-04-02 21:54:27 +000083def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
84 "Enable AES instructions">;
David Greene8f6f72c2009-06-26 22:46:54 +000085
Evan Chengff1beda2006-10-06 09:17:41 +000086//===----------------------------------------------------------------------===//
87// X86 processors supported.
88//===----------------------------------------------------------------------===//
89
90class Proc<string Name, list<SubtargetFeature> Features>
91 : Processor<Name, NoItineraries, Features>;
92
93def : Proc<"generic", []>;
94def : Proc<"i386", []>;
95def : Proc<"i486", []>;
Dale Johannesen28106752008-10-14 22:06:33 +000096def : Proc<"i586", []>;
Evan Chengff1beda2006-10-06 09:17:41 +000097def : Proc<"pentium", []>;
98def : Proc<"pentium-mmx", [FeatureMMX]>;
99def : Proc<"i686", []>;
Chris Lattnercc8c5812009-09-02 05:53:04 +0000100def : Proc<"pentiumpro", [FeatureCMOV]>;
101def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000102def : Proc<"pentium3", [FeatureSSE1]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +0000103def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000104def : Proc<"pentium4", [FeatureSSE2]>;
Evan Cheng71d7eaa2009-12-22 17:47:23 +0000105def : Proc<"x86-64", [FeatureSSE2, Feature64Bit, FeatureSlowBTMem]>;
106def : Proc<"yonah", [FeatureSSE3, FeatureSlowBTMem]>;
107def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
108def : Proc<"nocona", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>;
109def : Proc<"core2", [FeatureSSSE3, Feature64Bit, FeatureSlowBTMem]>;
110def : Proc<"penryn", [FeatureSSE41, Feature64Bit, FeatureSlowBTMem]>;
111def : Proc<"atom", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>;
Eric Christopher2ef63182010-04-02 21:54:27 +0000112// "Arrandale" along with corei3 and corei5
Evan Cheng738b0f92010-04-01 05:58:17 +0000113def : Proc<"corei7", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem,
Eric Christopher2ef63182010-04-02 21:54:27 +0000114 FeatureFastUAMem, FeatureAES]>;
Evan Cheng738b0f92010-04-01 05:58:17 +0000115def : Proc<"nehalem", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem,
116 FeatureFastUAMem]>;
Eric Christopher2ef63182010-04-02 21:54:27 +0000117// Westmere is a similar machine to nehalem with some additional features.
118// Westmere is the corei3/i5/i7 path from nehalem to sandybridge
Nate Begeman8b08f522010-12-10 00:26:57 +0000119def : Proc<"westmere", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem,
120 FeatureFastUAMem, FeatureAES, FeatureCLMUL]>;
121// SSE is not listed here since llvm treats AVX as a reimplementation of SSE,
122// rather than a superset.
Evan Chengf8b4c002010-12-13 04:23:53 +0000123// FIXME: Disabling AVX for now since it's not ready.
124def : Proc<"sandybridge", [FeatureSSE42, Feature64Bit,
125 FeatureAES, FeatureCLMUL]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000126
127def : Proc<"k6", [FeatureMMX]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000128def : Proc<"k6-2", [FeatureMMX, Feature3DNow]>;
129def : Proc<"k6-3", [FeatureMMX, Feature3DNow]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +0000130def : Proc<"athlon", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>;
131def : Proc<"athlon-tbird", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>;
132def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
133def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
134def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
Dan Gohman74037512009-02-03 00:04:43 +0000135def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
136 FeatureSlowBTMem]>;
137def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
138 FeatureSlowBTMem]>;
139def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
140 FeatureSlowBTMem]>;
141def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
142 FeatureSlowBTMem]>;
Stefanus Du Toit96180b52009-05-26 21:04:35 +0000143def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
144 FeatureSlowBTMem]>;
145def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
146 FeatureSlowBTMem]>;
147def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
148 FeatureSlowBTMem]>;
149def : Proc<"amdfam10", [FeatureSSE3, FeatureSSE4A,
150 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
151def : Proc<"barcelona", [FeatureSSE3, FeatureSSE4A,
152 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
David Greene46b56ff2009-06-29 16:54:06 +0000153def : Proc<"istanbul", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
154 Feature3DNowA]>;
155def : Proc<"shanghai", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
156 Feature3DNowA]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000157
158def : Proc<"winchip-c6", [FeatureMMX]>;
159def : Proc<"winchip2", [FeatureMMX, Feature3DNow]>;
160def : Proc<"c3", [FeatureMMX, Feature3DNow]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000161def : Proc<"c3-2", [FeatureSSE1]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000162
163//===----------------------------------------------------------------------===//
Chris Lattner5da8e802003-08-03 15:47:49 +0000164// Register File Description
165//===----------------------------------------------------------------------===//
166
167include "X86RegisterInfo.td"
168
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000169//===----------------------------------------------------------------------===//
170// Instruction Descriptions
171//===----------------------------------------------------------------------===//
172
Chris Lattner59a4a912003-08-03 21:54:21 +0000173include "X86InstrInfo.td"
174
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000175def X86InstrInfo : InstrInfo;
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000176
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000177//===----------------------------------------------------------------------===//
178// Calling Conventions
179//===----------------------------------------------------------------------===//
180
181include "X86CallingConv.td"
182
183
184//===----------------------------------------------------------------------===//
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000185// Assembly Parser
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000186//===----------------------------------------------------------------------===//
187
Daniel Dunbar00331992009-07-29 00:02:19 +0000188// Currently the X86 assembly parser only supports ATT syntax.
189def ATTAsmParser : AsmParser {
Daniel Dunbar9b816a12010-05-04 16:12:42 +0000190 string AsmParserClassName = "ATTAsmParser";
Daniel Dunbar00331992009-07-29 00:02:19 +0000191 int Variant = 0;
Daniel Dunbare4318712009-08-11 20:59:47 +0000192
193 // Discard comments in assembly strings.
194 string CommentDelimiter = "#";
195
196 // Recognize hard coded registers.
197 string RegisterPrefix = "%";
Daniel Dunbar00331992009-07-29 00:02:19 +0000198}
199
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000200//===----------------------------------------------------------------------===//
201// Assembly Printers
202//===----------------------------------------------------------------------===//
203
Chris Lattner56832602004-10-03 20:36:57 +0000204// The X86 target supports two different syntaxes for emitting machine code.
205// This is controlled by the -x86-asm-syntax={att|intel}
206def ATTAsmWriter : AsmWriter {
Chris Lattner1cbd3de2009-09-13 19:30:11 +0000207 string AsmWriterClassName = "ATTInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000208 int Variant = 0;
Jim Grosbachc6e13f72010-09-30 23:40:25 +0000209 bit isMCAsmWriter = 1;
Chris Lattner56832602004-10-03 20:36:57 +0000210}
211def IntelAsmWriter : AsmWriter {
Chris Lattner13306a12009-09-20 07:47:59 +0000212 string AsmWriterClassName = "IntelInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000213 int Variant = 1;
Jim Grosbachc6e13f72010-09-30 23:40:25 +0000214 bit isMCAsmWriter = 1;
Chris Lattner56832602004-10-03 20:36:57 +0000215}
216
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000217def X86 : Target {
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000218 // Information about the instructions...
Chris Lattner25510802003-08-04 04:59:56 +0000219 let InstructionSet = X86InstrInfo;
Chris Lattner56832602004-10-03 20:36:57 +0000220
Daniel Dunbar00331992009-07-29 00:02:19 +0000221 let AssemblyParsers = [ATTAsmParser];
222
Chris Lattner56832602004-10-03 20:36:57 +0000223 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000224}