blob: 75f4656d01b8d7e9e2b77715b8fe86fc74e3c9d6 [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 Finkelb4b99e52013-12-17 23:05:18 +0000554let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000555defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000556 "extsb", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000557 [(set i64:$rA, (sext_inreg i64:$rS, i8))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000558defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000559 "extsh", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000560 [(set i64:$rA, (sext_inreg i64:$rS, i16))]>;
Hal Finkel4c6658f2014-12-12 23:59:36 +0000561
562defm SLW8 : XForm_6r<31, 24, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
563 "slw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
564defm SRW8 : XForm_6r<31, 536, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
565 "srw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000566} // Interpretation64Bit
567
Bill Schmidtd89f6782013-08-26 19:42:51 +0000568// For fast-isel:
569let isCodeGenOnly = 1 in {
570def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000571 "extsb $rA, $rS", IIC_IntSimple, []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000572def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000573 "extsh $rA, $rS", IIC_IntSimple, []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000574} // isCodeGenOnly for fast-isel
575
Ulrich Weigand136ac222013-04-26 16:53:15 +0000576defm EXTSW : XForm_11r<31, 986, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000577 "extsw", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000578 [(set i64:$rA, (sext_inreg i64:$rS, i32))]>, isPPC64;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000579let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000580defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000581 "extsw", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000582 [(set i64:$rA, (sext i32:$rS))]>, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +0000583
Ulrich Weigand136ac222013-04-26 16:53:15 +0000584defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000585 "sradi", "$rA, $rS, $SH", IIC_IntRotateDI,
Hal Finkel1b58f332013-04-12 18:17:57 +0000586 [(set i64:$rA, (sra i64:$rS, (i32 imm:$SH)))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000587defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000588 "cntlzd", "$rA, $rS", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000589 [(set i64:$rA, (ctlz i64:$rS))]>;
Hal Finkel884bde302013-11-20 20:54:55 +0000590def POPCNTD : XForm_11<31, 506, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000591 "popcntd $rA, $rS", IIC_IntGeneral,
Hal Finkel884bde302013-11-20 20:54:55 +0000592 [(set i64:$rA, (ctpop i64:$rS))]>;
Chris Lattner88102412007-03-25 04:44:03 +0000593
Hal Finkel4edc66b2015-01-03 01:16:37 +0000594let isCodeGenOnly = 1, isCommutable = 1 in
595def CMPB8 : XForm_6<31, 508, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
596 "cmpb $rA, $rS, $rB", IIC_IntGeneral,
597 [(set i64:$rA, (PPCcmpb i64:$rS, i64:$rB))]>;
598
Hal Finkel290376d2013-04-01 15:58:15 +0000599// popcntw also does a population count on the high 32 bits (storing the
600// results in the high 32-bits of the output). We'll ignore that here (which is
601// safe because we never separately use the high part of the 64-bit registers).
Hal Finkel884bde302013-11-20 20:54:55 +0000602def POPCNTW : XForm_11<31, 378, (outs gprc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000603 "popcntw $rA, $rS", IIC_IntGeneral,
Hal Finkel884bde302013-11-20 20:54:55 +0000604 [(set i32:$rA, (ctpop i32:$rS))]>;
Hal Finkel290376d2013-04-01 15:58:15 +0000605
Ulrich Weigand136ac222013-04-26 16:53:15 +0000606defm DIVD : XOForm_1r<31, 489, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000607 "divd", "$rT, $rA, $rB", IIC_IntDivD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000608 [(set i64:$rT, (sdiv i64:$rA, i64:$rB))]>, isPPC64,
609 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000610defm DIVDU : XOForm_1r<31, 457, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000611 "divdu", "$rT, $rA, $rB", IIC_IntDivD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000612 [(set i64:$rT, (udiv i64:$rA, i64:$rB))]>, isPPC64,
613 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Hal Finkele01d3212014-03-24 15:07:28 +0000614let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000615defm MULLD : XOForm_1r<31, 233, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000616 "mulld", "$rT, $rA, $rB", IIC_IntMulHD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000617 [(set i64:$rT, (mul i64:$rA, i64:$rB))]>, isPPC64;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000618let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Hal Finkel11b9e4522013-08-06 17:03:03 +0000619def MULLI8 : DForm_2<7, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000620 "mulli $rD, $rA, $imm", IIC_IntMulLI,
Hal Finkel11b9e4522013-08-06 17:03:03 +0000621 [(set i64:$rD, (mul i64:$rA, imm64SExt16:$imm))]>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000622}
Chris Lattner7ecbd302006-06-26 23:53:10 +0000623
Craig Topperc50d64b2014-11-26 00:46:26 +0000624let hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000625defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$rA),
626 (ins g8rc:$rSi, g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000627 "rldimi", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000628 []>, isPPC64, RegConstraint<"$rSi = $rA">,
629 NoEncode<"$rSi">;
Chris Lattnerb4299832006-06-16 20:22:01 +0000630
631// Rotate instructions.
Ulrich Weigandfa451ba2013-04-26 15:39:12 +0000632defm RLDCL : MDSForm_1r<30, 8,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000633 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000634 "rldcl", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000635 []>, isPPC64;
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000636defm RLDCR : MDSForm_1r<30, 9,
637 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000638 "rldcr", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000639 []>, isPPC64;
Hal Finkel654d43b2013-04-12 02:18:09 +0000640defm RLDICL : MDForm_1r<30, 0,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000641 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000642 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000643 []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000644// For fast-isel:
645let isCodeGenOnly = 1 in
646def RLDICL_32_64 : MDForm_1<30, 0,
647 (outs g8rc:$rA),
648 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000649 "rldicl $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Bill Schmidtd89f6782013-08-26 19:42:51 +0000650 []>, isPPC64;
651// End fast-isel.
Hal Finkel654d43b2013-04-12 02:18:09 +0000652defm RLDICR : MDForm_1r<30, 1,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000653 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000654 "rldicr", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000655 []>, isPPC64;
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000656defm RLDIC : MDForm_1r<30, 2,
657 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000658 "rldic", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000659 []>, isPPC64;
Hal Finkelac9df3d2011-12-07 06:34:06 +0000660
Hal Finkelb4b99e52013-12-17 23:05:18 +0000661let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000662defm RLWINM8 : MForm_2r<21, (outs g8rc:$rA),
663 (ins g8rc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000664 "rlwinm", "$rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000665 []>;
Hal Finkelac9df3d2011-12-07 06:34:06 +0000666
Hal Finkel4c6658f2014-12-12 23:59:36 +0000667defm RLWNM8 : MForm_2r<23, (outs g8rc:$rA),
668 (ins g8rc:$rS, g8rc:$rB, u5imm:$MB, u5imm:$ME),
669 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
670 []>;
671
Hal Finkel940ab932014-02-28 00:27:01 +0000672// RLWIMI can be commuted if the rotate amount is zero.
673let Interpretation64Bit = 1, isCodeGenOnly = 1 in
674defm RLWIMI8 : MForm_2r<20, (outs g8rc:$rA),
675 (ins g8rc:$rSi, g8rc:$rS, u5imm:$SH, u5imm:$MB,
676 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
677 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
678 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
Hal Finkel940ab932014-02-28 00:27:01 +0000679
Hal Finkel7795e472013-04-07 15:06:53 +0000680let isSelect = 1 in
Ulrich Weigand84ee76a2012-11-13 19:14:19 +0000681def ISEL8 : AForm_4<31, 15,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000682 (outs g8rc:$rT), (ins g8rc_nox0:$rA, g8rc:$rB, crbitrc:$cond),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000683 "isel $rT, $rA, $rB, $cond", IIC_IntGeneral,
Hal Finkel460e94d2012-06-22 23:10:08 +0000684 []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000685} // Interpretation64Bit
Craig Topperc50d64b2014-11-26 00:46:26 +0000686} // hasSideEffects = 0
Chris Lattner7ecbd302006-06-26 23:53:10 +0000687} // End FXU Operations.
Chris Lattnerb4299832006-06-16 20:22:01 +0000688
689
690//===----------------------------------------------------------------------===//
691// Load/Store instructions.
692//
693
694
Chris Lattner96aecb52006-07-14 04:42:02 +0000695// Sign extending loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000696let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000697let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000698def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000699 "lha $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000700 [(set i64:$rD, (sextloadi16 iaddr:$src))]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000701 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000702def LWA : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000703 "lwa $rD, $src", IIC_LdStLWA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000704 [(set i64:$rD,
Hal Finkelb09680b2013-03-18 23:00:58 +0000705 (aligned4sextloadi32 ixaddr:$src))]>, isPPC64,
Chris Lattner94d18df2006-06-20 00:38:36 +0000706 PPC970_DGroup_Cracked;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000707let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000708def LHAX8: XForm_1<31, 343, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000709 "lhax $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000710 [(set i64:$rD, (sextloadi16 xaddr:$src))]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000711 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000712def LWAX : XForm_1<31, 341, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000713 "lwax $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000714 [(set i64:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
Chris Lattnerb4299832006-06-16 20:22:01 +0000715 PPC970_DGroup_Cracked;
Bill Schmidtccecf262013-08-30 02:29:45 +0000716// For fast-isel:
717let isCodeGenOnly = 1, mayLoad = 1 in {
718def LWA_32 : DSForm_1<58, 2, (outs gprc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000719 "lwa $rD, $src", IIC_LdStLWA, []>, isPPC64,
Bill Schmidtccecf262013-08-30 02:29:45 +0000720 PPC970_DGroup_Cracked;
721def LWAX_32 : XForm_1<31, 341, (outs gprc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000722 "lwax $rD, $src", IIC_LdStLHA, []>, isPPC64,
Bill Schmidtccecf262013-08-30 02:29:45 +0000723 PPC970_DGroup_Cracked;
724} // end fast-isel isCodeGenOnly
Chris Lattner96aecb52006-07-14 04:42:02 +0000725
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000726// Update forms.
Craig Topperc50d64b2014-11-26 00:46:26 +0000727let mayLoad = 1, hasSideEffects = 0 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000728let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000729def LHAU8 : DForm_1<43, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Ulrich Weigandf8030092013-03-19 19:52:30 +0000730 (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000731 "lhau $rD, $addr", IIC_LdStLHAU,
Ulrich Weigandf8030092013-03-19 19:52:30 +0000732 []>, RegConstraint<"$addr.reg = $ea_result">,
Chris Lattner57711562006-11-15 23:24:18 +0000733 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000734// NO LWAU!
735
Hal Finkelb4b99e52013-12-17 23:05:18 +0000736let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000737def LHAUX8 : XForm_1<31, 375, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000738 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000739 "lhaux $rD, $addr", IIC_LdStLHAUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000740 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000741 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000742def LWAUX : XForm_1<31, 373, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000743 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000744 "lwaux $rD, $addr", IIC_LdStLHAUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000745 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000746 NoEncode<"$ea_result">, isPPC64;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000747}
Ulrich Weigand01dd4c12013-03-19 19:53:27 +0000748}
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000749
Hal Finkelb4b99e52013-12-17 23:05:18 +0000750let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Chris Lattner96aecb52006-07-14 04:42:02 +0000751// Zero extending loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000752let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000753def LBZ8 : DForm_1<34, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000754 "lbz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000755 [(set i64:$rD, (zextloadi8 iaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000756def LHZ8 : DForm_1<40, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000757 "lhz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000758 [(set i64:$rD, (zextloadi16 iaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000759def LWZ8 : DForm_1<32, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000760 "lwz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000761 [(set i64:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
Chris Lattner96aecb52006-07-14 04:42:02 +0000762
Ulrich Weigand136ac222013-04-26 16:53:15 +0000763def LBZX8 : XForm_1<31, 87, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000764 "lbzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000765 [(set i64:$rD, (zextloadi8 xaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000766def LHZX8 : XForm_1<31, 279, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000767 "lhzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000768 [(set i64:$rD, (zextloadi16 xaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000769def LWZX8 : XForm_1<31, 23, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000770 "lwzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000771 [(set i64:$rD, (zextloadi32 xaddr:$src))]>;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000772
773
774// Update forms.
Craig Topperc50d64b2014-11-26 00:46:26 +0000775let mayLoad = 1, hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000776def LBZU8 : DForm_1<35, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000777 "lbzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000778 []>, RegConstraint<"$addr.reg = $ea_result">,
779 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000780def LHZU8 : DForm_1<41, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000781 "lhzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000782 []>, RegConstraint<"$addr.reg = $ea_result">,
783 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000784def LWZU8 : DForm_1<33, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000785 "lwzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000786 []>, RegConstraint<"$addr.reg = $ea_result">,
787 NoEncode<"$ea_result">;
Hal Finkelca542be2012-06-20 15:43:03 +0000788
Ulrich Weigand136ac222013-04-26 16:53:15 +0000789def LBZUX8 : XForm_1<31, 119, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000790 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000791 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000792 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000793 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000794def LHZUX8 : XForm_1<31, 311, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000795 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000796 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000797 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000798 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000799def LWZUX8 : XForm_1<31, 55, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000800 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000801 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000802 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000803 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000804}
Dan Gohmanae3ba452008-12-03 02:30:17 +0000805}
Hal Finkel654d43b2013-04-12 02:18:09 +0000806} // Interpretation64Bit
Chris Lattner96aecb52006-07-14 04:42:02 +0000807
808
809// Full 8-byte loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000810let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000811def LD : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000812 "ld $rD, $src", IIC_LdStLD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000813 [(set i64:$rD, (aligned4load ixaddr:$src))]>, isPPC64;
Ulrich Weigandc8c2ea22014-10-31 10:33:14 +0000814// The following four definitions are selected for small code model only.
Bill Schmidt34627e32012-11-27 17:35:46 +0000815// Otherwise, we need to create two instructions to form a 32-bit offset,
816// so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
Ulrich Weigand136ac222013-04-26 16:53:15 +0000817def LDtoc: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000818 "#LDtoc",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000819 [(set i64:$rD,
820 (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000821def LDtocJTI: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000822 "#LDtocJTI",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000823 [(set i64:$rD,
824 (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000825def LDtocCPT: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000826 "#LDtocCPT",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000827 [(set i64:$rD,
828 (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigandc8c2ea22014-10-31 10:33:14 +0000829def LDtocBA: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
830 "#LDtocCPT",
831 [(set i64:$rD,
832 (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64;
Hal Finkela3e6ed22012-02-24 17:54:01 +0000833
Bill Schmidt3755e172014-08-15 01:25:26 +0000834let hasSideEffects = 1, isCodeGenOnly = 1, RST = 2, Defs = [X2] in
Ulrich Weigandad0cb912014-06-18 17:52:49 +0000835def LDinto_toc: DSForm_1<58, 0, (outs), (ins memrix:$src),
836 "ld 2, $src", IIC_LdStLD,
837 [(PPCload_toc ixaddr:$src)]>, isPPC64;
838
Ulrich Weigand136ac222013-04-26 16:53:15 +0000839def LDX : XForm_1<31, 21, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000840 "ldx $rD, $src", IIC_LdStLD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000841 [(set i64:$rD, (load xaddr:$src))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000842def LDBRX : XForm_1<31, 532, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000843 "ldbrx $rD, $src", IIC_LdStLoad,
Hal Finkel31d29562013-03-28 19:25:55 +0000844 [(set i64:$rD, (PPClbrx xoaddr:$src, i64))]>, isPPC64;
845
Craig Topperc50d64b2014-11-26 00:46:26 +0000846let mayLoad = 1, hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000847def LDU : DSForm_1<58, 1, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memrix:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000848 "ldu $rD, $addr", IIC_LdStLDU,
Chris Lattner57711562006-11-15 23:24:18 +0000849 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
850 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000851
Ulrich Weigand136ac222013-04-26 16:53:15 +0000852def LDUX : XForm_1<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000853 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000854 "ldux $rD, $addr", IIC_LdStLDUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000855 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000856 NoEncode<"$ea_result">, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +0000857}
Hal Finkeld71cc3a2013-04-07 06:30:47 +0000858}
Chris Lattner96aecb52006-07-14 04:42:02 +0000859
Tilmann Scheller79fef932009-12-18 13:00:15 +0000860def : Pat<(PPCload ixaddr:$src),
861 (LD ixaddr:$src)>;
862def : Pat<(PPCload xaddr:$src),
863 (LDX xaddr:$src)>;
864
Bill Schmidt27917782013-02-21 17:12:27 +0000865// Support for medium and large code model.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000866def ADDIStocHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
Bill Schmidt34627e32012-11-27 17:35:46 +0000867 "#ADDIStocHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000868 [(set i64:$rD,
869 (PPCaddisTocHA i64:$reg, tglobaladdr:$disp))]>,
Bill Schmidt34627e32012-11-27 17:35:46 +0000870 isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000871def LDtocL: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
Bill Schmidt34627e32012-11-27 17:35:46 +0000872 "#LDtocL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000873 [(set i64:$rD,
874 (PPCldTocL tglobaladdr:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000875def ADDItocL: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
Bill Schmidt34627e32012-11-27 17:35:46 +0000876 "#ADDItocL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000877 [(set i64:$rD,
878 (PPCaddiTocL i64:$reg, tglobaladdr:$disp))]>, isPPC64;
Bill Schmidt34627e32012-11-27 17:35:46 +0000879
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000880// Support for thread-local storage.
Ulrich Weigand99485462013-05-23 22:48:06 +0000881def ADDISgotTprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000882 "#ADDISgotTprelHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000883 [(set i64:$rD,
884 (PPCaddisGotTprelHA i64:$reg,
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000885 tglobaltlsaddr:$disp))]>,
886 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000887def LDgotTprelL: Pseudo<(outs g8rc:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000888 "#LDgotTprelL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000889 [(set i64:$rD,
890 (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000891 isPPC64;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +0000892def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
893 (ADD8TLS $in, tglobaltlsaddr:$g)>;
Ulrich Weigand99485462013-05-23 22:48:06 +0000894def ADDIStlsgdHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000895 "#ADDIStlsgdHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000896 [(set i64:$rD,
897 (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000898 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000899def ADDItlsgdL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000900 "#ADDItlsgdL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000901 [(set i64:$rD,
902 (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000903 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000904def ADDIStlsldHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000905 "#ADDIStlsldHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000906 [(set i64:$rD,
907 (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000908 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000909def ADDItlsldL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000910 "#ADDItlsldL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000911 [(set i64:$rD,
912 (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000913 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000914def ADDISdtprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000915 "#ADDISdtprelHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000916 [(set i64:$rD,
917 (PPCaddisDtprelHA i64:$reg,
Bill Schmidt9ed4dbc2012-12-13 20:57:10 +0000918 tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000919 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000920def ADDIdtprelL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000921 "#ADDIdtprelL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000922 [(set i64:$rD,
923 (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000924 isPPC64;
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000925
Chris Lattnere20f3802008-01-06 05:53:26 +0000926let PPC970_Unit = 2 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000927let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Chris Lattner96aecb52006-07-14 04:42:02 +0000928// Truncating stores.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000929def STB8 : DForm_1<38, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000930 "stb $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000931 [(truncstorei8 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000932def STH8 : DForm_1<44, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000933 "sth $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000934 [(truncstorei16 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000935def STW8 : DForm_1<36, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000936 "stw $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000937 [(truncstorei32 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000938def STBX8 : XForm_8<31, 215, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000939 "stbx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000940 [(truncstorei8 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000941 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000942def STHX8 : XForm_8<31, 407, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000943 "sthx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000944 [(truncstorei16 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000945 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000946def STWX8 : XForm_8<31, 151, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000947 "stwx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000948 [(truncstorei32 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000949 PPC970_DGroup_Cracked;
Hal Finkel654d43b2013-04-12 02:18:09 +0000950} // Interpretation64Bit
951
Chris Lattnere742d9a2006-11-16 00:57:19 +0000952// Normal 8-byte stores.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000953def STD : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000954 "std $rS, $dst", IIC_LdStSTD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000955 [(aligned4store i64:$rS, ixaddr:$dst)]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000956def STDX : XForm_8<31, 149, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000957 "stdx $rS, $dst", IIC_LdStSTD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000958 [(store i64:$rS, xaddr:$dst)]>, isPPC64,
Chris Lattnere742d9a2006-11-16 00:57:19 +0000959 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000960def STDBRX: XForm_8<31, 660, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000961 "stdbrx $rS, $dst", IIC_LdStStore,
Hal Finkel31d29562013-03-28 19:25:55 +0000962 [(PPCstbrx i64:$rS, xoaddr:$dst, i64)]>, isPPC64,
963 PPC970_DGroup_Cracked;
Chris Lattnerb4299832006-06-16 20:22:01 +0000964}
965
Ulrich Weigandd8501672013-03-19 19:52:04 +0000966// Stores with Update (pre-inc).
967let PPC970_Unit = 2, mayStore = 1 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000968let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000969def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000970 "stbu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000971 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000972def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000973 "sthu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000974 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000975def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000976 "stwu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000977 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigandd8501672013-03-19 19:52:04 +0000978
Ulrich Weigand136ac222013-04-26 16:53:15 +0000979def STBUX8: XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000980 "stbux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000981 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000982 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000983def STHUX8: XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000984 "sthux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000985 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000986 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000987def STWUX8: XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000988 "stwux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000989 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000990 PPC970_DGroup_Cracked;
Hal Finkel654d43b2013-04-12 02:18:09 +0000991} // Interpretation64Bit
992
Hal Finkelb4b99e52013-12-17 23:05:18 +0000993def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrix:$dst),
994 "stdu $rS, $dst", IIC_LdStSTDU, []>,
995 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">,
996 isPPC64;
997
Ulrich Weigand136ac222013-04-26 16:53:15 +0000998def STDUX : XForm_8<31, 181, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel46402a42013-11-30 20:41:13 +0000999 "stdux $rS, $dst", IIC_LdStSTDUX, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +00001000 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +00001001 PPC970_DGroup_Cracked, isPPC64;
1002}
1003
1004// Patterns to match the pre-inc stores. We can't put the patterns on
1005// the instruction definitions directly as ISel wants the address base
1006// and offset to be separate operands, not a single complex operand.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001007def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1008 (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1009def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1010 (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1011def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1012 (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
1013def : Pat<(aligned4pre_store i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1014 (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
Ulrich Weigandd8501672013-03-19 19:52:04 +00001015
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001016def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1017 (STBUX8 $rS, $ptrreg, $ptroff)>;
1018def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1019 (STHUX8 $rS, $ptrreg, $ptroff)>;
1020def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1021 (STWUX8 $rS, $ptrreg, $ptroff)>;
1022def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1023 (STDUX $rS, $ptrreg, $ptroff)>;
Chris Lattnerb4299832006-06-16 20:22:01 +00001024
1025
1026//===----------------------------------------------------------------------===//
1027// Floating point instructions.
1028//
1029
1030
Craig Topperc50d64b2014-11-26 00:46:26 +00001031let PPC970_Unit = 3, hasSideEffects = 0,
Hal Finkel654d43b2013-04-12 02:18:09 +00001032 Uses = [RM] in { // FPU Operations.
Ulrich Weigand136ac222013-04-26 16:53:15 +00001033defm FCFID : XForm_26r<63, 846, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001034 "fcfid", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001035 [(set f64:$frD, (PPCfcfid f64:$frB))]>, isPPC64;
David Majnemer6ad26d32013-09-26 04:11:24 +00001036defm FCTID : XForm_26r<63, 814, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001037 "fctid", "$frD, $frB", IIC_FPGeneral,
David Majnemer08249a32013-09-26 05:22:11 +00001038 []>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001039defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001040 "fctidz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001041 [(set f64:$frD, (PPCfctidz f64:$frB))]>, isPPC64;
Hal Finkelf6d45f22013-04-01 17:52:07 +00001042
Ulrich Weigand136ac222013-04-26 16:53:15 +00001043defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001044 "fcfidu", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001045 [(set f64:$frD, (PPCfcfidu f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001046defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001047 "fcfids", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001048 [(set f32:$frD, (PPCfcfids f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001049defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001050 "fcfidus", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001051 [(set f32:$frD, (PPCfcfidus f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001052defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001053 "fctiduz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001054 [(set f64:$frD, (PPCfctiduz f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001055defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001056 "fctiwuz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001057 [(set f64:$frD, (PPCfctiwuz f64:$frB))]>, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +00001058}
1059
1060
1061//===----------------------------------------------------------------------===//
1062// Instruction Patterns
1063//
Chris Lattner7e742e42006-06-20 22:34:10 +00001064
Chris Lattnerb4299832006-06-16 20:22:01 +00001065// Extensions and truncates to/from 32-bit regs.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001066def : Pat<(i64 (zext i32:$in)),
1067 (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
Hal Finkel2edfbdd2012-06-09 22:10:19 +00001068 0, 32)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001069def : Pat<(i64 (anyext i32:$in)),
1070 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
1071def : Pat<(i32 (trunc i64:$in)),
1072 (EXTRACT_SUBREG $in, sub_32)>;
Chris Lattnerb4299832006-06-16 20:22:01 +00001073
Hal Finkel940ab932014-02-28 00:27:01 +00001074// Implement the 'not' operation with the NOR instruction.
1075// (we could use the default xori pattern, but nor has lower latency on some
1076// cores (such as the A2)).
1077def i64not : OutPatFrag<(ops node:$in),
1078 (NOR8 $in, $in)>;
1079def : Pat<(not i64:$in),
1080 (i64not $in)>;
1081
Chris Lattner96aecb52006-07-14 04:42:02 +00001082// Extending loads with i64 targets.
Evan Chenge71fe34d2006-10-09 20:57:25 +00001083def : Pat<(zextloadi1 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001084 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001085def : Pat<(zextloadi1 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001086 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001087def : Pat<(extloadi1 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001088 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001089def : Pat<(extloadi1 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001090 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001091def : Pat<(extloadi8 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001092 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001093def : Pat<(extloadi8 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001094 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001095def : Pat<(extloadi16 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001096 (LHZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001097def : Pat<(extloadi16 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001098 (LHZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001099def : Pat<(extloadi32 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001100 (LWZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001101def : Pat<(extloadi32 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001102 (LWZX8 xaddr:$src)>;
1103
Chris Lattner20b5a2b2008-03-07 20:18:24 +00001104// Standard shifts. These are represented separately from the real shifts above
1105// so that we can distinguish between shifts that allow 6-bit and 7-bit shift
1106// amounts.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001107def : Pat<(sra i64:$rS, i32:$rB),
1108 (SRAD $rS, $rB)>;
1109def : Pat<(srl i64:$rS, i32:$rB),
1110 (SRD $rS, $rB)>;
1111def : Pat<(shl i64:$rS, i32:$rB),
1112 (SLD $rS, $rB)>;
Chris Lattner20b5a2b2008-03-07 20:18:24 +00001113
Chris Lattnerb4299832006-06-16 20:22:01 +00001114// SHL/SRL
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001115def : Pat<(shl i64:$in, (i32 imm:$imm)),
1116 (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
1117def : Pat<(srl i64:$in, (i32 imm:$imm)),
1118 (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
Chris Lattner2d4e8f72006-06-20 21:23:06 +00001119
Evan Cheng4dbd9f22007-09-04 20:20:29 +00001120// ROTL
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001121def : Pat<(rotl i64:$in, i32:$sh),
1122 (RLDCL $in, $sh, 0)>;
1123def : Pat<(rotl i64:$in, (i32 imm:$imm)),
1124 (RLDICL $in, imm:$imm, 0)>;
Evan Cheng4dbd9f22007-09-04 20:20:29 +00001125
Chris Lattner2d4e8f72006-06-20 21:23:06 +00001126// Hi and Lo for Darwin Global Addresses.
1127def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
1128def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
1129def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
1130def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
1131def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
1132def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
Bob Wilsonf84f7102009-11-04 21:31:18 +00001133def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
1134def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001135def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
1136 (ADDIS8 $in, tglobaltlsaddr:$g)>;
1137def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
Ulrich Weigand35f9fdf2013-03-26 10:55:20 +00001138 (ADDI8 $in, tglobaltlsaddr:$g)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001139def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
1140 (ADDIS8 $in, tglobaladdr:$g)>;
1141def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
1142 (ADDIS8 $in, tconstpool:$g)>;
1143def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
1144 (ADDIS8 $in, tjumptable:$g)>;
1145def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
1146 (ADDIS8 $in, tblockaddress:$g)>;
Hal Finkelb09680b2013-03-18 23:00:58 +00001147
1148// Patterns to match r+r indexed loads and stores for
1149// addresses without at least 4-byte alignment.
1150def : Pat<(i64 (unaligned4sextloadi32 xoaddr:$src)),
1151 (LWAX xoaddr:$src)>;
1152def : Pat<(i64 (unaligned4load xoaddr:$src)),
1153 (LDX xoaddr:$src)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001154def : Pat<(unaligned4store i64:$rS, xoaddr:$dst),
1155 (STDX $rS, xoaddr:$dst)>;
Hal Finkelb09680b2013-03-18 23:00:58 +00001156
Robin Morissete1ca44b2014-10-02 22:27:07 +00001157// 64-bits atomic loads and stores
1158def : Pat<(atomic_load_64 ixaddr:$src), (LD memrix:$src)>;
1159def : Pat<(atomic_load_64 xaddr:$src), (LDX memrr:$src)>;
1160
1161def : Pat<(atomic_store_64 ixaddr:$ptr, i64:$val), (STD g8rc:$val, memrix:$ptr)>;
1162def : Pat<(atomic_store_64 xaddr:$ptr, i64:$val), (STDX g8rc:$val, memrr:$ptr)>;