Add the emms intrinsic for MMX support.
[oota-llvm.git] / lib / Target / X86 / X86InstrMMX.td
1 //====- X86InstrMMX.td - Describe the X86 Instruction Set -------*- C++ -*-===//
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 // Instruction templates
17 // MMXI   - MMX instructions with TB prefix.
18 // MMX2I  - MMX / SSE2 instructions with TB and OpSize prefixes.
19 // MMXIi8 - MMX instructions with ImmT == Imm8 and TB prefix.
20 class MMXI<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
21       : I<o, F, ops, asm, pattern>, TB, Requires<[HasMMX]>;
22 class MMX2I<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
23       : I<o, F, ops, asm, pattern>, TB, OpSize, Requires<[HasSSE2]>;
24 class MMXIi8<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
25       : Ii8<o, F, ops, asm, pattern>, TB, Requires<[HasMMX]>;
26
27 // Some 'special' instructions
28 def IMPLICIT_DEF_VR64 : I<0, Pseudo, (ops VR64:$dst),
29                           "#IMPLICIT_DEF $dst",
30                           [(set VR64:$dst, (v8i8 (undef)))]>,
31                         Requires<[HasMMX]>;
32
33 def : Pat<(v4i16 (undef)), (IMPLICIT_DEF_VR64)>,  Requires<[HasMMX]>;
34 def : Pat<(v2i32 (undef)), (IMPLICIT_DEF_VR64)>,  Requires<[HasMMX]>;
35
36 // EMMS
37 def EMMS : I<0x77, RawFrm, (ops), "emms", [(int_x86_mmx_emms)]>, TB,
38            Requires<[HasMMX]>;
39
40 // Move Instructions
41 def MOVD64rr : I<0x6E, MRMSrcReg, (ops VR64:$dst, GR32:$src),
42                  "movd {$src, $dst|$dst, $src}", []>, TB,
43                Requires<[HasMMX]>;
44 def MOVD64rm : I<0x6E, MRMSrcMem, (ops VR64:$dst, i32mem:$src),
45                  "movd {$src, $dst|$dst, $src}", []>, TB,
46                Requires<[HasMMX]>;
47 def MOVD64mr : I<0x7E, MRMDestMem, (ops i32mem:$dst, VR64:$src),
48                  "movd {$src, $dst|$dst, $src}", []>, TB,
49                Requires<[HasMMX]>;
50
51 def MOVQ64rr : I<0x6F, MRMSrcReg, (ops VR64:$dst, VR64:$src),
52                  "movq {$src, $dst|$dst, $src}", []>, TB,
53                Requires<[HasMMX]>;
54 def MOVQ64rm : I<0x6F, MRMSrcMem, (ops VR64:$dst, i64mem:$src),
55                  "movq {$src, $dst|$dst, $src}", []>, TB,
56                Requires<[HasMMX]>;
57 def MOVQ64mr : I<0x7F, MRMDestMem, (ops i64mem:$dst, VR64:$src),
58                  "movq {$src, $dst|$dst, $src}", []>, TB,
59                Requires<[HasMMX]>;
60
61 // Conversion instructions
62 def CVTPI2PSrr : MMXI<0x2A, MRMSrcReg, (ops VR128:$dst, VR64:$src),
63                       "cvtpi2ps {$src, $dst|$dst, $src}", []>;
64 def CVTPI2PSrm : MMXI<0x2A, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
65                       "cvtpi2ps {$src, $dst|$dst, $src}", []>;
66 def CVTPI2PDrr : MMX2I<0x2A, MRMSrcReg, (ops VR128:$dst, VR64:$src),
67                        "cvtpi2pd {$src, $dst|$dst, $src}", []>;
68 def CVTPI2PDrm : MMX2I<0x2A, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
69                        "cvtpi2pd {$src, $dst|$dst, $src}", []>;
70 def CVTTPS2PIrr: I<0x2C, MRMSrcReg, (ops VR64:$dst, VR128:$src),
71                    "cvttps2pi {$src, $dst|$dst, $src}", []>, TB,
72                  Requires<[HasSSE2]>;
73 def CVTTPS2PIrm: I<0x2C, MRMSrcMem, (ops VR64:$dst, f64mem:$src),
74                    "cvttps2pi {$src, $dst|$dst, $src}", []>, TB,
75                  Requires<[HasMMX]>;
76 def CVTPS2PIrr : MMXI<0x2D, MRMSrcReg, (ops VR64:$dst, VR128:$src),
77                       "cvtps2pi {$src, $dst|$dst, $src}", []>;
78 def CVTPS2PIrm : MMXI<0x2D, MRMSrcMem, (ops VR64:$dst, f64mem:$src),
79                       "cvtps2pi {$src, $dst|$dst, $src}", []>;
80 def CVTPD2PIrr : MMX2I<0x2D, MRMSrcReg, (ops VR64:$dst, VR128:$src),
81                        "cvtpd2pi {$src, $dst|$dst, $src}", []>;
82 def CVTPD2PIrm : MMX2I<0x2D, MRMSrcMem, (ops VR64:$dst, f128mem:$src),
83                        "cvtpd2pi {$src, $dst|$dst, $src}", []>;
84
85 // Shuffle and unpack instructions
86 def PSHUFWri : MMXIi8<0x70, MRMSrcReg,
87                       (ops VR64:$dst, VR64:$src1, i8imm:$src2),
88                       "pshufw {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
89 def PSHUFWmi : MMXIi8<0x70, MRMSrcMem,
90                       (ops VR64:$dst, i64mem:$src1, i8imm:$src2),
91                       "pshufw {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
92
93 // Misc.
94 def MOVNTQ   : I<0xE7, MRMDestMem, (ops i64mem:$dst, VR64:$src),
95                  "movntq {$src, $dst|$dst, $src}", []>, TB,
96                Requires<[HasMMX]>;
97
98 def MASKMOVQ : I<0xF7, MRMDestMem, (ops VR64:$src, VR64:$mask),
99                  "maskmovq {$mask, $src|$src, $mask}", []>, TB,
100                Requires<[HasMMX]>;