Properly support v8i8 and v4i16 types. It now converts them to v2i32 for
[oota-llvm.git] / lib / Target / X86 / X86InstrMMX.td
1 //====- X86InstrMMX.td - Describe the X86 Instruction Set --*- tablegen -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the Evan Cheng and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the X86 MMX instruction set, defining the instructions,
11 // and properties of the instructions which are needed for code generation,
12 // machine code emission, and analysis.
13 //
14 //===----------------------------------------------------------------------===//
15
16 //===----------------------------------------------------------------------===//
17 // Instruction templates
18 //===----------------------------------------------------------------------===//
19
20 // MMXI   - MMX instructions with TB prefix.
21 // MMX2I  - MMX / SSE2 instructions with TB and OpSize prefixes.
22 // MMXIi8 - MMX instructions with ImmT == Imm8 and TB prefix.
23 class MMXI<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
24       : I<o, F, ops, asm, pattern>, TB, Requires<[HasMMX]>;
25 class MMX2I<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
26       : I<o, F, ops, asm, pattern>, TB, OpSize, Requires<[HasSSE2]>;
27 class MMXIi8<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
28       : Ii8<o, F, ops, asm, pattern>, TB, Requires<[HasMMX]>;
29
30 // Some 'special' instructions
31 def IMPLICIT_DEF_VR64 : I<0, Pseudo, (ops VR64:$dst),
32                           "#IMPLICIT_DEF $dst",
33                           [(set VR64:$dst, (v8i8 (undef)))]>,
34                         Requires<[HasMMX]>;
35
36 // 64-bit vector undef's.
37 def : Pat<(v8i8  (undef)), (IMPLICIT_DEF_VR64)>;
38 def : Pat<(v4i16 (undef)), (IMPLICIT_DEF_VR64)>;
39 def : Pat<(v2i32 (undef)), (IMPLICIT_DEF_VR64)>;
40
41 //===----------------------------------------------------------------------===//
42 // MMX Pattern Fragments
43 //===----------------------------------------------------------------------===//
44
45 def loadv8i8  : PatFrag<(ops node:$ptr), (v8i8  (load node:$ptr))>;
46 def loadv4i16 : PatFrag<(ops node:$ptr), (v4i16 (load node:$ptr))>;
47 def loadv2i32 : PatFrag<(ops node:$ptr), (v2i32 (load node:$ptr))>;
48
49 //===----------------------------------------------------------------------===//
50 // MMX EMMS Instruction
51 //===----------------------------------------------------------------------===//
52
53 def EMMS : MMXI<0x77, RawFrm, (ops), "emms", [(int_x86_mmx_emms)]>;
54
55 //===----------------------------------------------------------------------===//
56 // MMX Scalar Instructions
57 //===----------------------------------------------------------------------===//
58
59 // Move Instructions
60 def MOVD64rr : MMXI<0x6E, MRMSrcReg, (ops VR64:$dst, GR32:$src),
61                     "movd {$src, $dst|$dst, $src}", []>;
62 def MOVD64rm : MMXI<0x6E, MRMSrcMem, (ops VR64:$dst, i32mem:$src),
63                     "movd {$src, $dst|$dst, $src}", []>;
64 def MOVD64mr : MMXI<0x7E, MRMDestMem, (ops i32mem:$dst, VR64:$src),
65                     "movd {$src, $dst|$dst, $src}", []>;
66
67 def MOVQ64rr : MMXI<0x6F, MRMSrcReg, (ops VR64:$dst, VR64:$src),
68                     "movq {$src, $dst|$dst, $src}", []>;
69 def MOVQ64rm : MMXI<0x6F, MRMSrcMem, (ops VR64:$dst, i64mem:$src),
70                     "movq {$src, $dst|$dst, $src}",
71                     [(set VR64:$dst, (loadv2i32 addr:$src))]>;
72 def MOVQ64mr : MMXI<0x7F, MRMDestMem, (ops i64mem:$dst, VR64:$src),
73                     "movq {$src, $dst|$dst, $src}",
74                     [(store (v2i32 VR64:$src), addr:$dst)]>;
75
76 // Conversion instructions
77 def CVTPI2PSrr : MMXI<0x2A, MRMSrcReg, (ops VR128:$dst, VR64:$src),
78                       "cvtpi2ps {$src, $dst|$dst, $src}", []>;
79 def CVTPI2PSrm : MMXI<0x2A, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
80                       "cvtpi2ps {$src, $dst|$dst, $src}", []>;
81 def CVTPI2PDrr : MMX2I<0x2A, MRMSrcReg, (ops VR128:$dst, VR64:$src),
82                        "cvtpi2pd {$src, $dst|$dst, $src}", []>;
83 def CVTPI2PDrm : MMX2I<0x2A, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
84                        "cvtpi2pd {$src, $dst|$dst, $src}", []>;
85 def CVTTPS2PIrr: I<0x2C, MRMSrcReg, (ops VR64:$dst, VR128:$src),
86                    "cvttps2pi {$src, $dst|$dst, $src}", []>, TB,
87                  Requires<[HasSSE2]>;
88 def CVTTPS2PIrm: I<0x2C, MRMSrcMem, (ops VR64:$dst, f64mem:$src),
89                    "cvttps2pi {$src, $dst|$dst, $src}", []>, TB,
90                  Requires<[HasMMX]>;
91 def CVTPS2PIrr : MMXI<0x2D, MRMSrcReg, (ops VR64:$dst, VR128:$src),
92                       "cvtps2pi {$src, $dst|$dst, $src}", []>;
93 def CVTPS2PIrm : MMXI<0x2D, MRMSrcMem, (ops VR64:$dst, f64mem:$src),
94                       "cvtps2pi {$src, $dst|$dst, $src}", []>;
95 def CVTPD2PIrr : MMX2I<0x2D, MRMSrcReg, (ops VR64:$dst, VR128:$src),
96                        "cvtpd2pi {$src, $dst|$dst, $src}", []>;
97 def CVTPD2PIrm : MMX2I<0x2D, MRMSrcMem, (ops VR64:$dst, f128mem:$src),
98                        "cvtpd2pi {$src, $dst|$dst, $src}", []>;
99
100 // Shuffle and unpack instructions
101 def PSHUFWri : MMXIi8<0x70, MRMSrcReg,
102                       (ops VR64:$dst, VR64:$src1, i8imm:$src2),
103                       "pshufw {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
104 def PSHUFWmi : MMXIi8<0x70, MRMSrcMem,
105                       (ops VR64:$dst, i64mem:$src1, i8imm:$src2),
106                       "pshufw {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
107
108 // Misc.
109 def MOVNTQ   : I<0xE7, MRMDestMem, (ops i64mem:$dst, VR64:$src),
110                  "movntq {$src, $dst|$dst, $src}", []>, TB,
111                Requires<[HasMMX]>;
112
113 def MASKMOVQ : I<0xF7, MRMDestMem, (ops VR64:$src, VR64:$mask),
114                  "maskmovq {$mask, $src|$src, $mask}", []>, TB,
115                Requires<[HasMMX]>;
116
117 //===----------------------------------------------------------------------===//
118 // Non-Instruction Patterns
119 //===----------------------------------------------------------------------===//
120
121 // Store 64-bit integer vector values.
122 def : Pat<(store (v8i8  VR64:$src), addr:$dst),
123           (MOVQ64mr addr:$dst, VR64:$src)>;
124 def : Pat<(store (v4i16 VR64:$src), addr:$dst),
125           (MOVQ64mr addr:$dst, VR64:$src)>;
126
127 // Bit convert.
128 def : Pat<(v8i8  (bitconvert (v2i32 VR64:$src))), (v8i8  VR64:$src)>;
129 def : Pat<(v8i8  (bitconvert (v4i16 VR64:$src))), (v8i8  VR64:$src)>;
130 def : Pat<(v4i16 (bitconvert (v2i32 VR64:$src))), (v4i16 VR64:$src)>;
131 def : Pat<(v4i16 (bitconvert (v8i8  VR64:$src))), (v4i16 VR64:$src)>;
132 def : Pat<(v2i32 (bitconvert (v4i16 VR64:$src))), (v2i32 VR64:$src)>;
133 def : Pat<(v2i32 (bitconvert (v8i8  VR64:$src))), (v2i32 VR64:$src)>;