blob: 9318f70f4305bcfb2559a37a0eb2c69da67a14a4 [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
Evan Cheng32e376f2008-07-12 02:23:19 +0000191// Atomic operations
Dan Gohman453d64c2009-10-29 18:10:34 +0000192let usesCustomInserter = 1 in {
Jakob Stoklund Olesen86e1a652011-04-04 17:07:09 +0000193 let Defs = [CR0] in {
Evan Cheng32e376f2008-07-12 02:23:19 +0000194 def ATOMIC_LOAD_ADD_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000195 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_ADD_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000196 [(set i64:$dst, (atomic_load_add_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000197 def ATOMIC_LOAD_SUB_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000198 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_SUB_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000199 [(set i64:$dst, (atomic_load_sub_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000200 def ATOMIC_LOAD_OR_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000201 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_OR_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000202 [(set i64:$dst, (atomic_load_or_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000203 def ATOMIC_LOAD_XOR_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000204 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_XOR_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000205 [(set i64:$dst, (atomic_load_xor_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000206 def ATOMIC_LOAD_AND_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000207 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_AND_i64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000208 [(set i64:$dst, (atomic_load_and_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000209 def ATOMIC_LOAD_NAND_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000210 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$incr), "#ATOMIC_LOAD_NAND_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000211 [(set i64:$dst, (atomic_load_nand_64 xoaddr:$ptr, i64:$incr))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000212
Dale Johannesendec51702008-08-22 03:49:10 +0000213 def ATOMIC_CMP_SWAP_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000214 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$old, g8rc:$new), "#ATOMIC_CMP_SWAP_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000215 [(set i64:$dst, (atomic_cmp_swap_64 xoaddr:$ptr, i64:$old, i64:$new))]>;
Dale Johannesend4eb0522008-08-25 22:34:37 +0000216
Dale Johannesen765065c2008-08-25 21:09:52 +0000217 def ATOMIC_SWAP_I64 : Pseudo<
Ulrich Weigand136ac222013-04-26 16:53:15 +0000218 (outs g8rc:$dst), (ins memrr:$ptr, g8rc:$new), "#ATOMIC_SWAP_I64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000219 [(set i64:$dst, (atomic_swap_64 xoaddr:$ptr, i64:$new))]>;
Dale Johannesendec51702008-08-22 03:49:10 +0000220 }
Evan Cheng5102bd92008-04-19 02:30:38 +0000221}
222
Evan Cheng32e376f2008-07-12 02:23:19 +0000223// Instructions to support atomic operations
Ulrich Weigand136ac222013-04-26 16:53:15 +0000224def LDARX : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000225 "ldarx $rD, $ptr", IIC_LdStLDARX,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000226 [(set i64:$rD, (PPClarx xoaddr:$ptr))]>;
Evan Cheng32e376f2008-07-12 02:23:19 +0000227
228let Defs = [CR0] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000229def STDCX : XForm_1<31, 214, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000230 "stdcx. $rS, $dst", IIC_LdStSTDCX,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000231 [(PPCstcx i64:$rS, xoaddr:$dst)]>,
Evan Cheng32e376f2008-07-12 02:23:19 +0000232 isDOT;
233
Hal Finkelb4b99e52013-12-17 23:05:18 +0000234let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000235let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000236def TCRETURNdi8 :Pseudo< (outs),
Jakob Stoklund Olesened6c0402012-07-13 20:44:29 +0000237 (ins calltarget:$dst, i32imm:$offset),
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000238 "#TC_RETURNd8 $dst $offset",
239 []>;
240
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000241let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000242def TCRETURNai8 :Pseudo<(outs), (ins abscalltarget:$func, i32imm:$offset),
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000243 "#TC_RETURNa8 $func $offset",
244 [(PPCtc_return (i64 imm:$func), imm:$offset)]>;
245
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000246let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
Jakob Stoklund Olesened6c0402012-07-13 20:44:29 +0000247def TCRETURNri8 : Pseudo<(outs), (ins CTRRC8:$dst, i32imm:$offset),
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000248 "#TC_RETURNr8 $dst $offset",
249 []>;
250
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000251let isTerminator = 1, isBarrier = 1, PPC970_Unit = 7, isBranch = 1,
Ulrich Weigand410a40b2013-03-26 10:53:03 +0000252 isIndirectBranch = 1, isCall = 1, isReturn = 1, Uses = [CTR8, RM] in
Hal Finkel3e5a3602013-11-27 23:26:09 +0000253def TAILBCTR8 : XLForm_2_ext<19, 528, 20, 0, 0, (outs), (ins), "bctr", IIC_BrB,
254 []>,
Ulrich Weigand410a40b2013-03-26 10:53:03 +0000255 Requires<[In64BitMode]>;
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000256
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000257let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000258 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000259def TAILB8 : IForm<18, 0, 0, (outs), (ins calltarget:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000260 "b $dst", IIC_BrB,
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000261 []>;
262
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000263let isBranch = 1, isTerminator = 1, hasCtrlDep = 1, PPC970_Unit = 7,
Dale Johannesen98aa9d32008-10-29 18:26:45 +0000264 isBarrier = 1, isCall = 1, isReturn = 1, Uses = [RM] in
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000265def TAILBA8 : IForm<18, 0, 0, (outs), (ins abscalltarget:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000266 "ba $dst", IIC_BrB,
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000267 []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000268} // Interpretation64Bit
Ulrich Weigandbbfb0c52013-03-26 10:57:16 +0000269
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000270def : Pat<(PPCtc_return (i64 tglobaladdr:$dst), imm:$imm),
271 (TCRETURNdi8 tglobaladdr:$dst, imm:$imm)>;
272
273def : Pat<(PPCtc_return (i64 texternalsym:$dst), imm:$imm),
274 (TCRETURNdi8 texternalsym:$dst, imm:$imm)>;
275
276def : Pat<(PPCtc_return CTRRC8:$dst, imm:$imm),
277 (TCRETURNri8 CTRRC8:$dst, imm:$imm)>;
278
Hal Finkel96c2d4d2012-06-08 15:38:21 +0000279
Hal Finkel25aab012013-03-28 03:38:08 +0000280// 64-bit CR instructions
Hal Finkelb4b99e52013-12-17 23:05:18 +0000281let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Hal Finkelb47a69a2013-04-07 14:33:13 +0000282let neverHasSideEffects = 1 in {
Ulrich Weigand49f487e2013-07-03 17:59:07 +0000283def MTOCRF8: XFXForm_5a<31, 144, (outs crbitm:$FXM), (ins g8rc:$ST),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000284 "mtocrf $FXM, $ST", IIC_BrMCRX>,
Ulrich Weigand49f487e2013-07-03 17:59:07 +0000285 PPC970_DGroup_First, PPC970_Unit_CRU;
286
287def MTCRF8 : XFXForm_5<31, 144, (outs), (ins i32imm:$FXM, g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000288 "mtcrf $FXM, $rS", IIC_BrMCRX>,
Hal Finkelac9df3d2011-12-07 06:34:06 +0000289 PPC970_MicroCode, PPC970_Unit_CRU;
290
Hal Finkel7fe6a532013-09-12 05:24:49 +0000291let hasExtraSrcRegAllocReq = 1 in // to enable post-ra anti-dep breaking.
Ulrich Weigandd5ebc622013-07-03 17:05:42 +0000292def MFOCRF8: XFXForm_5a<31, 19, (outs g8rc:$rT), (ins crbitm:$FXM),
Hal Finkel46402a42013-11-30 20:41:13 +0000293 "mfocrf $rT, $FXM", IIC_SprMFCRF>,
Ulrich Weigandd5ebc622013-07-03 17:05:42 +0000294 PPC970_DGroup_First, PPC970_Unit_CRU;
Hal Finkelb47a69a2013-04-07 14:33:13 +0000295
Ulrich Weigand136ac222013-04-26 16:53:15 +0000296def MFCR8 : XFXForm_3<31, 19, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000297 "mfcr $rT", IIC_SprMFCR>,
Hal Finkelac9df3d2011-12-07 06:34:06 +0000298 PPC970_MicroCode, PPC970_Unit_CRU;
Ulrich Weigandd5ebc622013-07-03 17:05:42 +0000299} // neverHasSideEffects = 1
Arnold Schwaighoferbe0de342008-04-30 09:16:33 +0000300
Ulrich Weigandbbfb0c52013-03-26 10:57:16 +0000301let hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
Hal Finkel40f76d52013-07-17 05:35:44 +0000302 let Defs = [CTR8] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000303 def EH_SjLj_SetJmp64 : Pseudo<(outs gprc:$dst), (ins memr:$buf),
Hal Finkel756810f2013-03-21 21:37:52 +0000304 "#EH_SJLJ_SETJMP64",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000305 [(set i32:$dst, (PPCeh_sjlj_setjmp addr:$buf))]>,
Hal Finkel756810f2013-03-21 21:37:52 +0000306 Requires<[In64BitMode]>;
307 let isTerminator = 1 in
308 def EH_SjLj_LongJmp64 : Pseudo<(outs), (ins memr:$buf),
309 "#EH_SJLJ_LONGJMP64",
310 [(PPCeh_sjlj_longjmp addr:$buf)]>,
311 Requires<[In64BitMode]>;
312}
313
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000314//===----------------------------------------------------------------------===//
315// 64-bit SPR manipulation instrs.
316
Dale Johannesene395d782008-10-23 20:41:28 +0000317let Uses = [CTR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000318def MFCTR8 : XFXForm_1_ext<31, 339, 9, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000319 "mfctr $rT", IIC_SprMFSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000320 PPC970_DGroup_First, PPC970_Unit_FXU;
Dale Johannesene395d782008-10-23 20:41:28 +0000321}
Ulrich Weigandc8868102013-03-25 19:05:30 +0000322let Pattern = [(PPCmtctr i64:$rS)], Defs = [CTR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000323def MTCTR8 : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000324 "mtctr $rS", IIC_SprMTSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000325 PPC970_DGroup_First, PPC970_Unit_FXU;
Chris Lattner3b587342006-06-27 18:36:44 +0000326}
Hal Finkelb4b99e52013-12-17 23:05:18 +0000327let hasSideEffects = 1, Defs = [CTR8] in {
Hal Finkel25c19922013-05-15 21:37:41 +0000328let Pattern = [(int_ppc_mtctr i64:$rS)] in
Hal Finkel0859ef22013-05-20 16:08:37 +0000329def MTCTR8loop : XFXForm_7_ext<31, 467, 9, (outs), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000330 "mtctr $rS", IIC_SprMTSPR>,
Hal Finkel0859ef22013-05-20 16:08:37 +0000331 PPC970_DGroup_First, PPC970_Unit_FXU;
Hal Finkel25c19922013-05-15 21:37:41 +0000332}
Chris Lattnerd48ce272006-06-27 18:18:41 +0000333
Hal Finkelb4b99e52013-12-17 23:05:18 +0000334let Pattern = [(set i64:$rT, readcyclecounter)] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000335def MFTB8 : XFXForm_1_ext<31, 339, 268, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000336 "mfspr $rT, 268", IIC_SprMFTB>,
Hal Finkel70381a72012-08-04 14:10:46 +0000337 PPC970_DGroup_First, PPC970_Unit_FXU;
Hal Finkel895a5f52012-08-07 17:04:20 +0000338// Note that encoding mftb using mfspr is now the preferred form,
339// and has been since at least ISA v2.03. The mftb instruction has
340// now been phased out. Using mfspr, however, is known not to work on
341// the POWER3.
Hal Finkel70381a72012-08-04 14:10:46 +0000342
Evan Cheng3e18e502007-09-11 19:55:27 +0000343let Defs = [X1], Uses = [X1] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000344def DYNALLOC8 : Pseudo<(outs g8rc:$result), (ins g8rc:$negsize, memri:$fpsi),"#DYNALLOC8",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000345 [(set i64:$result,
346 (PPCdynalloc i64:$negsize, iaddr:$fpsi))]>;
Jim Laskey48850c12006-11-16 22:43:37 +0000347
Dale Johannesene395d782008-10-23 20:41:28 +0000348let Defs = [LR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000349def MTLR8 : XFXForm_7_ext<31, 467, 8, (outs), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000350 "mtlr $rS", IIC_SprMTSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000351 PPC970_DGroup_First, PPC970_Unit_FXU;
Dale Johannesene395d782008-10-23 20:41:28 +0000352}
353let Uses = [LR8] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000354def MFLR8 : XFXForm_1_ext<31, 339, 8, (outs g8rc:$rT), (ins),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000355 "mflr $rT", IIC_SprMFSPR>,
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000356 PPC970_DGroup_First, PPC970_Unit_FXU;
Dale Johannesene395d782008-10-23 20:41:28 +0000357}
Hal Finkel654d43b2013-04-12 02:18:09 +0000358} // Interpretation64Bit
Chris Lattner44dbdbe2006-11-14 18:44:47 +0000359
Chris Lattnerd48ce272006-06-27 18:18:41 +0000360//===----------------------------------------------------------------------===//
Chris Lattnerb4299832006-06-16 20:22:01 +0000361// Fixed point instructions.
362//
363
364let PPC970_Unit = 1 in { // FXU Operations.
Hal Finkel654d43b2013-04-12 02:18:09 +0000365let Interpretation64Bit = 1 in {
366let neverHasSideEffects = 1 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000367let isCodeGenOnly = 1 in {
Chris Lattnerb4299832006-06-16 20:22:01 +0000368
Hal Finkel686f2ee2012-08-28 02:10:33 +0000369let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in {
Ulrich Weigand99485462013-05-23 22:48:06 +0000370def LI8 : DForm_2_r0<14, (outs g8rc:$rD), (ins s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000371 "li $rD, $imm", IIC_IntSimple,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000372 [(set i64:$rD, imm64SExt16:$imm)]>;
Ulrich Weigand5a02a022013-06-26 13:49:53 +0000373def LIS8 : DForm_2_r0<15, (outs g8rc:$rD), (ins s17imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000374 "lis $rD, $imm", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000375 [(set i64:$rD, imm16ShiftedSExt:$imm)]>;
Hal Finkel686f2ee2012-08-28 02:10:33 +0000376}
Chris Lattner7e742e42006-06-20 22:34:10 +0000377
378// Logical ops.
Hal Finkele01d3212014-03-24 15:07:28 +0000379let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000380defm NAND8: XForm_6r<31, 476, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000381 "nand", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000382 [(set i64:$rA, (not (and i64:$rS, i64:$rB)))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000383defm AND8 : XForm_6r<31, 28, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000384 "and", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000385 [(set i64:$rA, (and i64:$rS, i64:$rB))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000386} // isCommutable
Ulrich Weigand136ac222013-04-26 16:53:15 +0000387defm ANDC8: XForm_6r<31, 60, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000388 "andc", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000389 [(set i64:$rA, (and i64:$rS, (not i64:$rB)))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000390let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000391defm OR8 : XForm_6r<31, 444, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000392 "or", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000393 [(set i64:$rA, (or i64:$rS, i64:$rB))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000394defm NOR8 : XForm_6r<31, 124, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000395 "nor", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000396 [(set i64:$rA, (not (or i64:$rS, i64:$rB)))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000397} // isCommutable
Ulrich Weigand136ac222013-04-26 16:53:15 +0000398defm ORC8 : XForm_6r<31, 412, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000399 "orc", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000400 [(set i64:$rA, (or i64:$rS, (not i64:$rB)))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000401let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000402defm EQV8 : XForm_6r<31, 284, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000403 "eqv", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000404 [(set i64:$rA, (not (xor i64:$rS, i64:$rB)))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000405defm XOR8 : XForm_6r<31, 316, (outs g8rc:$rA), (ins g8rc:$rS, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000406 "xor", "$rA, $rS, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000407 [(set i64:$rA, (xor i64:$rS, i64:$rB))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000408} // let isCommutable = 1
Chris Lattner9d65f352006-06-20 23:11:59 +0000409
410// Logical ops with immediate.
Hal Finkel1b58f332013-04-12 18:17:57 +0000411let Defs = [CR0] in {
Hal Finkel77c8dc12014-01-02 21:26:59 +0000412def ANDIo8 : DForm_4<28, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000413 "andi. $dst, $src1, $src2", IIC_IntGeneral,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000414 [(set i64:$dst, (and i64:$src1, immZExt16:$src2))]>,
Chris Lattner7e742e42006-06-20 22:34:10 +0000415 isDOT;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000416def ANDISo8 : DForm_4<29, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000417 "andis. $dst, $src1, $src2", IIC_IntGeneral,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000418 [(set i64:$dst, (and i64:$src1, imm16ShiftedZExt:$src2))]>,
Chris Lattner7e742e42006-06-20 22:34:10 +0000419 isDOT;
Hal Finkel1b58f332013-04-12 18:17:57 +0000420}
Hal Finkel77c8dc12014-01-02 21:26:59 +0000421def ORI8 : DForm_4<24, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000422 "ori $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000423 [(set i64:$dst, (or i64:$src1, immZExt16:$src2))]>;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000424def ORIS8 : DForm_4<25, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000425 "oris $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000426 [(set i64:$dst, (or i64:$src1, imm16ShiftedZExt:$src2))]>;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000427def XORI8 : DForm_4<26, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000428 "xori $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000429 [(set i64:$dst, (xor i64:$src1, immZExt16:$src2))]>;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000430def XORIS8 : DForm_4<27, (outs g8rc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000431 "xoris $dst, $src1, $src2", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000432 [(set i64:$dst, (xor i64:$src1, imm16ShiftedZExt:$src2))]>;
Chris Lattner7e742e42006-06-20 22:34:10 +0000433
Hal Finkele01d3212014-03-24 15:07:28 +0000434let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000435defm ADD8 : XOForm_1r<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000436 "add", "$rT, $rA, $rB", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000437 [(set i64:$rT, (add i64:$rA, i64:$rB))]>;
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000438// ADD8 has a special form: reg = ADD8(reg, sym@tls) for use by the
439// initial-exec thread-local storage model.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000440def ADD8TLS : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000441 "add $rT, $rA, $rB", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000442 [(set i64:$rT, (add i64:$rA, tglobaltlsaddr:$rB))]>;
Chris Lattner3e549e92007-05-17 06:52:46 +0000443
Hal Finkele01d3212014-03-24 15:07:28 +0000444let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000445defm ADDC8 : XOForm_1rc<31, 10, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000446 "addc", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000447 [(set i64:$rT, (addc i64:$rA, i64:$rB))]>,
448 PPC970_DGroup_Cracked;
Hal Finkele01d3212014-03-24 15:07:28 +0000449
Hal Finkel1b58f332013-04-12 18:17:57 +0000450let Defs = [CARRY] in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000451def ADDIC8 : DForm_2<12, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000452 "addic $rD, $rA, $imm", IIC_IntGeneral,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000453 [(set i64:$rD, (addc i64:$rA, imm64SExt16:$imm))]>;
Ulrich Weigand99485462013-05-23 22:48:06 +0000454def ADDI8 : DForm_2<14, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000455 "addi $rD, $rA, $imm", IIC_IntSimple,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000456 [(set i64:$rD, (add i64:$rA, imm64SExt16:$imm))]>;
Ulrich Weigand5a02a022013-06-26 13:49:53 +0000457def ADDIS8 : DForm_2<15, (outs g8rc:$rD), (ins g8rc_nox0:$rA, s17imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000458 "addis $rD, $rA, $imm", IIC_IntSimple,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000459 [(set i64:$rD, (add i64:$rA, imm16ShiftedSExt:$imm))]>;
Chris Lattner7e742e42006-06-20 22:34:10 +0000460
Dale Johannesen5e9a5c32009-09-18 20:15:22 +0000461let Defs = [CARRY] in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000462def SUBFIC8: DForm_2< 8, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000463 "subfic $rD, $rA, $imm", IIC_IntGeneral,
Bill Schmidtf88571e2013-05-22 20:09:24 +0000464 [(set i64:$rD, (subc imm64SExt16:$imm, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000465defm SUBFC8 : XOForm_1r<31, 8, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000466 "subfc", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000467 [(set i64:$rT, (subc i64:$rB, i64:$rA))]>,
468 PPC970_DGroup_Cracked;
Dale Johannesen5e9a5c32009-09-18 20:15:22 +0000469}
Ulrich Weigand136ac222013-04-26 16:53:15 +0000470defm SUBF8 : XOForm_1r<31, 40, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000471 "subf", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000472 [(set i64:$rT, (sub i64:$rB, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000473defm NEG8 : XOForm_3r<31, 104, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000474 "neg", "$rT, $rA", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000475 [(set i64:$rT, (ineg i64:$rA))]>;
Hal Finkel1b58f332013-04-12 18:17:57 +0000476let Uses = [CARRY] in {
Hal Finkele01d3212014-03-24 15:07:28 +0000477let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000478defm ADDE8 : XOForm_1rc<31, 138, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000479 "adde", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000480 [(set i64:$rT, (adde i64:$rA, i64:$rB))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000481defm ADDME8 : XOForm_3rc<31, 234, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000482 "addme", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000483 [(set i64:$rT, (adde i64:$rA, -1))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000484defm ADDZE8 : XOForm_3rc<31, 202, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000485 "addze", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000486 [(set i64:$rT, (adde i64:$rA, 0))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000487defm SUBFE8 : XOForm_1rc<31, 136, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000488 "subfe", "$rT, $rA, $rB", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000489 [(set i64:$rT, (sube i64:$rB, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000490defm SUBFME8 : XOForm_3rc<31, 232, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000491 "subfme", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000492 [(set i64:$rT, (sube -1, i64:$rA))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000493defm SUBFZE8 : XOForm_3rc<31, 200, 0, (outs g8rc:$rT), (ins g8rc:$rA),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000494 "subfze", "$rT, $rA", IIC_IntGeneral,
Hal Finkel1b58f332013-04-12 18:17:57 +0000495 [(set i64:$rT, (sube 0, i64:$rA))]>;
Dale Johannesen5e9a5c32009-09-18 20:15:22 +0000496}
Hal Finkelb4b99e52013-12-17 23:05:18 +0000497} // isCodeGenOnly
Chris Lattner3e549e92007-05-17 06:52:46 +0000498
Hal Finkelb4b99e52013-12-17 23:05:18 +0000499// FIXME: Duplicating this for the asm parser should be unnecessary, but the
500// previous definition must be marked as CodeGen only to prevent decoding
501// conflicts.
502let isAsmParserOnly = 1 in
503def ADD8TLS_ : XOForm_1<31, 266, 0, (outs g8rc:$rT), (ins g8rc:$rA, tlsreg:$rB),
504 "add $rT, $rA, $rB", IIC_IntSimple, []>;
Chris Lattner2d4e8f72006-06-20 21:23:06 +0000505
Hal Finkele01d3212014-03-24 15:07:28 +0000506let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000507defm MULHD : XOForm_1r<31, 73, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000508 "mulhd", "$rT, $rA, $rB", IIC_IntMulHW,
Hal Finkel654d43b2013-04-12 02:18:09 +0000509 [(set i64:$rT, (mulhs i64:$rA, i64:$rB))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000510defm MULHDU : XOForm_1r<31, 9, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000511 "mulhdu", "$rT, $rA, $rB", IIC_IntMulHWU,
Hal Finkel654d43b2013-04-12 02:18:09 +0000512 [(set i64:$rT, (mulhu i64:$rA, i64:$rB))]>;
Hal Finkele01d3212014-03-24 15:07:28 +0000513} // isCommutable
Hal Finkel654d43b2013-04-12 02:18:09 +0000514}
515} // Interpretation64Bit
Chris Lattnerb4299832006-06-16 20:22:01 +0000516
Hal Finkel95e6ea62013-04-15 02:37:46 +0000517let isCompare = 1, neverHasSideEffects = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000518 def CMPD : XForm_16_ext<31, 0, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000519 "cmpd $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000520 def CMPLD : XForm_16_ext<31, 32, (outs crrc:$crD), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000521 "cmpld $crD, $rA, $rB", IIC_IntCompare>, isPPC64;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000522 def CMPDI : DForm_5_ext<11, (outs crrc:$crD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000523 "cmpdi $crD, $rA, $imm", IIC_IntCompare>, isPPC64;
Hal Finkel77c8dc12014-01-02 21:26:59 +0000524 def CMPLDI : DForm_6_ext<10, (outs crrc:$dst), (ins g8rc:$src1, u16imm64:$src2),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000525 "cmpldi $dst, $src1, $src2",
526 IIC_IntCompare>, isPPC64;
Hal Finkel95e6ea62013-04-15 02:37:46 +0000527}
Chris Lattnerb4299832006-06-16 20:22:01 +0000528
Hal Finkel654d43b2013-04-12 02:18:09 +0000529let neverHasSideEffects = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000530defm SLD : XForm_6r<31, 27, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000531 "sld", "$rA, $rS, $rB", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000532 [(set i64:$rA, (PPCshl i64:$rS, i32:$rB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000533defm SRD : XForm_6r<31, 539, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000534 "srd", "$rA, $rS, $rB", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000535 [(set i64:$rA, (PPCsrl i64:$rS, i32:$rB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000536defm SRAD : XForm_6rc<31, 794, (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000537 "srad", "$rA, $rS, $rB", IIC_IntRotateD,
Hal Finkel1b58f332013-04-12 18:17:57 +0000538 [(set i64:$rA, (PPCsra i64:$rS, i32:$rB))]>, isPPC64;
Chris Lattner43c0eb82006-12-06 21:46:13 +0000539
Hal Finkelb4b99e52013-12-17 23:05:18 +0000540let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000541defm EXTSB8 : XForm_11r<31, 954, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000542 "extsb", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000543 [(set i64:$rA, (sext_inreg i64:$rS, i8))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000544defm EXTSH8 : XForm_11r<31, 922, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000545 "extsh", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000546 [(set i64:$rA, (sext_inreg i64:$rS, i16))]>;
547} // Interpretation64Bit
548
Bill Schmidtd89f6782013-08-26 19:42:51 +0000549// For fast-isel:
550let isCodeGenOnly = 1 in {
551def EXTSB8_32_64 : XForm_11<31, 954, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000552 "extsb $rA, $rS", IIC_IntSimple, []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000553def EXTSH8_32_64 : XForm_11<31, 922, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000554 "extsh $rA, $rS", IIC_IntSimple, []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000555} // isCodeGenOnly for fast-isel
556
Ulrich Weigand136ac222013-04-26 16:53:15 +0000557defm EXTSW : XForm_11r<31, 986, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000558 "extsw", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000559 [(set i64:$rA, (sext_inreg i64:$rS, i32))]>, isPPC64;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000560let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000561defm EXTSW_32_64 : XForm_11r<31, 986, (outs g8rc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000562 "extsw", "$rA, $rS", IIC_IntSimple,
Hal Finkel654d43b2013-04-12 02:18:09 +0000563 [(set i64:$rA, (sext i32:$rS))]>, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +0000564
Ulrich Weigand136ac222013-04-26 16:53:15 +0000565defm SRADI : XSForm_1rc<31, 413, (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000566 "sradi", "$rA, $rS, $SH", IIC_IntRotateDI,
Hal Finkel1b58f332013-04-12 18:17:57 +0000567 [(set i64:$rA, (sra i64:$rS, (i32 imm:$SH)))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000568defm CNTLZD : XForm_11r<31, 58, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000569 "cntlzd", "$rA, $rS", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000570 [(set i64:$rA, (ctlz i64:$rS))]>;
Hal Finkel884bde302013-11-20 20:54:55 +0000571def POPCNTD : XForm_11<31, 506, (outs g8rc:$rA), (ins g8rc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000572 "popcntd $rA, $rS", IIC_IntGeneral,
Hal Finkel884bde302013-11-20 20:54:55 +0000573 [(set i64:$rA, (ctpop i64:$rS))]>;
Chris Lattner88102412007-03-25 04:44:03 +0000574
Hal Finkel290376d2013-04-01 15:58:15 +0000575// popcntw also does a population count on the high 32 bits (storing the
576// results in the high 32-bits of the output). We'll ignore that here (which is
577// safe because we never separately use the high part of the 64-bit registers).
Hal Finkel884bde302013-11-20 20:54:55 +0000578def POPCNTW : XForm_11<31, 378, (outs gprc:$rA), (ins gprc:$rS),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000579 "popcntw $rA, $rS", IIC_IntGeneral,
Hal Finkel884bde302013-11-20 20:54:55 +0000580 [(set i32:$rA, (ctpop i32:$rS))]>;
Hal Finkel290376d2013-04-01 15:58:15 +0000581
Ulrich Weigand136ac222013-04-26 16:53:15 +0000582defm DIVD : XOForm_1r<31, 489, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000583 "divd", "$rT, $rA, $rB", IIC_IntDivD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000584 [(set i64:$rT, (sdiv i64:$rA, i64:$rB))]>, isPPC64,
585 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000586defm DIVDU : XOForm_1r<31, 457, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000587 "divdu", "$rT, $rA, $rB", IIC_IntDivD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000588 [(set i64:$rT, (udiv i64:$rA, i64:$rB))]>, isPPC64,
589 PPC970_DGroup_First, PPC970_DGroup_Cracked;
Hal Finkele01d3212014-03-24 15:07:28 +0000590let isCommutable = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000591defm MULLD : XOForm_1r<31, 233, 0, (outs g8rc:$rT), (ins g8rc:$rA, g8rc:$rB),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000592 "mulld", "$rT, $rA, $rB", IIC_IntMulHD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000593 [(set i64:$rT, (mul i64:$rA, i64:$rB))]>, isPPC64;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000594let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Hal Finkel11b9e4522013-08-06 17:03:03 +0000595def MULLI8 : DForm_2<7, (outs g8rc:$rD), (ins g8rc:$rA, s16imm64:$imm),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000596 "mulli $rD, $rA, $imm", IIC_IntMulLI,
Hal Finkel11b9e4522013-08-06 17:03:03 +0000597 [(set i64:$rD, (mul i64:$rA, imm64SExt16:$imm))]>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000598}
Chris Lattner7ecbd302006-06-26 23:53:10 +0000599
Hal Finkel7795e472013-04-07 15:06:53 +0000600let neverHasSideEffects = 1 in {
Chris Lattner57711562006-11-15 23:24:18 +0000601let isCommutable = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000602defm RLDIMI : MDForm_1r<30, 3, (outs g8rc:$rA),
603 (ins g8rc:$rSi, g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000604 "rldimi", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000605 []>, isPPC64, RegConstraint<"$rSi = $rA">,
606 NoEncode<"$rSi">;
Chris Lattnerb4299832006-06-16 20:22:01 +0000607}
608
609// Rotate instructions.
Ulrich Weigandfa451ba2013-04-26 15:39:12 +0000610defm RLDCL : MDSForm_1r<30, 8,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000611 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000612 "rldcl", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
Hal Finkel654d43b2013-04-12 02:18:09 +0000613 []>, isPPC64;
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000614defm RLDCR : MDSForm_1r<30, 9,
615 (outs g8rc:$rA), (ins g8rc:$rS, gprc:$rB, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000616 "rldcr", "$rA, $rS, $rB, $MBE", IIC_IntRotateD,
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000617 []>, isPPC64;
Hal Finkel654d43b2013-04-12 02:18:09 +0000618defm RLDICL : MDForm_1r<30, 0,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000619 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000620 "rldicl", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000621 []>, isPPC64;
Bill Schmidtd89f6782013-08-26 19:42:51 +0000622// For fast-isel:
623let isCodeGenOnly = 1 in
624def RLDICL_32_64 : MDForm_1<30, 0,
625 (outs g8rc:$rA),
626 (ins gprc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000627 "rldicl $rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Bill Schmidtd89f6782013-08-26 19:42:51 +0000628 []>, isPPC64;
629// End fast-isel.
Hal Finkel654d43b2013-04-12 02:18:09 +0000630defm RLDICR : MDForm_1r<30, 1,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000631 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000632 "rldicr", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Hal Finkel654d43b2013-04-12 02:18:09 +0000633 []>, isPPC64;
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000634defm RLDIC : MDForm_1r<30, 2,
635 (outs g8rc:$rA), (ins g8rc:$rS, u6imm:$SH, u6imm:$MBE),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000636 "rldic", "$rA, $rS, $SH, $MBE", IIC_IntRotateDI,
Ulrich Weigand6c31c4a2013-06-25 13:17:10 +0000637 []>, isPPC64;
Hal Finkelac9df3d2011-12-07 06:34:06 +0000638
Hal Finkelb4b99e52013-12-17 23:05:18 +0000639let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000640defm RLWINM8 : MForm_2r<21, (outs g8rc:$rA),
641 (ins g8rc:$rS, u5imm:$SH, u5imm:$MB, u5imm:$ME),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000642 "rlwinm", "$rA, $rS, $SH, $MB, $ME", IIC_IntGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +0000643 []>;
Hal Finkelac9df3d2011-12-07 06:34:06 +0000644
Hal Finkel940ab932014-02-28 00:27:01 +0000645let isCommutable = 1 in {
646// RLWIMI can be commuted if the rotate amount is zero.
647let Interpretation64Bit = 1, isCodeGenOnly = 1 in
648defm RLWIMI8 : MForm_2r<20, (outs g8rc:$rA),
649 (ins g8rc:$rSi, g8rc:$rS, u5imm:$SH, u5imm:$MB,
650 u5imm:$ME), "rlwimi", "$rA, $rS, $SH, $MB, $ME",
651 IIC_IntRotate, []>, PPC970_DGroup_Cracked,
652 RegConstraint<"$rSi = $rA">, NoEncode<"$rSi">;
653}
654
Hal Finkel7795e472013-04-07 15:06:53 +0000655let isSelect = 1 in
Ulrich Weigand84ee76a2012-11-13 19:14:19 +0000656def ISEL8 : AForm_4<31, 15,
Ulrich Weigand136ac222013-04-26 16:53:15 +0000657 (outs g8rc:$rT), (ins g8rc_nox0:$rA, g8rc:$rB, crbitrc:$cond),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000658 "isel $rT, $rA, $rB, $cond", IIC_IntGeneral,
Hal Finkel460e94d2012-06-22 23:10:08 +0000659 []>;
Hal Finkel654d43b2013-04-12 02:18:09 +0000660} // Interpretation64Bit
Hal Finkel7795e472013-04-07 15:06:53 +0000661} // neverHasSideEffects = 1
Chris Lattner7ecbd302006-06-26 23:53:10 +0000662} // End FXU Operations.
Chris Lattnerb4299832006-06-16 20:22:01 +0000663
664
665//===----------------------------------------------------------------------===//
666// Load/Store instructions.
667//
668
669
Chris Lattner96aecb52006-07-14 04:42:02 +0000670// Sign extending loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000671let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000672let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000673def LHA8: DForm_1<42, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000674 "lha $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000675 [(set i64:$rD, (sextloadi16 iaddr:$src))]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000676 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000677def LWA : DSForm_1<58, 2, (outs g8rc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000678 "lwa $rD, $src", IIC_LdStLWA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000679 [(set i64:$rD,
Hal Finkelb09680b2013-03-18 23:00:58 +0000680 (aligned4sextloadi32 ixaddr:$src))]>, isPPC64,
Chris Lattner94d18df2006-06-20 00:38:36 +0000681 PPC970_DGroup_Cracked;
Hal Finkelb4b99e52013-12-17 23:05:18 +0000682let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000683def LHAX8: XForm_1<31, 343, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000684 "lhax $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000685 [(set i64:$rD, (sextloadi16 xaddr:$src))]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000686 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000687def LWAX : XForm_1<31, 341, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000688 "lwax $rD, $src", IIC_LdStLHA,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000689 [(set i64:$rD, (sextloadi32 xaddr:$src))]>, isPPC64,
Chris Lattnerb4299832006-06-16 20:22:01 +0000690 PPC970_DGroup_Cracked;
Bill Schmidtccecf262013-08-30 02:29:45 +0000691// For fast-isel:
692let isCodeGenOnly = 1, mayLoad = 1 in {
693def LWA_32 : DSForm_1<58, 2, (outs gprc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000694 "lwa $rD, $src", IIC_LdStLWA, []>, isPPC64,
Bill Schmidtccecf262013-08-30 02:29:45 +0000695 PPC970_DGroup_Cracked;
696def LWAX_32 : XForm_1<31, 341, (outs gprc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000697 "lwax $rD, $src", IIC_LdStLHA, []>, isPPC64,
Bill Schmidtccecf262013-08-30 02:29:45 +0000698 PPC970_DGroup_Cracked;
699} // end fast-isel isCodeGenOnly
Chris Lattner96aecb52006-07-14 04:42:02 +0000700
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000701// Update forms.
Hal Finkeld71cc3a2013-04-07 06:30:47 +0000702let mayLoad = 1, neverHasSideEffects = 1 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000703let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000704def LHAU8 : DForm_1<43, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Ulrich Weigandf8030092013-03-19 19:52:30 +0000705 (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000706 "lhau $rD, $addr", IIC_LdStLHAU,
Ulrich Weigandf8030092013-03-19 19:52:30 +0000707 []>, RegConstraint<"$addr.reg = $ea_result">,
Chris Lattner57711562006-11-15 23:24:18 +0000708 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000709// NO LWAU!
710
Hal Finkelb4b99e52013-12-17 23:05:18 +0000711let Interpretation64Bit = 1, isCodeGenOnly = 1 in
Ulrich Weigand136ac222013-04-26 16:53:15 +0000712def LHAUX8 : XForm_1<31, 375, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000713 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000714 "lhaux $rD, $addr", IIC_LdStLHAUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000715 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000716 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000717def LWAUX : XForm_1<31, 373, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000718 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000719 "lwaux $rD, $addr", IIC_LdStLHAUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000720 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000721 NoEncode<"$ea_result">, isPPC64;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000722}
Ulrich Weigand01dd4c12013-03-19 19:53:27 +0000723}
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000724
Hal Finkelb4b99e52013-12-17 23:05:18 +0000725let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Chris Lattner96aecb52006-07-14 04:42:02 +0000726// Zero extending loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000727let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000728def LBZ8 : DForm_1<34, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000729 "lbz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000730 [(set i64:$rD, (zextloadi8 iaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000731def LHZ8 : DForm_1<40, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000732 "lhz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000733 [(set i64:$rD, (zextloadi16 iaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000734def LWZ8 : DForm_1<32, (outs g8rc:$rD), (ins memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000735 "lwz $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000736 [(set i64:$rD, (zextloadi32 iaddr:$src))]>, isPPC64;
Chris Lattner96aecb52006-07-14 04:42:02 +0000737
Ulrich Weigand136ac222013-04-26 16:53:15 +0000738def LBZX8 : XForm_1<31, 87, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000739 "lbzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000740 [(set i64:$rD, (zextloadi8 xaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000741def LHZX8 : XForm_1<31, 279, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000742 "lhzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000743 [(set i64:$rD, (zextloadi16 xaddr:$src))]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000744def LWZX8 : XForm_1<31, 23, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000745 "lwzx $rD, $src", IIC_LdStLoad,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000746 [(set i64:$rD, (zextloadi32 xaddr:$src))]>;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000747
748
749// Update forms.
Hal Finkel6efd45e2013-04-07 05:46:58 +0000750let mayLoad = 1, neverHasSideEffects = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000751def LBZU8 : DForm_1<35, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000752 "lbzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000753 []>, RegConstraint<"$addr.reg = $ea_result">,
754 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000755def LHZU8 : DForm_1<41, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000756 "lhzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000757 []>, RegConstraint<"$addr.reg = $ea_result">,
758 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000759def LWZU8 : DForm_1<33, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memri:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000760 "lwzu $rD, $addr", IIC_LdStLoadUpd,
Chris Lattner57711562006-11-15 23:24:18 +0000761 []>, RegConstraint<"$addr.reg = $ea_result">,
762 NoEncode<"$ea_result">;
Hal Finkelca542be2012-06-20 15:43:03 +0000763
Ulrich Weigand136ac222013-04-26 16:53:15 +0000764def LBZUX8 : XForm_1<31, 119, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000765 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000766 "lbzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000767 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000768 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000769def LHZUX8 : XForm_1<31, 311, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000770 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000771 "lhzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000772 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000773 NoEncode<"$ea_result">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000774def LWZUX8 : XForm_1<31, 55, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000775 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000776 "lwzux $rD, $addr", IIC_LdStLoadUpdX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000777 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000778 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000779}
Dan Gohmanae3ba452008-12-03 02:30:17 +0000780}
Hal Finkel654d43b2013-04-12 02:18:09 +0000781} // Interpretation64Bit
Chris Lattner96aecb52006-07-14 04:42:02 +0000782
783
784// Full 8-byte loads.
Dan Gohman69cc2cb2008-12-03 18:15:48 +0000785let canFoldAsLoad = 1, PPC970_Unit = 2 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000786def LD : DSForm_1<58, 0, (outs g8rc:$rD), (ins memrix:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000787 "ld $rD, $src", IIC_LdStLD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000788 [(set i64:$rD, (aligned4load ixaddr:$src))]>, isPPC64;
Bill Schmidt34627e32012-11-27 17:35:46 +0000789// The following three definitions are selected for small code model only.
790// Otherwise, we need to create two instructions to form a 32-bit offset,
791// so we have a custom matcher for TOC_ENTRY in PPCDAGToDAGIsel::Select().
Ulrich Weigand136ac222013-04-26 16:53:15 +0000792def LDtoc: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000793 "#LDtoc",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000794 [(set i64:$rD,
795 (PPCtoc_entry tglobaladdr:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000796def LDtocJTI: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000797 "#LDtocJTI",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000798 [(set i64:$rD,
799 (PPCtoc_entry tjumptable:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000800def LDtocCPT: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc:$reg),
Will Schmidt4a67f2e2012-10-04 18:14:28 +0000801 "#LDtocCPT",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000802 [(set i64:$rD,
803 (PPCtoc_entry tconstpool:$disp, i64:$reg))]>, isPPC64;
Hal Finkela3e6ed22012-02-24 17:54:01 +0000804
Ulrich Weigandad0cb912014-06-18 17:52:49 +0000805let hasSideEffects = 1, isCodeGenOnly = 1, RST = 2 in
806def LDinto_toc: DSForm_1<58, 0, (outs), (ins memrix:$src),
807 "ld 2, $src", IIC_LdStLD,
808 [(PPCload_toc ixaddr:$src)]>, isPPC64;
809
Ulrich Weigand136ac222013-04-26 16:53:15 +0000810def LDX : XForm_1<31, 21, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000811 "ldx $rD, $src", IIC_LdStLD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000812 [(set i64:$rD, (load xaddr:$src))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000813def LDBRX : XForm_1<31, 532, (outs g8rc:$rD), (ins memrr:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000814 "ldbrx $rD, $src", IIC_LdStLoad,
Hal Finkel31d29562013-03-28 19:25:55 +0000815 [(set i64:$rD, (PPClbrx xoaddr:$src, i64))]>, isPPC64;
816
Hal Finkeld71cc3a2013-04-07 06:30:47 +0000817let mayLoad = 1, neverHasSideEffects = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000818def LDU : DSForm_1<58, 1, (outs g8rc:$rD, ptr_rc_nor0:$ea_result), (ins memrix:$addr),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000819 "ldu $rD, $addr", IIC_LdStLDU,
Chris Lattner57711562006-11-15 23:24:18 +0000820 []>, RegConstraint<"$addr.reg = $ea_result">, isPPC64,
821 NoEncode<"$ea_result">;
Chris Lattnerc9fa36d2006-11-10 23:58:45 +0000822
Ulrich Weigand136ac222013-04-26 16:53:15 +0000823def LDUX : XForm_1<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
Hal Finkelca542be2012-06-20 15:43:03 +0000824 (ins memrr:$addr),
Hal Finkel46402a42013-11-30 20:41:13 +0000825 "ldux $rD, $addr", IIC_LdStLDUX,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000826 []>, RegConstraint<"$addr.ptrreg = $ea_result">,
Hal Finkelca542be2012-06-20 15:43:03 +0000827 NoEncode<"$ea_result">, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +0000828}
Hal Finkeld71cc3a2013-04-07 06:30:47 +0000829}
Chris Lattner96aecb52006-07-14 04:42:02 +0000830
Tilmann Scheller79fef932009-12-18 13:00:15 +0000831def : Pat<(PPCload ixaddr:$src),
832 (LD ixaddr:$src)>;
833def : Pat<(PPCload xaddr:$src),
834 (LDX xaddr:$src)>;
835
Bill Schmidt27917782013-02-21 17:12:27 +0000836// Support for medium and large code model.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000837def ADDIStocHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
Bill Schmidt34627e32012-11-27 17:35:46 +0000838 "#ADDIStocHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000839 [(set i64:$rD,
840 (PPCaddisTocHA i64:$reg, tglobaladdr:$disp))]>,
Bill Schmidt34627e32012-11-27 17:35:46 +0000841 isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000842def LDtocL: Pseudo<(outs g8rc:$rD), (ins tocentry:$disp, g8rc_nox0:$reg),
Bill Schmidt34627e32012-11-27 17:35:46 +0000843 "#LDtocL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000844 [(set i64:$rD,
845 (PPCldTocL tglobaladdr:$disp, i64:$reg))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000846def ADDItocL: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, tocentry:$disp),
Bill Schmidt34627e32012-11-27 17:35:46 +0000847 "#ADDItocL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000848 [(set i64:$rD,
849 (PPCaddiTocL i64:$reg, tglobaladdr:$disp))]>, isPPC64;
Bill Schmidt34627e32012-11-27 17:35:46 +0000850
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000851// Support for thread-local storage.
Ulrich Weigand99485462013-05-23 22:48:06 +0000852def ADDISgotTprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000853 "#ADDISgotTprelHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000854 [(set i64:$rD,
855 (PPCaddisGotTprelHA i64:$reg,
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000856 tglobaltlsaddr:$disp))]>,
857 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000858def LDgotTprelL: Pseudo<(outs g8rc:$rD), (ins s16imm64:$disp, g8rc_nox0:$reg),
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000859 "#LDgotTprelL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000860 [(set i64:$rD,
861 (PPCldGotTprelL tglobaltlsaddr:$disp, i64:$reg))]>,
Bill Schmidt9f0b4ec2012-12-14 17:02:38 +0000862 isPPC64;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +0000863def : Pat<(PPCaddTls i64:$in, tglobaltlsaddr:$g),
864 (ADD8TLS $in, tglobaltlsaddr:$g)>;
Ulrich Weigand99485462013-05-23 22:48:06 +0000865def ADDIStlsgdHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000866 "#ADDIStlsgdHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000867 [(set i64:$rD,
868 (PPCaddisTlsgdHA i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000869 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000870def ADDItlsgdL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000871 "#ADDItlsgdL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000872 [(set i64:$rD,
873 (PPCaddiTlsgdL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000874 isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000875def GETtlsADDR : Pseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000876 "#GETtlsADDR",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000877 [(set i64:$rD,
878 (PPCgetTlsAddr i64:$reg, tglobaltlsaddr:$sym))]>,
Bill Schmidtc56f1d32012-12-11 20:30:11 +0000879 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000880def ADDIStlsldHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000881 "#ADDIStlsldHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000882 [(set i64:$rD,
883 (PPCaddisTlsldHA i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000884 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000885def ADDItlsldL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000886 "#ADDItlsldL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000887 [(set i64:$rD,
888 (PPCaddiTlsldL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000889 isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000890def GETtlsldADDR : Pseudo<(outs g8rc:$rD), (ins g8rc:$reg, tlsgd:$sym),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000891 "#GETtlsldADDR",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000892 [(set i64:$rD,
893 (PPCgetTlsldAddr i64:$reg, tglobaltlsaddr:$sym))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000894 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000895def ADDISdtprelHA: Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000896 "#ADDISdtprelHA",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000897 [(set i64:$rD,
898 (PPCaddisDtprelHA i64:$reg,
Bill Schmidt9ed4dbc2012-12-13 20:57:10 +0000899 tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000900 isPPC64;
Ulrich Weigand99485462013-05-23 22:48:06 +0000901def ADDIdtprelL : Pseudo<(outs g8rc:$rD), (ins g8rc_nox0:$reg, s16imm64:$disp),
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000902 "#ADDIdtprelL",
Ulrich Weigandc8868102013-03-25 19:05:30 +0000903 [(set i64:$rD,
904 (PPCaddiDtprelL i64:$reg, tglobaltlsaddr:$disp))]>,
Bill Schmidt24b8dd62012-12-12 19:29:35 +0000905 isPPC64;
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000906
Chris Lattnere20f3802008-01-06 05:53:26 +0000907let PPC970_Unit = 2 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000908let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Chris Lattner96aecb52006-07-14 04:42:02 +0000909// Truncating stores.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000910def STB8 : DForm_1<38, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000911 "stb $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000912 [(truncstorei8 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000913def STH8 : DForm_1<44, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000914 "sth $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000915 [(truncstorei16 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000916def STW8 : DForm_1<36, (outs), (ins g8rc:$rS, memri:$src),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000917 "stw $rS, $src", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000918 [(truncstorei32 i64:$rS, iaddr:$src)]>;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000919def STBX8 : XForm_8<31, 215, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000920 "stbx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000921 [(truncstorei8 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000922 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000923def STHX8 : XForm_8<31, 407, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000924 "sthx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000925 [(truncstorei16 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000926 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000927def STWX8 : XForm_8<31, 151, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000928 "stwx $rS, $dst", IIC_LdStStore,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000929 [(truncstorei32 i64:$rS, xaddr:$dst)]>,
Chris Lattner96aecb52006-07-14 04:42:02 +0000930 PPC970_DGroup_Cracked;
Hal Finkel654d43b2013-04-12 02:18:09 +0000931} // Interpretation64Bit
932
Chris Lattnere742d9a2006-11-16 00:57:19 +0000933// Normal 8-byte stores.
Ulrich Weigand136ac222013-04-26 16:53:15 +0000934def STD : DSForm_1<62, 0, (outs), (ins g8rc:$rS, memrix:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000935 "std $rS, $dst", IIC_LdStSTD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000936 [(aligned4store i64:$rS, ixaddr:$dst)]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000937def STDX : XForm_8<31, 149, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000938 "stdx $rS, $dst", IIC_LdStSTD,
Ulrich Weigandc8868102013-03-25 19:05:30 +0000939 [(store i64:$rS, xaddr:$dst)]>, isPPC64,
Chris Lattnere742d9a2006-11-16 00:57:19 +0000940 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000941def STDBRX: XForm_8<31, 660, (outs), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000942 "stdbrx $rS, $dst", IIC_LdStStore,
Hal Finkel31d29562013-03-28 19:25:55 +0000943 [(PPCstbrx i64:$rS, xoaddr:$dst, i64)]>, isPPC64,
944 PPC970_DGroup_Cracked;
Chris Lattnerb4299832006-06-16 20:22:01 +0000945}
946
Ulrich Weigandd8501672013-03-19 19:52:04 +0000947// Stores with Update (pre-inc).
948let PPC970_Unit = 2, mayStore = 1 in {
Hal Finkelb4b99e52013-12-17 23:05:18 +0000949let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
Ulrich Weigand136ac222013-04-26 16:53:15 +0000950def STBU8 : DForm_1<39, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000951 "stbu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000952 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000953def STHU8 : DForm_1<45, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000954 "sthu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000955 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000956def STWU8 : DForm_1<37, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memri:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000957 "stwu $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000958 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">;
Ulrich Weigandd8501672013-03-19 19:52:04 +0000959
Ulrich Weigand136ac222013-04-26 16:53:15 +0000960def STBUX8: XForm_8<31, 247, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000961 "stbux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000962 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000963 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000964def STHUX8: XForm_8<31, 439, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000965 "sthux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000966 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000967 PPC970_DGroup_Cracked;
Ulrich Weigand136ac222013-04-26 16:53:15 +0000968def STWUX8: XForm_8<31, 183, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel3e5a3602013-11-27 23:26:09 +0000969 "stwux $rS, $dst", IIC_LdStStoreUpd, []>,
Ulrich Weigand1df06d82013-03-22 14:59:13 +0000970 RegConstraint<"$dst.ptrreg = $ea_res">, NoEncode<"$ea_res">,
Ulrich Weigandd8501672013-03-19 19:52:04 +0000971 PPC970_DGroup_Cracked;
Hal Finkel654d43b2013-04-12 02:18:09 +0000972} // Interpretation64Bit
973
Hal Finkelb4b99e52013-12-17 23:05:18 +0000974def STDU : DSForm_1<62, 1, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrix:$dst),
975 "stdu $rS, $dst", IIC_LdStSTDU, []>,
976 RegConstraint<"$dst.reg = $ea_res">, NoEncode<"$ea_res">,
977 isPPC64;
978
Ulrich Weigand136ac222013-04-26 16:53:15 +0000979def STDUX : XForm_8<31, 181, (outs ptr_rc_nor0:$ea_res), (ins g8rc:$rS, memrr:$dst),
Hal Finkel46402a42013-11-30 20:41:13 +0000980 "stdux $rS, $dst", IIC_LdStSTDUX, []>,
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, isPPC64;
983}
984
985// Patterns to match the pre-inc stores. We can't put the patterns on
986// the instruction definitions directly as ISel wants the address base
987// and offset to be separate operands, not a single complex operand.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +0000988def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
989 (STBU8 $rS, iaddroff:$ptroff, $ptrreg)>;
990def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
991 (STHU8 $rS, iaddroff:$ptroff, $ptrreg)>;
992def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
993 (STWU8 $rS, iaddroff:$ptroff, $ptrreg)>;
994def : Pat<(aligned4pre_store i64:$rS, iPTR:$ptrreg, iaddroff:$ptroff),
995 (STDU $rS, iaddroff:$ptroff, $ptrreg)>;
Ulrich Weigandd8501672013-03-19 19:52:04 +0000996
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +0000997def : Pat<(pre_truncsti8 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
998 (STBUX8 $rS, $ptrreg, $ptroff)>;
999def : Pat<(pre_truncsti16 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1000 (STHUX8 $rS, $ptrreg, $ptroff)>;
1001def : Pat<(pre_truncsti32 i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1002 (STWUX8 $rS, $ptrreg, $ptroff)>;
1003def : Pat<(pre_store i64:$rS, iPTR:$ptrreg, iPTR:$ptroff),
1004 (STDUX $rS, $ptrreg, $ptroff)>;
Chris Lattnerb4299832006-06-16 20:22:01 +00001005
1006
1007//===----------------------------------------------------------------------===//
1008// Floating point instructions.
1009//
1010
1011
Hal Finkel654d43b2013-04-12 02:18:09 +00001012let PPC970_Unit = 3, neverHasSideEffects = 1,
1013 Uses = [RM] in { // FPU Operations.
Ulrich Weigand136ac222013-04-26 16:53:15 +00001014defm FCFID : XForm_26r<63, 846, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001015 "fcfid", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001016 [(set f64:$frD, (PPCfcfid f64:$frB))]>, isPPC64;
David Majnemer6ad26d32013-09-26 04:11:24 +00001017defm FCTID : XForm_26r<63, 814, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001018 "fctid", "$frD, $frB", IIC_FPGeneral,
David Majnemer08249a32013-09-26 05:22:11 +00001019 []>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001020defm FCTIDZ : XForm_26r<63, 815, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001021 "fctidz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001022 [(set f64:$frD, (PPCfctidz f64:$frB))]>, isPPC64;
Hal Finkelf6d45f22013-04-01 17:52:07 +00001023
Ulrich Weigand136ac222013-04-26 16:53:15 +00001024defm FCFIDU : XForm_26r<63, 974, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001025 "fcfidu", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001026 [(set f64:$frD, (PPCfcfidu f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001027defm FCFIDS : XForm_26r<59, 846, (outs f4rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001028 "fcfids", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001029 [(set f32:$frD, (PPCfcfids f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001030defm FCFIDUS : XForm_26r<59, 974, (outs f4rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001031 "fcfidus", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001032 [(set f32:$frD, (PPCfcfidus f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001033defm FCTIDUZ : XForm_26r<63, 943, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001034 "fctiduz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001035 [(set f64:$frD, (PPCfctiduz f64:$frB))]>, isPPC64;
Ulrich Weigand136ac222013-04-26 16:53:15 +00001036defm FCTIWUZ : XForm_26r<63, 143, (outs f8rc:$frD), (ins f8rc:$frB),
Hal Finkel3e5a3602013-11-27 23:26:09 +00001037 "fctiwuz", "$frD, $frB", IIC_FPGeneral,
Hal Finkel654d43b2013-04-12 02:18:09 +00001038 [(set f64:$frD, (PPCfctiwuz f64:$frB))]>, isPPC64;
Chris Lattnerb4299832006-06-16 20:22:01 +00001039}
1040
1041
1042//===----------------------------------------------------------------------===//
1043// Instruction Patterns
1044//
Chris Lattner7e742e42006-06-20 22:34:10 +00001045
Chris Lattnerb4299832006-06-16 20:22:01 +00001046// Extensions and truncates to/from 32-bit regs.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001047def : Pat<(i64 (zext i32:$in)),
1048 (RLDICL (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32),
Hal Finkel2edfbdd2012-06-09 22:10:19 +00001049 0, 32)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001050def : Pat<(i64 (anyext i32:$in)),
1051 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), $in, sub_32)>;
1052def : Pat<(i32 (trunc i64:$in)),
1053 (EXTRACT_SUBREG $in, sub_32)>;
Chris Lattnerb4299832006-06-16 20:22:01 +00001054
Hal Finkel940ab932014-02-28 00:27:01 +00001055// Implement the 'not' operation with the NOR instruction.
1056// (we could use the default xori pattern, but nor has lower latency on some
1057// cores (such as the A2)).
1058def i64not : OutPatFrag<(ops node:$in),
1059 (NOR8 $in, $in)>;
1060def : Pat<(not i64:$in),
1061 (i64not $in)>;
1062
Chris Lattner96aecb52006-07-14 04:42:02 +00001063// Extending loads with i64 targets.
Evan Chenge71fe34d2006-10-09 20:57:25 +00001064def : Pat<(zextloadi1 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001065 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001066def : Pat<(zextloadi1 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001067 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001068def : Pat<(extloadi1 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001069 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001070def : Pat<(extloadi1 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001071 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001072def : Pat<(extloadi8 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001073 (LBZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001074def : Pat<(extloadi8 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001075 (LBZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001076def : Pat<(extloadi16 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001077 (LHZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001078def : Pat<(extloadi16 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001079 (LHZX8 xaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001080def : Pat<(extloadi32 iaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001081 (LWZ8 iaddr:$src)>;
Evan Chenge71fe34d2006-10-09 20:57:25 +00001082def : Pat<(extloadi32 xaddr:$src),
Chris Lattner96aecb52006-07-14 04:42:02 +00001083 (LWZX8 xaddr:$src)>;
1084
Chris Lattner20b5a2b2008-03-07 20:18:24 +00001085// Standard shifts. These are represented separately from the real shifts above
1086// so that we can distinguish between shifts that allow 6-bit and 7-bit shift
1087// amounts.
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001088def : Pat<(sra i64:$rS, i32:$rB),
1089 (SRAD $rS, $rB)>;
1090def : Pat<(srl i64:$rS, i32:$rB),
1091 (SRD $rS, $rB)>;
1092def : Pat<(shl i64:$rS, i32:$rB),
1093 (SLD $rS, $rB)>;
Chris Lattner20b5a2b2008-03-07 20:18:24 +00001094
Chris Lattnerb4299832006-06-16 20:22:01 +00001095// SHL/SRL
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001096def : Pat<(shl i64:$in, (i32 imm:$imm)),
1097 (RLDICR $in, imm:$imm, (SHL64 imm:$imm))>;
1098def : Pat<(srl i64:$in, (i32 imm:$imm)),
1099 (RLDICL $in, (SRL64 imm:$imm), imm:$imm)>;
Chris Lattner2d4e8f72006-06-20 21:23:06 +00001100
Evan Cheng4dbd9f22007-09-04 20:20:29 +00001101// ROTL
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001102def : Pat<(rotl i64:$in, i32:$sh),
1103 (RLDCL $in, $sh, 0)>;
1104def : Pat<(rotl i64:$in, (i32 imm:$imm)),
1105 (RLDICL $in, imm:$imm, 0)>;
Evan Cheng4dbd9f22007-09-04 20:20:29 +00001106
Chris Lattner2d4e8f72006-06-20 21:23:06 +00001107// Hi and Lo for Darwin Global Addresses.
1108def : Pat<(PPChi tglobaladdr:$in, 0), (LIS8 tglobaladdr:$in)>;
1109def : Pat<(PPClo tglobaladdr:$in, 0), (LI8 tglobaladdr:$in)>;
1110def : Pat<(PPChi tconstpool:$in , 0), (LIS8 tconstpool:$in)>;
1111def : Pat<(PPClo tconstpool:$in , 0), (LI8 tconstpool:$in)>;
1112def : Pat<(PPChi tjumptable:$in , 0), (LIS8 tjumptable:$in)>;
1113def : Pat<(PPClo tjumptable:$in , 0), (LI8 tjumptable:$in)>;
Bob Wilsonf84f7102009-11-04 21:31:18 +00001114def : Pat<(PPChi tblockaddress:$in, 0), (LIS8 tblockaddress:$in)>;
1115def : Pat<(PPClo tblockaddress:$in, 0), (LI8 tblockaddress:$in)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001116def : Pat<(PPChi tglobaltlsaddr:$g, i64:$in),
1117 (ADDIS8 $in, tglobaltlsaddr:$g)>;
1118def : Pat<(PPClo tglobaltlsaddr:$g, i64:$in),
Ulrich Weigand35f9fdf2013-03-26 10:55:20 +00001119 (ADDI8 $in, tglobaltlsaddr:$g)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001120def : Pat<(add i64:$in, (PPChi tglobaladdr:$g, 0)),
1121 (ADDIS8 $in, tglobaladdr:$g)>;
1122def : Pat<(add i64:$in, (PPChi tconstpool:$g, 0)),
1123 (ADDIS8 $in, tconstpool:$g)>;
1124def : Pat<(add i64:$in, (PPChi tjumptable:$g, 0)),
1125 (ADDIS8 $in, tjumptable:$g)>;
1126def : Pat<(add i64:$in, (PPChi tblockaddress:$g, 0)),
1127 (ADDIS8 $in, tblockaddress:$g)>;
Hal Finkelb09680b2013-03-18 23:00:58 +00001128
1129// Patterns to match r+r indexed loads and stores for
1130// addresses without at least 4-byte alignment.
1131def : Pat<(i64 (unaligned4sextloadi32 xoaddr:$src)),
1132 (LWAX xoaddr:$src)>;
1133def : Pat<(i64 (unaligned4load xoaddr:$src)),
1134 (LDX xoaddr:$src)>;
Ulrich Weigandec6e2cd2013-03-25 19:04:58 +00001135def : Pat<(unaligned4store i64:$rS, xoaddr:$dst),
1136 (STDX $rS, xoaddr:$dst)>;
Hal Finkelb09680b2013-03-18 23:00:58 +00001137