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