1//===-- PPCInstrInfo.td - The PowerPC Instruction Set ------*- 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 subset of the 32-bit PowerPC instruction set, as used 11// by the PowerPC instruction selector. 12// 13//===----------------------------------------------------------------------===// 14 15include "PPCInstrFormats.td" 16 17//===----------------------------------------------------------------------===// 18// PowerPC specific type constraints. 19// 20def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx 21 SDTCisVT<0, f64>, SDTCisPtrTy<1> 22]>; 23def SDT_PPClfiwx : SDTypeProfile<1, 1, [ // lfiw[az]x 24 SDTCisVT<0, f64>, SDTCisPtrTy<1> 25]>; 26def SDT_PPCLxsizx : SDTypeProfile<1, 2, [ 27 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2> 28]>; 29def SDT_PPCstxsix : SDTypeProfile<0, 3, [ 30 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2> 31]>; 32def SDT_PPCVexts : SDTypeProfile<1, 2, [ 33 SDTCisVT<0, f64>, SDTCisVT<1, f64>, SDTCisPtrTy<2> 34]>; 35 36def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>; 37def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, 38 SDTCisVT<1, i32> ]>; 39def SDT_PPCvperm : SDTypeProfile<1, 3, [ 40 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2> 41]>; 42 43def SDT_PPCVecSplat : SDTypeProfile<1, 2, [ SDTCisVec<0>, 44 SDTCisVec<1>, SDTCisInt<2> 45]>; 46 47def SDT_PPCVecShift : SDTypeProfile<1, 3, [ SDTCisVec<0>, 48 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3> 49]>; 50 51def SDT_PPCVecInsert : SDTypeProfile<1, 3, [ SDTCisVec<0>, 52 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3> 53]>; 54 55def SDT_PPCvcmp : SDTypeProfile<1, 3, [ 56 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32> 57]>; 58 59def SDT_PPCcondbr : SDTypeProfile<0, 3, [ 60 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT> 61]>; 62 63def SDT_PPClbrx : SDTypeProfile<1, 2, [ 64 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT> 65]>; 66def SDT_PPCstbrx : SDTypeProfile<0, 3, [ 67 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT> 68]>; 69 70def SDT_PPCTC_ret : SDTypeProfile<0, 2, [ 71 SDTCisPtrTy<0>, SDTCisVT<1, i32> 72]>; 73 74def tocentry32 : Operand<iPTR> { 75 let MIOperandInfo = (ops i32imm:$imm); 76} 77 78def SDT_PPCqvfperm : SDTypeProfile<1, 3, [ 79 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3> 80]>; 81def SDT_PPCqvgpci : SDTypeProfile<1, 1, [ 82 SDTCisVec<0>, SDTCisInt<1> 83]>; 84def SDT_PPCqvaligni : SDTypeProfile<1, 3, [ 85 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3> 86]>; 87def SDT_PPCqvesplati : SDTypeProfile<1, 2, [ 88 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2> 89]>; 90 91def SDT_PPCqbflt : SDTypeProfile<1, 1, [ 92 SDTCisVec<0>, SDTCisVec<1> 93]>; 94 95def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [ 96 SDTCisVec<0>, SDTCisPtrTy<1> 97]>; 98 99//===----------------------------------------------------------------------===// 100// PowerPC specific DAG Nodes. 101// 102 103def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>; 104def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>; 105 106def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>; 107def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>; 108def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>; 109def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>; 110def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>; 111def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>; 112def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>; 113def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>; 114def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx, 115 [SDNPHasChain, SDNPMayStore]>; 116def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx, 117 [SDNPHasChain, SDNPMayLoad]>; 118def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx, 119 [SDNPHasChain, SDNPMayLoad]>; 120def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx, 121 [SDNPHasChain, SDNPMayLoad]>; 122def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix, 123 [SDNPHasChain, SDNPMayStore]>; 124def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>; 125 126// Extract FPSCR (not modeled at the DAG level). 127def PPCmffs : SDNode<"PPCISD::MFFS", 128 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, []>; 129 130// Perform FADD in round-to-zero mode. 131def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>; 132 133 134def PPCfsel : SDNode<"PPCISD::FSEL", 135 // Type constraint for fsel. 136 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, 137 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>; 138 139def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>; 140def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>; 141def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp, 142 [SDNPMayLoad, SDNPMemOperand]>; 143def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>; 144def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>; 145 146def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>; 147 148def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>; 149def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp, 150 [SDNPMayLoad]>; 151def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>; 152def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>; 153def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>; 154def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>; 155def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR", 156 SDTypeProfile<1, 3, [ 157 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, 158 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>; 159def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>; 160def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>; 161def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>; 162def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR", 163 SDTypeProfile<1, 3, [ 164 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, 165 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>; 166def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>; 167def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>; 168 169def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>; 170def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>; 171def PPCxxinsert : SDNode<"PPCISD::XXINSERT", SDT_PPCVecInsert, []>; 172def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>; 173 174def PPCqvfperm : SDNode<"PPCISD::QVFPERM", SDT_PPCqvfperm, []>; 175def PPCqvgpci : SDNode<"PPCISD::QVGPCI", SDT_PPCqvgpci, []>; 176def PPCqvaligni : SDNode<"PPCISD::QVALIGNI", SDT_PPCqvaligni, []>; 177def PPCqvesplati : SDNode<"PPCISD::QVESPLATI", SDT_PPCqvesplati, []>; 178 179def PPCqbflt : SDNode<"PPCISD::QBFLT", SDT_PPCqbflt, []>; 180 181def PPCqvlfsb : SDNode<"PPCISD::QVLFSb", SDT_PPCqvlfsb, 182 [SDNPHasChain, SDNPMayLoad]>; 183 184def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>; 185 186// These nodes represent the 32-bit PPC shifts that operate on 6-bit shift 187// amounts. These nodes are generated by the multi-precision shift code. 188def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>; 189def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>; 190def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>; 191 192// These are target-independent nodes, but have target-specific formats. 193def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart, 194 [SDNPHasChain, SDNPOutGlue]>; 195def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd, 196 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 197 198def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>; 199def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall, 200 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 201 SDNPVariadic]>; 202def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall, 203 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 204 SDNPVariadic]>; 205def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall, 206 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 207def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone, 208 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 209 SDNPVariadic]>; 210def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC", 211 SDTypeProfile<0, 1, []>, 212 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 213 SDNPVariadic]>; 214 215def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone, 216 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 217 218def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret, 219 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 220 221def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP", 222 SDTypeProfile<1, 1, [SDTCisInt<0>, 223 SDTCisPtrTy<1>]>, 224 [SDNPHasChain, SDNPSideEffect]>; 225def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP", 226 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>, 227 [SDNPHasChain, SDNPSideEffect]>; 228 229def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>; 230def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc, 231 [SDNPHasChain, SDNPSideEffect]>; 232 233def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone, 234 [SDNPHasChain, SDNPSideEffect]>; 235def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>; 236def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc, 237 [SDNPHasChain, SDNPSideEffect]>; 238 239def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>; 240def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutGlue]>; 241 242def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr, 243 [SDNPHasChain, SDNPOptInGlue]>; 244 245def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx, 246 [SDNPHasChain, SDNPMayLoad]>; 247def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx, 248 [SDNPHasChain, SDNPMayStore]>; 249 250// Instructions to set/unset CR bit 6 for SVR4 vararg calls 251def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone, 252 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 253def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone, 254 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 255 256// Instructions to support dynamic alloca. 257def SDTDynOp : SDTypeProfile<1, 2, []>; 258def SDTDynAreaOp : SDTypeProfile<1, 1, []>; 259def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>; 260def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>; 261 262//===----------------------------------------------------------------------===// 263// PowerPC specific transformation functions and pattern fragments. 264// 265 266def SHL32 : SDNodeXForm<imm, [{ 267 // Transformation function: 31 - imm 268 return getI32Imm(31 - N->getZExtValue(), SDLoc(N)); 269}]>; 270 271def SRL32 : SDNodeXForm<imm, [{ 272 // Transformation function: 32 - imm 273 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N)) 274 : getI32Imm(0, SDLoc(N)); 275}]>; 276 277def LO16 : SDNodeXForm<imm, [{ 278 // Transformation function: get the low 16 bits. 279 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N)); 280}]>; 281 282def HI16 : SDNodeXForm<imm, [{ 283 // Transformation function: shift the immediate value down into the low bits. 284 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N)); 285}]>; 286 287def HA16 : SDNodeXForm<imm, [{ 288 // Transformation function: shift the immediate value down into the low bits. 289 int Val = N->getZExtValue(); 290 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N)); 291}]>; 292def MB : SDNodeXForm<imm, [{ 293 // Transformation function: get the start bit of a mask 294 unsigned mb = 0, me; 295 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me); 296 return getI32Imm(mb, SDLoc(N)); 297}]>; 298 299def ME : SDNodeXForm<imm, [{ 300 // Transformation function: get the end bit of a mask 301 unsigned mb, me = 0; 302 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me); 303 return getI32Imm(me, SDLoc(N)); 304}]>; 305def maskimm32 : PatLeaf<(imm), [{ 306 // maskImm predicate - True if immediate is a run of ones. 307 unsigned mb, me; 308 if (N->getValueType(0) == MVT::i32) 309 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me); 310 else 311 return false; 312}]>; 313 314def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{ 315 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit 316 // sign extended field. Used by instructions like 'addi'. 317 return (int32_t)Imm == (short)Imm; 318}]>; 319def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{ 320 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit 321 // sign extended field. Used by instructions like 'addi'. 322 return (int64_t)Imm == (short)Imm; 323}]>; 324def immZExt16 : PatLeaf<(imm), [{ 325 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended 326 // field. Used by instructions like 'ori'. 327 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue(); 328}], LO16>; 329def immSExt8 : ImmLeaf<i32, [{ return isInt<8>(Imm); }]>; 330 331// imm16Shifted* - These match immediates where the low 16-bits are zero. There 332// are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are 333// identical in 32-bit mode, but in 64-bit mode, they return true if the 334// immediate fits into a sign/zero extended 32-bit immediate (with the low bits 335// clear). 336def imm16ShiftedZExt : PatLeaf<(imm), [{ 337 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the 338 // immediate are set. Used by instructions like 'xoris'. 339 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0; 340}], HI16>; 341 342def imm16ShiftedSExt : PatLeaf<(imm), [{ 343 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the 344 // immediate are set. Used by instructions like 'addis'. Identical to 345 // imm16ShiftedZExt in 32-bit mode. 346 if (N->getZExtValue() & 0xFFFF) return false; 347 if (N->getValueType(0) == MVT::i32) 348 return true; 349 // For 64-bit, make sure it is sext right. 350 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue(); 351}], HI16>; 352 353def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{ 354 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit 355 // zero extended field. 356 return isUInt<32>(Imm); 357}]>; 358 359// Some r+i load/store instructions (such as LD, STD, LDU, etc.) that require 360// restricted memrix (4-aligned) constants are alignment sensitive. If these 361// offsets are hidden behind TOC entries than the values of the lower-order 362// bits cannot be checked directly. As a result, we need to also incorporate 363// an alignment check into the relevant patterns. 364 365def aligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 366 return cast<LoadSDNode>(N)->getAlignment() >= 4; 367}]>; 368def aligned4store : PatFrag<(ops node:$val, node:$ptr), 369 (store node:$val, node:$ptr), [{ 370 return cast<StoreSDNode>(N)->getAlignment() >= 4; 371}]>; 372def aligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{ 373 return cast<LoadSDNode>(N)->getAlignment() >= 4; 374}]>; 375def aligned4pre_store : PatFrag< 376 (ops node:$val, node:$base, node:$offset), 377 (pre_store node:$val, node:$base, node:$offset), [{ 378 return cast<StoreSDNode>(N)->getAlignment() >= 4; 379}]>; 380 381def unaligned4load : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 382 return cast<LoadSDNode>(N)->getAlignment() < 4; 383}]>; 384def unaligned4store : PatFrag<(ops node:$val, node:$ptr), 385 (store node:$val, node:$ptr), [{ 386 return cast<StoreSDNode>(N)->getAlignment() < 4; 387}]>; 388def unaligned4sextloadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{ 389 return cast<LoadSDNode>(N)->getAlignment() < 4; 390}]>; 391 392//===----------------------------------------------------------------------===// 393// PowerPC Flag Definitions. 394 395class isPPC64 { bit PPC64 = 1; } 396class isDOT { bit RC = 1; } 397 398class RegConstraint<string C> { 399 string Constraints = C; 400} 401class NoEncode<string E> { 402 string DisableEncoding = E; 403} 404 405 406//===----------------------------------------------------------------------===// 407// PowerPC Operand Definitions. 408 409// In the default PowerPC assembler syntax, registers are specified simply 410// by number, so they cannot be distinguished from immediate values (without 411// looking at the opcode). This means that the default operand matching logic 412// for the asm parser does not work, and we need to specify custom matchers. 413// Since those can only be specified with RegisterOperand classes and not 414// directly on the RegisterClass, all instructions patterns used by the asm 415// parser need to use a RegisterOperand (instead of a RegisterClass) for 416// all their register operands. 417// For this purpose, we define one RegisterOperand for each RegisterClass, 418// using the same name as the class, just in lower case. 419 420def PPCRegGPRCAsmOperand : AsmOperandClass { 421 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber"; 422} 423def gprc : RegisterOperand<GPRC> { 424 let ParserMatchClass = PPCRegGPRCAsmOperand; 425} 426def PPCRegG8RCAsmOperand : AsmOperandClass { 427 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber"; 428} 429def g8rc : RegisterOperand<G8RC> { 430 let ParserMatchClass = PPCRegG8RCAsmOperand; 431} 432def PPCRegGPRCNoR0AsmOperand : AsmOperandClass { 433 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber"; 434} 435def gprc_nor0 : RegisterOperand<GPRC_NOR0> { 436 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand; 437} 438def PPCRegG8RCNoX0AsmOperand : AsmOperandClass { 439 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber"; 440} 441def g8rc_nox0 : RegisterOperand<G8RC_NOX0> { 442 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand; 443} 444def PPCRegF8RCAsmOperand : AsmOperandClass { 445 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber"; 446} 447def f8rc : RegisterOperand<F8RC> { 448 let ParserMatchClass = PPCRegF8RCAsmOperand; 449} 450def PPCRegF4RCAsmOperand : AsmOperandClass { 451 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber"; 452} 453def f4rc : RegisterOperand<F4RC> { 454 let ParserMatchClass = PPCRegF4RCAsmOperand; 455} 456def PPCRegVRRCAsmOperand : AsmOperandClass { 457 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber"; 458} 459def vrrc : RegisterOperand<VRRC> { 460 let ParserMatchClass = PPCRegVRRCAsmOperand; 461} 462def PPCRegVFRCAsmOperand : AsmOperandClass { 463 let Name = "RegVFRC"; let PredicateMethod = "isRegNumber"; 464} 465def vfrc : RegisterOperand<VFRC> { 466 let ParserMatchClass = PPCRegVFRCAsmOperand; 467} 468def PPCRegCRBITRCAsmOperand : AsmOperandClass { 469 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber"; 470} 471def crbitrc : RegisterOperand<CRBITRC> { 472 let ParserMatchClass = PPCRegCRBITRCAsmOperand; 473} 474def PPCRegCRRCAsmOperand : AsmOperandClass { 475 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber"; 476} 477def crrc : RegisterOperand<CRRC> { 478 let ParserMatchClass = PPCRegCRRCAsmOperand; 479} 480def crrc0 : RegisterOperand<CRRC0> { 481 let ParserMatchClass = PPCRegCRRCAsmOperand; 482} 483 484def PPCU1ImmAsmOperand : AsmOperandClass { 485 let Name = "U1Imm"; let PredicateMethod = "isU1Imm"; 486 let RenderMethod = "addImmOperands"; 487} 488def u1imm : Operand<i32> { 489 let PrintMethod = "printU1ImmOperand"; 490 let ParserMatchClass = PPCU1ImmAsmOperand; 491} 492 493def PPCU2ImmAsmOperand : AsmOperandClass { 494 let Name = "U2Imm"; let PredicateMethod = "isU2Imm"; 495 let RenderMethod = "addImmOperands"; 496} 497def u2imm : Operand<i32> { 498 let PrintMethod = "printU2ImmOperand"; 499 let ParserMatchClass = PPCU2ImmAsmOperand; 500} 501 502def PPCATBitsAsHintAsmOperand : AsmOperandClass { 503 let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint"; 504 let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails. 505} 506def atimm : Operand<i32> { 507 let PrintMethod = "printATBitsAsHint"; 508 let ParserMatchClass = PPCATBitsAsHintAsmOperand; 509} 510 511def PPCU3ImmAsmOperand : AsmOperandClass { 512 let Name = "U3Imm"; let PredicateMethod = "isU3Imm"; 513 let RenderMethod = "addImmOperands"; 514} 515def u3imm : Operand<i32> { 516 let PrintMethod = "printU3ImmOperand"; 517 let ParserMatchClass = PPCU3ImmAsmOperand; 518} 519 520def PPCU4ImmAsmOperand : AsmOperandClass { 521 let Name = "U4Imm"; let PredicateMethod = "isU4Imm"; 522 let RenderMethod = "addImmOperands"; 523} 524def u4imm : Operand<i32> { 525 let PrintMethod = "printU4ImmOperand"; 526 let ParserMatchClass = PPCU4ImmAsmOperand; 527} 528def PPCS5ImmAsmOperand : AsmOperandClass { 529 let Name = "S5Imm"; let PredicateMethod = "isS5Imm"; 530 let RenderMethod = "addImmOperands"; 531} 532def s5imm : Operand<i32> { 533 let PrintMethod = "printS5ImmOperand"; 534 let ParserMatchClass = PPCS5ImmAsmOperand; 535 let DecoderMethod = "decodeSImmOperand<5>"; 536} 537def PPCU5ImmAsmOperand : AsmOperandClass { 538 let Name = "U5Imm"; let PredicateMethod = "isU5Imm"; 539 let RenderMethod = "addImmOperands"; 540} 541def u5imm : Operand<i32> { 542 let PrintMethod = "printU5ImmOperand"; 543 let ParserMatchClass = PPCU5ImmAsmOperand; 544 let DecoderMethod = "decodeUImmOperand<5>"; 545} 546def PPCU6ImmAsmOperand : AsmOperandClass { 547 let Name = "U6Imm"; let PredicateMethod = "isU6Imm"; 548 let RenderMethod = "addImmOperands"; 549} 550def u6imm : Operand<i32> { 551 let PrintMethod = "printU6ImmOperand"; 552 let ParserMatchClass = PPCU6ImmAsmOperand; 553 let DecoderMethod = "decodeUImmOperand<6>"; 554} 555def PPCU7ImmAsmOperand : AsmOperandClass { 556 let Name = "U7Imm"; let PredicateMethod = "isU7Imm"; 557 let RenderMethod = "addImmOperands"; 558} 559def u7imm : Operand<i32> { 560 let PrintMethod = "printU7ImmOperand"; 561 let ParserMatchClass = PPCU7ImmAsmOperand; 562 let DecoderMethod = "decodeUImmOperand<7>"; 563} 564def PPCU8ImmAsmOperand : AsmOperandClass { 565 let Name = "U8Imm"; let PredicateMethod = "isU8Imm"; 566 let RenderMethod = "addImmOperands"; 567} 568def u8imm : Operand<i32> { 569 let PrintMethod = "printU8ImmOperand"; 570 let ParserMatchClass = PPCU8ImmAsmOperand; 571 let DecoderMethod = "decodeUImmOperand<8>"; 572} 573def PPCU10ImmAsmOperand : AsmOperandClass { 574 let Name = "U10Imm"; let PredicateMethod = "isU10Imm"; 575 let RenderMethod = "addImmOperands"; 576} 577def u10imm : Operand<i32> { 578 let PrintMethod = "printU10ImmOperand"; 579 let ParserMatchClass = PPCU10ImmAsmOperand; 580 let DecoderMethod = "decodeUImmOperand<10>"; 581} 582def PPCU12ImmAsmOperand : AsmOperandClass { 583 let Name = "U12Imm"; let PredicateMethod = "isU12Imm"; 584 let RenderMethod = "addImmOperands"; 585} 586def u12imm : Operand<i32> { 587 let PrintMethod = "printU12ImmOperand"; 588 let ParserMatchClass = PPCU12ImmAsmOperand; 589 let DecoderMethod = "decodeUImmOperand<12>"; 590} 591def PPCS16ImmAsmOperand : AsmOperandClass { 592 let Name = "S16Imm"; let PredicateMethod = "isS16Imm"; 593 let RenderMethod = "addS16ImmOperands"; 594} 595def s16imm : Operand<i32> { 596 let PrintMethod = "printS16ImmOperand"; 597 let EncoderMethod = "getImm16Encoding"; 598 let ParserMatchClass = PPCS16ImmAsmOperand; 599 let DecoderMethod = "decodeSImmOperand<16>"; 600} 601def PPCU16ImmAsmOperand : AsmOperandClass { 602 let Name = "U16Imm"; let PredicateMethod = "isU16Imm"; 603 let RenderMethod = "addU16ImmOperands"; 604} 605def u16imm : Operand<i32> { 606 let PrintMethod = "printU16ImmOperand"; 607 let EncoderMethod = "getImm16Encoding"; 608 let ParserMatchClass = PPCU16ImmAsmOperand; 609 let DecoderMethod = "decodeUImmOperand<16>"; 610} 611def PPCS17ImmAsmOperand : AsmOperandClass { 612 let Name = "S17Imm"; let PredicateMethod = "isS17Imm"; 613 let RenderMethod = "addS16ImmOperands"; 614} 615def s17imm : Operand<i32> { 616 // This operand type is used for addis/lis to allow the assembler parser 617 // to accept immediates in the range -65536..65535 for compatibility with 618 // the GNU assembler. The operand is treated as 16-bit otherwise. 619 let PrintMethod = "printS16ImmOperand"; 620 let EncoderMethod = "getImm16Encoding"; 621 let ParserMatchClass = PPCS17ImmAsmOperand; 622 let DecoderMethod = "decodeSImmOperand<16>"; 623} 624def PPCDirectBrAsmOperand : AsmOperandClass { 625 let Name = "DirectBr"; let PredicateMethod = "isDirectBr"; 626 let RenderMethod = "addBranchTargetOperands"; 627} 628def directbrtarget : Operand<OtherVT> { 629 let PrintMethod = "printBranchOperand"; 630 let EncoderMethod = "getDirectBrEncoding"; 631 let ParserMatchClass = PPCDirectBrAsmOperand; 632} 633def absdirectbrtarget : Operand<OtherVT> { 634 let PrintMethod = "printAbsBranchOperand"; 635 let EncoderMethod = "getAbsDirectBrEncoding"; 636 let ParserMatchClass = PPCDirectBrAsmOperand; 637} 638def PPCCondBrAsmOperand : AsmOperandClass { 639 let Name = "CondBr"; let PredicateMethod = "isCondBr"; 640 let RenderMethod = "addBranchTargetOperands"; 641} 642def condbrtarget : Operand<OtherVT> { 643 let PrintMethod = "printBranchOperand"; 644 let EncoderMethod = "getCondBrEncoding"; 645 let ParserMatchClass = PPCCondBrAsmOperand; 646} 647def abscondbrtarget : Operand<OtherVT> { 648 let PrintMethod = "printAbsBranchOperand"; 649 let EncoderMethod = "getAbsCondBrEncoding"; 650 let ParserMatchClass = PPCCondBrAsmOperand; 651} 652def calltarget : Operand<iPTR> { 653 let PrintMethod = "printBranchOperand"; 654 let EncoderMethod = "getDirectBrEncoding"; 655 let ParserMatchClass = PPCDirectBrAsmOperand; 656} 657def abscalltarget : Operand<iPTR> { 658 let PrintMethod = "printAbsBranchOperand"; 659 let EncoderMethod = "getAbsDirectBrEncoding"; 660 let ParserMatchClass = PPCDirectBrAsmOperand; 661} 662def PPCCRBitMaskOperand : AsmOperandClass { 663 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask"; 664} 665def crbitm: Operand<i8> { 666 let PrintMethod = "printcrbitm"; 667 let EncoderMethod = "get_crbitm_encoding"; 668 let DecoderMethod = "decodeCRBitMOperand"; 669 let ParserMatchClass = PPCCRBitMaskOperand; 670} 671// Address operands 672// A version of ptr_rc which excludes R0 (or X0 in 64-bit mode). 673def PPCRegGxRCNoR0Operand : AsmOperandClass { 674 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber"; 675} 676def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> { 677 let ParserMatchClass = PPCRegGxRCNoR0Operand; 678} 679// A version of ptr_rc usable with the asm parser. 680def PPCRegGxRCOperand : AsmOperandClass { 681 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber"; 682} 683def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> { 684 let ParserMatchClass = PPCRegGxRCOperand; 685} 686 687def PPCDispRIOperand : AsmOperandClass { 688 let Name = "DispRI"; let PredicateMethod = "isS16Imm"; 689 let RenderMethod = "addS16ImmOperands"; 690} 691def dispRI : Operand<iPTR> { 692 let ParserMatchClass = PPCDispRIOperand; 693} 694def PPCDispRIXOperand : AsmOperandClass { 695 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4"; 696 let RenderMethod = "addImmOperands"; 697} 698def dispRIX : Operand<iPTR> { 699 let ParserMatchClass = PPCDispRIXOperand; 700} 701def PPCDispRIX16Operand : AsmOperandClass { 702 let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16"; 703 let RenderMethod = "addImmOperands"; 704} 705def dispRIX16 : Operand<iPTR> { 706 let ParserMatchClass = PPCDispRIX16Operand; 707} 708def PPCDispSPE8Operand : AsmOperandClass { 709 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8"; 710 let RenderMethod = "addImmOperands"; 711} 712def dispSPE8 : Operand<iPTR> { 713 let ParserMatchClass = PPCDispSPE8Operand; 714} 715def PPCDispSPE4Operand : AsmOperandClass { 716 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4"; 717 let RenderMethod = "addImmOperands"; 718} 719def dispSPE4 : Operand<iPTR> { 720 let ParserMatchClass = PPCDispSPE4Operand; 721} 722def PPCDispSPE2Operand : AsmOperandClass { 723 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2"; 724 let RenderMethod = "addImmOperands"; 725} 726def dispSPE2 : Operand<iPTR> { 727 let ParserMatchClass = PPCDispSPE2Operand; 728} 729 730def memri : Operand<iPTR> { 731 let PrintMethod = "printMemRegImm"; 732 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg); 733 let EncoderMethod = "getMemRIEncoding"; 734 let DecoderMethod = "decodeMemRIOperands"; 735} 736def memrr : Operand<iPTR> { 737 let PrintMethod = "printMemRegReg"; 738 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg); 739} 740def memrix : Operand<iPTR> { // memri where the imm is 4-aligned. 741 let PrintMethod = "printMemRegImm"; 742 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg); 743 let EncoderMethod = "getMemRIXEncoding"; 744 let DecoderMethod = "decodeMemRIXOperands"; 745} 746def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27} 747 let PrintMethod = "printMemRegImm"; 748 let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg); 749 let EncoderMethod = "getMemRIX16Encoding"; 750 let DecoderMethod = "decodeMemRIX16Operands"; 751} 752def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned. 753 let PrintMethod = "printMemRegImm"; 754 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg); 755 let EncoderMethod = "getSPE8DisEncoding"; 756} 757def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned. 758 let PrintMethod = "printMemRegImm"; 759 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg); 760 let EncoderMethod = "getSPE4DisEncoding"; 761} 762def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned. 763 let PrintMethod = "printMemRegImm"; 764 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg); 765 let EncoderMethod = "getSPE2DisEncoding"; 766} 767 768// A single-register address. This is used with the SjLj 769// pseudo-instructions. 770def memr : Operand<iPTR> { 771 let MIOperandInfo = (ops ptr_rc:$ptrreg); 772} 773def PPCTLSRegOperand : AsmOperandClass { 774 let Name = "TLSReg"; let PredicateMethod = "isTLSReg"; 775 let RenderMethod = "addTLSRegOperands"; 776} 777def tlsreg32 : Operand<i32> { 778 let EncoderMethod = "getTLSRegEncoding"; 779 let ParserMatchClass = PPCTLSRegOperand; 780} 781def tlsgd32 : Operand<i32> {} 782def tlscall32 : Operand<i32> { 783 let PrintMethod = "printTLSCall"; 784 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym); 785 let EncoderMethod = "getTLSCallEncoding"; 786} 787 788// PowerPC Predicate operand. 789def pred : Operand<OtherVT> { 790 let PrintMethod = "printPredicateOperand"; 791 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg); 792} 793 794// Define PowerPC specific addressing mode. 795def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>; 796def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>; 797def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>; 798def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std" 799 800// The address in a single register. This is used with the SjLj 801// pseudo-instructions. 802def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>; 803 804/// This is just the offset part of iaddr, used for preinc. 805def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>; 806 807//===----------------------------------------------------------------------===// 808// PowerPC Instruction Predicate Definitions. 809def In32BitMode : Predicate<"!PPCSubTarget->isPPC64()">; 810def In64BitMode : Predicate<"PPCSubTarget->isPPC64()">; 811def IsBookE : Predicate<"PPCSubTarget->isBookE()">; 812def IsNotBookE : Predicate<"!PPCSubTarget->isBookE()">; 813def HasOnlyMSYNC : Predicate<"PPCSubTarget->hasOnlyMSYNC()">; 814def HasSYNC : Predicate<"!PPCSubTarget->hasOnlyMSYNC()">; 815def IsPPC4xx : Predicate<"PPCSubTarget->isPPC4xx()">; 816def IsPPC6xx : Predicate<"PPCSubTarget->isPPC6xx()">; 817def IsE500 : Predicate<"PPCSubTarget->isE500()">; 818def HasSPE : Predicate<"PPCSubTarget->HasSPE()">; 819def HasICBT : Predicate<"PPCSubTarget->hasICBT()">; 820def HasPartwordAtomics : Predicate<"PPCSubTarget->hasPartwordAtomics()">; 821def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">; 822def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">; 823def HasBPERMD : Predicate<"PPCSubTarget->hasBPERMD()">; 824def HasExtDiv : Predicate<"PPCSubTarget->hasExtDiv()">; 825def IsISA3_0 : Predicate<"PPCSubTarget->isISA3_0()">; 826 827//===----------------------------------------------------------------------===// 828// PowerPC Multiclass Definitions. 829 830multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 831 string asmbase, string asmstr, InstrItinClass itin, 832 list<dag> pattern> { 833 let BaseName = asmbase in { 834 def NAME : XForm_6<opcode, xo, OOL, IOL, 835 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 836 pattern>, RecFormRel; 837 let Defs = [CR0] in 838 def o : XForm_6<opcode, xo, OOL, IOL, 839 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 840 []>, isDOT, RecFormRel; 841 } 842} 843 844multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 845 string asmbase, string asmstr, InstrItinClass itin, 846 list<dag> pattern> { 847 let BaseName = asmbase in { 848 let Defs = [CARRY] in 849 def NAME : XForm_6<opcode, xo, OOL, IOL, 850 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 851 pattern>, RecFormRel; 852 let Defs = [CARRY, CR0] in 853 def o : XForm_6<opcode, xo, OOL, IOL, 854 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 855 []>, isDOT, RecFormRel; 856 } 857} 858 859multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 860 string asmbase, string asmstr, InstrItinClass itin, 861 list<dag> pattern> { 862 let BaseName = asmbase in { 863 let Defs = [CARRY] in 864 def NAME : XForm_10<opcode, xo, OOL, IOL, 865 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 866 pattern>, RecFormRel; 867 let Defs = [CARRY, CR0] in 868 def o : XForm_10<opcode, xo, OOL, IOL, 869 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 870 []>, isDOT, RecFormRel; 871 } 872} 873 874multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 875 string asmbase, string asmstr, InstrItinClass itin, 876 list<dag> pattern> { 877 let BaseName = asmbase in { 878 def NAME : XForm_11<opcode, xo, OOL, IOL, 879 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 880 pattern>, RecFormRel; 881 let Defs = [CR0] in 882 def o : XForm_11<opcode, xo, OOL, IOL, 883 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 884 []>, isDOT, RecFormRel; 885 } 886} 887 888multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 889 string asmbase, string asmstr, InstrItinClass itin, 890 list<dag> pattern> { 891 let BaseName = asmbase in { 892 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL, 893 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 894 pattern>, RecFormRel; 895 let Defs = [CR0] in 896 def o : XOForm_1<opcode, xo, oe, OOL, IOL, 897 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 898 []>, isDOT, RecFormRel; 899 } 900} 901 902// Multiclass for instructions for which the non record form is not cracked 903// and the record form is cracked (i.e. divw, mullw, etc.) 904multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 905 string asmbase, string asmstr, InstrItinClass itin, 906 list<dag> pattern> { 907 let BaseName = asmbase in { 908 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL, 909 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 910 pattern>, RecFormRel; 911 let Defs = [CR0] in 912 def o : XOForm_1<opcode, xo, oe, OOL, IOL, 913 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 914 []>, isDOT, RecFormRel, PPC970_DGroup_First, 915 PPC970_DGroup_Cracked; 916 } 917} 918 919multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 920 string asmbase, string asmstr, InstrItinClass itin, 921 list<dag> pattern> { 922 let BaseName = asmbase in { 923 let Defs = [CARRY] in 924 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL, 925 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 926 pattern>, RecFormRel; 927 let Defs = [CARRY, CR0] in 928 def o : XOForm_1<opcode, xo, oe, OOL, IOL, 929 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 930 []>, isDOT, RecFormRel; 931 } 932} 933 934multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 935 string asmbase, string asmstr, InstrItinClass itin, 936 list<dag> pattern> { 937 let BaseName = asmbase in { 938 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL, 939 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 940 pattern>, RecFormRel; 941 let Defs = [CR0] in 942 def o : XOForm_3<opcode, xo, oe, OOL, IOL, 943 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 944 []>, isDOT, RecFormRel; 945 } 946} 947 948multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 949 string asmbase, string asmstr, InstrItinClass itin, 950 list<dag> pattern> { 951 let BaseName = asmbase in { 952 let Defs = [CARRY] in 953 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL, 954 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 955 pattern>, RecFormRel; 956 let Defs = [CARRY, CR0] in 957 def o : XOForm_3<opcode, xo, oe, OOL, IOL, 958 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 959 []>, isDOT, RecFormRel; 960 } 961} 962 963multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL, 964 string asmbase, string asmstr, InstrItinClass itin, 965 list<dag> pattern> { 966 let BaseName = asmbase in { 967 def NAME : MForm_2<opcode, OOL, IOL, 968 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 969 pattern>, RecFormRel; 970 let Defs = [CR0] in 971 def o : MForm_2<opcode, OOL, IOL, 972 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 973 []>, isDOT, RecFormRel; 974 } 975} 976 977multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL, 978 string asmbase, string asmstr, InstrItinClass itin, 979 list<dag> pattern> { 980 let BaseName = asmbase in { 981 def NAME : MDForm_1<opcode, xo, OOL, IOL, 982 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 983 pattern>, RecFormRel; 984 let Defs = [CR0] in 985 def o : MDForm_1<opcode, xo, OOL, IOL, 986 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 987 []>, isDOT, RecFormRel; 988 } 989} 990 991multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL, 992 string asmbase, string asmstr, InstrItinClass itin, 993 list<dag> pattern> { 994 let BaseName = asmbase in { 995 def NAME : MDSForm_1<opcode, xo, OOL, IOL, 996 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 997 pattern>, RecFormRel; 998 let Defs = [CR0] in 999 def o : MDSForm_1<opcode, xo, OOL, IOL, 1000 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1001 []>, isDOT, RecFormRel; 1002 } 1003} 1004 1005multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL, 1006 string asmbase, string asmstr, InstrItinClass itin, 1007 list<dag> pattern> { 1008 let BaseName = asmbase in { 1009 let Defs = [CARRY] in 1010 def NAME : XSForm_1<opcode, xo, OOL, IOL, 1011 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1012 pattern>, RecFormRel; 1013 let Defs = [CARRY, CR0] in 1014 def o : XSForm_1<opcode, xo, OOL, IOL, 1015 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1016 []>, isDOT, RecFormRel; 1017 } 1018} 1019 1020multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 1021 string asmbase, string asmstr, InstrItinClass itin, 1022 list<dag> pattern> { 1023 let BaseName = asmbase in { 1024 def NAME : XForm_26<opcode, xo, OOL, IOL, 1025 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1026 pattern>, RecFormRel; 1027 let Defs = [CR1] in 1028 def o : XForm_26<opcode, xo, OOL, IOL, 1029 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1030 []>, isDOT, RecFormRel; 1031 } 1032} 1033 1034multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 1035 string asmbase, string asmstr, InstrItinClass itin, 1036 list<dag> pattern> { 1037 let BaseName = asmbase in { 1038 def NAME : XForm_28<opcode, xo, OOL, IOL, 1039 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1040 pattern>, RecFormRel; 1041 let Defs = [CR1] in 1042 def o : XForm_28<opcode, xo, OOL, IOL, 1043 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1044 []>, isDOT, RecFormRel; 1045 } 1046} 1047 1048multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, 1049 string asmbase, string asmstr, InstrItinClass itin, 1050 list<dag> pattern> { 1051 let BaseName = asmbase in { 1052 def NAME : AForm_1<opcode, xo, OOL, IOL, 1053 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1054 pattern>, RecFormRel; 1055 let Defs = [CR1] in 1056 def o : AForm_1<opcode, xo, OOL, IOL, 1057 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1058 []>, isDOT, RecFormRel; 1059 } 1060} 1061 1062multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, 1063 string asmbase, string asmstr, InstrItinClass itin, 1064 list<dag> pattern> { 1065 let BaseName = asmbase in { 1066 def NAME : AForm_2<opcode, xo, OOL, IOL, 1067 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1068 pattern>, RecFormRel; 1069 let Defs = [CR1] in 1070 def o : AForm_2<opcode, xo, OOL, IOL, 1071 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1072 []>, isDOT, RecFormRel; 1073 } 1074} 1075 1076multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, 1077 string asmbase, string asmstr, InstrItinClass itin, 1078 list<dag> pattern> { 1079 let BaseName = asmbase in { 1080 def NAME : AForm_3<opcode, xo, OOL, IOL, 1081 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1082 pattern>, RecFormRel; 1083 let Defs = [CR1] in 1084 def o : AForm_3<opcode, xo, OOL, IOL, 1085 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1086 []>, isDOT, RecFormRel; 1087 } 1088} 1089 1090//===----------------------------------------------------------------------===// 1091// PowerPC Instruction Definitions. 1092 1093// Pseudo-instructions: 1094 1095let hasCtrlDep = 1 in { 1096let Defs = [R1], Uses = [R1] in { 1097def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt), "#ADJCALLSTACKDOWN $amt", 1098 [(callseq_start timm:$amt)]>; 1099def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2), "#ADJCALLSTACKUP $amt1 $amt2", 1100 [(callseq_end timm:$amt1, timm:$amt2)]>; 1101} 1102 1103def UPDATE_VRSAVE : Pseudo<(outs gprc:$rD), (ins gprc:$rS), 1104 "UPDATE_VRSAVE $rD, $rS", []>; 1105} 1106 1107let Defs = [R1], Uses = [R1] in 1108def DYNALLOC : Pseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC", 1109 [(set i32:$result, 1110 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>; 1111def DYNAREAOFFSET : Pseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET", 1112 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>; 1113 1114// SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after 1115// instruction selection into a branch sequence. 1116let usesCustomInserter = 1, // Expanded after instruction selection. 1117 PPC970_Single = 1 in { 1118 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes 1119 // because either operand might become the first operand in an isel, and 1120 // that operand cannot be r0. 1121 def SELECT_CC_I4 : Pseudo<(outs gprc:$dst), (ins crrc:$cond, 1122 gprc_nor0:$T, gprc_nor0:$F, 1123 i32imm:$BROPC), "#SELECT_CC_I4", 1124 []>; 1125 def SELECT_CC_I8 : Pseudo<(outs g8rc:$dst), (ins crrc:$cond, 1126 g8rc_nox0:$T, g8rc_nox0:$F, 1127 i32imm:$BROPC), "#SELECT_CC_I8", 1128 []>; 1129 def SELECT_CC_F4 : Pseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F, 1130 i32imm:$BROPC), "#SELECT_CC_F4", 1131 []>; 1132 def SELECT_CC_F8 : Pseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F, 1133 i32imm:$BROPC), "#SELECT_CC_F8", 1134 []>; 1135 def SELECT_CC_VRRC: Pseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F, 1136 i32imm:$BROPC), "#SELECT_CC_VRRC", 1137 []>; 1138 1139 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition 1140 // register bit directly. 1141 def SELECT_I4 : Pseudo<(outs gprc:$dst), (ins crbitrc:$cond, 1142 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4", 1143 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>; 1144 def SELECT_I8 : Pseudo<(outs g8rc:$dst), (ins crbitrc:$cond, 1145 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8", 1146 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>; 1147 def SELECT_F4 : Pseudo<(outs f4rc:$dst), (ins crbitrc:$cond, 1148 f4rc:$T, f4rc:$F), "#SELECT_F4", 1149 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>; 1150 def SELECT_F8 : Pseudo<(outs f8rc:$dst), (ins crbitrc:$cond, 1151 f8rc:$T, f8rc:$F), "#SELECT_F8", 1152 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>; 1153 def SELECT_VRRC: Pseudo<(outs vrrc:$dst), (ins crbitrc:$cond, 1154 vrrc:$T, vrrc:$F), "#SELECT_VRRC", 1155 [(set v4i32:$dst, 1156 (select i1:$cond, v4i32:$T, v4i32:$F))]>; 1157} 1158 1159// SPILL_CR - Indicate that we're dumping the CR register, so we'll need to 1160// scavenge a register for it. 1161let mayStore = 1 in { 1162def SPILL_CR : Pseudo<(outs), (ins crrc:$cond, memri:$F), 1163 "#SPILL_CR", []>; 1164def SPILL_CRBIT : Pseudo<(outs), (ins crbitrc:$cond, memri:$F), 1165 "#SPILL_CRBIT", []>; 1166} 1167 1168// RESTORE_CR - Indicate that we're restoring the CR register (previously 1169// spilled), so we'll need to scavenge a register for it. 1170let mayLoad = 1 in { 1171def RESTORE_CR : Pseudo<(outs crrc:$cond), (ins memri:$F), 1172 "#RESTORE_CR", []>; 1173def RESTORE_CRBIT : Pseudo<(outs crbitrc:$cond), (ins memri:$F), 1174 "#RESTORE_CRBIT", []>; 1175} 1176 1177let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in { 1178 let isReturn = 1, Uses = [LR, RM] in 1179 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB, 1180 [(retflag)]>, Requires<[In32BitMode]>; 1181 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in { 1182 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB, 1183 []>; 1184 1185 let isCodeGenOnly = 1 in { 1186 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond), 1187 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB, 1188 []>; 1189 1190 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi), 1191 "bcctr 12, $bi, 0", IIC_BrB, []>; 1192 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi), 1193 "bcctr 4, $bi, 0", IIC_BrB, []>; 1194 } 1195 } 1196} 1197 1198let Defs = [LR] in 1199 def MovePCtoLR : Pseudo<(outs), (ins), "#MovePCtoLR", []>, 1200 PPC970_Unit_BRU; 1201let Defs = [LR] in 1202 def MoveGOTtoLR : Pseudo<(outs), (ins), "#MoveGOTtoLR", []>, 1203 PPC970_Unit_BRU; 1204 1205let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in { 1206 let isBarrier = 1 in { 1207 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst), 1208 "b $dst", IIC_BrB, 1209 [(br bb:$dst)]>; 1210 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst), 1211 "ba $dst", IIC_BrB, []>; 1212 } 1213 1214 // BCC represents an arbitrary conditional branch on a predicate. 1215 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use 1216 // a two-value operand where a dag node expects two operands. :( 1217 let isCodeGenOnly = 1 in { 1218 def BCC : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst), 1219 "b${cond:cc}${cond:pm} ${cond:reg}, $dst" 1220 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>; 1221 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst), 1222 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">; 1223 1224 let isReturn = 1, Uses = [LR, RM] in 1225 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond), 1226 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>; 1227 } 1228 1229 let isCodeGenOnly = 1 in { 1230 let Pattern = [(brcond i1:$bi, bb:$dst)] in 1231 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst), 1232 "bc 12, $bi, $dst">; 1233 1234 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in 1235 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst), 1236 "bc 4, $bi, $dst">; 1237 1238 let isReturn = 1, Uses = [LR, RM] in 1239 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi), 1240 "bclr 12, $bi, 0", IIC_BrB, []>; 1241 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi), 1242 "bclr 4, $bi, 0", IIC_BrB, []>; 1243 } 1244 1245 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in { 1246 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins), 1247 "bdzlr", IIC_BrB, []>; 1248 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins), 1249 "bdnzlr", IIC_BrB, []>; 1250 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins), 1251 "bdzlr+", IIC_BrB, []>; 1252 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins), 1253 "bdnzlr+", IIC_BrB, []>; 1254 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins), 1255 "bdzlr-", IIC_BrB, []>; 1256 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins), 1257 "bdnzlr-", IIC_BrB, []>; 1258 } 1259 1260 let Defs = [CTR], Uses = [CTR] in { 1261 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst), 1262 "bdz $dst">; 1263 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst), 1264 "bdnz $dst">; 1265 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst), 1266 "bdza $dst">; 1267 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst), 1268 "bdnza $dst">; 1269 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst), 1270 "bdz+ $dst">; 1271 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst), 1272 "bdnz+ $dst">; 1273 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst), 1274 "bdza+ $dst">; 1275 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst), 1276 "bdnza+ $dst">; 1277 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst), 1278 "bdz- $dst">; 1279 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst), 1280 "bdnz- $dst">; 1281 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst), 1282 "bdza- $dst">; 1283 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst), 1284 "bdnza- $dst">; 1285 } 1286} 1287 1288// The unconditional BCL used by the SjLj setjmp code. 1289let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7 in { 1290 let Defs = [LR], Uses = [RM] in { 1291 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst), 1292 "bcl 20, 31, $dst">; 1293 } 1294} 1295 1296let isCall = 1, PPC970_Unit = 7, Defs = [LR] in { 1297 // Convenient aliases for call instructions 1298 let Uses = [RM] in { 1299 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func), 1300 "bl $func", IIC_BrB, []>; // See Pat patterns below. 1301 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func), 1302 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>; 1303 1304 let isCodeGenOnly = 1 in { 1305 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func), 1306 "bl $func", IIC_BrB, []>; 1307 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst), 1308 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">; 1309 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst), 1310 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">; 1311 1312 def BCL : BForm_4<16, 12, 0, 1, (outs), 1313 (ins crbitrc:$bi, condbrtarget:$dst), 1314 "bcl 12, $bi, $dst">; 1315 def BCLn : BForm_4<16, 4, 0, 1, (outs), 1316 (ins crbitrc:$bi, condbrtarget:$dst), 1317 "bcl 4, $bi, $dst">; 1318 } 1319 } 1320 let Uses = [CTR, RM] in { 1321 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins), 1322 "bctrl", IIC_BrB, [(PPCbctrl)]>, 1323 Requires<[In32BitMode]>; 1324 1325 let isCodeGenOnly = 1 in { 1326 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond), 1327 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB, 1328 []>; 1329 1330 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi), 1331 "bcctrl 12, $bi, 0", IIC_BrB, []>; 1332 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi), 1333 "bcctrl 4, $bi, 0", IIC_BrB, []>; 1334 } 1335 } 1336 let Uses = [LR, RM] in { 1337 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins), 1338 "blrl", IIC_BrB, []>; 1339 1340 let isCodeGenOnly = 1 in { 1341 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond), 1342 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB, 1343 []>; 1344 1345 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi), 1346 "bclrl 12, $bi, 0", IIC_BrB, []>; 1347 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi), 1348 "bclrl 4, $bi, 0", IIC_BrB, []>; 1349 } 1350 } 1351 let Defs = [CTR], Uses = [CTR, RM] in { 1352 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst), 1353 "bdzl $dst">; 1354 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst), 1355 "bdnzl $dst">; 1356 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst), 1357 "bdzla $dst">; 1358 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst), 1359 "bdnzla $dst">; 1360 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst), 1361 "bdzl+ $dst">; 1362 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst), 1363 "bdnzl+ $dst">; 1364 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst), 1365 "bdzla+ $dst">; 1366 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst), 1367 "bdnzla+ $dst">; 1368 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst), 1369 "bdzl- $dst">; 1370 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst), 1371 "bdnzl- $dst">; 1372 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst), 1373 "bdzla- $dst">; 1374 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst), 1375 "bdnzla- $dst">; 1376 } 1377 let Defs = [CTR], Uses = [CTR, LR, RM] in { 1378 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins), 1379 "bdzlrl", IIC_BrB, []>; 1380 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins), 1381 "bdnzlrl", IIC_BrB, []>; 1382 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins), 1383 "bdzlrl+", IIC_BrB, []>; 1384 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins), 1385 "bdnzlrl+", IIC_BrB, []>; 1386 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins), 1387 "bdzlrl-", IIC_BrB, []>; 1388 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins), 1389 "bdnzlrl-", IIC_BrB, []>; 1390 } 1391} 1392 1393let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in 1394def TCRETURNdi :Pseudo< (outs), 1395 (ins calltarget:$dst, i32imm:$offset), 1396 "#TC_RETURNd $dst $offset", 1397 []>; 1398 1399 1400let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in 1401def TCRETURNai :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset), 1402 "#TC_RETURNa $func $offset", 1403 [(PPCtc_return (i32 imm:$func), imm:$offset)]>; 1404 1405let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in 1406def TCRETURNri : Pseudo<(outs), (ins CTRRC:$dst, i32imm:$offset), 1407 "#TC_RETURNr $dst $offset", 1408 []>; 1409 1410 1411let isCodeGenOnly = 1 in { 1412 1413let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1, 1414 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in 1415def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB, 1416 []>, Requires<[In32BitMode]>; 1417 1418let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, 1419 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in 1420def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst), 1421 "b $dst", IIC_BrB, 1422 []>; 1423 1424let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, 1425 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in 1426def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst), 1427 "ba $dst", IIC_BrB, 1428 []>; 1429 1430} 1431 1432let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in { 1433 let Defs = [CTR] in 1434 def EH_SjLj_SetJmp32 : Pseudo<(outs gprc:$dst), (ins memr:$buf), 1435 "#EH_SJLJ_SETJMP32", 1436 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>, 1437 Requires<[In32BitMode]>; 1438 let isTerminator = 1 in 1439 def EH_SjLj_LongJmp32 : Pseudo<(outs), (ins memr:$buf), 1440 "#EH_SJLJ_LONGJMP32", 1441 [(PPCeh_sjlj_longjmp addr:$buf)]>, 1442 Requires<[In32BitMode]>; 1443} 1444 1445// This pseudo is never removed from the function, as it serves as 1446// a terminator. Size is set to 0 to prevent the builtin assembler 1447// from emitting it. 1448let isBranch = 1, isTerminator = 1, Size = 0 in { 1449 def EH_SjLj_Setup : Pseudo<(outs), (ins directbrtarget:$dst), 1450 "#EH_SjLj_Setup\t$dst", []>; 1451} 1452 1453// System call. 1454let PPC970_Unit = 7 in { 1455 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev), 1456 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>; 1457} 1458 1459// Branch history rolling buffer. 1460def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB, 1461 [(PPCclrbhrb)]>, 1462 PPC970_DGroup_Single; 1463// The $dmy argument used for MFBHRBE is not needed; however, including 1464// it avoids automatic generation of PPCFastISel::fastEmit_i(), which 1465// interferes with necessary special handling (see PPCFastISel.cpp). 1466def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD), 1467 (ins u10imm:$imm, u10imm:$dmy), 1468 "mfbhrbe $rD, $imm", IIC_BrB, 1469 [(set i32:$rD, 1470 (PPCmfbhrbe imm:$imm, imm:$dmy))]>, 1471 PPC970_DGroup_First; 1472 1473def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm", 1474 IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>, 1475 PPC970_DGroup_Single; 1476 1477// DCB* instructions. 1478def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst", 1479 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>, 1480 PPC970_DGroup_Single; 1481def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst", 1482 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>, 1483 PPC970_DGroup_Single; 1484def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst", 1485 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>, 1486 PPC970_DGroup_Single; 1487def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst", 1488 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>, 1489 PPC970_DGroup_Single; 1490def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst", 1491 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>, 1492 PPC970_DGroup_Single; 1493 1494def DCBF : DCB_Form_hint<86, (outs), (ins u5imm:$TH, memrr:$dst), 1495 "dcbf $dst, $TH", IIC_LdStDCBF, []>, 1496 PPC970_DGroup_Single; 1497 1498let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in { 1499def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst), 1500 "dcbt $dst, $TH", IIC_LdStDCBF, []>, 1501 PPC970_DGroup_Single; 1502def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst), 1503 "dcbtst $dst, $TH", IIC_LdStDCBF, []>, 1504 PPC970_DGroup_Single; 1505} // hasSideEffects = 0 1506 1507def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src), 1508 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>; 1509 1510def : Pat<(int_ppc_dcbt xoaddr:$dst), 1511 (DCBT 0, xoaddr:$dst)>; 1512def : Pat<(int_ppc_dcbtst xoaddr:$dst), 1513 (DCBTST 0, xoaddr:$dst)>; 1514def : Pat<(int_ppc_dcbf xoaddr:$dst), 1515 (DCBF 0, xoaddr:$dst)>; 1516 1517def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)), 1518 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads 1519def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)), 1520 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores 1521def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)), 1522 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read) 1523 1524// Atomic operations 1525let usesCustomInserter = 1 in { 1526 let Defs = [CR0] in { 1527 def ATOMIC_LOAD_ADD_I8 : Pseudo< 1528 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8", 1529 [(set i32:$dst, (atomic_load_add_8 xoaddr:$ptr, i32:$incr))]>; 1530 def ATOMIC_LOAD_SUB_I8 : Pseudo< 1531 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8", 1532 [(set i32:$dst, (atomic_load_sub_8 xoaddr:$ptr, i32:$incr))]>; 1533 def ATOMIC_LOAD_AND_I8 : Pseudo< 1534 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8", 1535 [(set i32:$dst, (atomic_load_and_8 xoaddr:$ptr, i32:$incr))]>; 1536 def ATOMIC_LOAD_OR_I8 : Pseudo< 1537 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8", 1538 [(set i32:$dst, (atomic_load_or_8 xoaddr:$ptr, i32:$incr))]>; 1539 def ATOMIC_LOAD_XOR_I8 : Pseudo< 1540 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8", 1541 [(set i32:$dst, (atomic_load_xor_8 xoaddr:$ptr, i32:$incr))]>; 1542 def ATOMIC_LOAD_NAND_I8 : Pseudo< 1543 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8", 1544 [(set i32:$dst, (atomic_load_nand_8 xoaddr:$ptr, i32:$incr))]>; 1545 def ATOMIC_LOAD_MIN_I8 : Pseudo< 1546 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8", 1547 [(set i32:$dst, (atomic_load_min_8 xoaddr:$ptr, i32:$incr))]>; 1548 def ATOMIC_LOAD_MAX_I8 : Pseudo< 1549 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8", 1550 [(set i32:$dst, (atomic_load_max_8 xoaddr:$ptr, i32:$incr))]>; 1551 def ATOMIC_LOAD_UMIN_I8 : Pseudo< 1552 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8", 1553 [(set i32:$dst, (atomic_load_umin_8 xoaddr:$ptr, i32:$incr))]>; 1554 def ATOMIC_LOAD_UMAX_I8 : Pseudo< 1555 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8", 1556 [(set i32:$dst, (atomic_load_umax_8 xoaddr:$ptr, i32:$incr))]>; 1557 def ATOMIC_LOAD_ADD_I16 : Pseudo< 1558 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16", 1559 [(set i32:$dst, (atomic_load_add_16 xoaddr:$ptr, i32:$incr))]>; 1560 def ATOMIC_LOAD_SUB_I16 : Pseudo< 1561 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16", 1562 [(set i32:$dst, (atomic_load_sub_16 xoaddr:$ptr, i32:$incr))]>; 1563 def ATOMIC_LOAD_AND_I16 : Pseudo< 1564 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16", 1565 [(set i32:$dst, (atomic_load_and_16 xoaddr:$ptr, i32:$incr))]>; 1566 def ATOMIC_LOAD_OR_I16 : Pseudo< 1567 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16", 1568 [(set i32:$dst, (atomic_load_or_16 xoaddr:$ptr, i32:$incr))]>; 1569 def ATOMIC_LOAD_XOR_I16 : Pseudo< 1570 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16", 1571 [(set i32:$dst, (atomic_load_xor_16 xoaddr:$ptr, i32:$incr))]>; 1572 def ATOMIC_LOAD_NAND_I16 : Pseudo< 1573 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16", 1574 [(set i32:$dst, (atomic_load_nand_16 xoaddr:$ptr, i32:$incr))]>; 1575 def ATOMIC_LOAD_MIN_I16 : Pseudo< 1576 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16", 1577 [(set i32:$dst, (atomic_load_min_16 xoaddr:$ptr, i32:$incr))]>; 1578 def ATOMIC_LOAD_MAX_I16 : Pseudo< 1579 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16", 1580 [(set i32:$dst, (atomic_load_max_16 xoaddr:$ptr, i32:$incr))]>; 1581 def ATOMIC_LOAD_UMIN_I16 : Pseudo< 1582 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16", 1583 [(set i32:$dst, (atomic_load_umin_16 xoaddr:$ptr, i32:$incr))]>; 1584 def ATOMIC_LOAD_UMAX_I16 : Pseudo< 1585 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16", 1586 [(set i32:$dst, (atomic_load_umax_16 xoaddr:$ptr, i32:$incr))]>; 1587 def ATOMIC_LOAD_ADD_I32 : Pseudo< 1588 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32", 1589 [(set i32:$dst, (atomic_load_add_32 xoaddr:$ptr, i32:$incr))]>; 1590 def ATOMIC_LOAD_SUB_I32 : Pseudo< 1591 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32", 1592 [(set i32:$dst, (atomic_load_sub_32 xoaddr:$ptr, i32:$incr))]>; 1593 def ATOMIC_LOAD_AND_I32 : Pseudo< 1594 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32", 1595 [(set i32:$dst, (atomic_load_and_32 xoaddr:$ptr, i32:$incr))]>; 1596 def ATOMIC_LOAD_OR_I32 : Pseudo< 1597 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32", 1598 [(set i32:$dst, (atomic_load_or_32 xoaddr:$ptr, i32:$incr))]>; 1599 def ATOMIC_LOAD_XOR_I32 : Pseudo< 1600 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32", 1601 [(set i32:$dst, (atomic_load_xor_32 xoaddr:$ptr, i32:$incr))]>; 1602 def ATOMIC_LOAD_NAND_I32 : Pseudo< 1603 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32", 1604 [(set i32:$dst, (atomic_load_nand_32 xoaddr:$ptr, i32:$incr))]>; 1605 def ATOMIC_LOAD_MIN_I32 : Pseudo< 1606 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32", 1607 [(set i32:$dst, (atomic_load_min_32 xoaddr:$ptr, i32:$incr))]>; 1608 def ATOMIC_LOAD_MAX_I32 : Pseudo< 1609 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32", 1610 [(set i32:$dst, (atomic_load_max_32 xoaddr:$ptr, i32:$incr))]>; 1611 def ATOMIC_LOAD_UMIN_I32 : Pseudo< 1612 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32", 1613 [(set i32:$dst, (atomic_load_umin_32 xoaddr:$ptr, i32:$incr))]>; 1614 def ATOMIC_LOAD_UMAX_I32 : Pseudo< 1615 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32", 1616 [(set i32:$dst, (atomic_load_umax_32 xoaddr:$ptr, i32:$incr))]>; 1617 1618 def ATOMIC_CMP_SWAP_I8 : Pseudo< 1619 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8", 1620 [(set i32:$dst, (atomic_cmp_swap_8 xoaddr:$ptr, i32:$old, i32:$new))]>; 1621 def ATOMIC_CMP_SWAP_I16 : Pseudo< 1622 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new", 1623 [(set i32:$dst, (atomic_cmp_swap_16 xoaddr:$ptr, i32:$old, i32:$new))]>; 1624 def ATOMIC_CMP_SWAP_I32 : Pseudo< 1625 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new", 1626 [(set i32:$dst, (atomic_cmp_swap_32 xoaddr:$ptr, i32:$old, i32:$new))]>; 1627 1628 def ATOMIC_SWAP_I8 : Pseudo< 1629 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8", 1630 [(set i32:$dst, (atomic_swap_8 xoaddr:$ptr, i32:$new))]>; 1631 def ATOMIC_SWAP_I16 : Pseudo< 1632 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16", 1633 [(set i32:$dst, (atomic_swap_16 xoaddr:$ptr, i32:$new))]>; 1634 def ATOMIC_SWAP_I32 : Pseudo< 1635 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32", 1636 [(set i32:$dst, (atomic_swap_32 xoaddr:$ptr, i32:$new))]>; 1637 } 1638} 1639 1640// Instructions to support atomic operations 1641let mayLoad = 1, hasSideEffects = 0 in { 1642def LBARX : XForm_1<31, 52, (outs gprc:$rD), (ins memrr:$src), 1643 "lbarx $rD, $src", IIC_LdStLWARX, []>, 1644 Requires<[HasPartwordAtomics]>; 1645 1646def LHARX : XForm_1<31, 116, (outs gprc:$rD), (ins memrr:$src), 1647 "lharx $rD, $src", IIC_LdStLWARX, []>, 1648 Requires<[HasPartwordAtomics]>; 1649 1650def LWARX : XForm_1<31, 20, (outs gprc:$rD), (ins memrr:$src), 1651 "lwarx $rD, $src", IIC_LdStLWARX, []>; 1652 1653// Instructions to support lock versions of atomics 1654// (EH=1 - see Power ISA 2.07 Book II 4.4.2) 1655def LBARXL : XForm_1<31, 52, (outs gprc:$rD), (ins memrr:$src), 1656 "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT, 1657 Requires<[HasPartwordAtomics]>; 1658 1659def LHARXL : XForm_1<31, 116, (outs gprc:$rD), (ins memrr:$src), 1660 "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT, 1661 Requires<[HasPartwordAtomics]>; 1662 1663def LWARXL : XForm_1<31, 20, (outs gprc:$rD), (ins memrr:$src), 1664 "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT; 1665 1666// The atomic instructions use the destination register as well as the next one 1667// or two registers in order (modulo 31). 1668let hasExtraSrcRegAllocReq = 1 in 1669def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC), 1670 "lwat $rD, $rA, $FC", IIC_LdStLoad>, 1671 Requires<[IsISA3_0]>; 1672} 1673 1674let Defs = [CR0], mayStore = 1, hasSideEffects = 0 in { 1675def STBCX : XForm_1<31, 694, (outs), (ins gprc:$rS, memrr:$dst), 1676 "stbcx. $rS, $dst", IIC_LdStSTWCX, []>, 1677 isDOT, Requires<[HasPartwordAtomics]>; 1678 1679def STHCX : XForm_1<31, 726, (outs), (ins gprc:$rS, memrr:$dst), 1680 "sthcx. $rS, $dst", IIC_LdStSTWCX, []>, 1681 isDOT, Requires<[HasPartwordAtomics]>; 1682 1683def STWCX : XForm_1<31, 150, (outs), (ins gprc:$rS, memrr:$dst), 1684 "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isDOT; 1685} 1686 1687let mayStore = 1, hasSideEffects = 0 in 1688def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC), 1689 "stwat $rS, $rA, $FC", IIC_LdStStore>, 1690 Requires<[IsISA3_0]>; 1691 1692let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in 1693def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>; 1694 1695def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm), 1696 "twi $to, $rA, $imm", IIC_IntTrapW, []>; 1697def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB), 1698 "tw $to, $rA, $rB", IIC_IntTrapW, []>; 1699def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm), 1700 "tdi $to, $rA, $imm", IIC_IntTrapD, []>; 1701def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB), 1702 "td $to, $rA, $rB", IIC_IntTrapD, []>; 1703 1704//===----------------------------------------------------------------------===// 1705// PPC32 Load Instructions. 1706// 1707 1708// Unindexed (r+i) Loads. 1709let PPC970_Unit = 2 in { 1710def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src), 1711 "lbz $rD, $src", IIC_LdStLoad, 1712 [(set i32:$rD, (zextloadi8 iaddr:$src))]>; 1713def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src), 1714 "lha $rD, $src", IIC_LdStLHA, 1715 [(set i32:$rD, (sextloadi16 iaddr:$src))]>, 1716 PPC970_DGroup_Cracked; 1717def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src), 1718 "lhz $rD, $src", IIC_LdStLoad, 1719 [(set i32:$rD, (zextloadi16 iaddr:$src))]>; 1720def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src), 1721 "lwz $rD, $src", IIC_LdStLoad, 1722 [(set i32:$rD, (load iaddr:$src))]>; 1723 1724def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src), 1725 "lfs $rD, $src", IIC_LdStLFD, 1726 [(set f32:$rD, (load iaddr:$src))]>; 1727def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src), 1728 "lfd $rD, $src", IIC_LdStLFD, 1729 [(set f64:$rD, (load iaddr:$src))]>; 1730 1731 1732// Unindexed (r+i) Loads with Update (preinc). 1733let mayLoad = 1, hasSideEffects = 0 in { 1734def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 1735 "lbzu $rD, $addr", IIC_LdStLoadUpd, 1736 []>, RegConstraint<"$addr.reg = $ea_result">, 1737 NoEncode<"$ea_result">; 1738 1739def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 1740 "lhau $rD, $addr", IIC_LdStLHAU, 1741 []>, RegConstraint<"$addr.reg = $ea_result">, 1742 NoEncode<"$ea_result">; 1743 1744def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 1745 "lhzu $rD, $addr", IIC_LdStLoadUpd, 1746 []>, RegConstraint<"$addr.reg = $ea_result">, 1747 NoEncode<"$ea_result">; 1748 1749def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 1750 "lwzu $rD, $addr", IIC_LdStLoadUpd, 1751 []>, RegConstraint<"$addr.reg = $ea_result">, 1752 NoEncode<"$ea_result">; 1753 1754def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 1755 "lfsu $rD, $addr", IIC_LdStLFDU, 1756 []>, RegConstraint<"$addr.reg = $ea_result">, 1757 NoEncode<"$ea_result">; 1758 1759def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 1760 "lfdu $rD, $addr", IIC_LdStLFDU, 1761 []>, RegConstraint<"$addr.reg = $ea_result">, 1762 NoEncode<"$ea_result">; 1763 1764 1765// Indexed (r+r) Loads with Update (preinc). 1766def LBZUX : XForm_1<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result), 1767 (ins memrr:$addr), 1768 "lbzux $rD, $addr", IIC_LdStLoadUpdX, 1769 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 1770 NoEncode<"$ea_result">; 1771 1772def LHAUX : XForm_1<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result), 1773 (ins memrr:$addr), 1774 "lhaux $rD, $addr", IIC_LdStLHAUX, 1775 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 1776 NoEncode<"$ea_result">; 1777 1778def LHZUX : XForm_1<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result), 1779 (ins memrr:$addr), 1780 "lhzux $rD, $addr", IIC_LdStLoadUpdX, 1781 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 1782 NoEncode<"$ea_result">; 1783 1784def LWZUX : XForm_1<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result), 1785 (ins memrr:$addr), 1786 "lwzux $rD, $addr", IIC_LdStLoadUpdX, 1787 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 1788 NoEncode<"$ea_result">; 1789 1790def LFSUX : XForm_1<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), 1791 (ins memrr:$addr), 1792 "lfsux $rD, $addr", IIC_LdStLFDUX, 1793 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 1794 NoEncode<"$ea_result">; 1795 1796def LFDUX : XForm_1<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), 1797 (ins memrr:$addr), 1798 "lfdux $rD, $addr", IIC_LdStLFDUX, 1799 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 1800 NoEncode<"$ea_result">; 1801} 1802} 1803 1804// Indexed (r+r) Loads. 1805// 1806let PPC970_Unit = 2 in { 1807def LBZX : XForm_1<31, 87, (outs gprc:$rD), (ins memrr:$src), 1808 "lbzx $rD, $src", IIC_LdStLoad, 1809 [(set i32:$rD, (zextloadi8 xaddr:$src))]>; 1810def LHAX : XForm_1<31, 343, (outs gprc:$rD), (ins memrr:$src), 1811 "lhax $rD, $src", IIC_LdStLHA, 1812 [(set i32:$rD, (sextloadi16 xaddr:$src))]>, 1813 PPC970_DGroup_Cracked; 1814def LHZX : XForm_1<31, 279, (outs gprc:$rD), (ins memrr:$src), 1815 "lhzx $rD, $src", IIC_LdStLoad, 1816 [(set i32:$rD, (zextloadi16 xaddr:$src))]>; 1817def LWZX : XForm_1<31, 23, (outs gprc:$rD), (ins memrr:$src), 1818 "lwzx $rD, $src", IIC_LdStLoad, 1819 [(set i32:$rD, (load xaddr:$src))]>; 1820 1821 1822def LHBRX : XForm_1<31, 790, (outs gprc:$rD), (ins memrr:$src), 1823 "lhbrx $rD, $src", IIC_LdStLoad, 1824 [(set i32:$rD, (PPClbrx xoaddr:$src, i16))]>; 1825def LWBRX : XForm_1<31, 534, (outs gprc:$rD), (ins memrr:$src), 1826 "lwbrx $rD, $src", IIC_LdStLoad, 1827 [(set i32:$rD, (PPClbrx xoaddr:$src, i32))]>; 1828 1829def LFSX : XForm_25<31, 535, (outs f4rc:$frD), (ins memrr:$src), 1830 "lfsx $frD, $src", IIC_LdStLFD, 1831 [(set f32:$frD, (load xaddr:$src))]>; 1832def LFDX : XForm_25<31, 599, (outs f8rc:$frD), (ins memrr:$src), 1833 "lfdx $frD, $src", IIC_LdStLFD, 1834 [(set f64:$frD, (load xaddr:$src))]>; 1835 1836def LFIWAX : XForm_25<31, 855, (outs f8rc:$frD), (ins memrr:$src), 1837 "lfiwax $frD, $src", IIC_LdStLFD, 1838 [(set f64:$frD, (PPClfiwax xoaddr:$src))]>; 1839def LFIWZX : XForm_25<31, 887, (outs f8rc:$frD), (ins memrr:$src), 1840 "lfiwzx $frD, $src", IIC_LdStLFD, 1841 [(set f64:$frD, (PPClfiwzx xoaddr:$src))]>; 1842} 1843 1844// Load Multiple 1845def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src), 1846 "lmw $rD, $src", IIC_LdStLMW, []>; 1847 1848//===----------------------------------------------------------------------===// 1849// PPC32 Store Instructions. 1850// 1851 1852// Unindexed (r+i) Stores. 1853let PPC970_Unit = 2 in { 1854def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$src), 1855 "stb $rS, $src", IIC_LdStStore, 1856 [(truncstorei8 i32:$rS, iaddr:$src)]>; 1857def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$src), 1858 "sth $rS, $src", IIC_LdStStore, 1859 [(truncstorei16 i32:$rS, iaddr:$src)]>; 1860def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$src), 1861 "stw $rS, $src", IIC_LdStStore, 1862 [(store i32:$rS, iaddr:$src)]>; 1863def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst), 1864 "stfs $rS, $dst", IIC_LdStSTFD, 1865 [(store f32:$rS, iaddr:$dst)]>; 1866def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst), 1867 "stfd $rS, $dst", IIC_LdStSTFD, 1868 [(store f64:$rS, iaddr:$dst)]>; 1869} 1870 1871// Unindexed (r+i) Stores with Update (preinc). 1872let PPC970_Unit = 2, mayStore = 1 in { 1873def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst), 1874 "stbu $rS, $dst", IIC_LdStStoreUpd, []>, 1875 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 1876def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst), 1877 "sthu $rS, $dst", IIC_LdStStoreUpd, []>, 1878 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 1879def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst), 1880 "stwu $rS, $dst", IIC_LdStStoreUpd, []>, 1881 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 1882def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst), 1883 "stfsu $rS, $dst", IIC_LdStSTFDU, []>, 1884 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 1885def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst), 1886 "stfdu $rS, $dst", IIC_LdStSTFDU, []>, 1887 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 1888} 1889 1890// Patterns to match the pre-inc stores. We can't put the patterns on 1891// the instruction definitions directly as ISel wants the address base 1892// and offset to be separate operands, not a single complex operand. 1893def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 1894 (STBU $rS, iaddroff:$ptroff, $ptrreg)>; 1895def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 1896 (STHU $rS, iaddroff:$ptroff, $ptrreg)>; 1897def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 1898 (STWU $rS, iaddroff:$ptroff, $ptrreg)>; 1899def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 1900 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>; 1901def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 1902 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>; 1903 1904// Indexed (r+r) Stores. 1905let PPC970_Unit = 2 in { 1906def STBX : XForm_8<31, 215, (outs), (ins gprc:$rS, memrr:$dst), 1907 "stbx $rS, $dst", IIC_LdStStore, 1908 [(truncstorei8 i32:$rS, xaddr:$dst)]>, 1909 PPC970_DGroup_Cracked; 1910def STHX : XForm_8<31, 407, (outs), (ins gprc:$rS, memrr:$dst), 1911 "sthx $rS, $dst", IIC_LdStStore, 1912 [(truncstorei16 i32:$rS, xaddr:$dst)]>, 1913 PPC970_DGroup_Cracked; 1914def STWX : XForm_8<31, 151, (outs), (ins gprc:$rS, memrr:$dst), 1915 "stwx $rS, $dst", IIC_LdStStore, 1916 [(store i32:$rS, xaddr:$dst)]>, 1917 PPC970_DGroup_Cracked; 1918 1919def STHBRX: XForm_8<31, 918, (outs), (ins gprc:$rS, memrr:$dst), 1920 "sthbrx $rS, $dst", IIC_LdStStore, 1921 [(PPCstbrx i32:$rS, xoaddr:$dst, i16)]>, 1922 PPC970_DGroup_Cracked; 1923def STWBRX: XForm_8<31, 662, (outs), (ins gprc:$rS, memrr:$dst), 1924 "stwbrx $rS, $dst", IIC_LdStStore, 1925 [(PPCstbrx i32:$rS, xoaddr:$dst, i32)]>, 1926 PPC970_DGroup_Cracked; 1927 1928def STFIWX: XForm_28<31, 983, (outs), (ins f8rc:$frS, memrr:$dst), 1929 "stfiwx $frS, $dst", IIC_LdStSTFD, 1930 [(PPCstfiwx f64:$frS, xoaddr:$dst)]>; 1931 1932def STFSX : XForm_28<31, 663, (outs), (ins f4rc:$frS, memrr:$dst), 1933 "stfsx $frS, $dst", IIC_LdStSTFD, 1934 [(store f32:$frS, xaddr:$dst)]>; 1935def STFDX : XForm_28<31, 727, (outs), (ins f8rc:$frS, memrr:$dst), 1936 "stfdx $frS, $dst", IIC_LdStSTFD, 1937 [(store f64:$frS, xaddr:$dst)]>; 1938} 1939 1940// Indexed (r+r) Stores with Update (preinc). 1941let PPC970_Unit = 2, mayStore = 1 in { 1942def STBUX : XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst), 1943 "stbux $rS, $dst", IIC_LdStStoreUpd, []>, 1944 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">, 1945 PPC970_DGroup_Cracked; 1946def STHUX : XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst), 1947 "sthux $rS, $dst", IIC_LdStStoreUpd, []>, 1948 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">, 1949 PPC970_DGroup_Cracked; 1950def STWUX : XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memrr:$dst), 1951 "stwux $rS, $dst", IIC_LdStStoreUpd, []>, 1952 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">, 1953 PPC970_DGroup_Cracked; 1954def STFSUX: XForm_8<31, 695, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memrr:$dst), 1955 "stfsux $rS, $dst", IIC_LdStSTFDU, []>, 1956 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">, 1957 PPC970_DGroup_Cracked; 1958def STFDUX: XForm_8<31, 759, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memrr:$dst), 1959 "stfdux $rS, $dst", IIC_LdStSTFDU, []>, 1960 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">, 1961 PPC970_DGroup_Cracked; 1962} 1963 1964// Patterns to match the pre-inc stores. We can't put the patterns on 1965// the instruction definitions directly as ISel wants the address base 1966// and offset to be separate operands, not a single complex operand. 1967def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff), 1968 (STBUX $rS, $ptrreg, $ptroff)>; 1969def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff), 1970 (STHUX $rS, $ptrreg, $ptroff)>; 1971def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff), 1972 (STWUX $rS, $ptrreg, $ptroff)>; 1973def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff), 1974 (STFSUX $rS, $ptrreg, $ptroff)>; 1975def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff), 1976 (STFDUX $rS, $ptrreg, $ptroff)>; 1977 1978// Store Multiple 1979def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst), 1980 "stmw $rS, $dst", IIC_LdStLMW, []>; 1981 1982def SYNC : XForm_24_sync<31, 598, (outs), (ins i32imm:$L), 1983 "sync $L", IIC_LdStSync, []>; 1984 1985let isCodeGenOnly = 1 in { 1986 def MSYNC : XForm_24_sync<31, 598, (outs), (ins), 1987 "msync", IIC_LdStSync, []> { 1988 let L = 0; 1989 } 1990} 1991 1992def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>; 1993def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>; 1994def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>; 1995def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>; 1996 1997//===----------------------------------------------------------------------===// 1998// PPC32 Arithmetic Instructions. 1999// 2000 2001let PPC970_Unit = 1 in { // FXU Operations. 2002def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm), 2003 "addi $rD, $rA, $imm", IIC_IntSimple, 2004 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>; 2005let BaseName = "addic" in { 2006let Defs = [CARRY] in 2007def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm), 2008 "addic $rD, $rA, $imm", IIC_IntGeneral, 2009 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>, 2010 RecFormRel, PPC970_DGroup_Cracked; 2011let Defs = [CARRY, CR0] in 2012def ADDICo : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm), 2013 "addic. $rD, $rA, $imm", IIC_IntGeneral, 2014 []>, isDOT, RecFormRel; 2015} 2016def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm), 2017 "addis $rD, $rA, $imm", IIC_IntSimple, 2018 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>; 2019let isCodeGenOnly = 1 in 2020def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym), 2021 "la $rD, $sym($rA)", IIC_IntGeneral, 2022 [(set i32:$rD, (add i32:$rA, 2023 (PPClo tglobaladdr:$sym, 0)))]>; 2024def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm), 2025 "mulli $rD, $rA, $imm", IIC_IntMulLI, 2026 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>; 2027let Defs = [CARRY] in 2028def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm), 2029 "subfic $rD, $rA, $imm", IIC_IntGeneral, 2030 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>; 2031 2032let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in { 2033 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm), 2034 "li $rD, $imm", IIC_IntSimple, 2035 [(set i32:$rD, imm32SExt16:$imm)]>; 2036 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm), 2037 "lis $rD, $imm", IIC_IntSimple, 2038 [(set i32:$rD, imm16ShiftedSExt:$imm)]>; 2039} 2040} 2041 2042let PPC970_Unit = 1 in { // FXU Operations. 2043let Defs = [CR0] in { 2044def ANDIo : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2045 "andi. $dst, $src1, $src2", IIC_IntGeneral, 2046 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>, 2047 isDOT; 2048def ANDISo : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2049 "andis. $dst, $src1, $src2", IIC_IntGeneral, 2050 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>, 2051 isDOT; 2052} 2053def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2054 "ori $dst, $src1, $src2", IIC_IntSimple, 2055 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>; 2056def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2057 "oris $dst, $src1, $src2", IIC_IntSimple, 2058 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>; 2059def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2060 "xori $dst, $src1, $src2", IIC_IntSimple, 2061 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>; 2062def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2063 "xoris $dst, $src1, $src2", IIC_IntSimple, 2064 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>; 2065 2066def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple, 2067 []>; 2068let isCodeGenOnly = 1 in { 2069// The POWER6 and POWER7 have special group-terminating nops. 2070def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins), 2071 "ori 1, 1, 0", IIC_IntSimple, []>; 2072def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins), 2073 "ori 2, 2, 0", IIC_IntSimple, []>; 2074} 2075 2076let isCompare = 1, hasSideEffects = 0 in { 2077 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm), 2078 "cmpwi $crD, $rA, $imm", IIC_IntCompare>; 2079 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2), 2080 "cmplwi $dst, $src1, $src2", IIC_IntCompare>; 2081 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crbitrc:$BF), 2082 (ins u1imm:$L, g8rc:$rA, g8rc:$rB), 2083 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>, 2084 Requires<[IsISA3_0]>; 2085} 2086} 2087 2088let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations. 2089let isCommutable = 1 in { 2090defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2091 "nand", "$rA, $rS, $rB", IIC_IntSimple, 2092 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>; 2093defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2094 "and", "$rA, $rS, $rB", IIC_IntSimple, 2095 [(set i32:$rA, (and i32:$rS, i32:$rB))]>; 2096} // isCommutable 2097defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2098 "andc", "$rA, $rS, $rB", IIC_IntSimple, 2099 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>; 2100let isCommutable = 1 in { 2101defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2102 "or", "$rA, $rS, $rB", IIC_IntSimple, 2103 [(set i32:$rA, (or i32:$rS, i32:$rB))]>; 2104defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2105 "nor", "$rA, $rS, $rB", IIC_IntSimple, 2106 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>; 2107} // isCommutable 2108defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2109 "orc", "$rA, $rS, $rB", IIC_IntSimple, 2110 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>; 2111let isCommutable = 1 in { 2112defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2113 "eqv", "$rA, $rS, $rB", IIC_IntSimple, 2114 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>; 2115defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2116 "xor", "$rA, $rS, $rB", IIC_IntSimple, 2117 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>; 2118} // isCommutable 2119defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2120 "slw", "$rA, $rS, $rB", IIC_IntGeneral, 2121 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>; 2122defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2123 "srw", "$rA, $rS, $rB", IIC_IntGeneral, 2124 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>; 2125defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2126 "sraw", "$rA, $rS, $rB", IIC_IntShift, 2127 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>; 2128} 2129 2130let PPC970_Unit = 1 in { // FXU Operations. 2131let hasSideEffects = 0 in { 2132defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH), 2133 "srawi", "$rA, $rS, $SH", IIC_IntShift, 2134 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>; 2135defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS), 2136 "cntlzw", "$rA, $rS", IIC_IntGeneral, 2137 [(set i32:$rA, (ctlz i32:$rS))]>; 2138defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS), 2139 "cnttzw", "$rA, $rS", IIC_IntGeneral, 2140 [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>; 2141defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS), 2142 "extsb", "$rA, $rS", IIC_IntSimple, 2143 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>; 2144defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS), 2145 "extsh", "$rA, $rS", IIC_IntSimple, 2146 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>; 2147 2148let isCommutable = 1 in 2149def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2150 "cmpb $rA, $rS, $rB", IIC_IntGeneral, 2151 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>; 2152} 2153let isCompare = 1, hasSideEffects = 0 in { 2154 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB), 2155 "cmpw $crD, $rA, $rB", IIC_IntCompare>; 2156 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB), 2157 "cmplw $crD, $rA, $rB", IIC_IntCompare>; 2158} 2159} 2160let PPC970_Unit = 3 in { // FPU Operations. 2161//def FCMPO : XForm_17<63, 32, (outs CRRC:$crD), (ins FPRC:$fA, FPRC:$fB), 2162// "fcmpo $crD, $fA, $fB", IIC_FPCompare>; 2163let isCompare = 1, hasSideEffects = 0 in { 2164 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB), 2165 "fcmpu $crD, $fA, $fB", IIC_FPCompare>; 2166 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2167 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB), 2168 "fcmpu $crD, $fA, $fB", IIC_FPCompare>; 2169} 2170 2171let Uses = [RM] in { 2172 let hasSideEffects = 0 in { 2173 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB), 2174 "fctiw", "$frD, $frB", IIC_FPGeneral, 2175 []>; 2176 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB), 2177 "fctiwz", "$frD, $frB", IIC_FPGeneral, 2178 [(set f64:$frD, (PPCfctiwz f64:$frB))]>; 2179 2180 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB), 2181 "frsp", "$frD, $frB", IIC_FPGeneral, 2182 [(set f32:$frD, (fpround f64:$frB))]>; 2183 2184 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2185 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB), 2186 "frin", "$frD, $frB", IIC_FPGeneral, 2187 [(set f64:$frD, (fround f64:$frB))]>; 2188 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB), 2189 "frin", "$frD, $frB", IIC_FPGeneral, 2190 [(set f32:$frD, (fround f32:$frB))]>; 2191 } 2192 2193 let hasSideEffects = 0 in { 2194 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2195 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB), 2196 "frip", "$frD, $frB", IIC_FPGeneral, 2197 [(set f64:$frD, (fceil f64:$frB))]>; 2198 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB), 2199 "frip", "$frD, $frB", IIC_FPGeneral, 2200 [(set f32:$frD, (fceil f32:$frB))]>; 2201 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2202 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB), 2203 "friz", "$frD, $frB", IIC_FPGeneral, 2204 [(set f64:$frD, (ftrunc f64:$frB))]>; 2205 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB), 2206 "friz", "$frD, $frB", IIC_FPGeneral, 2207 [(set f32:$frD, (ftrunc f32:$frB))]>; 2208 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2209 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB), 2210 "frim", "$frD, $frB", IIC_FPGeneral, 2211 [(set f64:$frD, (ffloor f64:$frB))]>; 2212 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB), 2213 "frim", "$frD, $frB", IIC_FPGeneral, 2214 [(set f32:$frD, (ffloor f32:$frB))]>; 2215 2216 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB), 2217 "fsqrt", "$frD, $frB", IIC_FPSqrtD, 2218 [(set f64:$frD, (fsqrt f64:$frB))]>; 2219 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB), 2220 "fsqrts", "$frD, $frB", IIC_FPSqrtS, 2221 [(set f32:$frD, (fsqrt f32:$frB))]>; 2222 } 2223 } 2224} 2225 2226/// Note that FMR is defined as pseudo-ops on the PPC970 because they are 2227/// often coalesced away and we don't want the dispatch group builder to think 2228/// that they will fill slots (which could cause the load of a LSU reject to 2229/// sneak into a d-group with a store). 2230let hasSideEffects = 0 in 2231defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB), 2232 "fmr", "$frD, $frB", IIC_FPGeneral, 2233 []>, // (set f32:$frD, f32:$frB) 2234 PPC970_Unit_Pseudo; 2235 2236let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations. 2237// These are artificially split into two different forms, for 4/8 byte FP. 2238defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB), 2239 "fabs", "$frD, $frB", IIC_FPGeneral, 2240 [(set f32:$frD, (fabs f32:$frB))]>; 2241let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2242defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB), 2243 "fabs", "$frD, $frB", IIC_FPGeneral, 2244 [(set f64:$frD, (fabs f64:$frB))]>; 2245defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB), 2246 "fnabs", "$frD, $frB", IIC_FPGeneral, 2247 [(set f32:$frD, (fneg (fabs f32:$frB)))]>; 2248let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2249defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB), 2250 "fnabs", "$frD, $frB", IIC_FPGeneral, 2251 [(set f64:$frD, (fneg (fabs f64:$frB)))]>; 2252defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB), 2253 "fneg", "$frD, $frB", IIC_FPGeneral, 2254 [(set f32:$frD, (fneg f32:$frB))]>; 2255let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2256defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB), 2257 "fneg", "$frD, $frB", IIC_FPGeneral, 2258 [(set f64:$frD, (fneg f64:$frB))]>; 2259 2260defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB), 2261 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral, 2262 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>; 2263let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2264defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB), 2265 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral, 2266 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>; 2267 2268// Reciprocal estimates. 2269defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB), 2270 "fre", "$frD, $frB", IIC_FPGeneral, 2271 [(set f64:$frD, (PPCfre f64:$frB))]>; 2272defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB), 2273 "fres", "$frD, $frB", IIC_FPGeneral, 2274 [(set f32:$frD, (PPCfre f32:$frB))]>; 2275defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB), 2276 "frsqrte", "$frD, $frB", IIC_FPGeneral, 2277 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>; 2278defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB), 2279 "frsqrtes", "$frD, $frB", IIC_FPGeneral, 2280 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>; 2281} 2282 2283// XL-Form instructions. condition register logical ops. 2284// 2285let hasSideEffects = 0 in 2286def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA), 2287 "mcrf $BF, $BFA", IIC_BrMCR>, 2288 PPC970_DGroup_First, PPC970_Unit_CRU; 2289 2290// FIXME: According to the ISA (section 2.5.1 of version 2.06), the 2291// condition-register logical instructions have preferred forms. Specifically, 2292// it is preferred that the bit specified by the BT field be in the same 2293// condition register as that specified by the bit BB. We might want to account 2294// for this via hinting the register allocator and anti-dep breakers, or we 2295// could constrain the register class to force this constraint and then loosen 2296// it during register allocation via convertToThreeAddress or some similar 2297// mechanism. 2298 2299let isCommutable = 1 in { 2300def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD), 2301 (ins crbitrc:$CRA, crbitrc:$CRB), 2302 "crand $CRD, $CRA, $CRB", IIC_BrCR, 2303 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>; 2304 2305def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD), 2306 (ins crbitrc:$CRA, crbitrc:$CRB), 2307 "crnand $CRD, $CRA, $CRB", IIC_BrCR, 2308 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>; 2309 2310def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD), 2311 (ins crbitrc:$CRA, crbitrc:$CRB), 2312 "cror $CRD, $CRA, $CRB", IIC_BrCR, 2313 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>; 2314 2315def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD), 2316 (ins crbitrc:$CRA, crbitrc:$CRB), 2317 "crxor $CRD, $CRA, $CRB", IIC_BrCR, 2318 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>; 2319 2320def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD), 2321 (ins crbitrc:$CRA, crbitrc:$CRB), 2322 "crnor $CRD, $CRA, $CRB", IIC_BrCR, 2323 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>; 2324 2325def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD), 2326 (ins crbitrc:$CRA, crbitrc:$CRB), 2327 "creqv $CRD, $CRA, $CRB", IIC_BrCR, 2328 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>; 2329} // isCommutable 2330 2331def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD), 2332 (ins crbitrc:$CRA, crbitrc:$CRB), 2333 "crandc $CRD, $CRA, $CRB", IIC_BrCR, 2334 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>; 2335 2336def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD), 2337 (ins crbitrc:$CRA, crbitrc:$CRB), 2338 "crorc $CRD, $CRA, $CRB", IIC_BrCR, 2339 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>; 2340 2341let isCodeGenOnly = 1 in { 2342def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins), 2343 "creqv $dst, $dst, $dst", IIC_BrCR, 2344 [(set i1:$dst, 1)]>; 2345 2346def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins), 2347 "crxor $dst, $dst, $dst", IIC_BrCR, 2348 [(set i1:$dst, 0)]>; 2349 2350let Defs = [CR1EQ], CRD = 6 in { 2351def CR6SET : XLForm_1_ext<19, 289, (outs), (ins), 2352 "creqv 6, 6, 6", IIC_BrCR, 2353 [(PPCcr6set)]>; 2354 2355def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins), 2356 "crxor 6, 6, 6", IIC_BrCR, 2357 [(PPCcr6unset)]>; 2358} 2359} 2360 2361// XFX-Form instructions. Instructions that deal with SPRs. 2362// 2363 2364def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR), 2365 "mfspr $RT, $SPR", IIC_SprMFSPR>; 2366def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT), 2367 "mtspr $SPR, $RT", IIC_SprMTSPR>; 2368 2369def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR), 2370 "mftb $RT, $SPR", IIC_SprMFTB>; 2371 2372// A pseudo-instruction used to implement the read of the 64-bit cycle counter 2373// on a 32-bit target. 2374let hasSideEffects = 1, usesCustomInserter = 1 in 2375def ReadTB : Pseudo<(outs gprc:$lo, gprc:$hi), (ins), 2376 "#ReadTB", []>; 2377 2378let Uses = [CTR] in { 2379def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins), 2380 "mfctr $rT", IIC_SprMFSPR>, 2381 PPC970_DGroup_First, PPC970_Unit_FXU; 2382} 2383let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in { 2384def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS), 2385 "mtctr $rS", IIC_SprMTSPR>, 2386 PPC970_DGroup_First, PPC970_Unit_FXU; 2387} 2388let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in { 2389let Pattern = [(int_ppc_mtctr i32:$rS)] in 2390def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS), 2391 "mtctr $rS", IIC_SprMTSPR>, 2392 PPC970_DGroup_First, PPC970_Unit_FXU; 2393} 2394 2395let Defs = [LR] in { 2396def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS), 2397 "mtlr $rS", IIC_SprMTSPR>, 2398 PPC970_DGroup_First, PPC970_Unit_FXU; 2399} 2400let Uses = [LR] in { 2401def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins), 2402 "mflr $rT", IIC_SprMFSPR>, 2403 PPC970_DGroup_First, PPC970_Unit_FXU; 2404} 2405 2406let isCodeGenOnly = 1 in { 2407 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed 2408 // like a GPR on the PPC970. As such, copies in and out have the same 2409 // performance characteristics as an OR instruction. 2410 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS), 2411 "mtspr 256, $rS", IIC_IntGeneral>, 2412 PPC970_DGroup_Single, PPC970_Unit_FXU; 2413 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins), 2414 "mfspr $rT, 256", IIC_IntGeneral>, 2415 PPC970_DGroup_First, PPC970_Unit_FXU; 2416 2417 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256, 2418 (outs VRSAVERC:$reg), (ins gprc:$rS), 2419 "mtspr 256, $rS", IIC_IntGeneral>, 2420 PPC970_DGroup_Single, PPC970_Unit_FXU; 2421 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), 2422 (ins VRSAVERC:$reg), 2423 "mfspr $rT, 256", IIC_IntGeneral>, 2424 PPC970_DGroup_First, PPC970_Unit_FXU; 2425} 2426 2427// Aliases for mtvrsave/mfvrsave to mfspr/mtspr. 2428def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>; 2429def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>; 2430 2431// SPILL_VRSAVE - Indicate that we're dumping the VRSAVE register, 2432// so we'll need to scavenge a register for it. 2433let mayStore = 1 in 2434def SPILL_VRSAVE : Pseudo<(outs), (ins VRSAVERC:$vrsave, memri:$F), 2435 "#SPILL_VRSAVE", []>; 2436 2437// RESTORE_VRSAVE - Indicate that we're restoring the VRSAVE register (previously 2438// spilled), so we'll need to scavenge a register for it. 2439let mayLoad = 1 in 2440def RESTORE_VRSAVE : Pseudo<(outs VRSAVERC:$vrsave), (ins memri:$F), 2441 "#RESTORE_VRSAVE", []>; 2442 2443let hasSideEffects = 0 in { 2444// mtocrf's input needs to be prepared by shifting by an amount dependent 2445// on the cr register selected. Thus, post-ra anti-dep breaking must not 2446// later change that register assignment. 2447let hasExtraDefRegAllocReq = 1 in { 2448def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST), 2449 "mtocrf $FXM, $ST", IIC_BrMCRX>, 2450 PPC970_DGroup_First, PPC970_Unit_CRU; 2451 2452// Similarly to mtocrf, the mask for mtcrf must be prepared in a way that 2453// is dependent on the cr fields being set. 2454def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS), 2455 "mtcrf $FXM, $rS", IIC_BrMCRX>, 2456 PPC970_MicroCode, PPC970_Unit_CRU; 2457} // hasExtraDefRegAllocReq = 1 2458 2459// mfocrf's input needs to be prepared by shifting by an amount dependent 2460// on the cr register selected. Thus, post-ra anti-dep breaking must not 2461// later change that register assignment. 2462let hasExtraSrcRegAllocReq = 1 in { 2463def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM), 2464 "mfocrf $rT, $FXM", IIC_SprMFCRF>, 2465 PPC970_DGroup_First, PPC970_Unit_CRU; 2466 2467// Similarly to mfocrf, the mask for mfcrf must be prepared in a way that 2468// is dependent on the cr fields being copied. 2469def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins), 2470 "mfcr $rT", IIC_SprMFCR>, 2471 PPC970_MicroCode, PPC970_Unit_CRU; 2472} // hasExtraSrcRegAllocReq = 1 2473 2474def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins), 2475 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>; 2476} // hasSideEffects = 0 2477 2478// Pseudo instruction to perform FADD in round-to-zero mode. 2479let usesCustomInserter = 1, Uses = [RM] in { 2480 def FADDrtz: Pseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "", 2481 [(set f64:$FRT, (PPCfaddrtz f64:$FRA, f64:$FRB))]>; 2482} 2483 2484// The above pseudo gets expanded to make use of the following instructions 2485// to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level. 2486let Uses = [RM], Defs = [RM] in { 2487 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM), 2488 "mtfsb0 $FM", IIC_IntMTFSB0, []>, 2489 PPC970_DGroup_Single, PPC970_Unit_FPU; 2490 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM), 2491 "mtfsb1 $FM", IIC_IntMTFSB0, []>, 2492 PPC970_DGroup_Single, PPC970_Unit_FPU; 2493 let isCodeGenOnly = 1 in 2494 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT), 2495 "mtfsf $FM, $rT", IIC_IntMTFSB0, []>, 2496 PPC970_DGroup_Single, PPC970_Unit_FPU; 2497} 2498let Uses = [RM] in { 2499 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins), 2500 "mffs $rT", IIC_IntMFFS, 2501 [(set f64:$rT, (PPCmffs))]>, 2502 PPC970_DGroup_Single, PPC970_Unit_FPU; 2503 2504 let Defs = [CR1] in 2505 def MFFSo : XForm_42<63, 583, (outs f8rc:$rT), (ins), 2506 "mffs. $rT", IIC_IntMFFS, []>, isDOT; 2507} 2508 2509 2510let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations. 2511// XO-Form instructions. Arithmetic instructions that can set overflow bit 2512let isCommutable = 1 in 2513defm ADD4 : XOForm_1r<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2514 "add", "$rT, $rA, $rB", IIC_IntSimple, 2515 [(set i32:$rT, (add i32:$rA, i32:$rB))]>; 2516let isCodeGenOnly = 1 in 2517def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB), 2518 "add $rT, $rA, $rB", IIC_IntSimple, 2519 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>; 2520let isCommutable = 1 in 2521defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2522 "addc", "$rT, $rA, $rB", IIC_IntGeneral, 2523 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>, 2524 PPC970_DGroup_Cracked; 2525 2526defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2527 "divw", "$rT, $rA, $rB", IIC_IntDivW, 2528 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>; 2529defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2530 "divwu", "$rT, $rA, $rB", IIC_IntDivW, 2531 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>; 2532def DIVWE : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2533 "divwe $rT, $rA, $rB", IIC_IntDivW, 2534 [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>, 2535 Requires<[HasExtDiv]>; 2536let Defs = [CR0] in 2537def DIVWEo : XOForm_1<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2538 "divwe. $rT, $rA, $rB", IIC_IntDivW, 2539 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First, 2540 Requires<[HasExtDiv]>; 2541def DIVWEU : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2542 "divweu $rT, $rA, $rB", IIC_IntDivW, 2543 [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>, 2544 Requires<[HasExtDiv]>; 2545let Defs = [CR0] in 2546def DIVWEUo : XOForm_1<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2547 "divweu. $rT, $rA, $rB", IIC_IntDivW, 2548 []>, isDOT, PPC970_DGroup_Cracked, PPC970_DGroup_First, 2549 Requires<[HasExtDiv]>; 2550let isCommutable = 1 in { 2551defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2552 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW, 2553 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>; 2554defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2555 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU, 2556 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>; 2557defm MULLW : XOForm_1r<31, 235, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2558 "mullw", "$rT, $rA, $rB", IIC_IntMulHW, 2559 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>; 2560} // isCommutable 2561defm SUBF : XOForm_1r<31, 40, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2562 "subf", "$rT, $rA, $rB", IIC_IntGeneral, 2563 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>; 2564defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2565 "subfc", "$rT, $rA, $rB", IIC_IntGeneral, 2566 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>, 2567 PPC970_DGroup_Cracked; 2568defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA), 2569 "neg", "$rT, $rA", IIC_IntSimple, 2570 [(set i32:$rT, (ineg i32:$rA))]>; 2571let Uses = [CARRY] in { 2572let isCommutable = 1 in 2573defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2574 "adde", "$rT, $rA, $rB", IIC_IntGeneral, 2575 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>; 2576defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA), 2577 "addme", "$rT, $rA", IIC_IntGeneral, 2578 [(set i32:$rT, (adde i32:$rA, -1))]>; 2579defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA), 2580 "addze", "$rT, $rA", IIC_IntGeneral, 2581 [(set i32:$rT, (adde i32:$rA, 0))]>; 2582defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 2583 "subfe", "$rT, $rA, $rB", IIC_IntGeneral, 2584 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>; 2585defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA), 2586 "subfme", "$rT, $rA", IIC_IntGeneral, 2587 [(set i32:$rT, (sube -1, i32:$rA))]>; 2588defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA), 2589 "subfze", "$rT, $rA", IIC_IntGeneral, 2590 [(set i32:$rT, (sube 0, i32:$rA))]>; 2591} 2592} 2593 2594// A-Form instructions. Most of the instructions executed in the FPU are of 2595// this type. 2596// 2597let PPC970_Unit = 3, hasSideEffects = 0 in { // FPU Operations. 2598let Uses = [RM] in { 2599let isCommutable = 1 in { 2600 defm FMADD : AForm_1r<63, 29, 2601 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 2602 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused, 2603 [(set f64:$FRT, (fma f64:$FRA, f64:$FRC, f64:$FRB))]>; 2604 defm FMADDS : AForm_1r<59, 29, 2605 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB), 2606 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 2607 [(set f32:$FRT, (fma f32:$FRA, f32:$FRC, f32:$FRB))]>; 2608 defm FMSUB : AForm_1r<63, 28, 2609 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 2610 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused, 2611 [(set f64:$FRT, 2612 (fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>; 2613 defm FMSUBS : AForm_1r<59, 28, 2614 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB), 2615 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 2616 [(set f32:$FRT, 2617 (fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>; 2618 defm FNMADD : AForm_1r<63, 31, 2619 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 2620 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused, 2621 [(set f64:$FRT, 2622 (fneg (fma f64:$FRA, f64:$FRC, f64:$FRB)))]>; 2623 defm FNMADDS : AForm_1r<59, 31, 2624 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB), 2625 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 2626 [(set f32:$FRT, 2627 (fneg (fma f32:$FRA, f32:$FRC, f32:$FRB)))]>; 2628 defm FNMSUB : AForm_1r<63, 30, 2629 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 2630 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused, 2631 [(set f64:$FRT, (fneg (fma f64:$FRA, f64:$FRC, 2632 (fneg f64:$FRB))))]>; 2633 defm FNMSUBS : AForm_1r<59, 30, 2634 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB), 2635 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 2636 [(set f32:$FRT, (fneg (fma f32:$FRA, f32:$FRC, 2637 (fneg f32:$FRB))))]>; 2638} // isCommutable 2639} 2640// FSEL is artificially split into 4 and 8-byte forms for the result. To avoid 2641// having 4 of these, force the comparison to always be an 8-byte double (code 2642// should use an FMRSD if the input comparison value really wants to be a float) 2643// and 4/8 byte forms for the result and operand type.. 2644let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2645defm FSELD : AForm_1r<63, 23, 2646 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 2647 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 2648 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>; 2649defm FSELS : AForm_1r<63, 23, 2650 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB), 2651 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 2652 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>; 2653let Uses = [RM] in { 2654 let isCommutable = 1 in { 2655 defm FADD : AForm_2r<63, 21, 2656 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), 2657 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub, 2658 [(set f64:$FRT, (fadd f64:$FRA, f64:$FRB))]>; 2659 defm FADDS : AForm_2r<59, 21, 2660 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB), 2661 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral, 2662 [(set f32:$FRT, (fadd f32:$FRA, f32:$FRB))]>; 2663 } // isCommutable 2664 defm FDIV : AForm_2r<63, 18, 2665 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), 2666 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD, 2667 [(set f64:$FRT, (fdiv f64:$FRA, f64:$FRB))]>; 2668 defm FDIVS : AForm_2r<59, 18, 2669 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB), 2670 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS, 2671 [(set f32:$FRT, (fdiv f32:$FRA, f32:$FRB))]>; 2672 let isCommutable = 1 in { 2673 defm FMUL : AForm_3r<63, 25, 2674 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC), 2675 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused, 2676 [(set f64:$FRT, (fmul f64:$FRA, f64:$FRC))]>; 2677 defm FMULS : AForm_3r<59, 25, 2678 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC), 2679 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral, 2680 [(set f32:$FRT, (fmul f32:$FRA, f32:$FRC))]>; 2681 } // isCommutable 2682 defm FSUB : AForm_2r<63, 20, 2683 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), 2684 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub, 2685 [(set f64:$FRT, (fsub f64:$FRA, f64:$FRB))]>; 2686 defm FSUBS : AForm_2r<59, 20, 2687 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB), 2688 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral, 2689 [(set f32:$FRT, (fsub f32:$FRA, f32:$FRB))]>; 2690 } 2691} 2692 2693let hasSideEffects = 0 in { 2694let PPC970_Unit = 1 in { // FXU Operations. 2695 let isSelect = 1 in 2696 def ISEL : AForm_4<31, 15, 2697 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond), 2698 "isel $rT, $rA, $rB, $cond", IIC_IntISEL, 2699 []>; 2700} 2701 2702let PPC970_Unit = 1 in { // FXU Operations. 2703// M-Form instructions. rotate and mask instructions. 2704// 2705let isCommutable = 1 in { 2706// RLWIMI can be commuted if the rotate amount is zero. 2707defm RLWIMI : MForm_2r<20, (outs gprc:$rA), 2708 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB, 2709 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME", 2710 IIC_IntRotate, []>, PPC970_DGroup_Cracked, 2711 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">; 2712} 2713let BaseName = "rlwinm" in { 2714def RLWINM : MForm_2<21, 2715 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME), 2716 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral, 2717 []>, RecFormRel; 2718let Defs = [CR0] in 2719def RLWINMo : MForm_2<21, 2720 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME), 2721 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral, 2722 []>, isDOT, RecFormRel, PPC970_DGroup_Cracked; 2723} 2724defm RLWNM : MForm_2r<23, (outs gprc:$rA), 2725 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME), 2726 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral, 2727 []>; 2728} 2729} // hasSideEffects = 0 2730 2731//===----------------------------------------------------------------------===// 2732// PowerPC Instruction Patterns 2733// 2734 2735// Arbitrary immediate support. Implement in terms of LIS/ORI. 2736def : Pat<(i32 imm:$imm), 2737 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>; 2738 2739// Implement the 'not' operation with the NOR instruction. 2740def i32not : OutPatFrag<(ops node:$in), 2741 (NOR $in, $in)>; 2742def : Pat<(not i32:$in), 2743 (i32not $in)>; 2744 2745// ADD an arbitrary immediate. 2746def : Pat<(add i32:$in, imm:$imm), 2747 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>; 2748// OR an arbitrary immediate. 2749def : Pat<(or i32:$in, imm:$imm), 2750 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>; 2751// XOR an arbitrary immediate. 2752def : Pat<(xor i32:$in, imm:$imm), 2753 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>; 2754// SUBFIC 2755def : Pat<(sub imm32SExt16:$imm, i32:$in), 2756 (SUBFIC $in, imm:$imm)>; 2757 2758// SHL/SRL 2759def : Pat<(shl i32:$in, (i32 imm:$imm)), 2760 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>; 2761def : Pat<(srl i32:$in, (i32 imm:$imm)), 2762 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>; 2763 2764// ROTL 2765def : Pat<(rotl i32:$in, i32:$sh), 2766 (RLWNM $in, $sh, 0, 31)>; 2767def : Pat<(rotl i32:$in, (i32 imm:$imm)), 2768 (RLWINM $in, imm:$imm, 0, 31)>; 2769 2770// RLWNM 2771def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm), 2772 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>; 2773 2774// Calls 2775def : Pat<(PPCcall (i32 tglobaladdr:$dst)), 2776 (BL tglobaladdr:$dst)>; 2777def : Pat<(PPCcall (i32 texternalsym:$dst)), 2778 (BL texternalsym:$dst)>; 2779 2780def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm), 2781 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>; 2782 2783def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm), 2784 (TCRETURNdi texternalsym:$dst, imm:$imm)>; 2785 2786def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm), 2787 (TCRETURNri CTRRC:$dst, imm:$imm)>; 2788 2789 2790 2791// Hi and Lo for Darwin Global Addresses. 2792def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>; 2793def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>; 2794def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>; 2795def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>; 2796def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>; 2797def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>; 2798def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>; 2799def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>; 2800def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in), 2801 (ADDIS $in, tglobaltlsaddr:$g)>; 2802def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in), 2803 (ADDI $in, tglobaltlsaddr:$g)>; 2804def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)), 2805 (ADDIS $in, tglobaladdr:$g)>; 2806def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)), 2807 (ADDIS $in, tconstpool:$g)>; 2808def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)), 2809 (ADDIS $in, tjumptable:$g)>; 2810def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)), 2811 (ADDIS $in, tblockaddress:$g)>; 2812 2813// Support for thread-local storage. 2814def PPC32GOT: Pseudo<(outs gprc:$rD), (ins), "#PPC32GOT", 2815 [(set i32:$rD, (PPCppc32GOT))]>; 2816 2817// Get the _GLOBAL_OFFSET_TABLE_ in PIC mode. 2818// This uses two output registers, the first as the real output, the second as a 2819// temporary register, used internally in code generation. 2820def PPC32PICGOT: Pseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT", 2821 []>, NoEncode<"$rT">; 2822 2823def LDgotTprelL32: Pseudo<(outs gprc:$rD), (ins s16imm:$disp, gprc_nor0:$reg), 2824 "#LDgotTprelL32", 2825 [(set i32:$rD, 2826 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>; 2827def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g), 2828 (ADD4TLS $in, tglobaltlsaddr:$g)>; 2829 2830def ADDItlsgdL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp), 2831 "#ADDItlsgdL32", 2832 [(set i32:$rD, 2833 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>; 2834// LR is a true define, while the rest of the Defs are clobbers. R3 is 2835// explicitly defined when this op is created, so not mentioned here. 2836let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 2837 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in 2838def GETtlsADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym), 2839 "GETtlsADDR32", 2840 [(set i32:$rD, 2841 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>; 2842// Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR 2843// are true defines while the rest of the Defs are clobbers. 2844let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 2845 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in 2846def ADDItlsgdLADDR32 : Pseudo<(outs gprc:$rD), 2847 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym), 2848 "#ADDItlsgdLADDR32", 2849 [(set i32:$rD, 2850 (PPCaddiTlsgdLAddr i32:$reg, 2851 tglobaltlsaddr:$disp, 2852 tglobaltlsaddr:$sym))]>; 2853def ADDItlsldL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp), 2854 "#ADDItlsldL32", 2855 [(set i32:$rD, 2856 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>; 2857// LR is a true define, while the rest of the Defs are clobbers. R3 is 2858// explicitly defined when this op is created, so not mentioned here. 2859let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 2860 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in 2861def GETtlsldADDR32 : Pseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym), 2862 "GETtlsldADDR32", 2863 [(set i32:$rD, 2864 (PPCgetTlsldAddr i32:$reg, 2865 tglobaltlsaddr:$sym))]>; 2866// Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR 2867// are true defines while the rest of the Defs are clobbers. 2868let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 2869 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in 2870def ADDItlsldLADDR32 : Pseudo<(outs gprc:$rD), 2871 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym), 2872 "#ADDItlsldLADDR32", 2873 [(set i32:$rD, 2874 (PPCaddiTlsldLAddr i32:$reg, 2875 tglobaltlsaddr:$disp, 2876 tglobaltlsaddr:$sym))]>; 2877def ADDIdtprelL32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp), 2878 "#ADDIdtprelL32", 2879 [(set i32:$rD, 2880 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>; 2881def ADDISdtprelHA32 : Pseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp), 2882 "#ADDISdtprelHA32", 2883 [(set i32:$rD, 2884 (PPCaddisDtprelHA i32:$reg, 2885 tglobaltlsaddr:$disp))]>; 2886 2887// Support for Position-independent code 2888def LWZtoc : Pseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg), 2889 "#LWZtoc", 2890 [(set i32:$rD, 2891 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>; 2892// Get Global (GOT) Base Register offset, from the word immediately preceding 2893// the function label. 2894def UpdateGBR : Pseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>; 2895 2896 2897// Standard shifts. These are represented separately from the real shifts above 2898// so that we can distinguish between shifts that allow 5-bit and 6-bit shift 2899// amounts. 2900def : Pat<(sra i32:$rS, i32:$rB), 2901 (SRAW $rS, $rB)>; 2902def : Pat<(srl i32:$rS, i32:$rB), 2903 (SRW $rS, $rB)>; 2904def : Pat<(shl i32:$rS, i32:$rB), 2905 (SLW $rS, $rB)>; 2906 2907def : Pat<(zextloadi1 iaddr:$src), 2908 (LBZ iaddr:$src)>; 2909def : Pat<(zextloadi1 xaddr:$src), 2910 (LBZX xaddr:$src)>; 2911def : Pat<(extloadi1 iaddr:$src), 2912 (LBZ iaddr:$src)>; 2913def : Pat<(extloadi1 xaddr:$src), 2914 (LBZX xaddr:$src)>; 2915def : Pat<(extloadi8 iaddr:$src), 2916 (LBZ iaddr:$src)>; 2917def : Pat<(extloadi8 xaddr:$src), 2918 (LBZX xaddr:$src)>; 2919def : Pat<(extloadi16 iaddr:$src), 2920 (LHZ iaddr:$src)>; 2921def : Pat<(extloadi16 xaddr:$src), 2922 (LHZX xaddr:$src)>; 2923def : Pat<(f64 (extloadf32 iaddr:$src)), 2924 (COPY_TO_REGCLASS (LFS iaddr:$src), F8RC)>; 2925def : Pat<(f64 (extloadf32 xaddr:$src)), 2926 (COPY_TO_REGCLASS (LFSX xaddr:$src), F8RC)>; 2927 2928def : Pat<(f64 (fpextend f32:$src)), 2929 (COPY_TO_REGCLASS $src, F8RC)>; 2930 2931// Only seq_cst fences require the heavyweight sync (SYNC 0). 2932// All others can use the lightweight sync (SYNC 1). 2933// source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html 2934// The rule for seq_cst is duplicated to work with both 64 bits and 32 bits 2935// versions of Power. 2936def : Pat<(atomic_fence (i64 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>; 2937def : Pat<(atomic_fence (i32 7), (imm)), (SYNC 0)>, Requires<[HasSYNC]>; 2938def : Pat<(atomic_fence (imm), (imm)), (SYNC 1)>, Requires<[HasSYNC]>; 2939def : Pat<(atomic_fence (imm), (imm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>; 2940 2941// Additional FNMSUB patterns: -a*c + b == -(a*c - b) 2942def : Pat<(fma (fneg f64:$A), f64:$C, f64:$B), 2943 (FNMSUB $A, $C, $B)>; 2944def : Pat<(fma f64:$A, (fneg f64:$C), f64:$B), 2945 (FNMSUB $A, $C, $B)>; 2946def : Pat<(fma (fneg f32:$A), f32:$C, f32:$B), 2947 (FNMSUBS $A, $C, $B)>; 2948def : Pat<(fma f32:$A, (fneg f32:$C), f32:$B), 2949 (FNMSUBS $A, $C, $B)>; 2950 2951// FCOPYSIGN's operand types need not agree. 2952def : Pat<(fcopysign f64:$frB, f32:$frA), 2953 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>; 2954def : Pat<(fcopysign f32:$frB, f64:$frA), 2955 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>; 2956 2957include "PPCInstrAltivec.td" 2958include "PPCInstrSPE.td" 2959include "PPCInstr64Bit.td" 2960include "PPCInstrVSX.td" 2961include "PPCInstrQPX.td" 2962include "PPCInstrHTM.td" 2963 2964def crnot : OutPatFrag<(ops node:$in), 2965 (CRNOR $in, $in)>; 2966def : Pat<(not i1:$in), 2967 (crnot $in)>; 2968 2969// Patterns for arithmetic i1 operations. 2970def : Pat<(add i1:$a, i1:$b), 2971 (CRXOR $a, $b)>; 2972def : Pat<(sub i1:$a, i1:$b), 2973 (CRXOR $a, $b)>; 2974def : Pat<(mul i1:$a, i1:$b), 2975 (CRAND $a, $b)>; 2976 2977// We're sometimes asked to materialize i1 -1, which is just 1 in this case 2978// (-1 is used to mean all bits set). 2979def : Pat<(i1 -1), (CRSET)>; 2980 2981// i1 extensions, implemented in terms of isel. 2982def : Pat<(i32 (zext i1:$in)), 2983 (SELECT_I4 $in, (LI 1), (LI 0))>; 2984def : Pat<(i32 (sext i1:$in)), 2985 (SELECT_I4 $in, (LI -1), (LI 0))>; 2986 2987def : Pat<(i64 (zext i1:$in)), 2988 (SELECT_I8 $in, (LI8 1), (LI8 0))>; 2989def : Pat<(i64 (sext i1:$in)), 2990 (SELECT_I8 $in, (LI8 -1), (LI8 0))>; 2991 2992// FIXME: We should choose either a zext or a sext based on other constants 2993// already around. 2994def : Pat<(i32 (anyext i1:$in)), 2995 (SELECT_I4 $in, (LI 1), (LI 0))>; 2996def : Pat<(i64 (anyext i1:$in)), 2997 (SELECT_I8 $in, (LI8 1), (LI8 0))>; 2998 2999// match setcc on i1 variables. 3000// CRANDC is: 3001// 1 1 : F 3002// 1 0 : T 3003// 0 1 : F 3004// 0 0 : F 3005// 3006// LT is: 3007// -1 -1 : F 3008// -1 0 : T 3009// 0 -1 : F 3010// 0 0 : F 3011// 3012// ULT is: 3013// 1 1 : F 3014// 1 0 : F 3015// 0 1 : T 3016// 0 0 : F 3017def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)), 3018 (CRANDC $s1, $s2)>; 3019def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)), 3020 (CRANDC $s2, $s1)>; 3021// CRORC is: 3022// 1 1 : T 3023// 1 0 : T 3024// 0 1 : F 3025// 0 0 : T 3026// 3027// LE is: 3028// -1 -1 : T 3029// -1 0 : T 3030// 0 -1 : F 3031// 0 0 : T 3032// 3033// ULE is: 3034// 1 1 : T 3035// 1 0 : F 3036// 0 1 : T 3037// 0 0 : T 3038def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)), 3039 (CRORC $s1, $s2)>; 3040def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)), 3041 (CRORC $s2, $s1)>; 3042 3043def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)), 3044 (CREQV $s1, $s2)>; 3045 3046// GE is: 3047// -1 -1 : T 3048// -1 0 : F 3049// 0 -1 : T 3050// 0 0 : T 3051// 3052// UGE is: 3053// 1 1 : T 3054// 1 0 : T 3055// 0 1 : F 3056// 0 0 : T 3057def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)), 3058 (CRORC $s2, $s1)>; 3059def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)), 3060 (CRORC $s1, $s2)>; 3061 3062// GT is: 3063// -1 -1 : F 3064// -1 0 : F 3065// 0 -1 : T 3066// 0 0 : F 3067// 3068// UGT is: 3069// 1 1 : F 3070// 1 0 : T 3071// 0 1 : F 3072// 0 0 : F 3073def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)), 3074 (CRANDC $s2, $s1)>; 3075def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)), 3076 (CRANDC $s1, $s2)>; 3077 3078def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)), 3079 (CRXOR $s1, $s2)>; 3080 3081// match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE, 3082// SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for 3083// floating-point types. 3084 3085multiclass CRNotPat<dag pattern, dag result> { 3086 def : Pat<pattern, (crnot result)>; 3087 def : Pat<(not pattern), result>; 3088 3089 // We can also fold the crnot into an extension: 3090 def : Pat<(i32 (zext pattern)), 3091 (SELECT_I4 result, (LI 0), (LI 1))>; 3092 def : Pat<(i32 (sext pattern)), 3093 (SELECT_I4 result, (LI 0), (LI -1))>; 3094 3095 // We can also fold the crnot into an extension: 3096 def : Pat<(i64 (zext pattern)), 3097 (SELECT_I8 result, (LI8 0), (LI8 1))>; 3098 def : Pat<(i64 (sext pattern)), 3099 (SELECT_I8 result, (LI8 0), (LI8 -1))>; 3100 3101 // FIXME: We should choose either a zext or a sext based on other constants 3102 // already around. 3103 def : Pat<(i32 (anyext pattern)), 3104 (SELECT_I4 result, (LI 0), (LI 1))>; 3105 3106 def : Pat<(i64 (anyext pattern)), 3107 (SELECT_I8 result, (LI8 0), (LI8 1))>; 3108} 3109 3110// FIXME: Because of what seems like a bug in TableGen's type-inference code, 3111// we need to write imm:$imm in the output patterns below, not just $imm, or 3112// else the resulting matcher will not correctly add the immediate operand 3113// (making it a register operand instead). 3114 3115// extended SETCC. 3116multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag, 3117 OutPatFrag rfrag, OutPatFrag rfrag8> { 3118 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))), 3119 (rfrag $s1)>; 3120 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))), 3121 (rfrag8 $s1)>; 3122 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))), 3123 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>; 3124 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))), 3125 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>; 3126 3127 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))), 3128 (rfrag $s1)>; 3129 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))), 3130 (rfrag8 $s1)>; 3131 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))), 3132 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>; 3133 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))), 3134 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>; 3135} 3136 3137// Note that we do all inversions below with i(32|64)not, instead of using 3138// (xori x, 1) because on the A2 nor has single-cycle latency while xori 3139// has 2-cycle latency. 3140 3141defm : ExtSetCCPat<SETEQ, 3142 PatFrag<(ops node:$in, node:$cc), 3143 (setcc $in, 0, $cc)>, 3144 OutPatFrag<(ops node:$in), 3145 (RLWINM (CNTLZW $in), 27, 31, 31)>, 3146 OutPatFrag<(ops node:$in), 3147 (RLDICL (CNTLZD $in), 58, 63)> >; 3148 3149defm : ExtSetCCPat<SETNE, 3150 PatFrag<(ops node:$in, node:$cc), 3151 (setcc $in, 0, $cc)>, 3152 OutPatFrag<(ops node:$in), 3153 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>, 3154 OutPatFrag<(ops node:$in), 3155 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >; 3156 3157defm : ExtSetCCPat<SETLT, 3158 PatFrag<(ops node:$in, node:$cc), 3159 (setcc $in, 0, $cc)>, 3160 OutPatFrag<(ops node:$in), 3161 (RLWINM $in, 1, 31, 31)>, 3162 OutPatFrag<(ops node:$in), 3163 (RLDICL $in, 1, 63)> >; 3164 3165defm : ExtSetCCPat<SETGE, 3166 PatFrag<(ops node:$in, node:$cc), 3167 (setcc $in, 0, $cc)>, 3168 OutPatFrag<(ops node:$in), 3169 (RLWINM (i32not $in), 1, 31, 31)>, 3170 OutPatFrag<(ops node:$in), 3171 (RLDICL (i64not $in), 1, 63)> >; 3172 3173defm : ExtSetCCPat<SETGT, 3174 PatFrag<(ops node:$in, node:$cc), 3175 (setcc $in, 0, $cc)>, 3176 OutPatFrag<(ops node:$in), 3177 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>, 3178 OutPatFrag<(ops node:$in), 3179 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >; 3180 3181defm : ExtSetCCPat<SETLE, 3182 PatFrag<(ops node:$in, node:$cc), 3183 (setcc $in, 0, $cc)>, 3184 OutPatFrag<(ops node:$in), 3185 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>, 3186 OutPatFrag<(ops node:$in), 3187 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >; 3188 3189defm : ExtSetCCPat<SETLT, 3190 PatFrag<(ops node:$in, node:$cc), 3191 (setcc $in, -1, $cc)>, 3192 OutPatFrag<(ops node:$in), 3193 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>, 3194 OutPatFrag<(ops node:$in), 3195 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >; 3196 3197defm : ExtSetCCPat<SETGE, 3198 PatFrag<(ops node:$in, node:$cc), 3199 (setcc $in, -1, $cc)>, 3200 OutPatFrag<(ops node:$in), 3201 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>, 3202 OutPatFrag<(ops node:$in), 3203 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >; 3204 3205defm : ExtSetCCPat<SETGT, 3206 PatFrag<(ops node:$in, node:$cc), 3207 (setcc $in, -1, $cc)>, 3208 OutPatFrag<(ops node:$in), 3209 (RLWINM (i32not $in), 1, 31, 31)>, 3210 OutPatFrag<(ops node:$in), 3211 (RLDICL (i64not $in), 1, 63)> >; 3212 3213defm : ExtSetCCPat<SETLE, 3214 PatFrag<(ops node:$in, node:$cc), 3215 (setcc $in, -1, $cc)>, 3216 OutPatFrag<(ops node:$in), 3217 (RLWINM $in, 1, 31, 31)>, 3218 OutPatFrag<(ops node:$in), 3219 (RLDICL $in, 1, 63)> >; 3220 3221// An extended SETCC with shift amount. 3222multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag, 3223 OutPatFrag rfrag, OutPatFrag rfrag8> { 3224 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))), 3225 (rfrag $s1, $sa)>; 3226 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))), 3227 (rfrag8 $s1, $sa)>; 3228 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))), 3229 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>; 3230 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))), 3231 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>; 3232 3233 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))), 3234 (rfrag $s1, $sa)>; 3235 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))), 3236 (rfrag8 $s1, $sa)>; 3237 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))), 3238 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>; 3239 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))), 3240 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>; 3241} 3242 3243defm : ExtSetCCShiftPat<SETNE, 3244 PatFrag<(ops node:$in, node:$sa, node:$cc), 3245 (setcc (and $in, (shl 1, $sa)), 0, $cc)>, 3246 OutPatFrag<(ops node:$in, node:$sa), 3247 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>, 3248 OutPatFrag<(ops node:$in, node:$sa), 3249 (RLDCL $in, (SUBFIC $sa, 64), 63)> >; 3250 3251defm : ExtSetCCShiftPat<SETEQ, 3252 PatFrag<(ops node:$in, node:$sa, node:$cc), 3253 (setcc (and $in, (shl 1, $sa)), 0, $cc)>, 3254 OutPatFrag<(ops node:$in, node:$sa), 3255 (RLWNM (i32not $in), 3256 (SUBFIC $sa, 32), 31, 31)>, 3257 OutPatFrag<(ops node:$in, node:$sa), 3258 (RLDCL (i64not $in), 3259 (SUBFIC $sa, 64), 63)> >; 3260 3261// SETCC for i32. 3262def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)), 3263 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>; 3264def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)), 3265 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>; 3266def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)), 3267 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>; 3268def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)), 3269 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>; 3270def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)), 3271 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>; 3272def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)), 3273 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>; 3274 3275// For non-equality comparisons, the default code would materialize the 3276// constant, then compare against it, like this: 3277// lis r2, 4660 3278// ori r2, r2, 22136 3279// cmpw cr0, r3, r2 3280// beq cr0,L6 3281// Since we are just comparing for equality, we can emit this instead: 3282// xoris r0,r3,0x1234 3283// cmplwi cr0,r0,0x5678 3284// beq cr0,L6 3285 3286def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)), 3287 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)), 3288 (LO16 imm:$imm)), sub_eq)>; 3289 3290defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)), 3291 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>; 3292defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)), 3293 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>; 3294defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)), 3295 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>; 3296defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)), 3297 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>; 3298defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)), 3299 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>; 3300defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)), 3301 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>; 3302 3303defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)), 3304 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)), 3305 (LO16 imm:$imm)), sub_eq)>; 3306 3307def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)), 3308 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>; 3309def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)), 3310 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>; 3311def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)), 3312 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>; 3313def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)), 3314 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>; 3315def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)), 3316 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>; 3317 3318defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)), 3319 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>; 3320defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)), 3321 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>; 3322defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)), 3323 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>; 3324defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)), 3325 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>; 3326defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)), 3327 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>; 3328 3329// SETCC for i64. 3330def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)), 3331 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>; 3332def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)), 3333 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>; 3334def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)), 3335 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>; 3336def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)), 3337 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>; 3338def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)), 3339 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>; 3340def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)), 3341 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>; 3342 3343// For non-equality comparisons, the default code would materialize the 3344// constant, then compare against it, like this: 3345// lis r2, 4660 3346// ori r2, r2, 22136 3347// cmpd cr0, r3, r2 3348// beq cr0,L6 3349// Since we are just comparing for equality, we can emit this instead: 3350// xoris r0,r3,0x1234 3351// cmpldi cr0,r0,0x5678 3352// beq cr0,L6 3353 3354def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)), 3355 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)), 3356 (LO16 imm:$imm)), sub_eq)>; 3357 3358defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)), 3359 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>; 3360defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)), 3361 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>; 3362defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)), 3363 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>; 3364defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)), 3365 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>; 3366defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)), 3367 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>; 3368defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)), 3369 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>; 3370 3371defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)), 3372 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)), 3373 (LO16 imm:$imm)), sub_eq)>; 3374 3375def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)), 3376 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>; 3377def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)), 3378 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>; 3379def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)), 3380 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>; 3381def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)), 3382 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>; 3383def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)), 3384 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>; 3385 3386defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)), 3387 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>; 3388defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)), 3389 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>; 3390defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)), 3391 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>; 3392defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)), 3393 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>; 3394defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)), 3395 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>; 3396 3397// SETCC for f32. 3398def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOLT)), 3399 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>; 3400def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETLT)), 3401 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>; 3402def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOGT)), 3403 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>; 3404def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETGT)), 3405 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>; 3406def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETOEQ)), 3407 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>; 3408def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETEQ)), 3409 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>; 3410def : Pat<(i1 (setcc f32:$s1, f32:$s2, SETUO)), 3411 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>; 3412 3413defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUGE)), 3414 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>; 3415defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETGE)), 3416 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_lt)>; 3417defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETULE)), 3418 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>; 3419defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETLE)), 3420 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_gt)>; 3421defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETUNE)), 3422 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>; 3423defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETNE)), 3424 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_eq)>; 3425defm : CRNotPat<(i1 (setcc f32:$s1, f32:$s2, SETO)), 3426 (EXTRACT_SUBREG (FCMPUS $s1, $s2), sub_un)>; 3427 3428// SETCC for f64. 3429def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOLT)), 3430 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>; 3431def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETLT)), 3432 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>; 3433def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOGT)), 3434 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>; 3435def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETGT)), 3436 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>; 3437def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETOEQ)), 3438 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>; 3439def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETEQ)), 3440 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>; 3441def : Pat<(i1 (setcc f64:$s1, f64:$s2, SETUO)), 3442 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>; 3443 3444defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUGE)), 3445 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>; 3446defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETGE)), 3447 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_lt)>; 3448defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETULE)), 3449 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>; 3450defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETLE)), 3451 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_gt)>; 3452defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETUNE)), 3453 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>; 3454defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETNE)), 3455 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_eq)>; 3456defm : CRNotPat<(i1 (setcc f64:$s1, f64:$s2, SETO)), 3457 (EXTRACT_SUBREG (FCMPUD $s1, $s2), sub_un)>; 3458 3459// match select on i1 variables: 3460def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)), 3461 (CROR (CRAND $cond , $tval), 3462 (CRAND (crnot $cond), $fval))>; 3463 3464// match selectcc on i1 variables: 3465// select (lhs == rhs), tval, fval is: 3466// ((lhs == rhs) & tval) | (!(lhs == rhs) & fval) 3467def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)), 3468 (CROR (CRAND (CRANDC $lhs, $rhs), $tval), 3469 (CRAND (CRORC $rhs, $lhs), $fval))>; 3470def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)), 3471 (CROR (CRAND (CRANDC $rhs, $lhs), $tval), 3472 (CRAND (CRORC $lhs, $rhs), $fval))>; 3473def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)), 3474 (CROR (CRAND (CRORC $lhs, $rhs), $tval), 3475 (CRAND (CRANDC $rhs, $lhs), $fval))>; 3476def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)), 3477 (CROR (CRAND (CRORC $rhs, $lhs), $tval), 3478 (CRAND (CRANDC $lhs, $rhs), $fval))>; 3479def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)), 3480 (CROR (CRAND (CREQV $lhs, $rhs), $tval), 3481 (CRAND (CRXOR $lhs, $rhs), $fval))>; 3482def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)), 3483 (CROR (CRAND (CRORC $rhs, $lhs), $tval), 3484 (CRAND (CRANDC $lhs, $rhs), $fval))>; 3485def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)), 3486 (CROR (CRAND (CRORC $lhs, $rhs), $tval), 3487 (CRAND (CRANDC $rhs, $lhs), $fval))>; 3488def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)), 3489 (CROR (CRAND (CRANDC $rhs, $lhs), $tval), 3490 (CRAND (CRORC $lhs, $rhs), $fval))>; 3491def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)), 3492 (CROR (CRAND (CRANDC $lhs, $rhs), $tval), 3493 (CRAND (CRORC $rhs, $lhs), $fval))>; 3494def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)), 3495 (CROR (CRAND (CREQV $lhs, $rhs), $fval), 3496 (CRAND (CRXOR $lhs, $rhs), $tval))>; 3497 3498// match selectcc on i1 variables with non-i1 output. 3499def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)), 3500 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>; 3501def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)), 3502 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>; 3503def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)), 3504 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>; 3505def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)), 3506 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>; 3507def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)), 3508 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>; 3509def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)), 3510 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>; 3511def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)), 3512 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>; 3513def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)), 3514 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>; 3515def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)), 3516 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>; 3517def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)), 3518 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>; 3519 3520def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)), 3521 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>; 3522def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)), 3523 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>; 3524def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)), 3525 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>; 3526def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)), 3527 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>; 3528def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)), 3529 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>; 3530def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)), 3531 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>; 3532def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)), 3533 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>; 3534def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)), 3535 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>; 3536def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)), 3537 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>; 3538def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)), 3539 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>; 3540 3541def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)), 3542 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>; 3543def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)), 3544 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>; 3545def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)), 3546 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>; 3547def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)), 3548 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>; 3549def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)), 3550 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>; 3551def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)), 3552 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>; 3553def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)), 3554 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>; 3555def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)), 3556 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>; 3557def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)), 3558 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>; 3559def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)), 3560 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>; 3561 3562def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)), 3563 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>; 3564def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)), 3565 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>; 3566def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)), 3567 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>; 3568def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)), 3569 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>; 3570def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)), 3571 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>; 3572def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)), 3573 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>; 3574def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)), 3575 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>; 3576def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)), 3577 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>; 3578def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)), 3579 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>; 3580def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)), 3581 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>; 3582 3583def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)), 3584 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>; 3585def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)), 3586 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>; 3587def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)), 3588 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>; 3589def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)), 3590 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>; 3591def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)), 3592 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>; 3593def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)), 3594 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>; 3595def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)), 3596 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>; 3597def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)), 3598 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>; 3599def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)), 3600 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>; 3601def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)), 3602 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>; 3603 3604let usesCustomInserter = 1 in { 3605def ANDIo_1_EQ_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in), 3606 "#ANDIo_1_EQ_BIT", 3607 [(set i1:$dst, (trunc (not i32:$in)))]>; 3608def ANDIo_1_GT_BIT : Pseudo<(outs crbitrc:$dst), (ins gprc:$in), 3609 "#ANDIo_1_GT_BIT", 3610 [(set i1:$dst, (trunc i32:$in))]>; 3611 3612def ANDIo_1_EQ_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in), 3613 "#ANDIo_1_EQ_BIT8", 3614 [(set i1:$dst, (trunc (not i64:$in)))]>; 3615def ANDIo_1_GT_BIT8 : Pseudo<(outs crbitrc:$dst), (ins g8rc:$in), 3616 "#ANDIo_1_GT_BIT8", 3617 [(set i1:$dst, (trunc i64:$in))]>; 3618} 3619 3620def : Pat<(i1 (not (trunc i32:$in))), 3621 (ANDIo_1_EQ_BIT $in)>; 3622def : Pat<(i1 (not (trunc i64:$in))), 3623 (ANDIo_1_EQ_BIT8 $in)>; 3624 3625//===----------------------------------------------------------------------===// 3626// PowerPC Instructions used for assembler/disassembler only 3627// 3628 3629// FIXME: For B=0 or B > 8, the registers following RT are used. 3630// WARNING: Do not add patterns for this instruction without fixing this. 3631def LSWI : XForm_base_r3xo<31, 597, (outs gprc:$RT), (ins gprc:$A, u5imm:$B), 3632 "lswi $RT, $A, $B", IIC_LdStLoad, []>; 3633 3634// FIXME: For B=0 or B > 8, the registers following RT are used. 3635// WARNING: Do not add patterns for this instruction without fixing this. 3636def STSWI : XForm_base_r3xo<31, 725, (outs), (ins gprc:$RT, gprc:$A, u5imm:$B), 3637 "stswi $RT, $A, $B", IIC_LdStLoad, []>; 3638 3639def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins), 3640 "isync", IIC_SprISYNC, []>; 3641 3642def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src), 3643 "icbi $src", IIC_LdStICBI, []>; 3644 3645// We used to have EIEIO as value but E[0-9A-Z] is a reserved name 3646def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins), 3647 "eieio", IIC_LdStLoad, []>; 3648 3649def WAIT : XForm_24_sync<31, 62, (outs), (ins i32imm:$L), 3650 "wait $L", IIC_LdStLoad, []>; 3651 3652def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO), 3653 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>; 3654 3655def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR), 3656 "mtsr $SR, $RS", IIC_SprMTSR>; 3657 3658def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR), 3659 "mfsr $RS, $SR", IIC_SprMFSR>; 3660 3661def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB), 3662 "mtsrin $RS, $RB", IIC_SprMTSR>; 3663 3664def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB), 3665 "mfsrin $RS, $RB", IIC_SprMFSR>; 3666 3667def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, i32imm:$L), 3668 "mtmsr $RS, $L", IIC_SprMTMSR>; 3669 3670def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS), 3671 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> { 3672 let L = 0; 3673} 3674 3675def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>, 3676 Requires<[IsBookE]> { 3677 bits<1> E; 3678 3679 let Inst{16} = E; 3680 let Inst{21-30} = 163; 3681} 3682 3683def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B), 3684 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>; 3685def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B), 3686 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>; 3687 3688def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>; 3689def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>; 3690def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>; 3691def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>; 3692 3693def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins), 3694 "mfmsr $RT", IIC_SprMFMSR, []>; 3695 3696def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, i32imm:$L), 3697 "mtmsrd $RS, $L", IIC_SprMTMSRD>; 3698 3699def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA), 3700 "mcrfs $BF, $BFA", IIC_BrMCR>; 3701 3702def MTFSFI : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W), 3703 "mtfsfi $BF, $U, $W", IIC_IntMFFS>; 3704 3705def MTFSFIo : XLForm_4<63, 134, (outs crrc:$BF), (ins i32imm:$U, i32imm:$W), 3706 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isDOT; 3707 3708def : InstAlias<"mtfsfi $BF, $U", (MTFSFI crrc:$BF, i32imm:$U, 0)>; 3709def : InstAlias<"mtfsfi. $BF, $U", (MTFSFIo crrc:$BF, i32imm:$U, 0)>; 3710 3711def MTFSF : XFLForm_1<63, 711, (outs), 3712 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W), 3713 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>; 3714def MTFSFo : XFLForm_1<63, 711, (outs), 3715 (ins i32imm:$FLM, f8rc:$FRB, i32imm:$L, i32imm:$W), 3716 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isDOT; 3717 3718def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>; 3719def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSFo i32imm:$FLM, f8rc:$FRB, 0, 0)>; 3720 3721def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB), 3722 "slbie $RB", IIC_SprSLBIE, []>; 3723 3724def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB), 3725 "slbmte $RS, $RB", IIC_SprSLBMTE, []>; 3726 3727def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB), 3728 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>; 3729 3730def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB), 3731 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>; 3732 3733def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>; 3734 3735def TLBIA : XForm_0<31, 370, (outs), (ins), 3736 "tlbia", IIC_SprTLBIA, []>; 3737 3738def TLBSYNC : XForm_0<31, 566, (outs), (ins), 3739 "tlbsync", IIC_SprTLBSYNC, []>; 3740 3741def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB), 3742 "tlbiel $RB", IIC_SprTLBIEL, []>; 3743 3744def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB), 3745 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>; 3746def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB), 3747 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>; 3748 3749def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB), 3750 "tlbie $RB,$RS", IIC_SprTLBIE, []>; 3751 3752def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B", 3753 IIC_LdStLoad>, Requires<[IsBookE]>; 3754 3755def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B", 3756 IIC_LdStLoad>, Requires<[IsBookE]>; 3757 3758def TLBRE : XForm_24_eieio<31, 946, (outs), (ins), 3759 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>; 3760 3761def TLBWE : XForm_24_eieio<31, 978, (outs), (ins), 3762 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>; 3763 3764def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS), 3765 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>; 3766 3767def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS), 3768 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>; 3769 3770def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B), 3771 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>, 3772 Requires<[IsPPC4xx]>; 3773def TLBSX2D : XForm_base_r3xo<31, 914, (outs), 3774 (ins gprc:$RST, gprc:$A, gprc:$B), 3775 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>, 3776 Requires<[IsPPC4xx]>, isDOT; 3777 3778def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>; 3779 3780def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>, 3781 Requires<[IsBookE]>; 3782def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>, 3783 Requires<[IsBookE]>; 3784 3785def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>, 3786 Requires<[IsE500]>; 3787def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>, 3788 Requires<[IsE500]>; 3789 3790def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR), 3791 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>; 3792def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR), 3793 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>; 3794 3795def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>; 3796def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>; 3797 3798def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>; 3799 3800def LBZCIX : XForm_base_r3xo<31, 853, (outs gprc:$RST), (ins gprc:$A, gprc:$B), 3801 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>; 3802def LHZCIX : XForm_base_r3xo<31, 821, (outs gprc:$RST), (ins gprc:$A, gprc:$B), 3803 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>; 3804def LWZCIX : XForm_base_r3xo<31, 789, (outs gprc:$RST), (ins gprc:$A, gprc:$B), 3805 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>; 3806def LDCIX : XForm_base_r3xo<31, 885, (outs gprc:$RST), (ins gprc:$A, gprc:$B), 3807 "ldcix $RST, $A, $B", IIC_LdStLoad, []>; 3808 3809def STBCIX : XForm_base_r3xo<31, 981, (outs), (ins gprc:$RST, gprc:$A, gprc:$B), 3810 "stbcix $RST, $A, $B", IIC_LdStLoad, []>; 3811def STHCIX : XForm_base_r3xo<31, 949, (outs), (ins gprc:$RST, gprc:$A, gprc:$B), 3812 "sthcix $RST, $A, $B", IIC_LdStLoad, []>; 3813def STWCIX : XForm_base_r3xo<31, 917, (outs), (ins gprc:$RST, gprc:$A, gprc:$B), 3814 "stwcix $RST, $A, $B", IIC_LdStLoad, []>; 3815def STDCIX : XForm_base_r3xo<31, 1013, (outs), (ins gprc:$RST, gprc:$A, gprc:$B), 3816 "stdcix $RST, $A, $B", IIC_LdStLoad, []>; 3817 3818//===----------------------------------------------------------------------===// 3819// PowerPC Assembler Instruction Aliases 3820// 3821 3822// Pseudo-instructions for alternate assembly syntax (never used by codegen). 3823// These are aliases that require C++ handling to convert to the target 3824// instruction, while InstAliases can be handled directly by tblgen. 3825class PPCAsmPseudo<string asm, dag iops> 3826 : Instruction { 3827 let Namespace = "PPC"; 3828 bit PPC64 = 0; // Default value, override with isPPC64 3829 3830 let OutOperandList = (outs); 3831 let InOperandList = iops; 3832 let Pattern = []; 3833 let AsmString = asm; 3834 let isAsmParserOnly = 1; 3835 let isPseudo = 1; 3836} 3837 3838def : InstAlias<"sc", (SC 0)>; 3839 3840def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>; 3841def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>; 3842def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>; 3843def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>; 3844 3845def : InstAlias<"wait", (WAIT 0)>; 3846def : InstAlias<"waitrsv", (WAIT 1)>; 3847def : InstAlias<"waitimpl", (WAIT 2)>; 3848 3849def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>; 3850 3851def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>; 3852def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>; 3853 3854def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>; 3855def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>; 3856def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>; 3857 3858def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>; 3859def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>; 3860def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>; 3861 3862def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>; 3863def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>; 3864def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>; 3865 3866def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>; 3867def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>; 3868def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>; 3869def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>; 3870 3871def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>; 3872def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>; 3873 3874def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>; 3875def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>; 3876 3877def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>; 3878def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>; 3879 3880def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>; 3881def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>; 3882 3883def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>; 3884def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>; 3885 3886def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>; 3887def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>; 3888 3889def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>; 3890def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>; 3891 3892def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>; 3893def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>; 3894 3895def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>; 3896def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>; 3897 3898def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>; 3899def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>; 3900 3901def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>; 3902def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>; 3903 3904def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>; 3905def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>; 3906 3907def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>; 3908def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>; 3909 3910def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>; 3911def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>; 3912 3913def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>; 3914def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>; 3915def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>; 3916 3917def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>; 3918def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>; 3919 3920def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>; 3921def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>; 3922def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>; 3923def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>; 3924 3925def : InstAlias<"xnop", (XORI R0, R0, 0)>; 3926 3927def : InstAlias<"mr $rA, $rB", (OR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>; 3928def : InstAlias<"mr. $rA, $rB", (OR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>; 3929 3930def : InstAlias<"not $rA, $rB", (NOR8 g8rc:$rA, g8rc:$rB, g8rc:$rB)>; 3931def : InstAlias<"not. $rA, $rB", (NOR8o g8rc:$rA, g8rc:$rB, g8rc:$rB)>; 3932 3933def : InstAlias<"mtcr $rA", (MTCRF8 255, g8rc:$rA)>; 3934 3935foreach BATR = 0-3 in { 3936 def : InstAlias<"mtdbatu "#BATR#", $Rx", 3937 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>, 3938 Requires<[IsPPC6xx]>; 3939 def : InstAlias<"mfdbatu $Rx, "#BATR, 3940 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>, 3941 Requires<[IsPPC6xx]>; 3942 def : InstAlias<"mtdbatl "#BATR#", $Rx", 3943 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>, 3944 Requires<[IsPPC6xx]>; 3945 def : InstAlias<"mfdbatl $Rx, "#BATR, 3946 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>, 3947 Requires<[IsPPC6xx]>; 3948 def : InstAlias<"mtibatu "#BATR#", $Rx", 3949 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>, 3950 Requires<[IsPPC6xx]>; 3951 def : InstAlias<"mfibatu $Rx, "#BATR, 3952 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>, 3953 Requires<[IsPPC6xx]>; 3954 def : InstAlias<"mtibatl "#BATR#", $Rx", 3955 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>, 3956 Requires<[IsPPC6xx]>; 3957 def : InstAlias<"mfibatl $Rx, "#BATR, 3958 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>, 3959 Requires<[IsPPC6xx]>; 3960} 3961 3962foreach BR = 0-7 in { 3963 def : InstAlias<"mfbr"#BR#" $Rx", 3964 (MFDCR gprc:$Rx, !add(BR, 0x80))>, 3965 Requires<[IsPPC4xx]>; 3966 def : InstAlias<"mtbr"#BR#" $Rx", 3967 (MTDCR gprc:$Rx, !add(BR, 0x80))>, 3968 Requires<[IsPPC4xx]>; 3969} 3970 3971def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>; 3972def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>; 3973 3974def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>; 3975def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>; 3976 3977def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>; 3978def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>; 3979 3980def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>; 3981def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>; 3982 3983def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>; 3984def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>; 3985 3986def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>; 3987def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>; 3988 3989def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>; 3990 3991def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm", 3992 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>; 3993def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm", 3994 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>; 3995def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm", 3996 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>; 3997def SUBICo : PPCAsmPseudo<"subic. $rA, $rB, $imm", 3998 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>; 3999 4000def : InstAlias<"sub $rA, $rB, $rC", (SUBF8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>; 4001def : InstAlias<"sub. $rA, $rB, $rC", (SUBF8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>; 4002def : InstAlias<"subc $rA, $rB, $rC", (SUBFC8 g8rc:$rA, g8rc:$rC, g8rc:$rB)>; 4003def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC8o g8rc:$rA, g8rc:$rC, g8rc:$rB)>; 4004 4005def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>; 4006def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>; 4007 4008def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>; 4009def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>; 4010 4011foreach SPRG = 0-3 in { 4012 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>; 4013 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>; 4014 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>; 4015 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>; 4016} 4017foreach SPRG = 4-7 in { 4018 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>, 4019 Requires<[IsBookE]>; 4020 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>, 4021 Requires<[IsBookE]>; 4022 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>, 4023 Requires<[IsBookE]>; 4024 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>, 4025 Requires<[IsBookE]>; 4026} 4027 4028def : InstAlias<"mtasr $RS", (MTSPR 280, gprc:$RS)>; 4029 4030def : InstAlias<"mfdec $RT", (MFSPR gprc:$RT, 22)>; 4031def : InstAlias<"mtdec $RT", (MTSPR 22, gprc:$RT)>; 4032 4033def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>; 4034 4035def : InstAlias<"mfsdr1 $RT", (MFSPR gprc:$RT, 25)>; 4036def : InstAlias<"mtsdr1 $RT", (MTSPR 25, gprc:$RT)>; 4037 4038def : InstAlias<"mfsrr0 $RT", (MFSPR gprc:$RT, 26)>; 4039def : InstAlias<"mfsrr1 $RT", (MFSPR gprc:$RT, 27)>; 4040def : InstAlias<"mtsrr0 $RT", (MTSPR 26, gprc:$RT)>; 4041def : InstAlias<"mtsrr1 $RT", (MTSPR 27, gprc:$RT)>; 4042 4043def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>; 4044 4045def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>, 4046 Requires<[IsPPC4xx]>; 4047def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>, 4048 Requires<[IsPPC4xx]>; 4049def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>, 4050 Requires<[IsPPC4xx]>; 4051def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>, 4052 Requires<[IsPPC4xx]>; 4053 4054def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b", 4055 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4056def EXTLWIo : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b", 4057 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4058def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b", 4059 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4060def EXTRWIo : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b", 4061 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4062def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b", 4063 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4064def INSLWIo : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b", 4065 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4066def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b", 4067 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4068def INSRWIo : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b", 4069 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4070def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n", 4071 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4072def ROTRWIo : PPCAsmPseudo<"rotrwi. $rA, $rS, $n", 4073 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4074def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n", 4075 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4076def SLWIo : PPCAsmPseudo<"slwi. $rA, $rS, $n", 4077 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4078def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n", 4079 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4080def SRWIo : PPCAsmPseudo<"srwi. $rA, $rS, $n", 4081 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4082def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n", 4083 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4084def CLRRWIo : PPCAsmPseudo<"clrrwi. $rA, $rS, $n", 4085 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4086def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n", 4087 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>; 4088def CLRLSLWIo : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n", 4089 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>; 4090 4091def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>; 4092def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>; 4093def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>; 4094def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNMo gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>; 4095def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>; 4096def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINMo gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>; 4097 4098def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>; 4099def : InstAlias<"cntlzw. $rA, $rS", (CNTLZWo gprc:$rA, gprc:$rS)>; 4100// The POWER variant 4101def : MnemonicAlias<"cntlz", "cntlzw">; 4102def : MnemonicAlias<"cntlz.", "cntlzw.">; 4103 4104def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b", 4105 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 4106def EXTLDIo : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b", 4107 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 4108def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b", 4109 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 4110def EXTRDIo : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b", 4111 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 4112def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b", 4113 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 4114def INSRDIo : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b", 4115 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 4116def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n", 4117 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 4118def ROTRDIo : PPCAsmPseudo<"rotrdi. $rA, $rS, $n", 4119 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 4120def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n", 4121 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 4122def SLDIo : PPCAsmPseudo<"sldi. $rA, $rS, $n", 4123 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 4124def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n", 4125 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 4126def SRDIo : PPCAsmPseudo<"srdi. $rA, $rS, $n", 4127 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 4128def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n", 4129 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 4130def CLRRDIo : PPCAsmPseudo<"clrrdi. $rA, $rS, $n", 4131 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 4132def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n", 4133 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>; 4134def CLRLSLDIo : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n", 4135 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>; 4136 4137def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>; 4138def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>; 4139def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>; 4140def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCLo g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>; 4141def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>; 4142def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICLo g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>; 4143 4144def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b", 4145 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 4146def RLWINMobm : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b", 4147 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 4148def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b", 4149 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 4150def RLWIMIobm : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b", 4151 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 4152def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b", 4153 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 4154def RLWNMobm : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b", 4155 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 4156 4157// These generic branch instruction forms are used for the assembler parser only. 4158// Defs and Uses are conservative, since we don't know the BO value. 4159let PPC970_Unit = 7 in { 4160 let Defs = [CTR], Uses = [CTR, RM] in { 4161 def gBC : BForm_3<16, 0, 0, (outs), 4162 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst), 4163 "bc $bo, $bi, $dst">; 4164 def gBCA : BForm_3<16, 1, 0, (outs), 4165 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst), 4166 "bca $bo, $bi, $dst">; 4167 let isAsmParserOnly = 1 in { 4168 def gBCat : BForm_3_at<16, 0, 0, (outs), 4169 (ins u5imm:$bo, atimm:$at, crbitrc:$bi, 4170 condbrtarget:$dst), 4171 "bc$at $bo, $bi, $dst">; 4172 def gBCAat : BForm_3_at<16, 1, 0, (outs), 4173 (ins u5imm:$bo, atimm:$at, crbitrc:$bi, 4174 abscondbrtarget:$dst), 4175 "bca$at $bo, $bi, $dst">; 4176 } // isAsmParserOnly = 1 4177 } 4178 let Defs = [LR, CTR], Uses = [CTR, RM] in { 4179 def gBCL : BForm_3<16, 0, 1, (outs), 4180 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst), 4181 "bcl $bo, $bi, $dst">; 4182 def gBCLA : BForm_3<16, 1, 1, (outs), 4183 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst), 4184 "bcla $bo, $bi, $dst">; 4185 let isAsmParserOnly = 1 in { 4186 def gBCLat : BForm_3_at<16, 0, 1, (outs), 4187 (ins u5imm:$bo, atimm:$at, crbitrc:$bi, 4188 condbrtarget:$dst), 4189 "bcl$at $bo, $bi, $dst">; 4190 def gBCLAat : BForm_3_at<16, 1, 1, (outs), 4191 (ins u5imm:$bo, atimm:$at, crbitrc:$bi, 4192 abscondbrtarget:$dst), 4193 "bcla$at $bo, $bi, $dst">; 4194 } // // isAsmParserOnly = 1 4195 } 4196 let Defs = [CTR], Uses = [CTR, LR, RM] in 4197 def gBCLR : XLForm_2<19, 16, 0, (outs), 4198 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh), 4199 "bclr $bo, $bi, $bh", IIC_BrB, []>; 4200 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in 4201 def gBCLRL : XLForm_2<19, 16, 1, (outs), 4202 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh), 4203 "bclrl $bo, $bi, $bh", IIC_BrB, []>; 4204 let Defs = [CTR], Uses = [CTR, LR, RM] in 4205 def gBCCTR : XLForm_2<19, 528, 0, (outs), 4206 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh), 4207 "bcctr $bo, $bi, $bh", IIC_BrB, []>; 4208 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in 4209 def gBCCTRL : XLForm_2<19, 528, 1, (outs), 4210 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh), 4211 "bcctrl $bo, $bi, $bh", IIC_BrB, []>; 4212} 4213 4214multiclass BranchSimpleMnemonicAT<string pm, int at> { 4215 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi, 4216 condbrtarget:$dst)>; 4217 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi, 4218 condbrtarget:$dst)>; 4219 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi, 4220 condbrtarget:$dst)>; 4221 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi, 4222 condbrtarget:$dst)>; 4223} 4224defm : BranchSimpleMnemonicAT<"+", 3>; 4225defm : BranchSimpleMnemonicAT<"-", 2>; 4226 4227def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>; 4228def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>; 4229def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>; 4230def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>; 4231 4232multiclass BranchSimpleMnemonic1<string name, string pm, int bo> { 4233 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>; 4234 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>; 4235 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>; 4236 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>; 4237 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>; 4238 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>; 4239} 4240multiclass BranchSimpleMnemonic2<string name, string pm, int bo> 4241 : BranchSimpleMnemonic1<name, pm, bo> { 4242 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>; 4243 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>; 4244} 4245defm : BranchSimpleMnemonic2<"t", "", 12>; 4246defm : BranchSimpleMnemonic2<"f", "", 4>; 4247defm : BranchSimpleMnemonic2<"t", "-", 14>; 4248defm : BranchSimpleMnemonic2<"f", "-", 6>; 4249defm : BranchSimpleMnemonic2<"t", "+", 15>; 4250defm : BranchSimpleMnemonic2<"f", "+", 7>; 4251defm : BranchSimpleMnemonic1<"dnzt", "", 8>; 4252defm : BranchSimpleMnemonic1<"dnzf", "", 0>; 4253defm : BranchSimpleMnemonic1<"dzt", "", 10>; 4254defm : BranchSimpleMnemonic1<"dzf", "", 2>; 4255 4256multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> { 4257 def : InstAlias<"b"#name#pm#" $cc, $dst", 4258 (BCC bibo, crrc:$cc, condbrtarget:$dst)>; 4259 def : InstAlias<"b"#name#pm#" $dst", 4260 (BCC bibo, CR0, condbrtarget:$dst)>; 4261 4262 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst", 4263 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>; 4264 def : InstAlias<"b"#name#"a"#pm#" $dst", 4265 (BCCA bibo, CR0, abscondbrtarget:$dst)>; 4266 4267 def : InstAlias<"b"#name#"lr"#pm#" $cc", 4268 (BCCLR bibo, crrc:$cc)>; 4269 def : InstAlias<"b"#name#"lr"#pm, 4270 (BCCLR bibo, CR0)>; 4271 4272 def : InstAlias<"b"#name#"ctr"#pm#" $cc", 4273 (BCCCTR bibo, crrc:$cc)>; 4274 def : InstAlias<"b"#name#"ctr"#pm, 4275 (BCCCTR bibo, CR0)>; 4276 4277 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst", 4278 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>; 4279 def : InstAlias<"b"#name#"l"#pm#" $dst", 4280 (BCCL bibo, CR0, condbrtarget:$dst)>; 4281 4282 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst", 4283 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>; 4284 def : InstAlias<"b"#name#"la"#pm#" $dst", 4285 (BCCLA bibo, CR0, abscondbrtarget:$dst)>; 4286 4287 def : InstAlias<"b"#name#"lrl"#pm#" $cc", 4288 (BCCLRL bibo, crrc:$cc)>; 4289 def : InstAlias<"b"#name#"lrl"#pm, 4290 (BCCLRL bibo, CR0)>; 4291 4292 def : InstAlias<"b"#name#"ctrl"#pm#" $cc", 4293 (BCCCTRL bibo, crrc:$cc)>; 4294 def : InstAlias<"b"#name#"ctrl"#pm, 4295 (BCCCTRL bibo, CR0)>; 4296} 4297multiclass BranchExtendedMnemonic<string name, int bibo> { 4298 defm : BranchExtendedMnemonicPM<name, "", bibo>; 4299 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>; 4300 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>; 4301} 4302defm : BranchExtendedMnemonic<"lt", 12>; 4303defm : BranchExtendedMnemonic<"gt", 44>; 4304defm : BranchExtendedMnemonic<"eq", 76>; 4305defm : BranchExtendedMnemonic<"un", 108>; 4306defm : BranchExtendedMnemonic<"so", 108>; 4307defm : BranchExtendedMnemonic<"ge", 4>; 4308defm : BranchExtendedMnemonic<"nl", 4>; 4309defm : BranchExtendedMnemonic<"le", 36>; 4310defm : BranchExtendedMnemonic<"ng", 36>; 4311defm : BranchExtendedMnemonic<"ne", 68>; 4312defm : BranchExtendedMnemonic<"nu", 100>; 4313defm : BranchExtendedMnemonic<"ns", 100>; 4314 4315def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>; 4316def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>; 4317def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>; 4318def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>; 4319def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>; 4320def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>; 4321def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>; 4322def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>; 4323 4324def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>; 4325def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>; 4326def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>; 4327def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>; 4328def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>; 4329def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>; 4330def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>; 4331def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>; 4332 4333multiclass TrapExtendedMnemonic<string name, int to> { 4334 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>; 4335 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>; 4336 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>; 4337 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>; 4338} 4339defm : TrapExtendedMnemonic<"lt", 16>; 4340defm : TrapExtendedMnemonic<"le", 20>; 4341defm : TrapExtendedMnemonic<"eq", 4>; 4342defm : TrapExtendedMnemonic<"ge", 12>; 4343defm : TrapExtendedMnemonic<"gt", 8>; 4344defm : TrapExtendedMnemonic<"nl", 12>; 4345defm : TrapExtendedMnemonic<"ne", 24>; 4346defm : TrapExtendedMnemonic<"ng", 20>; 4347defm : TrapExtendedMnemonic<"llt", 2>; 4348defm : TrapExtendedMnemonic<"lle", 6>; 4349defm : TrapExtendedMnemonic<"lge", 5>; 4350defm : TrapExtendedMnemonic<"lgt", 1>; 4351defm : TrapExtendedMnemonic<"lnl", 5>; 4352defm : TrapExtendedMnemonic<"lng", 6>; 4353defm : TrapExtendedMnemonic<"u", 31>; 4354 4355// Atomic loads 4356def : Pat<(atomic_load_8 iaddr:$src), (LBZ memri:$src)>; 4357def : Pat<(atomic_load_16 iaddr:$src), (LHZ memri:$src)>; 4358def : Pat<(atomic_load_32 iaddr:$src), (LWZ memri:$src)>; 4359def : Pat<(atomic_load_8 xaddr:$src), (LBZX memrr:$src)>; 4360def : Pat<(atomic_load_16 xaddr:$src), (LHZX memrr:$src)>; 4361def : Pat<(atomic_load_32 xaddr:$src), (LWZX memrr:$src)>; 4362 4363// Atomic stores 4364def : Pat<(atomic_store_8 iaddr:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>; 4365def : Pat<(atomic_store_16 iaddr:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>; 4366def : Pat<(atomic_store_32 iaddr:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>; 4367def : Pat<(atomic_store_8 xaddr:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>; 4368def : Pat<(atomic_store_16 xaddr:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>; 4369def : Pat<(atomic_store_32 xaddr:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>; 4370 4371let Predicates = [IsISA3_0] in { 4372 4373// Copy-Paste Facility 4374// We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to 4375// PASTE for naming consistency. 4376let mayLoad = 1 in 4377def CP_COPY : X_L1_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>; 4378 4379let mayStore = 1 in 4380def CP_PASTE : X_L1_RA5_RB5<31, 902, "paste" , gprc, IIC_LdStPASTE, []>; 4381 4382let mayStore = 1, Defs = [CR0] in 4383def CP_PASTEo : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isDOT; 4384 4385def CP_COPYx : PPCAsmPseudo<"copy $rA, $rB" , (ins gprc:$rA, gprc:$rB)>; 4386def CP_PASTEx : PPCAsmPseudo<"paste $rA, $rB", (ins gprc:$rA, gprc:$rB)>; 4387def CP_COPY_FIRST : PPCAsmPseudo<"copy_first $rA, $rB", 4388 (ins gprc:$rA, gprc:$rB)>; 4389def CP_PASTE_LAST : PPCAsmPseudo<"paste_last $rA, $rB", 4390 (ins gprc:$rA, gprc:$rB)>; 4391def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cp_abort", IIC_SprABORT, []>; 4392 4393// Message Synchronize 4394def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>; 4395 4396// Power-Saving Mode Instruction: 4397def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>; 4398 4399} // IsISA3_0 4400