1 //===- PowerPCInstrInfo.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 "PowerPCInstrFormats.td"
17 //===----------------------------------------------------------------------===//
18 // Selection DAG Type Constraint definitions.
20 // Note that the semantics of these constraints are hard coded into tblgen. To
21 // modify or add constraints, you have to hack tblgen.
24 class SDTypeConstraint<int opnum> {
25 int OperandNum = opnum;
28 // SDTCisVT - The specified operand has exactly this VT.
29 class SDTCisVT <int OpNum, ValueType vt> : SDTypeConstraint<OpNum> {
33 // SDTCisInt - The specified operand is has integer type.
34 class SDTCisInt<int OpNum> : SDTypeConstraint<OpNum>;
36 // SDTCisFP - The specified operand is has floating point type.
37 class SDTCisFP <int OpNum> : SDTypeConstraint<OpNum>;
39 // SDTCisSameAs - The two specified operands have identical types.
40 class SDTCisSameAs<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
41 int OtherOperandNum = OtherOp;
44 // SDTCisVTSmallerThanOp - The specified operand is a VT SDNode, and its type is
45 // smaller than the 'Other' operand.
46 class SDTCisVTSmallerThanOp<int OpNum, int OtherOp> : SDTypeConstraint<OpNum> {
47 int OtherOperandNum = OtherOp;
50 //===----------------------------------------------------------------------===//
51 // Selection DAG Type Profile definitions.
53 // These use the constraints defined above to describe the type requirements of
54 // the various nodes. These are not hard coded into tblgen, allowing targets to
55 // add their own if needed.
58 // SDTypeProfile - This profile describes the type requirements of a Selection
60 class SDTypeProfile<int numresults, int numoperands,
61 list<SDTypeConstraint> constraints> {
62 int NumResults = numresults;
63 int NumOperands = numoperands;
64 list<SDTypeConstraint> Constraints = constraints;
68 def SDTImm : SDTypeProfile<1, 0, [SDTCisInt<0>]>; // for 'imm'.
69 def SDTVT : SDTypeProfile<1, 0, [SDTCisVT<0, OtherVT>]>; // for 'vt'
70 def SDTBinOp : SDTypeProfile<1, 2, [ // add, mul, etc.
71 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>
73 def SDTIntBinOp : SDTypeProfile<1, 2, [ // and, or, xor, udiv, etc.
74 SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, SDTCisInt<0>
76 def SDTIntUnaryOp : SDTypeProfile<1, 1, [ // ctlz
77 SDTCisSameAs<0, 1>, SDTCisInt<0>
79 def SDTExtInreg : SDTypeProfile<1, 2, [ // sext_inreg
80 SDTCisSameAs<0, 1>, SDTCisInt<0>, SDTCisVT<2, OtherVT>,
81 SDTCisVTSmallerThanOp<2, 1>
85 //===----------------------------------------------------------------------===//
86 // Selection DAG Node definitions.
88 class SDNode<string opcode, SDTypeProfile typeprof, string sdclass = "SDNode"> {
89 string Opcode = opcode;
90 string SDClass = sdclass;
91 SDTypeProfile TypeProfile = typeprof;
97 def imm : SDNode<"ISD::Constant" , SDTImm , "ConstantSDNode">;
98 def vt : SDNode<"ISD::VALUETYPE" , SDTVT , "VTSDNode">;
99 def and : SDNode<"ISD::AND" , SDTIntBinOp>;
100 def or : SDNode<"ISD::OR" , SDTIntBinOp>;
101 def xor : SDNode<"ISD::XOR" , SDTIntBinOp>;
102 def add : SDNode<"ISD::ADD" , SDTBinOp>;
103 def sub : SDNode<"ISD::SUB" , SDTBinOp>;
104 def mul : SDNode<"ISD::MUL" , SDTBinOp>;
105 def sdiv : SDNode<"ISD::SDIV" , SDTBinOp>;
106 def udiv : SDNode<"ISD::UDIV" , SDTIntBinOp>;
107 def mulhs : SDNode<"ISD::MULHS" , SDTIntBinOp>;
108 def mulhu : SDNode<"ISD::MULHU" , SDTIntBinOp>;
109 def sext_inreg : SDNode<"ISD::SIGN_EXTEND_INREG", SDTExtInreg>;
110 def ctlz : SDNode<"ISD::CTLZ" , SDTIntUnaryOp>;
113 //===----------------------------------------------------------------------===//
114 // Selection DAG Pattern Fragments.
117 /// PatFrag - Represents a pattern fragment. This can match something on the
118 /// DAG, frame a single node to multiply nested other fragments.
120 class PatFrag<dag ops, dag frag, code pred = [{}], code xform = [{}]> {
123 code Predicate = pred;
124 code OperandTransform = xform;
127 // PatLeaf's are pattern fragments that have no operands. This is just a helper
128 // to define immediates and other common things concisely.
129 class PatLeaf<dag frag, code pred = [{}], code xform = [{}]>
130 : PatFrag<(ops), frag, pred, xform>;
134 def immAllOnes : PatLeaf<(imm), [{ return N->isAllOnesValue(); }]>;
135 def immZero : PatLeaf<(imm), [{ return N->isNullValue(); }]>;
137 def vtInt : PatLeaf<(vt), [{ return MVT::isInteger(N->getVT()); }]>;
138 def vtFP : PatLeaf<(vt), [{ return MVT::isFloatingPoint(N->getVT()); }]>;
140 // Other helper fragments.
142 def not : PatFrag<(ops node:$in), (xor node:$in, immAllOnes)>;
143 def ineg : PatFrag<(ops node:$in), (sub immZero, node:$in)>;
147 //===----------------------------------------------------------------------===//
148 // PowerPC specific pattern fragments.
150 def immSExt16 : PatLeaf<(imm), [{
151 // immSExt16 predicate - True if the immediate fits in a 16-bit sign extended
152 // field. Used by instructions like 'addi'.
153 return (int)N->getValue() == (short)N->getValue();
155 def immZExt16 : PatLeaf<(imm), [{
156 // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended
157 // field. Used by instructions like 'ori'.
158 return (unsigned)N->getValue() == (unsigned short)N->getValue();
160 def imm16Shifted : PatLeaf<(imm), [{
161 // imm16Shifted predicate - True if only bits in the top 16-bits of the
162 // immediate are set. Used by instructions like 'addis'.
163 return ((unsigned)N->getValue() & 0xFFFF0000U) == (unsigned)N->getValue();
165 // Transformation function: shift the immediate value down into the low bits.
166 return getI32Imm((unsigned)N->getValue() >> 16);
170 // Example of a legalize expander: Only for PPC64.
171 def : Expander<(set i64:$dst, (fp_to_sint f64:$src)),
172 [(set f64:$tmp , (FCTIDZ f64:$src)),
173 (set i32:$tmpFI, (CreateNewFrameIndex 8, 8)),
174 (store f64:$tmp, i32:$tmpFI),
175 (set i64:$dst, (load i32:$tmpFI))],
181 //===----------------------------------------------------------------------===//
182 // PowerPC Flag Definitions.
184 class isPPC64 { bit PPC64 = 1; }
185 class isVMX { bit VMX = 1; }
187 list<Register> Defs = [CR0];
193 //===----------------------------------------------------------------------===//
194 // PowerPC Operand Definitions.
196 def u5imm : Operand<i8> {
197 let PrintMethod = "printU5ImmOperand";
199 def u6imm : Operand<i8> {
200 let PrintMethod = "printU6ImmOperand";
202 def s16imm : Operand<i16> {
203 let PrintMethod = "printS16ImmOperand";
205 def u16imm : Operand<i16> {
206 let PrintMethod = "printU16ImmOperand";
208 def target : Operand<i32> {
209 let PrintMethod = "printBranchOperand";
211 def piclabel: Operand<i32> {
212 let PrintMethod = "printPICLabel";
214 def symbolHi: Operand<i32> {
215 let PrintMethod = "printSymbolHi";
217 def symbolLo: Operand<i32> {
218 let PrintMethod = "printSymbolLo";
220 def crbitm: Operand<i8> {
221 let PrintMethod = "printcrbitm";
226 //===----------------------------------------------------------------------===//
227 // PowerPC Instruction Definitions.
229 // Pseudo-instructions:
230 def PHI : Pseudo<(ops variable_ops), "; PHI">;
233 def ADJCALLSTACKDOWN : Pseudo<(ops u16imm), "; ADJCALLSTACKDOWN">;
234 def ADJCALLSTACKUP : Pseudo<(ops u16imm), "; ADJCALLSTACKUP">;
236 def IMPLICIT_DEF_GPR : Pseudo<(ops GPRC:$rD), "; $rD = IMPLICIT_DEF_GPRC">;
237 def IMPLICIT_DEF_FP : Pseudo<(ops FPRC:$rD), "; %rD = IMPLICIT_DEF_FP">;
239 // SELECT_CC_* - Used to implement the SELECT_CC DAG operation. Expanded by the
240 // scheduler into a branch sequence.
241 let usesCustomDAGSchedInserter = 1 in { // Expanded by the scheduler.
242 def SELECT_CC_Int : Pseudo<(ops GPRC:$dst, CRRC:$cond, GPRC:$T, GPRC:$F,
243 i32imm:$BROPC), "; SELECT_CC PSEUDO!">;
244 def SELECT_CC_FP : Pseudo<(ops FPRC:$dst, CRRC:$cond, FPRC:$T, FPRC:$F,
245 i32imm:$BROPC), "; SELECT_CC PSEUDO!">;
249 let isTerminator = 1 in {
251 def BLR : XLForm_2_ext<19, 16, 20, 0, 0, (ops), "blr">;
252 def BCTR : XLForm_2_ext<19, 528, 20, 0, 0, (ops), "bctr">;
256 def MovePCtoLR : Pseudo<(ops piclabel:$label), "bl $label">;
258 let isBranch = 1, isTerminator = 1 in {
259 def COND_BRANCH : Pseudo<(ops CRRC:$crS, u16imm, target:$true, target:$false),
261 def B : IForm<18, 0, 0, (ops target:$func), "b $func">;
262 //def BA : IForm<18, 1, 0, (ops target:$func), "ba $func">;
263 def BL : IForm<18, 0, 1, (ops target:$func), "bl $func">;
264 //def BLA : IForm<18, 1, 1, (ops target:$func), "bla $func">;
266 // FIXME: 4*CR# needs to be added to the BI field!
267 // This will only work for CR0 as it stands now
268 def BLT : BForm<16, 0, 0, 12, 0, (ops CRRC:$crS, target:$block),
270 def BLE : BForm<16, 0, 0, 4, 1, (ops CRRC:$crS, target:$block),
272 def BEQ : BForm<16, 0, 0, 12, 2, (ops CRRC:$crS, target:$block),
274 def BGE : BForm<16, 0, 0, 4, 0, (ops CRRC:$crS, target:$block),
276 def BGT : BForm<16, 0, 0, 12, 1, (ops CRRC:$crS, target:$block),
278 def BNE : BForm<16, 0, 0, 4, 2, (ops CRRC:$crS, target:$block),
283 // All calls clobber the non-callee saved registers...
284 Defs = [R0,R2,R3,R4,R5,R6,R7,R8,R9,R10,R11,R12,
285 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
287 CR0,CR1,CR5,CR6,CR7] in {
288 // Convenient aliases for call instructions
289 def CALLpcrel : IForm<18, 0, 1, (ops target:$func, variable_ops), "bl $func">;
290 def CALLindirect : XLForm_2_ext<19, 528, 20, 0, 1,
291 (ops variable_ops), "bctrl">;
294 // D-Form instructions. Most instructions that perform an operation on a
295 // register and an immediate are of this type.
298 def LBZ : DForm_1<34, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
299 "lbz $rD, $disp($rA)">;
300 def LHA : DForm_1<42, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
301 "lha $rD, $disp($rA)">;
302 def LHZ : DForm_1<40, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
303 "lhz $rD, $disp($rA)">;
304 def LMW : DForm_1<46, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
305 "lmw $rD, $disp($rA)">;
306 def LWZ : DForm_1<32, (ops GPRC:$rD, symbolLo:$disp, GPRC:$rA),
307 "lwz $rD, $disp($rA)">;
308 def LWZU : DForm_1<35, (ops GPRC:$rD, s16imm:$disp, GPRC:$rA),
309 "lwzu $rD, $disp($rA)">;
311 def ADDI : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
312 "addi $rD, $rA, $imm",
313 [(set GPRC:$rD, (add GPRC:$rA, immSExt16:$imm))]>;
314 def ADDIC : DForm_2<12, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
315 "addic $rD, $rA, $imm",
317 def ADDICo : DForm_2<13, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
318 "addic. $rD, $rA, $imm",
320 def ADDIS : DForm_2<15, (ops GPRC:$rD, GPRC:$rA, symbolHi:$imm),
321 "addis $rD, $rA, $imm",
322 [(set GPRC:$rD, (add GPRC:$rA, imm16Shifted:$imm))]>;
323 def LA : DForm_2<14, (ops GPRC:$rD, GPRC:$rA, symbolLo:$sym),
326 def MULLI : DForm_2< 7, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
327 "mulli $rD, $rA, $imm",
328 [(set GPRC:$rD, (mul GPRC:$rA, immSExt16:$imm))]>;
329 def SUBFIC : DForm_2< 8, (ops GPRC:$rD, GPRC:$rA, s16imm:$imm),
330 "subfic $rD, $rA, $imm",
332 def LI : DForm_2_r0<14, (ops GPRC:$rD, s16imm:$imm),
334 [(set GPRC:$rD, immSExt16:$imm)]>;
335 def LIS : DForm_2_r0<15, (ops GPRC:$rD, symbolHi:$imm),
337 [(set GPRC:$rD, imm16Shifted:$imm)]>;
339 def STMW : DForm_3<47, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
340 "stmw $rS, $disp($rA)">;
341 def STB : DForm_3<38, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
342 "stb $rS, $disp($rA)">;
343 def STH : DForm_3<44, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
344 "sth $rS, $disp($rA)">;
345 def STW : DForm_3<36, (ops GPRC:$rS, symbolLo:$disp, GPRC:$rA),
346 "stw $rS, $disp($rA)">;
347 def STWU : DForm_3<37, (ops GPRC:$rS, s16imm:$disp, GPRC:$rA),
348 "stwu $rS, $disp($rA)">;
350 def ANDIo : DForm_4<28, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
351 "andi. $dst, $src1, $src2",
353 def ANDISo : DForm_4<29, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
354 "andis. $dst, $src1, $src2",
356 def ORI : DForm_4<24, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
357 "ori $dst, $src1, $src2",
358 [(set GPRC:$rD, (or GPRC:$rA, immZExt16:$imm))]>;
359 def ORIS : DForm_4<25, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
360 "oris $dst, $src1, $src2",
361 [(set GPRC:$rD, (or GPRC:$rA, imm16Shifted:$imm))]>;
362 def XORI : DForm_4<26, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
363 "xori $dst, $src1, $src2",
364 [(set GPRC:$rD, (xor GPRC:$rA, immZExt16:$imm))]>;
365 def XORIS : DForm_4<27, (ops GPRC:$dst, GPRC:$src1, u16imm:$src2),
366 "xoris $dst, $src1, $src2",
367 [(set GPRC:$rD, (xor GPRC:$rA, imm16Shifted:$imm))]>;
368 def NOP : DForm_4_zero<24, (ops), "nop">;
369 def CMPI : DForm_5<11, (ops CRRC:$crD, i1imm:$L, GPRC:$rA, s16imm:$imm),
370 "cmpi $crD, $L, $rA, $imm">;
371 def CMPWI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
372 "cmpwi $crD, $rA, $imm">;
373 def CMPDI : DForm_5_ext<11, (ops CRRC:$crD, GPRC:$rA, s16imm:$imm),
374 "cmpdi $crD, $rA, $imm">, isPPC64;
375 def CMPLI : DForm_6<10, (ops CRRC:$dst, i1imm:$size, GPRC:$src1, u16imm:$src2),
376 "cmpli $dst, $size, $src1, $src2">;
377 def CMPLWI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
378 "cmplwi $dst, $src1, $src2">;
379 def CMPLDI : DForm_6_ext<10, (ops CRRC:$dst, GPRC:$src1, u16imm:$src2),
380 "cmpldi $dst, $src1, $src2">, isPPC64;
382 def LFS : DForm_8<48, (ops FPRC:$rD, symbolLo:$disp, GPRC:$rA),
383 "lfs $rD, $disp($rA)">;
384 def LFD : DForm_8<50, (ops FPRC:$rD, symbolLo:$disp, GPRC:$rA),
385 "lfd $rD, $disp($rA)">;
388 def STFS : DForm_9<52, (ops FPRC:$rS, symbolLo:$disp, GPRC:$rA),
389 "stfs $rS, $disp($rA)">;
390 def STFD : DForm_9<54, (ops FPRC:$rS, symbolLo:$disp, GPRC:$rA),
391 "stfd $rS, $disp($rA)">;
394 // DS-Form instructions. Load/Store instructions available in PPC-64
397 def LWA : DSForm_1<58, 2, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
398 "lwa $rT, $DS($rA)">, isPPC64;
399 def LD : DSForm_2<58, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
400 "ld $rT, $DS($rA)">, isPPC64;
403 def STD : DSForm_2<62, 0, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
404 "std $rT, $DS($rA)">, isPPC64;
405 def STDU : DSForm_2<62, 1, (ops GPRC:$rT, s16imm:$DS, GPRC:$rA),
406 "stdu $rT, $DS($rA)">, isPPC64;
409 // X-Form instructions. Most instructions that perform an operation on a
410 // register and another register are of this type.
413 def LBZX : XForm_1<31, 87, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
414 "lbzx $dst, $base, $index">;
415 def LHAX : XForm_1<31, 343, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
416 "lhax $dst, $base, $index">;
417 def LHZX : XForm_1<31, 279, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
418 "lhzx $dst, $base, $index">;
419 def LWAX : XForm_1<31, 341, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
420 "lwax $dst, $base, $index">, isPPC64;
421 def LWZX : XForm_1<31, 23, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
422 "lwzx $dst, $base, $index">;
423 def LDX : XForm_1<31, 21, (ops GPRC:$dst, GPRC:$base, GPRC:$index),
424 "ldx $dst, $base, $index">, isPPC64;
426 def NAND : XForm_6<31, 476, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
427 "nand $rA, $rS, $rB",
428 [(set GPRC:$rA, (not (and GPRC:$rS, GPRC:$rB)))]>;
429 def AND : XForm_6<31, 28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
431 [(set GPRC:$rT, (and GPRC:$rA, GPRC:$rB))]>;
432 def ANDo : XForm_6<31, 28, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
433 "and. $rA, $rS, $rB",
435 def ANDC : XForm_6<31, 60, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
436 "andc $rA, $rS, $rB",
437 [(set GPRC:$rA, (and GPRC:$rS, (not GPRC:$rB)))]>;
438 def OR : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
440 [(set GPRC:$rT, (or GPRC:$rA, GPRC:$rB))]>;
441 def NOR : XForm_6<31, 124, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
443 [(set GPRC:$rA, (not (or GPRC:$rS, GPRC:$rB)))]>;
444 def ORo : XForm_6<31, 444, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
447 def ORC : XForm_6<31, 412, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
449 [(set GPRC:$rA, (or GPRC:$rS, (not GPRC:$rB)))]>;
450 def EQV : XForm_6<31, 284, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
452 [(set GPRC:$rT, (not (xor GPRC:$rA, GPRC:$rB)))]>;
453 def XOR : XForm_6<31, 316, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
455 [(set GPRC:$rT, (xor GPRC:$rA, GPRC:$rB))]>;
456 def SLD : XForm_6<31, 27, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
459 def SLW : XForm_6<31, 24, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
462 def SRD : XForm_6<31, 539, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
465 def SRW : XForm_6<31, 536, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
468 def SRAD : XForm_6<31, 794, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
469 "srad $rA, $rS, $rB",
471 def SRAW : XForm_6<31, 792, (ops GPRC:$rA, GPRC:$rS, GPRC:$rB),
472 "sraw $rA, $rS, $rB",
475 def STBX : XForm_8<31, 215, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
476 "stbx $rS, $rA, $rB">;
477 def STHX : XForm_8<31, 407, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
478 "sthx $rS, $rA, $rB">;
479 def STWX : XForm_8<31, 151, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
480 "stwx $rS, $rA, $rB">;
481 def STWUX : XForm_8<31, 183, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
482 "stwux $rS, $rA, $rB">;
483 def STDX : XForm_8<31, 149, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
484 "stdx $rS, $rA, $rB">, isPPC64;
485 def STDUX : XForm_8<31, 181, (ops GPRC:$rS, GPRC:$rA, GPRC:$rB),
486 "stdux $rS, $rA, $rB">, isPPC64;
488 def SRAWI : XForm_10<31, 824, (ops GPRC:$rA, GPRC:$rS, u5imm:$SH),
489 "srawi $rA, $rS, $SH">;
490 def CNTLZW : XForm_11<31, 26, (ops GPRC:$rA, GPRC:$rS),
492 [(set GPRC:$rA, (ctlz GPRC:$rS))]>;
493 def EXTSB : XForm_11<31, 954, (ops GPRC:$rA, GPRC:$rS),
495 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i8))]>;
496 def EXTSH : XForm_11<31, 922, (ops GPRC:$rA, GPRC:$rS),
498 [(set GPRC:$rA, (sext_inreg GPRC:$rS, i16))]>;
499 def EXTSW : XForm_11<31, 986, (ops GPRC:$rA, GPRC:$rS),
502 def CMP : XForm_16<31, 0, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
503 "cmp $crD, $long, $rA, $rB">;
504 def CMPL : XForm_16<31, 32, (ops CRRC:$crD, i1imm:$long, GPRC:$rA, GPRC:$rB),
505 "cmpl $crD, $long, $rA, $rB">;
506 def CMPW : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
507 "cmpw $crD, $rA, $rB">;
508 def CMPD : XForm_16_ext<31, 0, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
509 "cmpd $crD, $rA, $rB">, isPPC64;
510 def CMPLW : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
511 "cmplw $crD, $rA, $rB">;
512 def CMPLD : XForm_16_ext<31, 32, (ops CRRC:$crD, GPRC:$rA, GPRC:$rB),
513 "cmpld $crD, $rA, $rB">, isPPC64;
514 def FCMPO : XForm_17<63, 32, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
515 "fcmpo $crD, $fA, $fB">;
516 def FCMPU : XForm_17<63, 0, (ops CRRC:$crD, FPRC:$fA, FPRC:$fB),
517 "fcmpu $crD, $fA, $fB">;
519 def LFSX : XForm_25<31, 535, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
520 "lfsx $dst, $base, $index">;
521 def LFDX : XForm_25<31, 599, (ops FPRC:$dst, GPRC:$base, GPRC:$index),
522 "lfdx $dst, $base, $index">;
524 def FCFID : XForm_26<63, 846, (ops FPRC:$frD, FPRC:$frB),
525 "fcfid $frD, $frB">, isPPC64;
526 def FCTIDZ : XForm_26<63, 815, (ops FPRC:$frD, FPRC:$frB),
527 "fctidz $frD, $frB">, isPPC64;
528 def FCTIWZ : XForm_26<63, 15, (ops FPRC:$frD, FPRC:$frB),
529 "fctiwz $frD, $frB">;
530 def FABS : XForm_26<63, 264, (ops FPRC:$frD, FPRC:$frB),
532 def FMR : XForm_26<63, 72, (ops FPRC:$frD, FPRC:$frB),
534 def FNABS : XForm_26<63, 136, (ops FPRC:$frD, FPRC:$frB),
536 def FNEG : XForm_26<63, 40, (ops FPRC:$frD, FPRC:$frB),
538 def FRSP : XForm_26<63, 12, (ops FPRC:$frD, FPRC:$frB),
540 def FSQRT : XForm_26<63, 22, (ops FPRC:$frD, FPRC:$frB),
542 def FSQRTS : XForm_26<59, 22, (ops FPRC:$frD, FPRC:$frB),
543 "fsqrts $frD, $frB">;
546 def STFSX : XForm_28<31, 663, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
547 "stfsx $frS, $rA, $rB">;
548 def STFDX : XForm_28<31, 727, (ops FPRC:$frS, GPRC:$rA, GPRC:$rB),
549 "stfdx $frS, $rA, $rB">;
552 // XL-Form instructions. condition register logical ops.
554 def MCRF : XLForm_3<19, 0, (ops CRRC:$BF, CRRC:$BFA),
557 // XFX-Form instructions. Instructions that deal with SPRs
559 // Note that although LR should be listed as `8' and CTR as `9' in the SPR
560 // field, the manual lists the groups of bits as [5-9] = 0, [0-4] = 8 or 9
561 // which means the SPR value needs to be multiplied by a factor of 32.
562 def MFCTR : XFXForm_1_ext<31, 339, 288, (ops GPRC:$rT), "mfctr $rT">;
563 def MFLR : XFXForm_1_ext<31, 339, 256, (ops GPRC:$rT), "mflr $rT">;
564 def MFCR : XFXForm_3<31, 19, (ops GPRC:$rT), "mfcr $rT">;
565 def MTCRF : XFXForm_5<31, 144, (ops crbitm:$FXM, GPRC:$rS),
567 def MFOCRF : XFXForm_5a<31, 19, (ops GPRC:$rT, crbitm:$FXM),
569 def MTCTR : XFXForm_7_ext<31, 467, 288, (ops GPRC:$rS), "mtctr $rS">;
570 def MTLR : XFXForm_7_ext<31, 467, 256, (ops GPRC:$rS), "mtlr $rS">;
572 // XS-Form instructions. Just 'sradi'
574 def SRADI : XSForm_1<31, 413, (ops GPRC:$rA, GPRC:$rS, u6imm:$SH),
575 "sradi $rA, $rS, $SH">, isPPC64;
577 // XO-Form instructions. Arithmetic instructions that can set overflow bit
579 def ADD : XOForm_1<31, 266, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
581 [(set GPRC:$rT, (add GPRC:$rA, GPRC:$rB))]>;
582 def ADDC : XOForm_1<31, 10, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
583 "addc $rT, $rA, $rB",
585 def ADDE : XOForm_1<31, 138, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
586 "adde $rT, $rA, $rB",
588 def DIVD : XOForm_1<31, 489, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
589 "divd $rT, $rA, $rB",
591 def DIVDU : XOForm_1<31, 457, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
592 "divdu $rT, $rA, $rB",
594 def DIVW : XOForm_1<31, 491, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
595 "divw $rT, $rA, $rB",
596 [(set GPRC:$rT, (sdiv GPRC:$rA, GPRC:$rB))]>;
597 def DIVWU : XOForm_1<31, 459, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
598 "divwu $rT, $rA, $rB",
599 [(set GPRC:$rT, (udiv GPRC:$rA, GPRC:$rB))]>;
600 def MULHW : XOForm_1<31, 75, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
601 "mulhw $rT, $rA, $rB",
602 [(set GPRC:$rT, (mulhs GPRC:$rA, GPRC:$rB))]>;
603 def MULHWU : XOForm_1<31, 11, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
604 "mulhwu $rT, $rA, $rB",
605 [(set GPRC:$rT, (mulhu GPRC:$rA, GPRC:$rB))]>;
606 def MULLD : XOForm_1<31, 233, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
607 "mulld $rT, $rA, $rB",
609 def MULLW : XOForm_1<31, 235, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
610 "mullw $rT, $rA, $rB",
611 [(set GPRC:$rT, (mul GPRC:$rA, GPRC:$rB))]>;
612 def SUBF : XOForm_1<31, 40, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
613 "subf $rT, $rA, $rB",
614 [(set GPRC:$rT, (sub GPRC:$rB, GPRC:$rA))]>;
615 def SUBFC : XOForm_1<31, 8, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
616 "subfc $rT, $rA, $rB",
618 def SUBFE : XOForm_1<31, 136, 0, (ops GPRC:$rT, GPRC:$rA, GPRC:$rB),
619 "subfe $rT, $rA, $rB",
621 def ADDME : XOForm_3<31, 234, 0, (ops GPRC:$rT, GPRC:$rA),
624 def ADDZE : XOForm_3<31, 202, 0, (ops GPRC:$rT, GPRC:$rA),
627 def NEG : XOForm_3<31, 104, 0, (ops GPRC:$rT, GPRC:$rA),
629 [(set GPRC:$rT, (ineg GPRC:$rA))]>;
630 def SUBFZE : XOForm_3<31, 200, 0, (ops GPRC:$rT, GPRC:$rA),
634 // A-Form instructions. Most of the instructions executed in the FPU are of
637 def FMADD : AForm_1<63, 29,
638 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
639 "fmadd $FRT, $FRA, $FRC, $FRB">;
640 def FMADDS : AForm_1<59, 29,
641 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
642 "fmadds $FRT, $FRA, $FRC, $FRB">;
643 def FMSUB : AForm_1<63, 28,
644 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
645 "fmsub $FRT, $FRA, $FRC, $FRB">;
646 def FMSUBS : AForm_1<59, 28,
647 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
648 "fmsubs $FRT, $FRA, $FRC, $FRB">;
649 def FNMADD : AForm_1<63, 31,
650 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
651 "fnmadd $FRT, $FRA, $FRC, $FRB">;
652 def FNMADDS : AForm_1<59, 31,
653 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
654 "fnmadds $FRT, $FRA, $FRC, $FRB">;
655 def FNMSUB : AForm_1<63, 30,
656 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
657 "fnmsub $FRT, $FRA, $FRC, $FRB">;
658 def FNMSUBS : AForm_1<59, 30,
659 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
660 "fnmsubs $FRT, $FRA, $FRC, $FRB">;
661 def FSEL : AForm_1<63, 23,
662 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRC, FPRC:$FRB),
663 "fsel $FRT, $FRA, $FRC, $FRB">;
664 def FADD : AForm_2<63, 21,
665 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
666 "fadd $FRT, $FRA, $FRB">;
667 def FADDS : AForm_2<59, 21,
668 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
669 "fadds $FRT, $FRA, $FRB">;
670 def FDIV : AForm_2<63, 18,
671 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
672 "fdiv $FRT, $FRA, $FRB">;
673 def FDIVS : AForm_2<59, 18,
674 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
675 "fdivs $FRT, $FRA, $FRB">;
676 def FMUL : AForm_3<63, 25,
677 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
678 "fmul $FRT, $FRA, $FRB">;
679 def FMULS : AForm_3<59, 25,
680 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
681 "fmuls $FRT, $FRA, $FRB">;
682 def FSUB : AForm_2<63, 20,
683 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
684 "fsub $FRT, $FRA, $FRB">;
685 def FSUBS : AForm_2<59, 20,
686 (ops FPRC:$FRT, FPRC:$FRA, FPRC:$FRB),
687 "fsubs $FRT, $FRA, $FRB">;
689 // M-Form instructions. rotate and mask instructions.
691 let isTwoAddress = 1 in {
692 def RLWIMI : MForm_2<20,
693 (ops GPRC:$rA, GPRC:$rSi, GPRC:$rS, u5imm:$SH, u5imm:$MB,
694 u5imm:$ME), "rlwimi $rA, $rS, $SH, $MB, $ME">;
696 def RLWINM : MForm_2<21,
697 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
698 "rlwinm $rA, $rS, $SH, $MB, $ME">;
699 def RLWINMo : MForm_2<21,
700 (ops GPRC:$rA, GPRC:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
701 "rlwinm. $rA, $rS, $SH, $MB, $ME">, isDOT;
702 def RLWNM : MForm_2<23,
703 (ops GPRC:$rA, GPRC:$rS, GPRC:$rB, u5imm:$MB, u5imm:$ME),
704 "rlwnm $rA, $rS, $rB, $MB, $ME">;
706 // MD-Form instructions. 64 bit rotate instructions.
708 def RLDICL : MDForm_1<30, 0,
709 (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$MB),
710 "rldicl $rA, $rS, $SH, $MB">, isPPC64;
711 def RLDICR : MDForm_1<30, 1,
712 (ops GPRC:$rA, GPRC:$rS, u6imm:$SH, u6imm:$ME),
713 "rldicr $rA, $rS, $SH, $ME">, isPPC64;
715 def PowerPCInstrInfo : InstrInfo {
718 let TSFlagsFields = [ "VMX", "PPC64" ];
719 let TSFlagsShifts = [ 0, 1 ];
721 let isLittleEndianEncoding = 1;