1//===-- PPCInstr64Bit.td - The PowerPC 64-bit Support ------*- 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 PowerPC 64-bit instructions. These patterns are used 11// both when in ppc64 mode and when in "use 64-bit extensions in 32-bit" mode. 12// 13//===----------------------------------------------------------------------===// 14 15//===----------------------------------------------------------------------===// 16// 64-bit operands. 17// 18def s16imm64 : Operand<i64> { 19 let PrintMethod = "printS16ImmOperand"; 20 let EncoderMethod = "getImm16Encoding"; 21 let ParserMatchClass = PPCS16ImmAsmOperand; 22 let DecoderMethod = "decodeSImmOperand<16>"; 23} 24def u16imm64 : Operand<i64> { 25 let PrintMethod = "printU16ImmOperand"; 26 let EncoderMethod = "getImm16Encoding"; 27 let ParserMatchClass = PPCU16ImmAsmOperand; 28 let DecoderMethod = "decodeUImmOperand<16>"; 29} 30def s17imm64 : Operand<i64> { 31 // This operand type is used for addis/lis to allow the assembler parser 32 // to accept immediates in the range -65536..65535 for compatibility with 33 // the GNU assembler. The operand is treated as 16-bit otherwise. 34 let PrintMethod = "printS16ImmOperand"; 35 let EncoderMethod = "getImm16Encoding"; 36 let ParserMatchClass = PPCS17ImmAsmOperand; 37 let DecoderMethod = "decodeSImmOperand<16>"; 38} 39def tocentry : Operand<iPTR> { 40 let MIOperandInfo = (ops i64imm:$imm); 41} 42def tlsreg : Operand<i64> { 43 let EncoderMethod = "getTLSRegEncoding"; 44 let ParserMatchClass = PPCTLSRegOperand; 45} 46def tlsgd : Operand<i64> {} 47def tlscall : Operand<i64> { 48 let PrintMethod = "printTLSCall"; 49 let MIOperandInfo = (ops calltarget:$func, tlsgd:$sym); 50 let EncoderMethod = "getTLSCallEncoding"; 51} 52 53//===----------------------------------------------------------------------===// 54// 64-bit transformation functions. 55// 56 57def SHL64 : SDNodeXForm<imm, [{ 58 // Transformation function: 63 - imm 59 return getI32Imm(63 - N->getZExtValue(), SDLoc(N)); 60}]>; 61 62def SRL64 : SDNodeXForm<imm, [{ 63 // Transformation function: 64 - imm 64 return N->getZExtValue() ? getI32Imm(64 - N->getZExtValue(), SDLoc(N)) 65 : getI32Imm(0, SDLoc(N)); 66}]>; 67 68def HI32_48 : SDNodeXForm<imm, [{ 69 // Transformation function: shift the immediate value down into the low bits. 70 return getI32Imm((unsigned short)(N->getZExtValue() >> 32, SDLoc(N))); 71}]>; 72 73def HI48_64 : SDNodeXForm<imm, [{ 74 // Transformation function: shift the immediate value down into the low bits. 75 return getI32Imm((unsigned short)(N->getZExtValue() >> 48, SDLoc(N))); 76}]>; 77 78 79//===----------------------------------------------------------------------===// 80// Calls. 81// 82 83let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 84let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in { 85 let isReturn = 1, Uses = [LR8, RM] in 86 def BLR8 : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB, 87 [(retflag)]>, Requires<[In64BitMode]>; 88 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR8] in { 89 def BCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB, 90 []>, 91 Requires<[In64BitMode]>; 92 def BCCCTR8 : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond), 93 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB, 94 []>, 95 Requires<[In64BitMode]>; 96 97 def BCCTR8 : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi), 98 "bcctr 12, $bi, 0", IIC_BrB, []>, 99 Requires<[In64BitMode]>; 100 def BCCTR8n : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi), 101 "bcctr 4, $bi, 0", IIC_BrB, []>, 102 Requires<[In64BitMode]>; 103 } 104} 105 106let Defs = [LR8] in 107 def MovePCtoLR8 : Pseudo<(outs), (ins), "#MovePCtoLR8", []>, 108 PPC970_Unit_BRU; 109 110let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in { 111 let Defs = [CTR8], Uses = [CTR8] in { 112 def BDZ8 : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst), 113 "bdz $dst">; 114 def BDNZ8 : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst), 115 "bdnz $dst">; 116 } 117 118 let isReturn = 1, Defs = [CTR8], Uses = [CTR8, LR8, RM] in { 119 def BDZLR8 : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins), 120 "bdzlr", IIC_BrB, []>; 121 def BDNZLR8 : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins), 122 "bdnzlr", IIC_BrB, []>; 123 } 124} 125 126 127 128let isCall = 1, PPC970_Unit = 7, Defs = [LR8] in { 129 // Convenient aliases for call instructions 130 let Uses = [RM] in { 131 def BL8 : IForm<18, 0, 1, (outs), (ins calltarget:$func), 132 "bl $func", IIC_BrB, []>; // See Pat patterns below. 133 134 def BL8_TLS : IForm<18, 0, 1, (outs), (ins tlscall:$func), 135 "bl $func", IIC_BrB, []>; 136 137 def BLA8 : IForm<18, 1, 1, (outs), (ins abscalltarget:$func), 138 "bla $func", IIC_BrB, [(PPCcall (i64 imm:$func))]>; 139 } 140 let Uses = [RM], isCodeGenOnly = 1 in { 141 def BL8_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24, 142 (outs), (ins calltarget:$func), 143 "bl $func\n\tnop", IIC_BrB, []>; 144 145 def BL8_NOP_TLS : IForm_and_DForm_4_zero<18, 0, 1, 24, 146 (outs), (ins tlscall:$func), 147 "bl $func\n\tnop", IIC_BrB, []>; 148 149 def BLA8_NOP : IForm_and_DForm_4_zero<18, 1, 1, 24, 150 (outs), (ins abscalltarget:$func), 151 "bla $func\n\tnop", IIC_BrB, 152 [(PPCcall_nop (i64 imm:$func))]>; 153 } 154 let Uses = [CTR8, RM] in { 155 def BCTRL8 : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins), 156 "bctrl", IIC_BrB, [(PPCbctrl)]>, 157 Requires<[In64BitMode]>; 158 159 let isCodeGenOnly = 1 in { 160 def BCCCTRL8 : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond), 161 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB, 162 []>, 163 Requires<[In64BitMode]>; 164 165 def BCCTRL8 : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi), 166 "bcctrl 12, $bi, 0", IIC_BrB, []>, 167 Requires<[In64BitMode]>; 168 def BCCTRL8n : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi), 169 "bcctrl 4, $bi, 0", IIC_BrB, []>, 170 Requires<[In64BitMode]>; 171 } 172 } 173} 174 175let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1, 176 Defs = [LR8, X2], Uses = [CTR8, RM], RST = 2 in { 177 def BCTRL8_LDinto_toc : 178 XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs), 179 (ins memrix:$src), 180 "bctrl\n\tld 2, $src", IIC_BrB, 181 [(PPCbctrl_load_toc ixaddr:$src)]>, 182 Requires<[In64BitMode]>; 183} 184 185} // Interpretation64Bit 186 187// FIXME: Duplicating this for the asm parser should be unnecessary, but the 188// previous definition must be marked as CodeGen only to prevent decoding 189// conflicts. 190let Interpretation64Bit = 1, isAsmParserOnly = 1 in 191let isCall = 1, PPC970_Unit = 7, Defs = [LR8], Uses = [RM] in 192def BL8_TLS_ : IForm<18, 0, 1, (outs), (ins tlscall:$func), 193 "bl $func", IIC_BrB, []>; 194 195// Calls 196def : Pat<(PPCcall (i64 tglobaladdr:$dst)), 197 (BL8 tglobaladdr:$dst)>; 198def : Pat<(PPCcall_nop (i64 tglobaladdr:$dst)), 199 (BL8_NOP tglobaladdr:$dst)>; 200 201def : Pat<(PPCcall (i64 texternalsym:$dst)), 202 (BL8 texternalsym:$dst)>; 203def : Pat<(PPCcall_nop (i64 texternalsym:$dst)), 204 (BL8_NOP texternalsym:$dst)>; 205 206// Atomic operations 207let usesCustomInserter = 1 in { 208 let Defs = [CR0] in { 209 def ATOMIC_LOAD_ADD_I64 : Pseudo< 210 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64", 211 [(set i64:$dst, (atomic_load_add_64 xoaddr:$ptr, i64:$incr))]>; 212 def ATOMIC_LOAD_SUB_I64 : Pseudo< 213 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64", 214 [(set i64:$dst, (atomic_load_sub_64 xoaddr:$ptr, i64:$incr))]>; 215 def ATOMIC_LOAD_OR_I64 : Pseudo< 216 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64", 217 [(set i64:$dst, (atomic_load_or_64 xoaddr:$ptr, i64:$incr))]>; 218 def ATOMIC_LOAD_XOR_I64 : Pseudo< 219 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64", 220 [(set i64:$dst, (atomic_load_xor_64 xoaddr:$ptr, i64:$incr))]>; 221 def ATOMIC_LOAD_AND_I64 : Pseudo< 222 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64", 223 [(set i64:$dst, (atomic_load_and_64 xoaddr:$ptr, i64:$incr))]>; 224 def ATOMIC_LOAD_NAND_I64 : Pseudo< 225 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64", 226 [(set i64:$dst, (atomic_load_nand_64 xoaddr:$ptr, i64:$incr))]>; 227 228 def ATOMIC_CMP_SWAP_I64 : Pseudo< 229 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64", 230 [(set i64:$dst, (atomic_cmp_swap_64 xoaddr:$ptr, i64:$old, i64:$new))]>; 231 232 def ATOMIC_SWAP_I64 : Pseudo< 233 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64", 234 [(set i64:$dst, (atomic_swap_64 xoaddr:$ptr, i64:$new))]>; 235 } 236} 237 238// Instructions to support atomic operations 239let mayLoad = 1, hasSideEffects = 0 in { 240def LDARX : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr), 241 "ldarx $rD, $ptr", IIC_LdStLDARX, []>; 242 243// Instruction to support lock versions of atomics 244// (EH=1 - see Power ISA 2.07 Book II 4.4.2) 245def LDARXL : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr), 246 "ldarx $rD, $ptr, 1", IIC_LdStLDARX, []>, isDOT; 247 248let hasExtraDefRegAllocReq = 1 in 249def LDAT : X_RD5_RS5_IM5<31, 614, (outs g8rc:$rD), (ins g8rc:$rA, u5imm:$FC), 250 "ldat $rD, $rA, $FC", IIC_LdStLoad>, isPPC64, 251 Requires<[IsISA3_0]>; 252} 253 254let Defs = [CR0], mayStore = 1, hasSideEffects = 0 in 255def STDCX : XForm_1<31, 214, (outs), (ins g8rc:$rS, memrr:$dst), 256 "stdcx. $rS, $dst", IIC_LdStSTDCX, []>, isDOT; 257 258let mayStore = 1, hasSideEffects = 0 in 259def STDAT : X_RD5_RS5_IM5<31, 742, (outs), (ins g8rc:$rS, g8rc:$rA, u5imm:$FC), 260 "stdat $rS, $rA, $FC", IIC_LdStStore>, isPPC64, 261 Requires<[IsISA3_0]>; 262 263let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 264let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in 265def TCRETURNdi8 :Pseudo< (outs), 266 (ins calltarget:$dst, i32imm:$offset), 267 "#TC_RETURNd8 $dst $offset", 268 []>; 269 270let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in 271def TCRETURNai8 :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset), 272 "#TC_RETURNa8 $func $offset", 273 [(PPCtc_return (i64 imm:$func), imm:$offset)]>; 274 275let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in 276def TCRETURNri8 : Pseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset), 277 "#TC_RETURNr8 $dst $offset", 278 []>; 279 280let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1, 281 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in 282def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB, 283 []>, 284 Requires<[In64BitMode]>; 285 286let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, 287 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in 288def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst), 289 "b $dst", IIC_BrB, 290 []>; 291 292let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, 293 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in 294def TAILBA8 : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst), 295 "ba $dst", IIC_BrB, 296 []>; 297} // Interpretation64Bit 298 299def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm), 300 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>; 301 302def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm), 303 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>; 304 305def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm), 306 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>; 307 308 309// 64-bit CR instructions 310let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 311let hasSideEffects = 0 in { 312// mtocrf's input needs to be prepared by shifting by an amount dependent 313// on the cr register selected. Thus, post-ra anti-dep breaking must not 314// later change that register assignment. 315let hasExtraDefRegAllocReq = 1 in { 316def MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$ST), 317 "mtocrf $FXM, $ST", IIC_BrMCRX>, 318 PPC970_DGroup_First, PPC970_Unit_CRU; 319 320// Similarly to mtocrf, the mask for mtcrf must be prepared in a way that 321// is dependent on the cr fields being set. 322def MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$rS), 323 "mtcrf $FXM, $rS", IIC_BrMCRX>, 324 PPC970_MicroCode, PPC970_Unit_CRU; 325} // hasExtraDefRegAllocReq = 1 326 327// mfocrf's input needs to be prepared by shifting by an amount dependent 328// on the cr register selected. Thus, post-ra anti-dep breaking must not 329// later change that register assignment. 330let hasExtraSrcRegAllocReq = 1 in { 331def MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$rT), (ins crbitm:$FXM), 332 "mfocrf $rT, $FXM", IIC_SprMFCRF>, 333 PPC970_DGroup_First, PPC970_Unit_CRU; 334 335// Similarly to mfocrf, the mask for mfcrf must be prepared in a way that 336// is dependent on the cr fields being copied. 337def MFCR8 : XFXForm_3<31, 19, (outs g8rc:$rT), (ins), 338 "mfcr $rT", IIC_SprMFCR>, 339 PPC970_MicroCode, PPC970_Unit_CRU; 340} // hasExtraSrcRegAllocReq = 1 341} // hasSideEffects = 0 342 343let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in { 344 let Defs = [CTR8] in 345 def EH_SjLj_SetJmp64 : Pseudo<(outs gprc:$dst), (ins memr:$buf), 346 "#EH_SJLJ_SETJMP64", 347 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>, 348 Requires<[In64BitMode]>; 349 let isTerminator = 1 in 350 def EH_SjLj_LongJmp64 : Pseudo<(outs), (ins memr:$buf), 351 "#EH_SJLJ_LONGJMP64", 352 [(PPCeh_sjlj_longjmp addr:$buf)]>, 353 Requires<[In64BitMode]>; 354} 355 356def MFSPR8 : XFXForm_1<31, 339, (outs g8rc:$RT), (ins i32imm:$SPR), 357 "mfspr $RT, $SPR", IIC_SprMFSPR>; 358def MTSPR8 : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, g8rc:$RT), 359 "mtspr $SPR, $RT", IIC_SprMTSPR>; 360 361 362//===----------------------------------------------------------------------===// 363// 64-bit SPR manipulation instrs. 364 365let Uses = [CTR8] in { 366def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$rT), (ins), 367 "mfctr $rT", IIC_SprMFSPR>, 368 PPC970_DGroup_First, PPC970_Unit_FXU; 369} 370let Pattern = [(PPCmtctr i64:$rS)], Defs = [CTR8] in { 371def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS), 372 "mtctr $rS", IIC_SprMTSPR>, 373 PPC970_DGroup_First, PPC970_Unit_FXU; 374} 375let hasSideEffects = 1, Defs = [CTR8] in { 376let Pattern = [(int_ppc_mtctr i64:$rS)] in 377def MTCTR8loop : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS), 378 "mtctr $rS", IIC_SprMTSPR>, 379 PPC970_DGroup_First, PPC970_Unit_FXU; 380} 381 382let Pattern = [(set i64:$rT, readcyclecounter)] in 383def MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$rT), (ins), 384 "mfspr $rT, 268", IIC_SprMFTB>, 385 PPC970_DGroup_First, PPC970_Unit_FXU; 386// Note that encoding mftb using mfspr is now the preferred form, 387// and has been since at least ISA v2.03. The mftb instruction has 388// now been phased out. Using mfspr, however, is known not to work on 389// the POWER3. 390 391let Defs = [X1], Uses = [X1] in 392def DYNALLOC8 : Pseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8", 393 [(set i64:$result, 394 (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>; 395def DYNAREAOFFSET8 : Pseudo<(outs i64imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET8", 396 [(set i64:$result, (PPCdynareaoffset iaddr:$fpsi))]>; 397 398let Defs = [LR8] in { 399def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins g8rc:$rS), 400 "mtlr $rS", IIC_SprMTSPR>, 401 PPC970_DGroup_First, PPC970_Unit_FXU; 402} 403let Uses = [LR8] in { 404def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs g8rc:$rT), (ins), 405 "mflr $rT", IIC_SprMFSPR>, 406 PPC970_DGroup_First, PPC970_Unit_FXU; 407} 408} // Interpretation64Bit 409 410//===----------------------------------------------------------------------===// 411// Fixed point instructions. 412// 413 414let PPC970_Unit = 1 in { // FXU Operations. 415let Interpretation64Bit = 1 in { 416let hasSideEffects = 0 in { 417let isCodeGenOnly = 1 in { 418 419let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in { 420def LI8 : DForm_2_r0<14, (outs g8rc:$rD), (ins s16imm64:$imm), 421 "li $rD, $imm", IIC_IntSimple, 422 [(set i64:$rD, imm64SExt16:$imm)]>; 423def LIS8 : DForm_2_r0<15, (outs g8rc:$rD), (ins s17imm64:$imm), 424 "lis $rD, $imm", IIC_IntSimple, 425 [(set i64:$rD, imm16ShiftedSExt:$imm)]>; 426} 427 428// Logical ops. 429let isCommutable = 1 in { 430defm NAND8: XForm_6r<31, 476, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 431 "nand", "$rA, $rS, $rB", IIC_IntSimple, 432 [(set i64:$rA, (not (and i64:$rS, i64:$rB)))]>; 433defm AND8 : XForm_6r<31, 28, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 434 "and", "$rA, $rS, $rB", IIC_IntSimple, 435 [(set i64:$rA, (and i64:$rS, i64:$rB))]>; 436} // isCommutable 437defm ANDC8: XForm_6r<31, 60, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 438 "andc", "$rA, $rS, $rB", IIC_IntSimple, 439 [(set i64:$rA, (and i64:$rS, (not i64:$rB)))]>; 440let isCommutable = 1 in { 441defm OR8 : XForm_6r<31, 444, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 442 "or", "$rA, $rS, $rB", IIC_IntSimple, 443 [(set i64:$rA, (or i64:$rS, i64:$rB))]>; 444defm NOR8 : XForm_6r<31, 124, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 445 "nor", "$rA, $rS, $rB", IIC_IntSimple, 446 [(set i64:$rA, (not (or i64:$rS, i64:$rB)))]>; 447} // isCommutable 448defm ORC8 : XForm_6r<31, 412, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 449 "orc", "$rA, $rS, $rB", IIC_IntSimple, 450 [(set i64:$rA, (or i64:$rS, (not i64:$rB)))]>; 451let isCommutable = 1 in { 452defm EQV8 : XForm_6r<31, 284, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 453 "eqv", "$rA, $rS, $rB", IIC_IntSimple, 454 [(set i64:$rA, (not (xor i64:$rS, i64:$rB)))]>; 455defm XOR8 : XForm_6r<31, 316, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 456 "xor", "$rA, $rS, $rB", IIC_IntSimple, 457 [(set i64:$rA, (xor i64:$rS, i64:$rB))]>; 458} // let isCommutable = 1 459 460// Logical ops with immediate. 461let Defs = [CR0] in { 462def ANDIo8 : DForm_4<28, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2), 463 "andi. $dst, $src1, $src2", IIC_IntGeneral, 464 [(set i64:$dst, (and i64:$src1, immZExt16:$src2))]>, 465 isDOT; 466def ANDISo8 : DForm_4<29, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2), 467 "andis. $dst, $src1, $src2", IIC_IntGeneral, 468 [(set i64:$dst, (and i64:$src1, imm16ShiftedZExt:$src2))]>, 469 isDOT; 470} 471def ORI8 : DForm_4<24, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2), 472 "ori $dst, $src1, $src2", IIC_IntSimple, 473 [(set i64:$dst, (or i64:$src1, immZExt16:$src2))]>; 474def ORIS8 : DForm_4<25, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2), 475 "oris $dst, $src1, $src2", IIC_IntSimple, 476 [(set i64:$dst, (or i64:$src1, imm16ShiftedZExt:$src2))]>; 477def XORI8 : DForm_4<26, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2), 478 "xori $dst, $src1, $src2", IIC_IntSimple, 479 [(set i64:$dst, (xor i64:$src1, immZExt16:$src2))]>; 480def XORIS8 : DForm_4<27, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2), 481 "xoris $dst, $src1, $src2", IIC_IntSimple, 482 [(set i64:$dst, (xor i64:$src1, imm16ShiftedZExt:$src2))]>; 483 484let isCommutable = 1 in 485defm ADD8 : XOForm_1r<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 486 "add", "$rT, $rA, $rB", IIC_IntSimple, 487 [(set i64:$rT, (add i64:$rA, i64:$rB))]>; 488// ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the 489// initial-exec thread-local storage model. We need to forbid r0 here - 490// while it works for add just fine, the linker can relax this to local-exec 491// addi, which won't work for r0. 492def ADD8TLS : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc_nox0:$rA, tlsreg:$rB), 493 "add $rT, $rA, $rB", IIC_IntSimple, 494 [(set i64:$rT, (add i64:$rA, tglobaltlsaddr:$rB))]>; 495 496let isCommutable = 1 in 497defm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 498 "addc", "$rT, $rA, $rB", IIC_IntGeneral, 499 [(set i64:$rT, (addc i64:$rA, i64:$rB))]>, 500 PPC970_DGroup_Cracked; 501 502let Defs = [CARRY] in 503def ADDIC8 : DForm_2<12, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm), 504 "addic $rD, $rA, $imm", IIC_IntGeneral, 505 [(set i64:$rD, (addc i64:$rA, imm64SExt16:$imm))]>; 506def ADDI8 : DForm_2<14, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s16imm64:$imm), 507 "addi $rD, $rA, $imm", IIC_IntSimple, 508 [(set i64:$rD, (add i64:$rA, imm64SExt16:$imm))]>; 509def ADDIS8 : DForm_2<15, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s17imm64:$imm), 510 "addis $rD, $rA, $imm", IIC_IntSimple, 511 [(set i64:$rD, (add i64:$rA, imm16ShiftedSExt:$imm))]>; 512 513let Defs = [CARRY] in { 514def SUBFIC8: DForm_2< 8, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm), 515 "subfic $rD, $rA, $imm", IIC_IntGeneral, 516 [(set i64:$rD, (subc imm64SExt16:$imm, i64:$rA))]>; 517} 518defm SUBFC8 : XOForm_1rc<31, 8, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 519 "subfc", "$rT, $rA, $rB", IIC_IntGeneral, 520 [(set i64:$rT, (subc i64:$rB, i64:$rA))]>, 521 PPC970_DGroup_Cracked; 522defm SUBF8 : XOForm_1r<31, 40, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 523 "subf", "$rT, $rA, $rB", IIC_IntGeneral, 524 [(set i64:$rT, (sub i64:$rB, i64:$rA))]>; 525defm NEG8 : XOForm_3r<31, 104, 0, (outs g8rc:$rT), (ins g8rc:$rA), 526 "neg", "$rT, $rA", IIC_IntSimple, 527 [(set i64:$rT, (ineg i64:$rA))]>; 528let Uses = [CARRY] in { 529let isCommutable = 1 in 530defm ADDE8 : XOForm_1rc<31, 138, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 531 "adde", "$rT, $rA, $rB", IIC_IntGeneral, 532 [(set i64:$rT, (adde i64:$rA, i64:$rB))]>; 533defm ADDME8 : XOForm_3rc<31, 234, 0, (outs g8rc:$rT), (ins g8rc:$rA), 534 "addme", "$rT, $rA", IIC_IntGeneral, 535 [(set i64:$rT, (adde i64:$rA, -1))]>; 536defm ADDZE8 : XOForm_3rc<31, 202, 0, (outs g8rc:$rT), (ins g8rc:$rA), 537 "addze", "$rT, $rA", IIC_IntGeneral, 538 [(set i64:$rT, (adde i64:$rA, 0))]>; 539defm SUBFE8 : XOForm_1rc<31, 136, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 540 "subfe", "$rT, $rA, $rB", IIC_IntGeneral, 541 [(set i64:$rT, (sube i64:$rB, i64:$rA))]>; 542defm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$rT), (ins g8rc:$rA), 543 "subfme", "$rT, $rA", IIC_IntGeneral, 544 [(set i64:$rT, (sube -1, i64:$rA))]>; 545defm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$rT), (ins g8rc:$rA), 546 "subfze", "$rT, $rA", IIC_IntGeneral, 547 [(set i64:$rT, (sube 0, i64:$rA))]>; 548} 549} // isCodeGenOnly 550 551// FIXME: Duplicating this for the asm parser should be unnecessary, but the 552// previous definition must be marked as CodeGen only to prevent decoding 553// conflicts. 554let isAsmParserOnly = 1 in 555def ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB), 556 "add $rT, $rA, $rB", IIC_IntSimple, []>; 557 558let isCommutable = 1 in { 559defm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 560 "mulhd", "$rT, $rA, $rB", IIC_IntMulHW, 561 [(set i64:$rT, (mulhs i64:$rA, i64:$rB))]>; 562defm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 563 "mulhdu", "$rT, $rA, $rB", IIC_IntMulHWU, 564 [(set i64:$rT, (mulhu i64:$rA, i64:$rB))]>; 565} // isCommutable 566} 567} // Interpretation64Bit 568 569let isCompare = 1, hasSideEffects = 0 in { 570 def CMPD : XForm_16_ext<31, 0, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB), 571 "cmpd $crD, $rA, $rB", IIC_IntCompare>, isPPC64; 572 def CMPLD : XForm_16_ext<31, 32, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB), 573 "cmpld $crD, $rA, $rB", IIC_IntCompare>, isPPC64; 574 def CMPDI : DForm_5_ext<11, (outs crrc:$crD), (ins g8rc:$rA, s16imm64:$imm), 575 "cmpdi $crD, $rA, $imm", IIC_IntCompare>, isPPC64; 576 def CMPLDI : DForm_6_ext<10, (outs crrc:$dst), (ins g8rc:$src1, u16imm64:$src2), 577 "cmpldi $dst, $src1, $src2", 578 IIC_IntCompare>, isPPC64; 579 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 580 def CMPRB8 : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF), 581 (ins u1imm:$L, g8rc:$rA, g8rc:$rB), 582 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>, 583 Requires<[IsISA3_0]>; 584 def CMPEQB : X_BF3_RS5_RS5<31, 224, (outs crbitrc:$BF), 585 (ins g8rc:$rA, g8rc:$rB), "cmpeqb $BF, $rA, $rB", 586 IIC_IntCompare, []>, Requires<[IsISA3_0]>; 587} 588 589let hasSideEffects = 0 in { 590defm SLD : XForm_6r<31, 27, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB), 591 "sld", "$rA, $rS, $rB", IIC_IntRotateD, 592 [(set i64:$rA, (PPCshl i64:$rS, i32:$rB))]>, isPPC64; 593defm SRD : XForm_6r<31, 539, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB), 594 "srd", "$rA, $rS, $rB", IIC_IntRotateD, 595 [(set i64:$rA, (PPCsrl i64:$rS, i32:$rB))]>, isPPC64; 596defm SRAD : XForm_6rc<31, 794, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB), 597 "srad", "$rA, $rS, $rB", IIC_IntRotateD, 598 [(set i64:$rA, (PPCsra i64:$rS, i32:$rB))]>, isPPC64; 599 600let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 601defm CNTLZW8 : XForm_11r<31, 26, (outs g8rc:$rA), (ins g8rc:$rS), 602 "cntlzw", "$rA, $rS", IIC_IntGeneral, []>; 603defm CNTTZW8 : XForm_11r<31, 538, (outs g8rc:$rA), (ins g8rc:$rS), 604 "cnttzw", "$rA, $rS", IIC_IntGeneral, []>, 605 Requires<[IsISA3_0]>; 606 607defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$rA), (ins g8rc:$rS), 608 "extsb", "$rA, $rS", IIC_IntSimple, 609 [(set i64:$rA, (sext_inreg i64:$rS, i8))]>; 610defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$rA), (ins g8rc:$rS), 611 "extsh", "$rA, $rS", IIC_IntSimple, 612 [(set i64:$rA, (sext_inreg i64:$rS, i16))]>; 613 614defm SLW8 : XForm_6r<31, 24, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 615 "slw", "$rA, $rS, $rB", IIC_IntGeneral, []>; 616defm SRW8 : XForm_6r<31, 536, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 617 "srw", "$rA, $rS, $rB", IIC_IntGeneral, []>; 618} // Interpretation64Bit 619 620// For fast-isel: 621let isCodeGenOnly = 1 in { 622def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$rA), (ins gprc:$rS), 623 "extsb $rA, $rS", IIC_IntSimple, []>, isPPC64; 624def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$rA), (ins gprc:$rS), 625 "extsh $rA, $rS", IIC_IntSimple, []>, isPPC64; 626} // isCodeGenOnly for fast-isel 627 628defm EXTSW : XForm_11r<31, 986, (outs g8rc:$rA), (ins g8rc:$rS), 629 "extsw", "$rA, $rS", IIC_IntSimple, 630 [(set i64:$rA, (sext_inreg i64:$rS, i32))]>, isPPC64; 631let Interpretation64Bit = 1, isCodeGenOnly = 1 in 632defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$rA), (ins gprc:$rS), 633 "extsw", "$rA, $rS", IIC_IntSimple, 634 [(set i64:$rA, (sext i32:$rS))]>, isPPC64; 635 636defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH), 637 "sradi", "$rA, $rS, $SH", IIC_IntRotateDI, 638 [(set i64:$rA, (sra i64:$rS, (i32 imm:$SH)))]>, isPPC64; 639defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$rA), (ins g8rc:$rS), 640 "cntlzd", "$rA, $rS", IIC_IntGeneral, 641 [(set i64:$rA, (ctlz i64:$rS))]>; 642defm CNTTZD : XForm_11r<31, 570, (outs g8rc:$rA), (ins g8rc:$rS), 643 "cnttzd", "$rA, $rS", IIC_IntGeneral, 644 [(set i64:$rA, (cttz i64:$rS))]>, Requires<[IsISA3_0]>; 645def POPCNTD : XForm_11<31, 506, (outs g8rc:$rA), (ins g8rc:$rS), 646 "popcntd $rA, $rS", IIC_IntGeneral, 647 [(set i64:$rA, (ctpop i64:$rS))]>; 648def BPERMD : XForm_6<31, 252, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 649 "bpermd $rA, $rS, $rB", IIC_IntGeneral, 650 [(set i64:$rA, (int_ppc_bpermd g8rc:$rS, g8rc:$rB))]>, 651 isPPC64, Requires<[HasBPERMD]>; 652 653let isCodeGenOnly = 1, isCommutable = 1 in 654def CMPB8 : XForm_6<31, 508, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB), 655 "cmpb $rA, $rS, $rB", IIC_IntGeneral, 656 [(set i64:$rA, (PPCcmpb i64:$rS, i64:$rB))]>; 657 658// popcntw also does a population count on the high 32 bits (storing the 659// results in the high 32-bits of the output). We'll ignore that here (which is 660// safe because we never separately use the high part of the 64-bit registers). 661def POPCNTW : XForm_11<31, 378, (outs gprc:$rA), (ins gprc:$rS), 662 "popcntw $rA, $rS", IIC_IntGeneral, 663 [(set i32:$rA, (ctpop i32:$rS))]>; 664 665defm DIVD : XOForm_1rcr<31, 489, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 666 "divd", "$rT, $rA, $rB", IIC_IntDivD, 667 [(set i64:$rT, (sdiv i64:$rA, i64:$rB))]>, isPPC64; 668defm DIVDU : XOForm_1rcr<31, 457, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 669 "divdu", "$rT, $rA, $rB", IIC_IntDivD, 670 [(set i64:$rT, (udiv i64:$rA, i64:$rB))]>, isPPC64; 671def DIVDE : XOForm_1<31, 425, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 672 "divde $rT, $rA, $rB", IIC_IntDivD, 673 [(set i64:$rT, (int_ppc_divde g8rc:$rA, g8rc:$rB))]>, 674 isPPC64, Requires<[HasExtDiv]>; 675let Defs = [CR0] in 676def DIVDEo : XOForm_1<31, 425, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 677 "divde. $rT, $rA, $rB", IIC_IntDivD, 678 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First, 679 isPPC64, Requires<[HasExtDiv]>; 680def DIVDEU : XOForm_1<31, 393, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 681 "divdeu $rT, $rA, $rB", IIC_IntDivD, 682 [(set i64:$rT, (int_ppc_divdeu g8rc:$rA, g8rc:$rB))]>, 683 isPPC64, Requires<[HasExtDiv]>; 684let Defs = [CR0] in 685def DIVDEUo : XOForm_1<31, 393, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 686 "divdeu. $rT, $rA, $rB", IIC_IntDivD, 687 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First, 688 isPPC64, Requires<[HasExtDiv]>; 689let isCommutable = 1 in 690defm MULLD : XOForm_1r<31, 233, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB), 691 "mulld", "$rT, $rA, $rB", IIC_IntMulHD, 692 [(set i64:$rT, (mul i64:$rA, i64:$rB))]>, isPPC64; 693let Interpretation64Bit = 1, isCodeGenOnly = 1 in 694def MULLI8 : DForm_2<7, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm), 695 "mulli $rD, $rA, $imm", IIC_IntMulLI, 696 [(set i64:$rD, (mul i64:$rA, imm64SExt16:$imm))]>; 697} 698 699let hasSideEffects = 0 in { 700defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$rA), 701 (ins g8rc:$rSi, g8rc:$rS, u6imm:$SH, u6imm:$MBE), 702 "rldimi", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI, 703 []>, isPPC64, RegConstraint<"$rSi = $rA">, 704 NoEncode<"$rSi">; 705 706// Rotate instructions. 707defm RLDCL : MDSForm_1r<30, 8, 708 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE), 709 "rldcl", "$rA, $rS, $rB, $MBE", IIC_IntRotateD, 710 []>, isPPC64; 711defm RLDCR : MDSForm_1r<30, 9, 712 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE), 713 "rldcr", "$rA, $rS, $rB, $MBE", IIC_IntRotateD, 714 []>, isPPC64; 715defm RLDICL : MDForm_1r<30, 0, 716 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE), 717 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI, 718 []>, isPPC64; 719// For fast-isel: 720let isCodeGenOnly = 1 in 721def RLDICL_32_64 : MDForm_1<30, 0, 722 (outs g8rc:$rA), 723 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE), 724 "rldicl $rA, $rS, $SH, $MBE", IIC_IntRotateDI, 725 []>, isPPC64; 726// End fast-isel. 727defm RLDICR : MDForm_1r<30, 1, 728 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE), 729 "rldicr", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI, 730 []>, isPPC64; 731defm RLDIC : MDForm_1r<30, 2, 732 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE), 733 "rldic", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI, 734 []>, isPPC64; 735 736let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 737defm RLWINM8 : MForm_2r<21, (outs g8rc:$rA), 738 (ins g8rc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME), 739 "rlwinm", "$rA, $rS, $SH, $MB, $ME", IIC_IntGeneral, 740 []>; 741 742defm RLWNM8 : MForm_2r<23, (outs g8rc:$rA), 743 (ins g8rc:$rS, g8rc:$rB, u5imm:$MB, u5imm:$ME), 744 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral, 745 []>; 746 747// RLWIMI can be commuted if the rotate amount is zero. 748let Interpretation64Bit = 1, isCodeGenOnly = 1 in 749defm RLWIMI8 : MForm_2r<20, (outs g8rc:$rA), 750 (ins g8rc:$rSi, g8rc:$rS, u5imm:$SH, u5imm:$MB, 751 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME", 752 IIC_IntRotate, []>, PPC970_DGroup_Cracked, 753 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">; 754 755let isSelect = 1 in 756def ISEL8 : AForm_4<31, 15, 757 (outs g8rc:$rT), (ins g8rc_nox0:$rA, g8rc:$rB, crbitrc:$cond), 758 "isel $rT, $rA, $rB, $cond", IIC_IntISEL, 759 []>; 760} // Interpretation64Bit 761} // hasSideEffects = 0 762} // End FXU Operations. 763 764 765//===----------------------------------------------------------------------===// 766// Load/Store instructions. 767// 768 769 770// Sign extending loads. 771let PPC970_Unit = 2 in { 772let Interpretation64Bit = 1, isCodeGenOnly = 1 in 773def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src), 774 "lha $rD, $src", IIC_LdStLHA, 775 [(set i64:$rD, (sextloadi16 iaddr:$src))]>, 776 PPC970_DGroup_Cracked; 777def LWA : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src), 778 "lwa $rD, $src", IIC_LdStLWA, 779 [(set i64:$rD, 780 (aligned4sextloadi32 ixaddr:$src))]>, isPPC64, 781 PPC970_DGroup_Cracked; 782let Interpretation64Bit = 1, isCodeGenOnly = 1 in 783def LHAX8: XForm_1<31, 343, (outs g8rc:$rD), (ins memrr:$src), 784 "lhax $rD, $src", IIC_LdStLHA, 785 [(set i64:$rD, (sextloadi16 xaddr:$src))]>, 786 PPC970_DGroup_Cracked; 787def LWAX : XForm_1<31, 341, (outs g8rc:$rD), (ins memrr:$src), 788 "lwax $rD, $src", IIC_LdStLHA, 789 [(set i64:$rD, (sextloadi32 xaddr:$src))]>, isPPC64, 790 PPC970_DGroup_Cracked; 791// For fast-isel: 792let isCodeGenOnly = 1, mayLoad = 1 in { 793def LWA_32 : DSForm_1<58, 2, (outs gprc:$rD), (ins memrix:$src), 794 "lwa $rD, $src", IIC_LdStLWA, []>, isPPC64, 795 PPC970_DGroup_Cracked; 796def LWAX_32 : XForm_1<31, 341, (outs gprc:$rD), (ins memrr:$src), 797 "lwax $rD, $src", IIC_LdStLHA, []>, isPPC64, 798 PPC970_DGroup_Cracked; 799} // end fast-isel isCodeGenOnly 800 801// Update forms. 802let mayLoad = 1, hasSideEffects = 0 in { 803let Interpretation64Bit = 1, isCodeGenOnly = 1 in 804def LHAU8 : DForm_1<43, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), 805 (ins memri:$addr), 806 "lhau $rD, $addr", IIC_LdStLHAU, 807 []>, RegConstraint<"$addr.reg = $ea_result">, 808 NoEncode<"$ea_result">; 809// NO LWAU! 810 811let Interpretation64Bit = 1, isCodeGenOnly = 1 in 812def LHAUX8 : XForm_1<31, 375, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), 813 (ins memrr:$addr), 814 "lhaux $rD, $addr", IIC_LdStLHAUX, 815 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 816 NoEncode<"$ea_result">; 817def LWAUX : XForm_1<31, 373, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), 818 (ins memrr:$addr), 819 "lwaux $rD, $addr", IIC_LdStLHAUX, 820 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 821 NoEncode<"$ea_result">, isPPC64; 822} 823} 824 825let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 826// Zero extending loads. 827let PPC970_Unit = 2 in { 828def LBZ8 : DForm_1<34, (outs g8rc:$rD), (ins memri:$src), 829 "lbz $rD, $src", IIC_LdStLoad, 830 [(set i64:$rD, (zextloadi8 iaddr:$src))]>; 831def LHZ8 : DForm_1<40, (outs g8rc:$rD), (ins memri:$src), 832 "lhz $rD, $src", IIC_LdStLoad, 833 [(set i64:$rD, (zextloadi16 iaddr:$src))]>; 834def LWZ8 : DForm_1<32, (outs g8rc:$rD), (ins memri:$src), 835 "lwz $rD, $src", IIC_LdStLoad, 836 [(set i64:$rD, (zextloadi32 iaddr:$src))]>, isPPC64; 837 838def LBZX8 : XForm_1<31, 87, (outs g8rc:$rD), (ins memrr:$src), 839 "lbzx $rD, $src", IIC_LdStLoad, 840 [(set i64:$rD, (zextloadi8 xaddr:$src))]>; 841def LHZX8 : XForm_1<31, 279, (outs g8rc:$rD), (ins memrr:$src), 842 "lhzx $rD, $src", IIC_LdStLoad, 843 [(set i64:$rD, (zextloadi16 xaddr:$src))]>; 844def LWZX8 : XForm_1<31, 23, (outs g8rc:$rD), (ins memrr:$src), 845 "lwzx $rD, $src", IIC_LdStLoad, 846 [(set i64:$rD, (zextloadi32 xaddr:$src))]>; 847 848 849// Update forms. 850let mayLoad = 1, hasSideEffects = 0 in { 851def LBZU8 : DForm_1<35, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 852 "lbzu $rD, $addr", IIC_LdStLoadUpd, 853 []>, RegConstraint<"$addr.reg = $ea_result">, 854 NoEncode<"$ea_result">; 855def LHZU8 : DForm_1<41, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 856 "lhzu $rD, $addr", IIC_LdStLoadUpd, 857 []>, RegConstraint<"$addr.reg = $ea_result">, 858 NoEncode<"$ea_result">; 859def LWZU8 : DForm_1<33, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 860 "lwzu $rD, $addr", IIC_LdStLoadUpd, 861 []>, RegConstraint<"$addr.reg = $ea_result">, 862 NoEncode<"$ea_result">; 863 864def LBZUX8 : XForm_1<31, 119, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), 865 (ins memrr:$addr), 866 "lbzux $rD, $addr", IIC_LdStLoadUpdX, 867 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 868 NoEncode<"$ea_result">; 869def LHZUX8 : XForm_1<31, 311, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), 870 (ins memrr:$addr), 871 "lhzux $rD, $addr", IIC_LdStLoadUpdX, 872 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 873 NoEncode<"$ea_result">; 874def LWZUX8 : XForm_1<31, 55, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), 875 (ins memrr:$addr), 876 "lwzux $rD, $addr", IIC_LdStLoadUpdX, 877 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 878 NoEncode<"$ea_result">; 879} 880} 881} // Interpretation64Bit 882 883 884// Full 8-byte loads. 885let PPC970_Unit = 2 in { 886def LD : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src), 887 "ld $rD, $src", IIC_LdStLD, 888 [(set i64:$rD, (aligned4load ixaddr:$src))]>, isPPC64; 889// The following four definitions are selected for small code model only. 890// Otherwise, we need to create two instructions to form a 32-bit offset, 891// so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select(). 892def LDtoc: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg), 893 "#LDtoc", 894 [(set i64:$rD, 895 (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64; 896def LDtocJTI: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg), 897 "#LDtocJTI", 898 [(set i64:$rD, 899 (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64; 900def LDtocCPT: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg), 901 "#LDtocCPT", 902 [(set i64:$rD, 903 (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64; 904def LDtocBA: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg), 905 "#LDtocCPT", 906 [(set i64:$rD, 907 (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64; 908 909def LDX : XForm_1<31, 21, (outs g8rc:$rD), (ins memrr:$src), 910 "ldx $rD, $src", IIC_LdStLD, 911 [(set i64:$rD, (load xaddr:$src))]>, isPPC64; 912def LDBRX : XForm_1<31, 532, (outs g8rc:$rD), (ins memrr:$src), 913 "ldbrx $rD, $src", IIC_LdStLoad, 914 [(set i64:$rD, (PPClbrx xoaddr:$src, i64))]>, isPPC64; 915 916let mayLoad = 1, hasSideEffects = 0, isCodeGenOnly = 1 in { 917def LHBRX8 : XForm_1<31, 790, (outs g8rc:$rD), (ins memrr:$src), 918 "lhbrx $rD, $src", IIC_LdStLoad, []>; 919def LWBRX8 : XForm_1<31, 534, (outs g8rc:$rD), (ins memrr:$src), 920 "lwbrx $rD, $src", IIC_LdStLoad, []>; 921} 922 923let mayLoad = 1, hasSideEffects = 0 in { 924def LDU : DSForm_1<58, 1, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memrix:$addr), 925 "ldu $rD, $addr", IIC_LdStLDU, 926 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64, 927 NoEncode<"$ea_result">; 928 929def LDUX : XForm_1<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), 930 (ins memrr:$addr), 931 "ldux $rD, $addr", IIC_LdStLDUX, 932 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 933 NoEncode<"$ea_result">, isPPC64; 934 935def LDMX : XForm_1<31, 309, (outs g8rc:$rD), (ins memrr:$src), 936 "ldmx $rD, $src", IIC_LdStLD, []>, isPPC64, 937 Requires<[IsISA3_0]>; 938} 939} 940 941// Support for medium and large code model. 942let hasSideEffects = 0 in { 943def ADDIStocHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp), 944 "#ADDIStocHA", []>, isPPC64; 945let mayLoad = 1 in 946def LDtocL: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg), 947 "#LDtocL", []>, isPPC64; 948def ADDItocL: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp), 949 "#ADDItocL", []>, isPPC64; 950} 951 952// Support for thread-local storage. 953def ADDISgotTprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp), 954 "#ADDISgotTprelHA", 955 [(set i64:$rD, 956 (PPCaddisGotTprelHA i64:$reg, 957 tglobaltlsaddr:$disp))]>, 958 isPPC64; 959def LDgotTprelL: Pseudo<(outs g8rc:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg), 960 "#LDgotTprelL", 961 [(set i64:$rD, 962 (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>, 963 isPPC64; 964def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g), 965 (ADD8TLS $in, tglobaltlsaddr:$g)>; 966def ADDIStlsgdHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp), 967 "#ADDIStlsgdHA", 968 [(set i64:$rD, 969 (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>, 970 isPPC64; 971def ADDItlsgdL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp), 972 "#ADDItlsgdL", 973 [(set i64:$rD, 974 (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>, 975 isPPC64; 976// LR8 is a true define, while the rest of the Defs are clobbers. X3 is 977// explicitly defined when this op is created, so not mentioned here. 978let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 979 Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in 980def GETtlsADDR : Pseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym), 981 "#GETtlsADDR", 982 [(set i64:$rD, 983 (PPCgetTlsAddr i64:$reg, tglobaltlsaddr:$sym))]>, 984 isPPC64; 985// Combined op for ADDItlsgdL and GETtlsADDR, late expanded. X3 and LR8 986// are true defines while the rest of the Defs are clobbers. 987let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 988 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] 989 in 990def ADDItlsgdLADDR : Pseudo<(outs g8rc:$rD), 991 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym), 992 "#ADDItlsgdLADDR", 993 [(set i64:$rD, 994 (PPCaddiTlsgdLAddr i64:$reg, 995 tglobaltlsaddr:$disp, 996 tglobaltlsaddr:$sym))]>, 997 isPPC64; 998def ADDIStlsldHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp), 999 "#ADDIStlsldHA", 1000 [(set i64:$rD, 1001 (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>, 1002 isPPC64; 1003def ADDItlsldL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp), 1004 "#ADDItlsldL", 1005 [(set i64:$rD, 1006 (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>, 1007 isPPC64; 1008// LR8 is a true define, while the rest of the Defs are clobbers. X3 is 1009// explicitly defined when this op is created, so not mentioned here. 1010let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 1011 Defs = [X0,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] in 1012def GETtlsldADDR : Pseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym), 1013 "#GETtlsldADDR", 1014 [(set i64:$rD, 1015 (PPCgetTlsldAddr i64:$reg, tglobaltlsaddr:$sym))]>, 1016 isPPC64; 1017// Combined op for ADDItlsldL and GETtlsADDR, late expanded. X3 and LR8 1018// are true defines, while the rest of the Defs are clobbers. 1019let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 1020 Defs = [X0,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,LR8,CTR8,CR0,CR1,CR5,CR6,CR7] 1021 in 1022def ADDItlsldLADDR : Pseudo<(outs g8rc:$rD), 1023 (ins g8rc_nox0:$reg, s16imm64:$disp, tlsgd:$sym), 1024 "#ADDItlsldLADDR", 1025 [(set i64:$rD, 1026 (PPCaddiTlsldLAddr i64:$reg, 1027 tglobaltlsaddr:$disp, 1028 tglobaltlsaddr:$sym))]>, 1029 isPPC64; 1030def ADDISdtprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp), 1031 "#ADDISdtprelHA", 1032 [(set i64:$rD, 1033 (PPCaddisDtprelHA i64:$reg, 1034 tglobaltlsaddr:$disp))]>, 1035 isPPC64; 1036def ADDIdtprelL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp), 1037 "#ADDIdtprelL", 1038 [(set i64:$rD, 1039 (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>, 1040 isPPC64; 1041 1042let PPC970_Unit = 2 in { 1043let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 1044// Truncating stores. 1045def STB8 : DForm_1<38, (outs), (ins g8rc:$rS, memri:$src), 1046 "stb $rS, $src", IIC_LdStStore, 1047 [(truncstorei8 i64:$rS, iaddr:$src)]>; 1048def STH8 : DForm_1<44, (outs), (ins g8rc:$rS, memri:$src), 1049 "sth $rS, $src", IIC_LdStStore, 1050 [(truncstorei16 i64:$rS, iaddr:$src)]>; 1051def STW8 : DForm_1<36, (outs), (ins g8rc:$rS, memri:$src), 1052 "stw $rS, $src", IIC_LdStStore, 1053 [(truncstorei32 i64:$rS, iaddr:$src)]>; 1054def STBX8 : XForm_8<31, 215, (outs), (ins g8rc:$rS, memrr:$dst), 1055 "stbx $rS, $dst", IIC_LdStStore, 1056 [(truncstorei8 i64:$rS, xaddr:$dst)]>, 1057 PPC970_DGroup_Cracked; 1058def STHX8 : XForm_8<31, 407, (outs), (ins g8rc:$rS, memrr:$dst), 1059 "sthx $rS, $dst", IIC_LdStStore, 1060 [(truncstorei16 i64:$rS, xaddr:$dst)]>, 1061 PPC970_DGroup_Cracked; 1062def STWX8 : XForm_8<31, 151, (outs), (ins g8rc:$rS, memrr:$dst), 1063 "stwx $rS, $dst", IIC_LdStStore, 1064 [(truncstorei32 i64:$rS, xaddr:$dst)]>, 1065 PPC970_DGroup_Cracked; 1066} // Interpretation64Bit 1067 1068// Normal 8-byte stores. 1069def STD : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst), 1070 "std $rS, $dst", IIC_LdStSTD, 1071 [(aligned4store i64:$rS, ixaddr:$dst)]>, isPPC64; 1072def STDX : XForm_8<31, 149, (outs), (ins g8rc:$rS, memrr:$dst), 1073 "stdx $rS, $dst", IIC_LdStSTD, 1074 [(store i64:$rS, xaddr:$dst)]>, isPPC64, 1075 PPC970_DGroup_Cracked; 1076def STDBRX: XForm_8<31, 660, (outs), (ins g8rc:$rS, memrr:$dst), 1077 "stdbrx $rS, $dst", IIC_LdStStore, 1078 [(PPCstbrx i64:$rS, xoaddr:$dst, i64)]>, isPPC64, 1079 PPC970_DGroup_Cracked; 1080} 1081 1082// Stores with Update (pre-inc). 1083let PPC970_Unit = 2, mayStore = 1 in { 1084let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 1085def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst), 1086 "stbu $rS, $dst", IIC_LdStStoreUpd, []>, 1087 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 1088def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst), 1089 "sthu $rS, $dst", IIC_LdStStoreUpd, []>, 1090 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 1091def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst), 1092 "stwu $rS, $dst", IIC_LdStStoreUpd, []>, 1093 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 1094 1095def STBUX8: XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst), 1096 "stbux $rS, $dst", IIC_LdStStoreUpd, []>, 1097 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">, 1098 PPC970_DGroup_Cracked; 1099def STHUX8: XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst), 1100 "sthux $rS, $dst", IIC_LdStStoreUpd, []>, 1101 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">, 1102 PPC970_DGroup_Cracked; 1103def STWUX8: XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst), 1104 "stwux $rS, $dst", IIC_LdStStoreUpd, []>, 1105 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">, 1106 PPC970_DGroup_Cracked; 1107} // Interpretation64Bit 1108 1109def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrix:$dst), 1110 "stdu $rS, $dst", IIC_LdStSTDU, []>, 1111 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">, 1112 isPPC64; 1113 1114def STDUX : XForm_8<31, 181, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst), 1115 "stdux $rS, $dst", IIC_LdStSTDUX, []>, 1116 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">, 1117 PPC970_DGroup_Cracked, isPPC64; 1118} 1119 1120// Patterns to match the pre-inc stores. We can't put the patterns on 1121// the instruction definitions directly as ISel wants the address base 1122// and offset to be separate operands, not a single complex operand. 1123def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 1124 (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>; 1125def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 1126 (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>; 1127def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 1128 (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>; 1129def : Pat<(aligned4pre_store i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 1130 (STDU $rS, iaddroff:$ptroff, $ptrreg)>; 1131 1132def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff), 1133 (STBUX8 $rS, $ptrreg, $ptroff)>; 1134def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff), 1135 (STHUX8 $rS, $ptrreg, $ptroff)>; 1136def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff), 1137 (STWUX8 $rS, $ptrreg, $ptroff)>; 1138def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff), 1139 (STDUX $rS, $ptrreg, $ptroff)>; 1140 1141 1142//===----------------------------------------------------------------------===// 1143// Floating point instructions. 1144// 1145 1146 1147let PPC970_Unit = 3, hasSideEffects = 0, 1148 Uses = [RM] in { // FPU Operations. 1149defm FCFID : XForm_26r<63, 846, (outs f8rc:$frD), (ins f8rc:$frB), 1150 "fcfid", "$frD, $frB", IIC_FPGeneral, 1151 [(set f64:$frD, (PPCfcfid f64:$frB))]>, isPPC64; 1152defm FCTID : XForm_26r<63, 814, (outs f8rc:$frD), (ins f8rc:$frB), 1153 "fctid", "$frD, $frB", IIC_FPGeneral, 1154 []>, isPPC64; 1155defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$frD), (ins f8rc:$frB), 1156 "fctidz", "$frD, $frB", IIC_FPGeneral, 1157 [(set f64:$frD, (PPCfctidz f64:$frB))]>, isPPC64; 1158 1159defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$frD), (ins f8rc:$frB), 1160 "fcfidu", "$frD, $frB", IIC_FPGeneral, 1161 [(set f64:$frD, (PPCfcfidu f64:$frB))]>, isPPC64; 1162defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$frD), (ins f8rc:$frB), 1163 "fcfids", "$frD, $frB", IIC_FPGeneral, 1164 [(set f32:$frD, (PPCfcfids f64:$frB))]>, isPPC64; 1165defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$frD), (ins f8rc:$frB), 1166 "fcfidus", "$frD, $frB", IIC_FPGeneral, 1167 [(set f32:$frD, (PPCfcfidus f64:$frB))]>, isPPC64; 1168defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$frD), (ins f8rc:$frB), 1169 "fctiduz", "$frD, $frB", IIC_FPGeneral, 1170 [(set f64:$frD, (PPCfctiduz f64:$frB))]>, isPPC64; 1171defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$frD), (ins f8rc:$frB), 1172 "fctiwuz", "$frD, $frB", IIC_FPGeneral, 1173 [(set f64:$frD, (PPCfctiwuz f64:$frB))]>, isPPC64; 1174} 1175 1176 1177//===----------------------------------------------------------------------===// 1178// Instruction Patterns 1179// 1180 1181// Extensions and truncates to/from 32-bit regs. 1182def : Pat<(i64 (zext i32:$in)), 1183 (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32), 1184 0, 32)>; 1185def : Pat<(i64 (anyext i32:$in)), 1186 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>; 1187def : Pat<(i32 (trunc i64:$in)), 1188 (EXTRACT_SUBREG $in, sub_32)>; 1189 1190// Implement the 'not' operation with the NOR instruction. 1191// (we could use the default xori pattern, but nor has lower latency on some 1192// cores (such as the A2)). 1193def i64not : OutPatFrag<(ops node:$in), 1194 (NOR8 $in, $in)>; 1195def : Pat<(not i64:$in), 1196 (i64not $in)>; 1197 1198// Extending loads with i64 targets. 1199def : Pat<(zextloadi1 iaddr:$src), 1200 (LBZ8 iaddr:$src)>; 1201def : Pat<(zextloadi1 xaddr:$src), 1202 (LBZX8 xaddr:$src)>; 1203def : Pat<(extloadi1 iaddr:$src), 1204 (LBZ8 iaddr:$src)>; 1205def : Pat<(extloadi1 xaddr:$src), 1206 (LBZX8 xaddr:$src)>; 1207def : Pat<(extloadi8 iaddr:$src), 1208 (LBZ8 iaddr:$src)>; 1209def : Pat<(extloadi8 xaddr:$src), 1210 (LBZX8 xaddr:$src)>; 1211def : Pat<(extloadi16 iaddr:$src), 1212 (LHZ8 iaddr:$src)>; 1213def : Pat<(extloadi16 xaddr:$src), 1214 (LHZX8 xaddr:$src)>; 1215def : Pat<(extloadi32 iaddr:$src), 1216 (LWZ8 iaddr:$src)>; 1217def : Pat<(extloadi32 xaddr:$src), 1218 (LWZX8 xaddr:$src)>; 1219 1220// Standard shifts. These are represented separately from the real shifts above 1221// so that we can distinguish between shifts that allow 6-bit and 7-bit shift 1222// amounts. 1223def : Pat<(sra i64:$rS, i32:$rB), 1224 (SRAD $rS, $rB)>; 1225def : Pat<(srl i64:$rS, i32:$rB), 1226 (SRD $rS, $rB)>; 1227def : Pat<(shl i64:$rS, i32:$rB), 1228 (SLD $rS, $rB)>; 1229 1230// SHL/SRL 1231def : Pat<(shl i64:$in, (i32 imm:$imm)), 1232 (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>; 1233def : Pat<(srl i64:$in, (i32 imm:$imm)), 1234 (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>; 1235 1236// ROTL 1237def : Pat<(rotl i64:$in, i32:$sh), 1238 (RLDCL $in, $sh, 0)>; 1239def : Pat<(rotl i64:$in, (i32 imm:$imm)), 1240 (RLDICL $in, imm:$imm, 0)>; 1241 1242// Hi and Lo for Darwin Global Addresses. 1243def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>; 1244def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>; 1245def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>; 1246def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>; 1247def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>; 1248def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>; 1249def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>; 1250def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>; 1251def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in), 1252 (ADDIS8 $in, tglobaltlsaddr:$g)>; 1253def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in), 1254 (ADDI8 $in, tglobaltlsaddr:$g)>; 1255def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)), 1256 (ADDIS8 $in, tglobaladdr:$g)>; 1257def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)), 1258 (ADDIS8 $in, tconstpool:$g)>; 1259def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)), 1260 (ADDIS8 $in, tjumptable:$g)>; 1261def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)), 1262 (ADDIS8 $in, tblockaddress:$g)>; 1263 1264// Patterns to match r+r indexed loads and stores for 1265// addresses without at least 4-byte alignment. 1266def : Pat<(i64 (unaligned4sextloadi32 xoaddr:$src)), 1267 (LWAX xoaddr:$src)>; 1268def : Pat<(i64 (unaligned4load xoaddr:$src)), 1269 (LDX xoaddr:$src)>; 1270def : Pat<(unaligned4store i64:$rS, xoaddr:$dst), 1271 (STDX $rS, xoaddr:$dst)>; 1272 1273// 64-bits atomic loads and stores 1274def : Pat<(atomic_load_64 ixaddr:$src), (LD memrix:$src)>; 1275def : Pat<(atomic_load_64 xaddr:$src), (LDX memrr:$src)>; 1276 1277def : Pat<(atomic_store_64 ixaddr:$ptr, i64:$val), (STD g8rc:$val, memrix:$ptr)>; 1278def : Pat<(atomic_store_64 xaddr:$ptr, i64:$val), (STDX g8rc:$val, memrr:$ptr)>; 1279 1280let Predicates = [IsISA3_0] in { 1281 1282class X_L1_RA5_RB5<bits<6> opcode, bits<10> xo, string opc, RegisterOperand ty, 1283 InstrItinClass itin, list<dag> pattern> 1284 : X_L1_RS5_RS5<opcode, xo, (outs), (ins ty:$rA, ty:$rB, u1imm:$L), 1285 !strconcat(opc, " $rA, $rB, $L"), itin, pattern>; 1286 1287let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 1288def CP_COPY8 : X_L1_RA5_RB5<31, 774, "copy" , g8rc, IIC_LdStCOPY, []>; 1289def CP_PASTE8 : X_L1_RA5_RB5<31, 902, "paste" , g8rc, IIC_LdStPASTE, []>; 1290def CP_PASTE8o : X_L1_RA5_RB5<31, 902, "paste.", g8rc, IIC_LdStPASTE, []>,isDOT; 1291} 1292 1293// SLB Invalidate Entry Global 1294def SLBIEG : XForm_26<31, 466, (outs), (ins gprc:$RS, gprc:$RB), 1295 "slbieg $RS, $RB", IIC_SprSLBIEG, []>; 1296// SLB Synchronize 1297def SLBSYNC : XForm_0<31, 338, (outs), (ins), "slbsync", IIC_SprSLBSYNC, []>; 1298 1299} // IsISA3_0 1300