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