Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 1 | //===- X86InstrCompiler.td - Compiler Pseudos and Patterns -*- tablegen -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file describes the various pseudo instructions used by the compiler, |
| 11 | // as well as Pat patterns used during instruction selection. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Chris Lattner | 41efbfa | 2010-10-05 06:37:31 +0000 | [diff] [blame] | 15 | //===----------------------------------------------------------------------===// |
| 16 | // Pattern Matching Support |
| 17 | |
| 18 | def GetLo32XForm : SDNodeXForm<imm, [{ |
| 19 | // Transformation function: get the low 32 bits. |
| 20 | return getI32Imm((unsigned)N->getZExtValue()); |
| 21 | }]>; |
| 22 | |
| 23 | |
| 24 | //===----------------------------------------------------------------------===// |
| 25 | // Random Pseudo Instructions. |
| 26 | |
Chris Lattner | 8af88ef | 2010-10-05 06:10:16 +0000 | [diff] [blame] | 27 | // PIC base construction. This expands to code that looks like this: |
| 28 | // call $next_inst |
| 29 | // popl %destreg" |
| 30 | let neverHasSideEffects = 1, isNotDuplicable = 1, Uses = [ESP] in |
| 31 | def MOVPC32r : Ii32<0xE8, Pseudo, (outs GR32:$reg), (ins i32imm:$label), |
| 32 | "", []>; |
| 33 | |
| 34 | |
| 35 | // ADJCALLSTACKDOWN/UP implicitly use/def ESP because they may be expanded into |
| 36 | // a stack adjustment and the codegen must know that they may modify the stack |
| 37 | // pointer before prolog-epilog rewriting occurs. |
| 38 | // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become |
| 39 | // sub / add which can clobber EFLAGS. |
| 40 | let Defs = [ESP, EFLAGS], Uses = [ESP] in { |
| 41 | def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt), |
| 42 | "#ADJCALLSTACKDOWN", |
| 43 | [(X86callseq_start timm:$amt)]>, |
| 44 | Requires<[In32BitMode]>; |
| 45 | def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2), |
| 46 | "#ADJCALLSTACKUP", |
| 47 | [(X86callseq_end timm:$amt1, timm:$amt2)]>, |
| 48 | Requires<[In32BitMode]>; |
| 49 | } |
| 50 | |
| 51 | // ADJCALLSTACKDOWN/UP implicitly use/def RSP because they may be expanded into |
| 52 | // a stack adjustment and the codegen must know that they may modify the stack |
| 53 | // pointer before prolog-epilog rewriting occurs. |
| 54 | // Pessimistically assume ADJCALLSTACKDOWN / ADJCALLSTACKUP will become |
| 55 | // sub / add which can clobber EFLAGS. |
| 56 | let Defs = [RSP, EFLAGS], Uses = [RSP] in { |
| 57 | def ADJCALLSTACKDOWN64 : I<0, Pseudo, (outs), (ins i32imm:$amt), |
| 58 | "#ADJCALLSTACKDOWN", |
| 59 | [(X86callseq_start timm:$amt)]>, |
| 60 | Requires<[In64BitMode]>; |
| 61 | def ADJCALLSTACKUP64 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2), |
| 62 | "#ADJCALLSTACKUP", |
| 63 | [(X86callseq_end timm:$amt1, timm:$amt2)]>, |
| 64 | Requires<[In64BitMode]>; |
| 65 | } |
| 66 | |
| 67 | |
| 68 | |
| 69 | // x86-64 va_start lowering magic. |
| 70 | let usesCustomInserter = 1 in { |
| 71 | def VASTART_SAVE_XMM_REGS : I<0, Pseudo, |
| 72 | (outs), |
| 73 | (ins GR8:$al, |
| 74 | i64imm:$regsavefi, i64imm:$offset, |
| 75 | variable_ops), |
| 76 | "#VASTART_SAVE_XMM_REGS $al, $regsavefi, $offset", |
| 77 | [(X86vastart_save_xmm_regs GR8:$al, |
| 78 | imm:$regsavefi, |
| 79 | imm:$offset)]>; |
| 80 | |
Dan Gohman | 320afb8 | 2010-10-12 18:00:49 +0000 | [diff] [blame^] | 81 | // The VAARG_64 pseudo-instruction takes the address of the va_list, |
| 82 | // and places the address of the next argument into a register. |
| 83 | let Defs = [EFLAGS] in |
| 84 | def VAARG_64 : I<0, Pseudo, |
| 85 | (outs GR64:$dst), |
| 86 | (ins i8mem:$ap, i32imm:$size, i8imm:$mode, i32imm:$align), |
| 87 | "#VAARG_64 $dst, $ap, $size, $mode, $align", |
| 88 | [(set GR64:$dst, |
| 89 | (X86vaarg64 addr:$ap, imm:$size, imm:$mode, imm:$align)), |
| 90 | (implicit EFLAGS)]>; |
| 91 | |
Chris Lattner | 8af88ef | 2010-10-05 06:10:16 +0000 | [diff] [blame] | 92 | // Dynamic stack allocation yields _alloca call for Cygwin/Mingw targets. Calls |
| 93 | // to _alloca is needed to probe the stack when allocating more than 4k bytes in |
| 94 | // one go. Touching the stack at 4K increments is necessary to ensure that the |
| 95 | // guard pages used by the OS virtual memory manager are allocated in correct |
| 96 | // sequence. |
| 97 | // The main point of having separate instruction are extra unmodelled effects |
| 98 | // (compared to ordinary calls) like stack pointer change. |
| 99 | |
| 100 | let Defs = [EAX, ESP, EFLAGS], Uses = [ESP] in |
| 101 | def MINGW_ALLOCA : I<0, Pseudo, (outs), (ins), |
| 102 | "# dynamic stack allocation", |
| 103 | [(X86MingwAlloca)]>; |
| 104 | } |
| 105 | |
| 106 | |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 107 | |
| 108 | //===----------------------------------------------------------------------===// |
| 109 | // EH Pseudo Instructions |
| 110 | // |
| 111 | let isTerminator = 1, isReturn = 1, isBarrier = 1, |
| 112 | hasCtrlDep = 1, isCodeGenOnly = 1 in { |
| 113 | def EH_RETURN : I<0xC3, RawFrm, (outs), (ins GR32:$addr), |
| 114 | "ret\t#eh_return, addr: $addr", |
| 115 | [(X86ehret GR32:$addr)]>; |
| 116 | |
| 117 | } |
| 118 | |
| 119 | let isTerminator = 1, isReturn = 1, isBarrier = 1, |
| 120 | hasCtrlDep = 1, isCodeGenOnly = 1 in { |
| 121 | def EH_RETURN64 : I<0xC3, RawFrm, (outs), (ins GR64:$addr), |
| 122 | "ret\t#eh_return, addr: $addr", |
| 123 | [(X86ehret GR64:$addr)]>; |
| 124 | |
| 125 | } |
| 126 | |
Chris Lattner | 8af88ef | 2010-10-05 06:10:16 +0000 | [diff] [blame] | 127 | //===----------------------------------------------------------------------===// |
| 128 | // Alias Instructions |
| 129 | //===----------------------------------------------------------------------===// |
| 130 | |
| 131 | // Alias instructions that map movr0 to xor. |
| 132 | // FIXME: remove when we can teach regalloc that xor reg, reg is ok. |
| 133 | // FIXME: Set encoding to pseudo. |
| 134 | let Defs = [EFLAGS], isReMaterializable = 1, isAsCheapAsAMove = 1, |
| 135 | isCodeGenOnly = 1 in { |
| 136 | def MOV8r0 : I<0x30, MRMInitReg, (outs GR8 :$dst), (ins), "", |
| 137 | [(set GR8:$dst, 0)]>; |
| 138 | |
| 139 | // We want to rewrite MOV16r0 in terms of MOV32r0, because it's a smaller |
| 140 | // encoding and avoids a partial-register update sometimes, but doing so |
| 141 | // at isel time interferes with rematerialization in the current register |
| 142 | // allocator. For now, this is rewritten when the instruction is lowered |
| 143 | // to an MCInst. |
| 144 | def MOV16r0 : I<0x31, MRMInitReg, (outs GR16:$dst), (ins), |
| 145 | "", |
| 146 | [(set GR16:$dst, 0)]>, OpSize; |
| 147 | |
| 148 | // FIXME: Set encoding to pseudo. |
| 149 | def MOV32r0 : I<0x31, MRMInitReg, (outs GR32:$dst), (ins), "", |
| 150 | [(set GR32:$dst, 0)]>; |
| 151 | } |
| 152 | |
Chris Lattner | 010496c | 2010-10-05 06:22:35 +0000 | [diff] [blame] | 153 | // We want to rewrite MOV64r0 in terms of MOV32r0, because it's sometimes a |
| 154 | // smaller encoding, but doing so at isel time interferes with rematerialization |
| 155 | // in the current register allocator. For now, this is rewritten when the |
| 156 | // instruction is lowered to an MCInst. |
| 157 | // FIXME: AddedComplexity gives this a higher priority than MOV64ri32. Remove |
| 158 | // when we have a better way to specify isel priority. |
| 159 | let Defs = [EFLAGS], |
| 160 | AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in |
| 161 | def MOV64r0 : I<0x31, MRMInitReg, (outs GR64:$dst), (ins), "", |
| 162 | [(set GR64:$dst, 0)]>; |
| 163 | |
| 164 | // Materialize i64 constant where top 32-bits are zero. This could theoretically |
| 165 | // use MOV32ri with a SUBREG_TO_REG to represent the zero-extension, however |
| 166 | // that would make it more difficult to rematerialize. |
| 167 | let AddedComplexity = 1, isReMaterializable = 1, isAsCheapAsAMove = 1 in |
| 168 | def MOV64ri64i32 : Ii32<0xB8, AddRegFrm, (outs GR64:$dst), (ins i64i32imm:$src), |
| 169 | "", [(set GR64:$dst, i64immZExt32:$src)]>; |
| 170 | |
Chris Lattner | 35649fc | 2010-10-05 06:33:16 +0000 | [diff] [blame] | 171 | |
Chris Lattner | 2c383d8 | 2010-10-05 21:18:04 +0000 | [diff] [blame] | 172 | // Use sbb to materialize carry bit. |
| 173 | let Uses = [EFLAGS], Defs = [EFLAGS], isCodeGenOnly = 1 in { |
| 174 | // FIXME: These are pseudo ops that should be replaced with Pat<> patterns. |
Chris Lattner | 35649fc | 2010-10-05 06:33:16 +0000 | [diff] [blame] | 175 | // However, Pat<> can't replicate the destination reg into the inputs of the |
| 176 | // result. |
Chris Lattner | 2c383d8 | 2010-10-05 21:18:04 +0000 | [diff] [blame] | 177 | // FIXME: Change these to have encoding Pseudo when X86MCCodeEmitter replaces |
Chris Lattner | 35649fc | 2010-10-05 06:33:16 +0000 | [diff] [blame] | 178 | // X86CodeEmitter. |
Chris Lattner | 2c383d8 | 2010-10-05 21:18:04 +0000 | [diff] [blame] | 179 | def SETB_C8r : I<0x18, MRMInitReg, (outs GR8:$dst), (ins), "", |
| 180 | [(set GR8:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>; |
| 181 | def SETB_C16r : I<0x19, MRMInitReg, (outs GR16:$dst), (ins), "", |
| 182 | [(set GR16:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>, |
| 183 | OpSize; |
| 184 | def SETB_C32r : I<0x19, MRMInitReg, (outs GR32:$dst), (ins), "", |
| 185 | [(set GR32:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>; |
Chris Lattner | 35649fc | 2010-10-05 06:33:16 +0000 | [diff] [blame] | 186 | def SETB_C64r : RI<0x19, MRMInitReg, (outs GR64:$dst), (ins), "", |
| 187 | [(set GR64:$dst, (X86setcc_c X86_COND_B, EFLAGS))]>; |
Chris Lattner | 2c383d8 | 2010-10-05 21:18:04 +0000 | [diff] [blame] | 188 | } // isCodeGenOnly |
| 189 | |
Chris Lattner | 35649fc | 2010-10-05 06:33:16 +0000 | [diff] [blame] | 190 | |
| 191 | def : Pat<(i64 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))), |
| 192 | (SETB_C64r)>; |
| 193 | |
Chris Lattner | 010496c | 2010-10-05 06:22:35 +0000 | [diff] [blame] | 194 | |
Chris Lattner | d3f033d | 2010-10-05 06:27:48 +0000 | [diff] [blame] | 195 | //===----------------------------------------------------------------------===// |
| 196 | // String Pseudo Instructions |
| 197 | // |
| 198 | let Defs = [ECX,EDI,ESI], Uses = [ECX,EDI,ESI], isCodeGenOnly = 1 in { |
| 199 | def REP_MOVSB : I<0xA4, RawFrm, (outs), (ins), "{rep;movsb|rep movsb}", |
| 200 | [(X86rep_movs i8)]>, REP; |
| 201 | def REP_MOVSW : I<0xA5, RawFrm, (outs), (ins), "{rep;movsw|rep movsw}", |
| 202 | [(X86rep_movs i16)]>, REP, OpSize; |
| 203 | def REP_MOVSD : I<0xA5, RawFrm, (outs), (ins), "{rep;movsl|rep movsd}", |
| 204 | [(X86rep_movs i32)]>, REP; |
| 205 | } |
| 206 | |
| 207 | let Defs = [RCX,RDI,RSI], Uses = [RCX,RDI,RSI], isCodeGenOnly = 1 in |
| 208 | def REP_MOVSQ : RI<0xA5, RawFrm, (outs), (ins), "{rep;movsq|rep movsq}", |
| 209 | [(X86rep_movs i64)]>, REP; |
| 210 | |
| 211 | |
| 212 | // FIXME: Should use "(X86rep_stos AL)" as the pattern. |
| 213 | let Defs = [ECX,EDI], Uses = [AL,ECX,EDI], isCodeGenOnly = 1 in |
| 214 | def REP_STOSB : I<0xAA, RawFrm, (outs), (ins), "{rep;stosb|rep stosb}", |
| 215 | [(X86rep_stos i8)]>, REP; |
| 216 | let Defs = [ECX,EDI], Uses = [AX,ECX,EDI], isCodeGenOnly = 1 in |
| 217 | def REP_STOSW : I<0xAB, RawFrm, (outs), (ins), "{rep;stosw|rep stosw}", |
| 218 | [(X86rep_stos i16)]>, REP, OpSize; |
| 219 | let Defs = [ECX,EDI], Uses = [EAX,ECX,EDI], isCodeGenOnly = 1 in |
| 220 | def REP_STOSD : I<0xAB, RawFrm, (outs), (ins), "{rep;stosl|rep stosd}", |
| 221 | [(X86rep_stos i32)]>, REP; |
| 222 | |
| 223 | let Defs = [RCX,RDI], Uses = [RAX,RCX,RDI], isCodeGenOnly = 1 in |
| 224 | def REP_STOSQ : RI<0xAB, RawFrm, (outs), (ins), "{rep;stosq|rep stosq}", |
| 225 | [(X86rep_stos i64)]>, REP; |
Chris Lattner | 010496c | 2010-10-05 06:22:35 +0000 | [diff] [blame] | 226 | |
| 227 | |
Chris Lattner | 8af88ef | 2010-10-05 06:10:16 +0000 | [diff] [blame] | 228 | //===----------------------------------------------------------------------===// |
| 229 | // Thread Local Storage Instructions |
| 230 | // |
| 231 | |
| 232 | // ELF TLS Support |
| 233 | // All calls clobber the non-callee saved registers. ESP is marked as |
| 234 | // a use to prevent stack-pointer assignments that appear immediately |
| 235 | // before calls from potentially appearing dead. |
| 236 | let Defs = [EAX, ECX, EDX, FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, |
| 237 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
| 238 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, |
| 239 | XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], |
| 240 | Uses = [ESP] in |
| 241 | def TLS_addr32 : I<0, Pseudo, (outs), (ins i32mem:$sym), |
| 242 | "leal\t$sym, %eax; " |
| 243 | "call\t___tls_get_addr@PLT", |
| 244 | [(X86tlsaddr tls32addr:$sym)]>, |
| 245 | Requires<[In32BitMode]>; |
| 246 | |
| 247 | // All calls clobber the non-callee saved registers. RSP is marked as |
| 248 | // a use to prevent stack-pointer assignments that appear immediately |
| 249 | // before calls from potentially appearing dead. |
| 250 | let Defs = [RAX, RCX, RDX, RSI, RDI, R8, R9, R10, R11, |
| 251 | FP0, FP1, FP2, FP3, FP4, FP5, FP6, ST0, ST1, |
| 252 | MM0, MM1, MM2, MM3, MM4, MM5, MM6, MM7, |
| 253 | XMM0, XMM1, XMM2, XMM3, XMM4, XMM5, XMM6, XMM7, |
| 254 | XMM8, XMM9, XMM10, XMM11, XMM12, XMM13, XMM14, XMM15, EFLAGS], |
| 255 | Uses = [RSP] in |
| 256 | def TLS_addr64 : I<0, Pseudo, (outs), (ins i64mem:$sym), |
| 257 | ".byte\t0x66; " |
| 258 | "leaq\t$sym(%rip), %rdi; " |
| 259 | ".word\t0x6666; " |
| 260 | "rex64; " |
| 261 | "call\t__tls_get_addr@PLT", |
| 262 | [(X86tlsaddr tls64addr:$sym)]>, |
| 263 | Requires<[In64BitMode]>; |
| 264 | |
| 265 | // Darwin TLS Support |
| 266 | // For i386, the address of the thunk is passed on the stack, on return the |
| 267 | // address of the variable is in %eax. %ecx is trashed during the function |
| 268 | // call. All other registers are preserved. |
| 269 | let Defs = [EAX, ECX], |
| 270 | Uses = [ESP], |
| 271 | usesCustomInserter = 1 in |
| 272 | def TLSCall_32 : I<0, Pseudo, (outs), (ins i32mem:$sym), |
| 273 | "# TLSCall_32", |
| 274 | [(X86TLSCall addr:$sym)]>, |
| 275 | Requires<[In32BitMode]>; |
| 276 | |
| 277 | // For x86_64, the address of the thunk is passed in %rdi, on return |
| 278 | // the address of the variable is in %rax. All other registers are preserved. |
| 279 | let Defs = [RAX], |
| 280 | Uses = [RDI], |
| 281 | usesCustomInserter = 1 in |
| 282 | def TLSCall_64 : I<0, Pseudo, (outs), (ins i64mem:$sym), |
| 283 | "# TLSCall_64", |
| 284 | [(X86TLSCall addr:$sym)]>, |
| 285 | Requires<[In64BitMode]>; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 286 | |
Chris Lattner | 6dbbff9 | 2010-10-05 23:09:10 +0000 | [diff] [blame] | 287 | |
| 288 | //===----------------------------------------------------------------------===// |
| 289 | // Conditional Move Pseudo Instructions |
| 290 | |
| 291 | let Constraints = "$src1 = $dst" in { |
| 292 | |
| 293 | // Conditional moves |
| 294 | let Uses = [EFLAGS] in { |
| 295 | |
| 296 | // X86 doesn't have 8-bit conditional moves. Use a customInserter to |
| 297 | // emit control flow. An alternative to this is to mark i8 SELECT as Promote, |
| 298 | // however that requires promoting the operands, and can induce additional |
| 299 | // i8 register pressure. Note that CMOV_GR8 is conservatively considered to |
| 300 | // clobber EFLAGS, because if one of the operands is zero, the expansion |
| 301 | // could involve an xor. |
| 302 | let usesCustomInserter = 1, Constraints = "", Defs = [EFLAGS] in { |
| 303 | def CMOV_GR8 : I<0, Pseudo, |
| 304 | (outs GR8:$dst), (ins GR8:$src1, GR8:$src2, i8imm:$cond), |
| 305 | "#CMOV_GR8 PSEUDO!", |
| 306 | [(set GR8:$dst, (X86cmov GR8:$src1, GR8:$src2, |
| 307 | imm:$cond, EFLAGS))]>; |
| 308 | |
| 309 | let Predicates = [NoCMov] in { |
| 310 | def CMOV_GR32 : I<0, Pseudo, |
| 311 | (outs GR32:$dst), (ins GR32:$src1, GR32:$src2, i8imm:$cond), |
| 312 | "#CMOV_GR32* PSEUDO!", |
| 313 | [(set GR32:$dst, |
| 314 | (X86cmov GR32:$src1, GR32:$src2, imm:$cond, EFLAGS))]>; |
| 315 | def CMOV_GR16 : I<0, Pseudo, |
| 316 | (outs GR16:$dst), (ins GR16:$src1, GR16:$src2, i8imm:$cond), |
| 317 | "#CMOV_GR16* PSEUDO!", |
| 318 | [(set GR16:$dst, |
| 319 | (X86cmov GR16:$src1, GR16:$src2, imm:$cond, EFLAGS))]>; |
| 320 | def CMOV_RFP32 : I<0, Pseudo, |
| 321 | (outs RFP32:$dst), |
| 322 | (ins RFP32:$src1, RFP32:$src2, i8imm:$cond), |
| 323 | "#CMOV_RFP32 PSEUDO!", |
| 324 | [(set RFP32:$dst, |
| 325 | (X86cmov RFP32:$src1, RFP32:$src2, imm:$cond, |
| 326 | EFLAGS))]>; |
| 327 | def CMOV_RFP64 : I<0, Pseudo, |
| 328 | (outs RFP64:$dst), |
| 329 | (ins RFP64:$src1, RFP64:$src2, i8imm:$cond), |
| 330 | "#CMOV_RFP64 PSEUDO!", |
| 331 | [(set RFP64:$dst, |
| 332 | (X86cmov RFP64:$src1, RFP64:$src2, imm:$cond, |
| 333 | EFLAGS))]>; |
| 334 | def CMOV_RFP80 : I<0, Pseudo, |
| 335 | (outs RFP80:$dst), |
| 336 | (ins RFP80:$src1, RFP80:$src2, i8imm:$cond), |
| 337 | "#CMOV_RFP80 PSEUDO!", |
| 338 | [(set RFP80:$dst, |
| 339 | (X86cmov RFP80:$src1, RFP80:$src2, imm:$cond, |
| 340 | EFLAGS))]>; |
| 341 | } // Predicates = [NoCMov] |
| 342 | } // UsesCustomInserter = 1, Constraints = "", Defs = [EFLAGS] |
| 343 | } // Uses = [EFLAGS] |
| 344 | |
| 345 | } // Constraints = "$src1 = $dst" in |
| 346 | |
| 347 | |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 348 | //===----------------------------------------------------------------------===// |
Chris Lattner | 010496c | 2010-10-05 06:22:35 +0000 | [diff] [blame] | 349 | // Atomic Instruction Pseudo Instructions |
| 350 | //===----------------------------------------------------------------------===// |
| 351 | |
| 352 | // Atomic exchange, and, or, xor |
| 353 | let Constraints = "$val = $dst", Defs = [EFLAGS], |
| 354 | usesCustomInserter = 1 in { |
| 355 | |
| 356 | def ATOMAND8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val), |
| 357 | "#ATOMAND8 PSEUDO!", |
| 358 | [(set GR8:$dst, (atomic_load_and_8 addr:$ptr, GR8:$val))]>; |
| 359 | def ATOMOR8 : I<0, Pseudo, (outs GR8:$dst),(ins i8mem:$ptr, GR8:$val), |
| 360 | "#ATOMOR8 PSEUDO!", |
| 361 | [(set GR8:$dst, (atomic_load_or_8 addr:$ptr, GR8:$val))]>; |
| 362 | def ATOMXOR8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val), |
| 363 | "#ATOMXOR8 PSEUDO!", |
| 364 | [(set GR8:$dst, (atomic_load_xor_8 addr:$ptr, GR8:$val))]>; |
| 365 | def ATOMNAND8 : I<0, Pseudo,(outs GR8:$dst),(ins i8mem:$ptr, GR8:$val), |
| 366 | "#ATOMNAND8 PSEUDO!", |
| 367 | [(set GR8:$dst, (atomic_load_nand_8 addr:$ptr, GR8:$val))]>; |
| 368 | |
| 369 | def ATOMAND16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val), |
| 370 | "#ATOMAND16 PSEUDO!", |
| 371 | [(set GR16:$dst, (atomic_load_and_16 addr:$ptr, GR16:$val))]>; |
| 372 | def ATOMOR16 : I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val), |
| 373 | "#ATOMOR16 PSEUDO!", |
| 374 | [(set GR16:$dst, (atomic_load_or_16 addr:$ptr, GR16:$val))]>; |
| 375 | def ATOMXOR16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val), |
| 376 | "#ATOMXOR16 PSEUDO!", |
| 377 | [(set GR16:$dst, (atomic_load_xor_16 addr:$ptr, GR16:$val))]>; |
| 378 | def ATOMNAND16 : I<0, Pseudo,(outs GR16:$dst),(ins i16mem:$ptr, GR16:$val), |
| 379 | "#ATOMNAND16 PSEUDO!", |
| 380 | [(set GR16:$dst, (atomic_load_nand_16 addr:$ptr, GR16:$val))]>; |
| 381 | def ATOMMIN16: I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$ptr, GR16:$val), |
| 382 | "#ATOMMIN16 PSEUDO!", |
| 383 | [(set GR16:$dst, (atomic_load_min_16 addr:$ptr, GR16:$val))]>; |
| 384 | def ATOMMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val), |
| 385 | "#ATOMMAX16 PSEUDO!", |
| 386 | [(set GR16:$dst, (atomic_load_max_16 addr:$ptr, GR16:$val))]>; |
| 387 | def ATOMUMIN16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val), |
| 388 | "#ATOMUMIN16 PSEUDO!", |
| 389 | [(set GR16:$dst, (atomic_load_umin_16 addr:$ptr, GR16:$val))]>; |
| 390 | def ATOMUMAX16: I<0, Pseudo, (outs GR16:$dst),(ins i16mem:$ptr, GR16:$val), |
| 391 | "#ATOMUMAX16 PSEUDO!", |
| 392 | [(set GR16:$dst, (atomic_load_umax_16 addr:$ptr, GR16:$val))]>; |
| 393 | |
| 394 | |
| 395 | def ATOMAND32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), |
| 396 | "#ATOMAND32 PSEUDO!", |
| 397 | [(set GR32:$dst, (atomic_load_and_32 addr:$ptr, GR32:$val))]>; |
| 398 | def ATOMOR32 : I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), |
| 399 | "#ATOMOR32 PSEUDO!", |
| 400 | [(set GR32:$dst, (atomic_load_or_32 addr:$ptr, GR32:$val))]>; |
| 401 | def ATOMXOR32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), |
| 402 | "#ATOMXOR32 PSEUDO!", |
| 403 | [(set GR32:$dst, (atomic_load_xor_32 addr:$ptr, GR32:$val))]>; |
| 404 | def ATOMNAND32 : I<0, Pseudo,(outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), |
| 405 | "#ATOMNAND32 PSEUDO!", |
| 406 | [(set GR32:$dst, (atomic_load_nand_32 addr:$ptr, GR32:$val))]>; |
| 407 | def ATOMMIN32: I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$ptr, GR32:$val), |
| 408 | "#ATOMMIN32 PSEUDO!", |
| 409 | [(set GR32:$dst, (atomic_load_min_32 addr:$ptr, GR32:$val))]>; |
| 410 | def ATOMMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), |
| 411 | "#ATOMMAX32 PSEUDO!", |
| 412 | [(set GR32:$dst, (atomic_load_max_32 addr:$ptr, GR32:$val))]>; |
| 413 | def ATOMUMIN32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), |
| 414 | "#ATOMUMIN32 PSEUDO!", |
| 415 | [(set GR32:$dst, (atomic_load_umin_32 addr:$ptr, GR32:$val))]>; |
| 416 | def ATOMUMAX32: I<0, Pseudo, (outs GR32:$dst),(ins i32mem:$ptr, GR32:$val), |
| 417 | "#ATOMUMAX32 PSEUDO!", |
| 418 | [(set GR32:$dst, (atomic_load_umax_32 addr:$ptr, GR32:$val))]>; |
| 419 | |
| 420 | |
| 421 | |
| 422 | def ATOMAND64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
| 423 | "#ATOMAND64 PSEUDO!", |
| 424 | [(set GR64:$dst, (atomic_load_and_64 addr:$ptr, GR64:$val))]>; |
| 425 | def ATOMOR64 : I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
| 426 | "#ATOMOR64 PSEUDO!", |
| 427 | [(set GR64:$dst, (atomic_load_or_64 addr:$ptr, GR64:$val))]>; |
| 428 | def ATOMXOR64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
| 429 | "#ATOMXOR64 PSEUDO!", |
| 430 | [(set GR64:$dst, (atomic_load_xor_64 addr:$ptr, GR64:$val))]>; |
| 431 | def ATOMNAND64 : I<0, Pseudo,(outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
| 432 | "#ATOMNAND64 PSEUDO!", |
| 433 | [(set GR64:$dst, (atomic_load_nand_64 addr:$ptr, GR64:$val))]>; |
| 434 | def ATOMMIN64: I<0, Pseudo, (outs GR64:$dst), (ins i64mem:$ptr, GR64:$val), |
| 435 | "#ATOMMIN64 PSEUDO!", |
| 436 | [(set GR64:$dst, (atomic_load_min_64 addr:$ptr, GR64:$val))]>; |
| 437 | def ATOMMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
| 438 | "#ATOMMAX64 PSEUDO!", |
| 439 | [(set GR64:$dst, (atomic_load_max_64 addr:$ptr, GR64:$val))]>; |
| 440 | def ATOMUMIN64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
| 441 | "#ATOMUMIN64 PSEUDO!", |
| 442 | [(set GR64:$dst, (atomic_load_umin_64 addr:$ptr, GR64:$val))]>; |
| 443 | def ATOMUMAX64: I<0, Pseudo, (outs GR64:$dst),(ins i64mem:$ptr, GR64:$val), |
| 444 | "#ATOMUMAX64 PSEUDO!", |
| 445 | [(set GR64:$dst, (atomic_load_umax_64 addr:$ptr, GR64:$val))]>; |
| 446 | } |
| 447 | |
| 448 | let Constraints = "$val1 = $dst1, $val2 = $dst2", |
| 449 | Defs = [EFLAGS, EAX, EBX, ECX, EDX], |
| 450 | Uses = [EAX, EBX, ECX, EDX], |
| 451 | mayLoad = 1, mayStore = 1, |
| 452 | usesCustomInserter = 1 in { |
| 453 | def ATOMAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2), |
| 454 | (ins i64mem:$ptr, GR32:$val1, GR32:$val2), |
| 455 | "#ATOMAND6432 PSEUDO!", []>; |
| 456 | def ATOMOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2), |
| 457 | (ins i64mem:$ptr, GR32:$val1, GR32:$val2), |
| 458 | "#ATOMOR6432 PSEUDO!", []>; |
| 459 | def ATOMXOR6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2), |
| 460 | (ins i64mem:$ptr, GR32:$val1, GR32:$val2), |
| 461 | "#ATOMXOR6432 PSEUDO!", []>; |
| 462 | def ATOMNAND6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2), |
| 463 | (ins i64mem:$ptr, GR32:$val1, GR32:$val2), |
| 464 | "#ATOMNAND6432 PSEUDO!", []>; |
| 465 | def ATOMADD6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2), |
| 466 | (ins i64mem:$ptr, GR32:$val1, GR32:$val2), |
| 467 | "#ATOMADD6432 PSEUDO!", []>; |
| 468 | def ATOMSUB6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2), |
| 469 | (ins i64mem:$ptr, GR32:$val1, GR32:$val2), |
| 470 | "#ATOMSUB6432 PSEUDO!", []>; |
| 471 | def ATOMSWAP6432 : I<0, Pseudo, (outs GR32:$dst1, GR32:$dst2), |
| 472 | (ins i64mem:$ptr, GR32:$val1, GR32:$val2), |
| 473 | "#ATOMSWAP6432 PSEUDO!", []>; |
| 474 | } |
| 475 | |
| 476 | //===----------------------------------------------------------------------===// |
| 477 | // Normal-Instructions-With-Lock-Prefix Pseudo Instructions |
| 478 | //===----------------------------------------------------------------------===// |
| 479 | |
| 480 | // FIXME: Use normal instructions and add lock prefix dynamically. |
| 481 | |
| 482 | // Memory barriers |
| 483 | |
| 484 | // TODO: Get this to fold the constant into the instruction. |
| 485 | def OR32mrLocked : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$zero), |
| 486 | "lock\n\t" |
| 487 | "or{l}\t{$zero, $dst|$dst, $zero}", |
| 488 | []>, Requires<[In32BitMode]>, LOCK; |
| 489 | |
| 490 | let hasSideEffects = 1 in |
| 491 | def Int_MemBarrier : I<0, Pseudo, (outs), (ins), |
| 492 | "#MEMBARRIER", |
| 493 | [(X86MemBarrier)]>, Requires<[HasSSE2]>; |
| 494 | |
| 495 | // TODO: Get this to fold the constant into the instruction. |
| 496 | let hasSideEffects = 1, Defs = [ESP] in |
| 497 | def Int_MemBarrierNoSSE64 : RI<0x09, MRM1r, (outs), (ins GR64:$zero), |
| 498 | "lock\n\t" |
| 499 | "or{q}\t{$zero, (%rsp)|(%rsp), $zero}", |
| 500 | [(X86MemBarrierNoSSE GR64:$zero)]>, |
| 501 | Requires<[In64BitMode]>, LOCK; |
| 502 | |
| 503 | |
| 504 | // Optimized codegen when the non-memory output is not used. |
| 505 | let Defs = [EFLAGS], mayLoad = 1, mayStore = 1 in { |
| 506 | def LOCK_ADD8mr : I<0x00, MRMDestMem, (outs), (ins i8mem:$dst, GR8:$src2), |
| 507 | "lock\n\t" |
| 508 | "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 509 | def LOCK_ADD16mr : I<0x01, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), |
| 510 | "lock\n\t" |
| 511 | "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; |
| 512 | def LOCK_ADD32mr : I<0x01, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), |
| 513 | "lock\n\t" |
| 514 | "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 515 | def LOCK_ADD64mr : RI<0x01, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
| 516 | "lock\n\t" |
| 517 | "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 518 | |
| 519 | def LOCK_ADD8mi : Ii8<0x80, MRM0m, (outs), (ins i8mem :$dst, i8imm :$src2), |
| 520 | "lock\n\t" |
| 521 | "add{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 522 | def LOCK_ADD16mi : Ii16<0x81, MRM0m, (outs), (ins i16mem:$dst, i16imm:$src2), |
| 523 | "lock\n\t" |
| 524 | "add{w}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 525 | def LOCK_ADD32mi : Ii32<0x81, MRM0m, (outs), (ins i32mem:$dst, i32imm:$src2), |
| 526 | "lock\n\t" |
| 527 | "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 528 | def LOCK_ADD64mi32 : RIi32<0x81, MRM0m, (outs), |
| 529 | (ins i64mem:$dst, i64i32imm :$src2), |
| 530 | "lock\n\t" |
| 531 | "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 532 | |
| 533 | def LOCK_ADD16mi8 : Ii8<0x83, MRM0m, (outs), (ins i16mem:$dst, i16i8imm :$src2), |
| 534 | "lock\n\t" |
| 535 | "add{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; |
| 536 | def LOCK_ADD32mi8 : Ii8<0x83, MRM0m, (outs), (ins i32mem:$dst, i32i8imm :$src2), |
| 537 | "lock\n\t" |
| 538 | "add{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 539 | def LOCK_ADD64mi8 : RIi8<0x83, MRM0m, (outs), |
| 540 | (ins i64mem:$dst, i64i8imm :$src2), |
| 541 | "lock\n\t" |
| 542 | "add{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 543 | |
| 544 | def LOCK_SUB8mr : I<0x28, MRMDestMem, (outs), (ins i8mem :$dst, GR8 :$src2), |
| 545 | "lock\n\t" |
| 546 | "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 547 | def LOCK_SUB16mr : I<0x29, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src2), |
| 548 | "lock\n\t" |
| 549 | "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; |
| 550 | def LOCK_SUB32mr : I<0x29, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src2), |
| 551 | "lock\n\t" |
| 552 | "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 553 | def LOCK_SUB64mr : RI<0x29, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src2), |
| 554 | "lock\n\t" |
| 555 | "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 556 | |
| 557 | |
| 558 | def LOCK_SUB8mi : Ii8<0x80, MRM5m, (outs), (ins i8mem :$dst, i8imm:$src2), |
| 559 | "lock\n\t" |
| 560 | "sub{b}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 561 | def LOCK_SUB16mi : Ii16<0x81, MRM5m, (outs), (ins i16mem:$dst, i16imm:$src2), |
| 562 | "lock\n\t" |
| 563 | "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; |
| 564 | def LOCK_SUB32mi : Ii32<0x81, MRM5m, (outs), (ins i32mem:$dst, i32imm:$src2), |
| 565 | "lock\n\t" |
| 566 | "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 567 | def LOCK_SUB64mi32 : RIi32<0x81, MRM5m, (outs), |
| 568 | (ins i64mem:$dst, i64i32imm:$src2), |
| 569 | "lock\n\t" |
| 570 | "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 571 | |
| 572 | |
| 573 | def LOCK_SUB16mi8 : Ii8<0x83, MRM5m, (outs), (ins i16mem:$dst, i16i8imm :$src2), |
| 574 | "lock\n\t" |
| 575 | "sub{w}\t{$src2, $dst|$dst, $src2}", []>, OpSize, LOCK; |
| 576 | def LOCK_SUB32mi8 : Ii8<0x83, MRM5m, (outs), (ins i32mem:$dst, i32i8imm :$src2), |
| 577 | "lock\n\t" |
| 578 | "sub{l}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 579 | def LOCK_SUB64mi8 : RIi8<0x83, MRM5m, (outs), |
| 580 | (ins i64mem:$dst, i64i8imm :$src2), |
| 581 | "lock\n\t" |
| 582 | "sub{q}\t{$src2, $dst|$dst, $src2}", []>, LOCK; |
| 583 | |
| 584 | def LOCK_INC8m : I<0xFE, MRM0m, (outs), (ins i8mem :$dst), |
| 585 | "lock\n\t" |
| 586 | "inc{b}\t$dst", []>, LOCK; |
| 587 | def LOCK_INC16m : I<0xFF, MRM0m, (outs), (ins i16mem:$dst), |
| 588 | "lock\n\t" |
| 589 | "inc{w}\t$dst", []>, OpSize, LOCK; |
| 590 | def LOCK_INC32m : I<0xFF, MRM0m, (outs), (ins i32mem:$dst), |
| 591 | "lock\n\t" |
| 592 | "inc{l}\t$dst", []>, LOCK; |
| 593 | def LOCK_INC64m : RI<0xFF, MRM0m, (outs), (ins i64mem:$dst), |
| 594 | "lock\n\t" |
| 595 | "inc{q}\t$dst", []>, LOCK; |
| 596 | |
| 597 | def LOCK_DEC8m : I<0xFE, MRM1m, (outs), (ins i8mem :$dst), |
| 598 | "lock\n\t" |
| 599 | "dec{b}\t$dst", []>, LOCK; |
| 600 | def LOCK_DEC16m : I<0xFF, MRM1m, (outs), (ins i16mem:$dst), |
| 601 | "lock\n\t" |
| 602 | "dec{w}\t$dst", []>, OpSize, LOCK; |
| 603 | def LOCK_DEC32m : I<0xFF, MRM1m, (outs), (ins i32mem:$dst), |
| 604 | "lock\n\t" |
| 605 | "dec{l}\t$dst", []>, LOCK; |
| 606 | def LOCK_DEC64m : RI<0xFF, MRM1m, (outs), (ins i64mem:$dst), |
| 607 | "lock\n\t" |
| 608 | "dec{q}\t$dst", []>, LOCK; |
| 609 | } |
| 610 | |
| 611 | // Atomic compare and swap. |
| 612 | let Defs = [EAX, EDX, EFLAGS], Uses = [EAX, EBX, ECX, EDX] in { |
| 613 | def LCMPXCHG8B : I<0xC7, MRM1m, (outs), (ins i64mem:$ptr), |
| 614 | "lock\n\t" |
| 615 | "cmpxchg8b\t$ptr", |
| 616 | [(X86cas8 addr:$ptr)]>, TB, LOCK; |
| 617 | } |
| 618 | let Defs = [AL, EFLAGS], Uses = [AL] in { |
| 619 | def LCMPXCHG8 : I<0xB0, MRMDestMem, (outs), (ins i8mem:$ptr, GR8:$swap), |
| 620 | "lock\n\t" |
| 621 | "cmpxchg{b}\t{$swap, $ptr|$ptr, $swap}", |
| 622 | [(X86cas addr:$ptr, GR8:$swap, 1)]>, TB, LOCK; |
| 623 | } |
| 624 | |
| 625 | let Defs = [AX, EFLAGS], Uses = [AX] in { |
| 626 | def LCMPXCHG16 : I<0xB1, MRMDestMem, (outs), (ins i16mem:$ptr, GR16:$swap), |
| 627 | "lock\n\t" |
| 628 | "cmpxchg{w}\t{$swap, $ptr|$ptr, $swap}", |
| 629 | [(X86cas addr:$ptr, GR16:$swap, 2)]>, TB, OpSize, LOCK; |
| 630 | } |
| 631 | |
| 632 | let Defs = [EAX, EFLAGS], Uses = [EAX] in { |
| 633 | def LCMPXCHG32 : I<0xB1, MRMDestMem, (outs), (ins i32mem:$ptr, GR32:$swap), |
| 634 | "lock\n\t" |
| 635 | "cmpxchg{l}\t{$swap, $ptr|$ptr, $swap}", |
| 636 | [(X86cas addr:$ptr, GR32:$swap, 4)]>, TB, LOCK; |
| 637 | } |
| 638 | |
| 639 | let Defs = [RAX, EFLAGS], Uses = [RAX] in { |
| 640 | def LCMPXCHG64 : RI<0xB1, MRMDestMem, (outs), (ins i64mem:$ptr, GR64:$swap), |
| 641 | "lock\n\t" |
| 642 | "cmpxchgq\t$swap,$ptr", |
| 643 | [(X86cas addr:$ptr, GR64:$swap, 8)]>, TB, LOCK; |
| 644 | } |
| 645 | |
| 646 | // Atomic exchange and add |
| 647 | let Constraints = "$val = $dst", Defs = [EFLAGS] in { |
| 648 | def LXADD8 : I<0xC0, MRMSrcMem, (outs GR8:$dst), (ins GR8:$val, i8mem:$ptr), |
| 649 | "lock\n\t" |
| 650 | "xadd{b}\t{$val, $ptr|$ptr, $val}", |
| 651 | [(set GR8:$dst, (atomic_load_add_8 addr:$ptr, GR8:$val))]>, |
| 652 | TB, LOCK; |
| 653 | def LXADD16 : I<0xC1, MRMSrcMem, (outs GR16:$dst), (ins GR16:$val, i16mem:$ptr), |
| 654 | "lock\n\t" |
| 655 | "xadd{w}\t{$val, $ptr|$ptr, $val}", |
| 656 | [(set GR16:$dst, (atomic_load_add_16 addr:$ptr, GR16:$val))]>, |
| 657 | TB, OpSize, LOCK; |
| 658 | def LXADD32 : I<0xC1, MRMSrcMem, (outs GR32:$dst), (ins GR32:$val, i32mem:$ptr), |
| 659 | "lock\n\t" |
| 660 | "xadd{l}\t{$val, $ptr|$ptr, $val}", |
| 661 | [(set GR32:$dst, (atomic_load_add_32 addr:$ptr, GR32:$val))]>, |
| 662 | TB, LOCK; |
| 663 | def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins GR64:$val,i64mem:$ptr), |
| 664 | "lock\n\t" |
| 665 | "xadd\t$val, $ptr", |
| 666 | [(set GR64:$dst, (atomic_load_add_64 addr:$ptr, GR64:$val))]>, |
| 667 | TB, LOCK; |
| 668 | } |
| 669 | |
Chris Lattner | 5673e1d | 2010-10-05 06:41:40 +0000 | [diff] [blame] | 670 | //===----------------------------------------------------------------------===// |
| 671 | // Conditional Move Pseudo Instructions. |
| 672 | //===----------------------------------------------------------------------===// |
| 673 | |
| 674 | |
| 675 | // CMOV* - Used to implement the SSE SELECT DAG operation. Expanded after |
| 676 | // instruction selection into a branch sequence. |
| 677 | let Uses = [EFLAGS], usesCustomInserter = 1 in { |
| 678 | def CMOV_FR32 : I<0, Pseudo, |
| 679 | (outs FR32:$dst), (ins FR32:$t, FR32:$f, i8imm:$cond), |
| 680 | "#CMOV_FR32 PSEUDO!", |
| 681 | [(set FR32:$dst, (X86cmov FR32:$t, FR32:$f, imm:$cond, |
| 682 | EFLAGS))]>; |
| 683 | def CMOV_FR64 : I<0, Pseudo, |
| 684 | (outs FR64:$dst), (ins FR64:$t, FR64:$f, i8imm:$cond), |
| 685 | "#CMOV_FR64 PSEUDO!", |
| 686 | [(set FR64:$dst, (X86cmov FR64:$t, FR64:$f, imm:$cond, |
| 687 | EFLAGS))]>; |
| 688 | def CMOV_V4F32 : I<0, Pseudo, |
| 689 | (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond), |
| 690 | "#CMOV_V4F32 PSEUDO!", |
| 691 | [(set VR128:$dst, |
| 692 | (v4f32 (X86cmov VR128:$t, VR128:$f, imm:$cond, |
| 693 | EFLAGS)))]>; |
| 694 | def CMOV_V2F64 : I<0, Pseudo, |
| 695 | (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond), |
| 696 | "#CMOV_V2F64 PSEUDO!", |
| 697 | [(set VR128:$dst, |
| 698 | (v2f64 (X86cmov VR128:$t, VR128:$f, imm:$cond, |
| 699 | EFLAGS)))]>; |
| 700 | def CMOV_V2I64 : I<0, Pseudo, |
| 701 | (outs VR128:$dst), (ins VR128:$t, VR128:$f, i8imm:$cond), |
| 702 | "#CMOV_V2I64 PSEUDO!", |
| 703 | [(set VR128:$dst, |
| 704 | (v2i64 (X86cmov VR128:$t, VR128:$f, imm:$cond, |
| 705 | EFLAGS)))]>; |
| 706 | } |
| 707 | |
Chris Lattner | 010496c | 2010-10-05 06:22:35 +0000 | [diff] [blame] | 708 | |
| 709 | //===----------------------------------------------------------------------===// |
| 710 | // DAG Pattern Matching Rules |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 711 | //===----------------------------------------------------------------------===// |
| 712 | |
| 713 | // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable |
| 714 | def : Pat<(i32 (X86Wrapper tconstpool :$dst)), (MOV32ri tconstpool :$dst)>; |
| 715 | def : Pat<(i32 (X86Wrapper tjumptable :$dst)), (MOV32ri tjumptable :$dst)>; |
| 716 | def : Pat<(i32 (X86Wrapper tglobaltlsaddr:$dst)),(MOV32ri tglobaltlsaddr:$dst)>; |
| 717 | def : Pat<(i32 (X86Wrapper tglobaladdr :$dst)), (MOV32ri tglobaladdr :$dst)>; |
| 718 | def : Pat<(i32 (X86Wrapper texternalsym:$dst)), (MOV32ri texternalsym:$dst)>; |
| 719 | def : Pat<(i32 (X86Wrapper tblockaddress:$dst)), (MOV32ri tblockaddress:$dst)>; |
| 720 | |
| 721 | def : Pat<(add GR32:$src1, (X86Wrapper tconstpool:$src2)), |
| 722 | (ADD32ri GR32:$src1, tconstpool:$src2)>; |
| 723 | def : Pat<(add GR32:$src1, (X86Wrapper tjumptable:$src2)), |
| 724 | (ADD32ri GR32:$src1, tjumptable:$src2)>; |
| 725 | def : Pat<(add GR32:$src1, (X86Wrapper tglobaladdr :$src2)), |
| 726 | (ADD32ri GR32:$src1, tglobaladdr:$src2)>; |
| 727 | def : Pat<(add GR32:$src1, (X86Wrapper texternalsym:$src2)), |
| 728 | (ADD32ri GR32:$src1, texternalsym:$src2)>; |
| 729 | def : Pat<(add GR32:$src1, (X86Wrapper tblockaddress:$src2)), |
| 730 | (ADD32ri GR32:$src1, tblockaddress:$src2)>; |
| 731 | |
| 732 | def : Pat<(store (i32 (X86Wrapper tglobaladdr:$src)), addr:$dst), |
| 733 | (MOV32mi addr:$dst, tglobaladdr:$src)>; |
| 734 | def : Pat<(store (i32 (X86Wrapper texternalsym:$src)), addr:$dst), |
| 735 | (MOV32mi addr:$dst, texternalsym:$src)>; |
| 736 | def : Pat<(store (i32 (X86Wrapper tblockaddress:$src)), addr:$dst), |
| 737 | (MOV32mi addr:$dst, tblockaddress:$src)>; |
| 738 | |
| 739 | |
| 740 | |
| 741 | // ConstantPool GlobalAddress, ExternalSymbol, and JumpTable when not in small |
| 742 | // code model mode, should use 'movabs'. FIXME: This is really a hack, the |
| 743 | // 'movabs' predicate should handle this sort of thing. |
| 744 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
| 745 | (MOV64ri tconstpool :$dst)>, Requires<[FarData]>; |
| 746 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
| 747 | (MOV64ri tjumptable :$dst)>, Requires<[FarData]>; |
| 748 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
| 749 | (MOV64ri tglobaladdr :$dst)>, Requires<[FarData]>; |
| 750 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
| 751 | (MOV64ri texternalsym:$dst)>, Requires<[FarData]>; |
| 752 | def : Pat<(i64 (X86Wrapper tblockaddress:$dst)), |
| 753 | (MOV64ri tblockaddress:$dst)>, Requires<[FarData]>; |
| 754 | |
| 755 | // In static codegen with small code model, we can get the address of a label |
| 756 | // into a register with 'movl'. FIXME: This is a hack, the 'imm' predicate of |
| 757 | // the MOV64ri64i32 should accept these. |
| 758 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
| 759 | (MOV64ri64i32 tconstpool :$dst)>, Requires<[SmallCode]>; |
| 760 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
| 761 | (MOV64ri64i32 tjumptable :$dst)>, Requires<[SmallCode]>; |
| 762 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
| 763 | (MOV64ri64i32 tglobaladdr :$dst)>, Requires<[SmallCode]>; |
| 764 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
| 765 | (MOV64ri64i32 texternalsym:$dst)>, Requires<[SmallCode]>; |
| 766 | def : Pat<(i64 (X86Wrapper tblockaddress:$dst)), |
| 767 | (MOV64ri64i32 tblockaddress:$dst)>, Requires<[SmallCode]>; |
| 768 | |
| 769 | // In kernel code model, we can get the address of a label |
| 770 | // into a register with 'movq'. FIXME: This is a hack, the 'imm' predicate of |
| 771 | // the MOV64ri32 should accept these. |
| 772 | def : Pat<(i64 (X86Wrapper tconstpool :$dst)), |
| 773 | (MOV64ri32 tconstpool :$dst)>, Requires<[KernelCode]>; |
| 774 | def : Pat<(i64 (X86Wrapper tjumptable :$dst)), |
| 775 | (MOV64ri32 tjumptable :$dst)>, Requires<[KernelCode]>; |
| 776 | def : Pat<(i64 (X86Wrapper tglobaladdr :$dst)), |
| 777 | (MOV64ri32 tglobaladdr :$dst)>, Requires<[KernelCode]>; |
| 778 | def : Pat<(i64 (X86Wrapper texternalsym:$dst)), |
| 779 | (MOV64ri32 texternalsym:$dst)>, Requires<[KernelCode]>; |
| 780 | def : Pat<(i64 (X86Wrapper tblockaddress:$dst)), |
| 781 | (MOV64ri32 tblockaddress:$dst)>, Requires<[KernelCode]>; |
| 782 | |
| 783 | // If we have small model and -static mode, it is safe to store global addresses |
| 784 | // directly as immediates. FIXME: This is really a hack, the 'imm' predicate |
| 785 | // for MOV64mi32 should handle this sort of thing. |
| 786 | def : Pat<(store (i64 (X86Wrapper tconstpool:$src)), addr:$dst), |
| 787 | (MOV64mi32 addr:$dst, tconstpool:$src)>, |
| 788 | Requires<[NearData, IsStatic]>; |
| 789 | def : Pat<(store (i64 (X86Wrapper tjumptable:$src)), addr:$dst), |
| 790 | (MOV64mi32 addr:$dst, tjumptable:$src)>, |
| 791 | Requires<[NearData, IsStatic]>; |
| 792 | def : Pat<(store (i64 (X86Wrapper tglobaladdr:$src)), addr:$dst), |
| 793 | (MOV64mi32 addr:$dst, tglobaladdr:$src)>, |
| 794 | Requires<[NearData, IsStatic]>; |
| 795 | def : Pat<(store (i64 (X86Wrapper texternalsym:$src)), addr:$dst), |
| 796 | (MOV64mi32 addr:$dst, texternalsym:$src)>, |
| 797 | Requires<[NearData, IsStatic]>; |
| 798 | def : Pat<(store (i64 (X86Wrapper tblockaddress:$src)), addr:$dst), |
| 799 | (MOV64mi32 addr:$dst, tblockaddress:$src)>, |
| 800 | Requires<[NearData, IsStatic]>; |
| 801 | |
| 802 | |
| 803 | |
| 804 | // Calls |
| 805 | |
| 806 | // tls has some funny stuff here... |
| 807 | // This corresponds to movabs $foo@tpoff, %rax |
| 808 | def : Pat<(i64 (X86Wrapper tglobaltlsaddr :$dst)), |
| 809 | (MOV64ri tglobaltlsaddr :$dst)>; |
| 810 | // This corresponds to add $foo@tpoff, %rax |
| 811 | def : Pat<(add GR64:$src1, (X86Wrapper tglobaltlsaddr :$dst)), |
| 812 | (ADD64ri32 GR64:$src1, tglobaltlsaddr :$dst)>; |
| 813 | // This corresponds to mov foo@tpoff(%rbx), %eax |
| 814 | def : Pat<(load (i64 (X86Wrapper tglobaltlsaddr :$dst))), |
| 815 | (MOV64rm tglobaltlsaddr :$dst)>; |
| 816 | |
| 817 | |
| 818 | // Direct PC relative function call for small code model. 32-bit displacement |
| 819 | // sign extended to 64-bit. |
| 820 | def : Pat<(X86call (i64 tglobaladdr:$dst)), |
| 821 | (CALL64pcrel32 tglobaladdr:$dst)>, Requires<[NotWin64]>; |
| 822 | def : Pat<(X86call (i64 texternalsym:$dst)), |
| 823 | (CALL64pcrel32 texternalsym:$dst)>, Requires<[NotWin64]>; |
| 824 | |
| 825 | def : Pat<(X86call (i64 tglobaladdr:$dst)), |
| 826 | (WINCALL64pcrel32 tglobaladdr:$dst)>, Requires<[IsWin64]>; |
| 827 | def : Pat<(X86call (i64 texternalsym:$dst)), |
| 828 | (WINCALL64pcrel32 texternalsym:$dst)>, Requires<[IsWin64]>; |
| 829 | |
| 830 | // tailcall stuff |
| 831 | def : Pat<(X86tcret GR32_TC:$dst, imm:$off), |
| 832 | (TCRETURNri GR32_TC:$dst, imm:$off)>, |
| 833 | Requires<[In32BitMode]>; |
| 834 | |
| 835 | // FIXME: This is disabled for 32-bit PIC mode because the global base |
| 836 | // register which is part of the address mode may be assigned a |
| 837 | // callee-saved register. |
| 838 | def : Pat<(X86tcret (load addr:$dst), imm:$off), |
| 839 | (TCRETURNmi addr:$dst, imm:$off)>, |
| 840 | Requires<[In32BitMode, IsNotPIC]>; |
| 841 | |
| 842 | def : Pat<(X86tcret (i32 tglobaladdr:$dst), imm:$off), |
| 843 | (TCRETURNdi texternalsym:$dst, imm:$off)>, |
| 844 | Requires<[In32BitMode]>; |
| 845 | |
| 846 | def : Pat<(X86tcret (i32 texternalsym:$dst), imm:$off), |
| 847 | (TCRETURNdi texternalsym:$dst, imm:$off)>, |
| 848 | Requires<[In32BitMode]>; |
| 849 | |
| 850 | def : Pat<(X86tcret GR64_TC:$dst, imm:$off), |
| 851 | (TCRETURNri64 GR64_TC:$dst, imm:$off)>, |
| 852 | Requires<[In64BitMode]>; |
| 853 | |
| 854 | def : Pat<(X86tcret (load addr:$dst), imm:$off), |
| 855 | (TCRETURNmi64 addr:$dst, imm:$off)>, |
| 856 | Requires<[In64BitMode]>; |
| 857 | |
| 858 | def : Pat<(X86tcret (i64 tglobaladdr:$dst), imm:$off), |
| 859 | (TCRETURNdi64 tglobaladdr:$dst, imm:$off)>, |
| 860 | Requires<[In64BitMode]>; |
| 861 | |
| 862 | def : Pat<(X86tcret (i64 texternalsym:$dst), imm:$off), |
| 863 | (TCRETURNdi64 texternalsym:$dst, imm:$off)>, |
| 864 | Requires<[In64BitMode]>; |
| 865 | |
| 866 | // Normal calls, with various flavors of addresses. |
| 867 | def : Pat<(X86call (i32 tglobaladdr:$dst)), |
| 868 | (CALLpcrel32 tglobaladdr:$dst)>; |
| 869 | def : Pat<(X86call (i32 texternalsym:$dst)), |
| 870 | (CALLpcrel32 texternalsym:$dst)>; |
| 871 | def : Pat<(X86call (i32 imm:$dst)), |
| 872 | (CALLpcrel32 imm:$dst)>, Requires<[CallImmAddr]>; |
| 873 | |
| 874 | // X86 specific add which produces a flag. |
| 875 | def : Pat<(addc GR32:$src1, GR32:$src2), |
| 876 | (ADD32rr GR32:$src1, GR32:$src2)>; |
| 877 | def : Pat<(addc GR32:$src1, (load addr:$src2)), |
| 878 | (ADD32rm GR32:$src1, addr:$src2)>; |
| 879 | def : Pat<(addc GR32:$src1, imm:$src2), |
| 880 | (ADD32ri GR32:$src1, imm:$src2)>; |
| 881 | def : Pat<(addc GR32:$src1, i32immSExt8:$src2), |
| 882 | (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>; |
| 883 | |
| 884 | def : Pat<(addc GR64:$src1, GR64:$src2), |
| 885 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 886 | def : Pat<(addc GR64:$src1, (load addr:$src2)), |
| 887 | (ADD64rm GR64:$src1, addr:$src2)>; |
| 888 | def : Pat<(addc GR64:$src1, i64immSExt8:$src2), |
| 889 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 890 | def : Pat<(addc GR64:$src1, i64immSExt32:$src2), |
| 891 | (ADD64ri32 GR64:$src1, imm:$src2)>; |
| 892 | |
| 893 | def : Pat<(subc GR32:$src1, GR32:$src2), |
| 894 | (SUB32rr GR32:$src1, GR32:$src2)>; |
| 895 | def : Pat<(subc GR32:$src1, (load addr:$src2)), |
| 896 | (SUB32rm GR32:$src1, addr:$src2)>; |
| 897 | def : Pat<(subc GR32:$src1, imm:$src2), |
| 898 | (SUB32ri GR32:$src1, imm:$src2)>; |
| 899 | def : Pat<(subc GR32:$src1, i32immSExt8:$src2), |
| 900 | (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>; |
| 901 | |
| 902 | def : Pat<(subc GR64:$src1, GR64:$src2), |
| 903 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 904 | def : Pat<(subc GR64:$src1, (load addr:$src2)), |
| 905 | (SUB64rm GR64:$src1, addr:$src2)>; |
| 906 | def : Pat<(subc GR64:$src1, i64immSExt8:$src2), |
| 907 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 908 | def : Pat<(subc GR64:$src1, imm:$src2), |
| 909 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 910 | |
| 911 | // Comparisons. |
| 912 | |
| 913 | // TEST R,R is smaller than CMP R,0 |
| 914 | def : Pat<(X86cmp GR8:$src1, 0), |
| 915 | (TEST8rr GR8:$src1, GR8:$src1)>; |
| 916 | def : Pat<(X86cmp GR16:$src1, 0), |
| 917 | (TEST16rr GR16:$src1, GR16:$src1)>; |
| 918 | def : Pat<(X86cmp GR32:$src1, 0), |
| 919 | (TEST32rr GR32:$src1, GR32:$src1)>; |
| 920 | def : Pat<(X86cmp GR64:$src1, 0), |
| 921 | (TEST64rr GR64:$src1, GR64:$src1)>; |
| 922 | |
| 923 | // Conditional moves with folded loads with operands swapped and conditions |
| 924 | // inverted. |
Chris Lattner | 286997c | 2010-10-05 22:42:54 +0000 | [diff] [blame] | 925 | multiclass CMOVmr<PatLeaf InvertedCond, Instruction Inst16, Instruction Inst32, |
| 926 | Instruction Inst64> { |
| 927 | def : Pat<(X86cmov (loadi16 addr:$src1), GR16:$src2, InvertedCond, EFLAGS), |
| 928 | (Inst16 GR16:$src2, addr:$src1)>; |
| 929 | def : Pat<(X86cmov (loadi32 addr:$src1), GR32:$src2, InvertedCond, EFLAGS), |
| 930 | (Inst32 GR32:$src2, addr:$src1)>; |
| 931 | def : Pat<(X86cmov (loadi64 addr:$src1), GR64:$src2, InvertedCond, EFLAGS), |
| 932 | (Inst64 GR64:$src2, addr:$src1)>; |
| 933 | } |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 934 | |
Chris Lattner | df72eae | 2010-10-05 22:51:56 +0000 | [diff] [blame] | 935 | defm : CMOVmr<X86_COND_B , CMOVAE16rm, CMOVAE32rm, CMOVAE64rm>; |
| 936 | defm : CMOVmr<X86_COND_AE, CMOVB16rm , CMOVB32rm , CMOVB64rm>; |
| 937 | defm : CMOVmr<X86_COND_E , CMOVNE16rm, CMOVNE32rm, CMOVNE64rm>; |
| 938 | defm : CMOVmr<X86_COND_NE, CMOVE16rm , CMOVE32rm , CMOVE64rm>; |
| 939 | defm : CMOVmr<X86_COND_BE, CMOVA16rm , CMOVA32rm , CMOVA64rm>; |
Chris Lattner | 25cbf50 | 2010-10-05 23:00:14 +0000 | [diff] [blame] | 940 | defm : CMOVmr<X86_COND_A , CMOVBE16rm, CMOVBE32rm, CMOVBE64rm>; |
Chris Lattner | df72eae | 2010-10-05 22:51:56 +0000 | [diff] [blame] | 941 | defm : CMOVmr<X86_COND_L , CMOVGE16rm, CMOVGE32rm, CMOVGE64rm>; |
| 942 | defm : CMOVmr<X86_COND_GE, CMOVL16rm , CMOVL32rm , CMOVL64rm>; |
| 943 | defm : CMOVmr<X86_COND_LE, CMOVG16rm , CMOVG32rm , CMOVG64rm>; |
| 944 | defm : CMOVmr<X86_COND_G , CMOVLE16rm, CMOVLE32rm, CMOVLE64rm>; |
| 945 | defm : CMOVmr<X86_COND_P , CMOVNP16rm, CMOVNP32rm, CMOVNP64rm>; |
| 946 | defm : CMOVmr<X86_COND_NP, CMOVP16rm , CMOVP32rm , CMOVP64rm>; |
| 947 | defm : CMOVmr<X86_COND_S , CMOVNS16rm, CMOVNS32rm, CMOVNS64rm>; |
| 948 | defm : CMOVmr<X86_COND_NS, CMOVS16rm , CMOVS32rm , CMOVS64rm>; |
| 949 | defm : CMOVmr<X86_COND_O , CMOVNO16rm, CMOVNO32rm, CMOVNO64rm>; |
| 950 | defm : CMOVmr<X86_COND_NO, CMOVO16rm , CMOVO32rm , CMOVO64rm>; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 951 | |
| 952 | // zextload bool -> zextload byte |
| 953 | def : Pat<(zextloadi8i1 addr:$src), (MOV8rm addr:$src)>; |
| 954 | def : Pat<(zextloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>; |
| 955 | def : Pat<(zextloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>; |
| 956 | def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 957 | |
| 958 | // extload bool -> extload byte |
| 959 | // When extloading from 16-bit and smaller memory locations into 64-bit |
| 960 | // registers, use zero-extending loads so that the entire 64-bit register is |
| 961 | // defined, avoiding partial-register updates. |
| 962 | |
| 963 | def : Pat<(extloadi8i1 addr:$src), (MOV8rm addr:$src)>; |
| 964 | def : Pat<(extloadi16i1 addr:$src), (MOVZX16rm8 addr:$src)>; |
| 965 | def : Pat<(extloadi32i1 addr:$src), (MOVZX32rm8 addr:$src)>; |
| 966 | def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>; |
| 967 | def : Pat<(extloadi32i8 addr:$src), (MOVZX32rm8 addr:$src)>; |
| 968 | def : Pat<(extloadi32i16 addr:$src), (MOVZX32rm16 addr:$src)>; |
| 969 | |
| 970 | def : Pat<(extloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 971 | def : Pat<(extloadi64i8 addr:$src), (MOVZX64rm8 addr:$src)>; |
| 972 | def : Pat<(extloadi64i16 addr:$src), (MOVZX64rm16 addr:$src)>; |
| 973 | // For other extloads, use subregs, since the high contents of the register are |
| 974 | // defined after an extload. |
| 975 | def : Pat<(extloadi64i32 addr:$src), |
| 976 | (SUBREG_TO_REG (i64 0), (MOV32rm addr:$src), |
| 977 | sub_32bit)>; |
| 978 | |
| 979 | // anyext. Define these to do an explicit zero-extend to |
| 980 | // avoid partial-register updates. |
| 981 | def : Pat<(i16 (anyext GR8 :$src)), (MOVZX16rr8 GR8 :$src)>; |
| 982 | def : Pat<(i32 (anyext GR8 :$src)), (MOVZX32rr8 GR8 :$src)>; |
| 983 | |
| 984 | // Except for i16 -> i32 since isel expect i16 ops to be promoted to i32. |
| 985 | def : Pat<(i32 (anyext GR16:$src)), |
| 986 | (INSERT_SUBREG (i32 (IMPLICIT_DEF)), GR16:$src, sub_16bit)>; |
| 987 | |
| 988 | def : Pat<(i64 (anyext GR8 :$src)), (MOVZX64rr8 GR8 :$src)>; |
| 989 | def : Pat<(i64 (anyext GR16:$src)), (MOVZX64rr16 GR16 :$src)>; |
| 990 | def : Pat<(i64 (anyext GR32:$src)), |
| 991 | (SUBREG_TO_REG (i64 0), GR32:$src, sub_32bit)>; |
| 992 | |
Chris Lattner | d8cc272 | 2010-10-05 06:47:35 +0000 | [diff] [blame] | 993 | |
| 994 | // Any instruction that defines a 32-bit result leaves the high half of the |
| 995 | // register. Truncate can be lowered to EXTRACT_SUBREG. CopyFromReg may |
| 996 | // be copying from a truncate. And x86's cmov doesn't do anything if the |
| 997 | // condition is false. But any other 32-bit operation will zero-extend |
| 998 | // up to 64 bits. |
| 999 | def def32 : PatLeaf<(i32 GR32:$src), [{ |
| 1000 | return N->getOpcode() != ISD::TRUNCATE && |
| 1001 | N->getOpcode() != TargetOpcode::EXTRACT_SUBREG && |
| 1002 | N->getOpcode() != ISD::CopyFromReg && |
| 1003 | N->getOpcode() != X86ISD::CMOV; |
| 1004 | }]>; |
| 1005 | |
| 1006 | // In the case of a 32-bit def that is known to implicitly zero-extend, |
| 1007 | // we can use a SUBREG_TO_REG. |
| 1008 | def : Pat<(i64 (zext def32:$src)), |
| 1009 | (SUBREG_TO_REG (i64 0), GR32:$src, sub_32bit)>; |
| 1010 | |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 1011 | //===----------------------------------------------------------------------===// |
Chris Lattner | 99ae665 | 2010-10-08 03:54:52 +0000 | [diff] [blame] | 1012 | // Pattern match OR as ADD |
| 1013 | //===----------------------------------------------------------------------===// |
| 1014 | |
| 1015 | // If safe, we prefer to pattern match OR as ADD at isel time. ADD can be |
| 1016 | // 3-addressified into an LEA instruction to avoid copies. However, we also |
| 1017 | // want to finally emit these instructions as an or at the end of the code |
| 1018 | // generator to make the generated code easier to read. To do this, we select |
| 1019 | // into "disjoint bits" pseudo ops. |
| 1020 | |
| 1021 | // Treat an 'or' node is as an 'add' if the or'ed bits are known to be zero. |
| 1022 | def or_is_add : PatFrag<(ops node:$lhs, node:$rhs), (or node:$lhs, node:$rhs),[{ |
| 1023 | if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand(1))) |
| 1024 | return CurDAG->MaskedValueIsZero(N->getOperand(0), CN->getAPIntValue()); |
| 1025 | |
| 1026 | unsigned BitWidth = N->getValueType(0).getScalarType().getSizeInBits(); |
| 1027 | APInt Mask = APInt::getAllOnesValue(BitWidth); |
| 1028 | APInt KnownZero0, KnownOne0; |
| 1029 | CurDAG->ComputeMaskedBits(N->getOperand(0), Mask, KnownZero0, KnownOne0, 0); |
| 1030 | APInt KnownZero1, KnownOne1; |
| 1031 | CurDAG->ComputeMaskedBits(N->getOperand(1), Mask, KnownZero1, KnownOne1, 0); |
| 1032 | return (~KnownZero0 & ~KnownZero1) == 0; |
| 1033 | }]>; |
| 1034 | |
| 1035 | |
| 1036 | // (or x1, x2) -> (add x1, x2) if two operands are known not to share bits. |
| 1037 | let AddedComplexity = 5 in { // Try this before the selecting to OR |
| 1038 | |
| 1039 | let isCommutable = 1, isConvertibleToThreeAddress = 1, |
| 1040 | Constraints = "$src1 = $dst", Defs = [EFLAGS] in { |
| 1041 | def ADD16rr_DB : I<0, Pseudo, (outs GR16:$dst), (ins GR16:$src1, GR16:$src2), |
| 1042 | "", // orw/addw REG, REG |
| 1043 | [(set GR16:$dst, (or_is_add GR16:$src1, GR16:$src2))]>; |
| 1044 | def ADD32rr_DB : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src1, GR32:$src2), |
| 1045 | "", // orl/addl REG, REG |
| 1046 | [(set GR32:$dst, (or_is_add GR32:$src1, GR32:$src2))]>; |
| 1047 | def ADD64rr_DB : I<0, Pseudo, (outs GR64:$dst), (ins GR64:$src1, GR64:$src2), |
| 1048 | "", // orq/addq REG, REG |
| 1049 | [(set GR64:$dst, (or_is_add GR64:$src1, GR64:$src2))]>; |
Chris Lattner | 15df55d | 2010-10-08 03:57:25 +0000 | [diff] [blame] | 1050 | |
| 1051 | |
| 1052 | def ADD16ri_DB : I<0, Pseudo, (outs GR16:$dst), (ins GR16:$src1, i16imm:$src2), |
| 1053 | "", // orw/addw REG, imm |
| 1054 | [(set GR16:$dst, (or_is_add GR16:$src1, imm:$src2))]>; |
| 1055 | def ADD32ri_DB : I<0, Pseudo, (outs GR32:$dst), (ins GR32:$src1, i32imm:$src2), |
| 1056 | "", // orl/addl REG, imm |
| 1057 | [(set GR32:$dst, (or_is_add GR32:$src1, imm:$src2))]>; |
| 1058 | def ADD64ri32_DB : I<0, Pseudo, |
| 1059 | (outs GR64:$dst), (ins GR64:$src1, i64i32imm:$src2), |
| 1060 | "", // orq/addq REG, imm |
| 1061 | [(set GR64:$dst, (or_is_add GR64:$src1, |
| 1062 | i64immSExt32:$src2))]>; |
| 1063 | |
| 1064 | def ADD16ri8_DB : I<0, Pseudo, |
| 1065 | (outs GR16:$dst), (ins GR16:$src1, i16i8imm:$src2), |
| 1066 | "", // orw/addw REG, imm8 |
| 1067 | [(set GR16:$dst,(or_is_add GR16:$src1,i16immSExt8:$src2))]>; |
| 1068 | def ADD32ri8_DB : I<0, Pseudo, |
| 1069 | (outs GR32:$dst), (ins GR32:$src1, i32i8imm:$src2), |
| 1070 | "", // orl/addl REG, imm8 |
| 1071 | [(set GR32:$dst,(or_is_add GR32:$src1,i32immSExt8:$src2))]>; |
| 1072 | def ADD64ri8_DB : I<0, Pseudo, |
| 1073 | (outs GR64:$dst), (ins GR64:$src1, i64i8imm:$src2), |
| 1074 | "", // orq/addq REG, imm8 |
| 1075 | [(set GR64:$dst, (or_is_add GR64:$src1, |
| 1076 | i64immSExt8:$src2))]>; |
Chris Lattner | 99ae665 | 2010-10-08 03:54:52 +0000 | [diff] [blame] | 1077 | } |
Chris Lattner | 99ae665 | 2010-10-08 03:54:52 +0000 | [diff] [blame] | 1078 | } // AddedComplexity |
| 1079 | |
| 1080 | |
| 1081 | //===----------------------------------------------------------------------===// |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 1082 | // Some peepholes |
| 1083 | //===----------------------------------------------------------------------===// |
| 1084 | |
| 1085 | // Odd encoding trick: -128 fits into an 8-bit immediate field while |
| 1086 | // +128 doesn't, so in this special case use a sub instead of an add. |
| 1087 | def : Pat<(add GR16:$src1, 128), |
| 1088 | (SUB16ri8 GR16:$src1, -128)>; |
| 1089 | def : Pat<(store (add (loadi16 addr:$dst), 128), addr:$dst), |
| 1090 | (SUB16mi8 addr:$dst, -128)>; |
| 1091 | |
| 1092 | def : Pat<(add GR32:$src1, 128), |
| 1093 | (SUB32ri8 GR32:$src1, -128)>; |
| 1094 | def : Pat<(store (add (loadi32 addr:$dst), 128), addr:$dst), |
| 1095 | (SUB32mi8 addr:$dst, -128)>; |
| 1096 | |
| 1097 | def : Pat<(add GR64:$src1, 128), |
| 1098 | (SUB64ri8 GR64:$src1, -128)>; |
| 1099 | def : Pat<(store (add (loadi64 addr:$dst), 128), addr:$dst), |
| 1100 | (SUB64mi8 addr:$dst, -128)>; |
| 1101 | |
| 1102 | // The same trick applies for 32-bit immediate fields in 64-bit |
| 1103 | // instructions. |
| 1104 | def : Pat<(add GR64:$src1, 0x0000000080000000), |
| 1105 | (SUB64ri32 GR64:$src1, 0xffffffff80000000)>; |
| 1106 | def : Pat<(store (add (loadi64 addr:$dst), 0x00000000800000000), addr:$dst), |
| 1107 | (SUB64mi32 addr:$dst, 0xffffffff80000000)>; |
| 1108 | |
| 1109 | // Use a 32-bit and with implicit zero-extension instead of a 64-bit and if it |
| 1110 | // has an immediate with at least 32 bits of leading zeros, to avoid needing to |
| 1111 | // materialize that immediate in a register first. |
| 1112 | def : Pat<(and GR64:$src, i64immZExt32:$imm), |
| 1113 | (SUBREG_TO_REG |
| 1114 | (i64 0), |
| 1115 | (AND32ri |
| 1116 | (EXTRACT_SUBREG GR64:$src, sub_32bit), |
| 1117 | (i32 (GetLo32XForm imm:$imm))), |
| 1118 | sub_32bit)>; |
| 1119 | |
| 1120 | |
| 1121 | // r & (2^16-1) ==> movz |
| 1122 | def : Pat<(and GR32:$src1, 0xffff), |
| 1123 | (MOVZX32rr16 (EXTRACT_SUBREG GR32:$src1, sub_16bit))>; |
| 1124 | // r & (2^8-1) ==> movz |
| 1125 | def : Pat<(and GR32:$src1, 0xff), |
| 1126 | (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src1, |
| 1127 | GR32_ABCD)), |
| 1128 | sub_8bit))>, |
| 1129 | Requires<[In32BitMode]>; |
| 1130 | // r & (2^8-1) ==> movz |
| 1131 | def : Pat<(and GR16:$src1, 0xff), |
| 1132 | (MOVZX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src1, |
| 1133 | GR16_ABCD)), |
| 1134 | sub_8bit))>, |
| 1135 | Requires<[In32BitMode]>; |
| 1136 | |
| 1137 | // r & (2^32-1) ==> movz |
| 1138 | def : Pat<(and GR64:$src, 0x00000000FFFFFFFF), |
| 1139 | (MOVZX64rr32 (EXTRACT_SUBREG GR64:$src, sub_32bit))>; |
| 1140 | // r & (2^16-1) ==> movz |
| 1141 | def : Pat<(and GR64:$src, 0xffff), |
| 1142 | (MOVZX64rr16 (i16 (EXTRACT_SUBREG GR64:$src, sub_16bit)))>; |
| 1143 | // r & (2^8-1) ==> movz |
| 1144 | def : Pat<(and GR64:$src, 0xff), |
| 1145 | (MOVZX64rr8 (i8 (EXTRACT_SUBREG GR64:$src, sub_8bit)))>; |
| 1146 | // r & (2^8-1) ==> movz |
| 1147 | def : Pat<(and GR32:$src1, 0xff), |
| 1148 | (MOVZX32rr8 (EXTRACT_SUBREG GR32:$src1, sub_8bit))>, |
| 1149 | Requires<[In64BitMode]>; |
| 1150 | // r & (2^8-1) ==> movz |
| 1151 | def : Pat<(and GR16:$src1, 0xff), |
| 1152 | (MOVZX16rr8 (i8 (EXTRACT_SUBREG GR16:$src1, sub_8bit)))>, |
| 1153 | Requires<[In64BitMode]>; |
| 1154 | |
| 1155 | |
| 1156 | // sext_inreg patterns |
| 1157 | def : Pat<(sext_inreg GR32:$src, i16), |
| 1158 | (MOVSX32rr16 (EXTRACT_SUBREG GR32:$src, sub_16bit))>; |
| 1159 | def : Pat<(sext_inreg GR32:$src, i8), |
| 1160 | (MOVSX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, |
| 1161 | GR32_ABCD)), |
| 1162 | sub_8bit))>, |
| 1163 | Requires<[In32BitMode]>; |
| 1164 | def : Pat<(sext_inreg GR16:$src, i8), |
| 1165 | (MOVSX16rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, |
| 1166 | GR16_ABCD)), |
| 1167 | sub_8bit))>, |
| 1168 | Requires<[In32BitMode]>; |
| 1169 | |
| 1170 | def : Pat<(sext_inreg GR64:$src, i32), |
| 1171 | (MOVSX64rr32 (EXTRACT_SUBREG GR64:$src, sub_32bit))>; |
| 1172 | def : Pat<(sext_inreg GR64:$src, i16), |
| 1173 | (MOVSX64rr16 (EXTRACT_SUBREG GR64:$src, sub_16bit))>; |
| 1174 | def : Pat<(sext_inreg GR64:$src, i8), |
| 1175 | (MOVSX64rr8 (EXTRACT_SUBREG GR64:$src, sub_8bit))>; |
| 1176 | def : Pat<(sext_inreg GR32:$src, i8), |
| 1177 | (MOVSX32rr8 (EXTRACT_SUBREG GR32:$src, sub_8bit))>, |
| 1178 | Requires<[In64BitMode]>; |
| 1179 | def : Pat<(sext_inreg GR16:$src, i8), |
| 1180 | (MOVSX16rr8 (i8 (EXTRACT_SUBREG GR16:$src, sub_8bit)))>, |
| 1181 | Requires<[In64BitMode]>; |
| 1182 | |
| 1183 | |
| 1184 | // trunc patterns |
| 1185 | def : Pat<(i16 (trunc GR32:$src)), |
| 1186 | (EXTRACT_SUBREG GR32:$src, sub_16bit)>; |
| 1187 | def : Pat<(i8 (trunc GR32:$src)), |
| 1188 | (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)), |
| 1189 | sub_8bit)>, |
| 1190 | Requires<[In32BitMode]>; |
| 1191 | def : Pat<(i8 (trunc GR16:$src)), |
| 1192 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
| 1193 | sub_8bit)>, |
| 1194 | Requires<[In32BitMode]>; |
| 1195 | def : Pat<(i32 (trunc GR64:$src)), |
| 1196 | (EXTRACT_SUBREG GR64:$src, sub_32bit)>; |
| 1197 | def : Pat<(i16 (trunc GR64:$src)), |
| 1198 | (EXTRACT_SUBREG GR64:$src, sub_16bit)>; |
| 1199 | def : Pat<(i8 (trunc GR64:$src)), |
| 1200 | (EXTRACT_SUBREG GR64:$src, sub_8bit)>; |
| 1201 | def : Pat<(i8 (trunc GR32:$src)), |
| 1202 | (EXTRACT_SUBREG GR32:$src, sub_8bit)>, |
| 1203 | Requires<[In64BitMode]>; |
| 1204 | def : Pat<(i8 (trunc GR16:$src)), |
| 1205 | (EXTRACT_SUBREG GR16:$src, sub_8bit)>, |
| 1206 | Requires<[In64BitMode]>; |
| 1207 | |
| 1208 | // h-register tricks |
| 1209 | def : Pat<(i8 (trunc (srl_su GR16:$src, (i8 8)))), |
| 1210 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
| 1211 | sub_8bit_hi)>, |
| 1212 | Requires<[In32BitMode]>; |
| 1213 | def : Pat<(i8 (trunc (srl_su GR32:$src, (i8 8)))), |
| 1214 | (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)), |
| 1215 | sub_8bit_hi)>, |
| 1216 | Requires<[In32BitMode]>; |
| 1217 | def : Pat<(srl GR16:$src, (i8 8)), |
| 1218 | (EXTRACT_SUBREG |
| 1219 | (MOVZX32rr8 |
| 1220 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
| 1221 | sub_8bit_hi)), |
| 1222 | sub_16bit)>, |
| 1223 | Requires<[In32BitMode]>; |
| 1224 | def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))), |
| 1225 | (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, |
| 1226 | GR16_ABCD)), |
| 1227 | sub_8bit_hi))>, |
| 1228 | Requires<[In32BitMode]>; |
| 1229 | def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))), |
| 1230 | (MOVZX32rr8 (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, |
| 1231 | GR16_ABCD)), |
| 1232 | sub_8bit_hi))>, |
| 1233 | Requires<[In32BitMode]>; |
| 1234 | def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)), |
| 1235 | (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, |
| 1236 | GR32_ABCD)), |
| 1237 | sub_8bit_hi))>, |
| 1238 | Requires<[In32BitMode]>; |
| 1239 | def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)), |
| 1240 | (MOVZX32rr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, |
| 1241 | GR32_ABCD)), |
| 1242 | sub_8bit_hi))>, |
| 1243 | Requires<[In32BitMode]>; |
| 1244 | |
| 1245 | // h-register tricks. |
| 1246 | // For now, be conservative on x86-64 and use an h-register extract only if the |
| 1247 | // value is immediately zero-extended or stored, which are somewhat common |
| 1248 | // cases. This uses a bunch of code to prevent a register requiring a REX prefix |
| 1249 | // from being allocated in the same instruction as the h register, as there's |
| 1250 | // currently no way to describe this requirement to the register allocator. |
| 1251 | |
| 1252 | // h-register extract and zero-extend. |
| 1253 | def : Pat<(and (srl_su GR64:$src, (i8 8)), (i64 255)), |
| 1254 | (SUBREG_TO_REG |
| 1255 | (i64 0), |
| 1256 | (MOVZX32_NOREXrr8 |
| 1257 | (EXTRACT_SUBREG (i64 (COPY_TO_REGCLASS GR64:$src, GR64_ABCD)), |
| 1258 | sub_8bit_hi)), |
| 1259 | sub_32bit)>; |
| 1260 | def : Pat<(and (srl_su GR32:$src, (i8 8)), (i32 255)), |
| 1261 | (MOVZX32_NOREXrr8 |
| 1262 | (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)), |
| 1263 | sub_8bit_hi))>, |
| 1264 | Requires<[In64BitMode]>; |
| 1265 | def : Pat<(srl (and_su GR32:$src, 0xff00), (i8 8)), |
| 1266 | (MOVZX32_NOREXrr8 (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, |
| 1267 | GR32_ABCD)), |
| 1268 | sub_8bit_hi))>, |
| 1269 | Requires<[In64BitMode]>; |
| 1270 | def : Pat<(srl GR16:$src, (i8 8)), |
| 1271 | (EXTRACT_SUBREG |
| 1272 | (MOVZX32_NOREXrr8 |
| 1273 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
| 1274 | sub_8bit_hi)), |
| 1275 | sub_16bit)>, |
| 1276 | Requires<[In64BitMode]>; |
| 1277 | def : Pat<(i32 (zext (srl_su GR16:$src, (i8 8)))), |
| 1278 | (MOVZX32_NOREXrr8 |
| 1279 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
| 1280 | sub_8bit_hi))>, |
| 1281 | Requires<[In64BitMode]>; |
| 1282 | def : Pat<(i32 (anyext (srl_su GR16:$src, (i8 8)))), |
| 1283 | (MOVZX32_NOREXrr8 |
| 1284 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
| 1285 | sub_8bit_hi))>, |
| 1286 | Requires<[In64BitMode]>; |
| 1287 | def : Pat<(i64 (zext (srl_su GR16:$src, (i8 8)))), |
| 1288 | (SUBREG_TO_REG |
| 1289 | (i64 0), |
| 1290 | (MOVZX32_NOREXrr8 |
| 1291 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
| 1292 | sub_8bit_hi)), |
| 1293 | sub_32bit)>; |
| 1294 | def : Pat<(i64 (anyext (srl_su GR16:$src, (i8 8)))), |
| 1295 | (SUBREG_TO_REG |
| 1296 | (i64 0), |
| 1297 | (MOVZX32_NOREXrr8 |
| 1298 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
| 1299 | sub_8bit_hi)), |
| 1300 | sub_32bit)>; |
| 1301 | |
| 1302 | // h-register extract and store. |
| 1303 | def : Pat<(store (i8 (trunc_su (srl_su GR64:$src, (i8 8)))), addr:$dst), |
| 1304 | (MOV8mr_NOREX |
| 1305 | addr:$dst, |
| 1306 | (EXTRACT_SUBREG (i64 (COPY_TO_REGCLASS GR64:$src, GR64_ABCD)), |
| 1307 | sub_8bit_hi))>; |
| 1308 | def : Pat<(store (i8 (trunc_su (srl_su GR32:$src, (i8 8)))), addr:$dst), |
| 1309 | (MOV8mr_NOREX |
| 1310 | addr:$dst, |
| 1311 | (EXTRACT_SUBREG (i32 (COPY_TO_REGCLASS GR32:$src, GR32_ABCD)), |
| 1312 | sub_8bit_hi))>, |
| 1313 | Requires<[In64BitMode]>; |
| 1314 | def : Pat<(store (i8 (trunc_su (srl_su GR16:$src, (i8 8)))), addr:$dst), |
| 1315 | (MOV8mr_NOREX |
| 1316 | addr:$dst, |
| 1317 | (EXTRACT_SUBREG (i16 (COPY_TO_REGCLASS GR16:$src, GR16_ABCD)), |
| 1318 | sub_8bit_hi))>, |
| 1319 | Requires<[In64BitMode]>; |
| 1320 | |
| 1321 | |
| 1322 | // (shl x, 1) ==> (add x, x) |
| 1323 | def : Pat<(shl GR8 :$src1, (i8 1)), (ADD8rr GR8 :$src1, GR8 :$src1)>; |
| 1324 | def : Pat<(shl GR16:$src1, (i8 1)), (ADD16rr GR16:$src1, GR16:$src1)>; |
| 1325 | def : Pat<(shl GR32:$src1, (i8 1)), (ADD32rr GR32:$src1, GR32:$src1)>; |
| 1326 | def : Pat<(shl GR64:$src1, (i8 1)), (ADD64rr GR64:$src1, GR64:$src1)>; |
| 1327 | |
| 1328 | // (shl x (and y, 31)) ==> (shl x, y) |
| 1329 | def : Pat<(shl GR8:$src1, (and CL, 31)), |
| 1330 | (SHL8rCL GR8:$src1)>; |
| 1331 | def : Pat<(shl GR16:$src1, (and CL, 31)), |
| 1332 | (SHL16rCL GR16:$src1)>; |
| 1333 | def : Pat<(shl GR32:$src1, (and CL, 31)), |
| 1334 | (SHL32rCL GR32:$src1)>; |
| 1335 | def : Pat<(store (shl (loadi8 addr:$dst), (and CL, 31)), addr:$dst), |
| 1336 | (SHL8mCL addr:$dst)>; |
| 1337 | def : Pat<(store (shl (loadi16 addr:$dst), (and CL, 31)), addr:$dst), |
| 1338 | (SHL16mCL addr:$dst)>; |
| 1339 | def : Pat<(store (shl (loadi32 addr:$dst), (and CL, 31)), addr:$dst), |
| 1340 | (SHL32mCL addr:$dst)>; |
| 1341 | |
| 1342 | def : Pat<(srl GR8:$src1, (and CL, 31)), |
| 1343 | (SHR8rCL GR8:$src1)>; |
| 1344 | def : Pat<(srl GR16:$src1, (and CL, 31)), |
| 1345 | (SHR16rCL GR16:$src1)>; |
| 1346 | def : Pat<(srl GR32:$src1, (and CL, 31)), |
| 1347 | (SHR32rCL GR32:$src1)>; |
| 1348 | def : Pat<(store (srl (loadi8 addr:$dst), (and CL, 31)), addr:$dst), |
| 1349 | (SHR8mCL addr:$dst)>; |
| 1350 | def : Pat<(store (srl (loadi16 addr:$dst), (and CL, 31)), addr:$dst), |
| 1351 | (SHR16mCL addr:$dst)>; |
| 1352 | def : Pat<(store (srl (loadi32 addr:$dst), (and CL, 31)), addr:$dst), |
| 1353 | (SHR32mCL addr:$dst)>; |
| 1354 | |
| 1355 | def : Pat<(sra GR8:$src1, (and CL, 31)), |
| 1356 | (SAR8rCL GR8:$src1)>; |
| 1357 | def : Pat<(sra GR16:$src1, (and CL, 31)), |
| 1358 | (SAR16rCL GR16:$src1)>; |
| 1359 | def : Pat<(sra GR32:$src1, (and CL, 31)), |
| 1360 | (SAR32rCL GR32:$src1)>; |
| 1361 | def : Pat<(store (sra (loadi8 addr:$dst), (and CL, 31)), addr:$dst), |
| 1362 | (SAR8mCL addr:$dst)>; |
| 1363 | def : Pat<(store (sra (loadi16 addr:$dst), (and CL, 31)), addr:$dst), |
| 1364 | (SAR16mCL addr:$dst)>; |
| 1365 | def : Pat<(store (sra (loadi32 addr:$dst), (and CL, 31)), addr:$dst), |
| 1366 | (SAR32mCL addr:$dst)>; |
| 1367 | |
| 1368 | // (shl x (and y, 63)) ==> (shl x, y) |
| 1369 | def : Pat<(shl GR64:$src1, (and CL, 63)), |
| 1370 | (SHL64rCL GR64:$src1)>; |
| 1371 | def : Pat<(store (shl (loadi64 addr:$dst), (and CL, 63)), addr:$dst), |
| 1372 | (SHL64mCL addr:$dst)>; |
| 1373 | |
| 1374 | def : Pat<(srl GR64:$src1, (and CL, 63)), |
| 1375 | (SHR64rCL GR64:$src1)>; |
| 1376 | def : Pat<(store (srl (loadi64 addr:$dst), (and CL, 63)), addr:$dst), |
| 1377 | (SHR64mCL addr:$dst)>; |
| 1378 | |
| 1379 | def : Pat<(sra GR64:$src1, (and CL, 63)), |
| 1380 | (SAR64rCL GR64:$src1)>; |
| 1381 | def : Pat<(store (sra (loadi64 addr:$dst), (and CL, 63)), addr:$dst), |
| 1382 | (SAR64mCL addr:$dst)>; |
| 1383 | |
| 1384 | |
| 1385 | // (anyext (setcc_carry)) -> (setcc_carry) |
| 1386 | def : Pat<(i16 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))), |
| 1387 | (SETB_C16r)>; |
| 1388 | def : Pat<(i32 (anyext (i8 (X86setcc_c X86_COND_B, EFLAGS)))), |
| 1389 | (SETB_C32r)>; |
| 1390 | def : Pat<(i32 (anyext (i16 (X86setcc_c X86_COND_B, EFLAGS)))), |
| 1391 | (SETB_C32r)>; |
| 1392 | |
Chris Lattner | 99ae665 | 2010-10-08 03:54:52 +0000 | [diff] [blame] | 1393 | |
| 1394 | |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 1395 | |
| 1396 | //===----------------------------------------------------------------------===// |
| 1397 | // EFLAGS-defining Patterns |
| 1398 | //===----------------------------------------------------------------------===// |
| 1399 | |
| 1400 | // add reg, reg |
| 1401 | def : Pat<(add GR8 :$src1, GR8 :$src2), (ADD8rr GR8 :$src1, GR8 :$src2)>; |
| 1402 | def : Pat<(add GR16:$src1, GR16:$src2), (ADD16rr GR16:$src1, GR16:$src2)>; |
| 1403 | def : Pat<(add GR32:$src1, GR32:$src2), (ADD32rr GR32:$src1, GR32:$src2)>; |
| 1404 | |
| 1405 | // add reg, mem |
| 1406 | def : Pat<(add GR8:$src1, (loadi8 addr:$src2)), |
| 1407 | (ADD8rm GR8:$src1, addr:$src2)>; |
| 1408 | def : Pat<(add GR16:$src1, (loadi16 addr:$src2)), |
| 1409 | (ADD16rm GR16:$src1, addr:$src2)>; |
| 1410 | def : Pat<(add GR32:$src1, (loadi32 addr:$src2)), |
| 1411 | (ADD32rm GR32:$src1, addr:$src2)>; |
| 1412 | |
| 1413 | // add reg, imm |
| 1414 | def : Pat<(add GR8 :$src1, imm:$src2), (ADD8ri GR8:$src1 , imm:$src2)>; |
| 1415 | def : Pat<(add GR16:$src1, imm:$src2), (ADD16ri GR16:$src1, imm:$src2)>; |
| 1416 | def : Pat<(add GR32:$src1, imm:$src2), (ADD32ri GR32:$src1, imm:$src2)>; |
| 1417 | def : Pat<(add GR16:$src1, i16immSExt8:$src2), |
| 1418 | (ADD16ri8 GR16:$src1, i16immSExt8:$src2)>; |
| 1419 | def : Pat<(add GR32:$src1, i32immSExt8:$src2), |
| 1420 | (ADD32ri8 GR32:$src1, i32immSExt8:$src2)>; |
| 1421 | |
| 1422 | // sub reg, reg |
| 1423 | def : Pat<(sub GR8 :$src1, GR8 :$src2), (SUB8rr GR8 :$src1, GR8 :$src2)>; |
| 1424 | def : Pat<(sub GR16:$src1, GR16:$src2), (SUB16rr GR16:$src1, GR16:$src2)>; |
| 1425 | def : Pat<(sub GR32:$src1, GR32:$src2), (SUB32rr GR32:$src1, GR32:$src2)>; |
| 1426 | |
| 1427 | // sub reg, mem |
| 1428 | def : Pat<(sub GR8:$src1, (loadi8 addr:$src2)), |
| 1429 | (SUB8rm GR8:$src1, addr:$src2)>; |
| 1430 | def : Pat<(sub GR16:$src1, (loadi16 addr:$src2)), |
| 1431 | (SUB16rm GR16:$src1, addr:$src2)>; |
| 1432 | def : Pat<(sub GR32:$src1, (loadi32 addr:$src2)), |
| 1433 | (SUB32rm GR32:$src1, addr:$src2)>; |
| 1434 | |
| 1435 | // sub reg, imm |
| 1436 | def : Pat<(sub GR8:$src1, imm:$src2), |
| 1437 | (SUB8ri GR8:$src1, imm:$src2)>; |
| 1438 | def : Pat<(sub GR16:$src1, imm:$src2), |
| 1439 | (SUB16ri GR16:$src1, imm:$src2)>; |
| 1440 | def : Pat<(sub GR32:$src1, imm:$src2), |
| 1441 | (SUB32ri GR32:$src1, imm:$src2)>; |
| 1442 | def : Pat<(sub GR16:$src1, i16immSExt8:$src2), |
| 1443 | (SUB16ri8 GR16:$src1, i16immSExt8:$src2)>; |
| 1444 | def : Pat<(sub GR32:$src1, i32immSExt8:$src2), |
| 1445 | (SUB32ri8 GR32:$src1, i32immSExt8:$src2)>; |
| 1446 | |
| 1447 | // mul reg, reg |
| 1448 | def : Pat<(mul GR16:$src1, GR16:$src2), |
| 1449 | (IMUL16rr GR16:$src1, GR16:$src2)>; |
| 1450 | def : Pat<(mul GR32:$src1, GR32:$src2), |
| 1451 | (IMUL32rr GR32:$src1, GR32:$src2)>; |
| 1452 | |
| 1453 | // mul reg, mem |
| 1454 | def : Pat<(mul GR16:$src1, (loadi16 addr:$src2)), |
| 1455 | (IMUL16rm GR16:$src1, addr:$src2)>; |
| 1456 | def : Pat<(mul GR32:$src1, (loadi32 addr:$src2)), |
| 1457 | (IMUL32rm GR32:$src1, addr:$src2)>; |
| 1458 | |
| 1459 | // mul reg, imm |
| 1460 | def : Pat<(mul GR16:$src1, imm:$src2), |
| 1461 | (IMUL16rri GR16:$src1, imm:$src2)>; |
| 1462 | def : Pat<(mul GR32:$src1, imm:$src2), |
| 1463 | (IMUL32rri GR32:$src1, imm:$src2)>; |
| 1464 | def : Pat<(mul GR16:$src1, i16immSExt8:$src2), |
| 1465 | (IMUL16rri8 GR16:$src1, i16immSExt8:$src2)>; |
| 1466 | def : Pat<(mul GR32:$src1, i32immSExt8:$src2), |
| 1467 | (IMUL32rri8 GR32:$src1, i32immSExt8:$src2)>; |
| 1468 | |
| 1469 | // reg = mul mem, imm |
| 1470 | def : Pat<(mul (loadi16 addr:$src1), imm:$src2), |
| 1471 | (IMUL16rmi addr:$src1, imm:$src2)>; |
| 1472 | def : Pat<(mul (loadi32 addr:$src1), imm:$src2), |
| 1473 | (IMUL32rmi addr:$src1, imm:$src2)>; |
| 1474 | def : Pat<(mul (loadi16 addr:$src1), i16immSExt8:$src2), |
| 1475 | (IMUL16rmi8 addr:$src1, i16immSExt8:$src2)>; |
| 1476 | def : Pat<(mul (loadi32 addr:$src1), i32immSExt8:$src2), |
| 1477 | (IMUL32rmi8 addr:$src1, i32immSExt8:$src2)>; |
| 1478 | |
| 1479 | // Optimize multiply by 2 with EFLAGS result. |
| 1480 | let AddedComplexity = 2 in { |
| 1481 | def : Pat<(X86smul_flag GR16:$src1, 2), (ADD16rr GR16:$src1, GR16:$src1)>; |
| 1482 | def : Pat<(X86smul_flag GR32:$src1, 2), (ADD32rr GR32:$src1, GR32:$src1)>; |
| 1483 | } |
| 1484 | |
| 1485 | // Patterns for nodes that do not produce flags, for instructions that do. |
| 1486 | |
| 1487 | // addition |
| 1488 | def : Pat<(add GR64:$src1, GR64:$src2), |
| 1489 | (ADD64rr GR64:$src1, GR64:$src2)>; |
| 1490 | def : Pat<(add GR64:$src1, i64immSExt8:$src2), |
| 1491 | (ADD64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1492 | def : Pat<(add GR64:$src1, i64immSExt32:$src2), |
| 1493 | (ADD64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 1494 | def : Pat<(add GR64:$src1, (loadi64 addr:$src2)), |
| 1495 | (ADD64rm GR64:$src1, addr:$src2)>; |
| 1496 | |
| 1497 | // subtraction |
| 1498 | def : Pat<(sub GR64:$src1, GR64:$src2), |
| 1499 | (SUB64rr GR64:$src1, GR64:$src2)>; |
| 1500 | def : Pat<(sub GR64:$src1, (loadi64 addr:$src2)), |
| 1501 | (SUB64rm GR64:$src1, addr:$src2)>; |
| 1502 | def : Pat<(sub GR64:$src1, i64immSExt8:$src2), |
| 1503 | (SUB64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1504 | def : Pat<(sub GR64:$src1, i64immSExt32:$src2), |
| 1505 | (SUB64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 1506 | |
| 1507 | // Multiply |
| 1508 | def : Pat<(mul GR64:$src1, GR64:$src2), |
| 1509 | (IMUL64rr GR64:$src1, GR64:$src2)>; |
| 1510 | def : Pat<(mul GR64:$src1, (loadi64 addr:$src2)), |
| 1511 | (IMUL64rm GR64:$src1, addr:$src2)>; |
| 1512 | def : Pat<(mul GR64:$src1, i64immSExt8:$src2), |
| 1513 | (IMUL64rri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1514 | def : Pat<(mul GR64:$src1, i64immSExt32:$src2), |
| 1515 | (IMUL64rri32 GR64:$src1, i64immSExt32:$src2)>; |
| 1516 | def : Pat<(mul (loadi64 addr:$src1), i64immSExt8:$src2), |
| 1517 | (IMUL64rmi8 addr:$src1, i64immSExt8:$src2)>; |
| 1518 | def : Pat<(mul (loadi64 addr:$src1), i64immSExt32:$src2), |
| 1519 | (IMUL64rmi32 addr:$src1, i64immSExt32:$src2)>; |
| 1520 | |
| 1521 | // Increment reg. |
| 1522 | def : Pat<(add GR8 :$src, 1), (INC8r GR8 :$src)>; |
| 1523 | def : Pat<(add GR16:$src, 1), (INC16r GR16:$src)>, Requires<[In32BitMode]>; |
| 1524 | def : Pat<(add GR16:$src, 1), (INC64_16r GR16:$src)>, Requires<[In64BitMode]>; |
| 1525 | def : Pat<(add GR32:$src, 1), (INC32r GR32:$src)>, Requires<[In32BitMode]>; |
| 1526 | def : Pat<(add GR32:$src, 1), (INC64_32r GR32:$src)>, Requires<[In64BitMode]>; |
| 1527 | def : Pat<(add GR64:$src, 1), (INC64r GR64:$src)>; |
| 1528 | |
| 1529 | // Decrement reg. |
| 1530 | def : Pat<(add GR8 :$src, -1), (DEC8r GR8 :$src)>; |
| 1531 | def : Pat<(add GR16:$src, -1), (DEC16r GR16:$src)>, Requires<[In32BitMode]>; |
| 1532 | def : Pat<(add GR16:$src, -1), (DEC64_16r GR16:$src)>, Requires<[In64BitMode]>; |
| 1533 | def : Pat<(add GR32:$src, -1), (DEC32r GR32:$src)>, Requires<[In32BitMode]>; |
| 1534 | def : Pat<(add GR32:$src, -1), (DEC64_32r GR32:$src)>, Requires<[In64BitMode]>; |
| 1535 | def : Pat<(add GR64:$src, -1), (DEC64r GR64:$src)>; |
| 1536 | |
| 1537 | // or reg/reg. |
| 1538 | def : Pat<(or GR8 :$src1, GR8 :$src2), (OR8rr GR8 :$src1, GR8 :$src2)>; |
| 1539 | def : Pat<(or GR16:$src1, GR16:$src2), (OR16rr GR16:$src1, GR16:$src2)>; |
| 1540 | def : Pat<(or GR32:$src1, GR32:$src2), (OR32rr GR32:$src1, GR32:$src2)>; |
| 1541 | def : Pat<(or GR64:$src1, GR64:$src2), (OR64rr GR64:$src1, GR64:$src2)>; |
| 1542 | |
| 1543 | // or reg/mem |
| 1544 | def : Pat<(or GR8:$src1, (loadi8 addr:$src2)), |
| 1545 | (OR8rm GR8:$src1, addr:$src2)>; |
| 1546 | def : Pat<(or GR16:$src1, (loadi16 addr:$src2)), |
| 1547 | (OR16rm GR16:$src1, addr:$src2)>; |
| 1548 | def : Pat<(or GR32:$src1, (loadi32 addr:$src2)), |
| 1549 | (OR32rm GR32:$src1, addr:$src2)>; |
| 1550 | def : Pat<(or GR64:$src1, (loadi64 addr:$src2)), |
| 1551 | (OR64rm GR64:$src1, addr:$src2)>; |
| 1552 | |
| 1553 | // or reg/imm |
| 1554 | def : Pat<(or GR8:$src1 , imm:$src2), (OR8ri GR8 :$src1, imm:$src2)>; |
| 1555 | def : Pat<(or GR16:$src1, imm:$src2), (OR16ri GR16:$src1, imm:$src2)>; |
| 1556 | def : Pat<(or GR32:$src1, imm:$src2), (OR32ri GR32:$src1, imm:$src2)>; |
| 1557 | def : Pat<(or GR16:$src1, i16immSExt8:$src2), |
| 1558 | (OR16ri8 GR16:$src1, i16immSExt8:$src2)>; |
| 1559 | def : Pat<(or GR32:$src1, i32immSExt8:$src2), |
| 1560 | (OR32ri8 GR32:$src1, i32immSExt8:$src2)>; |
| 1561 | def : Pat<(or GR64:$src1, i64immSExt8:$src2), |
| 1562 | (OR64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1563 | def : Pat<(or GR64:$src1, i64immSExt32:$src2), |
| 1564 | (OR64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 1565 | |
| 1566 | // xor reg/reg |
| 1567 | def : Pat<(xor GR8 :$src1, GR8 :$src2), (XOR8rr GR8 :$src1, GR8 :$src2)>; |
| 1568 | def : Pat<(xor GR16:$src1, GR16:$src2), (XOR16rr GR16:$src1, GR16:$src2)>; |
| 1569 | def : Pat<(xor GR32:$src1, GR32:$src2), (XOR32rr GR32:$src1, GR32:$src2)>; |
| 1570 | def : Pat<(xor GR64:$src1, GR64:$src2), (XOR64rr GR64:$src1, GR64:$src2)>; |
| 1571 | |
| 1572 | // xor reg/mem |
| 1573 | def : Pat<(xor GR8:$src1, (loadi8 addr:$src2)), |
| 1574 | (XOR8rm GR8:$src1, addr:$src2)>; |
| 1575 | def : Pat<(xor GR16:$src1, (loadi16 addr:$src2)), |
| 1576 | (XOR16rm GR16:$src1, addr:$src2)>; |
| 1577 | def : Pat<(xor GR32:$src1, (loadi32 addr:$src2)), |
| 1578 | (XOR32rm GR32:$src1, addr:$src2)>; |
| 1579 | def : Pat<(xor GR64:$src1, (loadi64 addr:$src2)), |
| 1580 | (XOR64rm GR64:$src1, addr:$src2)>; |
| 1581 | |
| 1582 | // xor reg/imm |
| 1583 | def : Pat<(xor GR8:$src1, imm:$src2), |
| 1584 | (XOR8ri GR8:$src1, imm:$src2)>; |
| 1585 | def : Pat<(xor GR16:$src1, imm:$src2), |
| 1586 | (XOR16ri GR16:$src1, imm:$src2)>; |
| 1587 | def : Pat<(xor GR32:$src1, imm:$src2), |
| 1588 | (XOR32ri GR32:$src1, imm:$src2)>; |
| 1589 | def : Pat<(xor GR16:$src1, i16immSExt8:$src2), |
| 1590 | (XOR16ri8 GR16:$src1, i16immSExt8:$src2)>; |
| 1591 | def : Pat<(xor GR32:$src1, i32immSExt8:$src2), |
| 1592 | (XOR32ri8 GR32:$src1, i32immSExt8:$src2)>; |
| 1593 | def : Pat<(xor GR64:$src1, i64immSExt8:$src2), |
| 1594 | (XOR64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1595 | def : Pat<(xor GR64:$src1, i64immSExt32:$src2), |
| 1596 | (XOR64ri32 GR64:$src1, i64immSExt32:$src2)>; |
| 1597 | |
| 1598 | // and reg/reg |
| 1599 | def : Pat<(and GR8 :$src1, GR8 :$src2), (AND8rr GR8 :$src1, GR8 :$src2)>; |
| 1600 | def : Pat<(and GR16:$src1, GR16:$src2), (AND16rr GR16:$src1, GR16:$src2)>; |
| 1601 | def : Pat<(and GR32:$src1, GR32:$src2), (AND32rr GR32:$src1, GR32:$src2)>; |
| 1602 | def : Pat<(and GR64:$src1, GR64:$src2), (AND64rr GR64:$src1, GR64:$src2)>; |
| 1603 | |
| 1604 | // and reg/mem |
| 1605 | def : Pat<(and GR8:$src1, (loadi8 addr:$src2)), |
| 1606 | (AND8rm GR8:$src1, addr:$src2)>; |
| 1607 | def : Pat<(and GR16:$src1, (loadi16 addr:$src2)), |
| 1608 | (AND16rm GR16:$src1, addr:$src2)>; |
| 1609 | def : Pat<(and GR32:$src1, (loadi32 addr:$src2)), |
| 1610 | (AND32rm GR32:$src1, addr:$src2)>; |
| 1611 | def : Pat<(and GR64:$src1, (loadi64 addr:$src2)), |
| 1612 | (AND64rm GR64:$src1, addr:$src2)>; |
| 1613 | |
| 1614 | // and reg/imm |
| 1615 | def : Pat<(and GR8:$src1, imm:$src2), |
| 1616 | (AND8ri GR8:$src1, imm:$src2)>; |
| 1617 | def : Pat<(and GR16:$src1, imm:$src2), |
| 1618 | (AND16ri GR16:$src1, imm:$src2)>; |
| 1619 | def : Pat<(and GR32:$src1, imm:$src2), |
| 1620 | (AND32ri GR32:$src1, imm:$src2)>; |
| 1621 | def : Pat<(and GR16:$src1, i16immSExt8:$src2), |
| 1622 | (AND16ri8 GR16:$src1, i16immSExt8:$src2)>; |
| 1623 | def : Pat<(and GR32:$src1, i32immSExt8:$src2), |
| 1624 | (AND32ri8 GR32:$src1, i32immSExt8:$src2)>; |
| 1625 | def : Pat<(and GR64:$src1, i64immSExt8:$src2), |
| 1626 | (AND64ri8 GR64:$src1, i64immSExt8:$src2)>; |
| 1627 | def : Pat<(and GR64:$src1, i64immSExt32:$src2), |
| 1628 | (AND64ri32 GR64:$src1, i64immSExt32:$src2)>; |
Chris Lattner | 87be16a | 2010-10-05 06:04:14 +0000 | [diff] [blame] | 1629 | |