Arnold Schwaighofer | 48abc5c | 2007-10-12 21:30:57 +0000 | [diff] [blame] | 1 | //===- X86.td - Target definition file for the Intel X86 ---*- tablegen -*-===// |
John Criswell | 856ba76 | 2003-10-21 15:17:13 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
John Criswell | 856ba76 | 2003-10-21 15:17:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 762fb5f | 2003-08-03 15:47:49 +0000 | [diff] [blame] | 9 | // |
| 10 | // This is a target description file for the Intel i386 architecture, refered to |
| 11 | // here as the "X86" architecture. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Chris Lattner | c8f4587 | 2003-08-04 04:59:56 +0000 | [diff] [blame] | 15 | // Get the target-independent interfaces which we are implementing... |
Chris Lattner | 762fb5f | 2003-08-03 15:47:49 +0000 | [diff] [blame] | 16 | // |
Evan Cheng | 027fdbe | 2008-11-24 07:34:46 +0000 | [diff] [blame] | 17 | include "llvm/Target/Target.td" |
Chris Lattner | 762fb5f | 2003-08-03 15:47:49 +0000 | [diff] [blame] | 18 | |
| 19 | //===----------------------------------------------------------------------===// |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 20 | // X86 Subtarget features. |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 21 | //===----------------------------------------------------------------------===// |
Chris Lattner | 7008416 | 2009-09-02 05:53:04 +0000 | [diff] [blame] | 22 | |
| 23 | def FeatureCMOV : SubtargetFeature<"cmov","HasCMov", "true", |
| 24 | "Enable conditional move instructions">; |
| 25 | |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 26 | def FeatureMMX : SubtargetFeature<"mmx","X86SSELevel", "MMX", |
| 27 | "Enable MMX instructions">; |
| 28 | def FeatureSSE1 : SubtargetFeature<"sse", "X86SSELevel", "SSE1", |
| 29 | "Enable SSE instructions", |
Chris Lattner | 7008416 | 2009-09-02 05:53:04 +0000 | [diff] [blame] | 30 | // SSE codegen depends on cmovs, and all |
| 31 | // SSE1+ processors support them. |
| 32 | [FeatureMMX, FeatureCMOV]>; |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 33 | def FeatureSSE2 : SubtargetFeature<"sse2", "X86SSELevel", "SSE2", |
| 34 | "Enable SSE2 instructions", |
| 35 | [FeatureSSE1]>; |
| 36 | def FeatureSSE3 : SubtargetFeature<"sse3", "X86SSELevel", "SSE3", |
| 37 | "Enable SSE3 instructions", |
| 38 | [FeatureSSE2]>; |
| 39 | def FeatureSSSE3 : SubtargetFeature<"ssse3", "X86SSELevel", "SSSE3", |
| 40 | "Enable SSSE3 instructions", |
| 41 | [FeatureSSE3]>; |
Nate Begeman | 63ec90a | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 42 | def FeatureSSE41 : SubtargetFeature<"sse41", "X86SSELevel", "SSE41", |
| 43 | "Enable SSE 4.1 instructions", |
| 44 | [FeatureSSSE3]>; |
| 45 | def FeatureSSE42 : SubtargetFeature<"sse42", "X86SSELevel", "SSE42", |
| 46 | "Enable SSE 4.2 instructions", |
| 47 | [FeatureSSE41]>; |
Bill Wendling | 4222d80 | 2007-05-04 20:38:40 +0000 | [diff] [blame] | 48 | def Feature3DNow : SubtargetFeature<"3dnow", "X863DNowLevel", "ThreeDNow", |
| 49 | "Enable 3DNow! instructions">; |
| 50 | def Feature3DNowA : SubtargetFeature<"3dnowa", "X863DNowLevel", "ThreeDNowA", |
Bill Wendling | 11d8fda | 2007-05-06 07:56:19 +0000 | [diff] [blame] | 51 | "Enable 3DNow! Athlon instructions", |
| 52 | [Feature3DNow]>; |
Dan Gohman | f75e5b4 | 2009-02-03 00:04:43 +0000 | [diff] [blame] | 53 | // All x86-64 hardware has SSE2, but we don't mark SSE2 as an implied |
| 54 | // feature, because SSE2 can be disabled (e.g. for compiling OS kernels) |
| 55 | // without disabling 64-bit mode. |
Bill Wendling | 11d8fda | 2007-05-06 07:56:19 +0000 | [diff] [blame] | 56 | def Feature64Bit : SubtargetFeature<"64bit", "HasX86_64", "true", |
Dan Gohman | f75e5b4 | 2009-02-03 00:04:43 +0000 | [diff] [blame] | 57 | "Support 64-bit instructions">; |
Evan Cheng | ccb6976 | 2009-01-02 05:35:45 +0000 | [diff] [blame] | 58 | def FeatureSlowBTMem : SubtargetFeature<"slow-bt-mem", "IsBTMemSlow", "true", |
| 59 | "Bit testing of memory is slow">; |
Stefanus Du Toit | 8cf5ab1 | 2009-05-26 21:04:35 +0000 | [diff] [blame] | 60 | def FeatureSSE4A : SubtargetFeature<"sse4a", "HasSSE4A", "true", |
| 61 | "Support SSE 4a instructions">; |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 62 | |
David Greene | 343dadb | 2009-06-26 22:46:54 +0000 | [diff] [blame] | 63 | def FeatureAVX : SubtargetFeature<"avx", "HasAVX", "true", |
| 64 | "Enable AVX instructions">; |
| 65 | def FeatureFMA3 : SubtargetFeature<"fma3", "HasFMA3", "true", |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 66 | "Enable three-operand fused multiple-add">; |
David Greene | 343dadb | 2009-06-26 22:46:54 +0000 | [diff] [blame] | 67 | def FeatureFMA4 : SubtargetFeature<"fma4", "HasFMA4", "true", |
| 68 | "Enable four-operand fused multiple-add">; |
| 69 | |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 70 | //===----------------------------------------------------------------------===// |
| 71 | // X86 processors supported. |
| 72 | //===----------------------------------------------------------------------===// |
| 73 | |
| 74 | class Proc<string Name, list<SubtargetFeature> Features> |
| 75 | : Processor<Name, NoItineraries, Features>; |
| 76 | |
| 77 | def : Proc<"generic", []>; |
| 78 | def : Proc<"i386", []>; |
| 79 | def : Proc<"i486", []>; |
Dale Johannesen | 2194d46 | 2008-10-14 22:06:33 +0000 | [diff] [blame] | 80 | def : Proc<"i586", []>; |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 81 | def : Proc<"pentium", []>; |
| 82 | def : Proc<"pentium-mmx", [FeatureMMX]>; |
| 83 | def : Proc<"i686", []>; |
Chris Lattner | 7008416 | 2009-09-02 05:53:04 +0000 | [diff] [blame] | 84 | def : Proc<"pentiumpro", [FeatureCMOV]>; |
| 85 | def : Proc<"pentium2", [FeatureMMX, FeatureCMOV]>; |
Bill Wendling | cd6cea0 | 2007-05-22 05:15:37 +0000 | [diff] [blame] | 86 | def : Proc<"pentium3", [FeatureSSE1]>; |
Evan Cheng | ccb6976 | 2009-01-02 05:35:45 +0000 | [diff] [blame] | 87 | def : Proc<"pentium-m", [FeatureSSE2, FeatureSlowBTMem]>; |
Bill Wendling | cd6cea0 | 2007-05-22 05:15:37 +0000 | [diff] [blame] | 88 | def : Proc<"pentium4", [FeatureSSE2]>; |
Evan Cheng | b1f4981 | 2009-12-22 17:47:23 +0000 | [diff] [blame^] | 89 | def : Proc<"x86-64", [FeatureSSE2, Feature64Bit, FeatureSlowBTMem]>; |
| 90 | def : Proc<"yonah", [FeatureSSE3, FeatureSlowBTMem]>; |
| 91 | def : Proc<"prescott", [FeatureSSE3, FeatureSlowBTMem]>; |
| 92 | def : Proc<"nocona", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>; |
| 93 | def : Proc<"core2", [FeatureSSSE3, Feature64Bit, FeatureSlowBTMem]>; |
| 94 | def : Proc<"penryn", [FeatureSSE41, Feature64Bit, FeatureSlowBTMem]>; |
| 95 | def : Proc<"atom", [FeatureSSE3, Feature64Bit, FeatureSlowBTMem]>; |
| 96 | def : Proc<"corei7", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem]>; |
| 97 | def : Proc<"nehalem", [FeatureSSE42, Feature64Bit, FeatureSlowBTMem]>; |
David Greene | 343dadb | 2009-06-26 22:46:54 +0000 | [diff] [blame] | 98 | // Sandy Bridge does not have FMA |
Evan Cheng | b1f4981 | 2009-12-22 17:47:23 +0000 | [diff] [blame^] | 99 | def : Proc<"sandybridge", [FeatureSSE42, FeatureAVX, Feature64Bit]>; |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 100 | |
| 101 | def : Proc<"k6", [FeatureMMX]>; |
Bill Wendling | cd6cea0 | 2007-05-22 05:15:37 +0000 | [diff] [blame] | 102 | def : Proc<"k6-2", [FeatureMMX, Feature3DNow]>; |
| 103 | def : Proc<"k6-3", [FeatureMMX, Feature3DNow]>; |
Evan Cheng | ccb6976 | 2009-01-02 05:35:45 +0000 | [diff] [blame] | 104 | def : Proc<"athlon", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>; |
| 105 | def : Proc<"athlon-tbird", [FeatureMMX, Feature3DNowA, FeatureSlowBTMem]>; |
| 106 | def : Proc<"athlon-4", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>; |
| 107 | def : Proc<"athlon-xp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>; |
| 108 | def : Proc<"athlon-mp", [FeatureSSE1, Feature3DNowA, FeatureSlowBTMem]>; |
Dan Gohman | f75e5b4 | 2009-02-03 00:04:43 +0000 | [diff] [blame] | 109 | def : Proc<"k8", [FeatureSSE2, Feature3DNowA, Feature64Bit, |
| 110 | FeatureSlowBTMem]>; |
| 111 | def : Proc<"opteron", [FeatureSSE2, Feature3DNowA, Feature64Bit, |
| 112 | FeatureSlowBTMem]>; |
| 113 | def : Proc<"athlon64", [FeatureSSE2, Feature3DNowA, Feature64Bit, |
| 114 | FeatureSlowBTMem]>; |
| 115 | def : Proc<"athlon-fx", [FeatureSSE2, Feature3DNowA, Feature64Bit, |
| 116 | FeatureSlowBTMem]>; |
Stefanus Du Toit | 8cf5ab1 | 2009-05-26 21:04:35 +0000 | [diff] [blame] | 117 | def : Proc<"k8-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit, |
| 118 | FeatureSlowBTMem]>; |
| 119 | def : Proc<"opteron-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit, |
| 120 | FeatureSlowBTMem]>; |
| 121 | def : Proc<"athlon64-sse3", [FeatureSSE3, Feature3DNowA, Feature64Bit, |
| 122 | FeatureSlowBTMem]>; |
| 123 | def : Proc<"amdfam10", [FeatureSSE3, FeatureSSE4A, |
| 124 | Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>; |
| 125 | def : Proc<"barcelona", [FeatureSSE3, FeatureSSE4A, |
| 126 | Feature3DNowA, Feature64Bit, FeatureSlowBTMem]>; |
David Greene | 3016af5 | 2009-06-29 16:54:06 +0000 | [diff] [blame] | 127 | def : Proc<"istanbul", [Feature3DNowA, Feature64Bit, FeatureSSE4A, |
| 128 | Feature3DNowA]>; |
| 129 | def : Proc<"shanghai", [Feature3DNowA, Feature64Bit, FeatureSSE4A, |
| 130 | Feature3DNowA]>; |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 131 | |
| 132 | def : Proc<"winchip-c6", [FeatureMMX]>; |
| 133 | def : Proc<"winchip2", [FeatureMMX, Feature3DNow]>; |
| 134 | def : Proc<"c3", [FeatureMMX, Feature3DNow]>; |
Bill Wendling | cd6cea0 | 2007-05-22 05:15:37 +0000 | [diff] [blame] | 135 | def : Proc<"c3-2", [FeatureSSE1]>; |
Evan Cheng | a26eb5e | 2006-10-06 09:17:41 +0000 | [diff] [blame] | 136 | |
| 137 | //===----------------------------------------------------------------------===// |
Chris Lattner | 762fb5f | 2003-08-03 15:47:49 +0000 | [diff] [blame] | 138 | // Register File Description |
| 139 | //===----------------------------------------------------------------------===// |
| 140 | |
| 141 | include "X86RegisterInfo.td" |
| 142 | |
Chris Lattner | b77eb78 | 2003-08-03 18:19:37 +0000 | [diff] [blame] | 143 | //===----------------------------------------------------------------------===// |
| 144 | // Instruction Descriptions |
| 145 | //===----------------------------------------------------------------------===// |
| 146 | |
Chris Lattner | 1cca5e3 | 2003-08-03 21:54:21 +0000 | [diff] [blame] | 147 | include "X86InstrInfo.td" |
| 148 | |
Chris Lattner | b77eb78 | 2003-08-03 18:19:37 +0000 | [diff] [blame] | 149 | def X86InstrInfo : InstrInfo { |
Chris Lattner | 1cca5e3 | 2003-08-03 21:54:21 +0000 | [diff] [blame] | 150 | |
| 151 | // Define how we want to layout our TargetSpecific information field... This |
| 152 | // should be kept up-to-date with the fields in the X86InstrInfo.h file. |
John Criswell | 4ffff9e | 2004-04-08 20:31:47 +0000 | [diff] [blame] | 153 | let TSFlagsFields = ["FormBits", |
| 154 | "hasOpSizePrefix", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 155 | "hasAdSizePrefix", |
John Criswell | 4ffff9e | 2004-04-08 20:31:47 +0000 | [diff] [blame] | 156 | "Prefix", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 157 | "hasREX_WPrefix", |
John Criswell | 4ffff9e | 2004-04-08 20:31:47 +0000 | [diff] [blame] | 158 | "ImmTypeBits", |
| 159 | "FPFormBits", |
Andrew Lenharth | ea7da50 | 2008-03-01 13:37:02 +0000 | [diff] [blame] | 160 | "hasLockPrefix", |
Anton Korobeynikov | ef93cec | 2008-10-11 19:09:15 +0000 | [diff] [blame] | 161 | "SegOvrBits", |
John Criswell | 4ffff9e | 2004-04-08 20:31:47 +0000 | [diff] [blame] | 162 | "Opcode"]; |
| 163 | let TSFlagsShifts = [0, |
John Criswell | 4ffff9e | 2004-04-08 20:31:47 +0000 | [diff] [blame] | 164 | 6, |
Evan Cheng | 3c55c54 | 2006-02-01 06:13:50 +0000 | [diff] [blame] | 165 | 7, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 166 | 8, |
| 167 | 12, |
Evan Cheng | 3c55c54 | 2006-02-01 06:13:50 +0000 | [diff] [blame] | 168 | 13, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 169 | 16, |
Andrew Lenharth | ea7da50 | 2008-03-01 13:37:02 +0000 | [diff] [blame] | 170 | 19, |
Anton Korobeynikov | ef93cec | 2008-10-11 19:09:15 +0000 | [diff] [blame] | 171 | 20, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 172 | 24]; |
Chris Lattner | b77eb78 | 2003-08-03 18:19:37 +0000 | [diff] [blame] | 173 | } |
| 174 | |
Chris Lattner | 31c8a6d | 2007-02-26 18:17:14 +0000 | [diff] [blame] | 175 | //===----------------------------------------------------------------------===// |
| 176 | // Calling Conventions |
| 177 | //===----------------------------------------------------------------------===// |
| 178 | |
| 179 | include "X86CallingConv.td" |
| 180 | |
| 181 | |
| 182 | //===----------------------------------------------------------------------===// |
| 183 | // Assembly Printers |
| 184 | //===----------------------------------------------------------------------===// |
| 185 | |
Daniel Dunbar | 0e2771f | 2009-07-29 00:02:19 +0000 | [diff] [blame] | 186 | // Currently the X86 assembly parser only supports ATT syntax. |
| 187 | def ATTAsmParser : AsmParser { |
| 188 | string AsmParserClassName = "ATTAsmParser"; |
| 189 | int Variant = 0; |
Daniel Dunbar | 59fc42d | 2009-08-11 20:59:47 +0000 | [diff] [blame] | 190 | |
| 191 | // Discard comments in assembly strings. |
| 192 | string CommentDelimiter = "#"; |
| 193 | |
| 194 | // Recognize hard coded registers. |
| 195 | string RegisterPrefix = "%"; |
Daniel Dunbar | 0e2771f | 2009-07-29 00:02:19 +0000 | [diff] [blame] | 196 | } |
| 197 | |
Chris Lattner | 9a3e49a | 2004-10-03 20:36:57 +0000 | [diff] [blame] | 198 | // The X86 target supports two different syntaxes for emitting machine code. |
| 199 | // This is controlled by the -x86-asm-syntax={att|intel} |
| 200 | def ATTAsmWriter : AsmWriter { |
Chris Lattner | cae05cb | 2009-09-13 19:30:11 +0000 | [diff] [blame] | 201 | string AsmWriterClassName = "ATTInstPrinter"; |
Chris Lattner | 9a3e49a | 2004-10-03 20:36:57 +0000 | [diff] [blame] | 202 | int Variant = 0; |
| 203 | } |
| 204 | def IntelAsmWriter : AsmWriter { |
Chris Lattner | 7057641 | 2009-09-20 07:47:59 +0000 | [diff] [blame] | 205 | string AsmWriterClassName = "IntelInstPrinter"; |
Chris Lattner | 9a3e49a | 2004-10-03 20:36:57 +0000 | [diff] [blame] | 206 | int Variant = 1; |
| 207 | } |
| 208 | |
Chris Lattner | b77eb78 | 2003-08-03 18:19:37 +0000 | [diff] [blame] | 209 | def X86 : Target { |
Chris Lattner | b77eb78 | 2003-08-03 18:19:37 +0000 | [diff] [blame] | 210 | // Information about the instructions... |
Chris Lattner | c8f4587 | 2003-08-04 04:59:56 +0000 | [diff] [blame] | 211 | let InstructionSet = X86InstrInfo; |
Chris Lattner | 9a3e49a | 2004-10-03 20:36:57 +0000 | [diff] [blame] | 212 | |
Daniel Dunbar | 0e2771f | 2009-07-29 00:02:19 +0000 | [diff] [blame] | 213 | let AssemblyParsers = [ATTAsmParser]; |
| 214 | |
Chris Lattner | 9a3e49a | 2004-10-03 20:36:57 +0000 | [diff] [blame] | 215 | let AssemblyWriters = [ATTAsmWriter, IntelAsmWriter]; |
Chris Lattner | b77eb78 | 2003-08-03 18:19:37 +0000 | [diff] [blame] | 216 | } |