blob: 77d3d56fba2ed08f5982b497b65ad74ec5a446ad [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
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
35 // SSE1+ processors support them.
36 [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.
123def : Proc<"sandybridge", [FeatureAVX, FeatureAES, FeatureCLMUL, Feature64Bit]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000124
125def : Proc<"k6", [FeatureMMX]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000126def : Proc<"k6-2", [FeatureMMX, Feature3DNow]>;
127def : Proc<"k6-3", [FeatureMMX, Feature3DNow]>;
Evan Cheng4c91aa32009-01-02 05:35:45 +0000128def : Proc<"athlon", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>;
129def : Proc<"athlon-tbird", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>;
130def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
131def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
132def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>;
Dan Gohman74037512009-02-03 00:04:43 +0000133def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit,
134 FeatureSlowBTMem]>;
135def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit,
136 FeatureSlowBTMem]>;
137def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit,
138 FeatureSlowBTMem]>;
139def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit,
140 FeatureSlowBTMem]>;
Stefanus Du Toit96180b52009-05-26 21:04:35 +0000141def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
142 FeatureSlowBTMem]>;
143def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
144 FeatureSlowBTMem]>;
145def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit,
146 FeatureSlowBTMem]>;
147def : Proc<"amdfam10", [FeatureSSE3, FeatureSSE4A,
148 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
149def : Proc<"barcelona", [FeatureSSE3, FeatureSSE4A,
150 Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>;
David Greene46b56ff2009-06-29 16:54:06 +0000151def : Proc<"istanbul", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
152 Feature3DNowA]>;
153def : Proc<"shanghai", [Feature3DNowA, Feature64Bit, FeatureSSE4A,
154 Feature3DNowA]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000155
156def : Proc<"winchip-c6", [FeatureMMX]>;
157def : Proc<"winchip2", [FeatureMMX, Feature3DNow]>;
158def : Proc<"c3", [FeatureMMX, Feature3DNow]>;
Bill Wendling3fb7fdf2007-05-22 05:15:37 +0000159def : Proc<"c3-2", [FeatureSSE1]>;
Evan Chengff1beda2006-10-06 09:17:41 +0000160
161//===----------------------------------------------------------------------===//
Chris Lattner5da8e802003-08-03 15:47:49 +0000162// Register File Description
163//===----------------------------------------------------------------------===//
164
165include "X86RegisterInfo.td"
166
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000167//===----------------------------------------------------------------------===//
168// Instruction Descriptions
169//===----------------------------------------------------------------------===//
170
Chris Lattner59a4a912003-08-03 21:54:21 +0000171include "X86InstrInfo.td"
172
Jakob Stoklund Olesenb93331f2010-04-05 03:10:20 +0000173def X86InstrInfo : InstrInfo;
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000174
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000175//===----------------------------------------------------------------------===//
176// Calling Conventions
177//===----------------------------------------------------------------------===//
178
179include "X86CallingConv.td"
180
181
182//===----------------------------------------------------------------------===//
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000183// Assembly Parser
Chris Lattner5d00a0b2007-02-26 18:17:14 +0000184//===----------------------------------------------------------------------===//
185
Daniel Dunbar00331992009-07-29 00:02:19 +0000186// Currently the X86 assembly parser only supports ATT syntax.
187def ATTAsmParser : AsmParser {
Daniel Dunbar9b816a12010-05-04 16:12:42 +0000188 string AsmParserClassName = "ATTAsmParser";
Daniel Dunbar00331992009-07-29 00:02:19 +0000189 int Variant = 0;
Daniel Dunbare4318712009-08-11 20:59:47 +0000190
191 // Discard comments in assembly strings.
192 string CommentDelimiter = "#";
193
194 // Recognize hard coded registers.
195 string RegisterPrefix = "%";
Daniel Dunbar00331992009-07-29 00:02:19 +0000196}
197
Jim Grosbach4cf25f52010-10-30 13:48:28 +0000198//===----------------------------------------------------------------------===//
199// Assembly Printers
200//===----------------------------------------------------------------------===//
201
Chris Lattner56832602004-10-03 20:36:57 +0000202// The X86 target supports two different syntaxes for emitting machine code.
203// This is controlled by the -x86-asm-syntax={att|intel}
204def ATTAsmWriter : AsmWriter {
Chris Lattner1cbd3de2009-09-13 19:30:11 +0000205 string AsmWriterClassName = "ATTInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000206 int Variant = 0;
Jim Grosbachc6e13f72010-09-30 23:40:25 +0000207 bit isMCAsmWriter = 1;
Chris Lattner56832602004-10-03 20:36:57 +0000208}
209def IntelAsmWriter : AsmWriter {
Chris Lattner13306a12009-09-20 07:47:59 +0000210 string AsmWriterClassName = "IntelInstPrinter";
Chris Lattner56832602004-10-03 20:36:57 +0000211 int Variant = 1;
Jim Grosbachc6e13f72010-09-30 23:40:25 +0000212 bit isMCAsmWriter = 1;
Chris Lattner56832602004-10-03 20:36:57 +0000213}
214
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000215def X86 : Target {
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000216 // Information about the instructions...
Chris Lattner25510802003-08-04 04:59:56 +0000217 let InstructionSet = X86InstrInfo;
Chris Lattner56832602004-10-03 20:36:57 +0000218
Daniel Dunbar00331992009-07-29 00:02:19 +0000219 let AssemblyParsers = [ATTAsmParser];
220
Chris Lattner56832602004-10-03 20:36:57 +0000221 let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter];
Chris Lattnera8c3cff2003-08-03 18:19:37 +0000222}