Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1 | //====- X86InstrX86-64.td - Describe the X86 Instruction Set ----*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the Evan Cheng and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 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 | //===----------------------------------------------------------------------===// |
| 17 | // Operand Definitions... |
| 18 | // |
| 19 | |
| 20 | // 64-bits but only 32 bits are significant. |
| 21 | def i64i32imm : Operand<i64>; |
| 22 | // 64-bits but only 8 bits are significant. |
| 23 | def i64i8imm : Operand<i64>; |
| 24 | |
| 25 | def lea64mem : Operand<i64> { |
| 26 | let PrintMethod = "printi64mem"; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 27 | let MIOperandInfo = (ops GR64, i8imm, GR64, i32imm); |
| 28 | } |
| 29 | |
| 30 | def lea64_32mem : Operand<i32> { |
| 31 | let PrintMethod = "printlea64_32mem"; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 32 | let MIOperandInfo = (ops GR32, i8imm, GR32, i32imm); |
| 33 | } |
| 34 | |
| 35 | //===----------------------------------------------------------------------===// |
| 36 | // Complex Pattern Definitions... |
| 37 | // |
| 38 | def lea64addr : ComplexPattern<i64, 4, "SelectLEAAddr", |
Evan Cheng | 19f2ffc | 2006-12-05 04:01:03 +0000 | [diff] [blame] | 39 | [add, mul, shl, or, frameindex, X86Wrapper], |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 40 | []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 41 | |
| 42 | //===----------------------------------------------------------------------===// |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 43 | // Pattern fragments... |
| 44 | // |
| 45 | |
| 46 | def i64immSExt32 : PatLeaf<(i64 imm), [{ |
| 47 | // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit |
| 48 | // sign extended field. |
| 49 | return (int64_t)N->getValue() == (int32_t)N->getValue(); |
| 50 | }]>; |
| 51 | |
| 52 | def i64immZExt32 : PatLeaf<(i64 imm), [{ |
| 53 | // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit |
| 54 | // unsignedsign extended field. |
| 55 | return (uint64_t)N->getValue() == (uint32_t)N->getValue(); |
| 56 | }]>; |
| 57 | |
| 58 | def i64immSExt8 : PatLeaf<(i64 imm), [{ |
| 59 | // i64immSExt8 predicate - True if the 64-bit immediate fits in a 8-bit |
| 60 | // sign extended field. |
| 61 | return (int64_t)N->getValue() == (int8_t)N->getValue(); |
| 62 | }]>; |
| 63 | |
Evan Cheng | 466685d | 2006-10-09 20:57:25 +0000 | [diff] [blame] | 64 | def sextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (sextloadi1 node:$ptr))>; |
| 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))>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 68 | |
Evan Cheng | 466685d | 2006-10-09 20:57:25 +0000 | [diff] [blame] | 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))>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 73 | |
Evan Cheng | 466685d | 2006-10-09 20:57:25 +0000 | [diff] [blame] | 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))>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 78 | |
| 79 | //===----------------------------------------------------------------------===// |
| 80 | // Instruction list... |
| 81 | // |
| 82 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 83 | def IMPLICIT_DEF_GR64 : I<0, Pseudo, (outs GR64:$dst), (ins), |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 84 | "#IMPLICIT_DEF $dst", |
| 85 | [(set GR64:$dst, (undef))]>; |
| 86 | |
| 87 | //===----------------------------------------------------------------------===// |
| 88 | // Call Instructions... |
| 89 | // |
Evan Cheng | ffbacca | 2007-07-21 00:34:19 +0000 | [diff] [blame] | 90 | let isCall = 1 in |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 91 | // All calls clobber the non-callee saved registers... |
| 92 | let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, |
| 93 | FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, |
Bill Wendling | bff35d1 | 2007-04-26 21:06:48 +0000 | [diff] [blame] | 94 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 95 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, |
| 96 | XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15] in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 97 | def CALL64pcrel32 : I<0xE8, RawFrm, (outs), (ins i64imm:$dst, variable_ops), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 98 | "call\t${dst:call}", []>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 99 | def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 100 | "call\t{*}$dst", [(X86call GR64:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 101 | def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 102 | "call\t{*}$dst", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | // Branches |
Evan Cheng | ffbacca | 2007-07-21 00:34:19 +0000 | [diff] [blame] | 106 | let isBranch = 1, isTerminator = 1, isBarrier = 1 in { |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 107 | def JMP64r : I<0xFF, MRM4r, (outs), (ins GR64:$dst), "jmp{q}\t{*}$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 108 | [(brind GR64:$dst)]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 109 | def JMP64m : I<0xFF, MRM4m, (outs), (ins i64mem:$dst), "jmp{q}\t{*}$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 110 | [(brind (loadi64 addr:$dst))]>; |
| 111 | } |
| 112 | |
| 113 | //===----------------------------------------------------------------------===// |
| 114 | // Miscellaneous Instructions... |
| 115 | // |
| 116 | def LEAVE64 : I<0xC9, RawFrm, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 117 | (outs), (ins), "leave", []>, Imp<[RBP,RSP],[RBP,RSP]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 118 | def POP64r : I<0x58, AddRegFrm, |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 119 | (outs GR64:$reg), (ins), "pop{q}\t$reg", []>, Imp<[RSP],[RSP]>; |
Dan Gohman | 638c96d | 2007-06-18 14:12:56 +0000 | [diff] [blame] | 120 | def PUSH64r : I<0x50, AddRegFrm, |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 121 | (outs), (ins GR64:$reg), "push{q}\t$reg", []>, Imp<[RSP],[RSP]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 122 | |
| 123 | def LEA64_32r : I<0x8D, MRMSrcMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 124 | (outs GR32:$dst), (ins lea64_32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 125 | "lea{l}\t{$src|$dst}, {$dst|$src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 126 | [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>; |
| 127 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 128 | def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 129 | "lea{q}\t{$src|$dst}, {$dst|$src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 130 | [(set GR64:$dst, lea64addr:$src)]>; |
| 131 | |
| 132 | let isTwoAddress = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 133 | def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 134 | "bswap{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 135 | [(set GR64:$dst, (bswap GR64:$src))]>, TB; |
| 136 | // Exchange |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 137 | def XCHG64rr : RI<0x87, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 138 | "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 139 | def XCHG64mr : RI<0x87, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 140 | "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 141 | def XCHG64rm : RI<0x87, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 142 | "xchg{q}\t{$src2|$src1}, {$src1|$src2}", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 143 | |
| 144 | // Repeat string ops |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 145 | def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 146 | [(X86rep_movs i64)]>, |
| 147 | Imp<[RCX,RDI,RSI], [RCX,RDI,RSI]>, REP; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 148 | def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 149 | [(X86rep_stos i64)]>, |
| 150 | Imp<[RAX,RCX,RDI], [RCX,RDI]>, REP; |
| 151 | |
| 152 | //===----------------------------------------------------------------------===// |
| 153 | // Move Instructions... |
| 154 | // |
| 155 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 156 | def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 157 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 158 | |
Dan Gohman | 1ab7989 | 2007-09-07 21:32:51 +0000 | [diff] [blame] | 159 | let isReMaterializable = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 160 | def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 161 | "movabs{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 162 | [(set GR64:$dst, imm:$src)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 163 | def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 164 | "mov{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 165 | [(set GR64:$dst, i64immSExt32:$src)]>; |
Dan Gohman | 1ab7989 | 2007-09-07 21:32:51 +0000 | [diff] [blame] | 166 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 167 | |
Evan Cheng | 2f39426 | 2007-08-30 05:49:43 +0000 | [diff] [blame] | 168 | let isLoad = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 169 | def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 170 | "mov{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 171 | [(set GR64:$dst, (load addr:$src))]>; |
| 172 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 173 | def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 174 | "mov{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 175 | [(store GR64:$src, addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 176 | def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 177 | "mov{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 178 | [(store i64immSExt32:$src, addr:$dst)]>; |
| 179 | |
| 180 | // Sign/Zero extenders |
| 181 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 182 | def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 183 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 184 | [(set GR64:$dst, (sext GR8:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 185 | def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 186 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 187 | [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 188 | def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 189 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 190 | [(set GR64:$dst, (sext GR16:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 191 | def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 192 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 193 | [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 194 | def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 195 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 196 | [(set GR64:$dst, (sext GR32:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 197 | def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 198 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 199 | [(set GR64:$dst, (sextloadi64i32 addr:$src))]>; |
| 200 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 201 | def MOVZX64rr8 : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 202 | "movz{bq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 203 | [(set GR64:$dst, (zext GR8:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 204 | def MOVZX64rm8 : RI<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 205 | "movz{bq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 206 | [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 207 | def MOVZX64rr16: RI<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 208 | "movz{wq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 209 | [(set GR64:$dst, (zext GR16:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 210 | def MOVZX64rm16: RI<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 211 | "movz{wq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 212 | [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB; |
| 213 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 214 | def CDQE : RI<0x98, RawFrm, (outs), (ins), |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 215 | "{cltq|cdqe}", []>, Imp<[EAX],[RAX]>; // RAX = signext(EAX) |
| 216 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 217 | def CQO : RI<0x99, RawFrm, (outs), (ins), |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 218 | "{cqto|cqo}", []>, Imp<[RAX],[RAX,RDX]>; // RDX:RAX = signext(RAX) |
| 219 | |
| 220 | //===----------------------------------------------------------------------===// |
| 221 | // Arithmetic Instructions... |
| 222 | // |
| 223 | |
| 224 | let isTwoAddress = 1 in { |
| 225 | let isConvertibleToThreeAddress = 1 in { |
| 226 | let isCommutable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 227 | def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 228 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 229 | [(set GR64:$dst, (add GR64:$src1, GR64:$src2))]>; |
| 230 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 231 | def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 232 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 233 | [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 234 | def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 235 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 236 | [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2))]>; |
| 237 | } // isConvertibleToThreeAddress |
| 238 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 239 | def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 240 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 241 | [(set GR64:$dst, (add GR64:$src1, (load addr:$src2)))]>; |
| 242 | } // isTwoAddress |
| 243 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 244 | def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 245 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 246 | [(store (add (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 247 | def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 248 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 249 | [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 250 | def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 251 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 252 | [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
| 253 | |
| 254 | let isTwoAddress = 1 in { |
| 255 | let isCommutable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 256 | def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 257 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 258 | [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>; |
| 259 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 260 | def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 261 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 262 | [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>; |
| 263 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 264 | def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 265 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 266 | [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 267 | def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 268 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 269 | [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>; |
| 270 | } // isTwoAddress |
| 271 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 272 | def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 273 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 274 | [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 275 | def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 276 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 277 | [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 278 | def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 279 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 280 | [(store (adde (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
| 281 | |
| 282 | let isTwoAddress = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 283 | def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 284 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 285 | [(set GR64:$dst, (sub GR64:$src1, GR64:$src2))]>; |
| 286 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 287 | def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 288 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 289 | [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2)))]>; |
| 290 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 291 | def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 292 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 293 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 294 | def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 295 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 296 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2))]>; |
| 297 | } // isTwoAddress |
| 298 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 299 | def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 300 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 301 | [(store (sub (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 302 | def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 303 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 304 | [(store (sub (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 305 | def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 306 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 307 | [(store (sub (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
| 308 | |
| 309 | let isTwoAddress = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 310 | def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 311 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 312 | [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>; |
| 313 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 314 | def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 315 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 316 | [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>; |
| 317 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 318 | def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 319 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 320 | [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 321 | def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 322 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 323 | [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>; |
| 324 | } // isTwoAddress |
| 325 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 326 | def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 327 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 328 | [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 329 | def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 330 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 331 | [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 332 | def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 333 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 334 | [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
| 335 | |
| 336 | // Unsigned multiplication |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 337 | def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 338 | "mul{q}\t$src", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 339 | Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 340 | def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 341 | "mul{q}\t$src", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 342 | Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*[mem64] |
| 343 | |
| 344 | // Signed multiplication |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 345 | def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 346 | "imul{q}\t$src", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 347 | Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 348 | def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 349 | "imul{q}\t$src", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 350 | Imp<[RAX],[RAX,RDX]>; // RAX,RDX = RAX*[mem64] |
| 351 | |
| 352 | let isTwoAddress = 1 in { |
| 353 | let isCommutable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 354 | def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 355 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 356 | [(set GR64:$dst, (mul GR64:$src1, GR64:$src2))]>, TB; |
| 357 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 358 | def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 359 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 360 | [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2)))]>, TB; |
| 361 | } // isTwoAddress |
| 362 | |
| 363 | // Suprisingly enough, these are not two address instructions! |
| 364 | def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 365 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 366 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 367 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2))]>; |
| 368 | def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 369 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 370 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 371 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2))]>; |
| 372 | def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 373 | (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 374 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 375 | [(set GR64:$dst, (mul (load addr:$src1), i64immSExt32:$src2))]>; |
| 376 | def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 377 | (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 378 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 379 | [(set GR64:$dst, (mul (load addr:$src1), i64immSExt8:$src2))]>; |
| 380 | |
| 381 | // Unsigned division / remainder |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 382 | def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 383 | "div{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 384 | def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 385 | "div{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 386 | |
| 387 | // Signed division / remainder |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 388 | def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), // RDX:RAX/r64 = RAX,RDX |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 389 | "idiv{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 390 | def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), // RDX:RAX/[mem64] = RAX,RDX |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 391 | "idiv{q}\t$src", []>, Imp<[RAX,RDX],[RAX,RDX]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 392 | |
| 393 | // Unary instructions |
| 394 | let CodeSize = 2 in { |
| 395 | let isTwoAddress = 1 in |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 396 | def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 397 | [(set GR64:$dst, (ineg GR64:$src))]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 398 | def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 399 | [(store (ineg (loadi64 addr:$dst)), addr:$dst)]>; |
| 400 | |
| 401 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 402 | def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 403 | [(set GR64:$dst, (add GR64:$src, 1))]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 404 | def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 405 | [(store (add (loadi64 addr:$dst), 1), addr:$dst)]>; |
| 406 | |
| 407 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 408 | def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 409 | [(set GR64:$dst, (add GR64:$src, -1))]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 410 | def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 411 | [(store (add (loadi64 addr:$dst), -1), addr:$dst)]>; |
| 412 | |
| 413 | // In 64-bit mode, single byte INC and DEC cannot be encoded. |
| 414 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in { |
| 415 | // Can transform into LEA. |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 416 | def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), "inc{w}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 417 | [(set GR16:$dst, (add GR16:$src, 1))]>, |
| 418 | OpSize, Requires<[In64BitMode]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 419 | def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), "inc{l}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 420 | [(set GR32:$dst, (add GR32:$src, 1))]>, |
| 421 | Requires<[In64BitMode]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 422 | def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), "dec{w}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 423 | [(set GR16:$dst, (add GR16:$src, -1))]>, |
| 424 | OpSize, Requires<[In64BitMode]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 425 | def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), "dec{l}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 426 | [(set GR32:$dst, (add GR32:$src, -1))]>, |
| 427 | Requires<[In64BitMode]>; |
| 428 | } // isConvertibleToThreeAddress |
| 429 | } // CodeSize |
| 430 | |
| 431 | |
| 432 | // Shift instructions |
| 433 | let isTwoAddress = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 434 | def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 435 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 436 | [(set GR64:$dst, (shl GR64:$src, CL))]>, |
| 437 | Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 438 | def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 439 | "shl{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 440 | [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 441 | def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 442 | "shl{q}\t$dst", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 443 | } // isTwoAddress |
| 444 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 445 | def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 446 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 447 | [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>, |
| 448 | Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 449 | def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 450 | "shl{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 451 | [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 452 | def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 453 | "shl{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 454 | [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 455 | |
| 456 | let isTwoAddress = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 457 | def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 458 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 459 | [(set GR64:$dst, (srl GR64:$src, CL))]>, |
| 460 | Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 461 | def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 462 | "shr{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 463 | [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 464 | def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 465 | "shr{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 466 | [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>; |
| 467 | } // isTwoAddress |
| 468 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 469 | def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 470 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 471 | [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>, |
| 472 | Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 473 | def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 474 | "shr{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 475 | [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 476 | def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 477 | "shr{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 478 | [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 479 | |
| 480 | let isTwoAddress = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 481 | def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 482 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 483 | [(set GR64:$dst, (sra GR64:$src, CL))]>, Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 484 | def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 485 | "sar{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 486 | [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 487 | def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 488 | "sar{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 489 | [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>; |
| 490 | } // isTwoAddress |
| 491 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 492 | def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 493 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 494 | [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>, |
| 495 | Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 496 | def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 497 | "sar{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 498 | [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 499 | def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 500 | "sar{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 501 | [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 502 | |
| 503 | // Rotate instructions |
| 504 | let isTwoAddress = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 505 | def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 506 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 507 | [(set GR64:$dst, (rotl GR64:$src, CL))]>, Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 508 | def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 509 | "rol{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 510 | [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 511 | def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 512 | "rol{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 513 | [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>; |
| 514 | } // isTwoAddress |
| 515 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 516 | def ROL64mCL : I<0xD3, MRM0m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 517 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 518 | [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>, |
| 519 | Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 520 | def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 521 | "rol{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 522 | [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 523 | def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 524 | "rol{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 525 | [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 526 | |
| 527 | let isTwoAddress = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 528 | def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 529 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 530 | [(set GR64:$dst, (rotr GR64:$src, CL))]>, Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 531 | def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 532 | "ror{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 533 | [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 534 | def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 535 | "ror{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 536 | [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>; |
| 537 | } // isTwoAddress |
| 538 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 539 | def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 540 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 541 | [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>, |
| 542 | Imp<[CL],[]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 543 | def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 544 | "ror{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 545 | [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 546 | def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 547 | "ror{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 548 | [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 549 | |
| 550 | // Double shift instructions (generalizations of rotate) |
| 551 | let isTwoAddress = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 552 | def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 553 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 554 | Imp<[CL],[]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 555 | def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 556 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 557 | Imp<[CL],[]>, TB; |
| 558 | |
| 559 | let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction |
| 560 | def SHLD64rri8 : RIi8<0xA4, MRMDestReg, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 561 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 562 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 563 | TB; |
| 564 | def SHRD64rri8 : RIi8<0xAC, MRMDestReg, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 565 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 566 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 567 | TB; |
| 568 | } // isCommutable |
| 569 | } // isTwoAddress |
| 570 | |
| 571 | // Temporary hack: there is no patterns associated with these instructions |
| 572 | // so we have to tell tblgen that these do not produce results. |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 573 | def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 574 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 575 | Imp<[CL],[]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 576 | def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 577 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 578 | Imp<[CL],[]>, TB; |
| 579 | def SHLD64mri8 : RIi8<0xA4, MRMDestMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 580 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 581 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 582 | TB; |
| 583 | def SHRD64mri8 : RIi8<0xAC, MRMDestMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 584 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 585 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", []>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 586 | TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 587 | |
| 588 | //===----------------------------------------------------------------------===// |
| 589 | // Logical Instructions... |
| 590 | // |
| 591 | |
| 592 | let isTwoAddress = 1 in |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 593 | def NOT64r : RI<0xF7, MRM2r, (outs GR64:$dst), (ins GR64:$src), "not{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 594 | [(set GR64:$dst, (not GR64:$src))]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 595 | def NOT64m : RI<0xF7, MRM2m, (outs), (ins i64mem:$dst), "not{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 596 | [(store (not (loadi64 addr:$dst)), addr:$dst)]>; |
| 597 | |
| 598 | let isTwoAddress = 1 in { |
| 599 | let isCommutable = 1 in |
| 600 | def AND64rr : RI<0x21, MRMDestReg, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 601 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 602 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 603 | [(set GR64:$dst, (and GR64:$src1, GR64:$src2))]>; |
| 604 | def AND64rm : RI<0x23, MRMSrcMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 605 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 606 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 607 | [(set GR64:$dst, (and GR64:$src1, (load addr:$src2)))]>; |
| 608 | def AND64ri32 : RIi32<0x81, MRM4r, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 609 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 610 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 611 | [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2))]>; |
| 612 | def AND64ri8 : RIi8<0x83, MRM4r, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 613 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 614 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 615 | [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2))]>; |
| 616 | } // isTwoAddress |
| 617 | |
| 618 | def AND64mr : RI<0x21, MRMDestMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 619 | (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 620 | "and{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 621 | [(store (and (load addr:$dst), GR64:$src), addr:$dst)]>; |
| 622 | def AND64mi32 : RIi32<0x81, MRM4m, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 623 | (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 624 | "and{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 625 | [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>; |
| 626 | def AND64mi8 : RIi8<0x83, MRM4m, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 627 | (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 628 | "and{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 629 | [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst)]>; |
| 630 | |
| 631 | let isTwoAddress = 1 in { |
| 632 | let isCommutable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 633 | def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 634 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 635 | [(set GR64:$dst, (or GR64:$src1, GR64:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 636 | def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 637 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 638 | [(set GR64:$dst, (or GR64:$src1, (load addr:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 639 | def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 640 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 641 | [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 642 | def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 643 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 644 | [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2))]>; |
| 645 | } // isTwoAddress |
| 646 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 647 | def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 648 | "or{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 649 | [(store (or (load addr:$dst), GR64:$src), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 650 | def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 651 | "or{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 652 | [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 653 | def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 654 | "or{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 655 | [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst)]>; |
| 656 | |
| 657 | let isTwoAddress = 1 in { |
| 658 | let isCommutable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 659 | def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 660 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 661 | [(set GR64:$dst, (xor GR64:$src1, GR64:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 662 | def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 663 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 664 | [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2)))]>; |
| 665 | def XOR64ri32 : RIi32<0x81, MRM6r, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 666 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 667 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 668 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 669 | def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 670 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 671 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2))]>; |
| 672 | } // isTwoAddress |
| 673 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 674 | def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 675 | "xor{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 676 | [(store (xor (load addr:$dst), GR64:$src), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 677 | def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 678 | "xor{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 679 | [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 680 | def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 681 | "xor{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 682 | [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst)]>; |
| 683 | |
| 684 | //===----------------------------------------------------------------------===// |
| 685 | // Comparison Instructions... |
| 686 | // |
| 687 | |
| 688 | // Integer comparison |
| 689 | let isCommutable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 690 | def TEST64rr : RI<0x85, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 691 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 692 | [(X86cmp (and GR64:$src1, GR64:$src2), 0)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 693 | def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 694 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 734503b | 2006-09-11 02:19:56 +0000 | [diff] [blame] | 695 | [(X86cmp (and GR64:$src1, (loadi64 addr:$src2)), 0)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 696 | def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 697 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 698 | [(X86cmp (and GR64:$src1, i64immSExt32:$src2), 0)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 699 | def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), (ins i64mem:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 700 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 734503b | 2006-09-11 02:19:56 +0000 | [diff] [blame] | 701 | [(X86cmp (and (loadi64 addr:$src1), i64immSExt32:$src2), 0)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 702 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 703 | def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 704 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 705 | [(X86cmp GR64:$src1, GR64:$src2)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 706 | def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 707 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 708 | [(X86cmp (loadi64 addr:$src1), GR64:$src2)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 709 | def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 710 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 711 | [(X86cmp GR64:$src1, (loadi64 addr:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 712 | def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 713 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 714 | [(X86cmp GR64:$src1, i64immSExt32:$src2)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 715 | def CMP64mi32 : RIi32<0x81, MRM7m, (outs), (ins i64mem:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 716 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 717 | [(X86cmp (loadi64 addr:$src1), i64immSExt32:$src2)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 718 | def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 719 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 720 | [(X86cmp (loadi64 addr:$src1), i64immSExt8:$src2)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 721 | def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 722 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 723 | [(X86cmp GR64:$src1, i64immSExt8:$src2)]>; |
| 724 | |
| 725 | // Conditional moves |
| 726 | let isTwoAddress = 1 in { |
| 727 | def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 728 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 729 | "cmovb\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 730 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 731 | X86_COND_B))]>, TB; |
| 732 | def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 733 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 734 | "cmovb\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 735 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 736 | X86_COND_B))]>, TB; |
| 737 | def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 738 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 739 | "cmovae\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 740 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 741 | X86_COND_AE))]>, TB; |
| 742 | def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 743 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 744 | "cmovae\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 745 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 746 | X86_COND_AE))]>, TB; |
| 747 | def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 748 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 749 | "cmove\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 750 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 751 | X86_COND_E))]>, TB; |
| 752 | def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 753 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 754 | "cmove\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 755 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 756 | X86_COND_E))]>, TB; |
| 757 | def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 758 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 759 | "cmovne\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 760 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 761 | X86_COND_NE))]>, TB; |
| 762 | def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 763 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 764 | "cmovne\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 765 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 766 | X86_COND_NE))]>, TB; |
| 767 | def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 768 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 769 | "cmovbe\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 770 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 771 | X86_COND_BE))]>, TB; |
| 772 | def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 773 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 774 | "cmovbe\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 775 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 776 | X86_COND_BE))]>, TB; |
| 777 | def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 778 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 779 | "cmova\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 780 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 781 | X86_COND_A))]>, TB; |
| 782 | def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 783 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 784 | "cmova\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 785 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 786 | X86_COND_A))]>, TB; |
| 787 | def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 788 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 789 | "cmovl\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 790 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 791 | X86_COND_L))]>, TB; |
| 792 | def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 793 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 794 | "cmovl\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 795 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 796 | X86_COND_L))]>, TB; |
| 797 | def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 798 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 799 | "cmovge\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 800 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 801 | X86_COND_GE))]>, TB; |
| 802 | def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 803 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 804 | "cmovge\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 805 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 806 | X86_COND_GE))]>, TB; |
| 807 | def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 808 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 809 | "cmovle\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 810 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 811 | X86_COND_LE))]>, TB; |
| 812 | def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 813 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 814 | "cmovle\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 815 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 816 | X86_COND_LE))]>, TB; |
| 817 | def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 818 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 819 | "cmovg\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 820 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 821 | X86_COND_G))]>, TB; |
| 822 | def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 823 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 824 | "cmovg\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 825 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 826 | X86_COND_G))]>, TB; |
| 827 | def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 828 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 829 | "cmovs\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 830 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 831 | X86_COND_S))]>, TB; |
| 832 | def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 833 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 834 | "cmovs\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 835 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 836 | X86_COND_S))]>, TB; |
| 837 | def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 838 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 839 | "cmovns\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 840 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 841 | X86_COND_NS))]>, TB; |
| 842 | def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 843 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 844 | "cmovns\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 845 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 846 | X86_COND_NS))]>, TB; |
| 847 | def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 848 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 849 | "cmovp\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 850 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 851 | X86_COND_P))]>, TB; |
| 852 | def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 853 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 854 | "cmovp\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 855 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 856 | X86_COND_P))]>, TB; |
| 857 | def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 858 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 859 | "cmovnp\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 860 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 861 | X86_COND_NP))]>, TB; |
| 862 | def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 863 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 864 | "cmovnp\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 865 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 866 | X86_COND_NP))]>, TB; |
| 867 | } // isTwoAddress |
| 868 | |
| 869 | //===----------------------------------------------------------------------===// |
| 870 | // Conversion Instructions... |
| 871 | // |
| 872 | |
| 873 | // f64 -> signed i64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 874 | def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 875 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 876 | [(set GR64:$dst, |
| 877 | (int_x86_sse2_cvtsd2si64 VR128:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 878 | def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 879 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 880 | [(set GR64:$dst, (int_x86_sse2_cvtsd2si64 |
| 881 | (load addr:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 882 | def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 883 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 884 | [(set GR64:$dst, (fp_to_sint FR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 885 | def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 886 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 887 | [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 888 | def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 889 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 890 | [(set GR64:$dst, |
| 891 | (int_x86_sse2_cvttsd2si64 VR128:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 892 | def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f128mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 893 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 894 | [(set GR64:$dst, |
| 895 | (int_x86_sse2_cvttsd2si64 |
| 896 | (load addr:$src)))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 897 | |
| 898 | // Signed i64 -> f64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 899 | def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 900 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 901 | [(set FR64:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 902 | def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 903 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 904 | [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
| 905 | let isTwoAddress = 1 in { |
| 906 | def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 907 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 908 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 909 | [(set VR128:$dst, |
| 910 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 911 | GR64:$src2))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 912 | def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 913 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 914 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 915 | [(set VR128:$dst, |
| 916 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 917 | (loadi64 addr:$src2)))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 918 | } // isTwoAddress |
| 919 | |
| 920 | // Signed i64 -> f32 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 921 | def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 922 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 923 | [(set FR32:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 924 | def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 925 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 926 | [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
| 927 | let isTwoAddress = 1 in { |
| 928 | def Int_CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 929 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 930 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 931 | []>; // TODO: add intrinsic |
| 932 | def Int_CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 933 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 934 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 935 | []>; // TODO: add intrinsic |
| 936 | } // isTwoAddress |
| 937 | |
| 938 | // f32 -> signed i64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 939 | def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 940 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 941 | [(set GR64:$dst, |
| 942 | (int_x86_sse_cvtss2si64 VR128:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 943 | def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 944 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 945 | [(set GR64:$dst, (int_x86_sse_cvtss2si64 |
| 946 | (load addr:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 947 | def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 948 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 949 | [(set GR64:$dst, (fp_to_sint FR32:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 950 | def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 951 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 952 | [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 953 | def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 954 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 955 | [(set GR64:$dst, |
| 956 | (int_x86_sse_cvttss2si64 VR128:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 957 | def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 958 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 959 | [(set GR64:$dst, |
| 960 | (int_x86_sse_cvttss2si64 (load addr:$src)))]>; |
| 961 | |
| 962 | let isTwoAddress = 1 in { |
| 963 | def Int_CVTSI642SSrr : RSSI<0x2A, MRMSrcReg, |
| 964 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 965 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 966 | [(set VR128:$dst, |
| 967 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 968 | GR64:$src2))]>; |
| 969 | def Int_CVTSI642SSrm : RSSI<0x2A, MRMSrcMem, |
| 970 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 971 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 972 | [(set VR128:$dst, |
| 973 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 974 | (loadi64 addr:$src2)))]>; |
| 975 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 976 | |
| 977 | //===----------------------------------------------------------------------===// |
| 978 | // Alias Instructions |
| 979 | //===----------------------------------------------------------------------===// |
| 980 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 981 | // Zero-extension |
| 982 | // TODO: Remove this after proper i32 -> i64 zext support. |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 983 | def PsMOVZX64rr32: I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 984 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 985 | [(set GR64:$dst, (zext GR32:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 986 | def PsMOVZX64rm32: I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 987 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 988 | [(set GR64:$dst, (zextloadi64i32 addr:$src))]>; |
| 989 | |
| 990 | |
| 991 | // Alias instructions that map movr0 to xor. |
| 992 | // FIXME: remove when we can teach regalloc that xor reg, reg is ok. |
| 993 | // FIXME: AddedComplexity gives MOV64r0 a higher priority than MOV64ri32. Remove |
| 994 | // when we have a better way to specify isel priority. |
Dan Gohman | 1ab7989 | 2007-09-07 21:32:51 +0000 | [diff] [blame] | 995 | let AddedComplexity = 1, isReMaterializable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 996 | def MOV64r0 : RI<0x31, MRMInitReg, (outs GR64:$dst), (ins), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 997 | "xor{q}\t$dst, $dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 998 | [(set GR64:$dst, 0)]>; |
| 999 | |
| 1000 | // Materialize i64 constant where top 32-bits are zero. |
Dan Gohman | 1ab7989 | 2007-09-07 21:32:51 +0000 | [diff] [blame] | 1001 | let AddedComplexity = 1, isReMaterializable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1002 | def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1003 | "mov{l}\t{$src, ${dst:subreg32}|${dst:subreg32}, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1004 | [(set GR64:$dst, i64immZExt32:$src)]>; |
| 1005 | |
| 1006 | //===----------------------------------------------------------------------===// |
| 1007 | // Non-Instruction Patterns |
| 1008 | //===----------------------------------------------------------------------===// |
| 1009 | |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1010 | // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable |
| 1011 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1012 | (MOV64ri tconstpool :$dst)>, Requires<[NotSmallCode]>; |
| 1013 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
| 1014 | (MOV64ri tjumptable :$dst)>, Requires<[NotSmallCode]>; |
| 1015 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
| 1016 | (MOV64ri tglobaladdr :$dst)>, Requires<[NotSmallCode]>; |
| 1017 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
| 1018 | (MOV64ri texternalsym:$dst)>, Requires<[NotSmallCode]>; |
| 1019 | |
Evan Cheng | 28b51439 | 2006-12-05 19:50:18 +0000 | [diff] [blame] | 1020 | def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst), |
| 1021 | (MOV64mi32 addr:$dst, tconstpool:$src)>, |
Evan Cheng | 0db079e | 2007-08-01 23:46:10 +0000 | [diff] [blame] | 1022 | Requires<[SmallCode, HasLow4G, IsStatic]>; |
Evan Cheng | 28b51439 | 2006-12-05 19:50:18 +0000 | [diff] [blame] | 1023 | def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst), |
| 1024 | (MOV64mi32 addr:$dst, tjumptable:$src)>, |
Evan Cheng | 0db079e | 2007-08-01 23:46:10 +0000 | [diff] [blame] | 1025 | Requires<[SmallCode, HasLow4G, IsStatic]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1026 | def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst), |
Evan Cheng | 28b51439 | 2006-12-05 19:50:18 +0000 | [diff] [blame] | 1027 | (MOV64mi32 addr:$dst, tglobaladdr:$src)>, |
Evan Cheng | 0db079e | 2007-08-01 23:46:10 +0000 | [diff] [blame] | 1028 | Requires<[SmallCode, HasLow4G, IsStatic]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1029 | def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst), |
Evan Cheng | 28b51439 | 2006-12-05 19:50:18 +0000 | [diff] [blame] | 1030 | (MOV64mi32 addr:$dst, texternalsym:$src)>, |
Evan Cheng | 0db079e | 2007-08-01 23:46:10 +0000 | [diff] [blame] | 1031 | Requires<[SmallCode, HasLow4G, IsStatic]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1032 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1033 | // Calls |
| 1034 | // Direct PC relative function call for small code model. 32-bit displacement |
| 1035 | // sign extended to 64-bit. |
| 1036 | def : Pat<(X86call (i64 tglobaladdr:$dst)), |
| 1037 | (CALL64pcrel32 tglobaladdr:$dst)>; |
| 1038 | def : Pat<(X86call (i64 texternalsym:$dst)), |
| 1039 | (CALL64pcrel32 texternalsym:$dst)>; |
| 1040 | |
| 1041 | def : Pat<(X86tailcall (i64 tglobaladdr:$dst)), |
| 1042 | (CALL64pcrel32 tglobaladdr:$dst)>; |
| 1043 | def : Pat<(X86tailcall (i64 texternalsym:$dst)), |
| 1044 | (CALL64pcrel32 texternalsym:$dst)>; |
| 1045 | |
| 1046 | def : Pat<(X86tailcall GR64:$dst), |
| 1047 | (CALL64r GR64:$dst)>; |
| 1048 | |
| 1049 | // {s|z}extload bool -> {s|z}extload byte |
| 1050 | def : Pat<(sextloadi64i1 addr:$src), (MOVSX64rm8 addr:$src)>; |
| 1051 | def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1052 | |
| 1053 | // extload |
| 1054 | def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1055 | def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1056 | def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>; |
| 1057 | def : Pat<(extloadi64i32 addr:$src), (PsMOVZX64rm32 addr:$src)>; |
| 1058 | |
| 1059 | // anyext -> zext |
| 1060 | def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>; |
| 1061 | def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16:$src)>; |
| 1062 | def : Pat<(i64 (anyext GR32:$src)), (PsMOVZX64rr32 GR32:$src)>; |
| 1063 | def : Pat<(i64 (anyext (loadi8 addr:$src))), (MOVZX64rm8 addr:$src)>; |
| 1064 | def : Pat<(i64 (anyext (loadi16 addr:$src))), (MOVZX64rm16 addr:$src)>; |
| 1065 | def : Pat<(i64 (anyext (loadi32 addr:$src))), (PsMOVZX64rm32 addr:$src)>; |
| 1066 | |
| 1067 | //===----------------------------------------------------------------------===// |
| 1068 | // Some peepholes |
| 1069 | //===----------------------------------------------------------------------===// |
| 1070 | |
| 1071 | // (shl x, 1) ==> (add x, x) |
| 1072 | def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>; |
| 1073 | |
| 1074 | // (or (x >> c) | (y << (64 - c))) ==> (shrd64 x, y, c) |
| 1075 | def : Pat<(or (srl GR64:$src1, CL:$amt), |
| 1076 | (shl GR64:$src2, (sub 64, CL:$amt))), |
| 1077 | (SHRD64rrCL GR64:$src1, GR64:$src2)>; |
| 1078 | |
| 1079 | def : Pat<(store (or (srl (loadi64 addr:$dst), CL:$amt), |
| 1080 | (shl GR64:$src2, (sub 64, CL:$amt))), addr:$dst), |
| 1081 | (SHRD64mrCL addr:$dst, GR64:$src2)>; |
| 1082 | |
| 1083 | // (or (x << c) | (y >> (64 - c))) ==> (shld64 x, y, c) |
| 1084 | def : Pat<(or (shl GR64:$src1, CL:$amt), |
| 1085 | (srl GR64:$src2, (sub 64, CL:$amt))), |
| 1086 | (SHLD64rrCL GR64:$src1, GR64:$src2)>; |
| 1087 | |
| 1088 | def : Pat<(store (or (shl (loadi64 addr:$dst), CL:$amt), |
| 1089 | (srl GR64:$src2, (sub 64, CL:$amt))), addr:$dst), |
| 1090 | (SHLD64mrCL addr:$dst, GR64:$src2)>; |
Evan Cheng | ebf01d6 | 2006-11-16 23:33:25 +0000 | [diff] [blame] | 1091 | |
Chris Lattner | a066810 | 2007-05-17 06:35:11 +0000 | [diff] [blame] | 1092 | // X86 specific add which produces a flag. |
| 1093 | def : Pat<(addc GR64:$src1, GR64:$src2), |
| 1094 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 1095 | def : Pat<(addc GR64:$src1, (load addr:$src2)), |
| 1096 | (ADD64rm GR64:$src1, addr:$src2)>; |
| 1097 | def : Pat<(addc GR64:$src1, i64immSExt32:$src2), |
| 1098 | (ADD64ri32 GR64:$src1, imm:$src2)>; |
| 1099 | def : Pat<(addc GR64:$src1, i64immSExt8:$src2), |
| 1100 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1101 | |
| 1102 | def : Pat<(subc GR64:$src1, GR64:$src2), |
| 1103 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 1104 | def : Pat<(subc GR64:$src1, (load addr:$src2)), |
| 1105 | (SUB64rm GR64:$src1, addr:$src2)>; |
| 1106 | def : Pat<(subc GR64:$src1, imm:$src2), |
| 1107 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 1108 | def : Pat<(subc GR64:$src1, i64immSExt8:$src2), |
| 1109 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1110 | |
| 1111 | |
Evan Cheng | ebf01d6 | 2006-11-16 23:33:25 +0000 | [diff] [blame] | 1112 | //===----------------------------------------------------------------------===// |
| 1113 | // X86-64 SSE Instructions |
| 1114 | //===----------------------------------------------------------------------===// |
| 1115 | |
| 1116 | // Move instructions... |
| 1117 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1118 | def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1119 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | ebf01d6 | 2006-11-16 23:33:25 +0000 | [diff] [blame] | 1120 | [(set VR128:$dst, |
| 1121 | (v2i64 (scalar_to_vector GR64:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1122 | def MOV64toPQIrm : RPDI<0x6E, MRMSrcMem, (outs VR128:$dst), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1123 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | ebf01d6 | 2006-11-16 23:33:25 +0000 | [diff] [blame] | 1124 | [(set VR128:$dst, |
| 1125 | (v2i64 (scalar_to_vector (loadi64 addr:$src))))]>; |
| 1126 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1127 | def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1128 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | ebf01d6 | 2006-11-16 23:33:25 +0000 | [diff] [blame] | 1129 | [(set GR64:$dst, (vector_extract (v2i64 VR128:$src), |
| 1130 | (iPTR 0)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1131 | def MOVPQIto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1132 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | ebf01d6 | 2006-11-16 23:33:25 +0000 | [diff] [blame] | 1133 | [(store (i64 (vector_extract (v2i64 VR128:$src), |
| 1134 | (iPTR 0))), addr:$dst)]>; |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 1135 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1136 | def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1137 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 1138 | [(set FR64:$dst, (bitconvert GR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1139 | def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1140 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 1141 | [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>; |
| 1142 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1143 | def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1144 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 1145 | [(set GR64:$dst, (bitconvert FR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1146 | def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1147 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 1148 | [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>; |