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> ]>;
27 def SDT_PPCRetFlag : SDTypeProfile<0, 0, []>;
29 def SDT_PPCvperm : SDTypeProfile<1, 3, [
30 SDTCisVT<3, v16i8>, SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
33 def SDT_PPCvcmp : SDTypeProfile<1, 3, [
34 SDTCisSameAs<0, 1>, SDTCisSameAs<1, 2>, SDTCisVT<3, i32>
37 //===----------------------------------------------------------------------===//
38 // PowerPC specific DAG Nodes.
41 def PPCfcfid : SDNode<"PPCISD::FCFID" , SDTFPUnaryOp, []>;
42 def PPCfctidz : SDNode<"PPCISD::FCTIDZ", SDTFPUnaryOp, []>;
43 def PPCfctiwz : SDNode<"PPCISD::FCTIWZ", SDTFPUnaryOp, []>;
44 def PPCstfiwx : SDNode<"PPCISD::STFIWX", SDT_PPCstfiwx, [SDNPHasChain]>;
46 def PPCfsel : SDNode<"PPCISD::FSEL",
47 // Type constraint for fsel.
48 SDTypeProfile<1, 3, [SDTCisSameAs<0, 2>, SDTCisSameAs<0, 3>,
49 SDTCisFP<0>, SDTCisVT<1, f64>]>, []>;
51 def PPChi : SDNode<"PPCISD::Hi", SDTIntBinOp, []>;
52 def PPClo : SDNode<"PPCISD::Lo", SDTIntBinOp, []>;
53 def PPCvmaddfp : SDNode<"PPCISD::VMADDFP", SDTFPTernaryOp, []>;
54 def PPCvnmsubfp : SDNode<"PPCISD::VNMSUBFP", SDTFPTernaryOp, []>;
56 def PPCvperm : SDNode<"PPCISD::VPERM", SDT_PPCvperm, []>;
58 // These nodes represent the 32-bit PPC shifts that operate on 6-bit shift
59 // amounts. These nodes are generated by the multi-precision shift code.
60 def PPCsrl : SDNode<"PPCISD::SRL" , SDT_PPCShiftOp>;
61 def PPCsra : SDNode<"PPCISD::SRA" , SDT_PPCShiftOp>;
62 def PPCshl : SDNode<"PPCISD::SHL" , SDT_PPCShiftOp>;
64 def PPCextsw_32 : SDNode<"PPCISD::EXTSW_32" , SDTIntUnaryOp>;
65 def PPCstd_32 : SDNode<"PPCISD::STD_32" , SDTStore, [SDNPHasChain]>;
67 // These are target-independent nodes, but have target-specific formats.
68 def callseq_start : SDNode<"ISD::CALLSEQ_START", SDT_PPCCallSeq,[SDNPHasChain]>;
69 def callseq_end : SDNode<"ISD::CALLSEQ_END", SDT_PPCCallSeq,[SDNPHasChain]>;
71 def retflag : SDNode<"PPCISD::RET_FLAG", SDT_PPCRetFlag,
72 [SDNPHasChain, SDNPOptInFlag]>;
74 def PPCvcmp : SDNode<"PPCISD::VCMP" , SDT_PPCvcmp, []>;
75 def PPCvcmp_o : SDNode<"PPCISD::VCMPo", SDT_PPCvcmp, [SDNPOutFlag]>;
77 //===----------------------------------------------------------------------===//
78 // PowerPC specific transformation functions and pattern fragments.
81 def SHL32 : SDNodeXForm<imm, [{
82 // Transformation function: 31 - imm
83 return getI32Imm(31 - N->getValue());
86 def SHL64 : SDNodeXForm<imm, [{
87 // Transformation function: 63 - imm
88 return getI32Imm(63 - N->getValue());
91 def SRL32 : SDNodeXForm<imm, [{
92 // Transformation function: 32 - imm
93 return N->getValue() ? getI32Imm(32 - N->getValue()) : getI32Imm(0);
96 def SRL64 : SDNodeXForm<imm, [{
97 // Transformation function: 64 - imm
98 return N->getValue() ? getI32Imm(64 - N->getValue()) : getI32Imm(0);
101 def LO16 : SDNodeXForm<imm, [{
102 // Transformation function: get the low 16 bits.
103 return getI32Imm((unsigned short)N->getValue());
106 def HI16 : SDNodeXForm<imm, [{
107 // Transformation function: shift the immediate value down into the low bits.
108 return getI32Imm((unsigned)N->getValue() >> 16);
111 def HA16 : SDNodeXForm<imm, [{
112 // Transformation function: shift the immediate value down into the low bits.
113 signed int Val = N->getValue();
114 return getI32Imm((Val - (signed short)Val) >> 16);
118 def immSExt16 : PatLeaf<(imm), [{
119 // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended
120 // field. Used by instructions like 'addi'.
121 return (int)N->getValue() == (short)N->getValue();
123 def immZExt16 : PatLeaf<(imm), [{
124 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
125 // field. Used by instructions like 'ori'.
126 return (unsigned)N->getValue() == (unsigned short)N->getValue();
129 def imm16Shifted : PatLeaf<(imm), [{
130 // imm16Shifted predicate - True if only bits in the top 16-bits of the
131 // immediate are set. Used by instructions like 'addis'.
132 return ((unsigned)N->getValue() & 0xFFFF0000U) == (unsigned)N->getValue();
136 //===----------------------------------------------------------------------===//
137 // PowerPC Flag Definitions.
139 class isPPC64 { bit PPC64 = 1; }
140 class isVMX { bit VMX = 1; }
142 list<Register> Defs = [CR0];
148 //===----------------------------------------------------------------------===//
149 // PowerPC Operand Definitions.
151 def s5imm : Operand<i32> {
152 let PrintMethod = "printS5ImmOperand";
154 def u5imm : Operand<i32> {
155 let PrintMethod = "printU5ImmOperand";
157 def u6imm : Operand<i32> {
158 let PrintMethod = "printU6ImmOperand";
160 def s16imm : Operand<i32> {
161 let PrintMethod = "printS16ImmOperand";
163 def u16imm : Operand<i32> {
164 let PrintMethod = "printU16ImmOperand";
166 def s16immX4 : Operand<i32> { // Multiply imm by 4 before printing.
167 let PrintMethod = "printS16X4ImmOperand";
169 def target : Operand<OtherVT> {
170 let PrintMethod = "printBranchOperand";
172 def calltarget : Operand<i32> {
173 let PrintMethod = "printCallOperand";
175 def aaddr : Operand<i32> {
176 let PrintMethod = "printAbsAddrOperand";
178 def piclabel: Operand<i32> {
179 let PrintMethod = "printPICLabel";
181 def symbolHi: Operand<i32> {
182 let PrintMethod = "printSymbolHi";
184 def symbolLo: Operand<i32> {
185 let PrintMethod = "printSymbolLo";
187 def crbitm: Operand<i8> {
188 let PrintMethod = "printcrbitm";
191 def memri : Operand<i32> {
192 let PrintMethod = "printMemRegImm";
193 let NumMIOperands = 2;
194 let MIOperandInfo = (ops i32imm, GPRC);
196 def memrr : Operand<i32> {
197 let PrintMethod = "printMemRegReg";
198 let NumMIOperands = 2;
199 let MIOperandInfo = (ops GPRC, GPRC);
201 def memrix : Operand<i32> { // memri where the imm is shifted 2 bits.
202 let PrintMethod = "printMemRegImmShifted";
203 let NumMIOperands = 2;
204 let MIOperandInfo = (ops i32imm, GPRC);
207 // Define PowerPC specific addressing mode.
208 def iaddr : ComplexPattern<i32, 2, "SelectAddrImm", []>;
209 def xaddr : ComplexPattern<i32, 2, "SelectAddrIdx", []>;
210 def xoaddr : ComplexPattern<i32, 2, "SelectAddrIdxOnly",[]>;
211 def ixaddr : ComplexPattern<i32, 2, "SelectAddrImmShift", []>; // "std"
213 //===----------------------------------------------------------------------===//
214 // PowerPC Instruction Predicate Definitions.
215 def FPContractions : Predicate<"!NoExcessFPPrecision">;
217 //===----------------------------------------------------------------------===//
218 // PowerPC Instruction Definitions.
220 // Pseudo-instructions:
222 let hasCtrlDep = 1 in {
223 def ADJCALLSTACKDOWN : Pseudo<(ops u16imm:$amt),
224 "; ADJCALLSTACKDOWN",
225 [(callseq_start imm:$amt)]>;
226 def ADJCALLSTACKUP : Pseudo<(ops u16imm:$amt),
228 [(callseq_end imm:$amt)]>;
230 def UPDATE_VRSAVE : Pseudo<(ops GPRC:$rD, GPRC:$rS),
231 "UPDATE_VRSAVE $rD, $rS", []>;
233 def IMPLICIT_DEF_GPR : Pseudo<(ops GPRC:$rD), "; $rD = IMPLICIT_DEF_GPRC",
234 [(set GPRC:$rD, (undef))]>;
235 def IMPLICIT_DEF_F8 : Pseudo<(ops F8RC:$rD), "; $rD = IMPLICIT_DEF_F8",
236 [(set F8RC:$rD, (undef))]>;
237 def IMPLICIT_DEF_F4 : Pseudo<(ops F4RC:$rD), "; $rD = IMPLICIT_DEF_F4",
238 [(set F4RC:$rD, (undef))]>;
240 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded by the
241 // scheduler into a branch sequence.
242 let usesCustomDAGSchedInserter = 1, // Expanded by the scheduler.
243 PPC970_Single = 1 in {
244 def SELECT_CC_Int : Pseudo<(ops GPRC:$dst, CRRC:$cond, GPRC:$T, GPRC:$F,
245 i32imm:$BROPC), "; SELECT_CC PSEUDO!", []>;
246 def SELECT_CC_F4 : Pseudo<(ops F4RC:$dst, CRRC:$cond, F4RC:$T, F4RC:$F,
247 i32imm:$BROPC), "; SELECT_CC PSEUDO!", []>;
248 def SELECT_CC_F8 : Pseudo<(ops F8RC:$dst, CRRC:$cond, F8RC:$T, F8RC:$F,
249 i32imm:$BROPC), "; SELECT_CC PSEUDO!", []>;
250 def SELECT_CC_VRRC: Pseudo<(ops VRRC:$dst, CRRC:$cond, VRRC:$T, VRRC:$F,
251 i32imm:$BROPC), "; SELECT_CC PSEUDO!", []>;
254 let isTerminator = 1, noResults = 1, PPC970_Unit = 7 in {
256 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (ops), "blr", BrB, [(retflag)]>;
257 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (ops), "bctr", BrB, []>;
261 def MovePCtoLR : Pseudo<(ops piclabel:$label), "bl $label", []>,
264 let isBranch = 1, isTerminator = 1, hasCtrlDep = 1,
265 noResults = 1, PPC970_Unit = 7 in {
266 def COND_BRANCH : Pseudo<(ops CRRC:$crS, u16imm:$opc, target:$true),
267 "; COND_BRANCH", []>;
268 def B : IForm<18, 0, 0, (ops target:$dst),
272 // FIXME: 4*CR# needs to be added to the BI field!
273 // This will only work for CR0 as it stands now
274 def BLT : BForm<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block),
275 "blt $crS, $block", BrB>;
276 def BLE : BForm<16, 0, 0, 4, 1, (ops CRRC:$crS, target:$block),
277 "ble $crS, $block", BrB>;
278 def BEQ : BForm<16, 0, 0, 12, 2, (ops CRRC:$crS, target:$block),
279 "beq $crS, $block", BrB>;
280 def BGE : BForm<16, 0, 0, 4, 0, (ops CRRC:$crS, target:$block),
281 "bge $crS, $block", BrB>;
282 def BGT : BForm<16, 0, 0, 12, 1, (ops CRRC:$crS, target:$block),
283 "bgt $crS, $block", BrB>;
284 def BNE : BForm<16, 0, 0, 4, 2, (ops CRRC:$crS, target:$block),
285 "bne $crS, $block", BrB>;
286 def BUN : BForm<16, 0, 0, 12, 3, (ops CRRC:$crS, target:$block),
287 "bun $crS, $block", BrB>;
288 def BNU : BForm<16, 0, 0, 4, 3, (ops CRRC:$crS, target:$block),
289 "bnu $crS, $block", BrB>;
292 let isCall = 1, noResults = 1, PPC970_Unit = 7,
293 // All calls clobber the non-callee saved registers...
294 Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
295 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
296 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
298 CR0,CR1,CR5,CR6,CR7] in {
299 // Convenient aliases for call instructions
300 def BL : IForm<18, 0, 1, (ops calltarget:$func, variable_ops),
301 "bl $func", BrB, []>;
302 def BLA : IForm<18, 1, 1, (ops aaddr:$func, variable_ops),
303 "bla $func", BrB, []>;
304 def BCTRL : XLForm_2_ext<19, 528, 20, 0, 1, (ops variable_ops), "bctrl", BrB,
308 // D-Form instructions. Most instructions that perform an operation on a
309 // register and an immediate are of this type.
311 let isLoad = 1, PPC970_Unit = 2 in {
312 def LBZ : DForm_1<34, (ops GPRC:$rD, memri:$src),
313 "lbz $rD, $src", LdStGeneral,
314 [(set GPRC:$rD, (zextload iaddr:$src, i8))]>;
315 def LHA : DForm_1<42, (ops GPRC:$rD, memri:$src),
316 "lha $rD, $src", LdStLHA,
317 [(set GPRC:$rD, (sextload iaddr:$src, i16))]>,
318 PPC970_DGroup_Cracked;
319 def LHZ : DForm_1<40, (ops GPRC:$rD, memri:$src),
320 "lhz $rD, $src", LdStGeneral,
321 [(set GPRC:$rD, (zextload iaddr:$src, i16))]>;
322 def LWZ : DForm_1<32, (ops GPRC:$rD, memri:$src),
323 "lwz $rD, $src", LdStGeneral,
324 [(set GPRC:$rD, (load iaddr:$src))]>;
325 def LWZU : DForm_1<35, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
326 "lwzu $rD, $disp($rA)", LdStGeneral,
329 let PPC970_Unit = 1 in { // FXU Operations.
330 def ADDI : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
331 "addi $rD, $rA, $imm", IntGeneral,
332 [(set GPRC:$rD, (add GPRC:$rA, immSExt16:$imm))]>;
333 def ADDIC : DForm_2<12, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
334 "addic $rD, $rA, $imm", IntGeneral,
335 [(set GPRC:$rD, (addc GPRC:$rA, immSExt16:$imm))]>,
336 PPC970_DGroup_Cracked;
337 def ADDICo : DForm_2<13, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
338 "addic. $rD, $rA, $imm", IntGeneral,
340 def ADDIS : DForm_2<15, (ops GPRC:$rD, GPRC:$rA, symbolHi:$imm),
341 "addis $rD, $rA, $imm", IntGeneral,
342 [(set GPRC:$rD, (add GPRC:$rA, imm16Shifted:$imm))]>;
343 def LA : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, symbolLo:$sym),
344 "la $rD, $sym($rA)", IntGeneral,
345 [(set GPRC:$rD, (add GPRC:$rA,
346 (PPClo tglobaladdr:$sym, 0)))]>;
347 def MULLI : DForm_2< 7, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
348 "mulli $rD, $rA, $imm", IntMulLI,
349 [(set GPRC:$rD, (mul GPRC:$rA, immSExt16:$imm))]>;
350 def SUBFIC : DForm_2< 8, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
351 "subfic $rD, $rA, $imm", IntGeneral,
352 [(set GPRC:$rD, (subc immSExt16:$imm, GPRC:$rA))]>;
353 def LI : DForm_2_r0<14, (ops GPRC:$rD, symbolLo:$imm),
354 "li $rD, $imm", IntGeneral,
355 [(set GPRC:$rD, immSExt16:$imm)]>;
356 def LIS : DForm_2_r0<15, (ops GPRC:$rD, symbolHi:$imm),
357 "lis $rD, $imm", IntGeneral,
358 [(set GPRC:$rD, imm16Shifted:$imm)]>;
360 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
361 def STB : DForm_3<38, (ops GPRC:$rS, memri:$src),
362 "stb $rS, $src", LdStGeneral,
363 [(truncstore GPRC:$rS, iaddr:$src, i8)]>;
364 def STH : DForm_3<44, (ops GPRC:$rS, memri:$src),
365 "sth $rS, $src", LdStGeneral,
366 [(truncstore GPRC:$rS, iaddr:$src, i16)]>;
367 def STW : DForm_3<36, (ops GPRC:$rS, memri:$src),
368 "stw $rS, $src", LdStGeneral,
369 [(store GPRC:$rS, iaddr:$src)]>;
370 def STWU : DForm_3<37, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
371 "stwu $rS, $disp($rA)", LdStGeneral,
374 let PPC970_Unit = 1 in { // FXU Operations.
375 def ANDIo : DForm_4<28, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
376 "andi. $dst, $src1, $src2", IntGeneral,
377 [(set GPRC:$dst, (and GPRC:$src1, immZExt16:$src2))]>,
379 def ANDISo : DForm_4<29, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
380 "andis. $dst, $src1, $src2", IntGeneral,
381 [(set GPRC:$dst, (and GPRC:$src1, imm16Shifted:$src2))]>,
383 def ORI : DForm_4<24, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
384 "ori $dst, $src1, $src2", IntGeneral,
385 [(set GPRC:$dst, (or GPRC:$src1, immZExt16:$src2))]>;
386 def ORIS : DForm_4<25, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
387 "oris $dst, $src1, $src2", IntGeneral,
388 [(set GPRC:$dst, (or GPRC:$src1, imm16Shifted:$src2))]>;
389 def XORI : DForm_4<26, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
390 "xori $dst, $src1, $src2", IntGeneral,
391 [(set GPRC:$dst, (xor GPRC:$src1, immZExt16:$src2))]>;
392 def XORIS : DForm_4<27, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
393 "xoris $dst, $src1, $src2", IntGeneral,
394 [(set GPRC:$dst, (xor GPRC:$src1, imm16Shifted:$src2))]>;
395 def NOP : DForm_4_zero<24, (ops), "nop", IntGeneral,
397 def CMPI : DForm_5<11, (ops CRRC:$crD, i1imm:$L, GPRC:$rA, s16imm:$imm),
398 "cmpi $crD, $L, $rA, $imm", IntCompare>;
399 def CMPWI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
400 "cmpwi $crD, $rA, $imm", IntCompare>;
401 def CMPDI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
402 "cmpdi $crD, $rA, $imm", IntCompare>, isPPC64;
403 def CMPLI : DForm_6<10, (ops CRRC:$dst, i1imm:$size, GPRC:$src1, u16imm:$src2),
404 "cmpli $dst, $size, $src1, $src2", IntCompare>;
405 def CMPLWI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
406 "cmplwi $dst, $src1, $src2", IntCompare>;
407 def CMPLDI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
408 "cmpldi $dst, $src1, $src2", IntCompare>, isPPC64;
410 let isLoad = 1, PPC970_Unit = 2 in {
411 def LFS : DForm_8<48, (ops F4RC:$rD, memri:$src),
412 "lfs $rD, $src", LdStLFDU,
413 [(set F4RC:$rD, (load iaddr:$src))]>;
414 def LFD : DForm_8<50, (ops F8RC:$rD, memri:$src),
415 "lfd $rD, $src", LdStLFD,
416 [(set F8RC:$rD, (load iaddr:$src))]>;
418 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
419 def STFS : DForm_9<52, (ops F4RC:$rS, memri:$dst),
420 "stfs $rS, $dst", LdStUX,
421 [(store F4RC:$rS, iaddr:$dst)]>;
422 def STFD : DForm_9<54, (ops F8RC:$rS, memri:$dst),
423 "stfd $rS, $dst", LdStUX,
424 [(store F8RC:$rS, iaddr:$dst)]>;
427 // DS-Form instructions. Load/Store instructions available in PPC-64
429 let isLoad = 1, PPC970_Unit = 2 in {
430 def LWA : DSForm_1<58, 2, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
431 "lwa $rT, $DS($rA)", LdStLWA,
432 []>, isPPC64, PPC970_DGroup_Cracked;
433 def LD : DSForm_2<58, 0, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
434 "ld $rT, $DS($rA)", LdStLD,
437 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
438 def STD : DSForm_2<62, 0, (ops GPRC:$rT, s16immX4:$DS, GPRC:$rA),
439 "std $rT, $DS($rA)", LdStSTD,
442 // STD_32/STDX_32 - Just like STD/STDX, but uses a '32-bit' input register.
443 def STD_32 : DSForm_2<62, 0, (ops GPRC:$rT, memrix:$dst),
444 "std $rT, $dst", LdStSTD,
445 [(PPCstd_32 GPRC:$rT, ixaddr:$dst)]>, isPPC64;
446 def STDX_32 : XForm_8<31, 149, (ops GPRC:$rT, memrr:$dst),
447 "stdx $rT, $dst", LdStSTD,
448 [(PPCstd_32 GPRC:$rT, xaddr:$dst)]>, isPPC64,
449 PPC970_DGroup_Cracked;
452 // X-Form instructions. Most instructions that perform an operation on a
453 // register and another register are of this type.
455 let isLoad = 1, PPC970_Unit = 2 in {
456 def LBZX : XForm_1<31, 87, (ops GPRC:$rD, memrr:$src),
457 "lbzx $rD, $src", LdStGeneral,
458 [(set GPRC:$rD, (zextload xaddr:$src, i8))]>;
459 def LHAX : XForm_1<31, 343, (ops GPRC:$rD, memrr:$src),
460 "lhax $rD, $src", LdStLHA,
461 [(set GPRC:$rD, (sextload xaddr:$src, i16))]>,
462 PPC970_DGroup_Cracked;
463 def LHZX : XForm_1<31, 279, (ops GPRC:$rD, memrr:$src),
464 "lhzx $rD, $src", LdStGeneral,
465 [(set GPRC:$rD, (zextload xaddr:$src, i16))]>;
466 def LWAX : XForm_1<31, 341, (ops G8RC:$rD, memrr:$src),
467 "lwax $rD, $src", LdStLHA,
468 [(set G8RC:$rD, (sextload xaddr:$src, i32))]>, isPPC64,
469 PPC970_DGroup_Cracked;
470 def LWZX : XForm_1<31, 23, (ops GPRC:$rD, memrr:$src),
471 "lwzx $rD, $src", LdStGeneral,
472 [(set GPRC:$rD, (load xaddr:$src))]>;
473 def LDX : XForm_1<31, 21, (ops G8RC:$rD, memrr:$src),
474 "ldx $rD, $src", LdStLD,
475 [(set G8RC:$rD, (load xaddr:$src))]>, isPPC64;
478 let PPC970_Unit = 1 in { // FXU Operations.
479 def NAND : XForm_6<31, 476, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
480 "nand $rA, $rS, $rB", IntGeneral,
481 [(set GPRC:$rA, (not (and GPRC:$rS, GPRC:$rB)))]>;
482 def AND : XForm_6<31, 28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
483 "and $rA, $rS, $rB", IntGeneral,
484 [(set GPRC:$rA, (and GPRC:$rS, GPRC:$rB))]>;
485 def ANDo : XForm_6<31, 28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
486 "and. $rA, $rS, $rB", IntGeneral,
488 def ANDC : XForm_6<31, 60, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
489 "andc $rA, $rS, $rB", IntGeneral,
490 [(set GPRC:$rA, (and GPRC:$rS, (not GPRC:$rB)))]>;
491 def OR4 : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
492 "or $rA, $rS, $rB", IntGeneral,
493 [(set GPRC:$rA, (or GPRC:$rS, GPRC:$rB))]>;
494 def OR8 : XForm_6<31, 444, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
495 "or $rA, $rS, $rB", IntGeneral,
496 [(set G8RC:$rA, (or G8RC:$rS, G8RC:$rB))]>;
497 def OR4To8 : XForm_6<31, 444, (ops G8RC:$rA, GPRC:$rS, GPRC:$rB),
498 "or $rA, $rS, $rB", IntGeneral,
500 def OR8To4 : XForm_6<31, 444, (ops GPRC:$rA, G8RC:$rS, G8RC:$rB),
501 "or $rA, $rS, $rB", IntGeneral,
503 def NOR : XForm_6<31, 124, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
504 "nor $rA, $rS, $rB", IntGeneral,
505 [(set GPRC:$rA, (not (or GPRC:$rS, GPRC:$rB)))]>;
506 def ORo : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
507 "or. $rA, $rS, $rB", IntGeneral,
509 def ORC : XForm_6<31, 412, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
510 "orc $rA, $rS, $rB", IntGeneral,
511 [(set GPRC:$rA, (or GPRC:$rS, (not GPRC:$rB)))]>;
512 def EQV : XForm_6<31, 284, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
513 "eqv $rA, $rS, $rB", IntGeneral,
514 [(set GPRC:$rA, (not (xor GPRC:$rS, GPRC:$rB)))]>;
515 def XOR : XForm_6<31, 316, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
516 "xor $rA, $rS, $rB", IntGeneral,
517 [(set GPRC:$rA, (xor GPRC:$rS, GPRC:$rB))]>;
518 def SLD : XForm_6<31, 27, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
519 "sld $rA, $rS, $rB", IntRotateD,
520 [(set G8RC:$rA, (shl G8RC:$rS, G8RC:$rB))]>, isPPC64;
521 def SLW : XForm_6<31, 24, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
522 "slw $rA, $rS, $rB", IntGeneral,
523 [(set GPRC:$rA, (PPCshl GPRC:$rS, GPRC:$rB))]>;
524 def SRD : XForm_6<31, 539, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
525 "srd $rA, $rS, $rB", IntRotateD,
526 [(set G8RC:$rA, (srl G8RC:$rS, G8RC:$rB))]>, isPPC64;
527 def SRW : XForm_6<31, 536, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
528 "srw $rA, $rS, $rB", IntGeneral,
529 [(set GPRC:$rA, (PPCsrl GPRC:$rS, GPRC:$rB))]>;
530 def SRAD : XForm_6<31, 794, (ops G8RC:$rA, G8RC:$rS, G8RC:$rB),
531 "srad $rA, $rS, $rB", IntRotateD,
532 [(set G8RC:$rA, (sra G8RC:$rS, G8RC:$rB))]>, isPPC64;
533 def SRAW : XForm_6<31, 792, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
534 "sraw $rA, $rS, $rB", IntShift,
535 [(set GPRC:$rA, (PPCsra GPRC:$rS, GPRC:$rB))]>;
537 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
538 def STBX : XForm_8<31, 215, (ops GPRC:$rS, memrr:$dst),
539 "stbx $rS, $dst", LdStGeneral,
540 [(truncstore GPRC:$rS, xaddr:$dst, i8)]>,
541 PPC970_DGroup_Cracked;
542 def STHX : XForm_8<31, 407, (ops GPRC:$rS, memrr:$dst),
543 "sthx $rS, $dst", LdStGeneral,
544 [(truncstore GPRC:$rS, xaddr:$dst, i16)]>,
545 PPC970_DGroup_Cracked;
546 def STWX : XForm_8<31, 151, (ops GPRC:$rS, memrr:$dst),
547 "stwx $rS, $dst", LdStGeneral,
548 [(store GPRC:$rS, xaddr:$dst)]>,
549 PPC970_DGroup_Cracked;
550 def STWUX : XForm_8<31, 183, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
551 "stwux $rS, $rA, $rB", LdStGeneral,
553 def STDX : XForm_8<31, 149, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
554 "stdx $rS, $rA, $rB", LdStSTD,
555 []>, isPPC64, PPC970_DGroup_Cracked;
556 def STDUX : XForm_8<31, 181, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
557 "stdux $rS, $rA, $rB", LdStSTD,
560 let PPC970_Unit = 1 in { // FXU Operations.
561 def SRAWI : XForm_10<31, 824, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH),
562 "srawi $rA, $rS, $SH", IntShift,
563 [(set GPRC:$rA, (sra GPRC:$rS, (i32 imm:$SH)))]>;
564 def CNTLZW : XForm_11<31, 26, (ops GPRC:$rA, GPRC:$rS),
565 "cntlzw $rA, $rS", IntGeneral,
566 [(set GPRC:$rA, (ctlz GPRC:$rS))]>;
567 def EXTSB : XForm_11<31, 954, (ops GPRC:$rA, GPRC:$rS),
568 "extsb $rA, $rS", IntGeneral,
569 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i8))]>;
570 def EXTSH : XForm_11<31, 922, (ops GPRC:$rA, GPRC:$rS),
571 "extsh $rA, $rS", IntGeneral,
572 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i16))]>;
573 def EXTSW : XForm_11<31, 986, (ops G8RC:$rA, G8RC:$rS),
574 "extsw $rA, $rS", IntGeneral,
575 [(set G8RC:$rA, (sext_inreg G8RC:$rS, i32))]>, isPPC64;
576 /// EXTSW_32 - Just like EXTSW, but works on '32-bit' registers.
577 def EXTSW_32 : XForm_11<31, 986, (ops GPRC:$rA, GPRC:$rS),
578 "extsw $rA, $rS", IntGeneral,
579 [(set GPRC:$rA, (PPCextsw_32 GPRC:$rS))]>, isPPC64;
581 def CMP : XForm_16<31, 0, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
582 "cmp $crD, $long, $rA, $rB", IntCompare>;
583 def CMPL : XForm_16<31, 32, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
584 "cmpl $crD, $long, $rA, $rB", IntCompare>;
585 def CMPW : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
586 "cmpw $crD, $rA, $rB", IntCompare>;
587 def CMPD : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
588 "cmpd $crD, $rA, $rB", IntCompare>, isPPC64;
589 def CMPLW : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
590 "cmplw $crD, $rA, $rB", IntCompare>;
591 def CMPLD : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
592 "cmpld $crD, $rA, $rB", IntCompare>, isPPC64;
594 let PPC970_Unit = 3 in { // FPU Operations.
595 //def FCMPO : XForm_17<63, 32, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
596 // "fcmpo $crD, $fA, $fB", FPCompare>;
597 def FCMPUS : XForm_17<63, 0, (ops CRRC:$crD, F4RC:$fA, F4RC:$fB),
598 "fcmpu $crD, $fA, $fB", FPCompare>;
599 def FCMPUD : XForm_17<63, 0, (ops CRRC:$crD, F8RC:$fA, F8RC:$fB),
600 "fcmpu $crD, $fA, $fB", FPCompare>;
602 let isLoad = 1, PPC970_Unit = 2 in {
603 def LFSX : XForm_25<31, 535, (ops F4RC:$frD, memrr:$src),
604 "lfsx $frD, $src", LdStLFDU,
605 [(set F4RC:$frD, (load xaddr:$src))]>;
606 def LFDX : XForm_25<31, 599, (ops F8RC:$frD, memrr:$src),
607 "lfdx $frD, $src", LdStLFDU,
608 [(set F8RC:$frD, (load xaddr:$src))]>;
610 let PPC970_Unit = 3 in { // FPU Operations.
611 def FCFID : XForm_26<63, 846, (ops F8RC:$frD, F8RC:$frB),
612 "fcfid $frD, $frB", FPGeneral,
613 [(set F8RC:$frD, (PPCfcfid F8RC:$frB))]>, isPPC64;
614 def FCTIDZ : XForm_26<63, 815, (ops F8RC:$frD, F8RC:$frB),
615 "fctidz $frD, $frB", FPGeneral,
616 [(set F8RC:$frD, (PPCfctidz F8RC:$frB))]>, isPPC64;
617 def FCTIWZ : XForm_26<63, 15, (ops F8RC:$frD, F8RC:$frB),
618 "fctiwz $frD, $frB", FPGeneral,
619 [(set F8RC:$frD, (PPCfctiwz F8RC:$frB))]>;
620 def FRSP : XForm_26<63, 12, (ops F4RC:$frD, F8RC:$frB),
621 "frsp $frD, $frB", FPGeneral,
622 [(set F4RC:$frD, (fround F8RC:$frB))]>;
623 def FSQRT : XForm_26<63, 22, (ops F8RC:$frD, F8RC:$frB),
624 "fsqrt $frD, $frB", FPSqrt,
625 [(set F8RC:$frD, (fsqrt F8RC:$frB))]>;
626 def FSQRTS : XForm_26<59, 22, (ops F4RC:$frD, F4RC:$frB),
627 "fsqrts $frD, $frB", FPSqrt,
628 [(set F4RC:$frD, (fsqrt F4RC:$frB))]>;
631 /// FMR is split into 3 versions, one for 4/8 byte FP, and one for extending.
633 /// Note that these are defined as pseudo-ops on the PPC970 because they are
634 /// often coalesced away and we don't want the dispatch group builder to think
635 /// that they will fill slots (which could cause the load of a LSU reject to
636 /// sneak into a d-group with a store).
637 def FMRS : XForm_26<63, 72, (ops F4RC:$frD, F4RC:$frB),
638 "fmr $frD, $frB", FPGeneral,
639 []>, // (set F4RC:$frD, F4RC:$frB)
641 def FMRD : XForm_26<63, 72, (ops F8RC:$frD, F8RC:$frB),
642 "fmr $frD, $frB", FPGeneral,
643 []>, // (set F8RC:$frD, F8RC:$frB)
645 def FMRSD : XForm_26<63, 72, (ops F8RC:$frD, F4RC:$frB),
646 "fmr $frD, $frB", FPGeneral,
647 [(set F8RC:$frD, (fextend F4RC:$frB))]>,
650 let PPC970_Unit = 3 in { // FPU Operations.
651 // These are artificially split into two different forms, for 4/8 byte FP.
652 def FABSS : XForm_26<63, 264, (ops F4RC:$frD, F4RC:$frB),
653 "fabs $frD, $frB", FPGeneral,
654 [(set F4RC:$frD, (fabs F4RC:$frB))]>;
655 def FABSD : XForm_26<63, 264, (ops F8RC:$frD, F8RC:$frB),
656 "fabs $frD, $frB", FPGeneral,
657 [(set F8RC:$frD, (fabs F8RC:$frB))]>;
658 def FNABSS : XForm_26<63, 136, (ops F4RC:$frD, F4RC:$frB),
659 "fnabs $frD, $frB", FPGeneral,
660 [(set F4RC:$frD, (fneg (fabs F4RC:$frB)))]>;
661 def FNABSD : XForm_26<63, 136, (ops F8RC:$frD, F8RC:$frB),
662 "fnabs $frD, $frB", FPGeneral,
663 [(set F8RC:$frD, (fneg (fabs F8RC:$frB)))]>;
664 def FNEGS : XForm_26<63, 40, (ops F4RC:$frD, F4RC:$frB),
665 "fneg $frD, $frB", FPGeneral,
666 [(set F4RC:$frD, (fneg F4RC:$frB))]>;
667 def FNEGD : XForm_26<63, 40, (ops F8RC:$frD, F8RC:$frB),
668 "fneg $frD, $frB", FPGeneral,
669 [(set F8RC:$frD, (fneg F8RC:$frB))]>;
672 let isStore = 1, noResults = 1, PPC970_Unit = 2 in {
673 def STFIWX: XForm_28<31, 983, (ops F8RC:$frS, memrr:$dst),
674 "stfiwx $frS, $dst", LdStUX,
675 [(PPCstfiwx F8RC:$frS, xoaddr:$dst)]>;
676 def STFSX : XForm_28<31, 663, (ops F4RC:$frS, memrr:$dst),
677 "stfsx $frS, $dst", LdStUX,
678 [(store F4RC:$frS, xaddr:$dst)]>;
679 def STFDX : XForm_28<31, 727, (ops F8RC:$frS, memrr:$dst),
680 "stfdx $frS, $dst", LdStUX,
681 [(store F8RC:$frS, xaddr:$dst)]>;
684 // XL-Form instructions. condition register logical ops.
686 def MCRF : XLForm_3<19, 0, (ops CRRC:$BF, CRRC:$BFA),
687 "mcrf $BF, $BFA", BrMCR>,
688 PPC970_DGroup_First, PPC970_Unit_CRU;
690 // XFX-Form instructions. Instructions that deal with SPRs.
692 def MFCTR : XFXForm_1_ext<31, 339, 9, (ops GPRC:$rT), "mfctr $rT", SprMFSPR>,
693 PPC970_DGroup_First, PPC970_Unit_FXU;
694 def MTCTR : XFXForm_7_ext<31, 467, 9, (ops GPRC:$rS), "mtctr $rS", SprMTSPR>,
695 PPC970_DGroup_First, PPC970_Unit_FXU;
697 def MTLR : XFXForm_7_ext<31, 467, 8, (ops GPRC:$rS), "mtlr $rS", SprMTSPR>,
698 PPC970_DGroup_First, PPC970_Unit_FXU;
699 def MFLR : XFXForm_1_ext<31, 339, 8, (ops GPRC:$rT), "mflr $rT", SprMFSPR>,
700 PPC970_DGroup_First, PPC970_Unit_FXU;
702 // Move to/from VRSAVE: despite being a SPR, the VRSAVE register is renamed like
703 // a GPR on the PPC970. As such, copies in and out have the same performance
704 // characteristics as an OR instruction.
705 def MTVRSAVE : XFXForm_7_ext<31, 467, 256, (ops GPRC:$rS),
706 "mtspr 256, $rS", IntGeneral>,
707 PPC970_DGroup_Single, PPC970_Unit_FXU;
708 def MFVRSAVE : XFXForm_1_ext<31, 339, 256, (ops GPRC:$rT),
709 "mfspr $rT, 256", IntGeneral>,
710 PPC970_DGroup_First, PPC970_Unit_FXU;
712 def MTCRF : XFXForm_5<31, 144, (ops crbitm:$FXM, GPRC:$rS),
713 "mtcrf $FXM, $rS", BrMCRX>,
714 PPC970_MicroCode, PPC970_Unit_CRU;
715 def MFCR : XFXForm_3<31, 19, (ops GPRC:$rT), "mfcr $rT", SprMFCR>,
716 PPC970_MicroCode, PPC970_Unit_CRU;
717 def MFOCRF: XFXForm_5a<31, 19, (ops GPRC:$rT, crbitm:$FXM),
718 "mfcr $rT, $FXM", SprMFCR>,
719 PPC970_DGroup_First, PPC970_Unit_CRU;
721 // XS-Form instructions. Just 'sradi'
723 let PPC970_Unit = 1 in { // FXU Operations.
724 def SRADI : XSForm_1<31, 413, (ops GPRC:$rA, GPRC:$rS, u6imm:$SH),
725 "sradi $rA, $rS, $SH", IntRotateD>, isPPC64;
727 // XO-Form instructions. Arithmetic instructions that can set overflow bit
729 def ADD4 : XOForm_1<31, 266, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
730 "add $rT, $rA, $rB", IntGeneral,
731 [(set GPRC:$rT, (add GPRC:$rA, GPRC:$rB))]>;
732 def ADD8 : XOForm_1<31, 266, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
733 "add $rT, $rA, $rB", IntGeneral,
734 [(set G8RC:$rT, (add G8RC:$rA, G8RC:$rB))]>;
735 def ADDC : XOForm_1<31, 10, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
736 "addc $rT, $rA, $rB", IntGeneral,
737 [(set GPRC:$rT, (addc GPRC:$rA, GPRC:$rB))]>,
738 PPC970_DGroup_Cracked;
739 def ADDE : XOForm_1<31, 138, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
740 "adde $rT, $rA, $rB", IntGeneral,
741 [(set GPRC:$rT, (adde GPRC:$rA, GPRC:$rB))]>;
742 def DIVD : XOForm_1<31, 489, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
743 "divd $rT, $rA, $rB", IntDivD,
744 [(set G8RC:$rT, (sdiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
745 PPC970_DGroup_First, PPC970_DGroup_Cracked;
746 def DIVDU : XOForm_1<31, 457, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
747 "divdu $rT, $rA, $rB", IntDivD,
748 [(set G8RC:$rT, (udiv G8RC:$rA, G8RC:$rB))]>, isPPC64,
749 PPC970_DGroup_First, PPC970_DGroup_Cracked;
750 def DIVW : XOForm_1<31, 491, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
751 "divw $rT, $rA, $rB", IntDivW,
752 [(set GPRC:$rT, (sdiv GPRC:$rA, GPRC:$rB))]>,
753 PPC970_DGroup_First, PPC970_DGroup_Cracked;
754 def DIVWU : XOForm_1<31, 459, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
755 "divwu $rT, $rA, $rB", IntDivW,
756 [(set GPRC:$rT, (udiv GPRC:$rA, GPRC:$rB))]>,
757 PPC970_DGroup_First, PPC970_DGroup_Cracked;
758 def MULHD : XOForm_1<31, 73, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
759 "mulhd $rT, $rA, $rB", IntMulHW,
760 [(set G8RC:$rT, (mulhs G8RC:$rA, G8RC:$rB))]>;
761 def MULHDU : XOForm_1<31, 9, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
762 "mulhdu $rT, $rA, $rB", IntMulHWU,
763 [(set G8RC:$rT, (mulhu G8RC:$rA, G8RC:$rB))]>;
764 def MULHW : XOForm_1<31, 75, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
765 "mulhw $rT, $rA, $rB", IntMulHW,
766 [(set GPRC:$rT, (mulhs GPRC:$rA, GPRC:$rB))]>;
767 def MULHWU : XOForm_1<31, 11, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
768 "mulhwu $rT, $rA, $rB", IntMulHWU,
769 [(set GPRC:$rT, (mulhu GPRC:$rA, GPRC:$rB))]>;
770 def MULLD : XOForm_1<31, 233, 0, (ops G8RC:$rT, G8RC:$rA, G8RC:$rB),
771 "mulld $rT, $rA, $rB", IntMulHD,
772 [(set G8RC:$rT, (mul G8RC:$rA, G8RC:$rB))]>, isPPC64;
773 def MULLW : XOForm_1<31, 235, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
774 "mullw $rT, $rA, $rB", IntMulHW,
775 [(set GPRC:$rT, (mul GPRC:$rA, GPRC:$rB))]>;
776 def SUBF : XOForm_1<31, 40, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
777 "subf $rT, $rA, $rB", IntGeneral,
778 [(set GPRC:$rT, (sub GPRC:$rB, GPRC:$rA))]>;
779 def SUBFC : XOForm_1<31, 8, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
780 "subfc $rT, $rA, $rB", IntGeneral,
781 [(set GPRC:$rT, (subc GPRC:$rB, GPRC:$rA))]>,
782 PPC970_DGroup_Cracked;
783 def SUBFE : XOForm_1<31, 136, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
784 "subfe $rT, $rA, $rB", IntGeneral,
785 [(set GPRC:$rT, (sube GPRC:$rB, GPRC:$rA))]>;
786 def ADDME : XOForm_3<31, 234, 0, (ops GPRC:$rT, GPRC:$rA),
787 "addme $rT, $rA", IntGeneral,
788 [(set GPRC:$rT, (adde GPRC:$rA, immAllOnes))]>;
789 def ADDZE : XOForm_3<31, 202, 0, (ops GPRC:$rT, GPRC:$rA),
790 "addze $rT, $rA", IntGeneral,
791 [(set GPRC:$rT, (adde GPRC:$rA, 0))]>;
792 def NEG : XOForm_3<31, 104, 0, (ops GPRC:$rT, GPRC:$rA),
793 "neg $rT, $rA", IntGeneral,
794 [(set GPRC:$rT, (ineg GPRC:$rA))]>;
795 def SUBFME : XOForm_3<31, 232, 0, (ops GPRC:$rT, GPRC:$rA),
796 "subfme $rT, $rA", IntGeneral,
797 [(set GPRC:$rT, (sube immAllOnes, GPRC:$rA))]>;
798 def SUBFZE : XOForm_3<31, 200, 0, (ops GPRC:$rT, GPRC:$rA),
799 "subfze $rT, $rA", IntGeneral,
800 [(set GPRC:$rT, (sube 0, GPRC:$rA))]>;
803 // A-Form instructions. Most of the instructions executed in the FPU are of
806 let PPC970_Unit = 3 in { // FPU Operations.
807 def FMADD : AForm_1<63, 29,
808 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
809 "fmadd $FRT, $FRA, $FRC, $FRB", FPFused,
810 [(set F8RC:$FRT, (fadd (fmul F8RC:$FRA, F8RC:$FRC),
812 Requires<[FPContractions]>;
813 def FMADDS : AForm_1<59, 29,
814 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
815 "fmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
816 [(set F4RC:$FRT, (fadd (fmul F4RC:$FRA, F4RC:$FRC),
818 Requires<[FPContractions]>;
819 def FMSUB : AForm_1<63, 28,
820 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
821 "fmsub $FRT, $FRA, $FRC, $FRB", FPFused,
822 [(set F8RC:$FRT, (fsub (fmul F8RC:$FRA, F8RC:$FRC),
824 Requires<[FPContractions]>;
825 def FMSUBS : AForm_1<59, 28,
826 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
827 "fmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
828 [(set F4RC:$FRT, (fsub (fmul F4RC:$FRA, F4RC:$FRC),
830 Requires<[FPContractions]>;
831 def FNMADD : AForm_1<63, 31,
832 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
833 "fnmadd $FRT, $FRA, $FRC, $FRB", FPFused,
834 [(set F8RC:$FRT, (fneg (fadd (fmul F8RC:$FRA, F8RC:$FRC),
836 Requires<[FPContractions]>;
837 def FNMADDS : AForm_1<59, 31,
838 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
839 "fnmadds $FRT, $FRA, $FRC, $FRB", FPGeneral,
840 [(set F4RC:$FRT, (fneg (fadd (fmul F4RC:$FRA, F4RC:$FRC),
842 Requires<[FPContractions]>;
843 def FNMSUB : AForm_1<63, 30,
844 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
845 "fnmsub $FRT, $FRA, $FRC, $FRB", FPFused,
846 [(set F8RC:$FRT, (fneg (fsub (fmul F8RC:$FRA, F8RC:$FRC),
848 Requires<[FPContractions]>;
849 def FNMSUBS : AForm_1<59, 30,
850 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRC, F4RC:$FRB),
851 "fnmsubs $FRT, $FRA, $FRC, $FRB", FPGeneral,
852 [(set F4RC:$FRT, (fneg (fsub (fmul F4RC:$FRA, F4RC:$FRC),
854 Requires<[FPContractions]>;
855 // FSEL is artificially split into 4 and 8-byte forms for the result. To avoid
856 // having 4 of these, force the comparison to always be an 8-byte double (code
857 // should use an FMRSD if the input comparison value really wants to be a float)
858 // and 4/8 byte forms for the result and operand type..
859 def FSELD : AForm_1<63, 23,
860 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRC, F8RC:$FRB),
861 "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
862 [(set F8RC:$FRT, (PPCfsel F8RC:$FRA,F8RC:$FRC,F8RC:$FRB))]>;
863 def FSELS : AForm_1<63, 23,
864 (ops F4RC:$FRT, F8RC:$FRA, F4RC:$FRC, F4RC:$FRB),
865 "fsel $FRT, $FRA, $FRC, $FRB", FPGeneral,
866 [(set F4RC:$FRT, (PPCfsel F8RC:$FRA,F4RC:$FRC,F4RC:$FRB))]>;
867 def FADD : AForm_2<63, 21,
868 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
869 "fadd $FRT, $FRA, $FRB", FPGeneral,
870 [(set F8RC:$FRT, (fadd F8RC:$FRA, F8RC:$FRB))]>;
871 def FADDS : AForm_2<59, 21,
872 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
873 "fadds $FRT, $FRA, $FRB", FPGeneral,
874 [(set F4RC:$FRT, (fadd F4RC:$FRA, F4RC:$FRB))]>;
875 def FDIV : AForm_2<63, 18,
876 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
877 "fdiv $FRT, $FRA, $FRB", FPDivD,
878 [(set F8RC:$FRT, (fdiv F8RC:$FRA, F8RC:$FRB))]>;
879 def FDIVS : AForm_2<59, 18,
880 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
881 "fdivs $FRT, $FRA, $FRB", FPDivS,
882 [(set F4RC:$FRT, (fdiv F4RC:$FRA, F4RC:$FRB))]>;
883 def FMUL : AForm_3<63, 25,
884 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
885 "fmul $FRT, $FRA, $FRB", FPFused,
886 [(set F8RC:$FRT, (fmul F8RC:$FRA, F8RC:$FRB))]>;
887 def FMULS : AForm_3<59, 25,
888 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
889 "fmuls $FRT, $FRA, $FRB", FPGeneral,
890 [(set F4RC:$FRT, (fmul F4RC:$FRA, F4RC:$FRB))]>;
891 def FSUB : AForm_2<63, 20,
892 (ops F8RC:$FRT, F8RC:$FRA, F8RC:$FRB),
893 "fsub $FRT, $FRA, $FRB", FPGeneral,
894 [(set F8RC:$FRT, (fsub F8RC:$FRA, F8RC:$FRB))]>;
895 def FSUBS : AForm_2<59, 20,
896 (ops F4RC:$FRT, F4RC:$FRA, F4RC:$FRB),
897 "fsubs $FRT, $FRA, $FRB", FPGeneral,
898 [(set F4RC:$FRT, (fsub F4RC:$FRA, F4RC:$FRB))]>;
901 let PPC970_Unit = 1 in { // FXU Operations.
902 // M-Form instructions. rotate and mask instructions.
904 let isTwoAddress = 1, isCommutable = 1 in {
905 // RLWIMI can be commuted if the rotate amount is zero.
906 def RLWIMI : MForm_2<20,
907 (ops GPRC:$rA, GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB,
908 u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME", IntRotate,
909 []>, PPC970_DGroup_Cracked;
910 def RLDIMI : MDForm_1<30, 3,
911 (ops G8RC:$rA, G8RC:$rSi, G8RC:$rS, u6imm:$SH, u6imm:$MB),
912 "rldimi $rA, $rS, $SH, $MB", IntRotateD,
915 def RLWINM : MForm_2<21,
916 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
917 "rlwinm $rA, $rS, $SH, $MB, $ME", IntGeneral,
919 def RLWINMo : MForm_2<21,
920 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
921 "rlwinm. $rA, $rS, $SH, $MB, $ME", IntGeneral,
922 []>, isDOT, PPC970_DGroup_Cracked;
923 def RLWNM : MForm_2<23,
924 (ops GPRC:$rA, GPRC:$rS, GPRC:$rB, u5imm:$MB, u5imm:$ME),
925 "rlwnm $rA, $rS, $rB, $MB, $ME", IntGeneral,
928 // MD-Form instructions. 64 bit rotate instructions.
930 def RLDICL : MDForm_1<30, 0,
931 (ops G8RC:$rA, G8RC:$rS, u6imm:$SH, u6imm:$MB),
932 "rldicl $rA, $rS, $SH, $MB", IntRotateD,
934 def RLDICR : MDForm_1<30, 1,
935 (ops G8RC:$rA, G8RC:$rS, u6imm:$SH, u6imm:$ME),
936 "rldicr $rA, $rS, $SH, $ME", IntRotateD,
941 //===----------------------------------------------------------------------===//
942 // DWARF Pseudo Instructions
945 def DWARF_LOC : Pseudo<(ops i32imm:$line, i32imm:$col, i32imm:$file),
946 "; .loc $file, $line, $col",
947 [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
950 def DWARF_LABEL : Pseudo<(ops i32imm:$id),
952 [(dwarf_label (i32 imm:$id))]>;
954 //===----------------------------------------------------------------------===//
955 // PowerPC Instruction Patterns
958 // Arbitrary immediate support. Implement in terms of LIS/ORI.
959 def : Pat<(i32 imm:$imm),
960 (ORI (LIS (HI16 imm:$imm)), (LO16 imm:$imm))>;
962 // Implement the 'not' operation with the NOR instruction.
963 def NOT : Pat<(not GPRC:$in),
964 (NOR GPRC:$in, GPRC:$in)>;
966 // ADD an arbitrary immediate.
967 def : Pat<(add GPRC:$in, imm:$imm),
968 (ADDIS (ADDI GPRC:$in, (LO16 imm:$imm)), (HA16 imm:$imm))>;
969 // OR an arbitrary immediate.
970 def : Pat<(or GPRC:$in, imm:$imm),
971 (ORIS (ORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
972 // XOR an arbitrary immediate.
973 def : Pat<(xor GPRC:$in, imm:$imm),
974 (XORIS (XORI GPRC:$in, (LO16 imm:$imm)), (HI16 imm:$imm))>;
976 def : Pat<(sub immSExt16:$imm, GPRC:$in),
977 (SUBFIC GPRC:$in, imm:$imm)>;
979 // Return void support.
980 def : Pat<(ret), (BLR)>;
983 def : Pat<(i64 (zext GPRC:$in)),
984 (RLDICL (OR4To8 GPRC:$in, GPRC:$in), 0, 32)>;
985 def : Pat<(i64 (anyext GPRC:$in)),
986 (OR4To8 GPRC:$in, GPRC:$in)>;
987 def : Pat<(i32 (trunc G8RC:$in)),
988 (OR8To4 G8RC:$in, G8RC:$in)>;
991 def : Pat<(shl GPRC:$in, (i32 imm:$imm)),
992 (RLWINM GPRC:$in, imm:$imm, 0, (SHL32 imm:$imm))>;
993 def : Pat<(shl G8RC:$in, (i64 imm:$imm)),
994 (RLDICR G8RC:$in, imm:$imm, (SHL64 imm:$imm))>;
996 def : Pat<(srl GPRC:$in, (i32 imm:$imm)),
997 (RLWINM GPRC:$in, (SRL32 imm:$imm), imm:$imm, 31)>;
998 def : Pat<(srl G8RC:$in, (i64 imm:$imm)),
999 (RLDICL G8RC:$in, (SRL64 imm:$imm), imm:$imm)>;
1002 def : Pat<(rotl GPRC:$in, GPRC:$sh),
1003 (RLWNM GPRC:$in, GPRC:$sh, 0, 31)>;
1004 def : Pat<(rotl GPRC:$in, (i32 imm:$imm)),
1005 (RLWINM GPRC:$in, imm:$imm, 0, 31)>;
1007 // Hi and Lo for Darwin Global Addresses.
1008 def : Pat<(PPChi tglobaladdr:$in, 0), (LIS tglobaladdr:$in)>;
1009 def : Pat<(PPClo tglobaladdr:$in, 0), (LI tglobaladdr:$in)>;
1010 def : Pat<(PPChi tconstpool:$in, 0), (LIS tconstpool:$in)>;
1011 def : Pat<(PPClo tconstpool:$in, 0), (LI tconstpool:$in)>;
1012 def : Pat<(add GPRC:$in, (PPChi tglobaladdr:$g, 0)),
1013 (ADDIS GPRC:$in, tglobaladdr:$g)>;
1014 def : Pat<(add GPRC:$in, (PPChi tconstpool:$g, 0)),
1015 (ADDIS GPRC:$in, tconstpool:$g)>;
1017 // Fused negative multiply subtract, alternate pattern
1018 def : Pat<(fsub F8RC:$B, (fmul F8RC:$A, F8RC:$C)),
1019 (FNMSUB F8RC:$A, F8RC:$C, F8RC:$B)>,
1020 Requires<[FPContractions]>;
1021 def : Pat<(fsub F4RC:$B, (fmul F4RC:$A, F4RC:$C)),
1022 (FNMSUBS F4RC:$A, F4RC:$C, F4RC:$B)>,
1023 Requires<[FPContractions]>;
1025 // Standard shifts. These are represented separately from the real shifts above
1026 // so that we can distinguish between shifts that allow 5-bit and 6-bit shift
1028 def : Pat<(sra GPRC:$rS, GPRC:$rB),
1029 (SRAW GPRC:$rS, GPRC:$rB)>;
1030 def : Pat<(srl GPRC:$rS, GPRC:$rB),
1031 (SRW GPRC:$rS, GPRC:$rB)>;
1032 def : Pat<(shl GPRC:$rS, GPRC:$rB),
1033 (SLW GPRC:$rS, GPRC:$rB)>;
1035 def : Pat<(i32 (zextload iaddr:$src, i1)),
1037 def : Pat<(i32 (zextload xaddr:$src, i1)),
1039 def : Pat<(i32 (extload iaddr:$src, i1)),
1041 def : Pat<(i32 (extload xaddr:$src, i1)),
1043 def : Pat<(i32 (extload iaddr:$src, i8)),
1045 def : Pat<(i32 (extload xaddr:$src, i8)),
1047 def : Pat<(i32 (extload iaddr:$src, i16)),
1049 def : Pat<(i32 (extload xaddr:$src, i16)),
1051 def : Pat<(f64 (extload iaddr:$src, f32)),
1052 (FMRSD (LFS iaddr:$src))>;
1053 def : Pat<(f64 (extload xaddr:$src, f32)),
1054 (FMRSD (LFSX xaddr:$src))>;
1057 include "PPCInstrAltivec.td"