blob: a53f973c1c4311f0083cbd4fbaeed87fb69d6cea [file] [log] [blame]
Arnold Schwaighofer1f0da1f2007-10-12 21:30:57 +00001//===- X86.td - Target definition file for the Intel X86 ---*- tablegen -*-===//
John Criswell29265fe2003-10-21 15:17:13 +00002//
3// 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.
John Criswell29265fe2003-10-21 15:17:13 +00007//
8//===----------------------------------------------------------------------===//
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
David Greene206351a2010-01-11 16:29:42 +000026
Bill Wendlinge6182262007-05-04 20:38:40 +000027def FeatureMMX : SubtargetFeature<"mmx","X86SSELevel", "MMX",
28 "Enable MMX instructions">;
29def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1",
30 "Enable SSE instructions",
Chris Lattnercc8c5812009-09-02 05:53:04 +000031 // SSE codegen depends on cmovs, and all
32 // SSE1+ processors support them.
33 [FeatureMMX, FeatureCMOV]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000034def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2",
35 "Enable SSE2 instructions",
36 [FeatureSSE1]>;
37def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3",
38 "Enable SSE3 instructions",
39 [FeatureSSE2]>;
40def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3",
41 "Enable SSSE3 instructions",
42 [FeatureSSE3]>;
Nate Begemane14fdfa2008-02-03 07:18:54 +000043def FeatureSSE41 : SubtargetFeature<"sse41", "X86SSELevel", "SSE41",
44 "Enable SSE 4.1 instructions",
45 [FeatureSSSE3]>;
46def FeatureSSE42 : SubtargetFeature<"sse42", "X86SSELevel", "SSE42",
47 "Enable SSE 4.2 instructions",
48 [FeatureSSE41]>;
Bill Wendlinge6182262007-05-04 20:38:40 +000049def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow",
50 "Enable 3DNow! instructions">;
51def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA",
Bill Wendlingf985c492007-05-06 07:56:19 +000052 "Enable 3DNow! Athlon instructions",
53 [Feature3DNow]>;
Dan Gohman74037512009-02-03 00:04:43 +000054// All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied
55// feature, because SSE2 can be disabled (e.g. for compiling OS kernels)
56// without disabling 64-bit mode.
Bill Wendlingf985c492007-05-06 07:56:19 +000057def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true",
Chris Lattner77f7dba2010-03-14 22:24:34 +000058 "Support 64-bit instructions",
59 [FeatureCMOV]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +000060def FeatureSlowBTMem : SubtargetFeature<"slow-bt-mem", "IsBTMemSlow", "true",
61 "Bit testing of memory is slow">;
Evan Cheng738b0f92010-04-01 05:58:17 +000062def FeatureFastUAMem : SubtargetFeature<"fast-unaligned-mem",
63 "IsUAMemFast", "true",
64 "Fast unaligned memory access">;
Stefanus Du Toit96180b52009-05-26 21:04:35 +000065def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true",
66 "Support SSE 4a instructions">;
Evan Chengff1beda2006-10-06 09:17:41 +000067
David Greene8f6f72c2009-06-26 22:46:54 +000068def FeatureAVX : SubtargetFeature<"avx", "HasAVX", "true",
69 "Enable AVX instructions">;
70def FeatureFMA3 : SubtargetFeature<"fma3", "HasFMA3", "true",
Sean Callanan04d8cb72009-12-18 00:01:26 +000071 "Enable three-operand fused multiple-add">;
David Greene8f6f72c2009-06-26 22:46:54 +000072def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true",
73 "Enable four-operand fused multiple-add">;
David Greene206351a2010-01-11 16:29:42 +000074def FeatureVectorUAMem : SubtargetFeature<"vector-unaligned-mem",
75 "HasVectorUAMem", "true",
76 "Allow unaligned memory operands on vector/SIMD instructions">;
Eric Christopher2ef63182010-04-02 21:54:27 +000077def FeatureAES : SubtargetFeature<"aes", "HasAES", "true",
78 "Enable AES instructions">;
David Greene8f6f72c2009-06-26 22:46:54 +000079
Evan Chengff1beda2006-10-06 09:17:41 +000080//===----------------------------------------------------------------------===//
81// X86 processors supported.
82//===----------------------------------------------------------------------===//
83
84class Proc<string Name, list<SubtargetFeature> Features>
85 : Processor<Name, NoItineraries, Features>;
86
87def : Proc<"generic", []>;
88def : Proc<"i386", []>;
89def : Proc<"i486", []>;
Dale Johannesen28106752008-10-14 22:06:33 +000090def : Proc<"i586", []>;
Evan Chengff1beda2006-10-06 09:17:41 +000091def : Proc<"pentium", []>;
92def : Proc<"pentium-mmx", [FeatureMMX]>;
93def : Proc<"i686", []>;
Chris Lattnercc8c5812009-09-02 05:53:04 +000094def : Proc<"pentiumpro", [FeatureCMOV]>;
95def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +000096def : Proc<"pentium3", [FeatureSSE1]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +000097def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +000098def : Proc<"pentium4", [FeatureSSE2]>;
Evan Cheng71d7eaa2009-12-22 17:47:23 +000099def : Proc<"x86-64", [FeatureSSE2, Feature64Bit, FeatureSlowBTMem]>;
100def : Proc<"yonah", [FeatureSSE3, FeatureSlowBTMem]>;
101def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>;
102def : Proc<"nocona", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>;
103def : Proc<"core2", [FeatureSSSE3, Feature64Bit, FeatureSlowBTMem]>;
104def : Proc<"penryn", [FeatureSSE41, Feature64Bit, FeatureSlowBTMem]>;
105def : Proc<"atom", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>;
Eric Christopher2ef63182010-04-02 21:54:27 +0000106// "Arrandale" along with corei3 and corei5
Evan Cheng738b0f92010-04-01 05:58:17 +0000107def : Proc<"corei7", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem,
Eric Christopher2ef63182010-04-02 21:54:27 +0000108 FeatureFastUAMem, FeatureAES]>;
Evan Cheng738b0f92010-04-01 05:58:17 +0000109def : Proc<"nehalem", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem,
110 FeatureFastUAMem]>;
Eric Christopher2ef63182010-04-02 21:54:27 +0000111// Westmere is a similar machine to nehalem with some additional features.
112// Westmere is the corei3/i5/i7 path from nehalem to sandybridge
113def : Proc<"westmere", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem,
114 FeatureFastUAMem, FeatureAES]>;
David Greene8f6f72c2009-06-26 22:46:54 +0000115// Sandy Bridge does not have FMA
Eric Christopher2ef63182010-04-02 21:54:27 +0000116// FIXME: Wikipedia says it does... it should have AES as well.
Evan Cheng71d7eaa2009-12-22 17:47:23 +0000117def : Proc<"sandybridge", [FeatureSSE42, FeatureAVX, Feature64Bit]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000118
119def : Proc<"k6", [FeatureMMX]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000120def : Proc<"k6-2", [FeatureMMX, Feature3DNow]>;
121def : Proc<"k6-3", [FeatureMMX, Feature3DNow]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +0000122def : Proc<"athlon", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>;
123def : Proc<"athlon-tbird", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>;
124def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
125def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
126def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
Dan Gohman74037512009-02-03 00:04:43 +0000127def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
128 FeatureSlowBTMem]>;
129def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
130 FeatureSlowBTMem]>;
131def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
132 FeatureSlowBTMem]>;
133def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
134 FeatureSlowBTMem]>;
Stefanus Du Toit96180b52009-05-26 21:04:35 +0000135def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
136 FeatureSlowBTMem]>;
137def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
138 FeatureSlowBTMem]>;
139def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
140 FeatureSlowBTMem]>;
141def : Proc<"amdfam10", [FeatureSSE3, FeatureSSE4A,
142 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
143def : Proc<"barcelona", [FeatureSSE3, FeatureSSE4A,
144 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
David Greene46b56ff2009-06-29 16:54:06 +0000145def : Proc<"istanbul", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
146 Feature3DNowA]>;
147def : Proc<"shanghai", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
148 Feature3DNowA]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000149
150def : Proc<"winchip-c6", [FeatureMMX]>;
151def : Proc<"winchip2", [FeatureMMX, Feature3DNow]>;
152def : Proc<"c3", [FeatureMMX, Feature3DNow]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000153def : Proc<"c3-2", [FeatureSSE1]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000154
155//===----------------------------------------------------------------------===//
Chris Lattner5da8e802003-08-03 15:47:49 +0000156// Register File Description
157//===----------------------------------------------------------------------===//
158
159include "X86RegisterInfo.td"
160
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000161//===----------------------------------------------------------------------===//
162// Instruction Descriptions
163//===----------------------------------------------------------------------===//
164
Chris Lattner59a4a912003-08-03 21:54:21 +0000165include "X86InstrInfo.td"
166
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000167def X86InstrInfo : InstrInfo;
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000168
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000169//===----------------------------------------------------------------------===//
170// Calling Conventions
171//===----------------------------------------------------------------------===//
172
173include "X86CallingConv.td"
174
175
176//===----------------------------------------------------------------------===//
177// Assembly Printers
178//===----------------------------------------------------------------------===//
179
Daniel Dunbar00331992009-07-29 00:02:19 +0000180// Currently the X86 assembly parser only supports ATT syntax.
181def ATTAsmParser : AsmParser {
Daniel Dunbar9b816a12010-05-04 16:12:42 +0000182 string AsmParserClassName = "ATTAsmParser";
183 string AsmParserInstCleanup = "InstructionCleanup";
184 string MatchInstructionName = "MatchInstructionImpl";
Daniel Dunbar00331992009-07-29 00:02:19 +0000185 int Variant = 0;
Daniel Dunbare4318712009-08-11 20:59:47 +0000186
187 // Discard comments in assembly strings.
188 string CommentDelimiter = "#";
189
190 // Recognize hard coded registers.
191 string RegisterPrefix = "%";
Daniel Dunbar00331992009-07-29 00:02:19 +0000192}
193
Chris Lattner56832602004-10-03 20:36:57 +0000194// The X86 target supports two different syntaxes for emitting machine code.
195// This is controlled by the -x86-asm-syntax={att|intel}
196def ATTAsmWriter : AsmWriter {
Chris Lattner1cbd3de2009-09-13 19:30:11 +0000197 string AsmWriterClassName = "ATTInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000198 int Variant = 0;
199}
200def IntelAsmWriter : AsmWriter {
Chris Lattner13306a12009-09-20 07:47:59 +0000201 string AsmWriterClassName = "IntelInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000202 int Variant = 1;
203}
204
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000205def X86 : Target {
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000206 // Information about the instructions...
Chris Lattner25510802003-08-04 04:59:56 +0000207 let InstructionSet = X86InstrInfo;
Chris Lattner56832602004-10-03 20:36:57 +0000208
Daniel Dunbar00331992009-07-29 00:02:19 +0000209 let AssemblyParsers = [ATTAsmParser];
210
Chris Lattner56832602004-10-03 20:36:57 +0000211 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000212}