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> { |
Rafael Espindola | bca99f7 | 2009-04-08 21:14:34 +0000 | [diff] [blame] | 26 | let PrintMethod = "printlea64mem"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 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", |
Evan Cheng | c349576 | 2009-03-30 21:36:47 +0000 | [diff] [blame] | 39 | [add, mul, X86mul_imm, shl, or, frameindex, X86Wrapper], |
| 40 | []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 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 | |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 46 | def i64immSExt8 : PatLeaf<(i64 imm), [{ |
| 47 | // i64immSExt8 predicate - True if the 64-bit immediate fits in a 8-bit |
| 48 | // sign extended field. |
| 49 | return (int64_t)N->getZExtValue() == (int8_t)N->getZExtValue(); |
| 50 | }]>; |
| 51 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 52 | def i64immSExt32 : PatLeaf<(i64 imm), [{ |
| 53 | // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit |
| 54 | // sign extended field. |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 55 | return (int64_t)N->getZExtValue() == (int32_t)N->getZExtValue(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 56 | }]>; |
| 57 | |
| 58 | def i64immZExt32 : PatLeaf<(i64 imm), [{ |
| 59 | // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit |
| 60 | // unsignedsign extended field. |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 61 | return (uint64_t)N->getZExtValue() == (uint32_t)N->getZExtValue(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 62 | }]>; |
| 63 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 64 | def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>; |
| 65 | def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>; |
| 66 | def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>; |
| 67 | |
| 68 | def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>; |
| 69 | def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>; |
| 70 | def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>; |
| 71 | def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>; |
| 72 | |
| 73 | def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>; |
| 74 | def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>; |
| 75 | def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>; |
| 76 | def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>; |
| 77 | |
| 78 | //===----------------------------------------------------------------------===// |
| 79 | // Instruction list... |
| 80 | // |
| 81 | |
Dan Gohman | 01c9f77 | 2008-10-01 18:28:06 +0000 | [diff] [blame] | 82 | // ADJCALLSTACKDOWN/UP implicitly use/def RSP because they may be expanded into |
| 83 | // a stack adjustment and the codegen must know that they may modify the stack |
| 84 | // pointer before prolog-epilog rewriting occurs. |
| 85 | // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become |
| 86 | // sub / add which can clobber EFLAGS. |
| 87 | let Defs = [RSP, EFLAGS], Uses = [RSP] in { |
| 88 | def ADJCALLSTACKDOWN64 : I<0, Pseudo, (outs), (ins i32imm:$amt), |
| 89 | "#ADJCALLSTACKDOWN", |
Chris Lattner | fe5d402 | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 90 | [(X86callseq_start timm:$amt)]>, |
Dan Gohman | 01c9f77 | 2008-10-01 18:28:06 +0000 | [diff] [blame] | 91 | Requires<[In64BitMode]>; |
| 92 | def ADJCALLSTACKUP64 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2), |
| 93 | "#ADJCALLSTACKUP", |
Chris Lattner | fe5d402 | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 94 | [(X86callseq_end timm:$amt1, timm:$amt2)]>, |
Dan Gohman | 01c9f77 | 2008-10-01 18:28:06 +0000 | [diff] [blame] | 95 | Requires<[In64BitMode]>; |
| 96 | } |
| 97 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 98 | //===----------------------------------------------------------------------===// |
| 99 | // Call Instructions... |
| 100 | // |
Evan Cheng | 37e7c75 | 2007-07-21 00:34:19 +0000 | [diff] [blame] | 101 | let isCall = 1 in |
Dan Gohman | 01c9f77 | 2008-10-01 18:28:06 +0000 | [diff] [blame] | 102 | // All calls clobber the non-callee saved registers. RSP is marked as |
| 103 | // a use to prevent stack-pointer assignments that appear immediately |
| 104 | // before calls from potentially appearing dead. Uses for argument |
| 105 | // registers are added manually. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 106 | let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, |
Evan Cheng | 931a8f4 | 2008-01-29 19:34:22 +0000 | [diff] [blame] | 107 | FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 108 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
| 109 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, |
Dan Gohman | 9499cfe | 2008-10-01 04:14:30 +0000 | [diff] [blame] | 110 | XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], |
| 111 | Uses = [RSP] in { |
Chris Lattner | 7955239 | 2009-03-18 00:43:52 +0000 | [diff] [blame] | 112 | |
| 113 | // NOTE: this pattern doesn't match "X86call imm", because we do not know |
| 114 | // that the offset between an arbitrary immediate and the call will fit in |
| 115 | // the 32-bit pcrel field that we have. |
Evan Cheng | 0af5a04 | 2009-03-12 18:15:39 +0000 | [diff] [blame] | 116 | def CALL64pcrel32 : I<0xE8, RawFrm, |
| 117 | (outs), (ins i64i32imm:$dst, variable_ops), |
Chris Lattner | 7955239 | 2009-03-18 00:43:52 +0000 | [diff] [blame] | 118 | "call\t${dst:call}", []>, |
Evan Cheng | 0af5a04 | 2009-03-12 18:15:39 +0000 | [diff] [blame] | 119 | Requires<[In64BitMode]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 120 | def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 121 | "call\t{*}$dst", [(X86call GR64:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 122 | def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops), |
Dan Gohman | ea4faba | 2008-05-29 21:50:34 +0000 | [diff] [blame] | 123 | "call\t{*}$dst", [(X86call (loadi64 addr:$dst))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 124 | } |
| 125 | |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 126 | |
| 127 | |
| 128 | let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in |
Evan Cheng | bd780d2 | 2009-02-10 21:39:44 +0000 | [diff] [blame] | 129 | def TCRETURNdi64 : I<0, Pseudo, (outs), (ins i64imm:$dst, i32imm:$offset, |
| 130 | variable_ops), |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 131 | "#TC_RETURN $dst $offset", |
| 132 | []>; |
| 133 | |
| 134 | let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in |
Evan Cheng | bd780d2 | 2009-02-10 21:39:44 +0000 | [diff] [blame] | 135 | def TCRETURNri64 : I<0, Pseudo, (outs), (ins GR64:$dst, i32imm:$offset, |
| 136 | variable_ops), |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 137 | "#TC_RETURN $dst $offset", |
| 138 | []>; |
| 139 | |
| 140 | |
| 141 | let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in |
Evan Cheng | bd780d2 | 2009-02-10 21:39:44 +0000 | [diff] [blame] | 142 | def TAILJMPr64 : I<0xFF, MRM4r, (outs), (ins GR64:$dst), |
| 143 | "jmp{q}\t{*}$dst # TAILCALL", |
| 144 | []>; |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 145 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 146 | // Branches |
Owen Anderson | f805308 | 2007-11-12 07:39:39 +0000 | [diff] [blame] | 147 | let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 148 | 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] | 149 | [(brind GR64:$dst)]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 150 | 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] | 151 | [(brind (loadi64 addr:$dst))]>; |
| 152 | } |
| 153 | |
| 154 | //===----------------------------------------------------------------------===// |
Anton Korobeynikov | 1ec04ee | 2008-09-08 21:12:47 +0000 | [diff] [blame] | 155 | // EH Pseudo Instructions |
| 156 | // |
| 157 | let isTerminator = 1, isReturn = 1, isBarrier = 1, |
| 158 | hasCtrlDep = 1 in { |
| 159 | def EH_RETURN64 : I<0xC3, RawFrm, (outs), (ins GR64:$addr), |
| 160 | "ret\t#eh_return, addr: $addr", |
| 161 | [(X86ehret GR64:$addr)]>; |
| 162 | |
| 163 | } |
| 164 | |
| 165 | //===----------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 166 | // Miscellaneous Instructions... |
| 167 | // |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 168 | let Defs = [RBP,RSP], Uses = [RBP,RSP], mayLoad = 1, neverHasSideEffects = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 169 | def LEAVE64 : I<0xC9, RawFrm, |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 170 | (outs), (ins), "leave", []>; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 171 | let Defs = [RSP], Uses = [RSP], neverHasSideEffects=1 in { |
| 172 | let mayLoad = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 173 | def POP64r : I<0x58, AddRegFrm, |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 174 | (outs GR64:$reg), (ins), "pop{q}\t$reg", []>; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 175 | let mayStore = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 176 | def PUSH64r : I<0x50, AddRegFrm, |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 177 | (outs), (ins GR64:$reg), "push{q}\t$reg", []>; |
| 178 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 179 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 180 | let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1 in |
Evan Cheng | f134131 | 2007-09-26 21:28:00 +0000 | [diff] [blame] | 181 | def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf", []>, REX_W; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 182 | let Defs = [RSP], Uses = [RSP, EFLAGS], mayStore = 1 in |
Evan Cheng | f134131 | 2007-09-26 21:28:00 +0000 | [diff] [blame] | 183 | def PUSHFQ : I<0x9C, RawFrm, (outs), (ins), "pushf", []>; |
Evan Cheng | d843433 | 2007-09-26 01:29:06 +0000 | [diff] [blame] | 184 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 185 | def LEA64_32r : I<0x8D, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 186 | (outs GR32:$dst), (ins lea64_32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 187 | "lea{l}\t{$src|$dst}, {$dst|$src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 188 | [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>; |
| 189 | |
Evan Cheng | 1ea8e6b | 2008-03-27 01:41:09 +0000 | [diff] [blame] | 190 | let isReMaterializable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 191 | def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 192 | "lea{q}\t{$src|$dst}, {$dst|$src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 193 | [(set GR64:$dst, lea64addr:$src)]>; |
| 194 | |
| 195 | let isTwoAddress = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 196 | def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 197 | "bswap{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 198 | [(set GR64:$dst, (bswap GR64:$src))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 199 | |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 200 | // Bit scan instructions. |
| 201 | let Defs = [EFLAGS] in { |
Evan Cheng | 4e33de9 | 2007-12-14 18:49:43 +0000 | [diff] [blame] | 202 | def BSF64rr : RI<0xBC, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | cdb54c6 | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 203 | "bsf{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 9a8ffd5 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 204 | [(set GR64:$dst, (X86bsf GR64:$src)), (implicit EFLAGS)]>, TB; |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 205 | def BSF64rm : RI<0xBC, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | cdb54c6 | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 206 | "bsf{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 9a8ffd5 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 207 | [(set GR64:$dst, (X86bsf (loadi64 addr:$src))), |
| 208 | (implicit EFLAGS)]>, TB; |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 209 | |
Evan Cheng | 4e33de9 | 2007-12-14 18:49:43 +0000 | [diff] [blame] | 210 | def BSR64rr : RI<0xBD, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | cdb54c6 | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 211 | "bsr{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 9a8ffd5 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 212 | [(set GR64:$dst, (X86bsr GR64:$src)), (implicit EFLAGS)]>, TB; |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 213 | def BSR64rm : RI<0xBD, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | cdb54c6 | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 214 | "bsr{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 9a8ffd5 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 215 | [(set GR64:$dst, (X86bsr (loadi64 addr:$src))), |
| 216 | (implicit EFLAGS)]>, TB; |
Evan Cheng | 48679f4 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 217 | } // Defs = [EFLAGS] |
| 218 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 219 | // Repeat string ops |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 220 | let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 221 | def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 222 | [(X86rep_movs i64)]>, REP; |
| 223 | let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 224 | def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 225 | [(X86rep_stos i64)]>, REP; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 226 | |
| 227 | //===----------------------------------------------------------------------===// |
| 228 | // Move Instructions... |
| 229 | // |
| 230 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 231 | let neverHasSideEffects = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 232 | def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 233 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 234 | |
Evan Cheng | d2b9d30 | 2008-06-25 01:16:38 +0000 | [diff] [blame] | 235 | let isReMaterializable = 1, isAsCheapAsAMove = 1 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 236 | def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 237 | "movabs{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 238 | [(set GR64:$dst, imm:$src)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 239 | def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 240 | "mov{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 241 | [(set GR64:$dst, i64immSExt32:$src)]>; |
Dan Gohman | 8aef09b | 2007-09-07 21:32:51 +0000 | [diff] [blame] | 242 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 243 | |
Dan Gohman | 5574cc7 | 2008-12-03 18:15:48 +0000 | [diff] [blame] | 244 | let canFoldAsLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 245 | def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 246 | "mov{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 247 | [(set GR64:$dst, (load addr:$src))]>; |
| 248 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 249 | def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 250 | "mov{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 251 | [(store GR64:$src, addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 252 | def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 253 | "mov{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 254 | [(store i64immSExt32:$src, addr:$dst)]>; |
| 255 | |
| 256 | // Sign/Zero extenders |
| 257 | |
Dan Gohman | edde199 | 2009-04-13 15:13:28 +0000 | [diff] [blame] | 258 | // MOVSX64rr8 always has a REX prefix and it has an 8-bit register |
| 259 | // operand, which makes it a rare instruction with an 8-bit register |
| 260 | // operand that can never access an h register. If support for h registers |
| 261 | // were generalized, this would require a special register class. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 262 | def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 263 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 264 | [(set GR64:$dst, (sext GR8:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 265 | def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 266 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 267 | [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 268 | def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 269 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 270 | [(set GR64:$dst, (sext GR16:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 271 | def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 272 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 273 | [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 274 | def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 275 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 276 | [(set GR64:$dst, (sext GR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 277 | def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 278 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 279 | [(set GR64:$dst, (sextloadi64i32 addr:$src))]>; |
| 280 | |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 281 | // Use movzbl instead of movzbq when the destination is a register; it's |
| 282 | // equivalent due to implicit zero-extending, and it has a smaller encoding. |
| 283 | def MOVZX64rr8 : I<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
| 284 | "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 285 | [(set GR64:$dst, (zext GR8:$src))]>, TB; |
| 286 | def MOVZX64rm8 : I<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
| 287 | "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 288 | [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB; |
| 289 | // Use movzwl instead of movzwq when the destination is a register; it's |
| 290 | // equivalent due to implicit zero-extending, and it has a smaller encoding. |
| 291 | def MOVZX64rr16: I<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
| 292 | "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 293 | [(set GR64:$dst, (zext GR16:$src))]>, TB; |
| 294 | def MOVZX64rm16: I<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
| 295 | "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 296 | [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 297 | |
Dan Gohman | 47a419d | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 298 | // There's no movzlq instruction, but movl can be used for this purpose, using |
Dan Gohman | 4cedb1c | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 299 | // implicit zero-extension. The preferred way to do 32-bit-to-64-bit zero |
| 300 | // extension on x86-64 is to use a SUBREG_TO_REG to utilize implicit |
| 301 | // zero-extension, however this isn't possible when the 32-bit value is |
| 302 | // defined by a truncate or is copied from something where the high bits aren't |
| 303 | // necessarily all zero. In such cases, we fall back to these explicit zext |
| 304 | // instructions. |
Dan Gohman | 47a419d | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 305 | def MOVZX64rr32 : I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src), |
| 306 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 307 | [(set GR64:$dst, (zext GR32:$src))]>; |
| 308 | def MOVZX64rm32 : I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), |
| 309 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 310 | [(set GR64:$dst, (zextloadi64i32 addr:$src))]>; |
| 311 | |
Dan Gohman | 4cedb1c | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 312 | // Any instruction that defines a 32-bit result leaves the high half of the |
| 313 | // register. Truncate can be lowered to EXTRACT_SUBREG, and CopyFromReg may |
| 314 | // be copying from a truncate, but any other 32-bit operation will zero-extend |
| 315 | // up to 64 bits. |
| 316 | def def32 : PatLeaf<(i32 GR32:$src), [{ |
| 317 | return N->getOpcode() != ISD::TRUNCATE && |
| 318 | N->getOpcode() != TargetInstrInfo::EXTRACT_SUBREG && |
| 319 | N->getOpcode() != ISD::CopyFromReg; |
| 320 | }]>; |
| 321 | |
| 322 | // In the case of a 32-bit def that is known to implicitly zero-extend, |
| 323 | // we can use a SUBREG_TO_REG. |
| 324 | def : Pat<(i64 (zext def32:$src)), |
| 325 | (SUBREG_TO_REG (i64 0), GR32:$src, x86_subreg_32bit)>; |
| 326 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 327 | let neverHasSideEffects = 1 in { |
| 328 | let Defs = [RAX], Uses = [EAX] in |
| 329 | def CDQE : RI<0x98, RawFrm, (outs), (ins), |
| 330 | "{cltq|cdqe}", []>; // RAX = signext(EAX) |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 331 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 332 | let Defs = [RAX,RDX], Uses = [RAX] in |
| 333 | def CQO : RI<0x99, RawFrm, (outs), (ins), |
| 334 | "{cqto|cqo}", []>; // RDX:RAX = signext(RAX) |
| 335 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 336 | |
| 337 | //===----------------------------------------------------------------------===// |
| 338 | // Arithmetic Instructions... |
| 339 | // |
| 340 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 341 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 342 | let isTwoAddress = 1 in { |
| 343 | let isConvertibleToThreeAddress = 1 in { |
| 344 | let isCommutable = 1 in |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 345 | // Register-Register Addition |
| 346 | def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
| 347 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 348 | [(set GR64:$dst, (add GR64:$src1, GR64:$src2)), |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 349 | (implicit EFLAGS)]>; |
| 350 | |
| 351 | // Register-Integer Addition |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 352 | def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
| 353 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 354 | [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2)), |
| 355 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 356 | def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 357 | "add{q}\t{$src2, $dst|$dst, $src2}", |
| 358 | [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2)), |
| 359 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 360 | } // isConvertibleToThreeAddress |
| 361 | |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 362 | // Register-Memory Addition |
| 363 | def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 364 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 365 | [(set GR64:$dst, (add GR64:$src1, (load addr:$src2))), |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 366 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 367 | } // isTwoAddress |
| 368 | |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 369 | // Memory-Register Addition |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 370 | def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 371 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 372 | [(store (add (load addr:$dst), GR64:$src2), addr:$dst), |
| 373 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 374 | def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 375 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 376 | [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst), |
| 377 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 378 | def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2), |
| 379 | "add{q}\t{$src2, $dst|$dst, $src2}", |
| 380 | [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst), |
| 381 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 382 | |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 383 | let Uses = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 384 | let isTwoAddress = 1 in { |
| 385 | let isCommutable = 1 in |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 386 | def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), |
| 387 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 388 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 389 | [(set GR64:$dst, |
| 390 | (X86adde_flag GR64:$src1, GR64:$src2, EFLAGS)), |
| 391 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 392 | |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 393 | def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), |
| 394 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 395 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 396 | [(set GR64:$dst, |
| 397 | (X86adde_flag GR64:$src1, (load addr:$src2), EFLAGS)), |
| 398 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 399 | |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 400 | def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), |
| 401 | (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 402 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 403 | [(set GR64:$dst, |
| 404 | (X86adde_flag GR64:$src1, i64immSExt8:$src2, EFLAGS)), |
| 405 | (implicit EFLAGS)]>; |
| 406 | def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), |
| 407 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 408 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 409 | [(set GR64:$dst, |
| 410 | (X86adde_flag GR64:$src1, i64immSExt32:$src2, |
| 411 | EFLAGS)), |
| 412 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 413 | } // isTwoAddress |
| 414 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 415 | def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 416 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 417 | [(store (X86adde_flag (load addr:$dst), GR64:$src2, EFLAGS), |
| 418 | addr:$dst), |
| 419 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 420 | def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 421 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 422 | [(store (X86adde_flag (load addr:$dst), i64immSExt8:$src2, |
| 423 | EFLAGS), |
| 424 | addr:$dst), |
| 425 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 426 | def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
| 427 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 428 | [(store (X86adde_flag (load addr:$dst), i64immSExt8:$src2, |
| 429 | EFLAGS), |
| 430 | addr:$dst), |
| 431 | (implicit EFLAGS)]>; |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 432 | } // Uses = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 433 | |
| 434 | let isTwoAddress = 1 in { |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 435 | // Register-Register Subtraction |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 436 | 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] | 437 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 438 | [(set GR64:$dst, (sub GR64:$src1, GR64:$src2)), |
| 439 | (implicit EFLAGS)]>; |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 440 | |
| 441 | // Register-Memory Subtraction |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 442 | 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] | 443 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 444 | [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2))), |
| 445 | (implicit EFLAGS)]>; |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 446 | |
| 447 | // Register-Integer Subtraction |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 448 | def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), |
| 449 | (ins GR64:$src1, i64i8imm:$src2), |
| 450 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 451 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2)), |
| 452 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 453 | def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), |
| 454 | (ins GR64:$src1, i64i32imm:$src2), |
| 455 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
| 456 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2)), |
| 457 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 458 | } // isTwoAddress |
| 459 | |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 460 | // Memory-Register Subtraction |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 461 | def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 462 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 463 | [(store (sub (load addr:$dst), GR64:$src2), addr:$dst), |
| 464 | (implicit EFLAGS)]>; |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 465 | |
| 466 | // Memory-Integer Subtraction |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 467 | def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 468 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 469 | [(store (sub (load addr:$dst), i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 470 | addr:$dst), |
| 471 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 472 | def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
| 473 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
| 474 | [(store (sub (load addr:$dst), i64immSExt32:$src2), |
| 475 | addr:$dst), |
| 476 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 477 | |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 478 | let Uses = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 479 | let isTwoAddress = 1 in { |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 480 | def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), |
| 481 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 482 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 483 | [(set GR64:$dst, |
| 484 | (X86sube_flag GR64:$src1, GR64:$src2, EFLAGS)), |
| 485 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 486 | |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 487 | def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), |
| 488 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 489 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 490 | [(set GR64:$dst, |
| 491 | (X86sube_flag GR64:$src1, (load addr:$src2), EFLAGS)), |
| 492 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 493 | |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 494 | def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), |
| 495 | (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 496 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 497 | [(set GR64:$dst, |
| 498 | (X86sube_flag GR64:$src1, i64immSExt8:$src2, EFLAGS)), |
| 499 | (implicit EFLAGS)]>; |
| 500 | def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), |
| 501 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 502 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 503 | [(set GR64:$dst, |
| 504 | (X86sube_flag GR64:$src1, i64immSExt32:$src2, |
| 505 | EFLAGS)), |
| 506 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 507 | } // isTwoAddress |
| 508 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 509 | def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 510 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 511 | [(store (X86sube_flag (load addr:$dst), GR64:$src2, EFLAGS), |
| 512 | addr:$dst), |
| 513 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 514 | def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 515 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 516 | [(store (X86sube_flag (load addr:$dst), i64immSExt8:$src2, |
| 517 | EFLAGS), |
| 518 | addr:$dst), |
| 519 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 520 | def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
| 521 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | d6758f9 | 2009-06-01 23:27:20 +0000 | [diff] [blame] | 522 | [(store (X86sube_flag (load addr:$dst), i64immSExt32:$src2, |
| 523 | EFLAGS), |
| 524 | addr:$dst), |
| 525 | (implicit EFLAGS)]>; |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 526 | } // Uses = [EFLAGS] |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 527 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 528 | |
| 529 | // Unsigned multiplication |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 530 | let Defs = [RAX,RDX,EFLAGS], Uses = [RAX], neverHasSideEffects = 1 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 531 | def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 532 | "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64 |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 533 | let mayLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 534 | def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 535 | "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 536 | |
| 537 | // Signed multiplication |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 538 | def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 539 | "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64 |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 540 | let mayLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 541 | def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 542 | "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64] |
| 543 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 544 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 545 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 546 | let isTwoAddress = 1 in { |
| 547 | let isCommutable = 1 in |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 548 | // Register-Register Signed Integer Multiplication |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 549 | def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), |
| 550 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 551 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 552 | [(set GR64:$dst, (mul GR64:$src1, GR64:$src2)), |
| 553 | (implicit EFLAGS)]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 554 | |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 555 | // Register-Memory Signed Integer Multiplication |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 556 | def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), |
| 557 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 558 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 559 | [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2))), |
| 560 | (implicit EFLAGS)]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 561 | } // isTwoAddress |
| 562 | |
| 563 | // Suprisingly enough, these are not two address instructions! |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 564 | |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 565 | // Register-Integer Signed Integer Multiplication |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 566 | def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 567 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 568 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 569 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2)), |
| 570 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 571 | def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32 |
| 572 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 573 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
| 574 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2)), |
| 575 | (implicit EFLAGS)]>; |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 576 | |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 577 | // Memory-Integer Signed Integer Multiplication |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 578 | def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 579 | (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 580 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 581 | [(set GR64:$dst, (mul (load addr:$src1), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 582 | i64immSExt8:$src2)), |
| 583 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 584 | def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32 |
| 585 | (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2), |
| 586 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
| 587 | [(set GR64:$dst, (mul (load addr:$src1), |
| 588 | i64immSExt32:$src2)), |
| 589 | (implicit EFLAGS)]>; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 590 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 591 | |
| 592 | // Unsigned division / remainder |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 593 | let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 594 | 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] | 595 | "div{q}\t$src", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 596 | // Signed division / remainder |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 597 | 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] | 598 | "idiv{q}\t$src", []>; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 599 | let mayLoad = 1 in { |
| 600 | def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX |
| 601 | "div{q}\t$src", []>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 602 | 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] | 603 | "idiv{q}\t$src", []>; |
| 604 | } |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 605 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 606 | |
| 607 | // Unary instructions |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 608 | let Defs = [EFLAGS], CodeSize = 2 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 609 | let isTwoAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 610 | def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 611 | [(set GR64:$dst, (ineg GR64:$src)), |
| 612 | (implicit EFLAGS)]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 613 | def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 614 | [(store (ineg (loadi64 addr:$dst)), addr:$dst), |
| 615 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 616 | |
| 617 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 618 | def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 619 | [(set GR64:$dst, (add GR64:$src, 1)), |
| 620 | (implicit EFLAGS)]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 621 | def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 622 | [(store (add (loadi64 addr:$dst), 1), addr:$dst), |
| 623 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 624 | |
| 625 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 626 | def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 627 | [(set GR64:$dst, (add GR64:$src, -1)), |
| 628 | (implicit EFLAGS)]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 629 | def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 630 | [(store (add (loadi64 addr:$dst), -1), addr:$dst), |
| 631 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 632 | |
| 633 | // In 64-bit mode, single byte INC and DEC cannot be encoded. |
| 634 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in { |
| 635 | // Can transform into LEA. |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 636 | def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 637 | [(set GR16:$dst, (add GR16:$src, 1)), |
| 638 | (implicit EFLAGS)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 639 | OpSize, Requires<[In64BitMode]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 640 | def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 641 | [(set GR32:$dst, (add GR32:$src, 1)), |
| 642 | (implicit EFLAGS)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 643 | Requires<[In64BitMode]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 644 | def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 645 | [(set GR16:$dst, (add GR16:$src, -1)), |
| 646 | (implicit EFLAGS)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 647 | OpSize, Requires<[In64BitMode]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 648 | def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 649 | [(set GR32:$dst, (add GR32:$src, -1)), |
| 650 | (implicit EFLAGS)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 651 | Requires<[In64BitMode]>; |
| 652 | } // isConvertibleToThreeAddress |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 653 | |
| 654 | // These are duplicates of their 32-bit counterparts. Only needed so X86 knows |
| 655 | // how to unfold them. |
| 656 | let isTwoAddress = 0, CodeSize = 2 in { |
| 657 | def INC64_16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 658 | [(store (add (loadi16 addr:$dst), 1), addr:$dst), |
| 659 | (implicit EFLAGS)]>, |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 660 | OpSize, Requires<[In64BitMode]>; |
| 661 | def INC64_32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 662 | [(store (add (loadi32 addr:$dst), 1), addr:$dst), |
| 663 | (implicit EFLAGS)]>, |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 664 | Requires<[In64BitMode]>; |
| 665 | def DEC64_16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 666 | [(store (add (loadi16 addr:$dst), -1), addr:$dst), |
| 667 | (implicit EFLAGS)]>, |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 668 | OpSize, Requires<[In64BitMode]>; |
| 669 | def DEC64_32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 670 | [(store (add (loadi32 addr:$dst), -1), addr:$dst), |
| 671 | (implicit EFLAGS)]>, |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 672 | Requires<[In64BitMode]>; |
| 673 | } |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 674 | } // Defs = [EFLAGS], CodeSize |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 675 | |
| 676 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 677 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 678 | // Shift instructions |
| 679 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 680 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 681 | def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 682 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 683 | [(set GR64:$dst, (shl GR64:$src, CL))]>; |
Evan Cheng | a98f627 | 2007-10-05 18:20:36 +0000 | [diff] [blame] | 684 | let isConvertibleToThreeAddress = 1 in // Can transform into LEA. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 685 | 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] | 686 | "shl{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 687 | [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>; |
Chris Lattner | f4005a8 | 2008-01-11 18:00:50 +0000 | [diff] [blame] | 688 | // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is |
| 689 | // cheaper. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 690 | } // isTwoAddress |
| 691 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 692 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 693 | def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 694 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 695 | [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 696 | def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 697 | "shl{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 698 | [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 699 | def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 700 | "shl{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 701 | [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 702 | |
| 703 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 704 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 705 | def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 706 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 707 | [(set GR64:$dst, (srl GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 708 | 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] | 709 | "shr{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 710 | [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 711 | def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 712 | "shr{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 713 | [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>; |
| 714 | } // isTwoAddress |
| 715 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 716 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 717 | def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 718 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 719 | [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 720 | def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 721 | "shr{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 722 | [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 723 | def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 724 | "shr{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 725 | [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 726 | |
| 727 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 728 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 729 | def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 730 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 731 | [(set GR64:$dst, (sra GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 732 | 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] | 733 | "sar{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 734 | [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 735 | def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 736 | "sar{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 737 | [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>; |
| 738 | } // isTwoAddress |
| 739 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 740 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 741 | def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 742 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 743 | [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 744 | def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 745 | "sar{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 746 | [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 747 | def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 748 | "sar{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 749 | [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 750 | |
| 751 | // Rotate instructions |
| 752 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 753 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 754 | def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 755 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 756 | [(set GR64:$dst, (rotl GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 757 | 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] | 758 | "rol{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 759 | [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 760 | def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 761 | "rol{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 762 | [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>; |
| 763 | } // isTwoAddress |
| 764 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 765 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 766 | def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 767 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 768 | [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 769 | def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 770 | "rol{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 771 | [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 772 | def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 773 | "rol{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 774 | [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 775 | |
| 776 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 777 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 778 | def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 779 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 780 | [(set GR64:$dst, (rotr GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 781 | 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] | 782 | "ror{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 783 | [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 784 | def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 785 | "ror{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 786 | [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>; |
| 787 | } // isTwoAddress |
| 788 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 789 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 790 | def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 791 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 792 | [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 793 | def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 794 | "ror{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 795 | [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 796 | def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 797 | "ror{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 798 | [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 799 | |
| 800 | // Double shift instructions (generalizations of rotate) |
| 801 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 802 | let Uses = [CL] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 803 | 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] | 804 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 805 | [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 806 | 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] | 807 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 808 | [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB; |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 809 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 810 | |
| 811 | let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction |
| 812 | def SHLD64rri8 : RIi8<0xA4, MRMDestReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 813 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 814 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 815 | [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, |
| 816 | (i8 imm:$src3)))]>, |
| 817 | TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 818 | def SHRD64rri8 : RIi8<0xAC, MRMDestReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 819 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 820 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 821 | [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, |
| 822 | (i8 imm:$src3)))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 823 | TB; |
| 824 | } // isCommutable |
| 825 | } // isTwoAddress |
| 826 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 827 | let Uses = [CL] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 828 | def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 829 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 830 | [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL), |
| 831 | addr:$dst)]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 832 | def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 833 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 834 | [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL), |
| 835 | addr:$dst)]>, TB; |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 836 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 837 | def SHLD64mri8 : RIi8<0xA4, MRMDestMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 838 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 839 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 840 | [(store (X86shld (loadi64 addr:$dst), GR64:$src2, |
| 841 | (i8 imm:$src3)), addr:$dst)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 842 | TB; |
| 843 | def SHRD64mri8 : RIi8<0xAC, MRMDestMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 844 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 845 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 846 | [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, |
| 847 | (i8 imm:$src3)), addr:$dst)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 848 | TB; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 849 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 850 | |
| 851 | //===----------------------------------------------------------------------===// |
| 852 | // Logical Instructions... |
| 853 | // |
| 854 | |
Evan Cheng | 5b51c24 | 2009-01-21 19:45:31 +0000 | [diff] [blame] | 855 | let isTwoAddress = 1 , AddedComplexity = 15 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 856 | 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] | 857 | [(set GR64:$dst, (not GR64:$src))]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 858 | 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] | 859 | [(store (not (loadi64 addr:$dst)), addr:$dst)]>; |
| 860 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 861 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 862 | let isTwoAddress = 1 in { |
| 863 | let isCommutable = 1 in |
| 864 | def AND64rr : RI<0x21, MRMDestReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 865 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 866 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 867 | [(set GR64:$dst, (and GR64:$src1, GR64:$src2)), |
| 868 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 869 | def AND64rm : RI<0x23, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 870 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 871 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 872 | [(set GR64:$dst, (and GR64:$src1, (load addr:$src2))), |
| 873 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 874 | def AND64ri8 : RIi8<0x83, MRM4r, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 875 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 876 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 877 | [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2)), |
| 878 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 879 | def AND64ri32 : RIi32<0x81, MRM4r, |
| 880 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 881 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 882 | [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2)), |
| 883 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 884 | } // isTwoAddress |
| 885 | |
| 886 | def AND64mr : RI<0x21, MRMDestMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 887 | (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 888 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 889 | [(store (and (load addr:$dst), GR64:$src), addr:$dst), |
| 890 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 891 | def AND64mi8 : RIi8<0x83, MRM4m, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 892 | (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 893 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 894 | [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst), |
| 895 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 896 | def AND64mi32 : RIi32<0x81, MRM4m, |
| 897 | (outs), (ins i64mem:$dst, i64i32imm:$src), |
| 898 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 899 | [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), |
| 900 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 901 | |
| 902 | let isTwoAddress = 1 in { |
| 903 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 904 | 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] | 905 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 906 | [(set GR64:$dst, (or GR64:$src1, GR64:$src2)), |
| 907 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 908 | 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] | 909 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 910 | [(set GR64:$dst, (or GR64:$src1, (load addr:$src2))), |
| 911 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 912 | 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] | 913 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 914 | [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2)), |
| 915 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 916 | def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 917 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 918 | [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2)), |
| 919 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 920 | } // isTwoAddress |
| 921 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 922 | def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 923 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 924 | [(store (or (load addr:$dst), GR64:$src), addr:$dst), |
| 925 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 926 | def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 927 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 928 | [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst), |
| 929 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 930 | def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
| 931 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 932 | [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), |
| 933 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 934 | |
| 935 | let isTwoAddress = 1 in { |
Evan Cheng | 0685efa | 2008-08-30 08:54:22 +0000 | [diff] [blame] | 936 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 937 | 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] | 938 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 939 | [(set GR64:$dst, (xor GR64:$src1, GR64:$src2)), |
| 940 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 941 | 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] | 942 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 943 | [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2))), |
| 944 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 945 | def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
| 946 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 947 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2)), |
| 948 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 949 | def XOR64ri32 : RIi32<0x81, MRM6r, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 950 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 951 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 952 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2)), |
| 953 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 954 | } // isTwoAddress |
| 955 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 956 | def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 957 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 958 | [(store (xor (load addr:$dst), GR64:$src), addr:$dst), |
| 959 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 960 | def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 961 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 962 | [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst), |
| 963 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 964 | def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
| 965 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 966 | [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), |
| 967 | (implicit EFLAGS)]>; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 968 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 969 | |
| 970 | //===----------------------------------------------------------------------===// |
| 971 | // Comparison Instructions... |
| 972 | // |
| 973 | |
| 974 | // Integer comparison |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 975 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 976 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 977 | def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 978 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 979 | [(X86cmp (and GR64:$src1, GR64:$src2), 0), |
| 980 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 981 | def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 982 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 983 | [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0), |
| 984 | (implicit EFLAGS)]>; |
| 985 | def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), |
| 986 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 987 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 988 | [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0), |
| 989 | (implicit EFLAGS)]>; |
| 990 | def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), |
| 991 | (ins i64mem:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 992 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 993 | [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0), |
| 994 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 995 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 996 | def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 997 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 998 | [(X86cmp GR64:$src1, GR64:$src2), |
| 999 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1000 | def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1001 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1002 | [(X86cmp (loadi64 addr:$src1), GR64:$src2), |
| 1003 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1004 | def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1005 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1006 | [(X86cmp GR64:$src1, (loadi64 addr:$src2)), |
| 1007 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1008 | def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
| 1009 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
| 1010 | [(X86cmp GR64:$src1, i64immSExt8:$src2), |
| 1011 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1012 | def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1013 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1014 | [(X86cmp GR64:$src1, i64immSExt32:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1015 | (implicit EFLAGS)]>; |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1016 | def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1017 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1018 | [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1019 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1020 | def CMP64mi32 : RIi32<0x81, MRM7m, (outs), |
| 1021 | (ins i64mem:$src1, i64i32imm:$src2), |
| 1022 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
| 1023 | [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2), |
| 1024 | (implicit EFLAGS)]>; |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1025 | } // Defs = [EFLAGS] |
| 1026 | |
Dan Gohman | 7fe9b7f | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 1027 | // Bit tests. |
Dan Gohman | 7fe9b7f | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 1028 | // TODO: BTC, BTR, and BTS |
| 1029 | let Defs = [EFLAGS] in { |
Chris Lattner | 5a95cde | 2008-12-25 01:32:49 +0000 | [diff] [blame] | 1030 | def BT64rr : RI<0xA3, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 7fe9b7f | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 1031 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
| 1032 | [(X86bt GR64:$src1, GR64:$src2), |
Chris Lattner | 5a95cde | 2008-12-25 01:32:49 +0000 | [diff] [blame] | 1033 | (implicit EFLAGS)]>, TB; |
Dan Gohman | 85a228c | 2009-01-13 23:23:30 +0000 | [diff] [blame] | 1034 | |
| 1035 | // Unlike with the register+register form, the memory+register form of the |
| 1036 | // bt instruction does not ignore the high bits of the index. From ISel's |
| 1037 | // perspective, this is pretty bizarre. Disable these instructions for now. |
| 1038 | //def BT64mr : RI<0xA3, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
| 1039 | // "bt{q}\t{$src2, $src1|$src1, $src2}", |
| 1040 | // [(X86bt (loadi64 addr:$src1), GR64:$src2), |
| 1041 | // (implicit EFLAGS)]>, TB; |
Dan Gohman | 46fb1cf | 2009-01-13 20:33:23 +0000 | [diff] [blame] | 1042 | |
| 1043 | def BT64ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
| 1044 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
| 1045 | [(X86bt GR64:$src1, i64immSExt8:$src2), |
| 1046 | (implicit EFLAGS)]>, TB; |
| 1047 | // Note that these instructions don't need FastBTMem because that |
| 1048 | // only applies when the other operand is in a register. When it's |
| 1049 | // an immediate, bt is still fast. |
| 1050 | def BT64mi8 : Ii8<0xBA, MRM4m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
| 1051 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
| 1052 | [(X86bt (loadi64 addr:$src1), i64immSExt8:$src2), |
| 1053 | (implicit EFLAGS)]>, TB; |
Dan Gohman | 7fe9b7f | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 1054 | } // Defs = [EFLAGS] |
| 1055 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1056 | // Conditional moves |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1057 | let Uses = [EFLAGS], isTwoAddress = 1 in { |
Evan Cheng | 926658c | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1058 | let isCommutable = 1 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1059 | def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1060 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1061 | "cmovb\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1062 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1063 | X86_COND_B, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1064 | def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1065 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1066 | "cmovae\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1067 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1068 | X86_COND_AE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1069 | def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1070 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1071 | "cmove\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1072 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1073 | X86_COND_E, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1074 | def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1075 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1076 | "cmovne\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1077 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1078 | X86_COND_NE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1079 | def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1080 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1081 | "cmovbe\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1082 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1083 | X86_COND_BE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1084 | def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1085 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1086 | "cmova\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1087 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1088 | X86_COND_A, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1089 | def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1090 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1091 | "cmovl\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1092 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1093 | X86_COND_L, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1094 | def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1095 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1096 | "cmovge\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1097 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1098 | X86_COND_GE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1099 | def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1100 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1101 | "cmovle\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1102 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1103 | X86_COND_LE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1104 | def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1105 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1106 | "cmovg\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1107 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1108 | X86_COND_G, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1109 | def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1110 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1111 | "cmovs\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1112 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1113 | X86_COND_S, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1114 | def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1115 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1116 | "cmovns\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1117 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1118 | X86_COND_NS, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1119 | def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1120 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1121 | "cmovp\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1122 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1123 | X86_COND_P, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1124 | def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1125 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1126 | "cmovnp\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1127 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1128 | X86_COND_NP, EFLAGS))]>, TB; |
Dan Gohman | 12fd4d7 | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1129 | def CMOVO64rr : RI<0x40, MRMSrcReg, // if overflow, GR64 = GR64 |
| 1130 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
| 1131 | "cmovo\t{$src2, $dst|$dst, $src2}", |
| 1132 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 1133 | X86_COND_O, EFLAGS))]>, TB; |
| 1134 | def CMOVNO64rr : RI<0x41, MRMSrcReg, // if !overflow, GR64 = GR64 |
| 1135 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
| 1136 | "cmovno\t{$src2, $dst|$dst, $src2}", |
| 1137 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 1138 | X86_COND_NO, EFLAGS))]>, TB; |
Evan Cheng | 926658c | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1139 | } // isCommutable = 1 |
| 1140 | |
| 1141 | def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64] |
| 1142 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1143 | "cmovb\t{$src2, $dst|$dst, $src2}", |
| 1144 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1145 | X86_COND_B, EFLAGS))]>, TB; |
| 1146 | def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64] |
| 1147 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1148 | "cmovae\t{$src2, $dst|$dst, $src2}", |
| 1149 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1150 | X86_COND_AE, EFLAGS))]>, TB; |
| 1151 | def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64] |
| 1152 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1153 | "cmove\t{$src2, $dst|$dst, $src2}", |
| 1154 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1155 | X86_COND_E, EFLAGS))]>, TB; |
| 1156 | def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64] |
| 1157 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1158 | "cmovne\t{$src2, $dst|$dst, $src2}", |
| 1159 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1160 | X86_COND_NE, EFLAGS))]>, TB; |
| 1161 | def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64] |
| 1162 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1163 | "cmovbe\t{$src2, $dst|$dst, $src2}", |
| 1164 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1165 | X86_COND_BE, EFLAGS))]>, TB; |
| 1166 | def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64] |
| 1167 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1168 | "cmova\t{$src2, $dst|$dst, $src2}", |
| 1169 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1170 | X86_COND_A, EFLAGS))]>, TB; |
| 1171 | def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64] |
| 1172 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1173 | "cmovl\t{$src2, $dst|$dst, $src2}", |
| 1174 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1175 | X86_COND_L, EFLAGS))]>, TB; |
| 1176 | def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64] |
| 1177 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1178 | "cmovge\t{$src2, $dst|$dst, $src2}", |
| 1179 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1180 | X86_COND_GE, EFLAGS))]>, TB; |
| 1181 | def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64] |
| 1182 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1183 | "cmovle\t{$src2, $dst|$dst, $src2}", |
| 1184 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1185 | X86_COND_LE, EFLAGS))]>, TB; |
| 1186 | def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64] |
| 1187 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1188 | "cmovg\t{$src2, $dst|$dst, $src2}", |
| 1189 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1190 | X86_COND_G, EFLAGS))]>, TB; |
| 1191 | def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64] |
| 1192 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1193 | "cmovs\t{$src2, $dst|$dst, $src2}", |
| 1194 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1195 | X86_COND_S, EFLAGS))]>, TB; |
| 1196 | def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64] |
| 1197 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1198 | "cmovns\t{$src2, $dst|$dst, $src2}", |
| 1199 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1200 | X86_COND_NS, EFLAGS))]>, TB; |
| 1201 | def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64] |
| 1202 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1203 | "cmovp\t{$src2, $dst|$dst, $src2}", |
| 1204 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1205 | X86_COND_P, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1206 | def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64] |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1207 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1208 | "cmovnp\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1209 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1210 | X86_COND_NP, EFLAGS))]>, TB; |
Dan Gohman | 12fd4d7 | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1211 | def CMOVO64rm : RI<0x40, MRMSrcMem, // if overflow, GR64 = [mem64] |
| 1212 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1213 | "cmovo\t{$src2, $dst|$dst, $src2}", |
| 1214 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1215 | X86_COND_O, EFLAGS))]>, TB; |
| 1216 | def CMOVNO64rm : RI<0x41, MRMSrcMem, // if !overflow, GR64 = [mem64] |
| 1217 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1218 | "cmovno\t{$src2, $dst|$dst, $src2}", |
| 1219 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1220 | X86_COND_NO, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1221 | } // isTwoAddress |
| 1222 | |
| 1223 | //===----------------------------------------------------------------------===// |
| 1224 | // Conversion Instructions... |
| 1225 | // |
| 1226 | |
| 1227 | // f64 -> signed i64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1228 | def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1229 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1230 | [(set GR64:$dst, |
| 1231 | (int_x86_sse2_cvtsd2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1232 | def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1233 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1234 | [(set GR64:$dst, (int_x86_sse2_cvtsd2si64 |
| 1235 | (load addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1236 | def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1237 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1238 | [(set GR64:$dst, (fp_to_sint FR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1239 | def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1240 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1241 | [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1242 | def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1243 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1244 | [(set GR64:$dst, |
| 1245 | (int_x86_sse2_cvttsd2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1246 | def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1247 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1248 | [(set GR64:$dst, |
| 1249 | (int_x86_sse2_cvttsd2si64 |
| 1250 | (load addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1251 | |
| 1252 | // Signed i64 -> f64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1253 | def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1254 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1255 | [(set FR64:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1256 | def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1257 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1258 | [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
Evan Cheng | 1d5832e | 2008-01-11 07:37:44 +0000 | [diff] [blame] | 1259 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1260 | let isTwoAddress = 1 in { |
| 1261 | def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1262 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1263 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1264 | [(set VR128:$dst, |
| 1265 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 1266 | GR64:$src2))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1267 | def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1268 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1269 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1270 | [(set VR128:$dst, |
| 1271 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 1272 | (loadi64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1273 | } // isTwoAddress |
| 1274 | |
| 1275 | // Signed i64 -> f32 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1276 | def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1277 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1278 | [(set FR32:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1279 | def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1280 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1281 | [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
Evan Cheng | 1d5832e | 2008-01-11 07:37:44 +0000 | [diff] [blame] | 1282 | |
| 1283 | let isTwoAddress = 1 in { |
| 1284 | def Int_CVTSI2SS64rr : RSSI<0x2A, MRMSrcReg, |
| 1285 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
| 1286 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
| 1287 | [(set VR128:$dst, |
| 1288 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 1289 | GR64:$src2))]>; |
| 1290 | def Int_CVTSI2SS64rm : RSSI<0x2A, MRMSrcMem, |
| 1291 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
| 1292 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
| 1293 | [(set VR128:$dst, |
| 1294 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 1295 | (loadi64 addr:$src2)))]>; |
| 1296 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1297 | |
| 1298 | // f32 -> signed i64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1299 | def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1300 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1301 | [(set GR64:$dst, |
| 1302 | (int_x86_sse_cvtss2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1303 | def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1304 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1305 | [(set GR64:$dst, (int_x86_sse_cvtss2si64 |
| 1306 | (load addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1307 | def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1308 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1309 | [(set GR64:$dst, (fp_to_sint FR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1310 | def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1311 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1312 | [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1313 | def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1314 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1315 | [(set GR64:$dst, |
| 1316 | (int_x86_sse_cvttss2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1317 | def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1318 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1319 | [(set GR64:$dst, |
| 1320 | (int_x86_sse_cvttss2si64 (load addr:$src)))]>; |
| 1321 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1322 | //===----------------------------------------------------------------------===// |
| 1323 | // Alias Instructions |
| 1324 | //===----------------------------------------------------------------------===// |
| 1325 | |
Dan Gohman | 027cd11 | 2007-09-17 14:55:08 +0000 | [diff] [blame] | 1326 | // Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's |
| 1327 | // equivalent due to implicit zero-extending, and it sometimes has a smaller |
| 1328 | // encoding. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1329 | // FIXME: remove when we can teach regalloc that xor reg, reg is ok. |
| 1330 | // FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove |
| 1331 | // when we have a better way to specify isel priority. |
Bill Wendling | 12e9721 | 2008-05-30 06:47:04 +0000 | [diff] [blame] | 1332 | let Defs = [EFLAGS], AddedComplexity = 1, |
| 1333 | isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1334 | def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins), |
| 1335 | "xor{l}\t${dst:subreg32}, ${dst:subreg32}", |
| 1336 | [(set GR64:$dst, 0)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1337 | |
| 1338 | // Materialize i64 constant where top 32-bits are zero. |
Evan Cheng | bd0ca9c | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 1339 | let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1340 | def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1341 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1342 | [(set GR64:$dst, i64immZExt32:$src)]>; |
| 1343 | |
Anton Korobeynikov | 4fbf00b | 2008-05-04 21:36:32 +0000 | [diff] [blame] | 1344 | //===----------------------------------------------------------------------===// |
| 1345 | // Thread Local Storage Instructions |
| 1346 | //===----------------------------------------------------------------------===// |
| 1347 | |
Rafael Espindola | 7fc4b8d | 2009-04-24 12:59:40 +0000 | [diff] [blame] | 1348 | // All calls clobber the non-callee saved registers. RSP is marked as |
| 1349 | // a use to prevent stack-pointer assignments that appear immediately |
| 1350 | // before calls from potentially appearing dead. |
| 1351 | let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, |
| 1352 | FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1, |
| 1353 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
| 1354 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, |
| 1355 | XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], |
| 1356 | Uses = [RSP] in |
Rafael Espindola | af759ab | 2009-04-17 14:35:58 +0000 | [diff] [blame] | 1357 | def TLS_addr64 : I<0, Pseudo, (outs), (ins i64imm:$sym), |
Dan Gohman | 70a8a11 | 2009-04-27 15:13:28 +0000 | [diff] [blame] | 1358 | ".byte\t0x66; " |
| 1359 | "leaq\t${sym:mem}(%rip), %rdi; " |
| 1360 | ".word\t0x6666; " |
| 1361 | "rex64; " |
| 1362 | "call\t__tls_get_addr@PLT", |
Rafael Espindola | af759ab | 2009-04-17 14:35:58 +0000 | [diff] [blame] | 1363 | [(X86tlsaddr tglobaltlsaddr:$sym)]>, |
| 1364 | Requires<[In64BitMode]>; |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1365 | |
sampo | 9cc09a3 | 2009-01-26 01:24:32 +0000 | [diff] [blame] | 1366 | let AddedComplexity = 5 in |
| 1367 | def MOV64GSrm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
| 1368 | "movq\t%gs:$src, $dst", |
| 1369 | [(set GR64:$dst, (gsload addr:$src))]>, SegGS; |
| 1370 | |
Chris Lattner | a7c2d8a | 2009-05-05 18:52:19 +0000 | [diff] [blame] | 1371 | let AddedComplexity = 5 in |
| 1372 | def MOV64FSrm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
| 1373 | "movq\t%fs:$src, $dst", |
| 1374 | [(set GR64:$dst, (fsload addr:$src))]>, SegFS; |
| 1375 | |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1376 | //===----------------------------------------------------------------------===// |
| 1377 | // Atomic Instructions |
| 1378 | //===----------------------------------------------------------------------===// |
| 1379 | |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1380 | let Defs = [RAX, EFLAGS], Uses = [RAX] in { |
Evan Cheng | d49dbb8 | 2008-04-18 20:55:36 +0000 | [diff] [blame] | 1381 | def LCMPXCHG64 : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$ptr, GR64:$swap), |
Dan Gohman | 70a8a11 | 2009-04-27 15:13:28 +0000 | [diff] [blame] | 1382 | "lock\n\t" |
| 1383 | "cmpxchgq\t$swap,$ptr", |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1384 | [(X86cas addr:$ptr, GR64:$swap, 8)]>, TB, LOCK; |
| 1385 | } |
| 1386 | |
Dan Gohman | a41a1c09 | 2008-08-06 15:52:50 +0000 | [diff] [blame] | 1387 | let Constraints = "$val = $dst" in { |
| 1388 | let Defs = [EFLAGS] in |
Evan Cheng | d49dbb8 | 2008-04-18 20:55:36 +0000 | [diff] [blame] | 1389 | def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val), |
Dan Gohman | 70a8a11 | 2009-04-27 15:13:28 +0000 | [diff] [blame] | 1390 | "lock\n\t" |
| 1391 | "xadd\t$val, $ptr", |
Mon P Wang | 6bde9ec | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 1392 | [(set GR64:$dst, (atomic_load_add_64 addr:$ptr, GR64:$val))]>, |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1393 | TB, LOCK; |
Evan Cheng | a1e8060 | 2008-04-19 02:05:42 +0000 | [diff] [blame] | 1394 | def XCHG64rm : RI<0x87, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val), |
Bill Wendling | 6f189e2 | 2008-08-19 23:09:18 +0000 | [diff] [blame] | 1395 | "xchg\t$val, $ptr", |
Evan Cheng | a1e8060 | 2008-04-19 02:05:42 +0000 | [diff] [blame] | 1396 | [(set GR64:$dst, (atomic_swap_64 addr:$ptr, GR64:$val))]>; |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1397 | } |
| 1398 | |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1399 | // Atomic exchange, and, or, xor |
| 1400 | let Constraints = "$val = $dst", Defs = [EFLAGS], |
| 1401 | usesCustomDAGSchedInserter = 1 in { |
| 1402 | def ATOMAND64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | bfb9fd2 | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1403 | "#ATOMAND64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1404 | [(set GR64:$dst, (atomic_load_and_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1405 | def ATOMOR64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | bfb9fd2 | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1406 | "#ATOMOR64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1407 | [(set GR64:$dst, (atomic_load_or_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1408 | def ATOMXOR64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | bfb9fd2 | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1409 | "#ATOMXOR64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1410 | [(set GR64:$dst, (atomic_load_xor_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1411 | def ATOMNAND64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | bfb9fd2 | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1412 | "#ATOMNAND64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1413 | [(set GR64:$dst, (atomic_load_nand_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1414 | def ATOMMIN64: I<0, Pseudo, (outs GR64:$dst), (ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | bfb9fd2 | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1415 | "#ATOMMIN64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1416 | [(set GR64:$dst, (atomic_load_min_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1417 | def ATOMMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | bfb9fd2 | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1418 | "#ATOMMAX64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1419 | [(set GR64:$dst, (atomic_load_max_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1420 | def ATOMUMIN64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | bfb9fd2 | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1421 | "#ATOMUMIN64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1422 | [(set GR64:$dst, (atomic_load_umin_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1423 | def ATOMUMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | bfb9fd2 | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1424 | "#ATOMUMAX64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1425 | [(set GR64:$dst, (atomic_load_umax_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1426 | } |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1427 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1428 | //===----------------------------------------------------------------------===// |
| 1429 | // Non-Instruction Patterns |
| 1430 | //===----------------------------------------------------------------------===// |
| 1431 | |
Bill Wendling | fef0605 | 2008-09-16 21:48:12 +0000 | [diff] [blame] | 1432 | // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1433 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
| 1434 | (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>; |
| 1435 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
| 1436 | (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>; |
| 1437 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
| 1438 | (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>; |
| 1439 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
| 1440 | (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>; |
| 1441 | |
| 1442 | def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst), |
| 1443 | (MOV64mi32 addr:$dst, tconstpool:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1444 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1445 | def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst), |
| 1446 | (MOV64mi32 addr:$dst, tjumptable:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1447 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1448 | def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst), |
| 1449 | (MOV64mi32 addr:$dst, tglobaladdr:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1450 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1451 | def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst), |
| 1452 | (MOV64mi32 addr:$dst, texternalsym:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1453 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1454 | |
| 1455 | // Calls |
| 1456 | // Direct PC relative function call for small code model. 32-bit displacement |
| 1457 | // sign extended to 64-bit. |
| 1458 | def : Pat<(X86call (i64 tglobaladdr:$dst)), |
| 1459 | (CALL64pcrel32 tglobaladdr:$dst)>; |
| 1460 | def : Pat<(X86call (i64 texternalsym:$dst)), |
| 1461 | (CALL64pcrel32 texternalsym:$dst)>; |
| 1462 | |
| 1463 | def : Pat<(X86tailcall (i64 tglobaladdr:$dst)), |
| 1464 | (CALL64pcrel32 tglobaladdr:$dst)>; |
| 1465 | def : Pat<(X86tailcall (i64 texternalsym:$dst)), |
| 1466 | (CALL64pcrel32 texternalsym:$dst)>; |
| 1467 | |
| 1468 | def : Pat<(X86tailcall GR64:$dst), |
| 1469 | (CALL64r GR64:$dst)>; |
| 1470 | |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 1471 | |
| 1472 | // tailcall stuff |
| 1473 | def : Pat<(X86tailcall GR32:$dst), |
| 1474 | (TAILCALL)>; |
| 1475 | def : Pat<(X86tailcall (i64 tglobaladdr:$dst)), |
| 1476 | (TAILCALL)>; |
| 1477 | def : Pat<(X86tailcall (i64 texternalsym:$dst)), |
| 1478 | (TAILCALL)>; |
| 1479 | |
| 1480 | def : Pat<(X86tcret GR64:$dst, imm:$off), |
| 1481 | (TCRETURNri64 GR64:$dst, imm:$off)>; |
| 1482 | |
| 1483 | def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off), |
| 1484 | (TCRETURNdi64 texternalsym:$dst, imm:$off)>; |
| 1485 | |
| 1486 | def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off), |
| 1487 | (TCRETURNdi64 texternalsym:$dst, imm:$off)>; |
| 1488 | |
Dan Gohman | ec59604 | 2007-09-17 14:35:24 +0000 | [diff] [blame] | 1489 | // Comparisons. |
| 1490 | |
| 1491 | // TEST R,R is smaller than CMP R,0 |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1492 | def : Pat<(parallel (X86cmp GR64:$src1, 0), (implicit EFLAGS)), |
Dan Gohman | ec59604 | 2007-09-17 14:35:24 +0000 | [diff] [blame] | 1493 | (TEST64rr GR64:$src1, GR64:$src1)>; |
| 1494 | |
Dan Gohman | 0a3c522 | 2009-01-07 01:00:24 +0000 | [diff] [blame] | 1495 | // Conditional moves with folded loads with operands swapped and conditions |
| 1496 | // inverted. |
| 1497 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_B, EFLAGS), |
| 1498 | (CMOVAE64rm GR64:$src2, addr:$src1)>; |
| 1499 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_AE, EFLAGS), |
| 1500 | (CMOVB64rm GR64:$src2, addr:$src1)>; |
| 1501 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_E, EFLAGS), |
| 1502 | (CMOVNE64rm GR64:$src2, addr:$src1)>; |
| 1503 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NE, EFLAGS), |
| 1504 | (CMOVE64rm GR64:$src2, addr:$src1)>; |
| 1505 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_BE, EFLAGS), |
| 1506 | (CMOVA64rm GR64:$src2, addr:$src1)>; |
| 1507 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_A, EFLAGS), |
| 1508 | (CMOVBE64rm GR64:$src2, addr:$src1)>; |
| 1509 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_L, EFLAGS), |
| 1510 | (CMOVGE64rm GR64:$src2, addr:$src1)>; |
| 1511 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_GE, EFLAGS), |
| 1512 | (CMOVL64rm GR64:$src2, addr:$src1)>; |
| 1513 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_LE, EFLAGS), |
| 1514 | (CMOVG64rm GR64:$src2, addr:$src1)>; |
| 1515 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_G, EFLAGS), |
| 1516 | (CMOVLE64rm GR64:$src2, addr:$src1)>; |
| 1517 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_P, EFLAGS), |
| 1518 | (CMOVNP64rm GR64:$src2, addr:$src1)>; |
| 1519 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NP, EFLAGS), |
| 1520 | (CMOVP64rm GR64:$src2, addr:$src1)>; |
| 1521 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_S, EFLAGS), |
| 1522 | (CMOVNS64rm GR64:$src2, addr:$src1)>; |
| 1523 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NS, EFLAGS), |
| 1524 | (CMOVS64rm GR64:$src2, addr:$src1)>; |
| 1525 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_O, EFLAGS), |
| 1526 | (CMOVNO64rm GR64:$src2, addr:$src1)>; |
| 1527 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NO, EFLAGS), |
| 1528 | (CMOVO64rm GR64:$src2, addr:$src1)>; |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1529 | |
Duncan Sands | 082524c | 2008-01-23 20:39:46 +0000 | [diff] [blame] | 1530 | // zextload bool -> zextload byte |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1531 | def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1532 | |
| 1533 | // extload |
Dan Gohman | ab460da | 2008-08-27 17:33:15 +0000 | [diff] [blame] | 1534 | // When extloading from 16-bit and smaller memory locations into 64-bit registers, |
| 1535 | // use zero-extending loads so that the entire 64-bit register is defined, avoiding |
| 1536 | // partial-register updates. |
| 1537 | def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1538 | def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1539 | def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>; |
| 1540 | // For other extloads, use subregs, since the high contents of the register are |
| 1541 | // defined after an extload. |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1542 | def : Pat<(extloadi64i32 addr:$src), |
| 1543 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV32rm addr:$src), |
| 1544 | x86_subreg_32bit)>; |
| 1545 | def : Pat<(extloadi16i1 addr:$src), |
| 1546 | (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src), |
| 1547 | x86_subreg_8bit)>, |
| 1548 | Requires<[In64BitMode]>; |
| 1549 | def : Pat<(extloadi16i8 addr:$src), |
| 1550 | (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src), |
| 1551 | x86_subreg_8bit)>, |
| 1552 | Requires<[In64BitMode]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1553 | |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1554 | // anyext |
| 1555 | def : Pat<(i64 (anyext GR8:$src)), |
| 1556 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>; |
| 1557 | def : Pat<(i64 (anyext GR16:$src)), |
| 1558 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>; |
Christopher Lamb | 76d72da | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 1559 | def : Pat<(i64 (anyext GR32:$src)), |
| 1560 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$src, x86_subreg_32bit)>; |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1561 | def : Pat<(i16 (anyext GR8:$src)), |
| 1562 | (INSERT_SUBREG (i16 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>, |
| 1563 | Requires<[In64BitMode]>; |
| 1564 | def : Pat<(i32 (anyext GR8:$src)), |
| 1565 | (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>, |
| 1566 | Requires<[In64BitMode]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1567 | |
| 1568 | //===----------------------------------------------------------------------===// |
| 1569 | // Some peepholes |
| 1570 | //===----------------------------------------------------------------------===// |
| 1571 | |
Dan Gohman | 5a5e6e9 | 2008-10-17 01:33:43 +0000 | [diff] [blame] | 1572 | // Odd encoding trick: -128 fits into an 8-bit immediate field while |
| 1573 | // +128 doesn't, so in this special case use a sub instead of an add. |
| 1574 | def : Pat<(add GR64:$src1, 128), |
| 1575 | (SUB64ri8 GR64:$src1, -128)>; |
| 1576 | def : Pat<(store (add (loadi64 addr:$dst), 128), addr:$dst), |
| 1577 | (SUB64mi8 addr:$dst, -128)>; |
| 1578 | |
| 1579 | // The same trick applies for 32-bit immediate fields in 64-bit |
| 1580 | // instructions. |
| 1581 | def : Pat<(add GR64:$src1, 0x0000000080000000), |
| 1582 | (SUB64ri32 GR64:$src1, 0xffffffff80000000)>; |
| 1583 | def : Pat<(store (add (loadi64 addr:$dst), 0x00000000800000000), addr:$dst), |
| 1584 | (SUB64mi32 addr:$dst, 0xffffffff80000000)>; |
| 1585 | |
Dan Gohman | 47a419d | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 1586 | // r & (2^32-1) ==> movz |
Dan Gohman | 5a5e6e9 | 2008-10-17 01:33:43 +0000 | [diff] [blame] | 1587 | def : Pat<(and GR64:$src, 0x00000000FFFFFFFF), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1588 | (MOVZX64rr32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>; |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1589 | // r & (2^16-1) ==> movz |
| 1590 | def : Pat<(and GR64:$src, 0xffff), |
| 1591 | (MOVZX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>; |
| 1592 | // r & (2^8-1) ==> movz |
| 1593 | def : Pat<(and GR64:$src, 0xff), |
| 1594 | (MOVZX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>; |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1595 | // r & (2^8-1) ==> movz |
| 1596 | def : Pat<(and GR32:$src1, 0xff), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1597 | (MOVZX32rr8 (EXTRACT_SUBREG GR32:$src1, x86_subreg_8bit))>, |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1598 | Requires<[In64BitMode]>; |
| 1599 | // r & (2^8-1) ==> movz |
| 1600 | def : Pat<(and GR16:$src1, 0xff), |
| 1601 | (MOVZX16rr8 (i8 (EXTRACT_SUBREG GR16:$src1, x86_subreg_8bit)))>, |
| 1602 | Requires<[In64BitMode]>; |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1603 | |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1604 | // sext_inreg patterns |
| 1605 | def : Pat<(sext_inreg GR64:$src, i32), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1606 | (MOVSX64rr32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>; |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1607 | def : Pat<(sext_inreg GR64:$src, i16), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1608 | (MOVSX64rr16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit))>; |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1609 | def : Pat<(sext_inreg GR64:$src, i8), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1610 | (MOVSX64rr8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit))>; |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1611 | def : Pat<(sext_inreg GR32:$src, i8), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1612 | (MOVSX32rr8 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit))>, |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1613 | Requires<[In64BitMode]>; |
| 1614 | def : Pat<(sext_inreg GR16:$src, i8), |
| 1615 | (MOVSX16rr8 (i8 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit)))>, |
| 1616 | Requires<[In64BitMode]>; |
| 1617 | |
| 1618 | // trunc patterns |
| 1619 | def : Pat<(i32 (trunc GR64:$src)), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1620 | (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)>; |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1621 | def : Pat<(i16 (trunc GR64:$src)), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1622 | (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)>; |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1623 | def : Pat<(i8 (trunc GR64:$src)), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1624 | (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)>; |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1625 | def : Pat<(i8 (trunc GR32:$src)), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1626 | (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit)>, |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1627 | Requires<[In64BitMode]>; |
| 1628 | def : Pat<(i8 (trunc GR16:$src)), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1629 | (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit)>, |
| 1630 | Requires<[In64BitMode]>; |
| 1631 | |
| 1632 | // h-register tricks. |
Dan Gohman | 3aa0b18 | 2009-05-31 17:52:18 +0000 | [diff] [blame] | 1633 | // For now, be conservative on x86-64 and use an h-register extract only if the |
| 1634 | // value is immediately zero-extended or stored, which are somewhat common |
| 1635 | // cases. This uses a bunch of code to prevent a register requiring a REX prefix |
| 1636 | // from being allocated in the same instruction as the h register, as there's |
| 1637 | // currently no way to describe this requirement to the register allocator. |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1638 | |
| 1639 | // h-register extract and zero-extend. |
| 1640 | def : Pat<(and (srl_su GR64:$src, (i8 8)), (i64 255)), |
| 1641 | (SUBREG_TO_REG |
| 1642 | (i64 0), |
| 1643 | (MOVZX32_NOREXrr8 |
Dan Gohman | 6e43870 | 2009-04-27 16:33:14 +0000 | [diff] [blame] | 1644 | (EXTRACT_SUBREG (COPY_TO_REGCLASS GR64:$src, GR64_ABCD), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1645 | x86_subreg_8bit_hi)), |
| 1646 | x86_subreg_32bit)>; |
| 1647 | def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)), |
| 1648 | (MOVZX32_NOREXrr8 |
Dan Gohman | 6e43870 | 2009-04-27 16:33:14 +0000 | [diff] [blame] | 1649 | (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1650 | x86_subreg_8bit_hi))>, |
| 1651 | Requires<[In64BitMode]>; |
| 1652 | def : Pat<(srl_su GR16:$src, (i8 8)), |
| 1653 | (EXTRACT_SUBREG |
| 1654 | (MOVZX32_NOREXrr8 |
Dan Gohman | 6e43870 | 2009-04-27 16:33:14 +0000 | [diff] [blame] | 1655 | (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1656 | x86_subreg_8bit_hi)), |
| 1657 | x86_subreg_16bit)>, |
| 1658 | Requires<[In64BitMode]>; |
Evan Cheng | 957ca28 | 2009-05-29 01:44:43 +0000 | [diff] [blame] | 1659 | def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))), |
| 1660 | (MOVZX32_NOREXrr8 |
| 1661 | (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD), |
| 1662 | x86_subreg_8bit_hi))>, |
| 1663 | Requires<[In64BitMode]>; |
| 1664 | def : Pat<(i64 (zext (srl_su GR16:$src, (i8 8)))), |
| 1665 | (SUBREG_TO_REG |
| 1666 | (i64 0), |
| 1667 | (MOVZX32_NOREXrr8 |
| 1668 | (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD), |
| 1669 | x86_subreg_8bit_hi)), |
| 1670 | x86_subreg_32bit)>; |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1671 | |
| 1672 | // h-register extract and store. |
| 1673 | def : Pat<(store (i8 (trunc_su (srl_su GR64:$src, (i8 8)))), addr:$dst), |
| 1674 | (MOV8mr_NOREX |
| 1675 | addr:$dst, |
Dan Gohman | 6e43870 | 2009-04-27 16:33:14 +0000 | [diff] [blame] | 1676 | (EXTRACT_SUBREG (COPY_TO_REGCLASS GR64:$src, GR64_ABCD), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1677 | x86_subreg_8bit_hi))>; |
| 1678 | def : Pat<(store (i8 (trunc_su (srl_su GR32:$src, (i8 8)))), addr:$dst), |
| 1679 | (MOV8mr_NOREX |
| 1680 | addr:$dst, |
Dan Gohman | 6e43870 | 2009-04-27 16:33:14 +0000 | [diff] [blame] | 1681 | (EXTRACT_SUBREG (COPY_TO_REGCLASS GR32:$src, GR32_ABCD), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1682 | x86_subreg_8bit_hi))>, |
| 1683 | Requires<[In64BitMode]>; |
| 1684 | def : Pat<(store (i8 (trunc_su (srl_su GR16:$src, (i8 8)))), addr:$dst), |
| 1685 | (MOV8mr_NOREX |
| 1686 | addr:$dst, |
Dan Gohman | 6e43870 | 2009-04-27 16:33:14 +0000 | [diff] [blame] | 1687 | (EXTRACT_SUBREG (COPY_TO_REGCLASS GR16:$src, GR16_ABCD), |
Dan Gohman | 744d462 | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 1688 | x86_subreg_8bit_hi))>, |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1689 | Requires<[In64BitMode]>; |
| 1690 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1691 | // (shl x, 1) ==> (add x, x) |
| 1692 | def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>; |
| 1693 | |
Evan Cheng | 76a64c7 | 2008-08-30 02:03:58 +0000 | [diff] [blame] | 1694 | // (shl x (and y, 63)) ==> (shl x, y) |
| 1695 | def : Pat<(shl GR64:$src1, (and CL:$amt, 63)), |
| 1696 | (SHL64rCL GR64:$src1)>; |
| 1697 | def : Pat<(store (shl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst), |
| 1698 | (SHL64mCL addr:$dst)>; |
| 1699 | |
| 1700 | def : Pat<(srl GR64:$src1, (and CL:$amt, 63)), |
| 1701 | (SHR64rCL GR64:$src1)>; |
| 1702 | def : Pat<(store (srl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst), |
| 1703 | (SHR64mCL addr:$dst)>; |
| 1704 | |
| 1705 | def : Pat<(sra GR64:$src1, (and CL:$amt, 63)), |
| 1706 | (SAR64rCL GR64:$src1)>; |
| 1707 | def : Pat<(store (sra (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst), |
| 1708 | (SAR64mCL addr:$dst)>; |
| 1709 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1710 | // (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c) |
| 1711 | def : Pat<(or (srl GR64:$src1, CL:$amt), |
| 1712 | (shl GR64:$src2, (sub 64, CL:$amt))), |
| 1713 | (SHRD64rrCL GR64:$src1, GR64:$src2)>; |
| 1714 | |
| 1715 | def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt), |
| 1716 | (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst), |
| 1717 | (SHRD64mrCL addr:$dst, GR64:$src2)>; |
| 1718 | |
Dan Gohman | 921581d | 2008-10-17 01:23:35 +0000 | [diff] [blame] | 1719 | def : Pat<(or (srl GR64:$src1, (i8 (trunc RCX:$amt))), |
| 1720 | (shl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))), |
| 1721 | (SHRD64rrCL GR64:$src1, GR64:$src2)>; |
| 1722 | |
| 1723 | def : Pat<(store (or (srl (loadi64 addr:$dst), (i8 (trunc RCX:$amt))), |
| 1724 | (shl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))), |
| 1725 | addr:$dst), |
| 1726 | (SHRD64mrCL addr:$dst, GR64:$src2)>; |
| 1727 | |
| 1728 | def : Pat<(shrd GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm:$amt2)), |
| 1729 | (SHRD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>; |
| 1730 | |
| 1731 | def : Pat<(store (shrd (loadi64 addr:$dst), (i8 imm:$amt1), |
| 1732 | GR64:$src2, (i8 imm:$amt2)), addr:$dst), |
| 1733 | (SHRD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>; |
| 1734 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1735 | // (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c) |
| 1736 | def : Pat<(or (shl GR64:$src1, CL:$amt), |
| 1737 | (srl GR64:$src2, (sub 64, CL:$amt))), |
| 1738 | (SHLD64rrCL GR64:$src1, GR64:$src2)>; |
| 1739 | |
| 1740 | def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt), |
| 1741 | (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst), |
| 1742 | (SHLD64mrCL addr:$dst, GR64:$src2)>; |
| 1743 | |
Dan Gohman | 921581d | 2008-10-17 01:23:35 +0000 | [diff] [blame] | 1744 | def : Pat<(or (shl GR64:$src1, (i8 (trunc RCX:$amt))), |
| 1745 | (srl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))), |
| 1746 | (SHLD64rrCL GR64:$src1, GR64:$src2)>; |
| 1747 | |
| 1748 | def : Pat<(store (or (shl (loadi64 addr:$dst), (i8 (trunc RCX:$amt))), |
| 1749 | (srl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))), |
| 1750 | addr:$dst), |
| 1751 | (SHLD64mrCL addr:$dst, GR64:$src2)>; |
| 1752 | |
| 1753 | def : Pat<(shld GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm:$amt2)), |
| 1754 | (SHLD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>; |
| 1755 | |
| 1756 | def : Pat<(store (shld (loadi64 addr:$dst), (i8 imm:$amt1), |
| 1757 | GR64:$src2, (i8 imm:$amt2)), addr:$dst), |
| 1758 | (SHLD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>; |
| 1759 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1760 | // X86 specific add which produces a flag. |
| 1761 | def : Pat<(addc GR64:$src1, GR64:$src2), |
| 1762 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 1763 | def : Pat<(addc GR64:$src1, (load addr:$src2)), |
| 1764 | (ADD64rm GR64:$src1, addr:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1765 | def : Pat<(addc GR64:$src1, i64immSExt8:$src2), |
| 1766 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1767 | def : Pat<(addc GR64:$src1, i64immSExt32:$src2), |
| 1768 | (ADD64ri32 GR64:$src1, imm:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1769 | |
| 1770 | def : Pat<(subc GR64:$src1, GR64:$src2), |
| 1771 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 1772 | def : Pat<(subc GR64:$src1, (load addr:$src2)), |
| 1773 | (SUB64rm GR64:$src1, addr:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1774 | def : Pat<(subc GR64:$src1, i64immSExt8:$src2), |
| 1775 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1776 | def : Pat<(subc GR64:$src1, imm:$src2), |
| 1777 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1778 | |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1779 | //===----------------------------------------------------------------------===// |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1780 | // EFLAGS-defining Patterns |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1781 | //===----------------------------------------------------------------------===// |
| 1782 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1783 | // Register-Register Addition with EFLAGS result |
| 1784 | def : Pat<(parallel (X86add_flag GR64:$src1, GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1785 | (implicit EFLAGS)), |
| 1786 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 1787 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1788 | // Register-Integer Addition with EFLAGS result |
| 1789 | def : Pat<(parallel (X86add_flag GR64:$src1, i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1790 | (implicit EFLAGS)), |
| 1791 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1792 | def : Pat<(parallel (X86add_flag GR64:$src1, i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1793 | (implicit EFLAGS)), |
| 1794 | (ADD64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1795 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1796 | // Register-Memory Addition with EFLAGS result |
| 1797 | def : Pat<(parallel (X86add_flag GR64:$src1, (loadi64 addr:$src2)), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1798 | (implicit EFLAGS)), |
| 1799 | (ADD64rm GR64:$src1, addr:$src2)>; |
| 1800 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1801 | // Memory-Register Addition with EFLAGS result |
| 1802 | def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1803 | addr:$dst), |
| 1804 | (implicit EFLAGS)), |
| 1805 | (ADD64mr addr:$dst, GR64:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1806 | def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1807 | addr:$dst), |
| 1808 | (implicit EFLAGS)), |
| 1809 | (ADD64mi8 addr:$dst, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1810 | def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1811 | addr:$dst), |
| 1812 | (implicit EFLAGS)), |
| 1813 | (ADD64mi32 addr:$dst, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1814 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1815 | // Register-Register Subtraction with EFLAGS result |
| 1816 | def : Pat<(parallel (X86sub_flag GR64:$src1, GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1817 | (implicit EFLAGS)), |
| 1818 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 1819 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1820 | // Register-Memory Subtraction with EFLAGS result |
| 1821 | def : Pat<(parallel (X86sub_flag GR64:$src1, (loadi64 addr:$src2)), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1822 | (implicit EFLAGS)), |
| 1823 | (SUB64rm GR64:$src1, addr:$src2)>; |
| 1824 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1825 | // Register-Integer Subtraction with EFLAGS result |
| 1826 | def : Pat<(parallel (X86sub_flag GR64:$src1, i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1827 | (implicit EFLAGS)), |
| 1828 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1829 | def : Pat<(parallel (X86sub_flag GR64:$src1, i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1830 | (implicit EFLAGS)), |
| 1831 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1832 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1833 | // Memory-Register Subtraction with EFLAGS result |
| 1834 | def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1835 | addr:$dst), |
| 1836 | (implicit EFLAGS)), |
| 1837 | (SUB64mr addr:$dst, GR64:$src2)>; |
| 1838 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1839 | // Memory-Integer Subtraction with EFLAGS result |
| 1840 | def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1841 | addr:$dst), |
| 1842 | (implicit EFLAGS)), |
| 1843 | (SUB64mi8 addr:$dst, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1844 | def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1845 | addr:$dst), |
| 1846 | (implicit EFLAGS)), |
| 1847 | (SUB64mi32 addr:$dst, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1848 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1849 | // Register-Register Signed Integer Multiplication with EFLAGS result |
| 1850 | def : Pat<(parallel (X86smul_flag GR64:$src1, GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1851 | (implicit EFLAGS)), |
| 1852 | (IMUL64rr GR64:$src1, GR64:$src2)>; |
| 1853 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1854 | // Register-Memory Signed Integer Multiplication with EFLAGS result |
| 1855 | def : Pat<(parallel (X86smul_flag GR64:$src1, (loadi64 addr:$src2)), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1856 | (implicit EFLAGS)), |
| 1857 | (IMUL64rm GR64:$src1, addr:$src2)>; |
| 1858 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1859 | // Register-Integer Signed Integer Multiplication with EFLAGS result |
| 1860 | def : Pat<(parallel (X86smul_flag GR64:$src1, i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1861 | (implicit EFLAGS)), |
| 1862 | (IMUL64rri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1863 | def : Pat<(parallel (X86smul_flag GR64:$src1, i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1864 | (implicit EFLAGS)), |
| 1865 | (IMUL64rri32 GR64:$src1, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1866 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1867 | // Memory-Integer Signed Integer Multiplication with EFLAGS result |
| 1868 | def : Pat<(parallel (X86smul_flag (loadi64 addr:$src1), i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1869 | (implicit EFLAGS)), |
| 1870 | (IMUL64rmi8 addr:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1871 | def : Pat<(parallel (X86smul_flag (loadi64 addr:$src1), i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1872 | (implicit EFLAGS)), |
| 1873 | (IMUL64rmi32 addr:$src1, i64immSExt32:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1874 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1875 | // INC and DEC with EFLAGS result. Note that these do not set CF. |
Dan Gohman | eebcac7 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 1876 | def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)), |
| 1877 | (INC64_16r GR16:$src)>, Requires<[In64BitMode]>; |
| 1878 | def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst), |
| 1879 | (implicit EFLAGS)), |
| 1880 | (INC64_16m addr:$dst)>, Requires<[In64BitMode]>; |
| 1881 | def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)), |
| 1882 | (DEC64_16r GR16:$src)>, Requires<[In64BitMode]>; |
| 1883 | def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst), |
| 1884 | (implicit EFLAGS)), |
| 1885 | (DEC64_16m addr:$dst)>, Requires<[In64BitMode]>; |
| 1886 | |
| 1887 | def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)), |
| 1888 | (INC64_32r GR32:$src)>, Requires<[In64BitMode]>; |
| 1889 | def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst), |
| 1890 | (implicit EFLAGS)), |
| 1891 | (INC64_32m addr:$dst)>, Requires<[In64BitMode]>; |
| 1892 | def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)), |
| 1893 | (DEC64_32r GR32:$src)>, Requires<[In64BitMode]>; |
| 1894 | def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst), |
| 1895 | (implicit EFLAGS)), |
| 1896 | (DEC64_32m addr:$dst)>, Requires<[In64BitMode]>; |
| 1897 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1898 | def : Pat<(parallel (X86inc_flag GR64:$src), (implicit EFLAGS)), |
| 1899 | (INC64r GR64:$src)>; |
| 1900 | def : Pat<(parallel (store (i64 (X86inc_flag (loadi64 addr:$dst))), addr:$dst), |
| 1901 | (implicit EFLAGS)), |
| 1902 | (INC64m addr:$dst)>; |
| 1903 | def : Pat<(parallel (X86dec_flag GR64:$src), (implicit EFLAGS)), |
| 1904 | (DEC64r GR64:$src)>; |
| 1905 | def : Pat<(parallel (store (i64 (X86dec_flag (loadi64 addr:$dst))), addr:$dst), |
| 1906 | (implicit EFLAGS)), |
| 1907 | (DEC64m addr:$dst)>; |
| 1908 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1909 | //===----------------------------------------------------------------------===// |
| 1910 | // X86-64 SSE Instructions |
| 1911 | //===----------------------------------------------------------------------===// |
| 1912 | |
| 1913 | // Move instructions... |
| 1914 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1915 | def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1916 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1917 | [(set VR128:$dst, |
| 1918 | (v2i64 (scalar_to_vector GR64:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1919 | def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1920 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1921 | [(set GR64:$dst, (vector_extract (v2i64 VR128:$src), |
| 1922 | (iPTR 0)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1923 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1924 | def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1925 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1926 | [(set FR64:$dst, (bitconvert GR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1927 | def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Evan Cheng | 69ca4da | 2008-08-25 04:11:42 +0000 | [diff] [blame] | 1928 | "movq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1929 | [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>; |
| 1930 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1931 | def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1932 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1933 | [(set GR64:$dst, (bitconvert FR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1934 | def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src), |
Evan Cheng | 69ca4da | 2008-08-25 04:11:42 +0000 | [diff] [blame] | 1935 | "movq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1936 | [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>; |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 1937 | |
| 1938 | //===----------------------------------------------------------------------===// |
| 1939 | // X86-64 SSE4.1 Instructions |
| 1940 | //===----------------------------------------------------------------------===// |
| 1941 | |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1942 | /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination |
| 1943 | multiclass SS41I_extract64<bits<8> opc, string OpcodeStr> { |
Nate Begeman | 0050ab5 | 2008-10-29 23:07:17 +0000 | [diff] [blame] | 1944 | def rr : SS4AIi8<opc, MRMDestReg, (outs GR64:$dst), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1945 | (ins VR128:$src1, i32i8imm:$src2), |
| 1946 | !strconcat(OpcodeStr, |
| 1947 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 1948 | [(set GR64:$dst, |
| 1949 | (extractelt (v2i64 VR128:$src1), imm:$src2))]>, OpSize, REX_W; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1950 | def mr : SS4AIi8<opc, MRMDestMem, (outs), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1951 | (ins i64mem:$dst, VR128:$src1, i32i8imm:$src2), |
| 1952 | !strconcat(OpcodeStr, |
| 1953 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 1954 | [(store (extractelt (v2i64 VR128:$src1), imm:$src2), |
| 1955 | addr:$dst)]>, OpSize, REX_W; |
| 1956 | } |
| 1957 | |
| 1958 | defm PEXTRQ : SS41I_extract64<0x16, "pextrq">; |
| 1959 | |
| 1960 | let isTwoAddress = 1 in { |
| 1961 | multiclass SS41I_insert64<bits<8> opc, string OpcodeStr> { |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1962 | def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1963 | (ins VR128:$src1, GR64:$src2, i32i8imm:$src3), |
| 1964 | !strconcat(OpcodeStr, |
| 1965 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
| 1966 | [(set VR128:$dst, |
| 1967 | (v2i64 (insertelt VR128:$src1, GR64:$src2, imm:$src3)))]>, |
| 1968 | OpSize, REX_W; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1969 | def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1970 | (ins VR128:$src1, i64mem:$src2, i32i8imm:$src3), |
| 1971 | !strconcat(OpcodeStr, |
| 1972 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
| 1973 | [(set VR128:$dst, |
| 1974 | (v2i64 (insertelt VR128:$src1, (loadi64 addr:$src2), |
| 1975 | imm:$src3)))]>, OpSize, REX_W; |
| 1976 | } |
| 1977 | } |
| 1978 | |
| 1979 | defm PINSRQ : SS41I_insert64<0x22, "pinsrq">; |