blob: 460e49e5724af6f2e1f3e70193ef855698380c31 [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 Finkel654d43b2013-04-12 02:18:09 +0000170} // Interpretation64Bit
Chris Lattner43df5b32007-02-25 05:34:32 +0000171
Hal Finkelb4b99e52013-12-17 23:05:18 +0000172// FIXME: Duplicating this for the asm parser should be unnecessary, but the
173// previous definition must be marked as CodeGen only to prevent decoding
174// conflicts.
175let Interpretation64Bit = 1, isAsmParserOnly = 1 in
176let isCall = 1, PPC970_Unit = 7, Defs = [LR8], Uses = [RM] in
177def BL8_TLS_ : IForm<18, 0, 1, (outs), (ins tlscall:$func),
178 "bl $func", IIC_BrB, []>;
179
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000180// Calls
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000181def : Pat<(PPCcall (i64 tglobaladdr:$dst)),
182 (BL8 tglobaladdr:$dst)>;
183def : Pat<(PPCcall_nop (i64 tglobaladdr:$dst)),
184 (BL8_NOP tglobaladdr:$dst)>;
Nicolas Geoffray89d81872007-02-27 13:01:19 +0000185
Ulrich Weigandf62e83f2013-03-22 15:24:13 +0000186def : Pat<(PPCcall (i64 texternalsym:$dst)),
187 (BL8 texternalsym:$dst)>;
188def : Pat<(PPCcall_nop (i64 texternalsym:$dst)),
189 (BL8_NOP texternalsym:$dst)>;
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000190
Bill Schmidt3d9674c2014-11-11 20:44:09 +0000191def : Pat<(PPCcall_nop_tls texternalsym:$func, tglobaltlsaddr:$sym),
192 (BL8_NOP_TLS texternalsym:$func, tglobaltlsaddr:$sym)>;
193
Evan Cheng32e376f2008-07-12 02:23:19 +0000194// Atomic operations
Dan Gohman453d64c2009-10-29 18:10:34 +0000195let usesCustomInserter = 1 in {
Jakob Stoklund Olesen86e1a652011-04-04 17:07:09 +0000196 let Defs = [CR0] in {
Evan Cheng32e376f2008-07-12 02:23:19 +0000197 def ATOMIC_LOAD_ADD_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000198 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000199 [(set i64:$dst, (atomic_load_add_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000200 def ATOMIC_LOAD_SUB_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000201 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000202 [(set i64:$dst, (atomic_load_sub_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000203 def ATOMIC_LOAD_OR_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000204 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000205 [(set i64:$dst, (atomic_load_or_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000206 def ATOMIC_LOAD_XOR_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000207 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000208 [(set i64:$dst, (atomic_load_xor_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000209 def ATOMIC_LOAD_AND_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000210 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000211 [(set i64:$dst, (atomic_load_and_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000212 def ATOMIC_LOAD_NAND_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000213 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000214 [(set i64:$dst, (atomic_load_nand_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000215
Dale Johannesendec51702008-08-22 03:49:10 +0000216 def ATOMIC_CMP_SWAP_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000217 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000218 [(set i64:$dst, (atomic_cmp_swap_64 xoaddr:$ptr, i64:$old, i64:$new))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000219
Dale Johannesen765065c2008-08-25 21:09:52 +0000220 def ATOMIC_SWAP_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000221 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000222 [(set i64:$dst, (atomic_swap_64 xoaddr:$ptr, i64:$new))]>;
Dale Johannesendec51702008-08-22 03:49:10 +0000223 }
Evan Cheng5102bd92008-04-19 02:30:38 +0000224}
225
Evan Cheng32e376f2008-07-12 02:23:19 +0000226// Instructions to support atomic operations
Ulrich Weigand136ac222013-04-26 16:53:15 +0000227def LDARX : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000228 "ldarx $rD, $ptr", IIC_LdStLDARX,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000229 [(set i64:$rD, (PPClarx xoaddr:$ptr))]>;
Evan Cheng32e376f2008-07-12 02:23:19 +0000230
231let Defs = [CR0] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000232def STDCX : XForm_1<31, 214, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000233 "stdcx. $rS, $dst", IIC_LdStSTDCX,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000234 [(PPCstcx i64:$rS, xoaddr:$dst)]>,
Evan Cheng32e376f2008-07-12 02:23:19 +0000235 isDOT;
236
Hal Finkelb4b99e52013-12-17 23:05:18 +0000237let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000238let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000239def TCRETURNdi8 :Pseudo< (outs),
Jakob Stoklund Olesened6c0402012-07-13 20:44:29 +0000240 (ins calltarget:$dst, i32imm:$offset),
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000241 "#TC_RETURNd8 $dst $offset",
242 []>;
243
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000244let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000245def TCRETURNai8 :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000246 "#TC_RETURNa8 $func $offset",
247 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
248
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000249let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
Jakob Stoklund Olesened6c0402012-07-13 20:44:29 +0000250def TCRETURNri8 : Pseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset),
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000251 "#TC_RETURNr8 $dst $offset",
252 []>;
253
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000254let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
Ulrich Weigand410a40b2013-03-26 10:53:03 +0000255 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in
Hal Finkel3e5a3602013-11-27 23:26:09 +0000256def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
257 []>,
Ulrich Weigand410a40b2013-03-26 10:53:03 +0000258 Requires<[In64BitMode]>;
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000259
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000260let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000261 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000262def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000263 "b $dst", IIC_BrB,
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000264 []>;
265
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000266let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000267 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000268def TAILBA8 : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000269 "ba $dst", IIC_BrB,
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000270 []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000271} // Interpretation64Bit
Ulrich Weigandbbfb0c52013-03-26 10:57:16 +0000272
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000273def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
274 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
275
276def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
277 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
278
279def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
280 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
281
Hal Finkel96c2d4d2012-06-08 15:38:21 +0000282
Hal Finkel25aab012013-03-28 03:38:08 +0000283// 64-bit CR instructions
Hal Finkelb4b99e52013-12-17 23:05:18 +0000284let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Craig Topperc50d64b2014-11-26 00:46:26 +0000285let hasSideEffects = 0 in {
Ulrich Weigand49f487e2013-07-03 17:59:07 +0000286def MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$ST),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000287 "mtocrf $FXM, $ST", IIC_BrMCRX>,
Ulrich Weigand49f487e2013-07-03 17:59:07 +0000288 PPC970_DGroup_First, PPC970_Unit_CRU;
289
290def MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000291 "mtcrf $FXM, $rS", IIC_BrMCRX>,
Hal Finkelac9df3d2011-12-07 06:34:06 +0000292 PPC970_MicroCode, PPC970_Unit_CRU;
293
Hal Finkel7fe6a532013-09-12 05:24:49 +0000294let hasExtraSrcRegAllocReq = 1 in // to enable post-ra anti-dep breaking.
Ulrich Weigandd5ebc622013-07-03 17:05:42 +0000295def MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$rT), (ins crbitm:$FXM),
Hal Finkel46402a42013-11-30 20:41:13 +0000296 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
Ulrich Weigandd5ebc622013-07-03 17:05:42 +0000297 PPC970_DGroup_First, PPC970_Unit_CRU;
Hal Finkelb47a69a2013-04-07 14:33:13 +0000298
Ulrich Weigand136ac222013-04-26 16:53:15 +0000299def MFCR8 : XFXForm_3<31, 19, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000300 "mfcr $rT", IIC_SprMFCR>,
Hal Finkelac9df3d2011-12-07 06:34:06 +0000301 PPC970_MicroCode, PPC970_Unit_CRU;
Craig Topperc50d64b2014-11-26 00:46:26 +0000302} // hasSideEffects = 0
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000303
Ulrich Weigandbbfb0c52013-03-26 10:57:16 +0000304let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
Hal Finkel40f76d52013-07-17 05:35:44 +0000305 let Defs = [CTR8] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000306 def EH_SjLj_SetJmp64 : Pseudo<(outs gprc:$dst), (ins memr:$buf),
Hal Finkel756810f2013-03-21 21:37:52 +0000307 "#EH_SJLJ_SETJMP64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000308 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
Hal Finkel756810f2013-03-21 21:37:52 +0000309 Requires<[In64BitMode]>;
310 let isTerminator = 1 in
311 def EH_SjLj_LongJmp64 : Pseudo<(outs), (ins memr:$buf),
312 "#EH_SJLJ_LONGJMP64",
313 [(PPCeh_sjlj_longjmp addr:$buf)]>,
314 Requires<[In64BitMode]>;
315}
316
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000317//===----------------------------------------------------------------------===//
318// 64-bit SPR manipulation instrs.
319
Dale Johannesene395d782008-10-23 20:41:28 +0000320let Uses = [CTR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000321def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000322 "mfctr $rT", IIC_SprMFSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000323 PPC970_DGroup_First, PPC970_Unit_FXU;
Dale Johannesene395d782008-10-23 20:41:28 +0000324}
Ulrich Weigandc8868102013-03-25 19:05:30 +0000325let Pattern = [(PPCmtctr i64:$rS)], Defs = [CTR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000326def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000327 "mtctr $rS", IIC_SprMTSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000328 PPC970_DGroup_First, PPC970_Unit_FXU;
Chris Lattner3b587342006-06-27 18:36:44 +0000329}
Hal Finkelb4b99e52013-12-17 23:05:18 +0000330let hasSideEffects = 1, Defs = [CTR8] in {
Hal Finkel25c19922013-05-15 21:37:41 +0000331let Pattern = [(int_ppc_mtctr i64:$rS)] in
Hal Finkel0859ef22013-05-20 16:08:37 +0000332def MTCTR8loop : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000333 "mtctr $rS", IIC_SprMTSPR>,
Hal Finkel0859ef22013-05-20 16:08:37 +0000334 PPC970_DGroup_First, PPC970_Unit_FXU;
Hal Finkel25c19922013-05-15 21:37:41 +0000335}
Chris Lattnerd48ce272006-06-27 18:18:41 +0000336
Hal Finkelb4b99e52013-12-17 23:05:18 +0000337let Pattern = [(set i64:$rT, readcyclecounter)] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000338def MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000339 "mfspr $rT, 268", IIC_SprMFTB>,
Hal Finkel70381a72012-08-04 14:10:46 +0000340 PPC970_DGroup_First, PPC970_Unit_FXU;
Hal Finkel895a5f52012-08-07 17:04:20 +0000341// Note that encoding mftb using mfspr is now the preferred form,
342// and has been since at least ISA v2.03. The mftb instruction has
343// now been phased out. Using mfspr, however, is known not to work on
344// the POWER3.
Hal Finkel70381a72012-08-04 14:10:46 +0000345
Evan Cheng3e18e502007-09-11 19:55:27 +0000346let Defs = [X1], Uses = [X1] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000347def DYNALLOC8 : Pseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000348 [(set i64:$result,
349 (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>;
Jim Laskey48850c12006-11-16 22:43:37 +0000350
Dale Johannesene395d782008-10-23 20:41:28 +0000351let Defs = [LR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000352def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000353 "mtlr $rS", IIC_SprMTSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000354 PPC970_DGroup_First, PPC970_Unit_FXU;
Dale Johannesene395d782008-10-23 20:41:28 +0000355}
356let Uses = [LR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000357def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000358 "mflr $rT", IIC_SprMFSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000359 PPC970_DGroup_First, PPC970_Unit_FXU;
Dale Johannesene395d782008-10-23 20:41:28 +0000360}
Hal Finkel654d43b2013-04-12 02:18:09 +0000361} // Interpretation64Bit
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000362
Chris Lattnerd48ce272006-06-27 18:18:41 +0000363//===----------------------------------------------------------------------===//
Chris Lattnerb4299832006-06-16 20:22:01 +0000364// Fixed point instructions.
365//
366
367let PPC970_Unit = 1 in { // FXU Operations.
Hal Finkel654d43b2013-04-12 02:18:09 +0000368let Interpretation64Bit = 1 in {
Craig Topperc50d64b2014-11-26 00:46:26 +0000369let hasSideEffects = 0 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000370let isCodeGenOnly = 1 in {
Chris Lattnerb4299832006-06-16 20:22:01 +0000371
Hal Finkel686f2ee2012-08-28 02:10:33 +0000372let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
Ulrich Weigand99485462013-05-23 22:48:06 +0000373def LI8 : DForm_2_r0<14, (outs g8rc:$rD), (ins s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000374 "li $rD, $imm", IIC_IntSimple,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000375 [(set i64:$rD, imm64SExt16:$imm)]>;
Ulrich Weigand5a02a022013-06-26 13:49:53 +0000376def LIS8 : DForm_2_r0<15, (outs g8rc:$rD), (ins s17imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000377 "lis $rD, $imm", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000378 [(set i64:$rD, imm16ShiftedSExt:$imm)]>;
Hal Finkel686f2ee2012-08-28 02:10:33 +0000379}
Chris Lattner7e742e42006-06-20 22:34:10 +0000380
381// Logical ops.
Hal Finkele01d3212014-03-24 15:07:28 +0000382let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000383defm NAND8: XForm_6r<31, 476, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000384 "nand", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000385 [(set i64:$rA, (not (and i64:$rS, i64:$rB)))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000386defm AND8 : XForm_6r<31, 28, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000387 "and", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000388 [(set i64:$rA, (and i64:$rS, i64:$rB))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000389} // isCommutable
Ulrich Weigand136ac222013-04-26 16:53:15 +0000390defm ANDC8: XForm_6r<31, 60, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000391 "andc", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000392 [(set i64:$rA, (and i64:$rS, (not i64:$rB)))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000393let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000394defm OR8 : XForm_6r<31, 444, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000395 "or", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000396 [(set i64:$rA, (or i64:$rS, i64:$rB))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000397defm NOR8 : XForm_6r<31, 124, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000398 "nor", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000399 [(set i64:$rA, (not (or i64:$rS, i64:$rB)))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000400} // isCommutable
Ulrich Weigand136ac222013-04-26 16:53:15 +0000401defm ORC8 : XForm_6r<31, 412, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000402 "orc", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000403 [(set i64:$rA, (or i64:$rS, (not i64:$rB)))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000404let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000405defm EQV8 : XForm_6r<31, 284, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000406 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000407 [(set i64:$rA, (not (xor i64:$rS, i64:$rB)))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000408defm XOR8 : XForm_6r<31, 316, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000409 "xor", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000410 [(set i64:$rA, (xor i64:$rS, i64:$rB))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000411} // let isCommutable = 1
Chris Lattner9d65f352006-06-20 23:11:59 +0000412
413// Logical ops with immediate.
Hal Finkel1b58f332013-04-12 18:17:57 +0000414let Defs = [CR0] in {
Hal Finkel77c8dc12014-01-02 21:26:59 +0000415def ANDIo8 : DForm_4<28, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000416 "andi. $dst, $src1, $src2", IIC_IntGeneral,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000417 [(set i64:$dst, (and i64:$src1, immZExt16:$src2))]>,
Chris Lattner7e742e42006-06-20 22:34:10 +0000418 isDOT;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000419def ANDISo8 : DForm_4<29, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000420 "andis. $dst, $src1, $src2", IIC_IntGeneral,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000421 [(set i64:$dst, (and i64:$src1, imm16ShiftedZExt:$src2))]>,
Chris Lattner7e742e42006-06-20 22:34:10 +0000422 isDOT;
Hal Finkel1b58f332013-04-12 18:17:57 +0000423}
Hal Finkel77c8dc12014-01-02 21:26:59 +0000424def ORI8 : DForm_4<24, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000425 "ori $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000426 [(set i64:$dst, (or i64:$src1, immZExt16:$src2))]>;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000427def ORIS8 : DForm_4<25, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000428 "oris $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000429 [(set i64:$dst, (or i64:$src1, imm16ShiftedZExt:$src2))]>;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000430def XORI8 : DForm_4<26, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000431 "xori $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000432 [(set i64:$dst, (xor i64:$src1, immZExt16:$src2))]>;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000433def XORIS8 : DForm_4<27, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000434 "xoris $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000435 [(set i64:$dst, (xor i64:$src1, imm16ShiftedZExt:$src2))]>;
Chris Lattner7e742e42006-06-20 22:34:10 +0000436
Hal Finkele01d3212014-03-24 15:07:28 +0000437let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000438defm ADD8 : XOForm_1r<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000439 "add", "$rT, $rA, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000440 [(set i64:$rT, (add i64:$rA, i64:$rB))]>;
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000441// ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the
442// initial-exec thread-local storage model.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000443def ADD8TLS : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000444 "add $rT, $rA, $rB", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000445 [(set i64:$rT, (add i64:$rA, tglobaltlsaddr:$rB))]>;
Chris Lattner3e549e92007-05-17 06:52:46 +0000446
Hal Finkele01d3212014-03-24 15:07:28 +0000447let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000448defm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000449 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000450 [(set i64:$rT, (addc i64:$rA, i64:$rB))]>,
451 PPC970_DGroup_Cracked;
Hal Finkele01d3212014-03-24 15:07:28 +0000452
Hal Finkel1b58f332013-04-12 18:17:57 +0000453let Defs = [CARRY] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000454def ADDIC8 : DForm_2<12, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000455 "addic $rD, $rA, $imm", IIC_IntGeneral,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000456 [(set i64:$rD, (addc i64:$rA, imm64SExt16:$imm))]>;
Ulrich Weigand99485462013-05-23 22:48:06 +0000457def ADDI8 : DForm_2<14, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000458 "addi $rD, $rA, $imm", IIC_IntSimple,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000459 [(set i64:$rD, (add i64:$rA, imm64SExt16:$imm))]>;
Ulrich Weigand5a02a022013-06-26 13:49:53 +0000460def ADDIS8 : DForm_2<15, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s17imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000461 "addis $rD, $rA, $imm", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000462 [(set i64:$rD, (add i64:$rA, imm16ShiftedSExt:$imm))]>;
Chris Lattner7e742e42006-06-20 22:34:10 +0000463
Dale Johannesen5e9a5c32009-09-18 20:15:22 +0000464let Defs = [CARRY] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000465def SUBFIC8: DForm_2< 8, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000466 "subfic $rD, $rA, $imm", IIC_IntGeneral,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000467 [(set i64:$rD, (subc imm64SExt16:$imm, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000468defm SUBFC8 : XOForm_1r<31, 8, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000469 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000470 [(set i64:$rT, (subc i64:$rB, i64:$rA))]>,
471 PPC970_DGroup_Cracked;
Dale Johannesen5e9a5c32009-09-18 20:15:22 +0000472}
Ulrich Weigand136ac222013-04-26 16:53:15 +0000473defm SUBF8 : XOForm_1r<31, 40, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000474 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000475 [(set i64:$rT, (sub i64:$rB, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000476defm NEG8 : XOForm_3r<31, 104, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000477 "neg", "$rT, $rA", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000478 [(set i64:$rT, (ineg i64:$rA))]>;
Hal Finkel1b58f332013-04-12 18:17:57 +0000479let Uses = [CARRY] in {
Hal Finkele01d3212014-03-24 15:07:28 +0000480let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000481defm ADDE8 : XOForm_1rc<31, 138, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000482 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000483 [(set i64:$rT, (adde i64:$rA, i64:$rB))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000484defm ADDME8 : XOForm_3rc<31, 234, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000485 "addme", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000486 [(set i64:$rT, (adde i64:$rA, -1))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000487defm ADDZE8 : XOForm_3rc<31, 202, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000488 "addze", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000489 [(set i64:$rT, (adde i64:$rA, 0))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000490defm SUBFE8 : XOForm_1rc<31, 136, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000491 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000492 [(set i64:$rT, (sube i64:$rB, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000493defm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000494 "subfme", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000495 [(set i64:$rT, (sube -1, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000496defm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000497 "subfze", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000498 [(set i64:$rT, (sube 0, i64:$rA))]>;
Dale Johannesen5e9a5c32009-09-18 20:15:22 +0000499}
Hal Finkelb4b99e52013-12-17 23:05:18 +0000500} // isCodeGenOnly
Chris Lattner3e549e92007-05-17 06:52:46 +0000501
Hal Finkelb4b99e52013-12-17 23:05:18 +0000502// FIXME: Duplicating this for the asm parser should be unnecessary, but the
503// previous definition must be marked as CodeGen only to prevent decoding
504// conflicts.
505let isAsmParserOnly = 1 in
506def ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
507 "add $rT, $rA, $rB", IIC_IntSimple, []>;
Chris Lattner2d4e8f72006-06-20 21:23:06 +0000508
Hal Finkele01d3212014-03-24 15:07:28 +0000509let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000510defm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000511 "mulhd", "$rT, $rA, $rB", IIC_IntMulHW,
Hal Finkel654d43b2013-04-12 02:18:09 +0000512 [(set i64:$rT, (mulhs i64:$rA, i64:$rB))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000513defm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000514 "mulhdu", "$rT, $rA, $rB", IIC_IntMulHWU,
Hal Finkel654d43b2013-04-12 02:18:09 +0000515 [(set i64:$rT, (mulhu i64:$rA, i64:$rB))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000516} // isCommutable
Hal Finkel654d43b2013-04-12 02:18:09 +0000517}
518} // Interpretation64Bit
Chris Lattnerb4299832006-06-16 20:22:01 +0000519
Craig Topperc50d64b2014-11-26 00:46:26 +0000520let isCompare = 1, hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000521 def CMPD : XForm_16_ext<31, 0, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000522 "cmpd $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000523 def CMPLD : XForm_16_ext<31, 32, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000524 "cmpld $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000525 def CMPDI : DForm_5_ext<11, (outs crrc:$crD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000526 "cmpdi $crD, $rA, $imm", IIC_IntCompare>, isPPC64;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000527 def CMPLDI : DForm_6_ext<10, (outs crrc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000528 "cmpldi $dst, $src1, $src2",
529 IIC_IntCompare>, isPPC64;
Hal Finkel95e6ea62013-04-15 02:37:46 +0000530}
Chris Lattnerb4299832006-06-16 20:22:01 +0000531
Craig Topperc50d64b2014-11-26 00:46:26 +0000532let hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000533defm SLD : XForm_6r<31, 27, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000534 "sld", "$rA, $rS, $rB", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000535 [(set i64:$rA, (PPCshl i64:$rS, i32:$rB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000536defm SRD : XForm_6r<31, 539, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000537 "srd", "$rA, $rS, $rB", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000538 [(set i64:$rA, (PPCsrl i64:$rS, i32:$rB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000539defm SRAD : XForm_6rc<31, 794, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000540 "srad", "$rA, $rS, $rB", IIC_IntRotateD,
Hal Finkel1b58f332013-04-12 18:17:57 +0000541 [(set i64:$rA, (PPCsra i64:$rS, i32:$rB))]>, isPPC64;
Chris Lattner43c0eb82006-12-06 21:46:13 +0000542
Hal Finkelb4b99e52013-12-17 23:05:18 +0000543let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000544defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000545 "extsb", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000546 [(set i64:$rA, (sext_inreg i64:$rS, i8))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000547defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000548 "extsh", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000549 [(set i64:$rA, (sext_inreg i64:$rS, i16))]>;
Hal Finkel4c6658f2014-12-12 23:59:36 +0000550
551defm SLW8 : XForm_6r<31, 24, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
552 "slw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
553defm SRW8 : XForm_6r<31, 536, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
554 "srw", "$rA, $rS, $rB", IIC_IntGeneral, []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000555} // Interpretation64Bit
556
Bill Schmidtd89f6782013-08-26 19:42:51 +0000557// For fast-isel:
558let isCodeGenOnly = 1 in {
559def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000560 "extsb $rA, $rS", IIC_IntSimple, []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000561def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000562 "extsh $rA, $rS", IIC_IntSimple, []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000563} // isCodeGenOnly for fast-isel
564
Ulrich Weigand136ac222013-04-26 16:53:15 +0000565defm EXTSW : XForm_11r<31, 986, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000566 "extsw", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000567 [(set i64:$rA, (sext_inreg i64:$rS, i32))]>, isPPC64;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000568let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000569defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000570 "extsw", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000571 [(set i64:$rA, (sext i32:$rS))]>, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +0000572
Ulrich Weigand136ac222013-04-26 16:53:15 +0000573defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000574 "sradi", "$rA, $rS, $SH", IIC_IntRotateDI,
Hal Finkel1b58f332013-04-12 18:17:57 +0000575 [(set i64:$rA, (sra i64:$rS, (i32 imm:$SH)))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000576defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000577 "cntlzd", "$rA, $rS", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000578 [(set i64:$rA, (ctlz i64:$rS))]>;
Hal Finkel884bde302013-11-20 20:54:55 +0000579def POPCNTD : XForm_11<31, 506, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000580 "popcntd $rA, $rS", IIC_IntGeneral,
Hal Finkel884bde302013-11-20 20:54:55 +0000581 [(set i64:$rA, (ctpop i64:$rS))]>;
Chris Lattner88102412007-03-25 04:44:03 +0000582
Hal Finkel290376d2013-04-01 15:58:15 +0000583// popcntw also does a population count on the high 32 bits (storing the
584// results in the high 32-bits of the output). We'll ignore that here (which is
585// safe because we never separately use the high part of the 64-bit registers).
Hal Finkel884bde302013-11-20 20:54:55 +0000586def POPCNTW : XForm_11<31, 378, (outs gprc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000587 "popcntw $rA, $rS", IIC_IntGeneral,
Hal Finkel884bde302013-11-20 20:54:55 +0000588 [(set i32:$rA, (ctpop i32:$rS))]>;
Hal Finkel290376d2013-04-01 15:58:15 +0000589
Ulrich Weigand136ac222013-04-26 16:53:15 +0000590defm DIVD : XOForm_1r<31, 489, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000591 "divd", "$rT, $rA, $rB", IIC_IntDivD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000592 [(set i64:$rT, (sdiv i64:$rA, i64:$rB))]>, isPPC64,
593 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000594defm DIVDU : XOForm_1r<31, 457, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000595 "divdu", "$rT, $rA, $rB", IIC_IntDivD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000596 [(set i64:$rT, (udiv i64:$rA, i64:$rB))]>, isPPC64,
597 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Hal Finkele01d3212014-03-24 15:07:28 +0000598let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000599defm MULLD : XOForm_1r<31, 233, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000600 "mulld", "$rT, $rA, $rB", IIC_IntMulHD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000601 [(set i64:$rT, (mul i64:$rA, i64:$rB))]>, isPPC64;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000602let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Hal Finkel11b9e4522013-08-06 17:03:03 +0000603def MULLI8 : DForm_2<7, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000604 "mulli $rD, $rA, $imm", IIC_IntMulLI,
Hal Finkel11b9e4522013-08-06 17:03:03 +0000605 [(set i64:$rD, (mul i64:$rA, imm64SExt16:$imm))]>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000606}
Chris Lattner7ecbd302006-06-26 23:53:10 +0000607
Craig Topperc50d64b2014-11-26 00:46:26 +0000608let hasSideEffects = 0 in {
Chris Lattner57711562006-11-15 23:24:18 +0000609let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000610defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$rA),
611 (ins g8rc:$rSi, g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000612 "rldimi", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000613 []>, isPPC64, RegConstraint<"$rSi = $rA">,
614 NoEncode<"$rSi">;
Chris Lattnerb4299832006-06-16 20:22:01 +0000615}
616
617// Rotate instructions.
Ulrich Weigandfa451ba2013-04-26 15:39:12 +0000618defm RLDCL : MDSForm_1r<30, 8,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000619 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000620 "rldcl", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000621 []>, isPPC64;
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000622defm RLDCR : MDSForm_1r<30, 9,
623 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000624 "rldcr", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000625 []>, isPPC64;
Hal Finkel654d43b2013-04-12 02:18:09 +0000626defm RLDICL : MDForm_1r<30, 0,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000627 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000628 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000629 []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000630// For fast-isel:
631let isCodeGenOnly = 1 in
632def RLDICL_32_64 : MDForm_1<30, 0,
633 (outs g8rc:$rA),
634 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000635 "rldicl $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Bill Schmidtd89f6782013-08-26 19:42:51 +0000636 []>, isPPC64;
637// End fast-isel.
Hal Finkel654d43b2013-04-12 02:18:09 +0000638defm RLDICR : MDForm_1r<30, 1,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000639 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000640 "rldicr", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000641 []>, isPPC64;
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000642defm RLDIC : MDForm_1r<30, 2,
643 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000644 "rldic", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000645 []>, isPPC64;
Hal Finkelac9df3d2011-12-07 06:34:06 +0000646
Hal Finkelb4b99e52013-12-17 23:05:18 +0000647let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000648defm RLWINM8 : MForm_2r<21, (outs g8rc:$rA),
649 (ins g8rc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000650 "rlwinm", "$rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000651 []>;
Hal Finkelac9df3d2011-12-07 06:34:06 +0000652
Hal Finkel4c6658f2014-12-12 23:59:36 +0000653defm RLWNM8 : MForm_2r<23, (outs g8rc:$rA),
654 (ins g8rc:$rS, g8rc:$rB, u5imm:$MB, u5imm:$ME),
655 "rlwnm", "$rA, $rS, $rB, $MB, $ME", IIC_IntGeneral,
656 []>;
657
Hal Finkel940ab932014-02-28 00:27:01 +0000658// RLWIMI can be commuted if the rotate amount is zero.
659let Interpretation64Bit = 1, isCodeGenOnly = 1 in
660defm RLWIMI8 : MForm_2r<20, (outs g8rc:$rA),
661 (ins g8rc:$rSi, g8rc:$rS, u5imm:$SH, u5imm:$MB,
662 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
663 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
664 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
Hal Finkel940ab932014-02-28 00:27:01 +0000665
Hal Finkel7795e472013-04-07 15:06:53 +0000666let isSelect = 1 in
Ulrich Weigand84ee76a2012-11-13 19:14:19 +0000667def ISEL8 : AForm_4<31, 15,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000668 (outs g8rc:$rT), (ins g8rc_nox0:$rA, g8rc:$rB, crbitrc:$cond),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000669 "isel $rT, $rA, $rB, $cond", IIC_IntGeneral,
Hal Finkel460e94d2012-06-22 23:10:08 +0000670 []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000671} // Interpretation64Bit
Craig Topperc50d64b2014-11-26 00:46:26 +0000672} // hasSideEffects = 0
Chris Lattner7ecbd302006-06-26 23:53:10 +0000673} // End FXU Operations.
Chris Lattnerb4299832006-06-16 20:22:01 +0000674
675
676//===----------------------------------------------------------------------===//
677// Load/Store instructions.
678//
679
680
Chris Lattner96aecb52006-07-14 04:42:02 +0000681// Sign extending loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000682let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000683let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000684def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000685 "lha $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000686 [(set i64:$rD, (sextloadi16 iaddr:$src))]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000687 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000688def LWA : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000689 "lwa $rD, $src", IIC_LdStLWA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000690 [(set i64:$rD,
Hal Finkelb09680b2013-03-18 23:00:58 +0000691 (aligned4sextloadi32 ixaddr:$src))]>, isPPC64,
Chris Lattner94d18df2006-06-20 00:38:36 +0000692 PPC970_DGroup_Cracked;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000693let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000694def LHAX8: XForm_1<31, 343, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000695 "lhax $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000696 [(set i64:$rD, (sextloadi16 xaddr:$src))]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000697 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000698def LWAX : XForm_1<31, 341, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000699 "lwax $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000700 [(set i64:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
Chris Lattnerb4299832006-06-16 20:22:01 +0000701 PPC970_DGroup_Cracked;
Bill Schmidtccecf262013-08-30 02:29:45 +0000702// For fast-isel:
703let isCodeGenOnly = 1, mayLoad = 1 in {
704def LWA_32 : DSForm_1<58, 2, (outs gprc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000705 "lwa $rD, $src", IIC_LdStLWA, []>, isPPC64,
Bill Schmidtccecf262013-08-30 02:29:45 +0000706 PPC970_DGroup_Cracked;
707def LWAX_32 : XForm_1<31, 341, (outs gprc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000708 "lwax $rD, $src", IIC_LdStLHA, []>, isPPC64,
Bill Schmidtccecf262013-08-30 02:29:45 +0000709 PPC970_DGroup_Cracked;
710} // end fast-isel isCodeGenOnly
Chris Lattner96aecb52006-07-14 04:42:02 +0000711
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000712// Update forms.
Craig Topperc50d64b2014-11-26 00:46:26 +0000713let mayLoad = 1, hasSideEffects = 0 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000714let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000715def LHAU8 : DForm_1<43, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Ulrich Weigandf8030092013-03-19 19:52:30 +0000716 (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000717 "lhau $rD, $addr", IIC_LdStLHAU,
Ulrich Weigandf8030092013-03-19 19:52:30 +0000718 []>, RegConstraint<"$addr.reg = $ea_result">,
Chris Lattner57711562006-11-15 23:24:18 +0000719 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000720// NO LWAU!
721
Hal Finkelb4b99e52013-12-17 23:05:18 +0000722let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000723def LHAUX8 : XForm_1<31, 375, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000724 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000725 "lhaux $rD, $addr", IIC_LdStLHAUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000726 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000727 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000728def LWAUX : XForm_1<31, 373, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000729 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000730 "lwaux $rD, $addr", IIC_LdStLHAUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000731 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000732 NoEncode<"$ea_result">, isPPC64;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000733}
Ulrich Weigand01dd4c12013-03-19 19:53:27 +0000734}
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000735
Hal Finkelb4b99e52013-12-17 23:05:18 +0000736let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Chris Lattner96aecb52006-07-14 04:42:02 +0000737// Zero extending loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000738let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000739def LBZ8 : DForm_1<34, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000740 "lbz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000741 [(set i64:$rD, (zextloadi8 iaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000742def LHZ8 : DForm_1<40, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000743 "lhz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000744 [(set i64:$rD, (zextloadi16 iaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000745def LWZ8 : DForm_1<32, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000746 "lwz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000747 [(set i64:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
Chris Lattner96aecb52006-07-14 04:42:02 +0000748
Ulrich Weigand136ac222013-04-26 16:53:15 +0000749def LBZX8 : XForm_1<31, 87, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000750 "lbzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000751 [(set i64:$rD, (zextloadi8 xaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000752def LHZX8 : XForm_1<31, 279, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000753 "lhzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000754 [(set i64:$rD, (zextloadi16 xaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000755def LWZX8 : XForm_1<31, 23, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000756 "lwzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000757 [(set i64:$rD, (zextloadi32 xaddr:$src))]>;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000758
759
760// Update forms.
Craig Topperc50d64b2014-11-26 00:46:26 +0000761let mayLoad = 1, hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000762def LBZU8 : DForm_1<35, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000763 "lbzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000764 []>, RegConstraint<"$addr.reg = $ea_result">,
765 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000766def LHZU8 : DForm_1<41, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000767 "lhzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000768 []>, RegConstraint<"$addr.reg = $ea_result">,
769 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000770def LWZU8 : DForm_1<33, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000771 "lwzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000772 []>, RegConstraint<"$addr.reg = $ea_result">,
773 NoEncode<"$ea_result">;
Hal Finkelca542be2012-06-20 15:43:03 +0000774
Ulrich Weigand136ac222013-04-26 16:53:15 +0000775def LBZUX8 : XForm_1<31, 119, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000776 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000777 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000778 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000779 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000780def LHZUX8 : XForm_1<31, 311, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000781 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000782 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000783 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000784 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000785def LWZUX8 : XForm_1<31, 55, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000786 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000787 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000788 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000789 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000790}
Dan Gohmanae3ba452008-12-03 02:30:17 +0000791}
Hal Finkel654d43b2013-04-12 02:18:09 +0000792} // Interpretation64Bit
Chris Lattner96aecb52006-07-14 04:42:02 +0000793
794
795// Full 8-byte loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000796let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000797def LD : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000798 "ld $rD, $src", IIC_LdStLD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000799 [(set i64:$rD, (aligned4load ixaddr:$src))]>, isPPC64;
Ulrich Weigandc8c2ea22014-10-31 10:33:14 +0000800// The following four definitions are selected for small code model only.
Bill Schmidt34627e32012-11-27 17:35:46 +0000801// Otherwise, we need to create two instructions to form a 32-bit offset,
802// so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
Ulrich Weigand136ac222013-04-26 16:53:15 +0000803def LDtoc: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000804 "#LDtoc",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000805 [(set i64:$rD,
806 (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000807def LDtocJTI: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000808 "#LDtocJTI",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000809 [(set i64:$rD,
810 (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000811def LDtocCPT: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000812 "#LDtocCPT",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000813 [(set i64:$rD,
814 (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigandc8c2ea22014-10-31 10:33:14 +0000815def LDtocBA: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
816 "#LDtocCPT",
817 [(set i64:$rD,
818 (PPCtoc_entry tblockaddress:$disp, i64:$reg))]>, isPPC64;
Hal Finkela3e6ed22012-02-24 17:54:01 +0000819
Bill Schmidt3755e172014-08-15 01:25:26 +0000820let hasSideEffects = 1, isCodeGenOnly = 1, RST = 2, Defs = [X2] in
Ulrich Weigandad0cb912014-06-18 17:52:49 +0000821def LDinto_toc: DSForm_1<58, 0, (outs), (ins memrix:$src),
822 "ld 2, $src", IIC_LdStLD,
823 [(PPCload_toc ixaddr:$src)]>, isPPC64;
824
Ulrich Weigand136ac222013-04-26 16:53:15 +0000825def LDX : XForm_1<31, 21, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000826 "ldx $rD, $src", IIC_LdStLD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000827 [(set i64:$rD, (load xaddr:$src))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000828def LDBRX : XForm_1<31, 532, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000829 "ldbrx $rD, $src", IIC_LdStLoad,
Hal Finkel31d29562013-03-28 19:25:55 +0000830 [(set i64:$rD, (PPClbrx xoaddr:$src, i64))]>, isPPC64;
831
Craig Topperc50d64b2014-11-26 00:46:26 +0000832let mayLoad = 1, hasSideEffects = 0 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000833def LDU : DSForm_1<58, 1, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memrix:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000834 "ldu $rD, $addr", IIC_LdStLDU,
Chris Lattner57711562006-11-15 23:24:18 +0000835 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
836 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000837
Ulrich Weigand136ac222013-04-26 16:53:15 +0000838def LDUX : XForm_1<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000839 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000840 "ldux $rD, $addr", IIC_LdStLDUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000841 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000842 NoEncode<"$ea_result">, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +0000843}
Hal Finkeld71cc3a2013-04-07 06:30:47 +0000844}
Chris Lattner96aecb52006-07-14 04:42:02 +0000845
Tilmann Scheller79fef932009-12-18 13:00:15 +0000846def : Pat<(PPCload ixaddr:$src),
847 (LD ixaddr:$src)>;
848def : Pat<(PPCload xaddr:$src),
849 (LDX xaddr:$src)>;
850
Bill Schmidt27917782013-02-21 17:12:27 +0000851// Support for medium and large code model.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000852def ADDIStocHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
Bill Schmidt34627e32012-11-27 17:35:46 +0000853 "#ADDIStocHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000854 [(set i64:$rD,
855 (PPCaddisTocHA i64:$reg, tglobaladdr:$disp))]>,
Bill Schmidt34627e32012-11-27 17:35:46 +0000856 isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000857def LDtocL: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
Bill Schmidt34627e32012-11-27 17:35:46 +0000858 "#LDtocL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000859 [(set i64:$rD,
860 (PPCldTocL tglobaladdr:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000861def ADDItocL: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
Bill Schmidt34627e32012-11-27 17:35:46 +0000862 "#ADDItocL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000863 [(set i64:$rD,
864 (PPCaddiTocL i64:$reg, tglobaladdr:$disp))]>, isPPC64;
Bill Schmidt34627e32012-11-27 17:35:46 +0000865
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000866// Support for thread-local storage.
Ulrich Weigand99485462013-05-23 22:48:06 +0000867def ADDISgotTprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000868 "#ADDISgotTprelHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000869 [(set i64:$rD,
870 (PPCaddisGotTprelHA i64:$reg,
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000871 tglobaltlsaddr:$disp))]>,
872 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000873def LDgotTprelL: Pseudo<(outs g8rc:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000874 "#LDgotTprelL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000875 [(set i64:$rD,
876 (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000877 isPPC64;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +0000878def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
879 (ADD8TLS $in, tglobaltlsaddr:$g)>;
Ulrich Weigand99485462013-05-23 22:48:06 +0000880def ADDIStlsgdHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000881 "#ADDIStlsgdHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000882 [(set i64:$rD,
883 (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000884 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000885def ADDItlsgdL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000886 "#ADDItlsgdL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000887 [(set i64:$rD,
888 (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000889 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000890def ADDIStlsldHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000891 "#ADDIStlsldHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000892 [(set i64:$rD,
893 (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000894 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000895def ADDItlsldL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000896 "#ADDItlsldL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000897 [(set i64:$rD,
898 (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000899 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000900def ADDISdtprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000901 "#ADDISdtprelHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000902 [(set i64:$rD,
903 (PPCaddisDtprelHA i64:$reg,
Bill Schmidt9ed4dbc2012-12-13 20:57:10 +0000904 tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000905 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000906def ADDIdtprelL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000907 "#ADDIdtprelL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000908 [(set i64:$rD,
909 (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000910 isPPC64;
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000911
Chris Lattnere20f3802008-01-06 05:53:26 +0000912let PPC970_Unit = 2 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000913let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Chris Lattner96aecb52006-07-14 04:42:02 +0000914// Truncating stores.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000915def STB8 : DForm_1<38, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000916 "stb $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000917 [(truncstorei8 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000918def STH8 : DForm_1<44, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000919 "sth $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000920 [(truncstorei16 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000921def STW8 : DForm_1<36, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000922 "stw $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000923 [(truncstorei32 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000924def STBX8 : XForm_8<31, 215, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000925 "stbx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000926 [(truncstorei8 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000927 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000928def STHX8 : XForm_8<31, 407, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000929 "sthx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000930 [(truncstorei16 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000931 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000932def STWX8 : XForm_8<31, 151, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000933 "stwx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000934 [(truncstorei32 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000935 PPC970_DGroup_Cracked;
Hal Finkel654d43b2013-04-12 02:18:09 +0000936} // Interpretation64Bit
937
Chris Lattnere742d9a2006-11-16 00:57:19 +0000938// Normal 8-byte stores.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000939def STD : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000940 "std $rS, $dst", IIC_LdStSTD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000941 [(aligned4store i64:$rS, ixaddr:$dst)]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000942def STDX : XForm_8<31, 149, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000943 "stdx $rS, $dst", IIC_LdStSTD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000944 [(store i64:$rS, xaddr:$dst)]>, isPPC64,
Chris Lattnere742d9a2006-11-16 00:57:19 +0000945 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000946def STDBRX: XForm_8<31, 660, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000947 "stdbrx $rS, $dst", IIC_LdStStore,
Hal Finkel31d29562013-03-28 19:25:55 +0000948 [(PPCstbrx i64:$rS, xoaddr:$dst, i64)]>, isPPC64,
949 PPC970_DGroup_Cracked;
Chris Lattnerb4299832006-06-16 20:22:01 +0000950}
951
Ulrich Weigandd8501672013-03-19 19:52:04 +0000952// Stores with Update (pre-inc).
953let PPC970_Unit = 2, mayStore = 1 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000954let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000955def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000956 "stbu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000957 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000958def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000959 "sthu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000960 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000961def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000962 "stwu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000963 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigandd8501672013-03-19 19:52:04 +0000964
Ulrich Weigand136ac222013-04-26 16:53:15 +0000965def STBUX8: XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000966 "stbux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000967 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000968 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000969def STHUX8: XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000970 "sthux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000971 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000972 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000973def STWUX8: XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000974 "stwux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000975 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000976 PPC970_DGroup_Cracked;
Hal Finkel654d43b2013-04-12 02:18:09 +0000977} // Interpretation64Bit
978
Hal Finkelb4b99e52013-12-17 23:05:18 +0000979def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrix:$dst),
980 "stdu $rS, $dst", IIC_LdStSTDU, []>,
981 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">,
982 isPPC64;
983
Ulrich Weigand136ac222013-04-26 16:53:15 +0000984def STDUX : XForm_8<31, 181, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel46402a42013-11-30 20:41:13 +0000985 "stdux $rS, $dst", IIC_LdStSTDUX, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000986 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000987 PPC970_DGroup_Cracked, isPPC64;
988}
989
990// Patterns to match the pre-inc stores. We can't put the patterns on
991// the instruction definitions directly as ISel wants the address base
992// and offset to be separate operands, not a single complex operand.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +0000993def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
994 (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
995def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
996 (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
997def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
998 (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
999def : Pat<(aligned4pre_store i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
1000 (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
Ulrich Weigandd8501672013-03-19 19:52:04 +00001001
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001002def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1003 (STBUX8 $rS, $ptrreg, $ptroff)>;
1004def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1005 (STHUX8 $rS, $ptrreg, $ptroff)>;
1006def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1007 (STWUX8 $rS, $ptrreg, $ptroff)>;
1008def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1009 (STDUX $rS, $ptrreg, $ptroff)>;
Chris Lattnerb4299832006-06-16 20:22:01 +00001010
1011
1012//===----------------------------------------------------------------------===//
1013// Floating point instructions.
1014//
1015
1016
Craig Topperc50d64b2014-11-26 00:46:26 +00001017let PPC970_Unit = 3, hasSideEffects = 0,
Hal Finkel654d43b2013-04-12 02:18:09 +00001018 Uses = [RM] in { // FPU Operations.
Ulrich Weigand136ac222013-04-26 16:53:15 +00001019defm FCFID : XForm_26r<63, 846, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001020 "fcfid", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001021 [(set f64:$frD, (PPCfcfid f64:$frB))]>, isPPC64;
David Majnemer6ad26d32013-09-26 04:11:24 +00001022defm FCTID : XForm_26r<63, 814, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001023 "fctid", "$frD, $frB", IIC_FPGeneral,
David Majnemer08249a32013-09-26 05:22:11 +00001024 []>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001025defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001026 "fctidz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001027 [(set f64:$frD, (PPCfctidz f64:$frB))]>, isPPC64;
Hal Finkelf6d45f22013-04-01 17:52:07 +00001028
Ulrich Weigand136ac222013-04-26 16:53:15 +00001029defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001030 "fcfidu", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001031 [(set f64:$frD, (PPCfcfidu f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001032defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001033 "fcfids", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001034 [(set f32:$frD, (PPCfcfids f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001035defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001036 "fcfidus", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001037 [(set f32:$frD, (PPCfcfidus f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001038defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001039 "fctiduz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001040 [(set f64:$frD, (PPCfctiduz f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001041defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001042 "fctiwuz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001043 [(set f64:$frD, (PPCfctiwuz f64:$frB))]>, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +00001044}
1045
1046
1047//===----------------------------------------------------------------------===//
1048// Instruction Patterns
1049//
Chris Lattner7e742e42006-06-20 22:34:10 +00001050
Chris Lattnerb4299832006-06-16 20:22:01 +00001051// Extensions and truncates to/from 32-bit regs.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001052def : Pat<(i64 (zext i32:$in)),
1053 (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
Hal Finkel2edfbdd2012-06-09 22:10:19 +00001054 0, 32)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001055def : Pat<(i64 (anyext i32:$in)),
1056 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
1057def : Pat<(i32 (trunc i64:$in)),
1058 (EXTRACT_SUBREG $in, sub_32)>;
Chris Lattnerb4299832006-06-16 20:22:01 +00001059
Hal Finkel940ab932014-02-28 00:27:01 +00001060// Implement the 'not' operation with the NOR instruction.
1061// (we could use the default xori pattern, but nor has lower latency on some
1062// cores (such as the A2)).
1063def i64not : OutPatFrag<(ops node:$in),
1064 (NOR8 $in, $in)>;
1065def : Pat<(not i64:$in),
1066 (i64not $in)>;
1067
Chris Lattner96aecb52006-07-14 04:42:02 +00001068// Extending loads with i64 targets.
Evan Chenge71fe34d2006-10-09 20:57:25 +00001069def : Pat<(zextloadi1 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001070 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001071def : Pat<(zextloadi1 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001072 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001073def : Pat<(extloadi1 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001074 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001075def : Pat<(extloadi1 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001076 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001077def : Pat<(extloadi8 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001078 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001079def : Pat<(extloadi8 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001080 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001081def : Pat<(extloadi16 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001082 (LHZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001083def : Pat<(extloadi16 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001084 (LHZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001085def : Pat<(extloadi32 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001086 (LWZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001087def : Pat<(extloadi32 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001088 (LWZX8 xaddr:$src)>;
1089
Chris Lattner20b5a2b2008-03-07 20:18:24 +00001090// Standard shifts. These are represented separately from the real shifts above
1091// so that we can distinguish between shifts that allow 6-bit and 7-bit shift
1092// amounts.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001093def : Pat<(sra i64:$rS, i32:$rB),
1094 (SRAD $rS, $rB)>;
1095def : Pat<(srl i64:$rS, i32:$rB),
1096 (SRD $rS, $rB)>;
1097def : Pat<(shl i64:$rS, i32:$rB),
1098 (SLD $rS, $rB)>;
Chris Lattner20b5a2b2008-03-07 20:18:24 +00001099
Chris Lattnerb4299832006-06-16 20:22:01 +00001100// SHL/SRL
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001101def : Pat<(shl i64:$in, (i32 imm:$imm)),
1102 (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
1103def : Pat<(srl i64:$in, (i32 imm:$imm)),
1104 (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
Chris Lattner2d4e8f72006-06-20 21:23:06 +00001105
Evan Cheng4dbd9f22007-09-04 20:20:29 +00001106// ROTL
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001107def : Pat<(rotl i64:$in, i32:$sh),
1108 (RLDCL $in, $sh, 0)>;
1109def : Pat<(rotl i64:$in, (i32 imm:$imm)),
1110 (RLDICL $in, imm:$imm, 0)>;
Evan Cheng4dbd9f22007-09-04 20:20:29 +00001111
Chris Lattner2d4e8f72006-06-20 21:23:06 +00001112// Hi and Lo for Darwin Global Addresses.
1113def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
1114def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
1115def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
1116def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
1117def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
1118def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
Bob Wilsonf84f7102009-11-04 21:31:18 +00001119def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
1120def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001121def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
1122 (ADDIS8 $in, tglobaltlsaddr:$g)>;
1123def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
Ulrich Weigand35f9fdf2013-03-26 10:55:20 +00001124 (ADDI8 $in, tglobaltlsaddr:$g)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001125def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
1126 (ADDIS8 $in, tglobaladdr:$g)>;
1127def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
1128 (ADDIS8 $in, tconstpool:$g)>;
1129def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
1130 (ADDIS8 $in, tjumptable:$g)>;
1131def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
1132 (ADDIS8 $in, tblockaddress:$g)>;
Hal Finkelb09680b2013-03-18 23:00:58 +00001133
1134// Patterns to match r+r indexed loads and stores for
1135// addresses without at least 4-byte alignment.
1136def : Pat<(i64 (unaligned4sextloadi32 xoaddr:$src)),
1137 (LWAX xoaddr:$src)>;
1138def : Pat<(i64 (unaligned4load xoaddr:$src)),
1139 (LDX xoaddr:$src)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001140def : Pat<(unaligned4store i64:$rS, xoaddr:$dst),
1141 (STDX $rS, xoaddr:$dst)>;
Hal Finkelb09680b2013-03-18 23:00:58 +00001142
Robin Morissete1ca44b2014-10-02 22:27:07 +00001143// 64-bits atomic loads and stores
1144def : Pat<(atomic_load_64 ixaddr:$src), (LD memrix:$src)>;
1145def : Pat<(atomic_load_64 xaddr:$src), (LDX memrr:$src)>;
1146
1147def : Pat<(atomic_store_64 ixaddr:$ptr, i64:$val), (STD g8rc:$val, memrix:$ptr)>;
1148def : Pat<(atomic_store_64 xaddr:$ptr, i64:$val), (STDX g8rc:$val, memrr:$ptr)>;