blob: 361b6ab1508be0c03597f598becac78f8df76a9d [file] [log] [blame]
Evan Chengffcb95b2006-02-21 19:13:53 +00001//====- 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
Evan Chengfcf5e212006-04-11 06:57:30 +000016// Instruction templates
Evan Chengd2a6d542006-04-12 23:42:44 +000017// 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.
20class MMXI<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
21 : I<o, F, ops, asm, pattern>, TB, Requires<[HasMMX]>;
22class MMX2I<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
23 : I<o, F, ops, asm, pattern>, TB, OpSize, Requires<[HasSSE2]>;
Evan Chengfcf5e212006-04-11 06:57:30 +000024class MMXIi8<bits<8> o, Format F, dag ops, string asm, list<dag> pattern>
25 : X86Inst<o, F, Imm8, ops, asm>, TB, Requires<[HasMMX]> {
26 let Pattern = pattern;
27}
28
Evan Chengba753c62006-03-20 06:04:52 +000029// Some 'special' instructions
30def IMPLICIT_DEF_VR64 : I<0, Pseudo, (ops VR64:$dst),
31 "#IMPLICIT_DEF $dst",
32 [(set VR64:$dst, (v8i8 (undef)))]>,
33 Requires<[HasMMX]>;
34
35def : Pat<(v4i16 (undef)), (IMPLICIT_DEF_VR64)>, Requires<[HasMMX]>;
36def : Pat<(v2i32 (undef)), (IMPLICIT_DEF_VR64)>, Requires<[HasMMX]>;
37
Evan Chengffcb95b2006-02-21 19:13:53 +000038// Move Instructions
Evan Cheng069287d2006-05-16 07:21:53 +000039def MOVD64rr : I<0x6E, MRMSrcReg, (ops VR64:$dst, GR32:$src),
Evan Cheng4a7da362006-03-21 23:04:23 +000040 "movd {$src, $dst|$dst, $src}", []>, TB,
Evan Chengffcb95b2006-02-21 19:13:53 +000041 Requires<[HasMMX]>;
42def MOVD64rm : I<0x6E, MRMSrcMem, (ops VR64:$dst, i32mem:$src),
43 "movd {$src, $dst|$dst, $src}", []>, TB,
44 Requires<[HasMMX]>;
45def MOVD64mr : I<0x7E, MRMDestMem, (ops i32mem:$dst, VR64:$src),
46 "movd {$src, $dst|$dst, $src}", []>, TB,
47 Requires<[HasMMX]>;
48
Evan Chengffcb95b2006-02-21 19:13:53 +000049def MOVQ64rr : I<0x6F, MRMSrcReg, (ops VR64:$dst, VR64:$src),
50 "movq {$src, $dst|$dst, $src}", []>, TB,
51 Requires<[HasMMX]>;
52def MOVQ64rm : I<0x6F, MRMSrcMem, (ops VR64:$dst, i64mem:$src),
53 "movq {$src, $dst|$dst, $src}", []>, TB,
54 Requires<[HasMMX]>;
55def MOVQ64mr : I<0x7F, MRMDestMem, (ops i64mem:$dst, VR64:$src),
56 "movq {$src, $dst|$dst, $src}", []>, TB,
57 Requires<[HasMMX]>;
Evan Cheng3246e062006-03-25 01:31:59 +000058
59// Conversion instructions
Evan Chengd2a6d542006-04-12 23:42:44 +000060def CVTPI2PSrr : MMXI<0x2A, MRMSrcReg, (ops VR128:$dst, VR64:$src),
61 "cvtpi2ps {$src, $dst|$dst, $src}", []>;
62def CVTPI2PSrm : MMXI<0x2A, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
63 "cvtpi2ps {$src, $dst|$dst, $src}", []>;
64def CVTPI2PDrr : MMX2I<0x2A, MRMSrcReg, (ops VR128:$dst, VR64:$src),
65 "cvtpi2pd {$src, $dst|$dst, $src}", []>;
66def CVTPI2PDrm : MMX2I<0x2A, MRMSrcMem, (ops VR128:$dst, i64mem:$src),
67 "cvtpi2pd {$src, $dst|$dst, $src}", []>;
Evan Cheng3246e062006-03-25 01:31:59 +000068def CVTTPS2PIrr: I<0x2C, MRMSrcReg, (ops VR64:$dst, VR128:$src),
69 "cvttps2pi {$src, $dst|$dst, $src}", []>, TB,
70 Requires<[HasSSE2]>;
Evan Chengcc4f0472006-03-25 06:00:03 +000071def CVTTPS2PIrm: I<0x2C, MRMSrcMem, (ops VR64:$dst, f64mem:$src),
Evan Cheng3246e062006-03-25 01:31:59 +000072 "cvttps2pi {$src, $dst|$dst, $src}", []>, TB,
73 Requires<[HasMMX]>;
Evan Chengd2a6d542006-04-12 23:42:44 +000074def CVTPS2PIrr : MMXI<0x2D, MRMSrcReg, (ops VR64:$dst, VR128:$src),
75 "cvtps2pi {$src, $dst|$dst, $src}", []>;
76def CVTPS2PIrm : MMXI<0x2D, MRMSrcMem, (ops VR64:$dst, f64mem:$src),
77 "cvtps2pi {$src, $dst|$dst, $src}", []>;
78def CVTPD2PIrr : MMX2I<0x2D, MRMSrcReg, (ops VR64:$dst, VR128:$src),
79 "cvtpd2pi {$src, $dst|$dst, $src}", []>;
80def CVTPD2PIrm : MMX2I<0x2D, MRMSrcMem, (ops VR64:$dst, f128mem:$src),
81 "cvtpd2pi {$src, $dst|$dst, $src}", []>;
Evan Chengfcf5e212006-04-11 06:57:30 +000082
83// Shuffle and unpack instructions
84def PSHUFWri : MMXIi8<0x70, MRMSrcReg,
85 (ops VR64:$dst, VR64:$src1, i8imm:$src2),
86 "pshufw {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
87def PSHUFWmi : MMXIi8<0x70, MRMSrcMem,
88 (ops VR64:$dst, i64mem:$src1, i8imm:$src2),
89 "pshufw {$src2, $src1, $dst|$dst, $src1, $src2}", []>;
90
91// Misc.
92def MOVNTQ : I<0xE7, MRMDestMem, (ops i64mem:$dst, VR64:$src),
93 "movntq {$src, $dst|$dst, $src}", []>, TB,
94 Requires<[HasMMX]>;
95
96def MASKMOVQ : I<0xF7, MRMDestMem, (ops VR64:$src, VR64:$mask),
97 "maskmovq {$mask, $src|$src, $mask}", []>, TB,
98 Requires<[HasMMX]>;
99