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