1//===-- PPCInstrInfo.td - The PowerPC Instruction Set ------*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// This file describes the subset of the 32-bit PowerPC instruction set, as used 10// by the PowerPC instruction selector. 11// 12//===----------------------------------------------------------------------===// 13 14include "PPCInstrFormats.td" 15 16//===----------------------------------------------------------------------===// 17// PowerPC specific type constraints. 18// 19def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx 20 SDTCisVT<0, f64>, SDTCisPtrTy<1> 21]>; 22def SDT_PPClfiwx : SDTypeProfile<1, 1, [ // lfiw[az]x 23 SDTCisVT<0, f64>, SDTCisPtrTy<1> 24]>; 25def SDT_PPCLxsizx : SDTypeProfile<1, 2, [ 26 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2> 27]>; 28def SDT_PPCstxsix : SDTypeProfile<0, 3, [ 29 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2> 30]>; 31def SDT_PPCcv_fp_to_int : SDTypeProfile<1, 1, [ 32 SDTCisFP<0>, SDTCisFP<1> 33 ]>; 34def SDT_PPCstore_scal_int_from_vsr : SDTypeProfile<0, 3, [ 35 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2> 36]>; 37def SDT_PPCVexts : SDTypeProfile<1, 2, [ 38 SDTCisVT<0, f64>, SDTCisVT<1, f64>, SDTCisPtrTy<2> 39]>; 40 41def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>, 42 SDTCisVT<1, i32> ]>; 43def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, 44 SDTCisVT<1, i32> ]>; 45def SDT_PPCvperm : SDTypeProfile<1, 3, [ 46 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2> 47]>; 48 49def SDT_PPCVecSplat : SDTypeProfile<1, 2, [ SDTCisVec<0>, 50 SDTCisVec<1>, SDTCisInt<2> 51]>; 52 53def SDT_PPCSpToDp : SDTypeProfile<1, 1, [ SDTCisVT<0, v2f64>, 54 SDTCisInt<1> 55]>; 56 57def SDT_PPCVecShift : SDTypeProfile<1, 3, [ SDTCisVec<0>, 58 SDTCisVec<1>, SDTCisVec<2>, SDTCisPtrTy<3> 59]>; 60 61def SDT_PPCVecInsert : SDTypeProfile<1, 3, [ SDTCisVec<0>, 62 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3> 63]>; 64 65def SDT_PPCxxpermdi: SDTypeProfile<1, 3, [ SDTCisVec<0>, 66 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3> 67]>; 68 69def SDT_PPCvcmp : SDTypeProfile<1, 3, [ 70 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32> 71]>; 72 73def SDT_PPCcondbr : SDTypeProfile<0, 3, [ 74 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT> 75]>; 76 77def SDT_PPCFtsqrt : SDTypeProfile<1, 1, [ 78 SDTCisVT<0, i32>]>; 79 80def SDT_PPClbrx : SDTypeProfile<1, 2, [ 81 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT> 82]>; 83def SDT_PPCstbrx : SDTypeProfile<0, 3, [ 84 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT> 85]>; 86 87def SDT_PPCTC_ret : SDTypeProfile<0, 2, [ 88 SDTCisPtrTy<0>, SDTCisVT<1, i32> 89]>; 90 91def tocentry32 : Operand<iPTR> { 92 let MIOperandInfo = (ops i32imm:$imm); 93} 94 95def SDT_PPCqvfperm : SDTypeProfile<1, 3, [ 96 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3> 97]>; 98def SDT_PPCqvgpci : SDTypeProfile<1, 1, [ 99 SDTCisVec<0>, SDTCisInt<1> 100]>; 101def SDT_PPCqvaligni : SDTypeProfile<1, 3, [ 102 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3> 103]>; 104def SDT_PPCqvesplati : SDTypeProfile<1, 2, [ 105 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2> 106]>; 107 108def SDT_PPCqbflt : SDTypeProfile<1, 1, [ 109 SDTCisVec<0>, SDTCisVec<1> 110]>; 111 112def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [ 113 SDTCisVec<0>, SDTCisPtrTy<1> 114]>; 115 116def SDT_PPCextswsli : SDTypeProfile<1, 2, [ // extswsli 117 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisInt<2> 118]>; 119 120def SDT_PPCFPMinMax : SDTypeProfile<1, 2, [ 121 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0> 122]>; 123 124//===----------------------------------------------------------------------===// 125// PowerPC specific DAG Nodes. 126// 127 128def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>; 129def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>; 130def PPCfsqrt : SDNode<"PPCISD::FSQRT", SDTFPUnaryOp, []>; 131def PPCftsqrt : SDNode<"PPCISD::FTSQRT", SDT_PPCFtsqrt,[]>; 132 133def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>; 134def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>; 135def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>; 136def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>; 137def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>; 138def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>; 139def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>; 140def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>; 141 142def PPCstrict_fcfid : SDNode<"PPCISD::STRICT_FCFID", 143 SDTFPUnaryOp, [SDNPHasChain]>; 144def PPCstrict_fcfidu : SDNode<"PPCISD::STRICT_FCFIDU", 145 SDTFPUnaryOp, [SDNPHasChain]>; 146def PPCstrict_fcfids : SDNode<"PPCISD::STRICT_FCFIDS", 147 SDTFPRoundOp, [SDNPHasChain]>; 148def PPCstrict_fcfidus : SDNode<"PPCISD::STRICT_FCFIDUS", 149 SDTFPRoundOp, [SDNPHasChain]>; 150 151def PPCany_fcfid : PatFrags<(ops node:$op), 152 [(PPCfcfid node:$op), 153 (PPCstrict_fcfid node:$op)]>; 154def PPCany_fcfidu : PatFrags<(ops node:$op), 155 [(PPCfcfidu node:$op), 156 (PPCstrict_fcfidu node:$op)]>; 157def PPCany_fcfids : PatFrags<(ops node:$op), 158 [(PPCfcfids node:$op), 159 (PPCstrict_fcfids node:$op)]>; 160def PPCany_fcfidus : PatFrags<(ops node:$op), 161 [(PPCfcfidus node:$op), 162 (PPCstrict_fcfidus node:$op)]>; 163 164def PPCcv_fp_to_uint_in_vsr: 165 SDNode<"PPCISD::FP_TO_UINT_IN_VSR", SDT_PPCcv_fp_to_int, []>; 166def PPCcv_fp_to_sint_in_vsr: 167 SDNode<"PPCISD::FP_TO_SINT_IN_VSR", SDT_PPCcv_fp_to_int, []>; 168def PPCstore_scal_int_from_vsr: 169 SDNode<"PPCISD::ST_VSR_SCAL_INT", SDT_PPCstore_scal_int_from_vsr, 170 [SDNPHasChain, SDNPMayStore]>; 171def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx, 172 [SDNPHasChain, SDNPMayStore]>; 173def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx, 174 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 175def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx, 176 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 177def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx, 178 [SDNPHasChain, SDNPMayLoad]>; 179def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix, 180 [SDNPHasChain, SDNPMayStore]>; 181def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>; 182 183// Extract FPSCR (not modeled at the DAG level). 184def PPCmffs : SDNode<"PPCISD::MFFS", 185 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>, 186 [SDNPHasChain]>; 187 188// Perform FADD in round-to-zero mode. 189def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>; 190def PPCstrict_faddrtz: SDNode<"PPCISD::STRICT_FADDRTZ", SDTFPBinOp, 191 [SDNPHasChain]>; 192 193def PPCany_faddrtz: PatFrags<(ops node:$lhs, node:$rhs), 194 [(PPCfaddrtz node:$lhs, node:$rhs), 195 (PPCstrict_faddrtz node:$lhs, node:$rhs)]>; 196 197def PPCfsel : SDNode<"PPCISD::FSEL", 198 // Type constraint for fsel. 199 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>, 200 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>; 201def PPCxsmaxc : SDNode<"PPCISD::XSMAXCDP", SDT_PPCFPMinMax, []>; 202def PPCxsminc : SDNode<"PPCISD::XSMINCDP", SDT_PPCFPMinMax, []>; 203def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>; 204def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>; 205def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp, 206 [SDNPMayLoad, SDNPMemOperand]>; 207 208def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>; 209 210def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>; 211def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp, 212 [SDNPMayLoad]>; 213def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>; 214def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>; 215def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>; 216def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>; 217def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR", 218 SDTypeProfile<1, 3, [ 219 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, 220 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>; 221def PPCTlsgdAIX : SDNode<"PPCISD::TLSGD_AIX", SDTIntBinOp>; 222def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>; 223def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>; 224def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>; 225def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR", 226 SDTypeProfile<1, 3, [ 227 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, 228 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>; 229def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>; 230def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>; 231def PPCpaddiDtprel : SDNode<"PPCISD::PADDI_DTPREL", SDTIntBinOp>; 232 233def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>; 234def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>; 235def PPCxxspltidp : SDNode<"PPCISD::XXSPLTI_SP_TO_DP", SDT_PPCSpToDp, []>; 236def PPCvecinsert : SDNode<"PPCISD::VECINSERT", SDT_PPCVecInsert, []>; 237def PPCxxpermdi : SDNode<"PPCISD::XXPERMDI", SDT_PPCxxpermdi, []>; 238def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>; 239 240def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>; 241 242// These nodes represent the 32-bit PPC shifts that operate on 6-bit shift 243// amounts. These nodes are generated by the multi-precision shift code. 244def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>; 245def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>; 246def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>; 247 248def PPCfnmsub : SDNode<"PPCISD::FNMSUB" , SDTFPTernaryOp>; 249 250def PPCextswsli : SDNode<"PPCISD::EXTSWSLI" , SDT_PPCextswsli>; 251 252def PPCstrict_fctidz : SDNode<"PPCISD::STRICT_FCTIDZ", 253 SDTFPUnaryOp, [SDNPHasChain]>; 254def PPCstrict_fctiwz : SDNode<"PPCISD::STRICT_FCTIWZ", 255 SDTFPUnaryOp, [SDNPHasChain]>; 256def PPCstrict_fctiduz : SDNode<"PPCISD::STRICT_FCTIDUZ", 257 SDTFPUnaryOp, [SDNPHasChain]>; 258def PPCstrict_fctiwuz : SDNode<"PPCISD::STRICT_FCTIWUZ", 259 SDTFPUnaryOp, [SDNPHasChain]>; 260 261def PPCany_fctidz : PatFrags<(ops node:$op), 262 [(PPCstrict_fctidz node:$op), 263 (PPCfctidz node:$op)]>; 264def PPCany_fctiwz : PatFrags<(ops node:$op), 265 [(PPCstrict_fctiwz node:$op), 266 (PPCfctiwz node:$op)]>; 267def PPCany_fctiduz : PatFrags<(ops node:$op), 268 [(PPCstrict_fctiduz node:$op), 269 (PPCfctiduz node:$op)]>; 270def PPCany_fctiwuz : PatFrags<(ops node:$op), 271 [(PPCstrict_fctiwuz node:$op), 272 (PPCfctiwuz node:$op)]>; 273 274// Move 2 i64 values into a VSX register 275def PPCbuild_fp128: SDNode<"PPCISD::BUILD_FP128", 276 SDTypeProfile<1, 2, 277 [SDTCisFP<0>, SDTCisSameSizeAs<1,2>, 278 SDTCisSameAs<1,2>]>, 279 []>; 280 281def PPCbuild_spe64: SDNode<"PPCISD::BUILD_SPE64", 282 SDTypeProfile<1, 2, 283 [SDTCisVT<0, f64>, SDTCisVT<1,i32>, 284 SDTCisVT<1,i32>]>, 285 []>; 286 287def PPCextract_spe : SDNode<"PPCISD::EXTRACT_SPE", 288 SDTypeProfile<1, 2, 289 [SDTCisVT<0, i32>, SDTCisVT<1, f64>, 290 SDTCisPtrTy<2>]>, 291 []>; 292 293// These are target-independent nodes, but have target-specific formats. 294def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart, 295 [SDNPHasChain, SDNPOutGlue]>; 296def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd, 297 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 298 299def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>; 300def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall, 301 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 302 SDNPVariadic]>; 303def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall, 304 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 305 SDNPVariadic]>; 306def PPCcall_notoc : SDNode<"PPCISD::CALL_NOTOC", SDT_PPCCall, 307 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 308 SDNPVariadic]>; 309def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall, 310 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 311def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone, 312 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 313 SDNPVariadic]>; 314def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC", 315 SDTypeProfile<0, 1, []>, 316 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, 317 SDNPVariadic]>; 318 319def retflag : SDNode<"PPCISD::RET_FLAG", SDTNone, 320 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 321 322def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret, 323 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>; 324 325def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP", 326 SDTypeProfile<1, 1, [SDTCisInt<0>, 327 SDTCisPtrTy<1>]>, 328 [SDNPHasChain, SDNPSideEffect]>; 329def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP", 330 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>, 331 [SDNPHasChain, SDNPSideEffect]>; 332 333def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>; 334def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc, 335 [SDNPHasChain, SDNPSideEffect]>; 336 337def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone, 338 [SDNPHasChain, SDNPSideEffect]>; 339def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>; 340def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc, 341 [SDNPHasChain, SDNPSideEffect]>; 342 343def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>; 344def PPCvcmp_rec : SDNode<"PPCISD::VCMP_rec", SDT_PPCvcmp, [SDNPOutGlue]>; 345 346def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr, 347 [SDNPHasChain, SDNPOptInGlue]>; 348 349// PPC-specific atomic operations. 350def PPCatomicCmpSwap_8 : 351 SDNode<"PPCISD::ATOMIC_CMP_SWAP_8", SDTAtomic3, 352 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 353def PPCatomicCmpSwap_16 : 354 SDNode<"PPCISD::ATOMIC_CMP_SWAP_16", SDTAtomic3, 355 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>; 356def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx, 357 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>; 358def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx, 359 [SDNPHasChain, SDNPMayStore]>; 360 361// Instructions to set/unset CR bit 6 for SVR4 vararg calls 362def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone, 363 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 364def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone, 365 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>; 366 367// Instructions to support dynamic alloca. 368def SDTDynOp : SDTypeProfile<1, 2, []>; 369def SDTDynAreaOp : SDTypeProfile<1, 1, []>; 370def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>; 371def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>; 372def PPCprobedalloca : SDNode<"PPCISD::PROBED_ALLOCA", SDTDynOp, [SDNPHasChain]>; 373 374// PC Relative Specific Nodes 375def PPCmatpcreladdr : SDNode<"PPCISD::MAT_PCREL_ADDR", SDTIntUnaryOp, []>; 376def PPCtlsdynamatpcreladdr : SDNode<"PPCISD::TLS_DYNAMIC_MAT_PCREL_ADDR", 377 SDTIntUnaryOp, []>; 378def PPCtlslocalexecmataddr : SDNode<"PPCISD::TLS_LOCAL_EXEC_MAT_ADDR", 379 SDTIntUnaryOp, []>; 380 381//===----------------------------------------------------------------------===// 382// PowerPC specific transformation functions and pattern fragments. 383// 384 385// A floating point immediate that is not a positive zero and can be converted 386// to a single precision floating point non-denormal immediate without loss of 387// information. 388def nzFPImmAsi32 : PatLeaf<(fpimm), [{ 389 APFloat APFloatOfN = N->getValueAPF(); 390 return convertToNonDenormSingle(APFloatOfN) && !N->isExactlyValue(+0.0); 391}]>; 392 393// Convert the floating point immediate into a 32 bit floating point immediate 394// and get a i32 with the resulting bits. 395def getFPAs32BitInt : SDNodeXForm<fpimm, [{ 396 APFloat APFloatOfN = N->getValueAPF(); 397 convertToNonDenormSingle(APFloatOfN); 398 return CurDAG->getTargetConstant(APFloatOfN.bitcastToAPInt().getZExtValue(), 399 SDLoc(N), MVT::i32); 400}]>; 401 402// Check if the value can be converted to be single precision immediate, which 403// can be exploited by XXSPLTIDP. Ensure that it cannot be converted to single 404// precision before exploiting with XXSPLTI32DX. 405def nzFPImmAsi64 : PatLeaf<(fpimm), [{ 406 APFloat APFloatOfN = N->getValueAPF(); 407 return !N->isExactlyValue(+0.0) && !checkConvertToNonDenormSingle(APFloatOfN); 408}]>; 409 410// Get the Hi bits of a 64 bit immediate. 411def getFPAs64BitIntHi : SDNodeXForm<fpimm, [{ 412 APFloat APFloatOfN = N->getValueAPF(); 413 bool Unused; 414 APFloatOfN.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, 415 &Unused); 416 uint32_t Hi = (uint32_t)((APFloatOfN.bitcastToAPInt().getZExtValue() & 417 0xFFFFFFFF00000000LL) >> 32); 418 return CurDAG->getTargetConstant(Hi, SDLoc(N), MVT::i32); 419}]>; 420 421// Get the Lo bits of a 64 bit immediate. 422def getFPAs64BitIntLo : SDNodeXForm<fpimm, [{ 423 APFloat APFloatOfN = N->getValueAPF(); 424 bool Unused; 425 APFloatOfN.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven, 426 &Unused); 427 uint32_t Lo = (uint32_t)(APFloatOfN.bitcastToAPInt().getZExtValue() & 428 0xFFFFFFFF); 429 return CurDAG->getTargetConstant(Lo, SDLoc(N), MVT::i32); 430}]>; 431 432def imm34 : PatLeaf<(imm), [{ 433 return isInt<34>(N->getSExtValue()); 434}]>; 435 436def getImmAs64BitInt : SDNodeXForm<imm, [{ 437 return getI64Imm(N->getSExtValue(), SDLoc(N)); 438}]>; 439 440def SHL32 : SDNodeXForm<imm, [{ 441 // Transformation function: 31 - imm 442 return getI32Imm(31 - N->getZExtValue(), SDLoc(N)); 443}]>; 444 445def SRL32 : SDNodeXForm<imm, [{ 446 // Transformation function: 32 - imm 447 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N)) 448 : getI32Imm(0, SDLoc(N)); 449}]>; 450 451def LO16 : SDNodeXForm<imm, [{ 452 // Transformation function: get the low 16 bits. 453 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N)); 454}]>; 455 456def HI16 : SDNodeXForm<imm, [{ 457 // Transformation function: shift the immediate value down into the low bits. 458 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N)); 459}]>; 460 461def HA16 : SDNodeXForm<imm, [{ 462 // Transformation function: shift the immediate value down into the low bits. 463 long Val = N->getZExtValue(); 464 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N)); 465}]>; 466def MB : SDNodeXForm<imm, [{ 467 // Transformation function: get the start bit of a mask 468 unsigned mb = 0, me; 469 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me); 470 return getI32Imm(mb, SDLoc(N)); 471}]>; 472 473def ME : SDNodeXForm<imm, [{ 474 // Transformation function: get the end bit of a mask 475 unsigned mb, me = 0; 476 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me); 477 return getI32Imm(me, SDLoc(N)); 478}]>; 479def maskimm32 : PatLeaf<(imm), [{ 480 // maskImm predicate - True if immediate is a run of ones. 481 unsigned mb, me; 482 if (N->getValueType(0) == MVT::i32) 483 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me); 484 else 485 return false; 486}]>; 487 488def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{ 489 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit 490 // sign extended field. Used by instructions like 'addi'. 491 return (int32_t)Imm == (short)Imm; 492}]>; 493def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{ 494 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit 495 // sign extended field. Used by instructions like 'addi'. 496 return (int64_t)Imm == (short)Imm; 497}]>; 498def immZExt16 : PatLeaf<(imm), [{ 499 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended 500 // field. Used by instructions like 'ori'. 501 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue(); 502}], LO16>; 503def immNonAllOneAnyExt8 : ImmLeaf<i32, [{ 504 return (isInt<8>(Imm) && (Imm != -1)) || (isUInt<8>(Imm) && (Imm != 0xFF)); 505}]>; 506def i32immNonAllOneNonZero : ImmLeaf<i32, [{ return Imm && (Imm != -1); }]>; 507def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>; 508 509// imm16Shifted* - These match immediates where the low 16-bits are zero. There 510// are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are 511// identical in 32-bit mode, but in 64-bit mode, they return true if the 512// immediate fits into a sign/zero extended 32-bit immediate (with the low bits 513// clear). 514def imm16ShiftedZExt : PatLeaf<(imm), [{ 515 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the 516 // immediate are set. Used by instructions like 'xoris'. 517 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0; 518}], HI16>; 519 520def imm16ShiftedSExt : PatLeaf<(imm), [{ 521 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the 522 // immediate are set. Used by instructions like 'addis'. Identical to 523 // imm16ShiftedZExt in 32-bit mode. 524 if (N->getZExtValue() & 0xFFFF) return false; 525 if (N->getValueType(0) == MVT::i32) 526 return true; 527 // For 64-bit, make sure it is sext right. 528 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue(); 529}], HI16>; 530 531def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{ 532 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit 533 // zero extended field. 534 return isUInt<32>(Imm); 535}]>; 536 537// This is a somewhat weaker condition than actually checking for 4-byte 538// alignment. It is simply checking that the displacement can be represented 539// as an immediate that is a multiple of 4 (i.e. the requirements for DS-Form 540// instructions). 541// But some r+i load/store instructions (such as LD, STD, LDU, etc.) that require 542// restricted memrix (4-aligned) constants are alignment sensitive. If these 543// offsets are hidden behind TOC entries than the values of the lower-order 544// bits cannot be checked directly. As a result, we need to also incorporate 545// an alignment check into the relevant patterns. 546 547def DSFormLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 548 return isOffsetMultipleOf(N, 4) || cast<LoadSDNode>(N)->getAlignment() >= 4; 549}]>; 550def DSFormStore : PatFrag<(ops node:$val, node:$ptr), 551 (store node:$val, node:$ptr), [{ 552 return isOffsetMultipleOf(N, 4) || cast<StoreSDNode>(N)->getAlignment() >= 4; 553}]>; 554def DSFormSextLoadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{ 555 return isOffsetMultipleOf(N, 4) || cast<LoadSDNode>(N)->getAlignment() >= 4; 556}]>; 557def DSFormPreStore : PatFrag< 558 (ops node:$val, node:$base, node:$offset), 559 (pre_store node:$val, node:$base, node:$offset), [{ 560 return isOffsetMultipleOf(N, 4) || cast<StoreSDNode>(N)->getAlignment() >= 4; 561}]>; 562 563def NonDSFormLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 564 return cast<LoadSDNode>(N)->getAlignment() < 4 && !isOffsetMultipleOf(N, 4); 565}]>; 566def NonDSFormStore : PatFrag<(ops node:$val, node:$ptr), 567 (store node:$val, node:$ptr), [{ 568 return cast<StoreSDNode>(N)->getAlignment() < 4 && !isOffsetMultipleOf(N, 4); 569}]>; 570def NonDSFormSextLoadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{ 571 return cast<LoadSDNode>(N)->getAlignment() < 4 && !isOffsetMultipleOf(N, 4); 572}]>; 573 574// This is a somewhat weaker condition than actually checking for 16-byte 575// alignment. It is simply checking that the displacement can be represented 576// as an immediate that is a multiple of 16 (i.e. the requirements for DQ-Form 577// instructions). 578def quadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 579 return isOffsetMultipleOf(N, 16); 580}]>; 581def quadwOffsetStore : PatFrag<(ops node:$val, node:$ptr), 582 (store node:$val, node:$ptr), [{ 583 return isOffsetMultipleOf(N, 16); 584}]>; 585def nonQuadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 586 return !isOffsetMultipleOf(N, 16); 587}]>; 588def nonQuadwOffsetStore : PatFrag<(ops node:$val, node:$ptr), 589 (store node:$val, node:$ptr), [{ 590 return !isOffsetMultipleOf(N, 16); 591}]>; 592 593// PatFrag for binary operation whose operands are both non-constant 594class BinOpWithoutSImm16Operand<SDNode opcode> : 595 PatFrag<(ops node:$left, node:$right), (opcode node:$left, node:$right), [{ 596 int16_t Imm; 597 return !isIntS16Immediate(N->getOperand(0), Imm) 598 && !isIntS16Immediate(N->getOperand(1), Imm); 599}]>; 600 601def add_without_simm16 : BinOpWithoutSImm16Operand<add>; 602def mul_without_simm16 : BinOpWithoutSImm16Operand<mul>; 603 604//===----------------------------------------------------------------------===// 605// PowerPC Flag Definitions. 606 607class isPPC64 { bit PPC64 = 1; } 608class isRecordForm { bit RC = 1; } 609 610class RegConstraint<string C> { 611 string Constraints = C; 612} 613class NoEncode<string E> { 614 string DisableEncoding = E; 615} 616 617 618//===----------------------------------------------------------------------===// 619// PowerPC Operand Definitions. 620 621// In the default PowerPC assembler syntax, registers are specified simply 622// by number, so they cannot be distinguished from immediate values (without 623// looking at the opcode). This means that the default operand matching logic 624// for the asm parser does not work, and we need to specify custom matchers. 625// Since those can only be specified with RegisterOperand classes and not 626// directly on the RegisterClass, all instructions patterns used by the asm 627// parser need to use a RegisterOperand (instead of a RegisterClass) for 628// all their register operands. 629// For this purpose, we define one RegisterOperand for each RegisterClass, 630// using the same name as the class, just in lower case. 631 632def PPCRegGPRCAsmOperand : AsmOperandClass { 633 let Name = "RegGPRC"; let PredicateMethod = "isRegNumber"; 634} 635def gprc : RegisterOperand<GPRC> { 636 let ParserMatchClass = PPCRegGPRCAsmOperand; 637} 638def PPCRegG8RCAsmOperand : AsmOperandClass { 639 let Name = "RegG8RC"; let PredicateMethod = "isRegNumber"; 640} 641def g8rc : RegisterOperand<G8RC> { 642 let ParserMatchClass = PPCRegG8RCAsmOperand; 643} 644def PPCRegG8pRCAsmOperand : AsmOperandClass { 645 let Name = "RegG8pRC"; let PredicateMethod = "isEvenRegNumber"; 646} 647def g8prc : RegisterOperand<G8pRC> { 648 let ParserMatchClass = PPCRegG8pRCAsmOperand; 649} 650def PPCRegGPRCNoR0AsmOperand : AsmOperandClass { 651 let Name = "RegGPRCNoR0"; let PredicateMethod = "isRegNumber"; 652} 653def gprc_nor0 : RegisterOperand<GPRC_NOR0> { 654 let ParserMatchClass = PPCRegGPRCNoR0AsmOperand; 655} 656def PPCRegG8RCNoX0AsmOperand : AsmOperandClass { 657 let Name = "RegG8RCNoX0"; let PredicateMethod = "isRegNumber"; 658} 659def g8rc_nox0 : RegisterOperand<G8RC_NOX0> { 660 let ParserMatchClass = PPCRegG8RCNoX0AsmOperand; 661} 662def PPCRegF8RCAsmOperand : AsmOperandClass { 663 let Name = "RegF8RC"; let PredicateMethod = "isRegNumber"; 664} 665def f8rc : RegisterOperand<F8RC> { 666 let ParserMatchClass = PPCRegF8RCAsmOperand; 667} 668def PPCRegF4RCAsmOperand : AsmOperandClass { 669 let Name = "RegF4RC"; let PredicateMethod = "isRegNumber"; 670} 671def f4rc : RegisterOperand<F4RC> { 672 let ParserMatchClass = PPCRegF4RCAsmOperand; 673} 674def PPCRegVRRCAsmOperand : AsmOperandClass { 675 let Name = "RegVRRC"; let PredicateMethod = "isRegNumber"; 676} 677def vrrc : RegisterOperand<VRRC> { 678 let ParserMatchClass = PPCRegVRRCAsmOperand; 679} 680def PPCRegVFRCAsmOperand : AsmOperandClass { 681 let Name = "RegVFRC"; let PredicateMethod = "isRegNumber"; 682} 683def vfrc : RegisterOperand<VFRC> { 684 let ParserMatchClass = PPCRegVFRCAsmOperand; 685} 686def PPCRegCRBITRCAsmOperand : AsmOperandClass { 687 let Name = "RegCRBITRC"; let PredicateMethod = "isCRBitNumber"; 688} 689def crbitrc : RegisterOperand<CRBITRC> { 690 let ParserMatchClass = PPCRegCRBITRCAsmOperand; 691} 692def PPCRegCRRCAsmOperand : AsmOperandClass { 693 let Name = "RegCRRC"; let PredicateMethod = "isCCRegNumber"; 694} 695def crrc : RegisterOperand<CRRC> { 696 let ParserMatchClass = PPCRegCRRCAsmOperand; 697} 698def PPCRegSPERCAsmOperand : AsmOperandClass { 699 let Name = "RegSPERC"; let PredicateMethod = "isRegNumber"; 700} 701def sperc : RegisterOperand<SPERC> { 702 let ParserMatchClass = PPCRegSPERCAsmOperand; 703} 704def PPCRegSPE4RCAsmOperand : AsmOperandClass { 705 let Name = "RegSPE4RC"; let PredicateMethod = "isRegNumber"; 706} 707def spe4rc : RegisterOperand<GPRC> { 708 let ParserMatchClass = PPCRegSPE4RCAsmOperand; 709} 710 711def PPCU1ImmAsmOperand : AsmOperandClass { 712 let Name = "U1Imm"; let PredicateMethod = "isU1Imm"; 713 let RenderMethod = "addImmOperands"; 714} 715def u1imm : Operand<i32> { 716 let PrintMethod = "printU1ImmOperand"; 717 let ParserMatchClass = PPCU1ImmAsmOperand; 718 let OperandType = "OPERAND_IMMEDIATE"; 719} 720 721def PPCU2ImmAsmOperand : AsmOperandClass { 722 let Name = "U2Imm"; let PredicateMethod = "isU2Imm"; 723 let RenderMethod = "addImmOperands"; 724} 725def u2imm : Operand<i32> { 726 let PrintMethod = "printU2ImmOperand"; 727 let ParserMatchClass = PPCU2ImmAsmOperand; 728 let OperandType = "OPERAND_IMMEDIATE"; 729} 730 731def PPCATBitsAsHintAsmOperand : AsmOperandClass { 732 let Name = "ATBitsAsHint"; let PredicateMethod = "isATBitsAsHint"; 733 let RenderMethod = "addImmOperands"; // Irrelevant, predicate always fails. 734} 735def atimm : Operand<i32> { 736 let PrintMethod = "printATBitsAsHint"; 737 let ParserMatchClass = PPCATBitsAsHintAsmOperand; 738 let OperandType = "OPERAND_IMMEDIATE"; 739} 740 741def PPCU3ImmAsmOperand : AsmOperandClass { 742 let Name = "U3Imm"; let PredicateMethod = "isU3Imm"; 743 let RenderMethod = "addImmOperands"; 744} 745def u3imm : Operand<i32> { 746 let PrintMethod = "printU3ImmOperand"; 747 let ParserMatchClass = PPCU3ImmAsmOperand; 748 let OperandType = "OPERAND_IMMEDIATE"; 749} 750 751def PPCU4ImmAsmOperand : AsmOperandClass { 752 let Name = "U4Imm"; let PredicateMethod = "isU4Imm"; 753 let RenderMethod = "addImmOperands"; 754} 755def u4imm : Operand<i32> { 756 let PrintMethod = "printU4ImmOperand"; 757 let ParserMatchClass = PPCU4ImmAsmOperand; 758 let OperandType = "OPERAND_IMMEDIATE"; 759} 760def PPCS5ImmAsmOperand : AsmOperandClass { 761 let Name = "S5Imm"; let PredicateMethod = "isS5Imm"; 762 let RenderMethod = "addImmOperands"; 763} 764def s5imm : Operand<i32> { 765 let PrintMethod = "printS5ImmOperand"; 766 let ParserMatchClass = PPCS5ImmAsmOperand; 767 let DecoderMethod = "decodeSImmOperand<5>"; 768 let OperandType = "OPERAND_IMMEDIATE"; 769} 770def PPCU5ImmAsmOperand : AsmOperandClass { 771 let Name = "U5Imm"; let PredicateMethod = "isU5Imm"; 772 let RenderMethod = "addImmOperands"; 773} 774def u5imm : Operand<i32> { 775 let PrintMethod = "printU5ImmOperand"; 776 let ParserMatchClass = PPCU5ImmAsmOperand; 777 let DecoderMethod = "decodeUImmOperand<5>"; 778 let OperandType = "OPERAND_IMMEDIATE"; 779} 780def PPCU6ImmAsmOperand : AsmOperandClass { 781 let Name = "U6Imm"; let PredicateMethod = "isU6Imm"; 782 let RenderMethod = "addImmOperands"; 783} 784def u6imm : Operand<i32> { 785 let PrintMethod = "printU6ImmOperand"; 786 let ParserMatchClass = PPCU6ImmAsmOperand; 787 let DecoderMethod = "decodeUImmOperand<6>"; 788 let OperandType = "OPERAND_IMMEDIATE"; 789} 790def PPCU7ImmAsmOperand : AsmOperandClass { 791 let Name = "U7Imm"; let PredicateMethod = "isU7Imm"; 792 let RenderMethod = "addImmOperands"; 793} 794def u7imm : Operand<i32> { 795 let PrintMethod = "printU7ImmOperand"; 796 let ParserMatchClass = PPCU7ImmAsmOperand; 797 let DecoderMethod = "decodeUImmOperand<7>"; 798 let OperandType = "OPERAND_IMMEDIATE"; 799} 800def PPCU8ImmAsmOperand : AsmOperandClass { 801 let Name = "U8Imm"; let PredicateMethod = "isU8Imm"; 802 let RenderMethod = "addImmOperands"; 803} 804def u8imm : Operand<i32> { 805 let PrintMethod = "printU8ImmOperand"; 806 let ParserMatchClass = PPCU8ImmAsmOperand; 807 let DecoderMethod = "decodeUImmOperand<8>"; 808 let OperandType = "OPERAND_IMMEDIATE"; 809} 810def PPCU10ImmAsmOperand : AsmOperandClass { 811 let Name = "U10Imm"; let PredicateMethod = "isU10Imm"; 812 let RenderMethod = "addImmOperands"; 813} 814def u10imm : Operand<i32> { 815 let PrintMethod = "printU10ImmOperand"; 816 let ParserMatchClass = PPCU10ImmAsmOperand; 817 let DecoderMethod = "decodeUImmOperand<10>"; 818 let OperandType = "OPERAND_IMMEDIATE"; 819} 820def PPCU12ImmAsmOperand : AsmOperandClass { 821 let Name = "U12Imm"; let PredicateMethod = "isU12Imm"; 822 let RenderMethod = "addImmOperands"; 823} 824def u12imm : Operand<i32> { 825 let PrintMethod = "printU12ImmOperand"; 826 let ParserMatchClass = PPCU12ImmAsmOperand; 827 let DecoderMethod = "decodeUImmOperand<12>"; 828 let OperandType = "OPERAND_IMMEDIATE"; 829} 830def PPCS16ImmAsmOperand : AsmOperandClass { 831 let Name = "S16Imm"; let PredicateMethod = "isS16Imm"; 832 let RenderMethod = "addS16ImmOperands"; 833} 834def s16imm : Operand<i32> { 835 let PrintMethod = "printS16ImmOperand"; 836 let EncoderMethod = "getImm16Encoding"; 837 let ParserMatchClass = PPCS16ImmAsmOperand; 838 let DecoderMethod = "decodeSImmOperand<16>"; 839 let OperandType = "OPERAND_IMMEDIATE"; 840} 841def PPCU16ImmAsmOperand : AsmOperandClass { 842 let Name = "U16Imm"; let PredicateMethod = "isU16Imm"; 843 let RenderMethod = "addU16ImmOperands"; 844} 845def u16imm : Operand<i32> { 846 let PrintMethod = "printU16ImmOperand"; 847 let EncoderMethod = "getImm16Encoding"; 848 let ParserMatchClass = PPCU16ImmAsmOperand; 849 let DecoderMethod = "decodeUImmOperand<16>"; 850 let OperandType = "OPERAND_IMMEDIATE"; 851} 852def PPCS17ImmAsmOperand : AsmOperandClass { 853 let Name = "S17Imm"; let PredicateMethod = "isS17Imm"; 854 let RenderMethod = "addS16ImmOperands"; 855} 856def s17imm : Operand<i32> { 857 // This operand type is used for addis/lis to allow the assembler parser 858 // to accept immediates in the range -65536..65535 for compatibility with 859 // the GNU assembler. The operand is treated as 16-bit otherwise. 860 let PrintMethod = "printS16ImmOperand"; 861 let EncoderMethod = "getImm16Encoding"; 862 let ParserMatchClass = PPCS17ImmAsmOperand; 863 let DecoderMethod = "decodeSImmOperand<16>"; 864 let OperandType = "OPERAND_IMMEDIATE"; 865} 866def PPCS34ImmAsmOperand : AsmOperandClass { 867 let Name = "S34Imm"; 868 let PredicateMethod = "isS34Imm"; 869 let RenderMethod = "addImmOperands"; 870} 871def s34imm : Operand<i64> { 872 let PrintMethod = "printS34ImmOperand"; 873 let EncoderMethod = "getImm34EncodingNoPCRel"; 874 let ParserMatchClass = PPCS34ImmAsmOperand; 875 let DecoderMethod = "decodeSImmOperand<34>"; 876 let OperandType = "OPERAND_IMMEDIATE"; 877} 878def s34imm_pcrel : Operand<i64> { 879 let PrintMethod = "printS34ImmOperand"; 880 let EncoderMethod = "getImm34EncodingPCRel"; 881 let ParserMatchClass = PPCS34ImmAsmOperand; 882 let DecoderMethod = "decodeSImmOperand<34>"; 883 let OperandType = "OPERAND_IMMEDIATE"; 884} 885def PPCImmZeroAsmOperand : AsmOperandClass { 886 let Name = "ImmZero"; 887 let PredicateMethod = "isImmZero"; 888 let RenderMethod = "addImmOperands"; 889} 890def immZero : Operand<i32> { 891 let PrintMethod = "printImmZeroOperand"; 892 let ParserMatchClass = PPCImmZeroAsmOperand; 893 let DecoderMethod = "decodeImmZeroOperand"; 894 let OperandType = "OPERAND_IMMEDIATE"; 895} 896 897def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>; 898 899def PPCDirectBrAsmOperand : AsmOperandClass { 900 let Name = "DirectBr"; let PredicateMethod = "isDirectBr"; 901 let RenderMethod = "addBranchTargetOperands"; 902} 903def directbrtarget : Operand<OtherVT> { 904 let PrintMethod = "printBranchOperand"; 905 let EncoderMethod = "getDirectBrEncoding"; 906 let DecoderMethod = "decodeDirectBrTarget"; 907 let ParserMatchClass = PPCDirectBrAsmOperand; 908 let OperandType = "OPERAND_PCREL"; 909} 910def absdirectbrtarget : Operand<OtherVT> { 911 let PrintMethod = "printAbsBranchOperand"; 912 let EncoderMethod = "getAbsDirectBrEncoding"; 913 let ParserMatchClass = PPCDirectBrAsmOperand; 914} 915def PPCCondBrAsmOperand : AsmOperandClass { 916 let Name = "CondBr"; let PredicateMethod = "isCondBr"; 917 let RenderMethod = "addBranchTargetOperands"; 918} 919def condbrtarget : Operand<OtherVT> { 920 let PrintMethod = "printBranchOperand"; 921 let EncoderMethod = "getCondBrEncoding"; 922 let DecoderMethod = "decodeCondBrTarget"; 923 let ParserMatchClass = PPCCondBrAsmOperand; 924 let OperandType = "OPERAND_PCREL"; 925} 926def abscondbrtarget : Operand<OtherVT> { 927 let PrintMethod = "printAbsBranchOperand"; 928 let EncoderMethod = "getAbsCondBrEncoding"; 929 let ParserMatchClass = PPCCondBrAsmOperand; 930} 931def calltarget : Operand<iPTR> { 932 let PrintMethod = "printBranchOperand"; 933 let EncoderMethod = "getDirectBrEncoding"; 934 let DecoderMethod = "decodeDirectBrTarget"; 935 let ParserMatchClass = PPCDirectBrAsmOperand; 936 let OperandType = "OPERAND_PCREL"; 937} 938def abscalltarget : Operand<iPTR> { 939 let PrintMethod = "printAbsBranchOperand"; 940 let EncoderMethod = "getAbsDirectBrEncoding"; 941 let ParserMatchClass = PPCDirectBrAsmOperand; 942} 943def PPCCRBitMaskOperand : AsmOperandClass { 944 let Name = "CRBitMask"; let PredicateMethod = "isCRBitMask"; 945} 946def crbitm: Operand<i8> { 947 let PrintMethod = "printcrbitm"; 948 let EncoderMethod = "get_crbitm_encoding"; 949 let DecoderMethod = "decodeCRBitMOperand"; 950 let ParserMatchClass = PPCCRBitMaskOperand; 951} 952// Address operands 953// A version of ptr_rc which excludes R0 (or X0 in 64-bit mode). 954def PPCRegGxRCNoR0Operand : AsmOperandClass { 955 let Name = "RegGxRCNoR0"; let PredicateMethod = "isRegNumber"; 956} 957def ptr_rc_nor0 : Operand<iPTR>, PointerLikeRegClass<1> { 958 let ParserMatchClass = PPCRegGxRCNoR0Operand; 959} 960 961// New addressing modes with 34 bit immediates. 962def PPCDispRI34Operand : AsmOperandClass { 963 let Name = "DispRI34"; let PredicateMethod = "isS34Imm"; 964 let RenderMethod = "addImmOperands"; 965} 966def dispRI34 : Operand<iPTR> { 967 let ParserMatchClass = PPCDispRI34Operand; 968} 969def memri34 : Operand<iPTR> { // memri, imm is a 34-bit value. 970 let PrintMethod = "printMemRegImm34"; 971 let MIOperandInfo = (ops dispRI34:$imm, ptr_rc_nor0:$reg); 972 let EncoderMethod = "getMemRI34Encoding"; 973 let DecoderMethod = "decodeMemRI34Operands"; 974} 975// memri, imm is a 34-bit value for pc-relative instructions where 976// base register is set to zero. 977def memri34_pcrel : Operand<iPTR> { // memri, imm is a 34-bit value. 978 let PrintMethod = "printMemRegImm34PCRel"; 979 let MIOperandInfo = (ops dispRI34:$imm, immZero:$reg); 980 let EncoderMethod = "getMemRI34PCRelEncoding"; 981 let DecoderMethod = "decodeMemRI34PCRelOperands"; 982} 983 984// A version of ptr_rc usable with the asm parser. 985def PPCRegGxRCOperand : AsmOperandClass { 986 let Name = "RegGxRC"; let PredicateMethod = "isRegNumber"; 987} 988def ptr_rc_idx : Operand<iPTR>, PointerLikeRegClass<0> { 989 let ParserMatchClass = PPCRegGxRCOperand; 990} 991 992def PPCDispRIOperand : AsmOperandClass { 993 let Name = "DispRI"; let PredicateMethod = "isS16Imm"; 994 let RenderMethod = "addS16ImmOperands"; 995} 996def dispRI : Operand<iPTR> { 997 let ParserMatchClass = PPCDispRIOperand; 998} 999def PPCDispRIXOperand : AsmOperandClass { 1000 let Name = "DispRIX"; let PredicateMethod = "isS16ImmX4"; 1001 let RenderMethod = "addImmOperands"; 1002} 1003def dispRIX : Operand<iPTR> { 1004 let ParserMatchClass = PPCDispRIXOperand; 1005} 1006def PPCDispRIHashOperand : AsmOperandClass { 1007 let Name = "DispRIHash"; let PredicateMethod = "isHashImmX8"; 1008 let RenderMethod = "addImmOperands"; 1009} 1010def dispRIHash : Operand<iPTR> { 1011 let ParserMatchClass = PPCDispRIHashOperand; 1012} 1013def PPCDispRIX16Operand : AsmOperandClass { 1014 let Name = "DispRIX16"; let PredicateMethod = "isS16ImmX16"; 1015 let RenderMethod = "addImmOperands"; 1016} 1017def dispRIX16 : Operand<iPTR> { 1018 let ParserMatchClass = PPCDispRIX16Operand; 1019} 1020def PPCDispSPE8Operand : AsmOperandClass { 1021 let Name = "DispSPE8"; let PredicateMethod = "isU8ImmX8"; 1022 let RenderMethod = "addImmOperands"; 1023} 1024def dispSPE8 : Operand<iPTR> { 1025 let ParserMatchClass = PPCDispSPE8Operand; 1026} 1027def PPCDispSPE4Operand : AsmOperandClass { 1028 let Name = "DispSPE4"; let PredicateMethod = "isU7ImmX4"; 1029 let RenderMethod = "addImmOperands"; 1030} 1031def dispSPE4 : Operand<iPTR> { 1032 let ParserMatchClass = PPCDispSPE4Operand; 1033} 1034def PPCDispSPE2Operand : AsmOperandClass { 1035 let Name = "DispSPE2"; let PredicateMethod = "isU6ImmX2"; 1036 let RenderMethod = "addImmOperands"; 1037} 1038def dispSPE2 : Operand<iPTR> { 1039 let ParserMatchClass = PPCDispSPE2Operand; 1040} 1041 1042def memri : Operand<iPTR> { 1043 let PrintMethod = "printMemRegImm"; 1044 let MIOperandInfo = (ops dispRI:$imm, ptr_rc_nor0:$reg); 1045 let EncoderMethod = "getMemRIEncoding"; 1046 let DecoderMethod = "decodeMemRIOperands"; 1047 let OperandType = "OPERAND_MEMORY"; 1048} 1049def memrr : Operand<iPTR> { 1050 let PrintMethod = "printMemRegReg"; 1051 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg, ptr_rc_idx:$offreg); 1052 let OperandType = "OPERAND_MEMORY"; 1053} 1054def memrix : Operand<iPTR> { // memri where the imm is 4-aligned. 1055 let PrintMethod = "printMemRegImm"; 1056 let MIOperandInfo = (ops dispRIX:$imm, ptr_rc_nor0:$reg); 1057 let EncoderMethod = "getMemRIXEncoding"; 1058 let DecoderMethod = "decodeMemRIXOperands"; 1059 let OperandType = "OPERAND_MEMORY"; 1060} 1061def memrihash : Operand<iPTR> { 1062 // memrihash 8-aligned for ROP Protection Instructions. 1063 let PrintMethod = "printMemRegImmHash"; 1064 let MIOperandInfo = (ops dispRIHash:$imm, ptr_rc_nor0:$reg); 1065 let EncoderMethod = "getMemRIHashEncoding"; 1066 let DecoderMethod = "decodeMemRIHashOperands"; 1067 let OperandType = "OPERAND_MEMORY"; 1068} 1069def memrix16 : Operand<iPTR> { // memri, imm is 16-aligned, 12-bit, Inst{16:27} 1070 let PrintMethod = "printMemRegImm"; 1071 let MIOperandInfo = (ops dispRIX16:$imm, ptr_rc_nor0:$reg); 1072 let EncoderMethod = "getMemRIX16Encoding"; 1073 let DecoderMethod = "decodeMemRIX16Operands"; 1074 let OperandType = "OPERAND_MEMORY"; 1075} 1076def spe8dis : Operand<iPTR> { // SPE displacement where the imm is 8-aligned. 1077 let PrintMethod = "printMemRegImm"; 1078 let MIOperandInfo = (ops dispSPE8:$imm, ptr_rc_nor0:$reg); 1079 let EncoderMethod = "getSPE8DisEncoding"; 1080 let DecoderMethod = "decodeSPE8Operands"; 1081 let OperandType = "OPERAND_MEMORY"; 1082} 1083def spe4dis : Operand<iPTR> { // SPE displacement where the imm is 4-aligned. 1084 let PrintMethod = "printMemRegImm"; 1085 let MIOperandInfo = (ops dispSPE4:$imm, ptr_rc_nor0:$reg); 1086 let EncoderMethod = "getSPE4DisEncoding"; 1087 let DecoderMethod = "decodeSPE4Operands"; 1088 let OperandType = "OPERAND_MEMORY"; 1089} 1090def spe2dis : Operand<iPTR> { // SPE displacement where the imm is 2-aligned. 1091 let PrintMethod = "printMemRegImm"; 1092 let MIOperandInfo = (ops dispSPE2:$imm, ptr_rc_nor0:$reg); 1093 let EncoderMethod = "getSPE2DisEncoding"; 1094 let DecoderMethod = "decodeSPE2Operands"; 1095 let OperandType = "OPERAND_MEMORY"; 1096} 1097 1098// A single-register address. This is used with the SjLj 1099// pseudo-instructions which translates to LD/LWZ. These instructions requires 1100// G8RC_NOX0 registers. 1101def memr : Operand<iPTR> { 1102 let MIOperandInfo = (ops ptr_rc_nor0:$ptrreg); 1103 let OperandType = "OPERAND_MEMORY"; 1104} 1105def PPCTLSRegOperand : AsmOperandClass { 1106 let Name = "TLSReg"; let PredicateMethod = "isTLSReg"; 1107 let RenderMethod = "addTLSRegOperands"; 1108} 1109def tlsreg32 : Operand<i32> { 1110 let EncoderMethod = "getTLSRegEncoding"; 1111 let ParserMatchClass = PPCTLSRegOperand; 1112} 1113def tlsgd32 : Operand<i32> {} 1114def tlscall32 : Operand<i32> { 1115 let PrintMethod = "printTLSCall"; 1116 let MIOperandInfo = (ops calltarget:$func, tlsgd32:$sym); 1117 let EncoderMethod = "getTLSCallEncoding"; 1118} 1119 1120// PowerPC Predicate operand. 1121def pred : Operand<OtherVT> { 1122 let PrintMethod = "printPredicateOperand"; 1123 let MIOperandInfo = (ops i32imm:$bibo, crrc:$reg); 1124} 1125 1126// Define PowerPC specific addressing mode. 1127 1128// d-form 1129def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>; // "stb" 1130// ds-form 1131def iaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std" 1132// dq-form 1133def iaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrImmX16", [], []>; // "stxv" 1134// 8LS:d-form 1135def iaddrX34 : ComplexPattern<iPTR, 2, "SelectAddrImmX34", [], []>; // "pstxvp" 1136 1137// Below forms are all x-form addressing mode, use three different ones so we 1138// can make a accurate check for x-form instructions in ISEL. 1139// x-form addressing mode whose associated displacement form is D. 1140def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>; // "stbx" 1141// x-form addressing mode whose associated displacement form is DS. 1142def xaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrIdxX4", [], []>; // "stdx" 1143// x-form addressing mode whose associated displacement form is DQ. 1144def xaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrIdxX16", [], []>; // "stxvx" 1145 1146def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>; 1147 1148// The address in a single register. This is used with the SjLj 1149// pseudo-instructions. 1150def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>; 1151 1152/// This is just the offset part of iaddr, used for preinc. 1153def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>; 1154 1155// Load and Store Instruction Selection addressing modes. 1156def DForm : ComplexPattern<iPTR, 2, "SelectDForm", [], [SDNPWantParent]>; 1157def DSForm : ComplexPattern<iPTR, 2, "SelectDSForm", [], [SDNPWantParent]>; 1158def DQForm : ComplexPattern<iPTR, 2, "SelectDQForm", [], [SDNPWantParent]>; 1159def XForm : ComplexPattern<iPTR, 2, "SelectXForm", [], [SDNPWantParent]>; 1160def ForceXForm : ComplexPattern<iPTR, 2, "SelectForceXForm", [], [SDNPWantParent]>; 1161def PCRelForm : ComplexPattern<iPTR, 2, "SelectPCRelForm", [], [SDNPWantParent]>; 1162def PDForm : ComplexPattern<iPTR, 2, "SelectPDForm", [], [SDNPWantParent]>; 1163 1164//===----------------------------------------------------------------------===// 1165// PowerPC Instruction Predicate Definitions. 1166def In32BitMode : Predicate<"!Subtarget->isPPC64()">; 1167def In64BitMode : Predicate<"Subtarget->isPPC64()">; 1168def IsBookE : Predicate<"Subtarget->isBookE()">; 1169def IsNotBookE : Predicate<"!Subtarget->isBookE()">; 1170def HasOnlyMSYNC : Predicate<"Subtarget->hasOnlyMSYNC()">; 1171def HasSYNC : Predicate<"!Subtarget->hasOnlyMSYNC()">; 1172def IsPPC4xx : Predicate<"Subtarget->isPPC4xx()">; 1173def IsPPC6xx : Predicate<"Subtarget->isPPC6xx()">; 1174def IsE500 : Predicate<"Subtarget->isE500()">; 1175def HasSPE : Predicate<"Subtarget->hasSPE()">; 1176def HasICBT : Predicate<"Subtarget->hasICBT()">; 1177def HasPartwordAtomics : Predicate<"Subtarget->hasPartwordAtomics()">; 1178def HasQuadwordAtomics : Predicate<"Subtarget->hasQuadwordAtomics()">; 1179def NoNaNsFPMath 1180 : Predicate<"Subtarget->getTargetMachine().Options.NoNaNsFPMath">; 1181def NaNsFPMath 1182 : Predicate<"!Subtarget->getTargetMachine().Options.NoNaNsFPMath">; 1183def HasBPERMD : Predicate<"Subtarget->hasBPERMD()">; 1184def HasExtDiv : Predicate<"Subtarget->hasExtDiv()">; 1185def IsISA2_06 : Predicate<"Subtarget->isISA2_06()">; 1186def IsISA2_07 : Predicate<"Subtarget->isISA2_07()">; 1187def IsISA3_0 : Predicate<"Subtarget->isISA3_0()">; 1188def HasFPU : Predicate<"Subtarget->hasFPU()">; 1189def PCRelativeMemops : Predicate<"Subtarget->hasPCRelativeMemops()">; 1190def IsNotISA3_1 : Predicate<"!Subtarget->isISA3_1()">; 1191 1192// AIX assembler may not be modern enough to support some extended mne. 1193def ModernAs: Predicate<"!Subtarget->isAIXABI() || Subtarget->HasModernAIXAs">, 1194 AssemblerPredicate<(any_of (not AIXOS), FeatureModernAIXAs)>; 1195def IsAIX : Predicate<"Subtarget->isAIXABI()">; 1196def NotAIX : Predicate<"!Subtarget->isAIXABI()">; 1197 1198//===----------------------------------------------------------------------===// 1199// PowerPC Multiclass Definitions. 1200 1201multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 1202 string asmbase, string asmstr, InstrItinClass itin, 1203 list<dag> pattern> { 1204 let BaseName = asmbase in { 1205 def NAME : XForm_6<opcode, xo, OOL, IOL, 1206 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1207 pattern>, RecFormRel; 1208 let Defs = [CR0] in 1209 def _rec : XForm_6<opcode, xo, OOL, IOL, 1210 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1211 []>, isRecordForm, RecFormRel; 1212 } 1213} 1214 1215multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 1216 string asmbase, string asmstr, InstrItinClass itin, 1217 list<dag> pattern> { 1218 let BaseName = asmbase in { 1219 let Defs = [CARRY] in 1220 def NAME : XForm_6<opcode, xo, OOL, IOL, 1221 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1222 pattern>, RecFormRel; 1223 let Defs = [CARRY, CR0] in 1224 def _rec : XForm_6<opcode, xo, OOL, IOL, 1225 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1226 []>, isRecordForm, RecFormRel; 1227 } 1228} 1229 1230multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 1231 string asmbase, string asmstr, InstrItinClass itin, 1232 list<dag> pattern> { 1233 let BaseName = asmbase in { 1234 let Defs = [CARRY] in 1235 def NAME : XForm_10<opcode, xo, OOL, IOL, 1236 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1237 pattern>, RecFormRel; 1238 let Defs = [CARRY, CR0] in 1239 def _rec : XForm_10<opcode, xo, OOL, IOL, 1240 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1241 []>, isRecordForm, RecFormRel; 1242 } 1243} 1244 1245multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 1246 string asmbase, string asmstr, InstrItinClass itin, 1247 list<dag> pattern> { 1248 let BaseName = asmbase in { 1249 def NAME : XForm_11<opcode, xo, OOL, IOL, 1250 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1251 pattern>, RecFormRel; 1252 let Defs = [CR0] in 1253 def _rec : XForm_11<opcode, xo, OOL, IOL, 1254 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1255 []>, isRecordForm, RecFormRel; 1256 } 1257} 1258 1259multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 1260 string asmbase, string asmstr, InstrItinClass itin, 1261 list<dag> pattern> { 1262 let BaseName = asmbase in { 1263 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL, 1264 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1265 pattern>, RecFormRel; 1266 let Defs = [CR0] in 1267 def _rec : XOForm_1<opcode, xo, oe, OOL, IOL, 1268 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1269 []>, isRecordForm, RecFormRel; 1270 } 1271} 1272 1273// Multiclass for instructions which have a record overflow form as well 1274// as a record form but no carry (i.e. mulld, mulldo, subf, subfo, etc.) 1275multiclass XOForm_1rx<bits<6> opcode, bits<9> xo, dag OOL, dag IOL, 1276 string asmbase, string asmstr, InstrItinClass itin, 1277 list<dag> pattern> { 1278 let BaseName = asmbase in { 1279 def NAME : XOForm_1<opcode, xo, 0, OOL, IOL, 1280 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1281 pattern>, RecFormRel; 1282 let Defs = [CR0] in 1283 def _rec : XOForm_1<opcode, xo, 0, OOL, IOL, 1284 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1285 []>, isRecordForm, RecFormRel; 1286 } 1287 let BaseName = !strconcat(asmbase, "O") in { 1288 let Defs = [XER] in 1289 def O : XOForm_1<opcode, xo, 1, OOL, IOL, 1290 !strconcat(asmbase, !strconcat("o ", asmstr)), itin, 1291 []>, RecFormRel; 1292 let Defs = [XER, CR0] in 1293 def O_rec : XOForm_1<opcode, xo, 1, OOL, IOL, 1294 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin, 1295 []>, isRecordForm, RecFormRel; 1296 } 1297} 1298 1299// Multiclass for instructions for which the non record form is not cracked 1300// and the record form is cracked (i.e. divw, mullw, etc.) 1301multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 1302 string asmbase, string asmstr, InstrItinClass itin, 1303 list<dag> pattern> { 1304 let BaseName = asmbase in { 1305 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL, 1306 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1307 pattern>, RecFormRel; 1308 let Defs = [CR0] in 1309 def _rec : XOForm_1<opcode, xo, oe, OOL, IOL, 1310 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1311 []>, isRecordForm, RecFormRel, PPC970_DGroup_First, 1312 PPC970_DGroup_Cracked; 1313 } 1314 let BaseName = !strconcat(asmbase, "O") in { 1315 let Defs = [XER] in 1316 def O : XOForm_1<opcode, xo, 1, OOL, IOL, 1317 !strconcat(asmbase, !strconcat("o ", asmstr)), itin, 1318 []>, RecFormRel; 1319 let Defs = [XER, CR0] in 1320 def O_rec : XOForm_1<opcode, xo, 1, OOL, IOL, 1321 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin, 1322 []>, isRecordForm, RecFormRel; 1323 } 1324} 1325 1326multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 1327 string asmbase, string asmstr, InstrItinClass itin, 1328 list<dag> pattern> { 1329 let BaseName = asmbase in { 1330 let Defs = [CARRY] in 1331 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL, 1332 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1333 pattern>, RecFormRel; 1334 let Defs = [CARRY, CR0] in 1335 def _rec : XOForm_1<opcode, xo, oe, OOL, IOL, 1336 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1337 []>, isRecordForm, RecFormRel; 1338 } 1339 let BaseName = !strconcat(asmbase, "O") in { 1340 let Defs = [CARRY, XER] in 1341 def O : XOForm_1<opcode, xo, 1, OOL, IOL, 1342 !strconcat(asmbase, !strconcat("o ", asmstr)), itin, 1343 []>, RecFormRel; 1344 let Defs = [CARRY, XER, CR0] in 1345 def O_rec : XOForm_1<opcode, xo, 1, OOL, IOL, 1346 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin, 1347 []>, isRecordForm, RecFormRel; 1348 } 1349} 1350 1351multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 1352 string asmbase, string asmstr, InstrItinClass itin, 1353 list<dag> pattern> { 1354 let BaseName = asmbase in { 1355 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL, 1356 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1357 pattern>, RecFormRel; 1358 let Defs = [CR0] in 1359 def _rec : XOForm_3<opcode, xo, oe, OOL, IOL, 1360 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1361 []>, isRecordForm, RecFormRel; 1362 } 1363 let BaseName = !strconcat(asmbase, "O") in { 1364 let Defs = [XER] in 1365 def O : XOForm_3<opcode, xo, 1, OOL, IOL, 1366 !strconcat(asmbase, !strconcat("o ", asmstr)), itin, 1367 []>, RecFormRel; 1368 let Defs = [XER, CR0] in 1369 def O_rec : XOForm_3<opcode, xo, 1, OOL, IOL, 1370 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin, 1371 []>, isRecordForm, RecFormRel; 1372 } 1373} 1374 1375multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL, 1376 string asmbase, string asmstr, InstrItinClass itin, 1377 list<dag> pattern> { 1378 let BaseName = asmbase in { 1379 let Defs = [CARRY] in 1380 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL, 1381 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1382 pattern>, RecFormRel; 1383 let Defs = [CARRY, CR0] in 1384 def _rec : XOForm_3<opcode, xo, oe, OOL, IOL, 1385 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1386 []>, isRecordForm, RecFormRel; 1387 } 1388 let BaseName = !strconcat(asmbase, "O") in { 1389 let Defs = [CARRY, XER] in 1390 def O : XOForm_3<opcode, xo, 1, OOL, IOL, 1391 !strconcat(asmbase, !strconcat("o ", asmstr)), itin, 1392 []>, RecFormRel; 1393 let Defs = [CARRY, XER, CR0] in 1394 def O_rec : XOForm_3<opcode, xo, 1, OOL, IOL, 1395 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin, 1396 []>, isRecordForm, RecFormRel; 1397 } 1398} 1399 1400multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL, 1401 string asmbase, string asmstr, InstrItinClass itin, 1402 list<dag> pattern> { 1403 let BaseName = asmbase in { 1404 def NAME : MForm_2<opcode, OOL, IOL, 1405 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1406 pattern>, RecFormRel; 1407 let Defs = [CR0] in 1408 def _rec : MForm_2<opcode, OOL, IOL, 1409 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1410 []>, isRecordForm, RecFormRel; 1411 } 1412} 1413 1414multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL, 1415 string asmbase, string asmstr, InstrItinClass itin, 1416 list<dag> pattern> { 1417 let BaseName = asmbase in { 1418 def NAME : MDForm_1<opcode, xo, OOL, IOL, 1419 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1420 pattern>, RecFormRel; 1421 let Defs = [CR0] in 1422 def _rec : MDForm_1<opcode, xo, OOL, IOL, 1423 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1424 []>, isRecordForm, RecFormRel; 1425 } 1426} 1427 1428multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL, 1429 string asmbase, string asmstr, InstrItinClass itin, 1430 list<dag> pattern> { 1431 let BaseName = asmbase in { 1432 def NAME : MDSForm_1<opcode, xo, OOL, IOL, 1433 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1434 pattern>, RecFormRel; 1435 let Defs = [CR0] in 1436 def _rec : MDSForm_1<opcode, xo, OOL, IOL, 1437 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1438 []>, isRecordForm, RecFormRel; 1439 } 1440} 1441 1442multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL, 1443 string asmbase, string asmstr, InstrItinClass itin, 1444 list<dag> pattern> { 1445 let BaseName = asmbase in { 1446 let Defs = [CARRY] in 1447 def NAME : XSForm_1<opcode, xo, OOL, IOL, 1448 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1449 pattern>, RecFormRel; 1450 let Defs = [CARRY, CR0] in 1451 def _rec : XSForm_1<opcode, xo, OOL, IOL, 1452 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1453 []>, isRecordForm, RecFormRel; 1454 } 1455} 1456 1457multiclass XSForm_1r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL, 1458 string asmbase, string asmstr, InstrItinClass itin, 1459 list<dag> pattern> { 1460 let BaseName = asmbase in { 1461 def NAME : XSForm_1<opcode, xo, OOL, IOL, 1462 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1463 pattern>, RecFormRel; 1464 let Defs = [CR0] in 1465 def _rec : XSForm_1<opcode, xo, OOL, IOL, 1466 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1467 []>, isRecordForm, RecFormRel; 1468 } 1469} 1470 1471multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 1472 string asmbase, string asmstr, InstrItinClass itin, 1473 list<dag> pattern> { 1474 let BaseName = asmbase in { 1475 def NAME : XForm_26<opcode, xo, OOL, IOL, 1476 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1477 pattern>, RecFormRel; 1478 let Defs = [CR1] in 1479 def _rec : XForm_26<opcode, xo, OOL, IOL, 1480 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1481 []>, isRecordForm, RecFormRel; 1482 } 1483} 1484 1485multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, 1486 string asmbase, string asmstr, InstrItinClass itin, 1487 list<dag> pattern> { 1488 let BaseName = asmbase in { 1489 def NAME : XForm_28<opcode, xo, OOL, IOL, 1490 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1491 pattern>, RecFormRel; 1492 let Defs = [CR1] in 1493 def _rec : XForm_28<opcode, xo, OOL, IOL, 1494 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1495 []>, isRecordForm, RecFormRel; 1496 } 1497} 1498 1499multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, 1500 string asmbase, string asmstr, InstrItinClass itin, 1501 list<dag> pattern> { 1502 let BaseName = asmbase in { 1503 def NAME : AForm_1<opcode, xo, OOL, IOL, 1504 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1505 pattern>, RecFormRel; 1506 let Defs = [CR1] in 1507 def _rec : AForm_1<opcode, xo, OOL, IOL, 1508 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1509 []>, isRecordForm, RecFormRel; 1510 } 1511} 1512 1513multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, 1514 string asmbase, string asmstr, InstrItinClass itin, 1515 list<dag> pattern> { 1516 let BaseName = asmbase in { 1517 def NAME : AForm_2<opcode, xo, OOL, IOL, 1518 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1519 pattern>, RecFormRel; 1520 let Defs = [CR1] in 1521 def _rec : AForm_2<opcode, xo, OOL, IOL, 1522 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1523 []>, isRecordForm, RecFormRel; 1524 } 1525} 1526 1527multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL, 1528 string asmbase, string asmstr, InstrItinClass itin, 1529 list<dag> pattern> { 1530 let BaseName = asmbase in { 1531 def NAME : AForm_3<opcode, xo, OOL, IOL, 1532 !strconcat(asmbase, !strconcat(" ", asmstr)), itin, 1533 pattern>, RecFormRel; 1534 let Defs = [CR1] in 1535 def _rec : AForm_3<opcode, xo, OOL, IOL, 1536 !strconcat(asmbase, !strconcat(". ", asmstr)), itin, 1537 []>, isRecordForm, RecFormRel; 1538 } 1539} 1540 1541//===----------------------------------------------------------------------===// 1542// PowerPC Instruction Definitions. 1543 1544// Pseudo instructions: 1545 1546let hasCtrlDep = 1 in { 1547let Defs = [R1], Uses = [R1] in { 1548def ADJCALLSTACKDOWN : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2), 1549 "#ADJCALLSTACKDOWN $amt1 $amt2", 1550 [(callseq_start timm:$amt1, timm:$amt2)]>; 1551def ADJCALLSTACKUP : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2), 1552 "#ADJCALLSTACKUP $amt1 $amt2", 1553 [(callseq_end timm:$amt1, timm:$amt2)]>; 1554} 1555} // hasCtrlDep 1556 1557let Defs = [R1], Uses = [R1] in 1558def DYNALLOC : PPCEmitTimePseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC", 1559 [(set i32:$result, 1560 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>; 1561def DYNAREAOFFSET : PPCEmitTimePseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET", 1562 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>; 1563// Probed alloca to support stack clash protection. 1564let Defs = [R1], Uses = [R1], hasNoSchedulingInfo = 1 in { 1565def PROBED_ALLOCA_32 : PPCCustomInserterPseudo<(outs gprc:$result), 1566 (ins gprc:$negsize, memri:$fpsi), "#PROBED_ALLOCA_32", 1567 [(set i32:$result, 1568 (PPCprobedalloca i32:$negsize, iaddr:$fpsi))]>; 1569def PREPARE_PROBED_ALLOCA_32 : PPCEmitTimePseudo<(outs 1570 gprc:$fp, gprc:$actual_negsize), 1571 (ins gprc:$negsize, memri:$fpsi), "#PREPARE_PROBED_ALLOCA_32", []>; 1572def PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32 : PPCEmitTimePseudo<(outs 1573 gprc:$fp, gprc:$actual_negsize), 1574 (ins gprc:$negsize, memri:$fpsi), 1575 "#PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32", []>, 1576 RegConstraint<"$actual_negsize = $negsize">; 1577def PROBED_STACKALLOC_32 : PPCEmitTimePseudo<(outs gprc:$scratch, gprc:$temp), 1578 (ins i64imm:$stacksize), 1579 "#PROBED_STACKALLOC_32", []>; 1580} 1581 1582// SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after 1583// instruction selection into a branch sequence. 1584let PPC970_Single = 1 in { 1585 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes 1586 // because either operand might become the first operand in an isel, and 1587 // that operand cannot be r0. 1588 def SELECT_CC_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crrc:$cond, 1589 gprc_nor0:$T, gprc_nor0:$F, 1590 i32imm:$BROPC), "#SELECT_CC_I4", 1591 []>; 1592 def SELECT_CC_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crrc:$cond, 1593 g8rc_nox0:$T, g8rc_nox0:$F, 1594 i32imm:$BROPC), "#SELECT_CC_I8", 1595 []>; 1596 def SELECT_CC_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F, 1597 i32imm:$BROPC), "#SELECT_CC_F4", 1598 []>; 1599 def SELECT_CC_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F, 1600 i32imm:$BROPC), "#SELECT_CC_F8", 1601 []>; 1602 def SELECT_CC_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F, 1603 i32imm:$BROPC), "#SELECT_CC_F16", 1604 []>; 1605 def SELECT_CC_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F, 1606 i32imm:$BROPC), "#SELECT_CC_VRRC", 1607 []>; 1608 1609 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition 1610 // register bit directly. 1611 def SELECT_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crbitrc:$cond, 1612 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4", 1613 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>; 1614 def SELECT_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crbitrc:$cond, 1615 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8", 1616 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>; 1617let Predicates = [HasFPU] in { 1618 def SELECT_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crbitrc:$cond, 1619 f4rc:$T, f4rc:$F), "#SELECT_F4", 1620 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>; 1621 def SELECT_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crbitrc:$cond, 1622 f8rc:$T, f8rc:$F), "#SELECT_F8", 1623 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>; 1624 def SELECT_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond, 1625 vrrc:$T, vrrc:$F), "#SELECT_F16", 1626 [(set f128:$dst, (select i1:$cond, f128:$T, f128:$F))]>; 1627} 1628 def SELECT_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond, 1629 vrrc:$T, vrrc:$F), "#SELECT_VRRC", 1630 [(set v4i32:$dst, 1631 (select i1:$cond, v4i32:$T, v4i32:$F))]>; 1632} 1633 1634// SPILL_CR - Indicate that we're dumping the CR register, so we'll need to 1635// scavenge a register for it. 1636let mayStore = 1 in { 1637def SPILL_CR : PPCEmitTimePseudo<(outs), (ins crrc:$cond, memri:$F), 1638 "#SPILL_CR", []>; 1639def SPILL_CRBIT : PPCEmitTimePseudo<(outs), (ins crbitrc:$cond, memri:$F), 1640 "#SPILL_CRBIT", []>; 1641} 1642 1643// RESTORE_CR - Indicate that we're restoring the CR register (previously 1644// spilled), so we'll need to scavenge a register for it. 1645let mayLoad = 1 in { 1646def RESTORE_CR : PPCEmitTimePseudo<(outs crrc:$cond), (ins memri:$F), 1647 "#RESTORE_CR", []>; 1648def RESTORE_CRBIT : PPCEmitTimePseudo<(outs crbitrc:$cond), (ins memri:$F), 1649 "#RESTORE_CRBIT", []>; 1650} 1651 1652let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, hasSideEffects = 0 in { 1653 let isPredicable = 1, isReturn = 1, Uses = [LR, RM] in 1654 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB, 1655 [(retflag)]>, Requires<[In32BitMode]>; 1656 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in { 1657 let isPredicable = 1 in 1658 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB, 1659 []>; 1660 1661 let isCodeGenOnly = 1 in { 1662 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond), 1663 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB, 1664 []>; 1665 1666 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi), 1667 "bcctr 12, $bi, 0", IIC_BrB, []>; 1668 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi), 1669 "bcctr 4, $bi, 0", IIC_BrB, []>; 1670 } 1671 } 1672} 1673 1674// Set the float rounding mode. 1675let Uses = [RM], Defs = [RM] in { 1676def SETRNDi : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins u2imm:$RND), 1677 "#SETRNDi", [(set f64:$FRT, (int_ppc_setrnd (i32 imm:$RND)))]>; 1678 1679def SETRND : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins gprc:$in), 1680 "#SETRND", [(set f64:$FRT, (int_ppc_setrnd gprc :$in))]>; 1681 1682def SETFLM : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FLM), 1683 "#SETFLM", [(set f64:$FRT, (int_ppc_setflm f8rc:$FLM))]>; 1684} 1685 1686let Defs = [LR] in 1687 def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>, 1688 PPC970_Unit_BRU; 1689let Defs = [LR] in 1690 def MoveGOTtoLR : PPCEmitTimePseudo<(outs), (ins), "#MoveGOTtoLR", []>, 1691 PPC970_Unit_BRU; 1692 1693let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, 1694 hasSideEffects = 0 in { 1695 let isBarrier = 1 in { 1696 let isPredicable = 1 in 1697 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$dst), 1698 "b $dst", IIC_BrB, 1699 [(br bb:$dst)]>; 1700 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$dst), 1701 "ba $dst", IIC_BrB, []>; 1702 } 1703 1704 // BCC represents an arbitrary conditional branch on a predicate. 1705 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use 1706 // a two-value operand where a dag node expects two operands. :( 1707 let isCodeGenOnly = 1 in { 1708 class BCC_class : BForm<16, 0, 0, (outs), (ins pred:$cond, condbrtarget:$dst), 1709 "b${cond:cc}${cond:pm} ${cond:reg}, $dst" 1710 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$dst)]*/>; 1711 def BCC : BCC_class; 1712 1713 // The same as BCC, except that it's not a terminator. Used for introducing 1714 // control flow dependency without creating new blocks. 1715 let isTerminator = 0 in def CTRL_DEP : BCC_class; 1716 1717 def BCCA : BForm<16, 1, 0, (outs), (ins pred:$cond, abscondbrtarget:$dst), 1718 "b${cond:cc}a${cond:pm} ${cond:reg}, $dst">; 1719 1720 let isReturn = 1, Uses = [LR, RM] in 1721 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins pred:$cond), 1722 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>; 1723 } 1724 1725 let isCodeGenOnly = 1 in { 1726 let Pattern = [(brcond i1:$bi, bb:$dst)] in 1727 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst), 1728 "bc 12, $bi, $dst">; 1729 1730 let Pattern = [(brcond (not i1:$bi), bb:$dst)] in 1731 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$bi, condbrtarget:$dst), 1732 "bc 4, $bi, $dst">; 1733 1734 let isReturn = 1, Uses = [LR, RM] in { 1735 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$bi), 1736 "bclr 12, $bi, 0", IIC_BrB, []>; 1737 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$bi), 1738 "bclr 4, $bi, 0", IIC_BrB, []>; 1739 } 1740 } 1741 1742 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in { 1743 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins), 1744 "bdzlr", IIC_BrB, []>; 1745 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins), 1746 "bdnzlr", IIC_BrB, []>; 1747 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins), 1748 "bdzlr+", IIC_BrB, []>; 1749 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins), 1750 "bdnzlr+", IIC_BrB, []>; 1751 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins), 1752 "bdzlr-", IIC_BrB, []>; 1753 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins), 1754 "bdnzlr-", IIC_BrB, []>; 1755 } 1756 1757 let Defs = [CTR], Uses = [CTR] in { 1758 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst), 1759 "bdz $dst">; 1760 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst), 1761 "bdnz $dst">; 1762 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$dst), 1763 "bdza $dst">; 1764 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$dst), 1765 "bdnza $dst">; 1766 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$dst), 1767 "bdz+ $dst">; 1768 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$dst), 1769 "bdnz+ $dst">; 1770 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$dst), 1771 "bdza+ $dst">; 1772 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$dst), 1773 "bdnza+ $dst">; 1774 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$dst), 1775 "bdz- $dst">; 1776 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$dst), 1777 "bdnz- $dst">; 1778 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$dst), 1779 "bdza- $dst">; 1780 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$dst), 1781 "bdnza- $dst">; 1782 } 1783} 1784 1785// The unconditional BCL used by the SjLj setjmp code. 1786let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7, 1787 hasSideEffects = 0 in { 1788 let Defs = [LR], Uses = [RM] in { 1789 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$dst), 1790 "bcl 20, 31, $dst">; 1791 } 1792} 1793 1794let isCall = 1, PPC970_Unit = 7, Defs = [LR] in { 1795 // Convenient aliases for call instructions 1796 let Uses = [RM] in { 1797 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$func), 1798 "bl $func", IIC_BrB, []>; // See Pat patterns below. 1799 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$func), 1800 "bla $func", IIC_BrB, [(PPCcall (i32 imm:$func))]>; 1801 1802 let isCodeGenOnly = 1 in { 1803 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$func), 1804 "bl $func", IIC_BrB, []>; 1805 def BCCL : BForm<16, 0, 1, (outs), (ins pred:$cond, condbrtarget:$dst), 1806 "b${cond:cc}l${cond:pm} ${cond:reg}, $dst">; 1807 def BCCLA : BForm<16, 1, 1, (outs), (ins pred:$cond, abscondbrtarget:$dst), 1808 "b${cond:cc}la${cond:pm} ${cond:reg}, $dst">; 1809 1810 def BCL : BForm_4<16, 12, 0, 1, (outs), 1811 (ins crbitrc:$bi, condbrtarget:$dst), 1812 "bcl 12, $bi, $dst">; 1813 def BCLn : BForm_4<16, 4, 0, 1, (outs), 1814 (ins crbitrc:$bi, condbrtarget:$dst), 1815 "bcl 4, $bi, $dst">; 1816 def BL_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24, 1817 (outs), (ins calltarget:$func), 1818 "bl $func\n\tnop", IIC_BrB, []>; 1819 } 1820 } 1821 let Uses = [CTR, RM] in { 1822 let isPredicable = 1 in 1823 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins), 1824 "bctrl", IIC_BrB, [(PPCbctrl)]>, 1825 Requires<[In32BitMode]>; 1826 1827 let isCodeGenOnly = 1 in { 1828 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond), 1829 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB, 1830 []>; 1831 1832 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi), 1833 "bcctrl 12, $bi, 0", IIC_BrB, []>; 1834 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi), 1835 "bcctrl 4, $bi, 0", IIC_BrB, []>; 1836 } 1837 } 1838 let Uses = [LR, RM] in { 1839 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins), 1840 "blrl", IIC_BrB, []>; 1841 1842 let isCodeGenOnly = 1 in { 1843 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins pred:$cond), 1844 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB, 1845 []>; 1846 1847 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$bi), 1848 "bclrl 12, $bi, 0", IIC_BrB, []>; 1849 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$bi), 1850 "bclrl 4, $bi, 0", IIC_BrB, []>; 1851 } 1852 } 1853 let Defs = [CTR], Uses = [CTR, RM] in { 1854 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$dst), 1855 "bdzl $dst">; 1856 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$dst), 1857 "bdnzl $dst">; 1858 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$dst), 1859 "bdzla $dst">; 1860 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$dst), 1861 "bdnzla $dst">; 1862 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$dst), 1863 "bdzl+ $dst">; 1864 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$dst), 1865 "bdnzl+ $dst">; 1866 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$dst), 1867 "bdzla+ $dst">; 1868 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$dst), 1869 "bdnzla+ $dst">; 1870 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$dst), 1871 "bdzl- $dst">; 1872 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$dst), 1873 "bdnzl- $dst">; 1874 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$dst), 1875 "bdzla- $dst">; 1876 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$dst), 1877 "bdnzla- $dst">; 1878 } 1879 let Defs = [CTR], Uses = [CTR, LR, RM] in { 1880 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins), 1881 "bdzlrl", IIC_BrB, []>; 1882 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins), 1883 "bdnzlrl", IIC_BrB, []>; 1884 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins), 1885 "bdzlrl+", IIC_BrB, []>; 1886 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins), 1887 "bdnzlrl+", IIC_BrB, []>; 1888 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins), 1889 "bdzlrl-", IIC_BrB, []>; 1890 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins), 1891 "bdnzlrl-", IIC_BrB, []>; 1892 } 1893} 1894 1895let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in 1896def TCRETURNdi :PPCEmitTimePseudo< (outs), 1897 (ins calltarget:$dst, i32imm:$offset), 1898 "#TC_RETURNd $dst $offset", 1899 []>; 1900 1901 1902let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in 1903def TCRETURNai :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset), 1904 "#TC_RETURNa $func $offset", 1905 [(PPCtc_return (i32 imm:$func), imm:$offset)]>; 1906 1907let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in 1908def TCRETURNri : PPCEmitTimePseudo<(outs), (ins CTRRC:$dst, i32imm:$offset), 1909 "#TC_RETURNr $dst $offset", 1910 []>; 1911 1912let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1, 1913 Defs = [LR, R2], Uses = [CTR, RM], RST = 2 in { 1914 def BCTRL_LWZinto_toc: 1915 XLForm_2_ext_and_DForm_1<19, 528, 20, 0, 1, 32, (outs), 1916 (ins memri:$src), "bctrl\n\tlwz 2, $src", IIC_BrB, 1917 [(PPCbctrl_load_toc iaddr:$src)]>, Requires<[In32BitMode]>; 1918 1919} 1920 1921 1922let isCodeGenOnly = 1, hasSideEffects = 0 in { 1923 1924let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1, 1925 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in 1926def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB, 1927 []>, Requires<[In32BitMode]>; 1928 1929let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, 1930 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in 1931def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$dst), 1932 "b $dst", IIC_BrB, 1933 []>; 1934 1935let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7, 1936 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in 1937def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst), 1938 "ba $dst", IIC_BrB, 1939 []>; 1940 1941} 1942 1943// While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp 1944// is not. 1945let hasSideEffects = 1 in { 1946 let Defs = [CTR] in 1947 def EH_SjLj_SetJmp32 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf), 1948 "#EH_SJLJ_SETJMP32", 1949 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>, 1950 Requires<[In32BitMode]>; 1951} 1952 1953let hasSideEffects = 1, isBarrier = 1 in { 1954 let isTerminator = 1 in 1955 def EH_SjLj_LongJmp32 : PPCCustomInserterPseudo<(outs), (ins memr:$buf), 1956 "#EH_SJLJ_LONGJMP32", 1957 [(PPCeh_sjlj_longjmp addr:$buf)]>, 1958 Requires<[In32BitMode]>; 1959} 1960 1961// This pseudo is never removed from the function, as it serves as 1962// a terminator. Size is set to 0 to prevent the builtin assembler 1963// from emitting it. 1964let isBranch = 1, isTerminator = 1, Size = 0 in { 1965 def EH_SjLj_Setup : PPCEmitTimePseudo<(outs), (ins directbrtarget:$dst), 1966 "#EH_SjLj_Setup\t$dst", []>; 1967} 1968 1969// System call. 1970let PPC970_Unit = 7 in { 1971 def SC : SCForm<17, 1, (outs), (ins i32imm:$lev), 1972 "sc $lev", IIC_BrB, [(PPCsc (i32 imm:$lev))]>; 1973} 1974 1975// Branch history rolling buffer. 1976def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB, 1977 [(PPCclrbhrb)]>, 1978 PPC970_DGroup_Single; 1979// The $dmy argument used for MFBHRBE is not needed; however, including 1980// it avoids automatic generation of PPCFastISel::fastEmit_i(), which 1981// interferes with necessary special handling (see PPCFastISel.cpp). 1982def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$rD), 1983 (ins u10imm:$imm, u10imm:$dmy), 1984 "mfbhrbe $rD, $imm", IIC_BrB, 1985 [(set i32:$rD, 1986 (PPCmfbhrbe imm:$imm, imm:$dmy))]>, 1987 PPC970_DGroup_First; 1988 1989def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$imm), "rfebb $imm", 1990 IIC_BrB, [(PPCrfebb (i32 imm:$imm))]>, 1991 PPC970_DGroup_Single; 1992 1993def : InstAlias<"rfebb", (RFEBB 1)>; 1994 1995// DCB* instructions. 1996def DCBA : DCB_Form<758, 0, (outs), (ins memrr:$dst), "dcba $dst", 1997 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$dst)]>, 1998 PPC970_DGroup_Single; 1999def DCBI : DCB_Form<470, 0, (outs), (ins memrr:$dst), "dcbi $dst", 2000 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$dst)]>, 2001 PPC970_DGroup_Single; 2002def DCBST : DCB_Form<54, 0, (outs), (ins memrr:$dst), "dcbst $dst", 2003 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$dst)]>, 2004 PPC970_DGroup_Single; 2005def DCBZ : DCB_Form<1014, 0, (outs), (ins memrr:$dst), "dcbz $dst", 2006 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>, 2007 PPC970_DGroup_Single; 2008def DCBZL : DCB_Form<1014, 1, (outs), (ins memrr:$dst), "dcbzl $dst", 2009 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>, 2010 PPC970_DGroup_Single; 2011 2012def DCBF : DCB_Form_hint<86, (outs), (ins u3imm:$TH, memrr:$dst), 2013 "dcbf $dst, $TH", IIC_LdStDCBF, []>, 2014 PPC970_DGroup_Single; 2015 2016let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in { 2017def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, memrr:$dst), 2018 "dcbt $dst, $TH", IIC_LdStDCBF, []>, 2019 PPC970_DGroup_Single; 2020def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, memrr:$dst), 2021 "dcbtst $dst, $TH", IIC_LdStDCBF, []>, 2022 PPC970_DGroup_Single; 2023} // hasSideEffects = 0 2024 2025def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, memrr:$src), 2026 "icblc $CT, $src", IIC_LdStStore>, Requires<[HasICBT]>; 2027def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, memrr:$src), 2028 "icblq. $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>; 2029def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, memrr:$src), 2030 "icbt $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>; 2031def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, memrr:$src), 2032 "icbtls $CT, $src", IIC_LdStLoad>, Requires<[HasICBT]>; 2033 2034def : Pat<(int_ppc_dcbt xoaddr:$dst), 2035 (DCBT 0, xoaddr:$dst)>; 2036def : Pat<(int_ppc_dcbtst xoaddr:$dst), 2037 (DCBTST 0, xoaddr:$dst)>; 2038def : Pat<(int_ppc_dcbf xoaddr:$dst), 2039 (DCBF 0, xoaddr:$dst)>; 2040def : Pat<(int_ppc_icbt xoaddr:$dst), 2041 (ICBT 0, xoaddr:$dst)>; 2042 2043def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 1)), 2044 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads 2045def : Pat<(prefetch xoaddr:$dst, (i32 1), imm, (i32 1)), 2046 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores 2047def : Pat<(prefetch xoaddr:$dst, (i32 0), imm, (i32 0)), 2048 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read) 2049 2050def : Pat<(int_ppc_dcbt_with_hint xoaddr:$dst, i32:$TH), 2051 (DCBT i32:$TH, xoaddr:$dst)>; 2052def : Pat<(int_ppc_dcbtst_with_hint xoaddr:$dst, i32:$TH), 2053 (DCBTST i32:$TH, xoaddr:$dst)>; 2054 2055// Atomic operations 2056// FIXME: some of these might be used with constant operands. This will result 2057// in constant materialization instructions that may be redundant. We currently 2058// clean this up in PPCMIPeephole with calls to 2059// PPCInstrInfo::convertToImmediateForm() but we should probably not emit them 2060// in the first place. 2061let Defs = [CR0] in { 2062 def ATOMIC_LOAD_ADD_I8 : PPCCustomInserterPseudo< 2063 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8", 2064 [(set i32:$dst, (atomic_load_add_8 ForceXForm:$ptr, i32:$incr))]>; 2065 def ATOMIC_LOAD_SUB_I8 : PPCCustomInserterPseudo< 2066 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8", 2067 [(set i32:$dst, (atomic_load_sub_8 ForceXForm:$ptr, i32:$incr))]>; 2068 def ATOMIC_LOAD_AND_I8 : PPCCustomInserterPseudo< 2069 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8", 2070 [(set i32:$dst, (atomic_load_and_8 ForceXForm:$ptr, i32:$incr))]>; 2071 def ATOMIC_LOAD_OR_I8 : PPCCustomInserterPseudo< 2072 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8", 2073 [(set i32:$dst, (atomic_load_or_8 ForceXForm:$ptr, i32:$incr))]>; 2074 def ATOMIC_LOAD_XOR_I8 : PPCCustomInserterPseudo< 2075 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8", 2076 [(set i32:$dst, (atomic_load_xor_8 ForceXForm:$ptr, i32:$incr))]>; 2077 def ATOMIC_LOAD_NAND_I8 : PPCCustomInserterPseudo< 2078 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8", 2079 [(set i32:$dst, (atomic_load_nand_8 ForceXForm:$ptr, i32:$incr))]>; 2080 def ATOMIC_LOAD_MIN_I8 : PPCCustomInserterPseudo< 2081 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8", 2082 [(set i32:$dst, (atomic_load_min_8 ForceXForm:$ptr, i32:$incr))]>; 2083 def ATOMIC_LOAD_MAX_I8 : PPCCustomInserterPseudo< 2084 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8", 2085 [(set i32:$dst, (atomic_load_max_8 ForceXForm:$ptr, i32:$incr))]>; 2086 def ATOMIC_LOAD_UMIN_I8 : PPCCustomInserterPseudo< 2087 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8", 2088 [(set i32:$dst, (atomic_load_umin_8 ForceXForm:$ptr, i32:$incr))]>; 2089 def ATOMIC_LOAD_UMAX_I8 : PPCCustomInserterPseudo< 2090 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8", 2091 [(set i32:$dst, (atomic_load_umax_8 ForceXForm:$ptr, i32:$incr))]>; 2092 def ATOMIC_LOAD_ADD_I16 : PPCCustomInserterPseudo< 2093 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16", 2094 [(set i32:$dst, (atomic_load_add_16 ForceXForm:$ptr, i32:$incr))]>; 2095 def ATOMIC_LOAD_SUB_I16 : PPCCustomInserterPseudo< 2096 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16", 2097 [(set i32:$dst, (atomic_load_sub_16 ForceXForm:$ptr, i32:$incr))]>; 2098 def ATOMIC_LOAD_AND_I16 : PPCCustomInserterPseudo< 2099 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16", 2100 [(set i32:$dst, (atomic_load_and_16 ForceXForm:$ptr, i32:$incr))]>; 2101 def ATOMIC_LOAD_OR_I16 : PPCCustomInserterPseudo< 2102 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16", 2103 [(set i32:$dst, (atomic_load_or_16 ForceXForm:$ptr, i32:$incr))]>; 2104 def ATOMIC_LOAD_XOR_I16 : PPCCustomInserterPseudo< 2105 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16", 2106 [(set i32:$dst, (atomic_load_xor_16 ForceXForm:$ptr, i32:$incr))]>; 2107 def ATOMIC_LOAD_NAND_I16 : PPCCustomInserterPseudo< 2108 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16", 2109 [(set i32:$dst, (atomic_load_nand_16 ForceXForm:$ptr, i32:$incr))]>; 2110 def ATOMIC_LOAD_MIN_I16 : PPCCustomInserterPseudo< 2111 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16", 2112 [(set i32:$dst, (atomic_load_min_16 ForceXForm:$ptr, i32:$incr))]>; 2113 def ATOMIC_LOAD_MAX_I16 : PPCCustomInserterPseudo< 2114 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16", 2115 [(set i32:$dst, (atomic_load_max_16 ForceXForm:$ptr, i32:$incr))]>; 2116 def ATOMIC_LOAD_UMIN_I16 : PPCCustomInserterPseudo< 2117 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16", 2118 [(set i32:$dst, (atomic_load_umin_16 ForceXForm:$ptr, i32:$incr))]>; 2119 def ATOMIC_LOAD_UMAX_I16 : PPCCustomInserterPseudo< 2120 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16", 2121 [(set i32:$dst, (atomic_load_umax_16 ForceXForm:$ptr, i32:$incr))]>; 2122 def ATOMIC_LOAD_ADD_I32 : PPCCustomInserterPseudo< 2123 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32", 2124 [(set i32:$dst, (atomic_load_add_32 ForceXForm:$ptr, i32:$incr))]>; 2125 def ATOMIC_LOAD_SUB_I32 : PPCCustomInserterPseudo< 2126 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32", 2127 [(set i32:$dst, (atomic_load_sub_32 ForceXForm:$ptr, i32:$incr))]>; 2128 def ATOMIC_LOAD_AND_I32 : PPCCustomInserterPseudo< 2129 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32", 2130 [(set i32:$dst, (atomic_load_and_32 ForceXForm:$ptr, i32:$incr))]>; 2131 def ATOMIC_LOAD_OR_I32 : PPCCustomInserterPseudo< 2132 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32", 2133 [(set i32:$dst, (atomic_load_or_32 ForceXForm:$ptr, i32:$incr))]>; 2134 def ATOMIC_LOAD_XOR_I32 : PPCCustomInserterPseudo< 2135 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32", 2136 [(set i32:$dst, (atomic_load_xor_32 ForceXForm:$ptr, i32:$incr))]>; 2137 def ATOMIC_LOAD_NAND_I32 : PPCCustomInserterPseudo< 2138 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32", 2139 [(set i32:$dst, (atomic_load_nand_32 ForceXForm:$ptr, i32:$incr))]>; 2140 def ATOMIC_LOAD_MIN_I32 : PPCCustomInserterPseudo< 2141 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32", 2142 [(set i32:$dst, (atomic_load_min_32 ForceXForm:$ptr, i32:$incr))]>; 2143 def ATOMIC_LOAD_MAX_I32 : PPCCustomInserterPseudo< 2144 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32", 2145 [(set i32:$dst, (atomic_load_max_32 ForceXForm:$ptr, i32:$incr))]>; 2146 def ATOMIC_LOAD_UMIN_I32 : PPCCustomInserterPseudo< 2147 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32", 2148 [(set i32:$dst, (atomic_load_umin_32 ForceXForm:$ptr, i32:$incr))]>; 2149 def ATOMIC_LOAD_UMAX_I32 : PPCCustomInserterPseudo< 2150 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32", 2151 [(set i32:$dst, (atomic_load_umax_32 ForceXForm:$ptr, i32:$incr))]>; 2152 2153 def ATOMIC_CMP_SWAP_I8 : PPCCustomInserterPseudo< 2154 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8", 2155 [(set i32:$dst, (atomic_cmp_swap_8 ForceXForm:$ptr, i32:$old, i32:$new))]>; 2156 def ATOMIC_CMP_SWAP_I16 : PPCCustomInserterPseudo< 2157 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new", 2158 [(set i32:$dst, (atomic_cmp_swap_16 ForceXForm:$ptr, i32:$old, i32:$new))]>; 2159 def ATOMIC_CMP_SWAP_I32 : PPCCustomInserterPseudo< 2160 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new", 2161 [(set i32:$dst, (atomic_cmp_swap_32 ForceXForm:$ptr, i32:$old, i32:$new))]>; 2162 2163 def ATOMIC_SWAP_I8 : PPCCustomInserterPseudo< 2164 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8", 2165 [(set i32:$dst, (atomic_swap_8 ForceXForm:$ptr, i32:$new))]>; 2166 def ATOMIC_SWAP_I16 : PPCCustomInserterPseudo< 2167 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16", 2168 [(set i32:$dst, (atomic_swap_16 ForceXForm:$ptr, i32:$new))]>; 2169 def ATOMIC_SWAP_I32 : PPCCustomInserterPseudo< 2170 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32", 2171 [(set i32:$dst, (atomic_swap_32 ForceXForm:$ptr, i32:$new))]>; 2172} 2173 2174def : Pat<(PPCatomicCmpSwap_8 ForceXForm:$ptr, i32:$old, i32:$new), 2175 (ATOMIC_CMP_SWAP_I8 ForceXForm:$ptr, i32:$old, i32:$new)>; 2176def : Pat<(PPCatomicCmpSwap_16 ForceXForm:$ptr, i32:$old, i32:$new), 2177 (ATOMIC_CMP_SWAP_I16 ForceXForm:$ptr, i32:$old, i32:$new)>; 2178 2179// Instructions to support atomic operations 2180let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in { 2181def LBARX : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src), 2182 "lbarx $rD, $src", IIC_LdStLWARX, []>, 2183 Requires<[HasPartwordAtomics]>; 2184 2185def LHARX : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src), 2186 "lharx $rD, $src", IIC_LdStLWARX, []>, 2187 Requires<[HasPartwordAtomics]>; 2188 2189def LWARX : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src), 2190 "lwarx $rD, $src", IIC_LdStLWARX, []>; 2191 2192// Instructions to support lock versions of atomics 2193// (EH=1 - see Power ISA 2.07 Book II 4.4.2) 2194def LBARXL : XForm_1_memOp<31, 52, (outs gprc:$rD), (ins memrr:$src), 2195 "lbarx $rD, $src, 1", IIC_LdStLWARX, []>, isRecordForm, 2196 Requires<[HasPartwordAtomics]>; 2197 2198def LHARXL : XForm_1_memOp<31, 116, (outs gprc:$rD), (ins memrr:$src), 2199 "lharx $rD, $src, 1", IIC_LdStLWARX, []>, isRecordForm, 2200 Requires<[HasPartwordAtomics]>; 2201 2202def LWARXL : XForm_1_memOp<31, 20, (outs gprc:$rD), (ins memrr:$src), 2203 "lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isRecordForm; 2204 2205// The atomic instructions use the destination register as well as the next one 2206// or two registers in order (modulo 31). 2207let hasExtraSrcRegAllocReq = 1 in 2208def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC), 2209 "lwat $rD, $rA, $FC", IIC_LdStLoad>, 2210 Requires<[IsISA3_0]>; 2211} 2212 2213let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in { 2214def STBCX : XForm_1_memOp<31, 694, (outs), (ins gprc:$rS, memrr:$dst), 2215 "stbcx. $rS, $dst", IIC_LdStSTWCX, []>, 2216 isRecordForm, Requires<[HasPartwordAtomics]>; 2217 2218def STHCX : XForm_1_memOp<31, 726, (outs), (ins gprc:$rS, memrr:$dst), 2219 "sthcx. $rS, $dst", IIC_LdStSTWCX, []>, 2220 isRecordForm, Requires<[HasPartwordAtomics]>; 2221 2222def STWCX : XForm_1_memOp<31, 150, (outs), (ins gprc:$rS, memrr:$dst), 2223 "stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isRecordForm; 2224} 2225 2226let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in 2227def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC), 2228 "stwat $rS, $rA, $FC", IIC_LdStStore>, 2229 Requires<[IsISA3_0]>; 2230 2231let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in 2232def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>; 2233 2234def TWI : DForm_base<3, (outs), (ins u5imm:$to, gprc:$rA, s16imm:$imm), 2235 "twi $to, $rA, $imm", IIC_IntTrapW, []>; 2236def TW : XForm_1<31, 4, (outs), (ins u5imm:$to, gprc:$rA, gprc:$rB), 2237 "tw $to, $rA, $rB", IIC_IntTrapW, []>; 2238def TDI : DForm_base<2, (outs), (ins u5imm:$to, g8rc:$rA, s16imm:$imm), 2239 "tdi $to, $rA, $imm", IIC_IntTrapD, []>; 2240def TD : XForm_1<31, 68, (outs), (ins u5imm:$to, g8rc:$rA, g8rc:$rB), 2241 "td $to, $rA, $rB", IIC_IntTrapD, []>; 2242 2243def POPCNTB : XForm_11<31, 122, (outs gprc:$rA), (ins gprc:$rS), 2244 "popcntb $rA, $rS", IIC_IntGeneral, 2245 [(set i32:$rA, (int_ppc_popcntb i32:$rS))]>; 2246 2247//===----------------------------------------------------------------------===// 2248// PPC32 Load Instructions. 2249// 2250 2251// Unindexed (r+i) Loads. 2252let PPC970_Unit = 2 in { 2253def LBZ : DForm_1<34, (outs gprc:$rD), (ins memri:$src), 2254 "lbz $rD, $src", IIC_LdStLoad, 2255 [(set i32:$rD, (zextloadi8 DForm:$src))]>; 2256def LHA : DForm_1<42, (outs gprc:$rD), (ins memri:$src), 2257 "lha $rD, $src", IIC_LdStLHA, 2258 [(set i32:$rD, (sextloadi16 DForm:$src))]>, 2259 PPC970_DGroup_Cracked; 2260def LHZ : DForm_1<40, (outs gprc:$rD), (ins memri:$src), 2261 "lhz $rD, $src", IIC_LdStLoad, 2262 [(set i32:$rD, (zextloadi16 DForm:$src))]>; 2263def LWZ : DForm_1<32, (outs gprc:$rD), (ins memri:$src), 2264 "lwz $rD, $src", IIC_LdStLoad, 2265 [(set i32:$rD, (load DForm:$src))]>; 2266 2267let Predicates = [HasFPU] in { 2268def LFS : DForm_1<48, (outs f4rc:$rD), (ins memri:$src), 2269 "lfs $rD, $src", IIC_LdStLFD, 2270 [(set f32:$rD, (load DForm:$src))]>; 2271def LFD : DForm_1<50, (outs f8rc:$rD), (ins memri:$src), 2272 "lfd $rD, $src", IIC_LdStLFD, 2273 [(set f64:$rD, (load DForm:$src))]>; 2274} 2275 2276 2277// Unindexed (r+i) Loads with Update (preinc). 2278let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in { 2279def LBZU : DForm_1<35, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 2280 "lbzu $rD, $addr", IIC_LdStLoadUpd, 2281 []>, RegConstraint<"$addr.reg = $ea_result">, 2282 NoEncode<"$ea_result">; 2283 2284def LHAU : DForm_1<43, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 2285 "lhau $rD, $addr", IIC_LdStLHAU, 2286 []>, RegConstraint<"$addr.reg = $ea_result">, 2287 NoEncode<"$ea_result">; 2288 2289def LHZU : DForm_1<41, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 2290 "lhzu $rD, $addr", IIC_LdStLoadUpd, 2291 []>, RegConstraint<"$addr.reg = $ea_result">, 2292 NoEncode<"$ea_result">; 2293 2294def LWZU : DForm_1<33, (outs gprc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 2295 "lwzu $rD, $addr", IIC_LdStLoadUpd, 2296 []>, RegConstraint<"$addr.reg = $ea_result">, 2297 NoEncode<"$ea_result">; 2298 2299let Predicates = [HasFPU] in { 2300def LFSU : DForm_1<49, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 2301 "lfsu $rD, $addr", IIC_LdStLFDU, 2302 []>, RegConstraint<"$addr.reg = $ea_result">, 2303 NoEncode<"$ea_result">; 2304 2305def LFDU : DForm_1<51, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr), 2306 "lfdu $rD, $addr", IIC_LdStLFDU, 2307 []>, RegConstraint<"$addr.reg = $ea_result">, 2308 NoEncode<"$ea_result">; 2309} 2310 2311 2312// Indexed (r+r) Loads with Update (preinc). 2313def LBZUX : XForm_1_memOp<31, 119, (outs gprc:$rD, ptr_rc_nor0:$ea_result), 2314 (ins memrr:$addr), 2315 "lbzux $rD, $addr", IIC_LdStLoadUpdX, 2316 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 2317 NoEncode<"$ea_result">; 2318 2319def LHAUX : XForm_1_memOp<31, 375, (outs gprc:$rD, ptr_rc_nor0:$ea_result), 2320 (ins memrr:$addr), 2321 "lhaux $rD, $addr", IIC_LdStLHAUX, 2322 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 2323 NoEncode<"$ea_result">; 2324 2325def LHZUX : XForm_1_memOp<31, 311, (outs gprc:$rD, ptr_rc_nor0:$ea_result), 2326 (ins memrr:$addr), 2327 "lhzux $rD, $addr", IIC_LdStLoadUpdX, 2328 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 2329 NoEncode<"$ea_result">; 2330 2331def LWZUX : XForm_1_memOp<31, 55, (outs gprc:$rD, ptr_rc_nor0:$ea_result), 2332 (ins memrr:$addr), 2333 "lwzux $rD, $addr", IIC_LdStLoadUpdX, 2334 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 2335 NoEncode<"$ea_result">; 2336 2337let Predicates = [HasFPU] in { 2338def LFSUX : XForm_1_memOp<31, 567, (outs f4rc:$rD, ptr_rc_nor0:$ea_result), 2339 (ins memrr:$addr), 2340 "lfsux $rD, $addr", IIC_LdStLFDUX, 2341 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 2342 NoEncode<"$ea_result">; 2343 2344def LFDUX : XForm_1_memOp<31, 631, (outs f8rc:$rD, ptr_rc_nor0:$ea_result), 2345 (ins memrr:$addr), 2346 "lfdux $rD, $addr", IIC_LdStLFDUX, 2347 []>, RegConstraint<"$addr.ptrreg = $ea_result">, 2348 NoEncode<"$ea_result">; 2349} 2350} 2351} 2352 2353// Indexed (r+r) Loads. 2354// 2355let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in { 2356def LBZX : XForm_1_memOp<31, 87, (outs gprc:$rD), (ins memrr:$src), 2357 "lbzx $rD, $src", IIC_LdStLoad, 2358 [(set i32:$rD, (zextloadi8 XForm:$src))]>; 2359def LHAX : XForm_1_memOp<31, 343, (outs gprc:$rD), (ins memrr:$src), 2360 "lhax $rD, $src", IIC_LdStLHA, 2361 [(set i32:$rD, (sextloadi16 XForm:$src))]>, 2362 PPC970_DGroup_Cracked; 2363def LHZX : XForm_1_memOp<31, 279, (outs gprc:$rD), (ins memrr:$src), 2364 "lhzx $rD, $src", IIC_LdStLoad, 2365 [(set i32:$rD, (zextloadi16 XForm:$src))]>; 2366def LWZX : XForm_1_memOp<31, 23, (outs gprc:$rD), (ins memrr:$src), 2367 "lwzx $rD, $src", IIC_LdStLoad, 2368 [(set i32:$rD, (load XForm:$src))]>; 2369def LHBRX : XForm_1_memOp<31, 790, (outs gprc:$rD), (ins memrr:$src), 2370 "lhbrx $rD, $src", IIC_LdStLoad, 2371 [(set i32:$rD, (PPClbrx ForceXForm:$src, i16))]>; 2372def LWBRX : XForm_1_memOp<31, 534, (outs gprc:$rD), (ins memrr:$src), 2373 "lwbrx $rD, $src", IIC_LdStLoad, 2374 [(set i32:$rD, (PPClbrx ForceXForm:$src, i32))]>; 2375 2376let Predicates = [HasFPU] in { 2377def LFSX : XForm_25_memOp<31, 535, (outs f4rc:$frD), (ins memrr:$src), 2378 "lfsx $frD, $src", IIC_LdStLFD, 2379 [(set f32:$frD, (load XForm:$src))]>; 2380def LFDX : XForm_25_memOp<31, 599, (outs f8rc:$frD), (ins memrr:$src), 2381 "lfdx $frD, $src", IIC_LdStLFD, 2382 [(set f64:$frD, (load XForm:$src))]>; 2383 2384def LFIWAX : XForm_25_memOp<31, 855, (outs f8rc:$frD), (ins memrr:$src), 2385 "lfiwax $frD, $src", IIC_LdStLFD, 2386 [(set f64:$frD, (PPClfiwax ForceXForm:$src))]>; 2387def LFIWZX : XForm_25_memOp<31, 887, (outs f8rc:$frD), (ins memrr:$src), 2388 "lfiwzx $frD, $src", IIC_LdStLFD, 2389 [(set f64:$frD, (PPClfiwzx ForceXForm:$src))]>; 2390} 2391} 2392 2393// Load Multiple 2394let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in 2395def LMW : DForm_1<46, (outs gprc:$rD), (ins memri:$src), 2396 "lmw $rD, $src", IIC_LdStLMW, []>; 2397 2398//===----------------------------------------------------------------------===// 2399// PPC32 Store Instructions. 2400// 2401 2402// Unindexed (r+i) Stores. 2403let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in { 2404def STB : DForm_1<38, (outs), (ins gprc:$rS, memri:$dst), 2405 "stb $rS, $dst", IIC_LdStStore, 2406 [(truncstorei8 i32:$rS, DForm:$dst)]>; 2407def STH : DForm_1<44, (outs), (ins gprc:$rS, memri:$dst), 2408 "sth $rS, $dst", IIC_LdStStore, 2409 [(truncstorei16 i32:$rS, DForm:$dst)]>; 2410def STW : DForm_1<36, (outs), (ins gprc:$rS, memri:$dst), 2411 "stw $rS, $dst", IIC_LdStStore, 2412 [(store i32:$rS, DForm:$dst)]>; 2413let Predicates = [HasFPU] in { 2414def STFS : DForm_1<52, (outs), (ins f4rc:$rS, memri:$dst), 2415 "stfs $rS, $dst", IIC_LdStSTFD, 2416 [(store f32:$rS, DForm:$dst)]>; 2417def STFD : DForm_1<54, (outs), (ins f8rc:$rS, memri:$dst), 2418 "stfd $rS, $dst", IIC_LdStSTFD, 2419 [(store f64:$rS, DForm:$dst)]>; 2420} 2421} 2422 2423// Unindexed (r+i) Stores with Update (preinc). 2424let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in { 2425def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst), 2426 "stbu $rS, $dst", IIC_LdStSTU, []>, 2427 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 2428def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst), 2429 "sthu $rS, $dst", IIC_LdStSTU, []>, 2430 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 2431def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$rS, memri:$dst), 2432 "stwu $rS, $dst", IIC_LdStSTU, []>, 2433 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 2434let Predicates = [HasFPU] in { 2435def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$rS, memri:$dst), 2436 "stfsu $rS, $dst", IIC_LdStSTFDU, []>, 2437 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 2438def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$rS, memri:$dst), 2439 "stfdu $rS, $dst", IIC_LdStSTFDU, []>, 2440 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">; 2441} 2442} 2443 2444// Patterns to match the pre-inc stores. We can't put the patterns on 2445// the instruction definitions directly as ISel wants the address base 2446// and offset to be separate operands, not a single complex operand. 2447def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 2448 (STBU $rS, iaddroff:$ptroff, $ptrreg)>; 2449def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 2450 (STHU $rS, iaddroff:$ptroff, $ptrreg)>; 2451def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 2452 (STWU $rS, iaddroff:$ptroff, $ptrreg)>; 2453def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 2454 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>; 2455def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff), 2456 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>; 2457 2458// Indexed (r+r) Stores. 2459let PPC970_Unit = 2 in { 2460def STBX : XForm_8_memOp<31, 215, (outs), (ins gprc:$rS, memrr:$dst), 2461 "stbx $rS, $dst", IIC_LdStStore, 2462 [(truncstorei8 i32:$rS, XForm:$dst)]>, 2463 PPC970_DGroup_Cracked; 2464def STHX : XForm_8_memOp<31, 407, (outs), (ins gprc:$rS, memrr:$dst), 2465 "sthx $rS, $dst", IIC_LdStStore, 2466 [(truncstorei16 i32:$rS, XForm:$dst)]>, 2467 PPC970_DGroup_Cracked; 2468def STWX : XForm_8_memOp<31, 151, (outs), (ins gprc:$rS, memrr:$dst), 2469 "stwx $rS, $dst", IIC_LdStStore, 2470 [(store i32:$rS, XForm:$dst)]>, 2471 PPC970_DGroup_Cracked; 2472 2473def STHBRX: XForm_8_memOp<31, 918, (outs), (ins gprc:$rS, memrr:$dst), 2474 "sthbrx $rS, $dst", IIC_LdStStore, 2475 [(PPCstbrx i32:$rS, ForceXForm:$dst, i16)]>, 2476 PPC970_DGroup_Cracked; 2477def STWBRX: XForm_8_memOp<31, 662, (outs), (ins gprc:$rS, memrr:$dst), 2478 "stwbrx $rS, $dst", IIC_LdStStore, 2479 [(PPCstbrx i32:$rS, ForceXForm:$dst, i32)]>, 2480 PPC970_DGroup_Cracked; 2481 2482let Predicates = [HasFPU] in { 2483def STFIWX: XForm_28_memOp<31, 983, (outs), (ins f8rc:$frS, memrr:$dst), 2484 "stfiwx $frS, $dst", IIC_LdStSTFD, 2485 [(PPCstfiwx f64:$frS, ForceXForm:$dst)]>; 2486 2487def STFSX : XForm_28_memOp<31, 663, (outs), (ins f4rc:$frS, memrr:$dst), 2488 "stfsx $frS, $dst", IIC_LdStSTFD, 2489 [(store f32:$frS, XForm:$dst)]>; 2490def STFDX : XForm_28_memOp<31, 727, (outs), (ins f8rc:$frS, memrr:$dst), 2491 "stfdx $frS, $dst", IIC_LdStSTFD, 2492 [(store f64:$frS, XForm:$dst)]>; 2493} 2494} 2495 2496// Indexed (r+r) Stores with Update (preinc). 2497let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in { 2498def STBUX : XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res), 2499 (ins gprc:$rS, memrr:$dst), 2500 "stbux $rS, $dst", IIC_LdStSTUX, []>, 2501 RegConstraint<"$dst.ptrreg = $ea_res">, 2502 NoEncode<"$ea_res">, 2503 PPC970_DGroup_Cracked; 2504def STHUX : XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res), 2505 (ins gprc:$rS, memrr:$dst), 2506 "sthux $rS, $dst", IIC_LdStSTUX, []>, 2507 RegConstraint<"$dst.ptrreg = $ea_res">, 2508 NoEncode<"$ea_res">, 2509 PPC970_DGroup_Cracked; 2510def STWUX : XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res), 2511 (ins gprc:$rS, memrr:$dst), 2512 "stwux $rS, $dst", IIC_LdStSTUX, []>, 2513 RegConstraint<"$dst.ptrreg = $ea_res">, 2514 NoEncode<"$ea_res">, 2515 PPC970_DGroup_Cracked; 2516let Predicates = [HasFPU] in { 2517def STFSUX: XForm_8_memOp<31, 695, (outs ptr_rc_nor0:$ea_res), 2518 (ins f4rc:$rS, memrr:$dst), 2519 "stfsux $rS, $dst", IIC_LdStSTFDU, []>, 2520 RegConstraint<"$dst.ptrreg = $ea_res">, 2521 NoEncode<"$ea_res">, 2522 PPC970_DGroup_Cracked; 2523def STFDUX: XForm_8_memOp<31, 759, (outs ptr_rc_nor0:$ea_res), 2524 (ins f8rc:$rS, memrr:$dst), 2525 "stfdux $rS, $dst", IIC_LdStSTFDU, []>, 2526 RegConstraint<"$dst.ptrreg = $ea_res">, 2527 NoEncode<"$ea_res">, 2528 PPC970_DGroup_Cracked; 2529} 2530} 2531 2532// Patterns to match the pre-inc stores. We can't put the patterns on 2533// the instruction definitions directly as ISel wants the address base 2534// and offset to be separate operands, not a single complex operand. 2535def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff), 2536 (STBUX $rS, $ptrreg, $ptroff)>; 2537def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff), 2538 (STHUX $rS, $ptrreg, $ptroff)>; 2539def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff), 2540 (STWUX $rS, $ptrreg, $ptroff)>; 2541let Predicates = [HasFPU] in { 2542def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff), 2543 (STFSUX $rS, $ptrreg, $ptroff)>; 2544def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff), 2545 (STFDUX $rS, $ptrreg, $ptroff)>; 2546} 2547 2548// Store Multiple 2549let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in 2550def STMW : DForm_1<47, (outs), (ins gprc:$rS, memri:$dst), 2551 "stmw $rS, $dst", IIC_LdStLMW, []>; 2552 2553def SYNC : XForm_24_sync<31, 598, (outs), (ins u2imm:$L), 2554 "sync $L", IIC_LdStSync, []>; 2555 2556let isCodeGenOnly = 1 in { 2557 def MSYNC : XForm_24_sync<31, 598, (outs), (ins), 2558 "msync", IIC_LdStSync, []> { 2559 let L = 0; 2560 } 2561} 2562 2563// We used to have EIEIO as value but E[0-9A-Z] is a reserved name 2564def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins), 2565 "eieio", IIC_LdStLoad, []>; 2566 2567def PseudoEIEIO : PPCEmitTimePseudo<(outs), (ins), "#PPCEIEIO", 2568 [(int_ppc_eieio)]>; 2569 2570def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>; 2571def : Pat<(int_ppc_iospace_sync), (SYNC 0)>, Requires<[HasSYNC]>; 2572def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>; 2573def : Pat<(int_ppc_iospace_lwsync), (SYNC 1)>, Requires<[HasSYNC]>; 2574def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>; 2575def : Pat<(int_ppc_iospace_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>; 2576def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>; 2577def : Pat<(int_ppc_iospace_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>; 2578def : Pat<(int_ppc_eieio), (PseudoEIEIO)>; 2579def : Pat<(int_ppc_iospace_eieio), (PseudoEIEIO)>; 2580 2581//===----------------------------------------------------------------------===// 2582// PPC32 Arithmetic Instructions. 2583// 2584 2585let PPC970_Unit = 1 in { // FXU Operations. 2586def ADDI : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$imm), 2587 "addi $rD, $rA, $imm", IIC_IntSimple, 2588 [(set i32:$rD, (add i32:$rA, imm32SExt16:$imm))]>; 2589let BaseName = "addic" in { 2590let Defs = [CARRY] in 2591def ADDIC : DForm_2<12, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm), 2592 "addic $rD, $rA, $imm", IIC_IntGeneral, 2593 [(set i32:$rD, (addc i32:$rA, imm32SExt16:$imm))]>, 2594 RecFormRel, PPC970_DGroup_Cracked; 2595let Defs = [CARRY, CR0] in 2596def ADDIC_rec : DForm_2<13, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm), 2597 "addic. $rD, $rA, $imm", IIC_IntGeneral, 2598 []>, isRecordForm, RecFormRel; 2599} 2600def ADDIS : DForm_2<15, (outs gprc:$rD), (ins gprc_nor0:$rA, s17imm:$imm), 2601 "addis $rD, $rA, $imm", IIC_IntSimple, 2602 [(set i32:$rD, (add i32:$rA, imm16ShiftedSExt:$imm))]>; 2603let isCodeGenOnly = 1 in 2604def LA : DForm_2<14, (outs gprc:$rD), (ins gprc_nor0:$rA, s16imm:$sym), 2605 "la $rD, $sym($rA)", IIC_IntGeneral, 2606 [(set i32:$rD, (add i32:$rA, 2607 (PPClo tglobaladdr:$sym, 0)))]>; 2608def MULLI : DForm_2< 7, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm), 2609 "mulli $rD, $rA, $imm", IIC_IntMulLI, 2610 [(set i32:$rD, (mul i32:$rA, imm32SExt16:$imm))]>; 2611let Defs = [CARRY] in 2612def SUBFIC : DForm_2< 8, (outs gprc:$rD), (ins gprc:$rA, s16imm:$imm), 2613 "subfic $rD, $rA, $imm", IIC_IntGeneral, 2614 [(set i32:$rD, (subc imm32SExt16:$imm, i32:$rA))]>; 2615 2616let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in { 2617 def LI : DForm_2_r0<14, (outs gprc:$rD), (ins s16imm:$imm), 2618 "li $rD, $imm", IIC_IntSimple, 2619 [(set i32:$rD, imm32SExt16:$imm)]>; 2620 def LIS : DForm_2_r0<15, (outs gprc:$rD), (ins s17imm:$imm), 2621 "lis $rD, $imm", IIC_IntSimple, 2622 [(set i32:$rD, imm16ShiftedSExt:$imm)]>; 2623} 2624} 2625 2626def : InstAlias<"li $rD, $imm", (ADDI gprc:$rD, ZERO, s16imm:$imm)>; 2627def : InstAlias<"lis $rD, $imm", (ADDIS gprc:$rD, ZERO, s17imm:$imm)>; 2628 2629let PPC970_Unit = 1 in { // FXU Operations. 2630let Defs = [CR0] in { 2631def ANDI_rec : DForm_4<28, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2632 "andi. $dst, $src1, $src2", IIC_IntGeneral, 2633 [(set i32:$dst, (and i32:$src1, immZExt16:$src2))]>, 2634 isRecordForm; 2635def ANDIS_rec : DForm_4<29, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2636 "andis. $dst, $src1, $src2", IIC_IntGeneral, 2637 [(set i32:$dst, (and i32:$src1, imm16ShiftedZExt:$src2))]>, 2638 isRecordForm; 2639} 2640def ORI : DForm_4<24, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2641 "ori $dst, $src1, $src2", IIC_IntSimple, 2642 [(set i32:$dst, (or i32:$src1, immZExt16:$src2))]>; 2643def ORIS : DForm_4<25, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2644 "oris $dst, $src1, $src2", IIC_IntSimple, 2645 [(set i32:$dst, (or i32:$src1, imm16ShiftedZExt:$src2))]>; 2646def XORI : DForm_4<26, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2647 "xori $dst, $src1, $src2", IIC_IntSimple, 2648 [(set i32:$dst, (xor i32:$src1, immZExt16:$src2))]>; 2649def XORIS : DForm_4<27, (outs gprc:$dst), (ins gprc:$src1, u16imm:$src2), 2650 "xoris $dst, $src1, $src2", IIC_IntSimple, 2651 [(set i32:$dst, (xor i32:$src1, imm16ShiftedZExt:$src2))]>; 2652 2653def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple, 2654 []>; 2655let isCodeGenOnly = 1 in { 2656// The POWER6 and POWER7 have special group-terminating nops. 2657def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins), 2658 "ori 1, 1, 0", IIC_IntSimple, []>; 2659def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins), 2660 "ori 2, 2, 0", IIC_IntSimple, []>; 2661} 2662 2663let isCompare = 1, hasSideEffects = 0 in { 2664 def CMPWI : DForm_5_ext<11, (outs crrc:$crD), (ins gprc:$rA, s16imm:$imm), 2665 "cmpwi $crD, $rA, $imm", IIC_IntCompare>; 2666 def CMPLWI : DForm_6_ext<10, (outs crrc:$dst), (ins gprc:$src1, u16imm:$src2), 2667 "cmplwi $dst, $src1, $src2", IIC_IntCompare>; 2668 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crrc:$BF), 2669 (ins u1imm:$L, gprc:$rA, gprc:$rB), 2670 "cmprb $BF, $L, $rA, $rB", IIC_IntCompare, []>, 2671 Requires<[IsISA3_0]>; 2672} 2673} 2674 2675let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations. 2676let isCommutable = 1 in { 2677defm NAND : XForm_6r<31, 476, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2678 "nand", "$rA, $rS, $rB", IIC_IntSimple, 2679 [(set i32:$rA, (not (and i32:$rS, i32:$rB)))]>; 2680defm AND : XForm_6r<31, 28, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2681 "and", "$rA, $rS, $rB", IIC_IntSimple, 2682 [(set i32:$rA, (and i32:$rS, i32:$rB))]>; 2683} // isCommutable 2684defm ANDC : XForm_6r<31, 60, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2685 "andc", "$rA, $rS, $rB", IIC_IntSimple, 2686 [(set i32:$rA, (and i32:$rS, (not i32:$rB)))]>; 2687let isCommutable = 1 in { 2688defm OR : XForm_6r<31, 444, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2689 "or", "$rA, $rS, $rB", IIC_IntSimple, 2690 [(set i32:$rA, (or i32:$rS, i32:$rB))]>; 2691defm NOR : XForm_6r<31, 124, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2692 "nor", "$rA, $rS, $rB", IIC_IntSimple, 2693 [(set i32:$rA, (not (or i32:$rS, i32:$rB)))]>; 2694} // isCommutable 2695defm ORC : XForm_6r<31, 412, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2696 "orc", "$rA, $rS, $rB", IIC_IntSimple, 2697 [(set i32:$rA, (or i32:$rS, (not i32:$rB)))]>; 2698let isCommutable = 1 in { 2699defm EQV : XForm_6r<31, 284, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2700 "eqv", "$rA, $rS, $rB", IIC_IntSimple, 2701 [(set i32:$rA, (not (xor i32:$rS, i32:$rB)))]>; 2702defm XOR : XForm_6r<31, 316, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2703 "xor", "$rA, $rS, $rB", IIC_IntSimple, 2704 [(set i32:$rA, (xor i32:$rS, i32:$rB))]>; 2705} // isCommutable 2706defm SLW : XForm_6r<31, 24, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2707 "slw", "$rA, $rS, $rB", IIC_IntGeneral, 2708 [(set i32:$rA, (PPCshl i32:$rS, i32:$rB))]>; 2709defm SRW : XForm_6r<31, 536, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2710 "srw", "$rA, $rS, $rB", IIC_IntGeneral, 2711 [(set i32:$rA, (PPCsrl i32:$rS, i32:$rB))]>; 2712defm SRAW : XForm_6rc<31, 792, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2713 "sraw", "$rA, $rS, $rB", IIC_IntShift, 2714 [(set i32:$rA, (PPCsra i32:$rS, i32:$rB))]>; 2715} 2716 2717def : InstAlias<"mr $rA, $rB", (OR gprc:$rA, gprc:$rB, gprc:$rB)>; 2718def : InstAlias<"mr. $rA, $rB", (OR_rec gprc:$rA, gprc:$rB, gprc:$rB)>; 2719 2720def : InstAlias<"not $rA, $rS", (NOR gprc:$rA, gprc:$rS, gprc:$rS)>; 2721def : InstAlias<"not. $rA, $rS", (NOR_rec gprc:$rA, gprc:$rS, gprc:$rS)>; 2722 2723def : InstAlias<"nop", (ORI R0, R0, 0)>; 2724 2725let PPC970_Unit = 1 in { // FXU Operations. 2726let hasSideEffects = 0 in { 2727defm SRAWI : XForm_10rc<31, 824, (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH), 2728 "srawi", "$rA, $rS, $SH", IIC_IntShift, 2729 [(set i32:$rA, (sra i32:$rS, (i32 imm:$SH)))]>; 2730defm CNTLZW : XForm_11r<31, 26, (outs gprc:$rA), (ins gprc:$rS), 2731 "cntlzw", "$rA, $rS", IIC_IntGeneral, 2732 [(set i32:$rA, (ctlz i32:$rS))]>; 2733defm CNTTZW : XForm_11r<31, 538, (outs gprc:$rA), (ins gprc:$rS), 2734 "cnttzw", "$rA, $rS", IIC_IntGeneral, 2735 [(set i32:$rA, (cttz i32:$rS))]>, Requires<[IsISA3_0]>; 2736defm EXTSB : XForm_11r<31, 954, (outs gprc:$rA), (ins gprc:$rS), 2737 "extsb", "$rA, $rS", IIC_IntSimple, 2738 [(set i32:$rA, (sext_inreg i32:$rS, i8))]>; 2739defm EXTSH : XForm_11r<31, 922, (outs gprc:$rA), (ins gprc:$rS), 2740 "extsh", "$rA, $rS", IIC_IntSimple, 2741 [(set i32:$rA, (sext_inreg i32:$rS, i16))]>; 2742 2743let isCommutable = 1 in 2744def CMPB : XForm_6<31, 508, (outs gprc:$rA), (ins gprc:$rS, gprc:$rB), 2745 "cmpb $rA, $rS, $rB", IIC_IntGeneral, 2746 [(set i32:$rA, (PPCcmpb i32:$rS, i32:$rB))]>; 2747} 2748let isCompare = 1, hasSideEffects = 0 in { 2749 def CMPW : XForm_16_ext<31, 0, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB), 2750 "cmpw $crD, $rA, $rB", IIC_IntCompare>; 2751 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$crD), (ins gprc:$rA, gprc:$rB), 2752 "cmplw $crD, $rA, $rB", IIC_IntCompare>; 2753} 2754} 2755let PPC970_Unit = 3, Predicates = [HasFPU] in { // FPU Operations. 2756let isCompare = 1, mayRaiseFPException = 1, hasSideEffects = 0 in { 2757 def FCMPUS : XForm_17<63, 0, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB), 2758 "fcmpu $crD, $fA, $fB", IIC_FPCompare>; 2759 def FCMPOS : XForm_17<63, 32, (outs crrc:$crD), (ins f4rc:$fA, f4rc:$fB), 2760 "fcmpo $crD, $fA, $fB", IIC_FPCompare>; 2761 let Interpretation64Bit = 1, isCodeGenOnly = 1 in { 2762 def FCMPUD : XForm_17<63, 0, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB), 2763 "fcmpu $crD, $fA, $fB", IIC_FPCompare>; 2764 def FCMPOD : XForm_17<63, 32, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB), 2765 "fcmpo $crD, $fA, $fB", IIC_FPCompare>; 2766 } 2767} 2768 2769def FTDIV: XForm_17<63, 128, (outs crrc:$crD), (ins f8rc:$fA, f8rc:$fB), 2770 "ftdiv $crD, $fA, $fB", IIC_FPCompare>; 2771def FTSQRT: XForm_17a<63, 160, (outs crrc:$crD), (ins f8rc:$fB), 2772 "ftsqrt $crD, $fB", IIC_FPCompare, 2773 [(set i32:$crD, (PPCftsqrt f64:$fB))]>; 2774 2775let mayRaiseFPException = 1, hasSideEffects = 0 in { 2776 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2777 defm FRIND : XForm_26r<63, 392, (outs f8rc:$frD), (ins f8rc:$frB), 2778 "frin", "$frD, $frB", IIC_FPGeneral, 2779 [(set f64:$frD, (any_fround f64:$frB))]>; 2780 defm FRINS : XForm_26r<63, 392, (outs f4rc:$frD), (ins f4rc:$frB), 2781 "frin", "$frD, $frB", IIC_FPGeneral, 2782 [(set f32:$frD, (any_fround f32:$frB))]>; 2783 2784 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2785 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$frD), (ins f8rc:$frB), 2786 "frip", "$frD, $frB", IIC_FPGeneral, 2787 [(set f64:$frD, (any_fceil f64:$frB))]>; 2788 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$frD), (ins f4rc:$frB), 2789 "frip", "$frD, $frB", IIC_FPGeneral, 2790 [(set f32:$frD, (any_fceil f32:$frB))]>; 2791 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2792 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$frD), (ins f8rc:$frB), 2793 "friz", "$frD, $frB", IIC_FPGeneral, 2794 [(set f64:$frD, (any_ftrunc f64:$frB))]>; 2795 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$frD), (ins f4rc:$frB), 2796 "friz", "$frD, $frB", IIC_FPGeneral, 2797 [(set f32:$frD, (any_ftrunc f32:$frB))]>; 2798 let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2799 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$frD), (ins f8rc:$frB), 2800 "frim", "$frD, $frB", IIC_FPGeneral, 2801 [(set f64:$frD, (any_ffloor f64:$frB))]>; 2802 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$frD), (ins f4rc:$frB), 2803 "frim", "$frD, $frB", IIC_FPGeneral, 2804 [(set f32:$frD, (any_ffloor f32:$frB))]>; 2805} 2806 2807let Uses = [RM], mayRaiseFPException = 1, hasSideEffects = 0 in { 2808 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$frD), (ins f8rc:$frB), 2809 "fctiw", "$frD, $frB", IIC_FPGeneral, 2810 []>; 2811 defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$frD), (ins f8rc:$frB), 2812 "fctiwu", "$frD, $frB", IIC_FPGeneral, 2813 []>; 2814 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$frD), (ins f8rc:$frB), 2815 "fctiwz", "$frD, $frB", IIC_FPGeneral, 2816 [(set f64:$frD, (PPCany_fctiwz f64:$frB))]>; 2817 2818 defm FRSP : XForm_26r<63, 12, (outs f4rc:$frD), (ins f8rc:$frB), 2819 "frsp", "$frD, $frB", IIC_FPGeneral, 2820 [(set f32:$frD, (any_fpround f64:$frB))]>; 2821 2822 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$frD), (ins f8rc:$frB), 2823 "fsqrt", "$frD, $frB", IIC_FPSqrtD, 2824 [(set f64:$frD, (any_fsqrt f64:$frB))]>; 2825 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$frD), (ins f4rc:$frB), 2826 "fsqrts", "$frD, $frB", IIC_FPSqrtS, 2827 [(set f32:$frD, (any_fsqrt f32:$frB))]>; 2828} 2829} 2830 2831def : Pat<(PPCfsqrt f64:$frA), (FSQRT $frA)>; 2832 2833/// Note that FMR is defined as pseudo-ops on the PPC970 because they are 2834/// often coalesced away and we don't want the dispatch group builder to think 2835/// that they will fill slots (which could cause the load of a LSU reject to 2836/// sneak into a d-group with a store). 2837let hasSideEffects = 0, Predicates = [HasFPU] in 2838defm FMR : XForm_26r<63, 72, (outs f4rc:$frD), (ins f4rc:$frB), 2839 "fmr", "$frD, $frB", IIC_FPGeneral, 2840 []>, // (set f32:$frD, f32:$frB) 2841 PPC970_Unit_Pseudo; 2842 2843let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations. 2844// These are artificially split into two different forms, for 4/8 byte FP. 2845defm FABSS : XForm_26r<63, 264, (outs f4rc:$frD), (ins f4rc:$frB), 2846 "fabs", "$frD, $frB", IIC_FPGeneral, 2847 [(set f32:$frD, (fabs f32:$frB))]>; 2848let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2849defm FABSD : XForm_26r<63, 264, (outs f8rc:$frD), (ins f8rc:$frB), 2850 "fabs", "$frD, $frB", IIC_FPGeneral, 2851 [(set f64:$frD, (fabs f64:$frB))]>; 2852defm FNABSS : XForm_26r<63, 136, (outs f4rc:$frD), (ins f4rc:$frB), 2853 "fnabs", "$frD, $frB", IIC_FPGeneral, 2854 [(set f32:$frD, (fneg (fabs f32:$frB)))]>; 2855let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2856defm FNABSD : XForm_26r<63, 136, (outs f8rc:$frD), (ins f8rc:$frB), 2857 "fnabs", "$frD, $frB", IIC_FPGeneral, 2858 [(set f64:$frD, (fneg (fabs f64:$frB)))]>; 2859defm FNEGS : XForm_26r<63, 40, (outs f4rc:$frD), (ins f4rc:$frB), 2860 "fneg", "$frD, $frB", IIC_FPGeneral, 2861 [(set f32:$frD, (fneg f32:$frB))]>; 2862let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2863defm FNEGD : XForm_26r<63, 40, (outs f8rc:$frD), (ins f8rc:$frB), 2864 "fneg", "$frD, $frB", IIC_FPGeneral, 2865 [(set f64:$frD, (fneg f64:$frB))]>; 2866 2867defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$frD), (ins f4rc:$frA, f4rc:$frB), 2868 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral, 2869 [(set f32:$frD, (fcopysign f32:$frB, f32:$frA))]>; 2870let Interpretation64Bit = 1, isCodeGenOnly = 1 in 2871defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$frD), (ins f8rc:$frA, f8rc:$frB), 2872 "fcpsgn", "$frD, $frA, $frB", IIC_FPGeneral, 2873 [(set f64:$frD, (fcopysign f64:$frB, f64:$frA))]>; 2874 2875// Reciprocal estimates. 2876let mayRaiseFPException = 1 in { 2877defm FRE : XForm_26r<63, 24, (outs f8rc:$frD), (ins f8rc:$frB), 2878 "fre", "$frD, $frB", IIC_FPGeneral, 2879 [(set f64:$frD, (PPCfre f64:$frB))]>; 2880defm FRES : XForm_26r<59, 24, (outs f4rc:$frD), (ins f4rc:$frB), 2881 "fres", "$frD, $frB", IIC_FPGeneral, 2882 [(set f32:$frD, (PPCfre f32:$frB))]>; 2883defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$frD), (ins f8rc:$frB), 2884 "frsqrte", "$frD, $frB", IIC_FPGeneral, 2885 [(set f64:$frD, (PPCfrsqrte f64:$frB))]>; 2886defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$frD), (ins f4rc:$frB), 2887 "frsqrtes", "$frD, $frB", IIC_FPGeneral, 2888 [(set f32:$frD, (PPCfrsqrte f32:$frB))]>; 2889} 2890} 2891 2892// XL-Form instructions. condition register logical ops. 2893// 2894let hasSideEffects = 0 in 2895def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA), 2896 "mcrf $BF, $BFA", IIC_BrMCR>, 2897 PPC970_DGroup_First, PPC970_Unit_CRU; 2898 2899// FIXME: According to the ISA (section 2.5.1 of version 2.06), the 2900// condition-register logical instructions have preferred forms. Specifically, 2901// it is preferred that the bit specified by the BT field be in the same 2902// condition register as that specified by the bit BB. We might want to account 2903// for this via hinting the register allocator and anti-dep breakers, or we 2904// could constrain the register class to force this constraint and then loosen 2905// it during register allocation via convertToThreeAddress or some similar 2906// mechanism. 2907 2908let isCommutable = 1 in { 2909def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD), 2910 (ins crbitrc:$CRA, crbitrc:$CRB), 2911 "crand $CRD, $CRA, $CRB", IIC_BrCR, 2912 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>; 2913 2914def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD), 2915 (ins crbitrc:$CRA, crbitrc:$CRB), 2916 "crnand $CRD, $CRA, $CRB", IIC_BrCR, 2917 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>; 2918 2919def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD), 2920 (ins crbitrc:$CRA, crbitrc:$CRB), 2921 "cror $CRD, $CRA, $CRB", IIC_BrCR, 2922 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>; 2923 2924def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD), 2925 (ins crbitrc:$CRA, crbitrc:$CRB), 2926 "crxor $CRD, $CRA, $CRB", IIC_BrCR, 2927 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>; 2928 2929def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD), 2930 (ins crbitrc:$CRA, crbitrc:$CRB), 2931 "crnor $CRD, $CRA, $CRB", IIC_BrCR, 2932 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>; 2933 2934def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD), 2935 (ins crbitrc:$CRA, crbitrc:$CRB), 2936 "creqv $CRD, $CRA, $CRB", IIC_BrCR, 2937 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>; 2938} // isCommutable 2939 2940def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD), 2941 (ins crbitrc:$CRA, crbitrc:$CRB), 2942 "crandc $CRD, $CRA, $CRB", IIC_BrCR, 2943 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>; 2944 2945def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD), 2946 (ins crbitrc:$CRA, crbitrc:$CRB), 2947 "crorc $CRD, $CRA, $CRB", IIC_BrCR, 2948 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>; 2949 2950let isCodeGenOnly = 1 in { 2951let isReMaterializable = 1, isAsCheapAsAMove = 1 in { 2952def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$dst), (ins), 2953 "creqv $dst, $dst, $dst", IIC_BrCR, 2954 [(set i1:$dst, 1)]>; 2955 2956def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$dst), (ins), 2957 "crxor $dst, $dst, $dst", IIC_BrCR, 2958 [(set i1:$dst, 0)]>; 2959} 2960 2961let Defs = [CR1EQ], CRD = 6 in { 2962def CR6SET : XLForm_1_ext<19, 289, (outs), (ins), 2963 "creqv 6, 6, 6", IIC_BrCR, 2964 [(PPCcr6set)]>; 2965 2966def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins), 2967 "crxor 6, 6, 6", IIC_BrCR, 2968 [(PPCcr6unset)]>; 2969} 2970} 2971 2972// XFX-Form instructions. Instructions that deal with SPRs. 2973// 2974 2975def MFSPR : XFXForm_1<31, 339, (outs gprc:$RT), (ins i32imm:$SPR), 2976 "mfspr $RT, $SPR", IIC_SprMFSPR>; 2977def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RT), 2978 "mtspr $SPR, $RT", IIC_SprMTSPR>; 2979 2980def MFTB : XFXForm_1<31, 371, (outs gprc:$RT), (ins i32imm:$SPR), 2981 "mftb $RT, $SPR", IIC_SprMFTB>; 2982 2983def MFPMR : XFXForm_1<31, 334, (outs gprc:$RT), (ins i32imm:$SPR), 2984 "mfpmr $RT, $SPR", IIC_SprMFPMR>; 2985 2986def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RT), 2987 "mtpmr $SPR, $RT", IIC_SprMTPMR>; 2988 2989 2990// A pseudo-instruction used to implement the read of the 64-bit cycle counter 2991// on a 32-bit target. 2992let hasSideEffects = 1 in 2993def ReadTB : PPCCustomInserterPseudo<(outs gprc:$lo, gprc:$hi), (ins), 2994 "#ReadTB", []>; 2995 2996let Uses = [CTR] in { 2997def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$rT), (ins), 2998 "mfctr $rT", IIC_SprMFSPR>, 2999 PPC970_DGroup_First, PPC970_Unit_FXU; 3000} 3001let Defs = [CTR], Pattern = [(PPCmtctr i32:$rS)] in { 3002def MTCTR : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS), 3003 "mtctr $rS", IIC_SprMTSPR>, 3004 PPC970_DGroup_First, PPC970_Unit_FXU; 3005} 3006let hasSideEffects = 1, isCodeGenOnly = 1, Defs = [CTR] in { 3007let Pattern = [(int_set_loop_iterations i32:$rS)] in 3008def MTCTRloop : XFXForm_7_ext<31, 467, 9, (outs), (ins gprc:$rS), 3009 "mtctr $rS", IIC_SprMTSPR>, 3010 PPC970_DGroup_First, PPC970_Unit_FXU; 3011} 3012 3013let hasSideEffects = 0 in { 3014let Defs = [LR] in { 3015def MTLR : XFXForm_7_ext<31, 467, 8, (outs), (ins gprc:$rS), 3016 "mtlr $rS", IIC_SprMTSPR>, 3017 PPC970_DGroup_First, PPC970_Unit_FXU; 3018} 3019let Uses = [LR] in { 3020def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$rT), (ins), 3021 "mflr $rT", IIC_SprMFSPR>, 3022 PPC970_DGroup_First, PPC970_Unit_FXU; 3023} 3024} 3025 3026let isCodeGenOnly = 1 in { 3027 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed 3028 // like a GPR on the PPC970. As such, copies in and out have the same 3029 // performance characteristics as an OR instruction. 3030 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (outs), (ins gprc:$rS), 3031 "mtspr 256, $rS", IIC_IntGeneral>, 3032 PPC970_DGroup_Single, PPC970_Unit_FXU; 3033 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), (ins), 3034 "mfspr $rT, 256", IIC_IntGeneral>, 3035 PPC970_DGroup_First, PPC970_Unit_FXU; 3036 3037 def MTVRSAVEv : XFXForm_7_ext<31, 467, 256, 3038 (outs VRSAVERC:$reg), (ins gprc:$rS), 3039 "mtspr 256, $rS", IIC_IntGeneral>, 3040 PPC970_DGroup_Single, PPC970_Unit_FXU; 3041 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$rT), 3042 (ins VRSAVERC:$reg), 3043 "mfspr $rT, 256", IIC_IntGeneral>, 3044 PPC970_DGroup_First, PPC970_Unit_FXU; 3045} 3046 3047// Aliases for mtvrsave/mfvrsave to mfspr/mtspr. 3048def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>; 3049def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>; 3050 3051let hasSideEffects = 0 in { 3052// mtocrf's input needs to be prepared by shifting by an amount dependent 3053// on the cr register selected. Thus, post-ra anti-dep breaking must not 3054// later change that register assignment. 3055let hasExtraDefRegAllocReq = 1 in { 3056def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$ST), 3057 "mtocrf $FXM, $ST", IIC_BrMCRX>, 3058 PPC970_DGroup_First, PPC970_Unit_CRU; 3059 3060// Similarly to mtocrf, the mask for mtcrf must be prepared in a way that 3061// is dependent on the cr fields being set. 3062def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$rS), 3063 "mtcrf $FXM, $rS", IIC_BrMCRX>, 3064 PPC970_MicroCode, PPC970_Unit_CRU; 3065} // hasExtraDefRegAllocReq = 1 3066 3067// mfocrf's input needs to be prepared by shifting by an amount dependent 3068// on the cr register selected. Thus, post-ra anti-dep breaking must not 3069// later change that register assignment. 3070let hasExtraSrcRegAllocReq = 1 in { 3071def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$rT), (ins crbitm:$FXM), 3072 "mfocrf $rT, $FXM", IIC_SprMFCRF>, 3073 PPC970_DGroup_First, PPC970_Unit_CRU; 3074 3075// Similarly to mfocrf, the mask for mfcrf must be prepared in a way that 3076// is dependent on the cr fields being copied. 3077def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins), 3078 "mfcr $rT", IIC_SprMFCR>, 3079 PPC970_MicroCode, PPC970_Unit_CRU; 3080} // hasExtraSrcRegAllocReq = 1 3081 3082def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins), 3083 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>; 3084} // hasSideEffects = 0 3085 3086def : InstAlias<"mtcr $rA", (MTCRF 255, gprc:$rA)>; 3087 3088let Predicates = [HasFPU] in { 3089// Custom inserter instruction to perform FADD in round-to-zero mode. 3090let Uses = [RM], mayRaiseFPException = 1 in { 3091 def FADDrtz: PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "", 3092 [(set f64:$FRT, (PPCany_faddrtz f64:$FRA, f64:$FRB))]>; 3093} 3094 3095// The above pseudo gets expanded to make use of the following instructions 3096// to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level. 3097 3098// When FM is 30/31, we are setting the 62/63 bit of FPSCR, the implicit-def 3099// RM should be set. 3100let hasSideEffects = 1, Defs = [RM] in { 3101def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM), 3102 "mtfsb0 $FM", IIC_IntMTFSB0, 3103 [(int_ppc_mtfsb0 timm:$FM)]>, 3104 PPC970_DGroup_Single, PPC970_Unit_FPU; 3105def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM), 3106 "mtfsb1 $FM", IIC_IntMTFSB0, 3107 [(int_ppc_mtfsb1 timm:$FM)]>, 3108 PPC970_DGroup_Single, PPC970_Unit_FPU; 3109} 3110 3111let Defs = [RM] in { 3112 let isCodeGenOnly = 1 in 3113 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$rT), 3114 "mtfsf $FM, $rT", IIC_IntMTFSB0, 3115 [(int_ppc_mtfsf timm:$FM, f64:$rT)]>, 3116 PPC970_DGroup_Single, PPC970_Unit_FPU; 3117} 3118let Uses = [RM] in { 3119 def MFFS : XForm_42<63, 583, (outs f8rc:$rT), (ins), 3120 "mffs $rT", IIC_IntMFFS, 3121 [(set f64:$rT, (PPCmffs))]>, 3122 PPC970_DGroup_Single, PPC970_Unit_FPU; 3123 3124 let Defs = [CR1] in 3125 def MFFS_rec : XForm_42<63, 583, (outs f8rc:$rT), (ins), 3126 "mffs. $rT", IIC_IntMFFS, []>, isRecordForm; 3127 3128 def MFFSCE : X_FRT5_XO2_XO3_XO10<63, 0, 1, 583, (outs f8rc:$rT), (ins), 3129 "mffsce $rT", IIC_IntMFFS, []>, 3130 PPC970_DGroup_Single, PPC970_Unit_FPU; 3131 3132 def MFFSCDRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 4, 583, (outs f8rc:$rT), 3133 (ins f8rc:$FRB), "mffscdrn $rT, $FRB", 3134 IIC_IntMFFS, []>, 3135 PPC970_DGroup_Single, PPC970_Unit_FPU; 3136 3137 def MFFSCDRNI : X_FRT5_XO2_XO3_DRM3_XO10<63, 2, 5, 583, (outs f8rc:$rT), 3138 (ins u3imm:$DRM), 3139 "mffscdrni $rT, $DRM", 3140 IIC_IntMFFS, []>, 3141 PPC970_DGroup_Single, PPC970_Unit_FPU; 3142 3143 def MFFSCRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 6, 583, (outs f8rc:$rT), 3144 (ins f8rc:$FRB), "mffscrn $rT, $FRB", 3145 IIC_IntMFFS, []>, 3146 PPC970_DGroup_Single, PPC970_Unit_FPU; 3147 3148 def MFFSCRNI : X_FRT5_XO2_XO3_RM2_X10<63, 2, 7, 583, (outs f8rc:$rT), 3149 (ins u2imm:$RM), "mffscrni $rT, $RM", 3150 IIC_IntMFFS, []>, 3151 PPC970_DGroup_Single, PPC970_Unit_FPU; 3152 3153 def MFFSL : X_FRT5_XO2_XO3_XO10<63, 3, 0, 583, (outs f8rc:$rT), (ins), 3154 "mffsl $rT", IIC_IntMFFS, []>, 3155 PPC970_DGroup_Single, PPC970_Unit_FPU; 3156} 3157} 3158 3159let Predicates = [IsISA3_0] in { 3160def MODSW : XForm_8<31, 779, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3161 "modsw $rT, $rA, $rB", IIC_IntDivW, 3162 [(set i32:$rT, (srem i32:$rA, i32:$rB))]>; 3163def MODUW : XForm_8<31, 267, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3164 "moduw $rT, $rA, $rB", IIC_IntDivW, 3165 [(set i32:$rT, (urem i32:$rA, i32:$rB))]>; 3166let hasSideEffects = 1 in 3167def ADDEX : Z23Form_RTAB5_CY2<31, 170, (outs gprc:$rT), 3168 (ins gprc:$rA, gprc:$rB, u2imm:$CY), 3169 "addex $rT, $rA, $rB, $CY", IIC_IntGeneral, []>; 3170} 3171 3172let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations. 3173// XO-Form instructions. Arithmetic instructions that can set overflow bit 3174let isCommutable = 1 in 3175defm ADD4 : XOForm_1rx<31, 266, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3176 "add", "$rT, $rA, $rB", IIC_IntSimple, 3177 [(set i32:$rT, (add i32:$rA, i32:$rB))]>; 3178let isCodeGenOnly = 1 in 3179def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$rT), (ins gprc:$rA, tlsreg32:$rB), 3180 "add $rT, $rA, $rB", IIC_IntSimple, 3181 [(set i32:$rT, (add i32:$rA, tglobaltlsaddr:$rB))]>; 3182let isCommutable = 1 in 3183defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3184 "addc", "$rT, $rA, $rB", IIC_IntGeneral, 3185 [(set i32:$rT, (addc i32:$rA, i32:$rB))]>, 3186 PPC970_DGroup_Cracked; 3187 3188defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3189 "divw", "$rT, $rA, $rB", IIC_IntDivW, 3190 [(set i32:$rT, (sdiv i32:$rA, i32:$rB))]>; 3191defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3192 "divwu", "$rT, $rA, $rB", IIC_IntDivW, 3193 [(set i32:$rT, (udiv i32:$rA, i32:$rB))]>; 3194defm DIVWE : XOForm_1rcr<31, 427, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3195 "divwe", "$rT, $rA, $rB", IIC_IntDivW, 3196 [(set i32:$rT, (int_ppc_divwe gprc:$rA, gprc:$rB))]>, 3197 Requires<[HasExtDiv]>; 3198defm DIVWEU : XOForm_1rcr<31, 395, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3199 "divweu", "$rT, $rA, $rB", IIC_IntDivW, 3200 [(set i32:$rT, (int_ppc_divweu gprc:$rA, gprc:$rB))]>, 3201 Requires<[HasExtDiv]>; 3202let isCommutable = 1 in { 3203defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3204 "mulhw", "$rT, $rA, $rB", IIC_IntMulHW, 3205 [(set i32:$rT, (mulhs i32:$rA, i32:$rB))]>; 3206defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3207 "mulhwu", "$rT, $rA, $rB", IIC_IntMulHWU, 3208 [(set i32:$rT, (mulhu i32:$rA, i32:$rB))]>; 3209defm MULLW : XOForm_1rx<31, 235, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3210 "mullw", "$rT, $rA, $rB", IIC_IntMulHW, 3211 [(set i32:$rT, (mul i32:$rA, i32:$rB))]>; 3212} // isCommutable 3213defm SUBF : XOForm_1rx<31, 40, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3214 "subf", "$rT, $rA, $rB", IIC_IntGeneral, 3215 [(set i32:$rT, (sub i32:$rB, i32:$rA))]>; 3216defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3217 "subfc", "$rT, $rA, $rB", IIC_IntGeneral, 3218 [(set i32:$rT, (subc i32:$rB, i32:$rA))]>, 3219 PPC970_DGroup_Cracked; 3220defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$rT), (ins gprc:$rA), 3221 "neg", "$rT, $rA", IIC_IntSimple, 3222 [(set i32:$rT, (ineg i32:$rA))]>; 3223let Uses = [CARRY] in { 3224let isCommutable = 1 in 3225defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3226 "adde", "$rT, $rA, $rB", IIC_IntGeneral, 3227 [(set i32:$rT, (adde i32:$rA, i32:$rB))]>; 3228defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$rT), (ins gprc:$rA), 3229 "addme", "$rT, $rA", IIC_IntGeneral, 3230 [(set i32:$rT, (adde i32:$rA, -1))]>; 3231defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$rT), (ins gprc:$rA), 3232 "addze", "$rT, $rA", IIC_IntGeneral, 3233 [(set i32:$rT, (adde i32:$rA, 0))]>; 3234defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$rT), (ins gprc:$rA, gprc:$rB), 3235 "subfe", "$rT, $rA, $rB", IIC_IntGeneral, 3236 [(set i32:$rT, (sube i32:$rB, i32:$rA))]>; 3237defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$rT), (ins gprc:$rA), 3238 "subfme", "$rT, $rA", IIC_IntGeneral, 3239 [(set i32:$rT, (sube -1, i32:$rA))]>; 3240defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$rT), (ins gprc:$rA), 3241 "subfze", "$rT, $rA", IIC_IntGeneral, 3242 [(set i32:$rT, (sube 0, i32:$rA))]>; 3243} 3244} 3245 3246def : InstAlias<"sub $rA, $rB, $rC", (SUBF gprc:$rA, gprc:$rC, gprc:$rB)>; 3247def : InstAlias<"sub. $rA, $rB, $rC", (SUBF_rec gprc:$rA, gprc:$rC, gprc:$rB)>; 3248def : InstAlias<"subc $rA, $rB, $rC", (SUBFC gprc:$rA, gprc:$rC, gprc:$rB)>; 3249def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC_rec gprc:$rA, gprc:$rC, gprc:$rB)>; 3250 3251// A-Form instructions. Most of the instructions executed in the FPU are of 3252// this type. 3253// 3254let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations. 3255let mayRaiseFPException = 1, Uses = [RM] in { 3256let isCommutable = 1 in { 3257 defm FMADD : AForm_1r<63, 29, 3258 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 3259 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused, 3260 [(set f64:$FRT, (any_fma f64:$FRA, f64:$FRC, f64:$FRB))]>; 3261 defm FMADDS : AForm_1r<59, 29, 3262 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB), 3263 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 3264 [(set f32:$FRT, (any_fma f32:$FRA, f32:$FRC, f32:$FRB))]>; 3265 defm FMSUB : AForm_1r<63, 28, 3266 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 3267 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused, 3268 [(set f64:$FRT, 3269 (any_fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>; 3270 defm FMSUBS : AForm_1r<59, 28, 3271 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB), 3272 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 3273 [(set f32:$FRT, 3274 (any_fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>; 3275 defm FNMADD : AForm_1r<63, 31, 3276 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 3277 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused, 3278 [(set f64:$FRT, 3279 (fneg (any_fma f64:$FRA, f64:$FRC, f64:$FRB)))]>; 3280 defm FNMADDS : AForm_1r<59, 31, 3281 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB), 3282 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 3283 [(set f32:$FRT, 3284 (fneg (any_fma f32:$FRA, f32:$FRC, f32:$FRB)))]>; 3285 defm FNMSUB : AForm_1r<63, 30, 3286 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 3287 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused, 3288 [(set f64:$FRT, (fneg (any_fma f64:$FRA, f64:$FRC, 3289 (fneg f64:$FRB))))]>; 3290 defm FNMSUBS : AForm_1r<59, 30, 3291 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB), 3292 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 3293 [(set f32:$FRT, (fneg (any_fma f32:$FRA, f32:$FRC, 3294 (fneg f32:$FRB))))]>; 3295} // isCommutable 3296} 3297// FSEL is artificially split into 4 and 8-byte forms for the result. To avoid 3298// having 4 of these, force the comparison to always be an 8-byte double (code 3299// should use an FMRSD if the input comparison value really wants to be a float) 3300// and 4/8 byte forms for the result and operand type.. 3301let Interpretation64Bit = 1, isCodeGenOnly = 1 in 3302defm FSELD : AForm_1r<63, 23, 3303 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), 3304 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 3305 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>; 3306defm FSELS : AForm_1r<63, 23, 3307 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB), 3308 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral, 3309 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>; 3310let Uses = [RM], mayRaiseFPException = 1 in { 3311 let isCommutable = 1 in { 3312 defm FADD : AForm_2r<63, 21, 3313 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), 3314 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub, 3315 [(set f64:$FRT, (any_fadd f64:$FRA, f64:$FRB))]>; 3316 defm FADDS : AForm_2r<59, 21, 3317 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB), 3318 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral, 3319 [(set f32:$FRT, (any_fadd f32:$FRA, f32:$FRB))]>; 3320 } // isCommutable 3321 defm FDIV : AForm_2r<63, 18, 3322 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), 3323 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD, 3324 [(set f64:$FRT, (any_fdiv f64:$FRA, f64:$FRB))]>; 3325 defm FDIVS : AForm_2r<59, 18, 3326 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB), 3327 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS, 3328 [(set f32:$FRT, (any_fdiv f32:$FRA, f32:$FRB))]>; 3329 let isCommutable = 1 in { 3330 defm FMUL : AForm_3r<63, 25, 3331 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC), 3332 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused, 3333 [(set f64:$FRT, (any_fmul f64:$FRA, f64:$FRC))]>; 3334 defm FMULS : AForm_3r<59, 25, 3335 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC), 3336 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral, 3337 [(set f32:$FRT, (any_fmul f32:$FRA, f32:$FRC))]>; 3338 } // isCommutable 3339 defm FSUB : AForm_2r<63, 20, 3340 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), 3341 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub, 3342 [(set f64:$FRT, (any_fsub f64:$FRA, f64:$FRB))]>; 3343 defm FSUBS : AForm_2r<59, 20, 3344 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB), 3345 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral, 3346 [(set f32:$FRT, (any_fsub f32:$FRA, f32:$FRB))]>; 3347 } 3348} 3349 3350let hasSideEffects = 0 in { 3351let PPC970_Unit = 1 in { // FXU Operations. 3352 let isSelect = 1 in 3353 def ISEL : AForm_4<31, 15, 3354 (outs gprc:$rT), (ins gprc_nor0:$rA, gprc:$rB, crbitrc:$cond), 3355 "isel $rT, $rA, $rB, $cond", IIC_IntISEL, 3356 []>; 3357} 3358 3359let PPC970_Unit = 1 in { // FXU Operations. 3360// M-Form instructions. rotate and mask instructions. 3361// 3362let isCommutable = 1 in { 3363// RLWIMI can be commuted if the rotate amount is zero. 3364defm RLWIMI : MForm_2r<20, (outs gprc:$rA), 3365 (ins gprc:$rSi, gprc:$rS, u5imm:$SH, u5imm:$MB, 3366 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME", 3367 IIC_IntRotate, []>, PPC970_DGroup_Cracked, 3368 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">; 3369} 3370let BaseName = "rlwinm" in { 3371def RLWINM : MForm_2<21, 3372 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME), 3373 "rlwinm $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral, 3374 []>, RecFormRel; 3375let Defs = [CR0] in 3376def RLWINM_rec : MForm_2<21, 3377 (outs gprc:$rA), (ins gprc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME), 3378 "rlwinm. $rA, $rS, $SH, $MB, $ME", IIC_IntGeneral, 3379 []>, isRecordForm, RecFormRel, PPC970_DGroup_Cracked; 3380} 3381defm RLWNM : MForm_2r<23, (outs gprc:$rA), 3382 (ins gprc:$rS, gprc:$rB, u5imm:$MB, u5imm:$ME), 3383 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral, 3384 []>; 3385} 3386} // hasSideEffects = 0 3387 3388//===----------------------------------------------------------------------===// 3389// PowerPC Instruction Patterns 3390// 3391 3392// Arbitrary immediate support. Implement in terms of LIS/ORI. 3393def : Pat<(i32 imm:$imm), 3394 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>; 3395 3396// Implement the 'not' operation with the NOR instruction. 3397def i32not : OutPatFrag<(ops node:$in), 3398 (NOR $in, $in)>; 3399def : Pat<(not i32:$in), 3400 (i32not $in)>; 3401 3402// ADD an arbitrary immediate. 3403def : Pat<(add i32:$in, imm:$imm), 3404 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>; 3405// OR an arbitrary immediate. 3406def : Pat<(or i32:$in, imm:$imm), 3407 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>; 3408// XOR an arbitrary immediate. 3409def : Pat<(xor i32:$in, imm:$imm), 3410 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>; 3411// SUBFIC 3412def : Pat<(sub imm32SExt16:$imm, i32:$in), 3413 (SUBFIC $in, imm:$imm)>; 3414 3415// SHL/SRL 3416def : Pat<(shl i32:$in, (i32 imm:$imm)), 3417 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>; 3418def : Pat<(srl i32:$in, (i32 imm:$imm)), 3419 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>; 3420 3421// ROTL 3422def : Pat<(rotl i32:$in, i32:$sh), 3423 (RLWNM $in, $sh, 0, 31)>; 3424def : Pat<(rotl i32:$in, (i32 imm:$imm)), 3425 (RLWINM $in, imm:$imm, 0, 31)>; 3426 3427// RLWNM 3428def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm), 3429 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>; 3430 3431// Calls 3432def : Pat<(PPCcall (i32 tglobaladdr:$dst)), 3433 (BL tglobaladdr:$dst)>; 3434 3435def : Pat<(PPCcall (i32 texternalsym:$dst)), 3436 (BL texternalsym:$dst)>; 3437 3438// Calls for AIX only 3439def : Pat<(PPCcall (i32 mcsym:$dst)), 3440 (BL mcsym:$dst)>; 3441 3442def : Pat<(PPCcall_nop (i32 mcsym:$dst)), 3443 (BL_NOP mcsym:$dst)>; 3444 3445def : Pat<(PPCcall_nop (i32 texternalsym:$dst)), 3446 (BL_NOP texternalsym:$dst)>; 3447 3448def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm), 3449 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>; 3450 3451def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm), 3452 (TCRETURNdi texternalsym:$dst, imm:$imm)>; 3453 3454def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm), 3455 (TCRETURNri CTRRC:$dst, imm:$imm)>; 3456 3457def : Pat<(int_ppc_readflm), (MFFS)>; 3458 3459// Hi and Lo for Darwin Global Addresses. 3460def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>; 3461def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>; 3462def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>; 3463def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>; 3464def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>; 3465def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>; 3466def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>; 3467def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>; 3468def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in), 3469 (ADDIS $in, tglobaltlsaddr:$g)>; 3470def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in), 3471 (ADDI $in, tglobaltlsaddr:$g)>; 3472def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)), 3473 (ADDIS $in, tglobaladdr:$g)>; 3474def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)), 3475 (ADDIS $in, tconstpool:$g)>; 3476def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)), 3477 (ADDIS $in, tjumptable:$g)>; 3478def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)), 3479 (ADDIS $in, tblockaddress:$g)>; 3480 3481// Support for thread-local storage. 3482def PPC32GOT: PPCEmitTimePseudo<(outs gprc:$rD), (ins), "#PPC32GOT", 3483 [(set i32:$rD, (PPCppc32GOT))]>; 3484 3485// Get the _GLOBAL_OFFSET_TABLE_ in PIC mode. 3486// This uses two output registers, the first as the real output, the second as a 3487// temporary register, used internally in code generation. 3488def PPC32PICGOT: PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT", 3489 []>, NoEncode<"$rT">; 3490 3491def LDgotTprelL32: PPCEmitTimePseudo<(outs gprc_nor0:$rD), (ins s16imm:$disp, gprc_nor0:$reg), 3492 "#LDgotTprelL32", 3493 [(set i32:$rD, 3494 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>; 3495def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g), 3496 (ADD4TLS $in, tglobaltlsaddr:$g)>; 3497 3498def ADDItlsgdL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp), 3499 "#ADDItlsgdL32", 3500 [(set i32:$rD, 3501 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>; 3502// LR is a true define, while the rest of the Defs are clobbers. R3 is 3503// explicitly defined when this op is created, so not mentioned here. 3504let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 3505 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in 3506def GETtlsADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym), 3507 "GETtlsADDR32", 3508 [(set i32:$rD, 3509 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>; 3510// R3 is explicitly defined when this op is created, so not mentioned here. 3511// The rest of the Defs are the exact set of registers that will be clobbered by 3512// the call. 3513let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 3514 Defs = [R0,R4,R5,R11,LR,CR0] in 3515def GETtlsADDR32AIX : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$offset, gprc:$handle), 3516 "GETtlsADDR32AIX", 3517 [(set i32:$rD, 3518 (PPCgetTlsAddr i32:$offset, i32:$handle))]>; 3519// Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR 3520// are true defines while the rest of the Defs are clobbers. 3521let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 3522 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in 3523def ADDItlsgdLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), 3524 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym), 3525 "#ADDItlsgdLADDR32", 3526 [(set i32:$rD, 3527 (PPCaddiTlsgdLAddr i32:$reg, 3528 tglobaltlsaddr:$disp, 3529 tglobaltlsaddr:$sym))]>; 3530def ADDItlsldL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp), 3531 "#ADDItlsldL32", 3532 [(set i32:$rD, 3533 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>; 3534// This pseudo is expanded to two copies to put the variable offset in R4 and 3535// the region handle in R3 and GETtlsADDR32AIX. 3536def TLSGDAIX : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$offset, gprc:$handle), 3537 "#TLSGDAIX", 3538 [(set i32:$rD, 3539 (PPCTlsgdAIX i32:$offset, i32:$handle))]>; 3540// LR is a true define, while the rest of the Defs are clobbers. R3 is 3541// explicitly defined when this op is created, so not mentioned here. 3542let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 3543 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in 3544def GETtlsldADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym), 3545 "GETtlsldADDR32", 3546 [(set i32:$rD, 3547 (PPCgetTlsldAddr i32:$reg, 3548 tglobaltlsaddr:$sym))]>; 3549// Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR 3550// are true defines while the rest of the Defs are clobbers. 3551let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1, 3552 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in 3553def ADDItlsldLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), 3554 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym), 3555 "#ADDItlsldLADDR32", 3556 [(set i32:$rD, 3557 (PPCaddiTlsldLAddr i32:$reg, 3558 tglobaltlsaddr:$disp, 3559 tglobaltlsaddr:$sym))]>; 3560def ADDIdtprelL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp), 3561 "#ADDIdtprelL32", 3562 [(set i32:$rD, 3563 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>; 3564def ADDISdtprelHA32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp), 3565 "#ADDISdtprelHA32", 3566 [(set i32:$rD, 3567 (PPCaddisDtprelHA i32:$reg, 3568 tglobaltlsaddr:$disp))]>; 3569 3570// Support for Position-independent code 3571def LWZtoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg), 3572 "#LWZtoc", 3573 [(set i32:$rD, 3574 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>; 3575def LWZtocL : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc_nor0:$reg), 3576 "#LWZtocL", 3577 [(set i32:$rD, 3578 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>; 3579def ADDIStocHA : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, tocentry32:$disp), 3580 "#ADDIStocHA", 3581 [(set i32:$rD, 3582 (PPCtoc_entry i32:$reg, tglobaladdr:$disp))]>; 3583// Local Data Transform 3584def ADDItoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg), 3585 "#ADDItoc", 3586 [(set i32:$rD, 3587 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>; 3588 3589// Get Global (GOT) Base Register offset, from the word immediately preceding 3590// the function label. 3591def UpdateGBR : PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>; 3592 3593// Pseudo-instruction marked for deletion. When deleting the instruction would 3594// cause iterator invalidation in MIR transformation passes, this pseudo can be 3595// used instead. It will be removed unconditionally at pre-emit time (prior to 3596// branch selection). 3597def UNENCODED_NOP: PPCEmitTimePseudo<(outs), (ins), "#UNENCODED_NOP", []>; 3598 3599// Standard shifts. These are represented separately from the real shifts above 3600// so that we can distinguish between shifts that allow 5-bit and 6-bit shift 3601// amounts. 3602def : Pat<(sra i32:$rS, i32:$rB), 3603 (SRAW $rS, $rB)>; 3604def : Pat<(srl i32:$rS, i32:$rB), 3605 (SRW $rS, $rB)>; 3606def : Pat<(shl i32:$rS, i32:$rB), 3607 (SLW $rS, $rB)>; 3608 3609def : Pat<(i32 (zextloadi1 DForm:$src)), 3610 (LBZ DForm:$src)>; 3611def : Pat<(i32 (zextloadi1 XForm:$src)), 3612 (LBZX XForm:$src)>; 3613def : Pat<(i32 (extloadi1 DForm:$src)), 3614 (LBZ DForm:$src)>; 3615def : Pat<(i32 (extloadi1 XForm:$src)), 3616 (LBZX XForm:$src)>; 3617def : Pat<(i32 (extloadi8 DForm:$src)), 3618 (LBZ DForm:$src)>; 3619def : Pat<(i32 (extloadi8 XForm:$src)), 3620 (LBZX XForm:$src)>; 3621def : Pat<(i32 (extloadi16 DForm:$src)), 3622 (LHZ DForm:$src)>; 3623def : Pat<(i32 (extloadi16 XForm:$src)), 3624 (LHZX XForm:$src)>; 3625let Predicates = [HasFPU] in { 3626def : Pat<(f64 (extloadf32 DForm:$src)), 3627 (COPY_TO_REGCLASS (LFS DForm:$src), F8RC)>; 3628def : Pat<(f64 (extloadf32 XForm:$src)), 3629 (COPY_TO_REGCLASS (LFSX XForm:$src), F8RC)>; 3630 3631def : Pat<(f64 (any_fpextend f32:$src)), 3632 (COPY_TO_REGCLASS $src, F8RC)>; 3633} 3634 3635// Only seq_cst fences require the heavyweight sync (SYNC 0). 3636// All others can use the lightweight sync (SYNC 1). 3637// source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html 3638// The rule for seq_cst is duplicated to work with both 64 bits and 32 bits 3639// versions of Power. 3640def : Pat<(atomic_fence (i64 7), (timm)), (SYNC 0)>, Requires<[HasSYNC]>; 3641def : Pat<(atomic_fence (i32 7), (timm)), (SYNC 0)>, Requires<[HasSYNC]>; 3642def : Pat<(atomic_fence (timm), (timm)), (SYNC 1)>, Requires<[HasSYNC]>; 3643def : Pat<(atomic_fence (timm), (timm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>; 3644 3645let Predicates = [HasFPU] in { 3646// Additional fnmsub patterns for custom node 3647def : Pat<(PPCfnmsub f64:$A, f64:$B, f64:$C), 3648 (FNMSUB $A, $B, $C)>; 3649def : Pat<(PPCfnmsub f32:$A, f32:$B, f32:$C), 3650 (FNMSUBS $A, $B, $C)>; 3651def : Pat<(fneg (PPCfnmsub f64:$A, f64:$B, f64:$C)), 3652 (FMSUB $A, $B, $C)>; 3653def : Pat<(fneg (PPCfnmsub f32:$A, f32:$B, f32:$C)), 3654 (FMSUBS $A, $B, $C)>; 3655def : Pat<(PPCfnmsub f64:$A, f64:$B, (fneg f64:$C)), 3656 (FNMADD $A, $B, $C)>; 3657def : Pat<(PPCfnmsub f32:$A, f32:$B, (fneg f32:$C)), 3658 (FNMADDS $A, $B, $C)>; 3659 3660// FCOPYSIGN's operand types need not agree. 3661def : Pat<(fcopysign f64:$frB, f32:$frA), 3662 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>; 3663def : Pat<(fcopysign f32:$frB, f64:$frA), 3664 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>; 3665} 3666 3667// XL Compat intrinsics. 3668def : Pat<(int_ppc_fmsub f64:$A, f64:$B, f64:$C), (FMSUB $A, $B, $C)>; 3669def : Pat<(int_ppc_fmsubs f32:$A, f32:$B, f32:$C), (FMSUBS $A, $B, $C)>; 3670def : Pat<(int_ppc_fnmsub f64:$A, f64:$B, f64:$C), (FNMSUB $A, $B, $C)>; 3671def : Pat<(int_ppc_fnmsubs f32:$A, f32:$B, f32:$C), (FNMSUBS $A, $B, $C)>; 3672def : Pat<(int_ppc_fnmadd f64:$A, f64:$B, f64:$C), (FNMADD $A, $B, $C)>; 3673def : Pat<(int_ppc_fnmadds f32:$A, f32:$B, f32:$C), (FNMADDS $A, $B, $C)>; 3674def : Pat<(int_ppc_fre f64:$A), (FRE $A)>; 3675def : Pat<(int_ppc_fres f32:$A), (FRES $A)>; 3676 3677include "PPCInstrAltivec.td" 3678include "PPCInstrSPE.td" 3679include "PPCInstr64Bit.td" 3680include "PPCInstrVSX.td" 3681include "PPCInstrHTM.td" 3682 3683def crnot : OutPatFrag<(ops node:$in), 3684 (CRNOR $in, $in)>; 3685def : Pat<(not i1:$in), 3686 (crnot $in)>; 3687 3688// Prefixed instructions may require access to the above defs at a later 3689// time so we include this after the def. 3690include "PPCInstrPrefix.td" 3691 3692// Patterns for arithmetic i1 operations. 3693def : Pat<(add i1:$a, i1:$b), 3694 (CRXOR $a, $b)>; 3695def : Pat<(sub i1:$a, i1:$b), 3696 (CRXOR $a, $b)>; 3697def : Pat<(mul i1:$a, i1:$b), 3698 (CRAND $a, $b)>; 3699 3700// We're sometimes asked to materialize i1 -1, which is just 1 in this case 3701// (-1 is used to mean all bits set). 3702def : Pat<(i1 -1), (CRSET)>; 3703 3704// i1 extensions, implemented in terms of isel. 3705def : Pat<(i32 (zext i1:$in)), 3706 (SELECT_I4 $in, (LI 1), (LI 0))>; 3707def : Pat<(i32 (sext i1:$in)), 3708 (SELECT_I4 $in, (LI -1), (LI 0))>; 3709 3710def : Pat<(i64 (zext i1:$in)), 3711 (SELECT_I8 $in, (LI8 1), (LI8 0))>; 3712def : Pat<(i64 (sext i1:$in)), 3713 (SELECT_I8 $in, (LI8 -1), (LI8 0))>; 3714 3715// FIXME: We should choose either a zext or a sext based on other constants 3716// already around. 3717def : Pat<(i32 (anyext i1:$in)), 3718 (SELECT_I4 $in, (LI 1), (LI 0))>; 3719def : Pat<(i64 (anyext i1:$in)), 3720 (SELECT_I8 $in, (LI8 1), (LI8 0))>; 3721 3722// match setcc on i1 variables. 3723// CRANDC is: 3724// 1 1 : F 3725// 1 0 : T 3726// 0 1 : F 3727// 0 0 : F 3728// 3729// LT is: 3730// -1 -1 : F 3731// -1 0 : T 3732// 0 -1 : F 3733// 0 0 : F 3734// 3735// ULT is: 3736// 1 1 : F 3737// 1 0 : F 3738// 0 1 : T 3739// 0 0 : F 3740def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)), 3741 (CRANDC $s1, $s2)>; 3742def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)), 3743 (CRANDC $s2, $s1)>; 3744// CRORC is: 3745// 1 1 : T 3746// 1 0 : T 3747// 0 1 : F 3748// 0 0 : T 3749// 3750// LE is: 3751// -1 -1 : T 3752// -1 0 : T 3753// 0 -1 : F 3754// 0 0 : T 3755// 3756// ULE is: 3757// 1 1 : T 3758// 1 0 : F 3759// 0 1 : T 3760// 0 0 : T 3761def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)), 3762 (CRORC $s1, $s2)>; 3763def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)), 3764 (CRORC $s2, $s1)>; 3765 3766def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)), 3767 (CREQV $s1, $s2)>; 3768 3769// GE is: 3770// -1 -1 : T 3771// -1 0 : F 3772// 0 -1 : T 3773// 0 0 : T 3774// 3775// UGE is: 3776// 1 1 : T 3777// 1 0 : T 3778// 0 1 : F 3779// 0 0 : T 3780def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)), 3781 (CRORC $s2, $s1)>; 3782def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)), 3783 (CRORC $s1, $s2)>; 3784 3785// GT is: 3786// -1 -1 : F 3787// -1 0 : F 3788// 0 -1 : T 3789// 0 0 : F 3790// 3791// UGT is: 3792// 1 1 : F 3793// 1 0 : T 3794// 0 1 : F 3795// 0 0 : F 3796def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)), 3797 (CRANDC $s2, $s1)>; 3798def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)), 3799 (CRANDC $s1, $s2)>; 3800 3801def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)), 3802 (CRXOR $s1, $s2)>; 3803 3804// match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE, 3805// SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for 3806// floating-point types. 3807 3808multiclass CRNotPat<dag pattern, dag result> { 3809 def : Pat<pattern, (crnot result)>; 3810 def : Pat<(not pattern), result>; 3811 3812 // We can also fold the crnot into an extension: 3813 def : Pat<(i32 (zext pattern)), 3814 (SELECT_I4 result, (LI 0), (LI 1))>; 3815 def : Pat<(i32 (sext pattern)), 3816 (SELECT_I4 result, (LI 0), (LI -1))>; 3817 3818 // We can also fold the crnot into an extension: 3819 def : Pat<(i64 (zext pattern)), 3820 (SELECT_I8 result, (LI8 0), (LI8 1))>; 3821 def : Pat<(i64 (sext pattern)), 3822 (SELECT_I8 result, (LI8 0), (LI8 -1))>; 3823 3824 // FIXME: We should choose either a zext or a sext based on other constants 3825 // already around. 3826 def : Pat<(i32 (anyext pattern)), 3827 (SELECT_I4 result, (LI 0), (LI 1))>; 3828 3829 def : Pat<(i64 (anyext pattern)), 3830 (SELECT_I8 result, (LI8 0), (LI8 1))>; 3831} 3832 3833// FIXME: Because of what seems like a bug in TableGen's type-inference code, 3834// we need to write imm:$imm in the output patterns below, not just $imm, or 3835// else the resulting matcher will not correctly add the immediate operand 3836// (making it a register operand instead). 3837 3838// extended SETCC. 3839multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag, 3840 OutPatFrag rfrag, OutPatFrag rfrag8> { 3841 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))), 3842 (rfrag $s1)>; 3843 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))), 3844 (rfrag8 $s1)>; 3845 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))), 3846 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>; 3847 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))), 3848 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>; 3849 3850 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))), 3851 (rfrag $s1)>; 3852 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))), 3853 (rfrag8 $s1)>; 3854 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))), 3855 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>; 3856 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))), 3857 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>; 3858} 3859 3860// Note that we do all inversions below with i(32|64)not, instead of using 3861// (xori x, 1) because on the A2 nor has single-cycle latency while xori 3862// has 2-cycle latency. 3863 3864defm : ExtSetCCPat<SETEQ, 3865 PatFrag<(ops node:$in, node:$cc), 3866 (setcc $in, 0, $cc)>, 3867 OutPatFrag<(ops node:$in), 3868 (RLWINM (CNTLZW $in), 27, 31, 31)>, 3869 OutPatFrag<(ops node:$in), 3870 (RLDICL (CNTLZD $in), 58, 63)> >; 3871 3872defm : ExtSetCCPat<SETNE, 3873 PatFrag<(ops node:$in, node:$cc), 3874 (setcc $in, 0, $cc)>, 3875 OutPatFrag<(ops node:$in), 3876 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>, 3877 OutPatFrag<(ops node:$in), 3878 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >; 3879 3880defm : ExtSetCCPat<SETLT, 3881 PatFrag<(ops node:$in, node:$cc), 3882 (setcc $in, 0, $cc)>, 3883 OutPatFrag<(ops node:$in), 3884 (RLWINM $in, 1, 31, 31)>, 3885 OutPatFrag<(ops node:$in), 3886 (RLDICL $in, 1, 63)> >; 3887 3888defm : ExtSetCCPat<SETGE, 3889 PatFrag<(ops node:$in, node:$cc), 3890 (setcc $in, 0, $cc)>, 3891 OutPatFrag<(ops node:$in), 3892 (RLWINM (i32not $in), 1, 31, 31)>, 3893 OutPatFrag<(ops node:$in), 3894 (RLDICL (i64not $in), 1, 63)> >; 3895 3896defm : ExtSetCCPat<SETGT, 3897 PatFrag<(ops node:$in, node:$cc), 3898 (setcc $in, 0, $cc)>, 3899 OutPatFrag<(ops node:$in), 3900 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>, 3901 OutPatFrag<(ops node:$in), 3902 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >; 3903 3904defm : ExtSetCCPat<SETLE, 3905 PatFrag<(ops node:$in, node:$cc), 3906 (setcc $in, 0, $cc)>, 3907 OutPatFrag<(ops node:$in), 3908 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>, 3909 OutPatFrag<(ops node:$in), 3910 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >; 3911 3912defm : ExtSetCCPat<SETLT, 3913 PatFrag<(ops node:$in, node:$cc), 3914 (setcc $in, -1, $cc)>, 3915 OutPatFrag<(ops node:$in), 3916 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>, 3917 OutPatFrag<(ops node:$in), 3918 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >; 3919 3920defm : ExtSetCCPat<SETGE, 3921 PatFrag<(ops node:$in, node:$cc), 3922 (setcc $in, -1, $cc)>, 3923 OutPatFrag<(ops node:$in), 3924 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>, 3925 OutPatFrag<(ops node:$in), 3926 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >; 3927 3928defm : ExtSetCCPat<SETGT, 3929 PatFrag<(ops node:$in, node:$cc), 3930 (setcc $in, -1, $cc)>, 3931 OutPatFrag<(ops node:$in), 3932 (RLWINM (i32not $in), 1, 31, 31)>, 3933 OutPatFrag<(ops node:$in), 3934 (RLDICL (i64not $in), 1, 63)> >; 3935 3936defm : ExtSetCCPat<SETLE, 3937 PatFrag<(ops node:$in, node:$cc), 3938 (setcc $in, -1, $cc)>, 3939 OutPatFrag<(ops node:$in), 3940 (RLWINM $in, 1, 31, 31)>, 3941 OutPatFrag<(ops node:$in), 3942 (RLDICL $in, 1, 63)> >; 3943 3944// An extended SETCC with shift amount. 3945multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag, 3946 OutPatFrag rfrag, OutPatFrag rfrag8> { 3947 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))), 3948 (rfrag $s1, $sa)>; 3949 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))), 3950 (rfrag8 $s1, $sa)>; 3951 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))), 3952 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>; 3953 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))), 3954 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>; 3955 3956 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))), 3957 (rfrag $s1, $sa)>; 3958 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))), 3959 (rfrag8 $s1, $sa)>; 3960 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))), 3961 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>; 3962 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))), 3963 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>; 3964} 3965 3966defm : ExtSetCCShiftPat<SETNE, 3967 PatFrag<(ops node:$in, node:$sa, node:$cc), 3968 (setcc (and $in, (shl 1, $sa)), 0, $cc)>, 3969 OutPatFrag<(ops node:$in, node:$sa), 3970 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>, 3971 OutPatFrag<(ops node:$in, node:$sa), 3972 (RLDCL $in, (SUBFIC $sa, 64), 63)> >; 3973 3974defm : ExtSetCCShiftPat<SETEQ, 3975 PatFrag<(ops node:$in, node:$sa, node:$cc), 3976 (setcc (and $in, (shl 1, $sa)), 0, $cc)>, 3977 OutPatFrag<(ops node:$in, node:$sa), 3978 (RLWNM (i32not $in), 3979 (SUBFIC $sa, 32), 31, 31)>, 3980 OutPatFrag<(ops node:$in, node:$sa), 3981 (RLDCL (i64not $in), 3982 (SUBFIC $sa, 64), 63)> >; 3983 3984// SETCC for i32. 3985def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)), 3986 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>; 3987def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)), 3988 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>; 3989def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)), 3990 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>; 3991def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)), 3992 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>; 3993def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)), 3994 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>; 3995def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)), 3996 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>; 3997 3998// For non-equality comparisons, the default code would materialize the 3999// constant, then compare against it, like this: 4000// lis r2, 4660 4001// ori r2, r2, 22136 4002// cmpw cr0, r3, r2 4003// beq cr0,L6 4004// Since we are just comparing for equality, we can emit this instead: 4005// xoris r0,r3,0x1234 4006// cmplwi cr0,r0,0x5678 4007// beq cr0,L6 4008 4009def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)), 4010 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)), 4011 (LO16 imm:$imm)), sub_eq)>; 4012 4013def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)), 4014 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>; 4015def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)), 4016 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>; 4017def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)), 4018 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>; 4019def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)), 4020 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>; 4021def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)), 4022 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>; 4023 4024// SETCC for i64. 4025def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)), 4026 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>; 4027def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)), 4028 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>; 4029def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)), 4030 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>; 4031def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)), 4032 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>; 4033def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)), 4034 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>; 4035def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)), 4036 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>; 4037 4038// For non-equality comparisons, the default code would materialize the 4039// constant, then compare against it, like this: 4040// lis r2, 4660 4041// ori r2, r2, 22136 4042// cmpd cr0, r3, r2 4043// beq cr0,L6 4044// Since we are just comparing for equality, we can emit this instead: 4045// xoris r0,r3,0x1234 4046// cmpldi cr0,r0,0x5678 4047// beq cr0,L6 4048 4049def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)), 4050 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)), 4051 (LO16 imm:$imm)), sub_eq)>; 4052 4053def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)), 4054 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>; 4055def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)), 4056 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>; 4057def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)), 4058 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>; 4059def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)), 4060 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>; 4061def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)), 4062 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>; 4063 4064let Predicates = [IsNotISA3_1] in { 4065// Instantiations of CRNotPat for i32. 4066defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)), 4067 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>; 4068defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)), 4069 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>; 4070defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)), 4071 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>; 4072defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)), 4073 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>; 4074defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)), 4075 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>; 4076defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)), 4077 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>; 4078 4079defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)), 4080 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)), 4081 (LO16 imm:$imm)), sub_eq)>; 4082 4083defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)), 4084 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>; 4085defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)), 4086 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>; 4087defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)), 4088 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>; 4089defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)), 4090 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>; 4091defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)), 4092 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>; 4093 4094// Instantiations of CRNotPat for i64. 4095defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)), 4096 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>; 4097defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)), 4098 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>; 4099defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)), 4100 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>; 4101defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)), 4102 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>; 4103defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)), 4104 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>; 4105defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)), 4106 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>; 4107 4108defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)), 4109 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)), 4110 (LO16 imm:$imm)), sub_eq)>; 4111 4112defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)), 4113 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>; 4114defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)), 4115 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>; 4116defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)), 4117 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>; 4118defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)), 4119 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>; 4120defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)), 4121 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>; 4122} 4123 4124multiclass FSetCCPat<SDPatternOperator SetCC, ValueType Ty, I FCmp> { 4125 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETUGE)), 4126 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>; 4127 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETGE)), 4128 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>; 4129 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETULE)), 4130 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>; 4131 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETLE)), 4132 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>; 4133 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETUNE)), 4134 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>; 4135 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETNE)), 4136 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>; 4137 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETO)), 4138 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_un)>; 4139 4140 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETOLT)), 4141 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>; 4142 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETLT)), 4143 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>; 4144 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETOGT)), 4145 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>; 4146 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETGT)), 4147 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>; 4148 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETOEQ)), 4149 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>; 4150 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETEQ)), 4151 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>; 4152 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETUO)), 4153 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_un)>; 4154} 4155 4156let Predicates = [HasFPU] in { 4157// FCMPU: If either of the operands is a Signaling NaN, then VXSNAN is set. 4158// SETCC for f32. 4159defm : FSetCCPat<any_fsetcc, f32, FCMPUS>; 4160 4161// SETCC for f64. 4162defm : FSetCCPat<any_fsetcc, f64, FCMPUD>; 4163 4164// SETCC for f128. 4165defm : FSetCCPat<any_fsetcc, f128, XSCMPUQP>; 4166 4167// FCMPO: If either of the operands is a Signaling NaN, then VXSNAN is set and, 4168// if neither operand is a Signaling NaN but at least one operand is a Quiet NaN, 4169// then VXVC is set. 4170// SETCCS for f32. 4171defm : FSetCCPat<strict_fsetccs, f32, FCMPOS>; 4172 4173// SETCCS for f64. 4174defm : FSetCCPat<strict_fsetccs, f64, FCMPOD>; 4175 4176// SETCCS for f128. 4177defm : FSetCCPat<strict_fsetccs, f128, XSCMPOQP>; 4178} 4179 4180// This must be in this file because it relies on patterns defined in this file 4181// after the inclusion of the instruction sets. 4182let Predicates = [HasSPE] in { 4183// SETCC for f32. 4184def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETOLT)), 4185 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>; 4186def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETLT)), 4187 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>; 4188def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETOGT)), 4189 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>; 4190def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETGT)), 4191 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>; 4192def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETOEQ)), 4193 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>; 4194def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETEQ)), 4195 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>; 4196 4197defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETUGE)), 4198 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>; 4199defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETGE)), 4200 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>; 4201defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETULE)), 4202 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>; 4203defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETLE)), 4204 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>; 4205defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETUNE)), 4206 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>; 4207defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETNE)), 4208 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>; 4209 4210// SETCC for f64. 4211def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETOLT)), 4212 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>; 4213def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETLT)), 4214 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>; 4215def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETOGT)), 4216 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>; 4217def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETGT)), 4218 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>; 4219def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETOEQ)), 4220 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>; 4221def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETEQ)), 4222 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>; 4223 4224defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETUGE)), 4225 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>; 4226defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETGE)), 4227 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>; 4228defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETULE)), 4229 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>; 4230defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETLE)), 4231 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>; 4232defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETUNE)), 4233 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>; 4234defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETNE)), 4235 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>; 4236} 4237// match select on i1 variables: 4238def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)), 4239 (CROR (CRAND $cond , $tval), 4240 (CRAND (crnot $cond), $fval))>; 4241 4242// match selectcc on i1 variables: 4243// select (lhs == rhs), tval, fval is: 4244// ((lhs == rhs) & tval) | (!(lhs == rhs) & fval) 4245def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)), 4246 (CROR (CRAND (CRANDC $lhs, $rhs), $tval), 4247 (CRAND (CRORC $rhs, $lhs), $fval))>; 4248def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)), 4249 (CROR (CRAND (CRANDC $rhs, $lhs), $tval), 4250 (CRAND (CRORC $lhs, $rhs), $fval))>; 4251def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)), 4252 (CROR (CRAND (CRORC $lhs, $rhs), $tval), 4253 (CRAND (CRANDC $rhs, $lhs), $fval))>; 4254def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)), 4255 (CROR (CRAND (CRORC $rhs, $lhs), $tval), 4256 (CRAND (CRANDC $lhs, $rhs), $fval))>; 4257def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)), 4258 (CROR (CRAND (CREQV $lhs, $rhs), $tval), 4259 (CRAND (CRXOR $lhs, $rhs), $fval))>; 4260def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)), 4261 (CROR (CRAND (CRORC $rhs, $lhs), $tval), 4262 (CRAND (CRANDC $lhs, $rhs), $fval))>; 4263def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)), 4264 (CROR (CRAND (CRORC $lhs, $rhs), $tval), 4265 (CRAND (CRANDC $rhs, $lhs), $fval))>; 4266def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)), 4267 (CROR (CRAND (CRANDC $rhs, $lhs), $tval), 4268 (CRAND (CRORC $lhs, $rhs), $fval))>; 4269def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)), 4270 (CROR (CRAND (CRANDC $lhs, $rhs), $tval), 4271 (CRAND (CRORC $rhs, $lhs), $fval))>; 4272def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)), 4273 (CROR (CRAND (CREQV $lhs, $rhs), $fval), 4274 (CRAND (CRXOR $lhs, $rhs), $tval))>; 4275 4276// match selectcc on i1 variables with non-i1 output. 4277def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)), 4278 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>; 4279def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)), 4280 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>; 4281def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)), 4282 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>; 4283def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)), 4284 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>; 4285def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)), 4286 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>; 4287def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)), 4288 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>; 4289def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)), 4290 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>; 4291def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)), 4292 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>; 4293def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)), 4294 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>; 4295def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)), 4296 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>; 4297 4298def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)), 4299 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>; 4300def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)), 4301 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>; 4302def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)), 4303 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>; 4304def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)), 4305 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>; 4306def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)), 4307 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>; 4308def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)), 4309 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>; 4310def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)), 4311 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>; 4312def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)), 4313 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>; 4314def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)), 4315 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>; 4316def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)), 4317 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>; 4318 4319let Predicates = [HasFPU] in { 4320def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)), 4321 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>; 4322def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)), 4323 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>; 4324def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)), 4325 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>; 4326def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)), 4327 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>; 4328def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)), 4329 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>; 4330def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)), 4331 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>; 4332def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)), 4333 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>; 4334def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)), 4335 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>; 4336def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)), 4337 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>; 4338def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)), 4339 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>; 4340 4341def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)), 4342 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>; 4343def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)), 4344 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>; 4345def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)), 4346 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>; 4347def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)), 4348 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>; 4349def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)), 4350 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>; 4351def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)), 4352 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>; 4353def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)), 4354 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>; 4355def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)), 4356 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>; 4357def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)), 4358 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>; 4359def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)), 4360 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>; 4361} 4362 4363def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLT)), 4364 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>; 4365def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULT)), 4366 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>; 4367def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLE)), 4368 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>; 4369def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULE)), 4370 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>; 4371def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETEQ)), 4372 (SELECT_F16 (CREQV $lhs, $rhs), $tval, $fval)>; 4373def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGE)), 4374 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>; 4375def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGE)), 4376 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>; 4377def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGT)), 4378 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>; 4379def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGT)), 4380 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>; 4381def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETNE)), 4382 (SELECT_F16 (CRXOR $lhs, $rhs), $tval, $fval)>; 4383 4384def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)), 4385 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>; 4386def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)), 4387 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>; 4388def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)), 4389 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>; 4390def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)), 4391 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>; 4392def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)), 4393 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>; 4394def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)), 4395 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>; 4396def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)), 4397 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>; 4398def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)), 4399 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>; 4400def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)), 4401 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>; 4402def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)), 4403 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>; 4404 4405def ANDI_rec_1_EQ_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in), 4406 "#ANDI_rec_1_EQ_BIT", 4407 [(set i1:$dst, (trunc (not i32:$in)))]>; 4408def ANDI_rec_1_GT_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in), 4409 "#ANDI_rec_1_GT_BIT", 4410 [(set i1:$dst, (trunc i32:$in))]>; 4411 4412def ANDI_rec_1_EQ_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in), 4413 "#ANDI_rec_1_EQ_BIT8", 4414 [(set i1:$dst, (trunc (not i64:$in)))]>; 4415def ANDI_rec_1_GT_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in), 4416 "#ANDI_rec_1_GT_BIT8", 4417 [(set i1:$dst, (trunc i64:$in))]>; 4418 4419def : Pat<(i1 (not (trunc i32:$in))), 4420 (ANDI_rec_1_EQ_BIT $in)>; 4421def : Pat<(i1 (not (trunc i64:$in))), 4422 (ANDI_rec_1_EQ_BIT8 $in)>; 4423 4424def : Pat<(int_ppc_fsel f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), (FSELD $FRA, $FRC, $FRB)>; 4425def : Pat<(int_ppc_frsqrte f8rc:$frB), (FRSQRTE $frB)>; 4426def : Pat<(int_ppc_frsqrtes f4rc:$frB), (FRSQRTES $frB)>; 4427 4428//===----------------------------------------------------------------------===// 4429// PowerPC Instructions used for assembler/disassembler only 4430// 4431 4432// FIXME: For B=0 or B > 8, the registers following RT are used. 4433// WARNING: Do not add patterns for this instruction without fixing this. 4434def LSWI : XForm_base_r3xo_memOp<31, 597, (outs gprc:$RT), 4435 (ins gprc:$A, u5imm:$B), 4436 "lswi $RT, $A, $B", IIC_LdStLoad, []>; 4437 4438// FIXME: For B=0 or B > 8, the registers following RT are used. 4439// WARNING: Do not add patterns for this instruction without fixing this. 4440def STSWI : XForm_base_r3xo_memOp<31, 725, (outs), 4441 (ins gprc:$RT, gprc:$A, u5imm:$B), 4442 "stswi $RT, $A, $B", IIC_LdStLoad, []>; 4443 4444def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins), 4445 "isync", IIC_SprISYNC, []>; 4446 4447def ICBI : XForm_1a<31, 982, (outs), (ins memrr:$src), 4448 "icbi $src", IIC_LdStICBI, []>; 4449 4450def WAIT : XForm_24_sync<31, 30, (outs), (ins u2imm:$L), 4451 "wait $L", IIC_LdStLoad, []>; 4452 4453def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO), 4454 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>; 4455 4456def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR), 4457 "mtsr $SR, $RS", IIC_SprMTSR>; 4458 4459def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR), 4460 "mfsr $RS, $SR", IIC_SprMFSR>; 4461 4462def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB), 4463 "mtsrin $RS, $RB", IIC_SprMTSR>; 4464 4465def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB), 4466 "mfsrin $RS, $RB", IIC_SprMFSR>; 4467 4468def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, u1imm:$L), 4469 "mtmsr $RS, $L", IIC_SprMTMSR>; 4470 4471def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS), 4472 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> { 4473 let L = 0; 4474} 4475 4476def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>, 4477 Requires<[IsBookE]> { 4478 bits<1> E; 4479 4480 let Inst{16} = E; 4481 let Inst{21-30} = 163; 4482} 4483 4484def DCCCI : XForm_tlb<454, (outs), (ins gprc:$A, gprc:$B), 4485 "dccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>; 4486def ICCCI : XForm_tlb<966, (outs), (ins gprc:$A, gprc:$B), 4487 "iccci $A, $B", IIC_LdStLoad>, Requires<[IsPPC4xx]>; 4488 4489def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>; 4490def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>; 4491def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>; 4492def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>; 4493 4494def MFMSR : XForm_rs<31, 83, (outs gprc:$RT), (ins), 4495 "mfmsr $RT", IIC_SprMFMSR, []>; 4496 4497def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, u1imm:$L), 4498 "mtmsrd $RS, $L", IIC_SprMTMSRD>; 4499 4500def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA), 4501 "mcrfs $BF, $BFA", IIC_BrMCR>; 4502 4503// All MTFSF variants may change the rounding mode so conservatively set it 4504// as an implicit def for all of them. 4505let Predicates = [HasFPU] in { 4506let Defs = [RM] in { 4507let isCodeGenOnly = 1, 4508 Pattern = [(int_ppc_mtfsfi timm:$BF, timm:$U)], W = 0 in 4509def MTFSFIb : XLForm_4<63, 134, (outs), (ins u3imm:$BF, u4imm:$U), 4510 "mtfsfi $BF, $U", IIC_IntMFFS>; 4511def MTFSFI : XLForm_4<63, 134, (outs), (ins u3imm:$BF, u4imm:$U, i32imm:$W), 4512 "mtfsfi $BF, $U, $W", IIC_IntMFFS>; 4513let Defs = [CR1] in 4514def MTFSFI_rec : XLForm_4<63, 134, (outs), (ins u3imm:$BF, u4imm:$U, u1imm:$W), 4515 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isRecordForm; 4516 4517def MTFSF : XFLForm_1<63, 711, (outs), 4518 (ins i32imm:$FLM, f8rc:$FRB, u1imm:$L, i32imm:$W), 4519 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>; 4520let Defs = [CR1] in 4521def MTFSF_rec : XFLForm_1<63, 711, (outs), 4522 (ins i32imm:$FLM, f8rc:$FRB, u1imm:$L, i32imm:$W), 4523 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isRecordForm; 4524} 4525 4526def : InstAlias<"mtfsfi $BF, $U", (MTFSFI u3imm:$BF, u4imm:$U, 0)>; 4527def : InstAlias<"mtfsfi. $BF, $U", (MTFSFI_rec u3imm:$BF, u4imm:$U, 0)>; 4528def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>; 4529def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSF_rec i32imm:$FLM, f8rc:$FRB, 0, 0)>; 4530} 4531 4532def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB), 4533 "slbie $RB", IIC_SprSLBIE, []>; 4534 4535def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RS, gprc:$RB), 4536 "slbmte $RS, $RB", IIC_SprSLBMTE, []>; 4537 4538def SLBMFEE : XForm_26<31, 915, (outs gprc:$RT), (ins gprc:$RB), 4539 "slbmfee $RT, $RB", IIC_SprSLBMFEE, []>; 4540 4541def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB), 4542 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>; 4543 4544def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>; 4545 4546let Defs = [CR0] in 4547def SLBFEE_rec : XForm_26<31, 979, (outs gprc:$RT), (ins gprc:$RB), 4548 "slbfee. $RT, $RB", IIC_SprSLBFEE, []>, isRecordForm; 4549 4550def TLBIA : XForm_0<31, 370, (outs), (ins), 4551 "tlbia", IIC_SprTLBIA, []>; 4552 4553def TLBSYNC : XForm_0<31, 566, (outs), (ins), 4554 "tlbsync", IIC_SprTLBSYNC, []>; 4555 4556def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB), 4557 "tlbiel $RB", IIC_SprTLBIEL, []>; 4558 4559def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB), 4560 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>; 4561def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB), 4562 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>; 4563 4564def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RS, gprc:$RB), 4565 "tlbie $RB,$RS", IIC_SprTLBIE, []>; 4566 4567def TLBSX : XForm_tlb<914, (outs), (ins gprc:$A, gprc:$B), "tlbsx $A, $B", 4568 IIC_LdStLoad>, Requires<[IsBookE]>; 4569 4570def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$A, gprc:$B), "tlbivax $A, $B", 4571 IIC_LdStLoad>, Requires<[IsBookE]>; 4572 4573def TLBRE : XForm_24_eieio<31, 946, (outs), (ins), 4574 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>; 4575 4576def TLBWE : XForm_24_eieio<31, 978, (outs), (ins), 4577 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>; 4578 4579def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RS), (ins gprc:$A, i1imm:$WS), 4580 "tlbre $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>; 4581 4582def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RS, gprc:$A, i1imm:$WS), 4583 "tlbwe $RS, $A, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>; 4584 4585def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$A, gprc:$B), 4586 "tlbsx $RST, $A, $B", IIC_LdStLoad, []>, 4587 Requires<[IsPPC4xx]>; 4588def TLBSX2D : XForm_base_r3xo<31, 914, (outs), 4589 (ins gprc:$RST, gprc:$A, gprc:$B), 4590 "tlbsx. $RST, $A, $B", IIC_LdStLoad, []>, 4591 Requires<[IsPPC4xx]>, isRecordForm; 4592 4593def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>; 4594 4595def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>, 4596 Requires<[IsBookE]>; 4597def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>, 4598 Requires<[IsBookE]>; 4599 4600def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>, 4601 Requires<[IsE500]>; 4602def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>, 4603 Requires<[IsE500]>; 4604 4605def MFDCR : XFXForm_1<31, 323, (outs gprc:$RT), (ins i32imm:$SPR), 4606 "mfdcr $RT, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>; 4607def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RT, i32imm:$SPR), 4608 "mtdcr $SPR, $RT", IIC_SprMTSPR>, Requires<[IsPPC4xx]>; 4609 4610def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>; 4611def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>; 4612 4613def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>; 4614 4615def LBZCIX : XForm_base_r3xo_memOp<31, 853, (outs gprc:$RST), 4616 (ins gprc:$A, gprc:$B), 4617 "lbzcix $RST, $A, $B", IIC_LdStLoad, []>; 4618def LHZCIX : XForm_base_r3xo_memOp<31, 821, (outs gprc:$RST), 4619 (ins gprc:$A, gprc:$B), 4620 "lhzcix $RST, $A, $B", IIC_LdStLoad, []>; 4621def LWZCIX : XForm_base_r3xo_memOp<31, 789, (outs gprc:$RST), 4622 (ins gprc:$A, gprc:$B), 4623 "lwzcix $RST, $A, $B", IIC_LdStLoad, []>; 4624def LDCIX : XForm_base_r3xo_memOp<31, 885, (outs gprc:$RST), 4625 (ins gprc:$A, gprc:$B), 4626 "ldcix $RST, $A, $B", IIC_LdStLoad, []>; 4627 4628def STBCIX : XForm_base_r3xo_memOp<31, 981, (outs), 4629 (ins gprc:$RST, gprc:$A, gprc:$B), 4630 "stbcix $RST, $A, $B", IIC_LdStLoad, []>; 4631def STHCIX : XForm_base_r3xo_memOp<31, 949, (outs), 4632 (ins gprc:$RST, gprc:$A, gprc:$B), 4633 "sthcix $RST, $A, $B", IIC_LdStLoad, []>; 4634def STWCIX : XForm_base_r3xo_memOp<31, 917, (outs), 4635 (ins gprc:$RST, gprc:$A, gprc:$B), 4636 "stwcix $RST, $A, $B", IIC_LdStLoad, []>; 4637def STDCIX : XForm_base_r3xo_memOp<31, 1013, (outs), 4638 (ins gprc:$RST, gprc:$A, gprc:$B), 4639 "stdcix $RST, $A, $B", IIC_LdStLoad, []>; 4640 4641// External PID Load Store Instructions 4642 4643def LBEPX : XForm_1<31, 95, (outs gprc:$rD), (ins memrr:$src), 4644 "lbepx $rD, $src", IIC_LdStLoad, []>, 4645 Requires<[IsE500]>; 4646 4647def LFDEPX : XForm_25<31, 607, (outs f8rc:$frD), (ins memrr:$src), 4648 "lfdepx $frD, $src", IIC_LdStLFD, []>, 4649 Requires<[IsE500]>; 4650 4651def LHEPX : XForm_1<31, 287, (outs gprc:$rD), (ins memrr:$src), 4652 "lhepx $rD, $src", IIC_LdStLoad, []>, 4653 Requires<[IsE500]>; 4654 4655def LWEPX : XForm_1<31, 31, (outs gprc:$rD), (ins memrr:$src), 4656 "lwepx $rD, $src", IIC_LdStLoad, []>, 4657 Requires<[IsE500]>; 4658 4659def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$rS, memrr:$dst), 4660 "stbepx $rS, $dst", IIC_LdStStore, []>, 4661 Requires<[IsE500]>; 4662 4663def STFDEPX : XForm_28_memOp<31, 735, (outs), (ins f8rc:$frS, memrr:$dst), 4664 "stfdepx $frS, $dst", IIC_LdStSTFD, []>, 4665 Requires<[IsE500]>; 4666 4667def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$rS, memrr:$dst), 4668 "sthepx $rS, $dst", IIC_LdStStore, []>, 4669 Requires<[IsE500]>; 4670 4671def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$rS, memrr:$dst), 4672 "stwepx $rS, $dst", IIC_LdStStore, []>, 4673 Requires<[IsE500]>; 4674 4675def DCBFEP : DCB_Form<127, 0, (outs), (ins memrr:$dst), "dcbfep $dst", 4676 IIC_LdStDCBF, []>, Requires<[IsE500]>; 4677 4678def DCBSTEP : DCB_Form<63, 0, (outs), (ins memrr:$dst), "dcbstep $dst", 4679 IIC_LdStDCBF, []>, Requires<[IsE500]>; 4680 4681def DCBTEP : DCB_Form_hint<319, (outs), (ins memrr:$dst, u5imm:$TH), 4682 "dcbtep $TH, $dst", IIC_LdStDCBF, []>, 4683 Requires<[IsE500]>; 4684 4685def DCBTSTEP : DCB_Form_hint<255, (outs), (ins memrr:$dst, u5imm:$TH), 4686 "dcbtstep $TH, $dst", IIC_LdStDCBF, []>, 4687 Requires<[IsE500]>; 4688 4689def DCBZEP : DCB_Form<1023, 0, (outs), (ins memrr:$dst), "dcbzep $dst", 4690 IIC_LdStDCBF, []>, Requires<[IsE500]>; 4691 4692def DCBZLEP : DCB_Form<1023, 1, (outs), (ins memrr:$dst), "dcbzlep $dst", 4693 IIC_LdStDCBF, []>, Requires<[IsE500]>; 4694 4695def ICBIEP : XForm_1a<31, 991, (outs), (ins memrr:$src), "icbiep $src", 4696 IIC_LdStICBI, []>, Requires<[IsE500]>; 4697 4698//===----------------------------------------------------------------------===// 4699// PowerPC Assembler Instruction Aliases 4700// 4701 4702// Pseudo-instructions for alternate assembly syntax (never used by codegen). 4703// These are aliases that require C++ handling to convert to the target 4704// instruction, while InstAliases can be handled directly by tblgen. 4705class PPCAsmPseudo<string asm, dag iops> 4706 : Instruction { 4707 let Namespace = "PPC"; 4708 bit PPC64 = 0; // Default value, override with isPPC64 4709 4710 let OutOperandList = (outs); 4711 let InOperandList = iops; 4712 let Pattern = []; 4713 let AsmString = asm; 4714 let isAsmParserOnly = 1; 4715 let isPseudo = 1; 4716 let hasNoSchedulingInfo = 1; 4717} 4718 4719def : InstAlias<"sc", (SC 0)>; 4720 4721def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>; 4722def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>; 4723def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>; 4724def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>; 4725 4726def : InstAlias<"wait", (WAIT 0)>; 4727def : InstAlias<"waitrsv", (WAIT 1)>; 4728def : InstAlias<"waitimpl", (WAIT 2)>; 4729 4730def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>; 4731 4732def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>; 4733def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>; 4734 4735def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>; 4736def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>; 4737def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>; 4738 4739def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>; 4740def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>; 4741def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>; 4742 4743def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>; 4744def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>; 4745def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>; 4746 4747def : Pat<(int_ppc_isync), (ISYNC)>; 4748def : Pat<(int_ppc_dcbfl xoaddr:$dst), 4749 (DCBF 1, xoaddr:$dst)>; 4750def : Pat<(int_ppc_dcbflp xoaddr:$dst), 4751 (DCBF 3, xoaddr:$dst)>; 4752 4753let Predicates = [IsISA3_1] in { 4754 def DCBFPS : PPCAsmPseudo<"dcbfps $dst", (ins memrr:$dst)>; 4755 def DCBSTPS : PPCAsmPseudo<"dcbstps $dst", (ins memrr:$dst)>; 4756 4757 def : Pat<(int_ppc_dcbfps xoaddr:$dst), 4758 (DCBF 4, xoaddr:$dst)>; 4759 def : Pat<(int_ppc_dcbstps xoaddr:$dst), 4760 (DCBF 6, xoaddr:$dst)>; 4761} 4762 4763def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>; 4764def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>; 4765def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>; 4766def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>; 4767 4768def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>; 4769def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>; 4770def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>; 4771 4772def : InstAlias<"xnop", (XORI R0, R0, 0)>; 4773 4774def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>; 4775def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>; 4776 4777//Disable this alias on AIX for now because as does not support them. 4778let Predicates = [ModernAs] in { 4779 4780foreach BR = 0-7 in { 4781 def : InstAlias<"mfbr"#BR#" $Rx", 4782 (MFDCR gprc:$Rx, !add(BR, 0x80))>, 4783 Requires<[IsPPC4xx]>; 4784 def : InstAlias<"mtbr"#BR#" $Rx", 4785 (MTDCR gprc:$Rx, !add(BR, 0x80))>, 4786 Requires<[IsPPC4xx]>; 4787} 4788 4789def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>; 4790def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>; 4791def : InstAlias<"mtudscr $Rx", (MTSPR 3, gprc:$Rx)>; 4792def : InstAlias<"mfudscr $Rx", (MFSPR gprc:$Rx, 3)>; 4793 4794def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>; 4795def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>; 4796 4797def : InstAlias<"mtlr $Rx", (MTSPR 8, gprc:$Rx)>; 4798def : InstAlias<"mflr $Rx", (MFSPR gprc:$Rx, 8)>; 4799 4800def : InstAlias<"mtctr $Rx", (MTSPR 9, gprc:$Rx)>; 4801def : InstAlias<"mfctr $Rx", (MFSPR gprc:$Rx, 9)>; 4802 4803def : InstAlias<"mtuamr $Rx", (MTSPR 13, gprc:$Rx)>; 4804def : InstAlias<"mfuamr $Rx", (MFSPR gprc:$Rx, 13)>; 4805 4806def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>; 4807def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>; 4808 4809def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>; 4810def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>; 4811 4812def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>; 4813def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>; 4814 4815def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>; 4816def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>; 4817 4818def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>; 4819def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>; 4820 4821def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>; 4822def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>; 4823 4824def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>; 4825def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>; 4826 4827def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>; 4828def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>; 4829 4830def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>; 4831def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>; 4832 4833def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>; 4834def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>; 4835 4836foreach SPRG = 4-7 in { 4837 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>, 4838 Requires<[IsBookE]>; 4839 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>, 4840 Requires<[IsBookE]>; 4841 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>, 4842 Requires<[IsBookE]>; 4843 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>, 4844 Requires<[IsBookE]>; 4845} 4846 4847foreach SPRG = 0-3 in { 4848 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>; 4849 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>; 4850 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>; 4851 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>; 4852} 4853 4854def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>; 4855def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>; 4856 4857def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>; 4858def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>; 4859 4860def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>; 4861 4862def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>; 4863def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>; 4864 4865foreach BATR = 0-3 in { 4866 def : InstAlias<"mtdbatu "#BATR#", $Rx", 4867 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>, 4868 Requires<[IsPPC6xx]>; 4869 def : InstAlias<"mfdbatu $Rx, "#BATR, 4870 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>, 4871 Requires<[IsPPC6xx]>; 4872 def : InstAlias<"mtdbatl "#BATR#", $Rx", 4873 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>, 4874 Requires<[IsPPC6xx]>; 4875 def : InstAlias<"mfdbatl $Rx, "#BATR, 4876 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>, 4877 Requires<[IsPPC6xx]>; 4878 def : InstAlias<"mtibatu "#BATR#", $Rx", 4879 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>, 4880 Requires<[IsPPC6xx]>; 4881 def : InstAlias<"mfibatu $Rx, "#BATR, 4882 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>, 4883 Requires<[IsPPC6xx]>; 4884 def : InstAlias<"mtibatl "#BATR#", $Rx", 4885 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>, 4886 Requires<[IsPPC6xx]>; 4887 def : InstAlias<"mfibatl $Rx, "#BATR, 4888 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>, 4889 Requires<[IsPPC6xx]>; 4890} 4891 4892def : InstAlias<"mtppr $RT", (MTSPR 896, gprc:$RT)>; 4893def : InstAlias<"mfppr $RT", (MFSPR gprc:$RT, 896)>; 4894 4895def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>; 4896def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>; 4897 4898def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>; 4899def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>; 4900 4901def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>; 4902def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>; 4903 4904def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>; 4905def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>; 4906 4907def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>; 4908def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>; 4909 4910def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>; 4911def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>; 4912 4913def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>; 4914def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>; 4915 4916def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>; 4917def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>; 4918 4919def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>; 4920def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>; 4921 4922} 4923 4924def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>; 4925 4926def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>, 4927 Requires<[IsPPC4xx]>; 4928def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>, 4929 Requires<[IsPPC4xx]>; 4930def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>, 4931 Requires<[IsPPC4xx]>; 4932def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>, 4933 Requires<[IsPPC4xx]>; 4934 4935def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>; 4936 4937def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm", 4938 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>; 4939def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm", 4940 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>; 4941def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm", 4942 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>; 4943def SUBIC_rec : PPCAsmPseudo<"subic. $rA, $rB, $imm", 4944 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>; 4945 4946def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b", 4947 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4948def EXTLWI_rec : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b", 4949 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4950def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b", 4951 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4952def EXTRWI_rec : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b", 4953 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4954def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b", 4955 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4956def INSLWI_rec : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b", 4957 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4958def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b", 4959 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4960def INSRWI_rec : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b", 4961 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>; 4962def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n", 4963 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4964def ROTRWI_rec : PPCAsmPseudo<"rotrwi. $rA, $rS, $n", 4965 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4966def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n", 4967 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4968def SLWI_rec : PPCAsmPseudo<"slwi. $rA, $rS, $n", 4969 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4970def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n", 4971 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4972def SRWI_rec : PPCAsmPseudo<"srwi. $rA, $rS, $n", 4973 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4974def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n", 4975 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4976def CLRRWI_rec : PPCAsmPseudo<"clrrwi. $rA, $rS, $n", 4977 (ins gprc:$rA, gprc:$rS, u5imm:$n)>; 4978def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n", 4979 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>; 4980def CLRLSLWI_rec : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n", 4981 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>; 4982 4983def : InstAlias<"isellt $rT, $rA, $rB", 4984 (ISEL gprc:$rT, gprc_nor0:$rA, gprc:$rB, CR0LT)>; 4985def : InstAlias<"iselgt $rT, $rA, $rB", 4986 (ISEL gprc:$rT, gprc_nor0:$rA, gprc:$rB, CR0GT)>; 4987def : InstAlias<"iseleq $rT, $rA, $rB", 4988 (ISEL gprc:$rT, gprc_nor0:$rA, gprc:$rB, CR0EQ)>; 4989 4990def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>; 4991def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINM_rec gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>; 4992def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>; 4993def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNM_rec gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>; 4994def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>; 4995def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINM_rec gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>; 4996 4997def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>; 4998def : InstAlias<"cntlzw. $rA, $rS", (CNTLZW_rec gprc:$rA, gprc:$rS)>; 4999// The POWER variant 5000def : MnemonicAlias<"cntlz", "cntlzw">; 5001def : MnemonicAlias<"cntlz.", "cntlzw.">; 5002 5003def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b", 5004 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 5005def EXTLDI_rec : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b", 5006 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 5007def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b", 5008 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 5009def EXTRDI_rec : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b", 5010 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 5011def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b", 5012 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 5013def INSRDI_rec : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b", 5014 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>; 5015def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n", 5016 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 5017def ROTRDI_rec : PPCAsmPseudo<"rotrdi. $rA, $rS, $n", 5018 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 5019def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n", 5020 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 5021def SLDI_rec : PPCAsmPseudo<"sldi. $rA, $rS, $n", 5022 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 5023def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n", 5024 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 5025def SRDI_rec : PPCAsmPseudo<"srdi. $rA, $rS, $n", 5026 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 5027def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n", 5028 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 5029def CLRRDI_rec : PPCAsmPseudo<"clrrdi. $rA, $rS, $n", 5030 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>; 5031def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n", 5032 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>; 5033def CLRLSLDI_rec : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n", 5034 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>; 5035def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>; 5036 5037def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>; 5038def : InstAlias<"rotldi $rA, $rS, $n", 5039 (RLDICL_32_64 g8rc:$rA, gprc:$rS, u6imm:$n, 0)>; 5040def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICL_rec g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>; 5041def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>; 5042def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCL_rec g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>; 5043def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>; 5044def : InstAlias<"clrldi $rA, $rS, $n", 5045 (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>; 5046def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICL_rec g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>; 5047def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>; 5048 5049def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b", 5050 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 5051def RLWINMbm_rec : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b", 5052 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 5053def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b", 5054 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 5055def RLWIMIbm_rec : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b", 5056 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 5057def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b", 5058 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 5059def RLWNMbm_rec : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b", 5060 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>; 5061 5062// These generic branch instruction forms are used for the assembler parser only. 5063// Defs and Uses are conservative, since we don't know the BO value. 5064let PPC970_Unit = 7, isBranch = 1, hasSideEffects = 0 in { 5065 let Defs = [CTR], Uses = [CTR, RM] in { 5066 def gBC : BForm_3<16, 0, 0, (outs), 5067 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst), 5068 "bc $bo, $bi, $dst">; 5069 def gBCA : BForm_3<16, 1, 0, (outs), 5070 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst), 5071 "bca $bo, $bi, $dst">; 5072 let isAsmParserOnly = 1 in { 5073 def gBCat : BForm_3_at<16, 0, 0, (outs), 5074 (ins u5imm:$bo, atimm:$at, crbitrc:$bi, 5075 condbrtarget:$dst), 5076 "bc$at $bo, $bi, $dst">; 5077 def gBCAat : BForm_3_at<16, 1, 0, (outs), 5078 (ins u5imm:$bo, atimm:$at, crbitrc:$bi, 5079 abscondbrtarget:$dst), 5080 "bca$at $bo, $bi, $dst">; 5081 } // isAsmParserOnly = 1 5082 } 5083 let Defs = [LR, CTR], Uses = [CTR, RM] in { 5084 def gBCL : BForm_3<16, 0, 1, (outs), 5085 (ins u5imm:$bo, crbitrc:$bi, condbrtarget:$dst), 5086 "bcl $bo, $bi, $dst">; 5087 def gBCLA : BForm_3<16, 1, 1, (outs), 5088 (ins u5imm:$bo, crbitrc:$bi, abscondbrtarget:$dst), 5089 "bcla $bo, $bi, $dst">; 5090 let isAsmParserOnly = 1 in { 5091 def gBCLat : BForm_3_at<16, 0, 1, (outs), 5092 (ins u5imm:$bo, atimm:$at, crbitrc:$bi, 5093 condbrtarget:$dst), 5094 "bcl$at $bo, $bi, $dst">; 5095 def gBCLAat : BForm_3_at<16, 1, 1, (outs), 5096 (ins u5imm:$bo, atimm:$at, crbitrc:$bi, 5097 abscondbrtarget:$dst), 5098 "bcla$at $bo, $bi, $dst">; 5099 } // // isAsmParserOnly = 1 5100 } 5101 let Defs = [CTR], Uses = [CTR, LR, RM] in 5102 def gBCLR : XLForm_2<19, 16, 0, (outs), 5103 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh), 5104 "bclr $bo, $bi, $bh", IIC_BrB, []>; 5105 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in 5106 def gBCLRL : XLForm_2<19, 16, 1, (outs), 5107 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh), 5108 "bclrl $bo, $bi, $bh", IIC_BrB, []>; 5109 let Defs = [CTR], Uses = [CTR, LR, RM] in 5110 def gBCCTR : XLForm_2<19, 528, 0, (outs), 5111 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh), 5112 "bcctr $bo, $bi, $bh", IIC_BrB, []>; 5113 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in 5114 def gBCCTRL : XLForm_2<19, 528, 1, (outs), 5115 (ins u5imm:$bo, crbitrc:$bi, i32imm:$bh), 5116 "bcctrl $bo, $bi, $bh", IIC_BrB, []>; 5117} 5118 5119multiclass BranchSimpleMnemonicAT<string pm, int at> { 5120 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi, 5121 condbrtarget:$dst)>; 5122 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi, 5123 condbrtarget:$dst)>; 5124 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi, 5125 condbrtarget:$dst)>; 5126 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi, 5127 condbrtarget:$dst)>; 5128} 5129defm : BranchSimpleMnemonicAT<"+", 3>; 5130defm : BranchSimpleMnemonicAT<"-", 2>; 5131 5132def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>; 5133def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>; 5134def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>; 5135def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>; 5136 5137multiclass BranchSimpleMnemonic1<string name, string pm, int bo> { 5138 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>; 5139 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>; 5140 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>; 5141 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>; 5142 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>; 5143 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>; 5144} 5145multiclass BranchSimpleMnemonic2<string name, string pm, int bo> 5146 : BranchSimpleMnemonic1<name, pm, bo> { 5147 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>; 5148 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>; 5149} 5150defm : BranchSimpleMnemonic2<"t", "", 12>; 5151defm : BranchSimpleMnemonic2<"f", "", 4>; 5152defm : BranchSimpleMnemonic2<"t", "-", 14>; 5153defm : BranchSimpleMnemonic2<"f", "-", 6>; 5154defm : BranchSimpleMnemonic2<"t", "+", 15>; 5155defm : BranchSimpleMnemonic2<"f", "+", 7>; 5156defm : BranchSimpleMnemonic1<"dnzt", "", 8>; 5157defm : BranchSimpleMnemonic1<"dnzf", "", 0>; 5158defm : BranchSimpleMnemonic1<"dzt", "", 10>; 5159defm : BranchSimpleMnemonic1<"dzf", "", 2>; 5160 5161multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> { 5162 def : InstAlias<"b"#name#pm#" $cc, $dst", 5163 (BCC bibo, crrc:$cc, condbrtarget:$dst)>; 5164 def : InstAlias<"b"#name#pm#" $dst", 5165 (BCC bibo, CR0, condbrtarget:$dst)>; 5166 5167 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst", 5168 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>; 5169 def : InstAlias<"b"#name#"a"#pm#" $dst", 5170 (BCCA bibo, CR0, abscondbrtarget:$dst)>; 5171 5172 def : InstAlias<"b"#name#"lr"#pm#" $cc", 5173 (BCCLR bibo, crrc:$cc)>; 5174 def : InstAlias<"b"#name#"lr"#pm, 5175 (BCCLR bibo, CR0)>; 5176 5177 def : InstAlias<"b"#name#"ctr"#pm#" $cc", 5178 (BCCCTR bibo, crrc:$cc)>; 5179 def : InstAlias<"b"#name#"ctr"#pm, 5180 (BCCCTR bibo, CR0)>; 5181 5182 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst", 5183 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>; 5184 def : InstAlias<"b"#name#"l"#pm#" $dst", 5185 (BCCL bibo, CR0, condbrtarget:$dst)>; 5186 5187 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst", 5188 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>; 5189 def : InstAlias<"b"#name#"la"#pm#" $dst", 5190 (BCCLA bibo, CR0, abscondbrtarget:$dst)>; 5191 5192 def : InstAlias<"b"#name#"lrl"#pm#" $cc", 5193 (BCCLRL bibo, crrc:$cc)>; 5194 def : InstAlias<"b"#name#"lrl"#pm, 5195 (BCCLRL bibo, CR0)>; 5196 5197 def : InstAlias<"b"#name#"ctrl"#pm#" $cc", 5198 (BCCCTRL bibo, crrc:$cc)>; 5199 def : InstAlias<"b"#name#"ctrl"#pm, 5200 (BCCCTRL bibo, CR0)>; 5201} 5202multiclass BranchExtendedMnemonic<string name, int bibo> { 5203 defm : BranchExtendedMnemonicPM<name, "", bibo>; 5204 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>; 5205 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>; 5206} 5207defm : BranchExtendedMnemonic<"lt", 12>; 5208defm : BranchExtendedMnemonic<"gt", 44>; 5209defm : BranchExtendedMnemonic<"eq", 76>; 5210defm : BranchExtendedMnemonic<"un", 108>; 5211defm : BranchExtendedMnemonic<"so", 108>; 5212defm : BranchExtendedMnemonic<"ge", 4>; 5213defm : BranchExtendedMnemonic<"nl", 4>; 5214defm : BranchExtendedMnemonic<"le", 36>; 5215defm : BranchExtendedMnemonic<"ng", 36>; 5216defm : BranchExtendedMnemonic<"ne", 68>; 5217defm : BranchExtendedMnemonic<"nu", 100>; 5218defm : BranchExtendedMnemonic<"ns", 100>; 5219 5220def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>; 5221def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>; 5222def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>; 5223def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>; 5224def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>; 5225def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>; 5226def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>; 5227def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>; 5228 5229def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>; 5230def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>; 5231def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>; 5232def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>; 5233def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>; 5234def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>; 5235def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>; 5236def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>; 5237 5238def : InstAlias<"trap", (TW 31, R0, R0)>; 5239 5240multiclass TrapExtendedMnemonic<string name, int to> { 5241 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>; 5242 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>; 5243 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>; 5244 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>; 5245} 5246defm : TrapExtendedMnemonic<"lt", 16>; 5247defm : TrapExtendedMnemonic<"le", 20>; 5248defm : TrapExtendedMnemonic<"eq", 4>; 5249defm : TrapExtendedMnemonic<"ge", 12>; 5250defm : TrapExtendedMnemonic<"gt", 8>; 5251defm : TrapExtendedMnemonic<"nl", 12>; 5252defm : TrapExtendedMnemonic<"ne", 24>; 5253defm : TrapExtendedMnemonic<"ng", 20>; 5254defm : TrapExtendedMnemonic<"llt", 2>; 5255defm : TrapExtendedMnemonic<"lle", 6>; 5256defm : TrapExtendedMnemonic<"lge", 5>; 5257defm : TrapExtendedMnemonic<"lgt", 1>; 5258defm : TrapExtendedMnemonic<"lnl", 5>; 5259defm : TrapExtendedMnemonic<"lng", 6>; 5260defm : TrapExtendedMnemonic<"u", 31>; 5261 5262// Atomic loads 5263def : Pat<(atomic_load_8 DForm:$src), (LBZ memri:$src)>; 5264def : Pat<(atomic_load_16 DForm:$src), (LHZ memri:$src)>; 5265def : Pat<(atomic_load_32 DForm:$src), (LWZ memri:$src)>; 5266def : Pat<(atomic_load_8 XForm:$src), (LBZX memrr:$src)>; 5267def : Pat<(atomic_load_16 XForm:$src), (LHZX memrr:$src)>; 5268def : Pat<(atomic_load_32 XForm:$src), (LWZX memrr:$src)>; 5269 5270// Atomic stores 5271def : Pat<(atomic_store_8 DForm:$ptr, i32:$val), (STB gprc:$val, memri:$ptr)>; 5272def : Pat<(atomic_store_16 DForm:$ptr, i32:$val), (STH gprc:$val, memri:$ptr)>; 5273def : Pat<(atomic_store_32 DForm:$ptr, i32:$val), (STW gprc:$val, memri:$ptr)>; 5274def : Pat<(atomic_store_8 XForm:$ptr, i32:$val), (STBX gprc:$val, memrr:$ptr)>; 5275def : Pat<(atomic_store_16 XForm:$ptr, i32:$val), (STHX gprc:$val, memrr:$ptr)>; 5276def : Pat<(atomic_store_32 XForm:$ptr, i32:$val), (STWX gprc:$val, memrr:$ptr)>; 5277 5278let Predicates = [IsISA3_0] in { 5279 5280// Copy-Paste Facility 5281// We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to 5282// PASTE for naming consistency. 5283let mayLoad = 1 in 5284def CP_COPY : X_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>; 5285 5286let mayStore = 1, Defs = [CR0] in 5287def CP_PASTE_rec : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isRecordForm; 5288 5289def : InstAlias<"paste. $RA, $RB", (CP_PASTE_rec gprc:$RA, gprc:$RB, 1)>; 5290def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cpabort", IIC_SprABORT, []>; 5291 5292// Message Synchronize 5293def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>; 5294 5295// Power-Saving Mode Instruction: 5296def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>; 5297 5298def SETB : XForm_44<31, 128, (outs gprc:$RT), (ins crrc:$BFA), 5299 "setb $RT, $BFA", IIC_IntGeneral>; 5300} // IsISA3_0 5301 5302let Predicates = [IsISA3_0] in { 5303def : Pat<(i32 (int_ppc_cmprb i32:$a, gprc:$b, gprc:$c)), 5304 (i32 (SETB (CMPRB u1imm:$a, $b, $c)))>; 5305} 5306def : Pat<(i32 (int_ppc_mulhw gprc:$a, gprc:$b)), 5307 (i32 (MULHW $a, $b))>; 5308def : Pat<(i32 (int_ppc_mulhwu gprc:$a, gprc:$b)), 5309 (i32 (MULHWU $a, $b))>; 5310def : Pat<(i32 (int_ppc_cmpb gprc:$a, gprc:$b)), 5311 (i32 (CMPB $a, $b))>; 5312 5313def : Pat<(int_ppc_load2r ForceXForm:$ptr), 5314 (LHBRX ForceXForm:$ptr)>; 5315def : Pat<(int_ppc_load4r ForceXForm:$ptr), 5316 (LWBRX ForceXForm:$ptr)>; 5317def : Pat<(int_ppc_store2r gprc:$a, ForceXForm:$ptr), 5318 (STHBRX gprc:$a, ForceXForm:$ptr)>; 5319def : Pat<(int_ppc_store4r gprc:$a, ForceXForm:$ptr), 5320 (STWBRX gprc:$a, ForceXForm:$ptr)>; 5321 5322 5323// Fast 32-bit reverse bits algorithm: 5324// Step 1: 1-bit swap (swap odd 1-bit and even 1-bit): 5325// n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA); 5326// Step 2: 2-bit swap (swap odd 2-bit and even 2-bit): 5327// n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC); 5328// Step 3: 4-bit swap (swap odd 4-bit and even 4-bit): 5329// n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0); 5330// Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]): 5331// Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes): 5332// n' = (n rotl 24); After which n' = [B4, B1, B2, B3] 5333// Step 4.2: Insert B3 to the right position: 5334// n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3] 5335// Step 4.3: Insert B1 to the right position: 5336// n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1] 5337def MaskValues { 5338 dag Lo1 = (ORI (LIS 0x5555), 0x5555); 5339 dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA); 5340 dag Lo2 = (ORI (LIS 0x3333), 0x3333); 5341 dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC); 5342 dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F); 5343 dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0); 5344} 5345 5346def Shift1 { 5347 dag Right = (RLWINM $A, 31, 1, 31); 5348 dag Left = (RLWINM $A, 1, 0, 30); 5349} 5350 5351def Swap1 { 5352 dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1), 5353 (AND Shift1.Left, MaskValues.Hi1)); 5354} 5355 5356def Shift2 { 5357 dag Right = (RLWINM Swap1.Bit, 30, 2, 31); 5358 dag Left = (RLWINM Swap1.Bit, 2, 0, 29); 5359} 5360 5361def Swap2 { 5362 dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2), 5363 (AND Shift2.Left, MaskValues.Hi2)); 5364} 5365 5366def Shift4 { 5367 dag Right = (RLWINM Swap2.Bits, 28, 4, 31); 5368 dag Left = (RLWINM Swap2.Bits, 4, 0, 27); 5369} 5370 5371def Swap4 { 5372 dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4), 5373 (AND Shift4.Left, MaskValues.Hi4)); 5374} 5375 5376def Rotate { 5377 dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31); 5378} 5379 5380def RotateInsertByte3 { 5381 dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15); 5382} 5383 5384def RotateInsertByte1 { 5385 dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31); 5386} 5387 5388// Clear the upper half of the register when in 64-bit mode 5389let Predicates = [In64BitMode] in 5390def : Pat<(i32 (bitreverse i32:$A)), (RLDICL_32 RotateInsertByte1.Left, 0, 32)>; 5391let Predicates = [In32BitMode] in 5392def : Pat<(i32 (bitreverse i32:$A)), RotateInsertByte1.Left>; 5393 5394// Fast 64-bit reverse bits algorithm: 5395// Step 1: 1-bit swap (swap odd 1-bit and even 1-bit): 5396// n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA); 5397// Step 2: 2-bit swap (swap odd 2-bit and even 2-bit): 5398// n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC); 5399// Step 3: 4-bit swap (swap odd 4-bit and even 4-bit): 5400// n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0); 5401// Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]): 5402// Apply the same byte reverse algorithm mentioned above for the fast 32-bit 5403// reverse to both the high 32 bit and low 32 bit of the 64 bit value. And 5404// then OR them together to get the final result. 5405def MaskValues64 { 5406 dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32)); 5407 dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32)); 5408 dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32)); 5409 dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32)); 5410 dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32)); 5411 dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32)); 5412} 5413 5414def DWMaskValues { 5415 dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555); 5416 dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA); 5417 dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333); 5418 dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC); 5419 dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F); 5420 dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0); 5421} 5422 5423def DWSwapInByte { 5424 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1), 5425 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1)); 5426 dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2), 5427 (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2)); 5428 dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4), 5429 (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4)); 5430} 5431 5432// Intra-byte swap is done, now start inter-byte swap. 5433def DWBytes4567 { 5434 dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32)); 5435} 5436 5437def DWBytes7456 { 5438 dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31); 5439} 5440 5441def DWBytes7656 { 5442 dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15); 5443} 5444 5445// B7 B6 B5 B4 in the right order 5446def DWBytes7654 { 5447 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31); 5448 dag DWord = 5449 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32)); 5450} 5451 5452def DWBytes0123 { 5453 dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32)); 5454} 5455 5456def DWBytes3012 { 5457 dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31); 5458} 5459 5460def DWBytes3212 { 5461 dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15); 5462} 5463 5464// B3 B2 B1 B0 in the right order 5465def DWBytes3210 { 5466 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31); 5467 dag DWord = 5468 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32)); 5469} 5470 5471// Now both high word and low word are reversed, next 5472// swap the high word and low word. 5473def : Pat<(i64 (bitreverse i64:$A)), 5474 (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>; 5475 5476def : Pat<(int_ppc_stwcx ForceXForm:$dst, gprc:$A), 5477 (STWCX gprc:$A, ForceXForm:$dst)>; 5478def : Pat<(int_ppc_stbcx ForceXForm:$dst, gprc:$A), 5479 (STBCX gprc:$A, ForceXForm:$dst)>; 5480def : Pat<(int_ppc_tw gprc:$A, gprc:$B, i32:$IMM), 5481 (TW $IMM, $A, $B)>; 5482def : Pat<(int_ppc_trap gprc:$A), 5483 (TWI 24, $A, 0)>; 5484 5485def : Pat<(int_ppc_fcfid f64:$A), 5486 (XSCVSXDDP $A)>; 5487def : Pat<(int_ppc_fcfud f64:$A), 5488 (XSCVUXDDP $A)>; 5489def : Pat<(int_ppc_fctid f64:$A), 5490 (FCTID $A)>; 5491def : Pat<(int_ppc_fctidz f64:$A), 5492 (XSCVDPSXDS $A)>; 5493def : Pat<(int_ppc_fctiw f64:$A), 5494 (FCTIW $A)>; 5495def : Pat<(int_ppc_fctiwz f64:$A), 5496 (XSCVDPSXWS $A)>; 5497def : Pat<(int_ppc_fctudz f64:$A), 5498 (XSCVDPUXDS $A)>; 5499def : Pat<(int_ppc_fctuwz f64:$A), 5500 (XSCVDPUXWS $A)>; 5501 5502def : Pat<(int_ppc_mfmsr), (MFMSR)>; 5503def : Pat<(int_ppc_mftbu), (MFTB 269)>; 5504def : Pat<(i32 (int_ppc_mfspr timm:$SPR)), 5505 (MFSPR $SPR)>; 5506def : Pat<(int_ppc_mtspr timm:$SPR, gprc:$RT), 5507 (MTSPR $SPR, $RT)>; 5508def : Pat<(int_ppc_mtmsr gprc:$RS), 5509 (MTMSR $RS, 0)>; 5510 5511let Predicates = [IsISA2_07] in { 5512 def : Pat<(int_ppc_sthcx ForceXForm:$dst, gprc:$A), 5513 (STHCX gprc:$A, ForceXForm:$dst)>; 5514} 5515def : Pat<(int_ppc_dcbtstt ForceXForm:$dst), 5516 (DCBTST 16, ForceXForm:$dst)>; 5517def : Pat<(int_ppc_dcbtt ForceXForm:$dst), 5518 (DCBT 16, ForceXForm:$dst)>; 5519 5520def : Pat<(int_ppc_stfiw ForceXForm:$dst, f64:$XT), 5521 (STFIWX f64:$XT, ForceXForm:$dst)>; 5522