Chris Lattner | 36fe6d2 | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 1 | //====- X86Instr64bit.td - Describe X86-64 Instructions ----*- tablegen -*-===// |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file describes the X86-64 instruction set, defining the instructions, |
| 11 | // and properties of the instructions which are needed for code generation, |
| 12 | // machine code emission, and analysis. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | //===----------------------------------------------------------------------===// |
Chris Lattner | 36fe6d2 | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 17 | // Operand Definitions. |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 18 | // |
| 19 | |
| 20 | // 64-bits but only 32 bits are significant. |
| 21 | def i64i32imm : Operand<i64>; |
Chris Lattner | 7680e73 | 2009-06-20 19:34:09 +0000 | [diff] [blame] | 22 | |
| 23 | // 64-bits but only 32 bits are significant, and those bits are treated as being |
| 24 | // pc relative. |
| 25 | def i64i32imm_pcrel : Operand<i64> { |
| 26 | let PrintMethod = "print_pcrel_imm"; |
Daniel Dunbar | 989ac72 | 2010-03-13 19:31:38 +0000 | [diff] [blame] | 27 | let ParserMatchClass = X86AbsMemAsmOperand; |
Chris Lattner | 7680e73 | 2009-06-20 19:34:09 +0000 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 31 | // 64-bits but only 8 bits are significant. |
Daniel Dunbar | 44f63f9 | 2009-08-10 21:06:41 +0000 | [diff] [blame] | 32 | def i64i8imm : Operand<i64> { |
| 33 | let ParserMatchClass = ImmSExt8AsmOperand; |
| 34 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 35 | |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 36 | // Special i64mem for addresses of load folding tail calls. These are not |
| 37 | // allowed to use callee-saved registers since they must be scheduled |
| 38 | // after callee-saved register are popped. |
| 39 | def i64mem_TC : Operand<i64> { |
| 40 | let PrintMethod = "printi64mem"; |
| 41 | let MIOperandInfo = (ops GR64_TC, i8imm, GR64_TC, i32imm, i8imm); |
| 42 | let ParserMatchClass = X86MemAsmOperand; |
| 43 | } |
| 44 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 45 | def lea64mem : Operand<i64> { |
Rafael Espindola | 094fad3 | 2009-04-08 21:14:34 +0000 | [diff] [blame] | 46 | let PrintMethod = "printlea64mem"; |
Dan Gohman | 74f6f9a | 2009-08-05 17:40:24 +0000 | [diff] [blame] | 47 | let MIOperandInfo = (ops GR64, i8imm, GR64_NOSP, i32imm); |
Daniel Dunbar | 96e2cec | 2010-03-13 19:31:44 +0000 | [diff] [blame] | 48 | let ParserMatchClass = X86NoSegMemAsmOperand; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | def lea64_32mem : Operand<i32> { |
| 52 | let PrintMethod = "printlea64_32mem"; |
Chris Lattner | c124306 | 2009-06-20 07:03:18 +0000 | [diff] [blame] | 53 | let AsmOperandLowerMethod = "lower_lea64_32mem"; |
Dan Gohman | 74f6f9a | 2009-08-05 17:40:24 +0000 | [diff] [blame] | 54 | let MIOperandInfo = (ops GR32, i8imm, GR32_NOSP, i32imm); |
Daniel Dunbar | 96e2cec | 2010-03-13 19:31:44 +0000 | [diff] [blame] | 55 | let ParserMatchClass = X86NoSegMemAsmOperand; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | //===----------------------------------------------------------------------===// |
Chris Lattner | 36fe6d2 | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 59 | // Complex Pattern Definitions. |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 60 | // |
| 61 | def lea64addr : ComplexPattern<i64, 4, "SelectLEAAddr", |
Dan Gohman | a98634b | 2009-08-02 16:09:17 +0000 | [diff] [blame] | 62 | [add, sub, mul, X86mul_imm, shl, or, frameindex, |
Chris Lattner | 65a7a6f | 2009-07-11 23:17:29 +0000 | [diff] [blame] | 63 | X86WrapperRIP], []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 64 | |
Chris Lattner | 5c0b16d | 2009-06-20 20:38:48 +0000 | [diff] [blame] | 65 | def tls64addr : ComplexPattern<i64, 4, "SelectTLSADDRAddr", |
| 66 | [tglobaltlsaddr], []>; |
| 67 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 68 | //===----------------------------------------------------------------------===// |
Chris Lattner | 36fe6d2 | 2008-01-10 05:50:42 +0000 | [diff] [blame] | 69 | // Pattern fragments. |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 70 | // |
| 71 | |
Chris Lattner | 1840991 | 2010-03-03 01:45:01 +0000 | [diff] [blame] | 72 | def i64immSExt8 : PatLeaf<(i64 immSext8)>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 73 | |
Chris Lattner | be5ad7d | 2010-02-23 06:09:57 +0000 | [diff] [blame] | 74 | def GetLo32XForm : SDNodeXForm<imm, [{ |
| 75 | // Transformation function: get the low 32 bits. |
| 76 | return getI32Imm((unsigned)N->getZExtValue()); |
| 77 | }]>; |
| 78 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 79 | def i64immSExt32 : PatLeaf<(i64 imm), [{ |
| 80 | // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit |
| 81 | // sign extended field. |
Dan Gohman | f5aeb1a | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 82 | return (int64_t)N->getZExtValue() == (int32_t)N->getZExtValue(); |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 83 | }]>; |
| 84 | |
Chris Lattner | be5ad7d | 2010-02-23 06:09:57 +0000 | [diff] [blame] | 85 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 86 | def i64immZExt32 : PatLeaf<(i64 imm), [{ |
| 87 | // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit |
| 88 | // unsignedsign extended field. |
Dan Gohman | f5aeb1a | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 89 | return (uint64_t)N->getZExtValue() == (uint32_t)N->getZExtValue(); |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 90 | }]>; |
| 91 | |
Evan Cheng | 466685d | 2006-10-09 20:57:25 +0000 | [diff] [blame] | 92 | def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>; |
| 93 | def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>; |
| 94 | def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 95 | |
Evan Cheng | 466685d | 2006-10-09 20:57:25 +0000 | [diff] [blame] | 96 | def zextloadi64i1 : PatFrag<(ops node:$ptr), (i64 (zextloadi1 node:$ptr))>; |
| 97 | def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>; |
| 98 | def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>; |
| 99 | def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 100 | |
Evan Cheng | 466685d | 2006-10-09 20:57:25 +0000 | [diff] [blame] | 101 | def extloadi64i1 : PatFrag<(ops node:$ptr), (i64 (extloadi1 node:$ptr))>; |
| 102 | def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>; |
| 103 | def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>; |
| 104 | def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 105 | |
| 106 | //===----------------------------------------------------------------------===// |
| 107 | // Instruction list... |
| 108 | // |
| 109 | |
Dan Gohman | 6d4b052 | 2008-10-01 18:28:06 +0000 | [diff] [blame] | 110 | // ADJCALLSTACKDOWN/UP implicitly use/def RSP because they may be expanded into |
| 111 | // a stack adjustment and the codegen must know that they may modify the stack |
| 112 | // pointer before prolog-epilog rewriting occurs. |
| 113 | // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become |
| 114 | // sub / add which can clobber EFLAGS. |
| 115 | let Defs = [RSP, EFLAGS], Uses = [RSP] in { |
| 116 | def ADJCALLSTACKDOWN64 : I<0, Pseudo, (outs), (ins i32imm:$amt), |
| 117 | "#ADJCALLSTACKDOWN", |
Chris Lattner | e563bbc | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 118 | [(X86callseq_start timm:$amt)]>, |
Dan Gohman | 6d4b052 | 2008-10-01 18:28:06 +0000 | [diff] [blame] | 119 | Requires<[In64BitMode]>; |
| 120 | def ADJCALLSTACKUP64 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2), |
| 121 | "#ADJCALLSTACKUP", |
Chris Lattner | e563bbc | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 122 | [(X86callseq_end timm:$amt1, timm:$amt2)]>, |
Dan Gohman | 6d4b052 | 2008-10-01 18:28:06 +0000 | [diff] [blame] | 123 | Requires<[In64BitMode]>; |
| 124 | } |
| 125 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 126 | // Interrupt Instructions |
| 127 | def IRET64 : RI<0xcf, RawFrm, (outs), (ins), "iret{q}", []>; |
| 128 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 129 | //===----------------------------------------------------------------------===// |
| 130 | // Call Instructions... |
| 131 | // |
Evan Cheng | ffbacca | 2007-07-21 00:34:19 +0000 | [diff] [blame] | 132 | let isCall = 1 in |
Dan Gohman | 6d4b052 | 2008-10-01 18:28:06 +0000 | [diff] [blame] | 133 | // All calls clobber the non-callee saved registers. RSP is marked as |
| 134 | // a use to prevent stack-pointer assignments that appear immediately |
| 135 | // before calls from potentially appearing dead. Uses for argument |
| 136 | // registers are added manually. |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 137 | let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, |
Evan Cheng | 0d9e976 | 2008-01-29 19:34:22 +0000 | [diff] [blame] | 138 | FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1, |
Bill Wendling | bff35d1 | 2007-04-26 21:06:48 +0000 | [diff] [blame] | 139 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 140 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, |
Dan Gohman | 2662d55 | 2008-10-01 04:14:30 +0000 | [diff] [blame] | 141 | XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], |
| 142 | Uses = [RSP] in { |
Chris Lattner | ff81ebf | 2009-03-18 00:43:52 +0000 | [diff] [blame] | 143 | |
| 144 | // NOTE: this pattern doesn't match "X86call imm", because we do not know |
| 145 | // that the offset between an arbitrary immediate and the call will fit in |
| 146 | // the 32-bit pcrel field that we have. |
Chris Lattner | e10038e | 2010-03-18 17:52:22 +0000 | [diff] [blame] | 147 | def CALL64pcrel32 : Ii32PCRel<0xE8, RawFrm, |
Chris Lattner | 7680e73 | 2009-06-20 19:34:09 +0000 | [diff] [blame] | 148 | (outs), (ins i64i32imm_pcrel:$dst, variable_ops), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 149 | "call{q}\t$dst", []>, |
Anton Korobeynikov | cf6b739 | 2009-08-03 08:12:53 +0000 | [diff] [blame] | 150 | Requires<[In64BitMode, NotWin64]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 151 | def CALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 152 | "call{q}\t{*}$dst", [(X86call GR64:$dst)]>, |
Anton Korobeynikov | cf6b739 | 2009-08-03 08:12:53 +0000 | [diff] [blame] | 153 | Requires<[NotWin64]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 154 | def CALL64m : I<0xFF, MRM2m, (outs), (ins i64mem:$dst, variable_ops), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 155 | "call{q}\t{*}$dst", [(X86call (loadi64 addr:$dst))]>, |
Anton Korobeynikov | cf6b739 | 2009-08-03 08:12:53 +0000 | [diff] [blame] | 156 | Requires<[NotWin64]>; |
Sean Callanan | 9947bbb | 2009-09-03 00:04:47 +0000 | [diff] [blame] | 157 | |
| 158 | def FARCALL64 : RI<0xFF, MRM3m, (outs), (ins opaque80mem:$dst), |
| 159 | "lcall{q}\t{*}$dst", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 160 | } |
| 161 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 162 | // FIXME: We need to teach codegen about single list of call-clobbered |
| 163 | // registers. |
Anton Korobeynikov | cf6b739 | 2009-08-03 08:12:53 +0000 | [diff] [blame] | 164 | let isCall = 1 in |
| 165 | // All calls clobber the non-callee saved registers. RSP is marked as |
| 166 | // a use to prevent stack-pointer assignments that appear immediately |
| 167 | // before calls from potentially appearing dead. Uses for argument |
| 168 | // registers are added manually. |
| 169 | let Defs = [RAX, RCX, RDX, R8, R9, R10, R11, |
| 170 | FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1, |
| 171 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
| 172 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, EFLAGS], |
| 173 | Uses = [RSP] in { |
| 174 | def WINCALL64pcrel32 : I<0xE8, RawFrm, |
Anton Korobeynikov | 941222e | 2009-08-07 23:59:21 +0000 | [diff] [blame] | 175 | (outs), (ins i64i32imm_pcrel:$dst, variable_ops), |
| 176 | "call\t$dst", []>, |
Anton Korobeynikov | cf6b739 | 2009-08-03 08:12:53 +0000 | [diff] [blame] | 177 | Requires<[IsWin64]>; |
| 178 | def WINCALL64r : I<0xFF, MRM2r, (outs), (ins GR64:$dst, variable_ops), |
| 179 | "call\t{*}$dst", |
| 180 | [(X86call GR64:$dst)]>, Requires<[IsWin64]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 181 | def WINCALL64m : I<0xFF, MRM2m, (outs), |
| 182 | (ins i64mem:$dst, variable_ops), "call\t{*}$dst", |
| 183 | [(X86call (loadi64 addr:$dst))]>, |
| 184 | Requires<[IsWin64]>; |
Anton Korobeynikov | cf6b739 | 2009-08-03 08:12:53 +0000 | [diff] [blame] | 185 | } |
Arnold Schwaighofer | c85e171 | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 186 | |
| 187 | |
| 188 | let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 189 | let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, |
| 190 | FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1, |
| 191 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
| 192 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, |
| 193 | XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], |
| 194 | Uses = [RSP] in { |
| 195 | def TCRETURNdi64 : I<0, Pseudo, (outs), |
| 196 | (ins i64i32imm_pcrel:$dst, i32imm:$offset, variable_ops), |
| 197 | "#TC_RETURN $dst $offset", []>; |
| 198 | def TCRETURNri64 : I<0, Pseudo, (outs), (ins GR64_TC:$dst, i32imm:$offset, |
| 199 | variable_ops), |
| 200 | "#TC_RETURN $dst $offset", []>; |
| 201 | def TCRETURNmi64 : I<0, Pseudo, (outs), |
| 202 | (ins i64mem_TC:$dst, i32imm:$offset, variable_ops), |
| 203 | "#TC_RETURN $dst $offset", []>; |
Arnold Schwaighofer | c85e171 | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 204 | |
Chris Lattner | 4d82068 | 2010-03-16 06:39:08 +0000 | [diff] [blame] | 205 | def TAILJMPd64 : Ii32PCRel<0xE9, RawFrm, (outs), |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 206 | (ins i64i32imm_pcrel:$dst, variable_ops), |
| 207 | "jmp\t$dst # TAILCALL", []>; |
| 208 | def TAILJMPr64 : I<0xFF, MRM4r, (outs), (ins GR64_TC:$dst, variable_ops), |
| 209 | "jmp{q}\t{*}$dst # TAILCALL", []>; |
Arnold Schwaighofer | c85e171 | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 210 | |
Evan Cheng | 700c71d | 2010-03-14 19:28:34 +0000 | [diff] [blame] | 211 | def TAILJMPm64 : I<0xFF, MRM4m, (outs), (ins i64mem_TC:$dst, variable_ops), |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 212 | "jmp{q}\t{*}$dst # TAILCALL", []>; |
| 213 | } |
Arnold Schwaighofer | c85e171 | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 214 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 215 | // Branches |
Owen Anderson | 20ab290 | 2007-11-12 07:39:39 +0000 | [diff] [blame] | 216 | let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 217 | def JMP64pcrel32 : I<0xE9, RawFrm, (outs), (ins brtarget:$dst), |
| 218 | "jmp{q}\t$dst", []>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 219 | 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] | 220 | [(brind GR64:$dst)]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 221 | 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] | 222 | [(brind (loadi64 addr:$dst))]>; |
Sean Callanan | 9947bbb | 2009-09-03 00:04:47 +0000 | [diff] [blame] | 223 | def FARJMP64 : RI<0xFF, MRM5m, (outs), (ins opaque80mem:$dst), |
| 224 | "ljmp{q}\t{*}$dst", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | //===----------------------------------------------------------------------===// |
Anton Korobeynikov | b84c167 | 2008-09-08 21:12:47 +0000 | [diff] [blame] | 228 | // EH Pseudo Instructions |
| 229 | // |
| 230 | let isTerminator = 1, isReturn = 1, isBarrier = 1, |
Daniel Dunbar | 8a3ee71 | 2010-01-22 20:16:37 +0000 | [diff] [blame] | 231 | hasCtrlDep = 1, isCodeGenOnly = 1 in { |
Anton Korobeynikov | b84c167 | 2008-09-08 21:12:47 +0000 | [diff] [blame] | 232 | def EH_RETURN64 : I<0xC3, RawFrm, (outs), (ins GR64:$addr), |
| 233 | "ret\t#eh_return, addr: $addr", |
| 234 | [(X86ehret GR64:$addr)]>; |
| 235 | |
| 236 | } |
| 237 | |
| 238 | //===----------------------------------------------------------------------===// |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 239 | // Miscellaneous Instructions... |
| 240 | // |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 241 | |
| 242 | def POPCNT64rr : RI<0xB8, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
| 243 | "popcnt{q}\t{$src, $dst|$dst, $src}", []>, XS; |
| 244 | def POPCNT64rm : RI<0xB8, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
| 245 | "popcnt{q}\t{$src, $dst|$dst, $src}", []>, XS; |
| 246 | |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 247 | let Defs = [RBP,RSP], Uses = [RBP,RSP], mayLoad = 1, neverHasSideEffects = 1 in |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 248 | def LEAVE64 : I<0xC9, RawFrm, |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 249 | (outs), (ins), "leave", []>; |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 250 | let Defs = [RSP], Uses = [RSP], neverHasSideEffects=1 in { |
Sean Callanan | 1f24e01 | 2009-09-10 18:29:13 +0000 | [diff] [blame] | 251 | let mayLoad = 1 in { |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 252 | def POP64r : I<0x58, AddRegFrm, |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 253 | (outs GR64:$reg), (ins), "pop{q}\t$reg", []>; |
Sean Callanan | 1f24e01 | 2009-09-10 18:29:13 +0000 | [diff] [blame] | 254 | def POP64rmr: I<0x8F, MRM0r, (outs GR64:$reg), (ins), "pop{q}\t$reg", []>; |
| 255 | def POP64rmm: I<0x8F, MRM0m, (outs i64mem:$dst), (ins), "pop{q}\t$dst", []>; |
| 256 | } |
| 257 | let mayStore = 1 in { |
Dan Gohman | 638c96d | 2007-06-18 14:12:56 +0000 | [diff] [blame] | 258 | def PUSH64r : I<0x50, AddRegFrm, |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 259 | (outs), (ins GR64:$reg), "push{q}\t$reg", []>; |
Sean Callanan | 1f24e01 | 2009-09-10 18:29:13 +0000 | [diff] [blame] | 260 | def PUSH64rmr: I<0xFF, MRM6r, (outs), (ins GR64:$reg), "push{q}\t$reg", []>; |
| 261 | def PUSH64rmm: I<0xFF, MRM6m, (outs), (ins i64mem:$src), "push{q}\t$src", []>; |
| 262 | } |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 263 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 264 | |
Bill Wendling | 453eb26 | 2009-06-15 19:39:04 +0000 | [diff] [blame] | 265 | let Defs = [RSP], Uses = [RSP], neverHasSideEffects = 1, mayStore = 1 in { |
| 266 | def PUSH64i8 : Ii8<0x6a, RawFrm, (outs), (ins i8imm:$imm), |
Bill Wendling | 927788c | 2009-06-15 20:59:31 +0000 | [diff] [blame] | 267 | "push{q}\t$imm", []>; |
Bill Wendling | 453eb26 | 2009-06-15 19:39:04 +0000 | [diff] [blame] | 268 | def PUSH64i16 : Ii16<0x68, RawFrm, (outs), (ins i16imm:$imm), |
Bill Wendling | 927788c | 2009-06-15 20:59:31 +0000 | [diff] [blame] | 269 | "push{q}\t$imm", []>; |
Bill Wendling | 453eb26 | 2009-06-15 19:39:04 +0000 | [diff] [blame] | 270 | def PUSH64i32 : Ii32<0x68, RawFrm, (outs), (ins i32imm:$imm), |
Bill Wendling | 927788c | 2009-06-15 20:59:31 +0000 | [diff] [blame] | 271 | "push{q}\t$imm", []>; |
Bill Wendling | 453eb26 | 2009-06-15 19:39:04 +0000 | [diff] [blame] | 272 | } |
| 273 | |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 274 | let Defs = [RSP, EFLAGS], Uses = [RSP], mayLoad = 1 in |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 275 | def POPFQ : I<0x9D, RawFrm, (outs), (ins), "popf{q}", []>, REX_W; |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 276 | let Defs = [RSP], Uses = [RSP, EFLAGS], mayStore = 1 in |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 277 | def PUSHFQ64 : I<0x9C, RawFrm, (outs), (ins), "pushf{q}", []>; |
Evan Cheng | 2f245ba | 2007-09-26 01:29:06 +0000 | [diff] [blame] | 278 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 279 | def LEA64_32r : I<0x8D, MRMSrcMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 280 | (outs GR32:$dst), (ins lea64_32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 281 | "lea{l}\t{$src|$dst}, {$dst|$src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 282 | [(set GR32:$dst, lea32addr:$src)]>, Requires<[In64BitMode]>; |
| 283 | |
Evan Cheng | e771ebd | 2008-03-27 01:41:09 +0000 | [diff] [blame] | 284 | let isReMaterializable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 285 | def LEA64r : RI<0x8D, MRMSrcMem, (outs GR64:$dst), (ins lea64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 286 | "lea{q}\t{$src|$dst}, {$dst|$src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 287 | [(set GR64:$dst, lea64addr:$src)]>; |
| 288 | |
| 289 | let isTwoAddress = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 290 | def BSWAP64r : RI<0xC8, AddRegFrm, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 291 | "bswap{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 292 | [(set GR64:$dst, (bswap GR64:$src))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 293 | |
Evan Cheng | 18efe26 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 294 | // Bit scan instructions. |
| 295 | let Defs = [EFLAGS] in { |
Evan Cheng | fd9e473 | 2007-12-14 18:49:43 +0000 | [diff] [blame] | 296 | def BSF64rr : RI<0xBC, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 1a8001e | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 297 | "bsf{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 8ec8611 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 298 | [(set GR64:$dst, (X86bsf GR64:$src)), (implicit EFLAGS)]>, TB; |
Evan Cheng | 18efe26 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 299 | def BSF64rm : RI<0xBC, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | 1a8001e | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 300 | "bsf{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 8ec8611 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 301 | [(set GR64:$dst, (X86bsf (loadi64 addr:$src))), |
| 302 | (implicit EFLAGS)]>, TB; |
Evan Cheng | 18efe26 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 303 | |
Evan Cheng | fd9e473 | 2007-12-14 18:49:43 +0000 | [diff] [blame] | 304 | def BSR64rr : RI<0xBD, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | 1a8001e | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 305 | "bsr{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 8ec8611 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 306 | [(set GR64:$dst, (X86bsr GR64:$src)), (implicit EFLAGS)]>, TB; |
Evan Cheng | 18efe26 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 307 | def BSR64rm : RI<0xBD, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | 1a8001e | 2007-12-14 15:10:00 +0000 | [diff] [blame] | 308 | "bsr{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 8ec8611 | 2007-12-14 18:25:34 +0000 | [diff] [blame] | 309 | [(set GR64:$dst, (X86bsr (loadi64 addr:$src))), |
| 310 | (implicit EFLAGS)]>, TB; |
Evan Cheng | 18efe26 | 2007-12-14 02:13:44 +0000 | [diff] [blame] | 311 | } // Defs = [EFLAGS] |
| 312 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 313 | // Repeat string ops |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 314 | let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 315 | def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 316 | [(X86rep_movs i64)]>, REP; |
| 317 | let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 318 | def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 319 | [(X86rep_stos i64)]>, REP; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 320 | |
Sean Callanan | a82e465 | 2009-09-12 00:37:19 +0000 | [diff] [blame] | 321 | def SCAS64 : RI<0xAF, RawFrm, (outs), (ins), "scas{q}", []>; |
| 322 | |
Sean Callanan | 6f8f462 | 2009-09-12 02:25:20 +0000 | [diff] [blame] | 323 | def CMPS64 : RI<0xA7, RawFrm, (outs), (ins), "cmps{q}", []>; |
| 324 | |
Bill Wendling | 7239b51 | 2009-07-21 01:07:24 +0000 | [diff] [blame] | 325 | // Fast system-call instructions |
Bill Wendling | 7239b51 | 2009-07-21 01:07:24 +0000 | [diff] [blame] | 326 | def SYSEXIT64 : RI<0x35, RawFrm, |
| 327 | (outs), (ins), "sysexit", []>, TB; |
Bill Wendling | 7239b51 | 2009-07-21 01:07:24 +0000 | [diff] [blame] | 328 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 329 | //===----------------------------------------------------------------------===// |
| 330 | // Move Instructions... |
| 331 | // |
| 332 | |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 333 | let neverHasSideEffects = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 334 | def MOV64rr : RI<0x89, MRMDestReg, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 335 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 336 | |
Evan Cheng | 601ca4b | 2008-06-25 01:16:38 +0000 | [diff] [blame] | 337 | let isReMaterializable = 1, isAsCheapAsAMove = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 338 | def MOV64ri : RIi64<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 339 | "movabs{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 340 | [(set GR64:$dst, imm:$src)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 341 | def MOV64ri32 : RIi32<0xC7, MRM0r, (outs GR64:$dst), (ins i64i32imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 342 | "mov{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 343 | [(set GR64:$dst, i64immSExt32:$src)]>; |
Dan Gohman | 1ab7989 | 2007-09-07 21:32:51 +0000 | [diff] [blame] | 344 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 345 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 346 | def MOV64rr_REV : RI<0x8B, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
| 347 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
| 348 | |
Dan Gohman | bc9d98b | 2010-02-27 23:47:46 +0000 | [diff] [blame] | 349 | let canFoldAsLoad = 1, isReMaterializable = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 350 | def MOV64rm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 351 | "mov{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 352 | [(set GR64:$dst, (load addr:$src))]>; |
| 353 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 354 | def MOV64mr : RI<0x89, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 355 | "mov{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 356 | [(store GR64:$src, addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 357 | def MOV64mi32 : RIi32<0xC7, MRM0m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 358 | "mov{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 359 | [(store i64immSExt32:$src, addr:$dst)]>; |
| 360 | |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 361 | /// Versions of MOV64rr, MOV64rm, and MOV64mr for i64mem_TC and GR64_TC. |
| 362 | let neverHasSideEffects = 1 in |
Evan Cheng | 700c71d | 2010-03-14 19:28:34 +0000 | [diff] [blame] | 363 | def MOV64rr_TC : RI<0x89, MRMDestReg, (outs GR64_TC:$dst), (ins GR64_TC:$src), |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 364 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
| 365 | |
| 366 | let mayLoad = 1, |
| 367 | canFoldAsLoad = 1, isReMaterializable = 1 in |
Evan Cheng | 700c71d | 2010-03-14 19:28:34 +0000 | [diff] [blame] | 368 | def MOV64rm_TC : RI<0x8B, MRMSrcMem, (outs GR64_TC:$dst), (ins i64mem_TC:$src), |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 369 | "mov{q}\t{$src, $dst|$dst, $src}", |
| 370 | []>; |
| 371 | |
| 372 | let mayStore = 1 in |
Evan Cheng | 700c71d | 2010-03-14 19:28:34 +0000 | [diff] [blame] | 373 | def MOV64mr_TC : RI<0x89, MRMDestMem, (outs), (ins i64mem_TC:$dst, GR64_TC:$src), |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 374 | "mov{q}\t{$src, $dst|$dst, $src}", |
| 375 | []>; |
| 376 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 377 | def MOV64o8a : RIi8<0xA0, RawFrm, (outs), (ins offset8:$src), |
Sean Callanan | 2f34a13 | 2009-09-10 18:33:42 +0000 | [diff] [blame] | 378 | "mov{q}\t{$src, %rax|%rax, $src}", []>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 379 | def MOV64o64a : RIi32<0xA1, RawFrm, (outs), (ins offset64:$src), |
Sean Callanan | 2f34a13 | 2009-09-10 18:33:42 +0000 | [diff] [blame] | 380 | "mov{q}\t{$src, %rax|%rax, $src}", []>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 381 | def MOV64ao8 : RIi8<0xA2, RawFrm, (outs offset8:$dst), (ins), |
Sean Callanan | 2f34a13 | 2009-09-10 18:33:42 +0000 | [diff] [blame] | 382 | "mov{q}\t{%rax, $dst|$dst, %rax}", []>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 383 | def MOV64ao64 : RIi32<0xA3, RawFrm, (outs offset64:$dst), (ins), |
Sean Callanan | 2f34a13 | 2009-09-10 18:33:42 +0000 | [diff] [blame] | 384 | "mov{q}\t{%rax, $dst|$dst, %rax}", []>; |
| 385 | |
Sean Callanan | 38fee0e | 2009-09-15 18:47:29 +0000 | [diff] [blame] | 386 | // Moves to and from segment registers |
| 387 | def MOV64rs : RI<0x8C, MRMDestReg, (outs GR64:$dst), (ins SEGMENT_REG:$src), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 388 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
Sean Callanan | 38fee0e | 2009-09-15 18:47:29 +0000 | [diff] [blame] | 389 | def MOV64ms : RI<0x8C, MRMDestMem, (outs i64mem:$dst), (ins SEGMENT_REG:$src), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 390 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
Sean Callanan | 38fee0e | 2009-09-15 18:47:29 +0000 | [diff] [blame] | 391 | def MOV64sr : RI<0x8E, MRMSrcReg, (outs SEGMENT_REG:$dst), (ins GR64:$src), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 392 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
Sean Callanan | 38fee0e | 2009-09-15 18:47:29 +0000 | [diff] [blame] | 393 | def MOV64sm : RI<0x8E, MRMSrcMem, (outs SEGMENT_REG:$dst), (ins i64mem:$src), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 394 | "mov{q}\t{$src, $dst|$dst, $src}", []>; |
| 395 | |
| 396 | // Moves to and from debug registers |
| 397 | def MOV64rd : I<0x21, MRMDestReg, (outs GR64:$dst), (ins DEBUG_REG:$src), |
| 398 | "mov{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 399 | def MOV64dr : I<0x23, MRMSrcReg, (outs DEBUG_REG:$dst), (ins GR64:$src), |
| 400 | "mov{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 401 | |
| 402 | // Moves to and from control registers |
| 403 | def MOV64rc : I<0x20, MRMDestReg, (outs GR64:$dst), (ins CONTROL_REG_64:$src), |
| 404 | "mov{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 405 | def MOV64cr : I<0x22, MRMSrcReg, (outs CONTROL_REG_64:$dst), (ins GR64:$src), |
| 406 | "mov{q}\t{$src, $dst|$dst, $src}", []>, TB; |
Sean Callanan | 38fee0e | 2009-09-15 18:47:29 +0000 | [diff] [blame] | 407 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 408 | // Sign/Zero extenders |
| 409 | |
Dan Gohman | 04d19f0 | 2009-04-13 15:13:28 +0000 | [diff] [blame] | 410 | // MOVSX64rr8 always has a REX prefix and it has an 8-bit register |
| 411 | // operand, which makes it a rare instruction with an 8-bit register |
| 412 | // operand that can never access an h register. If support for h registers |
| 413 | // were generalized, this would require a special register class. |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 414 | def MOVSX64rr8 : RI<0xBE, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 415 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 416 | [(set GR64:$dst, (sext GR8:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 417 | def MOVSX64rm8 : RI<0xBE, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 418 | "movs{bq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 419 | [(set GR64:$dst, (sextloadi64i8 addr:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 420 | def MOVSX64rr16: RI<0xBF, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 421 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 422 | [(set GR64:$dst, (sext GR16:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 423 | def MOVSX64rm16: RI<0xBF, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 424 | "movs{wq|x}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 425 | [(set GR64:$dst, (sextloadi64i16 addr:$src))]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 426 | def MOVSX64rr32: RI<0x63, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 427 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 428 | [(set GR64:$dst, (sext GR32:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 429 | def MOVSX64rm32: RI<0x63, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 430 | "movs{lq|xd}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 431 | [(set GR64:$dst, (sextloadi64i32 addr:$src))]>; |
| 432 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 433 | // movzbq and movzwq encodings for the disassembler |
| 434 | def MOVZX64rr8_Q : RI<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8:$src), |
| 435 | "movz{bq|x}\t{$src, $dst|$dst, $src}", []>, TB; |
| 436 | def MOVZX64rm8_Q : RI<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem:$src), |
| 437 | "movz{bq|x}\t{$src, $dst|$dst, $src}", []>, TB; |
| 438 | def MOVZX64rr16_Q : RI<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
| 439 | "movz{wq|x}\t{$src, $dst|$dst, $src}", []>, TB; |
| 440 | def MOVZX64rm16_Q : RI<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
| 441 | "movz{wq|x}\t{$src, $dst|$dst, $src}", []>, TB; |
| 442 | |
Dan Gohman | 11ba3b1 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 443 | // Use movzbl instead of movzbq when the destination is a register; it's |
| 444 | // equivalent due to implicit zero-extending, and it has a smaller encoding. |
| 445 | def MOVZX64rr8 : I<0xB6, MRMSrcReg, (outs GR64:$dst), (ins GR8 :$src), |
Chris Lattner | 172862a | 2009-10-19 19:51:42 +0000 | [diff] [blame] | 446 | "", [(set GR64:$dst, (zext GR8:$src))]>, TB; |
Dan Gohman | 11ba3b1 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 447 | def MOVZX64rm8 : I<0xB6, MRMSrcMem, (outs GR64:$dst), (ins i8mem :$src), |
Chris Lattner | 172862a | 2009-10-19 19:51:42 +0000 | [diff] [blame] | 448 | "", [(set GR64:$dst, (zextloadi64i8 addr:$src))]>, TB; |
Dan Gohman | 11ba3b1 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 449 | // Use movzwl instead of movzwq when the destination is a register; it's |
| 450 | // equivalent due to implicit zero-extending, and it has a smaller encoding. |
| 451 | def MOVZX64rr16: I<0xB7, MRMSrcReg, (outs GR64:$dst), (ins GR16:$src), |
Chris Lattner | 172862a | 2009-10-19 19:51:42 +0000 | [diff] [blame] | 452 | "", [(set GR64:$dst, (zext GR16:$src))]>, TB; |
Dan Gohman | 11ba3b1 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 453 | def MOVZX64rm16: I<0xB7, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
Chris Lattner | 172862a | 2009-10-19 19:51:42 +0000 | [diff] [blame] | 454 | "", [(set GR64:$dst, (zextloadi64i16 addr:$src))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 455 | |
Dan Gohman | e3d9206 | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 456 | // There's no movzlq instruction, but movl can be used for this purpose, using |
Dan Gohman | 97121ba | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 457 | // implicit zero-extension. The preferred way to do 32-bit-to-64-bit zero |
| 458 | // extension on x86-64 is to use a SUBREG_TO_REG to utilize implicit |
| 459 | // zero-extension, however this isn't possible when the 32-bit value is |
| 460 | // defined by a truncate or is copied from something where the high bits aren't |
| 461 | // necessarily all zero. In such cases, we fall back to these explicit zext |
| 462 | // instructions. |
Dan Gohman | e3d9206 | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 463 | def MOVZX64rr32 : I<0x89, MRMDestReg, (outs GR64:$dst), (ins GR32:$src), |
Chris Lattner | 172862a | 2009-10-19 19:51:42 +0000 | [diff] [blame] | 464 | "", [(set GR64:$dst, (zext GR32:$src))]>; |
Dan Gohman | e3d9206 | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 465 | def MOVZX64rm32 : I<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i32mem:$src), |
Chris Lattner | 172862a | 2009-10-19 19:51:42 +0000 | [diff] [blame] | 466 | "", [(set GR64:$dst, (zextloadi64i32 addr:$src))]>; |
Dan Gohman | e3d9206 | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 467 | |
Dan Gohman | 97121ba | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 468 | // Any instruction that defines a 32-bit result leaves the high half of the |
Dan Gohman | 907355c | 2009-09-15 00:14:11 +0000 | [diff] [blame] | 469 | // register. Truncate can be lowered to EXTRACT_SUBREG. CopyFromReg may |
| 470 | // be copying from a truncate. And x86's cmov doesn't do anything if the |
| 471 | // condition is false. But any other 32-bit operation will zero-extend |
Dan Gohman | 97121ba | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 472 | // up to 64 bits. |
| 473 | def def32 : PatLeaf<(i32 GR32:$src), [{ |
| 474 | return N->getOpcode() != ISD::TRUNCATE && |
Chris Lattner | 518bb53 | 2010-02-09 19:54:29 +0000 | [diff] [blame] | 475 | N->getOpcode() != TargetOpcode::EXTRACT_SUBREG && |
Dan Gohman | 907355c | 2009-09-15 00:14:11 +0000 | [diff] [blame] | 476 | N->getOpcode() != ISD::CopyFromReg && |
| 477 | N->getOpcode() != X86ISD::CMOV; |
Dan Gohman | 97121ba | 2009-04-08 00:15:30 +0000 | [diff] [blame] | 478 | }]>; |
| 479 | |
| 480 | // In the case of a 32-bit def that is known to implicitly zero-extend, |
| 481 | // we can use a SUBREG_TO_REG. |
| 482 | def : Pat<(i64 (zext def32:$src)), |
| 483 | (SUBREG_TO_REG (i64 0), GR32:$src, x86_subreg_32bit)>; |
| 484 | |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 485 | let neverHasSideEffects = 1 in { |
| 486 | let Defs = [RAX], Uses = [EAX] in |
| 487 | def CDQE : RI<0x98, RawFrm, (outs), (ins), |
| 488 | "{cltq|cdqe}", []>; // RAX = signext(EAX) |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 489 | |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 490 | let Defs = [RAX,RDX], Uses = [RAX] in |
| 491 | def CQO : RI<0x99, RawFrm, (outs), (ins), |
| 492 | "{cqto|cqo}", []>; // RDX:RAX = signext(RAX) |
| 493 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 494 | |
| 495 | //===----------------------------------------------------------------------===// |
| 496 | // Arithmetic Instructions... |
| 497 | // |
| 498 | |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 499 | let Defs = [EFLAGS] in { |
Sean Callanan | a09caa5 | 2009-09-02 00:55:49 +0000 | [diff] [blame] | 500 | |
Daniel Dunbar | 859c9dc | 2010-03-13 22:49:39 +0000 | [diff] [blame] | 501 | def ADD64i32 : RIi32<0x05, RawFrm, (outs), (ins i32imm:$src), |
| 502 | "add{q}\t{$src, %rax|%rax, $src}", []>; |
Sean Callanan | a09caa5 | 2009-09-02 00:55:49 +0000 | [diff] [blame] | 503 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 504 | let isTwoAddress = 1 in { |
| 505 | let isConvertibleToThreeAddress = 1 in { |
| 506 | let isCommutable = 1 in |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 507 | // Register-Register Addition |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 508 | def ADD64rr : RI<0x01, MRMDestReg, (outs GR64:$dst), |
| 509 | (ins GR64:$src1, GR64:$src2), |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 510 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 511 | [(set GR64:$dst, (add GR64:$src1, GR64:$src2)), |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 512 | (implicit EFLAGS)]>; |
| 513 | |
Daniel Dunbar | 0180dae | 2010-03-19 18:07:48 +0000 | [diff] [blame^] | 514 | // These are alternate spellings for use by the disassembler, we mark them as |
| 515 | // code gen only to ensure they aren't matched by the assembler. |
| 516 | let isCodeGenOnly = 1 in { |
| 517 | def ADD64rr_alt : RI<0x03, MRMSrcReg, (outs GR64:$dst), |
| 518 | (ins GR64:$src1, GR64:$src2), |
| 519 | "add{l}\t{$src2, $dst|$dst, $src2}", []>; |
| 520 | } |
| 521 | |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 522 | // Register-Integer Addition |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 523 | def ADD64ri8 : RIi8<0x83, MRM0r, (outs GR64:$dst), |
| 524 | (ins GR64:$src1, i64i8imm:$src2), |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 525 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 526 | [(set GR64:$dst, (add GR64:$src1, i64immSExt8:$src2)), |
| 527 | (implicit EFLAGS)]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 528 | def ADD64ri32 : RIi32<0x81, MRM0r, (outs GR64:$dst), |
| 529 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 530 | "add{q}\t{$src2, $dst|$dst, $src2}", |
| 531 | [(set GR64:$dst, (add GR64:$src1, i64immSExt32:$src2)), |
| 532 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 533 | } // isConvertibleToThreeAddress |
| 534 | |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 535 | // Register-Memory Addition |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 536 | def ADD64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), |
| 537 | (ins GR64:$src1, i64mem:$src2), |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 538 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 539 | [(set GR64:$dst, (add GR64:$src1, (load addr:$src2))), |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 540 | (implicit EFLAGS)]>; |
Sean Callanan | 37be590 | 2009-09-15 20:53:57 +0000 | [diff] [blame] | 541 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 542 | } // isTwoAddress |
| 543 | |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 544 | // Memory-Register Addition |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 545 | def ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 546 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 547 | [(store (add (load addr:$dst), GR64:$src2), addr:$dst), |
| 548 | (implicit EFLAGS)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 549 | def ADD64mi8 : RIi8<0x83, MRM0m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 550 | "add{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 551 | [(store (add (load addr:$dst), i64immSExt8:$src2), addr:$dst), |
| 552 | (implicit EFLAGS)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 553 | def ADD64mi32 : RIi32<0x81, MRM0m, (outs), (ins i64mem:$dst, i64i32imm :$src2), |
| 554 | "add{q}\t{$src2, $dst|$dst, $src2}", |
| 555 | [(store (add (load addr:$dst), i64immSExt32:$src2), addr:$dst), |
| 556 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 557 | |
Evan Cheng | 3154cb6 | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 558 | let Uses = [EFLAGS] in { |
Sean Callanan | d00025a | 2009-09-11 19:01:56 +0000 | [diff] [blame] | 559 | |
Daniel Dunbar | bf2d4c0 | 2010-03-13 22:57:53 +0000 | [diff] [blame] | 560 | def ADC64i32 : RIi32<0x15, RawFrm, (outs), (ins i32imm:$src), |
| 561 | "adc{q}\t{$src, %rax|%rax, $src}", []>; |
Sean Callanan | d00025a | 2009-09-11 19:01:56 +0000 | [diff] [blame] | 562 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 563 | let isTwoAddress = 1 in { |
| 564 | let isCommutable = 1 in |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 565 | def ADC64rr : RI<0x11, MRMDestReg, (outs GR64:$dst), |
| 566 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 567 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 568 | [(set GR64:$dst, (adde GR64:$src1, GR64:$src2))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 569 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 570 | def ADC64rr_REV : RI<0x13, MRMSrcReg , (outs GR32:$dst), |
| 571 | (ins GR64:$src1, GR64:$src2), |
| 572 | "adc{q}\t{$src2, $dst|$dst, $src2}", []>; |
| 573 | |
| 574 | def ADC64rm : RI<0x13, MRMSrcMem , (outs GR64:$dst), |
| 575 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 576 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 577 | [(set GR64:$dst, (adde GR64:$src1, (load addr:$src2)))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 578 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 579 | def ADC64ri8 : RIi8<0x83, MRM2r, (outs GR64:$dst), |
| 580 | (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 581 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 582 | [(set GR64:$dst, (adde GR64:$src1, i64immSExt8:$src2))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 583 | def ADC64ri32 : RIi32<0x81, MRM2r, (outs GR64:$dst), |
| 584 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 585 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 586 | [(set GR64:$dst, (adde GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 587 | } // isTwoAddress |
| 588 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 589 | def ADC64mr : RI<0x11, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 590 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 591 | [(store (adde (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 592 | def ADC64mi8 : RIi8<0x83, MRM2m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 593 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 594 | [(store (adde (load addr:$dst), i64immSExt8:$src2), |
| 595 | addr:$dst)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 596 | def ADC64mi32 : RIi32<0x81, MRM2m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
| 597 | "adc{q}\t{$src2, $dst|$dst, $src2}", |
Chris Lattner | 4446c3f | 2010-02-27 08:18:55 +0000 | [diff] [blame] | 598 | [(store (adde (load addr:$dst), i64immSExt32:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 599 | addr:$dst)]>; |
Evan Cheng | 3154cb6 | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 600 | } // Uses = [EFLAGS] |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 601 | |
| 602 | let isTwoAddress = 1 in { |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 603 | // Register-Register Subtraction |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 604 | def SUB64rr : RI<0x29, MRMDestReg, (outs GR64:$dst), |
| 605 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 606 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 607 | [(set GR64:$dst, (sub GR64:$src1, GR64:$src2)), |
| 608 | (implicit EFLAGS)]>; |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 609 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 610 | def SUB64rr_REV : RI<0x2B, MRMSrcReg, (outs GR64:$dst), |
| 611 | (ins GR64:$src1, GR64:$src2), |
| 612 | "sub{q}\t{$src2, $dst|$dst, $src2}", []>; |
| 613 | |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 614 | // Register-Memory Subtraction |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 615 | def SUB64rm : RI<0x2B, MRMSrcMem, (outs GR64:$dst), |
| 616 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 617 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 618 | [(set GR64:$dst, (sub GR64:$src1, (load addr:$src2))), |
| 619 | (implicit EFLAGS)]>; |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 620 | |
| 621 | // Register-Integer Subtraction |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 622 | def SUB64ri8 : RIi8<0x83, MRM5r, (outs GR64:$dst), |
| 623 | (ins GR64:$src1, i64i8imm:$src2), |
| 624 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 625 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt8:$src2)), |
| 626 | (implicit EFLAGS)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 627 | def SUB64ri32 : RIi32<0x81, MRM5r, (outs GR64:$dst), |
| 628 | (ins GR64:$src1, i64i32imm:$src2), |
| 629 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
| 630 | [(set GR64:$dst, (sub GR64:$src1, i64immSExt32:$src2)), |
| 631 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 632 | } // isTwoAddress |
| 633 | |
Daniel Dunbar | bf2d4c0 | 2010-03-13 22:57:53 +0000 | [diff] [blame] | 634 | def SUB64i32 : RIi32<0x2D, RawFrm, (outs), (ins i32imm:$src), |
| 635 | "sub{q}\t{$src, %rax|%rax, $src}", []>; |
Sean Callanan | d00025a | 2009-09-11 19:01:56 +0000 | [diff] [blame] | 636 | |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 637 | // Memory-Register Subtraction |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 638 | def SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 639 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 640 | [(store (sub (load addr:$dst), GR64:$src2), addr:$dst), |
| 641 | (implicit EFLAGS)]>; |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 642 | |
| 643 | // Memory-Integer Subtraction |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 644 | def SUB64mi8 : RIi8<0x83, MRM5m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 645 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 646 | [(store (sub (load addr:$dst), i64immSExt8:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 647 | addr:$dst), |
| 648 | (implicit EFLAGS)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 649 | def SUB64mi32 : RIi32<0x81, MRM5m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
| 650 | "sub{q}\t{$src2, $dst|$dst, $src2}", |
| 651 | [(store (sub (load addr:$dst), i64immSExt32:$src2), |
| 652 | addr:$dst), |
| 653 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 654 | |
Evan Cheng | 3154cb6 | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 655 | let Uses = [EFLAGS] in { |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 656 | let isTwoAddress = 1 in { |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 657 | def SBB64rr : RI<0x19, MRMDestReg, (outs GR64:$dst), |
| 658 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 659 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 660 | [(set GR64:$dst, (sube GR64:$src1, GR64:$src2))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 661 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 662 | def SBB64rr_REV : RI<0x1B, MRMSrcReg, (outs GR64:$dst), |
| 663 | (ins GR64:$src1, GR64:$src2), |
| 664 | "sbb{q}\t{$src2, $dst|$dst, $src2}", []>; |
| 665 | |
| 666 | def SBB64rm : RI<0x1B, MRMSrcMem, (outs GR64:$dst), |
| 667 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 668 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 669 | [(set GR64:$dst, (sube GR64:$src1, (load addr:$src2)))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 670 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 671 | def SBB64ri8 : RIi8<0x83, MRM3r, (outs GR64:$dst), |
| 672 | (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 673 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 674 | [(set GR64:$dst, (sube GR64:$src1, i64immSExt8:$src2))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 675 | def SBB64ri32 : RIi32<0x81, MRM3r, (outs GR64:$dst), |
| 676 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 677 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 678 | [(set GR64:$dst, (sube GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 679 | } // isTwoAddress |
| 680 | |
Daniel Dunbar | bf2d4c0 | 2010-03-13 22:57:53 +0000 | [diff] [blame] | 681 | def SBB64i32 : RIi32<0x1D, RawFrm, (outs), (ins i32imm:$src), |
| 682 | "sbb{q}\t{$src, %rax|%rax, $src}", []>; |
Sean Callanan | d00025a | 2009-09-11 19:01:56 +0000 | [diff] [blame] | 683 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 684 | def SBB64mr : RI<0x19, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 685 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 686 | [(store (sube (load addr:$dst), GR64:$src2), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 687 | def SBB64mi8 : RIi8<0x83, MRM3m, (outs), (ins i64mem:$dst, i64i8imm :$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 688 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 689 | [(store (sube (load addr:$dst), i64immSExt8:$src2), addr:$dst)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 690 | def SBB64mi32 : RIi32<0x81, MRM3m, (outs), (ins i64mem:$dst, i64i32imm:$src2), |
| 691 | "sbb{q}\t{$src2, $dst|$dst, $src2}", |
Dale Johannesen | 874ae25 | 2009-06-02 03:12:52 +0000 | [diff] [blame] | 692 | [(store (sube (load addr:$dst), i64immSExt32:$src2), addr:$dst)]>; |
Evan Cheng | 3154cb6 | 2007-10-05 17:59:57 +0000 | [diff] [blame] | 693 | } // Uses = [EFLAGS] |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 694 | } // Defs = [EFLAGS] |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 695 | |
| 696 | // Unsigned multiplication |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 697 | let Defs = [RAX,RDX,EFLAGS], Uses = [RAX], neverHasSideEffects = 1 in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 698 | def MUL64r : RI<0xF7, MRM4r, (outs), (ins GR64:$src), |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 699 | "mul{q}\t$src", []>; // RAX,RDX = RAX*GR64 |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 700 | let mayLoad = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 701 | def MUL64m : RI<0xF7, MRM4m, (outs), (ins i64mem:$src), |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 702 | "mul{q}\t$src", []>; // RAX,RDX = RAX*[mem64] |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 703 | |
| 704 | // Signed multiplication |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 705 | def IMUL64r : RI<0xF7, MRM5r, (outs), (ins GR64:$src), |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 706 | "imul{q}\t$src", []>; // RAX,RDX = RAX*GR64 |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 707 | let mayLoad = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 708 | def IMUL64m : RI<0xF7, MRM5m, (outs), (ins i64mem:$src), |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 709 | "imul{q}\t$src", []>; // RAX,RDX = RAX*[mem64] |
| 710 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 711 | |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 712 | let Defs = [EFLAGS] in { |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 713 | let isTwoAddress = 1 in { |
| 714 | let isCommutable = 1 in |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 715 | // Register-Register Signed Integer Multiplication |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 716 | def IMUL64rr : RI<0xAF, MRMSrcReg, (outs GR64:$dst), |
| 717 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 718 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 719 | [(set GR64:$dst, (mul GR64:$src1, GR64:$src2)), |
| 720 | (implicit EFLAGS)]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 721 | |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 722 | // Register-Memory Signed Integer Multiplication |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 723 | def IMUL64rm : RI<0xAF, MRMSrcMem, (outs GR64:$dst), |
| 724 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 725 | "imul{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 726 | [(set GR64:$dst, (mul GR64:$src1, (load addr:$src2))), |
| 727 | (implicit EFLAGS)]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 728 | } // isTwoAddress |
| 729 | |
| 730 | // Suprisingly enough, these are not two address instructions! |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 731 | |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 732 | // Register-Integer Signed Integer Multiplication |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 733 | def IMUL64rri8 : RIi8<0x6B, MRMSrcReg, // GR64 = GR64*I8 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 734 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 735 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 736 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt8:$src2)), |
| 737 | (implicit EFLAGS)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 738 | def IMUL64rri32 : RIi32<0x69, MRMSrcReg, // GR64 = GR64*I32 |
| 739 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 740 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
| 741 | [(set GR64:$dst, (mul GR64:$src1, i64immSExt32:$src2)), |
| 742 | (implicit EFLAGS)]>; |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 743 | |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 744 | // Memory-Integer Signed Integer Multiplication |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 745 | def IMUL64rmi8 : RIi8<0x6B, MRMSrcMem, // GR64 = [mem64]*I8 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 746 | (outs GR64:$dst), (ins i64mem:$src1, i64i8imm: $src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 747 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
Bill Wendling | ab55ebd | 2008-12-12 00:56:36 +0000 | [diff] [blame] | 748 | [(set GR64:$dst, (mul (load addr:$src1), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 749 | i64immSExt8:$src2)), |
| 750 | (implicit EFLAGS)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 751 | def IMUL64rmi32 : RIi32<0x69, MRMSrcMem, // GR64 = [mem64]*I32 |
| 752 | (outs GR64:$dst), (ins i64mem:$src1, i64i32imm:$src2), |
| 753 | "imul{q}\t{$src2, $src1, $dst|$dst, $src1, $src2}", |
| 754 | [(set GR64:$dst, (mul (load addr:$src1), |
| 755 | i64immSExt32:$src2)), |
| 756 | (implicit EFLAGS)]>; |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 757 | } // Defs = [EFLAGS] |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 758 | |
| 759 | // Unsigned division / remainder |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 760 | let Defs = [RAX,RDX,EFLAGS], Uses = [RAX,RDX] in { |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 761 | // RDX:RAX/r64 = RAX,RDX |
| 762 | def DIV64r : RI<0xF7, MRM6r, (outs), (ins GR64:$src), |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 763 | "div{q}\t$src", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 764 | // Signed division / remainder |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 765 | // RDX:RAX/r64 = RAX,RDX |
| 766 | def IDIV64r: RI<0xF7, MRM7r, (outs), (ins GR64:$src), |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 767 | "idiv{q}\t$src", []>; |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 768 | let mayLoad = 1 in { |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 769 | // RDX:RAX/[mem64] = RAX,RDX |
| 770 | def DIV64m : RI<0xF7, MRM6m, (outs), (ins i64mem:$src), |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 771 | "div{q}\t$src", []>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 772 | // RDX:RAX/[mem64] = RAX,RDX |
| 773 | def IDIV64m: RI<0xF7, MRM7m, (outs), (ins i64mem:$src), |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 774 | "idiv{q}\t$src", []>; |
| 775 | } |
Chris Lattner | ba7e756 | 2008-01-10 07:59:24 +0000 | [diff] [blame] | 776 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 777 | |
| 778 | // Unary instructions |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 779 | let Defs = [EFLAGS], CodeSize = 2 in { |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 780 | let isTwoAddress = 1 in |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 781 | def NEG64r : RI<0xF7, MRM3r, (outs GR64:$dst), (ins GR64:$src), "neg{q}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 782 | [(set GR64:$dst, (ineg GR64:$src)), |
| 783 | (implicit EFLAGS)]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 784 | def NEG64m : RI<0xF7, MRM3m, (outs), (ins i64mem:$dst), "neg{q}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 785 | [(store (ineg (loadi64 addr:$dst)), addr:$dst), |
| 786 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 787 | |
| 788 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 789 | def INC64r : RI<0xFF, MRM0r, (outs GR64:$dst), (ins GR64:$src), "inc{q}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 790 | [(set GR64:$dst, (add GR64:$src, 1)), |
| 791 | (implicit EFLAGS)]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 792 | def INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), "inc{q}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 793 | [(store (add (loadi64 addr:$dst), 1), addr:$dst), |
| 794 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 795 | |
| 796 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 797 | def DEC64r : RI<0xFF, MRM1r, (outs GR64:$dst), (ins GR64:$src), "dec{q}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 798 | [(set GR64:$dst, (add GR64:$src, -1)), |
| 799 | (implicit EFLAGS)]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 800 | def DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), "dec{q}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 801 | [(store (add (loadi64 addr:$dst), -1), addr:$dst), |
| 802 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 803 | |
| 804 | // In 64-bit mode, single byte INC and DEC cannot be encoded. |
| 805 | let isTwoAddress = 1, isConvertibleToThreeAddress = 1 in { |
| 806 | // Can transform into LEA. |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 807 | def INC64_16r : I<0xFF, MRM0r, (outs GR16:$dst), (ins GR16:$src), |
| 808 | "inc{w}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 809 | [(set GR16:$dst, (add GR16:$src, 1)), |
| 810 | (implicit EFLAGS)]>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 811 | OpSize, Requires<[In64BitMode]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 812 | def INC64_32r : I<0xFF, MRM0r, (outs GR32:$dst), (ins GR32:$src), |
| 813 | "inc{l}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 814 | [(set GR32:$dst, (add GR32:$src, 1)), |
| 815 | (implicit EFLAGS)]>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 816 | Requires<[In64BitMode]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 817 | def DEC64_16r : I<0xFF, MRM1r, (outs GR16:$dst), (ins GR16:$src), |
| 818 | "dec{w}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 819 | [(set GR16:$dst, (add GR16:$src, -1)), |
| 820 | (implicit EFLAGS)]>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 821 | OpSize, Requires<[In64BitMode]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 822 | def DEC64_32r : I<0xFF, MRM1r, (outs GR32:$dst), (ins GR32:$src), |
| 823 | "dec{l}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 824 | [(set GR32:$dst, (add GR32:$src, -1)), |
| 825 | (implicit EFLAGS)]>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 826 | Requires<[In64BitMode]>; |
| 827 | } // isConvertibleToThreeAddress |
Evan Cheng | 66f7163 | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 828 | |
| 829 | // These are duplicates of their 32-bit counterparts. Only needed so X86 knows |
| 830 | // how to unfold them. |
| 831 | let isTwoAddress = 0, CodeSize = 2 in { |
| 832 | def INC64_16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), "inc{w}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 833 | [(store (add (loadi16 addr:$dst), 1), addr:$dst), |
| 834 | (implicit EFLAGS)]>, |
Evan Cheng | 66f7163 | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 835 | OpSize, Requires<[In64BitMode]>; |
| 836 | def INC64_32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), "inc{l}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 837 | [(store (add (loadi32 addr:$dst), 1), addr:$dst), |
| 838 | (implicit EFLAGS)]>, |
Evan Cheng | 66f7163 | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 839 | Requires<[In64BitMode]>; |
| 840 | def DEC64_16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), "dec{w}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 841 | [(store (add (loadi16 addr:$dst), -1), addr:$dst), |
| 842 | (implicit EFLAGS)]>, |
Evan Cheng | 66f7163 | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 843 | OpSize, Requires<[In64BitMode]>; |
| 844 | def DEC64_32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), "dec{l}\t$dst", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 845 | [(store (add (loadi32 addr:$dst), -1), addr:$dst), |
| 846 | (implicit EFLAGS)]>, |
Evan Cheng | 66f7163 | 2007-10-19 21:23:22 +0000 | [diff] [blame] | 847 | Requires<[In64BitMode]>; |
| 848 | } |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 849 | } // Defs = [EFLAGS], CodeSize |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 850 | |
| 851 | |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 852 | let Defs = [EFLAGS] in { |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 853 | // Shift instructions |
| 854 | let isTwoAddress = 1 in { |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 855 | let Uses = [CL] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 856 | def SHL64rCL : RI<0xD3, MRM4r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 857 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 858 | [(set GR64:$dst, (shl GR64:$src, CL))]>; |
Evan Cheng | b952d1f | 2007-10-05 18:20:36 +0000 | [diff] [blame] | 859 | let isConvertibleToThreeAddress = 1 in // Can transform into LEA. |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 860 | def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst), |
| 861 | (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 862 | "shl{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 863 | [(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>; |
Sean Callanan | 13cf8e9 | 2009-09-16 02:28:43 +0000 | [diff] [blame] | 864 | // NOTE: We don't include patterns for shifts of a register by one, because |
| 865 | // 'add reg,reg' is cheaper. |
| 866 | def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 867 | "shl{q}\t$dst", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 868 | } // isTwoAddress |
| 869 | |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 870 | let Uses = [CL] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 871 | def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 872 | "shl{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 873 | [(store (shl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 874 | def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 875 | "shl{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 876 | [(store (shl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 877 | def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 878 | "shl{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 879 | [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 880 | |
| 881 | let isTwoAddress = 1 in { |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 882 | let Uses = [CL] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 883 | def SHR64rCL : RI<0xD3, MRM5r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 884 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 885 | [(set GR64:$dst, (srl GR64:$src, CL))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 886 | 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] | 887 | "shr{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 888 | [(set GR64:$dst, (srl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 889 | def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 890 | "shr{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 891 | [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>; |
| 892 | } // isTwoAddress |
| 893 | |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 894 | let Uses = [CL] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 895 | def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 896 | "shr{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 897 | [(store (srl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 898 | def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 899 | "shr{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 900 | [(store (srl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 901 | def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 902 | "shr{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 903 | [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 904 | |
| 905 | let isTwoAddress = 1 in { |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 906 | let Uses = [CL] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 907 | def SAR64rCL : RI<0xD3, MRM7r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 908 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 909 | [(set GR64:$dst, (sra GR64:$src, CL))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 910 | def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst), |
| 911 | (ins GR64:$src1, i8imm:$src2), |
| 912 | "sar{q}\t{$src2, $dst|$dst, $src2}", |
| 913 | [(set GR64:$dst, (sra GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 914 | def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 915 | "sar{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 916 | [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>; |
| 917 | } // isTwoAddress |
| 918 | |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 919 | let Uses = [CL] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 920 | def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 921 | "sar{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 922 | [(store (sra (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 923 | def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 924 | "sar{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 925 | [(store (sra (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 926 | def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 927 | "sar{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 928 | [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 929 | |
| 930 | // Rotate instructions |
Sean Callanan | a2dc282 | 2009-09-18 19:35:23 +0000 | [diff] [blame] | 931 | |
| 932 | let isTwoAddress = 1 in { |
| 933 | def RCL64r1 : RI<0xD1, MRM2r, (outs GR64:$dst), (ins GR64:$src), |
| 934 | "rcl{q}\t{1, $dst|$dst, 1}", []>; |
Sean Callanan | a2dc282 | 2009-09-18 19:35:23 +0000 | [diff] [blame] | 935 | def RCL64ri : RIi8<0xC1, MRM2r, (outs GR64:$dst), (ins GR64:$src, i8imm:$cnt), |
| 936 | "rcl{q}\t{$cnt, $dst|$dst, $cnt}", []>; |
Sean Callanan | a2dc282 | 2009-09-18 19:35:23 +0000 | [diff] [blame] | 937 | |
| 938 | def RCR64r1 : RI<0xD1, MRM3r, (outs GR64:$dst), (ins GR64:$src), |
| 939 | "rcr{q}\t{1, $dst|$dst, 1}", []>; |
Sean Callanan | a2dc282 | 2009-09-18 19:35:23 +0000 | [diff] [blame] | 940 | def RCR64ri : RIi8<0xC1, MRM3r, (outs GR64:$dst), (ins GR64:$src, i8imm:$cnt), |
| 941 | "rcr{q}\t{$cnt, $dst|$dst, $cnt}", []>; |
Daniel Dunbar | ccfa1db | 2010-02-12 01:22:03 +0000 | [diff] [blame] | 942 | |
| 943 | let Uses = [CL] in { |
| 944 | def RCL64rCL : RI<0xD3, MRM2r, (outs GR64:$dst), (ins GR64:$src), |
| 945 | "rcl{q}\t{%cl, $dst|$dst, CL}", []>; |
| 946 | def RCR64rCL : RI<0xD3, MRM3r, (outs GR64:$dst), (ins GR64:$src), |
| 947 | "rcr{q}\t{%cl, $dst|$dst, CL}", []>; |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | let isTwoAddress = 0 in { |
| 952 | def RCL64m1 : RI<0xD1, MRM2m, (outs), (ins i64mem:$dst), |
| 953 | "rcl{q}\t{1, $dst|$dst, 1}", []>; |
| 954 | def RCL64mi : RIi8<0xC1, MRM2m, (outs), (ins i64mem:$dst, i8imm:$cnt), |
| 955 | "rcl{q}\t{$cnt, $dst|$dst, $cnt}", []>; |
| 956 | def RCR64m1 : RI<0xD1, MRM3m, (outs), (ins i64mem:$dst), |
| 957 | "rcr{q}\t{1, $dst|$dst, 1}", []>; |
| 958 | def RCR64mi : RIi8<0xC1, MRM3m, (outs), (ins i64mem:$dst, i8imm:$cnt), |
Sean Callanan | a2dc282 | 2009-09-18 19:35:23 +0000 | [diff] [blame] | 959 | "rcr{q}\t{$cnt, $dst|$dst, $cnt}", []>; |
Daniel Dunbar | ccfa1db | 2010-02-12 01:22:03 +0000 | [diff] [blame] | 960 | |
| 961 | let Uses = [CL] in { |
| 962 | def RCL64mCL : RI<0xD3, MRM2m, (outs), (ins i64mem:$dst), |
| 963 | "rcl{q}\t{%cl, $dst|$dst, CL}", []>; |
| 964 | def RCR64mCL : RI<0xD3, MRM3m, (outs), (ins i64mem:$dst), |
| 965 | "rcr{q}\t{%cl, $dst|$dst, CL}", []>; |
| 966 | } |
Sean Callanan | a2dc282 | 2009-09-18 19:35:23 +0000 | [diff] [blame] | 967 | } |
| 968 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 969 | let isTwoAddress = 1 in { |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 970 | let Uses = [CL] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 971 | def ROL64rCL : RI<0xD3, MRM0r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 972 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 973 | [(set GR64:$dst, (rotl GR64:$src, CL))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 974 | def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst), |
| 975 | (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 976 | "rol{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 977 | [(set GR64:$dst, (rotl GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 978 | def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 979 | "rol{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 980 | [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>; |
| 981 | } // isTwoAddress |
| 982 | |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 983 | let Uses = [CL] in |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 984 | def ROL64mCL : RI<0xD3, MRM0m, (outs), (ins i64mem:$dst), |
| 985 | "rol{q}\t{%cl, $dst|$dst, %CL}", |
| 986 | [(store (rotl (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 987 | def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 988 | "rol{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 989 | [(store (rotl (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 990 | def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 991 | "rol{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 992 | [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 993 | |
| 994 | let isTwoAddress = 1 in { |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 995 | let Uses = [CL] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 996 | def ROR64rCL : RI<0xD3, MRM1r, (outs GR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 997 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 998 | [(set GR64:$dst, (rotr GR64:$src, CL))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 999 | def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst), |
| 1000 | (ins GR64:$src1, i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1001 | "ror{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1002 | [(set GR64:$dst, (rotr GR64:$src1, (i8 imm:$src2)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1003 | def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1004 | "ror{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1005 | [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>; |
| 1006 | } // isTwoAddress |
| 1007 | |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1008 | let Uses = [CL] in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1009 | def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1010 | "ror{q}\t{%cl, $dst|$dst, %CL}", |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1011 | [(store (rotr (loadi64 addr:$dst), CL), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1012 | def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1013 | "ror{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1014 | [(store (rotr (loadi64 addr:$dst), (i8 imm:$src)), addr:$dst)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1015 | def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1016 | "ror{q}\t$dst", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1017 | [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>; |
| 1018 | |
| 1019 | // Double shift instructions (generalizations of rotate) |
| 1020 | let isTwoAddress = 1 in { |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1021 | let Uses = [CL] in { |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1022 | def SHLD64rrCL : RI<0xA5, MRMDestReg, (outs GR64:$dst), |
| 1023 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | e47f1f9 | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 1024 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1025 | [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, CL))]>, |
| 1026 | TB; |
| 1027 | def SHRD64rrCL : RI<0xAD, MRMDestReg, (outs GR64:$dst), |
| 1028 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | e47f1f9 | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 1029 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1030 | [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, CL))]>, |
| 1031 | TB; |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1032 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1033 | |
| 1034 | let isCommutable = 1 in { // FIXME: Update X86InstrInfo::commuteInstruction |
| 1035 | def SHLD64rri8 : RIi8<0xA4, MRMDestReg, |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1036 | (outs GR64:$dst), |
| 1037 | (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | e47f1f9 | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 1038 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 1039 | [(set GR64:$dst, (X86shld GR64:$src1, GR64:$src2, |
| 1040 | (i8 imm:$src3)))]>, |
| 1041 | TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1042 | def SHRD64rri8 : RIi8<0xAC, MRMDestReg, |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1043 | (outs GR64:$dst), |
| 1044 | (ins GR64:$src1, GR64:$src2, i8imm:$src3), |
Dan Gohman | e47f1f9 | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 1045 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 1046 | [(set GR64:$dst, (X86shrd GR64:$src1, GR64:$src2, |
| 1047 | (i8 imm:$src3)))]>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1048 | TB; |
| 1049 | } // isCommutable |
| 1050 | } // isTwoAddress |
| 1051 | |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1052 | let Uses = [CL] in { |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1053 | def SHLD64mrCL : RI<0xA5, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | e47f1f9 | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 1054 | "shld{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 1055 | [(store (X86shld (loadi64 addr:$dst), GR64:$src2, CL), |
| 1056 | addr:$dst)]>, TB; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1057 | def SHRD64mrCL : RI<0xAD, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
Dan Gohman | e47f1f9 | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 1058 | "shrd{q}\t{%cl, $src2, $dst|$dst, $src2, %CL}", |
| 1059 | [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, CL), |
| 1060 | addr:$dst)]>, TB; |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1061 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1062 | def SHLD64mri8 : RIi8<0xA4, MRMDestMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1063 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | e47f1f9 | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 1064 | "shld{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 1065 | [(store (X86shld (loadi64 addr:$dst), GR64:$src2, |
| 1066 | (i8 imm:$src3)), addr:$dst)]>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1067 | TB; |
| 1068 | def SHRD64mri8 : RIi8<0xAC, MRMDestMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1069 | (outs), (ins i64mem:$dst, GR64:$src2, i8imm:$src3), |
Dan Gohman | e47f1f9 | 2007-09-14 23:17:45 +0000 | [diff] [blame] | 1070 | "shrd{q}\t{$src3, $src2, $dst|$dst, $src2, $src3}", |
| 1071 | [(store (X86shrd (loadi64 addr:$dst), GR64:$src2, |
| 1072 | (i8 imm:$src3)), addr:$dst)]>, |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1073 | TB; |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 1074 | } // Defs = [EFLAGS] |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1075 | |
| 1076 | //===----------------------------------------------------------------------===// |
| 1077 | // Logical Instructions... |
| 1078 | // |
| 1079 | |
Evan Cheng | a095c97 | 2009-01-21 19:45:31 +0000 | [diff] [blame] | 1080 | let isTwoAddress = 1 , AddedComplexity = 15 in |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1081 | 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] | 1082 | [(set GR64:$dst, (not GR64:$src))]>; |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1083 | 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] | 1084 | [(store (not (loadi64 addr:$dst)), addr:$dst)]>; |
| 1085 | |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 1086 | let Defs = [EFLAGS] in { |
Daniel Dunbar | bf2d4c0 | 2010-03-13 22:57:53 +0000 | [diff] [blame] | 1087 | def AND64i32 : RIi32<0x25, RawFrm, (outs), (ins i32imm:$src), |
| 1088 | "and{q}\t{$src, %rax|%rax, $src}", []>; |
Sean Callanan | a09caa5 | 2009-09-02 00:55:49 +0000 | [diff] [blame] | 1089 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1090 | let isTwoAddress = 1 in { |
| 1091 | let isCommutable = 1 in |
| 1092 | def AND64rr : RI<0x21, MRMDestReg, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1093 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1094 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1095 | [(set GR64:$dst, (and GR64:$src1, GR64:$src2)), |
| 1096 | (implicit EFLAGS)]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1097 | def AND64rr_REV : RI<0x23, MRMSrcReg, (outs GR64:$dst), |
| 1098 | (ins GR64:$src1, GR64:$src2), |
| 1099 | "and{q}\t{$src2, $dst|$dst, $src2}", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1100 | def AND64rm : RI<0x23, MRMSrcMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1101 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1102 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1103 | [(set GR64:$dst, (and GR64:$src1, (load addr:$src2))), |
| 1104 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1105 | def AND64ri8 : RIi8<0x83, MRM4r, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1106 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1107 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1108 | [(set GR64:$dst, (and GR64:$src1, i64immSExt8:$src2)), |
| 1109 | (implicit EFLAGS)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1110 | def AND64ri32 : RIi32<0x81, MRM4r, |
| 1111 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 1112 | "and{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1113 | [(set GR64:$dst, (and GR64:$src1, i64immSExt32:$src2)), |
| 1114 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1115 | } // isTwoAddress |
| 1116 | |
| 1117 | def AND64mr : RI<0x21, MRMDestMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1118 | (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1119 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1120 | [(store (and (load addr:$dst), GR64:$src), addr:$dst), |
| 1121 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1122 | def AND64mi8 : RIi8<0x83, MRM4m, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1123 | (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1124 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1125 | [(store (and (load addr:$dst), i64immSExt8:$src), addr:$dst), |
| 1126 | (implicit EFLAGS)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1127 | def AND64mi32 : RIi32<0x81, MRM4m, |
| 1128 | (outs), (ins i64mem:$dst, i64i32imm:$src), |
| 1129 | "and{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1130 | [(store (and (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), |
| 1131 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1132 | |
| 1133 | let isTwoAddress = 1 in { |
| 1134 | let isCommutable = 1 in |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1135 | def OR64rr : RI<0x09, MRMDestReg, (outs GR64:$dst), |
| 1136 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1137 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 3bda201 | 2010-01-12 18:31:19 +0000 | [diff] [blame] | 1138 | [(set GR64:$dst, (or GR64:$src1, GR64:$src2)), |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1139 | (implicit EFLAGS)]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1140 | def OR64rr_REV : RI<0x0B, MRMSrcReg, (outs GR64:$dst), |
| 1141 | (ins GR64:$src1, GR64:$src2), |
| 1142 | "or{q}\t{$src2, $dst|$dst, $src2}", []>; |
| 1143 | def OR64rm : RI<0x0B, MRMSrcMem , (outs GR64:$dst), |
| 1144 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1145 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1146 | [(set GR64:$dst, (or GR64:$src1, (load addr:$src2))), |
| 1147 | (implicit EFLAGS)]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1148 | def OR64ri8 : RIi8<0x83, MRM1r, (outs GR64:$dst), |
| 1149 | (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1150 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 3bda201 | 2010-01-12 18:31:19 +0000 | [diff] [blame] | 1151 | [(set GR64:$dst, (or GR64:$src1, i64immSExt8:$src2)), |
Evan Cheng | 4b0345b | 2010-01-11 17:03:47 +0000 | [diff] [blame] | 1152 | (implicit EFLAGS)]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1153 | def OR64ri32 : RIi32<0x81, MRM1r, (outs GR64:$dst), |
| 1154 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1155 | "or{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 3bda201 | 2010-01-12 18:31:19 +0000 | [diff] [blame] | 1156 | [(set GR64:$dst, (or GR64:$src1, i64immSExt32:$src2)), |
Evan Cheng | 4b0345b | 2010-01-11 17:03:47 +0000 | [diff] [blame] | 1157 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1158 | } // isTwoAddress |
| 1159 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1160 | def OR64mr : RI<0x09, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1161 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1162 | [(store (or (load addr:$dst), GR64:$src), addr:$dst), |
| 1163 | (implicit EFLAGS)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1164 | def OR64mi8 : RIi8<0x83, MRM1m, (outs), (ins i64mem:$dst, i64i8imm:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1165 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1166 | [(store (or (load addr:$dst), i64immSExt8:$src), addr:$dst), |
| 1167 | (implicit EFLAGS)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1168 | def OR64mi32 : RIi32<0x81, MRM1m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
| 1169 | "or{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1170 | [(store (or (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), |
| 1171 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1172 | |
Sean Callanan | d00025a | 2009-09-11 19:01:56 +0000 | [diff] [blame] | 1173 | def OR64i32 : RIi32<0x0D, RawFrm, (outs), (ins i32imm:$src), |
| 1174 | "or{q}\t{$src, %rax|%rax, $src}", []>; |
| 1175 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1176 | let isTwoAddress = 1 in { |
Evan Cheng | b18ae3c | 2008-08-30 08:54:22 +0000 | [diff] [blame] | 1177 | let isCommutable = 1 in |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1178 | def XOR64rr : RI<0x31, MRMDestReg, (outs GR64:$dst), |
| 1179 | (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1180 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1181 | [(set GR64:$dst, (xor GR64:$src1, GR64:$src2)), |
| 1182 | (implicit EFLAGS)]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1183 | def XOR64rr_REV : RI<0x33, MRMSrcReg, (outs GR64:$dst), |
| 1184 | (ins GR64:$src1, GR64:$src2), |
| 1185 | "xor{q}\t{$src2, $dst|$dst, $src2}", []>; |
| 1186 | def XOR64rm : RI<0x33, MRMSrcMem, (outs GR64:$dst), |
| 1187 | (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1188 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1189 | [(set GR64:$dst, (xor GR64:$src1, (load addr:$src2))), |
| 1190 | (implicit EFLAGS)]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1191 | def XOR64ri8 : RIi8<0x83, MRM6r, (outs GR64:$dst), |
| 1192 | (ins GR64:$src1, i64i8imm:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1193 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1194 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt8:$src2)), |
| 1195 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1196 | def XOR64ri32 : RIi32<0x81, MRM6r, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1197 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1198 | "xor{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1199 | [(set GR64:$dst, (xor GR64:$src1, i64immSExt32:$src2)), |
| 1200 | (implicit EFLAGS)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1201 | } // isTwoAddress |
| 1202 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1203 | def XOR64mr : RI<0x31, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1204 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1205 | [(store (xor (load addr:$dst), GR64:$src), addr:$dst), |
| 1206 | (implicit EFLAGS)]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1207 | def XOR64mi8 : RIi8<0x83, MRM6m, (outs), (ins i64mem:$dst, i64i8imm :$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1208 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1209 | [(store (xor (load addr:$dst), i64immSExt8:$src), addr:$dst), |
| 1210 | (implicit EFLAGS)]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1211 | def XOR64mi32 : RIi32<0x81, MRM6m, (outs), (ins i64mem:$dst, i64i32imm:$src), |
| 1212 | "xor{q}\t{$src, $dst|$dst, $src}", |
Dan Gohman | 09a2609e | 2009-03-03 19:53:46 +0000 | [diff] [blame] | 1213 | [(store (xor (loadi64 addr:$dst), i64immSExt32:$src), addr:$dst), |
| 1214 | (implicit EFLAGS)]>; |
Sean Callanan | 7893ec6 | 2009-09-10 19:52:26 +0000 | [diff] [blame] | 1215 | |
| 1216 | def XOR64i32 : RIi32<0x35, RawFrm, (outs), (ins i32imm:$src), |
| 1217 | "xor{q}\t{$src, %rax|%rax, $src}", []>; |
| 1218 | |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 1219 | } // Defs = [EFLAGS] |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1220 | |
| 1221 | //===----------------------------------------------------------------------===// |
| 1222 | // Comparison Instructions... |
| 1223 | // |
| 1224 | |
| 1225 | // Integer comparison |
Evan Cheng | 24f2ea3 | 2007-09-14 21:48:26 +0000 | [diff] [blame] | 1226 | let Defs = [EFLAGS] in { |
Daniel Dunbar | bf2d4c0 | 2010-03-13 22:57:53 +0000 | [diff] [blame] | 1227 | def TEST64i32 : RIi32<0xa9, RawFrm, (outs), (ins i32imm:$src), |
| 1228 | "test{q}\t{$src, %rax|%rax, $src}", []>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1229 | let isCommutable = 1 in |
Daniel Dunbar | c28c768 | 2010-03-19 01:15:03 +0000 | [diff] [blame] | 1230 | def TEST64rr : RI<0x85, MRMSrcReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1231 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1232 | [(set EFLAGS, (X86cmp (and GR64:$src1, GR64:$src2), 0))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1233 | def TEST64rm : RI<0x85, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1234 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1235 | [(set EFLAGS, (X86cmp (and GR64:$src1, (loadi64 addr:$src2)), |
| 1236 | 0))]>; |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1237 | def TEST64ri32 : RIi32<0xF7, MRM0r, (outs), |
| 1238 | (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1239 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1240 | [(set EFLAGS, (X86cmp (and GR64:$src1, i64immSExt32:$src2), |
| 1241 | 0))]>; |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1242 | def TEST64mi32 : RIi32<0xF7, MRM0m, (outs), |
| 1243 | (ins i64mem:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1244 | "test{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1245 | [(set EFLAGS, (X86cmp (and (loadi64 addr:$src1), |
| 1246 | i64immSExt32:$src2), 0))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1247 | |
Sean Callanan | a09caa5 | 2009-09-02 00:55:49 +0000 | [diff] [blame] | 1248 | |
Daniel Dunbar | bf2d4c0 | 2010-03-13 22:57:53 +0000 | [diff] [blame] | 1249 | def CMP64i32 : RIi32<0x3D, RawFrm, (outs), (ins i32imm:$src), |
| 1250 | "cmp{q}\t{$src, %rax|%rax, $src}", []>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1251 | def CMP64rr : RI<0x39, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1252 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1253 | [(set EFLAGS, (X86cmp GR64:$src1, GR64:$src2))]>; |
Daniel Dunbar | 0180dae | 2010-03-19 18:07:48 +0000 | [diff] [blame^] | 1254 | |
| 1255 | // These are alternate spellings for use by the disassembler, we mark them as |
| 1256 | // code gen only to ensure they aren't matched by the assembler. |
| 1257 | let isCodeGenOnly = 1 in { |
| 1258 | def CMP64mrmrr : RI<0x3B, MRMSrcReg, (outs), (ins GR64:$src1, GR64:$src2), |
| 1259 | "cmp{q}\t{$src2, $src1|$src1, $src2}", []>; |
| 1260 | } |
| 1261 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1262 | def CMP64mr : RI<0x39, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1263 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1264 | [(set EFLAGS, (X86cmp (loadi64 addr:$src1), GR64:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1265 | def CMP64rm : RI<0x3B, MRMSrcMem, (outs), (ins GR64:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1266 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1267 | [(set EFLAGS, (X86cmp GR64:$src1, (loadi64 addr:$src2)))]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1268 | def CMP64ri8 : RIi8<0x83, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
| 1269 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1270 | [(set EFLAGS, (X86cmp GR64:$src1, i64immSExt8:$src2))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1271 | def CMP64ri32 : RIi32<0x81, MRM7r, (outs), (ins GR64:$src1, i64i32imm:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1272 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1273 | [(set EFLAGS, (X86cmp GR64:$src1, i64immSExt32:$src2))]>; |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1274 | def CMP64mi8 : RIi8<0x83, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
Evan Cheng | 0488db9 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1275 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1276 | [(set EFLAGS, (X86cmp (loadi64 addr:$src1), |
| 1277 | i64immSExt8:$src2))]>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 1278 | def CMP64mi32 : RIi32<0x81, MRM7m, (outs), |
| 1279 | (ins i64mem:$src1, i64i32imm:$src2), |
| 1280 | "cmp{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1281 | [(set EFLAGS, (X86cmp (loadi64 addr:$src1), |
| 1282 | i64immSExt32:$src2))]>; |
Evan Cheng | 0488db9 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1283 | } // Defs = [EFLAGS] |
| 1284 | |
Dan Gohman | c7a37d4 | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 1285 | // Bit tests. |
Dan Gohman | c7a37d4 | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 1286 | // TODO: BTC, BTR, and BTS |
| 1287 | let Defs = [EFLAGS] in { |
Chris Lattner | f1e9fd5 | 2008-12-25 01:32:49 +0000 | [diff] [blame] | 1288 | def BT64rr : RI<0xA3, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
Dan Gohman | c7a37d4 | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 1289 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1290 | [(set EFLAGS, (X86bt GR64:$src1, GR64:$src2))]>, TB; |
Dan Gohman | f31408d | 2009-01-13 23:23:30 +0000 | [diff] [blame] | 1291 | |
| 1292 | // Unlike with the register+register form, the memory+register form of the |
| 1293 | // bt instruction does not ignore the high bits of the index. From ISel's |
| 1294 | // perspective, this is pretty bizarre. Disable these instructions for now. |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1295 | def BT64mr : RI<0xA3, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
| 1296 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
Dan Gohman | f31408d | 2009-01-13 23:23:30 +0000 | [diff] [blame] | 1297 | // [(X86bt (loadi64 addr:$src1), GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1298 | // (implicit EFLAGS)] |
| 1299 | [] |
| 1300 | >, TB; |
Dan Gohman | 4afe15b | 2009-01-13 20:33:23 +0000 | [diff] [blame] | 1301 | |
| 1302 | def BT64ri8 : Ii8<0xBA, MRM4r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
| 1303 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1304 | [(set EFLAGS, (X86bt GR64:$src1, i64immSExt8:$src2))]>, TB; |
Dan Gohman | 4afe15b | 2009-01-13 20:33:23 +0000 | [diff] [blame] | 1305 | // Note that these instructions don't need FastBTMem because that |
| 1306 | // only applies when the other operand is in a register. When it's |
| 1307 | // an immediate, bt is still fast. |
| 1308 | def BT64mi8 : Ii8<0xBA, MRM4m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
| 1309 | "bt{q}\t{$src2, $src1|$src1, $src2}", |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1310 | [(set EFLAGS, (X86bt (loadi64 addr:$src1), |
| 1311 | i64immSExt8:$src2))]>, TB; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1312 | |
| 1313 | def BTC64rr : RI<0xBB, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
| 1314 | "btc{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1315 | def BTC64mr : RI<0xBB, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
| 1316 | "btc{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1317 | def BTC64ri8 : RIi8<0xBA, MRM7r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
| 1318 | "btc{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1319 | def BTC64mi8 : RIi8<0xBA, MRM7m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
| 1320 | "btc{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1321 | |
| 1322 | def BTR64rr : RI<0xB3, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
| 1323 | "btr{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1324 | def BTR64mr : RI<0xB3, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
| 1325 | "btr{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1326 | def BTR64ri8 : RIi8<0xBA, MRM6r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
| 1327 | "btr{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1328 | def BTR64mi8 : RIi8<0xBA, MRM6m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
| 1329 | "btr{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1330 | |
| 1331 | def BTS64rr : RI<0xAB, MRMDestReg, (outs), (ins GR64:$src1, GR64:$src2), |
| 1332 | "bts{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1333 | def BTS64mr : RI<0xAB, MRMDestMem, (outs), (ins i64mem:$src1, GR64:$src2), |
| 1334 | "bts{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1335 | def BTS64ri8 : RIi8<0xBA, MRM5r, (outs), (ins GR64:$src1, i64i8imm:$src2), |
| 1336 | "bts{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
| 1337 | def BTS64mi8 : RIi8<0xBA, MRM5m, (outs), (ins i64mem:$src1, i64i8imm:$src2), |
| 1338 | "bts{q}\t{$src2, $src1|$src1, $src2}", []>, TB; |
Dan Gohman | c7a37d4 | 2008-12-23 22:45:23 +0000 | [diff] [blame] | 1339 | } // Defs = [EFLAGS] |
| 1340 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1341 | // Conditional moves |
Evan Cheng | 0488db9 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1342 | let Uses = [EFLAGS], isTwoAddress = 1 in { |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1343 | let isCommutable = 1 in { |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1344 | def CMOVB64rr : RI<0x42, MRMSrcReg, // if <u, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1345 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1346 | "cmovb{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1347 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1348 | X86_COND_B, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1349 | def CMOVAE64rr: RI<0x43, MRMSrcReg, // if >=u, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1350 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1351 | "cmovae{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1352 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1353 | X86_COND_AE, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1354 | def CMOVE64rr : RI<0x44, MRMSrcReg, // if ==, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1355 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1356 | "cmove{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1357 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1358 | X86_COND_E, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1359 | def CMOVNE64rr: RI<0x45, MRMSrcReg, // if !=, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1360 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1361 | "cmovne{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1362 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1363 | X86_COND_NE, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1364 | def CMOVBE64rr: RI<0x46, MRMSrcReg, // if <=u, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1365 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1366 | "cmovbe{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1367 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1368 | X86_COND_BE, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1369 | def CMOVA64rr : RI<0x47, MRMSrcReg, // if >u, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1370 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1371 | "cmova{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1372 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1373 | X86_COND_A, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1374 | def CMOVL64rr : RI<0x4C, MRMSrcReg, // if <s, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1375 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1376 | "cmovl{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1377 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1378 | X86_COND_L, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1379 | def CMOVGE64rr: RI<0x4D, MRMSrcReg, // if >=s, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1380 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1381 | "cmovge{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1382 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1383 | X86_COND_GE, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1384 | def CMOVLE64rr: RI<0x4E, MRMSrcReg, // if <=s, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1385 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1386 | "cmovle{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1387 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1388 | X86_COND_LE, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1389 | def CMOVG64rr : RI<0x4F, MRMSrcReg, // if >s, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1390 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1391 | "cmovg{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1392 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1393 | X86_COND_G, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1394 | def CMOVS64rr : RI<0x48, MRMSrcReg, // if signed, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1395 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1396 | "cmovs{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1397 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1398 | X86_COND_S, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1399 | def CMOVNS64rr: RI<0x49, MRMSrcReg, // if !signed, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1400 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1401 | "cmovns{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1402 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1403 | X86_COND_NS, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1404 | def CMOVP64rr : RI<0x4A, MRMSrcReg, // if parity, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1405 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1406 | "cmovp{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1407 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1408 | X86_COND_P, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1409 | def CMOVNP64rr : RI<0x4B, MRMSrcReg, // if !parity, GR64 = GR64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1410 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1411 | "cmovnp{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1412 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
Evan Cheng | e5f6204 | 2007-09-29 00:00:36 +0000 | [diff] [blame] | 1413 | X86_COND_NP, EFLAGS))]>, TB; |
Dan Gohman | 305fceb | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1414 | def CMOVO64rr : RI<0x40, MRMSrcReg, // if overflow, GR64 = GR64 |
| 1415 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1416 | "cmovo{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 305fceb | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1417 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 1418 | X86_COND_O, EFLAGS))]>, TB; |
| 1419 | def CMOVNO64rr : RI<0x41, MRMSrcReg, // if !overflow, GR64 = GR64 |
| 1420 | (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1421 | "cmovno{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 305fceb | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1422 | [(set GR64:$dst, (X86cmov GR64:$src1, GR64:$src2, |
| 1423 | X86_COND_NO, EFLAGS))]>, TB; |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1424 | } // isCommutable = 1 |
| 1425 | |
| 1426 | def CMOVB64rm : RI<0x42, MRMSrcMem, // if <u, GR64 = [mem64] |
| 1427 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1428 | "cmovb{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1429 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1430 | X86_COND_B, EFLAGS))]>, TB; |
| 1431 | def CMOVAE64rm: RI<0x43, MRMSrcMem, // if >=u, GR64 = [mem64] |
| 1432 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1433 | "cmovae{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1434 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1435 | X86_COND_AE, EFLAGS))]>, TB; |
| 1436 | def CMOVE64rm : RI<0x44, MRMSrcMem, // if ==, GR64 = [mem64] |
| 1437 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1438 | "cmove{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1439 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1440 | X86_COND_E, EFLAGS))]>, TB; |
| 1441 | def CMOVNE64rm: RI<0x45, MRMSrcMem, // if !=, GR64 = [mem64] |
| 1442 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1443 | "cmovne{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1444 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1445 | X86_COND_NE, EFLAGS))]>, TB; |
| 1446 | def CMOVBE64rm: RI<0x46, MRMSrcMem, // if <=u, GR64 = [mem64] |
| 1447 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1448 | "cmovbe{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1449 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1450 | X86_COND_BE, EFLAGS))]>, TB; |
| 1451 | def CMOVA64rm : RI<0x47, MRMSrcMem, // if >u, GR64 = [mem64] |
| 1452 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1453 | "cmova{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1454 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1455 | X86_COND_A, EFLAGS))]>, TB; |
| 1456 | def CMOVL64rm : RI<0x4C, MRMSrcMem, // if <s, GR64 = [mem64] |
| 1457 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1458 | "cmovl{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1459 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1460 | X86_COND_L, EFLAGS))]>, TB; |
| 1461 | def CMOVGE64rm: RI<0x4D, MRMSrcMem, // if >=s, GR64 = [mem64] |
| 1462 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1463 | "cmovge{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1464 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1465 | X86_COND_GE, EFLAGS))]>, TB; |
| 1466 | def CMOVLE64rm: RI<0x4E, MRMSrcMem, // if <=s, GR64 = [mem64] |
| 1467 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1468 | "cmovle{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1469 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1470 | X86_COND_LE, EFLAGS))]>, TB; |
| 1471 | def CMOVG64rm : RI<0x4F, MRMSrcMem, // if >s, GR64 = [mem64] |
| 1472 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1473 | "cmovg{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1474 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1475 | X86_COND_G, EFLAGS))]>, TB; |
| 1476 | def CMOVS64rm : RI<0x48, MRMSrcMem, // if signed, GR64 = [mem64] |
| 1477 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1478 | "cmovs{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1479 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1480 | X86_COND_S, EFLAGS))]>, TB; |
| 1481 | def CMOVNS64rm: RI<0x49, MRMSrcMem, // if !signed, GR64 = [mem64] |
| 1482 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1483 | "cmovns{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1484 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1485 | X86_COND_NS, EFLAGS))]>, TB; |
| 1486 | def CMOVP64rm : RI<0x4A, MRMSrcMem, // if parity, GR64 = [mem64] |
| 1487 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1488 | "cmovp{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 7ad42d9 | 2007-10-05 23:13:21 +0000 | [diff] [blame] | 1489 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1490 | X86_COND_P, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1491 | def CMOVNP64rm : RI<0x4B, MRMSrcMem, // if !parity, GR64 = [mem64] |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1492 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1493 | "cmovnp{q}\t{$src2, $dst|$dst, $src2}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1494 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
Evan Cheng | 0488db9 | 2007-09-25 01:57:46 +0000 | [diff] [blame] | 1495 | X86_COND_NP, EFLAGS))]>, TB; |
Dan Gohman | 305fceb | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1496 | def CMOVO64rm : RI<0x40, MRMSrcMem, // if overflow, GR64 = [mem64] |
| 1497 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1498 | "cmovo{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 305fceb | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1499 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1500 | X86_COND_O, EFLAGS))]>, TB; |
| 1501 | def CMOVNO64rm : RI<0x41, MRMSrcMem, // if !overflow, GR64 = [mem64] |
| 1502 | (outs GR64:$dst), (ins GR64:$src1, i64mem:$src2), |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1503 | "cmovno{q}\t{$src2, $dst|$dst, $src2}", |
Dan Gohman | 305fceb | 2009-01-07 00:35:10 +0000 | [diff] [blame] | 1504 | [(set GR64:$dst, (X86cmov GR64:$src1, (loadi64 addr:$src2), |
| 1505 | X86_COND_NO, EFLAGS))]>, TB; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1506 | } // isTwoAddress |
| 1507 | |
Evan Cheng | ad9c0a3 | 2009-12-15 00:53:42 +0000 | [diff] [blame] | 1508 | // Use sbb to materialize carry flag into a GPR. |
Chris Lattner | c74e333 | 2010-02-05 21:13:48 +0000 | [diff] [blame] | 1509 | // FIXME: This are pseudo ops that should be replaced with Pat<> patterns. |
| 1510 | // However, Pat<> can't replicate the destination reg into the inputs of the |
| 1511 | // result. |
| 1512 | // FIXME: Change this to have encoding Pseudo when X86MCCodeEmitter replaces |
| 1513 | // X86CodeEmitter. |
Evan Cheng | ad9c0a3 | 2009-12-15 00:53:42 +0000 | [diff] [blame] | 1514 | let Defs = [EFLAGS], Uses = [EFLAGS], isCodeGenOnly = 1 in |
Chris Lattner | c74e333 | 2010-02-05 21:13:48 +0000 | [diff] [blame] | 1515 | def SETB_C64r : RI<0x19, MRMInitReg, (outs GR64:$dst), (ins), "", |
Evan Cheng | 2e489c4 | 2009-12-16 00:53:11 +0000 | [diff] [blame] | 1516 | [(set GR64:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>; |
Evan Cheng | ad9c0a3 | 2009-12-15 00:53:42 +0000 | [diff] [blame] | 1517 | |
Evan Cheng | 2e489c4 | 2009-12-16 00:53:11 +0000 | [diff] [blame] | 1518 | def : Pat<(i64 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))), |
Evan Cheng | ad9c0a3 | 2009-12-15 00:53:42 +0000 | [diff] [blame] | 1519 | (SETB_C64r)>; |
| 1520 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1521 | //===----------------------------------------------------------------------===// |
| 1522 | // Conversion Instructions... |
| 1523 | // |
| 1524 | |
| 1525 | // f64 -> signed i64 |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1526 | def CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src), |
| 1527 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", []>; |
| 1528 | def CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src), |
| 1529 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", []>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1530 | def Int_CVTSD2SI64rr: RSDI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1531 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1532 | [(set GR64:$dst, |
| 1533 | (int_x86_sse2_cvtsd2si64 VR128:$src))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1534 | def Int_CVTSD2SI64rm: RSDI<0x2D, MRMSrcMem, (outs GR64:$dst), |
| 1535 | (ins f128mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1536 | "cvtsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1537 | [(set GR64:$dst, (int_x86_sse2_cvtsd2si64 |
| 1538 | (load addr:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1539 | def CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1540 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1541 | [(set GR64:$dst, (fp_to_sint FR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1542 | def CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1543 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1544 | [(set GR64:$dst, (fp_to_sint (loadf64 addr:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1545 | def Int_CVTTSD2SI64rr: RSDI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1546 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1547 | [(set GR64:$dst, |
| 1548 | (int_x86_sse2_cvttsd2si64 VR128:$src))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1549 | def Int_CVTTSD2SI64rm: RSDI<0x2C, MRMSrcMem, (outs GR64:$dst), |
| 1550 | (ins f128mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1551 | "cvttsd2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1552 | [(set GR64:$dst, |
| 1553 | (int_x86_sse2_cvttsd2si64 |
| 1554 | (load addr:$src)))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1555 | |
| 1556 | // Signed i64 -> f64 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1557 | def CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1558 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1559 | [(set FR64:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1560 | def CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1561 | "cvtsi2sd{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1562 | [(set FR64:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
Evan Cheng | 90e9d4e | 2008-01-11 07:37:44 +0000 | [diff] [blame] | 1563 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1564 | let isTwoAddress = 1 in { |
| 1565 | def Int_CVTSI2SD64rr: RSDI<0x2A, MRMSrcReg, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1566 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1567 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1568 | [(set VR128:$dst, |
| 1569 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 1570 | GR64:$src2))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1571 | def Int_CVTSI2SD64rm: RSDI<0x2A, MRMSrcMem, |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1572 | (outs VR128:$dst), (ins VR128:$src1, i64mem:$src2), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1573 | "cvtsi2sd{q}\t{$src2, $dst|$dst, $src2}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1574 | [(set VR128:$dst, |
| 1575 | (int_x86_sse2_cvtsi642sd VR128:$src1, |
| 1576 | (loadi64 addr:$src2)))]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1577 | } // isTwoAddress |
| 1578 | |
| 1579 | // Signed i64 -> f32 |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1580 | def CVTSI2SS64rr: RSSI<0x2A, MRMSrcReg, (outs FR32:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1581 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1582 | [(set FR32:$dst, (sint_to_fp GR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1583 | def CVTSI2SS64rm: RSSI<0x2A, MRMSrcMem, (outs FR32:$dst), (ins i64mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1584 | "cvtsi2ss{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1585 | [(set FR32:$dst, (sint_to_fp (loadi64 addr:$src)))]>; |
Evan Cheng | 90e9d4e | 2008-01-11 07:37:44 +0000 | [diff] [blame] | 1586 | |
| 1587 | let isTwoAddress = 1 in { |
| 1588 | def Int_CVTSI2SS64rr : RSSI<0x2A, MRMSrcReg, |
| 1589 | (outs VR128:$dst), (ins VR128:$src1, GR64:$src2), |
| 1590 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
| 1591 | [(set VR128:$dst, |
| 1592 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 1593 | GR64:$src2))]>; |
| 1594 | def Int_CVTSI2SS64rm : RSSI<0x2A, MRMSrcMem, |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1595 | (outs VR128:$dst), |
| 1596 | (ins VR128:$src1, i64mem:$src2), |
Evan Cheng | 90e9d4e | 2008-01-11 07:37:44 +0000 | [diff] [blame] | 1597 | "cvtsi2ss{q}\t{$src2, $dst|$dst, $src2}", |
| 1598 | [(set VR128:$dst, |
| 1599 | (int_x86_sse_cvtsi642ss VR128:$src1, |
| 1600 | (loadi64 addr:$src2)))]>; |
| 1601 | } |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1602 | |
| 1603 | // f32 -> signed i64 |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1604 | def CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src), |
| 1605 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", []>; |
| 1606 | def CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
| 1607 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", []>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1608 | def Int_CVTSS2SI64rr: RSSI<0x2D, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1609 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1610 | [(set GR64:$dst, |
| 1611 | (int_x86_sse_cvtss2si64 VR128:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1612 | def Int_CVTSS2SI64rm: RSSI<0x2D, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1613 | "cvtss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1614 | [(set GR64:$dst, (int_x86_sse_cvtss2si64 |
| 1615 | (load addr:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1616 | def CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins FR32:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1617 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1618 | [(set GR64:$dst, (fp_to_sint FR32:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1619 | def CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), (ins f32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1620 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1621 | [(set GR64:$dst, (fp_to_sint (loadf32 addr:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1622 | def Int_CVTTSS2SI64rr: RSSI<0x2C, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1623 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1624 | [(set GR64:$dst, |
| 1625 | (int_x86_sse_cvttss2si64 VR128:$src))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1626 | def Int_CVTTSS2SI64rm: RSSI<0x2C, MRMSrcMem, (outs GR64:$dst), |
| 1627 | (ins f32mem:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 1628 | "cvttss2si{q}\t{$src, $dst|$dst, $src}", |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1629 | [(set GR64:$dst, |
| 1630 | (int_x86_sse_cvttss2si64 (load addr:$src)))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1631 | |
| 1632 | // Descriptor-table support instructions |
| 1633 | |
| 1634 | // LLDT is not interpreted specially in 64-bit mode because there is no sign |
| 1635 | // extension. |
| 1636 | def SLDT64r : RI<0x00, MRM0r, (outs GR64:$dst), (ins), |
| 1637 | "sldt{q}\t$dst", []>, TB; |
| 1638 | def SLDT64m : RI<0x00, MRM0m, (outs i16mem:$dst), (ins), |
| 1639 | "sldt{q}\t$dst", []>, TB; |
Bill Wendling | 6a20cf0 | 2007-07-23 03:07:27 +0000 | [diff] [blame] | 1640 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1641 | //===----------------------------------------------------------------------===// |
| 1642 | // Alias Instructions |
| 1643 | //===----------------------------------------------------------------------===// |
| 1644 | |
Dan Gohman | f1b4d26 | 2010-01-12 04:42:54 +0000 | [diff] [blame] | 1645 | // We want to rewrite MOV64r0 in terms of MOV32r0, because it's sometimes a |
| 1646 | // smaller encoding, but doing so at isel time interferes with rematerialization |
| 1647 | // in the current register allocator. For now, this is rewritten when the |
| 1648 | // instruction is lowered to an MCInst. |
Chris Lattner | 9ac7542 | 2009-07-14 20:19:57 +0000 | [diff] [blame] | 1649 | // FIXME: AddedComplexity gives this a higher priority than MOV64ri32. Remove |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1650 | // when we have a better way to specify isel priority. |
Dan Gohman | f1b4d26 | 2010-01-12 04:42:54 +0000 | [diff] [blame] | 1651 | let Defs = [EFLAGS], |
| 1652 | AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Chris Lattner | be1778f | 2010-02-05 21:34:18 +0000 | [diff] [blame] | 1653 | def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins), "", |
Dan Gohman | f1b4d26 | 2010-01-12 04:42:54 +0000 | [diff] [blame] | 1654 | [(set GR64:$dst, 0)]>; |
Chris Lattner | 9ac7542 | 2009-07-14 20:19:57 +0000 | [diff] [blame] | 1655 | |
Dan Gohman | f1b4d26 | 2010-01-12 04:42:54 +0000 | [diff] [blame] | 1656 | // Materialize i64 constant where top 32-bits are zero. This could theoretically |
| 1657 | // use MOV32ri with a SUBREG_TO_REG to represent the zero-extension, however |
| 1658 | // that would make it more difficult to rematerialize. |
Evan Cheng | b3379fb | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 1659 | let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 1660 | def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), |
Chris Lattner | 172862a | 2009-10-19 19:51:42 +0000 | [diff] [blame] | 1661 | "", [(set GR64:$dst, i64immZExt32:$src)]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1662 | |
Anton Korobeynikov | 6625eff | 2008-05-04 21:36:32 +0000 | [diff] [blame] | 1663 | //===----------------------------------------------------------------------===// |
| 1664 | // Thread Local Storage Instructions |
| 1665 | //===----------------------------------------------------------------------===// |
| 1666 | |
Rafael Espindola | 15f1b66 | 2009-04-24 12:59:40 +0000 | [diff] [blame] | 1667 | // All calls clobber the non-callee saved registers. RSP is marked as |
| 1668 | // a use to prevent stack-pointer assignments that appear immediately |
| 1669 | // before calls from potentially appearing dead. |
| 1670 | let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, |
| 1671 | FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1, |
| 1672 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
| 1673 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, |
| 1674 | XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], |
| 1675 | Uses = [RSP] in |
Chris Lattner | 5c0b16d | 2009-06-20 20:38:48 +0000 | [diff] [blame] | 1676 | def TLS_addr64 : I<0, Pseudo, (outs), (ins lea64mem:$sym), |
Dan Gohman | 4d47b9b | 2009-04-27 15:13:28 +0000 | [diff] [blame] | 1677 | ".byte\t0x66; " |
Chris Lattner | 5c0b16d | 2009-06-20 20:38:48 +0000 | [diff] [blame] | 1678 | "leaq\t$sym(%rip), %rdi; " |
Dan Gohman | 4d47b9b | 2009-04-27 15:13:28 +0000 | [diff] [blame] | 1679 | ".word\t0x6666; " |
| 1680 | "rex64; " |
| 1681 | "call\t__tls_get_addr@PLT", |
Chris Lattner | 5c0b16d | 2009-06-20 20:38:48 +0000 | [diff] [blame] | 1682 | [(X86tlsaddr tls64addr:$sym)]>, |
Rafael Espindola | 2ee3db3 | 2009-04-17 14:35:58 +0000 | [diff] [blame] | 1683 | Requires<[In64BitMode]>; |
Andrew Lenharth | a76e2f0 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1684 | |
Daniel Dunbar | 0c420fc | 2009-08-11 22:24:40 +0000 | [diff] [blame] | 1685 | let AddedComplexity = 5, isCodeGenOnly = 1 in |
Nate Begeman | 51a0437 | 2009-01-26 01:24:32 +0000 | [diff] [blame] | 1686 | def MOV64GSrm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
| 1687 | "movq\t%gs:$src, $dst", |
| 1688 | [(set GR64:$dst, (gsload addr:$src))]>, SegGS; |
| 1689 | |
Daniel Dunbar | 0c420fc | 2009-08-11 22:24:40 +0000 | [diff] [blame] | 1690 | let AddedComplexity = 5, isCodeGenOnly = 1 in |
Chris Lattner | 1777d0c | 2009-05-05 18:52:19 +0000 | [diff] [blame] | 1691 | def MOV64FSrm : RI<0x8B, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
| 1692 | "movq\t%fs:$src, $dst", |
| 1693 | [(set GR64:$dst, (fsload addr:$src))]>, SegFS; |
| 1694 | |
Andrew Lenharth | a76e2f0 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1695 | //===----------------------------------------------------------------------===// |
| 1696 | // Atomic Instructions |
| 1697 | //===----------------------------------------------------------------------===// |
| 1698 | |
Andrew Lenharth | a76e2f0 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1699 | let Defs = [RAX, EFLAGS], Uses = [RAX] in { |
Evan Cheng | 7e03280 | 2008-04-18 20:55:36 +0000 | [diff] [blame] | 1700 | def LCMPXCHG64 : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$ptr, GR64:$swap), |
Dan Gohman | 4d47b9b | 2009-04-27 15:13:28 +0000 | [diff] [blame] | 1701 | "lock\n\t" |
| 1702 | "cmpxchgq\t$swap,$ptr", |
Andrew Lenharth | a76e2f0 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1703 | [(X86cas addr:$ptr, GR64:$swap, 8)]>, TB, LOCK; |
| 1704 | } |
| 1705 | |
Dan Gohman | 165660e | 2008-08-06 15:52:50 +0000 | [diff] [blame] | 1706 | let Constraints = "$val = $dst" in { |
| 1707 | let Defs = [EFLAGS] in |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1708 | def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins GR64:$val,i64mem:$ptr), |
Dan Gohman | 4d47b9b | 2009-04-27 15:13:28 +0000 | [diff] [blame] | 1709 | "lock\n\t" |
| 1710 | "xadd\t$val, $ptr", |
Mon P Wang | 2887310 | 2008-06-25 08:15:39 +0000 | [diff] [blame] | 1711 | [(set GR64:$dst, (atomic_load_add_64 addr:$ptr, GR64:$val))]>, |
Andrew Lenharth | a76e2f0 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1712 | TB, LOCK; |
Evan Cheng | 37b7387 | 2009-07-30 08:33:02 +0000 | [diff] [blame] | 1713 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1714 | def XCHG64rm : RI<0x87, MRMSrcMem, (outs GR64:$dst), |
| 1715 | (ins GR64:$val,i64mem:$ptr), |
| 1716 | "xchg{q}\t{$val, $ptr|$ptr, $val}", |
Evan Cheng | 94d7b02 | 2008-04-19 02:05:42 +0000 | [diff] [blame] | 1717 | [(set GR64:$dst, (atomic_swap_64 addr:$ptr, GR64:$val))]>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1718 | |
| 1719 | def XCHG64rr : RI<0x87, MRMSrcReg, (outs GR64:$dst), (ins GR64:$val,GR64:$src), |
| 1720 | "xchg{q}\t{$val, $src|$src, $val}", []>; |
Andrew Lenharth | a76e2f0 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1721 | } |
| 1722 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1723 | def XADD64rr : RI<0xC1, MRMDestReg, (outs GR64:$dst), (ins GR64:$src), |
| 1724 | "xadd{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1725 | def XADD64rm : RI<0xC1, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
| 1726 | "xadd{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1727 | |
| 1728 | def CMPXCHG64rr : RI<0xB1, MRMDestReg, (outs GR64:$dst), (ins GR64:$src), |
| 1729 | "cmpxchg{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1730 | def CMPXCHG64rm : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), |
| 1731 | "cmpxchg{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1732 | |
Evan Cheng | b093bd0 | 2010-01-08 01:29:19 +0000 | [diff] [blame] | 1733 | let Defs = [RAX, RDX, EFLAGS], Uses = [RAX, RBX, RCX, RDX] in |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1734 | def CMPXCHG16B : RI<0xC7, MRM1m, (outs), (ins i128mem:$dst), |
| 1735 | "cmpxchg16b\t$dst", []>, TB; |
| 1736 | |
| 1737 | def XCHG64ar : RI<0x90, AddRegFrm, (outs), (ins GR64:$src), |
| 1738 | "xchg{q}\t{$src, %rax|%rax, $src}", []>; |
| 1739 | |
Evan Cheng | 37b7387 | 2009-07-30 08:33:02 +0000 | [diff] [blame] | 1740 | // Optimized codegen when the non-memory output is not used. |
Torok Edwin | 6602922 | 2009-10-19 11:00:58 +0000 | [diff] [blame] | 1741 | let Defs = [EFLAGS] in { |
Evan Cheng | 37b7387 | 2009-07-30 08:33:02 +0000 | [diff] [blame] | 1742 | // FIXME: Use normal add / sub instructions and add lock prefix dynamically. |
| 1743 | def LOCK_ADD64mr : RI<0x03, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
| 1744 | "lock\n\t" |
| 1745 | "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 1746 | def LOCK_ADD64mi8 : RIi8<0x83, MRM0m, (outs), |
| 1747 | (ins i64mem:$dst, i64i8imm :$src2), |
| 1748 | "lock\n\t" |
| 1749 | "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 1750 | def LOCK_ADD64mi32 : RIi32<0x81, MRM0m, (outs), |
| 1751 | (ins i64mem:$dst, i64i32imm :$src2), |
| 1752 | "lock\n\t" |
| 1753 | "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 1754 | def LOCK_SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
| 1755 | "lock\n\t" |
| 1756 | "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 1757 | def LOCK_SUB64mi8 : RIi8<0x83, MRM5m, (outs), |
| 1758 | (ins i64mem:$dst, i64i8imm :$src2), |
| 1759 | "lock\n\t" |
| 1760 | "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 1761 | def LOCK_SUB64mi32 : RIi32<0x81, MRM5m, (outs), |
| 1762 | (ins i64mem:$dst, i64i32imm:$src2), |
| 1763 | "lock\n\t" |
| 1764 | "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 1765 | def LOCK_INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), |
| 1766 | "lock\n\t" |
| 1767 | "inc{q}\t$dst", []>, LOCK; |
| 1768 | def LOCK_DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), |
| 1769 | "lock\n\t" |
| 1770 | "dec{q}\t$dst", []>, LOCK; |
Torok Edwin | 6602922 | 2009-10-19 11:00:58 +0000 | [diff] [blame] | 1771 | } |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1772 | // Atomic exchange, and, or, xor |
| 1773 | let Constraints = "$val = $dst", Defs = [EFLAGS], |
Dan Gohman | 533297b | 2009-10-29 18:10:34 +0000 | [diff] [blame] | 1774 | usesCustomInserter = 1 in { |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1775 | def ATOMAND64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | 6ecf5ce | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1776 | "#ATOMAND64 PSEUDO!", |
Dale Johannesen | e00a8a2 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1777 | [(set GR64:$dst, (atomic_load_and_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1778 | def ATOMOR64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | 6ecf5ce | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1779 | "#ATOMOR64 PSEUDO!", |
Dale Johannesen | e00a8a2 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1780 | [(set GR64:$dst, (atomic_load_or_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1781 | def ATOMXOR64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | 6ecf5ce | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1782 | "#ATOMXOR64 PSEUDO!", |
Dale Johannesen | e00a8a2 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1783 | [(set GR64:$dst, (atomic_load_xor_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1784 | def ATOMNAND64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | 6ecf5ce | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1785 | "#ATOMNAND64 PSEUDO!", |
Dale Johannesen | e00a8a2 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1786 | [(set GR64:$dst, (atomic_load_nand_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1787 | def ATOMMIN64: I<0, Pseudo, (outs GR64:$dst), (ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | 6ecf5ce | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1788 | "#ATOMMIN64 PSEUDO!", |
Dale Johannesen | e00a8a2 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1789 | [(set GR64:$dst, (atomic_load_min_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1790 | def ATOMMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | 6ecf5ce | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1791 | "#ATOMMAX64 PSEUDO!", |
Dale Johannesen | e00a8a2 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1792 | [(set GR64:$dst, (atomic_load_max_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1793 | def ATOMUMIN64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | 6ecf5ce | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1794 | "#ATOMUMIN64 PSEUDO!", |
Dale Johannesen | e00a8a2 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1795 | [(set GR64:$dst, (atomic_load_umin_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1796 | def ATOMUMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
Nick Lewycky | 6ecf5ce | 2008-12-07 03:49:52 +0000 | [diff] [blame] | 1797 | "#ATOMUMAX64 PSEUDO!", |
Dale Johannesen | e00a8a2 | 2008-08-28 02:44:49 +0000 | [diff] [blame] | 1798 | [(set GR64:$dst, (atomic_load_umax_64 addr:$ptr, GR64:$val))]>; |
Dale Johannesen | a99e384 | 2008-08-20 00:48:50 +0000 | [diff] [blame] | 1799 | } |
Andrew Lenharth | a76e2f0 | 2008-03-04 21:13:33 +0000 | [diff] [blame] | 1800 | |
Sean Callanan | 358f1ef | 2009-09-16 21:55:34 +0000 | [diff] [blame] | 1801 | // Segmentation support instructions |
| 1802 | |
| 1803 | // i16mem operand in LAR64rm and GR32 operand in LAR32rr is not a typo. |
| 1804 | def LAR64rm : RI<0x02, MRMSrcMem, (outs GR64:$dst), (ins i16mem:$src), |
| 1805 | "lar{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1806 | def LAR64rr : RI<0x02, MRMSrcReg, (outs GR64:$dst), (ins GR32:$src), |
| 1807 | "lar{q}\t{$src, $dst|$dst, $src}", []>, TB; |
Sean Callanan | 9a86f10 | 2009-09-16 22:59:28 +0000 | [diff] [blame] | 1808 | |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1809 | def LSL64rm : RI<0x03, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), |
| 1810 | "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1811 | def LSL64rr : RI<0x03, MRMSrcReg, (outs GR64:$dst), (ins GR64:$src), |
| 1812 | "lsl{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1813 | |
Chris Lattner | a599de2 | 2010-02-13 00:41:14 +0000 | [diff] [blame] | 1814 | def SWAPGS : I<0x01, MRM_F8, (outs), (ins), "swapgs", []>, TB; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1815 | |
| 1816 | def PUSHFS64 : I<0xa0, RawFrm, (outs), (ins), |
| 1817 | "push{q}\t%fs", []>, TB; |
| 1818 | def PUSHGS64 : I<0xa8, RawFrm, (outs), (ins), |
| 1819 | "push{q}\t%gs", []>, TB; |
| 1820 | |
| 1821 | def POPFS64 : I<0xa1, RawFrm, (outs), (ins), |
| 1822 | "pop{q}\t%fs", []>, TB; |
| 1823 | def POPGS64 : I<0xa9, RawFrm, (outs), (ins), |
| 1824 | "pop{q}\t%gs", []>, TB; |
| 1825 | |
| 1826 | def LSS64rm : RI<0xb2, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src), |
| 1827 | "lss{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1828 | def LFS64rm : RI<0xb4, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src), |
| 1829 | "lfs{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1830 | def LGS64rm : RI<0xb5, MRMSrcMem, (outs GR64:$dst), (ins opaque80mem:$src), |
| 1831 | "lgs{q}\t{$src, $dst|$dst, $src}", []>, TB; |
| 1832 | |
| 1833 | // Specialized register support |
| 1834 | |
| 1835 | // no m form encodable; use SMSW16m |
| 1836 | def SMSW64r : RI<0x01, MRM4r, (outs GR64:$dst), (ins), |
| 1837 | "smsw{q}\t$dst", []>, TB; |
| 1838 | |
Sean Callanan | 9a86f10 | 2009-09-16 22:59:28 +0000 | [diff] [blame] | 1839 | // String manipulation instructions |
| 1840 | |
| 1841 | def LODSQ : RI<0xAD, RawFrm, (outs), (ins), "lodsq", []>; |
Sean Callanan | 358f1ef | 2009-09-16 21:55:34 +0000 | [diff] [blame] | 1842 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1843 | //===----------------------------------------------------------------------===// |
| 1844 | // Non-Instruction Patterns |
| 1845 | //===----------------------------------------------------------------------===// |
| 1846 | |
Chris Lattner | 2514278 | 2009-07-11 22:50:33 +0000 | [diff] [blame] | 1847 | // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable when not in small |
| 1848 | // code model mode, should use 'movabs'. FIXME: This is really a hack, the |
| 1849 | // 'movabs' predicate should handle this sort of thing. |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1850 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
Anton Korobeynikov | d7697d0 | 2009-08-06 11:23:24 +0000 | [diff] [blame] | 1851 | (MOV64ri tconstpool :$dst)>, Requires<[FarData]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1852 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
Anton Korobeynikov | d7697d0 | 2009-08-06 11:23:24 +0000 | [diff] [blame] | 1853 | (MOV64ri tjumptable :$dst)>, Requires<[FarData]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1854 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
Anton Korobeynikov | d7697d0 | 2009-08-06 11:23:24 +0000 | [diff] [blame] | 1855 | (MOV64ri tglobaladdr :$dst)>, Requires<[FarData]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1856 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
Anton Korobeynikov | d7697d0 | 2009-08-06 11:23:24 +0000 | [diff] [blame] | 1857 | (MOV64ri texternalsym:$dst)>, Requires<[FarData]>; |
Dan Gohman | f705adb | 2009-10-30 01:28:02 +0000 | [diff] [blame] | 1858 | def : Pat<(i64 (X86Wrapper tblockaddress:$dst)), |
| 1859 | (MOV64ri tblockaddress:$dst)>, Requires<[FarData]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1860 | |
Chris Lattner | 65a7a6f | 2009-07-11 23:17:29 +0000 | [diff] [blame] | 1861 | // In static codegen with small code model, we can get the address of a label |
| 1862 | // into a register with 'movl'. FIXME: This is a hack, the 'imm' predicate of |
| 1863 | // the MOV64ri64i32 should accept these. |
| 1864 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
| 1865 | (MOV64ri64i32 tconstpool :$dst)>, Requires<[SmallCode]>; |
| 1866 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
| 1867 | (MOV64ri64i32 tjumptable :$dst)>, Requires<[SmallCode]>; |
| 1868 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
| 1869 | (MOV64ri64i32 tglobaladdr :$dst)>, Requires<[SmallCode]>; |
| 1870 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
| 1871 | (MOV64ri64i32 texternalsym:$dst)>, Requires<[SmallCode]>; |
Dan Gohman | f705adb | 2009-10-30 01:28:02 +0000 | [diff] [blame] | 1872 | def : Pat<(i64 (X86Wrapper tblockaddress:$dst)), |
| 1873 | (MOV64ri64i32 tblockaddress:$dst)>, Requires<[SmallCode]>; |
Chris Lattner | 65a7a6f | 2009-07-11 23:17:29 +0000 | [diff] [blame] | 1874 | |
Anton Korobeynikov | d7697d0 | 2009-08-06 11:23:24 +0000 | [diff] [blame] | 1875 | // In kernel code model, we can get the address of a label |
| 1876 | // into a register with 'movq'. FIXME: This is a hack, the 'imm' predicate of |
| 1877 | // the MOV64ri32 should accept these. |
| 1878 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
| 1879 | (MOV64ri32 tconstpool :$dst)>, Requires<[KernelCode]>; |
| 1880 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
| 1881 | (MOV64ri32 tjumptable :$dst)>, Requires<[KernelCode]>; |
| 1882 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
| 1883 | (MOV64ri32 tglobaladdr :$dst)>, Requires<[KernelCode]>; |
| 1884 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
| 1885 | (MOV64ri32 texternalsym:$dst)>, Requires<[KernelCode]>; |
Dan Gohman | f705adb | 2009-10-30 01:28:02 +0000 | [diff] [blame] | 1886 | def : Pat<(i64 (X86Wrapper tblockaddress:$dst)), |
| 1887 | (MOV64ri32 tblockaddress:$dst)>, Requires<[KernelCode]>; |
Chris Lattner | 65a7a6f | 2009-07-11 23:17:29 +0000 | [diff] [blame] | 1888 | |
Chris Lattner | 18c5987 | 2009-06-27 04:16:01 +0000 | [diff] [blame] | 1889 | // If we have small model and -static mode, it is safe to store global addresses |
| 1890 | // directly as immediates. FIXME: This is really a hack, the 'imm' predicate |
Chris Lattner | 2514278 | 2009-07-11 22:50:33 +0000 | [diff] [blame] | 1891 | // for MOV64mi32 should handle this sort of thing. |
Evan Cheng | 28b51439 | 2006-12-05 19:50:18 +0000 | [diff] [blame] | 1892 | def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst), |
| 1893 | (MOV64mi32 addr:$dst, tconstpool:$src)>, |
Anton Korobeynikov | d7697d0 | 2009-08-06 11:23:24 +0000 | [diff] [blame] | 1894 | Requires<[NearData, IsStatic]>; |
Evan Cheng | 28b51439 | 2006-12-05 19:50:18 +0000 | [diff] [blame] | 1895 | def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst), |
| 1896 | (MOV64mi32 addr:$dst, tjumptable:$src)>, |
Anton Korobeynikov | d7697d0 | 2009-08-06 11:23:24 +0000 | [diff] [blame] | 1897 | Requires<[NearData, IsStatic]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1898 | def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst), |
Evan Cheng | 28b51439 | 2006-12-05 19:50:18 +0000 | [diff] [blame] | 1899 | (MOV64mi32 addr:$dst, tglobaladdr:$src)>, |
Anton Korobeynikov | d7697d0 | 2009-08-06 11:23:24 +0000 | [diff] [blame] | 1900 | Requires<[NearData, IsStatic]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1901 | def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst), |
Evan Cheng | 28b51439 | 2006-12-05 19:50:18 +0000 | [diff] [blame] | 1902 | (MOV64mi32 addr:$dst, texternalsym:$src)>, |
Anton Korobeynikov | d7697d0 | 2009-08-06 11:23:24 +0000 | [diff] [blame] | 1903 | Requires<[NearData, IsStatic]>; |
Dan Gohman | f705adb | 2009-10-30 01:28:02 +0000 | [diff] [blame] | 1904 | def : Pat<(store (i64 (X86Wrapper tblockaddress:$src)), addr:$dst), |
| 1905 | (MOV64mi32 addr:$dst, tblockaddress:$src)>, |
| 1906 | Requires<[NearData, IsStatic]>; |
Evan Cheng | 0085a28 | 2006-11-30 21:55:46 +0000 | [diff] [blame] | 1907 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1908 | // Calls |
| 1909 | // Direct PC relative function call for small code model. 32-bit displacement |
| 1910 | // sign extended to 64-bit. |
| 1911 | def : Pat<(X86call (i64 tglobaladdr:$dst)), |
Anton Korobeynikov | cf6b739 | 2009-08-03 08:12:53 +0000 | [diff] [blame] | 1912 | (CALL64pcrel32 tglobaladdr:$dst)>, Requires<[NotWin64]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1913 | def : Pat<(X86call (i64 texternalsym:$dst)), |
Anton Korobeynikov | cf6b739 | 2009-08-03 08:12:53 +0000 | [diff] [blame] | 1914 | (CALL64pcrel32 texternalsym:$dst)>, Requires<[NotWin64]>; |
| 1915 | |
| 1916 | def : Pat<(X86call (i64 tglobaladdr:$dst)), |
| 1917 | (WINCALL64pcrel32 tglobaladdr:$dst)>, Requires<[IsWin64]>; |
| 1918 | def : Pat<(X86call (i64 texternalsym:$dst)), |
| 1919 | (WINCALL64pcrel32 texternalsym:$dst)>, Requires<[IsWin64]>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1920 | |
Arnold Schwaighofer | c85e171 | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 1921 | // tailcall stuff |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 1922 | def : Pat<(X86tcret GR64_TC:$dst, imm:$off), |
| 1923 | (TCRETURNri64 GR64_TC:$dst, imm:$off)>, |
| 1924 | Requires<[In64BitMode]>; |
| 1925 | |
| 1926 | def : Pat<(X86tcret (load addr:$dst), imm:$off), |
| 1927 | (TCRETURNmi64 addr:$dst, imm:$off)>, |
| 1928 | Requires<[In64BitMode]>; |
Arnold Schwaighofer | c85e171 | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 1929 | |
| 1930 | def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off), |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 1931 | (TCRETURNdi64 tglobaladdr:$dst, imm:$off)>, |
| 1932 | Requires<[In64BitMode]>; |
Arnold Schwaighofer | c85e171 | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 1933 | |
| 1934 | def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off), |
Evan Cheng | f48ef03 | 2010-03-14 03:48:46 +0000 | [diff] [blame] | 1935 | (TCRETURNdi64 texternalsym:$dst, imm:$off)>, |
| 1936 | Requires<[In64BitMode]>; |
Arnold Schwaighofer | c85e171 | 2007-10-11 19:40:01 +0000 | [diff] [blame] | 1937 | |
Dan Gohman | 11f7bfb | 2007-09-17 14:35:24 +0000 | [diff] [blame] | 1938 | // Comparisons. |
| 1939 | |
| 1940 | // TEST R,R is smaller than CMP R,0 |
Chris Lattner | e3486a4 | 2010-03-19 00:01:11 +0000 | [diff] [blame] | 1941 | def : Pat<(X86cmp GR64:$src1, 0), |
Dan Gohman | 11f7bfb | 2007-09-17 14:35:24 +0000 | [diff] [blame] | 1942 | (TEST64rr GR64:$src1, GR64:$src1)>; |
| 1943 | |
Dan Gohman | fbb7486 | 2009-01-07 01:00:24 +0000 | [diff] [blame] | 1944 | // Conditional moves with folded loads with operands swapped and conditions |
| 1945 | // inverted. |
| 1946 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_B, EFLAGS), |
| 1947 | (CMOVAE64rm GR64:$src2, addr:$src1)>; |
| 1948 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_AE, EFLAGS), |
| 1949 | (CMOVB64rm GR64:$src2, addr:$src1)>; |
| 1950 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_E, EFLAGS), |
| 1951 | (CMOVNE64rm GR64:$src2, addr:$src1)>; |
| 1952 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NE, EFLAGS), |
| 1953 | (CMOVE64rm GR64:$src2, addr:$src1)>; |
| 1954 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_BE, EFLAGS), |
| 1955 | (CMOVA64rm GR64:$src2, addr:$src1)>; |
| 1956 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_A, EFLAGS), |
| 1957 | (CMOVBE64rm GR64:$src2, addr:$src1)>; |
| 1958 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_L, EFLAGS), |
| 1959 | (CMOVGE64rm GR64:$src2, addr:$src1)>; |
| 1960 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_GE, EFLAGS), |
| 1961 | (CMOVL64rm GR64:$src2, addr:$src1)>; |
| 1962 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_LE, EFLAGS), |
| 1963 | (CMOVG64rm GR64:$src2, addr:$src1)>; |
| 1964 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_G, EFLAGS), |
| 1965 | (CMOVLE64rm GR64:$src2, addr:$src1)>; |
| 1966 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_P, EFLAGS), |
| 1967 | (CMOVNP64rm GR64:$src2, addr:$src1)>; |
| 1968 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NP, EFLAGS), |
| 1969 | (CMOVP64rm GR64:$src2, addr:$src1)>; |
| 1970 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_S, EFLAGS), |
| 1971 | (CMOVNS64rm GR64:$src2, addr:$src1)>; |
| 1972 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NS, EFLAGS), |
| 1973 | (CMOVS64rm GR64:$src2, addr:$src1)>; |
| 1974 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_O, EFLAGS), |
| 1975 | (CMOVNO64rm GR64:$src2, addr:$src1)>; |
| 1976 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, X86_COND_NO, EFLAGS), |
| 1977 | (CMOVO64rm GR64:$src2, addr:$src1)>; |
Christopher Lamb | 6634e26 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 1978 | |
Duncan Sands | f9c98e6 | 2008-01-23 20:39:46 +0000 | [diff] [blame] | 1979 | // zextload bool -> zextload byte |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1980 | def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1981 | |
| 1982 | // extload |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 1983 | // When extloading from 16-bit and smaller memory locations into 64-bit |
| 1984 | // registers, use zero-extending loads so that the entire 64-bit register is |
| 1985 | // defined, avoiding partial-register updates. |
Dan Gohman | 7deb171 | 2008-08-27 17:33:15 +0000 | [diff] [blame] | 1986 | def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1987 | def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 1988 | def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>; |
| 1989 | // For other extloads, use subregs, since the high contents of the register are |
| 1990 | // defined after an extload. |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1991 | def : Pat<(extloadi64i32 addr:$src), |
Dan Gohman | af70e5c | 2009-08-26 14:59:13 +0000 | [diff] [blame] | 1992 | (SUBREG_TO_REG (i64 0), (MOV32rm addr:$src), |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 1993 | x86_subreg_32bit)>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 1994 | |
Dan Gohman | af70e5c | 2009-08-26 14:59:13 +0000 | [diff] [blame] | 1995 | // anyext. Define these to do an explicit zero-extend to |
| 1996 | // avoid partial-register updates. |
| 1997 | def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>; |
| 1998 | def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16 :$src)>; |
| 1999 | def : Pat<(i64 (anyext GR32:$src)), |
| 2000 | (SUBREG_TO_REG (i64 0), GR32:$src, x86_subreg_32bit)>; |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 2001 | |
| 2002 | //===----------------------------------------------------------------------===// |
| 2003 | // Some peepholes |
| 2004 | //===----------------------------------------------------------------------===// |
| 2005 | |
Dan Gohman | 63f9720 | 2008-10-17 01:33:43 +0000 | [diff] [blame] | 2006 | // Odd encoding trick: -128 fits into an 8-bit immediate field while |
| 2007 | // +128 doesn't, so in this special case use a sub instead of an add. |
| 2008 | def : Pat<(add GR64:$src1, 128), |
| 2009 | (SUB64ri8 GR64:$src1, -128)>; |
| 2010 | def : Pat<(store (add (loadi64 addr:$dst), 128), addr:$dst), |
| 2011 | (SUB64mi8 addr:$dst, -128)>; |
| 2012 | |
| 2013 | // The same trick applies for 32-bit immediate fields in 64-bit |
| 2014 | // instructions. |
| 2015 | def : Pat<(add GR64:$src1, 0x0000000080000000), |
| 2016 | (SUB64ri32 GR64:$src1, 0xffffffff80000000)>; |
| 2017 | def : Pat<(store (add (loadi64 addr:$dst), 0x00000000800000000), addr:$dst), |
| 2018 | (SUB64mi32 addr:$dst, 0xffffffff80000000)>; |
| 2019 | |
Dan Gohman | e5dacc5 | 2010-01-11 17:58:34 +0000 | [diff] [blame] | 2020 | // Use a 32-bit and with implicit zero-extension instead of a 64-bit and if it |
| 2021 | // has an immediate with at least 32 bits of leading zeros, to avoid needing to |
| 2022 | // materialize that immediate in a register first. |
| 2023 | def : Pat<(and GR64:$src, i64immZExt32:$imm), |
| 2024 | (SUBREG_TO_REG |
| 2025 | (i64 0), |
| 2026 | (AND32ri |
| 2027 | (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit), |
Chris Lattner | be5ad7d | 2010-02-23 06:09:57 +0000 | [diff] [blame] | 2028 | (i32 (GetLo32XForm imm:$imm))), |
Dan Gohman | e5dacc5 | 2010-01-11 17:58:34 +0000 | [diff] [blame] | 2029 | x86_subreg_32bit)>; |
| 2030 | |
Dan Gohman | e3d9206 | 2008-08-07 02:54:50 +0000 | [diff] [blame] | 2031 | // r & (2^32-1) ==> movz |
Dan Gohman | 63f9720 | 2008-10-17 01:33:43 +0000 | [diff] [blame] | 2032 | def : Pat<(and GR64:$src, 0x00000000FFFFFFFF), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2033 | (MOVZX64rr32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>; |
Dan Gohman | 11ba3b1 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 2034 | // r & (2^16-1) ==> movz |
| 2035 | def : Pat<(and GR64:$src, 0xffff), |
| 2036 | (MOVZX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)))>; |
| 2037 | // r & (2^8-1) ==> movz |
| 2038 | def : Pat<(and GR64:$src, 0xff), |
| 2039 | (MOVZX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)))>; |
Dan Gohman | 11ba3b1 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 2040 | // r & (2^8-1) ==> movz |
| 2041 | def : Pat<(and GR32:$src1, 0xff), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2042 | (MOVZX32rr8 (EXTRACT_SUBREG GR32:$src1, x86_subreg_8bit))>, |
Dan Gohman | 11ba3b1 | 2008-07-30 18:09:17 +0000 | [diff] [blame] | 2043 | Requires<[In64BitMode]>; |
| 2044 | // r & (2^8-1) ==> movz |
| 2045 | def : Pat<(and GR16:$src1, 0xff), |
| 2046 | (MOVZX16rr8 (i8 (EXTRACT_SUBREG GR16:$src1, x86_subreg_8bit)))>, |
| 2047 | Requires<[In64BitMode]>; |
Christopher Lamb | 6634e26 | 2008-03-13 05:47:01 +0000 | [diff] [blame] | 2048 | |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2049 | // sext_inreg patterns |
| 2050 | def : Pat<(sext_inreg GR64:$src, i32), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2051 | (MOVSX64rr32 (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit))>; |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2052 | def : Pat<(sext_inreg GR64:$src, i16), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2053 | (MOVSX64rr16 (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit))>; |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2054 | def : Pat<(sext_inreg GR64:$src, i8), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2055 | (MOVSX64rr8 (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit))>; |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2056 | def : Pat<(sext_inreg GR32:$src, i8), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2057 | (MOVSX32rr8 (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit))>, |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2058 | Requires<[In64BitMode]>; |
| 2059 | def : Pat<(sext_inreg GR16:$src, i8), |
| 2060 | (MOVSX16rr8 (i8 (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit)))>, |
| 2061 | Requires<[In64BitMode]>; |
| 2062 | |
| 2063 | // trunc patterns |
| 2064 | def : Pat<(i32 (trunc GR64:$src)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2065 | (EXTRACT_SUBREG GR64:$src, x86_subreg_32bit)>; |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2066 | def : Pat<(i16 (trunc GR64:$src)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2067 | (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit)>; |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2068 | def : Pat<(i8 (trunc GR64:$src)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2069 | (EXTRACT_SUBREG GR64:$src, x86_subreg_8bit)>; |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2070 | def : Pat<(i8 (trunc GR32:$src)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2071 | (EXTRACT_SUBREG GR32:$src, x86_subreg_8bit)>, |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2072 | Requires<[In64BitMode]>; |
| 2073 | def : Pat<(i8 (trunc GR16:$src)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2074 | (EXTRACT_SUBREG GR16:$src, x86_subreg_8bit)>, |
| 2075 | Requires<[In64BitMode]>; |
| 2076 | |
| 2077 | // h-register tricks. |
Dan Gohman | 2d98f06 | 2009-05-31 17:52:18 +0000 | [diff] [blame] | 2078 | // For now, be conservative on x86-64 and use an h-register extract only if the |
| 2079 | // value is immediately zero-extended or stored, which are somewhat common |
| 2080 | // cases. This uses a bunch of code to prevent a register requiring a REX prefix |
| 2081 | // from being allocated in the same instruction as the h register, as there's |
| 2082 | // currently no way to describe this requirement to the register allocator. |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2083 | |
| 2084 | // h-register extract and zero-extend. |
| 2085 | def : Pat<(and (srl_su GR64:$src, (i8 8)), (i64 255)), |
| 2086 | (SUBREG_TO_REG |
| 2087 | (i64 0), |
| 2088 | (MOVZX32_NOREXrr8 |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2089 | (EXTRACT_SUBREG (i64 (COPY_TO_REGCLASS GR64:$src, GR64_ABCD)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2090 | x86_subreg_8bit_hi)), |
| 2091 | x86_subreg_32bit)>; |
| 2092 | def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)), |
| 2093 | (MOVZX32_NOREXrr8 |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2094 | (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2095 | x86_subreg_8bit_hi))>, |
| 2096 | Requires<[In64BitMode]>; |
Dan Gohman | 7e0d64a | 2010-01-11 17:21:05 +0000 | [diff] [blame] | 2097 | def : Pat<(srl GR16:$src, (i8 8)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2098 | (EXTRACT_SUBREG |
| 2099 | (MOVZX32_NOREXrr8 |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2100 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2101 | x86_subreg_8bit_hi)), |
| 2102 | x86_subreg_16bit)>, |
| 2103 | Requires<[In64BitMode]>; |
Evan Cheng | cb219f0 | 2009-05-29 01:44:43 +0000 | [diff] [blame] | 2104 | def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))), |
| 2105 | (MOVZX32_NOREXrr8 |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2106 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
Evan Cheng | cb219f0 | 2009-05-29 01:44:43 +0000 | [diff] [blame] | 2107 | x86_subreg_8bit_hi))>, |
| 2108 | Requires<[In64BitMode]>; |
Dan Gohman | af70e5c | 2009-08-26 14:59:13 +0000 | [diff] [blame] | 2109 | def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))), |
| 2110 | (MOVZX32_NOREXrr8 |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2111 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
Dan Gohman | af70e5c | 2009-08-26 14:59:13 +0000 | [diff] [blame] | 2112 | x86_subreg_8bit_hi))>, |
| 2113 | Requires<[In64BitMode]>; |
Evan Cheng | cb219f0 | 2009-05-29 01:44:43 +0000 | [diff] [blame] | 2114 | def : Pat<(i64 (zext (srl_su GR16:$src, (i8 8)))), |
| 2115 | (SUBREG_TO_REG |
| 2116 | (i64 0), |
| 2117 | (MOVZX32_NOREXrr8 |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2118 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
Evan Cheng | cb219f0 | 2009-05-29 01:44:43 +0000 | [diff] [blame] | 2119 | x86_subreg_8bit_hi)), |
| 2120 | x86_subreg_32bit)>; |
Dan Gohman | af70e5c | 2009-08-26 14:59:13 +0000 | [diff] [blame] | 2121 | def : Pat<(i64 (anyext (srl_su GR16:$src, (i8 8)))), |
| 2122 | (SUBREG_TO_REG |
| 2123 | (i64 0), |
| 2124 | (MOVZX32_NOREXrr8 |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2125 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
Dan Gohman | af70e5c | 2009-08-26 14:59:13 +0000 | [diff] [blame] | 2126 | x86_subreg_8bit_hi)), |
| 2127 | x86_subreg_32bit)>; |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2128 | |
| 2129 | // h-register extract and store. |
| 2130 | def : Pat<(store (i8 (trunc_su (srl_su GR64:$src, (i8 8)))), addr:$dst), |
| 2131 | (MOV8mr_NOREX |
| 2132 | addr:$dst, |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2133 | (EXTRACT_SUBREG (i64 (COPY_TO_REGCLASS GR64:$src, GR64_ABCD)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2134 | x86_subreg_8bit_hi))>; |
| 2135 | def : Pat<(store (i8 (trunc_su (srl_su GR32:$src, (i8 8)))), addr:$dst), |
| 2136 | (MOV8mr_NOREX |
| 2137 | addr:$dst, |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2138 | (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2139 | x86_subreg_8bit_hi))>, |
| 2140 | Requires<[In64BitMode]>; |
| 2141 | def : Pat<(store (i8 (trunc_su (srl_su GR16:$src, (i8 8)))), addr:$dst), |
| 2142 | (MOV8mr_NOREX |
| 2143 | addr:$dst, |
Anton Korobeynikov | 3a639a0 | 2009-11-02 00:11:39 +0000 | [diff] [blame] | 2144 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
Dan Gohman | 21e3dfb | 2009-04-13 16:09:41 +0000 | [diff] [blame] | 2145 | x86_subreg_8bit_hi))>, |
Dan Gohman | 0bfa1bf | 2008-08-20 21:27:32 +0000 | [diff] [blame] | 2146 | Requires<[In64BitMode]>; |
| 2147 | |
Evan Cheng | 25ab690 | 2006-09-08 06:48:29 +0000 | [diff] [blame] | 2148 | // (shl x, 1) ==> (add x, x) |
| 2149 | def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>; |
| 2150 | |
Evan Cheng | eb9f892 | 2008-08-30 02:03:58 +0000 | [diff] [blame] | 2151 | // (shl x (and y, 63)) ==> (shl x, y) |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2152 | def : Pat<(shl GR64:$src1, (and CL, 63)), |
Evan Cheng | eb9f892 | 2008-08-30 02:03:58 +0000 | [diff] [blame] | 2153 | (SHL64rCL GR64:$src1)>; |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2154 | def : Pat<(store (shl (loadi64 addr:$dst), (and CL, 63)), addr:$dst), |
Evan Cheng | eb9f892 | 2008-08-30 02:03:58 +0000 | [diff] [blame] | 2155 | (SHL64mCL addr:$dst)>; |
| 2156 | |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2157 | def : Pat<(srl GR64:$src1, (and CL, 63)), |
Evan Cheng | eb9f892 | 2008-08-30 02:03:58 +0000 | [diff] [blame] | 2158 | (SHR64rCL GR64:$src1)>; |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2159 | def : Pat<(store (srl (loadi64 addr:$dst), (and CL, 63)), addr:$dst), |
Evan Cheng | eb9f892 | 2008-08-30 02:03:58 +0000 | [diff] [blame] | 2160 | (SHR64mCL addr:$dst)>; |
| 2161 | |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2162 | def : Pat<(sra GR64:$src1, (and CL, 63)), |
Evan Cheng | eb9f892 | 2008-08-30 02:03:58 +0000 | [diff] [blame] | 2163 | (SAR64rCL GR64:$src1)>; |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2164 | def : Pat<(store (sra (loadi64 addr:$dst), (and CL, 63)), addr:$dst), |
Evan Cheng | eb9f892 | 2008-08-30 02:03:58 +0000 | [diff] [blame] | 2165 | (SAR64mCL addr:$dst)>; |
| 2166 | |
Evan Cheng | 760d194 | 2010-01-04 21:22:48 +0000 | [diff] [blame] | 2167 | // Double shift patterns |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2168 | def : Pat<(shrd GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm)), |
Dan Gohman | 74feef2 | 2008-10-17 01:23:35 +0000 | [diff] [blame] | 2169 | (SHRD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>; |
| 2170 | |
| 2171 | def : Pat<(store (shrd (loadi64 addr:$dst), (i8 imm:$amt1), |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2172 | GR64:$src2, (i8 imm)), addr:$dst), |
Dan Gohman | 74feef2 | 2008-10-17 01:23:35 +0000 | [diff] [blame] | 2173 | (SHRD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>; |
| 2174 | |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2175 | def : Pat<(shld GR64:$src1, (i8 imm:$amt1), GR64:$src2, (i8 imm)), |
Dan Gohman | 74feef2 | 2008-10-17 01:23:35 +0000 | [diff] [blame] | 2176 | (SHLD64rri8 GR64:$src1, GR64:$src2, (i8 imm:$amt1))>; |
| 2177 | |
| 2178 | def : Pat<(store (shld (loadi64 addr:$dst), (i8 imm:$amt1), |
Chris Lattner | 6d9f86b | 2010-02-23 06:54:29 +0000 | [diff] [blame] | 2179 | GR64:$src2, (i8 imm)), addr:$dst), |
Dan Gohman | 74feef2 | 2008-10-17 01:23:35 +0000 | [diff] [blame] | 2180 | (SHLD64mri8 addr:$dst, GR64:$src2, (i8 imm:$amt1))>; |
| 2181 | |
Evan Cheng | 199c424 | 2010-01-11 22:03:29 +0000 | [diff] [blame] | 2182 | // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits. |
Evan Cheng | 3bda201 | 2010-01-12 18:31:19 +0000 | [diff] [blame] | 2183 | let AddedComplexity = 5 in { // Try this before the selecting to OR |
Evan Cheng | 4b0345b | 2010-01-11 17:03:47 +0000 | [diff] [blame] | 2184 | def : Pat<(parallel (or_is_add GR64:$src1, i64immSExt8:$src2), |
| 2185 | (implicit EFLAGS)), |
| 2186 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 2187 | def : Pat<(parallel (or_is_add GR64:$src1, i64immSExt32:$src2), |
| 2188 | (implicit EFLAGS)), |
| 2189 | (ADD64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Evan Cheng | 199c424 | 2010-01-11 22:03:29 +0000 | [diff] [blame] | 2190 | def : Pat<(parallel (or_is_add GR64:$src1, GR64:$src2), |
| 2191 | (implicit EFLAGS)), |
| 2192 | (ADD64rr GR64:$src1, GR64:$src2)>; |
Evan Cheng | 3bda201 | 2010-01-12 18:31:19 +0000 | [diff] [blame] | 2193 | } // AddedComplexity |
Evan Cheng | 4b0345b | 2010-01-11 17:03:47 +0000 | [diff] [blame] | 2194 | |
Chris Lattner | a066810 | 2007-05-17 06:35:11 +0000 | [diff] [blame] | 2195 | // X86 specific add which produces a flag. |
| 2196 | def : Pat<(addc GR64:$src1, GR64:$src2), |
| 2197 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 2198 | def : Pat<(addc GR64:$src1, (load addr:$src2)), |
| 2199 | (ADD64rm GR64:$src1, addr:$src2)>; |
Chris Lattner | a066810 | 2007-05-17 06:35:11 +0000 | [diff] [blame] | 2200 | def : Pat<(addc GR64:$src1, i64immSExt8:$src2), |
| 2201 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 2202 | def : Pat<(addc GR64:$src1, i64immSExt32:$src2), |
| 2203 | (ADD64ri32 GR64:$src1, imm:$src2)>; |
Chris Lattner | a066810 | 2007-05-17 06:35:11 +0000 | [diff] [blame] | 2204 | |
| 2205 | def : Pat<(subc GR64:$src1, GR64:$src2), |
| 2206 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 2207 | def : Pat<(subc GR64:$src1, (load addr:$src2)), |
| 2208 | (SUB64rm GR64:$src1, addr:$src2)>; |
Chris Lattner | a066810 | 2007-05-17 06:35:11 +0000 | [diff] [blame] | 2209 | def : Pat<(subc GR64:$src1, i64immSExt8:$src2), |
| 2210 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 2211 | def : Pat<(subc GR64:$src1, imm:$src2), |
| 2212 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Chris Lattner | a066810 | 2007-05-17 06:35:11 +0000 | [diff] [blame] | 2213 | |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2214 | //===----------------------------------------------------------------------===// |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2215 | // EFLAGS-defining Patterns |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2216 | //===----------------------------------------------------------------------===// |
| 2217 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2218 | // Register-Register Addition with EFLAGS result |
| 2219 | def : Pat<(parallel (X86add_flag GR64:$src1, GR64:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2220 | (implicit EFLAGS)), |
| 2221 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 2222 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2223 | // Register-Integer Addition with EFLAGS result |
| 2224 | def : Pat<(parallel (X86add_flag GR64:$src1, i64immSExt8:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2225 | (implicit EFLAGS)), |
| 2226 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2227 | def : Pat<(parallel (X86add_flag GR64:$src1, i64immSExt32:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 2228 | (implicit EFLAGS)), |
| 2229 | (ADD64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2230 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2231 | // Register-Memory Addition with EFLAGS result |
| 2232 | def : Pat<(parallel (X86add_flag GR64:$src1, (loadi64 addr:$src2)), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2233 | (implicit EFLAGS)), |
| 2234 | (ADD64rm GR64:$src1, addr:$src2)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2235 | /* |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2236 | // Memory-Register Addition with EFLAGS result |
| 2237 | def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), GR64:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2238 | addr:$dst), |
| 2239 | (implicit EFLAGS)), |
| 2240 | (ADD64mr addr:$dst, GR64:$src2)>; |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2241 | def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), i64immSExt8:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2242 | addr:$dst), |
| 2243 | (implicit EFLAGS)), |
| 2244 | (ADD64mi8 addr:$dst, i64immSExt8:$src2)>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 2245 | def : Pat<(parallel (store (X86add_flag (loadi64 addr:$dst), |
| 2246 | i64immSExt32:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 2247 | addr:$dst), |
| 2248 | (implicit EFLAGS)), |
| 2249 | (ADD64mi32 addr:$dst, i64immSExt32:$src2)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2250 | */ |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2251 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2252 | // Register-Register Subtraction with EFLAGS result |
| 2253 | def : Pat<(parallel (X86sub_flag GR64:$src1, GR64:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2254 | (implicit EFLAGS)), |
| 2255 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 2256 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2257 | // Register-Memory Subtraction with EFLAGS result |
| 2258 | def : Pat<(parallel (X86sub_flag GR64:$src1, (loadi64 addr:$src2)), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2259 | (implicit EFLAGS)), |
| 2260 | (SUB64rm GR64:$src1, addr:$src2)>; |
| 2261 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2262 | // Register-Integer Subtraction with EFLAGS result |
| 2263 | def : Pat<(parallel (X86sub_flag GR64:$src1, i64immSExt8:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2264 | (implicit EFLAGS)), |
| 2265 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2266 | def : Pat<(parallel (X86sub_flag GR64:$src1, i64immSExt32:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 2267 | (implicit EFLAGS)), |
| 2268 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2269 | |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2270 | /* |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2271 | // Memory-Register Subtraction with EFLAGS result |
| 2272 | def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), GR64:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2273 | addr:$dst), |
| 2274 | (implicit EFLAGS)), |
| 2275 | (SUB64mr addr:$dst, GR64:$src2)>; |
| 2276 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2277 | // Memory-Integer Subtraction with EFLAGS result |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 2278 | def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), |
| 2279 | i64immSExt8:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2280 | addr:$dst), |
| 2281 | (implicit EFLAGS)), |
| 2282 | (SUB64mi8 addr:$dst, i64immSExt8:$src2)>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 2283 | def : Pat<(parallel (store (X86sub_flag (loadi64 addr:$dst), |
| 2284 | i64immSExt32:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 2285 | addr:$dst), |
| 2286 | (implicit EFLAGS)), |
| 2287 | (SUB64mi32 addr:$dst, i64immSExt32:$src2)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2288 | */ |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2289 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2290 | // Register-Register Signed Integer Multiplication with EFLAGS result |
| 2291 | def : Pat<(parallel (X86smul_flag GR64:$src1, GR64:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2292 | (implicit EFLAGS)), |
| 2293 | (IMUL64rr GR64:$src1, GR64:$src2)>; |
| 2294 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2295 | // Register-Memory Signed Integer Multiplication with EFLAGS result |
| 2296 | def : Pat<(parallel (X86smul_flag GR64:$src1, (loadi64 addr:$src2)), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2297 | (implicit EFLAGS)), |
| 2298 | (IMUL64rm GR64:$src1, addr:$src2)>; |
| 2299 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2300 | // Register-Integer Signed Integer Multiplication with EFLAGS result |
| 2301 | def : Pat<(parallel (X86smul_flag GR64:$src1, i64immSExt8:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2302 | (implicit EFLAGS)), |
| 2303 | (IMUL64rri8 GR64:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2304 | def : Pat<(parallel (X86smul_flag GR64:$src1, i64immSExt32:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 2305 | (implicit EFLAGS)), |
| 2306 | (IMUL64rri32 GR64:$src1, i64immSExt32:$src2)>; |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2307 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2308 | // Memory-Integer Signed Integer Multiplication with EFLAGS result |
| 2309 | def : Pat<(parallel (X86smul_flag (loadi64 addr:$src1), i64immSExt8:$src2), |
Bill Wendling | d350e02 | 2008-12-12 21:15:41 +0000 | [diff] [blame] | 2310 | (implicit EFLAGS)), |
| 2311 | (IMUL64rmi8 addr:$src1, i64immSExt8:$src2)>; |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2312 | def : Pat<(parallel (X86smul_flag (loadi64 addr:$src1), i64immSExt32:$src2), |
Dan Gohman | 018a34c | 2008-12-19 18:25:21 +0000 | [diff] [blame] | 2313 | (implicit EFLAGS)), |
| 2314 | (IMUL64rmi32 addr:$src1, i64immSExt32:$src2)>; |
Chris Lattner | a066810 | 2007-05-17 06:35:11 +0000 | [diff] [blame] | 2315 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2316 | // INC and DEC with EFLAGS result. Note that these do not set CF. |
Dan Gohman | 1f4af26 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 2317 | def : Pat<(parallel (X86inc_flag GR16:$src), (implicit EFLAGS)), |
| 2318 | (INC64_16r GR16:$src)>, Requires<[In64BitMode]>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2319 | /* |
Dan Gohman | 1f4af26 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 2320 | def : Pat<(parallel (store (i16 (X86inc_flag (loadi16 addr:$dst))), addr:$dst), |
| 2321 | (implicit EFLAGS)), |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2322 | (INC64_16m addr:$dst)>, Requires<[In64BitMode]>;*/ |
Dan Gohman | 1f4af26 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 2323 | def : Pat<(parallel (X86dec_flag GR16:$src), (implicit EFLAGS)), |
| 2324 | (DEC64_16r GR16:$src)>, Requires<[In64BitMode]>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2325 | /* |
Dan Gohman | 1f4af26 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 2326 | def : Pat<(parallel (store (i16 (X86dec_flag (loadi16 addr:$dst))), addr:$dst), |
| 2327 | (implicit EFLAGS)), |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2328 | (DEC64_16m addr:$dst)>, Requires<[In64BitMode]>;*/ |
Dan Gohman | 1f4af26 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 2329 | |
| 2330 | def : Pat<(parallel (X86inc_flag GR32:$src), (implicit EFLAGS)), |
| 2331 | (INC64_32r GR32:$src)>, Requires<[In64BitMode]>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2332 | /* |
Dan Gohman | 1f4af26 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 2333 | def : Pat<(parallel (store (i32 (X86inc_flag (loadi32 addr:$dst))), addr:$dst), |
| 2334 | (implicit EFLAGS)), |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2335 | (INC64_32m addr:$dst)>, Requires<[In64BitMode]>;*/ |
Dan Gohman | 1f4af26 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 2336 | def : Pat<(parallel (X86dec_flag GR32:$src), (implicit EFLAGS)), |
| 2337 | (DEC64_32r GR32:$src)>, Requires<[In64BitMode]>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2338 | /* |
Dan Gohman | 1f4af26 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 2339 | def : Pat<(parallel (store (i32 (X86dec_flag (loadi32 addr:$dst))), addr:$dst), |
| 2340 | (implicit EFLAGS)), |
| 2341 | (DEC64_32m addr:$dst)>, Requires<[In64BitMode]>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2342 | */ |
Dan Gohman | 1f4af26 | 2009-03-05 21:32:23 +0000 | [diff] [blame] | 2343 | |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2344 | def : Pat<(parallel (X86inc_flag GR64:$src), (implicit EFLAGS)), |
| 2345 | (INC64r GR64:$src)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2346 | /* |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2347 | def : Pat<(parallel (store (i64 (X86inc_flag (loadi64 addr:$dst))), addr:$dst), |
| 2348 | (implicit EFLAGS)), |
| 2349 | (INC64m addr:$dst)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2350 | */ |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2351 | def : Pat<(parallel (X86dec_flag GR64:$src), (implicit EFLAGS)), |
| 2352 | (DEC64r GR64:$src)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2353 | /* |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2354 | def : Pat<(parallel (store (i64 (X86dec_flag (loadi64 addr:$dst))), addr:$dst), |
| 2355 | (implicit EFLAGS)), |
| 2356 | (DEC64m addr:$dst)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2357 | */ |
Dan Gohman | 076aee3 | 2009-03-04 19:44:21 +0000 | [diff] [blame] | 2358 | |
Dan Gohman | e220c4b | 2009-09-18 19:59:53 +0000 | [diff] [blame] | 2359 | // Register-Register Logical Or with EFLAGS result |
| 2360 | def : Pat<(parallel (X86or_flag GR64:$src1, GR64:$src2), |
| 2361 | (implicit EFLAGS)), |
| 2362 | (OR64rr GR64:$src1, GR64:$src2)>; |
| 2363 | |
| 2364 | // Register-Integer Logical Or with EFLAGS result |
| 2365 | def : Pat<(parallel (X86or_flag GR64:$src1, i64immSExt8:$src2), |
| 2366 | (implicit EFLAGS)), |
| 2367 | (OR64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 2368 | def : Pat<(parallel (X86or_flag GR64:$src1, i64immSExt32:$src2), |
| 2369 | (implicit EFLAGS)), |
| 2370 | (OR64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 2371 | |
| 2372 | // Register-Memory Logical Or with EFLAGS result |
| 2373 | def : Pat<(parallel (X86or_flag GR64:$src1, (loadi64 addr:$src2)), |
| 2374 | (implicit EFLAGS)), |
| 2375 | (OR64rm GR64:$src1, addr:$src2)>; |
| 2376 | |
| 2377 | // Memory-Register Logical Or with EFLAGS result |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2378 | /* |
Dan Gohman | e220c4b | 2009-09-18 19:59:53 +0000 | [diff] [blame] | 2379 | def : Pat<(parallel (store (X86or_flag (loadi64 addr:$dst), GR64:$src2), |
| 2380 | addr:$dst), |
| 2381 | (implicit EFLAGS)), |
| 2382 | (OR64mr addr:$dst, GR64:$src2)>; |
| 2383 | def : Pat<(parallel (store (X86or_flag (loadi64 addr:$dst), i64immSExt8:$src2), |
| 2384 | addr:$dst), |
| 2385 | (implicit EFLAGS)), |
| 2386 | (OR64mi8 addr:$dst, i64immSExt8:$src2)>; |
| 2387 | def : Pat<(parallel (store (X86or_flag (loadi64 addr:$dst), i64immSExt32:$src2), |
| 2388 | addr:$dst), |
| 2389 | (implicit EFLAGS)), |
| 2390 | (OR64mi32 addr:$dst, i64immSExt32:$src2)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2391 | */ |
Dan Gohman | e220c4b | 2009-09-18 19:59:53 +0000 | [diff] [blame] | 2392 | |
| 2393 | // Register-Register Logical XOr with EFLAGS result |
| 2394 | def : Pat<(parallel (X86xor_flag GR64:$src1, GR64:$src2), |
| 2395 | (implicit EFLAGS)), |
| 2396 | (XOR64rr GR64:$src1, GR64:$src2)>; |
| 2397 | |
| 2398 | // Register-Integer Logical XOr with EFLAGS result |
| 2399 | def : Pat<(parallel (X86xor_flag GR64:$src1, i64immSExt8:$src2), |
| 2400 | (implicit EFLAGS)), |
| 2401 | (XOR64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 2402 | def : Pat<(parallel (X86xor_flag GR64:$src1, i64immSExt32:$src2), |
| 2403 | (implicit EFLAGS)), |
| 2404 | (XOR64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 2405 | |
| 2406 | // Register-Memory Logical XOr with EFLAGS result |
| 2407 | def : Pat<(parallel (X86xor_flag GR64:$src1, (loadi64 addr:$src2)), |
| 2408 | (implicit EFLAGS)), |
| 2409 | (XOR64rm GR64:$src1, addr:$src2)>; |
| 2410 | |
| 2411 | // Memory-Register Logical XOr with EFLAGS result |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2412 | /* |
Dan Gohman | e220c4b | 2009-09-18 19:59:53 +0000 | [diff] [blame] | 2413 | def : Pat<(parallel (store (X86xor_flag (loadi64 addr:$dst), GR64:$src2), |
| 2414 | addr:$dst), |
| 2415 | (implicit EFLAGS)), |
| 2416 | (XOR64mr addr:$dst, GR64:$src2)>; |
| 2417 | def : Pat<(parallel (store (X86xor_flag (loadi64 addr:$dst), i64immSExt8:$src2), |
| 2418 | addr:$dst), |
| 2419 | (implicit EFLAGS)), |
| 2420 | (XOR64mi8 addr:$dst, i64immSExt8:$src2)>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 2421 | def : Pat<(parallel (store (X86xor_flag (loadi64 addr:$dst), |
| 2422 | i64immSExt32:$src2), |
Dan Gohman | e220c4b | 2009-09-18 19:59:53 +0000 | [diff] [blame] | 2423 | addr:$dst), |
| 2424 | (implicit EFLAGS)), |
| 2425 | (XOR64mi32 addr:$dst, i64immSExt32:$src2)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2426 | */ |
Dan Gohman | e220c4b | 2009-09-18 19:59:53 +0000 | [diff] [blame] | 2427 | |
| 2428 | // Register-Register Logical And with EFLAGS result |
| 2429 | def : Pat<(parallel (X86and_flag GR64:$src1, GR64:$src2), |
| 2430 | (implicit EFLAGS)), |
| 2431 | (AND64rr GR64:$src1, GR64:$src2)>; |
| 2432 | |
| 2433 | // Register-Integer Logical And with EFLAGS result |
| 2434 | def : Pat<(parallel (X86and_flag GR64:$src1, i64immSExt8:$src2), |
| 2435 | (implicit EFLAGS)), |
| 2436 | (AND64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 2437 | def : Pat<(parallel (X86and_flag GR64:$src1, i64immSExt32:$src2), |
| 2438 | (implicit EFLAGS)), |
| 2439 | (AND64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 2440 | |
| 2441 | // Register-Memory Logical And with EFLAGS result |
| 2442 | def : Pat<(parallel (X86and_flag GR64:$src1, (loadi64 addr:$src2)), |
| 2443 | (implicit EFLAGS)), |
| 2444 | (AND64rm GR64:$src1, addr:$src2)>; |
| 2445 | |
| 2446 | // Memory-Register Logical And with EFLAGS result |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2447 | /* |
Dan Gohman | e220c4b | 2009-09-18 19:59:53 +0000 | [diff] [blame] | 2448 | def : Pat<(parallel (store (X86and_flag (loadi64 addr:$dst), GR64:$src2), |
| 2449 | addr:$dst), |
| 2450 | (implicit EFLAGS)), |
| 2451 | (AND64mr addr:$dst, GR64:$src2)>; |
| 2452 | def : Pat<(parallel (store (X86and_flag (loadi64 addr:$dst), i64immSExt8:$src2), |
| 2453 | addr:$dst), |
| 2454 | (implicit EFLAGS)), |
| 2455 | (AND64mi8 addr:$dst, i64immSExt8:$src2)>; |
Sean Callanan | 108934c | 2009-12-18 00:01:26 +0000 | [diff] [blame] | 2456 | def : Pat<(parallel (store (X86and_flag (loadi64 addr:$dst), |
| 2457 | i64immSExt32:$src2), |
Dan Gohman | e220c4b | 2009-09-18 19:59:53 +0000 | [diff] [blame] | 2458 | addr:$dst), |
| 2459 | (implicit EFLAGS)), |
| 2460 | (AND64mi32 addr:$dst, i64immSExt32:$src2)>; |
Chris Lattner | 1d7dbd1 | 2010-03-19 04:14:21 +0000 | [diff] [blame] | 2461 | */ |
Dan Gohman | e220c4b | 2009-09-18 19:59:53 +0000 | [diff] [blame] | 2462 | |
Evan Cheng | ebf01d6 | 2006-11-16 23:33:25 +0000 | [diff] [blame] | 2463 | //===----------------------------------------------------------------------===// |
| 2464 | // X86-64 SSE Instructions |
| 2465 | //===----------------------------------------------------------------------===// |
| 2466 | |
| 2467 | // Move instructions... |
| 2468 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2469 | def MOV64toPQIrr : RPDI<0x6E, MRMSrcReg, (outs VR128:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2470 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | ebf01d6 | 2006-11-16 23:33:25 +0000 | [diff] [blame] | 2471 | [(set VR128:$dst, |
| 2472 | (v2i64 (scalar_to_vector GR64:$src)))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2473 | def MOVPQIto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins VR128:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2474 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | ebf01d6 | 2006-11-16 23:33:25 +0000 | [diff] [blame] | 2475 | [(set GR64:$dst, (vector_extract (v2i64 VR128:$src), |
| 2476 | (iPTR 0)))]>; |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 2477 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2478 | def MOV64toSDrr : RPDI<0x6E, MRMSrcReg, (outs FR64:$dst), (ins GR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2479 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 2480 | [(set FR64:$dst, (bitconvert GR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2481 | def MOV64toSDrm : RPDI<0x6E, MRMSrcMem, (outs FR64:$dst), (ins i64mem:$src), |
Evan Cheng | e732144 | 2008-08-25 04:11:42 +0000 | [diff] [blame] | 2482 | "movq\t{$src, $dst|$dst, $src}", |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 2483 | [(set FR64:$dst, (bitconvert (loadi64 addr:$src)))]>; |
| 2484 | |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2485 | def MOVSDto64rr : RPDI<0x7E, MRMDestReg, (outs GR64:$dst), (ins FR64:$src), |
Dan Gohman | b1576f5 | 2007-07-31 20:11:57 +0000 | [diff] [blame] | 2486 | "mov{d|q}\t{$src, $dst|$dst, $src}", |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 2487 | [(set GR64:$dst, (bitconvert FR64:$src))]>; |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 2488 | def MOVSDto64mr : RPDI<0x7E, MRMDestMem, (outs), (ins i64mem:$dst, FR64:$src), |
Evan Cheng | e732144 | 2008-08-25 04:11:42 +0000 | [diff] [blame] | 2489 | "movq\t{$src, $dst|$dst, $src}", |
Evan Cheng | 21b7612 | 2006-12-14 21:55:39 +0000 | [diff] [blame] | 2490 | [(store (i64 (bitconvert FR64:$src)), addr:$dst)]>; |
Nate Begeman | 63ec90a | 2008-02-03 07:18:54 +0000 | [diff] [blame] | 2491 | |
| 2492 | //===----------------------------------------------------------------------===// |
| 2493 | // X86-64 SSE4.1 Instructions |
| 2494 | //===----------------------------------------------------------------------===// |
| 2495 | |
Nate Begeman | cdd1eec | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 2496 | /// SS41I_extract32 - SSE 4.1 extract 32 bits to int reg or memory destination |
| 2497 | multiclass SS41I_extract64<bits<8> opc, string OpcodeStr> { |
Nate Begeman | 110e3b3 | 2008-10-29 23:07:17 +0000 | [diff] [blame] | 2498 | def rr : SS4AIi8<opc, MRMDestReg, (outs GR64:$dst), |
Nate Begeman | cdd1eec | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 2499 | (ins VR128:$src1, i32i8imm:$src2), |
| 2500 | !strconcat(OpcodeStr, |
| 2501 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 2502 | [(set GR64:$dst, |
| 2503 | (extractelt (v2i64 VR128:$src1), imm:$src2))]>, OpSize, REX_W; |
Evan Cheng | 172b794 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 2504 | def mr : SS4AIi8<opc, MRMDestMem, (outs), |
Nate Begeman | cdd1eec | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 2505 | (ins i64mem:$dst, VR128:$src1, i32i8imm:$src2), |
| 2506 | !strconcat(OpcodeStr, |
| 2507 | "\t{$src2, $src1, $dst|$dst, $src1, $src2}"), |
| 2508 | [(store (extractelt (v2i64 VR128:$src1), imm:$src2), |
| 2509 | addr:$dst)]>, OpSize, REX_W; |
| 2510 | } |
| 2511 | |
| 2512 | defm PEXTRQ : SS41I_extract64<0x16, "pextrq">; |
| 2513 | |
| 2514 | let isTwoAddress = 1 in { |
| 2515 | multiclass SS41I_insert64<bits<8> opc, string OpcodeStr> { |
Evan Cheng | 172b794 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 2516 | def rr : SS4AIi8<opc, MRMSrcReg, (outs VR128:$dst), |
Nate Begeman | cdd1eec | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 2517 | (ins VR128:$src1, GR64:$src2, i32i8imm:$src3), |
| 2518 | !strconcat(OpcodeStr, |
| 2519 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
| 2520 | [(set VR128:$dst, |
| 2521 | (v2i64 (insertelt VR128:$src1, GR64:$src2, imm:$src3)))]>, |
| 2522 | OpSize, REX_W; |
Evan Cheng | 172b794 | 2008-03-14 07:39:27 +0000 | [diff] [blame] | 2523 | def rm : SS4AIi8<opc, MRMSrcMem, (outs VR128:$dst), |
Nate Begeman | cdd1eec | 2008-02-12 22:51:28 +0000 | [diff] [blame] | 2524 | (ins VR128:$src1, i64mem:$src2, i32i8imm:$src3), |
| 2525 | !strconcat(OpcodeStr, |
| 2526 | "\t{$src3, $src2, $dst|$dst, $src2, $src3}"), |
| 2527 | [(set VR128:$dst, |
| 2528 | (v2i64 (insertelt VR128:$src1, (loadi64 addr:$src2), |
| 2529 | imm:$src3)))]>, OpSize, REX_W; |
| 2530 | } |
| 2531 | } |
| 2532 | |
| 2533 | defm PINSRQ : SS41I_insert64<0x22, "pinsrq">; |
Dan Gohman | 2f67df7 | 2009-09-03 17:18:51 +0000 | [diff] [blame] | 2534 | |
| 2535 | // -disable-16bit support. |
Chris Lattner | 341b274 | 2010-03-08 18:55:15 +0000 | [diff] [blame] | 2536 | def : Pat<(truncstorei16 (i16 imm:$src), addr:$dst), |
Dan Gohman | 2f67df7 | 2009-09-03 17:18:51 +0000 | [diff] [blame] | 2537 | (MOV16mi addr:$dst, imm:$src)>; |
| 2538 | def : Pat<(truncstorei16 GR64:$src, addr:$dst), |
| 2539 | (MOV16mr addr:$dst, (EXTRACT_SUBREG GR64:$src, x86_subreg_16bit))>; |
| 2540 | def : Pat<(i64 (sextloadi16 addr:$dst)), |
| 2541 | (MOVSX64rm16 addr:$dst)>; |
| 2542 | def : Pat<(i64 (zextloadi16 addr:$dst)), |
| 2543 | (MOVZX64rm16 addr:$dst)>; |
| 2544 | def : Pat<(i64 (extloadi16 addr:$dst)), |
| 2545 | (MOVZX64rm16 addr:$dst)>; |