1 //===- PPCInstrInfo.td - The PowerPC Instruction Set -------*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the subset of the 32-bit PowerPC instruction set, as used
11 // by the PowerPC instruction selector.
13 //===----------------------------------------------------------------------===//
15 include "PPCInstrFormats.td"
17 //===----------------------------------------------------------------------===//
18 // PowerPC specific type constraints.
20 def SDT_PPCstfiwx : SDTypeProfile<0, 2, [ // stfiwx
21 SDTCisVT<0, f64>, SDTCisPtrTy<1>
23 def SDT_PPCShiftOp : SDTypeProfile<1, 2, [ // PPCshl, PPCsra, PPCsrl
24 SDTCisVT<0, i32>, SDTCisVT<1, i32>, SDTCisVT<2, i32>
26 def SDT_PPCCallSeq : SDTypeProfile<0, 1, [ SDTCisVT<0, i32> ]>;
28 def SDT_PPCvperm : SDTypeProfile<1, 3, [
29 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
32 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
33 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
36 def SDT_PPCcondbr : SDTypeProfile<0, 3, [
37 SDTCisVT<1, i32>, SDTCisVT<2, OtherVT>
40 //===----------------------------------------------------------------------===//
41 // PowerPC specific DAG Nodes.
44 def PPCfcfid : SDNode<"PPCISD::FCFID" , SDTFPUnaryOp, []>;
45 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
46 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
47 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx, [SDNPHasChain]>;
49 def PPCfsel : SDNode<"PPCISD::FSEL",
50 // Type constraint for fsel.
51 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
52 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
54 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
55 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
56 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
57 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
59 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
61 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
62 // amounts. These nodes are generated by the multi-precision shift code.
63 def PPCsrl : SDNode<"PPCISD::SRL" , SDT_PPCShiftOp>;
64 def PPCsra : SDNode<"PPCISD::SRA" , SDT_PPCShiftOp>;
65 def PPCshl : SDNode<"PPCISD::SHL" , SDT_PPCShiftOp>;
67 def PPCextsw_32 : SDNode<"PPCISD::EXTSW_32" , SDTIntUnaryOp>;
68 def PPCstd_32 : SDNode<"PPCISD::STD_32" , SDTStore, [SDNPHasChain]>;
70 // These are target-independent nodes, but have target-specific formats.
71 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeq,[SDNPHasChain]>;
72 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeq,[SDNPHasChain]>;
74 def SDT_PPCCall : SDTypeProfile<0, -1, [SDTCisVT<0, i32>]>;
75 def PPCcall : SDNode<"PPCISD::CALL", SDT_PPCCall,
76 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
77 def PPCmtctr : SDNode<"PPCISD::MTCTR", SDT_PPCCall,
78 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
79 def PPCbctrl : SDNode<"PPCISD::BCTRL", SDTRet,
80 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
82 def retflag : SDNode<"PPCISD::RET_FLAG", SDTRet,
83 [SDNPHasChain, SDNPOptInFlag]>;
85 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
86 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutFlag]>;
88 def PPCcondbranch : SDNode<"PPCISD::COND_BRANCH", SDT_PPCcondbr,
89 [SDNPHasChain, SDNPOptInFlag]>;
91 //===----------------------------------------------------------------------===//
92 // PowerPC specific transformation functions and pattern fragments.
95 def SHL32 : SDNodeXForm<imm, [{
96 // Transformation function: 31 - imm
97 return getI32Imm(31 - N->getValue());
100 def SRL32 : SDNodeXForm<imm, [{
101 // Transformation function: 32 - imm
102 return N->getValue() ? getI32Imm(32 - N->getValue()) : getI32Imm(0);
105 def LO16 : SDNodeXForm<imm, [{
106 // Transformation function: get the low 16 bits.
107 return getI32Imm((unsigned short)N->getValue());
110 def HI16 : SDNodeXForm<imm, [{
111 // Transformation function: shift the immediate value down into the low bits.
112 return getI32Imm((unsigned)N->getValue() >> 16);
115 def HA16 : SDNodeXForm<imm, [{
116 // Transformation function: shift the immediate value down into the low bits.
117 signed int Val = N->getValue();
118 return getI32Imm((Val - (signed short)Val) >> 16);
122 def immSExt16 : PatLeaf<(imm), [{
123 // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended
124 // field. Used by instructions like 'addi'.
125 if (N->getValueType(0) == MVT::i32)
126 return (int32_t)N->getValue() == (short)N->getValue();
128 return (int64_t)N->getValue() == (short)N->getValue();
130 def immZExt16 : PatLeaf<(imm), [{
131 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
132 // field. Used by instructions like 'ori'.
133 return (uint64_t)N->getValue() == (unsigned short)N->getValue();
136 // imm16Shifted* - These match immediates where the low 16-bits are zero. There
137 // are two forms: imm16ShiftedSExt and imm16ShiftedZExt. These two forms are
138 // identical in 32-bit mode, but in 64-bit mode, they return true if the
139 // immediate fits into a sign/zero extended 32-bit immediate (with the low bits
141 def imm16ShiftedZExt : PatLeaf<(imm), [{
142 // imm16ShiftedZExt predicate - True if only bits in the top 16-bits of the
143 // immediate are set. Used by instructions like 'xoris'.
144 return (N->getValue() & ~uint64_t(0xFFFF0000)) == 0;
147 def imm16ShiftedSExt : PatLeaf<(imm), [{
148 // imm16ShiftedSExt predicate - True if only bits in the top 16-bits of the
149 // immediate are set. Used by instructions like 'addis'. Identical to
150 // imm16ShiftedZExt in 32-bit mode.
151 if (N->getValue() & 0xFFFF) return false;
152 if (N->getValueType(0) == MVT::i32)
154 // For 64-bit, make sure it is sext right.
155 return N->getValue() == (uint64_t)(int)N->getValue();
159 //===----------------------------------------------------------------------===//
160 // PowerPC Flag Definitions.
162 class isPPC64 { bit PPC64 = 1; }
164 list<Register> Defs = [CR0];
170 //===----------------------------------------------------------------------===//
171 // PowerPC Operand Definitions.
173 def s5imm : Operand<i32> {
174 let PrintMethod = "printS5ImmOperand";
176 def u5imm : Operand<i32> {
177 let PrintMethod = "printU5ImmOperand";
179 def u6imm : Operand<i32> {
180 let PrintMethod = "printU6ImmOperand";
182 def s16imm : Operand<i32> {
183 let PrintMethod = "printS16ImmOperand";
185 def u16imm : Operand<i32> {
186 let PrintMethod = "printU16ImmOperand";
188 def s16immX4 : Operand<i32> { // Multiply imm by 4 before printing.
189 let PrintMethod = "printS16X4ImmOperand";
191 def target : Operand<OtherVT> {
192 let PrintMethod = "printBranchOperand";
194 def calltarget : Operand<iPTR> {
195 let PrintMethod = "printCallOperand";
197 def aaddr : Operand<iPTR> {
198 let PrintMethod = "printAbsAddrOperand";
200 def piclabel: Operand<iPTR> {
201 let PrintMethod = "printPICLabel";
203 def symbolHi: Operand<i32> {
204 let PrintMethod = "printSymbolHi";
206 def symbolLo: Operand<i32> {
207 let PrintMethod = "printSymbolLo";
209 def crbitm: Operand<i8> {
210 let PrintMethod = "printcrbitm";
213 def memri : Operand<iPTR> {
214 let PrintMethod = "printMemRegImm";
215 let NumMIOperands = 2;
216 let MIOperandInfo = (ops i32imm, ptr_rc);
218 def memrr : Operand<iPTR> {
219 let PrintMethod = "printMemRegReg";
220 let NumMIOperands = 2;
221 let MIOperandInfo = (ops ptr_rc, ptr_rc);
223 def memrix : Operand<iPTR> { // memri where the imm is shifted 2 bits.
224 let PrintMethod = "printMemRegImmShifted";
225 let NumMIOperands = 2;
226 let MIOperandInfo = (ops i32imm, ptr_rc);
229 // Define PowerPC specific addressing mode.
230 def iaddr : ComplexPattern<iPTR, 2, "SelectAddrImm", []>;
231 def xaddr : ComplexPattern<iPTR, 2, "SelectAddrIdx", []>;
232 def xoaddr : ComplexPattern<iPTR, 2, "SelectAddrIdxOnly",[]>;
233 def ixaddr : ComplexPattern<iPTR, 2, "SelectAddrImmShift", []>; // "std"
235 //===----------------------------------------------------------------------===//
236 // PowerPC Instruction Predicate Definitions.
237 def FPContractions : Predicate<"!NoExcessFPPrecision">;
239 //===----------------------------------------------------------------------===//
240 // PowerPC Instruction Definitions.
242 // Pseudo-instructions:
244 let hasCtrlDep = 1 in {
245 def ADJCALLSTACKDOWN : Pseudo<(ops u16imm:$amt),
246 "; ADJCALLSTACKDOWN",
247 [(callseq_start imm:$amt)]>;
248 def ADJCALLSTACKUP : Pseudo<(ops u16imm:$amt),
250 [(callseq_end imm:$amt)]>;
252 def UPDATE_VRSAVE : Pseudo<(ops GPRC:$rD, GPRC:$rS),
253 "UPDATE_VRSAVE $rD, $rS", []>;
255 def IMPLICIT_DEF_GPR : Pseudo<(ops GPRC:$rD), "; $rD = IMPLICIT_DEF_GPRC",
256 [(set GPRC:$rD, (undef))]>;
257 def IMPLICIT_DEF_F8 : Pseudo<(ops F8RC:$rD), "; $rD = IMPLICIT_DEF_F8",
258 [(set F8RC:$rD, (undef))]>;
259 def IMPLICIT_DEF_F4 : Pseudo<(ops F4RC:$rD), "; $rD = IMPLICIT_DEF_F4",
260 [(set F4RC:$rD, (undef))]>;
262 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded by the
263 // scheduler into a branch sequence.
264 let usesCustomDAGSchedInserter = 1, // Expanded by the scheduler.
265 PPC970_Single = 1 in {
266 def SELECT_CC_I4 : Pseudo<(ops GPRC:$dst, CRRC:$cond, GPRC:$T, GPRC:$F,
267 i32imm:$BROPC), "; SELECT_CC PSEUDO!", []>;
268 def SELECT_CC_I8 : Pseudo<(ops G8RC:$dst, CRRC:$cond, G8RC:$T, G8RC:$F,
269 i32imm:$BROPC), "; SELECT_CC PSEUDO!", []>;
270 def SELECT_CC_F4 : Pseudo<(ops F4RC:$dst, CRRC:$cond, F4RC:$T, F4RC:$F,
271 i32imm:$BROPC), "; SELECT_CC PSEUDO!", []>;
272 def SELECT_CC_F8 : Pseudo<(ops F8RC:$dst, CRRC:$cond, F8RC:$T, F8RC:$F,
273 i32imm:$BROPC), "; SELECT_CC PSEUDO!", []>;
274 def SELECT_CC_VRRC: Pseudo<(ops VRRC:$dst, CRRC:$cond, VRRC:$T, VRRC:$F,
275 i32imm:$BROPC), "; SELECT_CC PSEUDO!", []>;
278 let isTerminator = 1, noResults = 1, PPC970_Unit = 7 in {
280 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (ops), "blr", BrB, [(retflag)]>;
281 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (ops), "bctr", BrB, []>;
285 def MovePCtoLR : Pseudo<(ops piclabel:$label), "bl $label", []>,
288 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1,
289 noResults = 1, PPC970_Unit = 7 in {
290 def COND_BRANCH : Pseudo<(ops CRRC:$crS, u16imm:$opc, target:$dst),
291 "; COND_BRANCH $crS, $opc, $dst",
292 [(PPCcondbranch CRRC:$crS, imm:$opc, bb:$dst)]>;
293 def B : IForm<18, 0, 0, (ops target:$dst),
297 def BLT : BForm<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block),
298 "blt $crS, $block", BrB>;
299 def BLE : BForm<16, 0, 0, 4, 1, (ops CRRC:$crS, target:$block),
300 "ble $crS, $block", BrB>;
301 def BEQ : BForm<16, 0, 0, 12, 2, (ops CRRC:$crS, target:$block),
302 "beq $crS, $block", BrB>;
303 def BGE : BForm<16, 0, 0, 4, 0, (ops CRRC:$crS, target:$block),
304 "bge $crS, $block", BrB>;
305 def BGT : BForm<16, 0, 0, 12, 1, (ops CRRC:$crS, target:$block),
306 "bgt $crS, $block", BrB>;
307 def BNE : BForm<16, 0, 0, 4, 2, (ops CRRC:$crS, target:$block),
308 "bne $crS, $block", BrB>;
309 def BUN : BForm<16, 0, 0, 12, 3, (ops CRRC:$crS, target:$block),
310 "bun $crS, $block", BrB>;
311 def BNU : BForm<16, 0, 0, 4, 3, (ops CRRC:$crS, target:$block),
312 "bnu $crS, $block", BrB>;
315 let isCall = 1, noResults = 1, PPC970_Unit = 7,
316 // All calls clobber the non-callee saved registers...
317 Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
318 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
319 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
321 CR0,CR1,CR5,CR6,CR7] in {
322 // Convenient aliases for call instructions
323 def BL : IForm<18, 0, 1, (ops calltarget:$func, variable_ops),
324 "bl $func", BrB, []>; // See Pat patterns below.
325 def BLA : IForm<18, 1, 1, (ops aaddr:$func, variable_ops),
326 "bla $func", BrB, [(PPCcall imm:$func)]>;
327 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (ops variable_ops), "bctrl", BrB,
331 // DCB* instructions.
332 def DCBZ : DCB_Form<1014, 0, (ops memrr:$dst),
333 "dcbz $dst", LdStDCBF, [(int_ppc_dcbz xoaddr:$dst)]>,
334 PPC970_DGroup_Single;
335 def DCBZL : DCB_Form<1014, 1, (ops memrr:$dst),
336 "dcbzl $dst", LdStDCBF, [(int_ppc_dcbzl xoaddr:$dst)]>,
337 PPC970_DGroup_Single;
339 // D-Form instructions. Most instructions that perform an operation on a
340 // register and an immediate are of this type.
342 let isLoad = 1, PPC970_Unit = 2 in {
343 def LBZ : DForm_1<34, (ops GPRC:$rD, memri:$src),
344 "lbz $rD, $src", LdStGeneral,
345 [(set GPRC:$rD, (zextload iaddr:$src, i8))]>;
346 def LHA : DForm_1<42, (ops GPRC:$rD, memri:$src),
347 "lha $rD, $src", LdStLHA,
348 [(set GPRC:$rD, (sextload iaddr:$src, i16))]>,
349 PPC970_DGroup_Cracked;
350 def LHZ : DForm_1<40, (ops GPRC:$rD, memri:$src),
351 "lhz $rD, $src", LdStGeneral,
352 [(set GPRC:$rD, (zextload iaddr:$src, i16))]>;
353 def LWZ : DForm_1<32, (ops GPRC:$rD, memri:$src),
354 "lwz $rD, $src", LdStGeneral,
355 [(set GPRC:$rD, (load iaddr:$src))]>;
356 def LWZU : DForm_1<35, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
357 "lwzu $rD, $disp($rA)", LdStGeneral,
360 let PPC970_Unit = 1 in { // FXU Operations.
361 def ADDI : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
362 "addi $rD, $rA, $imm", IntGeneral,
363 [(set GPRC:$rD, (add GPRC:$rA, immSExt16:$imm))]>;
364 def ADDIC : DForm_2<12, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
365 "addic $rD, $rA, $imm", IntGeneral,
366 [(set GPRC:$rD, (addc GPRC:$rA, immSExt16:$imm))]>,
367 PPC970_DGroup_Cracked;
368 def ADDICo : DForm_2<13, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
369 "addic. $rD, $rA, $imm", IntGeneral,
371 def ADDIS : DForm_2<15, (ops GPRC:$rD, GPRC:$rA, symbolHi:$imm),
372 "addis $rD, $rA, $imm", IntGeneral,
373 [(set GPRC:$rD, (add GPRC:$rA, imm16ShiftedSExt:$imm))]>;
374 def LA : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, symbolLo:$sym),
375 "la $rD, $sym($rA)", IntGeneral,
376 [(set GPRC:$rD, (add GPRC:$rA,
377 (PPClo tglobaladdr:$sym, 0)))]>;
378 def MULLI : DForm_2< 7, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
379 "mulli $rD, $rA, $imm", IntMulLI,
380 [(set GPRC:$rD, (mul GPRC:$rA, immSExt16:$imm))]>;
381 def SUBFIC : DForm_2< 8, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
382 "subfic $rD, $rA, $imm", IntGeneral,
383 [(set GPRC:$rD, (subc immSExt16:$imm, GPRC:$rA))]>;
384 def LI : DForm_2_r0<14, (ops GPRC:$rD, symbolLo:$imm),
385 "li $rD, $imm", IntGeneral,
386 [(set GPRC:$rD, immSExt16:$imm)]>;
387 def LIS : DForm_2_r0<15, (ops GPRC:$rD, symbolHi:$imm),
388 "lis $rD, $imm", IntGeneral,
389 [(set GPRC:$rD, imm16ShiftedSExt:$imm)]>;
391 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
392 def STB : DForm_3<38, (ops GPRC:$rS, memri:$src),
393 "stb $rS, $src", LdStGeneral,
394 [(truncstore GPRC:$rS, iaddr:$src, i8)]>;
395 def STH : DForm_3<44, (ops GPRC:$rS, memri:$src),
396 "sth $rS, $src", LdStGeneral,
397 [(truncstore GPRC:$rS, iaddr:$src, i16)]>;
398 def STW : DForm_3<36, (ops GPRC:$rS, memri:$src),
399 "stw $rS, $src", LdStGeneral,
400 [(store GPRC:$rS, iaddr:$src)]>;
401 def STWU : DForm_3<37, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
402 "stwu $rS, $disp($rA)", LdStGeneral,
405 let PPC970_Unit = 1 in { // FXU Operations.
406 def ANDIo : DForm_4<28, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
407 "andi. $dst, $src1, $src2", IntGeneral,
408 [(set GPRC:$dst, (and GPRC:$src1, immZExt16:$src2))]>,
410 def ANDISo : DForm_4<29, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
411 "andis. $dst, $src1, $src2", IntGeneral,
412 [(set GPRC:$dst, (and GPRC:$src1,imm16ShiftedZExt:$src2))]>,
414 def ORI : DForm_4<24, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
415 "ori $dst, $src1, $src2", IntGeneral,
416 [(set GPRC:$dst, (or GPRC:$src1, immZExt16:$src2))]>;
417 def ORIS : DForm_4<25, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
418 "oris $dst, $src1, $src2", IntGeneral,
419 [(set GPRC:$dst, (or GPRC:$src1, imm16ShiftedZExt:$src2))]>;
420 def XORI : DForm_4<26, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
421 "xori $dst, $src1, $src2", IntGeneral,
422 [(set GPRC:$dst, (xor GPRC:$src1, immZExt16:$src2))]>;
423 def XORIS : DForm_4<27, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
424 "xoris $dst, $src1, $src2", IntGeneral,
425 [(set GPRC:$dst, (xor GPRC:$src1,imm16ShiftedZExt:$src2))]>;
426 def NOP : DForm_4_zero<24, (ops), "nop", IntGeneral,
428 def CMPWI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
429 "cmpwi $crD, $rA, $imm", IntCompare>;
430 def CMPLWI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
431 "cmplwi $dst, $src1, $src2", IntCompare>;
433 let isLoad = 1, PPC970_Unit = 2 in {
434 def LFS : DForm_8<48, (ops F4RC:$rD, memri:$src),
435 "lfs $rD, $src", LdStLFDU,
436 [(set F4RC:$rD, (load iaddr:$src))]>;
437 def LFD : DForm_8<50, (ops F8RC:$rD, memri:$src),
438 "lfd $rD, $src", LdStLFD,
439 [(set F8RC:$rD, (load iaddr:$src))]>;
441 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
442 def STFS : DForm_9<52, (ops F4RC:$rS, memri:$dst),
443 "stfs $rS, $dst", LdStUX,
444 [(store F4RC:$rS, iaddr:$dst)]>;
445 def STFD : DForm_9<54, (ops F8RC:$rS, memri:$dst),
446 "stfd $rS, $dst", LdStUX,
447 [(store F8RC:$rS, iaddr:$dst)]>;
450 // X-Form instructions. Most instructions that perform an operation on a
451 // register and another register are of this type.
453 let isLoad = 1, PPC970_Unit = 2 in {
454 def LBZX : XForm_1<31, 87, (ops GPRC:$rD, memrr:$src),
455 "lbzx $rD, $src", LdStGeneral,
456 [(set GPRC:$rD, (zextload xaddr:$src, i8))]>;
457 def LHAX : XForm_1<31, 343, (ops GPRC:$rD, memrr:$src),
458 "lhax $rD, $src", LdStLHA,
459 [(set GPRC:$rD, (sextload xaddr:$src, i16))]>,
460 PPC970_DGroup_Cracked;
461 def LHZX : XForm_1<31, 279, (ops GPRC:$rD, memrr:$src),
462 "lhzx $rD, $src", LdStGeneral,
463 [(set GPRC:$rD, (zextload xaddr:$src, i16))]>;
464 def LWZX : XForm_1<31, 23, (ops GPRC:$rD, memrr:$src),
465 "lwzx $rD, $src", LdStGeneral,
466 [(set GPRC:$rD, (load xaddr:$src))]>;
469 let PPC970_Unit = 1 in { // FXU Operations.
470 def NAND : XForm_6<31, 476, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
471 "nand $rA, $rS, $rB", IntGeneral,
472 [(set GPRC:$rA, (not (and GPRC:$rS, GPRC:$rB)))]>;
473 def AND : XForm_6<31, 28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
474 "and $rA, $rS, $rB", IntGeneral,
475 [(set GPRC:$rA, (and GPRC:$rS, GPRC:$rB))]>;
476 def ANDC : XForm_6<31, 60, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
477 "andc $rA, $rS, $rB", IntGeneral,
478 [(set GPRC:$rA, (and GPRC:$rS, (not GPRC:$rB)))]>;
479 def OR : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
480 "or $rA, $rS, $rB", IntGeneral,
481 [(set GPRC:$rA, (or GPRC:$rS, GPRC:$rB))]>;
482 def NOR : XForm_6<31, 124, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
483 "nor $rA, $rS, $rB", IntGeneral,
484 [(set GPRC:$rA, (not (or GPRC:$rS, GPRC:$rB)))]>;
485 def ORC : XForm_6<31, 412, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
486 "orc $rA, $rS, $rB", IntGeneral,
487 [(set GPRC:$rA, (or GPRC:$rS, (not GPRC:$rB)))]>;
488 def EQV : XForm_6<31, 284, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
489 "eqv $rA, $rS, $rB", IntGeneral,
490 [(set GPRC:$rA, (not (xor GPRC:$rS, GPRC:$rB)))]>;
491 def XOR : XForm_6<31, 316, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
492 "xor $rA, $rS, $rB", IntGeneral,
493 [(set GPRC:$rA, (xor GPRC:$rS, GPRC:$rB))]>;
494 def SLW : XForm_6<31, 24, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
495 "slw $rA, $rS, $rB", IntGeneral,
496 [(set GPRC:$rA, (PPCshl GPRC:$rS, GPRC:$rB))]>;
497 def SRW : XForm_6<31, 536, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
498 "srw $rA, $rS, $rB", IntGeneral,
499 [(set GPRC:$rA, (PPCsrl GPRC:$rS, GPRC:$rB))]>;
500 def SRAW : XForm_6<31, 792, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
501 "sraw $rA, $rS, $rB", IntShift,
502 [(set GPRC:$rA, (PPCsra GPRC:$rS, GPRC:$rB))]>;
504 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
505 def STBX : XForm_8<31, 215, (ops GPRC:$rS, memrr:$dst),
506 "stbx $rS, $dst", LdStGeneral,
507 [(truncstore GPRC:$rS, xaddr:$dst, i8)]>,
508 PPC970_DGroup_Cracked;
509 def STHX : XForm_8<31, 407, (ops GPRC:$rS, memrr:$dst),
510 "sthx $rS, $dst", LdStGeneral,
511 [(truncstore GPRC:$rS, xaddr:$dst, i16)]>,
512 PPC970_DGroup_Cracked;
513 def STWX : XForm_8<31, 151, (ops GPRC:$rS, memrr:$dst),
514 "stwx $rS, $dst", LdStGeneral,
515 [(store GPRC:$rS, xaddr:$dst)]>,
516 PPC970_DGroup_Cracked;
517 def STWUX : XForm_8<31, 183, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
518 "stwux $rS, $rA, $rB", LdStGeneral,
521 let PPC970_Unit = 1 in { // FXU Operations.
522 def SRAWI : XForm_10<31, 824, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH),
523 "srawi $rA, $rS, $SH", IntShift,
524 [(set GPRC:$rA, (sra GPRC:$rS, (i32 imm:$SH)))]>;
525 def CNTLZW : XForm_11<31, 26, (ops GPRC:$rA, GPRC:$rS),
526 "cntlzw $rA, $rS", IntGeneral,
527 [(set GPRC:$rA, (ctlz GPRC:$rS))]>;
528 def EXTSB : XForm_11<31, 954, (ops GPRC:$rA, GPRC:$rS),
529 "extsb $rA, $rS", IntGeneral,
530 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i8))]>;
531 def EXTSH : XForm_11<31, 922, (ops GPRC:$rA, GPRC:$rS),
532 "extsh $rA, $rS", IntGeneral,
533 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i16))]>;
535 def CMPW : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
536 "cmpw $crD, $rA, $rB", IntCompare>;
537 def CMPLW : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
538 "cmplw $crD, $rA, $rB", IntCompare>;
540 let PPC970_Unit = 3 in { // FPU Operations.
541 //def FCMPO : XForm_17<63, 32, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
542 // "fcmpo $crD, $fA, $fB", FPCompare>;
543 def FCMPUS : XForm_17<63, 0, (ops CRRC:$crD, F4RC:$fA, F4RC:$fB),
544 "fcmpu $crD, $fA, $fB", FPCompare>;
545 def FCMPUD : XForm_17<63, 0, (ops CRRC:$crD, F8RC:$fA, F8RC:$fB),
546 "fcmpu $crD, $fA, $fB", FPCompare>;
548 let isLoad = 1, PPC970_Unit = 2 in {
549 def LFSX : XForm_25<31, 535, (ops F4RC:$frD, memrr:$src),
550 "lfsx $frD, $src", LdStLFDU,
551 [(set F4RC:$frD, (load xaddr:$src))]>;
552 def LFDX : XForm_25<31, 599, (ops F8RC:$frD, memrr:$src),
553 "lfdx $frD, $src", LdStLFDU,
554 [(set F8RC:$frD, (load xaddr:$src))]>;
556 let PPC970_Unit = 3 in { // FPU Operations.
557 def FCTIWZ : XForm_26<63, 15, (ops F8RC:$frD, F8RC:$frB),
558 "fctiwz $frD, $frB", FPGeneral,
559 [(set F8RC:$frD, (PPCfctiwz F8RC:$frB))]>;
560 def FRSP : XForm_26<63, 12, (ops F4RC:$frD, F8RC:$frB),
561 "frsp $frD, $frB", FPGeneral,
562 [(set F4RC:$frD, (fround F8RC:$frB))]>;
563 def FSQRT : XForm_26<63, 22, (ops F8RC:$frD, F8RC:$frB),
564 "fsqrt $frD, $frB", FPSqrt,
565 [(set F8RC:$frD, (fsqrt F8RC:$frB))]>;
566 def FSQRTS : XForm_26<59, 22, (ops F4RC:$frD, F4RC:$frB),
567 "fsqrts $frD, $frB", FPSqrt,
568 [(set F4RC:$frD, (fsqrt F4RC:$frB))]>;
571 /// FMR is split into 3 versions, one for 4/8 byte FP, and one for extending.
573 /// Note that these are defined as pseudo-ops on the PPC970 because they are
574 /// often coalesced away and we don't want the dispatch group builder to think
575 /// that they will fill slots (which could cause the load of a LSU reject to
576 /// sneak into a d-group with a store).
577 def FMRS : XForm_26<63, 72, (ops F4RC:$frD, F4RC:$frB),
578 "fmr $frD, $frB", FPGeneral,
579 []>, // (set F4RC:$frD, F4RC:$frB)
581 def FMRD : XForm_26<63, 72, (ops F8RC:$frD, F8RC:$frB),
582 "fmr $frD, $frB", FPGeneral,
583 []>, // (set F8RC:$frD, F8RC:$frB)
585 def FMRSD : XForm_26<63, 72, (ops F8RC:$frD, F4RC:$frB),
586 "fmr $frD, $frB", FPGeneral,
587 [(set F8RC:$frD, (fextend F4RC:$frB))]>,
590 let PPC970_Unit = 3 in { // FPU Operations.
591 // These are artificially split into two different forms, for 4/8 byte FP.
592 def FABSS : XForm_26<63, 264, (ops F4RC:$frD, F4RC:$frB),
593 "fabs $frD, $frB", FPGeneral,
594 [(set F4RC:$frD, (fabs F4RC:$frB))]>;
595 def FABSD : XForm_26<63, 264, (ops F8RC:$frD, F8RC:$frB),
596 "fabs $frD, $frB", FPGeneral,
597 [(set F8RC:$frD, (fabs F8RC:$frB))]>;
598 def FNABSS : XForm_26<63, 136, (ops F4RC:$frD, F4RC:$frB),
599 "fnabs $frD, $frB", FPGeneral,
600 [(set F4RC:$frD, (fneg (fabs F4RC:$frB)))]>;
601 def FNABSD : XForm_26<63, 136, (ops F8RC:$frD, F8RC:$frB),
602 "fnabs $frD, $frB", FPGeneral,
603 [(set F8RC:$frD, (fneg (fabs F8RC:$frB)))]>;
604 def FNEGS : XForm_26<63, 40, (ops F4RC:$frD, F4RC:$frB),
605 "fneg $frD, $frB", FPGeneral,
606 [(set F4RC:$frD, (fneg F4RC:$frB))]>;
607 def FNEGD : XForm_26<63, 40, (ops F8RC:$frD, F8RC:$frB),
608 "fneg $frD, $frB", FPGeneral,
609 [(set F8RC:$frD, (fneg F8RC:$frB))]>;
612 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
613 def STFIWX: XForm_28<31, 983, (ops F8RC:$frS, memrr:$dst),
614 "stfiwx $frS, $dst", LdStUX,
615 [(PPCstfiwx F8RC:$frS, xoaddr:$dst)]>;
616 def STFSX : XForm_28<31, 663, (ops F4RC:$frS, memrr:$dst),
617 "stfsx $frS, $dst", LdStUX,
618 [(store F4RC:$frS, xaddr:$dst)]>;
619 def STFDX : XForm_28<31, 727, (ops F8RC:$frS, memrr:$dst),
620 "stfdx $frS, $dst", LdStUX,
621 [(store F8RC:$frS, xaddr:$dst)]>;
624 // XL-Form instructions. condition register logical ops.
626 def MCRF : XLForm_3<19, 0, (ops CRRC:$BF, CRRC:$BFA),
627 "mcrf $BF, $BFA", BrMCR>,
628 PPC970_DGroup_First, PPC970_Unit_CRU;
630 // XFX-Form instructions. Instructions that deal with SPRs.
632 def MFCTR : XFXForm_1_ext<31, 339, 9, (ops GPRC:$rT), "mfctr $rT", SprMFSPR>,
633 PPC970_DGroup_First, PPC970_Unit_FXU;
634 let Pattern = [(PPCmtctr GPRC:$rS)] in {
635 def MTCTR : XFXForm_7_ext<31, 467, 9, (ops GPRC:$rS), "mtctr $rS", SprMTSPR>,
636 PPC970_DGroup_First, PPC970_Unit_FXU;
639 def MTLR : XFXForm_7_ext<31, 467, 8, (ops GPRC:$rS), "mtlr $rS", SprMTSPR>,
640 PPC970_DGroup_First, PPC970_Unit_FXU;
641 def MFLR : XFXForm_1_ext<31, 339, 8, (ops GPRC:$rT), "mflr $rT", SprMFSPR>,
642 PPC970_DGroup_First, PPC970_Unit_FXU;
644 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed like
645 // a GPR on the PPC970. As such, copies in and out have the same performance
646 // characteristics as an OR instruction.
647 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (ops GPRC:$rS),
648 "mtspr 256, $rS", IntGeneral>,
649 PPC970_DGroup_Single, PPC970_Unit_FXU;
650 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (ops GPRC:$rT),
651 "mfspr $rT, 256", IntGeneral>,
652 PPC970_DGroup_First, PPC970_Unit_FXU;
654 def MTCRF : XFXForm_5<31, 144, (ops crbitm:$FXM, GPRC:$rS),
655 "mtcrf $FXM, $rS", BrMCRX>,
656 PPC970_MicroCode, PPC970_Unit_CRU;
657 def MFCR : XFXForm_3<31, 19, (ops GPRC:$rT), "mfcr $rT", SprMFCR>,
658 PPC970_MicroCode, PPC970_Unit_CRU;
659 def MFOCRF: XFXForm_5a<31, 19, (ops GPRC:$rT, crbitm:$FXM),
660 "mfcr $rT, $FXM", SprMFCR>,
661 PPC970_DGroup_First, PPC970_Unit_CRU;
663 let PPC970_Unit = 1 in { // FXU Operations.
665 // XO-Form instructions. Arithmetic instructions that can set overflow bit
667 def ADD4 : XOForm_1<31, 266, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
668 "add $rT, $rA, $rB", IntGeneral,
669 [(set GPRC:$rT, (add GPRC:$rA, GPRC:$rB))]>;
670 def ADDC : XOForm_1<31, 10, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
671 "addc $rT, $rA, $rB", IntGeneral,
672 [(set GPRC:$rT, (addc GPRC:$rA, GPRC:$rB))]>,
673 PPC970_DGroup_Cracked;
674 def ADDE : XOForm_1<31, 138, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
675 "adde $rT, $rA, $rB", IntGeneral,
676 [(set GPRC:$rT, (adde GPRC:$rA, GPRC:$rB))]>;
677 def DIVW : XOForm_1<31, 491, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
678 "divw $rT, $rA, $rB", IntDivW,
679 [(set GPRC:$rT, (sdiv GPRC:$rA, GPRC:$rB))]>,
680 PPC970_DGroup_First, PPC970_DGroup_Cracked;
681 def DIVWU : XOForm_1<31, 459, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
682 "divwu $rT, $rA, $rB", IntDivW,
683 [(set GPRC:$rT, (udiv GPRC:$rA, GPRC:$rB))]>,
684 PPC970_DGroup_First, PPC970_DGroup_Cracked;
685 def MULHW : XOForm_1<31, 75, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
686 "mulhw $rT, $rA, $rB", IntMulHW,
687 [(set GPRC:$rT, (mulhs GPRC:$rA, GPRC:$rB))]>;
688 def MULHWU : XOForm_1<31, 11, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
689 "mulhwu $rT, $rA, $rB", IntMulHWU,
690 [(set GPRC:$rT, (mulhu GPRC:$rA, GPRC:$rB))]>;
691 def MULLW : XOForm_1<31, 235, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
692 "mullw $rT, $rA, $rB", IntMulHW,
693 [(set GPRC:$rT, (mul GPRC:$rA, GPRC:$rB))]>;
694 def SUBF : XOForm_1<31, 40, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
695 "subf $rT, $rA, $rB", IntGeneral,
696 [(set GPRC:$rT, (sub GPRC:$rB, GPRC:$rA))]>;
697 def SUBFC : XOForm_1<31, 8, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
698 "subfc $rT, $rA, $rB", IntGeneral,
699 [(set GPRC:$rT, (subc GPRC:$rB, GPRC:$rA))]>,
700 PPC970_DGroup_Cracked;
701 def SUBFE : XOForm_1<31, 136, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
702 "subfe $rT, $rA, $rB", IntGeneral,
703 [(set GPRC:$rT, (sube GPRC:$rB, GPRC:$rA))]>;
704 def ADDME : XOForm_3<31, 234, 0, (ops GPRC:$rT, GPRC:$rA),
705 "addme $rT, $rA", IntGeneral,
706 [(set GPRC:$rT, (adde GPRC:$rA, immAllOnes))]>;
707 def ADDZE : XOForm_3<31, 202, 0, (ops GPRC:$rT, GPRC:$rA),
708 "addze $rT, $rA", IntGeneral,
709 [(set GPRC:$rT, (adde GPRC:$rA, 0))]>;
710 def NEG : XOForm_3<31, 104, 0, (ops GPRC:$rT, GPRC:$rA),
711 "neg $rT, $rA", IntGeneral,
712 [(set GPRC:$rT, (ineg GPRC:$rA))]>;
713 def SUBFME : XOForm_3<31, 232, 0, (ops GPRC:$rT, GPRC:$rA),
714 "subfme $rT, $rA", IntGeneral,
715 [(set GPRC:$rT, (sube immAllOnes, GPRC:$rA))]>;
716 def SUBFZE : XOForm_3<31, 200, 0, (ops GPRC:$rT, GPRC:$rA),
717 "subfze $rT, $rA", IntGeneral,
718 [(set GPRC:$rT, (sube 0, GPRC:$rA))]>;
721 // A-Form instructions. Most of the instructions executed in the FPU are of
724 let PPC970_Unit = 3 in { // FPU Operations.
725 def FMADD : AForm_1<63, 29,
726 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
727 "fmadd $FRT, $FRA, $FRC, $FRB", FPFused,
728 [(set F8RC:$FRT, (fadd (fmul F8RC:$FRA, F8RC:$FRC),
730 Requires<[FPContractions]>;
731 def FMADDS : AForm_1<59, 29,
732 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
733 "fmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
734 [(set F4RC:$FRT, (fadd (fmul F4RC:$FRA, F4RC:$FRC),
736 Requires<[FPContractions]>;
737 def FMSUB : AForm_1<63, 28,
738 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
739 "fmsub $FRT, $FRA, $FRC, $FRB", FPFused,
740 [(set F8RC:$FRT, (fsub (fmul F8RC:$FRA, F8RC:$FRC),
742 Requires<[FPContractions]>;
743 def FMSUBS : AForm_1<59, 28,
744 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
745 "fmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
746 [(set F4RC:$FRT, (fsub (fmul F4RC:$FRA, F4RC:$FRC),
748 Requires<[FPContractions]>;
749 def FNMADD : AForm_1<63, 31,
750 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
751 "fnmadd $FRT, $FRA, $FRC, $FRB", FPFused,
752 [(set F8RC:$FRT, (fneg (fadd (fmul F8RC:$FRA, F8RC:$FRC),
754 Requires<[FPContractions]>;
755 def FNMADDS : AForm_1<59, 31,
756 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
757 "fnmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
758 [(set F4RC:$FRT, (fneg (fadd (fmul F4RC:$FRA, F4RC:$FRC),
760 Requires<[FPContractions]>;
761 def FNMSUB : AForm_1<63, 30,
762 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
763 "fnmsub $FRT, $FRA, $FRC, $FRB", FPFused,
764 [(set F8RC:$FRT, (fneg (fsub (fmul F8RC:$FRA, F8RC:$FRC),
766 Requires<[FPContractions]>;
767 def FNMSUBS : AForm_1<59, 30,
768 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
769 "fnmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
770 [(set F4RC:$FRT, (fneg (fsub (fmul F4RC:$FRA, F4RC:$FRC),
772 Requires<[FPContractions]>;
773 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
774 // having 4 of these, force the comparison to always be an 8-byte double (code
775 // should use an FMRSD if the input comparison value really wants to be a float)
776 // and 4/8 byte forms for the result and operand type..
777 def FSELD : AForm_1<63, 23,
778 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
779 "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
780 [(set F8RC:$FRT, (PPCfsel F8RC:$FRA,F8RC:$FRC,F8RC:$FRB))]>;
781 def FSELS : AForm_1<63, 23,
782 (ops F4RC:$FRT, F8RC:$FRA, F4RC:$FRC, F4RC:$FRB),
783 "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
784 [(set F4RC:$FRT, (PPCfsel F8RC:$FRA,F4RC:$FRC,F4RC:$FRB))]>;
785 def FADD : AForm_2<63, 21,
786 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
787 "fadd $FRT, $FRA, $FRB", FPGeneral,
788 [(set F8RC:$FRT, (fadd F8RC:$FRA, F8RC:$FRB))]>;
789 def FADDS : AForm_2<59, 21,
790 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
791 "fadds $FRT, $FRA, $FRB", FPGeneral,
792 [(set F4RC:$FRT, (fadd F4RC:$FRA, F4RC:$FRB))]>;
793 def FDIV : AForm_2<63, 18,
794 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
795 "fdiv $FRT, $FRA, $FRB", FPDivD,
796 [(set F8RC:$FRT, (fdiv F8RC:$FRA, F8RC:$FRB))]>;
797 def FDIVS : AForm_2<59, 18,
798 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
799 "fdivs $FRT, $FRA, $FRB", FPDivS,
800 [(set F4RC:$FRT, (fdiv F4RC:$FRA, F4RC:$FRB))]>;
801 def FMUL : AForm_3<63, 25,
802 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
803 "fmul $FRT, $FRA, $FRB", FPFused,
804 [(set F8RC:$FRT, (fmul F8RC:$FRA, F8RC:$FRB))]>;
805 def FMULS : AForm_3<59, 25,
806 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
807 "fmuls $FRT, $FRA, $FRB", FPGeneral,
808 [(set F4RC:$FRT, (fmul F4RC:$FRA, F4RC:$FRB))]>;
809 def FSUB : AForm_2<63, 20,
810 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
811 "fsub $FRT, $FRA, $FRB", FPGeneral,
812 [(set F8RC:$FRT, (fsub F8RC:$FRA, F8RC:$FRB))]>;
813 def FSUBS : AForm_2<59, 20,
814 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
815 "fsubs $FRT, $FRA, $FRB", FPGeneral,
816 [(set F4RC:$FRT, (fsub F4RC:$FRA, F4RC:$FRB))]>;
819 let PPC970_Unit = 1 in { // FXU Operations.
820 // M-Form instructions. rotate and mask instructions.
822 let isTwoAddress = 1, isCommutable = 1 in {
823 // RLWIMI can be commuted if the rotate amount is zero.
824 def RLWIMI : MForm_2<20,
825 (ops GPRC:$rA, GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB,
826 u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME", IntRotate,
827 []>, PPC970_DGroup_Cracked;
829 def RLWINM : MForm_2<21,
830 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
831 "rlwinm $rA, $rS, $SH, $MB, $ME", IntGeneral,
833 def RLWINMo : MForm_2<21,
834 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
835 "rlwinm. $rA, $rS, $SH, $MB, $ME", IntGeneral,
836 []>, isDOT, PPC970_DGroup_Cracked;
837 def RLWNM : MForm_2<23,
838 (ops GPRC:$rA, GPRC:$rS, GPRC:$rB, u5imm:$MB, u5imm:$ME),
839 "rlwnm $rA, $rS, $rB, $MB, $ME", IntGeneral,
844 //===----------------------------------------------------------------------===//
845 // DWARF Pseudo Instructions
848 def DWARF_LOC : Pseudo<(ops i32imm:$line, i32imm:$col, i32imm:$file),
849 "; .loc $file, $line, $col",
850 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
853 def DWARF_LABEL : Pseudo<(ops i32imm:$id),
855 [(dwarf_label (i32 imm:$id))]>;
857 //===----------------------------------------------------------------------===//
858 // PowerPC Instruction Patterns
861 // Arbitrary immediate support. Implement in terms of LIS/ORI.
862 def : Pat<(i32 imm:$imm),
863 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
865 // Implement the 'not' operation with the NOR instruction.
866 def NOT : Pat<(not GPRC:$in),
867 (NOR GPRC:$in, GPRC:$in)>;
869 // ADD an arbitrary immediate.
870 def : Pat<(add GPRC:$in, imm:$imm),
871 (ADDIS (ADDI GPRC:$in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
872 // OR an arbitrary immediate.
873 def : Pat<(or GPRC:$in, imm:$imm),
874 (ORIS (ORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
875 // XOR an arbitrary immediate.
876 def : Pat<(xor GPRC:$in, imm:$imm),
877 (XORIS (XORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
879 def : Pat<(sub immSExt16:$imm, GPRC:$in),
880 (SUBFIC GPRC:$in, imm:$imm)>;
882 // Return void support.
883 def : Pat<(ret), (BLR)>;
886 def : Pat<(shl GPRC:$in, (i32 imm:$imm)),
887 (RLWINM GPRC:$in, imm:$imm, 0, (SHL32 imm:$imm))>;
888 def : Pat<(srl GPRC:$in, (i32 imm:$imm)),
889 (RLWINM GPRC:$in, (SRL32 imm:$imm), imm:$imm, 31)>;
892 def : Pat<(rotl GPRC:$in, GPRC:$sh),
893 (RLWNM GPRC:$in, GPRC:$sh, 0, 31)>;
894 def : Pat<(rotl GPRC:$in, (i32 imm:$imm)),
895 (RLWINM GPRC:$in, imm:$imm, 0, 31)>;
898 def : Pat<(PPCcall tglobaladdr:$dst),
899 (BL tglobaladdr:$dst)>;
900 def : Pat<(PPCcall texternalsym:$dst),
901 (BL texternalsym:$dst)>;
903 // Hi and Lo for Darwin Global Addresses.
904 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
905 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
906 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
907 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
908 def : Pat<(PPChi tjumptable:$in, 0), (LIS tjumptable:$in)>;
909 def : Pat<(PPClo tjumptable:$in, 0), (LI tjumptable:$in)>;
910 def : Pat<(add GPRC:$in, (PPChi tglobaladdr:$g, 0)),
911 (ADDIS GPRC:$in, tglobaladdr:$g)>;
912 def : Pat<(add GPRC:$in, (PPChi tconstpool:$g, 0)),
913 (ADDIS GPRC:$in, tconstpool:$g)>;
914 def : Pat<(add GPRC:$in, (PPChi tjumptable:$g, 0)),
915 (ADDIS GPRC:$in, tjumptable:$g)>;
917 // Fused negative multiply subtract, alternate pattern
918 def : Pat<(fsub F8RC:$B, (fmul F8RC:$A, F8RC:$C)),
919 (FNMSUB F8RC:$A, F8RC:$C, F8RC:$B)>,
920 Requires<[FPContractions]>;
921 def : Pat<(fsub F4RC:$B, (fmul F4RC:$A, F4RC:$C)),
922 (FNMSUBS F4RC:$A, F4RC:$C, F4RC:$B)>,
923 Requires<[FPContractions]>;
925 // Standard shifts. These are represented separately from the real shifts above
926 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
928 def : Pat<(sra GPRC:$rS, GPRC:$rB),
929 (SRAW GPRC:$rS, GPRC:$rB)>;
930 def : Pat<(srl GPRC:$rS, GPRC:$rB),
931 (SRW GPRC:$rS, GPRC:$rB)>;
932 def : Pat<(shl GPRC:$rS, GPRC:$rB),
933 (SLW GPRC:$rS, GPRC:$rB)>;
935 def : Pat<(zextload iaddr:$src, i1),
937 def : Pat<(zextload xaddr:$src, i1),
939 def : Pat<(extload iaddr:$src, i1),
941 def : Pat<(extload xaddr:$src, i1),
943 def : Pat<(extload iaddr:$src, i8),
945 def : Pat<(extload xaddr:$src, i8),
947 def : Pat<(extload iaddr:$src, i16),
949 def : Pat<(extload xaddr:$src, i16),
951 def : Pat<(extload iaddr:$src, f32),
952 (FMRSD (LFS iaddr:$src))>;
953 def : Pat<(extload xaddr:$src, f32),
954 (FMRSD (LFSX xaddr:$src))>;
956 include "PPCInstrAltivec.td"
957 include "PPCInstr64Bit.td"