blob: 1b6fcbeec736034b6f19def8945a104b0a7030ba [file] [log] [blame]
Jia Liub22310f2012-02-18 12:03:15 +00001//===-- PPCInstr64Bit.td - The PowerPC 64-bit Support ------*- tablegen -*-===//
2//
Chris Lattnerb4299832006-06-16 20:22:01 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jia Liub22310f2012-02-18 12:03:15 +00007//
Chris Lattnerb4299832006-06-16 20:22:01 +00008//===----------------------------------------------------------------------===//
9//
10// This file describes the PowerPC 64-bit instructions. These patterns are used
11// both when in ppc64 mode and when in "use 64-bit extensions in 32-bit" mode.
12//
13//===----------------------------------------------------------------------===//
14
Chris Lattner2d4e8f72006-06-20 21:23:06 +000015//===----------------------------------------------------------------------===//
16// 64-bit operands.
17//
Chris Lattner7ecbd302006-06-26 23:53:10 +000018def s16imm64 : Operand<i64> {
19 let PrintMethod = "printS16ImmOperand";
Ulrich Weigandfd3ad692013-06-26 13:49:15 +000020 let EncoderMethod = "getImm16Encoding";
Ulrich Weigand640192d2013-05-03 19:49:39 +000021 let ParserMatchClass = PPCS16ImmAsmOperand;
Hal Finkel23453472013-12-19 16:13:01 +000022 let DecoderMethod = "decodeSImmOperand<16>";
Chris Lattner7ecbd302006-06-26 23:53:10 +000023}
24def u16imm64 : Operand<i64> {
25 let PrintMethod = "printU16ImmOperand";
Ulrich Weigandfd3ad692013-06-26 13:49:15 +000026 let EncoderMethod = "getImm16Encoding";
Ulrich Weigand640192d2013-05-03 19:49:39 +000027 let ParserMatchClass = PPCU16ImmAsmOperand;
Hal Finkel23453472013-12-19 16:13:01 +000028 let DecoderMethod = "decodeUImmOperand<16>";
Chris Lattner7ecbd302006-06-26 23:53:10 +000029}
Ulrich Weigand5a02a022013-06-26 13:49:53 +000030def s17imm64 : Operand<i64> {
31 // This operand type is used for addis/lis to allow the assembler parser
32 // to accept immediates in the range -65536..65535 for compatibility with
33 // the GNU assembler. The operand is treated as 16-bit otherwise.
34 let PrintMethod = "printS16ImmOperand";
35 let EncoderMethod = "getImm16Encoding";
36 let ParserMatchClass = PPCS17ImmAsmOperand;
Hal Finkel23453472013-12-19 16:13:01 +000037 let DecoderMethod = "decodeSImmOperand<16>";
Ulrich Weigand5a02a022013-06-26 13:49:53 +000038}
Hal Finkelefe4a442012-09-05 19:22:27 +000039def tocentry : Operand<iPTR> {
Ulrich Weigandfd245442013-03-19 19:50:30 +000040 let MIOperandInfo = (ops i64imm:$imm);
Hal Finkelefe4a442012-09-05 19:22:27 +000041}
Bill Schmidtca4a0c92012-12-04 16:18:08 +000042def tlsreg : Operand<i64> {
43 let EncoderMethod = "getTLSRegEncoding";
Ulrich Weigand5b427592013-07-05 12:22:36 +000044 let ParserMatchClass = PPCTLSRegOperand;
Bill Schmidtca4a0c92012-12-04 16:18:08 +000045}
Bill Schmidtc56f1d32012-12-11 20:30:11 +000046def tlsgd : Operand<i64> {}
Ulrich Weigand5143bab2013-07-02 21:31:04 +000047def tlscall : Operand<i64> {
48 let PrintMethod = "printTLSCall";
49 let MIOperandInfo = (ops calltarget:$func, tlsgd:$sym);
50 let EncoderMethod = "getTLSCallEncoding";
51}
Chris Lattner2d4e8f72006-06-20 21:23:06 +000052
Chris Lattner52a956d2006-06-20 23:18:58 +000053//===----------------------------------------------------------------------===//
54// 64-bit transformation functions.
55//
Chris Lattner2d4e8f72006-06-20 21:23:06 +000056
Chris Lattner52a956d2006-06-20 23:18:58 +000057def SHL64 : SDNodeXForm<imm, [{
58 // Transformation function: 63 - imm
Dan Gohmaneffb8942008-09-12 16:56:44 +000059 return getI32Imm(63 - N->getZExtValue());
Chris Lattner52a956d2006-06-20 23:18:58 +000060}]>;
61
62def SRL64 : SDNodeXForm<imm, [{
63 // Transformation function: 64 - imm
Dan Gohmaneffb8942008-09-12 16:56:44 +000064 return N->getZExtValue() ? getI32Imm(64 - N->getZExtValue()) : getI32Imm(0);
Chris Lattner52a956d2006-06-20 23:18:58 +000065}]>;
66
67def HI32_48 : SDNodeXForm<imm, [{
68 // Transformation function: shift the immediate value down into the low bits.
Dan Gohmaneffb8942008-09-12 16:56:44 +000069 return getI32Imm((unsigned short)(N->getZExtValue() >> 32));
Chris Lattner52a956d2006-06-20 23:18:58 +000070}]>;
71
72def HI48_64 : SDNodeXForm<imm, [{
73 // Transformation function: shift the immediate value down into the low bits.
Dan Gohmaneffb8942008-09-12 16:56:44 +000074 return getI32Imm((unsigned short)(N->getZExtValue() >> 48));
Chris Lattner52a956d2006-06-20 23:18:58 +000075}]>;
Chris Lattner2d4e8f72006-06-20 21:23:06 +000076
Chris Lattnerb4299832006-06-16 20:22:01 +000077
78//===----------------------------------------------------------------------===//
Chris Lattner44dbdbe2006-11-14 18:44:47 +000079// Calls.
80//
81
Hal Finkelb4b99e52013-12-17 23:05:18 +000082let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand410a40b2013-03-26 10:53:03 +000083let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7 in {
Hal Finkel500b0042013-04-10 06:42:34 +000084 let isBranch = 1, isIndirectBranch = 1, Uses = [CTR8] in {
Hal Finkel3e5a3602013-11-27 23:26:09 +000085 def BCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
86 []>,
Ulrich Weigand410a40b2013-03-26 10:53:03 +000087 Requires<[In64BitMode]>;
Hal Finkel940ab932014-02-28 00:27:01 +000088 def BCCCTR8 : XLForm_2_br<19, 528, 0, (outs), (ins pred:$cond),
89 "b${cond:cc}ctr${cond:pm} ${cond:reg}", IIC_BrB,
90 []>,
91 Requires<[In64BitMode]>;
92
93 def BCCTR8 : XLForm_2_br2<19, 528, 12, 0, (outs), (ins crbitrc:$bi),
94 "bcctr 12, $bi, 0", IIC_BrB, []>,
95 Requires<[In64BitMode]>;
96 def BCCTR8n : XLForm_2_br2<19, 528, 4, 0, (outs), (ins crbitrc:$bi),
97 "bcctr 4, $bi, 0", IIC_BrB, []>,
Hal Finkel500b0042013-04-10 06:42:34 +000098 Requires<[In64BitMode]>;
99 }
Ulrich Weigand410a40b2013-03-26 10:53:03 +0000100}
101
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000102let Defs = [LR8] in
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000103 def MovePCtoLR8 : Pseudo<(outs), (ins), "#MovePCtoLR8", []>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000104 PPC970_Unit_BRU;
105
Ulrich Weigand410a40b2013-03-26 10:53:03 +0000106let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7 in {
107 let Defs = [CTR8], Uses = [CTR8] in {
108 def BDZ8 : BForm_1<16, 18, 0, 0, (outs), (ins condbrtarget:$dst),
109 "bdz $dst">;
110 def BDNZ8 : BForm_1<16, 16, 0, 0, (outs), (ins condbrtarget:$dst),
111 "bdnz $dst">;
112 }
Hal Finkel5711eca2013-04-09 22:58:37 +0000113
114 let isReturn = 1, Defs = [CTR8], Uses = [CTR8, LR8, RM] in {
115 def BDZLR8 : XLForm_2_ext<19, 16, 18, 0, 0, (outs), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000116 "bdzlr", IIC_BrB, []>;
Hal Finkel5711eca2013-04-09 22:58:37 +0000117 def BDNZLR8 : XLForm_2_ext<19, 16, 16, 0, 0, (outs), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000118 "bdnzlr", IIC_BrB, []>;
Hal Finkel5711eca2013-04-09 22:58:37 +0000119 }
Ulrich Weigand410a40b2013-03-26 10:53:03 +0000120}
121
Hal Finkel5711eca2013-04-09 22:58:37 +0000122
123
Roman Divackyef21be22012-03-06 16:41:49 +0000124let isCall = 1, PPC970_Unit = 7, Defs = [LR8] in {
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000125 // Convenient aliases for call instructions
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000126 let Uses = [RM] in {
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000127 def BL8 : IForm<18, 0, 1, (outs), (ins calltarget:$func),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000128 "bl $func", IIC_BrB, []>; // See Pat patterns below.
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000129
Ulrich Weigand42a09dc2013-07-02 21:31:59 +0000130 def BL8_TLS : IForm<18, 0, 1, (outs), (ins tlscall:$func),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000131 "bl $func", IIC_BrB, []>;
Ulrich Weigand42a09dc2013-07-02 21:31:59 +0000132
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000133 def BLA8 : IForm<18, 1, 1, (outs), (ins abscalltarget:$func),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000134 "bla $func", IIC_BrB, [(PPCcall (i64 imm:$func))]>;
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000135 }
136 let Uses = [RM], isCodeGenOnly = 1 in {
137 def BL8_NOP : IForm_and_DForm_4_zero<18, 0, 1, 24,
Jakob Stoklund Olesened6c0402012-07-13 20:44:29 +0000138 (outs), (ins calltarget:$func),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000139 "bl $func\n\tnop", IIC_BrB, []>;
Hal Finkel51861b42012-03-31 14:45:15 +0000140
Ulrich Weigand5143bab2013-07-02 21:31:04 +0000141 def BL8_NOP_TLS : IForm_and_DForm_4_zero<18, 0, 1, 24,
142 (outs), (ins tlscall:$func),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000143 "bl $func\n\tnop", IIC_BrB, []>;
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000144
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000145 def BLA8_NOP : IForm_and_DForm_4_zero<18, 1, 1, 24,
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000146 (outs), (ins abscalltarget:$func),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000147 "bla $func\n\tnop", IIC_BrB,
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000148 [(PPCcall_nop (i64 imm:$func))]>;
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000149 }
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000150 let Uses = [CTR8, RM] in {
151 def BCTRL8 : XLForm_2_ext<19, 528, 20, 0, 1, (outs), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000152 "bctrl", IIC_BrB, [(PPCbctrl)]>,
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000153 Requires<[In64BitMode]>;
Ulrich Weigandd0585d82013-04-17 17:19:05 +0000154
Hal Finkel940ab932014-02-28 00:27:01 +0000155 let isCodeGenOnly = 1 in {
156 def BCCCTRL8 : XLForm_2_br<19, 528, 1, (outs), (ins pred:$cond),
157 "b${cond:cc}ctrl${cond:pm} ${cond:reg}", IIC_BrB,
158 []>,
159 Requires<[In64BitMode]>;
160
161 def BCCTRL8 : XLForm_2_br2<19, 528, 12, 1, (outs), (ins crbitrc:$bi),
162 "bcctrl 12, $bi, 0", IIC_BrB, []>,
163 Requires<[In64BitMode]>;
164 def BCCTRL8n : XLForm_2_br2<19, 528, 4, 1, (outs), (ins crbitrc:$bi),
165 "bcctrl 4, $bi, 0", IIC_BrB, []>,
166 Requires<[In64BitMode]>;
167 }
Dale Johannesene395d782008-10-23 20:41:28 +0000168 }
Chris Lattner43df5b32007-02-25 05:34:32 +0000169}
Hal Finkelfc096c92014-12-23 22:29:40 +0000170
171let isCall = 1, PPC970_Unit = 7, isCodeGenOnly = 1,
172 Defs = [LR8, X2], Uses = [CTR8, RM], RST = 2 in {
173 def BCTRL8_LDinto_toc :
174 XLForm_2_ext_and_DSForm_1<19, 528, 20, 0, 1, 58, 0, (outs),
175 (ins memrix:$src),
176 "bctrl\n\tld 2, $src", IIC_BrB,
177 [(PPCbctrl_load_toc ixaddr:$src)]>,
178 Requires<[In64BitMode]>;
179}
180
Hal Finkel654d43b2013-04-12 02:18:09 +0000181} // Interpretation64Bit
Chris Lattner43df5b32007-02-25 05:34:32 +0000182
Hal Finkelb4b99e52013-12-17 23:05:18 +0000183// FIXME: Duplicating this for the asm parser should be unnecessary, but the
184// previous definition must be marked as CodeGen only to prevent decoding
185// conflicts.
186let Interpretation64Bit = 1, isAsmParserOnly = 1 in
187let isCall = 1, PPC970_Unit = 7, Defs = [LR8], Uses = [RM] in
188def BL8_TLS_ : IForm<18, 0, 1, (outs), (ins tlscall:$func),
189 "bl $func", IIC_BrB, []>;
190
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000191// Calls
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000192def : Pat<(PPCcall (i64 tglobaladdr:$dst)),
193 (BL8 tglobaladdr:$dst)>;
194def : Pat<(PPCcall_nop (i64 tglobaladdr:$dst)),
195 (BL8_NOP tglobaladdr:$dst)>;
Nicolas Geoffray89d81872007-02-27 13:01:19 +0000196
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000197def : Pat<(PPCcall (i64 texternalsym:$dst)),
198 (BL8 texternalsym:$dst)>;
199def : Pat<(PPCcall_nop (i64 texternalsym:$dst)),
200 (BL8_NOP texternalsym:$dst)>;
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000201
Bill Schmidt3d9674c2014-11-11 20:44:09 +0000202def : Pat<(PPCcall_nop_tls texternalsym:$func, tglobaltlsaddr:$sym),
203 (BL8_NOP_TLS texternalsym:$func, tglobaltlsaddr:$sym)>;
204
Evan Cheng32e376f2008-07-12 02:23:19 +0000205// Atomic operations
Dan Gohman453d64c2009-10-29 18:10:34 +0000206let usesCustomInserter = 1 in {
Jakob Stoklund Olesen86e1a652011-04-04 17:07:09 +0000207 let Defs = [CR0] in {
Evan Cheng32e376f2008-07-12 02:23:19 +0000208 def ATOMIC_LOAD_ADD_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000209 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000210 [(set i64:$dst, (atomic_load_add_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000211 def ATOMIC_LOAD_SUB_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000212 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000213 [(set i64:$dst, (atomic_load_sub_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000214 def ATOMIC_LOAD_OR_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000215 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000216 [(set i64:$dst, (atomic_load_or_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000217 def ATOMIC_LOAD_XOR_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000218 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000219 [(set i64:$dst, (atomic_load_xor_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000220 def ATOMIC_LOAD_AND_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000221 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000222 [(set i64:$dst, (atomic_load_and_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000223 def ATOMIC_LOAD_NAND_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000224 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000225 [(set i64:$dst, (atomic_load_nand_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000226
Dale Johannesendec51702008-08-22 03:49:10 +0000227 def ATOMIC_CMP_SWAP_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000228 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000229 [(set i64:$dst, (atomic_cmp_swap_64 xoaddr:$ptr, i64:$old, i64:$new))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000230
Dale Johannesen765065c2008-08-25 21:09:52 +0000231 def ATOMIC_SWAP_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000232 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000233 [(set i64:$dst, (atomic_swap_64 xoaddr:$ptr, i64:$new))]>;
Dale Johannesendec51702008-08-22 03:49:10 +0000234 }
Evan Cheng5102bd92008-04-19 02:30:38 +0000235}
236
Evan Cheng32e376f2008-07-12 02:23:19 +0000237// Instructions to support atomic operations
Ulrich Weigand136ac222013-04-26 16:53:15 +0000238def LDARX : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000239 "ldarx $rD, $ptr", IIC_LdStLDARX,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000240 [(set i64:$rD, (PPClarx xoaddr:$ptr))]>;
Evan Cheng32e376f2008-07-12 02:23:19 +0000241
242let Defs = [CR0] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000243def STDCX : XForm_1<31, 214, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000244 "stdcx. $rS, $dst", IIC_LdStSTDCX,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000245 [(PPCstcx i64:$rS, xoaddr:$dst)]>,
Evan Cheng32e376f2008-07-12 02:23:19 +0000246 isDOT;
247
Hal Finkelb4b99e52013-12-17 23:05:18 +0000248let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000249let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000250def TCRETURNdi8 :Pseudo< (outs),
Jakob Stoklund Olesened6c0402012-07-13 20:44:29 +0000251 (ins calltarget:$dst, i32imm:$offset),
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000252 "#TC_RETURNd8 $dst $offset",
253 []>;
254
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000255let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000256def TCRETURNai8 :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000257 "#TC_RETURNa8 $func $offset",
258 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
259
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000260let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
Jakob Stoklund Olesened6c0402012-07-13 20:44:29 +0000261def TCRETURNri8 : Pseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset),
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000262 "#TC_RETURNr8 $dst $offset",
263 []>;
264
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000265let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
Ulrich Weigand410a40b2013-03-26 10:53:03 +0000266 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in
Hal Finkel3e5a3602013-11-27 23:26:09 +0000267def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
268 []>,
Ulrich Weigand410a40b2013-03-26 10:53:03 +0000269 Requires<[In64BitMode]>;
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000270
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000271let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000272 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000273def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000274 "b $dst", IIC_BrB,
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000275 []>;
276
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000277let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000278 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000279def TAILBA8 : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000280 "ba $dst", IIC_BrB,
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000281 []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000282} // Interpretation64Bit
Ulrich Weigandbbfb0c52013-03-26 10:57:16 +0000283
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000284def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
285 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
286
287def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
288 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
289
290def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
291 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
292
Hal Finkel96c2d4d2012-06-08 15:38:21 +0000293
Hal Finkel25aab012013-03-28 03:38:08 +0000294// 64-bit CR instructions
Hal Finkelb4b99e52013-12-17 23:05:18 +0000295let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Craig Topperc50d64b2014-11-26 00:46:26 +0000296let hasSideEffects = 0 in {
Ulrich Weigand49f487e2013-07-03 17:59:07 +0000297def MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$ST),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000298 "mtocrf $FXM, $ST", IIC_BrMCRX>,
Ulrich Weigand49f487e2013-07-03 17:59:07 +0000299 PPC970_DGroup_First, PPC970_Unit_CRU;
300
301def MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000302 "mtcrf $FXM, $rS", IIC_BrMCRX>,
Hal Finkelac9df3d2011-12-07 06:34:06 +0000303 PPC970_MicroCode, PPC970_Unit_CRU;
304
Hal Finkel7fe6a532013-09-12 05:24:49 +0000305let hasExtraSrcRegAllocReq = 1 in // to enable post-ra anti-dep breaking.
Ulrich Weigandd5ebc622013-07-03 17:05:42 +0000306def MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$rT), (ins crbitm:$FXM),
Hal Finkel46402a42013-11-30 20:41:13 +0000307 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
Ulrich Weigandd5ebc622013-07-03 17:05:42 +0000308 PPC970_DGroup_First, PPC970_Unit_CRU;
Hal Finkelb47a69a2013-04-07 14:33:13 +0000309
Ulrich Weigand136ac222013-04-26 16:53:15 +0000310def MFCR8 : XFXForm_3<31, 19, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000311 "mfcr $rT", IIC_SprMFCR>,
Hal Finkelac9df3d2011-12-07 06:34:06 +0000312 PPC970_MicroCode, PPC970_Unit_CRU;
Craig Topperc50d64b2014-11-26 00:46:26 +0000313} // hasSideEffects = 0
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000314
Ulrich Weigandbbfb0c52013-03-26 10:57:16 +0000315let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
Hal Finkel40f76d52013-07-17 05:35:44 +0000316 let Defs = [CTR8] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000317 def EH_SjLj_SetJmp64 : Pseudo<(outs gprc:$dst), (ins memr:$buf),
Hal Finkel756810f2013-03-21 21:37:52 +0000318 "#EH_SJLJ_SETJMP64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000319 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
Hal Finkel756810f2013-03-21 21:37:52 +0000320 Requires<[In64BitMode]>;
321 let isTerminator = 1 in
322 def EH_SjLj_LongJmp64 : Pseudo<(outs), (ins memr:$buf),
323 "#EH_SJLJ_LONGJMP64",
324 [(PPCeh_sjlj_longjmp addr:$buf)]>,
325 Requires<[In64BitMode]>;
326}
327
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000328//===----------------------------------------------------------------------===//
329// 64-bit SPR manipulation instrs.
330
Dale Johannesene395d782008-10-23 20:41:28 +0000331let Uses = [CTR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000332def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000333 "mfctr $rT", IIC_SprMFSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000334 PPC970_DGroup_First, PPC970_Unit_FXU;
Dale Johannesene395d782008-10-23 20:41:28 +0000335}
Ulrich Weigandc8868102013-03-25 19:05:30 +0000336let Pattern = [(PPCmtctr i64:$rS)], Defs = [CTR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000337def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000338 "mtctr $rS", IIC_SprMTSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000339 PPC970_DGroup_First, PPC970_Unit_FXU;
Chris Lattner3b587342006-06-27 18:36:44 +0000340}
Hal Finkelb4b99e52013-12-17 23:05:18 +0000341let hasSideEffects = 1, Defs = [CTR8] in {
Hal Finkel25c19922013-05-15 21:37:41 +0000342let Pattern = [(int_ppc_mtctr i64:$rS)] in
Hal Finkel0859ef22013-05-20 16:08:37 +0000343def MTCTR8loop : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000344 "mtctr $rS", IIC_SprMTSPR>,
Hal Finkel0859ef22013-05-20 16:08:37 +0000345 PPC970_DGroup_First, PPC970_Unit_FXU;
Hal Finkel25c19922013-05-15 21:37:41 +0000346}
Chris Lattnerd48ce272006-06-27 18:18:41 +0000347
Hal Finkelb4b99e52013-12-17 23:05:18 +0000348let Pattern = [(set i64:$rT, readcyclecounter)] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000349def MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000350 "mfspr $rT, 268", IIC_SprMFTB>,
Hal Finkel70381a72012-08-04 14:10:46 +0000351 PPC970_DGroup_First, PPC970_Unit_FXU;
Hal Finkel895a5f52012-08-07 17:04:20 +0000352// Note that encoding mftb using mfspr is now the preferred form,
353// and has been since at least ISA v2.03. The mftb instruction has
354// now been phased out. Using mfspr, however, is known not to work on
355// the POWER3.
Hal Finkel70381a72012-08-04 14:10:46 +0000356
Evan Cheng3e18e502007-09-11 19:55:27 +0000357let Defs = [X1], Uses = [X1] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000358def DYNALLOC8 : Pseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000359 [(set i64:$result,
360 (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>;
Jim Laskey48850c12006-11-16 22:43:37 +0000361
Dale Johannesene395d782008-10-23 20:41:28 +0000362let Defs = [LR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000363def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000364 "mtlr $rS", IIC_SprMTSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000365 PPC970_DGroup_First, PPC970_Unit_FXU;
Dale Johannesene395d782008-10-23 20:41:28 +0000366}
367let Uses = [LR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000368def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000369 "mflr $rT", IIC_SprMFSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000370 PPC970_DGroup_First, PPC970_Unit_FXU;
Dale Johannesene395d782008-10-23 20:41:28 +0000371}
Hal Finkel654d43b2013-04-12 02:18:09 +0000372} // Interpretation64Bit
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000373
Chris Lattnerd48ce272006-06-27 18:18:41 +0000374//===----------------------------------------------------------------------===//
Chris Lattnerb4299832006-06-16 20:22:01 +0000375// Fixed point instructions.
376//
377
378let PPC970_Unit = 1 in { // FXU Operations.
Hal Finkel654d43b2013-04-12 02:18:09 +0000379let Interpretation64Bit = 1 in {
Craig Topperc50d64b2014-11-26 00:46:26 +0000380let hasSideEffects = 0 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000381let isCodeGenOnly = 1 in {
Chris Lattnerb4299832006-06-16 20:22:01 +0000382
Hal Finkel686f2ee2012-08-28 02:10:33 +0000383let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
Ulrich Weigand99485462013-05-23 22:48:06 +0000384def LI8 : DForm_2_r0<14, (outs g8rc:$rD), (ins s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000385 "li $rD, $imm", IIC_IntSimple,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000386 [(set i64:$rD, imm64SExt16:$imm)]>;
Ulrich Weigand5a02a022013-06-26 13:49:53 +0000387def LIS8 : DForm_2_r0<15, (outs g8rc:$rD), (ins s17imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000388 "lis $rD, $imm", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000389 [(set i64:$rD, imm16ShiftedSExt:$imm)]>;
Hal Finkel686f2ee2012-08-28 02:10:33 +0000390}
Chris Lattner7e742e42006-06-20 22:34:10 +0000391
392// Logical ops.
Hal Finkele01d3212014-03-24 15:07:28 +0000393let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000394defm NAND8: XForm_6r<31, 476, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000395 "nand", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000396 [(set i64:$rA, (not (and i64:$rS, i64:$rB)))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000397defm AND8 : XForm_6r<31, 28, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000398 "and", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000399 [(set i64:$rA, (and i64:$rS, i64:$rB))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000400} // isCommutable
Ulrich Weigand136ac222013-04-26 16:53:15 +0000401defm ANDC8: XForm_6r<31, 60, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000402 "andc", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000403 [(set i64:$rA, (and i64:$rS, (not i64:$rB)))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000404let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000405defm OR8 : XForm_6r<31, 444, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000406 "or", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000407 [(set i64:$rA, (or i64:$rS, i64:$rB))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000408defm NOR8 : XForm_6r<31, 124, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000409 "nor", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000410 [(set i64:$rA, (not (or i64:$rS, i64:$rB)))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000411} // isCommutable
Ulrich Weigand136ac222013-04-26 16:53:15 +0000412defm ORC8 : XForm_6r<31, 412, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000413 "orc", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000414 [(set i64:$rA, (or i64:$rS, (not i64:$rB)))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000415let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000416defm EQV8 : XForm_6r<31, 284, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000417 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000418 [(set i64:$rA, (not (xor i64:$rS, i64:$rB)))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000419defm XOR8 : XForm_6r<31, 316, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000420 "xor", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000421 [(set i64:$rA, (xor i64:$rS, i64:$rB))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000422} // let isCommutable = 1
Chris Lattner9d65f352006-06-20 23:11:59 +0000423
424// Logical ops with immediate.
Hal Finkel1b58f332013-04-12 18:17:57 +0000425let Defs = [CR0] in {
Hal Finkel77c8dc12014-01-02 21:26:59 +0000426def ANDIo8 : DForm_4<28, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000427 "andi. $dst, $src1, $src2", IIC_IntGeneral,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000428 [(set i64:$dst, (and i64:$src1, immZExt16:$src2))]>,
Chris Lattner7e742e42006-06-20 22:34:10 +0000429 isDOT;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000430def ANDISo8 : DForm_4<29, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000431 "andis. $dst, $src1, $src2", IIC_IntGeneral,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000432 [(set i64:$dst, (and i64:$src1, imm16ShiftedZExt:$src2))]>,
Chris Lattner7e742e42006-06-20 22:34:10 +0000433 isDOT;
Hal Finkel1b58f332013-04-12 18:17:57 +0000434}
Hal Finkel77c8dc12014-01-02 21:26:59 +0000435def ORI8 : DForm_4<24, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000436 "ori $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000437 [(set i64:$dst, (or i64:$src1, immZExt16:$src2))]>;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000438def ORIS8 : DForm_4<25, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000439 "oris $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000440 [(set i64:$dst, (or i64:$src1, imm16ShiftedZExt:$src2))]>;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000441def XORI8 : DForm_4<26, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000442 "xori $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000443 [(set i64:$dst, (xor i64:$src1, immZExt16:$src2))]>;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000444def XORIS8 : DForm_4<27, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000445 "xoris $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000446 [(set i64:$dst, (xor i64:$src1, imm16ShiftedZExt:$src2))]>;
Chris Lattner7e742e42006-06-20 22:34:10 +0000447
Hal Finkele01d3212014-03-24 15:07:28 +0000448let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000449defm ADD8 : XOForm_1r<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000450 "add", "$rT, $rA, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000451 [(set i64:$rT, (add i64:$rA, i64:$rB))]>;
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000452// ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the
453// initial-exec thread-local storage model.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000454def ADD8TLS : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000455 "add $rT, $rA, $rB", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000456 [(set i64:$rT, (add i64:$rA, tglobaltlsaddr:$rB))]>;
Chris Lattner3e549e92007-05-17 06:52:46 +0000457
Hal Finkele01d3212014-03-24 15:07:28 +0000458let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000459defm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000460 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000461 [(set i64:$rT, (addc i64:$rA, i64:$rB))]>,
462 PPC970_DGroup_Cracked;
Hal Finkele01d3212014-03-24 15:07:28 +0000463
Hal Finkel1b58f332013-04-12 18:17:57 +0000464let Defs = [CARRY] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000465def ADDIC8 : DForm_2<12, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000466 "addic $rD, $rA, $imm", IIC_IntGeneral,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000467 [(set i64:$rD, (addc i64:$rA, imm64SExt16:$imm))]>;
Ulrich Weigand99485462013-05-23 22:48:06 +0000468def ADDI8 : DForm_2<14, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000469 "addi $rD, $rA, $imm", IIC_IntSimple,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000470 [(set i64:$rD, (add i64:$rA, imm64SExt16:$imm))]>;
Ulrich Weigand5a02a022013-06-26 13:49:53 +0000471def ADDIS8 : DForm_2<15, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s17imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000472 "addis $rD, $rA, $imm", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000473 [(set i64:$rD, (add i64:$rA, imm16ShiftedSExt:$imm))]>;
Chris Lattner7e742e42006-06-20 22:34:10 +0000474
Dale Johannesen5e9a5c32009-09-18 20:15:22 +0000475let Defs = [CARRY] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000476def SUBFIC8: DForm_2< 8, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000477 "subfic $rD, $rA, $imm", IIC_IntGeneral,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000478 [(set i64:$rD, (subc imm64SExt16:$imm, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000479defm SUBFC8 : XOForm_1r<31, 8, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000480 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000481 [(set i64:$rT, (subc i64:$rB, i64:$rA))]>,
482 PPC970_DGroup_Cracked;
Dale Johannesen5e9a5c32009-09-18 20:15:22 +0000483}
Ulrich Weigand136ac222013-04-26 16:53:15 +0000484defm SUBF8 : XOForm_1r<31, 40, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000485 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000486 [(set i64:$rT, (sub i64:$rB, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000487defm NEG8 : XOForm_3r<31, 104, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000488 "neg", "$rT, $rA", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000489 [(set i64:$rT, (ineg i64:$rA))]>;
Hal Finkel1b58f332013-04-12 18:17:57 +0000490let Uses = [CARRY] in {
Hal Finkele01d3212014-03-24 15:07:28 +0000491let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000492defm ADDE8 : XOForm_1rc<31, 138, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000493 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000494 [(set i64:$rT, (adde i64:$rA, i64:$rB))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000495defm ADDME8 : XOForm_3rc<31, 234, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000496 "addme", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000497 [(set i64:$rT, (adde i64:$rA, -1))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000498defm ADDZE8 : XOForm_3rc<31, 202, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000499 "addze", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000500 [(set i64:$rT, (adde i64:$rA, 0))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000501defm SUBFE8 : XOForm_1rc<31, 136, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000502 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000503 [(set i64:$rT, (sube i64:$rB, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000504defm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000505 "subfme", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000506 [(set i64:$rT, (sube -1, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000507defm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000508 "subfze", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000509 [(set i64:$rT, (sube 0, i64:$rA))]>;
Dale Johannesen5e9a5c32009-09-18 20:15:22 +0000510}
Hal Finkelb4b99e52013-12-17 23:05:18 +0000511} // isCodeGenOnly
Chris Lattner3e549e92007-05-17 06:52:46 +0000512
Hal Finkelb4b99e52013-12-17 23:05:18 +0000513// FIXME: Duplicating this for the asm parser should be unnecessary, but the
514// previous definition must be marked as CodeGen only to prevent decoding
515// conflicts.
516let isAsmParserOnly = 1 in
517def ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
518 "add $rT, $rA, $rB", IIC_IntSimple, []>;
Chris Lattner2d4e8f72006-06-20 21:23:06 +0000519
Hal Finkele01d3212014-03-24 15:07:28 +0000520let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000521defm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000522 "mulhd", "$rT, $rA, $rB", IIC_IntMulHW,
Hal Finkel654d43b2013-04-12 02:18:09 +0000523 [(set i64:$rT, (mulhs i64:$rA, i64:$rB))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000524defm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000525 "mulhdu", "$rT, $rA, $rB", IIC_IntMulHWU,
Hal Finkel654d43b2013-04-12 02:18:09 +0000526 [(set i64:$rT, (mulhu i64:$rA, i64:$rB))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000527} // isCommutable
Hal Finkel654d43b2013-04-12 02:18:09 +0000528}
529} // Interpretation64Bit
Chris Lattnerb4299832006-06-16 20:22:01 +0000530
Craig Topperc50d64b2014-11-26 00:46:26 +0000531let isCompare = 1, hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000532 def CMPD : XForm_16_ext<31, 0, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000533 "cmpd $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000534 def CMPLD : XForm_16_ext<31, 32, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000535 "cmpld $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000536 def CMPDI : DForm_5_ext<11, (outs crrc:$crD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000537 "cmpdi $crD, $rA, $imm", IIC_IntCompare>, isPPC64;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000538 def CMPLDI : DForm_6_ext<10, (outs crrc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000539 "cmpldi $dst, $src1, $src2",
540 IIC_IntCompare>, isPPC64;
Hal Finkel95e6ea62013-04-15 02:37:46 +0000541}
Chris Lattnerb4299832006-06-16 20:22:01 +0000542
Craig Topperc50d64b2014-11-26 00:46:26 +0000543let hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000544defm SLD : XForm_6r<31, 27, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000545 "sld", "$rA, $rS, $rB", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000546 [(set i64:$rA, (PPCshl i64:$rS, i32:$rB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000547defm SRD : XForm_6r<31, 539, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000548 "srd", "$rA, $rS, $rB", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000549 [(set i64:$rA, (PPCsrl i64:$rS, i32:$rB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000550defm SRAD : XForm_6rc<31, 794, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000551 "srad", "$rA, $rS, $rB", IIC_IntRotateD,
Hal Finkel1b58f332013-04-12 18:17:57 +0000552 [(set i64:$rA, (PPCsra i64:$rS, i32:$rB))]>, isPPC64;
Chris Lattner43c0eb82006-12-06 21:46:13 +0000553
Hal Finkel49557f12015-01-05 18:52:29 +0000554let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
555defm CNTLZW8 : XForm_11r<31, 26, (outs g8rc:$rA), (ins g8rc:$rS),
556 "cntlzw", "$rA, $rS", IIC_IntGeneral, []>;
557
Ulrich Weigand136ac222013-04-26 16:53:15 +0000558defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000559 "extsb", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000560 [(set i64:$rA, (sext_inreg i64:$rS, i8))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000561defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000562 "extsh", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000563 [(set i64:$rA, (sext_inreg i64:$rS, i16))]>;
Hal Finkel4c6658f2014-12-12 23:59:36 +0000564
565defm SLW8 : XForm_6r<31, 24, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
566 "slw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
567defm SRW8 : XForm_6r<31, 536, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
568 "srw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000569} // Interpretation64Bit
570
Bill Schmidtd89f6782013-08-26 19:42:51 +0000571// For fast-isel:
572let isCodeGenOnly = 1 in {
573def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000574 "extsb $rA, $rS", IIC_IntSimple, []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000575def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000576 "extsh $rA, $rS", IIC_IntSimple, []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000577} // isCodeGenOnly for fast-isel
578
Ulrich Weigand136ac222013-04-26 16:53:15 +0000579defm EXTSW : XForm_11r<31, 986, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000580 "extsw", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000581 [(set i64:$rA, (sext_inreg i64:$rS, i32))]>, isPPC64;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000582let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000583defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000584 "extsw", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000585 [(set i64:$rA, (sext i32:$rS))]>, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +0000586
Ulrich Weigand136ac222013-04-26 16:53:15 +0000587defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000588 "sradi", "$rA, $rS, $SH", IIC_IntRotateDI,
Hal Finkel1b58f332013-04-12 18:17:57 +0000589 [(set i64:$rA, (sra i64:$rS, (i32 imm:$SH)))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000590defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000591 "cntlzd", "$rA, $rS", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000592 [(set i64:$rA, (ctlz i64:$rS))]>;
Hal Finkel884bde302013-11-20 20:54:55 +0000593def POPCNTD : XForm_11<31, 506, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000594 "popcntd $rA, $rS", IIC_IntGeneral,
Hal Finkel884bde302013-11-20 20:54:55 +0000595 [(set i64:$rA, (ctpop i64:$rS))]>;
Chris Lattner88102412007-03-25 04:44:03 +0000596
Hal Finkel4edc66b2015-01-03 01:16:37 +0000597let isCodeGenOnly = 1, isCommutable = 1 in
598def CMPB8 : XForm_6<31, 508, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
599 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
600 [(set i64:$rA, (PPCcmpb i64:$rS, i64:$rB))]>;
601
Hal Finkel290376d2013-04-01 15:58:15 +0000602// popcntw also does a population count on the high 32 bits (storing the
603// results in the high 32-bits of the output). We'll ignore that here (which is
604// safe because we never separately use the high part of the 64-bit registers).
Hal Finkel884bde302013-11-20 20:54:55 +0000605def POPCNTW : XForm_11<31, 378, (outs gprc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000606 "popcntw $rA, $rS", IIC_IntGeneral,
Hal Finkel884bde302013-11-20 20:54:55 +0000607 [(set i32:$rA, (ctpop i32:$rS))]>;
Hal Finkel290376d2013-04-01 15:58:15 +0000608
Ulrich Weigand136ac222013-04-26 16:53:15 +0000609defm DIVD : XOForm_1r<31, 489, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000610 "divd", "$rT, $rA, $rB", IIC_IntDivD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000611 [(set i64:$rT, (sdiv i64:$rA, i64:$rB))]>, isPPC64,
612 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000613defm DIVDU : XOForm_1r<31, 457, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000614 "divdu", "$rT, $rA, $rB", IIC_IntDivD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000615 [(set i64:$rT, (udiv i64:$rA, i64:$rB))]>, isPPC64,
616 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Hal Finkele01d3212014-03-24 15:07:28 +0000617let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000618defm MULLD : XOForm_1r<31, 233, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000619 "mulld", "$rT, $rA, $rB", IIC_IntMulHD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000620 [(set i64:$rT, (mul i64:$rA, i64:$rB))]>, isPPC64;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000621let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Hal Finkel11b9e4522013-08-06 17:03:03 +0000622def MULLI8 : DForm_2<7, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000623 "mulli $rD, $rA, $imm", IIC_IntMulLI,
Hal Finkel11b9e4522013-08-06 17:03:03 +0000624 [(set i64:$rD, (mul i64:$rA, imm64SExt16:$imm))]>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000625}
Chris Lattner7ecbd302006-06-26 23:53:10 +0000626
Craig Topperc50d64b2014-11-26 00:46:26 +0000627let hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000628defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$rA),
629 (ins g8rc:$rSi, g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000630 "rldimi", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000631 []>, isPPC64, RegConstraint<"$rSi = $rA">,
632 NoEncode<"$rSi">;
Chris Lattnerb4299832006-06-16 20:22:01 +0000633
634// Rotate instructions.
Ulrich Weigandfa451ba2013-04-26 15:39:12 +0000635defm RLDCL : MDSForm_1r<30, 8,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000636 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000637 "rldcl", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000638 []>, isPPC64;
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000639defm RLDCR : MDSForm_1r<30, 9,
640 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000641 "rldcr", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000642 []>, isPPC64;
Hal Finkel654d43b2013-04-12 02:18:09 +0000643defm RLDICL : MDForm_1r<30, 0,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000644 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000645 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000646 []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000647// For fast-isel:
648let isCodeGenOnly = 1 in
649def RLDICL_32_64 : MDForm_1<30, 0,
650 (outs g8rc:$rA),
651 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000652 "rldicl $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Bill Schmidtd89f6782013-08-26 19:42:51 +0000653 []>, isPPC64;
654// End fast-isel.
Hal Finkel654d43b2013-04-12 02:18:09 +0000655defm RLDICR : MDForm_1r<30, 1,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000656 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000657 "rldicr", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000658 []>, isPPC64;
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000659defm RLDIC : MDForm_1r<30, 2,
660 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000661 "rldic", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000662 []>, isPPC64;
Hal Finkelac9df3d2011-12-07 06:34:06 +0000663
Hal Finkelb4b99e52013-12-17 23:05:18 +0000664let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000665defm RLWINM8 : MForm_2r<21, (outs g8rc:$rA),
666 (ins g8rc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000667 "rlwinm", "$rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000668 []>;
Hal Finkelac9df3d2011-12-07 06:34:06 +0000669
Hal Finkel4c6658f2014-12-12 23:59:36 +0000670defm RLWNM8 : MForm_2r<23, (outs g8rc:$rA),
671 (ins g8rc:$rS, g8rc:$rB, u5imm:$MB, u5imm:$ME),
672 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
673 []>;
674
Hal Finkel940ab932014-02-28 00:27:01 +0000675// RLWIMI can be commuted if the rotate amount is zero.
676let Interpretation64Bit = 1, isCodeGenOnly = 1 in
677defm RLWIMI8 : MForm_2r<20, (outs g8rc:$rA),
678 (ins g8rc:$rSi, g8rc:$rS, u5imm:$SH, u5imm:$MB,
679 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
680 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
681 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
Hal Finkel940ab932014-02-28 00:27:01 +0000682
Hal Finkel7795e472013-04-07 15:06:53 +0000683let isSelect = 1 in
Ulrich Weigand84ee76a2012-11-13 19:14:19 +0000684def ISEL8 : AForm_4<31, 15,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000685 (outs g8rc:$rT), (ins g8rc_nox0:$rA, g8rc:$rB, crbitrc:$cond),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000686 "isel $rT, $rA, $rB, $cond", IIC_IntGeneral,
Hal Finkel460e94d2012-06-22 23:10:08 +0000687 []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000688} // Interpretation64Bit
Craig Topperc50d64b2014-11-26 00:46:26 +0000689} // hasSideEffects = 0
Chris Lattner7ecbd302006-06-26 23:53:10 +0000690} // End FXU Operations.
Chris Lattnerb4299832006-06-16 20:22:01 +0000691
692
693//===----------------------------------------------------------------------===//
694// Load/Store instructions.
695//
696
697
Chris Lattner96aecb52006-07-14 04:42:02 +0000698// Sign extending loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000699let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000700let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000701def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000702 "lha $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000703 [(set i64:$rD, (sextloadi16 iaddr:$src))]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000704 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000705def LWA : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000706 "lwa $rD, $src", IIC_LdStLWA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000707 [(set i64:$rD,
Hal Finkelb09680b2013-03-18 23:00:58 +0000708 (aligned4sextloadi32 ixaddr:$src))]>, isPPC64,
Chris Lattner94d18df2006-06-20 00:38:36 +0000709 PPC970_DGroup_Cracked;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000710let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000711def LHAX8: XForm_1<31, 343, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000712 "lhax $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000713 [(set i64:$rD, (sextloadi16 xaddr:$src))]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000714 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000715def LWAX : XForm_1<31, 341, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000716 "lwax $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000717 [(set i64:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
Chris Lattnerb4299832006-06-16 20:22:01 +0000718 PPC970_DGroup_Cracked;
Bill Schmidtccecf262013-08-30 02:29:45 +0000719// For fast-isel:
720let isCodeGenOnly = 1, mayLoad = 1 in {
721def LWA_32 : DSForm_1<58, 2, (outs gprc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000722 "lwa $rD, $src", IIC_LdStLWA, []>, isPPC64,
Bill Schmidtccecf262013-08-30 02:29:45 +0000723 PPC970_DGroup_Cracked;
724def LWAX_32 : XForm_1<31, 341, (outs gprc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000725 "lwax $rD, $src", IIC_LdStLHA, []>, isPPC64,
Bill Schmidtccecf262013-08-30 02:29:45 +0000726 PPC970_DGroup_Cracked;
727} // end fast-isel isCodeGenOnly
Chris Lattner96aecb52006-07-14 04:42:02 +0000728
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000729// Update forms.
Craig Topperc50d64b2014-11-26 00:46:26 +0000730let mayLoad = 1, hasSideEffects = 0 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000731let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000732def LHAU8 : DForm_1<43, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Ulrich Weigandf8030092013-03-19 19:52:30 +0000733 (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000734 "lhau $rD, $addr", IIC_LdStLHAU,
Ulrich Weigandf8030092013-03-19 19:52:30 +0000735 []>, RegConstraint<"$addr.reg = $ea_result">,
Chris Lattner57711562006-11-15 23:24:18 +0000736 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000737// NO LWAU!
738
Hal Finkelb4b99e52013-12-17 23:05:18 +0000739let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000740def LHAUX8 : XForm_1<31, 375, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000741 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000742 "lhaux $rD, $addr", IIC_LdStLHAUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000743 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000744 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000745def LWAUX : XForm_1<31, 373, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000746 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000747 "lwaux $rD, $addr", IIC_LdStLHAUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000748 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000749 NoEncode<"$ea_result">, isPPC64;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000750}
Ulrich Weigand01dd4c12013-03-19 19:53:27 +0000751}
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000752
Hal Finkelb4b99e52013-12-17 23:05:18 +0000753let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Chris Lattner96aecb52006-07-14 04:42:02 +0000754// Zero extending loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000755let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000756def LBZ8 : DForm_1<34, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000757 "lbz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000758 [(set i64:$rD, (zextloadi8 iaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000759def LHZ8 : DForm_1<40, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000760 "lhz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000761 [(set i64:$rD, (zextloadi16 iaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000762def LWZ8 : DForm_1<32, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000763 "lwz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000764 [(set i64:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
Chris Lattner96aecb52006-07-14 04:42:02 +0000765
Ulrich Weigand136ac222013-04-26 16:53:15 +0000766def LBZX8 : XForm_1<31, 87, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000767 "lbzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000768 [(set i64:$rD, (zextloadi8 xaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000769def LHZX8 : XForm_1<31, 279, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000770 "lhzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000771 [(set i64:$rD, (zextloadi16 xaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000772def LWZX8 : XForm_1<31, 23, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000773 "lwzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000774 [(set i64:$rD, (zextloadi32 xaddr:$src))]>;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000775
776
777// Update forms.
Craig Topperc50d64b2014-11-26 00:46:26 +0000778let mayLoad = 1, hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000779def LBZU8 : DForm_1<35, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000780 "lbzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000781 []>, RegConstraint<"$addr.reg = $ea_result">,
782 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000783def LHZU8 : DForm_1<41, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000784 "lhzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000785 []>, RegConstraint<"$addr.reg = $ea_result">,
786 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000787def LWZU8 : DForm_1<33, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000788 "lwzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000789 []>, RegConstraint<"$addr.reg = $ea_result">,
790 NoEncode<"$ea_result">;
Hal Finkelca542be2012-06-20 15:43:03 +0000791
Ulrich Weigand136ac222013-04-26 16:53:15 +0000792def LBZUX8 : XForm_1<31, 119, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000793 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000794 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000795 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000796 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000797def LHZUX8 : XForm_1<31, 311, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000798 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000799 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000800 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000801 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000802def LWZUX8 : XForm_1<31, 55, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000803 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000804 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000805 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000806 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000807}
Dan Gohmanae3ba452008-12-03 02:30:17 +0000808}
Hal Finkel654d43b2013-04-12 02:18:09 +0000809} // Interpretation64Bit
Chris Lattner96aecb52006-07-14 04:42:02 +0000810
811
812// Full 8-byte loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000813let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000814def LD : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000815 "ld $rD, $src", IIC_LdStLD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000816 [(set i64:$rD, (aligned4load ixaddr:$src))]>, isPPC64;
Ulrich Weigandc8c2ea22014-10-31 10:33:14 +0000817// The following four definitions are selected for small code model only.
Bill Schmidt34627e32012-11-27 17:35:46 +0000818// Otherwise, we need to create two instructions to form a 32-bit offset,
819// so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
Ulrich Weigand136ac222013-04-26 16:53:15 +0000820def LDtoc: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000821 "#LDtoc",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000822 [(set i64:$rD,
823 (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000824def LDtocJTI: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000825 "#LDtocJTI",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000826 [(set i64:$rD,
827 (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000828def LDtocCPT: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000829 "#LDtocCPT",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000830 [(set i64:$rD,
831 (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigandc8c2ea22014-10-31 10:33:14 +0000832def LDtocBA: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
833 "#LDtocCPT",
834 [(set i64:$rD,
835 (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64;
Hal Finkela3e6ed22012-02-24 17:54:01 +0000836
Bill Schmidt3755e172014-08-15 01:25:26 +0000837let hasSideEffects = 1, isCodeGenOnly = 1, RST = 2, Defs = [X2] in
Ulrich Weigandad0cb912014-06-18 17:52:49 +0000838def LDinto_toc: DSForm_1<58, 0, (outs), (ins memrix:$src),
839 "ld 2, $src", IIC_LdStLD,
840 [(PPCload_toc ixaddr:$src)]>, isPPC64;
841
Ulrich Weigand136ac222013-04-26 16:53:15 +0000842def LDX : XForm_1<31, 21, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000843 "ldx $rD, $src", IIC_LdStLD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000844 [(set i64:$rD, (load xaddr:$src))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000845def LDBRX : XForm_1<31, 532, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000846 "ldbrx $rD, $src", IIC_LdStLoad,
Hal Finkel31d29562013-03-28 19:25:55 +0000847 [(set i64:$rD, (PPClbrx xoaddr:$src, i64))]>, isPPC64;
848
Hal Finkel4e2c7822015-01-05 18:09:06 +0000849let mayLoad = 1, hasSideEffects = 0, isCodeGenOnly = 1 in {
850def LHBRX8 : XForm_1<31, 790, (outs g8rc:$rD), (ins memrr:$src),
851 "lhbrx $rD, $src", IIC_LdStLoad, []>;
852def LWBRX8 : XForm_1<31, 534, (outs g8rc:$rD), (ins memrr:$src),
853 "lwbrx $rD, $src", IIC_LdStLoad, []>;
854}
855
Craig Topperc50d64b2014-11-26 00:46:26 +0000856let mayLoad = 1, hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000857def LDU : DSForm_1<58, 1, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memrix:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000858 "ldu $rD, $addr", IIC_LdStLDU,
Chris Lattner57711562006-11-15 23:24:18 +0000859 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
860 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000861
Ulrich Weigand136ac222013-04-26 16:53:15 +0000862def LDUX : XForm_1<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000863 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000864 "ldux $rD, $addr", IIC_LdStLDUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000865 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000866 NoEncode<"$ea_result">, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +0000867}
Hal Finkeld71cc3a2013-04-07 06:30:47 +0000868}
Chris Lattner96aecb52006-07-14 04:42:02 +0000869
Tilmann Scheller79fef932009-12-18 13:00:15 +0000870def : Pat<(PPCload ixaddr:$src),
871 (LD ixaddr:$src)>;
872def : Pat<(PPCload xaddr:$src),
873 (LDX xaddr:$src)>;
874
Bill Schmidt27917782013-02-21 17:12:27 +0000875// Support for medium and large code model.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000876def ADDIStocHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
Bill Schmidt34627e32012-11-27 17:35:46 +0000877 "#ADDIStocHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000878 [(set i64:$rD,
879 (PPCaddisTocHA i64:$reg, tglobaladdr:$disp))]>,
Bill Schmidt34627e32012-11-27 17:35:46 +0000880 isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000881def LDtocL: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
Bill Schmidt34627e32012-11-27 17:35:46 +0000882 "#LDtocL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000883 [(set i64:$rD,
884 (PPCldTocL tglobaladdr:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000885def ADDItocL: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
Bill Schmidt34627e32012-11-27 17:35:46 +0000886 "#ADDItocL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000887 [(set i64:$rD,
888 (PPCaddiTocL i64:$reg, tglobaladdr:$disp))]>, isPPC64;
Bill Schmidt34627e32012-11-27 17:35:46 +0000889
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000890// Support for thread-local storage.
Ulrich Weigand99485462013-05-23 22:48:06 +0000891def ADDISgotTprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000892 "#ADDISgotTprelHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000893 [(set i64:$rD,
894 (PPCaddisGotTprelHA i64:$reg,
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000895 tglobaltlsaddr:$disp))]>,
896 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000897def LDgotTprelL: Pseudo<(outs g8rc:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000898 "#LDgotTprelL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000899 [(set i64:$rD,
900 (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000901 isPPC64;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +0000902def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
903 (ADD8TLS $in, tglobaltlsaddr:$g)>;
Ulrich Weigand99485462013-05-23 22:48:06 +0000904def ADDIStlsgdHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000905 "#ADDIStlsgdHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000906 [(set i64:$rD,
907 (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000908 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000909def ADDItlsgdL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000910 "#ADDItlsgdL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000911 [(set i64:$rD,
912 (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000913 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000914def ADDIStlsldHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000915 "#ADDIStlsldHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000916 [(set i64:$rD,
917 (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000918 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000919def ADDItlsldL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000920 "#ADDItlsldL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000921 [(set i64:$rD,
922 (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000923 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000924def ADDISdtprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000925 "#ADDISdtprelHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000926 [(set i64:$rD,
927 (PPCaddisDtprelHA i64:$reg,
Bill Schmidt9ed4dbc2012-12-13 20:57:10 +0000928 tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000929 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000930def ADDIdtprelL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000931 "#ADDIdtprelL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000932 [(set i64:$rD,
933 (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000934 isPPC64;
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000935
Chris Lattnere20f3802008-01-06 05:53:26 +0000936let PPC970_Unit = 2 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000937let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Chris Lattner96aecb52006-07-14 04:42:02 +0000938// Truncating stores.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000939def STB8 : DForm_1<38, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000940 "stb $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000941 [(truncstorei8 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000942def STH8 : DForm_1<44, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000943 "sth $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000944 [(truncstorei16 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000945def STW8 : DForm_1<36, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000946 "stw $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000947 [(truncstorei32 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000948def STBX8 : XForm_8<31, 215, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000949 "stbx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000950 [(truncstorei8 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000951 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000952def STHX8 : XForm_8<31, 407, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000953 "sthx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000954 [(truncstorei16 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000955 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000956def STWX8 : XForm_8<31, 151, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000957 "stwx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000958 [(truncstorei32 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000959 PPC970_DGroup_Cracked;
Hal Finkel654d43b2013-04-12 02:18:09 +0000960} // Interpretation64Bit
961
Chris Lattnere742d9a2006-11-16 00:57:19 +0000962// Normal 8-byte stores.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000963def STD : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000964 "std $rS, $dst", IIC_LdStSTD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000965 [(aligned4store i64:$rS, ixaddr:$dst)]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000966def STDX : XForm_8<31, 149, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000967 "stdx $rS, $dst", IIC_LdStSTD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000968 [(store i64:$rS, xaddr:$dst)]>, isPPC64,
Chris Lattnere742d9a2006-11-16 00:57:19 +0000969 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000970def STDBRX: XForm_8<31, 660, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000971 "stdbrx $rS, $dst", IIC_LdStStore,
Hal Finkel31d29562013-03-28 19:25:55 +0000972 [(PPCstbrx i64:$rS, xoaddr:$dst, i64)]>, isPPC64,
973 PPC970_DGroup_Cracked;
Chris Lattnerb4299832006-06-16 20:22:01 +0000974}
975
Ulrich Weigandd8501672013-03-19 19:52:04 +0000976// Stores with Update (pre-inc).
977let PPC970_Unit = 2, mayStore = 1 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000978let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000979def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000980 "stbu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000981 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000982def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000983 "sthu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000984 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000985def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000986 "stwu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000987 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigandd8501672013-03-19 19:52:04 +0000988
Ulrich Weigand136ac222013-04-26 16:53:15 +0000989def STBUX8: XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000990 "stbux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000991 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000992 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000993def STHUX8: XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000994 "sthux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000995 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000996 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000997def STWUX8: XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000998 "stwux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000999 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +00001000 PPC970_DGroup_Cracked;
Hal Finkel654d43b2013-04-12 02:18:09 +00001001} // Interpretation64Bit
1002
Hal Finkelb4b99e52013-12-17 23:05:18 +00001003def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrix:$dst),
1004 "stdu $rS, $dst", IIC_LdStSTDU, []>,
1005 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">,
1006 isPPC64;
1007
Ulrich Weigand136ac222013-04-26 16:53:15 +00001008def STDUX : XForm_8<31, 181, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel46402a42013-11-30 20:41:13 +00001009 "stdux $rS, $dst", IIC_LdStSTDUX, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +00001010 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +00001011 PPC970_DGroup_Cracked, isPPC64;
1012}
1013
1014// Patterns to match the pre-inc stores. We can't put the patterns on
1015// the instruction definitions directly as ISel wants the address base
1016// and offset to be separate operands, not a single complex operand.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001017def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1018 (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1019def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1020 (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1021def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1022 (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1023def : Pat<(aligned4pre_store i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1024 (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
Ulrich Weigandd8501672013-03-19 19:52:04 +00001025
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001026def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1027 (STBUX8 $rS, $ptrreg, $ptroff)>;
1028def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1029 (STHUX8 $rS, $ptrreg, $ptroff)>;
1030def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1031 (STWUX8 $rS, $ptrreg, $ptroff)>;
1032def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1033 (STDUX $rS, $ptrreg, $ptroff)>;
Chris Lattnerb4299832006-06-16 20:22:01 +00001034
1035
1036//===----------------------------------------------------------------------===//
1037// Floating point instructions.
1038//
1039
1040
Craig Topperc50d64b2014-11-26 00:46:26 +00001041let PPC970_Unit = 3, hasSideEffects = 0,
Hal Finkel654d43b2013-04-12 02:18:09 +00001042 Uses = [RM] in { // FPU Operations.
Ulrich Weigand136ac222013-04-26 16:53:15 +00001043defm FCFID : XForm_26r<63, 846, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001044 "fcfid", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001045 [(set f64:$frD, (PPCfcfid f64:$frB))]>, isPPC64;
David Majnemer6ad26d32013-09-26 04:11:24 +00001046defm FCTID : XForm_26r<63, 814, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001047 "fctid", "$frD, $frB", IIC_FPGeneral,
David Majnemer08249a32013-09-26 05:22:11 +00001048 []>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001049defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001050 "fctidz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001051 [(set f64:$frD, (PPCfctidz f64:$frB))]>, isPPC64;
Hal Finkelf6d45f22013-04-01 17:52:07 +00001052
Ulrich Weigand136ac222013-04-26 16:53:15 +00001053defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001054 "fcfidu", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001055 [(set f64:$frD, (PPCfcfidu f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001056defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001057 "fcfids", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001058 [(set f32:$frD, (PPCfcfids f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001059defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001060 "fcfidus", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001061 [(set f32:$frD, (PPCfcfidus f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001062defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001063 "fctiduz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001064 [(set f64:$frD, (PPCfctiduz f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001065defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001066 "fctiwuz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001067 [(set f64:$frD, (PPCfctiwuz f64:$frB))]>, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +00001068}
1069
1070
1071//===----------------------------------------------------------------------===//
1072// Instruction Patterns
1073//
Chris Lattner7e742e42006-06-20 22:34:10 +00001074
Chris Lattnerb4299832006-06-16 20:22:01 +00001075// Extensions and truncates to/from 32-bit regs.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001076def : Pat<(i64 (zext i32:$in)),
1077 (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
Hal Finkel2edfbdd2012-06-09 22:10:19 +00001078 0, 32)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001079def : Pat<(i64 (anyext i32:$in)),
1080 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
1081def : Pat<(i32 (trunc i64:$in)),
1082 (EXTRACT_SUBREG $in, sub_32)>;
Chris Lattnerb4299832006-06-16 20:22:01 +00001083
Hal Finkel940ab932014-02-28 00:27:01 +00001084// Implement the 'not' operation with the NOR instruction.
1085// (we could use the default xori pattern, but nor has lower latency on some
1086// cores (such as the A2)).
1087def i64not : OutPatFrag<(ops node:$in),
1088 (NOR8 $in, $in)>;
1089def : Pat<(not i64:$in),
1090 (i64not $in)>;
1091
Chris Lattner96aecb52006-07-14 04:42:02 +00001092// Extending loads with i64 targets.
Evan Chenge71fe34d2006-10-09 20:57:25 +00001093def : Pat<(zextloadi1 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001094 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001095def : Pat<(zextloadi1 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001096 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001097def : Pat<(extloadi1 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001098 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001099def : Pat<(extloadi1 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001100 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001101def : Pat<(extloadi8 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001102 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001103def : Pat<(extloadi8 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001104 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001105def : Pat<(extloadi16 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001106 (LHZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001107def : Pat<(extloadi16 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001108 (LHZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001109def : Pat<(extloadi32 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001110 (LWZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001111def : Pat<(extloadi32 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001112 (LWZX8 xaddr:$src)>;
1113
Chris Lattner20b5a2b2008-03-07 20:18:24 +00001114// Standard shifts. These are represented separately from the real shifts above
1115// so that we can distinguish between shifts that allow 6-bit and 7-bit shift
1116// amounts.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001117def : Pat<(sra i64:$rS, i32:$rB),
1118 (SRAD $rS, $rB)>;
1119def : Pat<(srl i64:$rS, i32:$rB),
1120 (SRD $rS, $rB)>;
1121def : Pat<(shl i64:$rS, i32:$rB),
1122 (SLD $rS, $rB)>;
Chris Lattner20b5a2b2008-03-07 20:18:24 +00001123
Chris Lattnerb4299832006-06-16 20:22:01 +00001124// SHL/SRL
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001125def : Pat<(shl i64:$in, (i32 imm:$imm)),
1126 (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
1127def : Pat<(srl i64:$in, (i32 imm:$imm)),
1128 (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
Chris Lattner2d4e8f72006-06-20 21:23:06 +00001129
Evan Cheng4dbd9f22007-09-04 20:20:29 +00001130// ROTL
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001131def : Pat<(rotl i64:$in, i32:$sh),
1132 (RLDCL $in, $sh, 0)>;
1133def : Pat<(rotl i64:$in, (i32 imm:$imm)),
1134 (RLDICL $in, imm:$imm, 0)>;
Evan Cheng4dbd9f22007-09-04 20:20:29 +00001135
Chris Lattner2d4e8f72006-06-20 21:23:06 +00001136// Hi and Lo for Darwin Global Addresses.
1137def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
1138def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
1139def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
1140def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
1141def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
1142def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
Bob Wilsonf84f7102009-11-04 21:31:18 +00001143def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
1144def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001145def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
1146 (ADDIS8 $in, tglobaltlsaddr:$g)>;
1147def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
Ulrich Weigand35f9fdf2013-03-26 10:55:20 +00001148 (ADDI8 $in, tglobaltlsaddr:$g)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001149def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
1150 (ADDIS8 $in, tglobaladdr:$g)>;
1151def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
1152 (ADDIS8 $in, tconstpool:$g)>;
1153def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
1154 (ADDIS8 $in, tjumptable:$g)>;
1155def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
1156 (ADDIS8 $in, tblockaddress:$g)>;
Hal Finkelb09680b2013-03-18 23:00:58 +00001157
1158// Patterns to match r+r indexed loads and stores for
1159// addresses without at least 4-byte alignment.
1160def : Pat<(i64 (unaligned4sextloadi32 xoaddr:$src)),
1161 (LWAX xoaddr:$src)>;
1162def : Pat<(i64 (unaligned4load xoaddr:$src)),
1163 (LDX xoaddr:$src)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001164def : Pat<(unaligned4store i64:$rS, xoaddr:$dst),
1165 (STDX $rS, xoaddr:$dst)>;
Hal Finkelb09680b2013-03-18 23:00:58 +00001166
Robin Morissete1ca44b2014-10-02 22:27:07 +00001167// 64-bits atomic loads and stores
1168def : Pat<(atomic_load_64 ixaddr:$src), (LD memrix:$src)>;
1169def : Pat<(atomic_load_64 xaddr:$src), (LDX memrr:$src)>;
1170
1171def : Pat<(atomic_store_64 ixaddr:$ptr, i64:$val), (STD g8rc:$val, memrix:$ptr)>;
1172def : Pat<(atomic_store_64 xaddr:$ptr, i64:$val), (STDX g8rc:$val, memrr:$ptr)>;