Chris Lattner | 2de8d2b | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 1 | //====- X86Instr64bit.td - Describe X86-64 Instructions ----*- tablegen -*-===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file describes the X86-64 instruction set, defining the instructions, |
| 11 | // and properties of the instructions which are needed for code generation, |
| 12 | // machine code emission, and analysis. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | //===----------------------------------------------------------------------===// |
Chris Lattner | 2de8d2b | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 17 | // Operand Definitions. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 18 | // |
| 19 | |
| 20 | // 64-bits but only 32 bits are significant. |
| 21 | def i64i32imm : Operand<i64>; |
| 22 | // 64-bits but only 8 bits are significant. |
| 23 | def i64i8imm : Operand<i64>; |
| 24 | |
| 25 | def lea64mem : Operand<i64> { |
| 26 | let PrintMethod = "printi64mem"; |
| 27 | let MIOperandInfo = (ops GR64, i8imm, GR64, i32imm); |
| 28 | } |
| 29 | |
| 30 | def lea64_32mem : Operand<i32> { |
| 31 | let PrintMethod = "printlea64_32mem"; |
| 32 | let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm); |
| 33 | } |
| 34 | |
| 35 | //===----------------------------------------------------------------------===// |
Chris Lattner | 2de8d2b | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 36 | // Complex Pattern Definitions. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 37 | // |
| 38 | def lea64addr : ComplexPattern<i64, 4, "SelectLEAAddr", |
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 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 258 | def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 259 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 260 | [(set GR64:$dst, (sext GR8:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 261 | def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 262 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 263 | [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 264 | def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 265 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 266 | [(set GR64:$dst, (sext GR16:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 267 | def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 268 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 269 | [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 270 | def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 271 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 272 | [(set GR64:$dst, (sext GR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 273 | def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 274 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 275 | [(set GR64:$dst, (sextloadi64i32 addr:$src))]>; |
| 276 | |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 277 | // Use movzbl instead of movzbq when the destination is a register; it's |
| 278 | // equivalent due to implicit zero-extending, and it has a smaller encoding. |
| 279 | def MOVZX64rr8 : I<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
| 280 | "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 281 | [(set GR64:$dst, (zext GR8:$src))]>, TB; |
| 282 | def MOVZX64rm8 : I<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
| 283 | "movz{bl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 284 | [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB; |
| 285 | // Use movzwl instead of movzwq when the destination is a register; it's |
| 286 | // equivalent due to implicit zero-extending, and it has a smaller encoding. |
| 287 | def MOVZX64rr16: I<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
| 288 | "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 289 | [(set GR64:$dst, (zext GR16:$src))]>, TB; |
| 290 | def MOVZX64rm16: I<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
| 291 | "movz{wl|x}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 292 | [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 293 | |
Dan Gohman | 47a419d | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 294 | // There's no movzlq instruction, but movl can be used for this purpose, using |
| 295 | // implicit zero-extension. We need this because the seeming alternative for |
| 296 | // implementing zext from 32 to 64, an EXTRACT_SUBREG/SUBREG_TO_REG pair, isn't |
| 297 | // safe because both instructions could be optimized away in the |
| 298 | // register-to-register case, leaving nothing behind to do the zero extension. |
| 299 | def MOVZX64rr32 : I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src), |
| 300 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 301 | [(set GR64:$dst, (zext GR32:$src))]>; |
| 302 | def MOVZX64rm32 : I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), |
| 303 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
| 304 | [(set GR64:$dst, (zextloadi64i32 addr:$src))]>; |
| 305 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 306 | let neverHasSideEffects = 1 in { |
| 307 | let Defs = [RAX], Uses = [EAX] in |
| 308 | def CDQE : RI<0x98, RawFrm, (outs), (ins), |
| 309 | "{cltq|cdqe}", []>; // RAX = signext(EAX) |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 310 | |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 311 | let Defs = [RAX,RDX], Uses = [RAX] in |
| 312 | def CQO : RI<0x99, RawFrm, (outs), (ins), |
| 313 | "{cqto|cqo}", []>; // RDX:RAX = signext(RAX) |
| 314 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 315 | |
| 316 | //===----------------------------------------------------------------------===// |
| 317 | // Arithmetic Instructions... |
| 318 | // |
| 319 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 320 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 321 | let isTwoAddress = 1 in { |
| 322 | let isConvertibleToThreeAddress = 1 in { |
| 323 | let isCommutable = 1 in |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 324 | // Register-Register Addition |
| 325 | def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
| 326 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 327 | [(set GR64:$dst, (add GR64:$src1, GR64:$src2)), |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 328 | (implicit EFLAGS)]>; |
| 329 | |
| 330 | // Register-Integer Addition |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 331 | def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
| 332 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 333 | [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2)), |
| 334 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 335 | def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 336 | "add{q}\t{$src2, $dst|$dst, $src2}", |
| 337 | [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2)), |
| 338 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 339 | } // isConvertibleToThreeAddress |
| 340 | |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 341 | // Register-Memory Addition |
| 342 | def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 343 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 344 | [(set GR64:$dst, (add GR64:$src1, (load addr:$src2))), |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 345 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 346 | } // isTwoAddress |
| 347 | |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 348 | // Memory-Register Addition |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 349 | def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 350 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 351 | [(store (add (load addr:$dst), GR64:$src2), addr:$dst), |
| 352 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 353 | def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 354 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 355 | [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst), |
| 356 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 357 | def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2), |
| 358 | "add{q}\t{$src2, $dst|$dst, $src2}", |
| 359 | [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst), |
| 360 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 361 | |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 362 | let Uses = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 363 | let isTwoAddress = 1 in { |
| 364 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 365 | def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 366 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | c0ca7f3 | 2008-12-01 23:44:08 +0000 | [diff] [blame] | 367 | [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 368 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 369 | def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 370 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | c0ca7f3 | 2008-12-01 23:44:08 +0000 | [diff] [blame] | 371 | [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 372 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 373 | def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 374 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | c0ca7f3 | 2008-12-01 23:44:08 +0000 | [diff] [blame] | 375 | [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 376 | def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 377 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
| 378 | [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 379 | } // isTwoAddress |
| 380 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 381 | def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 382 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | c0ca7f3 | 2008-12-01 23:44:08 +0000 | [diff] [blame] | 383 | [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 384 | def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 385 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 0c52d0a | 2008-12-02 00:07:05 +0000 | [diff] [blame] | 386 | [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 387 | def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
| 388 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
| 389 | [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 390 | } // Uses = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 391 | |
| 392 | let isTwoAddress = 1 in { |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 393 | // Register-Register Subtraction |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 394 | 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] | 395 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 396 | [(set GR64:$dst, (sub GR64:$src1, GR64:$src2)), |
| 397 | (implicit EFLAGS)]>; |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 398 | |
| 399 | // Register-Memory Subtraction |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 400 | 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] | 401 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 402 | [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2))), |
| 403 | (implicit EFLAGS)]>; |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 404 | |
| 405 | // Register-Integer Subtraction |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 406 | def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), |
| 407 | (ins GR64:$src1, i64i8imm:$src2), |
| 408 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 409 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2)), |
| 410 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 411 | def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), |
| 412 | (ins GR64:$src1, i64i32imm:$src2), |
| 413 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
| 414 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2)), |
| 415 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 416 | } // isTwoAddress |
| 417 | |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 418 | // Memory-Register Subtraction |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 419 | def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 420 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 421 | [(store (sub (load addr:$dst), GR64:$src2), addr:$dst), |
| 422 | (implicit EFLAGS)]>; |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 423 | |
| 424 | // Memory-Integer Subtraction |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 425 | def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 426 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 427 | [(store (sub (load addr:$dst), i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 428 | addr:$dst), |
| 429 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 430 | def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
| 431 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
| 432 | [(store (sub (load addr:$dst), i64immSExt32:$src2), |
| 433 | addr:$dst), |
| 434 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 435 | |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 436 | let Uses = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 437 | let isTwoAddress = 1 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 438 | def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 439 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 440 | [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>; |
| 441 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 442 | def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 443 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 444 | [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>; |
| 445 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 446 | def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 447 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 448 | [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 449 | def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 450 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
| 451 | [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 452 | } // isTwoAddress |
| 453 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 454 | def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 455 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 456 | [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 457 | def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 458 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 459 | [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 460 | def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
| 461 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
| 462 | [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>; |
Evan Cheng | 259471d | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 463 | } // Uses = [EFLAGS] |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 464 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 465 | |
| 466 | // Unsigned multiplication |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 467 | let Defs = [RAX,RDX,EFLAGS], Uses = [RAX], neverHasSideEffects = 1 in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 468 | def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 469 | "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64 |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 470 | let mayLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 471 | def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 472 | "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 473 | |
| 474 | // Signed multiplication |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 475 | def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 476 | "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64 |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 477 | let mayLoad = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 478 | def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src), |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 479 | "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64] |
| 480 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 481 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 482 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 483 | let isTwoAddress = 1 in { |
| 484 | let isCommutable = 1 in |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 485 | // Register-Register Signed Integer Multiplication |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 486 | def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), |
| 487 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 488 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 489 | [(set GR64:$dst, (mul GR64:$src1, GR64:$src2)), |
| 490 | (implicit EFLAGS)]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 491 | |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 492 | // Register-Memory Signed Integer Multiplication |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 493 | def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), |
| 494 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 495 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 496 | [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2))), |
| 497 | (implicit EFLAGS)]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 498 | } // isTwoAddress |
| 499 | |
| 500 | // Suprisingly enough, these are not two address instructions! |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 501 | |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 502 | // Register-Integer Signed Integer Multiplication |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 503 | def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 504 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 505 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 506 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2)), |
| 507 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 508 | def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32 |
| 509 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 510 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
| 511 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2)), |
| 512 | (implicit EFLAGS)]>; |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 513 | |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 514 | // Memory-Integer Signed Integer Multiplication |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 515 | def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 516 | (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 517 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Bill Wendling | ae034ed | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 518 | [(set GR64:$dst, (mul (load addr:$src1), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 519 | i64immSExt8:$src2)), |
| 520 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 521 | def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32 |
| 522 | (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2), |
| 523 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
| 524 | [(set GR64:$dst, (mul (load addr:$src1), |
| 525 | i64immSExt32:$src2)), |
| 526 | (implicit 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 division / remainder |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 530 | let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 531 | 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] | 532 | "div{q}\t$src", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 533 | // Signed division / remainder |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 534 | 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] | 535 | "idiv{q}\t$src", []>; |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 536 | let mayLoad = 1 in { |
| 537 | def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX |
| 538 | "div{q}\t$src", []>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 539 | 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] | 540 | "idiv{q}\t$src", []>; |
| 541 | } |
Chris Lattner | c90ee9c | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 542 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 543 | |
| 544 | // Unary instructions |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 545 | let Defs = [EFLAGS], CodeSize = 2 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 546 | let isTwoAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 547 | 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] | 548 | [(set GR64:$dst, (ineg GR64:$src)), |
| 549 | (implicit EFLAGS)]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 550 | 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] | 551 | [(store (ineg (loadi64 addr:$dst)), addr:$dst), |
| 552 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 553 | |
| 554 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 555 | 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] | 556 | [(set GR64:$dst, (add GR64:$src, 1)), |
| 557 | (implicit EFLAGS)]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 558 | 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] | 559 | [(store (add (loadi64 addr:$dst), 1), addr:$dst), |
| 560 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 561 | |
| 562 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 563 | 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] | 564 | [(set GR64:$dst, (add GR64:$src, -1)), |
| 565 | (implicit EFLAGS)]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 566 | 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] | 567 | [(store (add (loadi64 addr:$dst), -1), addr:$dst), |
| 568 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 569 | |
| 570 | // In 64-bit mode, single byte INC and DEC cannot be encoded. |
| 571 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in { |
| 572 | // Can transform into LEA. |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 573 | 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] | 574 | [(set GR16:$dst, (add GR16:$src, 1)), |
| 575 | (implicit EFLAGS)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 576 | OpSize, Requires<[In64BitMode]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 577 | 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] | 578 | [(set GR32:$dst, (add GR32:$src, 1)), |
| 579 | (implicit EFLAGS)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 580 | Requires<[In64BitMode]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 581 | 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] | 582 | [(set GR16:$dst, (add GR16:$src, -1)), |
| 583 | (implicit EFLAGS)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 584 | OpSize, Requires<[In64BitMode]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 585 | 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] | 586 | [(set GR32:$dst, (add GR32:$src, -1)), |
| 587 | (implicit EFLAGS)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 588 | Requires<[In64BitMode]>; |
| 589 | } // isConvertibleToThreeAddress |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 590 | |
| 591 | // These are duplicates of their 32-bit counterparts. Only needed so X86 knows |
| 592 | // how to unfold them. |
| 593 | let isTwoAddress = 0, CodeSize = 2 in { |
| 594 | 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] | 595 | [(store (add (loadi16 addr:$dst), 1), addr:$dst), |
| 596 | (implicit EFLAGS)]>, |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 597 | OpSize, Requires<[In64BitMode]>; |
| 598 | 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] | 599 | [(store (add (loadi32 addr:$dst), 1), addr:$dst), |
| 600 | (implicit EFLAGS)]>, |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 601 | Requires<[In64BitMode]>; |
| 602 | 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] | 603 | [(store (add (loadi16 addr:$dst), -1), addr:$dst), |
| 604 | (implicit EFLAGS)]>, |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 605 | OpSize, Requires<[In64BitMode]>; |
| 606 | 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] | 607 | [(store (add (loadi32 addr:$dst), -1), addr:$dst), |
| 608 | (implicit EFLAGS)]>, |
Evan Cheng | 4a7e72f | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 609 | Requires<[In64BitMode]>; |
| 610 | } |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 611 | } // Defs = [EFLAGS], CodeSize |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 612 | |
| 613 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 614 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 615 | // Shift instructions |
| 616 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 617 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 618 | def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 619 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 620 | [(set GR64:$dst, (shl GR64:$src, CL))]>; |
Evan Cheng | a98f627 | 2007-10-05 18:20:36 +0000 | [diff] [blame] | 621 | let isConvertibleToThreeAddress = 1 in // Can transform into LEA. |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 622 | 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] | 623 | "shl{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 624 | [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>; |
Chris Lattner | f4005a8 | 2008-01-11 18:00:50 +0000 | [diff] [blame] | 625 | // NOTE: We don't use shifts of a register by one, because 'add reg,reg' is |
| 626 | // cheaper. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 627 | } // isTwoAddress |
| 628 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 629 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 630 | def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 631 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 632 | [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 633 | def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 634 | "shl{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 635 | [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 636 | def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 637 | "shl{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 638 | [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 639 | |
| 640 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 641 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 642 | def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 643 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 644 | [(set GR64:$dst, (srl GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 645 | 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] | 646 | "shr{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 647 | [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 648 | def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 649 | "shr{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 650 | [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>; |
| 651 | } // isTwoAddress |
| 652 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 653 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 654 | def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 655 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 656 | [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 657 | def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 658 | "shr{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 659 | [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 660 | def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 661 | "shr{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 662 | [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 663 | |
| 664 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 665 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 666 | def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 667 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 668 | [(set GR64:$dst, (sra GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 669 | 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] | 670 | "sar{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 671 | [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 672 | def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 673 | "sar{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 674 | [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>; |
| 675 | } // isTwoAddress |
| 676 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 677 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 678 | def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 679 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 680 | [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 681 | def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 682 | "sar{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 683 | [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 684 | def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 685 | "sar{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 686 | [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 687 | |
| 688 | // Rotate instructions |
| 689 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 690 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 691 | def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 692 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 693 | [(set GR64:$dst, (rotl GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 694 | 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] | 695 | "rol{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 696 | [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 697 | def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 698 | "rol{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 699 | [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>; |
| 700 | } // isTwoAddress |
| 701 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 702 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 703 | def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 704 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 705 | [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 706 | def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 707 | "rol{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 708 | [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 709 | def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 710 | "rol{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 711 | [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 712 | |
| 713 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 714 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 715 | def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 716 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 717 | [(set GR64:$dst, (rotr GR64:$src, CL))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 718 | 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] | 719 | "ror{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 720 | [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 721 | def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 722 | "ror{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 723 | [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>; |
| 724 | } // isTwoAddress |
| 725 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 726 | let Uses = [CL] in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 727 | def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 728 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 729 | [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 730 | def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 731 | "ror{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 732 | [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 733 | def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 734 | "ror{q}\t$dst", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 735 | [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 736 | |
| 737 | // Double shift instructions (generalizations of rotate) |
| 738 | let isTwoAddress = 1 in { |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 739 | let Uses = [CL] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 740 | 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] | 741 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 742 | [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 743 | 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] | 744 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 745 | [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, TB; |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 746 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 747 | |
| 748 | let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction |
| 749 | def SHLD64rri8 : RIi8<0xA4, MRMDestReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 750 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 751 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 752 | [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, |
| 753 | (i8 imm:$src3)))]>, |
| 754 | TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 755 | def SHRD64rri8 : RIi8<0xAC, MRMDestReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 756 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 757 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 758 | [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, |
| 759 | (i8 imm:$src3)))]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 760 | TB; |
| 761 | } // isCommutable |
| 762 | } // isTwoAddress |
| 763 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 764 | let Uses = [CL] in { |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 765 | def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 766 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 767 | [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL), |
| 768 | addr:$dst)]>, TB; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 769 | def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 770 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 771 | [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL), |
| 772 | addr:$dst)]>, TB; |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 773 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 774 | def SHLD64mri8 : RIi8<0xA4, MRMDestMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 775 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 776 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 777 | [(store (X86shld (loadi64 addr:$dst), GR64:$src2, |
| 778 | (i8 imm:$src3)), addr:$dst)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 779 | TB; |
| 780 | def SHRD64mri8 : RIi8<0xAC, MRMDestMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 781 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | 4d9fc4a | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 782 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 783 | [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, |
| 784 | (i8 imm:$src3)), addr:$dst)]>, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 785 | TB; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 786 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 787 | |
| 788 | //===----------------------------------------------------------------------===// |
| 789 | // Logical Instructions... |
| 790 | // |
| 791 | |
Evan Cheng | 5b51c24 | 2009-01-21 19:45:31 +0000 | [diff] [blame] | 792 | let isTwoAddress = 1 , AddedComplexity = 15 in |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 793 | 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] | 794 | [(set GR64:$dst, (not GR64:$src))]>; |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 795 | 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] | 796 | [(store (not (loadi64 addr:$dst)), addr:$dst)]>; |
| 797 | |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 798 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 799 | let isTwoAddress = 1 in { |
| 800 | let isCommutable = 1 in |
| 801 | def AND64rr : RI<0x21, MRMDestReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 802 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 803 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 804 | [(set GR64:$dst, (and GR64:$src1, GR64:$src2)), |
| 805 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 806 | def AND64rm : RI<0x23, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 807 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 808 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 809 | [(set GR64:$dst, (and GR64:$src1, (load addr:$src2))), |
| 810 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 811 | def AND64ri8 : RIi8<0x83, MRM4r, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 812 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 813 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 814 | [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2)), |
| 815 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 816 | def AND64ri32 : RIi32<0x81, MRM4r, |
| 817 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 818 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 819 | [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2)), |
| 820 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 821 | } // isTwoAddress |
| 822 | |
| 823 | def AND64mr : RI<0x21, MRMDestMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 824 | (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 825 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 826 | [(store (and (load addr:$dst), GR64:$src), addr:$dst), |
| 827 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 828 | def AND64mi8 : RIi8<0x83, MRM4m, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 829 | (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 830 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 831 | [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst), |
| 832 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 833 | def AND64mi32 : RIi32<0x81, MRM4m, |
| 834 | (outs), (ins i64mem:$dst, i64i32imm:$src), |
| 835 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 836 | [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), |
| 837 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 838 | |
| 839 | let isTwoAddress = 1 in { |
| 840 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 841 | 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] | 842 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 843 | [(set GR64:$dst, (or GR64:$src1, GR64:$src2)), |
| 844 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 845 | 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] | 846 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 847 | [(set GR64:$dst, (or GR64:$src1, (load addr:$src2))), |
| 848 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 849 | 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] | 850 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 851 | [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2)), |
| 852 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 853 | def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 854 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 855 | [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2)), |
| 856 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 857 | } // isTwoAddress |
| 858 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 859 | def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 860 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 861 | [(store (or (load addr:$dst), GR64:$src), addr:$dst), |
| 862 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 863 | def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 864 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 865 | [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst), |
| 866 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 867 | def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
| 868 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 869 | [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), |
| 870 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 871 | |
| 872 | let isTwoAddress = 1 in { |
Evan Cheng | 0685efa | 2008-08-30 08:54:22 +0000 | [diff] [blame] | 873 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 874 | 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] | 875 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 876 | [(set GR64:$dst, (xor GR64:$src1, GR64:$src2)), |
| 877 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 878 | 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] | 879 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 880 | [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2))), |
| 881 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 882 | def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
| 883 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 884 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2)), |
| 885 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 886 | def XOR64ri32 : RIi32<0x81, MRM6r, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 887 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 888 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 889 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2)), |
| 890 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 891 | } // isTwoAddress |
| 892 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 893 | def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 894 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 895 | [(store (xor (load addr:$dst), GR64:$src), addr:$dst), |
| 896 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 897 | def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 898 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 899 | [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst), |
| 900 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 901 | def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
| 902 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 7b93f1c | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 903 | [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), |
| 904 | (implicit EFLAGS)]>; |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 905 | } // Defs = [EFLAGS] |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 906 | |
| 907 | //===----------------------------------------------------------------------===// |
| 908 | // Comparison Instructions... |
| 909 | // |
| 910 | |
| 911 | // Integer comparison |
Evan Cheng | 5568707 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 912 | let Defs = [EFLAGS] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 913 | let isCommutable = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 914 | def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 915 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 916 | [(X86cmp (and GR64:$src1, GR64:$src2), 0), |
| 917 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 918 | def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 919 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 920 | [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0), |
| 921 | (implicit EFLAGS)]>; |
| 922 | def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), |
| 923 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 924 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 925 | [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0), |
| 926 | (implicit EFLAGS)]>; |
| 927 | def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), |
| 928 | (ins i64mem:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 929 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 930 | [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0), |
| 931 | (implicit EFLAGS)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 932 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 933 | def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 934 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 935 | [(X86cmp GR64:$src1, GR64:$src2), |
| 936 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 937 | def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 938 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 939 | [(X86cmp (loadi64 addr:$src1), GR64:$src2), |
| 940 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 941 | def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 942 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 943 | [(X86cmp GR64:$src1, (loadi64 addr:$src2)), |
| 944 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 945 | def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
| 946 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
| 947 | [(X86cmp GR64:$src1, i64immSExt8:$src2), |
| 948 | (implicit EFLAGS)]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 949 | def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 950 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 951 | [(X86cmp GR64:$src1, i64immSExt32:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 952 | (implicit EFLAGS)]>; |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 953 | def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 954 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 955 | [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 956 | (implicit EFLAGS)]>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 957 | def CMP64mi32 : RIi32<0x81, MRM7m, (outs), |
| 958 | (ins i64mem:$src1, i64i32imm:$src2), |
| 959 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
| 960 | [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2), |
| 961 | (implicit EFLAGS)]>; |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 962 | } // Defs = [EFLAGS] |
| 963 | |
Dan Gohman | 7fe9b7f | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 964 | // Bit tests. |
Dan Gohman | 7fe9b7f | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 965 | // TODO: BTC, BTR, and BTS |
| 966 | let Defs = [EFLAGS] in { |
Chris Lattner | 5a95cde | 2008-12-25 01:32:49 +0000 | [diff] [blame] | 967 | def BT64rr : RI<0xA3, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 7fe9b7f | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 968 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
| 969 | [(X86bt GR64:$src1, GR64:$src2), |
Chris Lattner | 5a95cde | 2008-12-25 01:32:49 +0000 | [diff] [blame] | 970 | (implicit EFLAGS)]>, TB; |
Dan Gohman | 85a228c | 2009-01-13 23:23:30 +0000 | [diff] [blame] | 971 | |
| 972 | // Unlike with the register+register form, the memory+register form of the |
| 973 | // bt instruction does not ignore the high bits of the index. From ISel's |
| 974 | // perspective, this is pretty bizarre. Disable these instructions for now. |
| 975 | //def BT64mr : RI<0xA3, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
| 976 | // "bt{q}\t{$src2, $src1|$src1, $src2}", |
| 977 | // [(X86bt (loadi64 addr:$src1), GR64:$src2), |
| 978 | // (implicit EFLAGS)]>, TB; |
Dan Gohman | 46fb1cf | 2009-01-13 20:33:23 +0000 | [diff] [blame] | 979 | |
| 980 | def BT64ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
| 981 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
| 982 | [(X86bt GR64:$src1, i64immSExt8:$src2), |
| 983 | (implicit EFLAGS)]>, TB; |
| 984 | // Note that these instructions don't need FastBTMem because that |
| 985 | // only applies when the other operand is in a register. When it's |
| 986 | // an immediate, bt is still fast. |
| 987 | def BT64mi8 : Ii8<0xBA, MRM4m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
| 988 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
| 989 | [(X86bt (loadi64 addr:$src1), i64immSExt8:$src2), |
| 990 | (implicit EFLAGS)]>, TB; |
Dan Gohman | 7fe9b7f | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 991 | } // Defs = [EFLAGS] |
| 992 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 993 | // Conditional moves |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 994 | let Uses = [EFLAGS], isTwoAddress = 1 in { |
Evan Cheng | 926658c | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 995 | let isCommutable = 1 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 996 | def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 997 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 998 | "cmovb\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 999 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1000 | X86_COND_B, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1001 | def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1002 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1003 | "cmovae\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1004 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1005 | X86_COND_AE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1006 | def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1007 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1008 | "cmove\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1009 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1010 | X86_COND_E, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1011 | def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1012 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1013 | "cmovne\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1014 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1015 | X86_COND_NE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1016 | def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1017 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1018 | "cmovbe\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1019 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1020 | X86_COND_BE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1021 | def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1022 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1023 | "cmova\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1024 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1025 | X86_COND_A, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1026 | def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1027 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1028 | "cmovl\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1029 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1030 | X86_COND_L, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1031 | def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1032 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1033 | "cmovge\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1034 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1035 | X86_COND_GE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1036 | def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1037 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1038 | "cmovle\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1039 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1040 | X86_COND_LE, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1041 | def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1042 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1043 | "cmovg\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1044 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1045 | X86_COND_G, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1046 | def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1047 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1048 | "cmovs\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1049 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1050 | X86_COND_S, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1051 | def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1052 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1053 | "cmovns\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1054 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1055 | X86_COND_NS, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1056 | def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1057 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1058 | "cmovp\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1059 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1060 | X86_COND_P, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1061 | def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1062 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1063 | "cmovnp\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1064 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1065 | X86_COND_NP, EFLAGS))]>, TB; |
Dan Gohman | 12fd4d7 | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1066 | def CMOVO64rr : RI<0x40, MRMSrcReg, // if overflow, GR64 = GR64 |
| 1067 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
| 1068 | "cmovo\t{$src2, $dst|$dst, $src2}", |
| 1069 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 1070 | X86_COND_O, EFLAGS))]>, TB; |
| 1071 | def CMOVNO64rr : RI<0x41, MRMSrcReg, // if !overflow, GR64 = GR64 |
| 1072 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
| 1073 | "cmovno\t{$src2, $dst|$dst, $src2}", |
| 1074 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 1075 | X86_COND_NO, EFLAGS))]>, TB; |
Evan Cheng | 926658c | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1076 | } // isCommutable = 1 |
| 1077 | |
| 1078 | def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64] |
| 1079 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1080 | "cmovb\t{$src2, $dst|$dst, $src2}", |
| 1081 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1082 | X86_COND_B, EFLAGS))]>, TB; |
| 1083 | def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64] |
| 1084 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1085 | "cmovae\t{$src2, $dst|$dst, $src2}", |
| 1086 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1087 | X86_COND_AE, EFLAGS))]>, TB; |
| 1088 | def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64] |
| 1089 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1090 | "cmove\t{$src2, $dst|$dst, $src2}", |
| 1091 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1092 | X86_COND_E, EFLAGS))]>, TB; |
| 1093 | def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64] |
| 1094 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1095 | "cmovne\t{$src2, $dst|$dst, $src2}", |
| 1096 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1097 | X86_COND_NE, EFLAGS))]>, TB; |
| 1098 | def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64] |
| 1099 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1100 | "cmovbe\t{$src2, $dst|$dst, $src2}", |
| 1101 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1102 | X86_COND_BE, EFLAGS))]>, TB; |
| 1103 | def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64] |
| 1104 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1105 | "cmova\t{$src2, $dst|$dst, $src2}", |
| 1106 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1107 | X86_COND_A, EFLAGS))]>, TB; |
| 1108 | def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64] |
| 1109 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1110 | "cmovl\t{$src2, $dst|$dst, $src2}", |
| 1111 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1112 | X86_COND_L, EFLAGS))]>, TB; |
| 1113 | def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64] |
| 1114 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1115 | "cmovge\t{$src2, $dst|$dst, $src2}", |
| 1116 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1117 | X86_COND_GE, EFLAGS))]>, TB; |
| 1118 | def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64] |
| 1119 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1120 | "cmovle\t{$src2, $dst|$dst, $src2}", |
| 1121 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1122 | X86_COND_LE, EFLAGS))]>, TB; |
| 1123 | def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64] |
| 1124 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1125 | "cmovg\t{$src2, $dst|$dst, $src2}", |
| 1126 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1127 | X86_COND_G, EFLAGS))]>, TB; |
| 1128 | def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64] |
| 1129 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1130 | "cmovs\t{$src2, $dst|$dst, $src2}", |
| 1131 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1132 | X86_COND_S, EFLAGS))]>, TB; |
| 1133 | def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64] |
| 1134 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1135 | "cmovns\t{$src2, $dst|$dst, $src2}", |
| 1136 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1137 | X86_COND_NS, EFLAGS))]>, TB; |
| 1138 | def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64] |
| 1139 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1140 | "cmovp\t{$src2, $dst|$dst, $src2}", |
| 1141 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1142 | X86_COND_P, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1143 | def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64] |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1144 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1145 | "cmovnp\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1146 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
Evan Cheng | 950aac0 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1147 | X86_COND_NP, EFLAGS))]>, TB; |
Dan Gohman | 12fd4d7 | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1148 | def CMOVO64rm : RI<0x40, MRMSrcMem, // if overflow, GR64 = [mem64] |
| 1149 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1150 | "cmovo\t{$src2, $dst|$dst, $src2}", |
| 1151 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1152 | X86_COND_O, EFLAGS))]>, TB; |
| 1153 | def CMOVNO64rm : RI<0x41, MRMSrcMem, // if !overflow, GR64 = [mem64] |
| 1154 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
| 1155 | "cmovno\t{$src2, $dst|$dst, $src2}", |
| 1156 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1157 | X86_COND_NO, EFLAGS))]>, TB; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1158 | } // isTwoAddress |
| 1159 | |
| 1160 | //===----------------------------------------------------------------------===// |
| 1161 | // Conversion Instructions... |
| 1162 | // |
| 1163 | |
| 1164 | // f64 -> signed i64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1165 | def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1166 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1167 | [(set GR64:$dst, |
| 1168 | (int_x86_sse2_cvtsd2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1169 | def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1170 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1171 | [(set GR64:$dst, (int_x86_sse2_cvtsd2si64 |
| 1172 | (load addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1173 | def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1174 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1175 | [(set GR64:$dst, (fp_to_sint FR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1176 | def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1177 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1178 | [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1179 | def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1180 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1181 | [(set GR64:$dst, |
| 1182 | (int_x86_sse2_cvttsd2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1183 | def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1184 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1185 | [(set GR64:$dst, |
| 1186 | (int_x86_sse2_cvttsd2si64 |
| 1187 | (load addr:$src)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1188 | |
| 1189 | // Signed i64 -> f64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1190 | def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1191 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1192 | [(set FR64:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1193 | def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1194 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1195 | [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
Evan Cheng | 1d5832e | 2008-01-11 07:37:44 +0000 | [diff] [blame] | 1196 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1197 | let isTwoAddress = 1 in { |
| 1198 | def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1199 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1200 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1201 | [(set VR128:$dst, |
| 1202 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 1203 | GR64:$src2))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1204 | def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1205 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1206 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1207 | [(set VR128:$dst, |
| 1208 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 1209 | (loadi64 addr:$src2)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1210 | } // isTwoAddress |
| 1211 | |
| 1212 | // Signed i64 -> f32 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1213 | def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1214 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1215 | [(set FR32:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1216 | def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1217 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1218 | [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
Evan Cheng | 1d5832e | 2008-01-11 07:37:44 +0000 | [diff] [blame] | 1219 | |
| 1220 | let isTwoAddress = 1 in { |
| 1221 | def Int_CVTSI2SS64rr : RSSI<0x2A, MRMSrcReg, |
| 1222 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
| 1223 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
| 1224 | [(set VR128:$dst, |
| 1225 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 1226 | GR64:$src2))]>; |
| 1227 | def Int_CVTSI2SS64rm : RSSI<0x2A, MRMSrcMem, |
| 1228 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
| 1229 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
| 1230 | [(set VR128:$dst, |
| 1231 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 1232 | (loadi64 addr:$src2)))]>; |
| 1233 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1234 | |
| 1235 | // f32 -> signed i64 |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1236 | def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1237 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1238 | [(set GR64:$dst, |
| 1239 | (int_x86_sse_cvtss2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1240 | def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1241 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1242 | [(set GR64:$dst, (int_x86_sse_cvtss2si64 |
| 1243 | (load addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1244 | def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1245 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1246 | [(set GR64:$dst, (fp_to_sint FR32:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1247 | def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1248 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1249 | [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1250 | def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1251 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1252 | [(set GR64:$dst, |
| 1253 | (int_x86_sse_cvttss2si64 VR128:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1254 | def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1255 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6227d46 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1256 | [(set GR64:$dst, |
| 1257 | (int_x86_sse_cvttss2si64 (load addr:$src)))]>; |
| 1258 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1259 | //===----------------------------------------------------------------------===// |
| 1260 | // Alias Instructions |
| 1261 | //===----------------------------------------------------------------------===// |
| 1262 | |
Dan Gohman | 027cd11 | 2007-09-17 14:55:08 +0000 | [diff] [blame] | 1263 | // Alias instructions that map movr0 to xor. Use xorl instead of xorq; it's |
| 1264 | // equivalent due to implicit zero-extending, and it sometimes has a smaller |
| 1265 | // encoding. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1266 | // FIXME: remove when we can teach regalloc that xor reg, reg is ok. |
| 1267 | // FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove |
| 1268 | // when we have a better way to specify isel priority. |
Bill Wendling | 12e9721 | 2008-05-30 06:47:04 +0000 | [diff] [blame] | 1269 | let Defs = [EFLAGS], AddedComplexity = 1, |
| 1270 | isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1271 | def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins), |
| 1272 | "xor{l}\t${dst:subreg32}, ${dst:subreg32}", |
| 1273 | [(set GR64:$dst, 0)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1274 | |
| 1275 | // Materialize i64 constant where top 32-bits are zero. |
Evan Cheng | bd0ca9c | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 1276 | let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1277 | def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1278 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1279 | [(set GR64:$dst, i64immZExt32:$src)]>; |
| 1280 | |
Anton Korobeynikov | 4fbf00b | 2008-05-04 21:36:32 +0000 | [diff] [blame] | 1281 | //===----------------------------------------------------------------------===// |
| 1282 | // Thread Local Storage Instructions |
| 1283 | //===----------------------------------------------------------------------===// |
| 1284 | |
| 1285 | def TLS_addr64 : I<0, Pseudo, (outs GR64:$dst), (ins i64imm:$sym), |
Anton Korobeynikov | 5577e2e | 2008-05-05 17:08:59 +0000 | [diff] [blame] | 1286 | ".byte\t0x66; leaq\t${sym:mem}(%rip), $dst; .word\t0x6666; rex64", |
Anton Korobeynikov | 4fbf00b | 2008-05-04 21:36:32 +0000 | [diff] [blame] | 1287 | [(set GR64:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>; |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1288 | |
sampo | 9cc09a3 | 2009-01-26 01:24:32 +0000 | [diff] [blame] | 1289 | let AddedComplexity = 5 in |
| 1290 | def MOV64GSrm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
| 1291 | "movq\t%gs:$src, $dst", |
| 1292 | [(set GR64:$dst, (gsload addr:$src))]>, SegGS; |
| 1293 | |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1294 | //===----------------------------------------------------------------------===// |
| 1295 | // Atomic Instructions |
| 1296 | //===----------------------------------------------------------------------===// |
| 1297 | |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1298 | let Defs = [RAX, EFLAGS], Uses = [RAX] in { |
Evan Cheng | d49dbb8 | 2008-04-18 20:55:36 +0000 | [diff] [blame] | 1299 | def LCMPXCHG64 : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$ptr, GR64:$swap), |
Bill Wendling | 6f189e2 | 2008-08-19 23:09:18 +0000 | [diff] [blame] | 1300 | "lock\n\tcmpxchgq\t$swap,$ptr", |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1301 | [(X86cas addr:$ptr, GR64:$swap, 8)]>, TB, LOCK; |
| 1302 | } |
| 1303 | |
Dan Gohman | a41a1c09 | 2008-08-06 15:52:50 +0000 | [diff] [blame] | 1304 | let Constraints = "$val = $dst" in { |
| 1305 | let Defs = [EFLAGS] in |
Evan Cheng | d49dbb8 | 2008-04-18 20:55:36 +0000 | [diff] [blame] | 1306 | def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$ptr,GR64:$val), |
Bill Wendling | 6f189e2 | 2008-08-19 23:09:18 +0000 | [diff] [blame] | 1307 | "lock\n\txadd\t$val, $ptr", |
Mon P Wang | 6bde9ec | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 1308 | [(set GR64:$dst, (atomic_load_add_64 addr:$ptr, GR64:$val))]>, |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1309 | TB, LOCK; |
Evan Cheng | a1e8060 | 2008-04-19 02:05:42 +0000 | [diff] [blame] | 1310 | 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] | 1311 | "xchg\t$val, $ptr", |
Evan Cheng | a1e8060 | 2008-04-19 02:05:42 +0000 | [diff] [blame] | 1312 | [(set GR64:$dst, (atomic_swap_64 addr:$ptr, GR64:$val))]>; |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1313 | } |
| 1314 | |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1315 | // Atomic exchange, and, or, xor |
| 1316 | let Constraints = "$val = $dst", Defs = [EFLAGS], |
| 1317 | usesCustomDAGSchedInserter = 1 in { |
| 1318 | 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] | 1319 | "#ATOMAND64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1320 | [(set GR64:$dst, (atomic_load_and_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1321 | 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] | 1322 | "#ATOMOR64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1323 | [(set GR64:$dst, (atomic_load_or_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1324 | 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] | 1325 | "#ATOMXOR64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1326 | [(set GR64:$dst, (atomic_load_xor_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1327 | 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] | 1328 | "#ATOMNAND64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1329 | [(set GR64:$dst, (atomic_load_nand_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1330 | 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] | 1331 | "#ATOMMIN64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1332 | [(set GR64:$dst, (atomic_load_min_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1333 | 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] | 1334 | "#ATOMMAX64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1335 | [(set GR64:$dst, (atomic_load_max_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1336 | 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] | 1337 | "#ATOMUMIN64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1338 | [(set GR64:$dst, (atomic_load_umin_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1339 | 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] | 1340 | "#ATOMUMAX64 PSEUDO!", |
Dale Johannesen | bc18766 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1341 | [(set GR64:$dst, (atomic_load_umax_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | 6b60eca | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1342 | } |
Andrew Lenharth | bd7d326 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1343 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1344 | //===----------------------------------------------------------------------===// |
| 1345 | // Non-Instruction Patterns |
| 1346 | //===----------------------------------------------------------------------===// |
| 1347 | |
Bill Wendling | fef0605 | 2008-09-16 21:48:12 +0000 | [diff] [blame] | 1348 | // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1349 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
| 1350 | (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>; |
| 1351 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
| 1352 | (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>; |
| 1353 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
| 1354 | (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>; |
| 1355 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
| 1356 | (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>; |
| 1357 | |
| 1358 | def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst), |
| 1359 | (MOV64mi32 addr:$dst, tconstpool:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1360 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1361 | def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst), |
| 1362 | (MOV64mi32 addr:$dst, tjumptable:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1363 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1364 | def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst), |
| 1365 | (MOV64mi32 addr:$dst, tglobaladdr:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1366 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1367 | def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst), |
| 1368 | (MOV64mi32 addr:$dst, texternalsym:$src)>, |
Evan Cheng | 3b5a127 | 2008-02-07 08:53:49 +0000 | [diff] [blame] | 1369 | Requires<[SmallCode, IsStatic]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1370 | |
| 1371 | // Calls |
| 1372 | // Direct PC relative function call for small code model. 32-bit displacement |
| 1373 | // sign extended to 64-bit. |
| 1374 | def : Pat<(X86call (i64 tglobaladdr:$dst)), |
| 1375 | (CALL64pcrel32 tglobaladdr:$dst)>; |
| 1376 | def : Pat<(X86call (i64 texternalsym:$dst)), |
| 1377 | (CALL64pcrel32 texternalsym:$dst)>; |
| 1378 | |
| 1379 | def : Pat<(X86tailcall (i64 tglobaladdr:$dst)), |
| 1380 | (CALL64pcrel32 tglobaladdr:$dst)>; |
| 1381 | def : Pat<(X86tailcall (i64 texternalsym:$dst)), |
| 1382 | (CALL64pcrel32 texternalsym:$dst)>; |
| 1383 | |
| 1384 | def : Pat<(X86tailcall GR64:$dst), |
| 1385 | (CALL64r GR64:$dst)>; |
| 1386 | |
Arnold Schwaighofer | e2d6bbb | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 1387 | |
| 1388 | // tailcall stuff |
| 1389 | def : Pat<(X86tailcall GR32:$dst), |
| 1390 | (TAILCALL)>; |
| 1391 | def : Pat<(X86tailcall (i64 tglobaladdr:$dst)), |
| 1392 | (TAILCALL)>; |
| 1393 | def : Pat<(X86tailcall (i64 texternalsym:$dst)), |
| 1394 | (TAILCALL)>; |
| 1395 | |
| 1396 | def : Pat<(X86tcret GR64:$dst, imm:$off), |
| 1397 | (TCRETURNri64 GR64:$dst, imm:$off)>; |
| 1398 | |
| 1399 | def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off), |
| 1400 | (TCRETURNdi64 texternalsym:$dst, imm:$off)>; |
| 1401 | |
| 1402 | def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off), |
| 1403 | (TCRETURNdi64 texternalsym:$dst, imm:$off)>; |
| 1404 | |
Dan Gohman | ec59604 | 2007-09-17 14:35:24 +0000 | [diff] [blame] | 1405 | // Comparisons. |
| 1406 | |
| 1407 | // TEST R,R is smaller than CMP R,0 |
Evan Cheng | 621216e | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1408 | def : Pat<(parallel (X86cmp GR64:$src1, 0), (implicit EFLAGS)), |
Dan Gohman | ec59604 | 2007-09-17 14:35:24 +0000 | [diff] [blame] | 1409 | (TEST64rr GR64:$src1, GR64:$src1)>; |
| 1410 | |
Dan Gohman | 0a3c522 | 2009-01-07 01:00:24 +0000 | [diff] [blame] | 1411 | // Conditional moves with folded loads with operands swapped and conditions |
| 1412 | // inverted. |
| 1413 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_B, EFLAGS), |
| 1414 | (CMOVAE64rm GR64:$src2, addr:$src1)>; |
| 1415 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_AE, EFLAGS), |
| 1416 | (CMOVB64rm GR64:$src2, addr:$src1)>; |
| 1417 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_E, EFLAGS), |
| 1418 | (CMOVNE64rm GR64:$src2, addr:$src1)>; |
| 1419 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NE, EFLAGS), |
| 1420 | (CMOVE64rm GR64:$src2, addr:$src1)>; |
| 1421 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_BE, EFLAGS), |
| 1422 | (CMOVA64rm GR64:$src2, addr:$src1)>; |
| 1423 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_A, EFLAGS), |
| 1424 | (CMOVBE64rm GR64:$src2, addr:$src1)>; |
| 1425 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_L, EFLAGS), |
| 1426 | (CMOVGE64rm GR64:$src2, addr:$src1)>; |
| 1427 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_GE, EFLAGS), |
| 1428 | (CMOVL64rm GR64:$src2, addr:$src1)>; |
| 1429 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_LE, EFLAGS), |
| 1430 | (CMOVG64rm GR64:$src2, addr:$src1)>; |
| 1431 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_G, EFLAGS), |
| 1432 | (CMOVLE64rm GR64:$src2, addr:$src1)>; |
| 1433 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_P, EFLAGS), |
| 1434 | (CMOVNP64rm GR64:$src2, addr:$src1)>; |
| 1435 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NP, EFLAGS), |
| 1436 | (CMOVP64rm GR64:$src2, addr:$src1)>; |
| 1437 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_S, EFLAGS), |
| 1438 | (CMOVNS64rm GR64:$src2, addr:$src1)>; |
| 1439 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NS, EFLAGS), |
| 1440 | (CMOVS64rm GR64:$src2, addr:$src1)>; |
| 1441 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_O, EFLAGS), |
| 1442 | (CMOVNO64rm GR64:$src2, addr:$src1)>; |
| 1443 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NO, EFLAGS), |
| 1444 | (CMOVO64rm GR64:$src2, addr:$src1)>; |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1445 | |
| 1446 | // Zero-extension |
Christopher Lamb | 76d72da | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 1447 | def : Pat<(i64 (zext GR32:$src)), |
| 1448 | (SUBREG_TO_REG (i64 0), GR32:$src, x86_subreg_32bit)>; |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1449 | |
Duncan Sands | 082524c | 2008-01-23 20:39:46 +0000 | [diff] [blame] | 1450 | // zextload bool -> zextload byte |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1451 | def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1452 | |
| 1453 | // extload |
Dan Gohman | ab460da | 2008-08-27 17:33:15 +0000 | [diff] [blame] | 1454 | // When extloading from 16-bit and smaller memory locations into 64-bit registers, |
| 1455 | // use zero-extending loads so that the entire 64-bit register is defined, avoiding |
| 1456 | // partial-register updates. |
| 1457 | def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1458 | def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1459 | def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>; |
| 1460 | // For other extloads, use subregs, since the high contents of the register are |
| 1461 | // defined after an extload. |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1462 | def : Pat<(extloadi64i32 addr:$src), |
| 1463 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (MOV32rm addr:$src), |
| 1464 | x86_subreg_32bit)>; |
| 1465 | def : Pat<(extloadi16i1 addr:$src), |
| 1466 | (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src), |
| 1467 | x86_subreg_8bit)>, |
| 1468 | Requires<[In64BitMode]>; |
| 1469 | def : Pat<(extloadi16i8 addr:$src), |
| 1470 | (INSERT_SUBREG (i16 (IMPLICIT_DEF)), (MOV8rm addr:$src), |
| 1471 | x86_subreg_8bit)>, |
| 1472 | Requires<[In64BitMode]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1473 | |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1474 | // anyext |
| 1475 | def : Pat<(i64 (anyext GR8:$src)), |
| 1476 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>; |
| 1477 | def : Pat<(i64 (anyext GR16:$src)), |
| 1478 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR16:$src, x86_subreg_16bit)>; |
Christopher Lamb | 76d72da | 2008-03-16 03:12:01 +0000 | [diff] [blame] | 1479 | def : Pat<(i64 (anyext GR32:$src)), |
| 1480 | (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GR32:$src, x86_subreg_32bit)>; |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1481 | def : Pat<(i16 (anyext GR8:$src)), |
| 1482 | (INSERT_SUBREG (i16 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>, |
| 1483 | Requires<[In64BitMode]>; |
| 1484 | def : Pat<(i32 (anyext GR8:$src)), |
| 1485 | (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR8:$src, x86_subreg_8bit)>, |
| 1486 | Requires<[In64BitMode]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1487 | |
| 1488 | //===----------------------------------------------------------------------===// |
| 1489 | // Some peepholes |
| 1490 | //===----------------------------------------------------------------------===// |
| 1491 | |
Dan Gohman | 5a5e6e9 | 2008-10-17 01:33:43 +0000 | [diff] [blame] | 1492 | // Odd encoding trick: -128 fits into an 8-bit immediate field while |
| 1493 | // +128 doesn't, so in this special case use a sub instead of an add. |
| 1494 | def : Pat<(add GR64:$src1, 128), |
| 1495 | (SUB64ri8 GR64:$src1, -128)>; |
| 1496 | def : Pat<(store (add (loadi64 addr:$dst), 128), addr:$dst), |
| 1497 | (SUB64mi8 addr:$dst, -128)>; |
| 1498 | |
| 1499 | // The same trick applies for 32-bit immediate fields in 64-bit |
| 1500 | // instructions. |
| 1501 | def : Pat<(add GR64:$src1, 0x0000000080000000), |
| 1502 | (SUB64ri32 GR64:$src1, 0xffffffff80000000)>; |
| 1503 | def : Pat<(store (add (loadi64 addr:$dst), 0x00000000800000000), addr:$dst), |
| 1504 | (SUB64mi32 addr:$dst, 0xffffffff80000000)>; |
| 1505 | |
Dan Gohman | 47a419d | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 1506 | // r & (2^32-1) ==> movz |
Dan Gohman | 5a5e6e9 | 2008-10-17 01:33:43 +0000 | [diff] [blame] | 1507 | def : Pat<(and GR64:$src, 0x00000000FFFFFFFF), |
Dan Gohman | 47a419d | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 1508 | (MOVZX64rr32 (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)))>; |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1509 | // r & (2^16-1) ==> movz |
| 1510 | def : Pat<(and GR64:$src, 0xffff), |
| 1511 | (MOVZX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>; |
| 1512 | // r & (2^8-1) ==> movz |
| 1513 | def : Pat<(and GR64:$src, 0xff), |
| 1514 | (MOVZX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>; |
Dan Gohman | 9203ab4 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 1515 | // r & (2^8-1) ==> movz |
| 1516 | def : Pat<(and GR32:$src1, 0xff), |
| 1517 | (MOVZX32rr8 (i8 (EXTRACT_SUBREG GR32:$src1, x86_subreg_8bit)))>, |
| 1518 | Requires<[In64BitMode]>; |
| 1519 | // r & (2^8-1) ==> movz |
| 1520 | def : Pat<(and GR16:$src1, 0xff), |
| 1521 | (MOVZX16rr8 (i8 (EXTRACT_SUBREG GR16:$src1, x86_subreg_8bit)))>, |
| 1522 | Requires<[In64BitMode]>; |
Christopher Lamb | b371e03 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1523 | |
Dan Gohman | dd612bb | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1524 | // sext_inreg patterns |
| 1525 | def : Pat<(sext_inreg GR64:$src, i32), |
| 1526 | (MOVSX64rr32 (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)))>; |
| 1527 | def : Pat<(sext_inreg GR64:$src, i16), |
| 1528 | (MOVSX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>; |
| 1529 | def : Pat<(sext_inreg GR64:$src, i8), |
| 1530 | (MOVSX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>; |
| 1531 | def : Pat<(sext_inreg GR32:$src, i8), |
| 1532 | (MOVSX32rr8 (i8 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit)))>, |
| 1533 | Requires<[In64BitMode]>; |
| 1534 | def : Pat<(sext_inreg GR16:$src, i8), |
| 1535 | (MOVSX16rr8 (i8 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit)))>, |
| 1536 | Requires<[In64BitMode]>; |
| 1537 | |
| 1538 | // trunc patterns |
| 1539 | def : Pat<(i32 (trunc GR64:$src)), |
| 1540 | (i32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>; |
| 1541 | def : Pat<(i16 (trunc GR64:$src)), |
| 1542 | (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit))>; |
| 1543 | def : Pat<(i8 (trunc GR64:$src)), |
| 1544 | (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit))>; |
| 1545 | def : Pat<(i8 (trunc GR32:$src)), |
| 1546 | (i8 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit))>, |
| 1547 | Requires<[In64BitMode]>; |
| 1548 | def : Pat<(i8 (trunc GR16:$src)), |
| 1549 | (i8 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit))>, |
| 1550 | Requires<[In64BitMode]>; |
| 1551 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1552 | // (shl x, 1) ==> (add x, x) |
| 1553 | def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>; |
| 1554 | |
Evan Cheng | 76a64c7 | 2008-08-30 02:03:58 +0000 | [diff] [blame] | 1555 | // (shl x (and y, 63)) ==> (shl x, y) |
| 1556 | def : Pat<(shl GR64:$src1, (and CL:$amt, 63)), |
| 1557 | (SHL64rCL GR64:$src1)>; |
| 1558 | def : Pat<(store (shl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst), |
| 1559 | (SHL64mCL addr:$dst)>; |
| 1560 | |
| 1561 | def : Pat<(srl GR64:$src1, (and CL:$amt, 63)), |
| 1562 | (SHR64rCL GR64:$src1)>; |
| 1563 | def : Pat<(store (srl (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst), |
| 1564 | (SHR64mCL addr:$dst)>; |
| 1565 | |
| 1566 | def : Pat<(sra GR64:$src1, (and CL:$amt, 63)), |
| 1567 | (SAR64rCL GR64:$src1)>; |
| 1568 | def : Pat<(store (sra (loadi64 addr:$dst), (and CL:$amt, 63)), addr:$dst), |
| 1569 | (SAR64mCL addr:$dst)>; |
| 1570 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1571 | // (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c) |
| 1572 | def : Pat<(or (srl GR64:$src1, CL:$amt), |
| 1573 | (shl GR64:$src2, (sub 64, CL:$amt))), |
| 1574 | (SHRD64rrCL GR64:$src1, GR64:$src2)>; |
| 1575 | |
| 1576 | def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt), |
| 1577 | (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst), |
| 1578 | (SHRD64mrCL addr:$dst, GR64:$src2)>; |
| 1579 | |
Dan Gohman | 921581d | 2008-10-17 01:23:35 +0000 | [diff] [blame] | 1580 | def : Pat<(or (srl GR64:$src1, (i8 (trunc RCX:$amt))), |
| 1581 | (shl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))), |
| 1582 | (SHRD64rrCL GR64:$src1, GR64:$src2)>; |
| 1583 | |
| 1584 | def : Pat<(store (or (srl (loadi64 addr:$dst), (i8 (trunc RCX:$amt))), |
| 1585 | (shl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))), |
| 1586 | addr:$dst), |
| 1587 | (SHRD64mrCL addr:$dst, GR64:$src2)>; |
| 1588 | |
| 1589 | def : Pat<(shrd GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm:$amt2)), |
| 1590 | (SHRD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>; |
| 1591 | |
| 1592 | def : Pat<(store (shrd (loadi64 addr:$dst), (i8 imm:$amt1), |
| 1593 | GR64:$src2, (i8 imm:$amt2)), addr:$dst), |
| 1594 | (SHRD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>; |
| 1595 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1596 | // (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c) |
| 1597 | def : Pat<(or (shl GR64:$src1, CL:$amt), |
| 1598 | (srl GR64:$src2, (sub 64, CL:$amt))), |
| 1599 | (SHLD64rrCL GR64:$src1, GR64:$src2)>; |
| 1600 | |
| 1601 | def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt), |
| 1602 | (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst), |
| 1603 | (SHLD64mrCL addr:$dst, GR64:$src2)>; |
| 1604 | |
Dan Gohman | 921581d | 2008-10-17 01:23:35 +0000 | [diff] [blame] | 1605 | def : Pat<(or (shl GR64:$src1, (i8 (trunc RCX:$amt))), |
| 1606 | (srl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))), |
| 1607 | (SHLD64rrCL GR64:$src1, GR64:$src2)>; |
| 1608 | |
| 1609 | def : Pat<(store (or (shl (loadi64 addr:$dst), (i8 (trunc RCX:$amt))), |
| 1610 | (srl GR64:$src2, (i8 (trunc (sub 64, RCX:$amt))))), |
| 1611 | addr:$dst), |
| 1612 | (SHLD64mrCL addr:$dst, GR64:$src2)>; |
| 1613 | |
| 1614 | def : Pat<(shld GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm:$amt2)), |
| 1615 | (SHLD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>; |
| 1616 | |
| 1617 | def : Pat<(store (shld (loadi64 addr:$dst), (i8 imm:$amt1), |
| 1618 | GR64:$src2, (i8 imm:$amt2)), addr:$dst), |
| 1619 | (SHLD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>; |
| 1620 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1621 | // X86 specific add which produces a flag. |
| 1622 | def : Pat<(addc GR64:$src1, GR64:$src2), |
| 1623 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 1624 | def : Pat<(addc GR64:$src1, (load addr:$src2)), |
| 1625 | (ADD64rm GR64:$src1, addr:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1626 | def : Pat<(addc GR64:$src1, i64immSExt8:$src2), |
| 1627 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1628 | def : Pat<(addc GR64:$src1, i64immSExt32:$src2), |
| 1629 | (ADD64ri32 GR64:$src1, imm:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1630 | |
| 1631 | def : Pat<(subc GR64:$src1, GR64:$src2), |
| 1632 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 1633 | def : Pat<(subc GR64:$src1, (load addr:$src2)), |
| 1634 | (SUB64rm GR64:$src1, addr:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1635 | def : Pat<(subc GR64:$src1, i64immSExt8:$src2), |
| 1636 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1637 | def : Pat<(subc GR64:$src1, imm:$src2), |
| 1638 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1639 | |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1640 | //===----------------------------------------------------------------------===// |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1641 | // EFLAGS-defining Patterns |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1642 | //===----------------------------------------------------------------------===// |
| 1643 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1644 | // Register-Register Addition with EFLAGS result |
| 1645 | def : Pat<(parallel (X86add_flag GR64:$src1, GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1646 | (implicit EFLAGS)), |
| 1647 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 1648 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1649 | // Register-Integer Addition with EFLAGS result |
| 1650 | def : Pat<(parallel (X86add_flag GR64:$src1, i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1651 | (implicit EFLAGS)), |
| 1652 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1653 | def : Pat<(parallel (X86add_flag GR64:$src1, i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1654 | (implicit EFLAGS)), |
| 1655 | (ADD64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1656 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1657 | // Register-Memory Addition with EFLAGS result |
| 1658 | def : Pat<(parallel (X86add_flag GR64:$src1, (loadi64 addr:$src2)), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1659 | (implicit EFLAGS)), |
| 1660 | (ADD64rm GR64:$src1, addr:$src2)>; |
| 1661 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1662 | // Memory-Register Addition with EFLAGS result |
| 1663 | def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1664 | addr:$dst), |
| 1665 | (implicit EFLAGS)), |
| 1666 | (ADD64mr addr:$dst, GR64:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1667 | def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1668 | addr:$dst), |
| 1669 | (implicit EFLAGS)), |
| 1670 | (ADD64mi8 addr:$dst, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1671 | def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1672 | addr:$dst), |
| 1673 | (implicit EFLAGS)), |
| 1674 | (ADD64mi32 addr:$dst, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1675 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1676 | // Register-Register Subtraction with EFLAGS result |
| 1677 | def : Pat<(parallel (X86sub_flag GR64:$src1, GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1678 | (implicit EFLAGS)), |
| 1679 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 1680 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1681 | // Register-Memory Subtraction with EFLAGS result |
| 1682 | def : Pat<(parallel (X86sub_flag GR64:$src1, (loadi64 addr:$src2)), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1683 | (implicit EFLAGS)), |
| 1684 | (SUB64rm GR64:$src1, addr:$src2)>; |
| 1685 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1686 | // Register-Integer Subtraction with EFLAGS result |
| 1687 | def : Pat<(parallel (X86sub_flag GR64:$src1, i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1688 | (implicit EFLAGS)), |
| 1689 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1690 | def : Pat<(parallel (X86sub_flag GR64:$src1, i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1691 | (implicit EFLAGS)), |
| 1692 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1693 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1694 | // Memory-Register Subtraction with EFLAGS result |
| 1695 | def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1696 | addr:$dst), |
| 1697 | (implicit EFLAGS)), |
| 1698 | (SUB64mr addr:$dst, GR64:$src2)>; |
| 1699 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1700 | // Memory-Integer Subtraction with EFLAGS result |
| 1701 | def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1702 | addr:$dst), |
| 1703 | (implicit EFLAGS)), |
| 1704 | (SUB64mi8 addr:$dst, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1705 | def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1706 | addr:$dst), |
| 1707 | (implicit EFLAGS)), |
| 1708 | (SUB64mi32 addr:$dst, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1709 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1710 | // Register-Register Signed Integer Multiplication with EFLAGS result |
| 1711 | def : Pat<(parallel (X86smul_flag GR64:$src1, GR64:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1712 | (implicit EFLAGS)), |
| 1713 | (IMUL64rr GR64:$src1, GR64:$src2)>; |
| 1714 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1715 | // Register-Memory Signed Integer Multiplication with EFLAGS result |
| 1716 | def : Pat<(parallel (X86smul_flag GR64:$src1, (loadi64 addr:$src2)), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1717 | (implicit EFLAGS)), |
| 1718 | (IMUL64rm GR64:$src1, addr:$src2)>; |
| 1719 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1720 | // Register-Integer Signed Integer Multiplication with EFLAGS result |
| 1721 | def : Pat<(parallel (X86smul_flag GR64:$src1, i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1722 | (implicit EFLAGS)), |
| 1723 | (IMUL64rri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1724 | def : Pat<(parallel (X86smul_flag GR64:$src1, i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1725 | (implicit EFLAGS)), |
| 1726 | (IMUL64rri32 GR64:$src1, i64immSExt32:$src2)>; |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1727 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1728 | // Memory-Integer Signed Integer Multiplication with EFLAGS result |
| 1729 | def : Pat<(parallel (X86smul_flag (loadi64 addr:$src1), i64immSExt8:$src2), |
Bill Wendling | f539903 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 1730 | (implicit EFLAGS)), |
| 1731 | (IMUL64rmi8 addr:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1732 | def : Pat<(parallel (X86smul_flag (loadi64 addr:$src1), i64immSExt32:$src2), |
Dan Gohman | d16fdc0 | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1733 | (implicit EFLAGS)), |
| 1734 | (IMUL64rmi32 addr:$src1, i64immSExt32:$src2)>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1735 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1736 | // 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] | 1737 | def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)), |
| 1738 | (INC64_16r GR16:$src)>, Requires<[In64BitMode]>; |
| 1739 | def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst), |
| 1740 | (implicit EFLAGS)), |
| 1741 | (INC64_16m addr:$dst)>, Requires<[In64BitMode]>; |
| 1742 | def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)), |
| 1743 | (DEC64_16r GR16:$src)>, Requires<[In64BitMode]>; |
| 1744 | def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst), |
| 1745 | (implicit EFLAGS)), |
| 1746 | (DEC64_16m addr:$dst)>, Requires<[In64BitMode]>; |
| 1747 | |
| 1748 | def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)), |
| 1749 | (INC64_32r GR32:$src)>, Requires<[In64BitMode]>; |
| 1750 | def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst), |
| 1751 | (implicit EFLAGS)), |
| 1752 | (INC64_32m addr:$dst)>, Requires<[In64BitMode]>; |
| 1753 | def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)), |
| 1754 | (DEC64_32r GR32:$src)>, Requires<[In64BitMode]>; |
| 1755 | def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst), |
| 1756 | (implicit EFLAGS)), |
| 1757 | (DEC64_32m addr:$dst)>, Requires<[In64BitMode]>; |
| 1758 | |
Dan Gohman | 99a1219 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 1759 | def : Pat<(parallel (X86inc_flag GR64:$src), (implicit EFLAGS)), |
| 1760 | (INC64r GR64:$src)>; |
| 1761 | def : Pat<(parallel (store (i64 (X86inc_flag (loadi64 addr:$dst))), addr:$dst), |
| 1762 | (implicit EFLAGS)), |
| 1763 | (INC64m addr:$dst)>; |
| 1764 | def : Pat<(parallel (X86dec_flag GR64:$src), (implicit EFLAGS)), |
| 1765 | (DEC64r GR64:$src)>; |
| 1766 | def : Pat<(parallel (store (i64 (X86dec_flag (loadi64 addr:$dst))), addr:$dst), |
| 1767 | (implicit EFLAGS)), |
| 1768 | (DEC64m addr:$dst)>; |
| 1769 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1770 | //===----------------------------------------------------------------------===// |
| 1771 | // X86-64 SSE Instructions |
| 1772 | //===----------------------------------------------------------------------===// |
| 1773 | |
| 1774 | // Move instructions... |
| 1775 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1776 | def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1777 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1778 | [(set VR128:$dst, |
| 1779 | (v2i64 (scalar_to_vector GR64:$src)))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1780 | def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1781 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1782 | [(set GR64:$dst, (vector_extract (v2i64 VR128:$src), |
| 1783 | (iPTR 0)))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1784 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1785 | def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1786 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1787 | [(set FR64:$dst, (bitconvert GR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1788 | def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Evan Cheng | 69ca4da | 2008-08-25 04:11:42 +0000 | [diff] [blame] | 1789 | "movq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1790 | [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>; |
| 1791 | |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1792 | def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | 91888f0 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1793 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1794 | [(set GR64:$dst, (bitconvert FR64:$src))]>; |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1795 | def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src), |
Evan Cheng | 69ca4da | 2008-08-25 04:11:42 +0000 | [diff] [blame] | 1796 | "movq\t{$src, $dst|$dst, $src}", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1797 | [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>; |
Nate Begeman | b297556 | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 1798 | |
| 1799 | //===----------------------------------------------------------------------===// |
| 1800 | // X86-64 SSE4.1 Instructions |
| 1801 | //===----------------------------------------------------------------------===// |
| 1802 | |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1803 | /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination |
| 1804 | multiclass SS41I_extract64<bits<8> opc, string OpcodeStr> { |
Nate Begeman | 0050ab5 | 2008-10-29 23:07:17 +0000 | [diff] [blame] | 1805 | def rr : SS4AIi8<opc, MRMDestReg, (outs GR64:$dst), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1806 | (ins VR128:$src1, i32i8imm:$src2), |
| 1807 | !strconcat(OpcodeStr, |
| 1808 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 1809 | [(set GR64:$dst, |
| 1810 | (extractelt (v2i64 VR128:$src1), imm:$src2))]>, OpSize, REX_W; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1811 | def mr : SS4AIi8<opc, MRMDestMem, (outs), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1812 | (ins i64mem:$dst, VR128:$src1, i32i8imm:$src2), |
| 1813 | !strconcat(OpcodeStr, |
| 1814 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 1815 | [(store (extractelt (v2i64 VR128:$src1), imm:$src2), |
| 1816 | addr:$dst)]>, OpSize, REX_W; |
| 1817 | } |
| 1818 | |
| 1819 | defm PEXTRQ : SS41I_extract64<0x16, "pextrq">; |
| 1820 | |
| 1821 | let isTwoAddress = 1 in { |
| 1822 | multiclass SS41I_insert64<bits<8> opc, string OpcodeStr> { |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1823 | def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1824 | (ins VR128:$src1, GR64:$src2, i32i8imm:$src3), |
| 1825 | !strconcat(OpcodeStr, |
| 1826 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
| 1827 | [(set VR128:$dst, |
| 1828 | (v2i64 (insertelt VR128:$src1, GR64:$src2, imm:$src3)))]>, |
| 1829 | OpSize, REX_W; |
Evan Cheng | 78d0061 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 1830 | def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst), |
Nate Begeman | 4294c1f | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 1831 | (ins VR128:$src1, i64mem:$src2, i32i8imm:$src3), |
| 1832 | !strconcat(OpcodeStr, |
| 1833 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
| 1834 | [(set VR128:$dst, |
| 1835 | (v2i64 (insertelt VR128:$src1, (loadi64 addr:$src2), |
| 1836 | imm:$src3)))]>, OpSize, REX_W; |
| 1837 | } |
| 1838 | } |
| 1839 | |
| 1840 | defm PINSRQ : SS41I_insert64<0x22, "pinsrq">; |