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