blob: db52a3b9e6f5fb7c73624b5aeb4c83213d740a16 [file] [log] [blame]
Evan Chenga8e29892007-01-19 07:51:42 +00001//===- ARMInstrThumb.td - Thumb support for ARM ---------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Evan Chenga8e29892007-01-19 07:51:42 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file describes the Thumb instruction set.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// Thumb specific DAG Nodes.
16//
17
18def ARMtcall : SDNode<"ARMISD::tCALL", SDT_ARMcall,
19 [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>;
20
Evan Chenga8e29892007-01-19 07:51:42 +000021def imm_neg_XFORM : SDNodeXForm<imm, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000022 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
Evan Chenga8e29892007-01-19 07:51:42 +000023}]>;
24def imm_comp_XFORM : SDNodeXForm<imm, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000025 return CurDAG->getTargetConstant(~((uint32_t)N->getZExtValue()), MVT::i32);
Evan Chenga8e29892007-01-19 07:51:42 +000026}]>;
27
28
29/// imm0_7 predicate - True if the 32-bit immediate is in the range [0,7].
30def imm0_7 : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000031 return (uint32_t)N->getZExtValue() < 8;
Evan Chenga8e29892007-01-19 07:51:42 +000032}]>;
33def imm0_7_neg : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000034 return (uint32_t)-N->getZExtValue() < 8;
Evan Chenga8e29892007-01-19 07:51:42 +000035}], imm_neg_XFORM>;
36
37def imm0_255 : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000038 return (uint32_t)N->getZExtValue() < 256;
Evan Chenga8e29892007-01-19 07:51:42 +000039}]>;
40def imm0_255_comp : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000041 return ~((uint32_t)N->getZExtValue()) < 256;
Evan Chenga8e29892007-01-19 07:51:42 +000042}]>;
43
44def imm8_255 : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000045 return (uint32_t)N->getZExtValue() >= 8 && (uint32_t)N->getZExtValue() < 256;
Evan Chenga8e29892007-01-19 07:51:42 +000046}]>;
47def imm8_255_neg : PatLeaf<(i32 imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000048 unsigned Val = -N->getZExtValue();
Evan Chenga8e29892007-01-19 07:51:42 +000049 return Val >= 8 && Val < 256;
50}], imm_neg_XFORM>;
51
52// Break imm's up into two pieces: an immediate + a left shift.
53// This uses thumb_immshifted to match and thumb_immshifted_val and
54// thumb_immshifted_shamt to get the val/shift pieces.
55def thumb_immshifted : PatLeaf<(imm), [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000056 return ARM_AM::isThumbImmShiftedVal((unsigned)N->getZExtValue());
Evan Chenga8e29892007-01-19 07:51:42 +000057}]>;
58
59def thumb_immshifted_val : SDNodeXForm<imm, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000060 unsigned V = ARM_AM::getThumbImmNonShiftedVal((unsigned)N->getZExtValue());
Evan Chenga8e29892007-01-19 07:51:42 +000061 return CurDAG->getTargetConstant(V, MVT::i32);
62}]>;
63
64def thumb_immshifted_shamt : SDNodeXForm<imm, [{
Dan Gohmanf5aeb1a2008-09-12 16:56:44 +000065 unsigned V = ARM_AM::getThumbImmValShift((unsigned)N->getZExtValue());
Evan Chenga8e29892007-01-19 07:51:42 +000066 return CurDAG->getTargetConstant(V, MVT::i32);
67}]>;
68
69// Define Thumb specific addressing modes.
70
71// t_addrmode_rr := reg + reg
72//
73def t_addrmode_rr : Operand<i32>,
74 ComplexPattern<i32, 2, "SelectThumbAddrModeRR", []> {
75 let PrintMethod = "printThumbAddrModeRROperand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +000076 let MIOperandInfo = (ops tGPR:$base, tGPR:$offsreg);
Evan Chenga8e29892007-01-19 07:51:42 +000077}
78
Evan Chengc38f2bc2007-01-23 22:59:13 +000079// t_addrmode_s4 := reg + reg
80// reg + imm5 * 4
Evan Chenga8e29892007-01-19 07:51:42 +000081//
Evan Chengc38f2bc2007-01-23 22:59:13 +000082def t_addrmode_s4 : Operand<i32>,
83 ComplexPattern<i32, 3, "SelectThumbAddrModeS4", []> {
84 let PrintMethod = "printThumbAddrModeS4Operand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +000085 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
Evan Chenga8e29892007-01-19 07:51:42 +000086}
Evan Chengc38f2bc2007-01-23 22:59:13 +000087
88// t_addrmode_s2 := reg + reg
89// reg + imm5 * 2
90//
91def t_addrmode_s2 : Operand<i32>,
92 ComplexPattern<i32, 3, "SelectThumbAddrModeS2", []> {
93 let PrintMethod = "printThumbAddrModeS2Operand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +000094 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
Evan Chenga8e29892007-01-19 07:51:42 +000095}
Evan Chengc38f2bc2007-01-23 22:59:13 +000096
97// t_addrmode_s1 := reg + reg
98// reg + imm5
99//
100def t_addrmode_s1 : Operand<i32>,
101 ComplexPattern<i32, 3, "SelectThumbAddrModeS1", []> {
102 let PrintMethod = "printThumbAddrModeS1Operand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000103 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm, tGPR:$offsreg);
Evan Chenga8e29892007-01-19 07:51:42 +0000104}
105
106// t_addrmode_sp := sp + imm8 * 4
107//
108def t_addrmode_sp : Operand<i32>,
109 ComplexPattern<i32, 2, "SelectThumbAddrModeSP", []> {
110 let PrintMethod = "printThumbAddrModeSPOperand";
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000111 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm);
Evan Chenga8e29892007-01-19 07:51:42 +0000112}
113
114//===----------------------------------------------------------------------===//
115// Miscellaneous Instructions.
116//
117
Evan Cheng071a2792007-09-11 19:55:27 +0000118let Defs = [SP], Uses = [SP] in {
Evan Cheng44bec522007-05-15 01:29:07 +0000119def tADJCALLSTACKUP :
Bill Wendling0f8d9c02007-11-13 00:44:25 +0000120PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2),
121 "@ tADJCALLSTACKUP $amt1",
122 [(ARMcallseq_end imm:$amt1, imm:$amt2)]>, Requires<[IsThumb]>;
Evan Cheng44bec522007-05-15 01:29:07 +0000123
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000124def tADJCALLSTACKDOWN :
Evan Cheng64d80e32007-07-19 01:14:50 +0000125PseudoInst<(outs), (ins i32imm:$amt),
Evan Cheng44bec522007-05-15 01:29:07 +0000126 "@ tADJCALLSTACKDOWN $amt",
Evan Cheng071a2792007-09-11 19:55:27 +0000127 [(ARMcallseq_start imm:$amt)]>, Requires<[IsThumb]>;
128}
Evan Cheng44bec522007-05-15 01:29:07 +0000129
Evan Chengeaa91b02007-06-19 01:26:51 +0000130let isNotDuplicable = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000131def tPICADD : TIt<(outs tGPR:$dst), (ins tGPR:$lhs, pclabel:$cp),
Evan Chengc60e76d2007-01-30 20:37:08 +0000132 "$cp:\n\tadd $dst, pc",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000133 [(set tGPR:$dst, (ARMpic_add tGPR:$lhs, imm:$cp))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000134
135//===----------------------------------------------------------------------===//
136// Control Flow Instructions.
137//
138
Evan Cheng9d945f72007-02-01 01:49:46 +0000139let isReturn = 1, isTerminator = 1 in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000140 def tBX_RET : TI<(outs), (ins), "bx lr", [(ARMretflag)]>;
Evan Cheng9d945f72007-02-01 01:49:46 +0000141 // Alternative return instruction used by vararg functions.
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000142 def tBX_RET_vararg : TI<(outs), (ins tGPR:$target), "bx $target", []>;
Evan Cheng9d945f72007-02-01 01:49:46 +0000143}
Evan Chenga8e29892007-01-19 07:51:42 +0000144
145// FIXME: remove when we have a way to marking a MI with these properties.
Evan Cheng325474e2008-01-07 23:56:57 +0000146let isReturn = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000147def tPOP_RET : TI<(outs reglist:$dst1, variable_ops), (ins),
Evan Chenga8e29892007-01-19 07:51:42 +0000148 "pop $dst1", []>;
149
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000150let isCall = 1,
Evan Chenga8e29892007-01-19 07:51:42 +0000151 Defs = [R0, R1, R2, R3, LR,
152 D0, D1, D2, D3, D4, D5, D6, D7] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000153 def tBL : TIx2<(outs), (ins i32imm:$func, variable_ops),
Evan Chenga8e29892007-01-19 07:51:42 +0000154 "bl ${func:call}",
155 [(ARMtcall tglobaladdr:$func)]>;
156 // ARMv5T and above
Evan Cheng64d80e32007-07-19 01:14:50 +0000157 def tBLXi : TIx2<(outs), (ins i32imm:$func, variable_ops),
Evan Chenga8e29892007-01-19 07:51:42 +0000158 "blx ${func:call}",
159 [(ARMcall tglobaladdr:$func)]>, Requires<[HasV5T]>;
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000160 def tBLXr : TI<(outs), (ins tGPR:$func, variable_ops),
Evan Cheng64d80e32007-07-19 01:14:50 +0000161 "blx $func",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000162 [(ARMtcall tGPR:$func)]>, Requires<[HasV5T]>;
Lauro Ramos Venanciob8a93a42007-03-27 16:19:21 +0000163 // ARMv4T
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000164 def tBX : TIx2<(outs), (ins tGPR:$func, variable_ops),
Evan Cheng64d80e32007-07-19 01:14:50 +0000165 "cpy lr, pc\n\tbx $func",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000166 [(ARMcall_nolink tGPR:$func)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000167}
168
Evan Chengffbacca2007-07-21 00:34:19 +0000169let isBranch = 1, isTerminator = 1 in {
Evan Cheng3f8602c2007-05-16 21:53:43 +0000170 let isBarrier = 1 in {
171 let isPredicable = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000172 def tB : TI<(outs), (ins brtarget:$target), "b $target",
173 [(br bb:$target)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000174
Evan Cheng225dfe92007-01-30 01:13:37 +0000175 // Far jump
Evan Cheng64d80e32007-07-19 01:14:50 +0000176 def tBfar : TIx2<(outs), (ins brtarget:$target), "bl $target\t@ far jump",[]>;
Evan Cheng225dfe92007-01-30 01:13:37 +0000177
Evan Cheng64d80e32007-07-19 01:14:50 +0000178 def tBR_JTr : TJTI<(outs),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000179 (ins tGPR:$target, jtblock_operand:$jt, i32imm:$id),
Evan Cheng64d80e32007-07-19 01:14:50 +0000180 "cpy pc, $target \n\t.align\t2\n$jt",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000181 [(ARMbrjt tGPR:$target, tjumptable:$jt, imm:$id)]>;
Evan Cheng3f8602c2007-05-16 21:53:43 +0000182 }
Evan Chengd85ac4d2007-01-27 02:29:45 +0000183}
184
Evan Chengc85e8322007-07-05 07:13:32 +0000185// FIXME: should be able to write a pattern for ARMBrcond, but can't use
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000186// a two-value operand where a dag node expects two operands. :(
Evan Chengffbacca2007-07-21 00:34:19 +0000187let isBranch = 1, isTerminator = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000188 def tBcc : TI<(outs), (ins brtarget:$target, pred:$cc), "b$cc $target",
189 [/*(ARMbrcond bb:$target, imm:$cc)*/]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000190
191//===----------------------------------------------------------------------===//
192// Load Store Instructions.
193//
194
Dan Gohman15511cf2008-12-03 18:15:48 +0000195let canFoldAsLoad = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000196def tLDR : TI4<(outs tGPR:$dst), (ins t_addrmode_s4:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000197 "ldr $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000198 [(set tGPR:$dst, (load t_addrmode_s4:$addr))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000199
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000200def tLDRB : TI1<(outs tGPR:$dst), (ins t_addrmode_s1:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000201 "ldrb $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000202 [(set tGPR:$dst, (zextloadi8 t_addrmode_s1:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000203
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000204def tLDRH : TI2<(outs tGPR:$dst), (ins t_addrmode_s2:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000205 "ldrh $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000206 [(set tGPR:$dst, (zextloadi16 t_addrmode_s2:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000207
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000208def tLDRSB : TI1<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000209 "ldrsb $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000210 [(set tGPR:$dst, (sextloadi8 t_addrmode_rr:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000211
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000212def tLDRSH : TI2<(outs tGPR:$dst), (ins t_addrmode_rr:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000213 "ldrsh $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000214 [(set tGPR:$dst, (sextloadi16 t_addrmode_rr:$addr))]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000215
Dan Gohman15511cf2008-12-03 18:15:48 +0000216let canFoldAsLoad = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000217def tLDRspi : TIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
Evan Chenga8e29892007-01-19 07:51:42 +0000218 "ldr $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000219 [(set tGPR:$dst, (load t_addrmode_sp:$addr))]>;
Evan Cheng012f2d92007-01-24 08:53:17 +0000220
Evan Cheng8e59ea92007-02-07 00:06:56 +0000221// Special instruction for restore. It cannot clobber condition register
222// when it's expanded by eliminateCallFramePseudoInstr().
Dan Gohman15511cf2008-12-03 18:15:48 +0000223let canFoldAsLoad = 1, mayLoad = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000224def tRestore : TIs<(outs tGPR:$dst), (ins t_addrmode_sp:$addr),
Evan Cheng8e59ea92007-02-07 00:06:56 +0000225 "ldr $dst, $addr", []>;
226
Evan Cheng012f2d92007-01-24 08:53:17 +0000227// Load tconstpool
Dan Gohman15511cf2008-12-03 18:15:48 +0000228let canFoldAsLoad = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000229def tLDRpci : TIs<(outs tGPR:$dst), (ins i32imm:$addr),
Evan Cheng012f2d92007-01-24 08:53:17 +0000230 "ldr $dst, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000231 [(set tGPR:$dst, (load (ARMWrapper tconstpool:$addr)))]>;
Evan Chengfa775d02007-03-19 07:20:03 +0000232
233// Special LDR for loads from non-pc-relative constpools.
Dan Gohman15511cf2008-12-03 18:15:48 +0000234let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1 in
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000235def tLDRcp : TIs<(outs tGPR:$dst), (ins i32imm:$addr),
Evan Chengfa775d02007-03-19 07:20:03 +0000236 "ldr $dst, $addr", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000237
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000238def tSTR : TI4<(outs), (ins tGPR:$src, t_addrmode_s4:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000239 "str $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000240 [(store tGPR:$src, t_addrmode_s4:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000241
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000242def tSTRB : TI1<(outs), (ins tGPR:$src, t_addrmode_s1:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000243 "strb $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000244 [(truncstorei8 tGPR:$src, t_addrmode_s1:$addr)]>;
Evan Chengc38f2bc2007-01-23 22:59:13 +0000245
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000246def tSTRH : TI2<(outs), (ins tGPR:$src, t_addrmode_s2:$addr),
Evan Chengc38f2bc2007-01-23 22:59:13 +0000247 "strh $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000248 [(truncstorei16 tGPR:$src, t_addrmode_s2:$addr)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000249
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000250def tSTRspi : TIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
Evan Chenga8e29892007-01-19 07:51:42 +0000251 "str $src, $addr",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000252 [(store tGPR:$src, t_addrmode_sp:$addr)]>;
Evan Cheng8e59ea92007-02-07 00:06:56 +0000253
Chris Lattner2e48a702008-01-06 08:36:04 +0000254let mayStore = 1 in {
Evan Cheng8e59ea92007-02-07 00:06:56 +0000255// Special instruction for spill. It cannot clobber condition register
256// when it's expanded by eliminateCallFramePseudoInstr().
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000257def tSpill : TIs<(outs), (ins tGPR:$src, t_addrmode_sp:$addr),
Evan Cheng8e59ea92007-02-07 00:06:56 +0000258 "str $src, $addr", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000259}
260
261//===----------------------------------------------------------------------===//
262// Load / store multiple Instructions.
263//
264
265// TODO: A7-44: LDMIA - load multiple
266
Chris Lattner9b37aaf2008-01-10 05:12:37 +0000267let mayLoad = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000268def tPOP : TI<(outs reglist:$dst1, variable_ops), (ins),
Evan Chenga8e29892007-01-19 07:51:42 +0000269 "pop $dst1", []>;
270
Chris Lattner2e48a702008-01-06 08:36:04 +0000271let mayStore = 1 in
Evan Cheng64d80e32007-07-19 01:14:50 +0000272def tPUSH : TI<(outs), (ins reglist:$src1, variable_ops),
Evan Chenga8e29892007-01-19 07:51:42 +0000273 "push $src1", []>;
274
275//===----------------------------------------------------------------------===//
276// Arithmetic Instructions.
277//
278
Evan Cheng53d7dba2007-01-27 00:07:15 +0000279// Add with carry
Eli Friedman6b7bb422009-06-19 01:43:08 +0000280let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000281def tADC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Cheng53d7dba2007-01-27 00:07:15 +0000282 "adc $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000283 [(set tGPR:$dst, (adde tGPR:$lhs, tGPR:$rhs))]>;
Evan Cheng53d7dba2007-01-27 00:07:15 +0000284
Evan Cheng09c39fc2009-06-23 19:38:13 +0000285def tADDS : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Cheng3471b602007-01-31 20:12:31 +0000286 "add $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000287 [(set tGPR:$dst, (addc tGPR:$lhs, tGPR:$rhs))]>;
Evan Cheng53d7dba2007-01-27 00:07:15 +0000288
289
Evan Cheng09c39fc2009-06-23 19:38:13 +0000290def tADDi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000291 "add $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000292 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000293
Evan Cheng09c39fc2009-06-23 19:38:13 +0000294def tADDi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000295 "add $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000296 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000297
Evan Cheng09c39fc2009-06-23 19:38:13 +0000298def tADDrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000299 "add $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000300 [(set tGPR:$dst, (add tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000301
Evan Chengcd799b92009-06-12 20:46:18 +0000302let neverHasSideEffects = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000303def tADDhirr : T1It<(outs tGPR:$dst), (ins GPR:$lhs, GPR:$rhs),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000304 "add $dst, $rhs @ addhirr", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000305
Evan Cheng09c39fc2009-06-23 19:38:13 +0000306def tADDrPCi : T1I<(outs tGPR:$dst), (ins i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000307 "add $dst, pc, $rhs * 4", []>;
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000308
Evan Cheng09c39fc2009-06-23 19:38:13 +0000309def tADDrSPi : T1I<(outs tGPR:$dst), (ins GPR:$sp, i32imm:$rhs),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000310 "add $dst, $sp, $rhs * 4 @ addrspi", []>;
311
Evan Cheng09c39fc2009-06-23 19:38:13 +0000312def tADDspi : T1It<(outs GPR:$dst), (ins GPR:$lhs, i32imm:$rhs),
Evan Cheng3fdadfc2007-01-26 21:33:19 +0000313 "add $dst, $rhs * 4", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000314
Eli Friedman6b7bb422009-06-19 01:43:08 +0000315let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000316def tAND : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000317 "and $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000318 [(set tGPR:$dst, (and tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000319
Evan Cheng09c39fc2009-06-23 19:38:13 +0000320def tASRri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000321 "asr $dst, $lhs, $rhs",
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000322 [(set tGPR:$dst, (sra tGPR:$lhs, (i32 imm:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000323
Evan Cheng09c39fc2009-06-23 19:38:13 +0000324def tASRrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000325 "asr $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000326 [(set tGPR:$dst, (sra tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000327
Evan Cheng09c39fc2009-06-23 19:38:13 +0000328def tBIC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000329 "bic $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000330 [(set tGPR:$dst, (and tGPR:$lhs, (not tGPR:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000331
332
Evan Cheng09c39fc2009-06-23 19:38:13 +0000333def tCMN : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000334 "cmn $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000335 [(ARMcmp tGPR:$lhs, (ineg tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000336
Evan Cheng09c39fc2009-06-23 19:38:13 +0000337def tCMPi8 : T1I<(outs), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000338 "cmp $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000339 [(ARMcmp tGPR:$lhs, imm0_255:$rhs)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000340
Evan Cheng09c39fc2009-06-23 19:38:13 +0000341def tCMPr : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000342 "cmp $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000343 [(ARMcmp tGPR:$lhs, tGPR:$rhs)]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000344
Evan Cheng09c39fc2009-06-23 19:38:13 +0000345def tTST : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000346 "tst $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000347 [(ARMcmpNZ (and tGPR:$lhs, tGPR:$rhs), 0)]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000348
Evan Cheng09c39fc2009-06-23 19:38:13 +0000349def tCMNNZ : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000350 "cmn $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000351 [(ARMcmpNZ tGPR:$lhs, (ineg tGPR:$rhs))]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000352
Evan Cheng09c39fc2009-06-23 19:38:13 +0000353def tCMPNZi8 : T1I<(outs), (ins tGPR:$lhs, i32imm:$rhs),
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000354 "cmp $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000355 [(ARMcmpNZ tGPR:$lhs, imm0_255:$rhs)]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000356
Evan Cheng09c39fc2009-06-23 19:38:13 +0000357def tCMPNZr : T1I<(outs), (ins tGPR:$lhs, tGPR:$rhs),
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000358 "cmp $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000359 [(ARMcmpNZ tGPR:$lhs, tGPR:$rhs)]>;
Lauro Ramos Venancio99966632007-04-02 01:30:03 +0000360
Evan Chenga8e29892007-01-19 07:51:42 +0000361// TODO: A7-37: CMP(3) - cmp hi regs
362
Eli Friedman6b7bb422009-06-19 01:43:08 +0000363let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000364def tEOR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000365 "eor $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000366 [(set tGPR:$dst, (xor tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000367
Evan Cheng09c39fc2009-06-23 19:38:13 +0000368def tLSLri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000369 "lsl $dst, $lhs, $rhs",
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000370 [(set tGPR:$dst, (shl tGPR:$lhs, (i32 imm:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000371
Evan Cheng09c39fc2009-06-23 19:38:13 +0000372def tLSLrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000373 "lsl $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000374 [(set tGPR:$dst, (shl tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000375
Evan Cheng09c39fc2009-06-23 19:38:13 +0000376def tLSRri : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000377 "lsr $dst, $lhs, $rhs",
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000378 [(set tGPR:$dst, (srl tGPR:$lhs, (i32 imm:$rhs)))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000379
Evan Cheng09c39fc2009-06-23 19:38:13 +0000380def tLSRrr : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000381 "lsr $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000382 [(set tGPR:$dst, (srl tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000383
Evan Cheng5e3c2032007-03-29 21:38:31 +0000384// FIXME: This is not rematerializable because mov changes the condition code.
Evan Cheng09c39fc2009-06-23 19:38:13 +0000385def tMOVi8 : T1I<(outs tGPR:$dst), (ins i32imm:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000386 "mov $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000387 [(set tGPR:$dst, imm0_255:$src)]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000388
389// TODO: A7-73: MOV(2) - mov setting flag.
390
391
392// Note: MOV(2) of two low regs updates the flags, so we emit this as 'cpy',
393// which is MOV(3). This also supports high registers.
Evan Chengcd799b92009-06-12 20:46:18 +0000394let neverHasSideEffects = 1 in {
Evan Cheng09c39fc2009-06-23 19:38:13 +0000395def tMOVr : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000396 "cpy $dst, $src", []>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000397def tMOVhir2lor : T1I<(outs tGPR:$dst), (ins GPR:$src),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000398 "cpy $dst, $src\t@ hir2lor", []>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000399def tMOVlor2hir : T1I<(outs GPR:$dst), (ins tGPR:$src),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000400 "cpy $dst, $src\t@ lor2hir", []>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000401def tMOVhir2hir : T1I<(outs GPR:$dst), (ins GPR:$src),
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000402 "cpy $dst, $src\t@ hir2hir", []>;
Evan Chengcd799b92009-06-12 20:46:18 +0000403} // neverHasSideEffects
Evan Chenga8e29892007-01-19 07:51:42 +0000404
Eli Friedman6b7bb422009-06-19 01:43:08 +0000405let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000406def tMUL : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000407 "mul $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000408 [(set tGPR:$dst, (mul tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000409
Evan Cheng09c39fc2009-06-23 19:38:13 +0000410def tMVN : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000411 "mvn $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000412 [(set tGPR:$dst, (not tGPR:$src))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000413
Evan Cheng09c39fc2009-06-23 19:38:13 +0000414def tNEG : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000415 "neg $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000416 [(set tGPR:$dst, (ineg tGPR:$src))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000417
Eli Friedman6b7bb422009-06-19 01:43:08 +0000418let isCommutable = 1 in
Evan Cheng09c39fc2009-06-23 19:38:13 +0000419def tORR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000420 "orr $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000421 [(set tGPR:$dst, (or tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000422
423
Evan Cheng09c39fc2009-06-23 19:38:13 +0000424def tREV : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000425 "rev $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000426 [(set tGPR:$dst, (bswap tGPR:$src))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000427 Requires<[IsThumb, HasV6]>;
428
Evan Cheng09c39fc2009-06-23 19:38:13 +0000429def tREV16 : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000430 "rev16 $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000431 [(set tGPR:$dst,
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000432 (or (and (srl tGPR:$src, (i32 8)), 0xFF),
433 (or (and (shl tGPR:$src, (i32 8)), 0xFF00),
434 (or (and (srl tGPR:$src, (i32 8)), 0xFF0000),
435 (and (shl tGPR:$src, (i32 8)), 0xFF000000)))))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000436 Requires<[IsThumb, HasV6]>;
437
Evan Cheng09c39fc2009-06-23 19:38:13 +0000438def tREVSH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000439 "revsh $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000440 [(set tGPR:$dst,
Evan Chenga8e29892007-01-19 07:51:42 +0000441 (sext_inreg
Bob Wilson1c76d0e2009-06-22 22:08:29 +0000442 (or (srl (and tGPR:$src, 0xFFFF), (i32 8)),
443 (shl tGPR:$src, (i32 8))), i16))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000444 Requires<[IsThumb, HasV6]>;
445
Evan Cheng09c39fc2009-06-23 19:38:13 +0000446def tROR : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000447 "ror $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000448 [(set tGPR:$dst, (rotr tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000449
Evan Cheng53d7dba2007-01-27 00:07:15 +0000450
451// Subtract with carry
Evan Cheng09c39fc2009-06-23 19:38:13 +0000452def tSBC : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000453 "sbc $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000454 [(set tGPR:$dst, (sube tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000455
Evan Cheng09c39fc2009-06-23 19:38:13 +0000456def tSUBS : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Cheng3471b602007-01-31 20:12:31 +0000457 "sub $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000458 [(set tGPR:$dst, (subc tGPR:$lhs, tGPR:$rhs))]>;
Evan Cheng53d7dba2007-01-27 00:07:15 +0000459
460
Evan Chenga8e29892007-01-19 07:51:42 +0000461// TODO: A7-96: STMIA - store multiple.
462
Evan Cheng09c39fc2009-06-23 19:38:13 +0000463def tSUBi3 : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000464 "sub $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000465 [(set tGPR:$dst, (add tGPR:$lhs, imm0_7_neg:$rhs))]>;
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000466
Evan Cheng09c39fc2009-06-23 19:38:13 +0000467def tSUBi8 : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000468 "sub $dst, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000469 [(set tGPR:$dst, (add tGPR:$lhs, imm8_255_neg:$rhs))]>;
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000470
Evan Cheng09c39fc2009-06-23 19:38:13 +0000471def tSUBrr : T1I<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs),
Evan Chenga8e29892007-01-19 07:51:42 +0000472 "sub $dst, $lhs, $rhs",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000473 [(set tGPR:$dst, (sub tGPR:$lhs, tGPR:$rhs))]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000474
Evan Cheng09c39fc2009-06-23 19:38:13 +0000475def tSUBspi : T1It<(outs tGPR:$dst), (ins tGPR:$lhs, i32imm:$rhs),
Evan Cheng3fdadfc2007-01-26 21:33:19 +0000476 "sub $dst, $rhs * 4", []>;
Evan Chenga8e29892007-01-19 07:51:42 +0000477
Evan Cheng09c39fc2009-06-23 19:38:13 +0000478def tSXTB : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000479 "sxtb $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000480 [(set tGPR:$dst, (sext_inreg tGPR:$src, i8))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000481 Requires<[IsThumb, HasV6]>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000482def tSXTH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000483 "sxth $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000484 [(set tGPR:$dst, (sext_inreg tGPR:$src, i16))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000485 Requires<[IsThumb, HasV6]>;
486
Evan Chenga8e29892007-01-19 07:51:42 +0000487
Evan Cheng09c39fc2009-06-23 19:38:13 +0000488def tUXTB : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000489 "uxtb $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000490 [(set tGPR:$dst, (and tGPR:$src, 0xFF))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000491 Requires<[IsThumb, HasV6]>;
Evan Cheng09c39fc2009-06-23 19:38:13 +0000492def tUXTH : T1I<(outs tGPR:$dst), (ins tGPR:$src),
Evan Chenga8e29892007-01-19 07:51:42 +0000493 "uxth $dst, $src",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000494 [(set tGPR:$dst, (and tGPR:$src, 0xFFFF))]>,
Evan Chenga8e29892007-01-19 07:51:42 +0000495 Requires<[IsThumb, HasV6]>;
496
497
498// Conditional move tMOVCCr - Used to implement the Thumb SELECT_CC DAG operation.
499// Expanded by the scheduler into a branch sequence.
500let usesCustomDAGSchedInserter = 1 in // Expanded by the scheduler.
501 def tMOVCCr :
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000502 PseudoInst<(outs tGPR:$dst), (ins tGPR:$false, tGPR:$true, pred:$cc),
Evan Chenga8e29892007-01-19 07:51:42 +0000503 "@ tMOVCCr $cc",
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000504 [/*(set tGPR:$dst, (ARMcmov tGPR:$false, tGPR:$true, imm:$cc))*/]>;
Evan Chenga8e29892007-01-19 07:51:42 +0000505
506// tLEApcrel - Load a pc-relative address into a register without offending the
507// assembler.
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000508def tLEApcrel : TIx2<(outs tGPR:$dst), (ins i32imm:$label),
Evan Chenga8e29892007-01-19 07:51:42 +0000509 !strconcat(!strconcat(".set PCRELV${:uid}, ($label-(",
Evan Cheng1b201682007-05-01 20:27:19 +0000510 "${:private}PCRELL${:uid}+4))\n"),
Evan Chenge0c2b6b2007-02-01 03:04:49 +0000511 !strconcat("\tmov $dst, #PCRELV${:uid}\n",
512 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
Evan Chenga8e29892007-01-19 07:51:42 +0000513 []>;
514
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000515def tLEApcrelJT : TIx2<(outs tGPR:$dst), (ins i32imm:$label, i32imm:$id),
Evan Chengd85ac4d2007-01-27 02:29:45 +0000516 !strconcat(!strconcat(".set PCRELV${:uid}, (${label}_${id:no_hash}-(",
517 "${:private}PCRELL${:uid}+4))\n"),
Evan Chenge0c2b6b2007-02-01 03:04:49 +0000518 !strconcat("\tmov $dst, #PCRELV${:uid}\n",
519 "${:private}PCRELL${:uid}:\n\tadd $dst, pc")),
520 []>;
Evan Chengd85ac4d2007-01-27 02:29:45 +0000521
Evan Chenga8e29892007-01-19 07:51:42 +0000522//===----------------------------------------------------------------------===//
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +0000523// TLS Instructions
524//
525
526// __aeabi_read_tp preserves the registers r1-r3.
527let isCall = 1,
528 Defs = [R0, LR] in {
Evan Cheng64d80e32007-07-19 01:14:50 +0000529 def tTPsoft : TIx2<(outs), (ins),
Lauro Ramos Venancio64f4fa52007-04-27 13:54:47 +0000530 "bl __aeabi_read_tp",
531 [(set R0, ARMthread_pointer)]>;
532}
533
534//===----------------------------------------------------------------------===//
Evan Chenga8e29892007-01-19 07:51:42 +0000535// Non-Instruction Patterns
536//
537
538// ConstantPool, GlobalAddress
539def : ThumbPat<(ARMWrapper tglobaladdr :$dst), (tLEApcrel tglobaladdr :$dst)>;
540def : ThumbPat<(ARMWrapper tconstpool :$dst), (tLEApcrel tconstpool :$dst)>;
Evan Chenga8e29892007-01-19 07:51:42 +0000541
Evan Chengd85ac4d2007-01-27 02:29:45 +0000542// JumpTable
543def : ThumbPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
544 (tLEApcrelJT tjumptable:$dst, imm:$id)>;
545
Evan Chenga8e29892007-01-19 07:51:42 +0000546// Direct calls
547def : ThumbPat<(ARMtcall texternalsym:$func), (tBL texternalsym:$func)>;
548def : ThumbV5Pat<(ARMcall texternalsym:$func), (tBLXi texternalsym:$func)>;
549
550// Indirect calls to ARM routines
Jim Grosbach30eae3c2009-04-07 20:34:09 +0000551def : ThumbV5Pat<(ARMcall tGPR:$dst), (tBLXr tGPR:$dst)>;
Evan Chenga8e29892007-01-19 07:51:42 +0000552
553// zextload i1 -> zextload i8
Evan Chengc38f2bc2007-01-23 22:59:13 +0000554def : ThumbPat<(zextloadi1 t_addrmode_s1:$addr),
555 (tLDRB t_addrmode_s1:$addr)>;
Jim Grosbach0ede14f2009-03-27 23:06:27 +0000556
Evan Chengb60c02e2007-01-26 19:13:16 +0000557// extload -> zextload
558def : ThumbPat<(extloadi1 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
559def : ThumbPat<(extloadi8 t_addrmode_s1:$addr), (tLDRB t_addrmode_s1:$addr)>;
560def : ThumbPat<(extloadi16 t_addrmode_s2:$addr), (tLDRH t_addrmode_s2:$addr)>;
561
Evan Chenga8e29892007-01-19 07:51:42 +0000562// Large immediate handling.
563
564// Two piece imms.
Evan Cheng09c39fc2009-06-23 19:38:13 +0000565def : Thumb1Pat<(i32 thumb_immshifted:$src),
566 (tLSLri (tMOVi8 (thumb_immshifted_val imm:$src)),
567 (thumb_immshifted_shamt imm:$src))>;
Evan Chenga8e29892007-01-19 07:51:42 +0000568
Evan Cheng09c39fc2009-06-23 19:38:13 +0000569def : Thumb1Pat<(i32 imm0_255_comp:$src),
570 (tMVN (tMOVi8 (imm_comp_XFORM imm:$src)))>;