Arnold Schwaighofer | 373e865 | 2007-10-12 21:30:57 +0000 | [diff] [blame] | 1 | //====- X86InstrSSE.td - Describe the X86 Instruction Set --*- tablegen -*-===// |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2 | // |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 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. |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 7 | // |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file describes the X86 SSE 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 | //===----------------------------------------------------------------------===// |
| 18 | // SSE specific DAG Nodes. |
| 19 | //===----------------------------------------------------------------------===// |
| 20 | |
| 21 | def SDTX86FPShiftOp : SDTypeProfile<1, 2, [ SDTCisSameAs<0, 1>, |
| 22 | SDTCisFP<0>, SDTCisInt<2> ]>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 23 | def SDTX86VFCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>, |
| 24 | SDTCisFP<1>, SDTCisVT<3, i8>]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 25 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 26 | def X86fmin : SDNode<"X86ISD::FMIN", SDTFPBinOp>; |
| 27 | def X86fmax : SDNode<"X86ISD::FMAX", SDTFPBinOp>; |
| 28 | def X86fand : SDNode<"X86ISD::FAND", SDTFPBinOp, |
| 29 | [SDNPCommutative, SDNPAssociative]>; |
| 30 | def X86for : SDNode<"X86ISD::FOR", SDTFPBinOp, |
| 31 | [SDNPCommutative, SDNPAssociative]>; |
| 32 | def X86fxor : SDNode<"X86ISD::FXOR", SDTFPBinOp, |
| 33 | [SDNPCommutative, SDNPAssociative]>; |
| 34 | def X86frsqrt : SDNode<"X86ISD::FRSQRT", SDTFPUnaryOp>; |
| 35 | def X86frcp : SDNode<"X86ISD::FRCP", SDTFPUnaryOp>; |
| 36 | def X86fsrl : SDNode<"X86ISD::FSRL", SDTX86FPShiftOp>; |
Evan Cheng | f37bf45 | 2007-10-01 18:12:48 +0000 | [diff] [blame] | 37 | def X86comi : SDNode<"X86ISD::COMI", SDTX86CmpTest>; |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 38 | def X86ucomi : SDNode<"X86ISD::UCOMI", SDTX86CmpTest>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 39 | def X86pshufb : SDNode<"X86ISD::PSHUFB", |
Nate Begeman | 2c87c42 | 2009-02-23 08:49:38 +0000 | [diff] [blame] | 40 | SDTypeProfile<1, 2, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>, |
| 41 | SDTCisSameAs<0,2>]>>; |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 42 | def X86pextrb : SDNode<"X86ISD::PEXTRB", |
| 43 | SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>; |
| 44 | def X86pextrw : SDNode<"X86ISD::PEXTRW", |
| 45 | SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<2>]>>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 46 | def X86pinsrb : SDNode<"X86ISD::PINSRB", |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 47 | SDTypeProfile<1, 3, [SDTCisVT<0, v16i8>, SDTCisSameAs<0,1>, |
| 48 | SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 49 | def X86pinsrw : SDNode<"X86ISD::PINSRW", |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 50 | SDTypeProfile<1, 3, [SDTCisVT<0, v8i16>, SDTCisSameAs<0,1>, |
| 51 | SDTCisVT<2, i32>, SDTCisPtrTy<3>]>>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 52 | def X86insrtps : SDNode<"X86ISD::INSERTPS", |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 53 | SDTypeProfile<1, 3, [SDTCisVT<0, v4f32>, SDTCisSameAs<0,1>, |
Eric Christopher | efb657e | 2009-07-24 00:33:09 +0000 | [diff] [blame] | 54 | SDTCisVT<2, v4f32>, SDTCisPtrTy<3>]>>; |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 55 | def X86vzmovl : SDNode<"X86ISD::VZEXT_MOVL", |
| 56 | SDTypeProfile<1, 1, [SDTCisSameAs<0,1>]>>; |
| 57 | def X86vzload : SDNode<"X86ISD::VZEXT_LOAD", SDTLoad, |
| 58 | [SDNPHasChain, SDNPMayLoad]>; |
Evan Cheng | dea9936 | 2008-05-29 08:22:04 +0000 | [diff] [blame] | 59 | def X86vshl : SDNode<"X86ISD::VSHL", SDTIntShiftOp>; |
| 60 | def X86vshr : SDNode<"X86ISD::VSRL", SDTIntShiftOp>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 61 | def X86cmpps : SDNode<"X86ISD::CMPPS", SDTX86VFCMP>; |
| 62 | def X86cmppd : SDNode<"X86ISD::CMPPD", SDTX86VFCMP>; |
| 63 | def X86pcmpeqb : SDNode<"X86ISD::PCMPEQB", SDTIntBinOp, [SDNPCommutative]>; |
| 64 | def X86pcmpeqw : SDNode<"X86ISD::PCMPEQW", SDTIntBinOp, [SDNPCommutative]>; |
| 65 | def X86pcmpeqd : SDNode<"X86ISD::PCMPEQD", SDTIntBinOp, [SDNPCommutative]>; |
| 66 | def X86pcmpeqq : SDNode<"X86ISD::PCMPEQQ", SDTIntBinOp, [SDNPCommutative]>; |
| 67 | def X86pcmpgtb : SDNode<"X86ISD::PCMPGTB", SDTIntBinOp>; |
| 68 | def X86pcmpgtw : SDNode<"X86ISD::PCMPGTW", SDTIntBinOp>; |
| 69 | def X86pcmpgtd : SDNode<"X86ISD::PCMPGTD", SDTIntBinOp>; |
| 70 | def X86pcmpgtq : SDNode<"X86ISD::PCMPGTQ", SDTIntBinOp>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 71 | |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 72 | def SDTX86CmpPTest : SDTypeProfile<0, 2, [SDTCisVT<0, v4f32>, |
| 73 | SDTCisVT<1, v4f32>]>; |
Eric Christopher | 95d7926 | 2009-07-29 00:28:05 +0000 | [diff] [blame] | 74 | def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>; |
| 75 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 76 | //===----------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 77 | // SSE Complex Patterns |
| 78 | //===----------------------------------------------------------------------===// |
| 79 | |
| 80 | // These are 'extloads' from a scalar to the low element of a vector, zeroing |
| 81 | // the top elements. These are used for the SSE 'ss' and 'sd' instruction |
| 82 | // forms. |
Rafael Espindola | bca99f7 | 2009-04-08 21:14:34 +0000 | [diff] [blame] | 83 | def sse_load_f32 : ComplexPattern<v4f32, 5, "SelectScalarSSELoad", [], |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 84 | [SDNPHasChain, SDNPMayLoad]>; |
Rafael Espindola | bca99f7 | 2009-04-08 21:14:34 +0000 | [diff] [blame] | 85 | def sse_load_f64 : ComplexPattern<v2f64, 5, "SelectScalarSSELoad", [], |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 86 | [SDNPHasChain, SDNPMayLoad]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 87 | |
| 88 | def ssmem : Operand<v4f32> { |
| 89 | let PrintMethod = "printf32mem"; |
Dan Gohman | fe60682 | 2009-07-30 01:56:29 +0000 | [diff] [blame] | 90 | let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm); |
Daniel Dunbar | 0f10cbf | 2009-08-10 18:41:10 +0000 | [diff] [blame] | 91 | let ParserMatchClass = X86MemAsmOperand; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 92 | } |
| 93 | def sdmem : Operand<v2f64> { |
| 94 | let PrintMethod = "printf64mem"; |
Dan Gohman | fe60682 | 2009-07-30 01:56:29 +0000 | [diff] [blame] | 95 | let MIOperandInfo = (ops ptr_rc, i8imm, ptr_rc_nosp, i32imm, i8imm); |
Daniel Dunbar | 0f10cbf | 2009-08-10 18:41:10 +0000 | [diff] [blame] | 96 | let ParserMatchClass = X86MemAsmOperand; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | //===----------------------------------------------------------------------===// |
| 100 | // SSE pattern fragments |
| 101 | //===----------------------------------------------------------------------===// |
| 102 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 103 | def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>; |
| 104 | def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>; |
| 105 | def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>; |
| 106 | def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>; |
| 107 | |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 108 | // Like 'store', but always requires vector alignment. |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 109 | def alignedstore : PatFrag<(ops node:$val, node:$ptr), |
Dan Gohman | 2a17412 | 2008-10-15 06:50:19 +0000 | [diff] [blame] | 110 | (store node:$val, node:$ptr), [{ |
| 111 | return cast<StoreSDNode>(N)->getAlignment() >= 16; |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 112 | }]>; |
| 113 | |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 114 | // Like 'load', but always requires vector alignment. |
Dan Gohman | 2a17412 | 2008-10-15 06:50:19 +0000 | [diff] [blame] | 115 | def alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{ |
| 116 | return cast<LoadSDNode>(N)->getAlignment() >= 16; |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 117 | }]>; |
| 118 | |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 119 | def alignedloadfsf32 : PatFrag<(ops node:$ptr), (f32 (alignedload node:$ptr))>; |
| 120 | def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>; |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 121 | def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>; |
| 122 | def alignedloadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (alignedload node:$ptr))>; |
| 123 | def alignedloadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (alignedload node:$ptr))>; |
| 124 | def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>; |
| 125 | |
| 126 | // Like 'load', but uses special alignment checks suitable for use in |
| 127 | // memory operands in most SSE instructions, which are required to |
| 128 | // be naturally aligned on some targets but not on others. |
| 129 | // FIXME: Actually implement support for targets that don't require the |
| 130 | // alignment. This probably wants a subtarget predicate. |
Dan Gohman | 2a17412 | 2008-10-15 06:50:19 +0000 | [diff] [blame] | 131 | def memop : PatFrag<(ops node:$ptr), (load node:$ptr), [{ |
| 132 | return cast<LoadSDNode>(N)->getAlignment() >= 16; |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 133 | }]>; |
| 134 | |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 135 | def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>; |
| 136 | def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>; |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 137 | def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>; |
| 138 | def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>; |
| 139 | def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>; |
| 140 | def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>; |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 141 | def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>; |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 142 | |
Bill Wendling | 3b15d72 | 2007-08-11 09:52:53 +0000 | [diff] [blame] | 143 | // SSSE3 uses MMX registers for some instructions. They aren't aligned on a |
| 144 | // 16-byte boundary. |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 145 | // FIXME: 8 byte alignment for mmx reads is not required |
Dan Gohman | 61efc5a | 2008-10-16 00:03:00 +0000 | [diff] [blame] | 146 | def memop64 : PatFrag<(ops node:$ptr), (load node:$ptr), [{ |
Dan Gohman | 2a17412 | 2008-10-15 06:50:19 +0000 | [diff] [blame] | 147 | return cast<LoadSDNode>(N)->getAlignment() >= 8; |
Bill Wendling | 3b15d72 | 2007-08-11 09:52:53 +0000 | [diff] [blame] | 148 | }]>; |
| 149 | |
| 150 | def memopv8i8 : PatFrag<(ops node:$ptr), (v8i8 (memop64 node:$ptr))>; |
Bill Wendling | 3b15d72 | 2007-08-11 09:52:53 +0000 | [diff] [blame] | 151 | def memopv4i16 : PatFrag<(ops node:$ptr), (v4i16 (memop64 node:$ptr))>; |
| 152 | def memopv8i16 : PatFrag<(ops node:$ptr), (v8i16 (memop64 node:$ptr))>; |
| 153 | def memopv2i32 : PatFrag<(ops node:$ptr), (v2i32 (memop64 node:$ptr))>; |
| 154 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 155 | def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>; |
| 156 | def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>; |
| 157 | def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>; |
| 158 | def bc_v8i16 : PatFrag<(ops node:$in), (v8i16 (bitconvert node:$in))>; |
| 159 | def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>; |
| 160 | def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>; |
| 161 | |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 162 | def vzmovl_v2i64 : PatFrag<(ops node:$src), |
| 163 | (bitconvert (v2i64 (X86vzmovl |
| 164 | (v2i64 (scalar_to_vector (loadi64 node:$src))))))>; |
| 165 | def vzmovl_v4i32 : PatFrag<(ops node:$src), |
| 166 | (bitconvert (v4i32 (X86vzmovl |
| 167 | (v4i32 (scalar_to_vector (loadi32 node:$src))))))>; |
| 168 | |
| 169 | def vzload_v2i64 : PatFrag<(ops node:$src), |
| 170 | (bitconvert (v2i64 (X86vzload node:$src)))>; |
| 171 | |
| 172 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 173 | def fp32imm0 : PatLeaf<(f32 fpimm), [{ |
| 174 | return N->isExactlyValue(+0.0); |
| 175 | }]>; |
| 176 | |
| 177 | def PSxLDQ_imm : SDNodeXForm<imm, [{ |
| 178 | // Transformation function: imm >> 3 |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 179 | return getI32Imm(N->getZExtValue() >> 3); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 180 | }]>; |
| 181 | |
| 182 | // SHUFFLE_get_shuf_imm xform function: convert vector_shuffle mask to PSHUF*, |
| 183 | // SHUFP* etc. imm. |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 184 | def SHUFFLE_get_shuf_imm : SDNodeXForm<vector_shuffle, [{ |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 185 | return getI8Imm(X86::getShuffleSHUFImmediate(N)); |
| 186 | }]>; |
| 187 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 188 | // SHUFFLE_get_pshufhw_imm xform function: convert vector_shuffle mask to |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 189 | // PSHUFHW imm. |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 190 | def SHUFFLE_get_pshufhw_imm : SDNodeXForm<vector_shuffle, [{ |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 191 | return getI8Imm(X86::getShufflePSHUFHWImmediate(N)); |
| 192 | }]>; |
| 193 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 194 | // SHUFFLE_get_pshuflw_imm xform function: convert vector_shuffle mask to |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 195 | // PSHUFLW imm. |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 196 | def SHUFFLE_get_pshuflw_imm : SDNodeXForm<vector_shuffle, [{ |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 197 | return getI8Imm(X86::getShufflePSHUFLWImmediate(N)); |
| 198 | }]>; |
| 199 | |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 200 | def splat_lo : PatFrag<(ops node:$lhs, node:$rhs), |
| 201 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 202 | ShuffleVectorSDNode *SVOp = cast<ShuffleVectorSDNode>(N); |
| 203 | return SVOp->isSplat() && SVOp->getSplatIndex() == 0; |
| 204 | }]>; |
| 205 | |
| 206 | def movddup : PatFrag<(ops node:$lhs, node:$rhs), |
| 207 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 208 | return X86::isMOVDDUPMask(cast<ShuffleVectorSDNode>(N)); |
| 209 | }]>; |
| 210 | |
| 211 | def movhlps : PatFrag<(ops node:$lhs, node:$rhs), |
| 212 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 213 | return X86::isMOVHLPSMask(cast<ShuffleVectorSDNode>(N)); |
| 214 | }]>; |
| 215 | |
| 216 | def movhlps_undef : PatFrag<(ops node:$lhs, node:$rhs), |
| 217 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 218 | return X86::isMOVHLPS_v_undef_Mask(cast<ShuffleVectorSDNode>(N)); |
| 219 | }]>; |
| 220 | |
| 221 | def movhp : PatFrag<(ops node:$lhs, node:$rhs), |
| 222 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 223 | return X86::isMOVHPMask(cast<ShuffleVectorSDNode>(N)); |
| 224 | }]>; |
| 225 | |
| 226 | def movlp : PatFrag<(ops node:$lhs, node:$rhs), |
| 227 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 228 | return X86::isMOVLPMask(cast<ShuffleVectorSDNode>(N)); |
| 229 | }]>; |
| 230 | |
| 231 | def movl : PatFrag<(ops node:$lhs, node:$rhs), |
| 232 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 233 | return X86::isMOVLMask(cast<ShuffleVectorSDNode>(N)); |
| 234 | }]>; |
| 235 | |
| 236 | def movshdup : PatFrag<(ops node:$lhs, node:$rhs), |
| 237 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 238 | return X86::isMOVSHDUPMask(cast<ShuffleVectorSDNode>(N)); |
| 239 | }]>; |
| 240 | |
| 241 | def movsldup : PatFrag<(ops node:$lhs, node:$rhs), |
| 242 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 243 | return X86::isMOVSLDUPMask(cast<ShuffleVectorSDNode>(N)); |
| 244 | }]>; |
| 245 | |
| 246 | def unpckl : PatFrag<(ops node:$lhs, node:$rhs), |
| 247 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 248 | return X86::isUNPCKLMask(cast<ShuffleVectorSDNode>(N)); |
| 249 | }]>; |
| 250 | |
| 251 | def unpckh : PatFrag<(ops node:$lhs, node:$rhs), |
| 252 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 253 | return X86::isUNPCKHMask(cast<ShuffleVectorSDNode>(N)); |
| 254 | }]>; |
| 255 | |
| 256 | def unpckl_undef : PatFrag<(ops node:$lhs, node:$rhs), |
| 257 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 258 | return X86::isUNPCKL_v_undef_Mask(cast<ShuffleVectorSDNode>(N)); |
| 259 | }]>; |
| 260 | |
| 261 | def unpckh_undef : PatFrag<(ops node:$lhs, node:$rhs), |
| 262 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 263 | return X86::isUNPCKH_v_undef_Mask(cast<ShuffleVectorSDNode>(N)); |
| 264 | }]>; |
| 265 | |
| 266 | def pshufd : PatFrag<(ops node:$lhs, node:$rhs), |
| 267 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 268 | return X86::isPSHUFDMask(cast<ShuffleVectorSDNode>(N)); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 269 | }], SHUFFLE_get_shuf_imm>; |
| 270 | |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 271 | def shufp : PatFrag<(ops node:$lhs, node:$rhs), |
| 272 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 273 | return X86::isSHUFPMask(cast<ShuffleVectorSDNode>(N)); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 274 | }], SHUFFLE_get_shuf_imm>; |
| 275 | |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 276 | def pshufhw : PatFrag<(ops node:$lhs, node:$rhs), |
| 277 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 278 | return X86::isPSHUFHWMask(cast<ShuffleVectorSDNode>(N)); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 279 | }], SHUFFLE_get_pshufhw_imm>; |
| 280 | |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 281 | def pshuflw : PatFrag<(ops node:$lhs, node:$rhs), |
| 282 | (vector_shuffle node:$lhs, node:$rhs), [{ |
| 283 | return X86::isPSHUFLWMask(cast<ShuffleVectorSDNode>(N)); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 284 | }], SHUFFLE_get_pshuflw_imm>; |
| 285 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 286 | //===----------------------------------------------------------------------===// |
| 287 | // SSE scalar FP Instructions |
| 288 | //===----------------------------------------------------------------------===// |
| 289 | |
| 290 | // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded by the |
| 291 | // scheduler into a branch sequence. |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 292 | // These are expanded by the scheduler. |
| 293 | let Uses = [EFLAGS], usesCustomDAGSchedInserter = 1 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 294 | def CMOV_FR32 : I<0, Pseudo, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 295 | (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 296 | "#CMOV_FR32 PSEUDO!", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 297 | [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond, |
| 298 | EFLAGS))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 299 | def CMOV_FR64 : I<0, Pseudo, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 300 | (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 301 | "#CMOV_FR64 PSEUDO!", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 302 | [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond, |
| 303 | EFLAGS))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 304 | def CMOV_V4F32 : I<0, Pseudo, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 305 | (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 306 | "#CMOV_V4F32 PSEUDO!", |
| 307 | [(set VR128:$dst, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 308 | (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond, |
| 309 | EFLAGS)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 310 | def CMOV_V2F64 : I<0, Pseudo, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 311 | (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 312 | "#CMOV_V2F64 PSEUDO!", |
| 313 | [(set VR128:$dst, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 314 | (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond, |
| 315 | EFLAGS)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 316 | def CMOV_V2I64 : I<0, Pseudo, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 317 | (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 318 | "#CMOV_V2I64 PSEUDO!", |
| 319 | [(set VR128:$dst, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 320 | (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond, |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 321 | EFLAGS)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | //===----------------------------------------------------------------------===// |
| 325 | // SSE1 Instructions |
| 326 | //===----------------------------------------------------------------------===// |
| 327 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 328 | // Move Instructions |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 329 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 330 | def MOVSSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 331 | "movss\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 332 | let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 333 | def MOVSSrm : SSI<0x10, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 334 | "movss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 335 | [(set FR32:$dst, (loadf32 addr:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 336 | def MOVSSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 337 | "movss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 338 | [(store FR32:$src, addr:$dst)]>; |
| 339 | |
| 340 | // Conversion instructions |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 341 | def CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 342 | "cvttss2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 343 | [(set GR32:$dst, (fp_to_sint FR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 344 | def CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 345 | "cvttss2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 346 | [(set GR32:$dst, (fp_to_sint (loadf32 addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 347 | def CVTSI2SSrr : SSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 348 | "cvtsi2ss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 349 | [(set FR32:$dst, (sint_to_fp GR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 350 | def CVTSI2SSrm : SSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 351 | "cvtsi2ss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 352 | [(set FR32:$dst, (sint_to_fp (loadi32 addr:$src)))]>; |
| 353 | |
| 354 | // Match intrinsics which expect XMM operand(s). |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 355 | def Int_CVTSS2SIrr : SSI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 356 | "cvtss2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 357 | [(set GR32:$dst, (int_x86_sse_cvtss2si VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 358 | def Int_CVTSS2SIrm : SSI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 359 | "cvtss2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 360 | [(set GR32:$dst, (int_x86_sse_cvtss2si |
| 361 | (load addr:$src)))]>; |
| 362 | |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 363 | // Match intrinisics which expect MM and XMM operand(s). |
| 364 | def Int_CVTPS2PIrr : PSI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src), |
| 365 | "cvtps2pi\t{$src, $dst|$dst, $src}", |
| 366 | [(set VR64:$dst, (int_x86_sse_cvtps2pi VR128:$src))]>; |
| 367 | def Int_CVTPS2PIrm : PSI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src), |
| 368 | "cvtps2pi\t{$src, $dst|$dst, $src}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 369 | [(set VR64:$dst, (int_x86_sse_cvtps2pi |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 370 | (load addr:$src)))]>; |
| 371 | def Int_CVTTPS2PIrr: PSI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src), |
| 372 | "cvttps2pi\t{$src, $dst|$dst, $src}", |
| 373 | [(set VR64:$dst, (int_x86_sse_cvttps2pi VR128:$src))]>; |
| 374 | def Int_CVTTPS2PIrm: PSI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f64mem:$src), |
| 375 | "cvttps2pi\t{$src, $dst|$dst, $src}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 376 | [(set VR64:$dst, (int_x86_sse_cvttps2pi |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 377 | (load addr:$src)))]>; |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 378 | let Constraints = "$src1 = $dst" in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 379 | def Int_CVTPI2PSrr : PSI<0x2A, MRMSrcReg, |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 380 | (outs VR128:$dst), (ins VR128:$src1, VR64:$src2), |
| 381 | "cvtpi2ps\t{$src2, $dst|$dst, $src2}", |
| 382 | [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1, |
| 383 | VR64:$src2))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 384 | def Int_CVTPI2PSrm : PSI<0x2A, MRMSrcMem, |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 385 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
| 386 | "cvtpi2ps\t{$src2, $dst|$dst, $src2}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 387 | [(set VR128:$dst, (int_x86_sse_cvtpi2ps VR128:$src1, |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 388 | (load addr:$src2)))]>; |
| 389 | } |
| 390 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 391 | // Aliases for intrinsics |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 392 | def Int_CVTTSS2SIrr : SSI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 393 | "cvttss2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 394 | [(set GR32:$dst, |
| 395 | (int_x86_sse_cvttss2si VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 396 | def Int_CVTTSS2SIrm : SSI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 397 | "cvttss2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 398 | [(set GR32:$dst, |
| 399 | (int_x86_sse_cvttss2si(load addr:$src)))]>; |
| 400 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 401 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 402 | def Int_CVTSI2SSrr : SSI<0x2A, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 403 | (outs VR128:$dst), (ins VR128:$src1, GR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 404 | "cvtsi2ss\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 405 | [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1, |
| 406 | GR32:$src2))]>; |
| 407 | def Int_CVTSI2SSrm : SSI<0x2A, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 408 | (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 409 | "cvtsi2ss\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 410 | [(set VR128:$dst, (int_x86_sse_cvtsi2ss VR128:$src1, |
| 411 | (loadi32 addr:$src2)))]>; |
| 412 | } |
| 413 | |
| 414 | // Comparison instructions |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 415 | let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 416 | def CMPSSrr : SSIi8<0xC2, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 417 | (outs FR32:$dst), (ins FR32:$src1, FR32:$src, SSECC:$cc), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 418 | "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 419 | let mayLoad = 1 in |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 420 | def CMPSSrm : SSIi8<0xC2, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 421 | (outs FR32:$dst), (ins FR32:$src1, f32mem:$src, SSECC:$cc), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 422 | "cmp${cc}ss\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 423 | } |
| 424 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 425 | let Defs = [EFLAGS] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 426 | def UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins FR32:$src1, FR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 427 | "ucomiss\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 428 | [(X86cmp FR32:$src1, FR32:$src2), (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 429 | def UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs), (ins FR32:$src1, f32mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 430 | "ucomiss\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 431 | [(X86cmp FR32:$src1, (loadf32 addr:$src2)), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 432 | (implicit EFLAGS)]>; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 433 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 434 | |
| 435 | // Aliases to match intrinsics which expect XMM operand(s). |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 436 | let Constraints = "$src1 = $dst" in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 437 | def Int_CMPSSrr : SSIi8<0xC2, MRMSrcReg, |
| 438 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src, |
| 439 | SSECC:$cc), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 440 | "cmp${cc}ss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 441 | [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1, |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 442 | VR128:$src, imm:$cc))]>; |
| 443 | def Int_CMPSSrm : SSIi8<0xC2, MRMSrcMem, |
| 444 | (outs VR128:$dst), (ins VR128:$src1, f32mem:$src, |
| 445 | SSECC:$cc), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 446 | "cmp${cc}ss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 447 | [(set VR128:$dst, (int_x86_sse_cmp_ss VR128:$src1, |
| 448 | (load addr:$src), imm:$cc))]>; |
| 449 | } |
| 450 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 451 | let Defs = [EFLAGS] in { |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 452 | def Int_UCOMISSrr: PSI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 453 | "ucomiss\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 454 | [(X86ucomi (v4f32 VR128:$src1), VR128:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 455 | (implicit EFLAGS)]>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 456 | def Int_UCOMISSrm: PSI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 457 | "ucomiss\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 458 | [(X86ucomi (v4f32 VR128:$src1), (load addr:$src2)), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 459 | (implicit EFLAGS)]>; |
| 460 | |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 461 | def Int_COMISSrr: PSI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 462 | "comiss\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 463 | [(X86comi (v4f32 VR128:$src1), VR128:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 464 | (implicit EFLAGS)]>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 465 | def Int_COMISSrm: PSI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 466 | "comiss\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 467 | [(X86comi (v4f32 VR128:$src1), (load addr:$src2)), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 468 | (implicit EFLAGS)]>; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 469 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 470 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 471 | // Aliases of packed SSE1 instructions for scalar use. These all have names |
| 472 | // that start with 'Fs'. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 473 | |
| 474 | // Alias instructions that map fld0 to pxor for sse. |
Dan Gohman | 51dbce6 | 2009-09-21 18:30:38 +0000 | [diff] [blame] | 475 | let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1, |
| 476 | canFoldAsLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 477 | def FsFLD0SS : I<0xEF, MRMInitReg, (outs FR32:$dst), (ins), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 478 | "pxor\t$dst, $dst", [(set FR32:$dst, fp32imm0)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 479 | Requires<[HasSSE1]>, TB, OpSize; |
| 480 | |
| 481 | // Alias instruction to do FR32 reg-to-reg copy using movaps. Upper bits are |
| 482 | // disregarded. |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 483 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 484 | def FsMOVAPSrr : PSI<0x28, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 485 | "movaps\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 486 | |
| 487 | // Alias instruction to load FR32 from f128mem using movaps. Upper bits are |
| 488 | // disregarded. |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 489 | let canFoldAsLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 490 | def FsMOVAPSrm : PSI<0x28, MRMSrcMem, (outs FR32:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 491 | "movaps\t{$src, $dst|$dst, $src}", |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 492 | [(set FR32:$dst, (alignedloadfsf32 addr:$src))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 493 | |
| 494 | // Alias bitwise logical operations using SSE logical ops on packed FP values. |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 495 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 496 | let isCommutable = 1 in { |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 497 | def FsANDPSrr : PSI<0x54, MRMSrcReg, (outs FR32:$dst), |
| 498 | (ins FR32:$src1, FR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 499 | "andps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 500 | [(set FR32:$dst, (X86fand FR32:$src1, FR32:$src2))]>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 501 | def FsORPSrr : PSI<0x56, MRMSrcReg, (outs FR32:$dst), |
| 502 | (ins FR32:$src1, FR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 503 | "orps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 504 | [(set FR32:$dst, (X86for FR32:$src1, FR32:$src2))]>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 505 | def FsXORPSrr : PSI<0x57, MRMSrcReg, (outs FR32:$dst), |
| 506 | (ins FR32:$src1, FR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 507 | "xorps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 508 | [(set FR32:$dst, (X86fxor FR32:$src1, FR32:$src2))]>; |
| 509 | } |
| 510 | |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 511 | def FsANDPSrm : PSI<0x54, MRMSrcMem, (outs FR32:$dst), |
| 512 | (ins FR32:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 513 | "andps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 514 | [(set FR32:$dst, (X86fand FR32:$src1, |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 515 | (memopfsf32 addr:$src2)))]>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 516 | def FsORPSrm : PSI<0x56, MRMSrcMem, (outs FR32:$dst), |
| 517 | (ins FR32:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 518 | "orps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 519 | [(set FR32:$dst, (X86for FR32:$src1, |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 520 | (memopfsf32 addr:$src2)))]>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 521 | def FsXORPSrm : PSI<0x57, MRMSrcMem, (outs FR32:$dst), |
| 522 | (ins FR32:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 523 | "xorps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 524 | [(set FR32:$dst, (X86fxor FR32:$src1, |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 525 | (memopfsf32 addr:$src2)))]>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 526 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 527 | let neverHasSideEffects = 1 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 528 | def FsANDNPSrr : PSI<0x55, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 529 | (outs FR32:$dst), (ins FR32:$src1, FR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 530 | "andnps\t{$src2, $dst|$dst, $src2}", []>; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 531 | let mayLoad = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 532 | def FsANDNPSrm : PSI<0x55, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 533 | (outs FR32:$dst), (ins FR32:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 534 | "andnps\t{$src2, $dst|$dst, $src2}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 535 | } |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 536 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 537 | |
| 538 | /// basic_sse1_fp_binop_rm - SSE1 binops come in both scalar and vector forms. |
| 539 | /// |
| 540 | /// In addition, we also have a special variant of the scalar form here to |
| 541 | /// represent the associated intrinsic operation. This form is unlike the |
| 542 | /// plain scalar form, in that it takes an entire vector (instead of a scalar) |
Evan Cheng | 5d5dbbc | 2009-02-26 03:12:02 +0000 | [diff] [blame] | 543 | /// and leaves the top elements unmodified (therefore these cannot be commuted). |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 544 | /// |
| 545 | /// These three forms can each be reg+reg or reg+mem, so there are a total of |
| 546 | /// six "instructions". |
| 547 | /// |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 548 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 549 | multiclass basic_sse1_fp_binop_rm<bits<8> opc, string OpcodeStr, |
| 550 | SDNode OpNode, Intrinsic F32Int, |
| 551 | bit Commutable = 0> { |
| 552 | // Scalar operation, reg+reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 553 | def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 554 | !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 555 | [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> { |
| 556 | let isCommutable = Commutable; |
| 557 | } |
| 558 | |
| 559 | // Scalar operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 560 | def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), |
| 561 | (ins FR32:$src1, f32mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 562 | !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 563 | [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 564 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 565 | // Vector operation, reg+reg. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 566 | def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), |
| 567 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 568 | !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 569 | [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> { |
| 570 | let isCommutable = Commutable; |
| 571 | } |
| 572 | |
| 573 | // Vector operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 574 | def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), |
| 575 | (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 576 | !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 577 | [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 578 | |
| 579 | // Intrinsic operation, reg+reg. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 580 | def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), |
| 581 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 582 | !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"), |
Evan Cheng | 5d5dbbc | 2009-02-26 03:12:02 +0000 | [diff] [blame] | 583 | [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 584 | |
| 585 | // Intrinsic operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 586 | def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), |
| 587 | (ins VR128:$src1, ssmem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 588 | !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 589 | [(set VR128:$dst, (F32Int VR128:$src1, |
| 590 | sse_load_f32:$src2))]>; |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | // Arithmetic instructions |
| 595 | defm ADD : basic_sse1_fp_binop_rm<0x58, "add", fadd, int_x86_sse_add_ss, 1>; |
| 596 | defm MUL : basic_sse1_fp_binop_rm<0x59, "mul", fmul, int_x86_sse_mul_ss, 1>; |
| 597 | defm SUB : basic_sse1_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse_sub_ss>; |
| 598 | defm DIV : basic_sse1_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse_div_ss>; |
| 599 | |
| 600 | /// sse1_fp_binop_rm - Other SSE1 binops |
| 601 | /// |
| 602 | /// This multiclass is like basic_sse1_fp_binop_rm, with the addition of |
| 603 | /// instructions for a full-vector intrinsic form. Operations that map |
| 604 | /// onto C operators don't use this form since they just use the plain |
| 605 | /// vector form instead of having a separate vector intrinsic form. |
| 606 | /// |
| 607 | /// This provides a total of eight "instructions". |
| 608 | /// |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 609 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 610 | multiclass sse1_fp_binop_rm<bits<8> opc, string OpcodeStr, |
| 611 | SDNode OpNode, |
| 612 | Intrinsic F32Int, |
| 613 | Intrinsic V4F32Int, |
| 614 | bit Commutable = 0> { |
| 615 | |
| 616 | // Scalar operation, reg+reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 617 | def SSrr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src1, FR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 618 | !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 619 | [(set FR32:$dst, (OpNode FR32:$src1, FR32:$src2))]> { |
| 620 | let isCommutable = Commutable; |
| 621 | } |
| 622 | |
| 623 | // Scalar operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 624 | def SSrm : SSI<opc, MRMSrcMem, (outs FR32:$dst), |
| 625 | (ins FR32:$src1, f32mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 626 | !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 627 | [(set FR32:$dst, (OpNode FR32:$src1, (load addr:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 628 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 629 | // Vector operation, reg+reg. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 630 | def PSrr : PSI<opc, MRMSrcReg, (outs VR128:$dst), |
| 631 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 632 | !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 633 | [(set VR128:$dst, (v4f32 (OpNode VR128:$src1, VR128:$src2)))]> { |
| 634 | let isCommutable = Commutable; |
| 635 | } |
| 636 | |
| 637 | // Vector operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 638 | def PSrm : PSI<opc, MRMSrcMem, (outs VR128:$dst), |
| 639 | (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 640 | !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 641 | [(set VR128:$dst, (OpNode VR128:$src1, (memopv4f32 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 642 | |
| 643 | // Intrinsic operation, reg+reg. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 644 | def SSrr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), |
| 645 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 646 | !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 647 | [(set VR128:$dst, (F32Int VR128:$src1, VR128:$src2))]> { |
| 648 | let isCommutable = Commutable; |
| 649 | } |
| 650 | |
| 651 | // Intrinsic operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 652 | def SSrm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), |
| 653 | (ins VR128:$src1, ssmem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 654 | !strconcat(OpcodeStr, "ss\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 655 | [(set VR128:$dst, (F32Int VR128:$src1, |
| 656 | sse_load_f32:$src2))]>; |
| 657 | |
| 658 | // Vector intrinsic operation, reg+reg. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 659 | def PSrr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), |
| 660 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 661 | !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 662 | [(set VR128:$dst, (V4F32Int VR128:$src1, VR128:$src2))]> { |
| 663 | let isCommutable = Commutable; |
| 664 | } |
| 665 | |
| 666 | // Vector intrinsic operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 667 | def PSrm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), |
| 668 | (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 669 | !strconcat(OpcodeStr, "ps\t{$src2, $dst|$dst, $src2}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 670 | [(set VR128:$dst, (V4F32Int VR128:$src1, (memopv4f32 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 671 | } |
| 672 | } |
| 673 | |
| 674 | defm MAX : sse1_fp_binop_rm<0x5F, "max", X86fmax, |
| 675 | int_x86_sse_max_ss, int_x86_sse_max_ps>; |
| 676 | defm MIN : sse1_fp_binop_rm<0x5D, "min", X86fmin, |
| 677 | int_x86_sse_min_ss, int_x86_sse_min_ps>; |
| 678 | |
| 679 | //===----------------------------------------------------------------------===// |
| 680 | // SSE packed FP Instructions |
| 681 | |
| 682 | // Move Instructions |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 683 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 684 | def MOVAPSrr : PSI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 685 | "movaps\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 686 | let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 687 | def MOVAPSrm : PSI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 688 | "movaps\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 689 | [(set VR128:$dst, (alignedloadv4f32 addr:$src))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 690 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 691 | def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 692 | "movaps\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 693 | [(alignedstore (v4f32 VR128:$src), addr:$dst)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 694 | |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 695 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 696 | def MOVUPSrr : PSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 697 | "movups\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 698 | let canFoldAsLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 699 | def MOVUPSrm : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 700 | "movups\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 701 | [(set VR128:$dst, (loadv4f32 addr:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 702 | def MOVUPSmr : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 703 | "movups\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 704 | [(store (v4f32 VR128:$src), addr:$dst)]>; |
| 705 | |
| 706 | // Intrinsic forms of MOVUPS load and store |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 707 | let canFoldAsLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 708 | def MOVUPSrm_Int : PSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 709 | "movups\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 710 | [(set VR128:$dst, (int_x86_sse_loadu_ps addr:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 711 | def MOVUPSmr_Int : PSI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 712 | "movups\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 713 | [(int_x86_sse_storeu_ps addr:$dst, VR128:$src)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 714 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 715 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 716 | let AddedComplexity = 20 in { |
| 717 | def MOVLPSrm : PSI<0x12, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 718 | (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 719 | "movlps\t{$src2, $dst|$dst, $src2}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 720 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 721 | (movlp VR128:$src1, |
| 722 | (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 723 | def MOVHPSrm : PSI<0x16, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 724 | (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 725 | "movhps\t{$src2, $dst|$dst, $src2}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 726 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 727 | (movhp VR128:$src1, |
| 728 | (bc_v4f32 (v2f64 (scalar_to_vector (loadf64 addr:$src2))))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 729 | } // AddedComplexity |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 730 | } // Constraints = "$src1 = $dst" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 731 | |
Evan Cheng | d743a5f | 2008-05-10 00:59:18 +0000 | [diff] [blame] | 732 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 733 | def MOVLPSmr : PSI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 734 | "movlps\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 735 | [(store (f64 (vector_extract (bc_v2f64 (v4f32 VR128:$src)), |
| 736 | (iPTR 0))), addr:$dst)]>; |
| 737 | |
| 738 | // v2f64 extract element 1 is always custom lowered to unpack high to low |
| 739 | // and extract element 0 so the non-store version isn't too horrible. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 740 | def MOVHPSmr : PSI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 741 | "movhps\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 742 | [(store (f64 (vector_extract |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 743 | (unpckh (bc_v2f64 (v4f32 VR128:$src)), |
| 744 | (undef)), (iPTR 0))), addr:$dst)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 745 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 746 | let Constraints = "$src1 = $dst" in { |
Evan Cheng | 13559d6 | 2008-09-26 23:41:32 +0000 | [diff] [blame] | 747 | let AddedComplexity = 20 in { |
Evan Cheng | 7581a82 | 2009-05-12 20:17:52 +0000 | [diff] [blame] | 748 | def MOVLHPSrr : PSI<0x16, MRMSrcReg, (outs VR128:$dst), |
| 749 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 750 | "movlhps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 751 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 752 | (v4f32 (movhp VR128:$src1, VR128:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 753 | |
Evan Cheng | 7581a82 | 2009-05-12 20:17:52 +0000 | [diff] [blame] | 754 | def MOVHLPSrr : PSI<0x12, MRMSrcReg, (outs VR128:$dst), |
| 755 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 756 | "movhlps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 757 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 758 | (v4f32 (movhlps VR128:$src1, VR128:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 759 | } // AddedComplexity |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 760 | } // Constraints = "$src1 = $dst" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 761 | |
Nate Begeman | b44aad7 | 2009-04-29 22:47:44 +0000 | [diff] [blame] | 762 | let AddedComplexity = 20 in { |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 763 | def : Pat<(v4f32 (movddup VR128:$src, (undef))), |
Evan Cheng | a2497eb | 2008-09-25 20:50:48 +0000 | [diff] [blame] | 764 | (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>; |
Nate Begeman | b44aad7 | 2009-04-29 22:47:44 +0000 | [diff] [blame] | 765 | def : Pat<(v2i64 (movddup VR128:$src, (undef))), |
| 766 | (MOVLHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>; |
| 767 | } |
Evan Cheng | a2497eb | 2008-09-25 20:50:48 +0000 | [diff] [blame] | 768 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 769 | |
| 770 | |
| 771 | // Arithmetic |
| 772 | |
| 773 | /// sse1_fp_unop_rm - SSE1 unops come in both scalar and vector forms. |
| 774 | /// |
| 775 | /// In addition, we also have a special variant of the scalar form here to |
| 776 | /// represent the associated intrinsic operation. This form is unlike the |
| 777 | /// plain scalar form, in that it takes an entire vector (instead of a |
| 778 | /// scalar) and leaves the top elements undefined. |
| 779 | /// |
| 780 | /// And, we have a special variant form for a full-vector intrinsic form. |
| 781 | /// |
| 782 | /// These four forms can each have a reg or a mem operand, so there are a |
| 783 | /// total of eight "instructions". |
| 784 | /// |
| 785 | multiclass sse1_fp_unop_rm<bits<8> opc, string OpcodeStr, |
| 786 | SDNode OpNode, |
| 787 | Intrinsic F32Int, |
| 788 | Intrinsic V4F32Int, |
| 789 | bit Commutable = 0> { |
| 790 | // Scalar operation, reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 791 | def SSr : SSI<opc, MRMSrcReg, (outs FR32:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 792 | !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 793 | [(set FR32:$dst, (OpNode FR32:$src))]> { |
| 794 | let isCommutable = Commutable; |
| 795 | } |
| 796 | |
| 797 | // Scalar operation, mem. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 798 | def SSm : SSI<opc, MRMSrcMem, (outs FR32:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 799 | !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 800 | [(set FR32:$dst, (OpNode (load addr:$src)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 801 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 802 | // Vector operation, reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 803 | def PSr : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 804 | !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 805 | [(set VR128:$dst, (v4f32 (OpNode VR128:$src)))]> { |
| 806 | let isCommutable = Commutable; |
| 807 | } |
| 808 | |
| 809 | // Vector operation, mem. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 810 | def PSm : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 811 | !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"), |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 812 | [(set VR128:$dst, (OpNode (memopv4f32 addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 813 | |
| 814 | // Intrinsic operation, reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 815 | def SSr_Int : SSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 816 | !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 817 | [(set VR128:$dst, (F32Int VR128:$src))]> { |
| 818 | let isCommutable = Commutable; |
| 819 | } |
| 820 | |
| 821 | // Intrinsic operation, mem. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 822 | def SSm_Int : SSI<opc, MRMSrcMem, (outs VR128:$dst), (ins ssmem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 823 | !strconcat(OpcodeStr, "ss\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 824 | [(set VR128:$dst, (F32Int sse_load_f32:$src))]>; |
| 825 | |
| 826 | // Vector intrinsic operation, reg |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 827 | def PSr_Int : PSI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 828 | !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 829 | [(set VR128:$dst, (V4F32Int VR128:$src))]> { |
| 830 | let isCommutable = Commutable; |
| 831 | } |
| 832 | |
| 833 | // Vector intrinsic operation, mem |
Dan Gohman | c747be5 | 2007-08-02 21:06:40 +0000 | [diff] [blame] | 834 | def PSm_Int : PSI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 835 | !strconcat(OpcodeStr, "ps\t{$src, $dst|$dst, $src}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 836 | [(set VR128:$dst, (V4F32Int (memopv4f32 addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 837 | } |
| 838 | |
| 839 | // Square root. |
| 840 | defm SQRT : sse1_fp_unop_rm<0x51, "sqrt", fsqrt, |
| 841 | int_x86_sse_sqrt_ss, int_x86_sse_sqrt_ps>; |
| 842 | |
| 843 | // Reciprocal approximations. Note that these typically require refinement |
| 844 | // in order to obtain suitable precision. |
| 845 | defm RSQRT : sse1_fp_unop_rm<0x52, "rsqrt", X86frsqrt, |
| 846 | int_x86_sse_rsqrt_ss, int_x86_sse_rsqrt_ps>; |
| 847 | defm RCP : sse1_fp_unop_rm<0x53, "rcp", X86frcp, |
| 848 | int_x86_sse_rcp_ss, int_x86_sse_rcp_ps>; |
| 849 | |
| 850 | // Logical |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 851 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 852 | let isCommutable = 1 in { |
| 853 | def ANDPSrr : PSI<0x54, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 854 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 855 | "andps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 856 | [(set VR128:$dst, (v2i64 |
| 857 | (and VR128:$src1, VR128:$src2)))]>; |
| 858 | def ORPSrr : PSI<0x56, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 859 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 860 | "orps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 861 | [(set VR128:$dst, (v2i64 |
| 862 | (or VR128:$src1, VR128:$src2)))]>; |
| 863 | def XORPSrr : PSI<0x57, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 864 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 865 | "xorps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 866 | [(set VR128:$dst, (v2i64 |
| 867 | (xor VR128:$src1, VR128:$src2)))]>; |
| 868 | } |
| 869 | |
| 870 | def ANDPSrm : PSI<0x54, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 871 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 872 | "andps\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 8e92cd1 | 2007-07-19 23:34:10 +0000 | [diff] [blame] | 873 | [(set VR128:$dst, (and (bc_v2i64 (v4f32 VR128:$src1)), |
| 874 | (memopv2i64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 875 | def ORPSrm : PSI<0x56, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 876 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 877 | "orps\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 8e92cd1 | 2007-07-19 23:34:10 +0000 | [diff] [blame] | 878 | [(set VR128:$dst, (or (bc_v2i64 (v4f32 VR128:$src1)), |
| 879 | (memopv2i64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 880 | def XORPSrm : PSI<0x57, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 881 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 882 | "xorps\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 8e92cd1 | 2007-07-19 23:34:10 +0000 | [diff] [blame] | 883 | [(set VR128:$dst, (xor (bc_v2i64 (v4f32 VR128:$src1)), |
| 884 | (memopv2i64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 885 | def ANDNPSrr : PSI<0x55, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 886 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 887 | "andnps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 888 | [(set VR128:$dst, |
| 889 | (v2i64 (and (xor VR128:$src1, |
| 890 | (bc_v2i64 (v4i32 immAllOnesV))), |
| 891 | VR128:$src2)))]>; |
| 892 | def ANDNPSrm : PSI<0x55, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 893 | (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 894 | "andnps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 895 | [(set VR128:$dst, |
Evan Cheng | 8e92cd1 | 2007-07-19 23:34:10 +0000 | [diff] [blame] | 896 | (v2i64 (and (xor (bc_v2i64 (v4f32 VR128:$src1)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 897 | (bc_v2i64 (v4i32 immAllOnesV))), |
Evan Cheng | 8e92cd1 | 2007-07-19 23:34:10 +0000 | [diff] [blame] | 898 | (memopv2i64 addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 899 | } |
| 900 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 901 | let Constraints = "$src1 = $dst" in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 902 | def CMPPSrri : PSIi8<0xC2, MRMSrcReg, |
Nate Begeman | 061db5f | 2008-05-12 20:34:32 +0000 | [diff] [blame] | 903 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc), |
| 904 | "cmp${cc}ps\t{$src, $dst|$dst, $src}", |
| 905 | [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1, |
| 906 | VR128:$src, imm:$cc))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 907 | def CMPPSrmi : PSIi8<0xC2, MRMSrcMem, |
Nate Begeman | 061db5f | 2008-05-12 20:34:32 +0000 | [diff] [blame] | 908 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc), |
| 909 | "cmp${cc}ps\t{$src, $dst|$dst, $src}", |
| 910 | [(set VR128:$dst, (int_x86_sse_cmp_ps VR128:$src1, |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 911 | (memop addr:$src), imm:$cc))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 912 | } |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 913 | def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), VR128:$src2, imm:$cc)), |
| 914 | (CMPPSrri VR128:$src1, VR128:$src2, imm:$cc)>; |
| 915 | def : Pat<(v4i32 (X86cmpps (v4f32 VR128:$src1), (memop addr:$src2), imm:$cc)), |
| 916 | (CMPPSrmi VR128:$src1, addr:$src2, imm:$cc)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 917 | |
| 918 | // Shuffle and unpack instructions |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 919 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 920 | let isConvertibleToThreeAddress = 1 in // Convert to pshufd |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 921 | def SHUFPSrri : PSIi8<0xC6, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 922 | (outs VR128:$dst), (ins VR128:$src1, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 923 | VR128:$src2, i8imm:$src3), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 924 | "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 925 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 926 | (v4f32 (shufp:$src3 VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 927 | def SHUFPSrmi : PSIi8<0xC6, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 928 | (outs VR128:$dst), (ins VR128:$src1, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 929 | f128mem:$src2, i8imm:$src3), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 930 | "shufps\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 931 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 932 | (v4f32 (shufp:$src3 |
| 933 | VR128:$src1, (memopv4f32 addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 934 | |
| 935 | let AddedComplexity = 10 in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 936 | def UNPCKHPSrr : PSI<0x15, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 937 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 938 | "unpckhps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 939 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 940 | (v4f32 (unpckh VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 941 | def UNPCKHPSrm : PSI<0x15, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 942 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 943 | "unpckhps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 944 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 945 | (v4f32 (unpckh VR128:$src1, |
| 946 | (memopv4f32 addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 947 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 948 | def UNPCKLPSrr : PSI<0x14, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 949 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 950 | "unpcklps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 951 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 952 | (v4f32 (unpckl VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 953 | def UNPCKLPSrm : PSI<0x14, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 954 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 955 | "unpcklps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 956 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 957 | (unpckl VR128:$src1, (memopv4f32 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 958 | } // AddedComplexity |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 959 | } // Constraints = "$src1 = $dst" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 960 | |
| 961 | // Mask creation |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 962 | def MOVMSKPSrr : PSI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 963 | "movmskps\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 964 | [(set GR32:$dst, (int_x86_sse_movmsk_ps VR128:$src))]>; |
Evan Cheng | d8296b8 | 2009-05-28 18:55:28 +0000 | [diff] [blame] | 965 | def MOVMSKPDrr : PDI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 966 | "movmskpd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 967 | [(set GR32:$dst, (int_x86_sse2_movmsk_pd VR128:$src))]>; |
| 968 | |
Evan Cheng | d1d6807 | 2008-03-08 00:58:38 +0000 | [diff] [blame] | 969 | // Prefetch intrinsic. |
| 970 | def PREFETCHT0 : PSI<0x18, MRM1m, (outs), (ins i8mem:$src), |
| 971 | "prefetcht0\t$src", [(prefetch addr:$src, imm, (i32 3))]>; |
| 972 | def PREFETCHT1 : PSI<0x18, MRM2m, (outs), (ins i8mem:$src), |
| 973 | "prefetcht1\t$src", [(prefetch addr:$src, imm, (i32 2))]>; |
| 974 | def PREFETCHT2 : PSI<0x18, MRM3m, (outs), (ins i8mem:$src), |
| 975 | "prefetcht2\t$src", [(prefetch addr:$src, imm, (i32 1))]>; |
| 976 | def PREFETCHNTA : PSI<0x18, MRM0m, (outs), (ins i8mem:$src), |
| 977 | "prefetchnta\t$src", [(prefetch addr:$src, imm, (i32 0))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 978 | |
| 979 | // Non-temporal stores |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 980 | def MOVNTPSmr : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 981 | "movntps\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 982 | [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>; |
| 983 | |
| 984 | // Load, store, and memory fence |
Evan Cheng | 68cca15 | 2009-05-27 18:38:01 +0000 | [diff] [blame] | 985 | def SFENCE : PSI<0xAE, MRM7r, (outs), (ins), "sfence", [(int_x86_sse_sfence)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 986 | |
| 987 | // MXCSR register |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 988 | def LDMXCSR : PSI<0xAE, MRM2m, (outs), (ins i32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 989 | "ldmxcsr\t$src", [(int_x86_sse_ldmxcsr addr:$src)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 990 | def STMXCSR : PSI<0xAE, MRM3m, (outs), (ins i32mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 991 | "stmxcsr\t$dst", [(int_x86_sse_stmxcsr addr:$dst)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 992 | |
| 993 | // Alias instructions that map zero vector to pxor / xorp* for sse. |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 994 | // We set canFoldAsLoad because this can be converted to a constant-pool |
Dan Gohman | 37eb6c8 | 2008-12-03 05:21:24 +0000 | [diff] [blame] | 995 | // load of an all-zeros value if folding it would be beneficial. |
Daniel Dunbar | a0e6200 | 2009-08-11 22:17:52 +0000 | [diff] [blame] | 996 | let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, |
| 997 | isCodeGenOnly = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 998 | def V_SET0 : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 999 | "xorps\t$dst, $dst", |
Chris Lattner | e6aa386 | 2007-11-25 00:24:49 +0000 | [diff] [blame] | 1000 | [(set VR128:$dst, (v4i32 immAllZerosV))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1001 | |
Evan Cheng | a15896e | 2008-03-12 07:02:50 +0000 | [diff] [blame] | 1002 | let Predicates = [HasSSE1] in { |
| 1003 | def : Pat<(v2i64 immAllZerosV), (V_SET0)>; |
| 1004 | def : Pat<(v8i16 immAllZerosV), (V_SET0)>; |
| 1005 | def : Pat<(v16i8 immAllZerosV), (V_SET0)>; |
| 1006 | def : Pat<(v2f64 immAllZerosV), (V_SET0)>; |
| 1007 | def : Pat<(v4f32 immAllZerosV), (V_SET0)>; |
| 1008 | } |
| 1009 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1010 | // FR32 to 128-bit vector conversion. |
Evan Cheng | bd0ca9c | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 1011 | let isAsCheapAsAMove = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1012 | def MOVSS2PSrr : SSI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1013 | "movss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1014 | [(set VR128:$dst, |
| 1015 | (v4f32 (scalar_to_vector FR32:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1016 | def MOVSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1017 | "movss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1018 | [(set VR128:$dst, |
| 1019 | (v4f32 (scalar_to_vector (loadf32 addr:$src))))]>; |
| 1020 | |
| 1021 | // FIXME: may not be able to eliminate this movss with coalescing the src and |
| 1022 | // dest register classes are different. We really want to write this pattern |
| 1023 | // like this: |
| 1024 | // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))), |
| 1025 | // (f32 FR32:$src)>; |
Evan Cheng | bd0ca9c | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 1026 | let isAsCheapAsAMove = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1027 | def MOVPS2SSrr : SSI<0x10, MRMSrcReg, (outs FR32:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1028 | "movss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1029 | [(set FR32:$dst, (vector_extract (v4f32 VR128:$src), |
| 1030 | (iPTR 0)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1031 | def MOVPS2SSmr : SSI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1032 | "movss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1033 | [(store (f32 (vector_extract (v4f32 VR128:$src), |
| 1034 | (iPTR 0))), addr:$dst)]>; |
| 1035 | |
| 1036 | |
| 1037 | // Move to lower bits of a VR128, leaving upper bits alone. |
| 1038 | // Three operand (but two address) aliases. |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1039 | let Constraints = "$src1 = $dst" in { |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 1040 | let neverHasSideEffects = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1041 | def MOVLSS2PSrr : SSI<0x10, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1042 | (outs VR128:$dst), (ins VR128:$src1, FR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1043 | "movss\t{$src2, $dst|$dst, $src2}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1044 | |
| 1045 | let AddedComplexity = 15 in |
| 1046 | def MOVLPSrr : SSI<0x10, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1047 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1048 | "movss\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1049 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1050 | (v4f32 (movl VR128:$src1, VR128:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1051 | } |
| 1052 | |
| 1053 | // Move to lower bits of a VR128 and zeroing upper bits. |
| 1054 | // Loading from memory automatically zeroing upper bits. |
| 1055 | let AddedComplexity = 20 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1056 | def MOVZSS2PSrm : SSI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1057 | "movss\t{$src, $dst|$dst, $src}", |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 1058 | [(set VR128:$dst, (v4f32 (X86vzmovl (v4f32 (scalar_to_vector |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1059 | (loadf32 addr:$src))))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1060 | |
Evan Cheng | 056afe1 | 2008-05-20 18:24:47 +0000 | [diff] [blame] | 1061 | def : Pat<(v4f32 (X86vzmovl (loadv4f32 addr:$src))), |
Evan Cheng | 40ee6e5 | 2008-05-08 00:57:18 +0000 | [diff] [blame] | 1062 | (MOVZSS2PSrm addr:$src)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1063 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1064 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1065 | // SSE2 Instructions |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1066 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1067 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1068 | // Move Instructions |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 1069 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1070 | def MOVSDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1071 | "movsd\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 1072 | let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1073 | def MOVSDrm : SDI<0x10, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1074 | "movsd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1075 | [(set FR64:$dst, (loadf64 addr:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1076 | def MOVSDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1077 | "movsd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1078 | [(store FR64:$src, addr:$dst)]>; |
| 1079 | |
| 1080 | // Conversion instructions |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1081 | def CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1082 | "cvttsd2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1083 | [(set GR32:$dst, (fp_to_sint FR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1084 | def CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1085 | "cvttsd2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1086 | [(set GR32:$dst, (fp_to_sint (loadf64 addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1087 | def CVTSD2SSrr : SDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1088 | "cvtsd2ss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1089 | [(set FR32:$dst, (fround FR64:$src))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1090 | def CVTSD2SSrm : SDI<0x5A, MRMSrcMem, (outs FR32:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1091 | "cvtsd2ss\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1092 | [(set FR32:$dst, (fround (loadf64 addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1093 | def CVTSI2SDrr : SDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1094 | "cvtsi2sd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1095 | [(set FR64:$dst, (sint_to_fp GR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1096 | def CVTSI2SDrm : SDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1097 | "cvtsi2sd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1098 | [(set FR64:$dst, (sint_to_fp (loadi32 addr:$src)))]>; |
| 1099 | |
Sean Callanan | 3d5824c | 2009-09-16 01:13:52 +0000 | [diff] [blame] | 1100 | def CVTPD2DQrm : S3DI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
| 1101 | "cvtpd2dq\t{$src, $dst|$dst, $src}", []>; |
| 1102 | def CVTPD2DQrr : S3DI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
| 1103 | "cvtpd2dq\t{$src, $dst|$dst, $src}", []>; |
| 1104 | def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
| 1105 | "cvtdq2pd\t{$src, $dst|$dst, $src}", []>; |
| 1106 | def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
| 1107 | "cvtdq2pd\t{$src, $dst|$dst, $src}", []>; |
| 1108 | def CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
| 1109 | "cvtps2dq\t{$src, $dst|$dst, $src}", []>; |
| 1110 | def CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
| 1111 | "cvtps2dq\t{$src, $dst|$dst, $src}", []>; |
| 1112 | def CVTDQ2PSrr : PSI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
| 1113 | "cvtdq2ps\t{$src, $dst|$dst, $src}", []>; |
| 1114 | def CVTDQ2PSrm : PSI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
| 1115 | "cvtdq2ps\t{$src, $dst|$dst, $src}", []>; |
| 1116 | def COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2), |
| 1117 | "comisd\t{$src2, $src1|$src1, $src2}", []>; |
| 1118 | def COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2), |
| 1119 | "comisd\t{$src2, $src1|$src1, $src2}", []>; |
| 1120 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1121 | // SSE2 instructions with XS prefix |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1122 | def CVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1123 | "cvtss2sd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1124 | [(set FR64:$dst, (fextend FR32:$src))]>, XS, |
| 1125 | Requires<[HasSSE2]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1126 | def CVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1127 | "cvtss2sd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1128 | [(set FR64:$dst, (extloadf32 addr:$src))]>, XS, |
| 1129 | Requires<[HasSSE2]>; |
| 1130 | |
| 1131 | // Match intrinsics which expect XMM operand(s). |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1132 | def Int_CVTSD2SIrr : SDI<0x2D, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1133 | "cvtsd2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1134 | [(set GR32:$dst, (int_x86_sse2_cvtsd2si VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1135 | def Int_CVTSD2SIrm : SDI<0x2D, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1136 | "cvtsd2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1137 | [(set GR32:$dst, (int_x86_sse2_cvtsd2si |
| 1138 | (load addr:$src)))]>; |
| 1139 | |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 1140 | // Match intrinisics which expect MM and XMM operand(s). |
| 1141 | def Int_CVTPD2PIrr : PDI<0x2D, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src), |
| 1142 | "cvtpd2pi\t{$src, $dst|$dst, $src}", |
| 1143 | [(set VR64:$dst, (int_x86_sse_cvtpd2pi VR128:$src))]>; |
| 1144 | def Int_CVTPD2PIrm : PDI<0x2D, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src), |
| 1145 | "cvtpd2pi\t{$src, $dst|$dst, $src}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1146 | [(set VR64:$dst, (int_x86_sse_cvtpd2pi |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1147 | (memop addr:$src)))]>; |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 1148 | def Int_CVTTPD2PIrr: PDI<0x2C, MRMSrcReg, (outs VR64:$dst), (ins VR128:$src), |
| 1149 | "cvttpd2pi\t{$src, $dst|$dst, $src}", |
| 1150 | [(set VR64:$dst, (int_x86_sse_cvttpd2pi VR128:$src))]>; |
| 1151 | def Int_CVTTPD2PIrm: PDI<0x2C, MRMSrcMem, (outs VR64:$dst), (ins f128mem:$src), |
| 1152 | "cvttpd2pi\t{$src, $dst|$dst, $src}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1153 | [(set VR64:$dst, (int_x86_sse_cvttpd2pi |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1154 | (memop addr:$src)))]>; |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 1155 | def Int_CVTPI2PDrr : PDI<0x2A, MRMSrcReg, (outs VR128:$dst), (ins VR64:$src), |
| 1156 | "cvtpi2pd\t{$src, $dst|$dst, $src}", |
| 1157 | [(set VR128:$dst, (int_x86_sse_cvtpi2pd VR64:$src))]>; |
| 1158 | def Int_CVTPI2PDrm : PDI<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src), |
| 1159 | "cvtpi2pd\t{$src, $dst|$dst, $src}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1160 | [(set VR128:$dst, (int_x86_sse_cvtpi2pd |
Dale Johannesen | 1fbb4a5 | 2007-10-30 22:15:38 +0000 | [diff] [blame] | 1161 | (load addr:$src)))]>; |
| 1162 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1163 | // Aliases for intrinsics |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1164 | def Int_CVTTSD2SIrr : SDI<0x2C, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1165 | "cvttsd2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1166 | [(set GR32:$dst, |
| 1167 | (int_x86_sse2_cvttsd2si VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1168 | def Int_CVTTSD2SIrm : SDI<0x2C, MRMSrcMem, (outs GR32:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1169 | "cvttsd2si\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1170 | [(set GR32:$dst, (int_x86_sse2_cvttsd2si |
| 1171 | (load addr:$src)))]>; |
| 1172 | |
| 1173 | // Comparison instructions |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1174 | let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1175 | def CMPSDrr : SDIi8<0xC2, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1176 | (outs FR64:$dst), (ins FR64:$src1, FR64:$src, SSECC:$cc), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1177 | "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>; |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 1178 | let mayLoad = 1 in |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1179 | def CMPSDrm : SDIi8<0xC2, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1180 | (outs FR64:$dst), (ins FR64:$src1, f64mem:$src, SSECC:$cc), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1181 | "cmp${cc}sd\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1182 | } |
| 1183 | |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1184 | let Defs = [EFLAGS] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1185 | def UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins FR64:$src1, FR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1186 | "ucomisd\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1187 | [(X86cmp FR64:$src1, FR64:$src2), (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1188 | def UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs), (ins FR64:$src1, f64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1189 | "ucomisd\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1190 | [(X86cmp FR64:$src1, (loadf64 addr:$src2)), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1191 | (implicit EFLAGS)]>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 1192 | } // Defs = [EFLAGS] |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1193 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1194 | // Aliases to match intrinsics which expect XMM operand(s). |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1195 | let Constraints = "$src1 = $dst" in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1196 | def Int_CMPSDrr : SDIi8<0xC2, MRMSrcReg, |
| 1197 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src, |
| 1198 | SSECC:$cc), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1199 | "cmp${cc}sd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1200 | [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1, |
| 1201 | VR128:$src, imm:$cc))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1202 | def Int_CMPSDrm : SDIi8<0xC2, MRMSrcMem, |
| 1203 | (outs VR128:$dst), (ins VR128:$src1, f64mem:$src, |
| 1204 | SSECC:$cc), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1205 | "cmp${cc}sd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1206 | [(set VR128:$dst, (int_x86_sse2_cmp_sd VR128:$src1, |
| 1207 | (load addr:$src), imm:$cc))]>; |
| 1208 | } |
| 1209 | |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1210 | let Defs = [EFLAGS] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1211 | def Int_UCOMISDrr: PDI<0x2E, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1212 | "ucomisd\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1213 | [(X86ucomi (v2f64 VR128:$src1), (v2f64 VR128:$src2)), |
| 1214 | (implicit EFLAGS)]>; |
| 1215 | def Int_UCOMISDrm: PDI<0x2E, MRMSrcMem, (outs),(ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1216 | "ucomisd\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1217 | [(X86ucomi (v2f64 VR128:$src1), (load addr:$src2)), |
| 1218 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1219 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1220 | def Int_COMISDrr: PDI<0x2F, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1221 | "comisd\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1222 | [(X86comi (v2f64 VR128:$src1), (v2f64 VR128:$src2)), |
| 1223 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1224 | def Int_COMISDrm: PDI<0x2F, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1225 | "comisd\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1226 | [(X86comi (v2f64 VR128:$src1), (load addr:$src2)), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1227 | (implicit EFLAGS)]>; |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 1228 | } // Defs = [EFLAGS] |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1229 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1230 | // Aliases of packed SSE2 instructions for scalar use. These all have names |
| 1231 | // that start with 'Fs'. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1232 | |
| 1233 | // Alias instructions that map fld0 to pxor for sse. |
Dan Gohman | 51dbce6 | 2009-09-21 18:30:38 +0000 | [diff] [blame] | 1234 | let isReMaterializable = 1, isAsCheapAsAMove = 1, isCodeGenOnly = 1, |
| 1235 | canFoldAsLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1236 | def FsFLD0SD : I<0xEF, MRMInitReg, (outs FR64:$dst), (ins), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1237 | "pxor\t$dst, $dst", [(set FR64:$dst, fpimm0)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1238 | Requires<[HasSSE2]>, TB, OpSize; |
| 1239 | |
| 1240 | // Alias instruction to do FR64 reg-to-reg copy using movapd. Upper bits are |
| 1241 | // disregarded. |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 1242 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1243 | def FsMOVAPDrr : PDI<0x28, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1244 | "movapd\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1245 | |
| 1246 | // Alias instruction to load FR64 from f128mem using movapd. Upper bits are |
| 1247 | // disregarded. |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 1248 | let canFoldAsLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1249 | def FsMOVAPDrm : PDI<0x28, MRMSrcMem, (outs FR64:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1250 | "movapd\t{$src, $dst|$dst, $src}", |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 1251 | [(set FR64:$dst, (alignedloadfsf64 addr:$src))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1252 | |
| 1253 | // Alias bitwise logical operations using SSE logical ops on packed FP values. |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1254 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1255 | let isCommutable = 1 in { |
Evan Cheng | 0e3e01d | 2008-05-02 07:53:32 +0000 | [diff] [blame] | 1256 | def FsANDPDrr : PDI<0x54, MRMSrcReg, (outs FR64:$dst), |
| 1257 | (ins FR64:$src1, FR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1258 | "andpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1259 | [(set FR64:$dst, (X86fand FR64:$src1, FR64:$src2))]>; |
Evan Cheng | 0e3e01d | 2008-05-02 07:53:32 +0000 | [diff] [blame] | 1260 | def FsORPDrr : PDI<0x56, MRMSrcReg, (outs FR64:$dst), |
| 1261 | (ins FR64:$src1, FR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1262 | "orpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1263 | [(set FR64:$dst, (X86for FR64:$src1, FR64:$src2))]>; |
Evan Cheng | 0e3e01d | 2008-05-02 07:53:32 +0000 | [diff] [blame] | 1264 | def FsXORPDrr : PDI<0x57, MRMSrcReg, (outs FR64:$dst), |
| 1265 | (ins FR64:$src1, FR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1266 | "xorpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1267 | [(set FR64:$dst, (X86fxor FR64:$src1, FR64:$src2))]>; |
| 1268 | } |
| 1269 | |
Evan Cheng | 0e3e01d | 2008-05-02 07:53:32 +0000 | [diff] [blame] | 1270 | def FsANDPDrm : PDI<0x54, MRMSrcMem, (outs FR64:$dst), |
| 1271 | (ins FR64:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1272 | "andpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1273 | [(set FR64:$dst, (X86fand FR64:$src1, |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 1274 | (memopfsf64 addr:$src2)))]>; |
Evan Cheng | 0e3e01d | 2008-05-02 07:53:32 +0000 | [diff] [blame] | 1275 | def FsORPDrm : PDI<0x56, MRMSrcMem, (outs FR64:$dst), |
| 1276 | (ins FR64:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1277 | "orpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1278 | [(set FR64:$dst, (X86for FR64:$src1, |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 1279 | (memopfsf64 addr:$src2)))]>; |
Evan Cheng | 0e3e01d | 2008-05-02 07:53:32 +0000 | [diff] [blame] | 1280 | def FsXORPDrm : PDI<0x57, MRMSrcMem, (outs FR64:$dst), |
| 1281 | (ins FR64:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1282 | "xorpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1283 | [(set FR64:$dst, (X86fxor FR64:$src1, |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 1284 | (memopfsf64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1285 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 1286 | let neverHasSideEffects = 1 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1287 | def FsANDNPDrr : PDI<0x55, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1288 | (outs FR64:$dst), (ins FR64:$src1, FR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1289 | "andnpd\t{$src2, $dst|$dst, $src2}", []>; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 1290 | let mayLoad = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1291 | def FsANDNPDrm : PDI<0x55, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1292 | (outs FR64:$dst), (ins FR64:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1293 | "andnpd\t{$src2, $dst|$dst, $src2}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1294 | } |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 1295 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1296 | |
| 1297 | /// basic_sse2_fp_binop_rm - SSE2 binops come in both scalar and vector forms. |
| 1298 | /// |
| 1299 | /// In addition, we also have a special variant of the scalar form here to |
| 1300 | /// represent the associated intrinsic operation. This form is unlike the |
| 1301 | /// plain scalar form, in that it takes an entire vector (instead of a scalar) |
Evan Cheng | 5d5dbbc | 2009-02-26 03:12:02 +0000 | [diff] [blame] | 1302 | /// and leaves the top elements unmodified (therefore these cannot be commuted). |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1303 | /// |
| 1304 | /// These three forms can each be reg+reg or reg+mem, so there are a total of |
| 1305 | /// six "instructions". |
| 1306 | /// |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1307 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1308 | multiclass basic_sse2_fp_binop_rm<bits<8> opc, string OpcodeStr, |
| 1309 | SDNode OpNode, Intrinsic F64Int, |
| 1310 | bit Commutable = 0> { |
| 1311 | // Scalar operation, reg+reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1312 | def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1313 | !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1314 | [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> { |
| 1315 | let isCommutable = Commutable; |
| 1316 | } |
| 1317 | |
| 1318 | // Scalar operation, reg+mem. |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 1319 | def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), |
| 1320 | (ins FR64:$src1, f64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1321 | !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1322 | [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1323 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1324 | // Vector operation, reg+reg. |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 1325 | def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), |
| 1326 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1327 | !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1328 | [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> { |
| 1329 | let isCommutable = Commutable; |
| 1330 | } |
| 1331 | |
| 1332 | // Vector operation, reg+mem. |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 1333 | def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), |
| 1334 | (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1335 | !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 1336 | [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1337 | |
| 1338 | // Intrinsic operation, reg+reg. |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 1339 | def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), |
| 1340 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1341 | !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"), |
Evan Cheng | 5d5dbbc | 2009-02-26 03:12:02 +0000 | [diff] [blame] | 1342 | [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1343 | |
| 1344 | // Intrinsic operation, reg+mem. |
Dan Gohman | f221da1 | 2009-01-09 02:27:34 +0000 | [diff] [blame] | 1345 | def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), |
| 1346 | (ins VR128:$src1, sdmem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1347 | !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1348 | [(set VR128:$dst, (F64Int VR128:$src1, |
| 1349 | sse_load_f64:$src2))]>; |
| 1350 | } |
| 1351 | } |
| 1352 | |
| 1353 | // Arithmetic instructions |
| 1354 | defm ADD : basic_sse2_fp_binop_rm<0x58, "add", fadd, int_x86_sse2_add_sd, 1>; |
| 1355 | defm MUL : basic_sse2_fp_binop_rm<0x59, "mul", fmul, int_x86_sse2_mul_sd, 1>; |
| 1356 | defm SUB : basic_sse2_fp_binop_rm<0x5C, "sub", fsub, int_x86_sse2_sub_sd>; |
| 1357 | defm DIV : basic_sse2_fp_binop_rm<0x5E, "div", fdiv, int_x86_sse2_div_sd>; |
| 1358 | |
| 1359 | /// sse2_fp_binop_rm - Other SSE2 binops |
| 1360 | /// |
| 1361 | /// This multiclass is like basic_sse2_fp_binop_rm, with the addition of |
| 1362 | /// instructions for a full-vector intrinsic form. Operations that map |
| 1363 | /// onto C operators don't use this form since they just use the plain |
| 1364 | /// vector form instead of having a separate vector intrinsic form. |
| 1365 | /// |
| 1366 | /// This provides a total of eight "instructions". |
| 1367 | /// |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1368 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1369 | multiclass sse2_fp_binop_rm<bits<8> opc, string OpcodeStr, |
| 1370 | SDNode OpNode, |
| 1371 | Intrinsic F64Int, |
| 1372 | Intrinsic V2F64Int, |
| 1373 | bit Commutable = 0> { |
| 1374 | |
| 1375 | // Scalar operation, reg+reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1376 | def SDrr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src1, FR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1377 | !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1378 | [(set FR64:$dst, (OpNode FR64:$src1, FR64:$src2))]> { |
| 1379 | let isCommutable = Commutable; |
| 1380 | } |
| 1381 | |
| 1382 | // Scalar operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1383 | def SDrm : SDI<opc, MRMSrcMem, (outs FR64:$dst), |
| 1384 | (ins FR64:$src1, f64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1385 | !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1386 | [(set FR64:$dst, (OpNode FR64:$src1, (load addr:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1387 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1388 | // Vector operation, reg+reg. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1389 | def PDrr : PDI<opc, MRMSrcReg, (outs VR128:$dst), |
| 1390 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1391 | !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1392 | [(set VR128:$dst, (v2f64 (OpNode VR128:$src1, VR128:$src2)))]> { |
| 1393 | let isCommutable = Commutable; |
| 1394 | } |
| 1395 | |
| 1396 | // Vector operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1397 | def PDrm : PDI<opc, MRMSrcMem, (outs VR128:$dst), |
| 1398 | (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1399 | !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1400 | [(set VR128:$dst, (OpNode VR128:$src1, (memopv2f64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1401 | |
| 1402 | // Intrinsic operation, reg+reg. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1403 | def SDrr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), |
| 1404 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1405 | !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1406 | [(set VR128:$dst, (F64Int VR128:$src1, VR128:$src2))]> { |
| 1407 | let isCommutable = Commutable; |
| 1408 | } |
| 1409 | |
| 1410 | // Intrinsic operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1411 | def SDrm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), |
| 1412 | (ins VR128:$src1, sdmem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1413 | !strconcat(OpcodeStr, "sd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1414 | [(set VR128:$dst, (F64Int VR128:$src1, |
| 1415 | sse_load_f64:$src2))]>; |
| 1416 | |
| 1417 | // Vector intrinsic operation, reg+reg. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1418 | def PDrr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), |
| 1419 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1420 | !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1421 | [(set VR128:$dst, (V2F64Int VR128:$src1, VR128:$src2))]> { |
| 1422 | let isCommutable = Commutable; |
| 1423 | } |
| 1424 | |
| 1425 | // Vector intrinsic operation, reg+mem. |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1426 | def PDrm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), |
| 1427 | (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1428 | !strconcat(OpcodeStr, "pd\t{$src2, $dst|$dst, $src2}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1429 | [(set VR128:$dst, (V2F64Int VR128:$src1, |
| 1430 | (memopv2f64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1431 | } |
| 1432 | } |
| 1433 | |
| 1434 | defm MAX : sse2_fp_binop_rm<0x5F, "max", X86fmax, |
| 1435 | int_x86_sse2_max_sd, int_x86_sse2_max_pd>; |
| 1436 | defm MIN : sse2_fp_binop_rm<0x5D, "min", X86fmin, |
| 1437 | int_x86_sse2_min_sd, int_x86_sse2_min_pd>; |
| 1438 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1439 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1440 | // SSE packed FP Instructions |
| 1441 | |
| 1442 | // Move Instructions |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 1443 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1444 | def MOVAPDrr : PDI<0x28, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1445 | "movapd\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 1446 | let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1447 | def MOVAPDrm : PDI<0x28, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1448 | "movapd\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1449 | [(set VR128:$dst, (alignedloadv2f64 addr:$src))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1450 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1451 | def MOVAPDmr : PDI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1452 | "movapd\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1453 | [(alignedstore (v2f64 VR128:$src), addr:$dst)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1454 | |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 1455 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1456 | def MOVUPDrr : PDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1457 | "movupd\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 1458 | let canFoldAsLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1459 | def MOVUPDrm : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1460 | "movupd\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1461 | [(set VR128:$dst, (loadv2f64 addr:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1462 | def MOVUPDmr : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1463 | "movupd\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1464 | [(store (v2f64 VR128:$src), addr:$dst)]>; |
| 1465 | |
| 1466 | // Intrinsic forms of MOVUPD load and store |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1467 | def MOVUPDrm_Int : PDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1468 | "movupd\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1469 | [(set VR128:$dst, (int_x86_sse2_loadu_pd addr:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1470 | def MOVUPDmr_Int : PDI<0x11, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1471 | "movupd\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1472 | [(int_x86_sse2_storeu_pd addr:$dst, VR128:$src)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1473 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1474 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1475 | let AddedComplexity = 20 in { |
| 1476 | def MOVLPDrm : PDI<0x12, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1477 | (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1478 | "movlpd\t{$src2, $dst|$dst, $src2}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1479 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1480 | (v2f64 (movlp VR128:$src1, |
| 1481 | (scalar_to_vector (loadf64 addr:$src2)))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1482 | def MOVHPDrm : PDI<0x16, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1483 | (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1484 | "movhpd\t{$src2, $dst|$dst, $src2}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1485 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1486 | (v2f64 (movhp VR128:$src1, |
| 1487 | (scalar_to_vector (loadf64 addr:$src2)))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1488 | } // AddedComplexity |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1489 | } // Constraints = "$src1 = $dst" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1490 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1491 | def MOVLPDmr : PDI<0x13, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1492 | "movlpd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1493 | [(store (f64 (vector_extract (v2f64 VR128:$src), |
| 1494 | (iPTR 0))), addr:$dst)]>; |
| 1495 | |
| 1496 | // v2f64 extract element 1 is always custom lowered to unpack high to low |
| 1497 | // and extract element 0 so the non-store version isn't too horrible. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1498 | def MOVHPDmr : PDI<0x17, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1499 | "movhpd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1500 | [(store (f64 (vector_extract |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1501 | (v2f64 (unpckh VR128:$src, (undef))), |
| 1502 | (iPTR 0))), addr:$dst)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1503 | |
| 1504 | // SSE2 instructions without OpSize prefix |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1505 | def Int_CVTDQ2PSrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1506 | "cvtdq2ps\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1507 | [(set VR128:$dst, (int_x86_sse2_cvtdq2ps VR128:$src))]>, |
| 1508 | TB, Requires<[HasSSE2]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1509 | def Int_CVTDQ2PSrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), |
Evan Cheng | 14c97c3 | 2008-03-14 07:46:48 +0000 | [diff] [blame] | 1510 | "cvtdq2ps\t{$src, $dst|$dst, $src}", |
| 1511 | [(set VR128:$dst, (int_x86_sse2_cvtdq2ps |
| 1512 | (bitconvert (memopv2i64 addr:$src))))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1513 | TB, Requires<[HasSSE2]>; |
| 1514 | |
| 1515 | // SSE2 instructions with XS prefix |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1516 | def Int_CVTDQ2PDrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1517 | "cvtdq2pd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1518 | [(set VR128:$dst, (int_x86_sse2_cvtdq2pd VR128:$src))]>, |
| 1519 | XS, Requires<[HasSSE2]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1520 | def Int_CVTDQ2PDrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src), |
Evan Cheng | 14c97c3 | 2008-03-14 07:46:48 +0000 | [diff] [blame] | 1521 | "cvtdq2pd\t{$src, $dst|$dst, $src}", |
| 1522 | [(set VR128:$dst, (int_x86_sse2_cvtdq2pd |
| 1523 | (bitconvert (memopv2i64 addr:$src))))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1524 | XS, Requires<[HasSSE2]>; |
| 1525 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1526 | def Int_CVTPS2DQrr : PDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Evan Cheng | 14c97c3 | 2008-03-14 07:46:48 +0000 | [diff] [blame] | 1527 | "cvtps2dq\t{$src, $dst|$dst, $src}", |
| 1528 | [(set VR128:$dst, (int_x86_sse2_cvtps2dq VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1529 | def Int_CVTPS2DQrm : PDI<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1530 | "cvtps2dq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1531 | [(set VR128:$dst, (int_x86_sse2_cvtps2dq |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1532 | (memop addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1533 | // SSE2 packed instructions with XS prefix |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1534 | def Int_CVTTPS2DQrr : I<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1535 | "cvttps2dq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1536 | [(set VR128:$dst, (int_x86_sse2_cvttps2dq VR128:$src))]>, |
| 1537 | XS, Requires<[HasSSE2]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1538 | def Int_CVTTPS2DQrm : I<0x5B, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1539 | "cvttps2dq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1540 | [(set VR128:$dst, (int_x86_sse2_cvttps2dq |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1541 | (memop addr:$src)))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1542 | XS, Requires<[HasSSE2]>; |
| 1543 | |
| 1544 | // SSE2 packed instructions with XD prefix |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1545 | def Int_CVTPD2DQrr : I<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1546 | "cvtpd2dq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1547 | [(set VR128:$dst, (int_x86_sse2_cvtpd2dq VR128:$src))]>, |
| 1548 | XD, Requires<[HasSSE2]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1549 | def Int_CVTPD2DQrm : I<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1550 | "cvtpd2dq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1551 | [(set VR128:$dst, (int_x86_sse2_cvtpd2dq |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1552 | (memop addr:$src)))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1553 | XD, Requires<[HasSSE2]>; |
| 1554 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1555 | def Int_CVTTPD2DQrr : PDI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1556 | "cvttpd2dq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1557 | [(set VR128:$dst, (int_x86_sse2_cvttpd2dq VR128:$src))]>; |
Evan Cheng | 14c97c3 | 2008-03-14 07:46:48 +0000 | [diff] [blame] | 1558 | def Int_CVTTPD2DQrm : PDI<0xE6, MRMSrcMem, (outs VR128:$dst),(ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1559 | "cvttpd2dq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1560 | [(set VR128:$dst, (int_x86_sse2_cvttpd2dq |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1561 | (memop addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1562 | |
| 1563 | // SSE2 instructions without OpSize prefix |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1564 | def Int_CVTPS2PDrr : I<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1565 | "cvtps2pd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1566 | [(set VR128:$dst, (int_x86_sse2_cvtps2pd VR128:$src))]>, |
| 1567 | TB, Requires<[HasSSE2]>; |
Mon P Wang | aa3f266 | 2008-05-28 00:42:27 +0000 | [diff] [blame] | 1568 | def Int_CVTPS2PDrm : I<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1569 | "cvtps2pd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1570 | [(set VR128:$dst, (int_x86_sse2_cvtps2pd |
| 1571 | (load addr:$src)))]>, |
| 1572 | TB, Requires<[HasSSE2]>; |
| 1573 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1574 | def Int_CVTPD2PSrr : PDI<0x5A, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1575 | "cvtpd2ps\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1576 | [(set VR128:$dst, (int_x86_sse2_cvtpd2ps VR128:$src))]>; |
Mon P Wang | aa3f266 | 2008-05-28 00:42:27 +0000 | [diff] [blame] | 1577 | def Int_CVTPD2PSrm : PDI<0x5A, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1578 | "cvtpd2ps\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1579 | [(set VR128:$dst, (int_x86_sse2_cvtpd2ps |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1580 | (memop addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1581 | |
| 1582 | // Match intrinsics which expect XMM operand(s). |
| 1583 | // Aliases for intrinsics |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1584 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1585 | def Int_CVTSI2SDrr: SDI<0x2A, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1586 | (outs VR128:$dst), (ins VR128:$src1, GR32:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1587 | "cvtsi2sd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1588 | [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1, |
| 1589 | GR32:$src2))]>; |
| 1590 | def Int_CVTSI2SDrm: SDI<0x2A, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1591 | (outs VR128:$dst), (ins VR128:$src1, i32mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1592 | "cvtsi2sd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1593 | [(set VR128:$dst, (int_x86_sse2_cvtsi2sd VR128:$src1, |
| 1594 | (loadi32 addr:$src2)))]>; |
| 1595 | def Int_CVTSD2SSrr: SDI<0x5A, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1596 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1597 | "cvtsd2ss\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1598 | [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1, |
| 1599 | VR128:$src2))]>; |
| 1600 | def Int_CVTSD2SSrm: SDI<0x5A, MRMSrcMem, |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1601 | (outs VR128:$dst), (ins VR128:$src1, f64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1602 | "cvtsd2ss\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1603 | [(set VR128:$dst, (int_x86_sse2_cvtsd2ss VR128:$src1, |
| 1604 | (load addr:$src2)))]>; |
| 1605 | def Int_CVTSS2SDrr: I<0x5A, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1606 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1607 | "cvtss2sd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1608 | [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1, |
| 1609 | VR128:$src2))]>, XS, |
| 1610 | Requires<[HasSSE2]>; |
| 1611 | def Int_CVTSS2SDrm: I<0x5A, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1612 | (outs VR128:$dst), (ins VR128:$src1, f32mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1613 | "cvtss2sd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1614 | [(set VR128:$dst, (int_x86_sse2_cvtss2sd VR128:$src1, |
| 1615 | (load addr:$src2)))]>, XS, |
| 1616 | Requires<[HasSSE2]>; |
| 1617 | } |
| 1618 | |
| 1619 | // Arithmetic |
| 1620 | |
| 1621 | /// sse2_fp_unop_rm - SSE2 unops come in both scalar and vector forms. |
| 1622 | /// |
| 1623 | /// In addition, we also have a special variant of the scalar form here to |
| 1624 | /// represent the associated intrinsic operation. This form is unlike the |
| 1625 | /// plain scalar form, in that it takes an entire vector (instead of a |
| 1626 | /// scalar) and leaves the top elements undefined. |
| 1627 | /// |
| 1628 | /// And, we have a special variant form for a full-vector intrinsic form. |
| 1629 | /// |
| 1630 | /// These four forms can each have a reg or a mem operand, so there are a |
| 1631 | /// total of eight "instructions". |
| 1632 | /// |
| 1633 | multiclass sse2_fp_unop_rm<bits<8> opc, string OpcodeStr, |
| 1634 | SDNode OpNode, |
| 1635 | Intrinsic F64Int, |
| 1636 | Intrinsic V2F64Int, |
| 1637 | bit Commutable = 0> { |
| 1638 | // Scalar operation, reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1639 | def SDr : SDI<opc, MRMSrcReg, (outs FR64:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1640 | !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1641 | [(set FR64:$dst, (OpNode FR64:$src))]> { |
| 1642 | let isCommutable = Commutable; |
| 1643 | } |
| 1644 | |
| 1645 | // Scalar operation, mem. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1646 | def SDm : SDI<opc, MRMSrcMem, (outs FR64:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1647 | !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1648 | [(set FR64:$dst, (OpNode (load addr:$src)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1649 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1650 | // Vector operation, reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1651 | def PDr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1652 | !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1653 | [(set VR128:$dst, (v2f64 (OpNode VR128:$src)))]> { |
| 1654 | let isCommutable = Commutable; |
| 1655 | } |
| 1656 | |
| 1657 | // Vector operation, mem. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1658 | def PDm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1659 | !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"), |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1660 | [(set VR128:$dst, (OpNode (memopv2f64 addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1661 | |
| 1662 | // Intrinsic operation, reg. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1663 | def SDr_Int : SDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1664 | !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1665 | [(set VR128:$dst, (F64Int VR128:$src))]> { |
| 1666 | let isCommutable = Commutable; |
| 1667 | } |
| 1668 | |
| 1669 | // Intrinsic operation, mem. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1670 | def SDm_Int : SDI<opc, MRMSrcMem, (outs VR128:$dst), (ins sdmem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1671 | !strconcat(OpcodeStr, "sd\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1672 | [(set VR128:$dst, (F64Int sse_load_f64:$src))]>; |
| 1673 | |
| 1674 | // Vector intrinsic operation, reg |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1675 | def PDr_Int : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1676 | !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1677 | [(set VR128:$dst, (V2F64Int VR128:$src))]> { |
| 1678 | let isCommutable = Commutable; |
| 1679 | } |
| 1680 | |
| 1681 | // Vector intrinsic operation, mem |
Dan Gohman | c747be5 | 2007-08-02 21:06:40 +0000 | [diff] [blame] | 1682 | def PDm_Int : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1683 | !strconcat(OpcodeStr, "pd\t{$src, $dst|$dst, $src}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1684 | [(set VR128:$dst, (V2F64Int (memopv2f64 addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1685 | } |
| 1686 | |
| 1687 | // Square root. |
| 1688 | defm SQRT : sse2_fp_unop_rm<0x51, "sqrt", fsqrt, |
| 1689 | int_x86_sse2_sqrt_sd, int_x86_sse2_sqrt_pd>; |
| 1690 | |
| 1691 | // There is no f64 version of the reciprocal approximation instructions. |
| 1692 | |
| 1693 | // Logical |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1694 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1695 | let isCommutable = 1 in { |
| 1696 | def ANDPDrr : PDI<0x54, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1697 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1698 | "andpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1699 | [(set VR128:$dst, |
| 1700 | (and (bc_v2i64 (v2f64 VR128:$src1)), |
| 1701 | (bc_v2i64 (v2f64 VR128:$src2))))]>; |
| 1702 | def ORPDrr : PDI<0x56, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1703 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1704 | "orpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1705 | [(set VR128:$dst, |
| 1706 | (or (bc_v2i64 (v2f64 VR128:$src1)), |
| 1707 | (bc_v2i64 (v2f64 VR128:$src2))))]>; |
| 1708 | def XORPDrr : PDI<0x57, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1709 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1710 | "xorpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1711 | [(set VR128:$dst, |
| 1712 | (xor (bc_v2i64 (v2f64 VR128:$src1)), |
| 1713 | (bc_v2i64 (v2f64 VR128:$src2))))]>; |
| 1714 | } |
| 1715 | |
| 1716 | def ANDPDrm : PDI<0x54, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1717 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1718 | "andpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1719 | [(set VR128:$dst, |
| 1720 | (and (bc_v2i64 (v2f64 VR128:$src1)), |
Evan Cheng | 8e92cd1 | 2007-07-19 23:34:10 +0000 | [diff] [blame] | 1721 | (memopv2i64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1722 | def ORPDrm : PDI<0x56, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1723 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1724 | "orpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1725 | [(set VR128:$dst, |
| 1726 | (or (bc_v2i64 (v2f64 VR128:$src1)), |
Evan Cheng | 8e92cd1 | 2007-07-19 23:34:10 +0000 | [diff] [blame] | 1727 | (memopv2i64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1728 | def XORPDrm : PDI<0x57, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1729 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1730 | "xorpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1731 | [(set VR128:$dst, |
| 1732 | (xor (bc_v2i64 (v2f64 VR128:$src1)), |
Evan Cheng | 8e92cd1 | 2007-07-19 23:34:10 +0000 | [diff] [blame] | 1733 | (memopv2i64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1734 | def ANDNPDrr : PDI<0x55, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1735 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1736 | "andnpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1737 | [(set VR128:$dst, |
| 1738 | (and (vnot (bc_v2i64 (v2f64 VR128:$src1))), |
| 1739 | (bc_v2i64 (v2f64 VR128:$src2))))]>; |
| 1740 | def ANDNPDrm : PDI<0x55, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1741 | (outs VR128:$dst), (ins VR128:$src1,f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1742 | "andnpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1743 | [(set VR128:$dst, |
| 1744 | (and (vnot (bc_v2i64 (v2f64 VR128:$src1))), |
Evan Cheng | 8e92cd1 | 2007-07-19 23:34:10 +0000 | [diff] [blame] | 1745 | (memopv2i64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1746 | } |
| 1747 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1748 | let Constraints = "$src1 = $dst" in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1749 | def CMPPDrri : PDIi8<0xC2, MRMSrcReg, |
Evan Cheng | 14c97c3 | 2008-03-14 07:46:48 +0000 | [diff] [blame] | 1750 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc), |
| 1751 | "cmp${cc}pd\t{$src, $dst|$dst, $src}", |
| 1752 | [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1, |
Nate Begeman | 061db5f | 2008-05-12 20:34:32 +0000 | [diff] [blame] | 1753 | VR128:$src, imm:$cc))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1754 | def CMPPDrmi : PDIi8<0xC2, MRMSrcMem, |
Evan Cheng | 14c97c3 | 2008-03-14 07:46:48 +0000 | [diff] [blame] | 1755 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src, SSECC:$cc), |
| 1756 | "cmp${cc}pd\t{$src, $dst|$dst, $src}", |
| 1757 | [(set VR128:$dst, (int_x86_sse2_cmp_pd VR128:$src1, |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 1758 | (memop addr:$src), imm:$cc))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1759 | } |
Evan Cheng | 3375409 | 2008-08-05 22:19:15 +0000 | [diff] [blame] | 1760 | def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), VR128:$src2, imm:$cc)), |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 1761 | (CMPPDrri VR128:$src1, VR128:$src2, imm:$cc)>; |
Evan Cheng | 3375409 | 2008-08-05 22:19:15 +0000 | [diff] [blame] | 1762 | def : Pat<(v2i64 (X86cmppd (v2f64 VR128:$src1), (memop addr:$src2), imm:$cc)), |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 1763 | (CMPPDrmi VR128:$src1, addr:$src2, imm:$cc)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1764 | |
| 1765 | // Shuffle and unpack instructions |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1766 | let Constraints = "$src1 = $dst" in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1767 | def SHUFPDrri : PDIi8<0xC6, MRMSrcReg, |
Evan Cheng | 14c97c3 | 2008-03-14 07:46:48 +0000 | [diff] [blame] | 1768 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2, i8imm:$src3), |
| 1769 | "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1770 | [(set VR128:$dst, |
| 1771 | (v2f64 (shufp:$src3 VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1772 | def SHUFPDrmi : PDIi8<0xC6, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1773 | (outs VR128:$dst), (ins VR128:$src1, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1774 | f128mem:$src2, i8imm:$src3), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1775 | "shufpd\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1776 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1777 | (v2f64 (shufp:$src3 |
| 1778 | VR128:$src1, (memopv2f64 addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1779 | |
| 1780 | let AddedComplexity = 10 in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1781 | def UNPCKHPDrr : PDI<0x15, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1782 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1783 | "unpckhpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1784 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1785 | (v2f64 (unpckh VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1786 | def UNPCKHPDrm : PDI<0x15, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1787 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1788 | "unpckhpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1789 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1790 | (v2f64 (unpckh VR128:$src1, |
| 1791 | (memopv2f64 addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1792 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1793 | def UNPCKLPDrr : PDI<0x14, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1794 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1795 | "unpcklpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1796 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1797 | (v2f64 (unpckl VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1798 | def UNPCKLPDrm : PDI<0x14, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1799 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1800 | "unpcklpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1801 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 1802 | (unpckl VR128:$src1, (memopv2f64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1803 | } // AddedComplexity |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1804 | } // Constraints = "$src1 = $dst" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1805 | |
| 1806 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1807 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1808 | // SSE integer instructions |
| 1809 | |
| 1810 | // Move Instructions |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 1811 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1812 | def MOVDQArr : PDI<0x6F, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1813 | "movdqa\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 1814 | let canFoldAsLoad = 1, mayLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1815 | def MOVDQArm : PDI<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1816 | "movdqa\t{$src, $dst|$dst, $src}", |
Evan Cheng | 51a49b2 | 2007-07-20 00:27:43 +0000 | [diff] [blame] | 1817 | [/*(set VR128:$dst, (alignedloadv2i64 addr:$src))*/]>; |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 1818 | let mayStore = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1819 | def MOVDQAmr : PDI<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1820 | "movdqa\t{$src, $dst|$dst, $src}", |
Evan Cheng | 51a49b2 | 2007-07-20 00:27:43 +0000 | [diff] [blame] | 1821 | [/*(alignedstore (v2i64 VR128:$src), addr:$dst)*/]>; |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 1822 | let canFoldAsLoad = 1, mayLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1823 | def MOVDQUrm : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1824 | "movdqu\t{$src, $dst|$dst, $src}", |
Evan Cheng | 51a49b2 | 2007-07-20 00:27:43 +0000 | [diff] [blame] | 1825 | [/*(set VR128:$dst, (loadv2i64 addr:$src))*/]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1826 | XS, Requires<[HasSSE2]>; |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 1827 | let mayStore = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1828 | def MOVDQUmr : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1829 | "movdqu\t{$src, $dst|$dst, $src}", |
Evan Cheng | 51a49b2 | 2007-07-20 00:27:43 +0000 | [diff] [blame] | 1830 | [/*(store (v2i64 VR128:$src), addr:$dst)*/]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1831 | XS, Requires<[HasSSE2]>; |
| 1832 | |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1833 | // Intrinsic forms of MOVDQU load and store |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 1834 | let canFoldAsLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1835 | def MOVDQUrm_Int : I<0x6F, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1836 | "movdqu\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1837 | [(set VR128:$dst, (int_x86_sse2_loadu_dq addr:$src))]>, |
| 1838 | XS, Requires<[HasSSE2]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1839 | def MOVDQUmr_Int : I<0x7F, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1840 | "movdqu\t{$src, $dst|$dst, $src}", |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1841 | [(int_x86_sse2_storeu_dq addr:$dst, VR128:$src)]>, |
| 1842 | XS, Requires<[HasSSE2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1843 | |
Evan Cheng | 8800475 | 2008-03-05 08:11:27 +0000 | [diff] [blame] | 1844 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1845 | |
| 1846 | multiclass PDI_binop_rm_int<bits<8> opc, string OpcodeStr, Intrinsic IntId, |
| 1847 | bit Commutable = 0> { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1848 | def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1849 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1850 | [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]> { |
| 1851 | let isCommutable = Commutable; |
| 1852 | } |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1853 | def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1854 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1855 | [(set VR128:$dst, (IntId VR128:$src1, |
Dan Gohman | 4a4f151 | 2007-07-18 20:23:34 +0000 | [diff] [blame] | 1856 | (bitconvert (memopv2i64 addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1857 | } |
| 1858 | |
Evan Cheng | f90f8f8 | 2008-05-03 00:52:09 +0000 | [diff] [blame] | 1859 | multiclass PDI_binop_rmi_int<bits<8> opc, bits<8> opc2, Format ImmForm, |
| 1860 | string OpcodeStr, |
| 1861 | Intrinsic IntId, Intrinsic IntId2> { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1862 | def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, |
| 1863 | VR128:$src2), |
Evan Cheng | f90f8f8 | 2008-05-03 00:52:09 +0000 | [diff] [blame] | 1864 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 1865 | [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1866 | def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, |
| 1867 | i128mem:$src2), |
Evan Cheng | f90f8f8 | 2008-05-03 00:52:09 +0000 | [diff] [blame] | 1868 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 1869 | [(set VR128:$dst, (IntId VR128:$src1, |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1870 | (bitconvert (memopv2i64 addr:$src2))))]>; |
| 1871 | def ri : PDIi8<opc2, ImmForm, (outs VR128:$dst), (ins VR128:$src1, |
| 1872 | i32i8imm:$src2), |
Evan Cheng | f90f8f8 | 2008-05-03 00:52:09 +0000 | [diff] [blame] | 1873 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 1874 | [(set VR128:$dst, (IntId2 VR128:$src1, (i32 imm:$src2)))]>; |
| 1875 | } |
| 1876 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1877 | /// PDI_binop_rm - Simple SSE2 binary operator. |
| 1878 | multiclass PDI_binop_rm<bits<8> opc, string OpcodeStr, SDNode OpNode, |
| 1879 | ValueType OpVT, bit Commutable = 0> { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1880 | def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, |
| 1881 | VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1882 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1883 | [(set VR128:$dst, (OpVT (OpNode VR128:$src1, VR128:$src2)))]> { |
| 1884 | let isCommutable = Commutable; |
| 1885 | } |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1886 | def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, |
| 1887 | i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1888 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1889 | [(set VR128:$dst, (OpVT (OpNode VR128:$src1, |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1890 | (bitconvert (memopv2i64 addr:$src2)))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1891 | } |
| 1892 | |
| 1893 | /// PDI_binop_rm_v2i64 - Simple SSE2 binary operator whose type is v2i64. |
| 1894 | /// |
| 1895 | /// FIXME: we could eliminate this and use PDI_binop_rm instead if tblgen knew |
| 1896 | /// to collapse (bitconvert VT to VT) into its operand. |
| 1897 | /// |
| 1898 | multiclass PDI_binop_rm_v2i64<bits<8> opc, string OpcodeStr, SDNode OpNode, |
| 1899 | bit Commutable = 0> { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1900 | def rr : PDI<opc, MRMSrcReg, (outs VR128:$dst), |
| 1901 | (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1902 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1903 | [(set VR128:$dst, (v2i64 (OpNode VR128:$src1, VR128:$src2)))]> { |
| 1904 | let isCommutable = Commutable; |
| 1905 | } |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1906 | def rm : PDI<opc, MRMSrcMem, (outs VR128:$dst), |
| 1907 | (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1908 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 1909 | [(set VR128:$dst, (OpNode VR128:$src1, |
| 1910 | (memopv2i64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1911 | } |
| 1912 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1913 | } // Constraints = "$src1 = $dst" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1914 | |
| 1915 | // 128-bit Integer Arithmetic |
| 1916 | |
| 1917 | defm PADDB : PDI_binop_rm<0xFC, "paddb", add, v16i8, 1>; |
| 1918 | defm PADDW : PDI_binop_rm<0xFD, "paddw", add, v8i16, 1>; |
| 1919 | defm PADDD : PDI_binop_rm<0xFE, "paddd", add, v4i32, 1>; |
| 1920 | defm PADDQ : PDI_binop_rm_v2i64<0xD4, "paddq", add, 1>; |
| 1921 | |
| 1922 | defm PADDSB : PDI_binop_rm_int<0xEC, "paddsb" , int_x86_sse2_padds_b, 1>; |
| 1923 | defm PADDSW : PDI_binop_rm_int<0xED, "paddsw" , int_x86_sse2_padds_w, 1>; |
| 1924 | defm PADDUSB : PDI_binop_rm_int<0xDC, "paddusb", int_x86_sse2_paddus_b, 1>; |
| 1925 | defm PADDUSW : PDI_binop_rm_int<0xDD, "paddusw", int_x86_sse2_paddus_w, 1>; |
| 1926 | |
| 1927 | defm PSUBB : PDI_binop_rm<0xF8, "psubb", sub, v16i8>; |
| 1928 | defm PSUBW : PDI_binop_rm<0xF9, "psubw", sub, v8i16>; |
| 1929 | defm PSUBD : PDI_binop_rm<0xFA, "psubd", sub, v4i32>; |
| 1930 | defm PSUBQ : PDI_binop_rm_v2i64<0xFB, "psubq", sub>; |
| 1931 | |
| 1932 | defm PSUBSB : PDI_binop_rm_int<0xE8, "psubsb" , int_x86_sse2_psubs_b>; |
| 1933 | defm PSUBSW : PDI_binop_rm_int<0xE9, "psubsw" , int_x86_sse2_psubs_w>; |
| 1934 | defm PSUBUSB : PDI_binop_rm_int<0xD8, "psubusb", int_x86_sse2_psubus_b>; |
| 1935 | defm PSUBUSW : PDI_binop_rm_int<0xD9, "psubusw", int_x86_sse2_psubus_w>; |
| 1936 | |
| 1937 | defm PMULLW : PDI_binop_rm<0xD5, "pmullw", mul, v8i16, 1>; |
| 1938 | |
| 1939 | defm PMULHUW : PDI_binop_rm_int<0xE4, "pmulhuw", int_x86_sse2_pmulhu_w, 1>; |
| 1940 | defm PMULHW : PDI_binop_rm_int<0xE5, "pmulhw" , int_x86_sse2_pmulh_w , 1>; |
| 1941 | defm PMULUDQ : PDI_binop_rm_int<0xF4, "pmuludq", int_x86_sse2_pmulu_dq, 1>; |
| 1942 | |
| 1943 | defm PMADDWD : PDI_binop_rm_int<0xF5, "pmaddwd", int_x86_sse2_pmadd_wd, 1>; |
| 1944 | |
| 1945 | defm PAVGB : PDI_binop_rm_int<0xE0, "pavgb", int_x86_sse2_pavg_b, 1>; |
| 1946 | defm PAVGW : PDI_binop_rm_int<0xE3, "pavgw", int_x86_sse2_pavg_w, 1>; |
| 1947 | |
| 1948 | |
| 1949 | defm PMINUB : PDI_binop_rm_int<0xDA, "pminub", int_x86_sse2_pminu_b, 1>; |
| 1950 | defm PMINSW : PDI_binop_rm_int<0xEA, "pminsw", int_x86_sse2_pmins_w, 1>; |
| 1951 | defm PMAXUB : PDI_binop_rm_int<0xDE, "pmaxub", int_x86_sse2_pmaxu_b, 1>; |
| 1952 | defm PMAXSW : PDI_binop_rm_int<0xEE, "pmaxsw", int_x86_sse2_pmaxs_w, 1>; |
Bill Wendling | 953ad2e | 2009-05-28 02:04:00 +0000 | [diff] [blame] | 1953 | defm PSADBW : PDI_binop_rm_int<0xF6, "psadbw", int_x86_sse2_psad_bw, 1>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1954 | |
| 1955 | |
Evan Cheng | f90f8f8 | 2008-05-03 00:52:09 +0000 | [diff] [blame] | 1956 | defm PSLLW : PDI_binop_rmi_int<0xF1, 0x71, MRM6r, "psllw", |
| 1957 | int_x86_sse2_psll_w, int_x86_sse2_pslli_w>; |
| 1958 | defm PSLLD : PDI_binop_rmi_int<0xF2, 0x72, MRM6r, "pslld", |
| 1959 | int_x86_sse2_psll_d, int_x86_sse2_pslli_d>; |
| 1960 | defm PSLLQ : PDI_binop_rmi_int<0xF3, 0x73, MRM6r, "psllq", |
| 1961 | int_x86_sse2_psll_q, int_x86_sse2_pslli_q>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1962 | |
Evan Cheng | f90f8f8 | 2008-05-03 00:52:09 +0000 | [diff] [blame] | 1963 | defm PSRLW : PDI_binop_rmi_int<0xD1, 0x71, MRM2r, "psrlw", |
| 1964 | int_x86_sse2_psrl_w, int_x86_sse2_psrli_w>; |
| 1965 | defm PSRLD : PDI_binop_rmi_int<0xD2, 0x72, MRM2r, "psrld", |
| 1966 | int_x86_sse2_psrl_d, int_x86_sse2_psrli_d>; |
Nate Begeman | c2ca5f6 | 2008-05-13 17:52:09 +0000 | [diff] [blame] | 1967 | defm PSRLQ : PDI_binop_rmi_int<0xD3, 0x73, MRM2r, "psrlq", |
Evan Cheng | f90f8f8 | 2008-05-03 00:52:09 +0000 | [diff] [blame] | 1968 | int_x86_sse2_psrl_q, int_x86_sse2_psrli_q>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1969 | |
Evan Cheng | f90f8f8 | 2008-05-03 00:52:09 +0000 | [diff] [blame] | 1970 | defm PSRAW : PDI_binop_rmi_int<0xE1, 0x71, MRM4r, "psraw", |
| 1971 | int_x86_sse2_psra_w, int_x86_sse2_psrai_w>; |
Nate Begeman | d66fc34 | 2008-05-13 01:47:52 +0000 | [diff] [blame] | 1972 | defm PSRAD : PDI_binop_rmi_int<0xE2, 0x72, MRM4r, "psrad", |
Evan Cheng | f90f8f8 | 2008-05-03 00:52:09 +0000 | [diff] [blame] | 1973 | int_x86_sse2_psra_d, int_x86_sse2_psrai_d>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1974 | |
| 1975 | // 128-bit logical shifts. |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 1976 | let Constraints = "$src1 = $dst", neverHasSideEffects = 1 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1977 | def PSLLDQri : PDIi8<0x73, MRM7r, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1978 | (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1979 | "pslldq\t{$src2, $dst|$dst, $src2}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1980 | def PSRLDQri : PDIi8<0x73, MRM3r, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1981 | (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1982 | "psrldq\t{$src2, $dst|$dst, $src2}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1983 | // PSRADQri doesn't exist in SSE[1-3]. |
| 1984 | } |
| 1985 | |
| 1986 | let Predicates = [HasSSE2] in { |
| 1987 | def : Pat<(int_x86_sse2_psll_dq VR128:$src1, imm:$src2), |
| 1988 | (v2i64 (PSLLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>; |
| 1989 | def : Pat<(int_x86_sse2_psrl_dq VR128:$src1, imm:$src2), |
| 1990 | (v2i64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>; |
Bill Wendling | 314ee05 | 2008-10-02 05:56:52 +0000 | [diff] [blame] | 1991 | def : Pat<(int_x86_sse2_psll_dq_bs VR128:$src1, imm:$src2), |
| 1992 | (v2i64 (PSLLDQri VR128:$src1, imm:$src2))>; |
| 1993 | def : Pat<(int_x86_sse2_psrl_dq_bs VR128:$src1, imm:$src2), |
| 1994 | (v2i64 (PSRLDQri VR128:$src1, imm:$src2))>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1995 | def : Pat<(v2f64 (X86fsrl VR128:$src1, i32immSExt8:$src2)), |
| 1996 | (v2f64 (PSRLDQri VR128:$src1, (PSxLDQ_imm imm:$src2)))>; |
Evan Cheng | dea9936 | 2008-05-29 08:22:04 +0000 | [diff] [blame] | 1997 | |
| 1998 | // Shift up / down and insert zero's. |
| 1999 | def : Pat<(v2i64 (X86vshl VR128:$src, (i8 imm:$amt))), |
| 2000 | (v2i64 (PSLLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>; |
| 2001 | def : Pat<(v2i64 (X86vshr VR128:$src, (i8 imm:$amt))), |
| 2002 | (v2i64 (PSRLDQri VR128:$src, (PSxLDQ_imm imm:$amt)))>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2003 | } |
| 2004 | |
| 2005 | // Logical |
| 2006 | defm PAND : PDI_binop_rm_v2i64<0xDB, "pand", and, 1>; |
| 2007 | defm POR : PDI_binop_rm_v2i64<0xEB, "por" , or , 1>; |
| 2008 | defm PXOR : PDI_binop_rm_v2i64<0xEF, "pxor", xor, 1>; |
| 2009 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2010 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2011 | def PANDNrr : PDI<0xDF, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2012 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2013 | "pandn\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2014 | [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1), |
| 2015 | VR128:$src2)))]>; |
| 2016 | |
| 2017 | def PANDNrm : PDI<0xDF, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2018 | (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2019 | "pandn\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2020 | [(set VR128:$dst, (v2i64 (and (vnot VR128:$src1), |
Dan Gohman | 7dc1901 | 2007-08-02 21:17:01 +0000 | [diff] [blame] | 2021 | (memopv2i64 addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2022 | } |
| 2023 | |
| 2024 | // SSE2 Integer comparison |
| 2025 | defm PCMPEQB : PDI_binop_rm_int<0x74, "pcmpeqb", int_x86_sse2_pcmpeq_b>; |
| 2026 | defm PCMPEQW : PDI_binop_rm_int<0x75, "pcmpeqw", int_x86_sse2_pcmpeq_w>; |
| 2027 | defm PCMPEQD : PDI_binop_rm_int<0x76, "pcmpeqd", int_x86_sse2_pcmpeq_d>; |
| 2028 | defm PCMPGTB : PDI_binop_rm_int<0x64, "pcmpgtb", int_x86_sse2_pcmpgt_b>; |
| 2029 | defm PCMPGTW : PDI_binop_rm_int<0x65, "pcmpgtw", int_x86_sse2_pcmpgt_w>; |
| 2030 | defm PCMPGTD : PDI_binop_rm_int<0x66, "pcmpgtd", int_x86_sse2_pcmpgt_d>; |
| 2031 | |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2032 | def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, VR128:$src2)), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2033 | (PCMPEQBrr VR128:$src1, VR128:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2034 | def : Pat<(v16i8 (X86pcmpeqb VR128:$src1, (memop addr:$src2))), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2035 | (PCMPEQBrm VR128:$src1, addr:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2036 | def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, VR128:$src2)), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2037 | (PCMPEQWrr VR128:$src1, VR128:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2038 | def : Pat<(v8i16 (X86pcmpeqw VR128:$src1, (memop addr:$src2))), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2039 | (PCMPEQWrm VR128:$src1, addr:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2040 | def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, VR128:$src2)), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2041 | (PCMPEQDrr VR128:$src1, VR128:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2042 | def : Pat<(v4i32 (X86pcmpeqd VR128:$src1, (memop addr:$src2))), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2043 | (PCMPEQDrm VR128:$src1, addr:$src2)>; |
| 2044 | |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2045 | def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, VR128:$src2)), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2046 | (PCMPGTBrr VR128:$src1, VR128:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2047 | def : Pat<(v16i8 (X86pcmpgtb VR128:$src1, (memop addr:$src2))), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2048 | (PCMPGTBrm VR128:$src1, addr:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2049 | def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, VR128:$src2)), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2050 | (PCMPGTWrr VR128:$src1, VR128:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2051 | def : Pat<(v8i16 (X86pcmpgtw VR128:$src1, (memop addr:$src2))), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2052 | (PCMPGTWrm VR128:$src1, addr:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2053 | def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, VR128:$src2)), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2054 | (PCMPGTDrr VR128:$src1, VR128:$src2)>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 2055 | def : Pat<(v4i32 (X86pcmpgtd VR128:$src1, (memop addr:$src2))), |
Nate Begeman | 78ca4f9 | 2008-05-12 23:09:43 +0000 | [diff] [blame] | 2056 | (PCMPGTDrm VR128:$src1, addr:$src2)>; |
| 2057 | |
| 2058 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2059 | // Pack instructions |
| 2060 | defm PACKSSWB : PDI_binop_rm_int<0x63, "packsswb", int_x86_sse2_packsswb_128>; |
| 2061 | defm PACKSSDW : PDI_binop_rm_int<0x6B, "packssdw", int_x86_sse2_packssdw_128>; |
| 2062 | defm PACKUSWB : PDI_binop_rm_int<0x67, "packuswb", int_x86_sse2_packuswb_128>; |
| 2063 | |
| 2064 | // Shuffle and unpack instructions |
| 2065 | def PSHUFDri : PDIi8<0x70, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2066 | (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2067 | "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2068 | [(set VR128:$dst, (v4i32 (pshufd:$src2 |
| 2069 | VR128:$src1, (undef))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2070 | def PSHUFDmi : PDIi8<0x70, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2071 | (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2072 | "pshufd\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2073 | [(set VR128:$dst, (v4i32 (pshufd:$src2 |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2074 | (bc_v4i32(memopv2i64 addr:$src1)), |
| 2075 | (undef))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2076 | |
| 2077 | // SSE2 with ImmT == Imm8 and XS prefix. |
| 2078 | def PSHUFHWri : Ii8<0x70, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2079 | (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2080 | "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2081 | [(set VR128:$dst, (v8i16 (pshufhw:$src2 VR128:$src1, |
| 2082 | (undef))))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2083 | XS, Requires<[HasSSE2]>; |
| 2084 | def PSHUFHWmi : Ii8<0x70, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2085 | (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2086 | "pshufhw\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2087 | [(set VR128:$dst, (v8i16 (pshufhw:$src2 |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2088 | (bc_v8i16 (memopv2i64 addr:$src1)), |
| 2089 | (undef))))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2090 | XS, Requires<[HasSSE2]>; |
| 2091 | |
| 2092 | // SSE2 with ImmT == Imm8 and XD prefix. |
| 2093 | def PSHUFLWri : Ii8<0x70, MRMSrcReg, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2094 | (outs VR128:$dst), (ins VR128:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2095 | "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2096 | [(set VR128:$dst, (v8i16 (pshuflw:$src2 VR128:$src1, |
| 2097 | (undef))))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2098 | XD, Requires<[HasSSE2]>; |
| 2099 | def PSHUFLWmi : Ii8<0x70, MRMSrcMem, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2100 | (outs VR128:$dst), (ins i128mem:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2101 | "pshuflw\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2102 | [(set VR128:$dst, (v8i16 (pshuflw:$src2 |
| 2103 | (bc_v8i16 (memopv2i64 addr:$src1)), |
| 2104 | (undef))))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2105 | XD, Requires<[HasSSE2]>; |
| 2106 | |
| 2107 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2108 | let Constraints = "$src1 = $dst" in { |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2109 | def PUNPCKLBWrr : PDI<0x60, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2110 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2111 | "punpcklbw\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2112 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2113 | (v16i8 (unpckl VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2114 | def PUNPCKLBWrm : PDI<0x60, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2115 | (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2116 | "punpcklbw\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2117 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2118 | (unpckl VR128:$src1, |
| 2119 | (bc_v16i8 (memopv2i64 addr:$src2))))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2120 | def PUNPCKLWDrr : PDI<0x61, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2121 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2122 | "punpcklwd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2123 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2124 | (v8i16 (unpckl VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2125 | def PUNPCKLWDrm : PDI<0x61, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2126 | (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2127 | "punpcklwd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2128 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2129 | (unpckl VR128:$src1, |
| 2130 | (bc_v8i16 (memopv2i64 addr:$src2))))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2131 | def PUNPCKLDQrr : PDI<0x62, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2132 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2133 | "punpckldq\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2134 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2135 | (v4i32 (unpckl VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2136 | def PUNPCKLDQrm : PDI<0x62, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2137 | (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2138 | "punpckldq\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2139 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2140 | (unpckl VR128:$src1, |
| 2141 | (bc_v4i32 (memopv2i64 addr:$src2))))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2142 | def PUNPCKLQDQrr : PDI<0x6C, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2143 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2144 | "punpcklqdq\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2145 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2146 | (v2i64 (unpckl VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2147 | def PUNPCKLQDQrm : PDI<0x6C, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2148 | (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2149 | "punpcklqdq\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2150 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2151 | (v2i64 (unpckl VR128:$src1, |
| 2152 | (memopv2i64 addr:$src2))))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2153 | |
| 2154 | def PUNPCKHBWrr : PDI<0x68, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2155 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2156 | "punpckhbw\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2157 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2158 | (v16i8 (unpckh VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2159 | def PUNPCKHBWrm : PDI<0x68, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2160 | (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2161 | "punpckhbw\t{$src2, $dst|$dst, $src2}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2162 | [(set VR128:$dst, |
| 2163 | (unpckh VR128:$src1, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2164 | (bc_v16i8 (memopv2i64 addr:$src2))))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2165 | def PUNPCKHWDrr : PDI<0x69, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2166 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2167 | "punpckhwd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2168 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2169 | (v8i16 (unpckh VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2170 | def PUNPCKHWDrm : PDI<0x69, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2171 | (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2172 | "punpckhwd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2173 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2174 | (unpckh VR128:$src1, |
| 2175 | (bc_v8i16 (memopv2i64 addr:$src2))))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2176 | def PUNPCKHDQrr : PDI<0x6A, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2177 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2178 | "punpckhdq\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2179 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2180 | (v4i32 (unpckh VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2181 | def PUNPCKHDQrm : PDI<0x6A, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2182 | (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2183 | "punpckhdq\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2184 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2185 | (unpckh VR128:$src1, |
| 2186 | (bc_v4i32 (memopv2i64 addr:$src2))))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2187 | def PUNPCKHQDQrr : PDI<0x6D, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2188 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2189 | "punpckhqdq\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2190 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2191 | (v2i64 (unpckh VR128:$src1, VR128:$src2)))]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2192 | def PUNPCKHQDQrm : PDI<0x6D, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2193 | (outs VR128:$dst), (ins VR128:$src1, i128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2194 | "punpckhqdq\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2195 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2196 | (v2i64 (unpckh VR128:$src1, |
| 2197 | (memopv2i64 addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2198 | } |
| 2199 | |
| 2200 | // Extract / Insert |
| 2201 | def PEXTRWri : PDIi8<0xC5, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2202 | (outs GR32:$dst), (ins VR128:$src1, i32i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2203 | "pextrw\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2204 | [(set GR32:$dst, (X86pextrw (v8i16 VR128:$src1), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 2205 | imm:$src2))]>; |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2206 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2207 | def PINSRWrri : PDIi8<0xC4, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2208 | (outs VR128:$dst), (ins VR128:$src1, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2209 | GR32:$src2, i32i8imm:$src3), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2210 | "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2211 | [(set VR128:$dst, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 2212 | (X86pinsrw VR128:$src1, GR32:$src2, imm:$src3))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2213 | def PINSRWrmi : PDIi8<0xC4, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2214 | (outs VR128:$dst), (ins VR128:$src1, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2215 | i16mem:$src2, i32i8imm:$src3), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2216 | "pinsrw\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2217 | [(set VR128:$dst, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 2218 | (X86pinsrw VR128:$src1, (extloadi16 addr:$src2), |
| 2219 | imm:$src3))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2220 | } |
| 2221 | |
| 2222 | // Mask creation |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2223 | def PMOVMSKBrr : PDI<0xD7, MRMSrcReg, (outs GR32:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2224 | "pmovmskb\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2225 | [(set GR32:$dst, (int_x86_sse2_pmovmskb_128 VR128:$src))]>; |
| 2226 | |
| 2227 | // Conditional store |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 2228 | let Uses = [EDI] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2229 | def MASKMOVDQU : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2230 | "maskmovdqu\t{$mask, $src|$src, $mask}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 2231 | [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, EDI)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2232 | |
Evan Cheng | 430de08 | 2009-02-10 22:06:28 +0000 | [diff] [blame] | 2233 | let Uses = [RDI] in |
| 2234 | def MASKMOVDQU64 : PDI<0xF7, MRMSrcReg, (outs), (ins VR128:$src, VR128:$mask), |
| 2235 | "maskmovdqu\t{$mask, $src|$src, $mask}", |
| 2236 | [(int_x86_sse2_maskmov_dqu VR128:$src, VR128:$mask, RDI)]>; |
| 2237 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2238 | // Non-temporal stores |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2239 | def MOVNTPDmr : PDI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2240 | "movntpd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2241 | [(int_x86_sse2_movnt_pd addr:$dst, VR128:$src)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2242 | def MOVNTDQmr : PDI<0xE7, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2243 | "movntdq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2244 | [(int_x86_sse2_movnt_dq addr:$dst, VR128:$src)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2245 | def MOVNTImr : I<0xC3, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2246 | "movnti\t{$src, $dst|$dst, $src}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2247 | [(int_x86_sse2_movnt_i addr:$dst, GR32:$src)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2248 | TB, Requires<[HasSSE2]>; |
| 2249 | |
| 2250 | // Flush cache |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2251 | def CLFLUSH : I<0xAE, MRM7m, (outs), (ins i8mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2252 | "clflush\t$src", [(int_x86_sse2_clflush addr:$src)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2253 | TB, Requires<[HasSSE2]>; |
| 2254 | |
| 2255 | // Load, store, and memory fence |
Evan Cheng | 5d0d34e | 2008-10-17 17:14:20 +0000 | [diff] [blame] | 2256 | def LFENCE : I<0xAE, MRM5r, (outs), (ins), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2257 | "lfence", [(int_x86_sse2_lfence)]>, TB, Requires<[HasSSE2]>; |
Evan Cheng | 5d0d34e | 2008-10-17 17:14:20 +0000 | [diff] [blame] | 2258 | def MFENCE : I<0xAE, MRM6r, (outs), (ins), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2259 | "mfence", [(int_x86_sse2_mfence)]>, TB, Requires<[HasSSE2]>; |
| 2260 | |
Andrew Lenharth | 785610d | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 2261 | //TODO: custom lower this so as to never even generate the noop |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2262 | def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss), |
Andrew Lenharth | 785610d | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 2263 | (i8 0)), (NOOP)>; |
| 2264 | def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>; |
| 2265 | def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2266 | def : Pat<(membarrier (i8 imm:$ll), (i8 imm:$ls), (i8 imm:$sl), (i8 imm:$ss), |
Andrew Lenharth | 785610d | 2008-02-16 01:24:58 +0000 | [diff] [blame] | 2267 | (i8 1)), (MFENCE)>; |
| 2268 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2269 | // Alias instructions that map zero vector to pxor / xorp* for sse. |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 2270 | // We set canFoldAsLoad because this can be converted to a constant-pool |
Dan Gohman | 37eb6c8 | 2008-12-03 05:21:24 +0000 | [diff] [blame] | 2271 | // load of an all-ones value if folding it would be beneficial. |
Daniel Dunbar | a0e6200 | 2009-08-11 22:17:52 +0000 | [diff] [blame] | 2272 | let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, |
| 2273 | isCodeGenOnly = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2274 | def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2275 | "pcmpeqd\t$dst, $dst", |
Chris Lattner | e6aa386 | 2007-11-25 00:24:49 +0000 | [diff] [blame] | 2276 | [(set VR128:$dst, (v4i32 immAllOnesV))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2277 | |
| 2278 | // FR64 to 128-bit vector conversion. |
Evan Cheng | bd0ca9c | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 2279 | let isAsCheapAsAMove = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2280 | def MOVSD2PDrr : SDI<0x10, MRMSrcReg, (outs VR128:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2281 | "movsd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2282 | [(set VR128:$dst, |
| 2283 | (v2f64 (scalar_to_vector FR64:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2284 | def MOVSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2285 | "movsd\t{$src, $dst|$dst, $src}", |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2286 | [(set VR128:$dst, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2287 | (v2f64 (scalar_to_vector (loadf64 addr:$src))))]>; |
| 2288 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2289 | def MOVDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2290 | "movd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2291 | [(set VR128:$dst, |
| 2292 | (v4i32 (scalar_to_vector GR32:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2293 | def MOVDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2294 | "movd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2295 | [(set VR128:$dst, |
| 2296 | (v4i32 (scalar_to_vector (loadi32 addr:$src))))]>; |
| 2297 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2298 | def MOVDI2SSrr : PDI<0x6E, MRMSrcReg, (outs FR32:$dst), (ins GR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2299 | "movd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2300 | [(set FR32:$dst, (bitconvert GR32:$src))]>; |
| 2301 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2302 | def MOVDI2SSrm : PDI<0x6E, MRMSrcMem, (outs FR32:$dst), (ins i32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2303 | "movd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2304 | [(set FR32:$dst, (bitconvert (loadi32 addr:$src)))]>; |
| 2305 | |
| 2306 | // SSE2 instructions with XS prefix |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2307 | def MOVQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2308 | "movq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2309 | [(set VR128:$dst, |
| 2310 | (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>, XS, |
| 2311 | Requires<[HasSSE2]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2312 | def MOVPQI2QImr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2313 | "movq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2314 | [(store (i64 (vector_extract (v2i64 VR128:$src), |
| 2315 | (iPTR 0))), addr:$dst)]>; |
| 2316 | |
| 2317 | // FIXME: may not be able to eliminate this movss with coalescing the src and |
| 2318 | // dest register classes are different. We really want to write this pattern |
| 2319 | // like this: |
| 2320 | // def : Pat<(f32 (vector_extract (v4f32 VR128:$src), (iPTR 0))), |
| 2321 | // (f32 FR32:$src)>; |
Evan Cheng | bd0ca9c | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 2322 | let isAsCheapAsAMove = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2323 | def MOVPD2SDrr : SDI<0x10, MRMSrcReg, (outs FR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2324 | "movsd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2325 | [(set FR64:$dst, (vector_extract (v2f64 VR128:$src), |
| 2326 | (iPTR 0)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2327 | def MOVPD2SDmr : SDI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2328 | "movsd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2329 | [(store (f64 (vector_extract (v2f64 VR128:$src), |
| 2330 | (iPTR 0))), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2331 | def MOVPDI2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2332 | "movd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2333 | [(set GR32:$dst, (vector_extract (v4i32 VR128:$src), |
| 2334 | (iPTR 0)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2335 | def MOVPDI2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2336 | "movd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2337 | [(store (i32 (vector_extract (v4i32 VR128:$src), |
| 2338 | (iPTR 0))), addr:$dst)]>; |
| 2339 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2340 | def MOVSS2DIrr : PDI<0x7E, MRMDestReg, (outs GR32:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2341 | "movd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2342 | [(set GR32:$dst, (bitconvert FR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2343 | def MOVSS2DImr : PDI<0x7E, MRMDestMem, (outs), (ins i32mem:$dst, FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2344 | "movd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2345 | [(store (i32 (bitconvert FR32:$src)), addr:$dst)]>; |
| 2346 | |
| 2347 | |
| 2348 | // Move to lower bits of a VR128, leaving upper bits alone. |
| 2349 | // Three operand (but two address) aliases. |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2350 | let Constraints = "$src1 = $dst" in { |
Chris Lattner | d1a9eb6 | 2008-01-11 06:59:07 +0000 | [diff] [blame] | 2351 | let neverHasSideEffects = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2352 | def MOVLSD2PDrr : SDI<0x10, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2353 | (outs VR128:$dst), (ins VR128:$src1, FR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2354 | "movsd\t{$src2, $dst|$dst, $src2}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2355 | |
| 2356 | let AddedComplexity = 15 in |
| 2357 | def MOVLPDrr : SDI<0x10, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2358 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2359 | "movsd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2360 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2361 | (v2f64 (movl VR128:$src1, VR128:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2362 | } |
| 2363 | |
| 2364 | // Store / copy lower 64-bits of a XMM register. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2365 | def MOVLQ128mr : PDI<0xD6, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2366 | "movq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2367 | [(int_x86_sse2_storel_dq addr:$dst, VR128:$src)]>; |
| 2368 | |
| 2369 | // Move to lower bits of a VR128 and zeroing upper bits. |
| 2370 | // Loading from memory automatically zeroing upper bits. |
Evan Cheng | d743a5f | 2008-05-10 00:59:18 +0000 | [diff] [blame] | 2371 | let AddedComplexity = 20 in { |
| 2372 | def MOVZSD2PDrm : SDI<0x10, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src), |
| 2373 | "movsd\t{$src, $dst|$dst, $src}", |
| 2374 | [(set VR128:$dst, |
| 2375 | (v2f64 (X86vzmovl (v2f64 (scalar_to_vector |
| 2376 | (loadf64 addr:$src))))))]>; |
Evan Cheng | 40ee6e5 | 2008-05-08 00:57:18 +0000 | [diff] [blame] | 2377 | |
Evan Cheng | 056afe1 | 2008-05-20 18:24:47 +0000 | [diff] [blame] | 2378 | def : Pat<(v2f64 (X86vzmovl (loadv2f64 addr:$src))), |
| 2379 | (MOVZSD2PDrm addr:$src)>; |
| 2380 | def : Pat<(v2f64 (X86vzmovl (bc_v2f64 (loadv4f32 addr:$src)))), |
Evan Cheng | d743a5f | 2008-05-10 00:59:18 +0000 | [diff] [blame] | 2381 | (MOVZSD2PDrm addr:$src)>; |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2382 | def : Pat<(v2f64 (X86vzload addr:$src)), (MOVZSD2PDrm addr:$src)>; |
Evan Cheng | d743a5f | 2008-05-10 00:59:18 +0000 | [diff] [blame] | 2383 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2384 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2385 | // movd / movq to XMM register zero-extends |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2386 | let AddedComplexity = 15 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2387 | def MOVZDI2PDIrr : PDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2388 | "movd\t{$src, $dst|$dst, $src}", |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2389 | [(set VR128:$dst, (v4i32 (X86vzmovl |
Evan Cheng | 40ee6e5 | 2008-05-08 00:57:18 +0000 | [diff] [blame] | 2390 | (v4i32 (scalar_to_vector GR32:$src)))))]>; |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2391 | // This is X86-64 only. |
| 2392 | def MOVZQI2PQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src), |
| 2393 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2394 | [(set VR128:$dst, (v2i64 (X86vzmovl |
Evan Cheng | 40ee6e5 | 2008-05-08 00:57:18 +0000 | [diff] [blame] | 2395 | (v2i64 (scalar_to_vector GR64:$src)))))]>; |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2396 | } |
| 2397 | |
| 2398 | let AddedComplexity = 20 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2399 | def MOVZDI2PDIrm : PDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2400 | "movd\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2401 | [(set VR128:$dst, |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2402 | (v4i32 (X86vzmovl (v4i32 (scalar_to_vector |
Evan Cheng | 40ee6e5 | 2008-05-08 00:57:18 +0000 | [diff] [blame] | 2403 | (loadi32 addr:$src))))))]>; |
Evan Cheng | 3ad16c4 | 2008-05-22 18:56:56 +0000 | [diff] [blame] | 2404 | |
| 2405 | def : Pat<(v4i32 (X86vzmovl (loadv4i32 addr:$src))), |
| 2406 | (MOVZDI2PDIrm addr:$src)>; |
| 2407 | def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv4f32 addr:$src)))), |
| 2408 | (MOVZDI2PDIrm addr:$src)>; |
Duncan Sands | 2418bec | 2008-06-13 19:07:40 +0000 | [diff] [blame] | 2409 | def : Pat<(v4i32 (X86vzmovl (bc_v4i32 (loadv2i64 addr:$src)))), |
| 2410 | (MOVZDI2PDIrm addr:$src)>; |
Evan Cheng | 3ad16c4 | 2008-05-22 18:56:56 +0000 | [diff] [blame] | 2411 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2412 | def MOVZQI2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2413 | "movq\t{$src, $dst|$dst, $src}", |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2414 | [(set VR128:$dst, |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2415 | (v2i64 (X86vzmovl (v2i64 (scalar_to_vector |
Evan Cheng | 40ee6e5 | 2008-05-08 00:57:18 +0000 | [diff] [blame] | 2416 | (loadi64 addr:$src))))))]>, XS, |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2417 | Requires<[HasSSE2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2418 | |
Evan Cheng | 3ad16c4 | 2008-05-22 18:56:56 +0000 | [diff] [blame] | 2419 | def : Pat<(v2i64 (X86vzmovl (loadv2i64 addr:$src))), |
| 2420 | (MOVZQI2PQIrm addr:$src)>; |
| 2421 | def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4f32 addr:$src)))), |
| 2422 | (MOVZQI2PQIrm addr:$src)>; |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2423 | def : Pat<(v2i64 (X86vzload addr:$src)), (MOVZQI2PQIrm addr:$src)>; |
Evan Cheng | d743a5f | 2008-05-10 00:59:18 +0000 | [diff] [blame] | 2424 | } |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2425 | |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2426 | // Moving from XMM to XMM and clear upper 64 bits. Note, there is a bug in |
| 2427 | // IA32 document. movq xmm1, xmm2 does clear the high bits. |
| 2428 | let AddedComplexity = 15 in |
| 2429 | def MOVZPQILo2PQIrr : I<0x7E, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
| 2430 | "movq\t{$src, $dst|$dst, $src}", |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2431 | [(set VR128:$dst, (v2i64 (X86vzmovl (v2i64 VR128:$src))))]>, |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2432 | XS, Requires<[HasSSE2]>; |
| 2433 | |
Evan Cheng | 056afe1 | 2008-05-20 18:24:47 +0000 | [diff] [blame] | 2434 | let AddedComplexity = 20 in { |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2435 | def MOVZPQILo2PQIrm : I<0x7E, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), |
| 2436 | "movq\t{$src, $dst|$dst, $src}", |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2437 | [(set VR128:$dst, (v2i64 (X86vzmovl |
Evan Cheng | 056afe1 | 2008-05-20 18:24:47 +0000 | [diff] [blame] | 2438 | (loadv2i64 addr:$src))))]>, |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2439 | XS, Requires<[HasSSE2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2440 | |
Evan Cheng | 056afe1 | 2008-05-20 18:24:47 +0000 | [diff] [blame] | 2441 | def : Pat<(v2i64 (X86vzmovl (bc_v2i64 (loadv4i32 addr:$src)))), |
| 2442 | (MOVZPQILo2PQIrm addr:$src)>; |
| 2443 | } |
| 2444 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2445 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2446 | // SSE3 Instructions |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2447 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2448 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2449 | // Move Instructions |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2450 | def MOVSHDUPrr : S3SI<0x16, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2451 | "movshdup\t{$src, $dst|$dst, $src}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2452 | [(set VR128:$dst, (v4f32 (movshdup |
| 2453 | VR128:$src, (undef))))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2454 | def MOVSHDUPrm : S3SI<0x16, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2455 | "movshdup\t{$src, $dst|$dst, $src}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2456 | [(set VR128:$dst, (movshdup |
| 2457 | (memopv4f32 addr:$src), (undef)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2458 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2459 | def MOVSLDUPrr : S3SI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2460 | "movsldup\t{$src, $dst|$dst, $src}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2461 | [(set VR128:$dst, (v4f32 (movsldup |
| 2462 | VR128:$src, (undef))))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2463 | def MOVSLDUPrm : S3SI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2464 | "movsldup\t{$src, $dst|$dst, $src}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2465 | [(set VR128:$dst, (movsldup |
| 2466 | (memopv4f32 addr:$src), (undef)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2467 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2468 | def MOVDDUPrr : S3DI<0x12, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2469 | "movddup\t{$src, $dst|$dst, $src}", |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2470 | [(set VR128:$dst,(v2f64 (movddup VR128:$src, (undef))))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2471 | def MOVDDUPrm : S3DI<0x12, MRMSrcMem, (outs VR128:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2472 | "movddup\t{$src, $dst|$dst, $src}", |
Evan Cheng | a2497eb | 2008-09-25 20:50:48 +0000 | [diff] [blame] | 2473 | [(set VR128:$dst, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2474 | (v2f64 (movddup (scalar_to_vector (loadf64 addr:$src)), |
| 2475 | (undef))))]>; |
Evan Cheng | a2497eb | 2008-09-25 20:50:48 +0000 | [diff] [blame] | 2476 | |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2477 | def : Pat<(movddup (bc_v2f64 (v2i64 (scalar_to_vector (loadi64 addr:$src)))), |
| 2478 | (undef)), |
Evan Cheng | a2497eb | 2008-09-25 20:50:48 +0000 | [diff] [blame] | 2479 | (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>; |
Nate Begeman | b44aad7 | 2009-04-29 22:47:44 +0000 | [diff] [blame] | 2480 | |
| 2481 | let AddedComplexity = 5 in { |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2482 | def : Pat<(movddup (memopv2f64 addr:$src), (undef)), |
Evan Cheng | a2497eb | 2008-09-25 20:50:48 +0000 | [diff] [blame] | 2483 | (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>; |
Nate Begeman | b44aad7 | 2009-04-29 22:47:44 +0000 | [diff] [blame] | 2484 | def : Pat<(movddup (bc_v4f32 (memopv2f64 addr:$src)), (undef)), |
| 2485 | (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>; |
| 2486 | def : Pat<(movddup (memopv2i64 addr:$src), (undef)), |
| 2487 | (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>; |
| 2488 | def : Pat<(movddup (bc_v4i32 (memopv2i64 addr:$src)), (undef)), |
| 2489 | (MOVDDUPrm addr:$src)>, Requires<[HasSSE3]>; |
| 2490 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2491 | |
| 2492 | // Arithmetic |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2493 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2494 | def ADDSUBPSrr : S3DI<0xD0, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2495 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2496 | "addsubps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2497 | [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1, |
| 2498 | VR128:$src2))]>; |
| 2499 | def ADDSUBPSrm : S3DI<0xD0, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2500 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2501 | "addsubps\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2502 | [(set VR128:$dst, (int_x86_sse3_addsub_ps VR128:$src1, |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 2503 | (memop addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2504 | def ADDSUBPDrr : S3I<0xD0, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2505 | (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2506 | "addsubpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2507 | [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1, |
| 2508 | VR128:$src2))]>; |
| 2509 | def ADDSUBPDrm : S3I<0xD0, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2510 | (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2511 | "addsubpd\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2512 | [(set VR128:$dst, (int_x86_sse3_addsub_pd VR128:$src1, |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 2513 | (memop addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2514 | } |
| 2515 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2516 | def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2517 | "lddqu\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2518 | [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>; |
| 2519 | |
| 2520 | // Horizontal ops |
| 2521 | class S3D_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId> |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2522 | : S3DI<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2523 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2524 | [(set VR128:$dst, (v4f32 (IntId VR128:$src1, VR128:$src2)))]>; |
| 2525 | class S3D_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId> |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2526 | : S3DI<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2527 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 2528 | [(set VR128:$dst, (v4f32 (IntId VR128:$src1, (memop addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2529 | class S3_Intrr<bits<8> o, string OpcodeStr, Intrinsic IntId> |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2530 | : S3I<o, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2531 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2532 | [(set VR128:$dst, (v2f64 (IntId VR128:$src1, VR128:$src2)))]>; |
| 2533 | class S3_Intrm<bits<8> o, string OpcodeStr, Intrinsic IntId> |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2534 | : S3I<o, MRMSrcMem, (outs VR128:$dst), (ins VR128:$src1, f128mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2535 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 2536 | [(set VR128:$dst, (v2f64 (IntId VR128:$src1, (memopv2f64 addr:$src2))))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2537 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2538 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2539 | def HADDPSrr : S3D_Intrr<0x7C, "haddps", int_x86_sse3_hadd_ps>; |
| 2540 | def HADDPSrm : S3D_Intrm<0x7C, "haddps", int_x86_sse3_hadd_ps>; |
| 2541 | def HADDPDrr : S3_Intrr <0x7C, "haddpd", int_x86_sse3_hadd_pd>; |
| 2542 | def HADDPDrm : S3_Intrm <0x7C, "haddpd", int_x86_sse3_hadd_pd>; |
| 2543 | def HSUBPSrr : S3D_Intrr<0x7D, "hsubps", int_x86_sse3_hsub_ps>; |
| 2544 | def HSUBPSrm : S3D_Intrm<0x7D, "hsubps", int_x86_sse3_hsub_ps>; |
| 2545 | def HSUBPDrr : S3_Intrr <0x7D, "hsubpd", int_x86_sse3_hsub_pd>; |
| 2546 | def HSUBPDrm : S3_Intrm <0x7D, "hsubpd", int_x86_sse3_hsub_pd>; |
| 2547 | } |
| 2548 | |
| 2549 | // Thread synchronization |
Bill Wendling | 6ee7655 | 2009-05-28 23:40:46 +0000 | [diff] [blame] | 2550 | def MONITOR : I<0x01, MRM1r, (outs), (ins), "monitor", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2551 | [(int_x86_sse3_monitor EAX, ECX, EDX)]>,TB, Requires<[HasSSE3]>; |
Bill Wendling | 6ee7655 | 2009-05-28 23:40:46 +0000 | [diff] [blame] | 2552 | def MWAIT : I<0x01, MRM1r, (outs), (ins), "mwait", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2553 | [(int_x86_sse3_mwait ECX, EAX)]>, TB, Requires<[HasSSE3]>; |
| 2554 | |
| 2555 | // vector_shuffle v1, <undef> <1, 1, 3, 3> |
| 2556 | let AddedComplexity = 15 in |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2557 | def : Pat<(v4i32 (movshdup VR128:$src, (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2558 | (MOVSHDUPrr VR128:$src)>, Requires<[HasSSE3]>; |
| 2559 | let AddedComplexity = 20 in |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2560 | def : Pat<(v4i32 (movshdup (bc_v4i32 (memopv2i64 addr:$src)), (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2561 | (MOVSHDUPrm addr:$src)>, Requires<[HasSSE3]>; |
| 2562 | |
| 2563 | // vector_shuffle v1, <undef> <0, 0, 2, 2> |
| 2564 | let AddedComplexity = 15 in |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2565 | def : Pat<(v4i32 (movsldup VR128:$src, (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2566 | (MOVSLDUPrr VR128:$src)>, Requires<[HasSSE3]>; |
| 2567 | let AddedComplexity = 20 in |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2568 | def : Pat<(v4i32 (movsldup (bc_v4i32 (memopv2i64 addr:$src)), (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2569 | (MOVSLDUPrm addr:$src)>, Requires<[HasSSE3]>; |
| 2570 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2571 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2572 | // SSSE3 Instructions |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2573 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2574 | |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2575 | /// SS3I_unop_rm_int_8 - Simple SSSE3 unary operator whose type is v*i8. |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 2576 | multiclass SS3I_unop_rm_int_8<bits<8> opc, string OpcodeStr, |
| 2577 | Intrinsic IntId64, Intrinsic IntId128> { |
| 2578 | def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), (ins VR64:$src), |
| 2579 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2580 | [(set VR64:$dst, (IntId64 VR64:$src))]>; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2581 | |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 2582 | def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), (ins i64mem:$src), |
| 2583 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2584 | [(set VR64:$dst, |
| 2585 | (IntId64 (bitconvert (memopv8i8 addr:$src))))]>; |
| 2586 | |
| 2587 | def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst), |
| 2588 | (ins VR128:$src), |
| 2589 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2590 | [(set VR128:$dst, (IntId128 VR128:$src))]>, |
| 2591 | OpSize; |
| 2592 | |
| 2593 | def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst), |
| 2594 | (ins i128mem:$src), |
| 2595 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2596 | [(set VR128:$dst, |
| 2597 | (IntId128 |
| 2598 | (bitconvert (memopv16i8 addr:$src))))]>, OpSize; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2599 | } |
| 2600 | |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2601 | /// SS3I_unop_rm_int_16 - Simple SSSE3 unary operator whose type is v*i16. |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 2602 | multiclass SS3I_unop_rm_int_16<bits<8> opc, string OpcodeStr, |
| 2603 | Intrinsic IntId64, Intrinsic IntId128> { |
| 2604 | def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), |
| 2605 | (ins VR64:$src), |
| 2606 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2607 | [(set VR64:$dst, (IntId64 VR64:$src))]>; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2608 | |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 2609 | def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), |
| 2610 | (ins i64mem:$src), |
| 2611 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2612 | [(set VR64:$dst, |
| 2613 | (IntId64 |
| 2614 | (bitconvert (memopv4i16 addr:$src))))]>; |
| 2615 | |
| 2616 | def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst), |
| 2617 | (ins VR128:$src), |
| 2618 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2619 | [(set VR128:$dst, (IntId128 VR128:$src))]>, |
| 2620 | OpSize; |
| 2621 | |
| 2622 | def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst), |
| 2623 | (ins i128mem:$src), |
| 2624 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2625 | [(set VR128:$dst, |
| 2626 | (IntId128 |
| 2627 | (bitconvert (memopv8i16 addr:$src))))]>, OpSize; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2628 | } |
| 2629 | |
| 2630 | /// SS3I_unop_rm_int_32 - Simple SSSE3 unary operator whose type is v*i32. |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 2631 | multiclass SS3I_unop_rm_int_32<bits<8> opc, string OpcodeStr, |
| 2632 | Intrinsic IntId64, Intrinsic IntId128> { |
| 2633 | def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), |
| 2634 | (ins VR64:$src), |
| 2635 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2636 | [(set VR64:$dst, (IntId64 VR64:$src))]>; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2637 | |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 2638 | def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), |
| 2639 | (ins i64mem:$src), |
| 2640 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2641 | [(set VR64:$dst, |
| 2642 | (IntId64 |
| 2643 | (bitconvert (memopv2i32 addr:$src))))]>; |
| 2644 | |
| 2645 | def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst), |
| 2646 | (ins VR128:$src), |
| 2647 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2648 | [(set VR128:$dst, (IntId128 VR128:$src))]>, |
| 2649 | OpSize; |
| 2650 | |
| 2651 | def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst), |
| 2652 | (ins i128mem:$src), |
| 2653 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 2654 | [(set VR128:$dst, |
| 2655 | (IntId128 |
| 2656 | (bitconvert (memopv4i32 addr:$src))))]>, OpSize; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2657 | } |
| 2658 | |
| 2659 | defm PABSB : SS3I_unop_rm_int_8 <0x1C, "pabsb", |
| 2660 | int_x86_ssse3_pabs_b, |
| 2661 | int_x86_ssse3_pabs_b_128>; |
| 2662 | defm PABSW : SS3I_unop_rm_int_16<0x1D, "pabsw", |
| 2663 | int_x86_ssse3_pabs_w, |
| 2664 | int_x86_ssse3_pabs_w_128>; |
| 2665 | defm PABSD : SS3I_unop_rm_int_32<0x1E, "pabsd", |
| 2666 | int_x86_ssse3_pabs_d, |
| 2667 | int_x86_ssse3_pabs_d_128>; |
| 2668 | |
| 2669 | /// SS3I_binop_rm_int_8 - Simple SSSE3 binary operator whose type is v*i8. |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2670 | let Constraints = "$src1 = $dst" in { |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2671 | multiclass SS3I_binop_rm_int_8<bits<8> opc, string OpcodeStr, |
| 2672 | Intrinsic IntId64, Intrinsic IntId128, |
| 2673 | bit Commutable = 0> { |
| 2674 | def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), |
| 2675 | (ins VR64:$src1, VR64:$src2), |
| 2676 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2677 | [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> { |
| 2678 | let isCommutable = Commutable; |
| 2679 | } |
| 2680 | def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), |
| 2681 | (ins VR64:$src1, i64mem:$src2), |
| 2682 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2683 | [(set VR64:$dst, |
| 2684 | (IntId64 VR64:$src1, |
| 2685 | (bitconvert (memopv8i8 addr:$src2))))]>; |
| 2686 | |
| 2687 | def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst), |
| 2688 | (ins VR128:$src1, VR128:$src2), |
| 2689 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2690 | [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>, |
| 2691 | OpSize { |
| 2692 | let isCommutable = Commutable; |
| 2693 | } |
| 2694 | def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst), |
| 2695 | (ins VR128:$src1, i128mem:$src2), |
| 2696 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2697 | [(set VR128:$dst, |
| 2698 | (IntId128 VR128:$src1, |
| 2699 | (bitconvert (memopv16i8 addr:$src2))))]>, OpSize; |
| 2700 | } |
| 2701 | } |
| 2702 | |
| 2703 | /// SS3I_binop_rm_int_16 - Simple SSSE3 binary operator whose type is v*i16. |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2704 | let Constraints = "$src1 = $dst" in { |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2705 | multiclass SS3I_binop_rm_int_16<bits<8> opc, string OpcodeStr, |
| 2706 | Intrinsic IntId64, Intrinsic IntId128, |
| 2707 | bit Commutable = 0> { |
| 2708 | def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), |
| 2709 | (ins VR64:$src1, VR64:$src2), |
| 2710 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2711 | [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> { |
| 2712 | let isCommutable = Commutable; |
| 2713 | } |
| 2714 | def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), |
| 2715 | (ins VR64:$src1, i64mem:$src2), |
| 2716 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2717 | [(set VR64:$dst, |
| 2718 | (IntId64 VR64:$src1, |
| 2719 | (bitconvert (memopv4i16 addr:$src2))))]>; |
| 2720 | |
| 2721 | def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst), |
| 2722 | (ins VR128:$src1, VR128:$src2), |
| 2723 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2724 | [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>, |
| 2725 | OpSize { |
| 2726 | let isCommutable = Commutable; |
| 2727 | } |
| 2728 | def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst), |
| 2729 | (ins VR128:$src1, i128mem:$src2), |
| 2730 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2731 | [(set VR128:$dst, |
| 2732 | (IntId128 VR128:$src1, |
| 2733 | (bitconvert (memopv8i16 addr:$src2))))]>, OpSize; |
| 2734 | } |
| 2735 | } |
| 2736 | |
| 2737 | /// SS3I_binop_rm_int_32 - Simple SSSE3 binary operator whose type is v*i32. |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2738 | let Constraints = "$src1 = $dst" in { |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2739 | multiclass SS3I_binop_rm_int_32<bits<8> opc, string OpcodeStr, |
| 2740 | Intrinsic IntId64, Intrinsic IntId128, |
| 2741 | bit Commutable = 0> { |
| 2742 | def rr64 : SS38I<opc, MRMSrcReg, (outs VR64:$dst), |
| 2743 | (ins VR64:$src1, VR64:$src2), |
| 2744 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2745 | [(set VR64:$dst, (IntId64 VR64:$src1, VR64:$src2))]> { |
| 2746 | let isCommutable = Commutable; |
| 2747 | } |
| 2748 | def rm64 : SS38I<opc, MRMSrcMem, (outs VR64:$dst), |
| 2749 | (ins VR64:$src1, i64mem:$src2), |
| 2750 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2751 | [(set VR64:$dst, |
| 2752 | (IntId64 VR64:$src1, |
| 2753 | (bitconvert (memopv2i32 addr:$src2))))]>; |
| 2754 | |
| 2755 | def rr128 : SS38I<opc, MRMSrcReg, (outs VR128:$dst), |
| 2756 | (ins VR128:$src1, VR128:$src2), |
| 2757 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2758 | [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>, |
| 2759 | OpSize { |
| 2760 | let isCommutable = Commutable; |
| 2761 | } |
| 2762 | def rm128 : SS38I<opc, MRMSrcMem, (outs VR128:$dst), |
| 2763 | (ins VR128:$src1, i128mem:$src2), |
| 2764 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 2765 | [(set VR128:$dst, |
| 2766 | (IntId128 VR128:$src1, |
| 2767 | (bitconvert (memopv4i32 addr:$src2))))]>, OpSize; |
| 2768 | } |
| 2769 | } |
| 2770 | |
| 2771 | defm PHADDW : SS3I_binop_rm_int_16<0x01, "phaddw", |
| 2772 | int_x86_ssse3_phadd_w, |
Evan Cheng | 944e441 | 2008-06-16 21:16:24 +0000 | [diff] [blame] | 2773 | int_x86_ssse3_phadd_w_128>; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2774 | defm PHADDD : SS3I_binop_rm_int_32<0x02, "phaddd", |
| 2775 | int_x86_ssse3_phadd_d, |
Evan Cheng | 944e441 | 2008-06-16 21:16:24 +0000 | [diff] [blame] | 2776 | int_x86_ssse3_phadd_d_128>; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2777 | defm PHADDSW : SS3I_binop_rm_int_16<0x03, "phaddsw", |
| 2778 | int_x86_ssse3_phadd_sw, |
Evan Cheng | 944e441 | 2008-06-16 21:16:24 +0000 | [diff] [blame] | 2779 | int_x86_ssse3_phadd_sw_128>; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2780 | defm PHSUBW : SS3I_binop_rm_int_16<0x05, "phsubw", |
| 2781 | int_x86_ssse3_phsub_w, |
| 2782 | int_x86_ssse3_phsub_w_128>; |
| 2783 | defm PHSUBD : SS3I_binop_rm_int_32<0x06, "phsubd", |
| 2784 | int_x86_ssse3_phsub_d, |
| 2785 | int_x86_ssse3_phsub_d_128>; |
| 2786 | defm PHSUBSW : SS3I_binop_rm_int_16<0x07, "phsubsw", |
| 2787 | int_x86_ssse3_phsub_sw, |
| 2788 | int_x86_ssse3_phsub_sw_128>; |
| 2789 | defm PMADDUBSW : SS3I_binop_rm_int_8 <0x04, "pmaddubsw", |
| 2790 | int_x86_ssse3_pmadd_ub_sw, |
Evan Cheng | 944e441 | 2008-06-16 21:16:24 +0000 | [diff] [blame] | 2791 | int_x86_ssse3_pmadd_ub_sw_128>; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2792 | defm PMULHRSW : SS3I_binop_rm_int_16<0x0B, "pmulhrsw", |
| 2793 | int_x86_ssse3_pmul_hr_sw, |
| 2794 | int_x86_ssse3_pmul_hr_sw_128, 1>; |
| 2795 | defm PSHUFB : SS3I_binop_rm_int_8 <0x00, "pshufb", |
| 2796 | int_x86_ssse3_pshuf_b, |
| 2797 | int_x86_ssse3_pshuf_b_128>; |
| 2798 | defm PSIGNB : SS3I_binop_rm_int_8 <0x08, "psignb", |
| 2799 | int_x86_ssse3_psign_b, |
| 2800 | int_x86_ssse3_psign_b_128>; |
| 2801 | defm PSIGNW : SS3I_binop_rm_int_16<0x09, "psignw", |
| 2802 | int_x86_ssse3_psign_w, |
| 2803 | int_x86_ssse3_psign_w_128>; |
Evan Cheng | abfed47 | 2009-05-28 18:48:53 +0000 | [diff] [blame] | 2804 | defm PSIGND : SS3I_binop_rm_int_32<0x0A, "psignd", |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2805 | int_x86_ssse3_psign_d, |
| 2806 | int_x86_ssse3_psign_d_128>; |
| 2807 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 2808 | let Constraints = "$src1 = $dst" in { |
Bill Wendling | 1dc817c | 2007-08-10 09:00:17 +0000 | [diff] [blame] | 2809 | def PALIGNR64rr : SS3AI<0x0F, MRMSrcReg, (outs VR64:$dst), |
| 2810 | (ins VR64:$src1, VR64:$src2, i16imm:$src3), |
Dale Johannesen | 576b27e | 2007-10-11 20:58:37 +0000 | [diff] [blame] | 2811 | "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Bill Wendling | 1dc817c | 2007-08-10 09:00:17 +0000 | [diff] [blame] | 2812 | [(set VR64:$dst, |
| 2813 | (int_x86_ssse3_palign_r |
| 2814 | VR64:$src1, VR64:$src2, |
| 2815 | imm:$src3))]>; |
Dan Gohman | bcb9d46 | 2008-05-28 01:50:19 +0000 | [diff] [blame] | 2816 | def PALIGNR64rm : SS3AI<0x0F, MRMSrcMem, (outs VR64:$dst), |
Bill Wendling | 1dc817c | 2007-08-10 09:00:17 +0000 | [diff] [blame] | 2817 | (ins VR64:$src1, i64mem:$src2, i16imm:$src3), |
Dale Johannesen | 576b27e | 2007-10-11 20:58:37 +0000 | [diff] [blame] | 2818 | "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Bill Wendling | 1dc817c | 2007-08-10 09:00:17 +0000 | [diff] [blame] | 2819 | [(set VR64:$dst, |
| 2820 | (int_x86_ssse3_palign_r |
| 2821 | VR64:$src1, |
| 2822 | (bitconvert (memopv2i32 addr:$src2)), |
| 2823 | imm:$src3))]>; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2824 | |
Bill Wendling | 1dc817c | 2007-08-10 09:00:17 +0000 | [diff] [blame] | 2825 | def PALIGNR128rr : SS3AI<0x0F, MRMSrcReg, (outs VR128:$dst), |
| 2826 | (ins VR128:$src1, VR128:$src2, i32imm:$src3), |
Dale Johannesen | 576b27e | 2007-10-11 20:58:37 +0000 | [diff] [blame] | 2827 | "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Bill Wendling | 1dc817c | 2007-08-10 09:00:17 +0000 | [diff] [blame] | 2828 | [(set VR128:$dst, |
| 2829 | (int_x86_ssse3_palign_r_128 |
| 2830 | VR128:$src1, VR128:$src2, |
| 2831 | imm:$src3))]>, OpSize; |
Dan Gohman | bcb9d46 | 2008-05-28 01:50:19 +0000 | [diff] [blame] | 2832 | def PALIGNR128rm : SS3AI<0x0F, MRMSrcMem, (outs VR128:$dst), |
Bill Wendling | 1dc817c | 2007-08-10 09:00:17 +0000 | [diff] [blame] | 2833 | (ins VR128:$src1, i128mem:$src2, i32imm:$src3), |
Dale Johannesen | 576b27e | 2007-10-11 20:58:37 +0000 | [diff] [blame] | 2834 | "palignr\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
Bill Wendling | 1dc817c | 2007-08-10 09:00:17 +0000 | [diff] [blame] | 2835 | [(set VR128:$dst, |
| 2836 | (int_x86_ssse3_palign_r_128 |
| 2837 | VR128:$src1, |
| 2838 | (bitconvert (memopv4i32 addr:$src2)), |
| 2839 | imm:$src3))]>, OpSize; |
Bill Wendling | 9868029 | 2007-08-10 06:22:27 +0000 | [diff] [blame] | 2840 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2841 | |
Nate Begeman | 2c87c42 | 2009-02-23 08:49:38 +0000 | [diff] [blame] | 2842 | def : Pat<(X86pshufb VR128:$src, VR128:$mask), |
| 2843 | (PSHUFBrr128 VR128:$src, VR128:$mask)>, Requires<[HasSSSE3]>; |
| 2844 | def : Pat<(X86pshufb VR128:$src, (bc_v16i8 (memopv2i64 addr:$mask))), |
| 2845 | (PSHUFBrm128 VR128:$src, addr:$mask)>, Requires<[HasSSSE3]>; |
| 2846 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2847 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2848 | // Non-Instruction Patterns |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2849 | //===---------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2850 | |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2851 | // extload f32 -> f64. This matches load+fextend because we have a hack in |
| 2852 | // the isel (PreprocessForFPConvert) that can introduce loads after dag |
| 2853 | // combine. |
Chris Lattner | dec9cb5 | 2008-01-24 08:07:48 +0000 | [diff] [blame] | 2854 | // Since these loads aren't folded into the fextend, we have to match it |
| 2855 | // explicitly here. |
| 2856 | let Predicates = [HasSSE2] in |
| 2857 | def : Pat<(fextend (loadf32 addr:$src)), |
| 2858 | (CVTSS2SDrm addr:$src)>; |
| 2859 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2860 | // bit_convert |
| 2861 | let Predicates = [HasSSE2] in { |
| 2862 | def : Pat<(v2i64 (bitconvert (v4i32 VR128:$src))), (v2i64 VR128:$src)>; |
| 2863 | def : Pat<(v2i64 (bitconvert (v8i16 VR128:$src))), (v2i64 VR128:$src)>; |
| 2864 | def : Pat<(v2i64 (bitconvert (v16i8 VR128:$src))), (v2i64 VR128:$src)>; |
| 2865 | def : Pat<(v2i64 (bitconvert (v2f64 VR128:$src))), (v2i64 VR128:$src)>; |
| 2866 | def : Pat<(v2i64 (bitconvert (v4f32 VR128:$src))), (v2i64 VR128:$src)>; |
| 2867 | def : Pat<(v4i32 (bitconvert (v2i64 VR128:$src))), (v4i32 VR128:$src)>; |
| 2868 | def : Pat<(v4i32 (bitconvert (v8i16 VR128:$src))), (v4i32 VR128:$src)>; |
| 2869 | def : Pat<(v4i32 (bitconvert (v16i8 VR128:$src))), (v4i32 VR128:$src)>; |
| 2870 | def : Pat<(v4i32 (bitconvert (v2f64 VR128:$src))), (v4i32 VR128:$src)>; |
| 2871 | def : Pat<(v4i32 (bitconvert (v4f32 VR128:$src))), (v4i32 VR128:$src)>; |
| 2872 | def : Pat<(v8i16 (bitconvert (v2i64 VR128:$src))), (v8i16 VR128:$src)>; |
| 2873 | def : Pat<(v8i16 (bitconvert (v4i32 VR128:$src))), (v8i16 VR128:$src)>; |
| 2874 | def : Pat<(v8i16 (bitconvert (v16i8 VR128:$src))), (v8i16 VR128:$src)>; |
| 2875 | def : Pat<(v8i16 (bitconvert (v2f64 VR128:$src))), (v8i16 VR128:$src)>; |
| 2876 | def : Pat<(v8i16 (bitconvert (v4f32 VR128:$src))), (v8i16 VR128:$src)>; |
| 2877 | def : Pat<(v16i8 (bitconvert (v2i64 VR128:$src))), (v16i8 VR128:$src)>; |
| 2878 | def : Pat<(v16i8 (bitconvert (v4i32 VR128:$src))), (v16i8 VR128:$src)>; |
| 2879 | def : Pat<(v16i8 (bitconvert (v8i16 VR128:$src))), (v16i8 VR128:$src)>; |
| 2880 | def : Pat<(v16i8 (bitconvert (v2f64 VR128:$src))), (v16i8 VR128:$src)>; |
| 2881 | def : Pat<(v16i8 (bitconvert (v4f32 VR128:$src))), (v16i8 VR128:$src)>; |
| 2882 | def : Pat<(v4f32 (bitconvert (v2i64 VR128:$src))), (v4f32 VR128:$src)>; |
| 2883 | def : Pat<(v4f32 (bitconvert (v4i32 VR128:$src))), (v4f32 VR128:$src)>; |
| 2884 | def : Pat<(v4f32 (bitconvert (v8i16 VR128:$src))), (v4f32 VR128:$src)>; |
| 2885 | def : Pat<(v4f32 (bitconvert (v16i8 VR128:$src))), (v4f32 VR128:$src)>; |
| 2886 | def : Pat<(v4f32 (bitconvert (v2f64 VR128:$src))), (v4f32 VR128:$src)>; |
| 2887 | def : Pat<(v2f64 (bitconvert (v2i64 VR128:$src))), (v2f64 VR128:$src)>; |
| 2888 | def : Pat<(v2f64 (bitconvert (v4i32 VR128:$src))), (v2f64 VR128:$src)>; |
| 2889 | def : Pat<(v2f64 (bitconvert (v8i16 VR128:$src))), (v2f64 VR128:$src)>; |
| 2890 | def : Pat<(v2f64 (bitconvert (v16i8 VR128:$src))), (v2f64 VR128:$src)>; |
| 2891 | def : Pat<(v2f64 (bitconvert (v4f32 VR128:$src))), (v2f64 VR128:$src)>; |
| 2892 | } |
| 2893 | |
| 2894 | // Move scalar to XMM zero-extended |
| 2895 | // movd to XMM register zero-extends |
| 2896 | let AddedComplexity = 15 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2897 | // Zeroing a VR128 then do a MOVS{S|D} to the lower bits. |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2898 | def : Pat<(v2f64 (X86vzmovl (v2f64 (scalar_to_vector FR64:$src)))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2899 | (MOVLSD2PDrr (V_SET0), FR64:$src)>, Requires<[HasSSE2]>; |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 2900 | def : Pat<(v4f32 (X86vzmovl (v4f32 (scalar_to_vector FR32:$src)))), |
Anders Carlsson | fd7e450 | 2008-10-07 16:14:11 +0000 | [diff] [blame] | 2901 | (MOVLSS2PSrr (V_SET0), FR32:$src)>, Requires<[HasSSE1]>; |
Evan Cheng | e259e87 | 2008-05-09 23:37:55 +0000 | [diff] [blame] | 2902 | def : Pat<(v4f32 (X86vzmovl (v4f32 VR128:$src))), |
Anders Carlsson | fd7e450 | 2008-10-07 16:14:11 +0000 | [diff] [blame] | 2903 | (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>; |
Evan Cheng | 7fe0ff0 | 2008-07-10 01:08:23 +0000 | [diff] [blame] | 2904 | def : Pat<(v4i32 (X86vzmovl (v4i32 VR128:$src))), |
Anders Carlsson | fd7e450 | 2008-10-07 16:14:11 +0000 | [diff] [blame] | 2905 | (MOVLPSrr (V_SET0), VR128:$src)>, Requires<[HasSSE1]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2906 | } |
| 2907 | |
| 2908 | // Splat v2f64 / v2i64 |
| 2909 | let AddedComplexity = 10 in { |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2910 | def : Pat<(splat_lo (v2f64 VR128:$src), (undef)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2911 | (UNPCKLPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2912 | def : Pat<(unpckh (v2f64 VR128:$src), (undef)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2913 | (UNPCKHPDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2914 | def : Pat<(splat_lo (v2i64 VR128:$src), (undef)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2915 | (PUNPCKLQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2916 | def : Pat<(unpckh (v2i64 VR128:$src), (undef)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2917 | (PUNPCKHQDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
| 2918 | } |
| 2919 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2920 | // Special unary SHUFPSrri case. |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2921 | def : Pat<(v4f32 (pshufd:$src3 VR128:$src1, (undef))), |
| 2922 | (SHUFPSrri VR128:$src1, VR128:$src1, |
| 2923 | (SHUFFLE_get_shuf_imm VR128:$src3))>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2924 | Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2925 | let AddedComplexity = 5 in |
| 2926 | def : Pat<(v4f32 (pshufd:$src2 VR128:$src1, (undef))), |
| 2927 | (PSHUFDri VR128:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>, |
| 2928 | Requires<[HasSSE2]>; |
Dan Gohman | 7dc1901 | 2007-08-02 21:17:01 +0000 | [diff] [blame] | 2929 | // Special unary SHUFPDrri case. |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2930 | def : Pat<(v2i64 (pshufd:$src3 VR128:$src1, (undef))), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2931 | (SHUFPDrri VR128:$src1, VR128:$src1, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2932 | (SHUFFLE_get_shuf_imm VR128:$src3))>, |
| 2933 | Requires<[HasSSE2]>; |
| 2934 | // Special unary SHUFPDrri case. |
| 2935 | def : Pat<(v2f64 (pshufd:$src3 VR128:$src1, (undef))), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2936 | (SHUFPDrri VR128:$src1, VR128:$src1, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2937 | (SHUFFLE_get_shuf_imm VR128:$src3))>, |
Dan Gohman | 7dc1901 | 2007-08-02 21:17:01 +0000 | [diff] [blame] | 2938 | Requires<[HasSSE2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2939 | // Unary v4f32 shuffle with PSHUF* in order to fold a load. |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2940 | def : Pat<(pshufd:$src2 (bc_v4i32 (memopv4f32 addr:$src1)), (undef)), |
| 2941 | (PSHUFDmi addr:$src1, (SHUFFLE_get_shuf_imm VR128:$src2))>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2942 | Requires<[HasSSE2]>; |
Evan Cheng | 13559d6 | 2008-09-26 23:41:32 +0000 | [diff] [blame] | 2943 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2944 | // Special binary v4i32 shuffle cases with SHUFPS. |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2945 | def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (v4i32 VR128:$src2))), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2946 | (SHUFPSrri VR128:$src1, VR128:$src2, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2947 | (SHUFFLE_get_shuf_imm VR128:$src3))>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2948 | Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2949 | def : Pat<(v4i32 (shufp:$src3 VR128:$src1, (bc_v4i32 (memopv2i64 addr:$src2)))), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2950 | (SHUFPSrmi VR128:$src1, addr:$src2, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2951 | (SHUFFLE_get_shuf_imm VR128:$src3))>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2952 | Requires<[HasSSE2]>; |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2953 | // Special binary v2i64 shuffle cases using SHUFPDrri. |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2954 | def : Pat<(v2i64 (shufp:$src3 VR128:$src1, VR128:$src2)), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 2955 | (SHUFPDrri VR128:$src1, VR128:$src2, |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2956 | (SHUFFLE_get_shuf_imm VR128:$src3))>, |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 2957 | Requires<[HasSSE2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2958 | |
| 2959 | // vector_shuffle v1, <undef>, <0, 0, 1, 1, ...> |
Evan Cheng | 13559d6 | 2008-09-26 23:41:32 +0000 | [diff] [blame] | 2960 | let AddedComplexity = 15 in { |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2961 | def : Pat<(v4i32 (unpckl_undef:$src2 VR128:$src, (undef))), |
| 2962 | (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>, |
Evan Cheng | 13559d6 | 2008-09-26 23:41:32 +0000 | [diff] [blame] | 2963 | Requires<[OptForSpeed, HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2964 | def : Pat<(v4f32 (unpckl_undef:$src2 VR128:$src, (undef))), |
| 2965 | (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>, |
Evan Cheng | 13559d6 | 2008-09-26 23:41:32 +0000 | [diff] [blame] | 2966 | Requires<[OptForSpeed, HasSSE2]>; |
| 2967 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2968 | let AddedComplexity = 10 in { |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2969 | def : Pat<(v4f32 (unpckl_undef VR128:$src, (undef))), |
Evan Cheng | 09d4507 | 2008-09-26 21:26:30 +0000 | [diff] [blame] | 2970 | (UNPCKLPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2971 | def : Pat<(v16i8 (unpckl_undef VR128:$src, (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2972 | (PUNPCKLBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2973 | def : Pat<(v8i16 (unpckl_undef VR128:$src, (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2974 | (PUNPCKLWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2975 | def : Pat<(v4i32 (unpckl_undef VR128:$src, (undef))), |
Evan Cheng | 09d4507 | 2008-09-26 21:26:30 +0000 | [diff] [blame] | 2976 | (PUNPCKLDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2977 | } |
| 2978 | |
| 2979 | // vector_shuffle v1, <undef>, <2, 2, 3, 3, ...> |
Evan Cheng | 13559d6 | 2008-09-26 23:41:32 +0000 | [diff] [blame] | 2980 | let AddedComplexity = 15 in { |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2981 | def : Pat<(v4i32 (unpckh_undef:$src2 VR128:$src, (undef))), |
| 2982 | (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>, |
Evan Cheng | 13559d6 | 2008-09-26 23:41:32 +0000 | [diff] [blame] | 2983 | Requires<[OptForSpeed, HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2984 | def : Pat<(v4f32 (unpckh_undef:$src2 VR128:$src, (undef))), |
| 2985 | (PSHUFDri VR128:$src, (SHUFFLE_get_shuf_imm VR128:$src2))>, |
Evan Cheng | 13559d6 | 2008-09-26 23:41:32 +0000 | [diff] [blame] | 2986 | Requires<[OptForSpeed, HasSSE2]>; |
| 2987 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2988 | let AddedComplexity = 10 in { |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2989 | def : Pat<(v4f32 (unpckh_undef VR128:$src, (undef))), |
Evan Cheng | 09d4507 | 2008-09-26 21:26:30 +0000 | [diff] [blame] | 2990 | (UNPCKHPSrr VR128:$src, VR128:$src)>, Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2991 | def : Pat<(v16i8 (unpckh_undef VR128:$src, (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2992 | (PUNPCKHBWrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2993 | def : Pat<(v8i16 (unpckh_undef VR128:$src, (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2994 | (PUNPCKHWDrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 2995 | def : Pat<(v4i32 (unpckh_undef VR128:$src, (undef))), |
Evan Cheng | 09d4507 | 2008-09-26 21:26:30 +0000 | [diff] [blame] | 2996 | (PUNPCKHDQrr VR128:$src, VR128:$src)>, Requires<[HasSSE2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2997 | } |
| 2998 | |
Evan Cheng | 13559d6 | 2008-09-26 23:41:32 +0000 | [diff] [blame] | 2999 | let AddedComplexity = 20 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3000 | // vector_shuffle v1, v2 <0, 1, 4, 5> using MOVLHPS |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3001 | def : Pat<(v4i32 (movhp VR128:$src1, VR128:$src2)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3002 | (MOVLHPSrr VR128:$src1, VR128:$src2)>; |
| 3003 | |
| 3004 | // vector_shuffle v1, v2 <6, 7, 2, 3> using MOVHLPS |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3005 | def : Pat<(v4i32 (movhlps VR128:$src1, VR128:$src2)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3006 | (MOVHLPSrr VR128:$src1, VR128:$src2)>; |
| 3007 | |
| 3008 | // vector_shuffle v1, undef <2, ?, ?, ?> using MOVHLPS |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3009 | def : Pat<(v4f32 (movhlps_undef VR128:$src1, (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3010 | (MOVHLPSrr VR128:$src1, VR128:$src1)>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3011 | def : Pat<(v4i32 (movhlps_undef VR128:$src1, (undef))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3012 | (MOVHLPSrr VR128:$src1, VR128:$src1)>; |
| 3013 | } |
| 3014 | |
| 3015 | let AddedComplexity = 20 in { |
| 3016 | // vector_shuffle v1, (load v2) <4, 5, 2, 3> using MOVLPS |
| 3017 | // vector_shuffle v1, (load v2) <0, 1, 4, 5> using MOVHPS |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3018 | def : Pat<(v4f32 (movlp VR128:$src1, (load addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3019 | (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3020 | def : Pat<(v2f64 (movlp VR128:$src1, (load addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3021 | (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3022 | def : Pat<(v4f32 (movhp VR128:$src1, (load addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3023 | (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3024 | def : Pat<(v2f64 (movhp VR128:$src1, (load addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3025 | (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; |
| 3026 | |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3027 | def : Pat<(v4i32 (movlp VR128:$src1, (load addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3028 | (MOVLPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3029 | def : Pat<(v2i64 (movlp VR128:$src1, (load addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3030 | (MOVLPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3031 | def : Pat<(v4i32 (movhp VR128:$src1, (load addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3032 | (MOVHPSrm VR128:$src1, addr:$src2)>, Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3033 | def : Pat<(v2i64 (movhp VR128:$src1, (load addr:$src2))), |
Evan Cheng | 1ff2ea5 | 2008-05-23 18:00:18 +0000 | [diff] [blame] | 3034 | (MOVHPDrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3035 | } |
| 3036 | |
Evan Cheng | 2b2a701 | 2008-05-23 21:23:16 +0000 | [diff] [blame] | 3037 | // (store (vector_shuffle (load addr), v2, <4, 5, 2, 3>), addr) using MOVLPS |
| 3038 | // (store (vector_shuffle (load addr), v2, <0, 1, 4, 5>), addr) using MOVHPS |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3039 | def : Pat<(store (v4f32 (movlp (load addr:$src1), VR128:$src2)), addr:$src1), |
Evan Cheng | 2b2a701 | 2008-05-23 21:23:16 +0000 | [diff] [blame] | 3040 | (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3041 | def : Pat<(store (v2f64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1), |
Evan Cheng | 2b2a701 | 2008-05-23 21:23:16 +0000 | [diff] [blame] | 3042 | (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3043 | def : Pat<(store (v4f32 (movhp (load addr:$src1), VR128:$src2)), addr:$src1), |
Evan Cheng | 2b2a701 | 2008-05-23 21:23:16 +0000 | [diff] [blame] | 3044 | (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3045 | def : Pat<(store (v2f64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1), |
Evan Cheng | 2b2a701 | 2008-05-23 21:23:16 +0000 | [diff] [blame] | 3046 | (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
| 3047 | |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3048 | def : Pat<(store (v4i32 (movlp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)), |
| 3049 | addr:$src1), |
Evan Cheng | 2b2a701 | 2008-05-23 21:23:16 +0000 | [diff] [blame] | 3050 | (MOVLPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3051 | def : Pat<(store (v2i64 (movlp (load addr:$src1), VR128:$src2)), addr:$src1), |
Evan Cheng | 2b2a701 | 2008-05-23 21:23:16 +0000 | [diff] [blame] | 3052 | (MOVLPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3053 | def : Pat<(store (v4i32 (movhp (bc_v4i32 (loadv2i64 addr:$src1)), VR128:$src2)), |
| 3054 | addr:$src1), |
Evan Cheng | 2b2a701 | 2008-05-23 21:23:16 +0000 | [diff] [blame] | 3055 | (MOVHPSmr addr:$src1, VR128:$src2)>, Requires<[HasSSE1]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3056 | def : Pat<(store (v2i64 (movhp (load addr:$src1), VR128:$src2)), addr:$src1), |
Evan Cheng | 2b2a701 | 2008-05-23 21:23:16 +0000 | [diff] [blame] | 3057 | (MOVHPDmr addr:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
| 3058 | |
| 3059 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3060 | let AddedComplexity = 15 in { |
| 3061 | // Setting the lowest element in the vector. |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3062 | def : Pat<(v4i32 (movl VR128:$src1, VR128:$src2)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3063 | (MOVLPSrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3064 | def : Pat<(v2i64 (movl VR128:$src1, VR128:$src2)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3065 | (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
| 3066 | |
| 3067 | // vector_shuffle v1, v2 <4, 5, 2, 3> using MOVLPDrr (movsd) |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3068 | def : Pat<(v4f32 (movlp VR128:$src1, VR128:$src2)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3069 | (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3070 | def : Pat<(v4i32 (movlp VR128:$src1, VR128:$src2)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3071 | (MOVLPDrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
| 3072 | } |
| 3073 | |
Eli Friedman | 27d1974 | 2009-06-19 07:00:55 +0000 | [diff] [blame] | 3074 | // vector_shuffle v1, v2 <4, 5, 2, 3> using SHUFPSrri (we prefer movsd, but |
| 3075 | // fall back to this for SSE1) |
| 3076 | def : Pat<(v4f32 (movlp:$src3 VR128:$src1, (v4f32 VR128:$src2))), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3077 | (SHUFPSrri VR128:$src2, VR128:$src1, |
Eli Friedman | 27d1974 | 2009-06-19 07:00:55 +0000 | [diff] [blame] | 3078 | (SHUFFLE_get_shuf_imm VR128:$src3))>, Requires<[HasSSE1]>; |
| 3079 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3080 | // Set lowest element and zero upper elements. |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 3081 | let AddedComplexity = 15 in |
Nate Begeman | 543d214 | 2009-04-27 18:41:29 +0000 | [diff] [blame] | 3082 | def : Pat<(v2f64 (movl immAllZerosV_bc, VR128:$src)), |
Evan Cheng | 15e8f5a | 2007-12-15 03:00:47 +0000 | [diff] [blame] | 3083 | (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>; |
Evan Cheng | e9b9c67 | 2008-05-09 21:53:03 +0000 | [diff] [blame] | 3084 | def : Pat<(v2f64 (X86vzmovl (v2f64 VR128:$src))), |
Evan Cheng | d09a8a0 | 2008-05-08 22:35:02 +0000 | [diff] [blame] | 3085 | (MOVZPQILo2PQIrr VR128:$src)>, Requires<[HasSSE2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3086 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3087 | // Some special case pandn patterns. |
| 3088 | def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))), |
| 3089 | VR128:$src2)), |
| 3090 | (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
| 3091 | def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))), |
| 3092 | VR128:$src2)), |
| 3093 | (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
| 3094 | def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))), |
| 3095 | VR128:$src2)), |
| 3096 | (PANDNrr VR128:$src1, VR128:$src2)>, Requires<[HasSSE2]>; |
| 3097 | |
| 3098 | def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v4i32 immAllOnesV))), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 3099 | (memop addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3100 | (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; |
| 3101 | def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v8i16 immAllOnesV))), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 3102 | (memop addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3103 | (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; |
| 3104 | def : Pat<(v2i64 (and (xor VR128:$src1, (bc_v2i64 (v16i8 immAllOnesV))), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 3105 | (memop addr:$src2))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 3106 | (PANDNrm VR128:$src1, addr:$src2)>, Requires<[HasSSE2]>; |
| 3107 | |
Nate Begeman | 78246ca | 2007-11-17 03:58:34 +0000 | [diff] [blame] | 3108 | // vector -> vector casts |
| 3109 | def : Pat<(v4f32 (sint_to_fp (v4i32 VR128:$src))), |
| 3110 | (Int_CVTDQ2PSrr VR128:$src)>, Requires<[HasSSE2]>; |
| 3111 | def : Pat<(v4i32 (fp_to_sint (v4f32 VR128:$src))), |
| 3112 | (Int_CVTTPS2DQrr VR128:$src)>, Requires<[HasSSE2]>; |
Eli Friedman | 7fa52ca | 2008-09-05 23:07:03 +0000 | [diff] [blame] | 3113 | def : Pat<(v2f64 (sint_to_fp (v2i32 VR64:$src))), |
| 3114 | (Int_CVTPI2PDrr VR64:$src)>, Requires<[HasSSE2]>; |
| 3115 | def : Pat<(v2i32 (fp_to_sint (v2f64 VR128:$src))), |
| 3116 | (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>; |
Nate Begeman | 78246ca | 2007-11-17 03:58:34 +0000 | [diff] [blame] | 3117 | |
Evan Cheng | 51a49b2 | 2007-07-20 00:27:43 +0000 | [diff] [blame] | 3118 | // Use movaps / movups for SSE integer load / store (one byte shorter). |
Dan Gohman | 1182170 | 2007-07-27 17:16:43 +0000 | [diff] [blame] | 3119 | def : Pat<(alignedloadv4i32 addr:$src), |
| 3120 | (MOVAPSrm addr:$src)>, Requires<[HasSSE1]>; |
| 3121 | def : Pat<(loadv4i32 addr:$src), |
| 3122 | (MOVUPSrm addr:$src)>, Requires<[HasSSE1]>; |
Evan Cheng | 51a49b2 | 2007-07-20 00:27:43 +0000 | [diff] [blame] | 3123 | def : Pat<(alignedloadv2i64 addr:$src), |
| 3124 | (MOVAPSrm addr:$src)>, Requires<[HasSSE2]>; |
| 3125 | def : Pat<(loadv2i64 addr:$src), |
| 3126 | (MOVUPSrm addr:$src)>, Requires<[HasSSE2]>; |
| 3127 | |
| 3128 | def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst), |
| 3129 | (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>; |
| 3130 | def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst), |
| 3131 | (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>; |
| 3132 | def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst), |
| 3133 | (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>; |
| 3134 | def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst), |
| 3135 | (MOVAPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>; |
| 3136 | def : Pat<(store (v2i64 VR128:$src), addr:$dst), |
| 3137 | (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>; |
| 3138 | def : Pat<(store (v4i32 VR128:$src), addr:$dst), |
| 3139 | (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>; |
| 3140 | def : Pat<(store (v8i16 VR128:$src), addr:$dst), |
| 3141 | (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>; |
| 3142 | def : Pat<(store (v16i8 VR128:$src), addr:$dst), |
| 3143 | (MOVUPSmr addr:$dst, VR128:$src)>, Requires<[HasSSE2]>; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3144 | |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3145 | //===----------------------------------------------------------------------===// |
| 3146 | // SSE4.1 Instructions |
| 3147 | //===----------------------------------------------------------------------===// |
| 3148 | |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3149 | multiclass sse41_fp_unop_rm<bits<8> opcps, bits<8> opcpd, |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3150 | string OpcodeStr, |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3151 | Intrinsic V4F32Int, |
Nate Begeman | eb3f543 | 2008-02-04 05:34:34 +0000 | [diff] [blame] | 3152 | Intrinsic V2F64Int> { |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3153 | // Intrinsic operation, reg. |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3154 | // Vector intrinsic operation, reg |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3155 | def PSr_Int : SS4AIi8<opcps, MRMSrcReg, |
Nate Begeman | 72d802a | 2008-02-04 06:00:24 +0000 | [diff] [blame] | 3156 | (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2), |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3157 | !strconcat(OpcodeStr, |
| 3158 | "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
Nate Begeman | eb3f543 | 2008-02-04 05:34:34 +0000 | [diff] [blame] | 3159 | [(set VR128:$dst, (V4F32Int VR128:$src1, imm:$src2))]>, |
| 3160 | OpSize; |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3161 | |
| 3162 | // Vector intrinsic operation, mem |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3163 | def PSm_Int : SS4AIi8<opcps, MRMSrcMem, |
Nate Begeman | 72d802a | 2008-02-04 06:00:24 +0000 | [diff] [blame] | 3164 | (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2), |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3165 | !strconcat(OpcodeStr, |
| 3166 | "ps\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 3167 | [(set VR128:$dst, |
| 3168 | (V4F32Int (memopv4f32 addr:$src1),imm:$src2))]>, |
Nate Begeman | eb3f543 | 2008-02-04 05:34:34 +0000 | [diff] [blame] | 3169 | OpSize; |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3170 | |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3171 | // Vector intrinsic operation, reg |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3172 | def PDr_Int : SS4AIi8<opcpd, MRMSrcReg, |
Nate Begeman | 72d802a | 2008-02-04 06:00:24 +0000 | [diff] [blame] | 3173 | (outs VR128:$dst), (ins VR128:$src1, i32i8imm:$src2), |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3174 | !strconcat(OpcodeStr, |
| 3175 | "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
Nate Begeman | eb3f543 | 2008-02-04 05:34:34 +0000 | [diff] [blame] | 3176 | [(set VR128:$dst, (V2F64Int VR128:$src1, imm:$src2))]>, |
| 3177 | OpSize; |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3178 | |
| 3179 | // Vector intrinsic operation, mem |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3180 | def PDm_Int : SS4AIi8<opcpd, MRMSrcMem, |
Nate Begeman | 72d802a | 2008-02-04 06:00:24 +0000 | [diff] [blame] | 3181 | (outs VR128:$dst), (ins f128mem:$src1, i32i8imm:$src2), |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3182 | !strconcat(OpcodeStr, |
| 3183 | "pd\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 3184 | [(set VR128:$dst, |
| 3185 | (V2F64Int (memopv2f64 addr:$src1),imm:$src2))]>, |
Nate Begeman | eb3f543 | 2008-02-04 05:34:34 +0000 | [diff] [blame] | 3186 | OpSize; |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3187 | } |
| 3188 | |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3189 | let Constraints = "$src1 = $dst" in { |
| 3190 | multiclass sse41_fp_binop_rm<bits<8> opcss, bits<8> opcsd, |
| 3191 | string OpcodeStr, |
| 3192 | Intrinsic F32Int, |
| 3193 | Intrinsic F64Int> { |
| 3194 | // Intrinsic operation, reg. |
| 3195 | def SSr_Int : SS4AIi8<opcss, MRMSrcReg, |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3196 | (outs VR128:$dst), |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3197 | (ins VR128:$src1, VR128:$src2, i32i8imm:$src3), |
| 3198 | !strconcat(OpcodeStr, |
| 3199 | "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3200 | [(set VR128:$dst, |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3201 | (F32Int VR128:$src1, VR128:$src2, imm:$src3))]>, |
| 3202 | OpSize; |
| 3203 | |
| 3204 | // Intrinsic operation, mem. |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3205 | def SSm_Int : SS4AIi8<opcss, MRMSrcMem, |
| 3206 | (outs VR128:$dst), |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3207 | (ins VR128:$src1, ssmem:$src2, i32i8imm:$src3), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3208 | !strconcat(OpcodeStr, |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3209 | "ss\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3210 | [(set VR128:$dst, |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3211 | (F32Int VR128:$src1, sse_load_f32:$src2, imm:$src3))]>, |
| 3212 | OpSize; |
| 3213 | |
| 3214 | // Intrinsic operation, reg. |
| 3215 | def SDr_Int : SS4AIi8<opcsd, MRMSrcReg, |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3216 | (outs VR128:$dst), |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3217 | (ins VR128:$src1, VR128:$src2, i32i8imm:$src3), |
| 3218 | !strconcat(OpcodeStr, |
| 3219 | "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3220 | [(set VR128:$dst, |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3221 | (F64Int VR128:$src1, VR128:$src2, imm:$src3))]>, |
| 3222 | OpSize; |
| 3223 | |
| 3224 | // Intrinsic operation, mem. |
| 3225 | def SDm_Int : SS4AIi8<opcsd, MRMSrcMem, |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3226 | (outs VR128:$dst), |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3227 | (ins VR128:$src1, sdmem:$src2, i32i8imm:$src3), |
| 3228 | !strconcat(OpcodeStr, |
| 3229 | "sd\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3230 | [(set VR128:$dst, |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3231 | (F64Int VR128:$src1, sse_load_f64:$src2, imm:$src3))]>, |
| 3232 | OpSize; |
| 3233 | } |
| 3234 | } |
| 3235 | |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 3236 | // FP round - roundss, roundps, roundsd, roundpd |
Dale Johannesen | a7d2b44 | 2008-10-10 23:51:03 +0000 | [diff] [blame] | 3237 | defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round", |
| 3238 | int_x86_sse41_round_ps, int_x86_sse41_round_pd>; |
| 3239 | defm ROUND : sse41_fp_binop_rm<0x0A, 0x0B, "round", |
| 3240 | int_x86_sse41_round_ss, int_x86_sse41_round_sd>; |
Nate Begeman | eb3f543 | 2008-02-04 05:34:34 +0000 | [diff] [blame] | 3241 | |
| 3242 | // SS41I_unop_rm_int_v16 - SSE 4.1 unary operator whose type is v8i16. |
| 3243 | multiclass SS41I_unop_rm_int_v16<bits<8> opc, string OpcodeStr, |
| 3244 | Intrinsic IntId128> { |
| 3245 | def rr128 : SS48I<opc, MRMSrcReg, (outs VR128:$dst), |
| 3246 | (ins VR128:$src), |
| 3247 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 3248 | [(set VR128:$dst, (IntId128 VR128:$src))]>, OpSize; |
| 3249 | def rm128 : SS48I<opc, MRMSrcMem, (outs VR128:$dst), |
| 3250 | (ins i128mem:$src), |
| 3251 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 3252 | [(set VR128:$dst, |
| 3253 | (IntId128 |
| 3254 | (bitconvert (memopv8i16 addr:$src))))]>, OpSize; |
| 3255 | } |
| 3256 | |
| 3257 | defm PHMINPOSUW : SS41I_unop_rm_int_v16 <0x41, "phminposuw", |
| 3258 | int_x86_sse41_phminposuw>; |
| 3259 | |
| 3260 | /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 3261 | let Constraints = "$src1 = $dst" in { |
Nate Begeman | eb3f543 | 2008-02-04 05:34:34 +0000 | [diff] [blame] | 3262 | multiclass SS41I_binop_rm_int<bits<8> opc, string OpcodeStr, |
| 3263 | Intrinsic IntId128, bit Commutable = 0> { |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3264 | def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), |
| 3265 | (ins VR128:$src1, VR128:$src2), |
| 3266 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 3267 | [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>, |
| 3268 | OpSize { |
Nate Begeman | eb3f543 | 2008-02-04 05:34:34 +0000 | [diff] [blame] | 3269 | let isCommutable = Commutable; |
| 3270 | } |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3271 | def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), |
| 3272 | (ins VR128:$src1, i128mem:$src2), |
| 3273 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 3274 | [(set VR128:$dst, |
| 3275 | (IntId128 VR128:$src1, |
| 3276 | (bitconvert (memopv16i8 addr:$src2))))]>, OpSize; |
Nate Begeman | eb3f543 | 2008-02-04 05:34:34 +0000 | [diff] [blame] | 3277 | } |
| 3278 | } |
| 3279 | |
| 3280 | defm PCMPEQQ : SS41I_binop_rm_int<0x29, "pcmpeqq", |
| 3281 | int_x86_sse41_pcmpeqq, 1>; |
| 3282 | defm PACKUSDW : SS41I_binop_rm_int<0x2B, "packusdw", |
| 3283 | int_x86_sse41_packusdw, 0>; |
| 3284 | defm PMINSB : SS41I_binop_rm_int<0x38, "pminsb", |
| 3285 | int_x86_sse41_pminsb, 1>; |
| 3286 | defm PMINSD : SS41I_binop_rm_int<0x39, "pminsd", |
| 3287 | int_x86_sse41_pminsd, 1>; |
| 3288 | defm PMINUD : SS41I_binop_rm_int<0x3B, "pminud", |
| 3289 | int_x86_sse41_pminud, 1>; |
| 3290 | defm PMINUW : SS41I_binop_rm_int<0x3A, "pminuw", |
| 3291 | int_x86_sse41_pminuw, 1>; |
| 3292 | defm PMAXSB : SS41I_binop_rm_int<0x3C, "pmaxsb", |
| 3293 | int_x86_sse41_pmaxsb, 1>; |
| 3294 | defm PMAXSD : SS41I_binop_rm_int<0x3D, "pmaxsd", |
| 3295 | int_x86_sse41_pmaxsd, 1>; |
| 3296 | defm PMAXUD : SS41I_binop_rm_int<0x3F, "pmaxud", |
| 3297 | int_x86_sse41_pmaxud, 1>; |
| 3298 | defm PMAXUW : SS41I_binop_rm_int<0x3E, "pmaxuw", |
| 3299 | int_x86_sse41_pmaxuw, 1>; |
Nate Begeman | 72d802a | 2008-02-04 06:00:24 +0000 | [diff] [blame] | 3300 | |
Mon P Wang | 14edb09 | 2008-12-18 21:42:19 +0000 | [diff] [blame] | 3301 | defm PMULDQ : SS41I_binop_rm_int<0x28, "pmuldq", int_x86_sse41_pmuldq, 1>; |
| 3302 | |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 3303 | def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, VR128:$src2)), |
| 3304 | (PCMPEQQrr VR128:$src1, VR128:$src2)>; |
| 3305 | def : Pat<(v2i64 (X86pcmpeqq VR128:$src1, (memop addr:$src2))), |
| 3306 | (PCMPEQQrm VR128:$src1, addr:$src2)>; |
| 3307 | |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3308 | /// SS41I_binop_rm_int - Simple SSE 4.1 binary operator |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 3309 | let Constraints = "$src1 = $dst" in { |
Dan Gohman | e3731f5 | 2008-05-23 17:49:40 +0000 | [diff] [blame] | 3310 | multiclass SS41I_binop_patint<bits<8> opc, string OpcodeStr, ValueType OpVT, |
| 3311 | SDNode OpNode, Intrinsic IntId128, |
| 3312 | bit Commutable = 0> { |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3313 | def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), |
| 3314 | (ins VR128:$src1, VR128:$src2), |
| 3315 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
Dan Gohman | e3731f5 | 2008-05-23 17:49:40 +0000 | [diff] [blame] | 3316 | [(set VR128:$dst, (OpNode (OpVT VR128:$src1), |
| 3317 | VR128:$src2))]>, OpSize { |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3318 | let isCommutable = Commutable; |
| 3319 | } |
| 3320 | def rr_int : SS48I<opc, MRMSrcReg, (outs VR128:$dst), |
| 3321 | (ins VR128:$src1, VR128:$src2), |
| 3322 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 3323 | [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>, |
| 3324 | OpSize { |
| 3325 | let isCommutable = Commutable; |
| 3326 | } |
| 3327 | def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), |
| 3328 | (ins VR128:$src1, i128mem:$src2), |
| 3329 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 3330 | [(set VR128:$dst, |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 3331 | (OpNode VR128:$src1, (memop addr:$src2)))]>, OpSize; |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3332 | def rm_int : SS48I<opc, MRMSrcMem, (outs VR128:$dst), |
| 3333 | (ins VR128:$src1, i128mem:$src2), |
| 3334 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 3335 | [(set VR128:$dst, |
Evan Cheng | 00b66ef | 2008-05-23 00:37:07 +0000 | [diff] [blame] | 3336 | (IntId128 VR128:$src1, (memop addr:$src2)))]>, |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3337 | OpSize; |
| 3338 | } |
| 3339 | } |
Dan Gohman | e3731f5 | 2008-05-23 17:49:40 +0000 | [diff] [blame] | 3340 | defm PMULLD : SS41I_binop_patint<0x40, "pmulld", v4i32, mul, |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3341 | int_x86_sse41_pmulld, 1>; |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3342 | |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3343 | /// SS41I_binop_rmi_int - SSE 4.1 binary operator with 8-bit immediate |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 3344 | let Constraints = "$src1 = $dst" in { |
Nate Begeman | 72d802a | 2008-02-04 06:00:24 +0000 | [diff] [blame] | 3345 | multiclass SS41I_binop_rmi_int<bits<8> opc, string OpcodeStr, |
| 3346 | Intrinsic IntId128, bit Commutable = 0> { |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3347 | def rri : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3348 | (ins VR128:$src1, VR128:$src2, i32i8imm:$src3), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3349 | !strconcat(OpcodeStr, |
Nate Begeman | b4e9a04 | 2008-02-10 18:47:57 +0000 | [diff] [blame] | 3350 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3351 | [(set VR128:$dst, |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3352 | (IntId128 VR128:$src1, VR128:$src2, imm:$src3))]>, |
| 3353 | OpSize { |
Nate Begeman | 72d802a | 2008-02-04 06:00:24 +0000 | [diff] [blame] | 3354 | let isCommutable = Commutable; |
| 3355 | } |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3356 | def rmi : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3357 | (ins VR128:$src1, i128mem:$src2, i32i8imm:$src3), |
| 3358 | !strconcat(OpcodeStr, |
Nate Begeman | b4e9a04 | 2008-02-10 18:47:57 +0000 | [diff] [blame] | 3359 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3360 | [(set VR128:$dst, |
| 3361 | (IntId128 VR128:$src1, |
| 3362 | (bitconvert (memopv16i8 addr:$src2)), imm:$src3))]>, |
| 3363 | OpSize; |
Nate Begeman | 72d802a | 2008-02-04 06:00:24 +0000 | [diff] [blame] | 3364 | } |
| 3365 | } |
| 3366 | |
| 3367 | defm BLENDPS : SS41I_binop_rmi_int<0x0C, "blendps", |
| 3368 | int_x86_sse41_blendps, 0>; |
| 3369 | defm BLENDPD : SS41I_binop_rmi_int<0x0D, "blendpd", |
| 3370 | int_x86_sse41_blendpd, 0>; |
| 3371 | defm PBLENDW : SS41I_binop_rmi_int<0x0E, "pblendw", |
| 3372 | int_x86_sse41_pblendw, 0>; |
| 3373 | defm DPPS : SS41I_binop_rmi_int<0x40, "dpps", |
| 3374 | int_x86_sse41_dpps, 1>; |
| 3375 | defm DPPD : SS41I_binop_rmi_int<0x41, "dppd", |
| 3376 | int_x86_sse41_dppd, 1>; |
| 3377 | defm MPSADBW : SS41I_binop_rmi_int<0x42, "mpsadbw", |
Evan Cheng | 81ed985 | 2008-06-16 20:25:59 +0000 | [diff] [blame] | 3378 | int_x86_sse41_mpsadbw, 1>; |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3379 | |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3380 | |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3381 | /// SS41I_ternary_int - SSE 4.1 ternary operator |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 3382 | let Uses = [XMM0], Constraints = "$src1 = $dst" in { |
Nate Begeman | b4e9a04 | 2008-02-10 18:47:57 +0000 | [diff] [blame] | 3383 | multiclass SS41I_ternary_int<bits<8> opc, string OpcodeStr, Intrinsic IntId> { |
| 3384 | def rr0 : SS48I<opc, MRMSrcReg, (outs VR128:$dst), |
| 3385 | (ins VR128:$src1, VR128:$src2), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3386 | !strconcat(OpcodeStr, |
Nate Begeman | b4e9a04 | 2008-02-10 18:47:57 +0000 | [diff] [blame] | 3387 | "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"), |
| 3388 | [(set VR128:$dst, (IntId VR128:$src1, VR128:$src2, XMM0))]>, |
| 3389 | OpSize; |
| 3390 | |
| 3391 | def rm0 : SS48I<opc, MRMSrcMem, (outs VR128:$dst), |
| 3392 | (ins VR128:$src1, i128mem:$src2), |
| 3393 | !strconcat(OpcodeStr, |
| 3394 | "\t{%xmm0, $src2, $dst|$dst, $src2, %xmm0}"), |
| 3395 | [(set VR128:$dst, |
| 3396 | (IntId VR128:$src1, |
| 3397 | (bitconvert (memopv16i8 addr:$src2)), XMM0))]>, OpSize; |
| 3398 | } |
| 3399 | } |
| 3400 | |
| 3401 | defm BLENDVPD : SS41I_ternary_int<0x15, "blendvpd", int_x86_sse41_blendvpd>; |
| 3402 | defm BLENDVPS : SS41I_ternary_int<0x14, "blendvps", int_x86_sse41_blendvps>; |
| 3403 | defm PBLENDVB : SS41I_ternary_int<0x10, "pblendvb", int_x86_sse41_pblendvb>; |
| 3404 | |
| 3405 | |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3406 | multiclass SS41I_binop_rm_int8<bits<8> opc, string OpcodeStr, Intrinsic IntId> { |
| 3407 | def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
| 3408 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 3409 | [(set VR128:$dst, (IntId VR128:$src))]>, OpSize; |
| 3410 | |
| 3411 | def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src), |
| 3412 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3413 | [(set VR128:$dst, |
| 3414 | (IntId (bitconvert (v2i64 (scalar_to_vector (loadi64 addr:$src))))))]>, |
| 3415 | OpSize; |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3416 | } |
| 3417 | |
| 3418 | defm PMOVSXBW : SS41I_binop_rm_int8<0x20, "pmovsxbw", int_x86_sse41_pmovsxbw>; |
| 3419 | defm PMOVSXWD : SS41I_binop_rm_int8<0x23, "pmovsxwd", int_x86_sse41_pmovsxwd>; |
| 3420 | defm PMOVSXDQ : SS41I_binop_rm_int8<0x25, "pmovsxdq", int_x86_sse41_pmovsxdq>; |
| 3421 | defm PMOVZXBW : SS41I_binop_rm_int8<0x30, "pmovzxbw", int_x86_sse41_pmovzxbw>; |
| 3422 | defm PMOVZXWD : SS41I_binop_rm_int8<0x33, "pmovzxwd", int_x86_sse41_pmovzxwd>; |
| 3423 | defm PMOVZXDQ : SS41I_binop_rm_int8<0x35, "pmovzxdq", int_x86_sse41_pmovzxdq>; |
| 3424 | |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3425 | // Common patterns involving scalar load. |
| 3426 | def : Pat<(int_x86_sse41_pmovsxbw (vzmovl_v2i64 addr:$src)), |
| 3427 | (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>; |
| 3428 | def : Pat<(int_x86_sse41_pmovsxbw (vzload_v2i64 addr:$src)), |
| 3429 | (PMOVSXBWrm addr:$src)>, Requires<[HasSSE41]>; |
| 3430 | |
| 3431 | def : Pat<(int_x86_sse41_pmovsxwd (vzmovl_v2i64 addr:$src)), |
| 3432 | (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>; |
| 3433 | def : Pat<(int_x86_sse41_pmovsxwd (vzload_v2i64 addr:$src)), |
| 3434 | (PMOVSXWDrm addr:$src)>, Requires<[HasSSE41]>; |
| 3435 | |
| 3436 | def : Pat<(int_x86_sse41_pmovsxdq (vzmovl_v2i64 addr:$src)), |
| 3437 | (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>; |
| 3438 | def : Pat<(int_x86_sse41_pmovsxdq (vzload_v2i64 addr:$src)), |
| 3439 | (PMOVSXDQrm addr:$src)>, Requires<[HasSSE41]>; |
| 3440 | |
| 3441 | def : Pat<(int_x86_sse41_pmovzxbw (vzmovl_v2i64 addr:$src)), |
| 3442 | (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>; |
| 3443 | def : Pat<(int_x86_sse41_pmovzxbw (vzload_v2i64 addr:$src)), |
| 3444 | (PMOVZXBWrm addr:$src)>, Requires<[HasSSE41]>; |
| 3445 | |
| 3446 | def : Pat<(int_x86_sse41_pmovzxwd (vzmovl_v2i64 addr:$src)), |
| 3447 | (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>; |
| 3448 | def : Pat<(int_x86_sse41_pmovzxwd (vzload_v2i64 addr:$src)), |
| 3449 | (PMOVZXWDrm addr:$src)>, Requires<[HasSSE41]>; |
| 3450 | |
| 3451 | def : Pat<(int_x86_sse41_pmovzxdq (vzmovl_v2i64 addr:$src)), |
| 3452 | (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>; |
| 3453 | def : Pat<(int_x86_sse41_pmovzxdq (vzload_v2i64 addr:$src)), |
| 3454 | (PMOVZXDQrm addr:$src)>, Requires<[HasSSE41]>; |
| 3455 | |
| 3456 | |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3457 | multiclass SS41I_binop_rm_int4<bits<8> opc, string OpcodeStr, Intrinsic IntId> { |
| 3458 | def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
| 3459 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 3460 | [(set VR128:$dst, (IntId VR128:$src))]>, OpSize; |
| 3461 | |
| 3462 | def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i32mem:$src), |
| 3463 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3464 | [(set VR128:$dst, |
| 3465 | (IntId (bitconvert (v4i32 (scalar_to_vector (loadi32 addr:$src))))))]>, |
| 3466 | OpSize; |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3467 | } |
| 3468 | |
| 3469 | defm PMOVSXBD : SS41I_binop_rm_int4<0x21, "pmovsxbd", int_x86_sse41_pmovsxbd>; |
| 3470 | defm PMOVSXWQ : SS41I_binop_rm_int4<0x24, "pmovsxwq", int_x86_sse41_pmovsxwq>; |
| 3471 | defm PMOVZXBD : SS41I_binop_rm_int4<0x31, "pmovzxbd", int_x86_sse41_pmovzxbd>; |
| 3472 | defm PMOVZXWQ : SS41I_binop_rm_int4<0x34, "pmovzxwq", int_x86_sse41_pmovzxwq>; |
| 3473 | |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3474 | // Common patterns involving scalar load |
| 3475 | def : Pat<(int_x86_sse41_pmovsxbd (vzmovl_v4i32 addr:$src)), |
Evan Cheng | 00a3ec5 | 2008-09-25 00:49:51 +0000 | [diff] [blame] | 3476 | (PMOVSXBDrm addr:$src)>, Requires<[HasSSE41]>; |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3477 | def : Pat<(int_x86_sse41_pmovsxwq (vzmovl_v4i32 addr:$src)), |
Evan Cheng | 00a3ec5 | 2008-09-25 00:49:51 +0000 | [diff] [blame] | 3478 | (PMOVSXWQrm addr:$src)>, Requires<[HasSSE41]>; |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3479 | |
| 3480 | def : Pat<(int_x86_sse41_pmovzxbd (vzmovl_v4i32 addr:$src)), |
Evan Cheng | 00a3ec5 | 2008-09-25 00:49:51 +0000 | [diff] [blame] | 3481 | (PMOVZXBDrm addr:$src)>, Requires<[HasSSE41]>; |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3482 | def : Pat<(int_x86_sse41_pmovzxwq (vzmovl_v4i32 addr:$src)), |
Evan Cheng | 00a3ec5 | 2008-09-25 00:49:51 +0000 | [diff] [blame] | 3483 | (PMOVZXWQrm addr:$src)>, Requires<[HasSSE41]>; |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3484 | |
| 3485 | |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3486 | multiclass SS41I_binop_rm_int2<bits<8> opc, string OpcodeStr, Intrinsic IntId> { |
| 3487 | def rr : SS48I<opc, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), |
| 3488 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
| 3489 | [(set VR128:$dst, (IntId VR128:$src))]>, OpSize; |
| 3490 | |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3491 | // Expecting a i16 load any extended to i32 value. |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3492 | def rm : SS48I<opc, MRMSrcMem, (outs VR128:$dst), (ins i16mem:$src), |
| 3493 | !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3494 | [(set VR128:$dst, (IntId (bitconvert |
| 3495 | (v4i32 (scalar_to_vector (loadi16_anyext addr:$src))))))]>, |
| 3496 | OpSize; |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3497 | } |
| 3498 | |
| 3499 | defm PMOVSXBQ : SS41I_binop_rm_int2<0x22, "pmovsxbq", int_x86_sse41_pmovsxbq>; |
Eli Friedman | 75a89d6 | 2009-06-06 05:55:37 +0000 | [diff] [blame] | 3500 | defm PMOVZXBQ : SS41I_binop_rm_int2<0x32, "pmovzxbq", int_x86_sse41_pmovzxbq>; |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3501 | |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3502 | // Common patterns involving scalar load |
| 3503 | def : Pat<(int_x86_sse41_pmovsxbq |
| 3504 | (bitconvert (v4i32 (X86vzmovl |
| 3505 | (v4i32 (scalar_to_vector (loadi32 addr:$src))))))), |
Evan Cheng | 00a3ec5 | 2008-09-25 00:49:51 +0000 | [diff] [blame] | 3506 | (PMOVSXBQrm addr:$src)>, Requires<[HasSSE41]>; |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3507 | |
| 3508 | def : Pat<(int_x86_sse41_pmovzxbq |
| 3509 | (bitconvert (v4i32 (X86vzmovl |
| 3510 | (v4i32 (scalar_to_vector (loadi32 addr:$src))))))), |
Evan Cheng | 00a3ec5 | 2008-09-25 00:49:51 +0000 | [diff] [blame] | 3511 | (PMOVZXBQrm addr:$src)>, Requires<[HasSSE41]>; |
Evan Cheng | 56ec77b | 2008-09-24 23:27:55 +0000 | [diff] [blame] | 3512 | |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3513 | |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3514 | /// SS41I_binop_ext8 - SSE 4.1 extract 8 bits to 32 bit reg or 8 bit mem |
| 3515 | multiclass SS41I_extract8<bits<8> opc, string OpcodeStr> { |
Evan Cheng | c2054be | 2008-03-26 08:11:49 +0000 | [diff] [blame] | 3516 | def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3517 | (ins VR128:$src1, i32i8imm:$src2), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3518 | !strconcat(OpcodeStr, |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3519 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3520 | [(set GR32:$dst, (X86pextrb (v16i8 VR128:$src1), imm:$src2))]>, |
| 3521 | OpSize; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3522 | def mr : SS4AIi8<opc, MRMDestMem, (outs), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3523 | (ins i8mem:$dst, VR128:$src1, i32i8imm:$src2), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3524 | !strconcat(OpcodeStr, |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3525 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3526 | []>, OpSize; |
| 3527 | // FIXME: |
| 3528 | // There's an AssertZext in the way of writing the store pattern |
| 3529 | // (store (i8 (trunc (X86pextrb (v16i8 VR128:$src1), imm:$src2))), addr:$dst) |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3530 | } |
| 3531 | |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3532 | defm PEXTRB : SS41I_extract8<0x14, "pextrb">; |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3533 | |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3534 | |
| 3535 | /// SS41I_extract16 - SSE 4.1 extract 16 bits to memory destination |
| 3536 | multiclass SS41I_extract16<bits<8> opc, string OpcodeStr> { |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3537 | def mr : SS4AIi8<opc, MRMDestMem, (outs), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3538 | (ins i16mem:$dst, VR128:$src1, i32i8imm:$src2), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3539 | !strconcat(OpcodeStr, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3540 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 3541 | []>, OpSize; |
| 3542 | // FIXME: |
| 3543 | // There's an AssertZext in the way of writing the store pattern |
| 3544 | // (store (i16 (trunc (X86pextrw (v16i8 VR128:$src1), imm:$src2))), addr:$dst) |
| 3545 | } |
| 3546 | |
| 3547 | defm PEXTRW : SS41I_extract16<0x15, "pextrw">; |
| 3548 | |
| 3549 | |
| 3550 | /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination |
| 3551 | multiclass SS41I_extract32<bits<8> opc, string OpcodeStr> { |
Evan Cheng | c2054be | 2008-03-26 08:11:49 +0000 | [diff] [blame] | 3552 | def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3553 | (ins VR128:$src1, i32i8imm:$src2), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3554 | !strconcat(OpcodeStr, |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3555 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 3556 | [(set GR32:$dst, |
| 3557 | (extractelt (v4i32 VR128:$src1), imm:$src2))]>, OpSize; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3558 | def mr : SS4AIi8<opc, MRMDestMem, (outs), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3559 | (ins i32mem:$dst, VR128:$src1, i32i8imm:$src2), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3560 | !strconcat(OpcodeStr, |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3561 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 3562 | [(store (extractelt (v4i32 VR128:$src1), imm:$src2), |
| 3563 | addr:$dst)]>, OpSize; |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3564 | } |
| 3565 | |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3566 | defm PEXTRD : SS41I_extract32<0x16, "pextrd">; |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3567 | |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3568 | |
Evan Cheng | 6c24933 | 2008-03-24 21:52:23 +0000 | [diff] [blame] | 3569 | /// SS41I_extractf32 - SSE 4.1 extract 32 bits fp value to int reg or memory |
| 3570 | /// destination |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3571 | multiclass SS41I_extractf32<bits<8> opc, string OpcodeStr> { |
Evan Cheng | c2054be | 2008-03-26 08:11:49 +0000 | [diff] [blame] | 3572 | def rr : SS4AIi8<opc, MRMDestReg, (outs GR32:$dst), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3573 | (ins VR128:$src1, i32i8imm:$src2), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3574 | !strconcat(OpcodeStr, |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3575 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
Dan Gohman | 788db59 | 2008-04-16 02:32:24 +0000 | [diff] [blame] | 3576 | [(set GR32:$dst, |
| 3577 | (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2))]>, |
Evan Cheng | 6c24933 | 2008-03-24 21:52:23 +0000 | [diff] [blame] | 3578 | OpSize; |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3579 | def mr : SS4AIi8<opc, MRMDestMem, (outs), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3580 | (ins f32mem:$dst, VR128:$src1, i32i8imm:$src2), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3581 | !strconcat(OpcodeStr, |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3582 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
Evan Cheng | 6c24933 | 2008-03-24 21:52:23 +0000 | [diff] [blame] | 3583 | [(store (extractelt (bc_v4i32 (v4f32 VR128:$src1)), imm:$src2), |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3584 | addr:$dst)]>, OpSize; |
Nate Begeman | 5805796 | 2008-02-09 01:38:08 +0000 | [diff] [blame] | 3585 | } |
| 3586 | |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3587 | defm EXTRACTPS : SS41I_extractf32<0x17, "extractps">; |
Nate Begeman | 9a58b8a | 2008-02-09 23:46:37 +0000 | [diff] [blame] | 3588 | |
Dan Gohman | a41862a | 2008-08-08 18:30:21 +0000 | [diff] [blame] | 3589 | // Also match an EXTRACTPS store when the store is done as f32 instead of i32. |
| 3590 | def : Pat<(store (f32 (bitconvert (extractelt (bc_v4i32 (v4f32 VR128:$src1)), |
| 3591 | imm:$src2))), |
| 3592 | addr:$dst), |
| 3593 | (EXTRACTPSmr addr:$dst, VR128:$src1, imm:$src2)>, |
| 3594 | Requires<[HasSSE41]>; |
| 3595 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 3596 | let Constraints = "$src1 = $dst" in { |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3597 | multiclass SS41I_insert8<bits<8> opc, string OpcodeStr> { |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3598 | def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3599 | (ins VR128:$src1, GR32:$src2, i32i8imm:$src3), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3600 | !strconcat(OpcodeStr, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3601 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3602 | [(set VR128:$dst, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3603 | (X86pinsrb VR128:$src1, GR32:$src2, imm:$src3))]>, OpSize; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3604 | def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3605 | (ins VR128:$src1, i8mem:$src2, i32i8imm:$src3), |
| 3606 | !strconcat(OpcodeStr, |
| 3607 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3608 | [(set VR128:$dst, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3609 | (X86pinsrb VR128:$src1, (extloadi8 addr:$src2), |
| 3610 | imm:$src3))]>, OpSize; |
| 3611 | } |
| 3612 | } |
| 3613 | |
| 3614 | defm PINSRB : SS41I_insert8<0x20, "pinsrb">; |
| 3615 | |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 3616 | let Constraints = "$src1 = $dst" in { |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3617 | multiclass SS41I_insert32<bits<8> opc, string OpcodeStr> { |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3618 | def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3619 | (ins VR128:$src1, GR32:$src2, i32i8imm:$src3), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3620 | !strconcat(OpcodeStr, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3621 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3622 | [(set VR128:$dst, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3623 | (v4i32 (insertelt VR128:$src1, GR32:$src2, imm:$src3)))]>, |
| 3624 | OpSize; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 3625 | def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3626 | (ins VR128:$src1, i32mem:$src2, i32i8imm:$src3), |
| 3627 | !strconcat(OpcodeStr, |
| 3628 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3629 | [(set VR128:$dst, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3630 | (v4i32 (insertelt VR128:$src1, (loadi32 addr:$src2), |
| 3631 | imm:$src3)))]>, OpSize; |
| 3632 | } |
| 3633 | } |
| 3634 | |
| 3635 | defm PINSRD : SS41I_insert32<0x22, "pinsrd">; |
| 3636 | |
Eric Christopher | a044360 | 2009-07-23 02:22:41 +0000 | [diff] [blame] | 3637 | // insertps has a few different modes, there's the first two here below which |
| 3638 | // are optimized inserts that won't zero arbitrary elements in the destination |
| 3639 | // vector. The next one matches the intrinsic and could zero arbitrary elements |
| 3640 | // in the target vector. |
Evan Cheng | 3ea4d67 | 2008-03-05 08:19:16 +0000 | [diff] [blame] | 3641 | let Constraints = "$src1 = $dst" in { |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3642 | multiclass SS41I_insertf32<bits<8> opc, string OpcodeStr> { |
Eric Christopher | efb657e | 2009-07-24 00:33:09 +0000 | [diff] [blame] | 3643 | def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst), |
| 3644 | (ins VR128:$src1, VR128:$src2, i32i8imm:$src3), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3645 | !strconcat(OpcodeStr, |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3646 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3647 | [(set VR128:$dst, |
| 3648 | (X86insrtps VR128:$src1, VR128:$src2, imm:$src3))]>, |
| 3649 | OpSize; |
Eric Christopher | efb657e | 2009-07-24 00:33:09 +0000 | [diff] [blame] | 3650 | def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3651 | (ins VR128:$src1, f32mem:$src2, i32i8imm:$src3), |
| 3652 | !strconcat(OpcodeStr, |
| 3653 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
Eric Christopher | 7f2d4f4 | 2009-07-31 20:07:27 +0000 | [diff] [blame] | 3654 | [(set VR128:$dst, |
Eric Christopher | efb657e | 2009-07-24 00:33:09 +0000 | [diff] [blame] | 3655 | (X86insrtps VR128:$src1, |
| 3656 | (v4f32 (scalar_to_vector (loadf32 addr:$src2))), |
Nate Begeman | d77e59e | 2008-02-11 04:19:36 +0000 | [diff] [blame] | 3657 | imm:$src3))]>, OpSize; |
| 3658 | } |
| 3659 | } |
| 3660 | |
Evan Cheng | c2054be | 2008-03-26 08:11:49 +0000 | [diff] [blame] | 3661 | defm INSERTPS : SS41I_insertf32<0x21, "insertps">; |
Nate Begeman | 0dd3cb5 | 2008-03-16 21:14:46 +0000 | [diff] [blame] | 3662 | |
Eric Christopher | efb657e | 2009-07-24 00:33:09 +0000 | [diff] [blame] | 3663 | def : Pat<(int_x86_sse41_insertps VR128:$src1, VR128:$src2, imm:$src3), |
| 3664 | (INSERTPSrr VR128:$src1, VR128:$src2, imm:$src3)>; |
| 3665 | |
Eric Christopher | 95d7926 | 2009-07-29 00:28:05 +0000 | [diff] [blame] | 3666 | // ptest instruction we'll lower to this in X86ISelLowering primarily from |
| 3667 | // the intel intrinsic that corresponds to this. |
Nate Begeman | 0dd3cb5 | 2008-03-16 21:14:46 +0000 | [diff] [blame] | 3668 | let Defs = [EFLAGS] in { |
| 3669 | def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2), |
Eric Christopher | 95d7926 | 2009-07-29 00:28:05 +0000 | [diff] [blame] | 3670 | "ptest \t{$src2, $src1|$src1, $src2}", |
| 3671 | [(X86ptest VR128:$src1, VR128:$src2), |
| 3672 | (implicit EFLAGS)]>, OpSize; |
Nate Begeman | 0dd3cb5 | 2008-03-16 21:14:46 +0000 | [diff] [blame] | 3673 | def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2), |
Eric Christopher | 95d7926 | 2009-07-29 00:28:05 +0000 | [diff] [blame] | 3674 | "ptest \t{$src2, $src1|$src1, $src2}", |
| 3675 | [(X86ptest VR128:$src1, (load addr:$src2)), |
| 3676 | (implicit EFLAGS)]>, OpSize; |
Nate Begeman | 0dd3cb5 | 2008-03-16 21:14:46 +0000 | [diff] [blame] | 3677 | } |
| 3678 | |
| 3679 | def MOVNTDQArm : SS48I<0x2A, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), |
| 3680 | "movntdqa\t{$src, $dst|$dst, $src}", |
| 3681 | [(set VR128:$dst, (int_x86_sse41_movntdqa addr:$src))]>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 3682 | |
Eric Christopher | 22a3940 | 2009-08-18 22:50:32 +0000 | [diff] [blame] | 3683 | |
| 3684 | //===----------------------------------------------------------------------===// |
| 3685 | // SSE4.2 Instructions |
| 3686 | //===----------------------------------------------------------------------===// |
| 3687 | |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 3688 | /// SS42I_binop_rm_int - Simple SSE 4.2 binary operator |
| 3689 | let Constraints = "$src1 = $dst" in { |
| 3690 | multiclass SS42I_binop_rm_int<bits<8> opc, string OpcodeStr, |
| 3691 | Intrinsic IntId128, bit Commutable = 0> { |
| 3692 | def rr : SS428I<opc, MRMSrcReg, (outs VR128:$dst), |
| 3693 | (ins VR128:$src1, VR128:$src2), |
| 3694 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 3695 | [(set VR128:$dst, (IntId128 VR128:$src1, VR128:$src2))]>, |
| 3696 | OpSize { |
| 3697 | let isCommutable = Commutable; |
| 3698 | } |
| 3699 | def rm : SS428I<opc, MRMSrcMem, (outs VR128:$dst), |
| 3700 | (ins VR128:$src1, i128mem:$src2), |
| 3701 | !strconcat(OpcodeStr, "\t{$src2, $dst|$dst, $src2}"), |
| 3702 | [(set VR128:$dst, |
| 3703 | (IntId128 VR128:$src1, |
| 3704 | (bitconvert (memopv16i8 addr:$src2))))]>, OpSize; |
| 3705 | } |
| 3706 | } |
| 3707 | |
Nate Begeman | 235666b | 2008-07-17 17:04:58 +0000 | [diff] [blame] | 3708 | defm PCMPGTQ : SS42I_binop_rm_int<0x37, "pcmpgtq", int_x86_sse42_pcmpgtq>; |
Nate Begeman | 03605a0 | 2008-07-17 16:51:19 +0000 | [diff] [blame] | 3709 | |
| 3710 | def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, VR128:$src2)), |
| 3711 | (PCMPGTQrr VR128:$src1, VR128:$src2)>; |
| 3712 | def : Pat<(v2i64 (X86pcmpgtq VR128:$src1, (memop addr:$src2))), |
| 3713 | (PCMPGTQrm VR128:$src1, addr:$src2)>; |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3714 | |
| 3715 | // crc intrinsic instruction |
| 3716 | // This set of instructions are only rm, the only difference is the size |
| 3717 | // of r and m. |
| 3718 | let Constraints = "$src1 = $dst" in { |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3719 | def CRC32m8 : SS42FI<0xF0, MRMSrcMem, (outs GR32:$dst), |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3720 | (ins GR32:$src1, i8mem:$src2), |
| 3721 | "crc32 \t{$src2, $src1|$src1, $src2}", |
| 3722 | [(set GR32:$dst, |
| 3723 | (int_x86_sse42_crc32_8 GR32:$src1, |
| 3724 | (load addr:$src2)))]>, OpSize; |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3725 | def CRC32r8 : SS42FI<0xF0, MRMSrcReg, (outs GR32:$dst), |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3726 | (ins GR32:$src1, GR8:$src2), |
| 3727 | "crc32 \t{$src2, $src1|$src1, $src2}", |
| 3728 | [(set GR32:$dst, |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3729 | (int_x86_sse42_crc32_8 GR32:$src1, GR8:$src2))]>, |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3730 | OpSize; |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3731 | def CRC32m16 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst), |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3732 | (ins GR32:$src1, i16mem:$src2), |
| 3733 | "crc32 \t{$src2, $src1|$src1, $src2}", |
| 3734 | [(set GR32:$dst, |
| 3735 | (int_x86_sse42_crc32_16 GR32:$src1, |
| 3736 | (load addr:$src2)))]>, |
| 3737 | OpSize; |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3738 | def CRC32r16 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst), |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3739 | (ins GR32:$src1, GR16:$src2), |
| 3740 | "crc32 \t{$src2, $src1|$src1, $src2}", |
| 3741 | [(set GR32:$dst, |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3742 | (int_x86_sse42_crc32_16 GR32:$src1, GR16:$src2))]>, |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3743 | OpSize; |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3744 | def CRC32m32 : SS42FI<0xF1, MRMSrcMem, (outs GR32:$dst), |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3745 | (ins GR32:$src1, i32mem:$src2), |
| 3746 | "crc32 \t{$src2, $src1|$src1, $src2}", |
| 3747 | [(set GR32:$dst, |
| 3748 | (int_x86_sse42_crc32_32 GR32:$src1, |
| 3749 | (load addr:$src2)))]>, OpSize; |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3750 | def CRC32r32 : SS42FI<0xF1, MRMSrcReg, (outs GR32:$dst), |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3751 | (ins GR32:$src1, GR32:$src2), |
| 3752 | "crc32 \t{$src2, $src1|$src1, $src2}", |
| 3753 | [(set GR32:$dst, |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3754 | (int_x86_sse42_crc32_32 GR32:$src1, GR32:$src2))]>, |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3755 | OpSize; |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3756 | def CRC64m64 : SS42FI<0xF0, MRMSrcMem, (outs GR64:$dst), |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3757 | (ins GR64:$src1, i64mem:$src2), |
| 3758 | "crc32 \t{$src2, $src1|$src1, $src2}", |
| 3759 | [(set GR64:$dst, |
| 3760 | (int_x86_sse42_crc32_64 GR64:$src1, |
| 3761 | (load addr:$src2)))]>, |
| 3762 | OpSize, REX_W; |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3763 | def CRC64r64 : SS42FI<0xF0, MRMSrcReg, (outs GR64:$dst), |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3764 | (ins GR64:$src1, GR64:$src2), |
| 3765 | "crc32 \t{$src2, $src1|$src1, $src2}", |
| 3766 | [(set GR64:$dst, |
Eric Christopher | 85f187b | 2009-08-10 21:48:58 +0000 | [diff] [blame] | 3767 | (int_x86_sse42_crc32_64 GR64:$src1, GR64:$src2))]>, |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3768 | OpSize, REX_W; |
Eric Christopher | b5f948c | 2009-08-08 21:55:08 +0000 | [diff] [blame] | 3769 | } |
Eric Christopher | 22a3940 | 2009-08-18 22:50:32 +0000 | [diff] [blame] | 3770 | |
| 3771 | // String/text processing instructions. |
| 3772 | let Defs = [EFLAGS], usesCustomDAGSchedInserter = 1 in { |
| 3773 | def PCMPISTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst), |
| 3774 | (ins VR128:$src1, VR128:$src2, i8imm:$src3), |
| 3775 | "#PCMPISTRM128rr PSEUDO!", |
| 3776 | [(set VR128:$dst, |
| 3777 | (int_x86_sse42_pcmpistrm128 VR128:$src1, VR128:$src2, |
| 3778 | imm:$src3))]>, OpSize; |
| 3779 | def PCMPISTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst), |
| 3780 | (ins VR128:$src1, i128mem:$src2, i8imm:$src3), |
| 3781 | "#PCMPISTRM128rm PSEUDO!", |
| 3782 | [(set VR128:$dst, |
| 3783 | (int_x86_sse42_pcmpistrm128 VR128:$src1, |
| 3784 | (load addr:$src2), |
| 3785 | imm:$src3))]>, OpSize; |
| 3786 | } |
| 3787 | |
| 3788 | let Defs = [XMM0, EFLAGS] in { |
| 3789 | def PCMPISTRM128rr : SS42AI<0x62, MRMSrcReg, (outs), |
| 3790 | (ins VR128:$src1, VR128:$src2, i8imm:$src3), |
| 3791 | "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", |
| 3792 | []>, OpSize; |
| 3793 | def PCMPISTRM128rm : SS42AI<0x62, MRMSrcMem, (outs), |
| 3794 | (ins VR128:$src1, i128mem:$src2, i8imm:$src3), |
| 3795 | "pcmpistrm\t{$src3, $src2, $src1|$src1, $src2, $src3}", |
| 3796 | []>, OpSize; |
| 3797 | } |
| 3798 | |
| 3799 | let Defs = [EFLAGS], Uses = [EAX, EDX], |
| 3800 | usesCustomDAGSchedInserter = 1 in { |
| 3801 | def PCMPESTRM128REG : SS42AI<0, Pseudo, (outs VR128:$dst), |
| 3802 | (ins VR128:$src1, VR128:$src3, i8imm:$src5), |
| 3803 | "#PCMPESTRM128rr PSEUDO!", |
| 3804 | [(set VR128:$dst, |
| 3805 | (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX, |
| 3806 | VR128:$src3, |
| 3807 | EDX, imm:$src5))]>, OpSize; |
| 3808 | def PCMPESTRM128MEM : SS42AI<0, Pseudo, (outs VR128:$dst), |
| 3809 | (ins VR128:$src1, i128mem:$src3, i8imm:$src5), |
| 3810 | "#PCMPESTRM128rm PSEUDO!", |
| 3811 | [(set VR128:$dst, |
| 3812 | (int_x86_sse42_pcmpestrm128 VR128:$src1, EAX, |
| 3813 | (load addr:$src3), |
| 3814 | EDX, imm:$src5))]>, OpSize; |
| 3815 | } |
| 3816 | |
| 3817 | let Defs = [XMM0, EFLAGS], Uses = [EAX, EDX] in { |
Sean Callanan | c5a05b7 | 2009-08-20 18:24:27 +0000 | [diff] [blame] | 3818 | def PCMPESTRM128rr : SS42AI<0x60, MRMSrcReg, (outs), |
Eric Christopher | 22a3940 | 2009-08-18 22:50:32 +0000 | [diff] [blame] | 3819 | (ins VR128:$src1, VR128:$src3, i8imm:$src5), |
| 3820 | "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", |
| 3821 | []>, OpSize; |
Sean Callanan | c5a05b7 | 2009-08-20 18:24:27 +0000 | [diff] [blame] | 3822 | def PCMPESTRM128rm : SS42AI<0x60, MRMSrcMem, (outs), |
Eric Christopher | 22a3940 | 2009-08-18 22:50:32 +0000 | [diff] [blame] | 3823 | (ins VR128:$src1, i128mem:$src3, i8imm:$src5), |
| 3824 | "pcmpestrm\t{$src5, $src3, $src1|$src1, $src3, $src5}", |
| 3825 | []>, OpSize; |
| 3826 | } |
| 3827 | |
| 3828 | let Defs = [ECX, EFLAGS] in { |
| 3829 | multiclass SS42AI_pcmpistri<Intrinsic IntId128> { |
| 3830 | def rr : SS42AI<0x63, MRMSrcReg, (outs), |
| 3831 | (ins VR128:$src1, VR128:$src2, i8imm:$src3), |
| 3832 | "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}", |
| 3833 | [(set ECX, |
| 3834 | (IntId128 VR128:$src1, VR128:$src2, imm:$src3)), |
| 3835 | (implicit EFLAGS)]>, |
| 3836 | OpSize; |
| 3837 | def rm : SS42AI<0x63, MRMSrcMem, (outs), |
| 3838 | (ins VR128:$src1, i128mem:$src2, i8imm:$src3), |
| 3839 | "pcmpistri\t{$src3, $src2, $src1|$src1, $src2, $src3}", |
| 3840 | [(set ECX, |
| 3841 | (IntId128 VR128:$src1, (load addr:$src2), imm:$src3)), |
| 3842 | (implicit EFLAGS)]>, |
| 3843 | OpSize; |
| 3844 | } |
| 3845 | } |
| 3846 | |
| 3847 | defm PCMPISTRI : SS42AI_pcmpistri<int_x86_sse42_pcmpistri128>; |
| 3848 | defm PCMPISTRIA : SS42AI_pcmpistri<int_x86_sse42_pcmpistria128>; |
| 3849 | defm PCMPISTRIC : SS42AI_pcmpistri<int_x86_sse42_pcmpistric128>; |
| 3850 | defm PCMPISTRIO : SS42AI_pcmpistri<int_x86_sse42_pcmpistrio128>; |
| 3851 | defm PCMPISTRIS : SS42AI_pcmpistri<int_x86_sse42_pcmpistris128>; |
| 3852 | defm PCMPISTRIZ : SS42AI_pcmpistri<int_x86_sse42_pcmpistriz128>; |
| 3853 | |
| 3854 | let Defs = [ECX, EFLAGS] in { |
| 3855 | let Uses = [EAX, EDX] in { |
| 3856 | multiclass SS42AI_pcmpestri<Intrinsic IntId128> { |
| 3857 | def rr : SS42AI<0x61, MRMSrcReg, (outs), |
| 3858 | (ins VR128:$src1, VR128:$src3, i8imm:$src5), |
| 3859 | "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}", |
| 3860 | [(set ECX, |
| 3861 | (IntId128 VR128:$src1, EAX, VR128:$src3, EDX, imm:$src5)), |
| 3862 | (implicit EFLAGS)]>, |
| 3863 | OpSize; |
| 3864 | def rm : SS42AI<0x61, MRMSrcMem, (outs), |
| 3865 | (ins VR128:$src1, i128mem:$src3, i8imm:$src5), |
| 3866 | "pcmpestri\t{$src5, $src3, $src1|$src1, $src3, $src5}", |
| 3867 | [(set ECX, |
| 3868 | (IntId128 VR128:$src1, EAX, (load addr:$src3), |
| 3869 | EDX, imm:$src5)), |
| 3870 | (implicit EFLAGS)]>, |
| 3871 | OpSize; |
| 3872 | } |
| 3873 | } |
| 3874 | } |
| 3875 | |
| 3876 | defm PCMPESTRI : SS42AI_pcmpestri<int_x86_sse42_pcmpestri128>; |
| 3877 | defm PCMPESTRIA : SS42AI_pcmpestri<int_x86_sse42_pcmpestria128>; |
| 3878 | defm PCMPESTRIC : SS42AI_pcmpestri<int_x86_sse42_pcmpestric128>; |
| 3879 | defm PCMPESTRIO : SS42AI_pcmpestri<int_x86_sse42_pcmpestrio128>; |
| 3880 | defm PCMPESTRIS : SS42AI_pcmpestri<int_x86_sse42_pcmpestris128>; |
| 3881 | defm PCMPESTRIZ : SS42AI_pcmpestri<int_x86_sse42_pcmpestriz128>; |