Chris Lattner | 2de8d2b | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 1 | //====- X86Instr64bit.td - Describe X86-64 Instructions ----*- tablegen -*-===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file describes the X86-64 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 | //===----------------------------------------------------------------------===// |
Chris Lattner | 2de8d2b | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 17 | // Operand Definitions. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 18 | // |
| 19 | |
| 20 | // 64-bits but only 32 bits are significant. |
| 21 | def i64i32imm : Operand<i64>; |
| 22 | // 64-bits but only 8 bits are significant. |
| 23 | def i64i8imm : Operand<i64>; |
| 24 | |
| 25 | def lea64mem : Operand<i64> { |
| 26 | let PrintMethod = "printi64mem"; |
| 27 | let MIOperandInfo = (ops GR64, i8imm, GR64, i32imm); |
| 28 | } |
| 29 | |
| 30 | def lea64_32mem : Operand<i32> { |
| 31 | let PrintMethod = "printlea64_32mem"; |
| 32 | let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm); |
| 33 | } |
| 34 | |
| 35 | //===----------------------------------------------------------------------===// |
Chris Lattner | 2de8d2b | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 36 | // Complex Pattern Definitions. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 37 | // |
| 38 | def lea64addr : ComplexPattern<i64, 4, "SelectLEAAddr", |
| 39 | [add, mul, shl, or, frameindex, X86Wrapper], |
| 40 | []>; |
| 41 | |
| 42 | //===----------------------------------------------------------------------===// |
Chris Lattner | 2de8d2b | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 43 | // Pattern fragments. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 44 | // |
| 45 | |
| 46 | def i64immSExt32 : PatLeaf<(i64 imm), [{ |
| 47 | // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit |
| 48 | // sign extended field. |
| 49 | return (int64_t)N->getValue() == (int32_t)N->getValue(); |
| 50 | }]>; |
| 51 | |
| 52 | def i64immZExt32 : PatLeaf<(i64 imm), [{ |
| 53 | // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit |
| 54 | // unsignedsign extended field. |
| 55 | return (uint64_t)N->getValue() == (uint32_t)N->getValue(); |
| 56 | }]>; |
| 57 | |
| 58 | def i64immSExt8 : PatLeaf<(i64 imm), [{ |
| 59 | // i64immSExt8 predicate - True if the 64-bit immediate fits in a 8-bit |
| 60 | // sign extended field. |
| 61 | return (int64_t)N->getValue() == (int8_t)N->getValue(); |
| 62 | }]>; |
| 63 | |
Chris Lattner | 20be7d7 | 2008-02-27 05:47:54 +0000 | [diff] [blame] | 64 | def i64immFFFFFFFF : PatLeaf<(i64 imm), [{ |
| 65 | // i64immFFFFFFFF - True if this is a specific constant we can't write in |
| 66 | // tblgen files. |
| 67 | return N->getValue() == 0x00000000FFFFFFFFULL; |
| 68 | }]>; |
| 69 | |
| 70 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 71 | def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>; |
| 72 | def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>; |
| 73 | def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>; |
| 74 | |
| 75 | def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>; |
| 76 | def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>; |
| 77 | def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>; |
| 78 | def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>; |
| 79 | |
| 80 | def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>; |
| 81 | def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>; |
| 82 | def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>; |
| 83 | def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>; |
| 84 | |
| 85 | //===----------------------------------------------------------------------===// |
| 86 | // Instruction list... |
| 87 | // |
| 88 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 89 | //===----------------------------------------------------------------------===// |
| 90 | // Call Instructions... |
| 91 | // |
Evan Cheng | 37e7c75 | 2007-07-21 00:34:19 +0000 | [diff] [blame] | 92 | let isCall = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 93 | // All calls clobber the non-callee saved registers... |
| 94 | let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, |
Evan Cheng | 931a8f4 | 2008-01-29 19:34:22 +0000 | [diff] [blame] | 95 | FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 96 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
| 97 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, |
Evan Cheng | 6e8b8bd | 2007-09-27 19:01:55 +0000 | [diff] [blame] | 98 | XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 99 | def CALL64pcrel32 : I<0xE8, RawFrm, (outs), (ins i64imm:$dst, variable_ops), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 100 | "call\t${dst:call}", []>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 101 | def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 102 | "call\t{*}$dst", [(X86call GR64:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 103 | def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops), |
Dan Gohman | ea4faba | 2008-05-29 21:50:34 +0000 | [diff] [blame] | 104 | "call\t{*}$dst", [(X86call (loadi64 addr:$dst))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 105 | } |
| 106 | |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 107 | |
| 108 | |
| 109 | let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in |
Arnold Schwaighofer | 6fd37ac | 2008-03-19 16:39:45 +0000 | [diff] [blame] | 110 | def TCRETURNdi64 : I<0, Pseudo, (outs), (ins i64imm:$dst, i32imm:$offset, variable_ops), |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 111 | "#TC_RETURN $dst $offset", |
| 112 | []>; |
| 113 | |
| 114 | let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in |
Arnold Schwaighofer | 6fd37ac | 2008-03-19 16:39:45 +0000 | [diff] [blame] | 115 | def TCRETURNri64 : I<0, Pseudo, (outs), (ins GR64:$dst, i32imm:$offset, variable_ops), |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 116 | "#TC_RETURN $dst $offset", |
| 117 | []>; |
| 118 | |
| 119 | |
| 120 | let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in |
| 121 | def TAILJMPr64 : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst # TAILCALL", |
| 122 | []>; |
| 123 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 124 | // Branches |
Owen Anderson | f805308 | 2007-11-12 07:39:39 +0000 | [diff] [blame] | 125 | let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 126 | def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 127 | [(brind GR64:$dst)]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 128 | def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 129 | [(brind (loadi64 addr:$dst))]>; |
| 130 | } |
| 131 | |
| 132 | //===----------------------------------------------------------------------===// |
| 133 | // Miscellaneous Instructions... |
| 134 | // |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 135 | let Defs = [RBP,RSP], Uses = [RBP,RSP], mayLoad = 1, neverHasSideEffects = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 136 | def LEAVE64 : I<0xC9, RawFrm, |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 137 | (outs), (ins), "leave", []>; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 138 | let Defs = [RSP], Uses = [RSP], neverHasSideEffects=1 in { |
| 139 | let mayLoad = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 140 | def POP64r : I<0x58, AddRegFrm, |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 141 | (outs GR64:$reg), (ins), "pop{q}\t$reg", []>; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 142 | let mayStore = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 143 | def PUSH64r : I<0x50, AddRegFrm, |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 144 | (outs), (ins GR64:$reg), "push{q}\t$reg", []>; |
| 145 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 146 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 147 | let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1 in |
Evan Cheng | f134131 | 2007-09-26 21:28:00 +0000 | [diff] [blame] | 148 | def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 149 | let Defs = [RSP], Uses = [RSP, EFLAGS], mayStore = 1 in |
Evan Cheng | f134131 | 2007-09-26 21:28:00 +0000 | [diff] [blame] | 150 | def PUSHFQ : I<0x9C, RawFrm, (outs), (ins), "pushf", []>; |
Evan Cheng | d843433 | 2007-09-26 01:29:06 +0000 | [diff] [blame] | 151 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 152 | def LEA64_32r : I<0x8D, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 153 | (outs GR32:$dst), (ins lea64_32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 154 | "lea{l}\t{$src|$dst}, {$dst|$src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 155 | [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>; |
| 156 | |
Evan Cheng | 1ea8e6b | 2008-03-27 01:41:09 +0000 | [diff] [blame] | 157 | let isReMaterializable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 158 | def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 159 | "lea{q}\t{$src|$dst}, {$dst|$src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 160 | [(set GR64:$dst, lea64addr:$src)]>; |
| 161 | |
| 162 | let isTwoAddress = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 163 | def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 164 | "bswap{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 165 | [(set GR64:$dst, (bswap GR64:$src))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 166 | |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 167 | // Bit scan instructions. |
| 168 | let Defs = [EFLAGS] in { |
Evan Cheng | 4e33de9 | 2007-12-14 18:49:43 +0000 | [diff] [blame] | 169 | def BSF64rr : RI<0xBC, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | cdb54c6 | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 170 | "bsf{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 9a8ffd5 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 171 | [(set GR64:$dst, (X86bsf GR64:$src)), (implicit EFLAGS)]>, TB; |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 172 | def BSF64rm : RI<0xBC, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | cdb54c6 | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 173 | "bsf{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 9a8ffd5 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 174 | [(set GR64:$dst, (X86bsf (loadi64 addr:$src))), |
| 175 | (implicit EFLAGS)]>, TB; |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 176 | |
Evan Cheng | 4e33de9 | 2007-12-14 18:49:43 +0000 | [diff] [blame] | 177 | def BSR64rr : RI<0xBD, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | cdb54c6 | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 178 | "bsr{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 9a8ffd5 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 179 | [(set GR64:$dst, (X86bsr GR64:$src)), (implicit EFLAGS)]>, TB; |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 180 | def BSR64rm : RI<0xBD, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | cdb54c6 | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 181 | "bsr{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 9a8ffd5 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 182 | [(set GR64:$dst, (X86bsr (loadi64 addr:$src))), |
| 183 | (implicit EFLAGS)]>, TB; |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 184 | } // Defs = [EFLAGS] |
| 185 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 186 | // Repeat string ops |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 187 | let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 188 | def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 189 | [(X86rep_movs i64)]>, REP; |
| 190 | let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 191 | def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 192 | [(X86rep_stos i64)]>, REP; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 193 | |
| 194 | //===----------------------------------------------------------------------===// |
| 195 | // Move Instructions... |
| 196 | // |
| 197 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 198 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 199 | def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 200 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 201 | |
Evan Cheng | d2b9d30 | 2008-06-25 01:16:38 +0000 | [diff] [blame] | 202 | let isReMaterializable = 1, isAsCheapAsAMove = 1 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 203 | def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 204 | "movabs{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 205 | [(set GR64:$dst, imm:$src)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 206 | def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 207 | "mov{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 208 | [(set GR64:$dst, i64immSExt32:$src)]>; |
Dan Gohman | 8aef09b | 2007-09-07 21:32:51 +0000 | [diff] [blame] | 209 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 210 | |
Chris Lattner | 1a1932c | 2008-01-06 23:38:27 +0000 | [diff] [blame] | 211 | let isSimpleLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 212 | def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 213 | "mov{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 214 | [(set GR64:$dst, (load addr:$src))]>; |
| 215 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 216 | def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 217 | "mov{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 218 | [(store GR64:$src, addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 219 | def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 220 | "mov{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 221 | [(store i64immSExt32:$src, addr:$dst)]>; |
| 222 | |
| 223 | // Sign/Zero extenders |
| 224 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 225 | def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 226 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 227 | [(set GR64:$dst, (sext GR8:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 228 | def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 229 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 230 | [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 231 | def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 232 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 233 | [(set GR64:$dst, (sext GR16:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 234 | def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 235 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 236 | [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 237 | def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 238 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 239 | [(set GR64:$dst, (sext GR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 240 | def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 241 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 242 | [(set GR64:$dst, (sextloadi64i32 addr:$src))]>; |
| 243 | |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 244 | // Use movzbl instead of movzbq when the destination is a register; it's |
| 245 | // equivalent due to implicit zero-extending, and it has a smaller encoding. |
| 246 | def MOVZX64rr8 : I<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
| 247 | "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 248 | [(set GR64:$dst, (zext GR8:$src))]>, TB; |
| 249 | def MOVZX64rm8 : I<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
| 250 | "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 251 | [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB; |
| 252 | // Use movzwl instead of movzwq when the destination is a register; it's |
| 253 | // equivalent due to implicit zero-extending, and it has a smaller encoding. |
| 254 | def MOVZX64rr16: I<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
| 255 | "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 256 | [(set GR64:$dst, (zext GR16:$src))]>, TB; |
| 257 | def MOVZX64rm16: I<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
| 258 | "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 259 | [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 260 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 261 | let neverHasSideEffects = 1 in { |
| 262 | let Defs = [RAX], Uses = [EAX] in |
| 263 | def CDQE : RI<0x98, RawFrm, (outs), (ins), |
| 264 | "{cltq|cdqe}", []>; // RAX = signext(EAX) |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 265 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 266 | let Defs = [RAX,RDX], Uses = [RAX] in |
| 267 | def CQO : RI<0x99, RawFrm, (outs), (ins), |
| 268 | "{cqto|cqo}", []>; // RDX:RAX = signext(RAX) |
| 269 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 270 | |
| 271 | //===----------------------------------------------------------------------===// |
| 272 | // Arithmetic Instructions... |
| 273 | // |
| 274 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 275 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 276 | let isTwoAddress = 1 in { |
| 277 | let isConvertibleToThreeAddress = 1 in { |
| 278 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 279 | def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 280 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 281 | [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>; |
| 282 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 283 | def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 284 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 285 | [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 286 | def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 287 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 288 | [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>; |
| 289 | } // isConvertibleToThreeAddress |
| 290 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 291 | def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 292 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 293 | [(set GR64:$dst, (add GR64:$src1, (load addr:$src2)))]>; |
| 294 | } // isTwoAddress |
| 295 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 296 | def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 297 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 298 | [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 299 | def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 300 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 301 | [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 302 | def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 303 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 304 | [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
| 305 | |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 306 | let Uses = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 307 | let isTwoAddress = 1 in { |
| 308 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 309 | def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 310 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 311 | [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>; |
| 312 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 313 | def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 314 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 315 | [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>; |
| 316 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 317 | def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 318 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 319 | [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 320 | def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 321 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 322 | [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>; |
| 323 | } // isTwoAddress |
| 324 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 325 | def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 326 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 327 | [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 328 | def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 329 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 330 | [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 331 | def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 332 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 333 | [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 334 | } // Uses = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 335 | |
| 336 | let isTwoAddress = 1 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 337 | def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 338 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 339 | [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>; |
| 340 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 341 | def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 342 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 343 | [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>; |
| 344 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 345 | def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 346 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 347 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 348 | def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 349 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 350 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>; |
| 351 | } // isTwoAddress |
| 352 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 353 | def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 354 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 355 | [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 356 | def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 357 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 358 | [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 359 | def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 360 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 361 | [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
| 362 | |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 363 | let Uses = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 364 | let isTwoAddress = 1 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 365 | def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 366 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 367 | [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>; |
| 368 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 369 | def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 370 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 371 | [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>; |
| 372 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 373 | def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 374 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 375 | [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 376 | def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 377 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 378 | [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>; |
| 379 | } // isTwoAddress |
| 380 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 381 | def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 382 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 383 | [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 384 | def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 385 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 386 | [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 387 | def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 388 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 389 | [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 390 | } // Uses = [EFLAGS] |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 391 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 392 | |
| 393 | // Unsigned multiplication |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 394 | let Defs = [RAX,RDX,EFLAGS], Uses = [RAX], neverHasSideEffects = 1 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 395 | def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 396 | "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64 |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 397 | let mayLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 398 | def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 399 | "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 400 | |
| 401 | // Signed multiplication |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 402 | def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 403 | "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64 |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 404 | let mayLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 405 | def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 406 | "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64] |
| 407 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 408 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 409 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 410 | let isTwoAddress = 1 in { |
| 411 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 412 | def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 413 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 414 | [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB; |
| 415 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 416 | def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 417 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 418 | [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB; |
| 419 | } // isTwoAddress |
| 420 | |
| 421 | // Suprisingly enough, these are not two address instructions! |
| 422 | def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 423 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 424 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 425 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>; |
| 426 | def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 427 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 428 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 429 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>; |
| 430 | def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 431 | (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 432 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 433 | [(set GR64:$dst, (mul (load addr:$src1), i64immSExt32:$src2))]>; |
| 434 | def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 435 | (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 436 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 437 | [(set GR64:$dst, (mul (load addr:$src1), i64immSExt8:$src2))]>; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 438 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 439 | |
| 440 | // Unsigned division / remainder |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 441 | let neverHasSideEffects = 1 in { |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 442 | let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 443 | def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 444 | "div{q}\t$src", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 445 | // Signed division / remainder |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 446 | def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 447 | "idiv{q}\t$src", []>; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 448 | let mayLoad = 1 in { |
| 449 | def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX |
| 450 | "div{q}\t$src", []>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 451 | def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 452 | "idiv{q}\t$src", []>; |
| 453 | } |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 454 | } |
| 455 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 456 | |
| 457 | // Unary instructions |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 458 | let Defs = [EFLAGS], CodeSize = 2 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 459 | let isTwoAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 460 | def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 461 | [(set GR64:$dst, (ineg GR64:$src))]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 462 | def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 463 | [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>; |
| 464 | |
| 465 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 466 | def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 467 | [(set GR64:$dst, (add GR64:$src, 1))]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 468 | def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 469 | [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>; |
| 470 | |
| 471 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 472 | def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 473 | [(set GR64:$dst, (add GR64:$src, -1))]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 474 | def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 475 | [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>; |
| 476 | |
| 477 | // In 64-bit mode, single byte INC and DEC cannot be encoded. |
| 478 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in { |
| 479 | // Can transform into LEA. |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 480 | def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 481 | [(set GR16:$dst, (add GR16:$src, 1))]>, |
| 482 | OpSize, Requires<[In64BitMode]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 483 | def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 484 | [(set GR32:$dst, (add GR32:$src, 1))]>, |
| 485 | Requires<[In64BitMode]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 486 | def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 487 | [(set GR16:$dst, (add GR16:$src, -1))]>, |
| 488 | OpSize, Requires<[In64BitMode]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 489 | def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 490 | [(set GR32:$dst, (add GR32:$src, -1))]>, |
| 491 | Requires<[In64BitMode]>; |
| 492 | } // isConvertibleToThreeAddress |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 493 | |
| 494 | // These are duplicates of their 32-bit counterparts. Only needed so X86 knows |
| 495 | // how to unfold them. |
| 496 | let isTwoAddress = 0, CodeSize = 2 in { |
| 497 | def INC64_16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst", |
| 498 | [(store (add (loadi16 addr:$dst), 1), addr:$dst)]>, |
| 499 | OpSize, Requires<[In64BitMode]>; |
| 500 | def INC64_32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst", |
| 501 | [(store (add (loadi32 addr:$dst), 1), addr:$dst)]>, |
| 502 | Requires<[In64BitMode]>; |
| 503 | def DEC64_16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst", |
| 504 | [(store (add (loadi16 addr:$dst), -1), addr:$dst)]>, |
| 505 | OpSize, Requires<[In64BitMode]>; |
| 506 | def DEC64_32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst", |
| 507 | [(store (add (loadi32 addr:$dst), -1), addr:$dst)]>, |
| 508 | Requires<[In64BitMode]>; |
| 509 | } |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 510 | } // Defs = [EFLAGS], CodeSize |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 511 | |
| 512 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 513 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 514 | // Shift instructions |
| 515 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 516 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 517 | def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 518 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 519 | [(set GR64:$dst, (shl GR64:$src, CL))]>; |
Evan Cheng | a98f627 | 2007-10-05 18:20:36 +0000 | [diff] [blame] | 520 | let isConvertibleToThreeAddress = 1 in // Can transform into LEA. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 521 | def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 522 | "shl{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 523 | [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>; |
Chris Lattner | f4005a8 | 2008-01-11 18:00:50 +0000 | [diff] [blame] | 524 | // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is |
| 525 | // cheaper. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 526 | } // isTwoAddress |
| 527 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 528 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 529 | def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 530 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 531 | [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 532 | def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 533 | "shl{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 534 | [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 535 | def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 536 | "shl{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 537 | [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 538 | |
| 539 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 540 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 541 | def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 542 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 543 | [(set GR64:$dst, (srl GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 544 | def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 545 | "shr{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 546 | [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 547 | def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 548 | "shr{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 549 | [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>; |
| 550 | } // isTwoAddress |
| 551 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 552 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 553 | def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 554 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 555 | [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 556 | def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 557 | "shr{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 558 | [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 559 | def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 560 | "shr{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 561 | [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 562 | |
| 563 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 564 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 565 | def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 566 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 567 | [(set GR64:$dst, (sra GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 568 | def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 569 | "sar{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 570 | [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 571 | def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 572 | "sar{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 573 | [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>; |
| 574 | } // isTwoAddress |
| 575 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 576 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 577 | def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 578 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 579 | [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 580 | def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 581 | "sar{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 582 | [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 583 | def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 584 | "sar{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 585 | [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 586 | |
| 587 | // Rotate instructions |
| 588 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 589 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 590 | def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 591 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 592 | [(set GR64:$dst, (rotl GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 593 | def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 594 | "rol{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 595 | [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 596 | def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 597 | "rol{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 598 | [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>; |
| 599 | } // isTwoAddress |
| 600 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 601 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 602 | def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 603 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 604 | [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 605 | def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 606 | "rol{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 607 | [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 608 | def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 609 | "rol{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 610 | [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 611 | |
| 612 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 613 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 614 | def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 615 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 616 | [(set GR64:$dst, (rotr GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 617 | def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 618 | "ror{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 619 | [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 620 | def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 621 | "ror{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 622 | [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>; |
| 623 | } // isTwoAddress |
| 624 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 625 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 626 | def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 627 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 628 | [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 629 | def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 630 | "ror{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 631 | [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 632 | def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 633 | "ror{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 634 | [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 635 | |
| 636 | // Double shift instructions (generalizations of rotate) |
| 637 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 638 | let Uses = [CL] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 639 | def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 640 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 641 | [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 642 | def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 643 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 644 | [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB; |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 645 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 646 | |
| 647 | let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction |
| 648 | def SHLD64rri8 : RIi8<0xA4, MRMDestReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 649 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 650 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 651 | [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, |
| 652 | (i8 imm:$src3)))]>, |
| 653 | TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 654 | def SHRD64rri8 : RIi8<0xAC, MRMDestReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 655 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 656 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 657 | [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, |
| 658 | (i8 imm:$src3)))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 659 | TB; |
| 660 | } // isCommutable |
| 661 | } // isTwoAddress |
| 662 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 663 | let Uses = [CL] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 664 | def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 665 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 666 | [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL), |
| 667 | addr:$dst)]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 668 | def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 669 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 670 | [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL), |
| 671 | addr:$dst)]>, TB; |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 672 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 673 | def SHLD64mri8 : RIi8<0xA4, MRMDestMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 674 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 675 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 676 | [(store (X86shld (loadi64 addr:$dst), GR64:$src2, |
| 677 | (i8 imm:$src3)), addr:$dst)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 678 | TB; |
| 679 | def SHRD64mri8 : RIi8<0xAC, MRMDestMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 680 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 681 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 682 | [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, |
| 683 | (i8 imm:$src3)), addr:$dst)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 684 | TB; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 685 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 686 | |
| 687 | //===----------------------------------------------------------------------===// |
| 688 | // Logical Instructions... |
| 689 | // |
| 690 | |
| 691 | let isTwoAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 692 | def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 693 | [(set GR64:$dst, (not GR64:$src))]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 694 | def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 695 | [(store (not (loadi64 addr:$dst)), addr:$dst)]>; |
| 696 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 697 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 698 | let isTwoAddress = 1 in { |
| 699 | let isCommutable = 1 in |
| 700 | def AND64rr : RI<0x21, MRMDestReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 701 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 702 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 703 | [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>; |
| 704 | def AND64rm : RI<0x23, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 705 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 706 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 707 | [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>; |
| 708 | def AND64ri32 : RIi32<0x81, MRM4r, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 709 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 710 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 711 | [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>; |
| 712 | def AND64ri8 : RIi8<0x83, MRM4r, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 713 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 714 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 715 | [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>; |
| 716 | } // isTwoAddress |
| 717 | |
| 718 | def AND64mr : RI<0x21, MRMDestMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 719 | (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 720 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 721 | [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>; |
| 722 | def AND64mi32 : RIi32<0x81, MRM4m, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 723 | (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 724 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 725 | [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>; |
| 726 | def AND64mi8 : RIi8<0x83, MRM4m, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 727 | (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 728 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 729 | [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>; |
| 730 | |
| 731 | let isTwoAddress = 1 in { |
| 732 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 733 | def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 734 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 735 | [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 736 | def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 737 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 738 | [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 739 | def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 740 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 741 | [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 742 | def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 743 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 744 | [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>; |
| 745 | } // isTwoAddress |
| 746 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 747 | def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 748 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 749 | [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 750 | def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 751 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 752 | [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 753 | def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 754 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 755 | [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>; |
| 756 | |
| 757 | let isTwoAddress = 1 in { |
Bill Wendling | 12e9721 | 2008-05-30 06:47:04 +0000 | [diff] [blame] | 758 | let isCommutable = 1, isAsCheapAsAMove = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 759 | def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 760 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 761 | [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 762 | def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 763 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 764 | [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>; |
| 765 | def XOR64ri32 : RIi32<0x81, MRM6r, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 766 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 767 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 768 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 769 | def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 770 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 771 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>; |
| 772 | } // isTwoAddress |
| 773 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 774 | def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 775 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 776 | [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 777 | def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 778 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 779 | [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 780 | def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 781 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 782 | [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 783 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 784 | |
| 785 | //===----------------------------------------------------------------------===// |
| 786 | // Comparison Instructions... |
| 787 | // |
| 788 | |
| 789 | // Integer comparison |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 790 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 791 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 792 | def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 793 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 794 | [(X86cmp (and GR64:$src1, GR64:$src2), 0), |
| 795 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 796 | def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 797 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 798 | [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0), |
| 799 | (implicit EFLAGS)]>; |
| 800 | def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), |
| 801 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 802 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 803 | [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0), |
| 804 | (implicit EFLAGS)]>; |
| 805 | def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), |
| 806 | (ins i64mem:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 807 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 808 | [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0), |
| 809 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 810 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 811 | def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 812 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 813 | [(X86cmp GR64:$src1, GR64:$src2), |
| 814 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 815 | def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 816 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 817 | [(X86cmp (loadi64 addr:$src1), GR64:$src2), |
| 818 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 819 | def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 820 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 821 | [(X86cmp GR64:$src1, (loadi64 addr:$src2)), |
| 822 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 823 | def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 824 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 825 | [(X86cmp GR64:$src1, i64immSExt32:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 826 | (implicit EFLAGS)]>; |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 827 | def CMP64mi32 : RIi32<0x81, MRM7m, (outs), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 828 | (ins i64mem:$src1, i64i32imm:$src2), |
| 829 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 830 | [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 831 | (implicit EFLAGS)]>; |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 832 | def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 833 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 834 | [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 835 | (implicit EFLAGS)]>; |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 836 | def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 837 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 838 | [(X86cmp GR64:$src1, i64immSExt8:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 839 | (implicit EFLAGS)]>; |
| 840 | } // Defs = [EFLAGS] |
| 841 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 842 | // Conditional moves |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 843 | let Uses = [EFLAGS], isTwoAddress = 1 in { |
Evan Cheng | 926658c | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 844 | let isCommutable = 1 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 845 | def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 846 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 847 | "cmovb\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 848 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 849 | X86_COND_B, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 850 | def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 851 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 852 | "cmovae\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 853 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 854 | X86_COND_AE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 855 | def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 856 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 857 | "cmove\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 858 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 859 | X86_COND_E, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 860 | def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 861 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 862 | "cmovne\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 863 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 864 | X86_COND_NE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 865 | def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 866 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 867 | "cmovbe\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 868 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 869 | X86_COND_BE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 870 | def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 871 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 872 | "cmova\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 873 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 874 | X86_COND_A, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 875 | def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 876 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 877 | "cmovl\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 878 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 879 | X86_COND_L, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 880 | def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 881 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 882 | "cmovge\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 883 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 884 | X86_COND_GE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 885 | def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 886 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 887 | "cmovle\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 888 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 889 | X86_COND_LE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 890 | def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 891 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 892 | "cmovg\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 893 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 894 | X86_COND_G, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 895 | def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 896 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 897 | "cmovs\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 898 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 899 | X86_COND_S, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 900 | def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 901 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 902 | "cmovns\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 903 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 904 | X86_COND_NS, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 905 | def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 906 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 907 | "cmovp\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 908 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 909 | X86_COND_P, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 910 | def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 911 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 912 | "cmovnp\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 913 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 914 | X86_COND_NP, EFLAGS))]>, TB; |
Evan Cheng | 926658c | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 915 | } // isCommutable = 1 |
| 916 | |
| 917 | def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64] |
| 918 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 919 | "cmovb\t{$src2, $dst|$dst, $src2}", |
| 920 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 921 | X86_COND_B, EFLAGS))]>, TB; |
| 922 | def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64] |
| 923 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 924 | "cmovae\t{$src2, $dst|$dst, $src2}", |
| 925 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 926 | X86_COND_AE, EFLAGS))]>, TB; |
| 927 | def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64] |
| 928 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 929 | "cmove\t{$src2, $dst|$dst, $src2}", |
| 930 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 931 | X86_COND_E, EFLAGS))]>, TB; |
| 932 | def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64] |
| 933 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 934 | "cmovne\t{$src2, $dst|$dst, $src2}", |
| 935 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 936 | X86_COND_NE, EFLAGS))]>, TB; |
| 937 | def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64] |
| 938 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 939 | "cmovbe\t{$src2, $dst|$dst, $src2}", |
| 940 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 941 | X86_COND_BE, EFLAGS))]>, TB; |
| 942 | def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64] |
| 943 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 944 | "cmova\t{$src2, $dst|$dst, $src2}", |
| 945 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 946 | X86_COND_A, EFLAGS))]>, TB; |
| 947 | def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64] |
| 948 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 949 | "cmovl\t{$src2, $dst|$dst, $src2}", |
| 950 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 951 | X86_COND_L, EFLAGS))]>, TB; |
| 952 | def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64] |
| 953 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 954 | "cmovge\t{$src2, $dst|$dst, $src2}", |
| 955 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 956 | X86_COND_GE, EFLAGS))]>, TB; |
| 957 | def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64] |
| 958 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 959 | "cmovle\t{$src2, $dst|$dst, $src2}", |
| 960 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 961 | X86_COND_LE, EFLAGS))]>, TB; |
| 962 | def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64] |
| 963 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 964 | "cmovg\t{$src2, $dst|$dst, $src2}", |
| 965 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 966 | X86_COND_G, EFLAGS))]>, TB; |
| 967 | def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64] |
| 968 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 969 | "cmovs\t{$src2, $dst|$dst, $src2}", |
| 970 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 971 | X86_COND_S, EFLAGS))]>, TB; |
| 972 | def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64] |
| 973 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 974 | "cmovns\t{$src2, $dst|$dst, $src2}", |
| 975 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 976 | X86_COND_NS, EFLAGS))]>, TB; |
| 977 | def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64] |
| 978 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 979 | "cmovp\t{$src2, $dst|$dst, $src2}", |
| 980 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 981 | X86_COND_P, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 982 | def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64] |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 983 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 984 | "cmovnp\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 985 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 986 | X86_COND_NP, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 987 | } // isTwoAddress |
| 988 | |
| 989 | //===----------------------------------------------------------------------===// |
| 990 | // Conversion Instructions... |
| 991 | // |
| 992 | |
| 993 | // f64 -> signed i64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 994 | def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 995 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 996 | [(set GR64:$dst, |
| 997 | (int_x86_sse2_cvtsd2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 998 | def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 999 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1000 | [(set GR64:$dst, (int_x86_sse2_cvtsd2si64 |
| 1001 | (load addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1002 | def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1003 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1004 | [(set GR64:$dst, (fp_to_sint FR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1005 | def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1006 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1007 | [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1008 | def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1009 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1010 | [(set GR64:$dst, |
| 1011 | (int_x86_sse2_cvttsd2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1012 | def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1013 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1014 | [(set GR64:$dst, |
| 1015 | (int_x86_sse2_cvttsd2si64 |
| 1016 | (load addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1017 | |
| 1018 | // Signed i64 -> f64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1019 | def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1020 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1021 | [(set FR64:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1022 | def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1023 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1024 | [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
Evan Cheng | 1d5832e | 2008-01-11 07:37:44 +0000 | [diff] [blame] | 1025 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1026 | let isTwoAddress = 1 in { |
| 1027 | def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1028 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1029 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1030 | [(set VR128:$dst, |
| 1031 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 1032 | GR64:$src2))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1033 | def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1034 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1035 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1036 | [(set VR128:$dst, |
| 1037 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 1038 | (loadi64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1039 | } // isTwoAddress |
| 1040 | |
| 1041 | // Signed i64 -> f32 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1042 | def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1043 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1044 | [(set FR32:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1045 | def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1046 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1047 | [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
Evan Cheng | 1d5832e | 2008-01-11 07:37:44 +0000 | [diff] [blame] | 1048 | |
| 1049 | let isTwoAddress = 1 in { |
| 1050 | def Int_CVTSI2SS64rr : RSSI<0x2A, MRMSrcReg, |
| 1051 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
| 1052 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
| 1053 | [(set VR128:$dst, |
| 1054 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 1055 | GR64:$src2))]>; |
| 1056 | def Int_CVTSI2SS64rm : RSSI<0x2A, MRMSrcMem, |
| 1057 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
| 1058 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
| 1059 | [(set VR128:$dst, |
| 1060 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 1061 | (loadi64 addr:$src2)))]>; |
| 1062 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1063 | |
| 1064 | // f32 -> signed i64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1065 | def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1066 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1067 | [(set GR64:$dst, |
| 1068 | (int_x86_sse_cvtss2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1069 | def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1070 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1071 | [(set GR64:$dst, (int_x86_sse_cvtss2si64 |
| 1072 | (load addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1073 | def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1074 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1075 | [(set GR64:$dst, (fp_to_sint FR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1076 | def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1077 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1078 | [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1079 | def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1080 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1081 | [(set GR64:$dst, |
| 1082 | (int_x86_sse_cvttss2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1083 | def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1084 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1085 | [(set GR64:$dst, |
| 1086 | (int_x86_sse_cvttss2si64 (load addr:$src)))]>; |
| 1087 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1088 | //===----------------------------------------------------------------------===// |
| 1089 | // Alias Instructions |
| 1090 | //===----------------------------------------------------------------------===// |
| 1091 | |
Dan Gohman | 027cd11 | 2007-09-17 14:55:08 +0000 | [diff] [blame] | 1092 | // Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's |
| 1093 | // equivalent due to implicit zero-extending, and it sometimes has a smaller |
| 1094 | // encoding. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1095 | // FIXME: remove when we can teach regalloc that xor reg, reg is ok. |
| 1096 | // FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove |
| 1097 | // when we have a better way to specify isel priority. |
Bill Wendling | 12e9721 | 2008-05-30 06:47:04 +0000 | [diff] [blame] | 1098 | let Defs = [EFLAGS], AddedComplexity = 1, |
| 1099 | isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1100 | def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins), |
| 1101 | "xor{l}\t${dst:subreg32}, ${dst:subreg32}", |
| 1102 | [(set GR64:$dst, 0)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1103 | |
| 1104 | // Materialize i64 constant where top 32-bits are zero. |
Chris Lattner | 17dab4a | 2008-01-10 05:45:39 +0000 | [diff] [blame] | 1105 | let AddedComplexity = 1, isReMaterializable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1106 | def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1107 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1108 | [(set GR64:$dst, i64immZExt32:$src)]>; |
| 1109 | |
Anton Korobeynikov | 4fbf00b | 2008-05-04 21:36:32 +0000 | [diff] [blame] | 1110 | //===----------------------------------------------------------------------===// |
| 1111 | // Thread Local Storage Instructions |
| 1112 | //===----------------------------------------------------------------------===// |
| 1113 | |
| 1114 | def TLS_addr64 : I<0, Pseudo, (outs GR64:$dst), (ins i64imm:$sym), |
Anton Korobeynikov | 5577e2e | 2008-05-05 17:08:59 +0000 | [diff] [blame] | 1115 | ".byte\t0x66; leaq\t${sym:mem}(%rip), $dst; .word\t0x6666; rex64", |
Anton Korobeynikov | 4fbf00b | 2008-05-04 21:36:32 +0000 | [diff] [blame] | 1116 | [(set GR64:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>; |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1117 | |
| 1118 | //===----------------------------------------------------------------------===// |
| 1119 | // Atomic Instructions |
| 1120 | //===----------------------------------------------------------------------===// |
| 1121 | |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1122 | let Defs = [RAX, EFLAGS], Uses = [RAX] in { |
Evan Cheng | d49dbb8 | 2008-04-18 20:55:36 +0000 | [diff] [blame] | 1123 | def LCMPXCHG64 : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$ptr, GR64:$swap), |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1124 | "lock cmpxchgq $swap,$ptr", |
| 1125 | [(X86cas addr:$ptr, GR64:$swap, 8)]>, TB, LOCK; |
| 1126 | } |
| 1127 | |
Dan Gohman | a41a1c09 | 2008-08-06 15:52:50 +0000 | [diff] [blame] | 1128 | let Constraints = "$val = $dst" in { |
| 1129 | let Defs = [EFLAGS] in |
Evan Cheng | d49dbb8 | 2008-04-18 20:55:36 +0000 | [diff] [blame] | 1130 | def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val), |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1131 | "lock xadd $val, $ptr", |
Mon P Wang | 6bde9ec | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 1132 | [(set GR64:$dst, (atomic_load_add_64 addr:$ptr, GR64:$val))]>, |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1133 | TB, LOCK; |
Evan Cheng | a1e8060 | 2008-04-19 02:05:42 +0000 | [diff] [blame] | 1134 | def XCHG64rm : RI<0x87, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val), |
| 1135 | "xchg $val, $ptr", |
| 1136 | [(set GR64:$dst, (atomic_swap_64 addr:$ptr, GR64:$val))]>; |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1140 | //===----------------------------------------------------------------------===// |
| 1141 | // Non-Instruction Patterns |
| 1142 | //===----------------------------------------------------------------------===// |
| 1143 | |
| 1144 | // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable |
| 1145 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
| 1146 | (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>; |
| 1147 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
| 1148 | (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>; |
| 1149 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
| 1150 | (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>; |
| 1151 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
| 1152 | (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>; |
| 1153 | |
| 1154 | def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst), |
| 1155 | (MOV64mi32 addr:$dst, tconstpool:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1156 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1157 | def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst), |
| 1158 | (MOV64mi32 addr:$dst, tjumptable:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1159 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1160 | def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst), |
| 1161 | (MOV64mi32 addr:$dst, tglobaladdr:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1162 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1163 | def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst), |
| 1164 | (MOV64mi32 addr:$dst, texternalsym:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1165 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1166 | |
| 1167 | // Calls |
| 1168 | // Direct PC relative function call for small code model. 32-bit displacement |
| 1169 | // sign extended to 64-bit. |
| 1170 | def : Pat<(X86call (i64 tglobaladdr:$dst)), |
| 1171 | (CALL64pcrel32 tglobaladdr:$dst)>; |
| 1172 | def : Pat<(X86call (i64 texternalsym:$dst)), |
| 1173 | (CALL64pcrel32 texternalsym:$dst)>; |
| 1174 | |
| 1175 | def : Pat<(X86tailcall (i64 tglobaladdr:$dst)), |
| 1176 | (CALL64pcrel32 tglobaladdr:$dst)>; |
| 1177 | def : Pat<(X86tailcall (i64 texternalsym:$dst)), |
| 1178 | (CALL64pcrel32 texternalsym:$dst)>; |
| 1179 | |
| 1180 | def : Pat<(X86tailcall GR64:$dst), |
| 1181 | (CALL64r GR64:$dst)>; |
| 1182 | |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 1183 | |
| 1184 | // tailcall stuff |
| 1185 | def : Pat<(X86tailcall GR32:$dst), |
| 1186 | (TAILCALL)>; |
| 1187 | def : Pat<(X86tailcall (i64 tglobaladdr:$dst)), |
| 1188 | (TAILCALL)>; |
| 1189 | def : Pat<(X86tailcall (i64 texternalsym:$dst)), |
| 1190 | (TAILCALL)>; |
| 1191 | |
| 1192 | def : Pat<(X86tcret GR64:$dst, imm:$off), |
| 1193 | (TCRETURNri64 GR64:$dst, imm:$off)>; |
| 1194 | |
| 1195 | def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off), |
| 1196 | (TCRETURNdi64 texternalsym:$dst, imm:$off)>; |
| 1197 | |
| 1198 | def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off), |
| 1199 | (TCRETURNdi64 texternalsym:$dst, imm:$off)>; |
| 1200 | |
Dan Gohman | ec59604 | 2007-09-17 14:35:24 +0000 | [diff] [blame] | 1201 | // Comparisons. |
| 1202 | |
| 1203 | // TEST R,R is smaller than CMP R,0 |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1204 | def : Pat<(parallel (X86cmp GR64:$src1, 0), (implicit EFLAGS)), |
Dan Gohman | ec59604 | 2007-09-17 14:35:24 +0000 | [diff] [blame] | 1205 | (TEST64rr GR64:$src1, GR64:$src1)>; |
| 1206 | |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1207 | |
| 1208 | |
| 1209 | // Zero-extension |
Christopher Lamb | 76d72da | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 1210 | def : Pat<(i64 (zext GR32:$src)), |
| 1211 | (SUBREG_TO_REG (i64 0), GR32:$src, x86_subreg_32bit)>; |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1212 | |
Duncan Sands | 082524c | 2008-01-23 20:39:46 +0000 | [diff] [blame] | 1213 | // zextload bool -> zextload byte |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1214 | def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1215 | |
Christopher Lamb | 76d72da | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 1216 | def : Pat<(zextloadi64i32 addr:$src), |
| 1217 | (SUBREG_TO_REG (i64 0), (MOV32rm addr:$src), x86_subreg_32bit)>; |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1218 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1219 | // extload |
| 1220 | def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1221 | def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1222 | def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>; |
Christopher Lamb | 76d72da | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 1223 | def : Pat<(extloadi64i32 addr:$src), |
| 1224 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV32rm addr:$src), |
| 1225 | x86_subreg_32bit)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1226 | |
| 1227 | // anyext -> zext |
| 1228 | def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>; |
| 1229 | def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16:$src)>; |
Christopher Lamb | 76d72da | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 1230 | def : Pat<(i64 (anyext GR32:$src)), |
| 1231 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$src, x86_subreg_32bit)>; |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1232 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1233 | def : Pat<(i64 (anyext (loadi8 addr:$src))), (MOVZX64rm8 addr:$src)>; |
| 1234 | def : Pat<(i64 (anyext (loadi16 addr:$src))), (MOVZX64rm16 addr:$src)>; |
Christopher Lamb | 76d72da | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 1235 | def : Pat<(i64 (anyext (loadi32 addr:$src))), |
| 1236 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV32rm addr:$src), |
| 1237 | x86_subreg_32bit)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1238 | |
| 1239 | //===----------------------------------------------------------------------===// |
| 1240 | // Some peepholes |
| 1241 | //===----------------------------------------------------------------------===// |
| 1242 | |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1243 | // r & (2^32-1) ==> mov32 + implicit zext |
| 1244 | def : Pat<(and GR64:$src, i64immFFFFFFFF), |
Christopher Lamb | 76d72da | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 1245 | (SUBREG_TO_REG (i64 0), |
| 1246 | (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)), |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1247 | x86_subreg_32bit)>; |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1248 | // r & (2^16-1) ==> movz |
| 1249 | def : Pat<(and GR64:$src, 0xffff), |
| 1250 | (MOVZX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>; |
| 1251 | // r & (2^8-1) ==> movz |
| 1252 | def : Pat<(and GR64:$src, 0xff), |
| 1253 | (MOVZX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>; |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1254 | // r & (2^8-1) ==> movz |
| 1255 | def : Pat<(and GR32:$src1, 0xff), |
| 1256 | (MOVZX32rr8 (i8 (EXTRACT_SUBREG GR32:$src1, x86_subreg_8bit)))>, |
| 1257 | Requires<[In64BitMode]>; |
| 1258 | // r & (2^8-1) ==> movz |
| 1259 | def : Pat<(and GR16:$src1, 0xff), |
| 1260 | (MOVZX16rr8 (i8 (EXTRACT_SUBREG GR16:$src1, x86_subreg_8bit)))>, |
| 1261 | Requires<[In64BitMode]>; |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1262 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1263 | // (shl x, 1) ==> (add x, x) |
| 1264 | def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>; |
| 1265 | |
| 1266 | // (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c) |
| 1267 | def : Pat<(or (srl GR64:$src1, CL:$amt), |
| 1268 | (shl GR64:$src2, (sub 64, CL:$amt))), |
| 1269 | (SHRD64rrCL GR64:$src1, GR64:$src2)>; |
| 1270 | |
| 1271 | def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt), |
| 1272 | (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst), |
| 1273 | (SHRD64mrCL addr:$dst, GR64:$src2)>; |
| 1274 | |
| 1275 | // (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c) |
| 1276 | def : Pat<(or (shl GR64:$src1, CL:$amt), |
| 1277 | (srl GR64:$src2, (sub 64, CL:$amt))), |
| 1278 | (SHLD64rrCL GR64:$src1, GR64:$src2)>; |
| 1279 | |
| 1280 | def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt), |
| 1281 | (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst), |
| 1282 | (SHLD64mrCL addr:$dst, GR64:$src2)>; |
| 1283 | |
| 1284 | // X86 specific add which produces a flag. |
| 1285 | def : Pat<(addc GR64:$src1, GR64:$src2), |
| 1286 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 1287 | def : Pat<(addc GR64:$src1, (load addr:$src2)), |
| 1288 | (ADD64rm GR64:$src1, addr:$src2)>; |
| 1289 | def : Pat<(addc GR64:$src1, i64immSExt32:$src2), |
| 1290 | (ADD64ri32 GR64:$src1, imm:$src2)>; |
| 1291 | def : Pat<(addc GR64:$src1, i64immSExt8:$src2), |
| 1292 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1293 | |
| 1294 | def : Pat<(subc GR64:$src1, GR64:$src2), |
| 1295 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 1296 | def : Pat<(subc GR64:$src1, (load addr:$src2)), |
| 1297 | (SUB64rm GR64:$src1, addr:$src2)>; |
| 1298 | def : Pat<(subc GR64:$src1, imm:$src2), |
| 1299 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 1300 | def : Pat<(subc GR64:$src1, i64immSExt8:$src2), |
| 1301 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1302 | |
| 1303 | |
| 1304 | //===----------------------------------------------------------------------===// |
| 1305 | // X86-64 SSE Instructions |
| 1306 | //===----------------------------------------------------------------------===// |
| 1307 | |
| 1308 | // Move instructions... |
| 1309 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1310 | def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1311 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1312 | [(set VR128:$dst, |
| 1313 | (v2i64 (scalar_to_vector GR64:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1314 | def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1315 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1316 | [(set GR64:$dst, (vector_extract (v2i64 VR128:$src), |
| 1317 | (iPTR 0)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1318 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1319 | def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1320 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1321 | [(set FR64:$dst, (bitconvert GR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1322 | def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1323 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1324 | [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>; |
| 1325 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1326 | def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1327 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1328 | [(set GR64:$dst, (bitconvert FR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1329 | def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1330 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1331 | [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>; |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 1332 | |
| 1333 | //===----------------------------------------------------------------------===// |
| 1334 | // X86-64 SSE4.1 Instructions |
| 1335 | //===----------------------------------------------------------------------===// |
| 1336 | |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1337 | /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination |
| 1338 | multiclass SS41I_extract64<bits<8> opc, string OpcodeStr> { |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1339 | def rr : SS4AIi8<opc, MRMSrcReg, (outs GR64:$dst), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1340 | (ins VR128:$src1, i32i8imm:$src2), |
| 1341 | !strconcat(OpcodeStr, |
| 1342 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 1343 | [(set GR64:$dst, |
| 1344 | (extractelt (v2i64 VR128:$src1), imm:$src2))]>, OpSize, REX_W; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1345 | def mr : SS4AIi8<opc, MRMDestMem, (outs), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1346 | (ins i64mem:$dst, VR128:$src1, i32i8imm:$src2), |
| 1347 | !strconcat(OpcodeStr, |
| 1348 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 1349 | [(store (extractelt (v2i64 VR128:$src1), imm:$src2), |
| 1350 | addr:$dst)]>, OpSize, REX_W; |
| 1351 | } |
| 1352 | |
| 1353 | defm PEXTRQ : SS41I_extract64<0x16, "pextrq">; |
| 1354 | |
| 1355 | let isTwoAddress = 1 in { |
| 1356 | multiclass SS41I_insert64<bits<8> opc, string OpcodeStr> { |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1357 | def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1358 | (ins VR128:$src1, GR64:$src2, i32i8imm:$src3), |
| 1359 | !strconcat(OpcodeStr, |
| 1360 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
| 1361 | [(set VR128:$dst, |
| 1362 | (v2i64 (insertelt VR128:$src1, GR64:$src2, imm:$src3)))]>, |
| 1363 | OpSize, REX_W; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1364 | def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1365 | (ins VR128:$src1, i64mem:$src2, i32i8imm:$src3), |
| 1366 | !strconcat(OpcodeStr, |
| 1367 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
| 1368 | [(set VR128:$dst, |
| 1369 | (v2i64 (insertelt VR128:$src1, (loadi64 addr:$src2), |
| 1370 | imm:$src3)))]>, OpSize, REX_W; |
| 1371 | } |
| 1372 | } |
| 1373 | |
| 1374 | defm PINSRQ : SS41I_insert64<0x22, "pinsrq">; |