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