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