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