1 //===-- PPCInstrInfo.td - The PowerPC Instruction Set ------*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file describes the subset of the 32-bit PowerPC instruction set, as used
10 // by the PowerPC instruction selector.
12 //===----------------------------------------------------------------------===//
14 include "PPCInstrFormats.td"
16 //===----------------------------------------------------------------------===//
17 // PowerPC specific type constraints.
19 def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx
20 SDTCisVT<0, f64>, SDTCisPtrTy<1>
22 def SDT_PPClfiwx : SDTypeProfile<1, 1, [ // lfiw[az]x
23 SDTCisVT<0, f64>, SDTCisPtrTy<1>
25 def SDT_PPCLxsizx : SDTypeProfile<1, 2, [
26 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
28 def SDT_PPCstxsix : SDTypeProfile<0, 3, [
29 SDTCisVT<0, f64>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
31 def SDT_PPCcv_fp_to_int : SDTypeProfile<1, 1, [
32 SDTCisFP<0>, SDTCisFP<1>
34 def SDT_PPCstore_scal_int_from_vsr : SDTypeProfile<0, 3, [
35 SDTCisFP<0>, SDTCisPtrTy<1>, SDTCisPtrTy<2>
37 def SDT_PPCVexts : SDTypeProfile<1, 2, [
38 SDTCisVT<0, f64>, SDTCisVT<1, f64>, SDTCisPtrTy<2>
41 def SDT_PPCCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
43 def SDT_PPCCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>,
45 def SDT_PPCvperm : SDTypeProfile<1, 3, [
46 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
49 def SDT_PPCVecSplat : SDTypeProfile<1, 2, [ SDTCisVec<0>,
50 SDTCisVec<1>, SDTCisInt<2>
53 def SDT_PPCSpToDp : SDTypeProfile<1, 1, [ SDTCisVT<0, v2f64>,
57 def SDT_PPCVecShift : SDTypeProfile<1, 3, [ SDTCisVec<0>,
58 SDTCisVec<1>, SDTCisVec<2>, SDTCisPtrTy<3>
61 def SDT_PPCVecInsert : SDTypeProfile<1, 3, [ SDTCisVec<0>,
62 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
65 def SDT_PPCxxpermdi: SDTypeProfile<1, 3, [ SDTCisVec<0>,
66 SDTCisVec<1>, SDTCisVec<2>, SDTCisInt<3>
69 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
70 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
73 def SDT_PPCcondbr : SDTypeProfile<0, 3, [
74 SDTCisVT<0, i32>, SDTCisVT<2, OtherVT>
77 def SDT_PPCFtsqrt : SDTypeProfile<1, 1, [
80 def SDT_PPClbrx : SDTypeProfile<1, 2, [
81 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
83 def SDT_PPCstbrx : SDTypeProfile<0, 3, [
84 SDTCisInt<0>, SDTCisPtrTy<1>, SDTCisVT<2, OtherVT>
86 def SDT_StoreCond : SDTypeProfile<0, 3, [
87 SDTCisPtrTy<0>, SDTCisInt<1>, SDTCisPtrTy<2>
90 def SDT_PPCTC_ret : SDTypeProfile<0, 2, [
91 SDTCisPtrTy<0>, SDTCisVT<1, i32>
94 def tocentry32 : Operand<iPTR> {
95 let MIOperandInfo = (ops i32imm:$imm);
98 def SDT_PPCqvfperm : SDTypeProfile<1, 3, [
99 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisVec<3>
101 def SDT_PPCqvgpci : SDTypeProfile<1, 1, [
102 SDTCisVec<0>, SDTCisInt<1>
104 def SDT_PPCqvaligni : SDTypeProfile<1, 3, [
105 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<3>
107 def SDT_PPCqvesplati : SDTypeProfile<1, 2, [
108 SDTCisVec<0>, SDTCisSameAs<0, 1>, SDTCisInt<2>
111 def SDT_PPCqbflt : SDTypeProfile<1, 1, [
112 SDTCisVec<0>, SDTCisVec<1>
115 def SDT_PPCqvlfsb : SDTypeProfile<1, 1, [
116 SDTCisVec<0>, SDTCisPtrTy<1>
119 def SDT_PPCextswsli : SDTypeProfile<1, 2, [ // extswsli
120 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>, SDTCisInt<2>
123 def SDT_PPCFPMinMax : SDTypeProfile<1, 2, [
124 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisFP<0>
127 //===----------------------------------------------------------------------===//
128 // PowerPC specific DAG Nodes.
131 def PPCfre : SDNode<"PPCISD::FRE", SDTFPUnaryOp, []>;
132 def PPCfrsqrte: SDNode<"PPCISD::FRSQRTE", SDTFPUnaryOp, []>;
133 def PPCfsqrt : SDNode<"PPCISD::FSQRT", SDTFPUnaryOp, []>;
134 def PPCftsqrt : SDNode<"PPCISD::FTSQRT", SDT_PPCFtsqrt,[]>;
136 def PPCfcfid : SDNode<"PPCISD::FCFID", SDTFPUnaryOp, []>;
137 def PPCfcfidu : SDNode<"PPCISD::FCFIDU", SDTFPUnaryOp, []>;
138 def PPCfcfids : SDNode<"PPCISD::FCFIDS", SDTFPRoundOp, []>;
139 def PPCfcfidus: SDNode<"PPCISD::FCFIDUS", SDTFPRoundOp, []>;
140 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
141 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
142 def PPCfctiduz: SDNode<"PPCISD::FCTIDUZ",SDTFPUnaryOp, []>;
143 def PPCfctiwuz: SDNode<"PPCISD::FCTIWUZ",SDTFPUnaryOp, []>;
145 def PPCstrict_fcfid : SDNode<"PPCISD::STRICT_FCFID",
146 SDTFPUnaryOp, [SDNPHasChain]>;
147 def PPCstrict_fcfidu : SDNode<"PPCISD::STRICT_FCFIDU",
148 SDTFPUnaryOp, [SDNPHasChain]>;
149 def PPCstrict_fcfids : SDNode<"PPCISD::STRICT_FCFIDS",
150 SDTFPRoundOp, [SDNPHasChain]>;
151 def PPCstrict_fcfidus : SDNode<"PPCISD::STRICT_FCFIDUS",
152 SDTFPRoundOp, [SDNPHasChain]>;
154 def PPCany_fcfid : PatFrags<(ops node:$op),
155 [(PPCfcfid node:$op),
156 (PPCstrict_fcfid node:$op)]>;
157 def PPCany_fcfidu : PatFrags<(ops node:$op),
158 [(PPCfcfidu node:$op),
159 (PPCstrict_fcfidu node:$op)]>;
160 def PPCany_fcfids : PatFrags<(ops node:$op),
161 [(PPCfcfids node:$op),
162 (PPCstrict_fcfids node:$op)]>;
163 def PPCany_fcfidus : PatFrags<(ops node:$op),
164 [(PPCfcfidus node:$op),
165 (PPCstrict_fcfidus node:$op)]>;
167 def PPCstore_scal_int_from_vsr:
168 SDNode<"PPCISD::ST_VSR_SCAL_INT", SDT_PPCstore_scal_int_from_vsr,
169 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
170 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx,
171 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
172 def PPClfiwax : SDNode<"PPCISD::LFIWAX", SDT_PPClfiwx,
173 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
174 def PPClfiwzx : SDNode<"PPCISD::LFIWZX", SDT_PPClfiwx,
175 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
176 def PPClxsizx : SDNode<"PPCISD::LXSIZX", SDT_PPCLxsizx,
177 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
178 def PPCstxsix : SDNode<"PPCISD::STXSIX", SDT_PPCstxsix,
179 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
180 def PPCVexts : SDNode<"PPCISD::VEXTS", SDT_PPCVexts, []>;
182 // Extract FPSCR (not modeled at the DAG level).
183 def PPCmffs : SDNode<"PPCISD::MFFS",
184 SDTypeProfile<1, 0, [SDTCisVT<0, f64>]>,
187 // Perform FADD in round-to-zero mode.
188 def PPCfaddrtz: SDNode<"PPCISD::FADDRTZ", SDTFPBinOp, []>;
189 def PPCstrict_faddrtz: SDNode<"PPCISD::STRICT_FADDRTZ", SDTFPBinOp,
192 def PPCany_faddrtz: PatFrags<(ops node:$lhs, node:$rhs),
193 [(PPCfaddrtz node:$lhs, node:$rhs),
194 (PPCstrict_faddrtz node:$lhs, node:$rhs)]>;
196 def PPCfsel : SDNode<"PPCISD::FSEL",
197 // Type constraint for fsel.
198 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
199 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
200 def PPCxsmaxc : SDNode<"PPCISD::XSMAXC", SDT_PPCFPMinMax, []>;
201 def PPCxsminc : SDNode<"PPCISD::XSMINC", SDT_PPCFPMinMax, []>;
202 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
203 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
204 def PPCtoc_entry: SDNode<"PPCISD::TOC_ENTRY", SDTIntBinOp,
205 [SDNPMayLoad, SDNPMemOperand]>;
207 def PPCppc32GOT : SDNode<"PPCISD::PPC32_GOT", SDTIntLeaf, []>;
209 def PPCaddisGotTprelHA : SDNode<"PPCISD::ADDIS_GOT_TPREL_HA", SDTIntBinOp>;
210 def PPCldGotTprelL : SDNode<"PPCISD::LD_GOT_TPREL_L", SDTIntBinOp,
212 def PPCaddTls : SDNode<"PPCISD::ADD_TLS", SDTIntBinOp, []>;
213 def PPCaddisTlsgdHA : SDNode<"PPCISD::ADDIS_TLSGD_HA", SDTIntBinOp>;
214 def PPCaddiTlsgdL : SDNode<"PPCISD::ADDI_TLSGD_L", SDTIntBinOp>;
215 def PPCgetTlsAddr : SDNode<"PPCISD::GET_TLS_ADDR", SDTIntBinOp>;
216 def PPCgetTlsMod : SDNode<"PPCISD::GET_TLS_MOD_AIX", SDTIntUnaryOp>;
217 def PPCgetTpointer : SDNode<"PPCISD::GET_TPOINTER", SDTIntLeaf, []>;
218 def PPCaddiTlsgdLAddr : SDNode<"PPCISD::ADDI_TLSGD_L_ADDR",
219 SDTypeProfile<1, 3, [
220 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
221 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
222 def PPCTlsgdAIX : SDNode<"PPCISD::TLSGD_AIX", SDTIntBinOp>;
223 def PPCTlsldAIX : SDNode<"PPCISD::TLSLD_AIX", SDTIntUnaryOp>;
224 def PPCaddisTlsldHA : SDNode<"PPCISD::ADDIS_TLSLD_HA", SDTIntBinOp>;
225 def PPCaddiTlsldL : SDNode<"PPCISD::ADDI_TLSLD_L", SDTIntBinOp>;
226 def PPCgetTlsldAddr : SDNode<"PPCISD::GET_TLSLD_ADDR", SDTIntBinOp>;
227 def PPCaddiTlsldLAddr : SDNode<"PPCISD::ADDI_TLSLD_L_ADDR",
228 SDTypeProfile<1, 3, [
229 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
230 SDTCisSameAs<0, 3>, SDTCisInt<0> ]>>;
231 def PPCaddisDtprelHA : SDNode<"PPCISD::ADDIS_DTPREL_HA", SDTIntBinOp>;
232 def PPCaddiDtprelL : SDNode<"PPCISD::ADDI_DTPREL_L", SDTIntBinOp>;
233 def PPCpaddiDtprel : SDNode<"PPCISD::PADDI_DTPREL", SDTIntBinOp>;
235 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
236 def PPCxxsplt : SDNode<"PPCISD::XXSPLT", SDT_PPCVecSplat, []>;
237 def PPCxxspltidp : SDNode<"PPCISD::XXSPLTI_SP_TO_DP", SDT_PPCSpToDp, []>;
238 def PPCvecinsert : SDNode<"PPCISD::VECINSERT", SDT_PPCVecInsert, []>;
239 def PPCxxpermdi : SDNode<"PPCISD::XXPERMDI", SDT_PPCxxpermdi, []>;
240 def PPCvecshl : SDNode<"PPCISD::VECSHL", SDT_PPCVecShift, []>;
242 def PPCcmpb : SDNode<"PPCISD::CMPB", SDTIntBinOp, []>;
244 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
245 // amounts. These nodes are generated by the multi-precision shift code.
246 def PPCsrl : SDNode<"PPCISD::SRL" , SDTIntShiftOp>;
247 def PPCsra : SDNode<"PPCISD::SRA" , SDTIntShiftOp>;
248 def PPCshl : SDNode<"PPCISD::SHL" , SDTIntShiftOp>;
250 def PPCfnmsub : SDNode<"PPCISD::FNMSUB" , SDTFPTernaryOp>;
252 def PPCextswsli : SDNode<"PPCISD::EXTSWSLI" , SDT_PPCextswsli>;
254 def PPCstrict_fctidz : SDNode<"PPCISD::STRICT_FCTIDZ",
255 SDTFPUnaryOp, [SDNPHasChain]>;
256 def PPCstrict_fctiwz : SDNode<"PPCISD::STRICT_FCTIWZ",
257 SDTFPUnaryOp, [SDNPHasChain]>;
258 def PPCstrict_fctiduz : SDNode<"PPCISD::STRICT_FCTIDUZ",
259 SDTFPUnaryOp, [SDNPHasChain]>;
260 def PPCstrict_fctiwuz : SDNode<"PPCISD::STRICT_FCTIWUZ",
261 SDTFPUnaryOp, [SDNPHasChain]>;
263 def PPCany_fctidz : PatFrags<(ops node:$op),
264 [(PPCstrict_fctidz node:$op),
265 (PPCfctidz node:$op)]>;
266 def PPCany_fctiwz : PatFrags<(ops node:$op),
267 [(PPCstrict_fctiwz node:$op),
268 (PPCfctiwz node:$op)]>;
269 def PPCany_fctiduz : PatFrags<(ops node:$op),
270 [(PPCstrict_fctiduz node:$op),
271 (PPCfctiduz node:$op)]>;
272 def PPCany_fctiwuz : PatFrags<(ops node:$op),
273 [(PPCstrict_fctiwuz node:$op),
274 (PPCfctiwuz node:$op)]>;
276 // Move 2 i64 values into a VSX register
277 def PPCbuild_fp128: SDNode<"PPCISD::BUILD_FP128",
279 [SDTCisFP<0>, SDTCisSameSizeAs<1,2>,
283 def PPCbuild_spe64: SDNode<"PPCISD::BUILD_SPE64",
285 [SDTCisVT<0, f64>, SDTCisVT<1,i32>,
289 def PPCextract_spe : SDNode<"PPCISD::EXTRACT_SPE",
291 [SDTCisVT<0, i32>, SDTCisVT<1, f64>,
295 // These are target-independent nodes, but have target-specific formats.
296 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeqStart,
297 [SDNPHasChain, SDNPOutGlue]>;
298 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeqEnd,
299 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
301 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisInt<0>]>;
302 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
303 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
305 def PPCcall_nop : SDNode<"PPCISD::CALL_NOP", SDT_PPCCall,
306 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
308 def PPCcall_notoc : SDNode<"PPCISD::CALL_NOTOC", SDT_PPCCall,
309 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
311 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
312 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
313 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTNone,
314 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
316 def PPCbctrl_load_toc : SDNode<"PPCISD::BCTRL_LOAD_TOC",
317 SDTypeProfile<0, 1, []>,
318 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
321 // Call nodes for strictfp calls (that define RM).
322 def PPCcall_rm : SDNode<"PPCISD::CALL_RM", SDT_PPCCall,
323 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
325 def PPCcall_nop_rm : SDNode<"PPCISD::CALL_NOP_RM", SDT_PPCCall,
326 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
328 def PPCcall_notoc_rm : SDNode<"PPCISD::CALL_NOTOC_RM", SDT_PPCCall,
329 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
331 def PPCbctrl_rm : SDNode<"PPCISD::BCTRL_RM", SDTNone,
332 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
334 def PPCbctrl_load_toc_rm : SDNode<"PPCISD::BCTRL_LOAD_TOC_RM",
335 SDTypeProfile<0, 1, []>,
336 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
339 def PPCretglue : SDNode<"PPCISD::RET_GLUE", SDTNone,
340 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
342 def PPCtc_return : SDNode<"PPCISD::TC_RETURN", SDT_PPCTC_ret,
343 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
345 def PPCeh_sjlj_setjmp : SDNode<"PPCISD::EH_SJLJ_SETJMP",
346 SDTypeProfile<1, 1, [SDTCisInt<0>,
348 [SDNPHasChain, SDNPSideEffect]>;
349 def PPCeh_sjlj_longjmp : SDNode<"PPCISD::EH_SJLJ_LONGJMP",
350 SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>,
351 [SDNPHasChain, SDNPSideEffect]>;
353 def SDT_PPCsc : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
354 def PPCsc : SDNode<"PPCISD::SC", SDT_PPCsc,
355 [SDNPHasChain, SDNPSideEffect]>;
357 def PPCclrbhrb : SDNode<"PPCISD::CLRBHRB", SDTNone,
358 [SDNPHasChain, SDNPSideEffect]>;
359 def PPCmfbhrbe : SDNode<"PPCISD::MFBHRBE", SDTIntBinOp, [SDNPHasChain]>;
360 def PPCrfebb : SDNode<"PPCISD::RFEBB", SDT_PPCsc,
361 [SDNPHasChain, SDNPSideEffect]>;
363 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
364 def PPCvcmp_rec : SDNode<"PPCISD::VCMP_rec", SDT_PPCvcmp, [SDNPOutGlue]>;
366 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
367 [SDNPHasChain, SDNPOptInGlue]>;
369 // PPC-specific atomic operations.
370 def PPCatomicCmpSwap_8 :
371 SDNode<"PPCISD::ATOMIC_CMP_SWAP_8", SDTAtomic3,
372 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
373 def PPCatomicCmpSwap_16 :
374 SDNode<"PPCISD::ATOMIC_CMP_SWAP_16", SDTAtomic3,
375 [SDNPHasChain, SDNPMayStore, SDNPMayLoad, SDNPMemOperand]>;
376 def PPClbrx : SDNode<"PPCISD::LBRX", SDT_PPClbrx,
377 [SDNPHasChain, SDNPMayLoad, SDNPMemOperand]>;
378 def PPCstbrx : SDNode<"PPCISD::STBRX", SDT_PPCstbrx,
379 [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
380 def PPCStoreCond : SDNode<"PPCISD::STORE_COND", SDT_StoreCond,
381 [SDNPHasChain, SDNPMayStore,
382 SDNPMemOperand, SDNPOutGlue]>;
384 // Instructions to set/unset CR bit 6 for SVR4 vararg calls
385 def PPCcr6set : SDNode<"PPCISD::CR6SET", SDTNone,
386 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
387 def PPCcr6unset : SDNode<"PPCISD::CR6UNSET", SDTNone,
388 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
390 // Instructions to support dynamic alloca.
391 def SDTDynOp : SDTypeProfile<1, 2, []>;
392 def SDTDynAreaOp : SDTypeProfile<1, 1, []>;
393 def PPCdynalloc : SDNode<"PPCISD::DYNALLOC", SDTDynOp, [SDNPHasChain]>;
394 def PPCdynareaoffset : SDNode<"PPCISD::DYNAREAOFFSET", SDTDynAreaOp, [SDNPHasChain]>;
395 def PPCprobedalloca : SDNode<"PPCISD::PROBED_ALLOCA", SDTDynOp, [SDNPHasChain]>;
397 // PC Relative Specific Nodes
398 def PPCmatpcreladdr : SDNode<"PPCISD::MAT_PCREL_ADDR", SDTIntUnaryOp, []>;
399 def PPCtlsdynamatpcreladdr : SDNode<"PPCISD::TLS_DYNAMIC_MAT_PCREL_ADDR",
401 def PPCtlslocalexecmataddr : SDNode<"PPCISD::TLS_LOCAL_EXEC_MAT_ADDR",
404 //===----------------------------------------------------------------------===//
405 // PowerPC specific transformation functions and pattern fragments.
408 // A floating point immediate that is not a positive zero and can be converted
409 // to a single precision floating point non-denormal immediate without loss of
411 def nzFPImmAsi32 : PatLeaf<(fpimm), [{
412 APFloat APFloatOfN = N->getValueAPF();
413 return convertToNonDenormSingle(APFloatOfN) && !N->isExactlyValue(+0.0);
416 // A floating point immediate that is exactly an integer (for example 3.0, -5.0)
417 // and can be represented in 5 bits (range of [-16, 15]).
418 def nzFPImmExactInti5 : PatLeaf<(fpimm), [{
419 APFloat FloatValue = N->getValueAPF();
421 APSInt IntResult(16, false);
422 FloatValue.convertToInteger(IntResult, APFloat::rmTowardZero, &IsExact);
423 return IsExact && IntResult <= 15 && IntResult >= -16 && !FloatValue.isZero();
426 def getFPAs5BitExactInt : SDNodeXForm<fpimm, [{
427 APFloat FloatValue = N->getValueAPF();
429 APSInt IntResult(32, false);
430 FloatValue.convertToInteger(IntResult, APFloat::rmTowardZero, &IsExact);
431 return CurDAG->getTargetConstant(IntResult, SDLoc(N), MVT::i32);
434 // Convert the floating point immediate into a 32 bit floating point immediate
435 // and get a i32 with the resulting bits.
436 def getFPAs32BitInt : SDNodeXForm<fpimm, [{
437 APFloat APFloatOfN = N->getValueAPF();
438 convertToNonDenormSingle(APFloatOfN);
439 return CurDAG->getTargetConstant(APFloatOfN.bitcastToAPInt().getZExtValue(),
443 // Check if the value can be converted to be single precision immediate, which
444 // can be exploited by XXSPLTIDP. Ensure that it cannot be converted to single
445 // precision before exploiting with XXSPLTI32DX.
446 def nzFPImmAsi64 : PatLeaf<(fpimm), [{
447 APFloat APFloatOfN = N->getValueAPF();
448 return !N->isExactlyValue(+0.0) && !checkConvertToNonDenormSingle(APFloatOfN);
451 // Get the Hi bits of a 64 bit immediate.
452 def getFPAs64BitIntHi : SDNodeXForm<fpimm, [{
453 APFloat APFloatOfN = N->getValueAPF();
455 APFloatOfN.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
457 uint32_t Hi = (uint32_t)((APFloatOfN.bitcastToAPInt().getZExtValue() &
458 0xFFFFFFFF00000000LL) >> 32);
459 return CurDAG->getTargetConstant(Hi, SDLoc(N), MVT::i32);
462 // Get the Lo bits of a 64 bit immediate.
463 def getFPAs64BitIntLo : SDNodeXForm<fpimm, [{
464 APFloat APFloatOfN = N->getValueAPF();
466 APFloatOfN.convert(APFloat::IEEEdouble(), APFloat::rmNearestTiesToEven,
468 uint32_t Lo = (uint32_t)(APFloatOfN.bitcastToAPInt().getZExtValue() &
470 return CurDAG->getTargetConstant(Lo, SDLoc(N), MVT::i32);
473 def imm34 : PatLeaf<(imm), [{
474 return isInt<34>(N->getSExtValue());
477 def getImmAs64BitInt : SDNodeXForm<imm, [{
478 return getI64Imm(N->getSExtValue(), SDLoc(N));
481 def SHL32 : SDNodeXForm<imm, [{
482 // Transformation function: 31 - imm
483 return getI32Imm(31 - N->getZExtValue(), SDLoc(N));
486 def SRL32 : SDNodeXForm<imm, [{
487 // Transformation function: 32 - imm
488 return N->getZExtValue() ? getI32Imm(32 - N->getZExtValue(), SDLoc(N))
489 : getI32Imm(0, SDLoc(N));
492 def LO16 : SDNodeXForm<imm, [{
493 // Transformation function: get the low 16 bits.
494 return getI32Imm((unsigned short)N->getZExtValue(), SDLoc(N));
497 def HI16 : SDNodeXForm<imm, [{
498 // Transformation function: shift the immediate value down into the low bits.
499 return getI32Imm((unsigned)N->getZExtValue() >> 16, SDLoc(N));
502 def HA16 : SDNodeXForm<imm, [{
503 // Transformation function: shift the immediate value down into the low bits.
504 int64_t Val = N->getZExtValue();
505 return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
507 def MB : SDNodeXForm<imm, [{
508 // Transformation function: get the start bit of a mask
510 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
511 return getI32Imm(mb, SDLoc(N));
514 def ME : SDNodeXForm<imm, [{
515 // Transformation function: get the end bit of a mask
517 (void)isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
518 return getI32Imm(me, SDLoc(N));
520 def maskimm32 : PatLeaf<(imm), [{
521 // maskImm predicate - True if immediate is a run of ones.
523 if (N->getValueType(0) == MVT::i32)
524 return isRunOfOnes((unsigned)N->getZExtValue(), mb, me);
529 def imm32SExt16 : Operand<i32>, ImmLeaf<i32, [{
530 // imm32SExt16 predicate - True if the i32 immediate fits in a 16-bit
531 // sign extended field. Used by instructions like 'addi'.
532 return (int32_t)Imm == (short)Imm;
534 def imm64SExt16 : Operand<i64>, ImmLeaf<i64, [{
535 // imm64SExt16 predicate - True if the i64 immediate fits in a 16-bit
536 // sign extended field. Used by instructions like 'addi'.
537 return (int64_t)Imm == (short)Imm;
539 def immZExt16 : PatLeaf<(imm), [{
540 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
541 // field. Used by instructions like 'ori'.
542 return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue();
544 def immNonAllOneAnyExt8 : ImmLeaf<i32, [{
545 return (isInt<8>(Imm) && (Imm != -1)) || (isUInt<8>(Imm) && (Imm != 0xFF));
547 def i32immNonAllOneNonZero : ImmLeaf<i32, [{ return Imm && (Imm != -1); }]>;
548 def immSExt5NonZero : ImmLeaf<i32, [{ return Imm && isInt<5>(Imm); }]>;
550 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
551 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
552 // identical in 32-bit mode, but in 64-bit mode, they return true if the
553 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
555 def imm16ShiftedZExt : PatLeaf<(imm), [{
556 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
557 // immediate are set. Used by instructions like 'xoris'.
558 return (N->getZExtValue() & ~uint64_t(0xFFFF0000)) == 0;
561 def imm16ShiftedSExt : PatLeaf<(imm), [{
562 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
563 // immediate are set. Used by instructions like 'addis'. Identical to
564 // imm16ShiftedZExt in 32-bit mode.
565 if (N->getZExtValue() & 0xFFFF) return false;
566 if (N->getValueType(0) == MVT::i32)
568 // For 64-bit, make sure it is sext right.
569 return N->getZExtValue() == (uint64_t)(int)N->getZExtValue();
572 def imm64ZExt32 : Operand<i64>, ImmLeaf<i64, [{
573 // imm64ZExt32 predicate - True if the i64 immediate fits in a 32-bit
574 // zero extended field.
575 return isUInt<32>(Imm);
578 // This is a somewhat weaker condition than actually checking for 4-byte
579 // alignment. It is simply checking that the displacement can be represented
580 // as an immediate that is a multiple of 4 (i.e. the requirements for DS-Form
582 // But some r+i load/store instructions (such as LD, STD, LDU, etc.) that require
583 // restricted memrix (4-aligned) constants are alignment sensitive. If these
584 // offsets are hidden behind TOC entries than the values of the lower-order
585 // bits cannot be checked directly. As a result, we need to also incorporate
586 // an alignment check into the relevant patterns.
588 def DSFormLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
589 return isOffsetMultipleOf(N, 4) || cast<LoadSDNode>(N)->getAlign() >= 4;
591 def DSFormStore : PatFrag<(ops node:$val, node:$ptr),
592 (store node:$val, node:$ptr), [{
593 return isOffsetMultipleOf(N, 4) || cast<StoreSDNode>(N)->getAlign() >= 4;
595 def DSFormSextLoadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
596 return isOffsetMultipleOf(N, 4) || cast<LoadSDNode>(N)->getAlign() >= 4;
598 def DSFormPreStore : PatFrag<
599 (ops node:$val, node:$base, node:$offset),
600 (pre_store node:$val, node:$base, node:$offset), [{
601 return isOffsetMultipleOf(N, 4) || cast<StoreSDNode>(N)->getAlign() >= 4;
604 def NonDSFormLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
605 return cast<LoadSDNode>(N)->getAlign() < 4 && !isOffsetMultipleOf(N, 4);
607 def NonDSFormStore : PatFrag<(ops node:$val, node:$ptr),
608 (store node:$val, node:$ptr), [{
609 return cast<StoreSDNode>(N)->getAlign() < 4 && !isOffsetMultipleOf(N, 4);
611 def NonDSFormSextLoadi32 : PatFrag<(ops node:$ptr), (sextloadi32 node:$ptr), [{
612 return cast<LoadSDNode>(N)->getAlign() < 4 && !isOffsetMultipleOf(N, 4);
615 // This is a somewhat weaker condition than actually checking for 16-byte
616 // alignment. It is simply checking that the displacement can be represented
617 // as an immediate that is a multiple of 16 (i.e. the requirements for DQ-Form
619 def quadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
620 return isOffsetMultipleOf(N, 16);
622 def quadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
623 (store node:$val, node:$ptr), [{
624 return isOffsetMultipleOf(N, 16);
626 def nonQuadwOffsetLoad : PatFrag<(ops node:$ptr), (load node:$ptr), [{
627 return !isOffsetMultipleOf(N, 16);
629 def nonQuadwOffsetStore : PatFrag<(ops node:$val, node:$ptr),
630 (store node:$val, node:$ptr), [{
631 return !isOffsetMultipleOf(N, 16);
634 // PatFrag for binary operation whose operands are both non-constant
635 class BinOpWithoutSImm16Operand<SDNode opcode> :
636 PatFrag<(ops node:$left, node:$right), (opcode node:$left, node:$right), [{
638 return !isIntS16Immediate(N->getOperand(0), Imm)
639 && !isIntS16Immediate(N->getOperand(1), Imm);
642 def add_without_simm16 : BinOpWithoutSImm16Operand<add>;
643 def mul_without_simm16 : BinOpWithoutSImm16Operand<mul>;
645 //===----------------------------------------------------------------------===//
646 // PowerPC Flag Definitions.
648 class isPPC64 { bit PPC64 = 1; }
649 class isRecordForm { bit RC = 1; }
651 class RegConstraint<string C> {
652 string Constraints = C;
654 class NoEncode<string E> {
655 string DisableEncoding = E;
659 // Define PowerPC specific addressing mode.
662 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", [], []>; // "stb"
664 def iaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrImmX4", [], []>; // "std"
666 def iaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrImmX16", [], []>; // "stxv"
668 def iaddrX34 : ComplexPattern<iPTR, 2, "SelectAddrImmX34", [], []>; // "pstxvp"
670 // Below forms are all x-form addressing mode, use three different ones so we
671 // can make a accurate check for x-form instructions in ISEL.
672 // x-form addressing mode whose associated displacement form is D.
673 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", [], []>; // "stbx"
674 // x-form addressing mode whose associated displacement form is DS.
675 def xaddrX4 : ComplexPattern<iPTR, 2, "SelectAddrIdxX4", [], []>; // "stdx"
676 // x-form addressing mode whose associated displacement form is DQ.
677 def xaddrX16 : ComplexPattern<iPTR, 2, "SelectAddrIdxX16", [], []>; // "stxvx"
679 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[], []>;
681 // The address in a single register. This is used with the SjLj
682 // pseudo-instructions.
683 def addr : ComplexPattern<iPTR, 1, "SelectAddr",[], []>;
685 /// This is just the offset part of iaddr, used for preinc.
686 def iaddroff : ComplexPattern<iPTR, 1, "SelectAddrImmOffs", [], []>;
688 // Load and Store Instruction Selection addressing modes.
689 let WantsParent = true in {
690 def DForm : ComplexPattern<iPTR, 2, "SelectDForm">;
691 def DSForm : ComplexPattern<iPTR, 2, "SelectDSForm">;
692 def DQForm : ComplexPattern<iPTR, 2, "SelectDQForm">;
693 def XForm : ComplexPattern<iPTR, 2, "SelectXForm">;
694 def ForceXForm : ComplexPattern<iPTR, 2, "SelectForceXForm">;
695 def PCRelForm : ComplexPattern<iPTR, 2, "SelectPCRelForm">;
696 def PDForm : ComplexPattern<iPTR, 2, "SelectPDForm">;
699 //===----------------------------------------------------------------------===//
700 // PowerPC Instruction Predicate Definitions.
701 def In32BitMode : Predicate<"!Subtarget->isPPC64()">;
702 def In64BitMode : Predicate<"Subtarget->isPPC64()">;
703 def IsBookE : Predicate<"Subtarget->isBookE()">;
704 def IsNotBookE : Predicate<"!Subtarget->isBookE()">;
705 def HasOnlyMSYNC : Predicate<"Subtarget->hasOnlyMSYNC()">;
706 def HasSYNC : Predicate<"!Subtarget->hasOnlyMSYNC()">;
707 def IsPPC4xx : Predicate<"Subtarget->isPPC4xx()">;
708 def IsPPC6xx : Predicate<"Subtarget->isPPC6xx()">;
709 def IsE500 : Predicate<"Subtarget->isE500()">;
710 def HasSPE : Predicate<"Subtarget->hasSPE()">;
711 def HasICBT : Predicate<"Subtarget->hasICBT()">;
712 def HasPartwordAtomics : Predicate<"Subtarget->hasPartwordAtomics()">;
713 def HasQuadwordAtomics : Predicate<"Subtarget->hasQuadwordAtomics()">;
715 : Predicate<"Subtarget->getTargetMachine().Options.NoNaNsFPMath">;
717 : Predicate<"!Subtarget->getTargetMachine().Options.NoNaNsFPMath">;
718 def HasBPERMD : Predicate<"Subtarget->hasBPERMD()">;
719 def HasExtDiv : Predicate<"Subtarget->hasExtDiv()">;
720 def IsISA2_06 : Predicate<"Subtarget->isISA2_06()">;
721 def IsISA2_07 : Predicate<"Subtarget->isISA2_07()">;
722 def IsISA3_0 : Predicate<"Subtarget->isISA3_0()">;
723 def HasFPU : Predicate<"Subtarget->hasFPU()">;
724 def PCRelativeMemops : Predicate<"Subtarget->hasPCRelativeMemops()">;
725 def IsNotISA3_1 : Predicate<"!Subtarget->isISA3_1()">;
727 // AIX assembler may not be modern enough to support some extended mne.
728 def ModernAs: Predicate<"!Subtarget->isAIXABI() || Subtarget->HasModernAIXAs">,
729 AssemblerPredicate<(any_of (not AIXOS), FeatureModernAIXAs)>;
730 def IsAIX : Predicate<"Subtarget->isAIXABI()">;
731 def NotAIX : Predicate<"!Subtarget->isAIXABI()">;
732 def IsISAFuture : Predicate<"Subtarget->isISAFuture()">;
733 def IsNotISAFuture : Predicate<"!Subtarget->isISAFuture()">;
735 //===----------------------------------------------------------------------===//
736 // PowerPC Multiclass Definitions.
737 multiclass XForm_base_r3xo_r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
738 string asmbase, string asmstr, list<dag> pattern> {
739 let BaseName = asmbase in {
740 def NAME : XForm_base_r3xo<opcode, xo, OOL, IOL,
741 !strconcat(asmbase, !strconcat(" ", asmstr)),
742 NoItinerary, pattern>, RecFormRel;
744 def _rec : XForm_base_r3xo<opcode, xo, OOL, IOL,
745 !strconcat(asmbase, !strconcat(". ", asmstr)),
746 NoItinerary, []>, isRecordForm, RecFormRel;
750 multiclass XForm_6r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
751 string asmbase, string asmstr, InstrItinClass itin,
753 let BaseName = asmbase in {
754 def NAME : XForm_6<opcode, xo, OOL, IOL,
755 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
756 pattern>, RecFormRel;
758 def _rec : XForm_6<opcode, xo, OOL, IOL,
759 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
760 []>, isRecordForm, RecFormRel;
764 multiclass XForm_6rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
765 string asmbase, string asmstr, InstrItinClass itin,
767 let BaseName = asmbase in {
768 let Defs = [CARRY] in
769 def NAME : XForm_6<opcode, xo, OOL, IOL,
770 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
771 pattern>, RecFormRel;
772 let Defs = [CARRY, CR0] in
773 def _rec : XForm_6<opcode, xo, OOL, IOL,
774 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
775 []>, isRecordForm, RecFormRel;
779 multiclass XForm_10rc<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
780 string asmbase, string asmstr, InstrItinClass itin,
782 let BaseName = asmbase in {
783 let Defs = [CARRY] in
784 def NAME : XForm_10<opcode, xo, OOL, IOL,
785 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
786 pattern>, RecFormRel;
787 let Defs = [CARRY, CR0] in
788 def _rec : XForm_10<opcode, xo, OOL, IOL,
789 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
790 []>, isRecordForm, RecFormRel;
794 multiclass XForm_11r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
795 string asmbase, string asmstr, InstrItinClass itin,
797 let BaseName = asmbase in {
798 def NAME : XForm_11<opcode, xo, OOL, IOL,
799 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
800 pattern>, RecFormRel;
802 def _rec : XForm_11<opcode, xo, OOL, IOL,
803 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
804 []>, isRecordForm, RecFormRel;
808 multiclass XOForm_1r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
809 string asmbase, string asmstr, InstrItinClass itin,
811 let BaseName = asmbase in {
812 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
813 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
814 pattern>, RecFormRel;
816 def _rec : XOForm_1<opcode, xo, oe, OOL, IOL,
817 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
818 []>, isRecordForm, RecFormRel;
822 // Multiclass for instructions which have a record overflow form as well
823 // as a record form but no carry (i.e. mulld, mulldo, subf, subfo, etc.)
824 multiclass XOForm_1rx<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
825 string asmbase, string asmstr, InstrItinClass itin,
827 let BaseName = asmbase in {
828 def NAME : XOForm_1<opcode, xo, 0, OOL, IOL,
829 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
830 pattern>, RecFormRel;
832 def _rec : XOForm_1<opcode, xo, 0, OOL, IOL,
833 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
834 []>, isRecordForm, RecFormRel;
836 let BaseName = !strconcat(asmbase, "O") in {
838 def O : XOForm_1<opcode, xo, 1, OOL, IOL,
839 !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
841 let Defs = [XER, CR0] in
842 def O_rec : XOForm_1<opcode, xo, 1, OOL, IOL,
843 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
844 []>, isRecordForm, RecFormRel;
848 // Multiclass for instructions for which the non record form is not cracked
849 // and the record form is cracked (i.e. divw, mullw, etc.)
850 multiclass XOForm_1rcr<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
851 string asmbase, string asmstr, InstrItinClass itin,
853 let BaseName = asmbase in {
854 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
855 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
856 pattern>, RecFormRel;
858 def _rec : XOForm_1<opcode, xo, oe, OOL, IOL,
859 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
860 []>, isRecordForm, RecFormRel, PPC970_DGroup_First,
861 PPC970_DGroup_Cracked;
863 let BaseName = !strconcat(asmbase, "O") in {
865 def O : XOForm_1<opcode, xo, 1, OOL, IOL,
866 !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
868 let Defs = [XER, CR0] in
869 def O_rec : XOForm_1<opcode, xo, 1, OOL, IOL,
870 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
871 []>, isRecordForm, RecFormRel;
875 multiclass XOForm_1rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
876 string asmbase, string asmstr, InstrItinClass itin,
878 let BaseName = asmbase in {
879 let Defs = [CARRY] in
880 def NAME : XOForm_1<opcode, xo, oe, OOL, IOL,
881 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
882 pattern>, RecFormRel;
883 let Defs = [CARRY, CR0] in
884 def _rec : XOForm_1<opcode, xo, oe, OOL, IOL,
885 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
886 []>, isRecordForm, RecFormRel;
888 let BaseName = !strconcat(asmbase, "O") in {
889 let Defs = [CARRY, XER] in
890 def O : XOForm_1<opcode, xo, 1, OOL, IOL,
891 !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
893 let Defs = [CARRY, XER, CR0] in
894 def O_rec : XOForm_1<opcode, xo, 1, OOL, IOL,
895 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
896 []>, isRecordForm, RecFormRel;
900 multiclass XOForm_3r<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
901 string asmbase, string asmstr, InstrItinClass itin,
903 let BaseName = asmbase in {
904 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
905 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
906 pattern>, RecFormRel;
908 def _rec : XOForm_3<opcode, xo, oe, OOL, IOL,
909 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
910 []>, isRecordForm, RecFormRel;
912 let BaseName = !strconcat(asmbase, "O") in {
914 def O : XOForm_3<opcode, xo, 1, OOL, IOL,
915 !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
917 let Defs = [XER, CR0] in
918 def O_rec : XOForm_3<opcode, xo, 1, OOL, IOL,
919 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
920 []>, isRecordForm, RecFormRel;
924 multiclass XOForm_3rc<bits<6> opcode, bits<9> xo, bit oe, dag OOL, dag IOL,
925 string asmbase, string asmstr, InstrItinClass itin,
927 let BaseName = asmbase in {
928 let Defs = [CARRY] in
929 def NAME : XOForm_3<opcode, xo, oe, OOL, IOL,
930 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
931 pattern>, RecFormRel;
932 let Defs = [CARRY, CR0] in
933 def _rec : XOForm_3<opcode, xo, oe, OOL, IOL,
934 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
935 []>, isRecordForm, RecFormRel;
937 let BaseName = !strconcat(asmbase, "O") in {
938 let Defs = [CARRY, XER] in
939 def O : XOForm_3<opcode, xo, 1, OOL, IOL,
940 !strconcat(asmbase, !strconcat("o ", asmstr)), itin,
942 let Defs = [CARRY, XER, CR0] in
943 def O_rec : XOForm_3<opcode, xo, 1, OOL, IOL,
944 !strconcat(asmbase, !strconcat("o. ", asmstr)), itin,
945 []>, isRecordForm, RecFormRel;
949 multiclass MForm_1r<bits<6> opcode, dag OOL, dag IOL,
950 string asmbase, string asmstr, InstrItinClass itin,
952 let BaseName = asmbase in {
953 def NAME : MForm_1<opcode, OOL, IOL,
954 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
955 pattern>, RecFormRel;
957 def _rec : MForm_1<opcode, OOL, IOL,
958 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
959 []>, isRecordForm, RecFormRel;
963 multiclass MForm_2r<bits<6> opcode, dag OOL, dag IOL,
964 string asmbase, string asmstr, InstrItinClass itin,
966 let BaseName = asmbase in {
967 def NAME : MForm_2<opcode, OOL, IOL,
968 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
969 pattern>, RecFormRel;
971 def _rec : MForm_2<opcode, OOL, IOL,
972 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
973 []>, isRecordForm, RecFormRel;
977 multiclass MDForm_1r<bits<6> opcode, bits<3> xo, dag OOL, dag IOL,
978 string asmbase, string asmstr, InstrItinClass itin,
980 let BaseName = asmbase in {
981 def NAME : MDForm_1<opcode, xo, OOL, IOL,
982 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
983 pattern>, RecFormRel;
985 def _rec : MDForm_1<opcode, xo, OOL, IOL,
986 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
987 []>, isRecordForm, RecFormRel;
991 multiclass MDSForm_1r<bits<6> opcode, bits<4> xo, dag OOL, dag IOL,
992 string asmbase, string asmstr, InstrItinClass itin,
994 let BaseName = asmbase in {
995 def NAME : MDSForm_1<opcode, xo, OOL, IOL,
996 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
997 pattern>, RecFormRel;
999 def _rec : MDSForm_1<opcode, xo, OOL, IOL,
1000 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1001 []>, isRecordForm, RecFormRel;
1005 multiclass XSForm_1rc<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1006 string asmbase, string asmstr, InstrItinClass itin,
1007 list<dag> pattern> {
1008 let BaseName = asmbase in {
1009 let Defs = [CARRY] in
1010 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1011 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1012 pattern>, RecFormRel;
1013 let Defs = [CARRY, CR0] in
1014 def _rec : XSForm_1<opcode, xo, OOL, IOL,
1015 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1016 []>, isRecordForm, RecFormRel;
1020 multiclass XSForm_1r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1021 string asmbase, string asmstr, InstrItinClass itin,
1022 list<dag> pattern> {
1023 let BaseName = asmbase in {
1024 def NAME : XSForm_1<opcode, xo, OOL, IOL,
1025 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1026 pattern>, RecFormRel;
1028 def _rec : XSForm_1<opcode, xo, OOL, IOL,
1029 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1030 []>, isRecordForm, RecFormRel;
1034 multiclass XForm_26r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1035 string asmbase, string asmstr, InstrItinClass itin,
1036 list<dag> pattern> {
1037 let BaseName = asmbase in {
1038 def NAME : XForm_26<opcode, xo, OOL, IOL,
1039 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1040 pattern>, RecFormRel;
1042 def _rec : XForm_26<opcode, xo, OOL, IOL,
1043 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1044 []>, isRecordForm, RecFormRel;
1048 multiclass XForm_28r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1049 string asmbase, string asmstr, InstrItinClass itin,
1050 list<dag> pattern> {
1051 let BaseName = asmbase in {
1052 def NAME : XForm_28<opcode, xo, OOL, IOL,
1053 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1054 pattern>, RecFormRel;
1056 def _rec : XForm_28<opcode, xo, OOL, IOL,
1057 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1058 []>, isRecordForm, RecFormRel;
1062 multiclass XForm_SP2_FRTB5r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1063 string asmbase, string asmstr, list<dag> pattern> {
1064 let BaseName = asmbase in {
1065 def NAME : XForm_SP2_FRTB5<opcode, xo, OOL, IOL,
1066 !strconcat(asmbase, !strconcat(" ", asmstr)),
1067 pattern, NoItinerary>, RecFormRel;
1069 def _rec : XForm_SP2_FRTB5<opcode, xo, OOL, IOL,
1070 !strconcat(asmbase, !strconcat(". ", asmstr)),
1071 [], NoItinerary>, isRecordForm, RecFormRel;
1075 multiclass XForm_S1_FRTB5r<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
1076 string asmbase, string asmstr, list<dag> pattern> {
1077 let BaseName = asmbase in {
1078 def NAME : XForm_S1_FRTB5<opcode, xo, OOL, IOL,
1079 !strconcat(asmbase, !strconcat(" ", asmstr)),
1080 pattern, NoItinerary>, RecFormRel;
1082 def _rec : XForm_S1_FRTB5<opcode, xo, OOL, IOL,
1083 !strconcat(asmbase, !strconcat(". ", asmstr)), [],
1084 NoItinerary>, isRecordForm, RecFormRel;
1088 multiclass AForm_1r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1089 string asmbase, string asmstr, InstrItinClass itin,
1090 list<dag> pattern> {
1091 let BaseName = asmbase in {
1092 def NAME : AForm_1<opcode, xo, OOL, IOL,
1093 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1094 pattern>, RecFormRel;
1096 def _rec : AForm_1<opcode, xo, OOL, IOL,
1097 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1098 []>, isRecordForm, RecFormRel;
1102 multiclass AForm_2r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1103 string asmbase, string asmstr, InstrItinClass itin,
1104 list<dag> pattern> {
1105 let BaseName = asmbase in {
1106 def NAME : AForm_2<opcode, xo, OOL, IOL,
1107 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1108 pattern>, RecFormRel;
1110 def _rec : AForm_2<opcode, xo, OOL, IOL,
1111 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1112 []>, isRecordForm, RecFormRel;
1116 multiclass AForm_3r<bits<6> opcode, bits<5> xo, dag OOL, dag IOL,
1117 string asmbase, string asmstr, InstrItinClass itin,
1118 list<dag> pattern> {
1119 let BaseName = asmbase in {
1120 def NAME : AForm_3<opcode, xo, OOL, IOL,
1121 !strconcat(asmbase, !strconcat(" ", asmstr)), itin,
1122 pattern>, RecFormRel;
1124 def _rec : AForm_3<opcode, xo, OOL, IOL,
1125 !strconcat(asmbase, !strconcat(". ", asmstr)), itin,
1126 []>, isRecordForm, RecFormRel;
1131 Z23Form_TE5_FRTB5_RMC2r<bits<6> opcode, bits<8> xo, dag OOL, dag IOL,
1132 string asmbase, string asmstr, list<dag> pattern> {
1133 let BaseName = asmbase in {
1135 : Z23Form_TE5_FRTB5_RMC2<opcode, xo, OOL, IOL,
1136 !strconcat(asmbase, !strconcat(" ", asmstr)),
1137 pattern>, RecFormRel;
1139 def _rec : Z23Form_TE5_FRTB5_RMC2<opcode, xo, OOL, IOL,
1140 !strconcat(asmbase, !strconcat(". ", asmstr)),
1141 []>, isRecordForm, RecFormRel;
1146 Z23Form_FRTAB5_RMC2r<bits<6> opcode, bits<8> xo, dag OOL, dag IOL,
1147 string asmbase, string asmstr, list<dag> pattern> {
1148 let BaseName = asmbase in {
1149 def NAME : Z23Form_FRTAB5_RMC2<opcode, xo, OOL, IOL,
1150 !strconcat(asmbase, !strconcat(" ", asmstr)),
1151 pattern>, RecFormRel;
1153 def _rec : Z23Form_FRTAB5_RMC2<opcode, xo, OOL, IOL,
1154 !strconcat(asmbase, !strconcat(". ", asmstr)),
1155 []>, isRecordForm, RecFormRel;
1160 Z23Form_FRTB5_R1_RMC2r<bits<6> opcode, bits<8> xo, dag OOL, dag IOL,
1161 string asmbase, string asmstr, list<dag> pattern> {
1162 let BaseName = asmbase in {
1163 def NAME : Z23Form_FRTB5_R1_RMC2<opcode, xo, OOL, IOL,
1164 !strconcat(asmbase, !strconcat(" ", asmstr)),
1165 pattern>, RecFormRel;
1167 def _rec : Z23Form_FRTB5_R1_RMC2<opcode, xo, OOL, IOL,
1168 !strconcat(asmbase, !strconcat(". ", asmstr)),
1169 []>, isRecordForm, RecFormRel;
1173 multiclass Z22Form_FRTA5_SH6r<bits<6> opcode, bits<9> xo, dag OOL, dag IOL,
1174 string asmbase, string asmstr, list<dag> pattern> {
1175 let BaseName = asmbase in {
1176 def NAME : Z22Form_FRTA5_SH6<opcode, xo, OOL, IOL,
1177 !strconcat(asmbase, !strconcat(" ", asmstr)),
1178 pattern, NoItinerary>, RecFormRel;
1180 def _rec : Z22Form_FRTA5_SH6<opcode, xo, OOL, IOL,
1181 !strconcat(asmbase, !strconcat(". ", asmstr)),
1182 [], NoItinerary>, isRecordForm, RecFormRel;
1186 //===----------------------------------------------------------------------===//
1187 // END OF MULTICLASS DEFINITIONS
1188 //===----------------------------------------------------------------------===//
1190 //===----------------------------------------------------------------------===//
1191 // PowerPC Instruction Definitions.
1193 // Pseudo instructions:
1195 let hasCtrlDep = 1 in {
1196 let Defs = [R1], Uses = [R1] in {
1197 def ADJCALLSTACKDOWN : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1198 "#ADJCALLSTACKDOWN $amt1 $amt2",
1199 [(callseq_start timm:$amt1, timm:$amt2)]>;
1200 def ADJCALLSTACKUP : PPCEmitTimePseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
1201 "#ADJCALLSTACKUP $amt1 $amt2",
1202 [(callseq_end timm:$amt1, timm:$amt2)]>;
1206 let Defs = [R1], Uses = [R1] in
1207 def DYNALLOC : PPCEmitTimePseudo<(outs gprc:$result), (ins gprc:$negsize, memri:$fpsi), "#DYNALLOC",
1209 (PPCdynalloc i32:$negsize, iaddr:$fpsi))]>;
1210 def DYNAREAOFFSET : PPCEmitTimePseudo<(outs i32imm:$result), (ins memri:$fpsi), "#DYNAREAOFFSET",
1211 [(set i32:$result, (PPCdynareaoffset iaddr:$fpsi))]>;
1212 // Probed alloca to support stack clash protection.
1213 let Defs = [R1], Uses = [R1], hasNoSchedulingInfo = 1 in {
1214 def PROBED_ALLOCA_32 : PPCCustomInserterPseudo<(outs gprc:$result),
1215 (ins gprc:$negsize, memri:$fpsi), "#PROBED_ALLOCA_32",
1217 (PPCprobedalloca i32:$negsize, iaddr:$fpsi))]>;
1218 def PREPARE_PROBED_ALLOCA_32 : PPCEmitTimePseudo<(outs
1219 gprc:$fp, gprc:$actual_negsize),
1220 (ins gprc:$negsize, memri:$fpsi), "#PREPARE_PROBED_ALLOCA_32", []>;
1221 def PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32 : PPCEmitTimePseudo<(outs
1222 gprc:$fp, gprc:$actual_negsize),
1223 (ins gprc:$negsize, memri:$fpsi),
1224 "#PREPARE_PROBED_ALLOCA_NEGSIZE_SAME_REG_32", []>,
1225 RegConstraint<"$actual_negsize = $negsize">;
1226 def PROBED_STACKALLOC_32 : PPCEmitTimePseudo<(outs gprc:$scratch, gprc:$temp),
1227 (ins i64imm:$stacksize),
1228 "#PROBED_STACKALLOC_32", []>;
1231 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded after
1232 // instruction selection into a branch sequence.
1233 let PPC970_Single = 1 in {
1234 // Note that SELECT_CC_I4 and SELECT_CC_I8 use the no-r0 register classes
1235 // because either operand might become the first operand in an isel, and
1236 // that operand cannot be r0.
1237 def SELECT_CC_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crrc:$cond,
1238 gprc_nor0:$T, gprc_nor0:$F,
1239 i32imm:$BROPC), "#SELECT_CC_I4",
1241 def SELECT_CC_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crrc:$cond,
1242 g8rc_nox0:$T, g8rc_nox0:$F,
1243 i32imm:$BROPC), "#SELECT_CC_I8",
1245 def SELECT_CC_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crrc:$cond, f4rc:$T, f4rc:$F,
1246 i32imm:$BROPC), "#SELECT_CC_F4",
1248 def SELECT_CC_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crrc:$cond, f8rc:$T, f8rc:$F,
1249 i32imm:$BROPC), "#SELECT_CC_F8",
1251 def SELECT_CC_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1252 i32imm:$BROPC), "#SELECT_CC_F16",
1254 def SELECT_CC_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crrc:$cond, vrrc:$T, vrrc:$F,
1255 i32imm:$BROPC), "#SELECT_CC_VRRC",
1258 // SELECT_* pseudo instructions, like SELECT_CC_* but taking condition
1259 // register bit directly.
1260 def SELECT_I4 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins crbitrc:$cond,
1261 gprc_nor0:$T, gprc_nor0:$F), "#SELECT_I4",
1262 [(set i32:$dst, (select i1:$cond, i32:$T, i32:$F))]>;
1263 def SELECT_I8 : PPCCustomInserterPseudo<(outs g8rc:$dst), (ins crbitrc:$cond,
1264 g8rc_nox0:$T, g8rc_nox0:$F), "#SELECT_I8",
1265 [(set i64:$dst, (select i1:$cond, i64:$T, i64:$F))]>;
1266 let Predicates = [HasFPU] in {
1267 def SELECT_F4 : PPCCustomInserterPseudo<(outs f4rc:$dst), (ins crbitrc:$cond,
1268 f4rc:$T, f4rc:$F), "#SELECT_F4",
1269 [(set f32:$dst, (select i1:$cond, f32:$T, f32:$F))]>;
1270 def SELECT_F8 : PPCCustomInserterPseudo<(outs f8rc:$dst), (ins crbitrc:$cond,
1271 f8rc:$T, f8rc:$F), "#SELECT_F8",
1272 [(set f64:$dst, (select i1:$cond, f64:$T, f64:$F))]>;
1273 def SELECT_F16 : PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1274 vrrc:$T, vrrc:$F), "#SELECT_F16",
1275 [(set f128:$dst, (select i1:$cond, f128:$T, f128:$F))]>;
1277 def SELECT_VRRC: PPCCustomInserterPseudo<(outs vrrc:$dst), (ins crbitrc:$cond,
1278 vrrc:$T, vrrc:$F), "#SELECT_VRRC",
1280 (select i1:$cond, v4i32:$T, v4i32:$F))]>;
1283 // SPILL_CR - Indicate that we're dumping the CR register, so we'll need to
1284 // scavenge a register for it.
1285 let mayStore = 1 in {
1286 def SPILL_CR : PPCEmitTimePseudo<(outs), (ins crrc:$cond, memri:$F),
1288 def SPILL_CRBIT : PPCEmitTimePseudo<(outs), (ins crbitrc:$cond, memri:$F),
1289 "#SPILL_CRBIT", []>;
1292 // RESTORE_CR - Indicate that we're restoring the CR register (previously
1293 // spilled), so we'll need to scavenge a register for it.
1294 let mayLoad = 1 in {
1295 def RESTORE_CR : PPCEmitTimePseudo<(outs crrc:$cond), (ins memri:$F),
1297 def RESTORE_CRBIT : PPCEmitTimePseudo<(outs crbitrc:$cond), (ins memri:$F),
1298 "#RESTORE_CRBIT", []>;
1301 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, hasSideEffects = 0 in {
1302 let isPredicable = 1, isReturn = 1, Uses = [LR, RM] in
1303 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (outs), (ins), "blr", IIC_BrB,
1304 [(PPCretglue)]>, Requires<[In32BitMode]>;
1305 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR] in {
1306 let isPredicable = 1 in
1307 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1310 let isCodeGenOnly = 1 in {
1311 def BCCCTR : XLForm_2_br<19, 528, 0, (outs), (ins (pred $BIBO, $CR):$cond),
1312 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
1315 def BCCTR : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$BI),
1316 "bcctr 12, $BI, 0", IIC_BrB, []>;
1317 def BCCTRn : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$BI),
1318 "bcctr 4, $BI, 0", IIC_BrB, []>;
1323 // Set the float rounding mode.
1324 let Uses = [RM], Defs = [RM] in {
1325 def SETRNDi : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins u2imm:$RND),
1326 "#SETRNDi", [(set f64:$FRT, (int_ppc_setrnd (i32 imm:$RND)))]>;
1328 def SETRND : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins gprc:$in),
1329 "#SETRND", [(set f64:$FRT, (int_ppc_setrnd gprc :$in))]>;
1331 def SETFLM : PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FLM),
1332 "#SETFLM", [(set f64:$FRT, (int_ppc_setflm f8rc:$FLM))]>;
1335 let isBarrier = 1, hasSideEffects = 1, Defs = [RM] in
1336 def FENCE : PPCEmitTimePseudo<(outs), (ins), "#FENCE", []>;
1339 def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>,
1342 def MoveGOTtoLR : PPCEmitTimePseudo<(outs), (ins), "#MoveGOTtoLR", []>,
1345 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1346 hasSideEffects = 0 in {
1347 let isBarrier = 1 in {
1348 let isPredicable = 1 in
1349 def B : IForm<18, 0, 0, (outs), (ins directbrtarget:$LI),
1352 def BA : IForm<18, 1, 0, (outs), (ins absdirectbrtarget:$LI),
1353 "ba $LI", IIC_BrB, []>;
1356 // BCC represents an arbitrary conditional branch on a predicate.
1357 // FIXME: should be able to write a pattern for PPCcondbranch, but can't use
1358 // a two-value operand where a dag node expects two operands. :(
1359 let isCodeGenOnly = 1 in {
1360 class BCC_class : BForm<16, 0, 0, (outs), (ins (pred $BIBO, $CR):$cond, condbrtarget:$BD),
1361 "b${cond:cc}${cond:pm} ${cond:reg}, $BD"
1362 /*[(PPCcondbranch crrc:$crS, imm:$opc, bb:$BD)]*/>;
1363 def BCC : BCC_class;
1365 // The same as BCC, except that it's not a terminator. Used for introducing
1366 // control flow dependency without creating new blocks.
1367 let isTerminator = 0 in def CTRL_DEP : BCC_class;
1369 def BCCA : BForm<16, 1, 0, (outs), (ins (pred $BIBO, $CR):$cond, abscondbrtarget:$BD),
1370 "b${cond:cc}a${cond:pm} ${cond:reg}, $BD">;
1372 let isReturn = 1, Uses = [LR, RM] in
1373 def BCCLR : XLForm_2_br<19, 16, 0, (outs), (ins (pred $BIBO, $CR):$cond),
1374 "b${cond:cc}lr${cond:pm} ${cond:reg}", IIC_BrB, []>;
1377 let isCodeGenOnly = 1 in {
1378 let Pattern = [(brcond i1:$BI, bb:$BD)] in
1379 def BC : BForm_4<16, 12, 0, 0, (outs), (ins crbitrc:$BI, condbrtarget:$BD),
1382 let Pattern = [(brcond (not i1:$BI), bb:$BD)] in
1383 def BCn : BForm_4<16, 4, 0, 0, (outs), (ins crbitrc:$BI, condbrtarget:$BD),
1386 let isReturn = 1, Uses = [LR, RM] in {
1387 def BCLR : XLForm_2_br2<19, 16, 12, 0, (outs), (ins crbitrc:$BI),
1388 "bclr 12, $BI, 0", IIC_BrB, []>;
1389 def BCLRn : XLForm_2_br2<19, 16, 4, 0, (outs), (ins crbitrc:$BI),
1390 "bclr 4, $BI, 0", IIC_BrB, []>;
1394 let isReturn = 1, Defs = [CTR], Uses = [CTR, LR, RM] in {
1395 def BDZLR : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
1396 "bdzlr", IIC_BrB, []>;
1397 def BDNZLR : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
1398 "bdnzlr", IIC_BrB, []>;
1399 def BDZLRp : XLForm_2_ext<19, 16, 27, 0, 0, (outs), (ins),
1400 "bdzlr+", IIC_BrB, []>;
1401 def BDNZLRp: XLForm_2_ext<19, 16, 25, 0, 0, (outs), (ins),
1402 "bdnzlr+", IIC_BrB, []>;
1403 def BDZLRm : XLForm_2_ext<19, 16, 26, 0, 0, (outs), (ins),
1404 "bdzlr-", IIC_BrB, []>;
1405 def BDNZLRm: XLForm_2_ext<19, 16, 24, 0, 0, (outs), (ins),
1406 "bdnzlr-", IIC_BrB, []>;
1409 let Defs = [CTR], Uses = [CTR] in {
1410 def BDZ : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$BD),
1412 def BDNZ : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$BD),
1414 def BDZA : BForm_1<16, 18, 1, 0, (outs), (ins abscondbrtarget:$BD),
1416 def BDNZA : BForm_1<16, 16, 1, 0, (outs), (ins abscondbrtarget:$BD),
1418 def BDZp : BForm_1<16, 27, 0, 0, (outs), (ins condbrtarget:$BD),
1420 def BDNZp: BForm_1<16, 25, 0, 0, (outs), (ins condbrtarget:$BD),
1422 def BDZAp : BForm_1<16, 27, 1, 0, (outs), (ins abscondbrtarget:$BD),
1424 def BDNZAp: BForm_1<16, 25, 1, 0, (outs), (ins abscondbrtarget:$BD),
1426 def BDZm : BForm_1<16, 26, 0, 0, (outs), (ins condbrtarget:$BD),
1428 def BDNZm: BForm_1<16, 24, 0, 0, (outs), (ins condbrtarget:$BD),
1430 def BDZAm : BForm_1<16, 26, 1, 0, (outs), (ins abscondbrtarget:$BD),
1432 def BDNZAm: BForm_1<16, 24, 1, 0, (outs), (ins abscondbrtarget:$BD),
1437 // The unconditional BCL used by the SjLj setjmp code.
1438 let isCall = 1, hasCtrlDep = 1, isCodeGenOnly = 1, PPC970_Unit = 7,
1439 hasSideEffects = 0 in {
1440 let Defs = [LR], Uses = [RM] in {
1441 def BCLalways : BForm_2<16, 20, 31, 0, 1, (outs), (ins condbrtarget:$BD),
1446 let isCall = 1, PPC970_Unit = 7, Defs = [LR] in {
1447 // Convenient aliases for call instructions
1448 let Uses = [RM] in {
1449 def BL : IForm<18, 0, 1, (outs), (ins calltarget:$LI),
1450 "bl $LI", IIC_BrB, []>; // See Pat patterns below.
1451 def BLA : IForm<18, 1, 1, (outs), (ins abscalltarget:$LI),
1452 "bla $LI", IIC_BrB, [(PPCcall (i32 imm:$LI))]>;
1454 let isCodeGenOnly = 1 in {
1455 def BL_TLS : IForm<18, 0, 1, (outs), (ins tlscall32:$LI),
1456 "bl $LI", IIC_BrB, []>;
1457 def BCCL : BForm<16, 0, 1, (outs), (ins (pred $BIBO, $CR):$cond, condbrtarget:$BD),
1458 "b${cond:cc}l${cond:pm} ${cond:reg}, $BD">;
1459 def BCCLA : BForm<16, 1, 1, (outs), (ins (pred $BIBO, $CR):$cond, abscondbrtarget:$BD),
1460 "b${cond:cc}la${cond:pm} ${cond:reg}, $BD">;
1462 def BCL : BForm_4<16, 12, 0, 1, (outs),
1463 (ins crbitrc:$BI, condbrtarget:$BD),
1464 "bcl 12, $BI, $BD">;
1465 def BCLn : BForm_4<16, 4, 0, 1, (outs),
1466 (ins crbitrc:$BI, condbrtarget:$BD),
1468 def BL_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24,
1469 (outs), (ins calltarget:$LI),
1470 "bl $LI\n\tnop", IIC_BrB, []>;
1473 let Uses = [CTR, RM] in {
1474 let isPredicable = 1 in
1475 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1476 "bctrl", IIC_BrB, [(PPCbctrl)]>,
1477 Requires<[In32BitMode]>;
1479 let isCodeGenOnly = 1 in {
1480 def BCCCTRL : XLForm_2_br<19, 528, 1, (outs), (ins (pred $BIBO, $CR):$cond),
1481 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
1484 def BCCTRL : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$BI),
1485 "bcctrl 12, $BI, 0", IIC_BrB, []>;
1486 def BCCTRLn : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$BI),
1487 "bcctrl 4, $BI, 0", IIC_BrB, []>;
1490 let Uses = [LR, RM] in {
1491 def BLRL : XLForm_2_ext<19, 16, 20, 0, 1, (outs), (ins),
1492 "blrl", IIC_BrB, []>;
1494 let isCodeGenOnly = 1 in {
1495 def BCCLRL : XLForm_2_br<19, 16, 1, (outs), (ins (pred $BIBO, $CR):$cond),
1496 "b${cond:cc}lrl${cond:pm} ${cond:reg}", IIC_BrB,
1499 def BCLRL : XLForm_2_br2<19, 16, 12, 1, (outs), (ins crbitrc:$BI),
1500 "bclrl 12, $BI, 0", IIC_BrB, []>;
1501 def BCLRLn : XLForm_2_br2<19, 16, 4, 1, (outs), (ins crbitrc:$BI),
1502 "bclrl 4, $BI, 0", IIC_BrB, []>;
1505 let Defs = [CTR], Uses = [CTR, RM] in {
1506 def BDZL : BForm_1<16, 18, 0, 1, (outs), (ins condbrtarget:$BD),
1508 def BDNZL : BForm_1<16, 16, 0, 1, (outs), (ins condbrtarget:$BD),
1510 def BDZLA : BForm_1<16, 18, 1, 1, (outs), (ins abscondbrtarget:$BD),
1512 def BDNZLA : BForm_1<16, 16, 1, 1, (outs), (ins abscondbrtarget:$BD),
1514 def BDZLp : BForm_1<16, 27, 0, 1, (outs), (ins condbrtarget:$BD),
1516 def BDNZLp: BForm_1<16, 25, 0, 1, (outs), (ins condbrtarget:$BD),
1518 def BDZLAp : BForm_1<16, 27, 1, 1, (outs), (ins abscondbrtarget:$BD),
1520 def BDNZLAp: BForm_1<16, 25, 1, 1, (outs), (ins abscondbrtarget:$BD),
1522 def BDZLm : BForm_1<16, 26, 0, 1, (outs), (ins condbrtarget:$BD),
1524 def BDNZLm: BForm_1<16, 24, 0, 1, (outs), (ins condbrtarget:$BD),
1526 def BDZLAm : BForm_1<16, 26, 1, 1, (outs), (ins abscondbrtarget:$BD),
1528 def BDNZLAm: BForm_1<16, 24, 1, 1, (outs), (ins abscondbrtarget:$BD),
1531 let Defs = [CTR], Uses = [CTR, LR, RM] in {
1532 def BDZLRL : XLForm_2_ext<19, 16, 18, 0, 1, (outs), (ins),
1533 "bdzlrl", IIC_BrB, []>;
1534 def BDNZLRL : XLForm_2_ext<19, 16, 16, 0, 1, (outs), (ins),
1535 "bdnzlrl", IIC_BrB, []>;
1536 def BDZLRLp : XLForm_2_ext<19, 16, 27, 0, 1, (outs), (ins),
1537 "bdzlrl+", IIC_BrB, []>;
1538 def BDNZLRLp: XLForm_2_ext<19, 16, 25, 0, 1, (outs), (ins),
1539 "bdnzlrl+", IIC_BrB, []>;
1540 def BDZLRLm : XLForm_2_ext<19, 16, 26, 0, 1, (outs), (ins),
1541 "bdzlrl-", IIC_BrB, []>;
1542 def BDNZLRLm: XLForm_2_ext<19, 16, 24, 0, 1, (outs), (ins),
1543 "bdnzlrl-", IIC_BrB, []>;
1547 let isCall = 1, PPC970_Unit = 7, Defs = [LR, RM], isCodeGenOnly = 1 in {
1548 // Convenient aliases for call instructions
1549 let Uses = [RM] in {
1550 def BL_RM : IForm<18, 0, 1, (outs), (ins calltarget:$LI),
1551 "bl $LI", IIC_BrB, []>; // See Pat patterns below.
1552 def BLA_RM : IForm<18, 1, 1, (outs), (ins abscalltarget:$LI),
1553 "bla $LI", IIC_BrB, [(PPCcall_rm (i32 imm:$LI))]>;
1555 def BL_NOP_RM : IForm_and_DForm_4_zero<18, 0, 1, 24,
1556 (outs), (ins calltarget:$LI),
1557 "bl $LI\n\tnop", IIC_BrB, []>;
1559 let Uses = [CTR, RM] in {
1560 let isPredicable = 1 in
1561 def BCTRL_RM : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
1562 "bctrl", IIC_BrB, [(PPCbctrl_rm)]>,
1563 Requires<[In32BitMode]>;
1567 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1568 def TCRETURNdi :PPCEmitTimePseudo< (outs),
1569 (ins calltarget:$dst, i32imm:$offset),
1570 "#TC_RETURNd $dst $offset",
1574 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1575 def TCRETURNai :PPCEmitTimePseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
1576 "#TC_RETURNa $func $offset",
1577 [(PPCtc_return (i32 imm:$func), imm:$offset)]>;
1579 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
1580 def TCRETURNri : PPCEmitTimePseudo<(outs), (ins CTRRC:$dst, i32imm:$offset),
1581 "#TC_RETURNr $dst $offset",
1584 let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
1585 Defs = [LR, R2], Uses = [CTR, RM], RST = 2 in {
1586 def BCTRL_LWZinto_toc:
1587 XLForm_2_ext_and_DForm_1<19, 528, 20, 0, 1, 32, (outs),
1588 (ins (memri $D, $RA):$addr), "bctrl\n\tlwz 2, $addr", IIC_BrB,
1589 [(PPCbctrl_load_toc iaddr:$addr)]>, Requires<[In32BitMode]>;
1593 let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
1594 Defs = [LR, R2, RM], Uses = [CTR, RM], RST = 2 in {
1595 def BCTRL_LWZinto_toc_RM:
1596 XLForm_2_ext_and_DForm_1<19, 528, 20, 0, 1, 32, (outs),
1597 (ins (memri $D, $RA):$addr), "bctrl\n\tlwz 2, $addr", IIC_BrB,
1598 [(PPCbctrl_load_toc_rm iaddr:$addr)]>, Requires<[In32BitMode]>;
1602 let isCodeGenOnly = 1, hasSideEffects = 0 in {
1604 let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
1605 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR, RM] in
1606 def TAILBCTR : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
1607 []>, Requires<[In32BitMode]>;
1609 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1610 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1611 def TAILB : IForm<18, 0, 0, (outs), (ins calltarget:$LI),
1615 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
1616 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
1617 def TAILBA : IForm<18, 0, 0, (outs), (ins abscalltarget:$LI),
1623 // While longjmp is a control-flow barrier (fallthrough isn't allowed), setjmp
1625 let hasSideEffects = 1 in {
1627 def EH_SjLj_SetJmp32 : PPCCustomInserterPseudo<(outs gprc:$dst), (ins memr:$buf),
1628 "#EH_SJLJ_SETJMP32",
1629 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
1630 Requires<[In32BitMode]>;
1633 let hasSideEffects = 1, isBarrier = 1 in {
1634 let isTerminator = 1 in
1635 def EH_SjLj_LongJmp32 : PPCCustomInserterPseudo<(outs), (ins memr:$buf),
1636 "#EH_SJLJ_LONGJMP32",
1637 [(PPCeh_sjlj_longjmp addr:$buf)]>,
1638 Requires<[In32BitMode]>;
1641 // This pseudo is never removed from the function, as it serves as
1642 // a terminator. Size is set to 0 to prevent the builtin assembler
1643 // from emitting it.
1644 let isBranch = 1, isTerminator = 1, Size = 0 in {
1645 def EH_SjLj_Setup : PPCEmitTimePseudo<(outs), (ins directbrtarget:$dst),
1646 "#EH_SjLj_Setup\t$dst", []>;
1650 let PPC970_Unit = 7 in {
1651 def SC : SCForm<17, 1, 0, (outs), (ins i32imm:$LEV),
1652 "sc $LEV", IIC_BrB, [(PPCsc (i32 imm:$LEV))]>;
1655 // We mark SCV as having no scheduling model since it is only meant to be used
1656 // as inline assembly. If we implement a builtin pattern for it we will need to
1657 // add it to the P9 and P10 scheduling models.
1658 let Predicates = [IsISA3_0], hasNoSchedulingInfo = 1 in {
1659 def SCV : SCForm<17, 0, 1, (outs), (ins i32imm:$LEV),
1660 "scv $LEV", IIC_BrB, []>;
1663 // Branch history rolling buffer.
1664 def CLRBHRB : XForm_0<31, 430, (outs), (ins), "clrbhrb", IIC_BrB,
1666 PPC970_DGroup_Single;
1667 // The $dmy argument used for MFBHRBE is not needed; however, including
1668 // it avoids automatic generation of PPCFastISel::fastEmit_i(), which
1669 // interferes with necessary special handling (see PPCFastISel.cpp).
1670 def MFBHRBE : XFXForm_3p<31, 302, (outs gprc:$RT),
1671 (ins u10imm:$imm, u10imm:$dmy),
1672 "mfbhrbe $RT, $imm", IIC_BrB,
1674 (PPCmfbhrbe imm:$imm, imm:$dmy))]>,
1675 PPC970_DGroup_First;
1677 def RFEBB : XLForm_S<19, 146, (outs), (ins u1imm:$S), "rfebb $S",
1678 IIC_BrB, [(PPCrfebb (i32 imm:$S))]>,
1679 PPC970_DGroup_Single;
1681 def : InstAlias<"rfebb", (RFEBB 1)>;
1683 // DCB* instructions.
1684 def DCBA : DCB_Form<758, 0, (outs), (ins (memrr $RA, $RB):$addr), "dcba $addr",
1685 IIC_LdStDCBF, [(int_ppc_dcba xoaddr:$addr)]>,
1686 PPC970_DGroup_Single;
1687 def DCBI : DCB_Form<470, 0, (outs), (ins (memrr $RA, $RB):$addr), "dcbi $addr",
1688 IIC_LdStDCBF, [(int_ppc_dcbi xoaddr:$addr)]>,
1689 PPC970_DGroup_Single;
1690 def DCBST : DCB_Form<54, 0, (outs), (ins (memrr $RA, $RB):$addr), "dcbst $addr",
1691 IIC_LdStDCBF, [(int_ppc_dcbst xoaddr:$addr)]>,
1692 PPC970_DGroup_Single;
1693 def DCBZ : DCB_Form<1014, 0, (outs), (ins (memrr $RA, $RB):$addr), "dcbz $addr",
1694 IIC_LdStDCBF, [(int_ppc_dcbz xoaddr:$addr)]>,
1695 PPC970_DGroup_Single;
1696 def DCBZL : DCB_Form<1014, 1, (outs), (ins (memrr $RA, $RB):$addr), "dcbzl $addr",
1697 IIC_LdStDCBF, [(int_ppc_dcbzl xoaddr:$addr)]>,
1698 PPC970_DGroup_Single;
1700 def DCBF : DCB_Form_hint<86, (outs), (ins u3imm:$TH, (memrr $RA, $RB):$addr),
1701 "dcbf $addr, $TH", IIC_LdStDCBF, []>,
1702 PPC970_DGroup_Single;
1704 let hasSideEffects = 0, mayLoad = 1, mayStore = 1 in {
1705 def DCBT : DCB_Form_hint<278, (outs), (ins u5imm:$TH, (memrr $RA, $RB):$addr),
1706 "dcbt $addr, $TH", IIC_LdStDCBF, []>,
1707 PPC970_DGroup_Single;
1708 def DCBTST : DCB_Form_hint<246, (outs), (ins u5imm:$TH, (memrr $RA, $RB):$addr),
1709 "dcbtst $addr, $TH", IIC_LdStDCBF, []>,
1710 PPC970_DGroup_Single;
1711 } // hasSideEffects = 0
1713 def ICBLC : XForm_icbt<31, 230, (outs), (ins u4imm:$CT, (memrr $RA, $RB):$addr),
1714 "icblc $CT, $addr", IIC_LdStStore>, Requires<[HasICBT]>;
1715 def ICBLQ : XForm_icbt<31, 198, (outs), (ins u4imm:$CT, (memrr $RA, $RB):$addr),
1716 "icblq. $CT, $addr", IIC_LdStLoad>, Requires<[HasICBT]>;
1717 def ICBT : XForm_icbt<31, 22, (outs), (ins u4imm:$CT, (memrr $RA, $RB):$addr),
1718 "icbt $CT, $addr", IIC_LdStLoad>, Requires<[HasICBT]>;
1719 def ICBTLS : XForm_icbt<31, 486, (outs), (ins u4imm:$CT, (memrr $RA, $RB):$addr),
1720 "icbtls $CT, $addr", IIC_LdStLoad>, Requires<[HasICBT]>;
1722 def : Pat<(int_ppc_dcbt xoaddr:$dst),
1723 (DCBT 0, xoaddr:$dst)>;
1724 def : Pat<(int_ppc_dcbtst xoaddr:$dst),
1725 (DCBTST 0, xoaddr:$dst)>;
1726 def : Pat<(int_ppc_dcbf xoaddr:$dst),
1727 (DCBF 0, xoaddr:$dst)>;
1728 def : Pat<(int_ppc_icbt xoaddr:$dst),
1729 (ICBT 0, xoaddr:$dst)>;
1731 def : Pat<(prefetch xoaddr:$dst, (i32 0), timm, (i32 1)),
1732 (DCBT 0, xoaddr:$dst)>; // data prefetch for loads
1733 def : Pat<(prefetch xoaddr:$dst, (i32 1), timm, (i32 1)),
1734 (DCBTST 0, xoaddr:$dst)>; // data prefetch for stores
1735 def : Pat<(prefetch xoaddr:$dst, (i32 0), timm, (i32 0)),
1736 (ICBT 0, xoaddr:$dst)>, Requires<[HasICBT]>; // inst prefetch (for read)
1738 def : Pat<(int_ppc_dcbt_with_hint xoaddr:$dst, i32:$TH),
1739 (DCBT i32:$TH, xoaddr:$dst)>;
1740 def : Pat<(int_ppc_dcbtst_with_hint xoaddr:$dst, i32:$TH),
1741 (DCBTST i32:$TH, xoaddr:$dst)>;
1743 // Atomic operations
1744 // FIXME: some of these might be used with constant operands. This will result
1745 // in constant materialization instructions that may be redundant. We currently
1746 // clean this up in PPCMIPeephole with calls to
1747 // PPCInstrInfo::convertToImmediateForm() but we should probably not emit them
1748 // in the first place.
1749 let Defs = [CR0] in {
1750 def ATOMIC_LOAD_ADD_I8 : PPCCustomInserterPseudo<
1751 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I8",
1752 [(set i32:$dst, (atomic_load_add_i8 ForceXForm:$ptr, i32:$incr))]>;
1753 def ATOMIC_LOAD_SUB_I8 : PPCCustomInserterPseudo<
1754 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I8",
1755 [(set i32:$dst, (atomic_load_sub_i8 ForceXForm:$ptr, i32:$incr))]>;
1756 def ATOMIC_LOAD_AND_I8 : PPCCustomInserterPseudo<
1757 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I8",
1758 [(set i32:$dst, (atomic_load_and_i8 ForceXForm:$ptr, i32:$incr))]>;
1759 def ATOMIC_LOAD_OR_I8 : PPCCustomInserterPseudo<
1760 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I8",
1761 [(set i32:$dst, (atomic_load_or_i8 ForceXForm:$ptr, i32:$incr))]>;
1762 def ATOMIC_LOAD_XOR_I8 : PPCCustomInserterPseudo<
1763 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "ATOMIC_LOAD_XOR_I8",
1764 [(set i32:$dst, (atomic_load_xor_i8 ForceXForm:$ptr, i32:$incr))]>;
1765 def ATOMIC_LOAD_NAND_I8 : PPCCustomInserterPseudo<
1766 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I8",
1767 [(set i32:$dst, (atomic_load_nand_i8 ForceXForm:$ptr, i32:$incr))]>;
1768 def ATOMIC_LOAD_MIN_I8 : PPCCustomInserterPseudo<
1769 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I8",
1770 [(set i32:$dst, (atomic_load_min_i8 ForceXForm:$ptr, i32:$incr))]>;
1771 def ATOMIC_LOAD_MAX_I8 : PPCCustomInserterPseudo<
1772 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I8",
1773 [(set i32:$dst, (atomic_load_max_i8 ForceXForm:$ptr, i32:$incr))]>;
1774 def ATOMIC_LOAD_UMIN_I8 : PPCCustomInserterPseudo<
1775 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I8",
1776 [(set i32:$dst, (atomic_load_umin_i8 ForceXForm:$ptr, i32:$incr))]>;
1777 def ATOMIC_LOAD_UMAX_I8 : PPCCustomInserterPseudo<
1778 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I8",
1779 [(set i32:$dst, (atomic_load_umax_i8 ForceXForm:$ptr, i32:$incr))]>;
1780 def ATOMIC_LOAD_ADD_I16 : PPCCustomInserterPseudo<
1781 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I16",
1782 [(set i32:$dst, (atomic_load_add_i16 ForceXForm:$ptr, i32:$incr))]>;
1783 def ATOMIC_LOAD_SUB_I16 : PPCCustomInserterPseudo<
1784 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I16",
1785 [(set i32:$dst, (atomic_load_sub_i16 ForceXForm:$ptr, i32:$incr))]>;
1786 def ATOMIC_LOAD_AND_I16 : PPCCustomInserterPseudo<
1787 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I16",
1788 [(set i32:$dst, (atomic_load_and_i16 ForceXForm:$ptr, i32:$incr))]>;
1789 def ATOMIC_LOAD_OR_I16 : PPCCustomInserterPseudo<
1790 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I16",
1791 [(set i32:$dst, (atomic_load_or_i16 ForceXForm:$ptr, i32:$incr))]>;
1792 def ATOMIC_LOAD_XOR_I16 : PPCCustomInserterPseudo<
1793 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I16",
1794 [(set i32:$dst, (atomic_load_xor_i16 ForceXForm:$ptr, i32:$incr))]>;
1795 def ATOMIC_LOAD_NAND_I16 : PPCCustomInserterPseudo<
1796 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I16",
1797 [(set i32:$dst, (atomic_load_nand_i16 ForceXForm:$ptr, i32:$incr))]>;
1798 def ATOMIC_LOAD_MIN_I16 : PPCCustomInserterPseudo<
1799 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I16",
1800 [(set i32:$dst, (atomic_load_min_i16 ForceXForm:$ptr, i32:$incr))]>;
1801 def ATOMIC_LOAD_MAX_I16 : PPCCustomInserterPseudo<
1802 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I16",
1803 [(set i32:$dst, (atomic_load_max_i16 ForceXForm:$ptr, i32:$incr))]>;
1804 def ATOMIC_LOAD_UMIN_I16 : PPCCustomInserterPseudo<
1805 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I16",
1806 [(set i32:$dst, (atomic_load_umin_i16 ForceXForm:$ptr, i32:$incr))]>;
1807 def ATOMIC_LOAD_UMAX_I16 : PPCCustomInserterPseudo<
1808 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I16",
1809 [(set i32:$dst, (atomic_load_umax_i16 ForceXForm:$ptr, i32:$incr))]>;
1810 def ATOMIC_LOAD_ADD_I32 : PPCCustomInserterPseudo<
1811 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_ADD_I32",
1812 [(set i32:$dst, (atomic_load_add_i32 ForceXForm:$ptr, i32:$incr))]>;
1813 def ATOMIC_LOAD_SUB_I32 : PPCCustomInserterPseudo<
1814 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_SUB_I32",
1815 [(set i32:$dst, (atomic_load_sub_i32 ForceXForm:$ptr, i32:$incr))]>;
1816 def ATOMIC_LOAD_AND_I32 : PPCCustomInserterPseudo<
1817 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_AND_I32",
1818 [(set i32:$dst, (atomic_load_and_i32 ForceXForm:$ptr, i32:$incr))]>;
1819 def ATOMIC_LOAD_OR_I32 : PPCCustomInserterPseudo<
1820 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_OR_I32",
1821 [(set i32:$dst, (atomic_load_or_i32 ForceXForm:$ptr, i32:$incr))]>;
1822 def ATOMIC_LOAD_XOR_I32 : PPCCustomInserterPseudo<
1823 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_XOR_I32",
1824 [(set i32:$dst, (atomic_load_xor_i32 ForceXForm:$ptr, i32:$incr))]>;
1825 def ATOMIC_LOAD_NAND_I32 : PPCCustomInserterPseudo<
1826 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_NAND_I32",
1827 [(set i32:$dst, (atomic_load_nand_i32 ForceXForm:$ptr, i32:$incr))]>;
1828 def ATOMIC_LOAD_MIN_I32 : PPCCustomInserterPseudo<
1829 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MIN_I32",
1830 [(set i32:$dst, (atomic_load_min_i32 ForceXForm:$ptr, i32:$incr))]>;
1831 def ATOMIC_LOAD_MAX_I32 : PPCCustomInserterPseudo<
1832 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_MAX_I32",
1833 [(set i32:$dst, (atomic_load_max_i32 ForceXForm:$ptr, i32:$incr))]>;
1834 def ATOMIC_LOAD_UMIN_I32 : PPCCustomInserterPseudo<
1835 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMIN_I32",
1836 [(set i32:$dst, (atomic_load_umin_i32 ForceXForm:$ptr, i32:$incr))]>;
1837 def ATOMIC_LOAD_UMAX_I32 : PPCCustomInserterPseudo<
1838 (outs gprc:$dst), (ins memrr:$ptr, gprc:$incr), "#ATOMIC_LOAD_UMAX_I32",
1839 [(set i32:$dst, (atomic_load_umax_i32 ForceXForm:$ptr, i32:$incr))]>;
1841 def ATOMIC_CMP_SWAP_I8 : PPCCustomInserterPseudo<
1842 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I8",
1843 [(set i32:$dst, (atomic_cmp_swap_i8 ForceXForm:$ptr, i32:$old, i32:$new))]>;
1844 def ATOMIC_CMP_SWAP_I16 : PPCCustomInserterPseudo<
1845 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I16 $dst $ptr $old $new",
1846 [(set i32:$dst, (atomic_cmp_swap_i16 ForceXForm:$ptr, i32:$old, i32:$new))]>;
1847 def ATOMIC_CMP_SWAP_I32 : PPCCustomInserterPseudo<
1848 (outs gprc:$dst), (ins memrr:$ptr, gprc:$old, gprc:$new), "#ATOMIC_CMP_SWAP_I32 $dst $ptr $old $new",
1849 [(set i32:$dst, (atomic_cmp_swap_i32 ForceXForm:$ptr, i32:$old, i32:$new))]>;
1851 def ATOMIC_SWAP_I8 : PPCCustomInserterPseudo<
1852 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_i8",
1853 [(set i32:$dst, (atomic_swap_i8 ForceXForm:$ptr, i32:$new))]>;
1854 def ATOMIC_SWAP_I16 : PPCCustomInserterPseudo<
1855 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I16",
1856 [(set i32:$dst, (atomic_swap_i16 ForceXForm:$ptr, i32:$new))]>;
1857 def ATOMIC_SWAP_I32 : PPCCustomInserterPseudo<
1858 (outs gprc:$dst), (ins memrr:$ptr, gprc:$new), "#ATOMIC_SWAP_I32",
1859 [(set i32:$dst, (atomic_swap_i32 ForceXForm:$ptr, i32:$new))]>;
1862 def : Pat<(PPCatomicCmpSwap_8 ForceXForm:$ptr, i32:$old, i32:$new),
1863 (ATOMIC_CMP_SWAP_I8 ForceXForm:$ptr, i32:$old, i32:$new)>;
1864 def : Pat<(PPCatomicCmpSwap_16 ForceXForm:$ptr, i32:$old, i32:$new),
1865 (ATOMIC_CMP_SWAP_I16 ForceXForm:$ptr, i32:$old, i32:$new)>;
1867 // Instructions to support atomic operations
1868 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1869 def LBARX : XForm_1_memOp<31, 52, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
1870 "lbarx $RST, $addr", IIC_LdStLWARX, []>,
1871 Requires<[HasPartwordAtomics]>;
1873 def LHARX : XForm_1_memOp<31, 116, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
1874 "lharx $RST, $addr", IIC_LdStLWARX, []>,
1875 Requires<[HasPartwordAtomics]>;
1877 def LWARX : XForm_1_memOp<31, 20, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
1878 "lwarx $RST, $addr", IIC_LdStLWARX, []>;
1880 // Instructions to support lock versions of atomics
1881 // (EH=1 - see Power ISA 2.07 Book II 4.4.2)
1882 def LBARXL : XForm_1_memOp<31, 52, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
1883 "lbarx $RST, $addr, 1", IIC_LdStLWARX, []>, isRecordForm,
1884 Requires<[HasPartwordAtomics]>;
1886 def LHARXL : XForm_1_memOp<31, 116, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
1887 "lharx $RST, $addr, 1", IIC_LdStLWARX, []>, isRecordForm,
1888 Requires<[HasPartwordAtomics]>;
1890 def LWARXL : XForm_1_memOp<31, 20, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
1891 "lwarx $RST, $addr, 1", IIC_LdStLWARX, []>, isRecordForm;
1893 // The atomic instructions use the destination register as well as the next one
1894 // or two registers in order (modulo 31).
1895 let hasExtraSrcRegAllocReq = 1 in
1896 def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$RST), (ins gprc:$RA, u5imm:$RB),
1897 "lwat $RST, $RA, $RB", IIC_LdStLoad>,
1898 Requires<[IsISA3_0]>;
1901 let Defs = [CR0], mayStore = 1, mayLoad = 0, hasSideEffects = 0 in {
1902 def STBCX : XForm_1_memOp<31, 694, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
1903 "stbcx. $RST, $addr", IIC_LdStSTWCX, []>,
1904 isRecordForm, Requires<[HasPartwordAtomics]>;
1906 def STHCX : XForm_1_memOp<31, 726, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
1907 "sthcx. $RST, $addr", IIC_LdStSTWCX, []>,
1908 isRecordForm, Requires<[HasPartwordAtomics]>;
1910 def STWCX : XForm_1_memOp<31, 150, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
1911 "stwcx. $RST, $addr", IIC_LdStSTWCX, []>, isRecordForm;
1914 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
1915 def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$RST, gprc:$RA, u5imm:$RB),
1916 "stwat $RST, $RA, $RB", IIC_LdStStore>,
1917 Requires<[IsISA3_0]>;
1919 let isTrap = 1, hasCtrlDep = 1 in
1920 def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
1922 def TWI : DForm_base<3, (outs), (ins u5imm:$RST, gprc:$RA, s16imm:$D, variable_ops),
1923 "twi $RST, $RA, $D", IIC_IntTrapW, []>;
1924 def TW : XForm_1<31, 4, (outs), (ins u5imm:$RST, gprc:$RA, gprc:$RB, variable_ops),
1925 "tw $RST, $RA, $RB", IIC_IntTrapW, []>;
1926 def TDI : DForm_base<2, (outs), (ins u5imm:$RST, g8rc:$RA, s16imm:$D, variable_ops),
1927 "tdi $RST, $RA, $D", IIC_IntTrapD, []>;
1928 def TD : XForm_1<31, 68, (outs), (ins u5imm:$RST, g8rc:$RA, g8rc:$RB, variable_ops),
1929 "td $RST, $RA, $RB", IIC_IntTrapD, []>;
1931 def POPCNTB : XForm_11<31, 122, (outs gprc:$RA), (ins gprc:$RST),
1932 "popcntb $RA, $RST", IIC_IntGeneral,
1933 [(set i32:$RA, (int_ppc_popcntb i32:$RST))]>;
1935 def CDTBCD : XForm_11<31, 282, (outs gprc:$RA), (ins gprc:$RST),
1936 "cdtbcd $RA, $RST", IIC_IntGeneral,
1937 [(set i32:$RA, (int_ppc_cdtbcd i32:$RST))]>;
1938 def CBCDTD : XForm_11<31, 314, (outs gprc:$RA), (ins gprc:$RST),
1939 "cbcdtd $RA, $RST", IIC_IntGeneral,
1940 [(set i32:$RA, (int_ppc_cbcdtd i32:$RST))]>;
1941 def ADDG6S : XOForm_1<31, 74, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
1942 "addg6s $RT, $RA, $RB", IIC_IntGeneral,
1943 [(set i32:$RT, (int_ppc_addg6s i32:$RA, i32:$RB))]>;
1945 //===----------------------------------------------------------------------===//
1946 // PPC32 Load Instructions.
1949 // Unindexed (r+i) Loads.
1950 let PPC970_Unit = 2 in {
1951 def LBZ : DForm_1<34, (outs gprc:$RST), (ins (memri $D, $RA):$addr),
1952 "lbz $RST, $addr", IIC_LdStLoad,
1953 [(set i32:$RST, (zextloadi8 DForm:$addr))]>, ZExt32To64,
1955 def LHA : DForm_1<42, (outs gprc:$RST), (ins (memri $D, $RA):$addr),
1956 "lha $RST, $addr", IIC_LdStLHA,
1957 [(set i32:$RST, (sextloadi16 DForm:$addr))]>,
1958 PPC970_DGroup_Cracked, SExt32To64;
1959 def LHZ : DForm_1<40, (outs gprc:$RST), (ins (memri $D, $RA):$addr),
1960 "lhz $RST, $addr", IIC_LdStLoad,
1961 [(set i32:$RST, (zextloadi16 DForm:$addr))]>, ZExt32To64,
1963 def LWZ : DForm_1<32, (outs gprc:$RST), (ins (memri $D, $RA):$addr),
1964 "lwz $RST, $addr", IIC_LdStLoad,
1965 [(set i32:$RST, (load DForm:$addr))]>, ZExt32To64;
1967 let Predicates = [HasFPU] in {
1968 def LFS : DForm_1<48, (outs f4rc:$RST), (ins (memri $D, $RA):$addr),
1969 "lfs $RST, $addr", IIC_LdStLFD,
1970 [(set f32:$RST, (load DForm:$addr))]>;
1971 def LFD : DForm_1<50, (outs f8rc:$RST), (ins (memri $D, $RA):$addr),
1972 "lfd $RST, $addr", IIC_LdStLFD,
1973 [(set f64:$RST, (load DForm:$addr))]>;
1977 // Unindexed (r+i) Loads with Update (preinc).
1978 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in {
1979 def LBZU : DForm_1<35, (outs gprc:$RST, ptr_rc_nor0:$ea_result), (ins (memri $D, $RA):$addr),
1980 "lbzu $RST, $addr", IIC_LdStLoadUpd,
1981 []>, RegConstraint<"$RA = $ea_result">;
1983 def LHAU : DForm_1<43, (outs gprc:$RST, ptr_rc_nor0:$ea_result), (ins (memri $D, $RA):$addr),
1984 "lhau $RST, $addr", IIC_LdStLHAU,
1985 []>, RegConstraint<"$addr.reg = $ea_result">,
1986 NoEncode<"$ea_result">;
1988 def LHZU : DForm_1<41, (outs gprc:$RST, ptr_rc_nor0:$ea_result), (ins (memri $D, $RA):$addr),
1989 "lhzu $RST, $addr", IIC_LdStLoadUpd,
1990 []>, RegConstraint<"$addr.reg = $ea_result">,
1991 NoEncode<"$ea_result">;
1993 def LWZU : DForm_1<33, (outs gprc:$RST, ptr_rc_nor0:$ea_result), (ins (memri $D, $RA):$addr),
1994 "lwzu $RST, $addr", IIC_LdStLoadUpd,
1995 []>, RegConstraint<"$addr.reg = $ea_result">,
1996 NoEncode<"$ea_result">;
1998 let Predicates = [HasFPU] in {
1999 def LFSU : DForm_1<49, (outs f4rc:$RST, ptr_rc_nor0:$ea_result), (ins (memri $D, $RA):$addr),
2000 "lfsu $RST, $addr", IIC_LdStLFDU,
2001 []>, RegConstraint<"$addr.reg = $ea_result">,
2002 NoEncode<"$ea_result">;
2004 def LFDU : DForm_1<51, (outs f8rc:$RST, ptr_rc_nor0:$ea_result), (ins (memri $D, $RA):$addr),
2005 "lfdu $RST, $addr", IIC_LdStLFDU,
2006 []>, RegConstraint<"$addr.reg = $ea_result">,
2007 NoEncode<"$ea_result">;
2011 // Indexed (r+r) Loads with Update (preinc).
2012 def LBZUX : XForm_1_memOp<31, 119, (outs gprc:$RST, ptr_rc_nor0:$ea_result),
2013 (ins (memrr $RA, $RB):$addr),
2014 "lbzux $RST, $addr", IIC_LdStLoadUpdX,
2015 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
2016 NoEncode<"$ea_result">;
2018 def LHAUX : XForm_1_memOp<31, 375, (outs gprc:$RST, ptr_rc_nor0:$ea_result),
2019 (ins (memrr $RA, $RB):$addr),
2020 "lhaux $RST, $addr", IIC_LdStLHAUX,
2021 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
2022 NoEncode<"$ea_result">;
2024 def LHZUX : XForm_1_memOp<31, 311, (outs gprc:$RST, ptr_rc_nor0:$ea_result),
2025 (ins (memrr $RA, $RB):$addr),
2026 "lhzux $RST, $addr", IIC_LdStLoadUpdX,
2027 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
2028 NoEncode<"$ea_result">;
2030 def LWZUX : XForm_1_memOp<31, 55, (outs gprc:$RST, ptr_rc_nor0:$ea_result),
2031 (ins (memrr $RA, $RB):$addr),
2032 "lwzux $RST, $addr", IIC_LdStLoadUpdX,
2033 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
2034 NoEncode<"$ea_result">;
2036 let Predicates = [HasFPU] in {
2037 def LFSUX : XForm_1_memOp<31, 567, (outs f4rc:$RST, ptr_rc_nor0:$ea_result),
2038 (ins (memrr $RA, $RB):$addr),
2039 "lfsux $RST, $addr", IIC_LdStLFDUX,
2040 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
2041 NoEncode<"$ea_result">;
2043 def LFDUX : XForm_1_memOp<31, 631, (outs f8rc:$RST, ptr_rc_nor0:$ea_result),
2044 (ins (memrr $RA, $RB):$addr),
2045 "lfdux $RST, $addr", IIC_LdStLFDUX,
2046 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
2047 NoEncode<"$ea_result">;
2052 // Indexed (r+r) Loads.
2054 let PPC970_Unit = 2, mayLoad = 1, mayStore = 0 in {
2055 def LBZX : XForm_1_memOp<31, 87, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
2056 "lbzx $RST, $addr", IIC_LdStLoad,
2057 [(set i32:$RST, (zextloadi8 XForm:$addr))]>, ZExt32To64,
2059 def LHAX : XForm_1_memOp<31, 343, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
2060 "lhax $RST, $addr", IIC_LdStLHA,
2061 [(set i32:$RST, (sextloadi16 XForm:$addr))]>,
2062 PPC970_DGroup_Cracked, SExt32To64;
2063 def LHZX : XForm_1_memOp<31, 279, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
2064 "lhzx $RST, $addr", IIC_LdStLoad,
2065 [(set i32:$RST, (zextloadi16 XForm:$addr))]>, ZExt32To64,
2067 def LWZX : XForm_1_memOp<31, 23, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
2068 "lwzx $RST, $addr", IIC_LdStLoad,
2069 [(set i32:$RST, (load XForm:$addr))]>, ZExt32To64;
2070 def LHBRX : XForm_1_memOp<31, 790, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
2071 "lhbrx $RST, $addr", IIC_LdStLoad,
2072 [(set i32:$RST, (PPClbrx ForceXForm:$addr, i16))]>, ZExt32To64;
2073 def LWBRX : XForm_1_memOp<31, 534, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
2074 "lwbrx $RST, $addr", IIC_LdStLoad,
2075 [(set i32:$RST, (PPClbrx ForceXForm:$addr, i32))]>, ZExt32To64;
2077 let Predicates = [HasFPU] in {
2078 def LFSX : XForm_25_memOp<31, 535, (outs f4rc:$RST), (ins (memrr $RA, $RB):$addr),
2079 "lfsx $RST, $addr", IIC_LdStLFD,
2080 [(set f32:$RST, (load XForm:$addr))]>;
2081 def LFDX : XForm_25_memOp<31, 599, (outs f8rc:$RST), (ins (memrr $RA, $RB):$addr),
2082 "lfdx $RST, $addr", IIC_LdStLFD,
2083 [(set f64:$RST, (load XForm:$addr))]>;
2085 def LFIWAX : XForm_25_memOp<31, 855, (outs f8rc:$RST), (ins (memrr $RA, $RB):$addr),
2086 "lfiwax $RST, $addr", IIC_LdStLFD,
2087 [(set f64:$RST, (PPClfiwax ForceXForm:$addr))]>;
2088 def LFIWZX : XForm_25_memOp<31, 887, (outs f8rc:$RST), (ins (memrr $RA, $RB):$addr),
2089 "lfiwzx $RST, $addr", IIC_LdStLFD,
2090 [(set f64:$RST, (PPClfiwzx ForceXForm:$addr))]>;
2095 let mayLoad = 1, mayStore = 0, hasSideEffects = 0 in
2096 def LMW : DForm_1<46, (outs gprc:$RST), (ins (memri $D, $RA):$src),
2097 "lmw $RST, $src", IIC_LdStLMW, []>;
2099 //===----------------------------------------------------------------------===//
2100 // PPC32 Store Instructions.
2103 // Unindexed (r+i) Stores.
2104 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2105 def STB : DForm_1<38, (outs), (ins gprc:$RST, (memri $D, $RA):$dst),
2106 "stb $RST, $dst", IIC_LdStStore,
2107 [(truncstorei8 i32:$RST, DForm:$dst)]>;
2108 def STH : DForm_1<44, (outs), (ins gprc:$RST, (memri $D, $RA):$dst),
2109 "sth $RST, $dst", IIC_LdStStore,
2110 [(truncstorei16 i32:$RST, DForm:$dst)]>;
2111 def STW : DForm_1<36, (outs), (ins gprc:$RST, (memri $D, $RA):$dst),
2112 "stw $RST, $dst", IIC_LdStStore,
2113 [(store i32:$RST, DForm:$dst)]>;
2114 let Predicates = [HasFPU] in {
2115 def STFS : DForm_1<52, (outs), (ins f4rc:$RST, (memri $D, $RA):$dst),
2116 "stfs $RST, $dst", IIC_LdStSTFD,
2117 [(store f32:$RST, DForm:$dst)]>;
2118 def STFD : DForm_1<54, (outs), (ins f8rc:$RST, (memri $D, $RA):$dst),
2119 "stfd $RST, $dst", IIC_LdStSTFD,
2120 [(store f64:$RST, DForm:$dst)]>;
2124 // Unindexed (r+i) Stores with Update (preinc).
2125 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2126 def STBU : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins gprc:$RST, (memri $D, $RA):$dst),
2127 "stbu $RST, $dst", IIC_LdStSTU, []>,
2128 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2129 def STHU : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins gprc:$RST, (memri $D, $RA):$dst),
2130 "sthu $RST, $dst", IIC_LdStSTU, []>,
2131 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2132 def STWU : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins gprc:$RST, (memri $D, $RA):$dst),
2133 "stwu $RST, $dst", IIC_LdStSTU, []>,
2134 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2135 let Predicates = [HasFPU] in {
2136 def STFSU : DForm_1<53, (outs ptr_rc_nor0:$ea_res), (ins f4rc:$RST, (memri $D, $RA):$dst),
2137 "stfsu $RST, $dst", IIC_LdStSTFDU, []>,
2138 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2139 def STFDU : DForm_1<55, (outs ptr_rc_nor0:$ea_res), (ins f8rc:$RST, (memri $D, $RA):$dst),
2140 "stfdu $RST, $dst", IIC_LdStSTFDU, []>,
2141 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
2145 // Patterns to match the pre-inc stores. We can't put the patterns on
2146 // the instruction definitions directly as ISel wants the address base
2147 // and offset to be separate operands, not a single complex operand.
2148 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2149 (STBU $rS, iaddroff:$ptroff, $ptrreg)>;
2150 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2151 (STHU $rS, iaddroff:$ptroff, $ptrreg)>;
2152 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2153 (STWU $rS, iaddroff:$ptroff, $ptrreg)>;
2154 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2155 (STFSU $rS, iaddroff:$ptroff, $ptrreg)>;
2156 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
2157 (STFDU $rS, iaddroff:$ptroff, $ptrreg)>;
2159 // Indexed (r+r) Stores.
2160 let PPC970_Unit = 2 in {
2161 def STBX : XForm_8_memOp<31, 215, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
2162 "stbx $RST, $addr", IIC_LdStStore,
2163 [(truncstorei8 i32:$RST, XForm:$addr)]>,
2164 PPC970_DGroup_Cracked;
2165 def STHX : XForm_8_memOp<31, 407, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
2166 "sthx $RST, $addr", IIC_LdStStore,
2167 [(truncstorei16 i32:$RST, XForm:$addr)]>,
2168 PPC970_DGroup_Cracked;
2169 def STWX : XForm_8_memOp<31, 151, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
2170 "stwx $RST, $addr", IIC_LdStStore,
2171 [(store i32:$RST, XForm:$addr)]>,
2172 PPC970_DGroup_Cracked;
2174 def STHBRX: XForm_8_memOp<31, 918, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
2175 "sthbrx $RST, $addr", IIC_LdStStore,
2176 [(PPCstbrx i32:$RST, ForceXForm:$addr, i16)]>,
2177 PPC970_DGroup_Cracked;
2178 def STWBRX: XForm_8_memOp<31, 662, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
2179 "stwbrx $RST, $addr", IIC_LdStStore,
2180 [(PPCstbrx i32:$RST, ForceXForm:$addr, i32)]>,
2181 PPC970_DGroup_Cracked;
2183 let Predicates = [HasFPU] in {
2184 def STFIWX: XForm_28_memOp<31, 983, (outs), (ins f8rc:$RST, (memrr $RA, $RB):$addr),
2185 "stfiwx $RST, $addr", IIC_LdStSTFD,
2186 [(PPCstfiwx f64:$RST, ForceXForm:$addr)]>;
2188 def STFSX : XForm_28_memOp<31, 663, (outs), (ins f4rc:$RST, (memrr $RA, $RB):$addr),
2189 "stfsx $RST, $addr", IIC_LdStSTFD,
2190 [(store f32:$RST, XForm:$addr)]>;
2191 def STFDX : XForm_28_memOp<31, 727, (outs), (ins f8rc:$RST, (memrr $RA, $RB):$addr),
2192 "stfdx $RST, $addr", IIC_LdStSTFD,
2193 [(store f64:$RST, XForm:$addr)]>;
2197 // Indexed (r+r) Stores with Update (preinc).
2198 let PPC970_Unit = 2, mayStore = 1, mayLoad = 0 in {
2199 def STBUX : XForm_8_memOp<31, 247, (outs ptr_rc_nor0:$ea_res),
2200 (ins gprc:$RST, (memrr $RA, $RB):$addr),
2201 "stbux $RST, $addr", IIC_LdStSTUX, []>,
2202 RegConstraint<"$addr.ptrreg = $ea_res">,
2203 NoEncode<"$ea_res">,
2204 PPC970_DGroup_Cracked;
2205 def STHUX : XForm_8_memOp<31, 439, (outs ptr_rc_nor0:$ea_res),
2206 (ins gprc:$RST, (memrr $RA, $RB):$addr),
2207 "sthux $RST, $addr", IIC_LdStSTUX, []>,
2208 RegConstraint<"$addr.ptrreg = $ea_res">,
2209 NoEncode<"$ea_res">,
2210 PPC970_DGroup_Cracked;
2211 def STWUX : XForm_8_memOp<31, 183, (outs ptr_rc_nor0:$ea_res),
2212 (ins gprc:$RST, (memrr $RA, $RB):$addr),
2213 "stwux $RST, $addr", IIC_LdStSTUX, []>,
2214 RegConstraint<"$addr.ptrreg = $ea_res">,
2215 NoEncode<"$ea_res">,
2216 PPC970_DGroup_Cracked;
2217 let Predicates = [HasFPU] in {
2218 def STFSUX: XForm_8_memOp<31, 695, (outs ptr_rc_nor0:$ea_res),
2219 (ins f4rc:$RST, (memrr $RA, $RB):$addr),
2220 "stfsux $RST, $addr", IIC_LdStSTFDU, []>,
2221 RegConstraint<"$addr.ptrreg = $ea_res">,
2222 NoEncode<"$ea_res">,
2223 PPC970_DGroup_Cracked;
2224 def STFDUX: XForm_8_memOp<31, 759, (outs ptr_rc_nor0:$ea_res),
2225 (ins f8rc:$RST, (memrr $RA, $RB):$addr),
2226 "stfdux $RST, $addr", IIC_LdStSTFDU, []>,
2227 RegConstraint<"$addr.ptrreg = $ea_res">,
2228 NoEncode<"$ea_res">,
2229 PPC970_DGroup_Cracked;
2233 // Patterns to match the pre-inc stores. We can't put the patterns on
2234 // the instruction definitions directly as ISel wants the address base
2235 // and offset to be separate operands, not a single complex operand.
2236 def : Pat<(pre_truncsti8 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2237 (STBUX $rS, $ptrreg, $ptroff)>;
2238 def : Pat<(pre_truncsti16 i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2239 (STHUX $rS, $ptrreg, $ptroff)>;
2240 def : Pat<(pre_store i32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2241 (STWUX $rS, $ptrreg, $ptroff)>;
2242 let Predicates = [HasFPU] in {
2243 def : Pat<(pre_store f32:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2244 (STFSUX $rS, $ptrreg, $ptroff)>;
2245 def : Pat<(pre_store f64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
2246 (STFDUX $rS, $ptrreg, $ptroff)>;
2250 let mayStore = 1, mayLoad = 0, hasSideEffects = 0 in
2251 def STMW : DForm_1<47, (outs), (ins gprc:$RST, (memri $D, $RA):$dst),
2252 "stmw $RST, $dst", IIC_LdStLMW, []>;
2254 def SYNC : XForm_24_sync<31, 598, (outs), (ins u2imm:$L),
2255 "sync $L", IIC_LdStSync, []>;
2257 let isCodeGenOnly = 1 in {
2258 def MSYNC : XForm_24_sync<31, 598, (outs), (ins),
2259 "msync", IIC_LdStSync, []> {
2264 // We used to have EIEIO as value but E[0-9A-Z] is a reserved name
2265 def EnforceIEIO : XForm_24_eieio<31, 854, (outs), (ins),
2266 "eieio", IIC_LdStLoad, []>;
2268 def PseudoEIEIO : PPCEmitTimePseudo<(outs), (ins), "#PPCEIEIO",
2271 def : Pat<(int_ppc_sync), (SYNC 0)>, Requires<[HasSYNC]>;
2272 def : Pat<(int_ppc_iospace_sync), (SYNC 0)>, Requires<[HasSYNC]>;
2273 def : Pat<(int_ppc_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
2274 def : Pat<(int_ppc_iospace_lwsync), (SYNC 1)>, Requires<[HasSYNC]>;
2275 def : Pat<(int_ppc_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2276 def : Pat<(int_ppc_iospace_sync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2277 def : Pat<(int_ppc_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2278 def : Pat<(int_ppc_iospace_lwsync), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
2279 def : Pat<(int_ppc_eieio), (PseudoEIEIO)>;
2280 def : Pat<(int_ppc_iospace_eieio), (PseudoEIEIO)>;
2282 //===----------------------------------------------------------------------===//
2283 // PPC32 Arithmetic Instructions.
2286 let PPC970_Unit = 1 in { // FXU Operations.
2287 def ADDI : DForm_2<14, (outs gprc:$RST), (ins gprc_nor0:$RA, s16imm:$D),
2288 "addi $RST, $RA, $D", IIC_IntSimple,
2289 [(set i32:$RST, (add i32:$RA, imm32SExt16:$D))]>;
2290 let BaseName = "addic" in {
2291 let Defs = [CARRY] in
2292 def ADDIC : DForm_2<12, (outs gprc:$RST), (ins gprc:$RA, s16imm:$D),
2293 "addic $RST, $RA, $D", IIC_IntGeneral,
2294 [(set i32:$RST, (addc i32:$RA, imm32SExt16:$D))]>,
2295 RecFormRel, PPC970_DGroup_Cracked;
2296 let Defs = [CARRY, CR0] in
2297 def ADDIC_rec : DForm_2<13, (outs gprc:$RST), (ins gprc:$RA, s16imm:$D),
2298 "addic. $RST, $RA, $D", IIC_IntGeneral,
2299 []>, isRecordForm, RecFormRel;
2301 def ADDIS : DForm_2<15, (outs gprc:$RST), (ins gprc_nor0:$RA, s17imm:$D),
2302 "addis $RST, $RA, $D", IIC_IntSimple,
2303 [(set i32:$RST, (add i32:$RA, imm16ShiftedSExt:$D))]>;
2304 let isCodeGenOnly = 1 in
2305 def LA : DForm_2<14, (outs gprc:$RST), (ins gprc_nor0:$RA, s16imm:$D),
2306 "la $RST, $D($RA)", IIC_IntGeneral,
2307 [(set i32:$RST, (add i32:$RA,
2308 (PPClo tglobaladdr:$D, 0)))]>, MemriOp;
2309 def MULLI : DForm_2< 7, (outs gprc:$RST), (ins gprc:$RA, s16imm:$D),
2310 "mulli $RST, $RA, $D", IIC_IntMulLI,
2311 [(set i32:$RST, (mul i32:$RA, imm32SExt16:$D))]>;
2312 let Defs = [CARRY] in
2313 def SUBFIC : DForm_2< 8, (outs gprc:$RST), (ins gprc:$RA, s16imm:$D),
2314 "subfic $RST, $RA, $D", IIC_IntGeneral,
2315 [(set i32:$RST, (subc imm32SExt16:$D, i32:$RA))]>;
2317 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
2318 def LI : DForm_2_r0<14, (outs gprc:$RST), (ins s16imm:$D),
2319 "li $RST, $D", IIC_IntSimple,
2320 [(set i32:$RST, imm32SExt16:$D)]>, SExt32To64;
2321 def LIS : DForm_2_r0<15, (outs gprc:$RST), (ins s17imm:$D),
2322 "lis $RST, $D", IIC_IntSimple,
2323 [(set i32:$RST, imm16ShiftedSExt:$D)]>, SExt32To64;
2327 def : InstAlias<"li $rD, $imm", (ADDI gprc:$rD, ZERO, s16imm:$imm)>;
2328 def : InstAlias<"lis $rD, $imm", (ADDIS gprc:$rD, ZERO, s17imm:$imm)>;
2330 let PPC970_Unit = 1 in { // FXU Operations.
2331 let Defs = [CR0] in {
2332 def ANDI_rec : DForm_4<28, (outs gprc:$RA), (ins gprc:$RST, u16imm:$D),
2333 "andi. $RA, $RST, $D", IIC_IntGeneral,
2334 [(set i32:$RA, (and i32:$RST, immZExt16:$D))]>,
2335 isRecordForm, ZExt32To64, SExt32To64;
2336 def ANDIS_rec : DForm_4<29, (outs gprc:$RA), (ins gprc:$RST, u16imm:$D),
2337 "andis. $RA, $RST, $D", IIC_IntGeneral,
2338 [(set i32:$RA, (and i32:$RST, imm16ShiftedZExt:$D))]>,
2339 isRecordForm, ZExt32To64;
2341 def ORI : DForm_4<24, (outs gprc:$RA), (ins gprc:$RST, u16imm:$D),
2342 "ori $RA, $RST, $D", IIC_IntSimple,
2343 [(set i32:$RA, (or i32:$RST, immZExt16:$D))]>;
2344 def ORIS : DForm_4<25, (outs gprc:$RA), (ins gprc:$RST, u16imm:$D),
2345 "oris $RA, $RST, $D", IIC_IntSimple,
2346 [(set i32:$RA, (or i32:$RST, imm16ShiftedZExt:$D))]>;
2347 def XORI : DForm_4<26, (outs gprc:$RA), (ins gprc:$RST, u16imm:$D),
2348 "xori $RA, $RST, $D", IIC_IntSimple,
2349 [(set i32:$RA, (xor i32:$RST, immZExt16:$D))]>;
2350 def XORIS : DForm_4<27, (outs gprc:$RA), (ins gprc:$RST, u16imm:$D),
2351 "xoris $RA, $RST, $D", IIC_IntSimple,
2352 [(set i32:$RA, (xor i32:$RST, imm16ShiftedZExt:$D))]>;
2354 def NOP : DForm_4_zero<24, (outs), (ins), "nop", IIC_IntSimple,
2356 let isCodeGenOnly = 1 in {
2357 // The POWER6 and POWER7 have special group-terminating nops.
2358 def NOP_GT_PWR6 : DForm_4_fixedreg_zero<24, 1, (outs), (ins),
2359 "ori 1, 1, 0", IIC_IntSimple, []>;
2360 def NOP_GT_PWR7 : DForm_4_fixedreg_zero<24, 2, (outs), (ins),
2361 "ori 2, 2, 0", IIC_IntSimple, []>;
2364 let isCompare = 1, hasSideEffects = 0 in {
2365 def CMPWI : DForm_5_ext<11, (outs crrc:$BF), (ins gprc:$RA, s16imm:$D),
2366 "cmpwi $BF, $RA, $D", IIC_IntCompare>;
2367 def CMPLWI : DForm_6_ext<10, (outs crrc:$BF), (ins gprc:$RA, u16imm:$D),
2368 "cmplwi $BF, $RA, $D", IIC_IntCompare>;
2369 def CMPRB : X_BF3_L1_RS5_RS5<31, 192, (outs crrc:$BF),
2370 (ins u1imm:$L, gprc:$RA, gprc:$RB),
2371 "cmprb $BF, $L, $RA, $RB", IIC_IntCompare, []>,
2372 Requires<[IsISA3_0]>;
2376 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2377 let isCommutable = 1 in {
2378 defm NAND : XForm_6r<31, 476, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2379 "nand", "$RA, $RST, $RB", IIC_IntSimple,
2380 [(set i32:$RA, (not (and i32:$RST, i32:$RB)))]>;
2381 defm AND : XForm_6r<31, 28, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2382 "and", "$RA, $RST, $RB", IIC_IntSimple,
2383 [(set i32:$RA, (and i32:$RST, i32:$RB))]>;
2385 defm ANDC : XForm_6r<31, 60, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2386 "andc", "$RA, $RST, $RB", IIC_IntSimple,
2387 [(set i32:$RA, (and i32:$RST, (not i32:$RB)))]>;
2388 let isCommutable = 1 in {
2389 defm OR : XForm_6r<31, 444, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2390 "or", "$RA, $RST, $RB", IIC_IntSimple,
2391 [(set i32:$RA, (or i32:$RST, i32:$RB))]>;
2392 defm NOR : XForm_6r<31, 124, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2393 "nor", "$RA, $RST, $RB", IIC_IntSimple,
2394 [(set i32:$RA, (not (or i32:$RST, i32:$RB)))]>;
2396 defm ORC : XForm_6r<31, 412, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2397 "orc", "$RA, $RST, $RB", IIC_IntSimple,
2398 [(set i32:$RA, (or i32:$RST, (not i32:$RB)))]>;
2399 let isCommutable = 1 in {
2400 defm EQV : XForm_6r<31, 284, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2401 "eqv", "$RA, $RST, $RB", IIC_IntSimple,
2402 [(set i32:$RA, (not (xor i32:$RST, i32:$RB)))]>;
2403 defm XOR : XForm_6r<31, 316, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2404 "xor", "$RA, $RST, $RB", IIC_IntSimple,
2405 [(set i32:$RA, (xor i32:$RST, i32:$RB))]>;
2407 defm SLW : XForm_6r<31, 24, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2408 "slw", "$RA, $RST, $RB", IIC_IntGeneral,
2409 [(set i32:$RA, (PPCshl i32:$RST, i32:$RB))]>, ZExt32To64;
2410 defm SRW : XForm_6r<31, 536, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2411 "srw", "$RA, $RST, $RB", IIC_IntGeneral,
2412 [(set i32:$RA, (PPCsrl i32:$RST, i32:$RB))]>, ZExt32To64;
2413 defm SRAW : XForm_6rc<31, 792, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2414 "sraw", "$RA, $RST, $RB", IIC_IntShift,
2415 [(set i32:$RA, (PPCsra i32:$RST, i32:$RB))]>, SExt32To64;
2418 def : InstAlias<"mr $rA, $rB", (OR gprc:$rA, gprc:$rB, gprc:$rB)>;
2419 def : InstAlias<"mr. $rA, $rB", (OR_rec gprc:$rA, gprc:$rB, gprc:$rB)>;
2421 def : InstAlias<"not $rA, $rS", (NOR gprc:$rA, gprc:$rS, gprc:$rS)>;
2422 def : InstAlias<"not. $rA, $rS", (NOR_rec gprc:$rA, gprc:$rS, gprc:$rS)>;
2424 def : InstAlias<"nop", (ORI R0, R0, 0)>;
2426 let PPC970_Unit = 1 in { // FXU Operations.
2427 let hasSideEffects = 0 in {
2428 defm SRAWI : XForm_10rc<31, 824, (outs gprc:$RA), (ins gprc:$RST, u5imm:$RB),
2429 "srawi", "$RA, $RST, $RB", IIC_IntShift,
2430 [(set i32:$RA, (sra i32:$RST, (i32 imm:$RB)))]>,
2432 defm CNTLZW : XForm_11r<31, 26, (outs gprc:$RA), (ins gprc:$RST),
2433 "cntlzw", "$RA, $RST", IIC_IntGeneral,
2434 [(set i32:$RA, (ctlz i32:$RST))]>, ZExt32To64;
2435 defm CNTTZW : XForm_11r<31, 538, (outs gprc:$RA), (ins gprc:$RST),
2436 "cnttzw", "$RA, $RST", IIC_IntGeneral,
2437 [(set i32:$RA, (cttz i32:$RST))]>, Requires<[IsISA3_0]>,
2439 defm EXTSB : XForm_11r<31, 954, (outs gprc:$RA), (ins gprc:$RST),
2440 "extsb", "$RA, $RST", IIC_IntSimple,
2441 [(set i32:$RA, (sext_inreg i32:$RST, i8))]>, SExt32To64;
2442 defm EXTSH : XForm_11r<31, 922, (outs gprc:$RA), (ins gprc:$RST),
2443 "extsh", "$RA, $RST", IIC_IntSimple,
2444 [(set i32:$RA, (sext_inreg i32:$RST, i16))]>, SExt32To64;
2446 let isCommutable = 1 in
2447 def CMPB : XForm_6<31, 508, (outs gprc:$RA), (ins gprc:$RST, gprc:$RB),
2448 "cmpb $RA, $RST, $RB", IIC_IntGeneral,
2449 [(set i32:$RA, (PPCcmpb i32:$RST, i32:$RB))]>;
2451 let isCompare = 1, hasSideEffects = 0 in {
2452 def CMPW : XForm_16_ext<31, 0, (outs crrc:$BF), (ins gprc:$RA, gprc:$RB),
2453 "cmpw $BF, $RA, $RB", IIC_IntCompare>;
2454 def CMPLW : XForm_16_ext<31, 32, (outs crrc:$BF), (ins gprc:$RA, gprc:$RB),
2455 "cmplw $BF, $RA, $RB", IIC_IntCompare>;
2458 let PPC970_Unit = 3, Predicates = [HasFPU] in { // FPU Operations.
2459 let isCompare = 1, mayRaiseFPException = 1, hasSideEffects = 0 in {
2460 def FCMPUS : XForm_17<63, 0, (outs crrc:$BF), (ins f4rc:$RA, f4rc:$RB),
2461 "fcmpu $BF, $RA, $RB", IIC_FPCompare>;
2462 def FCMPOS : XForm_17<63, 32, (outs crrc:$BF), (ins f4rc:$RA, f4rc:$RB),
2463 "fcmpo $BF, $RA, $RB", IIC_FPCompare>;
2464 let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
2465 def FCMPUD : XForm_17<63, 0, (outs crrc:$BF), (ins f8rc:$RA, f8rc:$RB),
2466 "fcmpu $BF, $RA, $RB", IIC_FPCompare>;
2467 def FCMPOD : XForm_17<63, 32, (outs crrc:$BF), (ins f8rc:$RA, f8rc:$RB),
2468 "fcmpo $BF, $RA, $RB", IIC_FPCompare>;
2472 def FTDIV: XForm_17<63, 128, (outs crrc:$BF), (ins f8rc:$RA, f8rc:$RB),
2473 "ftdiv $BF, $RA, $RB", IIC_FPCompare>;
2474 def FTSQRT: XForm_17a<63, 160, (outs crrc:$BF), (ins f8rc:$RB),
2475 "ftsqrt $BF, $RB", IIC_FPCompare,
2476 [(set i32:$BF, (PPCftsqrt f64:$RB))]>;
2478 let mayRaiseFPException = 1, hasSideEffects = 0 in {
2479 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2480 defm FRIND : XForm_26r<63, 392, (outs f8rc:$RST), (ins f8rc:$RB),
2481 "frin", "$RST, $RB", IIC_FPGeneral,
2482 [(set f64:$RST, (any_fround f64:$RB))]>;
2483 defm FRINS : XForm_26r<63, 392, (outs f4rc:$RST), (ins f4rc:$RB),
2484 "frin", "$RST, $RB", IIC_FPGeneral,
2485 [(set f32:$RST, (any_fround f32:$RB))]>;
2487 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2488 defm FRIPD : XForm_26r<63, 456, (outs f8rc:$RST), (ins f8rc:$RB),
2489 "frip", "$RST, $RB", IIC_FPGeneral,
2490 [(set f64:$RST, (any_fceil f64:$RB))]>;
2491 defm FRIPS : XForm_26r<63, 456, (outs f4rc:$RST), (ins f4rc:$RB),
2492 "frip", "$RST, $RB", IIC_FPGeneral,
2493 [(set f32:$RST, (any_fceil f32:$RB))]>;
2494 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2495 defm FRIZD : XForm_26r<63, 424, (outs f8rc:$RST), (ins f8rc:$RB),
2496 "friz", "$RST, $RB", IIC_FPGeneral,
2497 [(set f64:$RST, (any_ftrunc f64:$RB))]>;
2498 defm FRIZS : XForm_26r<63, 424, (outs f4rc:$RST), (ins f4rc:$RB),
2499 "friz", "$RST, $RB", IIC_FPGeneral,
2500 [(set f32:$RST, (any_ftrunc f32:$RB))]>;
2501 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2502 defm FRIMD : XForm_26r<63, 488, (outs f8rc:$RST), (ins f8rc:$RB),
2503 "frim", "$RST, $RB", IIC_FPGeneral,
2504 [(set f64:$RST, (any_ffloor f64:$RB))]>;
2505 defm FRIMS : XForm_26r<63, 488, (outs f4rc:$RST), (ins f4rc:$RB),
2506 "frim", "$RST, $RB", IIC_FPGeneral,
2507 [(set f32:$RST, (any_ffloor f32:$RB))]>;
2510 let Uses = [RM], mayRaiseFPException = 1, hasSideEffects = 0 in {
2511 defm FCTIW : XForm_26r<63, 14, (outs f8rc:$RST), (ins f8rc:$RB),
2512 "fctiw", "$RST, $RB", IIC_FPGeneral,
2514 defm FCTIWU : XForm_26r<63, 142, (outs f8rc:$RST), (ins f8rc:$RB),
2515 "fctiwu", "$RST, $RB", IIC_FPGeneral,
2517 defm FCTIWZ : XForm_26r<63, 15, (outs f8rc:$RST), (ins f8rc:$RB),
2518 "fctiwz", "$RST, $RB", IIC_FPGeneral,
2519 [(set f64:$RST, (PPCany_fctiwz f64:$RB))]>;
2521 defm FRSP : XForm_26r<63, 12, (outs f4rc:$RST), (ins f8rc:$RB),
2522 "frsp", "$RST, $RB", IIC_FPGeneral,
2523 [(set f32:$RST, (any_fpround f64:$RB))]>;
2525 defm FSQRT : XForm_26r<63, 22, (outs f8rc:$RST), (ins f8rc:$RB),
2526 "fsqrt", "$RST, $RB", IIC_FPSqrtD,
2527 [(set f64:$RST, (any_fsqrt f64:$RB))]>;
2528 defm FSQRTS : XForm_26r<59, 22, (outs f4rc:$RST), (ins f4rc:$RB),
2529 "fsqrts", "$RST, $RB", IIC_FPSqrtS,
2530 [(set f32:$RST, (any_fsqrt f32:$RB))]>;
2534 def : Pat<(PPCfsqrt f64:$frA), (FSQRT $frA)>;
2536 /// Note that FMR is defined as pseudo-ops on the PPC970 because they are
2537 /// often coalesced away and we don't want the dispatch group builder to think
2538 /// that they will fill slots (which could cause the load of a LSU reject to
2539 /// sneak into a d-group with a store).
2540 let hasSideEffects = 0, Predicates = [HasFPU] in
2541 defm FMR : XForm_26r<63, 72, (outs f4rc:$RST), (ins f4rc:$RB),
2542 "fmr", "$RST, $RB", IIC_FPGeneral,
2543 []>, // (set f32:$RST, f32:$RB)
2546 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2547 // These are artificially split into two different forms, for 4/8 byte FP.
2548 defm FABSS : XForm_26r<63, 264, (outs f4rc:$RST), (ins f4rc:$RB),
2549 "fabs", "$RST, $RB", IIC_FPGeneral,
2550 [(set f32:$RST, (fabs f32:$RB))]>;
2551 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2552 defm FABSD : XForm_26r<63, 264, (outs f8rc:$RST), (ins f8rc:$RB),
2553 "fabs", "$RST, $RB", IIC_FPGeneral,
2554 [(set f64:$RST, (fabs f64:$RB))]>;
2555 defm FNABSS : XForm_26r<63, 136, (outs f4rc:$RST), (ins f4rc:$RB),
2556 "fnabs", "$RST, $RB", IIC_FPGeneral,
2557 [(set f32:$RST, (fneg (fabs f32:$RB)))]>;
2558 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2559 defm FNABSD : XForm_26r<63, 136, (outs f8rc:$RST), (ins f8rc:$RB),
2560 "fnabs", "$RST, $RB", IIC_FPGeneral,
2561 [(set f64:$RST, (fneg (fabs f64:$RB)))]>;
2562 defm FNEGS : XForm_26r<63, 40, (outs f4rc:$RST), (ins f4rc:$RB),
2563 "fneg", "$RST, $RB", IIC_FPGeneral,
2564 [(set f32:$RST, (fneg f32:$RB))]>;
2565 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2566 defm FNEGD : XForm_26r<63, 40, (outs f8rc:$RST), (ins f8rc:$RB),
2567 "fneg", "$RST, $RB", IIC_FPGeneral,
2568 [(set f64:$RST, (fneg f64:$RB))]>;
2570 defm FCPSGNS : XForm_28r<63, 8, (outs f4rc:$RST), (ins f4rc:$RA, f4rc:$RB),
2571 "fcpsgn", "$RST, $RA, $RB", IIC_FPGeneral,
2572 [(set f32:$RST, (fcopysign f32:$RB, f32:$RA))]>;
2573 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
2574 defm FCPSGND : XForm_28r<63, 8, (outs f8rc:$RST), (ins f8rc:$RA, f8rc:$RB),
2575 "fcpsgn", "$RST, $RA, $RB", IIC_FPGeneral,
2576 [(set f64:$RST, (fcopysign f64:$RB, f64:$RA))]>;
2578 // Reciprocal estimates.
2579 let mayRaiseFPException = 1 in {
2580 defm FRE : XForm_26r<63, 24, (outs f8rc:$RST), (ins f8rc:$RB),
2581 "fre", "$RST, $RB", IIC_FPGeneral,
2582 [(set f64:$RST, (PPCfre f64:$RB))]>;
2583 defm FRES : XForm_26r<59, 24, (outs f4rc:$RST), (ins f4rc:$RB),
2584 "fres", "$RST, $RB", IIC_FPGeneral,
2585 [(set f32:$RST, (PPCfre f32:$RB))]>;
2586 defm FRSQRTE : XForm_26r<63, 26, (outs f8rc:$RST), (ins f8rc:$RB),
2587 "frsqrte", "$RST, $RB", IIC_FPGeneral,
2588 [(set f64:$RST, (PPCfrsqrte f64:$RB))]>;
2589 defm FRSQRTES : XForm_26r<59, 26, (outs f4rc:$RST), (ins f4rc:$RB),
2590 "frsqrtes", "$RST, $RB", IIC_FPGeneral,
2591 [(set f32:$RST, (PPCfrsqrte f32:$RB))]>;
2595 // XL-Form instructions. condition register logical ops.
2597 let hasSideEffects = 0 in
2598 def MCRF : XLForm_3<19, 0, (outs crrc:$BF), (ins crrc:$BFA),
2599 "mcrf $BF, $BFA", IIC_BrMCR>,
2600 PPC970_DGroup_First, PPC970_Unit_CRU;
2602 // FIXME: According to the ISA (section 2.5.1 of version 2.06), the
2603 // condition-register logical instructions have preferred forms. Specifically,
2604 // it is preferred that the bit specified by the BT field be in the same
2605 // condition register as that specified by the bit BB. We might want to account
2606 // for this via hinting the register allocator and anti-dep breakers, or we
2607 // could constrain the register class to force this constraint and then loosen
2608 // it during register allocation via convertToThreeAddress or some similar
2611 let isCommutable = 1 in {
2612 def CRAND : XLForm_1<19, 257, (outs crbitrc:$CRD),
2613 (ins crbitrc:$CRA, crbitrc:$CRB),
2614 "crand $CRD, $CRA, $CRB", IIC_BrCR,
2615 [(set i1:$CRD, (and i1:$CRA, i1:$CRB))]>;
2617 def CRNAND : XLForm_1<19, 225, (outs crbitrc:$CRD),
2618 (ins crbitrc:$CRA, crbitrc:$CRB),
2619 "crnand $CRD, $CRA, $CRB", IIC_BrCR,
2620 [(set i1:$CRD, (not (and i1:$CRA, i1:$CRB)))]>;
2622 def CROR : XLForm_1<19, 449, (outs crbitrc:$CRD),
2623 (ins crbitrc:$CRA, crbitrc:$CRB),
2624 "cror $CRD, $CRA, $CRB", IIC_BrCR,
2625 [(set i1:$CRD, (or i1:$CRA, i1:$CRB))]>;
2627 def CRXOR : XLForm_1<19, 193, (outs crbitrc:$CRD),
2628 (ins crbitrc:$CRA, crbitrc:$CRB),
2629 "crxor $CRD, $CRA, $CRB", IIC_BrCR,
2630 [(set i1:$CRD, (xor i1:$CRA, i1:$CRB))]>;
2632 def CRNOR : XLForm_1<19, 33, (outs crbitrc:$CRD),
2633 (ins crbitrc:$CRA, crbitrc:$CRB),
2634 "crnor $CRD, $CRA, $CRB", IIC_BrCR,
2635 [(set i1:$CRD, (not (or i1:$CRA, i1:$CRB)))]>;
2636 def CREQV : XLForm_1<19, 289, (outs crbitrc:$CRD),
2637 (ins crbitrc:$CRA, crbitrc:$CRB),
2638 "creqv $CRD, $CRA, $CRB", IIC_BrCR,
2639 [(set i1:$CRD, (not (xor i1:$CRA, i1:$CRB)))]>;
2642 let isCodeGenOnly = 1 in
2643 def CRNOT : XLForm_1s<19, 33, (outs crbitrc:$CRD), (ins crbitrc:$CRA),
2644 "crnot $CRD, $CRA", IIC_BrCR,
2645 [(set i1:$CRD, (not i1:$CRA))]>;
2647 def CRANDC : XLForm_1<19, 129, (outs crbitrc:$CRD),
2648 (ins crbitrc:$CRA, crbitrc:$CRB),
2649 "crandc $CRD, $CRA, $CRB", IIC_BrCR,
2650 [(set i1:$CRD, (and i1:$CRA, (not i1:$CRB)))]>;
2652 def CRORC : XLForm_1<19, 417, (outs crbitrc:$CRD),
2653 (ins crbitrc:$CRA, crbitrc:$CRB),
2654 "crorc $CRD, $CRA, $CRB", IIC_BrCR,
2655 [(set i1:$CRD, (or i1:$CRA, (not i1:$CRB)))]>;
2657 let isCodeGenOnly = 1 in {
2658 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
2659 def CRSET : XLForm_1_ext<19, 289, (outs crbitrc:$CRD), (ins),
2660 "creqv $CRD, $CRD, $CRD", IIC_BrCR,
2661 [(set i1:$CRD, 1)]>;
2663 def CRUNSET: XLForm_1_ext<19, 193, (outs crbitrc:$CRD), (ins),
2664 "crxor $CRD, $CRD, $CRD", IIC_BrCR,
2665 [(set i1:$CRD, 0)]>;
2668 let Defs = [CR1EQ], CRD = 6 in {
2669 def CR6SET : XLForm_1_ext<19, 289, (outs), (ins),
2670 "creqv 6, 6, 6", IIC_BrCR,
2673 def CR6UNSET: XLForm_1_ext<19, 193, (outs), (ins),
2674 "crxor 6, 6, 6", IIC_BrCR,
2679 // XFX-Form instructions. Instructions that deal with SPRs.
2682 def MFSPR : XFXForm_1<31, 339, (outs gprc:$RST), (ins i32imm:$SPR),
2683 "mfspr $RST, $SPR", IIC_SprMFSPR>;
2684 def MTSPR : XFXForm_1<31, 467, (outs), (ins i32imm:$SPR, gprc:$RST),
2685 "mtspr $SPR, $RST", IIC_SprMTSPR>;
2687 def MFTB : XFXForm_1<31, 371, (outs gprc:$RST), (ins i32imm:$SPR),
2688 "mftb $RST, $SPR", IIC_SprMFTB>;
2690 def MFPMR : XFXForm_1<31, 334, (outs gprc:$RST), (ins i32imm:$SPR),
2691 "mfpmr $RST, $SPR", IIC_SprMFPMR>;
2693 def MTPMR : XFXForm_1<31, 462, (outs), (ins i32imm:$SPR, gprc:$RST),
2694 "mtpmr $SPR, $RST", IIC_SprMTPMR>;
2697 // A pseudo-instruction used to implement the read of the 64-bit cycle counter
2698 // on a 32-bit target.
2699 let hasSideEffects = 1 in
2700 def ReadTB : PPCCustomInserterPseudo<(outs gprc:$lo, gprc:$hi), (ins),
2703 let Uses = [CTR] in {
2704 def MFCTR : XFXForm_1_ext<31, 339, 9, (outs gprc:$RST), (ins),
2705 "mfctr $RST", IIC_SprMFSPR>,
2706 PPC970_DGroup_First, PPC970_Unit_FXU;
2708 let Defs = [CTR], Pattern = [(PPCmtctr i32:$RST)] in {
2709 def MTCTR : XFXForm_1_ext<31, 467, 9, (outs), (ins gprc:$RST),
2710 "mtctr $RST", IIC_SprMTSPR>,
2711 PPC970_DGroup_First, PPC970_Unit_FXU;
2713 let hasSideEffects = 1, isCodeGenOnly = 1, isNotDuplicable = 1, Defs = [CTR] in {
2714 let Pattern = [(int_set_loop_iterations i32:$RST)] in
2715 def MTCTRloop : XFXForm_1_ext<31, 467, 9, (outs), (ins gprc:$RST),
2716 "mtctr $RST", IIC_SprMTSPR>,
2717 PPC970_DGroup_First, PPC970_Unit_FXU;
2720 let hasSideEffects = 1, hasNoSchedulingInfo = 1, isNotDuplicable = 1, Uses = [CTR], Defs = [CTR] in
2721 def DecreaseCTRloop : PPCEmitTimePseudo<(outs crbitrc:$rT), (ins i32imm:$stride),
2722 "#DecreaseCTRloop", [(set i1:$rT, (int_loop_decrement (i32 imm:$stride)))]>;
2724 let hasSideEffects = 0 in {
2725 let Defs = [LR] in {
2726 def MTLR : XFXForm_1_ext<31, 467, 8, (outs), (ins gprc:$RST),
2727 "mtlr $RST", IIC_SprMTSPR>,
2728 PPC970_DGroup_First, PPC970_Unit_FXU;
2730 let Uses = [LR] in {
2731 def MFLR : XFXForm_1_ext<31, 339, 8, (outs gprc:$RST), (ins),
2732 "mflr $RST", IIC_SprMFSPR>,
2733 PPC970_DGroup_First, PPC970_Unit_FXU;
2737 let hasSideEffects = 1 in {
2738 def MTUDSCR : XFXForm_1_ext<31, 467, 3, (outs), (ins gprc:$RST),
2739 "mtspr 3, $RST", IIC_SprMTSPR>,
2740 PPC970_DGroup_Single, PPC970_Unit_FXU;
2741 def MFUDSCR : XFXForm_1_ext<31, 339, 3, (outs gprc:$RST), (ins),
2742 "mfspr $RST, 3", IIC_SprMFSPR>,
2743 PPC970_DGroup_First, PPC970_Unit_FXU;
2746 // Disable these alias on AIX since they are not supported.
2747 let Predicates = [ModernAs] in {
2748 // Aliases for moving to/from dscr to mtspr/mfspr
2749 def : InstAlias<"mtudscr $Rx", (MTUDSCR gprc:$Rx)>;
2750 def : InstAlias<"mfudscr $Rx", (MFUDSCR gprc:$Rx)>;
2753 let isCodeGenOnly = 1 in {
2754 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed
2755 // like a GPR on the PPC970. As such, copies in and out have the same
2756 // performance characteristics as an OR instruction.
2757 def MTVRSAVE : XFXForm_1_ext<31, 467, 256, (outs), (ins gprc:$RST),
2758 "mtspr 256, $RST", IIC_IntGeneral>,
2759 PPC970_DGroup_Single, PPC970_Unit_FXU;
2760 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (outs gprc:$RST), (ins),
2761 "mfspr $RST, 256", IIC_IntGeneral>,
2762 PPC970_DGroup_First, PPC970_Unit_FXU;
2764 def MTVRSAVEv : XFXForm_1_ext<31, 467, 256,
2765 (outs VRSAVERC:$SPR), (ins gprc:$RST),
2766 "mtspr 256, $RST", IIC_IntGeneral>,
2767 PPC970_DGroup_Single, PPC970_Unit_FXU;
2768 def MFVRSAVEv : XFXForm_1_ext<31, 339, 256, (outs gprc:$RST),
2769 (ins VRSAVERC:$SPR),
2770 "mfspr $RST, 256", IIC_IntGeneral>,
2771 PPC970_DGroup_First, PPC970_Unit_FXU;
2774 // Aliases for mtvrsave/mfvrsave to mfspr/mtspr.
2775 def : InstAlias<"mtvrsave $rS", (MTVRSAVE gprc:$rS)>;
2776 def : InstAlias<"mfvrsave $rS", (MFVRSAVE gprc:$rS)>;
2778 let hasSideEffects = 0 in {
2779 // mtocrf's input needs to be prepared by shifting by an amount dependent
2780 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2781 // later change that register assignment.
2782 let hasExtraDefRegAllocReq = 1 in {
2783 def MTOCRF: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins gprc:$RST),
2784 "mtocrf $FXM, $RST", IIC_BrMCRX>,
2785 PPC970_DGroup_First, PPC970_Unit_CRU;
2787 // Similarly to mtocrf, the mask for mtcrf must be prepared in a way that
2788 // is dependent on the cr fields being set.
2789 def MTCRF : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, gprc:$RST),
2790 "mtcrf $FXM, $RST", IIC_BrMCRX>,
2791 PPC970_MicroCode, PPC970_Unit_CRU;
2792 } // hasExtraDefRegAllocReq = 1
2794 // mfocrf's input needs to be prepared by shifting by an amount dependent
2795 // on the cr register selected. Thus, post-ra anti-dep breaking must not
2796 // later change that register assignment.
2797 let hasExtraSrcRegAllocReq = 1 in {
2798 def MFOCRF: XFXForm_5a<31, 19, (outs gprc:$RST), (ins crbitm:$FXM),
2799 "mfocrf $RST, $FXM", IIC_SprMFCRF>,
2800 PPC970_DGroup_First, PPC970_Unit_CRU;
2802 // Similarly to mfocrf, the mask for mfcrf must be prepared in a way that
2803 // is dependent on the cr fields being copied.
2804 def MFCR : XFXForm_3<31, 19, (outs gprc:$RT), (ins),
2805 "mfcr $RT", IIC_SprMFCR>,
2806 PPC970_MicroCode, PPC970_Unit_CRU;
2807 } // hasExtraSrcRegAllocReq = 1
2809 def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
2810 "mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
2811 } // hasSideEffects = 0
2813 def : InstAlias<"mtcr $rA", (MTCRF 255, gprc:$rA)>;
2815 let Predicates = [HasFPU] in {
2816 // Custom inserter instruction to perform FADD in round-to-zero mode.
2817 let Uses = [RM], mayRaiseFPException = 1 in {
2818 def FADDrtz: PPCCustomInserterPseudo<(outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB), "",
2819 [(set f64:$FRT, (PPCany_faddrtz f64:$FRA, f64:$FRB))]>;
2822 // The above pseudo gets expanded to make use of the following instructions
2823 // to manipulate FPSCR. Note that FPSCR is not modeled at the DAG level.
2825 // When FM is 30/31, we are setting the 62/63 bit of FPSCR, the implicit-def
2826 // RM should be set.
2827 let hasSideEffects = 1, Defs = [RM] in {
2828 def MTFSB0 : XForm_43<63, 70, (outs), (ins u5imm:$FM),
2829 "mtfsb0 $FM", IIC_IntMTFSB0,
2830 [(int_ppc_mtfsb0 timm:$FM)]>,
2831 PPC970_DGroup_Single, PPC970_Unit_FPU;
2832 def MTFSB1 : XForm_43<63, 38, (outs), (ins u5imm:$FM),
2833 "mtfsb1 $FM", IIC_IntMTFSB0,
2834 [(int_ppc_mtfsb1 timm:$FM)]>,
2835 PPC970_DGroup_Single, PPC970_Unit_FPU;
2838 let Defs = [RM], hasSideEffects = 1 in {
2839 let isCodeGenOnly = 1 in
2840 def MTFSFb : XFLForm<63, 711, (outs), (ins i32imm:$FM, f8rc:$RT),
2841 "mtfsf $FM, $RT", IIC_IntMTFSB0,
2842 [(int_ppc_mtfsf timm:$FM, f64:$RT)]>,
2843 PPC970_DGroup_Single, PPC970_Unit_FPU;
2845 let Uses = [RM], hasSideEffects = 1 in {
2846 def MFFS : XForm_42<63, 583, (outs f8rc:$RST), (ins),
2847 "mffs $RST", IIC_IntMFFS,
2848 [(set f64:$RST, (PPCmffs))]>,
2849 PPC970_DGroup_Single, PPC970_Unit_FPU;
2852 def MFFS_rec : XForm_42<63, 583, (outs f8rc:$RST), (ins),
2853 "mffs. $RST", IIC_IntMFFS, []>, isRecordForm;
2855 def MFFSCE : X_FRT5_XO2_XO3_XO10<63, 0, 1, 583, (outs f8rc:$RST), (ins),
2856 "mffsce $RST", IIC_IntMFFS, []>,
2857 PPC970_DGroup_Single, PPC970_Unit_FPU;
2859 def MFFSCDRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 4, 583, (outs f8rc:$RST),
2860 (ins f8rc:$FRB), "mffscdrn $RST, $FRB",
2862 PPC970_DGroup_Single, PPC970_Unit_FPU;
2864 def MFFSCDRNI : X_FRT5_XO2_XO3_DRM3_XO10<63, 2, 5, 583, (outs f8rc:$RST),
2866 "mffscdrni $RST, $DRM",
2868 PPC970_DGroup_Single, PPC970_Unit_FPU;
2870 def MFFSCRN : X_FRT5_XO2_XO3_FRB5_XO10<63, 2, 6, 583, (outs f8rc:$RST),
2871 (ins f8rc:$FRB), "mffscrn $RST, $FRB",
2873 PPC970_DGroup_Single, PPC970_Unit_FPU;
2875 def MFFSCRNI : X_FRT5_XO2_XO3_RM2_X10<63, 2, 7, 583, (outs f8rc:$RST),
2876 (ins u2imm:$RM), "mffscrni $RST, $RM",
2878 PPC970_DGroup_Single, PPC970_Unit_FPU;
2880 def MFFSL : X_FRT5_XO2_XO3_XO10<63, 3, 0, 583, (outs f8rc:$RST), (ins),
2881 "mffsl $RST", IIC_IntMFFS, []>,
2882 PPC970_DGroup_Single, PPC970_Unit_FPU;
2886 let Predicates = [IsISA3_0] in {
2887 def MODSW : XForm_8<31, 779, (outs gprc:$RST), (ins gprc:$RA, gprc:$RB),
2888 "modsw $RST, $RA, $RB", IIC_IntDivW,
2889 [(set i32:$RST, (srem i32:$RA, i32:$RB))]>;
2890 def MODUW : XForm_8<31, 267, (outs gprc:$RST), (ins gprc:$RA, gprc:$RB),
2891 "moduw $RST, $RA, $RB", IIC_IntDivW,
2892 [(set i32:$RST, (urem i32:$RA, i32:$RB))]>;
2893 let hasSideEffects = 1 in
2894 def ADDEX : Z23Form_RTAB5_CY2<31, 170, (outs gprc:$RT),
2895 (ins gprc:$RA, gprc:$RB, u2imm:$CY),
2896 "addex $RT, $RA, $RB, $CY", IIC_IntGeneral, []>;
2899 let PPC970_Unit = 1, hasSideEffects = 0 in { // FXU Operations.
2900 // XO-Form instructions. Arithmetic instructions that can set overflow bit
2901 let isCommutable = 1 in
2902 defm ADD4 : XOForm_1rx<31, 266, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2903 "add", "$RT, $RA, $RB", IIC_IntSimple,
2904 [(set i32:$RT, (add i32:$RA, i32:$RB))]>;
2905 let isCodeGenOnly = 1 in
2906 def ADD4TLS : XOForm_1<31, 266, 0, (outs gprc:$RT), (ins gprc:$RA, tlsreg32:$RB),
2907 "add $RT, $RA, $RB", IIC_IntSimple,
2908 [(set i32:$RT, (add i32:$RA, tglobaltlsaddr:$RB))]>;
2909 let isCommutable = 1 in
2910 defm ADDC : XOForm_1rc<31, 10, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2911 "addc", "$RT, $RA, $RB", IIC_IntGeneral,
2912 [(set i32:$RT, (addc i32:$RA, i32:$RB))]>,
2913 PPC970_DGroup_Cracked;
2915 defm DIVW : XOForm_1rcr<31, 491, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2916 "divw", "$RT, $RA, $RB", IIC_IntDivW,
2917 [(set i32:$RT, (sdiv i32:$RA, i32:$RB))]>;
2918 defm DIVWU : XOForm_1rcr<31, 459, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2919 "divwu", "$RT, $RA, $RB", IIC_IntDivW,
2920 [(set i32:$RT, (udiv i32:$RA, i32:$RB))]>;
2921 defm DIVWE : XOForm_1rcr<31, 427, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2922 "divwe", "$RT, $RA, $RB", IIC_IntDivW,
2923 [(set i32:$RT, (int_ppc_divwe gprc:$RA, gprc:$RB))]>,
2924 Requires<[HasExtDiv]>;
2925 defm DIVWEU : XOForm_1rcr<31, 395, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2926 "divweu", "$RT, $RA, $RB", IIC_IntDivW,
2927 [(set i32:$RT, (int_ppc_divweu gprc:$RA, gprc:$RB))]>,
2928 Requires<[HasExtDiv]>;
2929 let isCommutable = 1 in {
2930 defm MULHW : XOForm_1r<31, 75, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2931 "mulhw", "$RT, $RA, $RB", IIC_IntMulHW,
2932 [(set i32:$RT, (mulhs i32:$RA, i32:$RB))]>;
2933 defm MULHWU : XOForm_1r<31, 11, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2934 "mulhwu", "$RT, $RA, $RB", IIC_IntMulHWU,
2935 [(set i32:$RT, (mulhu i32:$RA, i32:$RB))]>;
2936 defm MULLW : XOForm_1rx<31, 235, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2937 "mullw", "$RT, $RA, $RB", IIC_IntMulHW,
2938 [(set i32:$RT, (mul i32:$RA, i32:$RB))]>;
2940 defm SUBF : XOForm_1rx<31, 40, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2941 "subf", "$RT, $RA, $RB", IIC_IntGeneral,
2942 [(set i32:$RT, (sub i32:$RB, i32:$RA))]>;
2943 defm SUBFC : XOForm_1rc<31, 8, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2944 "subfc", "$RT, $RA, $RB", IIC_IntGeneral,
2945 [(set i32:$RT, (subc i32:$RB, i32:$RA))]>,
2946 PPC970_DGroup_Cracked;
2947 defm NEG : XOForm_3r<31, 104, 0, (outs gprc:$RT), (ins gprc:$RA),
2948 "neg", "$RT, $RA", IIC_IntSimple,
2949 [(set i32:$RT, (ineg i32:$RA))]>;
2950 let Uses = [CARRY] in {
2951 let isCommutable = 1 in
2952 defm ADDE : XOForm_1rc<31, 138, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2953 "adde", "$RT, $RA, $RB", IIC_IntGeneral,
2954 [(set i32:$RT, (adde i32:$RA, i32:$RB))]>;
2955 defm ADDME : XOForm_3rc<31, 234, 0, (outs gprc:$RT), (ins gprc:$RA),
2956 "addme", "$RT, $RA", IIC_IntGeneral,
2957 [(set i32:$RT, (adde i32:$RA, -1))]>;
2958 defm ADDZE : XOForm_3rc<31, 202, 0, (outs gprc:$RT), (ins gprc:$RA),
2959 "addze", "$RT, $RA", IIC_IntGeneral,
2960 [(set i32:$RT, (adde i32:$RA, 0))]>;
2961 defm SUBFE : XOForm_1rc<31, 136, 0, (outs gprc:$RT), (ins gprc:$RA, gprc:$RB),
2962 "subfe", "$RT, $RA, $RB", IIC_IntGeneral,
2963 [(set i32:$RT, (sube i32:$RB, i32:$RA))]>;
2964 defm SUBFME : XOForm_3rc<31, 232, 0, (outs gprc:$RT), (ins gprc:$RA),
2965 "subfme", "$RT, $RA", IIC_IntGeneral,
2966 [(set i32:$RT, (sube -1, i32:$RA))]>;
2967 defm SUBFZE : XOForm_3rc<31, 200, 0, (outs gprc:$RT), (ins gprc:$RA),
2968 "subfze", "$RT, $RA", IIC_IntGeneral,
2969 [(set i32:$RT, (sube 0, i32:$RA))]>;
2973 def : InstAlias<"sub $rA, $rB, $rC", (SUBF gprc:$rA, gprc:$rC, gprc:$rB)>;
2974 def : InstAlias<"sub. $rA, $rB, $rC", (SUBF_rec gprc:$rA, gprc:$rC, gprc:$rB)>;
2975 def : InstAlias<"subc $rA, $rB, $rC", (SUBFC gprc:$rA, gprc:$rC, gprc:$rB)>;
2976 def : InstAlias<"subc. $rA, $rB, $rC", (SUBFC_rec gprc:$rA, gprc:$rC, gprc:$rB)>;
2978 // A-Form instructions. Most of the instructions executed in the FPU are of
2981 let PPC970_Unit = 3, hasSideEffects = 0, Predicates = [HasFPU] in { // FPU Operations.
2982 let mayRaiseFPException = 1, Uses = [RM] in {
2983 let isCommutable = 1 in {
2984 defm FMADD : AForm_1r<63, 29,
2985 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2986 "fmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2987 [(set f64:$FRT, (any_fma f64:$FRA, f64:$FRC, f64:$FRB))]>;
2988 defm FMADDS : AForm_1r<59, 29,
2989 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2990 "fmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
2991 [(set f32:$FRT, (any_fma f32:$FRA, f32:$FRC, f32:$FRB))]>;
2992 defm FMSUB : AForm_1r<63, 28,
2993 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
2994 "fmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
2996 (any_fma f64:$FRA, f64:$FRC, (fneg f64:$FRB)))]>;
2997 defm FMSUBS : AForm_1r<59, 28,
2998 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
2999 "fmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
3001 (any_fma f32:$FRA, f32:$FRC, (fneg f32:$FRB)))]>;
3002 defm FNMADD : AForm_1r<63, 31,
3003 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
3004 "fnmadd", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
3006 (fneg (any_fma f64:$FRA, f64:$FRC, f64:$FRB)))]>;
3007 defm FNMADDS : AForm_1r<59, 31,
3008 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
3009 "fnmadds", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
3011 (fneg (any_fma f32:$FRA, f32:$FRC, f32:$FRB)))]>;
3012 defm FNMSUB : AForm_1r<63, 30,
3013 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
3014 "fnmsub", "$FRT, $FRA, $FRC, $FRB", IIC_FPFused,
3015 [(set f64:$FRT, (fneg (any_fma f64:$FRA, f64:$FRC,
3016 (fneg f64:$FRB))))]>;
3017 defm FNMSUBS : AForm_1r<59, 30,
3018 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC, f4rc:$FRB),
3019 "fnmsubs", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
3020 [(set f32:$FRT, (fneg (any_fma f32:$FRA, f32:$FRC,
3021 (fneg f32:$FRB))))]>;
3024 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
3025 // having 4 of these, force the comparison to always be an 8-byte double (code
3026 // should use an FMRSD if the input comparison value really wants to be a float)
3027 // and 4/8 byte forms for the result and operand type..
3028 let Interpretation64Bit = 1, isCodeGenOnly = 1 in
3029 defm FSELD : AForm_1r<63, 23,
3030 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC, f8rc:$FRB),
3031 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
3032 [(set f64:$FRT, (PPCfsel f64:$FRA, f64:$FRC, f64:$FRB))]>;
3033 defm FSELS : AForm_1r<63, 23,
3034 (outs f4rc:$FRT), (ins f8rc:$FRA, f4rc:$FRC, f4rc:$FRB),
3035 "fsel", "$FRT, $FRA, $FRC, $FRB", IIC_FPGeneral,
3036 [(set f32:$FRT, (PPCfsel f64:$FRA, f32:$FRC, f32:$FRB))]>;
3037 let Uses = [RM], mayRaiseFPException = 1 in {
3038 let isCommutable = 1 in {
3039 defm FADD : AForm_2r<63, 21,
3040 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
3041 "fadd", "$FRT, $FRA, $FRB", IIC_FPAddSub,
3042 [(set f64:$FRT, (any_fadd f64:$FRA, f64:$FRB))]>;
3043 defm FADDS : AForm_2r<59, 21,
3044 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
3045 "fadds", "$FRT, $FRA, $FRB", IIC_FPGeneral,
3046 [(set f32:$FRT, (any_fadd f32:$FRA, f32:$FRB))]>;
3048 defm FDIV : AForm_2r<63, 18,
3049 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
3050 "fdiv", "$FRT, $FRA, $FRB", IIC_FPDivD,
3051 [(set f64:$FRT, (any_fdiv f64:$FRA, f64:$FRB))]>;
3052 defm FDIVS : AForm_2r<59, 18,
3053 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
3054 "fdivs", "$FRT, $FRA, $FRB", IIC_FPDivS,
3055 [(set f32:$FRT, (any_fdiv f32:$FRA, f32:$FRB))]>;
3056 let isCommutable = 1 in {
3057 defm FMUL : AForm_3r<63, 25,
3058 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRC),
3059 "fmul", "$FRT, $FRA, $FRC", IIC_FPFused,
3060 [(set f64:$FRT, (any_fmul f64:$FRA, f64:$FRC))]>;
3061 defm FMULS : AForm_3r<59, 25,
3062 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRC),
3063 "fmuls", "$FRT, $FRA, $FRC", IIC_FPGeneral,
3064 [(set f32:$FRT, (any_fmul f32:$FRA, f32:$FRC))]>;
3066 defm FSUB : AForm_2r<63, 20,
3067 (outs f8rc:$FRT), (ins f8rc:$FRA, f8rc:$FRB),
3068 "fsub", "$FRT, $FRA, $FRB", IIC_FPAddSub,
3069 [(set f64:$FRT, (any_fsub f64:$FRA, f64:$FRB))]>;
3070 defm FSUBS : AForm_2r<59, 20,
3071 (outs f4rc:$FRT), (ins f4rc:$FRA, f4rc:$FRB),
3072 "fsubs", "$FRT, $FRA, $FRB", IIC_FPGeneral,
3073 [(set f32:$FRT, (any_fsub f32:$FRA, f32:$FRB))]>;
3077 let hasSideEffects = 0 in {
3078 let PPC970_Unit = 1 in { // FXU Operations.
3080 def ISEL : AForm_4<31, 15,
3081 (outs gprc:$RT), (ins gprc_nor0:$RA, gprc:$RB, crbitrc:$COND),
3082 "isel $RT, $RA, $RB, $COND", IIC_IntISEL,
3086 let PPC970_Unit = 1 in { // FXU Operations.
3087 // M-Form instructions. rotate and mask instructions.
3089 let isCommutable = 1 in {
3090 // RLWIMI can be commuted if the rotate amount is zero.
3091 defm RLWIMI : MForm_2r<20, (outs gprc:$RA),
3092 (ins gprc:$RAi, gprc:$RS, u5imm:$SH, u5imm:$MB,
3093 u5imm:$ME), "rlwimi", "$RA, $RS, $SH, $MB, $ME",
3094 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
3095 RegConstraint<"$RAi = $RA">, NoEncode<"$RAi">;
3097 let BaseName = "rlwinm" in {
3098 def RLWINM : MForm_2<21,
3099 (outs gprc:$RA), (ins gprc:$RS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
3100 "rlwinm $RA, $RS, $SH, $MB, $ME", IIC_IntGeneral,
3103 def RLWINM_rec : MForm_2<21,
3104 (outs gprc:$RA), (ins gprc:$RS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
3105 "rlwinm. $RA, $RS, $SH, $MB, $ME", IIC_IntGeneral,
3106 []>, isRecordForm, RecFormRel, PPC970_DGroup_Cracked;
3108 defm RLWNM : MForm_1r<23, (outs gprc:$RA),
3109 (ins gprc:$RS, gprc:$RB, u5imm:$MB, u5imm:$ME),
3110 "rlwnm", "$RA, $RS, $RB, $MB, $ME", IIC_IntGeneral,
3113 } // hasSideEffects = 0
3115 //===----------------------------------------------------------------------===//
3116 // PowerPC Instruction Patterns
3119 // Arbitrary immediate support. Implement in terms of LIS/ORI.
3120 def : Pat<(i32 imm:$imm),
3121 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
3123 // Implement the 'not' operation with the NOR instruction.
3124 def i32not : OutPatFrag<(ops node:$in),
3126 def : Pat<(not i32:$in),
3129 // ADD an arbitrary immediate.
3130 def : Pat<(add i32:$in, imm:$imm),
3131 (ADDIS (ADDI $in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
3132 // OR an arbitrary immediate.
3133 def : Pat<(or i32:$in, imm:$imm),
3134 (ORIS (ORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
3135 // XOR an arbitrary immediate.
3136 def : Pat<(xor i32:$in, imm:$imm),
3137 (XORIS (XORI $in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
3139 def : Pat<(sub imm32SExt16:$imm, i32:$in),
3140 (SUBFIC $in, imm:$imm)>;
3143 def : Pat<(shl i32:$in, (i32 imm:$imm)),
3144 (RLWINM $in, imm:$imm, 0, (SHL32 imm:$imm))>;
3145 def : Pat<(srl i32:$in, (i32 imm:$imm)),
3146 (RLWINM $in, (SRL32 imm:$imm), imm:$imm, 31)>;
3149 def : Pat<(rotl i32:$in, i32:$sh),
3150 (RLWNM $in, $sh, 0, 31)>;
3151 def : Pat<(rotl i32:$in, (i32 imm:$imm)),
3152 (RLWINM $in, imm:$imm, 0, 31)>;
3155 def : Pat<(and (rotl i32:$in, i32:$sh), maskimm32:$imm),
3156 (RLWNM $in, $sh, (MB maskimm32:$imm), (ME maskimm32:$imm))>;
3159 def : Pat<(PPCcall (i32 tglobaladdr:$dst)),
3160 (BL tglobaladdr:$dst)>;
3162 def : Pat<(PPCcall (i32 texternalsym:$dst)),
3163 (BL texternalsym:$dst)>;
3165 def : Pat<(PPCcall_rm (i32 tglobaladdr:$dst)),
3166 (BL_RM tglobaladdr:$dst)>;
3168 def : Pat<(PPCcall_rm (i32 texternalsym:$dst)),
3169 (BL_RM texternalsym:$dst)>;
3171 // Calls for AIX only
3172 def : Pat<(PPCcall (i32 mcsym:$dst)),
3175 def : Pat<(PPCcall_nop (i32 mcsym:$dst)),
3176 (BL_NOP mcsym:$dst)>;
3178 def : Pat<(PPCcall_nop (i32 texternalsym:$dst)),
3179 (BL_NOP texternalsym:$dst)>;
3181 def : Pat<(PPCcall_rm (i32 mcsym:$dst)),
3182 (BL_RM mcsym:$dst)>;
3184 def : Pat<(PPCcall_nop_rm (i32 mcsym:$dst)),
3185 (BL_NOP_RM mcsym:$dst)>;
3187 def : Pat<(PPCcall_nop_rm (i32 texternalsym:$dst)),
3188 (BL_NOP_RM texternalsym:$dst)>;
3190 def : Pat<(PPCtc_return (i32 tglobaladdr:$dst), imm:$imm),
3191 (TCRETURNdi tglobaladdr:$dst, imm:$imm)>;
3193 def : Pat<(PPCtc_return (i32 texternalsym:$dst), imm:$imm),
3194 (TCRETURNdi texternalsym:$dst, imm:$imm)>;
3196 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
3197 (TCRETURNri CTRRC:$dst, imm:$imm)>;
3199 def : Pat<(int_ppc_fence), (FENCE)>;
3200 def : Pat<(int_ppc_readflm), (MFFS)>;
3201 def : Pat<(int_ppc_mffsl), (MFFSL)>;
3203 // Hi and Lo for Darwin Global Addresses.
3204 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
3205 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
3206 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
3207 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
3208 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
3209 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
3210 def : Pat<(PPChi tblockaddress:$in, 0), (LIS tblockaddress:$in)>;
3211 def : Pat<(PPClo tblockaddress:$in, 0), (LI tblockaddress:$in)>;
3212 def : Pat<(PPChi tglobaltlsaddr:$g, i32:$in),
3213 (ADDIS $in, tglobaltlsaddr:$g)>;
3214 def : Pat<(PPClo tglobaltlsaddr:$g, i32:$in),
3215 (ADDI $in, tglobaltlsaddr:$g)>;
3216 def : Pat<(add i32:$in, (PPChi tglobaladdr:$g, 0)),
3217 (ADDIS $in, tglobaladdr:$g)>;
3218 def : Pat<(add i32:$in, (PPChi tconstpool:$g, 0)),
3219 (ADDIS $in, tconstpool:$g)>;
3220 def : Pat<(add i32:$in, (PPChi tjumptable:$g, 0)),
3221 (ADDIS $in, tjumptable:$g)>;
3222 def : Pat<(add i32:$in, (PPChi tblockaddress:$g, 0)),
3223 (ADDIS $in, tblockaddress:$g)>;
3225 // Support for thread-local storage.
3226 def PPC32GOT: PPCEmitTimePseudo<(outs gprc:$rD), (ins), "#PPC32GOT",
3227 [(set i32:$rD, (PPCppc32GOT))]>;
3229 // Get the _GLOBAL_OFFSET_TABLE_ in PIC mode.
3230 // This uses two output registers, the first as the real output, the second as a
3231 // temporary register, used internally in code generation.
3232 def PPC32PICGOT: PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins), "#PPC32PICGOT",
3233 []>, NoEncode<"$rT">;
3235 def LDgotTprelL32: PPCEmitTimePseudo<(outs gprc_nor0:$rD), (ins s16imm:$disp, gprc_nor0:$reg),
3238 (PPCldGotTprelL tglobaltlsaddr:$disp, i32:$reg))]>;
3239 def : Pat<(PPCaddTls i32:$in, tglobaltlsaddr:$g),
3240 (ADD4TLS $in, tglobaltlsaddr:$g)>;
3242 def ADDItlsgdL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3245 (PPCaddiTlsgdL i32:$reg, tglobaltlsaddr:$disp))]>;
3246 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3247 // explicitly defined when this op is created, so not mentioned here.
3248 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3249 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3250 def GETtlsADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3253 (PPCgetTlsAddr i32:$reg, tglobaltlsaddr:$sym))]>;
3254 // R3 is explicitly defined when this op is created, so not mentioned here.
3255 // The rest of the Defs are the exact set of registers that will be clobbered by
3257 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3258 Defs = [R0,R4,R5,R11,LR,CR0] in {
3259 def GETtlsADDR32AIX : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$offset, gprc:$handle),
3262 (PPCgetTlsAddr i32:$offset, i32:$handle))]>;
3263 def GETtlsMOD32AIX : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$handle),
3266 (PPCgetTlsMod i32:$handle))]>;
3269 // For local-exec accesses on 32-bit AIX, a call to .__get_tpointer is
3270 // generated to retrieve the thread pointer. GETtlsTpointer32AIX clobbers both
3271 // R3 and the LR (link register).
3272 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3274 def GETtlsTpointer32AIX : PPCEmitTimePseudo<(outs gprc:$rD), (ins),
3275 "GETtlsTpointer32AIX",
3276 [(set i32:$rD, (PPCgetTpointer))]>;
3278 // The following pattern matches local- and initial-exec TLS accesses on 32-bit AIX.
3279 // PPCaddTls is used in local- and initial-exec accesses in order to:
3280 // - Get the address of a variable (add the variable offset to the thread
3281 // pointer, retrieved by calling .__get_tpointer).
3282 // - Create an opportunity to optimize the user of the loaded address.
3283 def : Pat<(PPCaddTls i32:$in, i32:$addr),
3284 (ADD4TLS $in, $addr)>;
3286 // Combined op for ADDItlsgdL32 and GETtlsADDR32, late expanded. R3 and LR
3287 // are true defines while the rest of the Defs are clobbers.
3288 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3289 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3290 def ADDItlsgdLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3291 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3292 "#ADDItlsgdLADDR32",
3294 (PPCaddiTlsgdLAddr i32:$reg,
3295 tglobaltlsaddr:$disp,
3296 tglobaltlsaddr:$sym))]>;
3297 def ADDItlsldL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3300 (PPCaddiTlsldL i32:$reg, tglobaltlsaddr:$disp))]>;
3301 // This pseudo is expanded to two copies to put the variable offset in R4 and
3302 // the region handle in R3 and GETtlsADDR32AIX.
3303 def TLSGDAIX : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$offset, gprc:$handle),
3306 (PPCTlsgdAIX i32:$offset, i32:$handle))]>;
3307 // This pseudo is expanded to the call to GETtlsMOD32AIX.
3308 def TLSLDAIX : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$handle),
3309 "#TLSLDAIX", [(set i32:$rD, (PPCTlsldAIX i32:$handle))]>;
3310 // LR is a true define, while the rest of the Defs are clobbers. R3 is
3311 // explicitly defined when this op is created, so not mentioned here.
3312 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3313 Defs = [R0,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3314 def GETtlsldADDR32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tlsgd32:$sym),
3317 (PPCgetTlsldAddr i32:$reg,
3318 tglobaltlsaddr:$sym))]>;
3319 // Combined op for ADDItlsldL32 and GETtlsADDR32, late expanded. R3 and LR
3320 // are true defines while the rest of the Defs are clobbers.
3321 let hasExtraSrcRegAllocReq = 1, hasExtraDefRegAllocReq = 1,
3322 Defs = [R0,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,LR,CTR,CR0,CR1,CR5,CR6,CR7] in
3323 def ADDItlsldLADDR32 : PPCEmitTimePseudo<(outs gprc:$rD),
3324 (ins gprc_nor0:$reg, s16imm:$disp, tlsgd32:$sym),
3325 "#ADDItlsldLADDR32",
3327 (PPCaddiTlsldLAddr i32:$reg,
3328 tglobaltlsaddr:$disp,
3329 tglobaltlsaddr:$sym))]>;
3330 def ADDIdtprelL32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3333 (PPCaddiDtprelL i32:$reg, tglobaltlsaddr:$disp))]>;
3334 def ADDISdtprelHA32 : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, s16imm:$disp),
3337 (PPCaddisDtprelHA i32:$reg,
3338 tglobaltlsaddr:$disp))]>;
3340 // Support for Position-independent code
3341 def LWZtoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc:$reg),
3344 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
3345 def LWZtocL : PPCEmitTimePseudo<(outs gprc:$rD), (ins tocentry32:$disp, gprc_nor0:$reg),
3348 (PPCtoc_entry tglobaladdr:$disp, i32:$reg))]>;
3349 def ADDIStocHA : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, tocentry32:$disp),
3351 // TOC Data Transform on AIX
3352 def ADDItoc : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc:$reg, tocentry32:$disp),
3354 def ADDItocL : PPCEmitTimePseudo<(outs gprc:$rD), (ins gprc_nor0:$reg, tocentry32:$disp),
3357 // Get Global (GOT) Base Register offset, from the word immediately preceding
3358 // the function label.
3359 def UpdateGBR : PPCEmitTimePseudo<(outs gprc:$rD, gprc:$rT), (ins gprc:$rI), "#UpdateGBR", []>;
3361 // Pseudo-instruction marked for deletion. When deleting the instruction would
3362 // cause iterator invalidation in MIR transformation passes, this pseudo can be
3363 // used instead. It will be removed unconditionally at pre-emit time (prior to
3364 // branch selection).
3365 def UNENCODED_NOP: PPCEmitTimePseudo<(outs), (ins), "#UNENCODED_NOP", []>;
3367 // Standard shifts. These are represented separately from the real shifts above
3368 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
3370 def : Pat<(sra i32:$rS, i32:$rB),
3372 def : Pat<(srl i32:$rS, i32:$rB),
3374 def : Pat<(shl i32:$rS, i32:$rB),
3377 def : Pat<(i32 (zextloadi1 DForm:$src)),
3379 def : Pat<(i32 (zextloadi1 XForm:$src)),
3381 def : Pat<(i32 (extloadi1 DForm:$src)),
3383 def : Pat<(i32 (extloadi1 XForm:$src)),
3385 def : Pat<(i32 (extloadi8 DForm:$src)),
3387 def : Pat<(i32 (extloadi8 XForm:$src)),
3389 def : Pat<(i32 (extloadi16 DForm:$src)),
3391 def : Pat<(i32 (extloadi16 XForm:$src)),
3393 let Predicates = [HasFPU] in {
3394 def : Pat<(f64 (extloadf32 DForm:$src)),
3395 (COPY_TO_REGCLASS (LFS DForm:$src), F8RC)>;
3396 def : Pat<(f64 (extloadf32 XForm:$src)),
3397 (COPY_TO_REGCLASS (LFSX XForm:$src), F8RC)>;
3399 def : Pat<(f64 (any_fpextend f32:$src)),
3400 (COPY_TO_REGCLASS $src, F8RC)>;
3403 // Only seq_cst fences require the heavyweight sync (SYNC 0).
3404 // All others can use the lightweight sync (SYNC 1).
3405 // source: http://www.cl.cam.ac.uk/~pes20/cpp/cpp0xmappings.html
3406 // The rule for seq_cst is duplicated to work with both 64 bits and 32 bits
3407 // versions of Power.
3408 def : Pat<(atomic_fence (i64 7), (timm)), (SYNC 0)>, Requires<[HasSYNC]>;
3409 def : Pat<(atomic_fence (i32 7), (timm)), (SYNC 0)>, Requires<[HasSYNC]>;
3410 def : Pat<(atomic_fence (timm), (timm)), (SYNC 1)>, Requires<[HasSYNC]>;
3411 def : Pat<(atomic_fence (timm), (timm)), (MSYNC)>, Requires<[HasOnlyMSYNC]>;
3413 let Predicates = [HasFPU] in {
3414 // Additional fnmsub patterns for custom node
3415 def : Pat<(PPCfnmsub f64:$A, f64:$B, f64:$C),
3416 (FNMSUB $A, $B, $C)>;
3417 def : Pat<(PPCfnmsub f32:$A, f32:$B, f32:$C),
3418 (FNMSUBS $A, $B, $C)>;
3419 def : Pat<(fneg (PPCfnmsub f64:$A, f64:$B, f64:$C)),
3420 (FMSUB $A, $B, $C)>;
3421 def : Pat<(fneg (PPCfnmsub f32:$A, f32:$B, f32:$C)),
3422 (FMSUBS $A, $B, $C)>;
3423 def : Pat<(PPCfnmsub f64:$A, f64:$B, (fneg f64:$C)),
3424 (FNMADD $A, $B, $C)>;
3425 def : Pat<(PPCfnmsub f32:$A, f32:$B, (fneg f32:$C)),
3426 (FNMADDS $A, $B, $C)>;
3428 // FCOPYSIGN's operand types need not agree.
3429 def : Pat<(fcopysign f64:$frB, f32:$frA),
3430 (FCPSGND (COPY_TO_REGCLASS $frA, F8RC), $frB)>;
3431 def : Pat<(fcopysign f32:$frB, f64:$frA),
3432 (FCPSGNS (COPY_TO_REGCLASS $frA, F4RC), $frB)>;
3435 // XL Compat intrinsics.
3436 def : Pat<(int_ppc_fmsub f64:$A, f64:$B, f64:$C), (FMSUB $A, $B, $C)>;
3437 def : Pat<(int_ppc_fmsubs f32:$A, f32:$B, f32:$C), (FMSUBS $A, $B, $C)>;
3438 def : Pat<(int_ppc_fnmadd f64:$A, f64:$B, f64:$C), (FNMADD $A, $B, $C)>;
3439 def : Pat<(int_ppc_fnmadds f32:$A, f32:$B, f32:$C), (FNMADDS $A, $B, $C)>;
3440 def : Pat<(int_ppc_fre f64:$A), (FRE $A)>;
3441 def : Pat<(int_ppc_fres f32:$A), (FRES $A)>;
3442 def : Pat<(int_ppc_fnabs f64:$A), (FNABSD $A)>;
3443 def : Pat<(int_ppc_fnabss f32:$A), (FNABSS $A)>;
3445 include "PPCInstrAltivec.td"
3446 include "PPCInstrSPE.td"
3447 include "PPCInstr64Bit.td"
3448 include "PPCInstrVSX.td"
3449 include "PPCInstrHTM.td"
3451 def crnot : OutPatFrag<(ops node:$in),
3453 def : Pat<(not i1:$in),
3456 // Pseudo-instructions for alternate assembly syntax (never used by codegen).
3457 // These are aliases that require C++ handling to convert to the target
3458 // instruction, while InstAliases can be handled directly by tblgen.
3459 class PPCAsmPseudo<string asm, dag iops>
3461 let Namespace = "PPC";
3462 bit PPC64 = 0; // Default value, override with isPPC64
3464 let OutOperandList = (outs);
3465 let InOperandList = iops;
3467 let AsmString = asm;
3468 let isAsmParserOnly = 1;
3470 let hasNoSchedulingInfo = 1;
3472 // Indicate that this instruction takes a register+immediate memory operand.
3473 bits<1> MemriOp = 0;
3474 let TSFlags{10} = MemriOp;
3477 // Prefixed instructions may require access to the above defs at a later
3478 // time so we include this after the def.
3479 include "PPCInstrP10.td"
3480 include "PPCInstrFutureMMA.td"
3481 include "PPCInstrFuture.td"
3482 include "PPCInstrMMA.td"
3483 include "PPCInstrDFP.td"
3485 // Patterns for arithmetic i1 operations.
3486 def : Pat<(add i1:$a, i1:$b),
3488 def : Pat<(sub i1:$a, i1:$b),
3490 def : Pat<(mul i1:$a, i1:$b),
3493 // We're sometimes asked to materialize i1 -1, which is just 1 in this case
3494 // (-1 is used to mean all bits set).
3495 def : Pat<(i1 -1), (CRSET)>;
3497 // i1 extensions, implemented in terms of isel.
3498 def : Pat<(i32 (zext i1:$in)),
3499 (SELECT_I4 $in, (LI 1), (LI 0))>;
3500 def : Pat<(i32 (sext i1:$in)),
3501 (SELECT_I4 $in, (LI -1), (LI 0))>;
3503 def : Pat<(i64 (zext i1:$in)),
3504 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3505 def : Pat<(i64 (sext i1:$in)),
3506 (SELECT_I8 $in, (LI8 -1), (LI8 0))>;
3508 // FIXME: We should choose either a zext or a sext based on other constants
3510 def : Pat<(i32 (anyext i1:$in)),
3511 (SELECT_I4 $in, (LI 1), (LI 0))>;
3512 def : Pat<(i64 (anyext i1:$in)),
3513 (SELECT_I8 $in, (LI8 1), (LI8 0))>;
3515 // match setcc on i1 variables.
3533 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLT)),
3535 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULT)),
3554 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETLE)),
3556 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETULE)),
3559 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETEQ)),
3573 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGE)),
3575 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGE)),
3589 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETGT)),
3591 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETUGT)),
3594 def : Pat<(i1 (setcc i1:$s1, i1:$s2, SETNE)),
3597 // match setcc on non-i1 (non-vector) variables. Note that SETUEQ, SETOGE,
3598 // SETOLE, SETONE, SETULT and SETUGT should be expanded by legalize for
3599 // floating-point types.
3601 multiclass CRNotPat<dag pattern, dag result> {
3602 def : Pat<pattern, (crnot result)>;
3603 def : Pat<(not pattern), result>;
3605 // We can also fold the crnot into an extension:
3606 def : Pat<(i32 (zext pattern)),
3607 (SELECT_I4 result, (LI 0), (LI 1))>;
3608 def : Pat<(i32 (sext pattern)),
3609 (SELECT_I4 result, (LI 0), (LI -1))>;
3611 // We can also fold the crnot into an extension:
3612 def : Pat<(i64 (zext pattern)),
3613 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3614 def : Pat<(i64 (sext pattern)),
3615 (SELECT_I8 result, (LI8 0), (LI8 -1))>;
3617 // FIXME: We should choose either a zext or a sext based on other constants
3619 def : Pat<(i32 (anyext pattern)),
3620 (SELECT_I4 result, (LI 0), (LI 1))>;
3622 def : Pat<(i64 (anyext pattern)),
3623 (SELECT_I8 result, (LI8 0), (LI8 1))>;
3626 // FIXME: Because of what seems like a bug in TableGen's type-inference code,
3627 // we need to write imm:$imm in the output patterns below, not just $imm, or
3628 // else the resulting matcher will not correctly add the immediate operand
3629 // (making it a register operand instead).
3632 multiclass ExtSetCCPat<CondCode cc, PatFrag pfrag,
3633 OutPatFrag rfrag, OutPatFrag rfrag8> {
3634 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, cc)))),
3636 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, cc)))),
3638 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, cc)))),
3639 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3640 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, cc)))),
3641 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3643 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, cc)))),
3645 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, cc)))),
3647 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, cc)))),
3648 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1), sub_32)>;
3649 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, cc)))),
3650 (EXTRACT_SUBREG (rfrag8 $s1), sub_32)>;
3653 // Note that we do all inversions below with i(32|64)not, instead of using
3654 // (xori x, 1) because on the A2 nor has single-cycle latency while xori
3655 // has 2-cycle latency.
3657 defm : ExtSetCCPat<SETEQ,
3658 PatFrag<(ops node:$in, node:$cc),
3659 (setcc $in, 0, $cc)>,
3660 OutPatFrag<(ops node:$in),
3661 (RLWINM (CNTLZW $in), 27, 31, 31)>,
3662 OutPatFrag<(ops node:$in),
3663 (RLDICL (CNTLZD $in), 58, 63)> >;
3665 defm : ExtSetCCPat<SETNE,
3666 PatFrag<(ops node:$in, node:$cc),
3667 (setcc $in, 0, $cc)>,
3668 OutPatFrag<(ops node:$in),
3669 (RLWINM (i32not (CNTLZW $in)), 27, 31, 31)>,
3670 OutPatFrag<(ops node:$in),
3671 (RLDICL (i64not (CNTLZD $in)), 58, 63)> >;
3673 defm : ExtSetCCPat<SETLT,
3674 PatFrag<(ops node:$in, node:$cc),
3675 (setcc $in, 0, $cc)>,
3676 OutPatFrag<(ops node:$in),
3677 (RLWINM $in, 1, 31, 31)>,
3678 OutPatFrag<(ops node:$in),
3679 (RLDICL $in, 1, 63)> >;
3681 defm : ExtSetCCPat<SETGE,
3682 PatFrag<(ops node:$in, node:$cc),
3683 (setcc $in, 0, $cc)>,
3684 OutPatFrag<(ops node:$in),
3685 (RLWINM (i32not $in), 1, 31, 31)>,
3686 OutPatFrag<(ops node:$in),
3687 (RLDICL (i64not $in), 1, 63)> >;
3689 defm : ExtSetCCPat<SETGT,
3690 PatFrag<(ops node:$in, node:$cc),
3691 (setcc $in, 0, $cc)>,
3692 OutPatFrag<(ops node:$in),
3693 (RLWINM (ANDC (NEG $in), $in), 1, 31, 31)>,
3694 OutPatFrag<(ops node:$in),
3695 (RLDICL (ANDC8 (NEG8 $in), $in), 1, 63)> >;
3697 defm : ExtSetCCPat<SETLE,
3698 PatFrag<(ops node:$in, node:$cc),
3699 (setcc $in, 0, $cc)>,
3700 OutPatFrag<(ops node:$in),
3701 (RLWINM (ORC $in, (NEG $in)), 1, 31, 31)>,
3702 OutPatFrag<(ops node:$in),
3703 (RLDICL (ORC8 $in, (NEG8 $in)), 1, 63)> >;
3705 defm : ExtSetCCPat<SETLT,
3706 PatFrag<(ops node:$in, node:$cc),
3707 (setcc $in, -1, $cc)>,
3708 OutPatFrag<(ops node:$in),
3709 (RLWINM (AND $in, (ADDI $in, 1)), 1, 31, 31)>,
3710 OutPatFrag<(ops node:$in),
3711 (RLDICL (AND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3713 defm : ExtSetCCPat<SETGE,
3714 PatFrag<(ops node:$in, node:$cc),
3715 (setcc $in, -1, $cc)>,
3716 OutPatFrag<(ops node:$in),
3717 (RLWINM (NAND $in, (ADDI $in, 1)), 1, 31, 31)>,
3718 OutPatFrag<(ops node:$in),
3719 (RLDICL (NAND8 $in, (ADDI8 $in, 1)), 1, 63)> >;
3721 defm : ExtSetCCPat<SETGT,
3722 PatFrag<(ops node:$in, node:$cc),
3723 (setcc $in, -1, $cc)>,
3724 OutPatFrag<(ops node:$in),
3725 (RLWINM (i32not $in), 1, 31, 31)>,
3726 OutPatFrag<(ops node:$in),
3727 (RLDICL (i64not $in), 1, 63)> >;
3729 defm : ExtSetCCPat<SETLE,
3730 PatFrag<(ops node:$in, node:$cc),
3731 (setcc $in, -1, $cc)>,
3732 OutPatFrag<(ops node:$in),
3733 (RLWINM $in, 1, 31, 31)>,
3734 OutPatFrag<(ops node:$in),
3735 (RLDICL $in, 1, 63)> >;
3737 // An extended SETCC with shift amount.
3738 multiclass ExtSetCCShiftPat<CondCode cc, PatFrag pfrag,
3739 OutPatFrag rfrag, OutPatFrag rfrag8> {
3740 def : Pat<(i32 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3742 def : Pat<(i64 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3744 def : Pat<(i64 (zext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3745 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3746 def : Pat<(i32 (zext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3747 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3749 def : Pat<(i32 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3751 def : Pat<(i64 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3753 def : Pat<(i64 (anyext (i1 (pfrag i32:$s1, i32:$sa, cc)))),
3754 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), (rfrag $s1, $sa), sub_32)>;
3755 def : Pat<(i32 (anyext (i1 (pfrag i64:$s1, i32:$sa, cc)))),
3756 (EXTRACT_SUBREG (rfrag8 $s1, $sa), sub_32)>;
3759 defm : ExtSetCCShiftPat<SETNE,
3760 PatFrag<(ops node:$in, node:$sa, node:$cc),
3761 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3762 OutPatFrag<(ops node:$in, node:$sa),
3763 (RLWNM $in, (SUBFIC $sa, 32), 31, 31)>,
3764 OutPatFrag<(ops node:$in, node:$sa),
3765 (RLDCL $in, (SUBFIC $sa, 64), 63)> >;
3767 defm : ExtSetCCShiftPat<SETEQ,
3768 PatFrag<(ops node:$in, node:$sa, node:$cc),
3769 (setcc (and $in, (shl 1, $sa)), 0, $cc)>,
3770 OutPatFrag<(ops node:$in, node:$sa),
3771 (RLWNM (i32not $in),
3772 (SUBFIC $sa, 32), 31, 31)>,
3773 OutPatFrag<(ops node:$in, node:$sa),
3774 (RLDCL (i64not $in),
3775 (SUBFIC $sa, 64), 63)> >;
3778 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULT)),
3779 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3780 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLT)),
3781 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3782 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGT)),
3783 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3784 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGT)),
3785 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3786 def : Pat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETEQ)),
3787 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3788 def : Pat<(i1 (setcc i32:$s1, immZExt16:$imm, SETEQ)),
3789 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3791 // For non-equality comparisons, the default code would materialize the
3792 // constant, then compare against it, like this:
3794 // ori r2, r2, 22136
3797 // Since we are just comparing for equality, we can emit this instead:
3798 // xoris r0,r3,0x1234
3799 // cmplwi cr0,r0,0x5678
3802 def : Pat<(i1 (setcc i32:$s1, imm:$imm, SETEQ)),
3803 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3804 (LO16 imm:$imm)), sub_eq)>;
3806 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETULT)),
3807 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3808 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETLT)),
3809 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3810 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETUGT)),
3811 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3812 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETGT)),
3813 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3814 def : Pat<(i1 (setcc i32:$s1, i32:$s2, SETEQ)),
3815 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3818 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULT)),
3819 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3820 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLT)),
3821 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3822 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGT)),
3823 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3824 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGT)),
3825 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3826 def : Pat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETEQ)),
3827 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3828 def : Pat<(i1 (setcc i64:$s1, immZExt16:$imm, SETEQ)),
3829 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3831 // For non-equality comparisons, the default code would materialize the
3832 // constant, then compare against it, like this:
3834 // ori r2, r2, 22136
3837 // Since we are just comparing for equality, we can emit this instead:
3838 // xoris r0,r3,0x1234
3839 // cmpldi cr0,r0,0x5678
3842 def : Pat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETEQ)),
3843 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3844 (LO16 imm:$imm)), sub_eq)>;
3846 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETULT)),
3847 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3848 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETLT)),
3849 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3850 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETUGT)),
3851 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3852 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETGT)),
3853 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3854 def : Pat<(i1 (setcc i64:$s1, i64:$s2, SETEQ)),
3855 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3857 let Predicates = [IsNotISA3_1] in {
3858 // Instantiations of CRNotPat for i32.
3859 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETUGE)),
3860 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_lt)>;
3861 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETGE)),
3862 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_lt)>;
3863 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETULE)),
3864 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_gt)>;
3865 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETLE)),
3866 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_gt)>;
3867 defm : CRNotPat<(i1 (setcc i32:$s1, imm32SExt16:$imm, SETNE)),
3868 (EXTRACT_SUBREG (CMPWI $s1, imm:$imm), sub_eq)>;
3869 defm : CRNotPat<(i1 (setcc i32:$s1, immZExt16:$imm, SETNE)),
3870 (EXTRACT_SUBREG (CMPLWI $s1, imm:$imm), sub_eq)>;
3872 defm : CRNotPat<(i1 (setcc i32:$s1, imm:$imm, SETNE)),
3873 (EXTRACT_SUBREG (CMPLWI (XORIS $s1, (HI16 imm:$imm)),
3874 (LO16 imm:$imm)), sub_eq)>;
3876 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETUGE)),
3877 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_lt)>;
3878 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETGE)),
3879 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_lt)>;
3880 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETULE)),
3881 (EXTRACT_SUBREG (CMPLW $s1, $s2), sub_gt)>;
3882 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETLE)),
3883 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_gt)>;
3884 defm : CRNotPat<(i1 (setcc i32:$s1, i32:$s2, SETNE)),
3885 (EXTRACT_SUBREG (CMPW $s1, $s2), sub_eq)>;
3887 // Instantiations of CRNotPat for i64.
3888 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETUGE)),
3889 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_lt)>;
3890 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETGE)),
3891 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_lt)>;
3892 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETULE)),
3893 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_gt)>;
3894 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETLE)),
3895 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_gt)>;
3896 defm : CRNotPat<(i1 (setcc i64:$s1, imm64SExt16:$imm, SETNE)),
3897 (EXTRACT_SUBREG (CMPDI $s1, imm:$imm), sub_eq)>;
3898 defm : CRNotPat<(i1 (setcc i64:$s1, immZExt16:$imm, SETNE)),
3899 (EXTRACT_SUBREG (CMPLDI $s1, imm:$imm), sub_eq)>;
3901 defm : CRNotPat<(i1 (setcc i64:$s1, imm64ZExt32:$imm, SETNE)),
3902 (EXTRACT_SUBREG (CMPLDI (XORIS8 $s1, (HI16 imm:$imm)),
3903 (LO16 imm:$imm)), sub_eq)>;
3905 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETUGE)),
3906 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_lt)>;
3907 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETGE)),
3908 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_lt)>;
3909 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETULE)),
3910 (EXTRACT_SUBREG (CMPLD $s1, $s2), sub_gt)>;
3911 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETLE)),
3912 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_gt)>;
3913 defm : CRNotPat<(i1 (setcc i64:$s1, i64:$s2, SETNE)),
3914 (EXTRACT_SUBREG (CMPD $s1, $s2), sub_eq)>;
3917 multiclass FSetCCPat<SDPatternOperator SetCC, ValueType Ty, I FCmp> {
3918 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETUGE)),
3919 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
3920 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETGE)),
3921 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
3922 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETULE)),
3923 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
3924 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETLE)),
3925 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
3926 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETUNE)),
3927 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
3928 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETNE)),
3929 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
3930 defm : CRNotPat<(i1 (SetCC Ty:$s1, Ty:$s2, SETO)),
3931 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_un)>;
3933 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETOLT)),
3934 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
3935 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETLT)),
3936 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_lt)>;
3937 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETOGT)),
3938 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
3939 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETGT)),
3940 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_gt)>;
3941 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETOEQ)),
3942 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
3943 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETEQ)),
3944 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_eq)>;
3945 def : Pat<(i1 (SetCC Ty:$s1, Ty:$s2, SETUO)),
3946 (EXTRACT_SUBREG (FCmp $s1, $s2), sub_un)>;
3949 let Predicates = [HasFPU] in {
3950 // FCMPU: If either of the operands is a Signaling NaN, then VXSNAN is set.
3952 defm : FSetCCPat<any_fsetcc, f32, FCMPUS>;
3955 defm : FSetCCPat<any_fsetcc, f64, FCMPUD>;
3958 defm : FSetCCPat<any_fsetcc, f128, XSCMPUQP>;
3960 // FCMPO: If either of the operands is a Signaling NaN, then VXSNAN is set and,
3961 // if neither operand is a Signaling NaN but at least one operand is a Quiet NaN,
3962 // then VXVC is set.
3964 defm : FSetCCPat<strict_fsetccs, f32, FCMPOS>;
3967 defm : FSetCCPat<strict_fsetccs, f64, FCMPOD>;
3970 defm : FSetCCPat<strict_fsetccs, f128, XSCMPOQP>;
3973 // This must be in this file because it relies on patterns defined in this file
3974 // after the inclusion of the instruction sets.
3975 let Predicates = [HasSPE] in {
3977 def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETOLT)),
3978 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3979 def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETLT)),
3980 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3981 def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETOGT)),
3982 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3983 def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETGT)),
3984 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3985 def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETOEQ)),
3986 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3987 def : Pat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETEQ)),
3988 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
3990 defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETUGE)),
3991 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3992 defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETGE)),
3993 (EXTRACT_SUBREG (EFSCMPLT $s1, $s2), sub_gt)>;
3994 defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETULE)),
3995 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3996 defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETLE)),
3997 (EXTRACT_SUBREG (EFSCMPGT $s1, $s2), sub_gt)>;
3998 defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETUNE)),
3999 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
4000 defm : CRNotPat<(i1 (any_fsetccs f32:$s1, f32:$s2, SETNE)),
4001 (EXTRACT_SUBREG (EFSCMPEQ $s1, $s2), sub_gt)>;
4004 def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETOLT)),
4005 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
4006 def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETLT)),
4007 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
4008 def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETOGT)),
4009 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
4010 def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETGT)),
4011 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
4012 def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETOEQ)),
4013 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
4014 def : Pat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETEQ)),
4015 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
4017 defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETUGE)),
4018 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
4019 defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETGE)),
4020 (EXTRACT_SUBREG (EFDCMPLT $s1, $s2), sub_gt)>;
4021 defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETULE)),
4022 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
4023 defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETLE)),
4024 (EXTRACT_SUBREG (EFDCMPGT $s1, $s2), sub_gt)>;
4025 defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETUNE)),
4026 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
4027 defm : CRNotPat<(i1 (any_fsetccs f64:$s1, f64:$s2, SETNE)),
4028 (EXTRACT_SUBREG (EFDCMPEQ $s1, $s2), sub_gt)>;
4030 // match select on i1 variables:
4031 def : Pat<(i1 (select i1:$cond, i1:$tval, i1:$fval)),
4032 (CROR (CRAND $cond , $tval),
4033 (CRAND (crnot $cond), $fval))>;
4035 // match selectcc on i1 variables:
4036 // select (lhs == rhs), tval, fval is:
4037 // ((lhs == rhs) & tval) | (!(lhs == rhs) & fval)
4038 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLT)),
4039 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
4040 (CRAND (CRORC $rhs, $lhs), $fval))>;
4041 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULT)),
4042 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
4043 (CRAND (CRORC $lhs, $rhs), $fval))>;
4044 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETLE)),
4045 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
4046 (CRAND (CRANDC $rhs, $lhs), $fval))>;
4047 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETULE)),
4048 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
4049 (CRAND (CRANDC $lhs, $rhs), $fval))>;
4050 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETEQ)),
4051 (CROR (CRAND (CREQV $lhs, $rhs), $tval),
4052 (CRAND (CRXOR $lhs, $rhs), $fval))>;
4053 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGE)),
4054 (CROR (CRAND (CRORC $rhs, $lhs), $tval),
4055 (CRAND (CRANDC $lhs, $rhs), $fval))>;
4056 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGE)),
4057 (CROR (CRAND (CRORC $lhs, $rhs), $tval),
4058 (CRAND (CRANDC $rhs, $lhs), $fval))>;
4059 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETGT)),
4060 (CROR (CRAND (CRANDC $rhs, $lhs), $tval),
4061 (CRAND (CRORC $lhs, $rhs), $fval))>;
4062 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETUGT)),
4063 (CROR (CRAND (CRANDC $lhs, $rhs), $tval),
4064 (CRAND (CRORC $rhs, $lhs), $fval))>;
4065 def : Pat <(i1 (selectcc i1:$lhs, i1:$rhs, i1:$tval, i1:$fval, SETNE)),
4066 (CROR (CRAND (CREQV $lhs, $rhs), $fval),
4067 (CRAND (CRXOR $lhs, $rhs), $tval))>;
4069 // match selectcc on i1 variables with non-i1 output.
4070 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLT)),
4071 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
4072 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULT)),
4073 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
4074 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETLE)),
4075 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
4076 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETULE)),
4077 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
4078 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETEQ)),
4079 (SELECT_I4 (CREQV $lhs, $rhs), $tval, $fval)>;
4080 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGE)),
4081 (SELECT_I4 (CRORC $rhs, $lhs), $tval, $fval)>;
4082 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGE)),
4083 (SELECT_I4 (CRORC $lhs, $rhs), $tval, $fval)>;
4084 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETGT)),
4085 (SELECT_I4 (CRANDC $rhs, $lhs), $tval, $fval)>;
4086 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETUGT)),
4087 (SELECT_I4 (CRANDC $lhs, $rhs), $tval, $fval)>;
4088 def : Pat<(i32 (selectcc i1:$lhs, i1:$rhs, i32:$tval, i32:$fval, SETNE)),
4089 (SELECT_I4 (CRXOR $lhs, $rhs), $tval, $fval)>;
4091 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLT)),
4092 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
4093 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULT)),
4094 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
4095 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETLE)),
4096 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
4097 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETULE)),
4098 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
4099 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETEQ)),
4100 (SELECT_I8 (CREQV $lhs, $rhs), $tval, $fval)>;
4101 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGE)),
4102 (SELECT_I8 (CRORC $rhs, $lhs), $tval, $fval)>;
4103 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGE)),
4104 (SELECT_I8 (CRORC $lhs, $rhs), $tval, $fval)>;
4105 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETGT)),
4106 (SELECT_I8 (CRANDC $rhs, $lhs), $tval, $fval)>;
4107 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETUGT)),
4108 (SELECT_I8 (CRANDC $lhs, $rhs), $tval, $fval)>;
4109 def : Pat<(i64 (selectcc i1:$lhs, i1:$rhs, i64:$tval, i64:$fval, SETNE)),
4110 (SELECT_I8 (CRXOR $lhs, $rhs), $tval, $fval)>;
4112 let Predicates = [HasFPU] in {
4113 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLT)),
4114 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
4115 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULT)),
4116 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
4117 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETLE)),
4118 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
4119 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETULE)),
4120 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
4121 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETEQ)),
4122 (SELECT_F4 (CREQV $lhs, $rhs), $tval, $fval)>;
4123 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGE)),
4124 (SELECT_F4 (CRORC $rhs, $lhs), $tval, $fval)>;
4125 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGE)),
4126 (SELECT_F4 (CRORC $lhs, $rhs), $tval, $fval)>;
4127 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETGT)),
4128 (SELECT_F4 (CRANDC $rhs, $lhs), $tval, $fval)>;
4129 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETUGT)),
4130 (SELECT_F4 (CRANDC $lhs, $rhs), $tval, $fval)>;
4131 def : Pat<(f32 (selectcc i1:$lhs, i1:$rhs, f32:$tval, f32:$fval, SETNE)),
4132 (SELECT_F4 (CRXOR $lhs, $rhs), $tval, $fval)>;
4134 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLT)),
4135 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
4136 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULT)),
4137 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
4138 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETLE)),
4139 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
4140 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETULE)),
4141 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
4142 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETEQ)),
4143 (SELECT_F8 (CREQV $lhs, $rhs), $tval, $fval)>;
4144 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGE)),
4145 (SELECT_F8 (CRORC $rhs, $lhs), $tval, $fval)>;
4146 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGE)),
4147 (SELECT_F8 (CRORC $lhs, $rhs), $tval, $fval)>;
4148 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETGT)),
4149 (SELECT_F8 (CRANDC $rhs, $lhs), $tval, $fval)>;
4150 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETUGT)),
4151 (SELECT_F8 (CRANDC $lhs, $rhs), $tval, $fval)>;
4152 def : Pat<(f64 (selectcc i1:$lhs, i1:$rhs, f64:$tval, f64:$fval, SETNE)),
4153 (SELECT_F8 (CRXOR $lhs, $rhs), $tval, $fval)>;
4156 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLT)),
4157 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
4158 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULT)),
4159 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
4160 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETLE)),
4161 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
4162 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETULE)),
4163 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
4164 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETEQ)),
4165 (SELECT_F16 (CREQV $lhs, $rhs), $tval, $fval)>;
4166 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGE)),
4167 (SELECT_F16 (CRORC $rhs, $lhs), $tval, $fval)>;
4168 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGE)),
4169 (SELECT_F16 (CRORC $lhs, $rhs), $tval, $fval)>;
4170 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETGT)),
4171 (SELECT_F16 (CRANDC $rhs, $lhs), $tval, $fval)>;
4172 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETUGT)),
4173 (SELECT_F16 (CRANDC $lhs, $rhs), $tval, $fval)>;
4174 def : Pat<(f128 (selectcc i1:$lhs, i1:$rhs, f128:$tval, f128:$fval, SETNE)),
4175 (SELECT_F16 (CRXOR $lhs, $rhs), $tval, $fval)>;
4177 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLT)),
4178 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
4179 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULT)),
4180 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
4181 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETLE)),
4182 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
4183 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETULE)),
4184 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
4185 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETEQ)),
4186 (SELECT_VRRC (CREQV $lhs, $rhs), $tval, $fval)>;
4187 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGE)),
4188 (SELECT_VRRC (CRORC $rhs, $lhs), $tval, $fval)>;
4189 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGE)),
4190 (SELECT_VRRC (CRORC $lhs, $rhs), $tval, $fval)>;
4191 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETGT)),
4192 (SELECT_VRRC (CRANDC $rhs, $lhs), $tval, $fval)>;
4193 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETUGT)),
4194 (SELECT_VRRC (CRANDC $lhs, $rhs), $tval, $fval)>;
4195 def : Pat<(v4i32 (selectcc i1:$lhs, i1:$rhs, v4i32:$tval, v4i32:$fval, SETNE)),
4196 (SELECT_VRRC (CRXOR $lhs, $rhs), $tval, $fval)>;
4198 let Defs = [CR0] in {
4199 def ANDI_rec_1_EQ_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
4200 "#ANDI_rec_1_EQ_BIT",
4201 [(set i1:$dst, (trunc (not i32:$in)))]>;
4202 def ANDI_rec_1_GT_BIT : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins gprc:$in),
4203 "#ANDI_rec_1_GT_BIT",
4204 [(set i1:$dst, (trunc i32:$in))]>;
4206 def ANDI_rec_1_EQ_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
4207 "#ANDI_rec_1_EQ_BIT8",
4208 [(set i1:$dst, (trunc (not i64:$in)))]>;
4209 def ANDI_rec_1_GT_BIT8 : PPCCustomInserterPseudo<(outs crbitrc:$dst), (ins g8rc:$in),
4210 "#ANDI_rec_1_GT_BIT8",
4211 [(set i1:$dst, (trunc i64:$in))]>;
4214 def : Pat<(i1 (not (trunc i32:$in))),
4215 (ANDI_rec_1_EQ_BIT $in)>;
4216 def : Pat<(i1 (not (trunc i64:$in))),
4217 (ANDI_rec_1_EQ_BIT8 $in)>;
4219 def : Pat<(int_ppc_fsel f8rc:$FRA, f8rc:$FRC, f8rc:$FRB), (FSELD $FRA, $FRC, $FRB)>;
4220 def : Pat<(int_ppc_frsqrte f8rc:$frB), (FRSQRTE $frB)>;
4221 def : Pat<(int_ppc_frsqrtes f4rc:$frB), (FRSQRTES $frB)>;
4223 //===----------------------------------------------------------------------===//
4224 // PowerPC Instructions used for assembler/disassembler only
4227 // FIXME: For B=0 or B > 8, the registers following RT are used.
4228 // WARNING: Do not add patterns for this instruction without fixing this.
4229 def LSWI : XForm_base_r3xo_memOp<31, 597, (outs gprc:$RST),
4230 (ins gprc:$RA, u5imm:$RB),
4231 "lswi $RST, $RA, $RB", IIC_LdStLoad, []>;
4233 // FIXME: For B=0 or B > 8, the registers following RT are used.
4234 // WARNING: Do not add patterns for this instruction without fixing this.
4235 def STSWI : XForm_base_r3xo_memOp<31, 725, (outs),
4236 (ins gprc:$RST, gprc:$RA, u5imm:$RB),
4237 "stswi $RST, $RA, $RB", IIC_LdStLoad, []>;
4239 def ISYNC : XLForm_2_ext<19, 150, 0, 0, 0, (outs), (ins),
4240 "isync", IIC_SprISYNC, []>;
4242 def ICBI : XForm_1a<31, 982, (outs), (ins (memrr $RA, $RB):$addr),
4243 "icbi $addr", IIC_LdStICBI, []>;
4245 def WAIT : XForm_24_sync<31, 30, (outs), (ins u2imm:$L),
4246 "wait $L", IIC_LdStLoad, []>;
4248 def MBAR : XForm_mbar<31, 854, (outs), (ins u5imm:$MO),
4249 "mbar $MO", IIC_LdStLoad>, Requires<[IsBookE]>;
4251 def MTSR: XForm_sr<31, 210, (outs), (ins gprc:$RS, u4imm:$SR),
4252 "mtsr $SR, $RS", IIC_SprMTSR>;
4254 def MFSR: XForm_sr<31, 595, (outs gprc:$RS), (ins u4imm:$SR),
4255 "mfsr $RS, $SR", IIC_SprMFSR>;
4257 def MTSRIN: XForm_srin<31, 242, (outs), (ins gprc:$RS, gprc:$RB),
4258 "mtsrin $RS, $RB", IIC_SprMTSR>;
4260 def MFSRIN: XForm_srin<31, 659, (outs gprc:$RS), (ins gprc:$RB),
4261 "mfsrin $RS, $RB", IIC_SprMFSR>;
4263 def MTMSR: XForm_mtmsr<31, 146, (outs), (ins gprc:$RS, u1imm:$L),
4264 "mtmsr $RS, $L", IIC_SprMTMSR>;
4266 def WRTEE: XForm_mtmsr<31, 131, (outs), (ins gprc:$RS),
4267 "wrtee $RS", IIC_SprMTMSR>, Requires<[IsBookE]> {
4271 def WRTEEI: I<31, (outs), (ins i1imm:$E), "wrteei $E", IIC_SprMTMSR>,
4272 Requires<[IsBookE]> {
4276 let Inst{21-30} = 163;
4279 def DCCCI : XForm_tlb<454, (outs), (ins gprc:$RA, gprc:$RB),
4280 "dccci $RA, $RB", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4281 def ICCCI : XForm_tlb<966, (outs), (ins gprc:$RA, gprc:$RB),
4282 "iccci $RA, $RB", IIC_LdStLoad>, Requires<[IsPPC4xx]>;
4284 def : InstAlias<"dci 0", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4285 def : InstAlias<"dccci", (DCCCI R0, R0)>, Requires<[IsPPC4xx]>;
4286 def : InstAlias<"ici 0", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4287 def : InstAlias<"iccci", (ICCCI R0, R0)>, Requires<[IsPPC4xx]>;
4289 def MFMSR : XForm_rs<31, 83, (outs gprc:$RST), (ins),
4290 "mfmsr $RST", IIC_SprMFMSR, []>;
4292 def MTMSRD : XForm_mtmsr<31, 178, (outs), (ins gprc:$RS, u1imm:$L),
4293 "mtmsrd $RS, $L", IIC_SprMTMSRD>;
4295 def MCRFS : XLForm_3<63, 64, (outs crrc:$BF), (ins crrc:$BFA),
4296 "mcrfs $BF, $BFA", IIC_BrMCR>;
4298 // All MTFSF variants may change the rounding mode so conservatively set it
4299 // as an implicit def for all of them.
4300 let Predicates = [HasFPU] in {
4301 let Defs = [RM], hasSideEffects = 1 in {
4302 let isCodeGenOnly = 1,
4303 Pattern = [(int_ppc_mtfsfi timm:$BF, timm:$U)], W = 0 in
4304 def MTFSFIb : XLForm_4<63, 134, (outs), (ins u3imm:$BF, u4imm:$U),
4305 "mtfsfi $BF, $U", IIC_IntMFFS>;
4306 def MTFSFI : XLForm_4<63, 134, (outs), (ins u3imm:$BF, u4imm:$U, i32imm:$W),
4307 "mtfsfi $BF, $U, $W", IIC_IntMFFS>;
4309 def MTFSFI_rec : XLForm_4<63, 134, (outs), (ins u3imm:$BF, u4imm:$U, u1imm:$W),
4310 "mtfsfi. $BF, $U, $W", IIC_IntMFFS>, isRecordForm;
4312 def MTFSF : XFLForm_1<63, 711, (outs),
4313 (ins i32imm:$FLM, f8rc:$FRB, u1imm:$L, i32imm:$W),
4314 "mtfsf $FLM, $FRB, $L, $W", IIC_IntMFFS, []>;
4316 def MTFSF_rec : XFLForm_1<63, 711, (outs),
4317 (ins i32imm:$FLM, f8rc:$FRB, u1imm:$L, i32imm:$W),
4318 "mtfsf. $FLM, $FRB, $L, $W", IIC_IntMFFS, []>, isRecordForm;
4321 def : InstAlias<"mtfsfi $BF, $U", (MTFSFI u3imm:$BF, u4imm:$U, 0)>;
4322 def : InstAlias<"mtfsfi. $BF, $U", (MTFSFI_rec u3imm:$BF, u4imm:$U, 0)>;
4323 def : InstAlias<"mtfsf $FLM, $FRB", (MTFSF i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4324 def : InstAlias<"mtfsf. $FLM, $FRB", (MTFSF_rec i32imm:$FLM, f8rc:$FRB, 0, 0)>;
4327 def SLBIE : XForm_16b<31, 434, (outs), (ins gprc:$RB),
4328 "slbie $RB", IIC_SprSLBIE, []>;
4330 def SLBMTE : XForm_26<31, 402, (outs), (ins gprc:$RST, gprc:$RB),
4331 "slbmte $RST, $RB", IIC_SprSLBMTE, []>;
4333 def SLBMFEE : XForm_26<31, 915, (outs gprc:$RST), (ins gprc:$RB),
4334 "slbmfee $RST, $RB", IIC_SprSLBMFEE, []>;
4336 def SLBMFEV : XLForm_1_gen<31, 851, (outs gprc:$RT), (ins gprc:$RB),
4337 "slbmfev $RT, $RB", IIC_SprSLBMFEV, []>;
4339 def SLBIA : XForm_0<31, 498, (outs), (ins), "slbia", IIC_SprSLBIA, []>;
4342 def SLBFEE_rec : XForm_26<31, 979, (outs gprc:$RST), (ins gprc:$RB),
4343 "slbfee. $RST, $RB", IIC_SprSLBFEE, []>, isRecordForm;
4345 def TLBIA : XForm_0<31, 370, (outs), (ins),
4346 "tlbia", IIC_SprTLBIA, []>;
4348 def TLBSYNC : XForm_0<31, 566, (outs), (ins),
4349 "tlbsync", IIC_SprTLBSYNC, []>;
4351 def TLBIEL : XForm_16b<31, 274, (outs), (ins gprc:$RB),
4352 "tlbiel $RB", IIC_SprTLBIEL, []>;
4354 def TLBLD : XForm_16b<31, 978, (outs), (ins gprc:$RB),
4355 "tlbld $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4356 def TLBLI : XForm_16b<31, 1010, (outs), (ins gprc:$RB),
4357 "tlbli $RB", IIC_LdStLoad, []>, Requires<[IsPPC6xx]>;
4359 def TLBIE : XForm_26<31, 306, (outs), (ins gprc:$RST, gprc:$RB),
4360 "tlbie $RB,$RST", IIC_SprTLBIE, []>;
4362 def TLBSX : XForm_tlb<914, (outs), (ins gprc:$RA, gprc:$RB), "tlbsx $RA, $RB",
4363 IIC_LdStLoad>, Requires<[IsBookE]>;
4365 def TLBIVAX : XForm_tlb<786, (outs), (ins gprc:$RA, gprc:$RB), "tlbivax $RA, $RB",
4366 IIC_LdStLoad>, Requires<[IsBookE]>;
4368 def TLBILX : XForm_tlbilx<18, (outs), (ins u2imm:$T, gprc:$RA, gprc:$RB),
4369 "tlbilx $T, $RA, $RB", IIC_LdStLoad>, Requires<[IsBookE]>;
4371 def TLBRE : XForm_24_eieio<31, 946, (outs), (ins),
4372 "tlbre", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4374 def TLBWE : XForm_24_eieio<31, 978, (outs), (ins),
4375 "tlbwe", IIC_LdStLoad, []>, Requires<[IsBookE]>;
4377 def TLBRE2 : XForm_tlbws<31, 946, (outs gprc:$RST), (ins gprc:$RA, i1imm:$WS),
4378 "tlbre $RST, $RA, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4380 def TLBWE2 : XForm_tlbws<31, 978, (outs), (ins gprc:$RST, gprc:$RA, i1imm:$WS),
4381 "tlbwe $RST, $RA, $WS", IIC_LdStLoad, []>, Requires<[IsPPC4xx]>;
4383 def TLBSX2 : XForm_base_r3xo<31, 914, (outs), (ins gprc:$RST, gprc:$RA, gprc:$RB),
4384 "tlbsx $RST, $RA, $RB", IIC_LdStLoad, []>,
4385 Requires<[IsPPC4xx]>;
4386 def TLBSX2D : XForm_base_r3xo<31, 914, (outs),
4387 (ins gprc:$RST, gprc:$RA, gprc:$RB),
4388 "tlbsx. $RST, $RA, $RB", IIC_LdStLoad, []>,
4389 Requires<[IsPPC4xx]>, isRecordForm;
4391 def RFID : XForm_0<19, 18, (outs), (ins), "rfid", IIC_IntRFID, []>;
4393 def RFI : XForm_0<19, 50, (outs), (ins), "rfi", IIC_SprRFI, []>,
4394 Requires<[IsBookE]>;
4395 def RFCI : XForm_0<19, 51, (outs), (ins), "rfci", IIC_BrB, []>,
4396 Requires<[IsBookE]>;
4398 def RFDI : XForm_0<19, 39, (outs), (ins), "rfdi", IIC_BrB, []>,
4400 def RFMCI : XForm_0<19, 38, (outs), (ins), "rfmci", IIC_BrB, []>,
4403 def MFDCR : XFXForm_1<31, 323, (outs gprc:$RST), (ins i32imm:$SPR),
4404 "mfdcr $RST, $SPR", IIC_SprMFSPR>, Requires<[IsPPC4xx]>;
4405 def MTDCR : XFXForm_1<31, 451, (outs), (ins gprc:$RST, i32imm:$SPR),
4406 "mtdcr $SPR, $RST", IIC_SprMTSPR>, Requires<[IsPPC4xx]>;
4408 def HRFID : XLForm_1_np<19, 274, (outs), (ins), "hrfid", IIC_BrB, []>;
4409 def NAP : XLForm_1_np<19, 434, (outs), (ins), "nap", IIC_BrB, []>;
4411 def ATTN : XForm_attn<0, 256, (outs), (ins), "attn", IIC_BrB>;
4413 def LBZCIX : XForm_base_r3xo_memOp<31, 853, (outs gprc:$RST),
4414 (ins gprc:$RA, gprc:$RB),
4415 "lbzcix $RST, $RA, $RB", IIC_LdStLoad, []>;
4416 def LHZCIX : XForm_base_r3xo_memOp<31, 821, (outs gprc:$RST),
4417 (ins gprc:$RA, gprc:$RB),
4418 "lhzcix $RST, $RA, $RB", IIC_LdStLoad, []>;
4419 def LWZCIX : XForm_base_r3xo_memOp<31, 789, (outs gprc:$RST),
4420 (ins gprc:$RA, gprc:$RB),
4421 "lwzcix $RST, $RA, $RB", IIC_LdStLoad, []>;
4422 def LDCIX : XForm_base_r3xo_memOp<31, 885, (outs gprc:$RST),
4423 (ins gprc:$RA, gprc:$RB),
4424 "ldcix $RST, $RA, $RB", IIC_LdStLoad, []>;
4426 def STBCIX : XForm_base_r3xo_memOp<31, 981, (outs),
4427 (ins gprc:$RST, gprc:$RA, gprc:$RB),
4428 "stbcix $RST, $RA, $RB", IIC_LdStLoad, []>;
4429 def STHCIX : XForm_base_r3xo_memOp<31, 949, (outs),
4430 (ins gprc:$RST, gprc:$RA, gprc:$RB),
4431 "sthcix $RST, $RA, $RB", IIC_LdStLoad, []>;
4432 def STWCIX : XForm_base_r3xo_memOp<31, 917, (outs),
4433 (ins gprc:$RST, gprc:$RA, gprc:$RB),
4434 "stwcix $RST, $RA, $RB", IIC_LdStLoad, []>;
4435 def STDCIX : XForm_base_r3xo_memOp<31, 1013, (outs),
4436 (ins gprc:$RST, gprc:$RA, gprc:$RB),
4437 "stdcix $RST, $RA, $RB", IIC_LdStLoad, []>;
4439 // External PID Load Store Instructions
4441 def LBEPX : XForm_1<31, 95, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
4442 "lbepx $RST, $addr", IIC_LdStLoad, []>,
4445 def LFDEPX : XForm_25<31, 607, (outs f8rc:$RST), (ins (memrr $RA, $RB):$addr),
4446 "lfdepx $RST, $addr", IIC_LdStLFD, []>,
4449 def LHEPX : XForm_1<31, 287, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
4450 "lhepx $RST, $addr", IIC_LdStLoad, []>,
4453 def LWEPX : XForm_1<31, 31, (outs gprc:$RST), (ins (memrr $RA, $RB):$addr),
4454 "lwepx $RST, $addr", IIC_LdStLoad, []>,
4457 def STBEPX : XForm_8<31, 223, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
4458 "stbepx $RST, $addr", IIC_LdStStore, []>,
4461 def STFDEPX : XForm_28_memOp<31, 735, (outs), (ins f8rc:$RST, (memrr $RA, $RB):$addr),
4462 "stfdepx $RST, $addr", IIC_LdStSTFD, []>,
4465 def STHEPX : XForm_8<31, 415, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
4466 "sthepx $RST, $addr", IIC_LdStStore, []>,
4469 def STWEPX : XForm_8<31, 159, (outs), (ins gprc:$RST, (memrr $RA, $RB):$addr),
4470 "stwepx $RST, $addr", IIC_LdStStore, []>,
4473 def DCBFEP : DCB_Form<127, 0, (outs), (ins (memrr $RA, $RB):$addr), "dcbfep $addr",
4474 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4476 def DCBSTEP : DCB_Form<63, 0, (outs), (ins (memrr $RA, $RB):$addr), "dcbstep $addr",
4477 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4479 def DCBTEP : DCB_Form_hint<319, (outs), (ins (memrr $RA, $RB):$addr, u5imm:$TH),
4480 "dcbtep $TH, $addr", IIC_LdStDCBF, []>,
4483 def DCBTSTEP : DCB_Form_hint<255, (outs), (ins (memrr $RA, $RB):$addr, u5imm:$TH),
4484 "dcbtstep $TH, $addr", IIC_LdStDCBF, []>,
4487 def DCBZEP : DCB_Form<1023, 0, (outs), (ins (memrr $RA, $RB):$addr), "dcbzep $addr",
4488 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4490 def DCBZLEP : DCB_Form<1023, 1, (outs), (ins (memrr $RA, $RB):$addr), "dcbzlep $addr",
4491 IIC_LdStDCBF, []>, Requires<[IsE500]>;
4493 def ICBIEP : XForm_1a<31, 991, (outs), (ins (memrr $RA, $RB):$addr), "icbiep $addr",
4494 IIC_LdStICBI, []>, Requires<[IsE500]>;
4496 //===----------------------------------------------------------------------===//
4497 // PowerPC Assembler Instruction Aliases
4500 def : InstAlias<"sc", (SC 0)>;
4502 def : InstAlias<"sync", (SYNC 0)>, Requires<[HasSYNC]>;
4503 def : InstAlias<"hwsync", (SYNC 0), 0>, Requires<[HasSYNC]>;
4504 def : InstAlias<"msync", (SYNC 0), 0>, Requires<[HasSYNC]>;
4505 def : InstAlias<"lwsync", (SYNC 1)>, Requires<[HasSYNC]>;
4506 def : InstAlias<"ptesync", (SYNC 2)>, Requires<[HasSYNC]>;
4508 def : InstAlias<"wait", (WAIT 0)>;
4509 def : InstAlias<"waitrsv", (WAIT 1)>;
4510 def : InstAlias<"waitimpl", (WAIT 2)>;
4512 def : InstAlias<"mbar", (MBAR 0)>, Requires<[IsBookE]>;
4514 def DCBTx : PPCAsmPseudo<"dcbt $dst", (ins memrr:$dst)>;
4515 def DCBTSTx : PPCAsmPseudo<"dcbtst $dst", (ins memrr:$dst)>;
4517 def DCBTCT : PPCAsmPseudo<"dcbtct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4518 def DCBTDS : PPCAsmPseudo<"dcbtds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4519 def DCBTT : PPCAsmPseudo<"dcbtt $dst", (ins memrr:$dst)>;
4521 def DCBTSTCT : PPCAsmPseudo<"dcbtstct $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4522 def DCBTSTDS : PPCAsmPseudo<"dcbtstds $dst, $TH", (ins memrr:$dst, u5imm:$TH)>;
4523 def DCBTSTT : PPCAsmPseudo<"dcbtstt $dst", (ins memrr:$dst)>;
4525 def DCBFx : PPCAsmPseudo<"dcbf $dst", (ins memrr:$dst)>;
4526 def DCBFL : PPCAsmPseudo<"dcbfl $dst", (ins memrr:$dst)>;
4527 def DCBFLP : PPCAsmPseudo<"dcbflp $dst", (ins memrr:$dst)>;
4529 def : Pat<(int_ppc_isync), (ISYNC)>;
4530 def : Pat<(int_ppc_dcbfl xoaddr:$dst),
4531 (DCBF 1, xoaddr:$dst)>;
4532 def : Pat<(int_ppc_dcbflp xoaddr:$dst),
4533 (DCBF 3, xoaddr:$dst)>;
4535 let Predicates = [IsISA3_1] in {
4536 def DCBFPS : PPCAsmPseudo<"dcbfps $dst", (ins memrr:$dst)>;
4537 def DCBSTPS : PPCAsmPseudo<"dcbstps $dst", (ins memrr:$dst)>;
4539 def : Pat<(int_ppc_dcbfps xoaddr:$dst),
4540 (DCBF 4, xoaddr:$dst)>;
4541 def : Pat<(int_ppc_dcbstps xoaddr:$dst),
4542 (DCBF 6, xoaddr:$dst)>;
4545 def : InstAlias<"crset $bx", (CREQV crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4546 def : InstAlias<"crclr $bx", (CRXOR crbitrc:$bx, crbitrc:$bx, crbitrc:$bx)>;
4547 def : InstAlias<"crmove $bx, $by", (CROR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4548 def : InstAlias<"crnot $bx, $by", (CRNOR crbitrc:$bx, crbitrc:$by, crbitrc:$by)>;
4550 def : InstAlias<"mftb $Rx", (MFTB gprc:$Rx, 268)>;
4551 def : InstAlias<"mftbl $Rx", (MFTB gprc:$Rx, 268)>;
4552 def : InstAlias<"mftbu $Rx", (MFTB gprc:$Rx, 269)>;
4554 def : InstAlias<"xnop", (XORI R0, R0, 0)>;
4556 def : InstAlias<"mtxer $Rx", (MTSPR 1, gprc:$Rx)>;
4557 def : InstAlias<"mfxer $Rx", (MFSPR gprc:$Rx, 1)>;
4559 //Disable this alias on AIX for now because as does not support them.
4560 let Predicates = [ModernAs] in {
4562 foreach BR = 0-7 in {
4563 def : InstAlias<"mfbr"#BR#" $Rx",
4564 (MFDCR gprc:$Rx, !add(BR, 0x80))>,
4565 Requires<[IsPPC4xx]>;
4566 def : InstAlias<"mtbr"#BR#" $Rx",
4567 (MTDCR gprc:$Rx, !add(BR, 0x80))>,
4568 Requires<[IsPPC4xx]>;
4571 def : InstAlias<"mtmsrd $RS", (MTMSRD gprc:$RS, 0)>;
4572 def : InstAlias<"mtmsr $RS", (MTMSR gprc:$RS, 0)>;
4573 def : InstAlias<"mtudscr $Rx", (MTSPR 3, gprc:$Rx)>;
4574 def : InstAlias<"mfudscr $Rx", (MFSPR gprc:$Rx, 3)>;
4576 def : InstAlias<"mfrtcu $Rx", (MFSPR gprc:$Rx, 4)>;
4577 def : InstAlias<"mfrtcl $Rx", (MFSPR gprc:$Rx, 5)>;
4579 def : InstAlias<"mtlr $Rx", (MTSPR 8, gprc:$Rx)>;
4580 def : InstAlias<"mflr $Rx", (MFSPR gprc:$Rx, 8)>;
4582 def : InstAlias<"mtctr $Rx", (MTSPR 9, gprc:$Rx)>;
4583 def : InstAlias<"mfctr $Rx", (MFSPR gprc:$Rx, 9)>;
4585 def : InstAlias<"mtuamr $Rx", (MTSPR 13, gprc:$Rx)>;
4586 def : InstAlias<"mfuamr $Rx", (MFSPR gprc:$Rx, 13)>;
4588 def : InstAlias<"mtdscr $Rx", (MTSPR 17, gprc:$Rx)>;
4589 def : InstAlias<"mfdscr $Rx", (MFSPR gprc:$Rx, 17)>;
4591 def : InstAlias<"mtdsisr $Rx", (MTSPR 18, gprc:$Rx)>;
4592 def : InstAlias<"mfdsisr $Rx", (MFSPR gprc:$Rx, 18)>;
4594 def : InstAlias<"mtdar $Rx", (MTSPR 19, gprc:$Rx)>;
4595 def : InstAlias<"mfdar $Rx", (MFSPR gprc:$Rx, 19)>;
4597 def : InstAlias<"mtdec $Rx", (MTSPR 22, gprc:$Rx)>;
4598 def : InstAlias<"mfdec $Rx", (MFSPR gprc:$Rx, 22)>;
4600 def : InstAlias<"mtsdr1 $Rx", (MTSPR 25, gprc:$Rx)>;
4601 def : InstAlias<"mfsdr1 $Rx", (MFSPR gprc:$Rx, 25)>;
4603 def : InstAlias<"mtsrr0 $Rx", (MTSPR 26, gprc:$Rx)>;
4604 def : InstAlias<"mfsrr0 $Rx", (MFSPR gprc:$Rx, 26)>;
4606 def : InstAlias<"mtsrr1 $Rx", (MTSPR 27, gprc:$Rx)>;
4607 def : InstAlias<"mfsrr1 $Rx", (MFSPR gprc:$Rx, 27)>;
4609 def : InstAlias<"mtcfar $Rx", (MTSPR 28, gprc:$Rx)>;
4610 def : InstAlias<"mfcfar $Rx", (MFSPR gprc:$Rx, 28)>;
4612 def : InstAlias<"mtamr $Rx", (MTSPR 29, gprc:$Rx)>;
4613 def : InstAlias<"mfamr $Rx", (MFSPR gprc:$Rx, 29)>;
4615 def : InstAlias<"mtpid $Rx", (MTSPR 48, gprc:$Rx)>, Requires<[IsBookE]>;
4616 def : InstAlias<"mfpid $Rx", (MFSPR gprc:$Rx, 48)>, Requires<[IsBookE]>;
4618 foreach SPRG = 4-7 in {
4619 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 256))>,
4620 Requires<[IsBookE]>;
4621 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 256))>,
4622 Requires<[IsBookE]>;
4623 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4624 Requires<[IsBookE]>;
4625 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 256), gprc:$RT)>,
4626 Requires<[IsBookE]>;
4629 foreach SPRG = 0-3 in {
4630 def : InstAlias<"mfsprg $RT, "#SPRG, (MFSPR gprc:$RT, !add(SPRG, 272))>;
4631 def : InstAlias<"mfsprg"#SPRG#" $RT", (MFSPR gprc:$RT, !add(SPRG, 272))>;
4632 def : InstAlias<"mtsprg "#SPRG#", $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4633 def : InstAlias<"mtsprg"#SPRG#" $RT", (MTSPR !add(SPRG, 272), gprc:$RT)>;
4636 def : InstAlias<"mfasr $RT", (MFSPR gprc:$RT, 280)>;
4637 def : InstAlias<"mtasr $RT", (MTSPR 280, gprc:$RT)>;
4639 def : InstAlias<"mttbl $Rx", (MTSPR 284, gprc:$Rx)>;
4640 def : InstAlias<"mttbu $Rx", (MTSPR 285, gprc:$Rx)>;
4642 def : InstAlias<"mfpvr $RT", (MFSPR gprc:$RT, 287)>;
4644 def : InstAlias<"mfspefscr $Rx", (MFSPR gprc:$Rx, 512)>;
4645 def : InstAlias<"mtspefscr $Rx", (MTSPR 512, gprc:$Rx)>;
4647 foreach BATR = 0-3 in {
4648 def : InstAlias<"mtdbatu "#BATR#", $Rx",
4649 (MTSPR !add(BATR, !add(BATR, 536)), gprc:$Rx)>,
4650 Requires<[IsPPC6xx]>;
4651 def : InstAlias<"mfdbatu $Rx, "#BATR,
4652 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 536)))>,
4653 Requires<[IsPPC6xx]>;
4654 def : InstAlias<"mtdbatl "#BATR#", $Rx",
4655 (MTSPR !add(BATR, !add(BATR, 537)), gprc:$Rx)>,
4656 Requires<[IsPPC6xx]>;
4657 def : InstAlias<"mfdbatl $Rx, "#BATR,
4658 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 537)))>,
4659 Requires<[IsPPC6xx]>;
4660 def : InstAlias<"mtibatu "#BATR#", $Rx",
4661 (MTSPR !add(BATR, !add(BATR, 528)), gprc:$Rx)>,
4662 Requires<[IsPPC6xx]>;
4663 def : InstAlias<"mfibatu $Rx, "#BATR,
4664 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 528)))>,
4665 Requires<[IsPPC6xx]>;
4666 def : InstAlias<"mtibatl "#BATR#", $Rx",
4667 (MTSPR !add(BATR, !add(BATR, 529)), gprc:$Rx)>,
4668 Requires<[IsPPC6xx]>;
4669 def : InstAlias<"mfibatl $Rx, "#BATR,
4670 (MFSPR gprc:$Rx, !add(BATR, !add(BATR, 529)))>,
4671 Requires<[IsPPC6xx]>;
4674 def : InstAlias<"mtppr $RT", (MTSPR 896, gprc:$RT)>;
4675 def : InstAlias<"mfppr $RT", (MFSPR gprc:$RT, 896)>;
4677 def : InstAlias<"mtesr $Rx", (MTSPR 980, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4678 def : InstAlias<"mfesr $Rx", (MFSPR gprc:$Rx, 980)>, Requires<[IsPPC4xx]>;
4680 def : InstAlias<"mtdear $Rx", (MTSPR 981, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4681 def : InstAlias<"mfdear $Rx", (MFSPR gprc:$Rx, 981)>, Requires<[IsPPC4xx]>;
4683 def : InstAlias<"mttcr $Rx", (MTSPR 986, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4684 def : InstAlias<"mftcr $Rx", (MFSPR gprc:$Rx, 986)>, Requires<[IsPPC4xx]>;
4686 def : InstAlias<"mftbhi $Rx", (MFSPR gprc:$Rx, 988)>, Requires<[IsPPC4xx]>;
4687 def : InstAlias<"mttbhi $Rx", (MTSPR 988, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4689 def : InstAlias<"mftblo $Rx", (MFSPR gprc:$Rx, 989)>, Requires<[IsPPC4xx]>;
4690 def : InstAlias<"mttblo $Rx", (MTSPR 989, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4692 def : InstAlias<"mtsrr2 $Rx", (MTSPR 990, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4693 def : InstAlias<"mfsrr2 $Rx", (MFSPR gprc:$Rx, 990)>, Requires<[IsPPC4xx]>;
4695 def : InstAlias<"mtsrr3 $Rx", (MTSPR 991, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4696 def : InstAlias<"mfsrr3 $Rx", (MFSPR gprc:$Rx, 991)>, Requires<[IsPPC4xx]>;
4698 def : InstAlias<"mtdccr $Rx", (MTSPR 1018, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4699 def : InstAlias<"mfdccr $Rx", (MFSPR gprc:$Rx, 1018)>, Requires<[IsPPC4xx]>;
4701 def : InstAlias<"mticcr $Rx", (MTSPR 1019, gprc:$Rx)>, Requires<[IsPPC4xx]>;
4702 def : InstAlias<"mficcr $Rx", (MFSPR gprc:$Rx, 1019)>, Requires<[IsPPC4xx]>;
4706 def : InstAlias<"tlbie $RB", (TLBIE R0, gprc:$RB)>;
4708 def : InstAlias<"tlbrehi $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 0)>,
4709 Requires<[IsPPC4xx]>;
4710 def : InstAlias<"tlbrelo $RS, $A", (TLBRE2 gprc:$RS, gprc:$A, 1)>,
4711 Requires<[IsPPC4xx]>;
4712 def : InstAlias<"tlbwehi $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 0)>,
4713 Requires<[IsPPC4xx]>;
4714 def : InstAlias<"tlbwelo $RS, $A", (TLBWE2 gprc:$RS, gprc:$A, 1)>,
4715 Requires<[IsPPC4xx]>;
4717 def : InstAlias<"tlbilxlpid", (TLBILX 0, R0, R0)>, Requires<[IsBookE]>;
4718 def : InstAlias<"tlbilxpid", (TLBILX 1, R0, R0)>, Requires<[IsBookE]>;
4719 def : InstAlias<"tlbilxva $RA, $RB", (TLBILX 3, gprc:$RA, gprc:$RB)>,
4720 Requires<[IsBookE]>;
4721 def : InstAlias<"tlbilxva $RB", (TLBILX 3, R0, gprc:$RB)>, Requires<[IsBookE]>;
4723 def LAx : PPCAsmPseudo<"la $rA, $addr", (ins gprc:$rA, memri:$addr)>, MemriOp;
4725 def SUBI : PPCAsmPseudo<"subi $rA, $rB, $imm",
4726 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4727 def SUBIS : PPCAsmPseudo<"subis $rA, $rB, $imm",
4728 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4729 def SUBIC : PPCAsmPseudo<"subic $rA, $rB, $imm",
4730 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4731 def SUBIC_rec : PPCAsmPseudo<"subic. $rA, $rB, $imm",
4732 (ins gprc:$rA, gprc:$rB, s16imm:$imm)>;
4734 def EXTLWI : PPCAsmPseudo<"extlwi $rA, $rS, $n, $b",
4735 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>,
4737 def EXTLWI_rec : PPCAsmPseudo<"extlwi. $rA, $rS, $n, $b",
4738 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>,
4740 def EXTRWI : PPCAsmPseudo<"extrwi $rA, $rS, $n, $b",
4741 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4742 def EXTRWI_rec : PPCAsmPseudo<"extrwi. $rA, $rS, $n, $b",
4743 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4744 def INSLWI : PPCAsmPseudo<"inslwi $rA, $rS, $n, $b",
4745 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4746 def INSLWI_rec : PPCAsmPseudo<"inslwi. $rA, $rS, $n, $b",
4747 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4748 def INSRWI : PPCAsmPseudo<"insrwi $rA, $rS, $n, $b",
4749 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4750 def INSRWI_rec : PPCAsmPseudo<"insrwi. $rA, $rS, $n, $b",
4751 (ins gprc:$rA, gprc:$rS, u5imm:$n, u5imm:$b)>;
4752 def ROTRWI : PPCAsmPseudo<"rotrwi $rA, $rS, $n",
4753 (ins gprc:$rA, gprc:$rS, u5imm:$n)>, ZExt32To64;
4754 def ROTRWI_rec : PPCAsmPseudo<"rotrwi. $rA, $rS, $n",
4755 (ins gprc:$rA, gprc:$rS, u5imm:$n)>, ZExt32To64;
4756 def SLWI : PPCAsmPseudo<"slwi $rA, $rS, $n",
4757 (ins gprc:$rA, gprc:$rS, u5imm:$n)>, ZExt32To64;
4758 def SLWI_rec : PPCAsmPseudo<"slwi. $rA, $rS, $n",
4759 (ins gprc:$rA, gprc:$rS, u5imm:$n)>, ZExt32To64;
4760 def SRWI : PPCAsmPseudo<"srwi $rA, $rS, $n",
4761 (ins gprc:$rA, gprc:$rS, u5imm:$n)>, ZExt32To64;
4762 def SRWI_rec : PPCAsmPseudo<"srwi. $rA, $rS, $n",
4763 (ins gprc:$rA, gprc:$rS, u5imm:$n)>, ZExt32To64;
4764 def CLRRWI : PPCAsmPseudo<"clrrwi $rA, $rS, $n",
4765 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4766 def CLRRWI_rec : PPCAsmPseudo<"clrrwi. $rA, $rS, $n",
4767 (ins gprc:$rA, gprc:$rS, u5imm:$n)>;
4768 def CLRLSLWI : PPCAsmPseudo<"clrlslwi $rA, $rS, $b, $n",
4769 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4770 def CLRLSLWI_rec : PPCAsmPseudo<"clrlslwi. $rA, $rS, $b, $n",
4771 (ins gprc:$rA, gprc:$rS, u5imm:$b, u5imm:$n)>;
4773 def : InstAlias<"isellt $rT, $rA, $rB",
4774 (ISEL gprc:$rT, gprc_nor0:$rA, gprc:$rB, CR0LT)>;
4775 def : InstAlias<"iselgt $rT, $rA, $rB",
4776 (ISEL gprc:$rT, gprc_nor0:$rA, gprc:$rB, CR0GT)>;
4777 def : InstAlias<"iseleq $rT, $rA, $rB",
4778 (ISEL gprc:$rT, gprc_nor0:$rA, gprc:$rB, CR0EQ)>;
4780 def : InstAlias<"rotlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4781 def : InstAlias<"rotlwi. $rA, $rS, $n", (RLWINM_rec gprc:$rA, gprc:$rS, u5imm:$n, 0, 31)>;
4782 def : InstAlias<"rotlw $rA, $rS, $rB", (RLWNM gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4783 def : InstAlias<"rotlw. $rA, $rS, $rB", (RLWNM_rec gprc:$rA, gprc:$rS, gprc:$rB, 0, 31)>;
4784 def : InstAlias<"clrlwi $rA, $rS, $n", (RLWINM gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4785 def : InstAlias<"clrlwi. $rA, $rS, $n", (RLWINM_rec gprc:$rA, gprc:$rS, 0, u5imm:$n, 31)>;
4787 def : InstAlias<"cntlzw $rA, $rS", (CNTLZW gprc:$rA, gprc:$rS)>;
4788 def : InstAlias<"cntlzw. $rA, $rS", (CNTLZW_rec gprc:$rA, gprc:$rS)>;
4789 // The POWER variant
4790 def : MnemonicAlias<"cntlz", "cntlzw">;
4791 def : MnemonicAlias<"cntlz.", "cntlzw.">;
4793 def EXTLDI : PPCAsmPseudo<"extldi $rA, $rS, $n, $b",
4794 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4795 def EXTLDI_rec : PPCAsmPseudo<"extldi. $rA, $rS, $n, $b",
4796 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4797 def EXTRDI : PPCAsmPseudo<"extrdi $rA, $rS, $n, $b",
4798 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4799 def EXTRDI_rec : PPCAsmPseudo<"extrdi. $rA, $rS, $n, $b",
4800 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4801 def INSRDI : PPCAsmPseudo<"insrdi $rA, $rS, $n, $b",
4802 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4803 def INSRDI_rec : PPCAsmPseudo<"insrdi. $rA, $rS, $n, $b",
4804 (ins g8rc:$rA, g8rc:$rS, u6imm:$n, u6imm:$b)>;
4805 def ROTRDI : PPCAsmPseudo<"rotrdi $rA, $rS, $n",
4806 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4807 def ROTRDI_rec : PPCAsmPseudo<"rotrdi. $rA, $rS, $n",
4808 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4809 def SLDI : PPCAsmPseudo<"sldi $rA, $rS, $n",
4810 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4811 def SLDI_rec : PPCAsmPseudo<"sldi. $rA, $rS, $n",
4812 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4813 def SRDI : PPCAsmPseudo<"srdi $rA, $rS, $n",
4814 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4815 def SRDI_rec : PPCAsmPseudo<"srdi. $rA, $rS, $n",
4816 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4817 def CLRRDI : PPCAsmPseudo<"clrrdi $rA, $rS, $n",
4818 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4819 def CLRRDI_rec : PPCAsmPseudo<"clrrdi. $rA, $rS, $n",
4820 (ins g8rc:$rA, g8rc:$rS, u6imm:$n)>;
4821 def CLRLSLDI : PPCAsmPseudo<"clrlsldi $rA, $rS, $b, $n",
4822 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4823 def CLRLSLDI_rec : PPCAsmPseudo<"clrlsldi. $rA, $rS, $b, $n",
4824 (ins g8rc:$rA, g8rc:$rS, u6imm:$b, u6imm:$n)>;
4825 def SUBPCIS : PPCAsmPseudo<"subpcis $RT, $D", (ins g8rc:$RT, s16imm:$D)>;
4827 def : InstAlias<"rotldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4828 def : InstAlias<"rotldi $rA, $rS, $n",
4829 (RLDICL_32_64 g8rc:$rA, gprc:$rS, u6imm:$n, 0)>;
4830 def : InstAlias<"rotldi. $rA, $rS, $n", (RLDICL_rec g8rc:$rA, g8rc:$rS, u6imm:$n, 0)>;
4831 def : InstAlias<"rotld $rA, $rS, $rB", (RLDCL g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4832 def : InstAlias<"rotld. $rA, $rS, $rB", (RLDCL_rec g8rc:$rA, g8rc:$rS, gprc:$rB, 0)>;
4833 def : InstAlias<"clrldi $rA, $rS, $n", (RLDICL g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4834 def : InstAlias<"clrldi $rA, $rS, $n",
4835 (RLDICL_32_64 g8rc:$rA, gprc:$rS, 0, u6imm:$n)>;
4836 def : InstAlias<"clrldi. $rA, $rS, $n", (RLDICL_rec g8rc:$rA, g8rc:$rS, 0, u6imm:$n)>;
4837 def : InstAlias<"lnia $RT", (ADDPCIS g8rc:$RT, 0)>;
4839 def RLWINMbm : PPCAsmPseudo<"rlwinm $rA, $rS, $n, $b",
4840 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4841 def RLWINMbm_rec : PPCAsmPseudo<"rlwinm. $rA, $rS, $n, $b",
4842 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4843 def RLWIMIbm : PPCAsmPseudo<"rlwimi $rA, $rS, $n, $b",
4844 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4845 def RLWIMIbm_rec : PPCAsmPseudo<"rlwimi. $rA, $rS, $n, $b",
4846 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4847 def RLWNMbm : PPCAsmPseudo<"rlwnm $rA, $rS, $n, $b",
4848 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4849 def RLWNMbm_rec : PPCAsmPseudo<"rlwnm. $rA, $rS, $n, $b",
4850 (ins g8rc:$rA, g8rc:$rS, u5imm:$n, i32imm:$b)>;
4851 def PPCLdFixedAddr :
4852 PPCPostRAExpPseudo<(outs gprc:$rT), (ins i32imm:$imm), "#FA_LOAD",
4853 [(set i32:$rT, (int_ppc_fixed_addr_ld timm:$imm))]>;
4855 // These generic branch instruction forms are used for the assembler parser only.
4856 // Defs and Uses are conservative, since we don't know the BO value.
4857 let PPC970_Unit = 7, isBranch = 1, hasSideEffects = 0 in {
4858 let Defs = [CTR], Uses = [CTR, RM] in {
4859 def gBC : BForm_3<16, 0, 0, (outs),
4860 (ins u5imm:$BO, crbitrc:$BI, condbrtarget:$BD),
4861 "bc $BO, $BI, $BD">;
4862 def gBCA : BForm_3<16, 1, 0, (outs),
4863 (ins u5imm:$BO, crbitrc:$BI, abscondbrtarget:$BD),
4864 "bca $BO, $BI, $BD">;
4865 let isAsmParserOnly = 1 in {
4866 def gBCat : BForm_3_at<16, 0, 0, (outs),
4867 (ins u5imm:$BO, atimm:$at, crbitrc:$BI,
4869 "bc$at $BO, $BI, $BD">;
4870 def gBCAat : BForm_3_at<16, 1, 0, (outs),
4871 (ins u5imm:$BO, atimm:$at, crbitrc:$BI,
4872 abscondbrtarget:$BD),
4873 "bca$at $BO, $BI, $BD">;
4874 } // isAsmParserOnly = 1
4876 let Defs = [LR, CTR], Uses = [CTR, RM] in {
4877 def gBCL : BForm_3<16, 0, 1, (outs),
4878 (ins u5imm:$BO, crbitrc:$BI, condbrtarget:$BD),
4879 "bcl $BO, $BI, $BD">;
4880 def gBCLA : BForm_3<16, 1, 1, (outs),
4881 (ins u5imm:$BO, crbitrc:$BI, abscondbrtarget:$BD),
4882 "bcla $BO, $BI, $BD">;
4883 let isAsmParserOnly = 1 in {
4884 def gBCLat : BForm_3_at<16, 0, 1, (outs),
4885 (ins u5imm:$BO, atimm:$at, crbitrc:$BI,
4887 "bcl$at $BO, $BI, $BD">;
4888 def gBCLAat : BForm_3_at<16, 1, 1, (outs),
4889 (ins u5imm:$BO, atimm:$at, crbitrc:$BI,
4890 abscondbrtarget:$BD),
4891 "bcla$at $BO, $BI, $BD">;
4892 } // // isAsmParserOnly = 1
4894 let Defs = [CTR], Uses = [CTR, LR, RM] in
4895 def gBCLR : XLForm_2<19, 16, 0, (outs),
4896 (ins u5imm:$BO, crbitrc:$BI, i32imm:$BH),
4897 "bclr $BO, $BI, $BH", IIC_BrB, []>;
4898 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4899 def gBCLRL : XLForm_2<19, 16, 1, (outs),
4900 (ins u5imm:$BO, crbitrc:$BI, i32imm:$BH),
4901 "bclrl $BO, $BI, $BH", IIC_BrB, []>;
4902 let Defs = [CTR], Uses = [CTR, LR, RM] in
4903 def gBCCTR : XLForm_2<19, 528, 0, (outs),
4904 (ins u5imm:$BO, crbitrc:$BI, i32imm:$BH),
4905 "bcctr $BO, $BI, $BH", IIC_BrB, []>;
4906 let Defs = [LR, CTR], Uses = [CTR, LR, RM] in
4907 def gBCCTRL : XLForm_2<19, 528, 1, (outs),
4908 (ins u5imm:$BO, crbitrc:$BI, i32imm:$BH),
4909 "bcctrl $BO, $BI, $BH", IIC_BrB, []>;
4912 multiclass BranchSimpleMnemonicAT<string pm, int at> {
4913 def : InstAlias<"bc"#pm#" $bo, $bi, $dst", (gBCat u5imm:$bo, at, crbitrc:$bi,
4914 condbrtarget:$dst)>;
4915 def : InstAlias<"bca"#pm#" $bo, $bi, $dst", (gBCAat u5imm:$bo, at, crbitrc:$bi,
4916 condbrtarget:$dst)>;
4917 def : InstAlias<"bcl"#pm#" $bo, $bi, $dst", (gBCLat u5imm:$bo, at, crbitrc:$bi,
4918 condbrtarget:$dst)>;
4919 def : InstAlias<"bcla"#pm#" $bo, $bi, $dst", (gBCLAat u5imm:$bo, at, crbitrc:$bi,
4920 condbrtarget:$dst)>;
4922 defm : BranchSimpleMnemonicAT<"+", 3>;
4923 defm : BranchSimpleMnemonicAT<"-", 2>;
4925 def : InstAlias<"bclr $bo, $bi", (gBCLR u5imm:$bo, crbitrc:$bi, 0)>;
4926 def : InstAlias<"bclrl $bo, $bi", (gBCLRL u5imm:$bo, crbitrc:$bi, 0)>;
4927 def : InstAlias<"bcctr $bo, $bi", (gBCCTR u5imm:$bo, crbitrc:$bi, 0)>;
4928 def : InstAlias<"bcctrl $bo, $bi", (gBCCTRL u5imm:$bo, crbitrc:$bi, 0)>;
4930 multiclass BranchSimpleMnemonic1<string name, string pm, int bo> {
4931 def : InstAlias<"b"#name#pm#" $bi, $dst", (gBC bo, crbitrc:$bi, condbrtarget:$dst)>;
4932 def : InstAlias<"b"#name#"a"#pm#" $bi, $dst", (gBCA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4933 def : InstAlias<"b"#name#"lr"#pm#" $bi", (gBCLR bo, crbitrc:$bi, 0)>;
4934 def : InstAlias<"b"#name#"l"#pm#" $bi, $dst", (gBCL bo, crbitrc:$bi, condbrtarget:$dst)>;
4935 def : InstAlias<"b"#name#"la"#pm#" $bi, $dst", (gBCLA bo, crbitrc:$bi, abscondbrtarget:$dst)>;
4936 def : InstAlias<"b"#name#"lrl"#pm#" $bi", (gBCLRL bo, crbitrc:$bi, 0)>;
4938 multiclass BranchSimpleMnemonic2<string name, string pm, int bo>
4939 : BranchSimpleMnemonic1<name, pm, bo> {
4940 def : InstAlias<"b"#name#"ctr"#pm#" $bi", (gBCCTR bo, crbitrc:$bi, 0)>;
4941 def : InstAlias<"b"#name#"ctrl"#pm#" $bi", (gBCCTRL bo, crbitrc:$bi, 0)>;
4943 defm : BranchSimpleMnemonic2<"t", "", 12>;
4944 defm : BranchSimpleMnemonic2<"f", "", 4>;
4945 defm : BranchSimpleMnemonic2<"t", "-", 14>;
4946 defm : BranchSimpleMnemonic2<"f", "-", 6>;
4947 defm : BranchSimpleMnemonic2<"t", "+", 15>;
4948 defm : BranchSimpleMnemonic2<"f", "+", 7>;
4949 defm : BranchSimpleMnemonic1<"dnzt", "", 8>;
4950 defm : BranchSimpleMnemonic1<"dnzf", "", 0>;
4951 defm : BranchSimpleMnemonic1<"dzt", "", 10>;
4952 defm : BranchSimpleMnemonic1<"dzf", "", 2>;
4954 multiclass BranchExtendedMnemonicPM<string name, string pm, int bibo> {
4955 def : InstAlias<"b"#name#pm#" $cc, $dst",
4956 (BCC bibo, crrc:$cc, condbrtarget:$dst)>;
4957 def : InstAlias<"b"#name#pm#" $dst",
4958 (BCC bibo, CR0, condbrtarget:$dst)>;
4960 def : InstAlias<"b"#name#"a"#pm#" $cc, $dst",
4961 (BCCA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4962 def : InstAlias<"b"#name#"a"#pm#" $dst",
4963 (BCCA bibo, CR0, abscondbrtarget:$dst)>;
4965 def : InstAlias<"b"#name#"lr"#pm#" $cc",
4966 (BCCLR bibo, crrc:$cc)>;
4967 def : InstAlias<"b"#name#"lr"#pm,
4970 def : InstAlias<"b"#name#"ctr"#pm#" $cc",
4971 (BCCCTR bibo, crrc:$cc)>;
4972 def : InstAlias<"b"#name#"ctr"#pm,
4973 (BCCCTR bibo, CR0)>;
4975 def : InstAlias<"b"#name#"l"#pm#" $cc, $dst",
4976 (BCCL bibo, crrc:$cc, condbrtarget:$dst)>;
4977 def : InstAlias<"b"#name#"l"#pm#" $dst",
4978 (BCCL bibo, CR0, condbrtarget:$dst)>;
4980 def : InstAlias<"b"#name#"la"#pm#" $cc, $dst",
4981 (BCCLA bibo, crrc:$cc, abscondbrtarget:$dst)>;
4982 def : InstAlias<"b"#name#"la"#pm#" $dst",
4983 (BCCLA bibo, CR0, abscondbrtarget:$dst)>;
4985 def : InstAlias<"b"#name#"lrl"#pm#" $cc",
4986 (BCCLRL bibo, crrc:$cc)>;
4987 def : InstAlias<"b"#name#"lrl"#pm,
4988 (BCCLRL bibo, CR0)>;
4990 def : InstAlias<"b"#name#"ctrl"#pm#" $cc",
4991 (BCCCTRL bibo, crrc:$cc)>;
4992 def : InstAlias<"b"#name#"ctrl"#pm,
4993 (BCCCTRL bibo, CR0)>;
4995 multiclass BranchExtendedMnemonic<string name, int bibo> {
4996 defm : BranchExtendedMnemonicPM<name, "", bibo>;
4997 defm : BranchExtendedMnemonicPM<name, "-", !add(bibo, 2)>;
4998 defm : BranchExtendedMnemonicPM<name, "+", !add(bibo, 3)>;
5000 defm : BranchExtendedMnemonic<"lt", 12>;
5001 defm : BranchExtendedMnemonic<"gt", 44>;
5002 defm : BranchExtendedMnemonic<"eq", 76>;
5003 defm : BranchExtendedMnemonic<"un", 108>;
5004 defm : BranchExtendedMnemonic<"so", 108>;
5005 defm : BranchExtendedMnemonic<"ge", 4>;
5006 defm : BranchExtendedMnemonic<"nl", 4>;
5007 defm : BranchExtendedMnemonic<"le", 36>;
5008 defm : BranchExtendedMnemonic<"ng", 36>;
5009 defm : BranchExtendedMnemonic<"ne", 68>;
5010 defm : BranchExtendedMnemonic<"nu", 100>;
5011 defm : BranchExtendedMnemonic<"ns", 100>;
5013 def : InstAlias<"cmpwi $rA, $imm", (CMPWI CR0, gprc:$rA, s16imm:$imm)>;
5014 def : InstAlias<"cmpw $rA, $rB", (CMPW CR0, gprc:$rA, gprc:$rB)>;
5015 def : InstAlias<"cmplwi $rA, $imm", (CMPLWI CR0, gprc:$rA, u16imm:$imm)>;
5016 def : InstAlias<"cmplw $rA, $rB", (CMPLW CR0, gprc:$rA, gprc:$rB)>;
5017 def : InstAlias<"cmpdi $rA, $imm", (CMPDI CR0, g8rc:$rA, s16imm64:$imm)>;
5018 def : InstAlias<"cmpd $rA, $rB", (CMPD CR0, g8rc:$rA, g8rc:$rB)>;
5019 def : InstAlias<"cmpldi $rA, $imm", (CMPLDI CR0, g8rc:$rA, u16imm64:$imm)>;
5020 def : InstAlias<"cmpld $rA, $rB", (CMPLD CR0, g8rc:$rA, g8rc:$rB)>;
5022 def : InstAlias<"cmpi $bf, 0, $rA, $imm", (CMPWI crrc:$bf, gprc:$rA, s16imm:$imm)>;
5023 def : InstAlias<"cmp $bf, 0, $rA, $rB", (CMPW crrc:$bf, gprc:$rA, gprc:$rB)>;
5024 def : InstAlias<"cmpli $bf, 0, $rA, $imm", (CMPLWI crrc:$bf, gprc:$rA, u16imm:$imm)>;
5025 def : InstAlias<"cmpl $bf, 0, $rA, $rB", (CMPLW crrc:$bf, gprc:$rA, gprc:$rB)>;
5026 def : InstAlias<"cmpi $bf, 1, $rA, $imm", (CMPDI crrc:$bf, g8rc:$rA, s16imm64:$imm)>;
5027 def : InstAlias<"cmp $bf, 1, $rA, $rB", (CMPD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
5028 def : InstAlias<"cmpli $bf, 1, $rA, $imm", (CMPLDI crrc:$bf, g8rc:$rA, u16imm64:$imm)>;
5029 def : InstAlias<"cmpl $bf, 1, $rA, $rB", (CMPLD crrc:$bf, g8rc:$rA, g8rc:$rB)>;
5031 def : InstAlias<"trap", (TW 31, R0, R0)>;
5033 multiclass TrapExtendedMnemonic<string name, int to> {
5034 def : InstAlias<"td"#name#"i $rA, $imm", (TDI to, g8rc:$rA, s16imm:$imm)>;
5035 def : InstAlias<"td"#name#" $rA, $rB", (TD to, g8rc:$rA, g8rc:$rB)>;
5036 def : InstAlias<"tw"#name#"i $rA, $imm", (TWI to, gprc:$rA, s16imm:$imm)>;
5037 def : InstAlias<"tw"#name#" $rA, $rB", (TW to, gprc:$rA, gprc:$rB)>;
5039 defm : TrapExtendedMnemonic<"lt", 16>;
5040 defm : TrapExtendedMnemonic<"le", 20>;
5041 defm : TrapExtendedMnemonic<"eq", 4>;
5042 defm : TrapExtendedMnemonic<"ge", 12>;
5043 defm : TrapExtendedMnemonic<"gt", 8>;
5044 defm : TrapExtendedMnemonic<"nl", 12>;
5045 defm : TrapExtendedMnemonic<"ne", 24>;
5046 defm : TrapExtendedMnemonic<"ng", 20>;
5047 defm : TrapExtendedMnemonic<"llt", 2>;
5048 defm : TrapExtendedMnemonic<"lle", 6>;
5049 defm : TrapExtendedMnemonic<"lge", 5>;
5050 defm : TrapExtendedMnemonic<"lgt", 1>;
5051 defm : TrapExtendedMnemonic<"lnl", 5>;
5052 defm : TrapExtendedMnemonic<"lng", 6>;
5053 defm : TrapExtendedMnemonic<"u", 31>;
5056 def : Pat<(i32 (atomic_load_8 DForm:$src)), (LBZ memri:$src)>;
5057 def : Pat<(i32 (atomic_load_16 DForm:$src)), (LHZ memri:$src)>;
5058 def : Pat<(i32 (atomic_load_32 DForm:$src)), (LWZ memri:$src)>;
5059 def : Pat<(i32 (atomic_load_8 XForm:$src)), (LBZX memrr:$src)>;
5060 def : Pat<(i32 (atomic_load_16 XForm:$src)), (LHZX memrr:$src)>;
5061 def : Pat<(i32 (atomic_load_32 XForm:$src)), (LWZX memrr:$src)>;
5064 def : Pat<(atomic_store_8 i32:$val, DForm:$ptr), (STB gprc:$val, memri:$ptr)>;
5065 def : Pat<(atomic_store_16 i32:$val, DForm:$ptr), (STH gprc:$val, memri:$ptr)>;
5066 def : Pat<(atomic_store_32 i32:$val, DForm:$ptr), (STW gprc:$val, memri:$ptr)>;
5067 def : Pat<(atomic_store_8 i32:$val, XForm:$ptr), (STBX gprc:$val, memrr:$ptr)>;
5068 def : Pat<(atomic_store_16 i32:$val, XForm:$ptr), (STHX gprc:$val, memrr:$ptr)>;
5069 def : Pat<(atomic_store_32 i32:$val, XForm:$ptr), (STWX gprc:$val, memrr:$ptr)>;
5071 let Predicates = [IsISA3_0] in {
5073 // Copy-Paste Facility
5074 // We prefix 'CP' to COPY due to name conflict in Target.td. We also prefix to
5075 // PASTE for naming consistency.
5077 def CP_COPY : X_RA5_RB5<31, 774, "copy" , gprc, IIC_LdStCOPY, []>;
5079 let mayStore = 1, Defs = [CR0] in
5080 def CP_PASTE_rec : X_L1_RA5_RB5<31, 902, "paste.", gprc, IIC_LdStPASTE, []>, isRecordForm;
5082 def : InstAlias<"paste. $RA, $RB", (CP_PASTE_rec gprc:$RA, gprc:$RB, 1)>;
5083 def CP_ABORT : XForm_0<31, 838, (outs), (ins), "cpabort", IIC_SprABORT, []>;
5085 // Message Synchronize
5086 def MSGSYNC : XForm_0<31, 886, (outs), (ins), "msgsync", IIC_SprMSGSYNC, []>;
5088 // Power-Saving Mode Instruction:
5089 def STOP : XForm_0<19, 370, (outs), (ins), "stop", IIC_SprSTOP, []>;
5091 def SETB : XForm_44<31, 128, (outs gprc:$RT), (ins crrc:$BFA),
5092 "setb $RT, $BFA", IIC_IntGeneral>, SExt32To64;
5095 let Predicates = [IsISA3_0] in {
5096 def : Pat<(i32 (int_ppc_cmprb i32:$a, gprc:$b, gprc:$c)),
5097 (i32 (SETB (CMPRB u1imm:$a, $b, $c)))>;
5099 def : Pat<(i32 (int_ppc_mulhw gprc:$a, gprc:$b)),
5100 (i32 (MULHW $a, $b))>;
5101 def : Pat<(i32 (int_ppc_mulhwu gprc:$a, gprc:$b)),
5102 (i32 (MULHWU $a, $b))>;
5103 def : Pat<(i32 (int_ppc_cmpb gprc:$a, gprc:$b)),
5104 (i32 (CMPB $a, $b))>;
5106 def : Pat<(int_ppc_load2r ForceXForm:$ptr),
5107 (LHBRX ForceXForm:$ptr)>;
5108 def : Pat<(int_ppc_load4r ForceXForm:$ptr),
5109 (LWBRX ForceXForm:$ptr)>;
5110 def : Pat<(int_ppc_store2r gprc:$a, ForceXForm:$ptr),
5111 (STHBRX gprc:$a, ForceXForm:$ptr)>;
5112 def : Pat<(int_ppc_store4r gprc:$a, ForceXForm:$ptr),
5113 (STWBRX gprc:$a, ForceXForm:$ptr)>;
5116 // Fast 32-bit reverse bits algorithm:
5117 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
5118 // n = ((n >> 1) & 0x55555555) | ((n << 1) & 0xAAAAAAAA);
5119 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
5120 // n = ((n >> 2) & 0x33333333) | ((n << 2) & 0xCCCCCCCC);
5121 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
5122 // n = ((n >> 4) & 0x0F0F0F0F) | ((n << 4) & 0xF0F0F0F0);
5123 // Step 4: byte reverse (Suppose n = [B1,B2,B3,B4]):
5124 // Step 4.1: Put B4,B2 in the right position (rotate left 3 bytes):
5125 // n' = (n rotl 24); After which n' = [B4, B1, B2, B3]
5126 // Step 4.2: Insert B3 to the right position:
5127 // n' = rlwimi n', n, 8, 8, 15; After which n' = [B4, B3, B2, B3]
5128 // Step 4.3: Insert B1 to the right position:
5129 // n' = rlwimi n', n, 8, 24, 31; After which n' = [B4, B3, B2, B1]
5131 dag Lo1 = (ORI (LIS 0x5555), 0x5555);
5132 dag Hi1 = (ORI (LIS 0xAAAA), 0xAAAA);
5133 dag Lo2 = (ORI (LIS 0x3333), 0x3333);
5134 dag Hi2 = (ORI (LIS 0xCCCC), 0xCCCC);
5135 dag Lo4 = (ORI (LIS 0x0F0F), 0x0F0F);
5136 dag Hi4 = (ORI (LIS 0xF0F0), 0xF0F0);
5140 dag Right = (RLWINM $A, 31, 1, 31);
5141 dag Left = (RLWINM $A, 1, 0, 30);
5145 dag Bit = (OR (AND Shift1.Right, MaskValues.Lo1),
5146 (AND Shift1.Left, MaskValues.Hi1));
5150 dag Right = (RLWINM Swap1.Bit, 30, 2, 31);
5151 dag Left = (RLWINM Swap1.Bit, 2, 0, 29);
5155 dag Bits = (OR (AND Shift2.Right, MaskValues.Lo2),
5156 (AND Shift2.Left, MaskValues.Hi2));
5160 dag Right = (RLWINM Swap2.Bits, 28, 4, 31);
5161 dag Left = (RLWINM Swap2.Bits, 4, 0, 27);
5165 dag Bits = (OR (AND Shift4.Right, MaskValues.Lo4),
5166 (AND Shift4.Left, MaskValues.Hi4));
5170 dag Left3Bytes = (RLWINM Swap4.Bits, 24, 0, 31);
5173 def RotateInsertByte3 {
5174 dag Left = (RLWIMI Rotate.Left3Bytes, Swap4.Bits, 8, 8, 15);
5177 def RotateInsertByte1 {
5178 dag Left = (RLWIMI RotateInsertByte3.Left, Swap4.Bits, 8, 24, 31);
5181 // Clear the upper half of the register when in 64-bit mode
5182 let Predicates = [In64BitMode] in
5183 def : Pat<(i32 (bitreverse i32:$A)), (RLDICL_32 RotateInsertByte1.Left, 0, 32)>;
5184 let Predicates = [In32BitMode] in
5185 def : Pat<(i32 (bitreverse i32:$A)), RotateInsertByte1.Left>;
5187 // Fast 64-bit reverse bits algorithm:
5188 // Step 1: 1-bit swap (swap odd 1-bit and even 1-bit):
5189 // n = ((n >> 1) & 0x5555555555555555) | ((n << 1) & 0xAAAAAAAAAAAAAAAA);
5190 // Step 2: 2-bit swap (swap odd 2-bit and even 2-bit):
5191 // n = ((n >> 2) & 0x3333333333333333) | ((n << 2) & 0xCCCCCCCCCCCCCCCC);
5192 // Step 3: 4-bit swap (swap odd 4-bit and even 4-bit):
5193 // n = ((n >> 4) & 0x0F0F0F0F0F0F0F0F) | ((n << 4) & 0xF0F0F0F0F0F0F0F0);
5194 // Step 4: byte reverse (Suppose n = [B0,B1,B2,B3,B4,B5,B6,B7]):
5195 // Apply the same byte reverse algorithm mentioned above for the fast 32-bit
5196 // reverse to both the high 32 bit and low 32 bit of the 64 bit value. And
5197 // then OR them together to get the final result.
5199 dag Lo1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo1, sub_32));
5200 dag Hi1 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi1, sub_32));
5201 dag Lo2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo2, sub_32));
5202 dag Hi2 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi2, sub_32));
5203 dag Lo4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Lo4, sub_32));
5204 dag Hi4 = (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), MaskValues.Hi4, sub_32));
5208 dag Lo1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo1, 32, 31), 0x5555), 0x5555);
5209 dag Hi1 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi1, 32, 31), 0xAAAA), 0xAAAA);
5210 dag Lo2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo2, 32, 31), 0x3333), 0x3333);
5211 dag Hi2 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi2, 32, 31), 0xCCCC), 0xCCCC);
5212 dag Lo4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Lo4, 32, 31), 0x0F0F), 0x0F0F);
5213 dag Hi4 = (ORI8 (ORIS8 (RLDICR MaskValues64.Hi4, 32, 31), 0xF0F0), 0xF0F0);
5217 dag Swap1 = (OR8 (AND8 (RLDICL $A, 63, 1), DWMaskValues.Lo1),
5218 (AND8 (RLDICR $A, 1, 62), DWMaskValues.Hi1));
5219 dag Swap2 = (OR8 (AND8 (RLDICL Swap1, 62, 2), DWMaskValues.Lo2),
5220 (AND8 (RLDICR Swap1, 2, 61), DWMaskValues.Hi2));
5221 dag Swap4 = (OR8 (AND8 (RLDICL Swap2, 60, 4), DWMaskValues.Lo4),
5222 (AND8 (RLDICR Swap2, 4, 59), DWMaskValues.Hi4));
5225 // Intra-byte swap is done, now start inter-byte swap.
5227 dag Word = (i32 (EXTRACT_SUBREG DWSwapInByte.Swap4, sub_32));
5231 dag Word = (RLWINM DWBytes4567.Word, 24, 0, 31);
5235 dag Word = (RLWIMI DWBytes7456.Word, DWBytes4567.Word, 8, 8, 15);
5238 // B7 B6 B5 B4 in the right order
5240 dag Word = (RLWIMI DWBytes7656.Word, DWBytes4567.Word, 8, 24, 31);
5242 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
5246 dag Word = (i32 (EXTRACT_SUBREG (RLDICL DWSwapInByte.Swap4, 32, 32), sub_32));
5250 dag Word = (RLWINM DWBytes0123.Word, 24, 0, 31);
5254 dag Word = (RLWIMI DWBytes3012.Word, DWBytes0123.Word, 8, 8, 15);
5257 // B3 B2 B1 B0 in the right order
5259 dag Word = (RLWIMI DWBytes3212.Word, DWBytes0123.Word, 8, 24, 31);
5261 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), Word, sub_32));
5264 // These instructions store a hash computed from the value of the link register
5265 // and the value of the stack pointer.
5266 let mayStore = 1 in {
5267 def HASHST : XForm_XD6_RA5_RB5<31, 722, (outs),
5268 (ins gprc:$RB, (memrihash $D, $RA):$addr),
5269 "hashst $RB, $addr", IIC_IntGeneral, []>;
5270 def HASHSTP : XForm_XD6_RA5_RB5<31, 658, (outs),
5271 (ins gprc:$RB, (memrihash $D, $RA):$addr),
5272 "hashstp $RB, $addr", IIC_IntGeneral, []>;
5275 // These instructions check a hash computed from the value of the link register
5276 // and the value of the stack pointer. The hasSideEffects flag is needed as the
5277 // instruction may TRAP if the hash does not match the hash stored at the
5278 // specified address.
5279 let mayLoad = 1, hasSideEffects = 1 in {
5280 def HASHCHK : XForm_XD6_RA5_RB5<31, 754, (outs),
5281 (ins gprc:$RB, (memrihash $D, $RA):$addr),
5282 "hashchk $RB, $addr", IIC_IntGeneral, []>;
5283 def HASHCHKP : XForm_XD6_RA5_RB5<31, 690, (outs),
5284 (ins gprc:$RB, (memrihash $D, $RA):$addr),
5285 "hashchkp $RB, $addr", IIC_IntGeneral, []>;
5288 let Defs = [CR7], Itinerary = IIC_LdStSync in
5289 def CFENCE : PPCPostRAExpPseudo<(outs), (ins gprc:$cr), "#CFENCE", []>;
5291 // Now both high word and low word are reversed, next
5292 // swap the high word and low word.
5293 def : Pat<(i64 (bitreverse i64:$A)),
5294 (OR8 (RLDICR DWBytes7654.DWord, 32, 31), DWBytes3210.DWord)>;
5296 def : Pat<(int_ppc_stwcx ForceXForm:$dst, gprc:$A),
5297 (RLWINM (STWCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
5298 def : Pat<(PPCStoreCond ForceXForm:$dst, gprc:$A, 4),
5299 (RLWINM (STWCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
5300 def : Pat<(int_ppc_stbcx ForceXForm:$dst, gprc:$A),
5301 (RLWINM (STBCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
5302 def : Pat<(PPCStoreCond ForceXForm:$dst, gprc:$A, 1),
5303 (RLWINM (STBCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
5305 def : Pat<(int_ppc_fcfid f64:$A),
5307 def : Pat<(int_ppc_fcfud f64:$A),
5309 def : Pat<(int_ppc_fctid f64:$A),
5311 def : Pat<(int_ppc_fctidz f64:$A),
5313 def : Pat<(int_ppc_fctiw f64:$A),
5315 def : Pat<(int_ppc_fctiwz f64:$A),
5317 def : Pat<(int_ppc_fctudz f64:$A),
5319 def : Pat<(int_ppc_fctuwz f64:$A),
5322 def : Pat<(int_ppc_mfmsr), (MFMSR)>;
5323 def : Pat<(int_ppc_mftbu), (MFTB 269)>;
5324 def : Pat<(i32 (int_ppc_mfspr timm:$SPR)),
5326 def : Pat<(int_ppc_mtspr timm:$SPR, gprc:$RT),
5328 def : Pat<(int_ppc_mtmsr gprc:$RS),
5331 let Predicates = [IsISA2_07] in {
5332 def : Pat<(int_ppc_sthcx ForceXForm:$dst, gprc:$A),
5333 (RLWINM (STHCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
5334 def : Pat<(PPCStoreCond ForceXForm:$dst, gprc:$A, 2),
5335 (RLWINM (STHCX gprc:$A, ForceXForm:$dst), 31, 31, 31)>;
5337 def : Pat<(int_ppc_dcbtstt ForceXForm:$dst),
5338 (DCBTST 16, ForceXForm:$dst)>;
5339 def : Pat<(int_ppc_dcbtt ForceXForm:$dst),
5340 (DCBT 16, ForceXForm:$dst)>;
5342 def : Pat<(int_ppc_stfiw ForceXForm:$dst, f64:$XT),
5343 (STFIWX f64:$XT, ForceXForm:$dst)>;