Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file describes the ARM instructions in TableGen format. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | // ARM specific DAG Nodes. |
| 16 | // |
| 17 | |
| 18 | // Type profiles. |
Bill Wendling | 7173da5 | 2007-11-13 09:19:02 +0000 | [diff] [blame] | 19 | def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>; |
| 20 | def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 21 | |
| 22 | def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>; |
| 23 | |
| 24 | def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisInt<0>]>; |
| 25 | |
| 26 | def SDT_ARMCMov : SDTypeProfile<1, 3, |
| 27 | [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, |
| 28 | SDTCisVT<3, i32>]>; |
| 29 | |
| 30 | def SDT_ARMBrcond : SDTypeProfile<0, 2, |
| 31 | [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>; |
| 32 | |
| 33 | def SDT_ARMBrJT : SDTypeProfile<0, 3, |
| 34 | [SDTCisPtrTy<0>, SDTCisVT<1, i32>, |
| 35 | SDTCisVT<2, i32>]>; |
| 36 | |
Evan Cheng | 1b2b3e2 | 2009-07-29 02:18:14 +0000 | [diff] [blame] | 37 | def SDT_ARMBr2JT : SDTypeProfile<0, 4, |
| 38 | [SDTCisPtrTy<0>, SDTCisVT<1, i32>, |
| 39 | SDTCisVT<2, i32>, SDTCisVT<3, i32>]>; |
| 40 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 41 | def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>; |
| 42 | |
| 43 | def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, |
| 44 | SDTCisPtrTy<1>, SDTCisVT<2, i32>]>; |
| 45 | |
| 46 | def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; |
Jim Grosbach | 4a9025e | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 47 | def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 1, [SDTCisInt<0>, SDTCisPtrTy<1>]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 48 | |
| 49 | // Node definitions. |
| 50 | def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>; |
| 51 | def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>; |
| 52 | |
Bill Wendling | 7173da5 | 2007-11-13 09:19:02 +0000 | [diff] [blame] | 53 | def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart, |
Bill Wendling | 6c02cd2 | 2008-02-27 06:33:05 +0000 | [diff] [blame] | 54 | [SDNPHasChain, SDNPOutFlag]>; |
Bill Wendling | 7173da5 | 2007-11-13 09:19:02 +0000 | [diff] [blame] | 55 | def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd, |
Bill Wendling | 6c02cd2 | 2008-02-27 06:33:05 +0000 | [diff] [blame] | 56 | [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 57 | |
| 58 | def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall, |
| 59 | [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; |
| 60 | def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall, |
| 61 | [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; |
| 62 | def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall, |
| 63 | [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; |
| 64 | |
Chris Lattner | 3d25455 | 2008-01-15 22:02:54 +0000 | [diff] [blame] | 65 | def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 66 | [SDNPHasChain, SDNPOptInFlag]>; |
| 67 | |
| 68 | def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov, |
| 69 | [SDNPInFlag]>; |
| 70 | def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov, |
| 71 | [SDNPInFlag]>; |
| 72 | |
| 73 | def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond, |
| 74 | [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>; |
| 75 | |
| 76 | def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT, |
| 77 | [SDNPHasChain]>; |
Evan Cheng | 1b2b3e2 | 2009-07-29 02:18:14 +0000 | [diff] [blame] | 78 | def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT, |
| 79 | [SDNPHasChain]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 80 | |
| 81 | def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp, |
| 82 | [SDNPOutFlag]>; |
| 83 | |
David Goodwin | 8bdcbb3 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 84 | def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp, |
| 85 | [SDNPOutFlag,SDNPCommutative]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 86 | |
| 87 | def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>; |
| 88 | |
| 89 | def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>; |
| 90 | def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>; |
| 91 | def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>; |
| 92 | |
| 93 | def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>; |
Jim Grosbach | 4a9025e | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 94 | def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP", SDT_ARMEH_SJLJ_Setjmp>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 95 | |
| 96 | //===----------------------------------------------------------------------===// |
| 97 | // ARM Instruction Predicate Definitions. |
| 98 | // |
Anton Korobeynikov | cba0269 | 2009-06-15 21:46:20 +0000 | [diff] [blame] | 99 | def HasV5T : Predicate<"Subtarget->hasV5TOps()">; |
| 100 | def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">; |
| 101 | def HasV6 : Predicate<"Subtarget->hasV6Ops()">; |
Evan Cheng | c8147e1 | 2009-07-06 22:05:45 +0000 | [diff] [blame] | 102 | def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">; |
Evan Cheng | 16c012d | 2009-09-28 09:14:39 +0000 | [diff] [blame] | 103 | def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">; |
Bob Wilson | e60fee0 | 2009-06-22 23:27:02 +0000 | [diff] [blame] | 104 | def HasV7 : Predicate<"Subtarget->hasV7Ops()">; |
| 105 | def HasVFP2 : Predicate<"Subtarget->hasVFP2()">; |
| 106 | def HasVFP3 : Predicate<"Subtarget->hasVFP3()">; |
| 107 | def HasNEON : Predicate<"Subtarget->hasNEON()">; |
David Goodwin | dd19ce4 | 2009-08-04 17:53:06 +0000 | [diff] [blame] | 108 | def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">; |
| 109 | def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">; |
Anton Korobeynikov | cba0269 | 2009-06-15 21:46:20 +0000 | [diff] [blame] | 110 | def IsThumb : Predicate<"Subtarget->isThumb()">; |
Evan Cheng | 3617371 | 2009-06-23 17:48:47 +0000 | [diff] [blame] | 111 | def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">; |
Evan Cheng | b1b2abc | 2009-07-02 06:38:40 +0000 | [diff] [blame] | 112 | def IsThumb2 : Predicate<"Subtarget->isThumb2()">; |
Anton Korobeynikov | cba0269 | 2009-06-15 21:46:20 +0000 | [diff] [blame] | 113 | def IsARM : Predicate<"!Subtarget->isThumb()">; |
Bob Wilson | 243b37c | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 114 | def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">; |
| 115 | def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">; |
Evan Cheng | 3e9a99e | 2009-06-26 06:10:18 +0000 | [diff] [blame] | 116 | def CarryDefIsUnused : Predicate<"!N.getNode()->hasAnyUseOfValue(1)">; |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 117 | def CarryDefIsUsed : Predicate<"N.getNode()->hasAnyUseOfValue(1)">; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 118 | |
| 119 | //===----------------------------------------------------------------------===// |
| 120 | // ARM Flag Definitions. |
| 121 | |
| 122 | class RegConstraint<string C> { |
| 123 | string Constraints = C; |
| 124 | } |
| 125 | |
| 126 | //===----------------------------------------------------------------------===// |
| 127 | // ARM specific transformation functions and pattern fragments. |
| 128 | // |
| 129 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 130 | // so_imm_neg_XFORM - Return a so_imm value packed into the format described for |
| 131 | // so_imm_neg def below. |
| 132 | def so_imm_neg_XFORM : SDNodeXForm<imm, [{ |
Owen Anderson | 36e3a6e | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 133 | return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 134 | }]>; |
| 135 | |
| 136 | // so_imm_not_XFORM - Return a so_imm value packed into the format described for |
| 137 | // so_imm_not def below. |
| 138 | def so_imm_not_XFORM : SDNodeXForm<imm, [{ |
Owen Anderson | 36e3a6e | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 139 | return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 140 | }]>; |
| 141 | |
| 142 | // rot_imm predicate - True if the 32-bit immediate is equal to 8, 16, or 24. |
| 143 | def rot_imm : PatLeaf<(i32 imm), [{ |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 144 | int32_t v = (int32_t)N->getZExtValue(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 145 | return v == 8 || v == 16 || v == 24; |
| 146 | }]>; |
| 147 | |
| 148 | /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15]. |
| 149 | def imm1_15 : PatLeaf<(i32 imm), [{ |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 150 | return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 151 | }]>; |
| 152 | |
| 153 | /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31]. |
| 154 | def imm16_31 : PatLeaf<(i32 imm), [{ |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 155 | return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 156 | }]>; |
| 157 | |
| 158 | def so_imm_neg : |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 159 | PatLeaf<(imm), [{ |
| 160 | return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1; |
| 161 | }], so_imm_neg_XFORM>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 162 | |
| 163 | def so_imm_not : |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 164 | PatLeaf<(imm), [{ |
| 165 | return ARM_AM::getSOImmVal(~(int)N->getZExtValue()) != -1; |
| 166 | }], so_imm_not_XFORM>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 167 | |
| 168 | // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits. |
| 169 | def sext_16_node : PatLeaf<(i32 GPR:$a), [{ |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 170 | return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 171 | }]>; |
| 172 | |
Evan Cheng | 299ee65 | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 173 | /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield |
| 174 | /// e.g., 0xf000ffff |
| 175 | def bf_inv_mask_imm : Operand<i32>, |
| 176 | PatLeaf<(imm), [{ |
| 177 | uint32_t v = (uint32_t)N->getZExtValue(); |
| 178 | if (v == 0xffffffff) |
| 179 | return 0; |
David Goodwin | f354d36 | 2009-07-14 00:57:56 +0000 | [diff] [blame] | 180 | // there can be 1's on either or both "outsides", all the "inside" |
| 181 | // bits must be 0's |
| 182 | unsigned int lsb = 0, msb = 31; |
| 183 | while (v & (1 << msb)) --msb; |
| 184 | while (v & (1 << lsb)) ++lsb; |
| 185 | for (unsigned int i = lsb; i <= msb; ++i) { |
| 186 | if (v & (1 << i)) |
| 187 | return 0; |
| 188 | } |
| 189 | return 1; |
Evan Cheng | 299ee65 | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 190 | }] > { |
| 191 | let PrintMethod = "printBitfieldInvMaskImmOperand"; |
| 192 | } |
| 193 | |
Anton Korobeynikov | 6092895 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 194 | /// Split a 32-bit immediate into two 16 bit parts. |
| 195 | def lo16 : SDNodeXForm<imm, [{ |
| 196 | return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() & 0xffff, |
| 197 | MVT::i32); |
| 198 | }]>; |
| 199 | |
| 200 | def hi16 : SDNodeXForm<imm, [{ |
| 201 | return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32); |
| 202 | }]>; |
| 203 | |
| 204 | def lo16AllZero : PatLeaf<(i32 imm), [{ |
| 205 | // Returns true if all low 16-bits are 0. |
| 206 | return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0; |
| 207 | }], hi16>; |
| 208 | |
| 209 | /// imm0_65535 predicate - True if the 32-bit immediate is in the range |
| 210 | /// [0.65535]. |
| 211 | def imm0_65535 : PatLeaf<(i32 imm), [{ |
| 212 | return (uint32_t)N->getZExtValue() < 65536; |
| 213 | }]>; |
| 214 | |
Evan Cheng | 7b0249b | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 215 | class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>; |
| 216 | class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 217 | |
| 218 | //===----------------------------------------------------------------------===// |
| 219 | // Operand Definitions. |
| 220 | // |
| 221 | |
| 222 | // Branch target. |
| 223 | def brtarget : Operand<OtherVT>; |
| 224 | |
| 225 | // A list of registers separated by comma. Used by load/store multiple. |
| 226 | def reglist : Operand<i32> { |
| 227 | let PrintMethod = "printRegisterList"; |
| 228 | } |
| 229 | |
| 230 | // An operand for the CONSTPOOL_ENTRY pseudo-instruction. |
| 231 | def cpinst_operand : Operand<i32> { |
| 232 | let PrintMethod = "printCPInstOperand"; |
| 233 | } |
| 234 | |
| 235 | def jtblock_operand : Operand<i32> { |
| 236 | let PrintMethod = "printJTBlockOperand"; |
| 237 | } |
Evan Cheng | 6e2ebc9 | 2009-07-25 00:33:29 +0000 | [diff] [blame] | 238 | def jt2block_operand : Operand<i32> { |
| 239 | let PrintMethod = "printJT2BlockOperand"; |
| 240 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 241 | |
| 242 | // Local PC labels. |
| 243 | def pclabel : Operand<i32> { |
| 244 | let PrintMethod = "printPCLabel"; |
| 245 | } |
| 246 | |
| 247 | // shifter_operand operands: so_reg and so_imm. |
| 248 | def so_reg : Operand<i32>, // reg reg imm |
| 249 | ComplexPattern<i32, 3, "SelectShifterOperandReg", |
| 250 | [shl,srl,sra,rotr]> { |
| 251 | let PrintMethod = "printSORegOperand"; |
| 252 | let MIOperandInfo = (ops GPR, GPR, i32imm); |
| 253 | } |
| 254 | |
| 255 | // so_imm - Match a 32-bit shifter_operand immediate operand, which is an |
| 256 | // 8-bit immediate rotated by an arbitrary number of bits. so_imm values are |
| 257 | // represented in the imm field in the same 12-bit form that they are encoded |
| 258 | // into so_imm instructions: the 8-bit immediate is the least significant bits |
| 259 | // [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11]. |
| 260 | def so_imm : Operand<i32>, |
Evan Cheng | 8be2a5b | 2009-07-08 21:03:57 +0000 | [diff] [blame] | 261 | PatLeaf<(imm), [{ |
| 262 | return ARM_AM::getSOImmVal(N->getZExtValue()) != -1; |
| 263 | }]> { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 264 | let PrintMethod = "printSOImmOperand"; |
| 265 | } |
| 266 | |
| 267 | // Break so_imm's up into two pieces. This handles immediates with up to 16 |
| 268 | // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to |
| 269 | // get the first/second pieces. |
| 270 | def so_imm2part : Operand<i32>, |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 271 | PatLeaf<(imm), [{ |
| 272 | return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue()); |
| 273 | }]> { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 274 | let PrintMethod = "printSOImm2PartOperand"; |
| 275 | } |
| 276 | |
| 277 | def so_imm2part_1 : SDNodeXForm<imm, [{ |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 278 | unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue()); |
Owen Anderson | 36e3a6e | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 279 | return CurDAG->getTargetConstant(V, MVT::i32); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 280 | }]>; |
| 281 | |
| 282 | def so_imm2part_2 : SDNodeXForm<imm, [{ |
Dan Gohman | faeb4a3 | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 283 | unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue()); |
Owen Anderson | 36e3a6e | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 284 | return CurDAG->getTargetConstant(V, MVT::i32); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 285 | }]>; |
| 286 | |
Jim Grosbach | 66e70cd | 2009-11-23 20:35:53 +0000 | [diff] [blame^] | 287 | def so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{ |
| 288 | return ARM_AM::isSOImmTwoPartVal(-(int)N->getZExtValue()); |
| 289 | }]> { |
| 290 | let PrintMethod = "printSOImm2PartOperand"; |
| 291 | } |
| 292 | |
| 293 | def so_neg_imm2part_1 : SDNodeXForm<imm, [{ |
| 294 | unsigned V = ARM_AM::getSOImmTwoPartFirst(-(int)N->getZExtValue()); |
| 295 | return CurDAG->getTargetConstant(V, MVT::i32); |
| 296 | }]>; |
| 297 | |
| 298 | def so_neg_imm2part_2 : SDNodeXForm<imm, [{ |
| 299 | unsigned V = ARM_AM::getSOImmTwoPartSecond(-(int)N->getZExtValue()); |
| 300 | return CurDAG->getTargetConstant(V, MVT::i32); |
| 301 | }]>; |
| 302 | |
Sandeep Patel | bb4648a | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 303 | /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31]. |
| 304 | def imm0_31 : Operand<i32>, PatLeaf<(imm), [{ |
| 305 | return (int32_t)N->getZExtValue() < 32; |
| 306 | }]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 307 | |
| 308 | // Define ARM specific addressing modes. |
| 309 | |
| 310 | // addrmode2 := reg +/- reg shop imm |
| 311 | // addrmode2 := reg +/- imm12 |
| 312 | // |
| 313 | def addrmode2 : Operand<i32>, |
| 314 | ComplexPattern<i32, 3, "SelectAddrMode2", []> { |
| 315 | let PrintMethod = "printAddrMode2Operand"; |
| 316 | let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm); |
| 317 | } |
| 318 | |
| 319 | def am2offset : Operand<i32>, |
| 320 | ComplexPattern<i32, 2, "SelectAddrMode2Offset", []> { |
| 321 | let PrintMethod = "printAddrMode2OffsetOperand"; |
| 322 | let MIOperandInfo = (ops GPR, i32imm); |
| 323 | } |
| 324 | |
| 325 | // addrmode3 := reg +/- reg |
| 326 | // addrmode3 := reg +/- imm8 |
| 327 | // |
| 328 | def addrmode3 : Operand<i32>, |
| 329 | ComplexPattern<i32, 3, "SelectAddrMode3", []> { |
| 330 | let PrintMethod = "printAddrMode3Operand"; |
| 331 | let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm); |
| 332 | } |
| 333 | |
| 334 | def am3offset : Operand<i32>, |
| 335 | ComplexPattern<i32, 2, "SelectAddrMode3Offset", []> { |
| 336 | let PrintMethod = "printAddrMode3OffsetOperand"; |
| 337 | let MIOperandInfo = (ops GPR, i32imm); |
| 338 | } |
| 339 | |
| 340 | // addrmode4 := reg, <mode|W> |
| 341 | // |
| 342 | def addrmode4 : Operand<i32>, |
Anton Korobeynikov | 3f08766 | 2009-08-08 13:35:48 +0000 | [diff] [blame] | 343 | ComplexPattern<i32, 2, "SelectAddrMode4", []> { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 344 | let PrintMethod = "printAddrMode4Operand"; |
| 345 | let MIOperandInfo = (ops GPR, i32imm); |
| 346 | } |
| 347 | |
| 348 | // addrmode5 := reg +/- imm8*4 |
| 349 | // |
| 350 | def addrmode5 : Operand<i32>, |
| 351 | ComplexPattern<i32, 2, "SelectAddrMode5", []> { |
| 352 | let PrintMethod = "printAddrMode5Operand"; |
| 353 | let MIOperandInfo = (ops GPR, i32imm); |
| 354 | } |
| 355 | |
Bob Wilson | 970a10d | 2009-07-01 23:16:05 +0000 | [diff] [blame] | 356 | // addrmode6 := reg with optional writeback |
| 357 | // |
| 358 | def addrmode6 : Operand<i32>, |
Jim Grosbach | 04d9282 | 2009-11-07 21:25:39 +0000 | [diff] [blame] | 359 | ComplexPattern<i32, 4, "SelectAddrMode6", []> { |
Bob Wilson | 970a10d | 2009-07-01 23:16:05 +0000 | [diff] [blame] | 360 | let PrintMethod = "printAddrMode6Operand"; |
Jim Grosbach | 04d9282 | 2009-11-07 21:25:39 +0000 | [diff] [blame] | 361 | let MIOperandInfo = (ops GPR:$addr, GPR:$upd, i32imm, i32imm); |
Bob Wilson | 970a10d | 2009-07-01 23:16:05 +0000 | [diff] [blame] | 362 | } |
| 363 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 364 | // addrmodepc := pc + reg |
| 365 | // |
| 366 | def addrmodepc : Operand<i32>, |
| 367 | ComplexPattern<i32, 2, "SelectAddrModePC", []> { |
| 368 | let PrintMethod = "printAddrModePCOperand"; |
| 369 | let MIOperandInfo = (ops GPR, i32imm); |
| 370 | } |
| 371 | |
Bob Wilson | 30ff449 | 2009-08-21 21:58:55 +0000 | [diff] [blame] | 372 | def nohash_imm : Operand<i32> { |
| 373 | let PrintMethod = "printNoHashImmediate"; |
Anton Korobeynikov | e2be338 | 2009-08-08 23:10:41 +0000 | [diff] [blame] | 374 | } |
| 375 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 376 | //===----------------------------------------------------------------------===// |
Evan Cheng | a7b3e7c | 2007-08-07 01:37:15 +0000 | [diff] [blame] | 377 | |
Evan Cheng | 7b0249b | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 378 | include "ARMInstrFormats.td" |
Evan Cheng | a7b3e7c | 2007-08-07 01:37:15 +0000 | [diff] [blame] | 379 | |
| 380 | //===----------------------------------------------------------------------===// |
Evan Cheng | 7b0249b | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 381 | // Multiclass helpers... |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 382 | // |
| 383 | |
Evan Cheng | 40d6453 | 2008-08-29 07:36:24 +0000 | [diff] [blame] | 384 | /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 385 | /// binop that produces a value. |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 386 | multiclass AsI1_bin_irs<bits<4> opcod, string opc, PatFrag opnode, |
| 387 | bit Commutable = 0> { |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 388 | def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 389 | IIC_iALUi, opc, "\t$dst, $a, $b", |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 390 | [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> { |
| 391 | let Inst{25} = 1; |
| 392 | } |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 393 | def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 394 | IIC_iALUr, opc, "\t$dst, $a, $b", |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 395 | [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> { |
Johnny Chen | d139b94 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 396 | let Inst{11-4} = 0b00000000; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 397 | let Inst{25} = 0; |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 398 | let isCommutable = Commutable; |
| 399 | } |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 400 | def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 401 | IIC_iALUsr, opc, "\t$dst, $a, $b", |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 402 | [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> { |
| 403 | let Inst{25} = 0; |
| 404 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 405 | } |
| 406 | |
Evan Cheng | d4e2f05 | 2009-06-25 20:59:23 +0000 | [diff] [blame] | 407 | /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the |
Bob Wilson | 3443c21 | 2009-10-06 20:18:46 +0000 | [diff] [blame] | 408 | /// instruction modifies the CPSR register. |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 409 | let Defs = [CPSR] in { |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 410 | multiclass AI1_bin_s_irs<bits<4> opcod, string opc, PatFrag opnode, |
| 411 | bit Commutable = 0> { |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 412 | def ri : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 413 | IIC_iALUi, opc, "\t$dst, $a, $b", |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 414 | [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]> { |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 415 | let Inst{20} = 1; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 416 | let Inst{25} = 1; |
| 417 | } |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 418 | def rr : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 419 | IIC_iALUr, opc, "\t$dst, $a, $b", |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 420 | [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]> { |
| 421 | let isCommutable = Commutable; |
Johnny Chen | d139b94 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 422 | let Inst{11-4} = 0b00000000; |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 423 | let Inst{20} = 1; |
Bob Wilson | b072c75 | 2009-10-13 15:27:23 +0000 | [diff] [blame] | 424 | let Inst{25} = 0; |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 425 | } |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 426 | def rs : AI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 427 | IIC_iALUsr, opc, "\t$dst, $a, $b", |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 428 | [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]> { |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 429 | let Inst{20} = 1; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 430 | let Inst{25} = 0; |
| 431 | } |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 432 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test |
| 436 | /// patterns. Similar to AsI1_bin_irs except the instruction does not produce |
| 437 | /// a explicit result, only implicitly set CPSR. |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 438 | let Defs = [CPSR] in { |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 439 | multiclass AI1_cmp_irs<bits<4> opcod, string opc, PatFrag opnode, |
| 440 | bit Commutable = 0> { |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 441 | def ri : AI1<opcod, (outs), (ins GPR:$a, so_imm:$b), DPFrm, IIC_iCMPi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 442 | opc, "\t$a, $b", |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 443 | [(opnode GPR:$a, so_imm:$b)]> { |
Bob Wilson | ce7c9eb | 2009-10-13 17:35:30 +0000 | [diff] [blame] | 444 | let Inst{20} = 1; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 445 | let Inst{25} = 1; |
| 446 | } |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 447 | def rr : AI1<opcod, (outs), (ins GPR:$a, GPR:$b), DPFrm, IIC_iCMPr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 448 | opc, "\t$a, $b", |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 449 | [(opnode GPR:$a, GPR:$b)]> { |
Johnny Chen | d139b94 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 450 | let Inst{11-4} = 0b00000000; |
Bob Wilson | ce7c9eb | 2009-10-13 17:35:30 +0000 | [diff] [blame] | 451 | let Inst{20} = 1; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 452 | let Inst{25} = 0; |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 453 | let isCommutable = Commutable; |
| 454 | } |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 455 | def rs : AI1<opcod, (outs), (ins GPR:$a, so_reg:$b), DPSoRegFrm, IIC_iCMPsr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 456 | opc, "\t$a, $b", |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 457 | [(opnode GPR:$a, so_reg:$b)]> { |
Bob Wilson | ce7c9eb | 2009-10-13 17:35:30 +0000 | [diff] [blame] | 458 | let Inst{20} = 1; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 459 | let Inst{25} = 0; |
| 460 | } |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 461 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | /// AI_unary_rrot - A unary operation with two forms: one whose operand is a |
| 465 | /// register and one whose operand is a register rotated by 8/16/24. |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 466 | /// FIXME: Remove the 'r' variant. Its rot_imm is zero. |
| 467 | multiclass AI_unary_rrot<bits<8> opcod, string opc, PatFrag opnode> { |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 468 | def r : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 469 | IIC_iUNAr, opc, "\t$dst, $src", |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 470 | [(set GPR:$dst, (opnode GPR:$src))]>, |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 471 | Requires<[IsARM, HasV6]> { |
Johnny Chen | 1bf7944 | 2009-10-27 18:44:24 +0000 | [diff] [blame] | 472 | let Inst{11-10} = 0b00; |
| 473 | let Inst{19-16} = 0b1111; |
| 474 | } |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 475 | def r_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$src, i32imm:$rot), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 476 | IIC_iUNAsi, opc, "\t$dst, $src, ror $rot", |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 477 | [(set GPR:$dst, (opnode (rotr GPR:$src, rot_imm:$rot)))]>, |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 478 | Requires<[IsARM, HasV6]> { |
Johnny Chen | 1bf7944 | 2009-10-27 18:44:24 +0000 | [diff] [blame] | 479 | let Inst{19-16} = 0b1111; |
| 480 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | /// AI_bin_rrot - A binary operation with two forms: one whose operand is a |
| 484 | /// register and one whose operand is a register rotated by 8/16/24. |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 485 | multiclass AI_bin_rrot<bits<8> opcod, string opc, PatFrag opnode> { |
| 486 | def rr : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 487 | IIC_iALUr, opc, "\t$dst, $LHS, $RHS", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 488 | [(set GPR:$dst, (opnode GPR:$LHS, GPR:$RHS))]>, |
Johnny Chen | 1bf7944 | 2009-10-27 18:44:24 +0000 | [diff] [blame] | 489 | Requires<[IsARM, HasV6]> { |
| 490 | let Inst{11-10} = 0b00; |
| 491 | } |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 492 | def rr_rot : AExtI<opcod, (outs GPR:$dst), (ins GPR:$LHS, GPR:$RHS, i32imm:$rot), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 493 | IIC_iALUsi, opc, "\t$dst, $LHS, $RHS, ror $rot", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 494 | [(set GPR:$dst, (opnode GPR:$LHS, |
| 495 | (rotr GPR:$RHS, rot_imm:$rot)))]>, |
| 496 | Requires<[IsARM, HasV6]>; |
| 497 | } |
| 498 | |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 499 | /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube. |
| 500 | let Uses = [CPSR] in { |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 501 | multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode, |
| 502 | bit Commutable = 0> { |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 503 | def ri : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 504 | DPFrm, IIC_iALUi, opc, "\t$dst, $a, $b", |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 505 | [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>, |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 506 | Requires<[IsARM, CarryDefIsUnused]> { |
| 507 | let Inst{25} = 1; |
| 508 | } |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 509 | def rr : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 510 | DPFrm, IIC_iALUr, opc, "\t$dst, $a, $b", |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 511 | [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>, |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 512 | Requires<[IsARM, CarryDefIsUnused]> { |
| 513 | let isCommutable = Commutable; |
Johnny Chen | d139b94 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 514 | let Inst{11-4} = 0b00000000; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 515 | let Inst{25} = 0; |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 516 | } |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 517 | def rs : AsI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 518 | DPSoRegFrm, IIC_iALUsr, opc, "\t$dst, $a, $b", |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 519 | [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>, |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 520 | Requires<[IsARM, CarryDefIsUnused]> { |
| 521 | let Inst{25} = 0; |
| 522 | } |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 523 | } |
| 524 | // Carry setting variants |
| 525 | let Defs = [CPSR] in { |
| 526 | multiclass AI1_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode, |
| 527 | bit Commutable = 0> { |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 528 | def Sri : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 529 | DPFrm, IIC_iALUi, !strconcat(opc, "\t$dst, $a, $b"), |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 530 | [(set GPR:$dst, (opnode GPR:$a, so_imm:$b))]>, |
| 531 | Requires<[IsARM, CarryDefIsUsed]> { |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 532 | let Defs = [CPSR]; |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 533 | let Inst{20} = 1; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 534 | let Inst{25} = 1; |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 535 | } |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 536 | def Srr : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 537 | DPFrm, IIC_iALUr, !strconcat(opc, "\t$dst, $a, $b"), |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 538 | [(set GPR:$dst, (opnode GPR:$a, GPR:$b))]>, |
| 539 | Requires<[IsARM, CarryDefIsUsed]> { |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 540 | let Defs = [CPSR]; |
Johnny Chen | d139b94 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 541 | let Inst{11-4} = 0b00000000; |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 542 | let Inst{20} = 1; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 543 | let Inst{25} = 0; |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 544 | } |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 545 | def Srs : AXI1<opcod, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 546 | DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$dst, $a, $b"), |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 547 | [(set GPR:$dst, (opnode GPR:$a, so_reg:$b))]>, |
| 548 | Requires<[IsARM, CarryDefIsUsed]> { |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 549 | let Defs = [CPSR]; |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 550 | let Inst{20} = 1; |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 551 | let Inst{25} = 0; |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 552 | } |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 553 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 554 | } |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 555 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 556 | |
| 557 | //===----------------------------------------------------------------------===// |
| 558 | // Instructions |
| 559 | //===----------------------------------------------------------------------===// |
| 560 | |
| 561 | //===----------------------------------------------------------------------===// |
| 562 | // Miscellaneous Instructions. |
| 563 | // |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 564 | |
| 565 | /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in |
| 566 | /// the function. The first operand is the ID# for this instruction, the second |
| 567 | /// is the index into the MachineConstantPool that this is, the third is the |
| 568 | /// size in bytes of this constant pool entry. |
Evan Cheng | d97d714 | 2009-06-12 20:46:18 +0000 | [diff] [blame] | 569 | let neverHasSideEffects = 1, isNotDuplicable = 1 in |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 570 | def CONSTPOOL_ENTRY : |
Evan Cheng | b783fa3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 571 | PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 572 | i32imm:$size), NoItinerary, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 573 | "${instid:label} ${cpidx:cpentry}", []>; |
| 574 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 575 | let Defs = [SP], Uses = [SP] in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 576 | def ADJCALLSTACKUP : |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 577 | PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary, |
Bill Wendling | 22f8deb | 2007-11-13 00:44:25 +0000 | [diff] [blame] | 578 | "@ ADJCALLSTACKUP $amt1", |
Chris Lattner | fe5d402 | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 579 | [(ARMcallseq_end timm:$amt1, timm:$amt2)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 580 | |
| 581 | def ADJCALLSTACKDOWN : |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 582 | PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 583 | "@ ADJCALLSTACKDOWN $amt", |
Chris Lattner | fe5d402 | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 584 | [(ARMcallseq_start timm:$amt)]>; |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 585 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 586 | |
| 587 | def DWARF_LOC : |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 588 | PseudoInst<(outs), (ins i32imm:$line, i32imm:$col, i32imm:$file), NoItinerary, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 589 | ".loc $file, $line, $col", |
| 590 | [(dwarf_loc (i32 imm:$line), (i32 imm:$col), (i32 imm:$file))]>; |
| 591 | |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 592 | |
| 593 | // Address computation and loads and stores in PIC mode. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 594 | let isNotDuplicable = 1 in { |
Evan Cheng | 0d28b38 | 2008-10-31 19:11:09 +0000 | [diff] [blame] | 595 | def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 596 | Pseudo, IIC_iALUr, "\n$cp:\n\tadd$p\t$dst, pc, $a", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 597 | [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>; |
| 598 | |
Evan Cheng | 8610a3b | 2008-01-07 23:56:57 +0000 | [diff] [blame] | 599 | let AddedComplexity = 10 in { |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 600 | def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 601 | Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr$p\t$dst, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 602 | [(set GPR:$dst, (load addrmodepc:$addr))]>; |
| 603 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 604 | def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 605 | Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}h\t$dst, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 606 | [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>; |
| 607 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 608 | def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 609 | Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}b\t$dst, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 610 | [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>; |
| 611 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 612 | def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 613 | Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}sh\t$dst, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 614 | [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>; |
| 615 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 616 | def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 617 | Pseudo, IIC_iLoadr, "\n${addr:label}:\n\tldr${p}sb\t$dst, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 618 | [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>; |
| 619 | } |
Chris Lattner | f823faf | 2008-01-06 05:55:01 +0000 | [diff] [blame] | 620 | let AddedComplexity = 10 in { |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 621 | def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 622 | Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstr$p\t$src, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 623 | [(store GPR:$src, addrmodepc:$addr)]>; |
| 624 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 625 | def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p), |
Bob Wilson | ecce4b7 | 2009-11-18 18:10:35 +0000 | [diff] [blame] | 626 | Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrh${p}\t$src, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 627 | [(truncstorei16 GPR:$src, addrmodepc:$addr)]>; |
| 628 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 629 | def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p), |
Bob Wilson | ecce4b7 | 2009-11-18 18:10:35 +0000 | [diff] [blame] | 630 | Pseudo, IIC_iStorer, "\n${addr:label}:\n\tstrb${p}\t$src, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 631 | [(truncstorei8 GPR:$src, addrmodepc:$addr)]>; |
| 632 | } |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 633 | } // isNotDuplicable = 1 |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 634 | |
Evan Cheng | a1366cd | 2009-06-23 05:25:29 +0000 | [diff] [blame] | 635 | |
| 636 | // LEApcrel - Load a pc-relative address into a register without offending the |
| 637 | // assembler. |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 638 | def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 639 | Pseudo, IIC_iALUi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 640 | !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, ($label-(", |
| 641 | "${:private}PCRELL${:uid}+8))\n"), |
| 642 | !strconcat("${:private}PCRELL${:uid}:\n\t", |
| 643 | "add$p\t$dst, pc, #${:private}PCRELV${:uid}")), |
Evan Cheng | a1366cd | 2009-06-23 05:25:29 +0000 | [diff] [blame] | 644 | []>; |
| 645 | |
Evan Cheng | ba83d7c | 2009-06-24 23:14:45 +0000 | [diff] [blame] | 646 | def LEApcrelJT : AXI1<0x0, (outs GPR:$dst), |
Bob Wilson | 30ff449 | 2009-08-21 21:58:55 +0000 | [diff] [blame] | 647 | (ins i32imm:$label, nohash_imm:$id, pred:$p), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 648 | Pseudo, IIC_iALUi, |
Evan Cheng | 9cf1e3e | 2009-07-22 22:03:29 +0000 | [diff] [blame] | 649 | !strconcat(!strconcat(".set ${:private}PCRELV${:uid}, " |
Anton Korobeynikov | e2be338 | 2009-08-08 23:10:41 +0000 | [diff] [blame] | 650 | "(${label}_${id}-(", |
Evan Cheng | 9cf1e3e | 2009-07-22 22:03:29 +0000 | [diff] [blame] | 651 | "${:private}PCRELL${:uid}+8))\n"), |
| 652 | !strconcat("${:private}PCRELL${:uid}:\n\t", |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 653 | "add$p\t$dst, pc, #${:private}PCRELV${:uid}")), |
Evan Cheng | 83a32b4 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 654 | []> { |
| 655 | let Inst{25} = 1; |
| 656 | } |
Evan Cheng | a1366cd | 2009-06-23 05:25:29 +0000 | [diff] [blame] | 657 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 658 | //===----------------------------------------------------------------------===// |
| 659 | // Control Flow Instructions. |
| 660 | // |
| 661 | |
Jim Grosbach | c6f0c02 | 2009-09-30 01:35:11 +0000 | [diff] [blame] | 662 | let isReturn = 1, isTerminator = 1, isBarrier = 1 in |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 663 | def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 664 | "bx", "\tlr", [(ARMretflag)]> { |
Johnny Chen | ff43a62 | 2009-11-16 23:57:56 +0000 | [diff] [blame] | 665 | let Inst{3-0} = 0b1110; |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 666 | let Inst{7-4} = 0b0001; |
| 667 | let Inst{19-8} = 0b111111111111; |
| 668 | let Inst{27-20} = 0b00010010; |
Evan Cheng | 469bc76 | 2008-09-17 07:53:38 +0000 | [diff] [blame] | 669 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 670 | |
Bob Wilson | f061fc8 | 2009-10-28 00:37:03 +0000 | [diff] [blame] | 671 | // Indirect branches |
| 672 | let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { |
Bob Wilson | ea69865 | 2009-10-28 18:26:41 +0000 | [diff] [blame] | 673 | def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst", |
Bob Wilson | f061fc8 | 2009-10-28 00:37:03 +0000 | [diff] [blame] | 674 | [(brind GPR:$dst)]> { |
| 675 | let Inst{7-4} = 0b0001; |
| 676 | let Inst{19-8} = 0b111111111111; |
| 677 | let Inst{27-20} = 0b00010010; |
Johnny Chen | ff43a62 | 2009-11-16 23:57:56 +0000 | [diff] [blame] | 678 | let Inst{31-28} = 0b1110; |
Bob Wilson | f061fc8 | 2009-10-28 00:37:03 +0000 | [diff] [blame] | 679 | } |
| 680 | } |
| 681 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 682 | // FIXME: remove when we have a way to marking a MI with these properties. |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 683 | // FIXME: Should pc be an implicit operand like PICADD, etc? |
Evan Cheng | 7c8d5ea | 2009-10-01 08:22:27 +0000 | [diff] [blame] | 684 | let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1, |
| 685 | hasExtraDefRegAllocReq = 1 in |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 686 | def LDM_RET : AXI4ld<(outs), |
Evan Cheng | b43a20e | 2009-10-01 01:33:39 +0000 | [diff] [blame] | 687 | (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops), |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 688 | LdStMulFrm, IIC_Br, "ldm${addr:submode}${p}\t$addr, $wb", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 689 | []>; |
| 690 | |
Bob Wilson | 243b37c | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 691 | // On non-Darwin platforms R9 is callee-saved. |
David Goodwin | 4b6e498 | 2009-08-12 18:31:53 +0000 | [diff] [blame] | 692 | let isCall = 1, |
Evan Cheng | 27396a6 | 2009-07-22 06:46:53 +0000 | [diff] [blame] | 693 | Defs = [R0, R1, R2, R3, R12, LR, |
| 694 | D0, D1, D2, D3, D4, D5, D6, D7, |
| 695 | D16, D17, D18, D19, D20, D21, D22, D23, |
David Goodwin | 3d88e91 | 2009-09-03 22:12:28 +0000 | [diff] [blame] | 696 | D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in { |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 697 | def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 698 | IIC_Br, "bl\t${func:call}", |
Evan Cheng | 9e73448 | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 699 | [(ARMcall tglobaladdr:$func)]>, |
Johnny Chen | 2b4d1db | 2009-10-27 20:45:15 +0000 | [diff] [blame] | 700 | Requires<[IsARM, IsNotDarwin]> { |
| 701 | let Inst{31-28} = 0b1110; |
| 702 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 703 | |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 704 | def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 705 | IIC_Br, "bl", "\t${func:call}", |
Evan Cheng | 9e73448 | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 706 | [(ARMcall_pred tglobaladdr:$func)]>, |
| 707 | Requires<[IsARM, IsNotDarwin]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 708 | |
| 709 | // ARMv5T and above |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 710 | def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 711 | IIC_Br, "blx\t$func", |
Evan Cheng | 9e73448 | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 712 | [(ARMcall GPR:$func)]>, |
| 713 | Requires<[IsARM, HasV5T, IsNotDarwin]> { |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 714 | let Inst{7-4} = 0b0011; |
| 715 | let Inst{19-8} = 0b111111111111; |
| 716 | let Inst{27-20} = 0b00010010; |
Evan Cheng | 469bc76 | 2008-09-17 07:53:38 +0000 | [diff] [blame] | 717 | } |
| 718 | |
Evan Cheng | fb1d147 | 2009-07-14 01:49:27 +0000 | [diff] [blame] | 719 | // ARMv4T |
| 720 | def BX : ABXIx2<(outs), (ins GPR:$func, variable_ops), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 721 | IIC_Br, "mov\tlr, pc\n\tbx\t$func", |
Evan Cheng | 9e73448 | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 722 | [(ARMcall_nolink GPR:$func)]>, |
| 723 | Requires<[IsARM, IsNotDarwin]> { |
Evan Cheng | fb1d147 | 2009-07-14 01:49:27 +0000 | [diff] [blame] | 724 | let Inst{7-4} = 0b0001; |
| 725 | let Inst{19-8} = 0b111111111111; |
| 726 | let Inst{27-20} = 0b00010010; |
Bob Wilson | 243b37c | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 727 | } |
| 728 | } |
| 729 | |
| 730 | // On Darwin R9 is call-clobbered. |
David Goodwin | 4b6e498 | 2009-08-12 18:31:53 +0000 | [diff] [blame] | 731 | let isCall = 1, |
Evan Cheng | 27396a6 | 2009-07-22 06:46:53 +0000 | [diff] [blame] | 732 | Defs = [R0, R1, R2, R3, R9, R12, LR, |
| 733 | D0, D1, D2, D3, D4, D5, D6, D7, |
| 734 | D16, D17, D18, D19, D20, D21, D22, D23, |
David Goodwin | 3d88e91 | 2009-09-03 22:12:28 +0000 | [diff] [blame] | 735 | D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in { |
Bob Wilson | 243b37c | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 736 | def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 737 | IIC_Br, "bl\t${func:call}", |
Johnny Chen | 2b4d1db | 2009-10-27 20:45:15 +0000 | [diff] [blame] | 738 | [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]> { |
| 739 | let Inst{31-28} = 0b1110; |
| 740 | } |
Bob Wilson | 243b37c | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 741 | |
| 742 | def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 743 | IIC_Br, "bl", "\t${func:call}", |
Evan Cheng | 9e73448 | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 744 | [(ARMcall_pred tglobaladdr:$func)]>, |
| 745 | Requires<[IsARM, IsDarwin]>; |
Bob Wilson | 243b37c | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 746 | |
| 747 | // ARMv5T and above |
| 748 | def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 749 | IIC_Br, "blx\t$func", |
Bob Wilson | 243b37c | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 750 | [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> { |
| 751 | let Inst{7-4} = 0b0011; |
| 752 | let Inst{19-8} = 0b111111111111; |
| 753 | let Inst{27-20} = 0b00010010; |
| 754 | } |
| 755 | |
Evan Cheng | fb1d147 | 2009-07-14 01:49:27 +0000 | [diff] [blame] | 756 | // ARMv4T |
| 757 | def BXr9 : ABXIx2<(outs), (ins GPR:$func, variable_ops), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 758 | IIC_Br, "mov\tlr, pc\n\tbx\t$func", |
Evan Cheng | fb1d147 | 2009-07-14 01:49:27 +0000 | [diff] [blame] | 759 | [(ARMcall_nolink GPR:$func)]>, Requires<[IsARM, IsDarwin]> { |
| 760 | let Inst{7-4} = 0b0001; |
| 761 | let Inst{19-8} = 0b111111111111; |
| 762 | let Inst{27-20} = 0b00010010; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 763 | } |
| 764 | } |
| 765 | |
David Goodwin | 4b6e498 | 2009-08-12 18:31:53 +0000 | [diff] [blame] | 766 | let isBranch = 1, isTerminator = 1 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 767 | // B is "predicable" since it can be xformed into a Bcc. |
| 768 | let isBarrier = 1 in { |
| 769 | let isPredicable = 1 in |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 770 | def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 771 | "b\t$target", [(br bb:$target)]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 772 | |
Owen Anderson | f805308 | 2007-11-12 07:39:39 +0000 | [diff] [blame] | 773 | let isNotDuplicable = 1, isIndirectBranch = 1 in { |
Evan Cheng | 0f63ae1 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 774 | def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 775 | IIC_Br, "mov\tpc, $target \n$jt", |
Evan Cheng | 0f63ae1 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 776 | [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> { |
Johnny Chen | 3f64740 | 2009-11-17 17:17:50 +0000 | [diff] [blame] | 777 | let Inst{15-12} = 0b1111; |
Evan Cheng | 0f63ae1 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 778 | let Inst{20} = 0; // S Bit |
| 779 | let Inst{24-21} = 0b1101; |
Evan Cheng | e5f32ae | 2009-07-07 23:45:10 +0000 | [diff] [blame] | 780 | let Inst{27-25} = 0b000; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 781 | } |
Evan Cheng | 0f63ae1 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 782 | def BR_JTm : JTI<(outs), |
| 783 | (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 784 | IIC_Br, "ldr\tpc, $target \n$jt", |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 785 | [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt, |
| 786 | imm:$id)]> { |
Johnny Chen | 3f64740 | 2009-11-17 17:17:50 +0000 | [diff] [blame] | 787 | let Inst{15-12} = 0b1111; |
Evan Cheng | 0f63ae1 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 788 | let Inst{20} = 1; // L bit |
| 789 | let Inst{21} = 0; // W bit |
| 790 | let Inst{22} = 0; // B bit |
| 791 | let Inst{24} = 1; // P bit |
Evan Cheng | e5f32ae | 2009-07-07 23:45:10 +0000 | [diff] [blame] | 792 | let Inst{27-25} = 0b011; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 793 | } |
Evan Cheng | 0f63ae1 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 794 | def BR_JTadd : JTI<(outs), |
| 795 | (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 796 | IIC_Br, "add\tpc, $target, $idx \n$jt", |
Evan Cheng | 0f63ae1 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 797 | [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt, |
| 798 | imm:$id)]> { |
Johnny Chen | 3f64740 | 2009-11-17 17:17:50 +0000 | [diff] [blame] | 799 | let Inst{15-12} = 0b1111; |
Evan Cheng | 0f63ae1 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 800 | let Inst{20} = 0; // S bit |
| 801 | let Inst{24-21} = 0b0100; |
Evan Cheng | e5f32ae | 2009-07-07 23:45:10 +0000 | [diff] [blame] | 802 | let Inst{27-25} = 0b000; |
Evan Cheng | 0f63ae1 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 803 | } |
| 804 | } // isNotDuplicable = 1, isIndirectBranch = 1 |
| 805 | } // isBarrier = 1 |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 806 | |
| 807 | // FIXME: should be able to write a pattern for ARMBrcond, but can't use |
| 808 | // a two-value operand where a dag node expects two operands. :( |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 809 | def Bcc : ABI<0b1010, (outs), (ins brtarget:$target), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 810 | IIC_Br, "b", "\t$target", |
Evan Cheng | a7b3e7c | 2007-08-07 01:37:15 +0000 | [diff] [blame] | 811 | [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | //===----------------------------------------------------------------------===// |
| 815 | // Load / store Instructions. |
| 816 | // |
| 817 | |
| 818 | // Load |
Evan Cheng | 2f6bfd4 | 2009-11-20 19:57:15 +0000 | [diff] [blame] | 819 | let canFoldAsLoad = 1, isReMaterializable = 1, mayHaveSideEffects = 1 in |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 820 | def LDR : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 821 | "ldr", "\t$dst, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 822 | [(set GPR:$dst, (load addrmode2:$addr))]>; |
| 823 | |
| 824 | // Special LDR for loads from non-pc-relative constpools. |
Evan Cheng | 2f6bfd4 | 2009-11-20 19:57:15 +0000 | [diff] [blame] | 825 | let canFoldAsLoad = 1, mayLoad = 1, isReMaterializable = 1, |
| 826 | mayHaveSideEffects = 1 in |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 827 | def LDRcp : AI2ldw<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, IIC_iLoadr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 828 | "ldr", "\t$dst, $addr", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 829 | |
| 830 | // Loads with zero extension |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 831 | def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 832 | IIC_iLoadr, "ldrh", "\t$dst, $addr", |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 833 | [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 834 | |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 835 | def LDRB : AI2ldb<(outs GPR:$dst), (ins addrmode2:$addr), LdFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 836 | IIC_iLoadr, "ldrb", "\t$dst, $addr", |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 837 | [(set GPR:$dst, (zextloadi8 addrmode2:$addr))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 838 | |
| 839 | // Loads with sign extension |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 840 | def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 841 | IIC_iLoadr, "ldrsh", "\t$dst, $addr", |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 842 | [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 843 | |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 844 | def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 845 | IIC_iLoadr, "ldrsb", "\t$dst, $addr", |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 846 | [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 847 | |
Evan Cheng | 7c8d5ea | 2009-10-01 08:22:27 +0000 | [diff] [blame] | 848 | let mayLoad = 1, hasExtraDefRegAllocReq = 1 in { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 849 | // Load doubleword |
Evan Cheng | 4116955 | 2009-06-15 08:28:29 +0000 | [diff] [blame] | 850 | def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 851 | IIC_iLoadr, "ldrd", "\t$dst1, $addr", |
Misha Brukman | 9daa067 | 2009-08-27 14:14:21 +0000 | [diff] [blame] | 852 | []>, Requires<[IsARM, HasV5TE]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 853 | |
| 854 | // Indexed loads |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 855 | def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 856 | (ins addrmode2:$addr), LdFrm, IIC_iLoadru, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 857 | "ldr", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 858 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 859 | def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 860 | (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoadru, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 861 | "ldr", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 862 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 863 | def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 864 | (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 865 | "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 866 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 867 | def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 868 | (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 869 | "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 870 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 871 | def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 872 | (ins addrmode2:$addr), LdFrm, IIC_iLoadru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 873 | "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 874 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 875 | def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 876 | (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoadru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 877 | "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 878 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 879 | def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 880 | (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 881 | "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 882 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 883 | def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 884 | (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 885 | "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 886 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 887 | def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 888 | (ins addrmode3:$addr), LdMiscFrm, IIC_iLoadru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 889 | "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 890 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 891 | def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 892 | (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoadru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 893 | "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Chris Lattner | ca4e0fe | 2008-01-10 05:12:37 +0000 | [diff] [blame] | 894 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 895 | |
| 896 | // Store |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 897 | def STR : AI2stw<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 898 | "str", "\t$src, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 899 | [(store GPR:$src, addrmode2:$addr)]>; |
| 900 | |
| 901 | // Stores with truncate |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 902 | def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm, IIC_iStorer, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 903 | "strh", "\t$src, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 904 | [(truncstorei16 GPR:$src, addrmode3:$addr)]>; |
| 905 | |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 906 | def STRB : AI2stb<(outs), (ins GPR:$src, addrmode2:$addr), StFrm, IIC_iStorer, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 907 | "strb", "\t$src, $addr", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 908 | [(truncstorei8 GPR:$src, addrmode2:$addr)]>; |
| 909 | |
| 910 | // Store doubleword |
Evan Cheng | 7c8d5ea | 2009-10-01 08:22:27 +0000 | [diff] [blame] | 911 | let mayStore = 1, hasExtraSrcRegAllocReq = 1 in |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 912 | def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 913 | StMiscFrm, IIC_iStorer, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 914 | "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 915 | |
| 916 | // Indexed stores |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 917 | def STR_PRE : AI2stwpr<(outs GPR:$base_wb), |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 918 | (ins GPR:$src, GPR:$base, am2offset:$offset), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 919 | StFrm, IIC_iStoreru, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 920 | "str", "\t$src, [$base, $offset]!", "$base = $base_wb", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 921 | [(set GPR:$base_wb, |
| 922 | (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>; |
| 923 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 924 | def STR_POST : AI2stwpo<(outs GPR:$base_wb), |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 925 | (ins GPR:$src, GPR:$base,am2offset:$offset), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 926 | StFrm, IIC_iStoreru, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 927 | "str", "\t$src, [$base], $offset", "$base = $base_wb", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 928 | [(set GPR:$base_wb, |
| 929 | (post_store GPR:$src, GPR:$base, am2offset:$offset))]>; |
| 930 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 931 | def STRH_PRE : AI3sthpr<(outs GPR:$base_wb), |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 932 | (ins GPR:$src, GPR:$base,am3offset:$offset), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 933 | StMiscFrm, IIC_iStoreru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 934 | "strh", "\t$src, [$base, $offset]!", "$base = $base_wb", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 935 | [(set GPR:$base_wb, |
| 936 | (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>; |
| 937 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 938 | def STRH_POST: AI3sthpo<(outs GPR:$base_wb), |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 939 | (ins GPR:$src, GPR:$base,am3offset:$offset), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 940 | StMiscFrm, IIC_iStoreru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 941 | "strh", "\t$src, [$base], $offset", "$base = $base_wb", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 942 | [(set GPR:$base_wb, (post_truncsti16 GPR:$src, |
| 943 | GPR:$base, am3offset:$offset))]>; |
| 944 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 945 | def STRB_PRE : AI2stbpr<(outs GPR:$base_wb), |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 946 | (ins GPR:$src, GPR:$base,am2offset:$offset), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 947 | StFrm, IIC_iStoreru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 948 | "strb", "\t$src, [$base, $offset]!", "$base = $base_wb", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 949 | [(set GPR:$base_wb, (pre_truncsti8 GPR:$src, |
| 950 | GPR:$base, am2offset:$offset))]>; |
| 951 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 952 | def STRB_POST: AI2stbpo<(outs GPR:$base_wb), |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 953 | (ins GPR:$src, GPR:$base,am2offset:$offset), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 954 | StFrm, IIC_iStoreru, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 955 | "strb", "\t$src, [$base], $offset", "$base = $base_wb", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 956 | [(set GPR:$base_wb, (post_truncsti8 GPR:$src, |
| 957 | GPR:$base, am2offset:$offset))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 958 | |
| 959 | //===----------------------------------------------------------------------===// |
| 960 | // Load / store multiple Instructions. |
| 961 | // |
| 962 | |
Evan Cheng | 7c8d5ea | 2009-10-01 08:22:27 +0000 | [diff] [blame] | 963 | let mayLoad = 1, hasExtraDefRegAllocReq = 1 in |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 964 | def LDM : AXI4ld<(outs), |
Evan Cheng | b43a20e | 2009-10-01 01:33:39 +0000 | [diff] [blame] | 965 | (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops), |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 966 | LdStMulFrm, IIC_iLoadm, "ldm${addr:submode}${p}\t$addr, $wb", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 967 | []>; |
| 968 | |
Evan Cheng | 7c8d5ea | 2009-10-01 08:22:27 +0000 | [diff] [blame] | 969 | let mayStore = 1, hasExtraSrcRegAllocReq = 1 in |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 970 | def STM : AXI4st<(outs), |
Evan Cheng | b43a20e | 2009-10-01 01:33:39 +0000 | [diff] [blame] | 971 | (ins addrmode4:$addr, pred:$p, reglist:$wb, variable_ops), |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 972 | LdStMulFrm, IIC_iStorem, "stm${addr:submode}${p}\t$addr, $wb", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 973 | []>; |
| 974 | |
| 975 | //===----------------------------------------------------------------------===// |
| 976 | // Move Instructions. |
| 977 | // |
| 978 | |
Evan Cheng | d97d714 | 2009-06-12 20:46:18 +0000 | [diff] [blame] | 979 | let neverHasSideEffects = 1 in |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 980 | def MOVr : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 981 | "mov", "\t$dst, $src", []>, UnaryDP { |
Johnny Chen | d139b94 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 982 | let Inst{11-4} = 0b00000000; |
Bob Wilson | cfb46c5 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 983 | let Inst{25} = 0; |
| 984 | } |
| 985 | |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 986 | def MOVs : AsI1<0b1101, (outs GPR:$dst), (ins so_reg:$src), |
Anton Korobeynikov | 6092895 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 987 | DPSoRegFrm, IIC_iMOVsr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 988 | "mov", "\t$dst, $src", [(set GPR:$dst, so_reg:$src)]>, UnaryDP { |
Bob Wilson | cfb46c5 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 989 | let Inst{25} = 0; |
| 990 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 991 | |
Evan Cheng | bd0ca9c | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 992 | let isReMaterializable = 1, isAsCheapAsAMove = 1 in |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 993 | def MOVi : AsI1<0b1101, (outs GPR:$dst), (ins so_imm:$src), DPFrm, IIC_iMOVi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 994 | "mov", "\t$dst, $src", [(set GPR:$dst, so_imm:$src)]>, UnaryDP { |
Anton Korobeynikov | 6092895 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 995 | let Inst{25} = 1; |
| 996 | } |
| 997 | |
| 998 | let isReMaterializable = 1, isAsCheapAsAMove = 1 in |
| 999 | def MOVi16 : AI1<0b1000, (outs GPR:$dst), (ins i32imm:$src), |
| 1000 | DPFrm, IIC_iMOVi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1001 | "movw", "\t$dst, $src", |
Anton Korobeynikov | 6092895 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1002 | [(set GPR:$dst, imm0_65535:$src)]>, |
| 1003 | Requires<[IsARM, HasV6T2]> { |
Bob Wilson | ce7c9eb | 2009-10-13 17:35:30 +0000 | [diff] [blame] | 1004 | let Inst{20} = 0; |
Anton Korobeynikov | 6092895 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1005 | let Inst{25} = 1; |
| 1006 | } |
| 1007 | |
Evan Cheng | 16c012d | 2009-09-28 09:14:39 +0000 | [diff] [blame] | 1008 | let Constraints = "$src = $dst" in |
Anton Korobeynikov | 6092895 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1009 | def MOVTi16 : AI1<0b1010, (outs GPR:$dst), (ins GPR:$src, i32imm:$imm), |
| 1010 | DPFrm, IIC_iMOVi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1011 | "movt", "\t$dst, $imm", |
Anton Korobeynikov | 6092895 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1012 | [(set GPR:$dst, |
| 1013 | (or (and GPR:$src, 0xffff), |
| 1014 | lo16AllZero:$imm))]>, UnaryDP, |
| 1015 | Requires<[IsARM, HasV6T2]> { |
Bob Wilson | ce7c9eb | 2009-10-13 17:35:30 +0000 | [diff] [blame] | 1016 | let Inst{20} = 0; |
Anton Korobeynikov | 6092895 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1017 | let Inst{25} = 1; |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1018 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1019 | |
Evan Cheng | 89ef285 | 2009-10-21 08:15:52 +0000 | [diff] [blame] | 1020 | def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>, |
| 1021 | Requires<[IsARM, HasV6T2]>; |
| 1022 | |
David Goodwin | 02b0e35 | 2009-09-01 18:32:09 +0000 | [diff] [blame] | 1023 | let Uses = [CPSR] in |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1024 | def MOVrx : AsI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, IIC_iMOVsi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1025 | "mov", "\t$dst, $src, rrx", |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 1026 | [(set GPR:$dst, (ARMrrx GPR:$src))]>, UnaryDP; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1027 | |
| 1028 | // These aren't really mov instructions, but we have to define them this way |
| 1029 | // due to flag operands. |
| 1030 | |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1031 | let Defs = [CPSR] in { |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 1032 | def MOVsrl_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1033 | IIC_iMOVsi, "movs", "\t$dst, $src, lsr #1", |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 1034 | [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP; |
Evan Cheng | 7f240d2 | 2008-11-14 20:09:11 +0000 | [diff] [blame] | 1035 | def MOVsra_flag : AI1<0b1101, (outs GPR:$dst), (ins GPR:$src), Pseudo, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1036 | IIC_iMOVsi, "movs", "\t$dst, $src, asr #1", |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 1037 | [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP; |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1038 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1039 | |
| 1040 | //===----------------------------------------------------------------------===// |
| 1041 | // Extend Instructions. |
| 1042 | // |
| 1043 | |
| 1044 | // Sign extenders |
| 1045 | |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 1046 | defm SXTB : AI_unary_rrot<0b01101010, |
| 1047 | "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>; |
| 1048 | defm SXTH : AI_unary_rrot<0b01101011, |
| 1049 | "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1050 | |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 1051 | defm SXTAB : AI_bin_rrot<0b01101010, |
| 1052 | "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>; |
| 1053 | defm SXTAH : AI_bin_rrot<0b01101011, |
| 1054 | "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1055 | |
| 1056 | // TODO: SXT(A){B|H}16 |
| 1057 | |
| 1058 | // Zero extenders |
| 1059 | |
| 1060 | let AddedComplexity = 16 in { |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 1061 | defm UXTB : AI_unary_rrot<0b01101110, |
| 1062 | "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>; |
| 1063 | defm UXTH : AI_unary_rrot<0b01101111, |
| 1064 | "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>; |
| 1065 | defm UXTB16 : AI_unary_rrot<0b01101100, |
| 1066 | "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1067 | |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1068 | def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1069 | (UXTB16r_rot GPR:$Src, 24)>; |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1070 | def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1071 | (UXTB16r_rot GPR:$Src, 8)>; |
| 1072 | |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 1073 | defm UXTAB : AI_bin_rrot<0b01101110, "uxtab", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1074 | BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>; |
Evan Cheng | 37afa43 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 1075 | defm UXTAH : AI_bin_rrot<0b01101111, "uxtah", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1076 | BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>; |
| 1077 | } |
| 1078 | |
| 1079 | // This isn't safe in general, the add is two 16-bit units, not a 32-bit add. |
| 1080 | //defm UXTAB16 : xxx<"uxtab16", 0xff00ff>; |
| 1081 | |
| 1082 | // TODO: UXT(A){B|H}16 |
| 1083 | |
Sandeep Patel | bb4648a | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 1084 | def SBFX : I<(outs GPR:$dst), |
| 1085 | (ins GPR:$src, imm0_31:$lsb, imm0_31:$width), |
| 1086 | AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1087 | "sbfx", "\t$dst, $src, $lsb, $width", "", []>, |
Sandeep Patel | bb4648a | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 1088 | Requires<[IsARM, HasV6T2]> { |
| 1089 | let Inst{27-21} = 0b0111101; |
| 1090 | let Inst{6-4} = 0b101; |
| 1091 | } |
| 1092 | |
| 1093 | def UBFX : I<(outs GPR:$dst), |
| 1094 | (ins GPR:$src, imm0_31:$lsb, imm0_31:$width), |
| 1095 | AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iALUi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1096 | "ubfx", "\t$dst, $src, $lsb, $width", "", []>, |
Sandeep Patel | bb4648a | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 1097 | Requires<[IsARM, HasV6T2]> { |
| 1098 | let Inst{27-21} = 0b0111111; |
| 1099 | let Inst{6-4} = 0b101; |
| 1100 | } |
| 1101 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1102 | //===----------------------------------------------------------------------===// |
| 1103 | // Arithmetic Instructions. |
| 1104 | // |
| 1105 | |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1106 | defm ADD : AsI1_bin_irs<0b0100, "add", |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 1107 | BinOpFrag<(add node:$LHS, node:$RHS)>, 1>; |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1108 | defm SUB : AsI1_bin_irs<0b0010, "sub", |
Evan Cheng | 469bc76 | 2008-09-17 07:53:38 +0000 | [diff] [blame] | 1109 | BinOpFrag<(sub node:$LHS, node:$RHS)>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1110 | |
| 1111 | // ADD and SUB with 's' bit set. |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1112 | defm ADDS : AI1_bin_s_irs<0b0100, "adds", |
| 1113 | BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>; |
| 1114 | defm SUBS : AI1_bin_s_irs<0b0010, "subs", |
Evan Cheng | d4e2f05 | 2009-06-25 20:59:23 +0000 | [diff] [blame] | 1115 | BinOpFrag<(subc node:$LHS, node:$RHS)>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1116 | |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1117 | defm ADC : AI1_adde_sube_irs<0b0101, "adc", |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 1118 | BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>; |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1119 | defm SBC : AI1_adde_sube_irs<0b0110, "sbc", |
| 1120 | BinOpFrag<(sube node:$LHS, node:$RHS)>>; |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1121 | defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs", |
| 1122 | BinOpFrag<(adde node:$LHS, node:$RHS)>, 1>; |
| 1123 | defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs", |
| 1124 | BinOpFrag<(sube node:$LHS, node:$RHS)>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1125 | |
| 1126 | // These don't define reg/reg forms, because they are handled above. |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 1127 | def RSBri : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1128 | IIC_iALUi, "rsb", "\t$dst, $a, $b", |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1129 | [(set GPR:$dst, (sub so_imm:$b, GPR:$a))]> { |
| 1130 | let Inst{25} = 1; |
| 1131 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1132 | |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 1133 | def RSBrs : AsI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1134 | IIC_iALUsr, "rsb", "\t$dst, $a, $b", |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 1135 | [(set GPR:$dst, (sub so_reg:$b, GPR:$a))]> { |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 1136 | let Inst{25} = 0; |
| 1137 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1138 | |
| 1139 | // RSB with 's' bit set. |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1140 | let Defs = [CPSR] in { |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 1141 | def RSBSri : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), DPFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1142 | IIC_iALUi, "rsbs", "\t$dst, $a, $b", |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1143 | [(set GPR:$dst, (subc so_imm:$b, GPR:$a))]> { |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 1144 | let Inst{20} = 1; |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1145 | let Inst{25} = 1; |
| 1146 | } |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 1147 | def RSBSrs : AI1<0b0011, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), DPSoRegFrm, |
Jim Grosbach | e2fda53 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1148 | IIC_iALUsr, "rsbs", "\t$dst, $a, $b", |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 1149 | [(set GPR:$dst, (subc so_reg:$b, GPR:$a))]> { |
Bob Wilson | 3a30852 | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 1150 | let Inst{20} = 1; |
| 1151 | let Inst{25} = 0; |
| 1152 | } |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1153 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1154 | |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1155 | let Uses = [CPSR] in { |
| 1156 | def RSCri : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1157 | DPFrm, IIC_iALUi, "rsc", "\t$dst, $a, $b", |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1158 | [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>, |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1159 | Requires<[IsARM, CarryDefIsUnused]> { |
| 1160 | let Inst{25} = 1; |
| 1161 | } |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1162 | def RSCrs : AsI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1163 | DPSoRegFrm, IIC_iALUsr, "rsc", "\t$dst, $a, $b", |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1164 | [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>, |
Bob Wilson | 2aec46e | 2009-10-26 22:59:12 +0000 | [diff] [blame] | 1165 | Requires<[IsARM, CarryDefIsUnused]> { |
Bob Wilson | 2aec46e | 2009-10-26 22:59:12 +0000 | [diff] [blame] | 1166 | let Inst{25} = 0; |
| 1167 | } |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1168 | } |
| 1169 | |
| 1170 | // FIXME: Allow these to be predicated. |
Evan Cheng | d4e2f05 | 2009-06-25 20:59:23 +0000 | [diff] [blame] | 1171 | let Defs = [CPSR], Uses = [CPSR] in { |
| 1172 | def RSCSri : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_imm:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1173 | DPFrm, IIC_iALUi, "rscs\t$dst, $a, $b", |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1174 | [(set GPR:$dst, (sube so_imm:$b, GPR:$a))]>, |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1175 | Requires<[IsARM, CarryDefIsUnused]> { |
Bob Wilson | 2aec46e | 2009-10-26 22:59:12 +0000 | [diff] [blame] | 1176 | let Inst{20} = 1; |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1177 | let Inst{25} = 1; |
| 1178 | } |
Evan Cheng | d4e2f05 | 2009-06-25 20:59:23 +0000 | [diff] [blame] | 1179 | def RSCSrs : AXI1<0b0111, (outs GPR:$dst), (ins GPR:$a, so_reg:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1180 | DPSoRegFrm, IIC_iALUsr, "rscs\t$dst, $a, $b", |
Evan Cheng | 9b4d26f | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1181 | [(set GPR:$dst, (sube so_reg:$b, GPR:$a))]>, |
Bob Wilson | 2aec46e | 2009-10-26 22:59:12 +0000 | [diff] [blame] | 1182 | Requires<[IsARM, CarryDefIsUnused]> { |
Bob Wilson | 2aec46e | 2009-10-26 22:59:12 +0000 | [diff] [blame] | 1183 | let Inst{20} = 1; |
| 1184 | let Inst{25} = 0; |
| 1185 | } |
Evan Cheng | 6e4d1d9 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1186 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1187 | |
| 1188 | // (sub X, imm) gets canonicalized to (add X, -imm). Match this form. |
| 1189 | def : ARMPat<(add GPR:$src, so_imm_neg:$imm), |
| 1190 | (SUBri GPR:$src, so_imm_neg:$imm)>; |
| 1191 | |
| 1192 | //def : ARMPat<(addc GPR:$src, so_imm_neg:$imm), |
| 1193 | // (SUBSri GPR:$src, so_imm_neg:$imm)>; |
| 1194 | //def : ARMPat<(adde GPR:$src, so_imm_neg:$imm), |
| 1195 | // (SBCri GPR:$src, so_imm_neg:$imm)>; |
| 1196 | |
| 1197 | // Note: These are implemented in C++ code, because they have to generate |
| 1198 | // ADD/SUBrs instructions, which use a complex pattern that a xform function |
| 1199 | // cannot produce. |
| 1200 | // (mul X, 2^n+1) -> (add (X << n), X) |
| 1201 | // (mul X, 2^n-1) -> (rsb X, (X << n)) |
| 1202 | |
| 1203 | |
| 1204 | //===----------------------------------------------------------------------===// |
| 1205 | // Bitwise Instructions. |
| 1206 | // |
| 1207 | |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1208 | defm AND : AsI1_bin_irs<0b0000, "and", |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 1209 | BinOpFrag<(and node:$LHS, node:$RHS)>, 1>; |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1210 | defm ORR : AsI1_bin_irs<0b1100, "orr", |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 1211 | BinOpFrag<(or node:$LHS, node:$RHS)>, 1>; |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1212 | defm EOR : AsI1_bin_irs<0b0001, "eor", |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 1213 | BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>; |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1214 | defm BIC : AsI1_bin_irs<0b1110, "bic", |
Evan Cheng | 469bc76 | 2008-09-17 07:53:38 +0000 | [diff] [blame] | 1215 | BinOpFrag<(and node:$LHS, (not node:$RHS))>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1216 | |
Evan Cheng | 299ee65 | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 1217 | def BFC : I<(outs GPR:$dst), (ins GPR:$src, bf_inv_mask_imm:$imm), |
David Goodwin | 9a8ec82 | 2009-11-02 17:28:36 +0000 | [diff] [blame] | 1218 | AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1219 | "bfc", "\t$dst, $imm", "$src = $dst", |
Evan Cheng | 299ee65 | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 1220 | [(set GPR:$dst, (and GPR:$src, bf_inv_mask_imm:$imm))]>, |
| 1221 | Requires<[IsARM, HasV6T2]> { |
| 1222 | let Inst{27-21} = 0b0111110; |
| 1223 | let Inst{6-0} = 0b0011111; |
| 1224 | } |
| 1225 | |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1226 | def MVNr : AsI1<0b1111, (outs GPR:$dst), (ins GPR:$src), DPFrm, IIC_iMOVr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1227 | "mvn", "\t$dst, $src", |
Bob Wilson | cfb46c5 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1228 | [(set GPR:$dst, (not GPR:$src))]>, UnaryDP { |
Johnny Chen | d139b94 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 1229 | let Inst{11-4} = 0b00000000; |
Bob Wilson | cfb46c5 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1230 | } |
Evan Cheng | 86a926a | 2008-11-05 18:35:52 +0000 | [diff] [blame] | 1231 | def MVNs : AsI1<0b1111, (outs GPR:$dst), (ins so_reg:$src), DPSoRegFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1232 | IIC_iMOVsr, "mvn", "\t$dst, $src", |
Johnny Chen | d139b94 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 1233 | [(set GPR:$dst, (not so_reg:$src))]>, UnaryDP; |
Evan Cheng | bd0ca9c | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 1234 | let isReMaterializable = 1, isAsCheapAsAMove = 1 in |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1235 | def MVNi : AsI1<0b1111, (outs GPR:$dst), (ins so_imm:$imm), DPFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1236 | IIC_iMOVi, "mvn", "\t$dst, $imm", |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1237 | [(set GPR:$dst, so_imm_not:$imm)]>,UnaryDP { |
| 1238 | let Inst{25} = 1; |
| 1239 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1240 | |
| 1241 | def : ARMPat<(and GPR:$src, so_imm_not:$imm), |
| 1242 | (BICri GPR:$src, so_imm_not:$imm)>; |
| 1243 | |
| 1244 | //===----------------------------------------------------------------------===// |
| 1245 | // Multiply Instructions. |
| 1246 | // |
| 1247 | |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 1248 | let isCommutable = 1 in |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1249 | def MUL : AsMul1I<0b0000000, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1250 | IIC_iMUL32, "mul", "\t$dst, $a, $b", |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 1251 | [(set GPR:$dst, (mul GPR:$a, GPR:$b))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1252 | |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1253 | def MLA : AsMul1I<0b0000001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1254 | IIC_iMAC32, "mla", "\t$dst, $a, $b, $c", |
Evan Cheng | f8e8b62 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 1255 | [(set GPR:$dst, (add (mul GPR:$a, GPR:$b), GPR:$c))]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1256 | |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 1257 | def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1258 | IIC_iMAC32, "mls", "\t$dst, $a, $b, $c", |
Evan Cheng | c8147e1 | 2009-07-06 22:05:45 +0000 | [diff] [blame] | 1259 | [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>, |
| 1260 | Requires<[IsARM, HasV6T2]>; |
| 1261 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1262 | // Extra precision multiplies with low / high results |
Evan Cheng | d97d714 | 2009-06-12 20:46:18 +0000 | [diff] [blame] | 1263 | let neverHasSideEffects = 1 in { |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 1264 | let isCommutable = 1 in { |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1265 | def SMULL : AsMul1I<0b0000110, (outs GPR:$ldst, GPR:$hdst), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1266 | (ins GPR:$a, GPR:$b), IIC_iMUL64, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1267 | "smull", "\t$ldst, $hdst, $a, $b", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1268 | |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1269 | def UMULL : AsMul1I<0b0000100, (outs GPR:$ldst, GPR:$hdst), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1270 | (ins GPR:$a, GPR:$b), IIC_iMUL64, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1271 | "umull", "\t$ldst, $hdst, $a, $b", []>; |
Evan Cheng | bdd679a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 1272 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1273 | |
| 1274 | // Multiply + accumulate |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1275 | def SMLAL : AsMul1I<0b0000111, (outs GPR:$ldst, GPR:$hdst), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1276 | (ins GPR:$a, GPR:$b), IIC_iMAC64, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1277 | "smlal", "\t$ldst, $hdst, $a, $b", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1278 | |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1279 | def UMLAL : AsMul1I<0b0000101, (outs GPR:$ldst, GPR:$hdst), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1280 | (ins GPR:$a, GPR:$b), IIC_iMAC64, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1281 | "umlal", "\t$ldst, $hdst, $a, $b", []>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1282 | |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1283 | def UMAAL : AMul1I <0b0000010, (outs GPR:$ldst, GPR:$hdst), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1284 | (ins GPR:$a, GPR:$b), IIC_iMAC64, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1285 | "umaal", "\t$ldst, $hdst, $a, $b", []>, |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1286 | Requires<[IsARM, HasV6]>; |
Evan Cheng | d97d714 | 2009-06-12 20:46:18 +0000 | [diff] [blame] | 1287 | } // neverHasSideEffects |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1288 | |
| 1289 | // Most significant word multiply |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1290 | def SMMUL : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1291 | IIC_iMUL32, "smmul", "\t$dst, $a, $b", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1292 | [(set GPR:$dst, (mulhs GPR:$a, GPR:$b))]>, |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1293 | Requires<[IsARM, HasV6]> { |
| 1294 | let Inst{7-4} = 0b0001; |
| 1295 | let Inst{15-12} = 0b1111; |
| 1296 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1297 | |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1298 | def SMMLA : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1299 | IIC_iMAC32, "smmla", "\t$dst, $a, $b, $c", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1300 | [(set GPR:$dst, (add (mulhs GPR:$a, GPR:$b), GPR:$c))]>, |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1301 | Requires<[IsARM, HasV6]> { |
| 1302 | let Inst{7-4} = 0b0001; |
| 1303 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1304 | |
| 1305 | |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1306 | def SMMLS : AMul2I <0b0111010, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1307 | IIC_iMAC32, "smmls", "\t$dst, $a, $b, $c", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1308 | [(set GPR:$dst, (sub GPR:$c, (mulhs GPR:$a, GPR:$b)))]>, |
Evan Cheng | ee80fb7 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 1309 | Requires<[IsARM, HasV6]> { |
| 1310 | let Inst{7-4} = 0b1101; |
| 1311 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1312 | |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1313 | multiclass AI_smul<string opc, PatFrag opnode> { |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1314 | def BB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1315 | IIC_iMUL32, !strconcat(opc, "bb"), "\t$dst, $a, $b", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1316 | [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16), |
| 1317 | (sext_inreg GPR:$b, i16)))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1318 | Requires<[IsARM, HasV5TE]> { |
| 1319 | let Inst{5} = 0; |
| 1320 | let Inst{6} = 0; |
| 1321 | } |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1322 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1323 | def BT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1324 | IIC_iMUL32, !strconcat(opc, "bt"), "\t$dst, $a, $b", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1325 | [(set GPR:$dst, (opnode (sext_inreg GPR:$a, i16), |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1326 | (sra GPR:$b, (i32 16))))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1327 | Requires<[IsARM, HasV5TE]> { |
| 1328 | let Inst{5} = 0; |
| 1329 | let Inst{6} = 1; |
| 1330 | } |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1331 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1332 | def TB : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1333 | IIC_iMUL32, !strconcat(opc, "tb"), "\t$dst, $a, $b", |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1334 | [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1335 | (sext_inreg GPR:$b, i16)))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1336 | Requires<[IsARM, HasV5TE]> { |
| 1337 | let Inst{5} = 1; |
| 1338 | let Inst{6} = 0; |
| 1339 | } |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1340 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1341 | def TT : AMulxyI<0b0001011, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1342 | IIC_iMUL32, !strconcat(opc, "tt"), "\t$dst, $a, $b", |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1343 | [(set GPR:$dst, (opnode (sra GPR:$a, (i32 16)), |
| 1344 | (sra GPR:$b, (i32 16))))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1345 | Requires<[IsARM, HasV5TE]> { |
| 1346 | let Inst{5} = 1; |
| 1347 | let Inst{6} = 1; |
| 1348 | } |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1349 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1350 | def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1351 | IIC_iMUL16, !strconcat(opc, "wb"), "\t$dst, $a, $b", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1352 | [(set GPR:$dst, (sra (opnode GPR:$a, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1353 | (sext_inreg GPR:$b, i16)), (i32 16)))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1354 | Requires<[IsARM, HasV5TE]> { |
| 1355 | let Inst{5} = 1; |
| 1356 | let Inst{6} = 0; |
| 1357 | } |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1358 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1359 | def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1360 | IIC_iMUL16, !strconcat(opc, "wt"), "\t$dst, $a, $b", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1361 | [(set GPR:$dst, (sra (opnode GPR:$a, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1362 | (sra GPR:$b, (i32 16))), (i32 16)))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1363 | Requires<[IsARM, HasV5TE]> { |
| 1364 | let Inst{5} = 1; |
| 1365 | let Inst{6} = 1; |
| 1366 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1367 | } |
| 1368 | |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1369 | |
| 1370 | multiclass AI_smla<string opc, PatFrag opnode> { |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1371 | def BB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1372 | IIC_iMAC16, !strconcat(opc, "bb"), "\t$dst, $a, $b, $acc", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1373 | [(set GPR:$dst, (add GPR:$acc, |
| 1374 | (opnode (sext_inreg GPR:$a, i16), |
| 1375 | (sext_inreg GPR:$b, i16))))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1376 | Requires<[IsARM, HasV5TE]> { |
| 1377 | let Inst{5} = 0; |
| 1378 | let Inst{6} = 0; |
| 1379 | } |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1380 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1381 | def BT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1382 | IIC_iMAC16, !strconcat(opc, "bt"), "\t$dst, $a, $b, $acc", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1383 | [(set GPR:$dst, (add GPR:$acc, (opnode (sext_inreg GPR:$a, i16), |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1384 | (sra GPR:$b, (i32 16)))))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1385 | Requires<[IsARM, HasV5TE]> { |
| 1386 | let Inst{5} = 0; |
| 1387 | let Inst{6} = 1; |
| 1388 | } |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1389 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1390 | def TB : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1391 | IIC_iMAC16, !strconcat(opc, "tb"), "\t$dst, $a, $b, $acc", |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1392 | [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1393 | (sext_inreg GPR:$b, i16))))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1394 | Requires<[IsARM, HasV5TE]> { |
| 1395 | let Inst{5} = 1; |
| 1396 | let Inst{6} = 0; |
| 1397 | } |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1398 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1399 | def TT : AMulxyI<0b0001000, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1400 | IIC_iMAC16, !strconcat(opc, "tt"), "\t$dst, $a, $b, $acc", |
| 1401 | [(set GPR:$dst, (add GPR:$acc, (opnode (sra GPR:$a, (i32 16)), |
| 1402 | (sra GPR:$b, (i32 16)))))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1403 | Requires<[IsARM, HasV5TE]> { |
| 1404 | let Inst{5} = 1; |
| 1405 | let Inst{6} = 1; |
| 1406 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1407 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1408 | def WB : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1409 | IIC_iMAC16, !strconcat(opc, "wb"), "\t$dst, $a, $b, $acc", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1410 | [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1411 | (sext_inreg GPR:$b, i16)), (i32 16))))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1412 | Requires<[IsARM, HasV5TE]> { |
| 1413 | let Inst{5} = 0; |
| 1414 | let Inst{6} = 0; |
| 1415 | } |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1416 | |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1417 | def WT : AMulxyI<0b0001001, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$acc), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1418 | IIC_iMAC16, !strconcat(opc, "wt"), "\t$dst, $a, $b, $acc", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1419 | [(set GPR:$dst, (add GPR:$acc, (sra (opnode GPR:$a, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1420 | (sra GPR:$b, (i32 16))), (i32 16))))]>, |
Evan Cheng | 38396be | 2008-11-06 03:35:07 +0000 | [diff] [blame] | 1421 | Requires<[IsARM, HasV5TE]> { |
| 1422 | let Inst{5} = 0; |
| 1423 | let Inst{6} = 1; |
| 1424 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1425 | } |
| 1426 | |
Raul Herbster | 2e07e8d | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 1427 | defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>; |
| 1428 | defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1429 | |
| 1430 | // TODO: Halfword multiple accumulate long: SMLAL<x><y> |
| 1431 | // TODO: Dual halfword multiple: SMUAD, SMUSD, SMLAD, SMLSD, SMLALD, SMLSLD |
| 1432 | |
| 1433 | //===----------------------------------------------------------------------===// |
| 1434 | // Misc. Arithmetic Instructions. |
| 1435 | // |
| 1436 | |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1437 | def CLZ : AMiscA1I<0b000010110, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1438 | "clz", "\t$dst, $src", |
Evan Cheng | c2121a2 | 2008-11-07 01:41:35 +0000 | [diff] [blame] | 1439 | [(set GPR:$dst, (ctlz GPR:$src))]>, Requires<[IsARM, HasV5T]> { |
| 1440 | let Inst{7-4} = 0b0001; |
| 1441 | let Inst{11-8} = 0b1111; |
| 1442 | let Inst{19-16} = 0b1111; |
| 1443 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1444 | |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1445 | def REV : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1446 | "rev", "\t$dst, $src", |
Evan Cheng | c2121a2 | 2008-11-07 01:41:35 +0000 | [diff] [blame] | 1447 | [(set GPR:$dst, (bswap GPR:$src))]>, Requires<[IsARM, HasV6]> { |
| 1448 | let Inst{7-4} = 0b0011; |
| 1449 | let Inst{11-8} = 0b1111; |
| 1450 | let Inst{19-16} = 0b1111; |
| 1451 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1452 | |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1453 | def REV16 : AMiscA1I<0b01101011, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1454 | "rev16", "\t$dst, $src", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1455 | [(set GPR:$dst, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1456 | (or (and (srl GPR:$src, (i32 8)), 0xFF), |
| 1457 | (or (and (shl GPR:$src, (i32 8)), 0xFF00), |
| 1458 | (or (and (srl GPR:$src, (i32 8)), 0xFF0000), |
| 1459 | (and (shl GPR:$src, (i32 8)), 0xFF000000)))))]>, |
Evan Cheng | c2121a2 | 2008-11-07 01:41:35 +0000 | [diff] [blame] | 1460 | Requires<[IsARM, HasV6]> { |
| 1461 | let Inst{7-4} = 0b1011; |
| 1462 | let Inst{11-8} = 0b1111; |
| 1463 | let Inst{19-16} = 0b1111; |
| 1464 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1465 | |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1466 | def REVSH : AMiscA1I<0b01101111, (outs GPR:$dst), (ins GPR:$src), IIC_iUNAr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1467 | "revsh", "\t$dst, $src", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1468 | [(set GPR:$dst, |
| 1469 | (sext_inreg |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1470 | (or (srl (and GPR:$src, 0xFF00), (i32 8)), |
| 1471 | (shl GPR:$src, (i32 8))), i16))]>, |
Evan Cheng | c2121a2 | 2008-11-07 01:41:35 +0000 | [diff] [blame] | 1472 | Requires<[IsARM, HasV6]> { |
| 1473 | let Inst{7-4} = 0b1011; |
| 1474 | let Inst{11-8} = 0b1111; |
| 1475 | let Inst{19-16} = 0b1111; |
| 1476 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1477 | |
Evan Cheng | c2121a2 | 2008-11-07 01:41:35 +0000 | [diff] [blame] | 1478 | def PKHBT : AMiscA1I<0b01101000, (outs GPR:$dst), |
| 1479 | (ins GPR:$src1, GPR:$src2, i32imm:$shamt), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1480 | IIC_iALUsi, "pkhbt", "\t$dst, $src1, $src2, LSL $shamt", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1481 | [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF), |
| 1482 | (and (shl GPR:$src2, (i32 imm:$shamt)), |
| 1483 | 0xFFFF0000)))]>, |
Evan Cheng | c2121a2 | 2008-11-07 01:41:35 +0000 | [diff] [blame] | 1484 | Requires<[IsARM, HasV6]> { |
| 1485 | let Inst{6-4} = 0b001; |
| 1486 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1487 | |
| 1488 | // Alternate cases for PKHBT where identities eliminate some nodes. |
| 1489 | def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (and GPR:$src2, 0xFFFF0000)), |
| 1490 | (PKHBT GPR:$src1, GPR:$src2, 0)>; |
| 1491 | def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF), (shl GPR:$src2, imm16_31:$shamt)), |
| 1492 | (PKHBT GPR:$src1, GPR:$src2, imm16_31:$shamt)>; |
| 1493 | |
| 1494 | |
Evan Cheng | c2121a2 | 2008-11-07 01:41:35 +0000 | [diff] [blame] | 1495 | def PKHTB : AMiscA1I<0b01101000, (outs GPR:$dst), |
| 1496 | (ins GPR:$src1, GPR:$src2, i32imm:$shamt), |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1497 | IIC_iALUsi, "pkhtb", "\t$dst, $src1, $src2, ASR $shamt", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1498 | [(set GPR:$dst, (or (and GPR:$src1, 0xFFFF0000), |
| 1499 | (and (sra GPR:$src2, imm16_31:$shamt), |
Evan Cheng | c2121a2 | 2008-11-07 01:41:35 +0000 | [diff] [blame] | 1500 | 0xFFFF)))]>, Requires<[IsARM, HasV6]> { |
| 1501 | let Inst{6-4} = 0b101; |
| 1502 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1503 | |
| 1504 | // Alternate cases for PKHTB where identities eliminate some nodes. Note that |
| 1505 | // a shift amount of 0 is *not legal* here, it is PKHBT instead. |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1506 | def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, (i32 16))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1507 | (PKHTB GPR:$src1, GPR:$src2, 16)>; |
| 1508 | def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), |
| 1509 | (and (srl GPR:$src2, imm1_15:$shamt), 0xFFFF)), |
| 1510 | (PKHTB GPR:$src1, GPR:$src2, imm1_15:$shamt)>; |
| 1511 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1512 | //===----------------------------------------------------------------------===// |
| 1513 | // Comparison Instructions... |
| 1514 | // |
| 1515 | |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1516 | defm CMP : AI1_cmp_irs<0b1010, "cmp", |
Evan Cheng | a7b3e7c | 2007-08-07 01:37:15 +0000 | [diff] [blame] | 1517 | BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>; |
Jim Grosbach | 88c246f | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1518 | defm CMN : AI1_cmp_irs<0b1011, "cmn", |
Evan Cheng | a7b3e7c | 2007-08-07 01:37:15 +0000 | [diff] [blame] | 1519 | BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1520 | |
| 1521 | // Note that TST/TEQ don't set all the same flags that CMP does! |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1522 | defm TST : AI1_cmp_irs<0b1000, "tst", |
David Goodwin | 8bdcbb3 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 1523 | BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>; |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1524 | defm TEQ : AI1_cmp_irs<0b1001, "teq", |
David Goodwin | 8bdcbb3 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 1525 | BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1526 | |
David Goodwin | 8bdcbb3 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 1527 | defm CMPz : AI1_cmp_irs<0b1010, "cmp", |
| 1528 | BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>; |
| 1529 | defm CMNz : AI1_cmp_irs<0b1011, "cmn", |
| 1530 | BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1531 | |
| 1532 | def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm), |
| 1533 | (CMNri GPR:$src, so_imm_neg:$imm)>; |
| 1534 | |
David Goodwin | 8bdcbb3 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 1535 | def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1536 | (CMNri GPR:$src, so_imm_neg:$imm)>; |
| 1537 | |
| 1538 | |
| 1539 | // Conditional moves |
| 1540 | // FIXME: should be able to write a pattern for ARMcmov, but can't use |
| 1541 | // a two-value operand where a dag node expects two operands. :( |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1542 | def MOVCCr : AI1<0b1101, (outs GPR:$dst), (ins GPR:$false, GPR:$true), DPFrm, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1543 | IIC_iCMOVr, "mov", "\t$dst, $true", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1544 | [/*(set GPR:$dst, (ARMcmov GPR:$false, GPR:$true, imm:$cc, CCR:$ccr))*/]>, |
Bob Wilson | cfb46c5 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1545 | RegConstraint<"$false = $dst">, UnaryDP { |
Johnny Chen | d139b94 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 1546 | let Inst{11-4} = 0b00000000; |
Bob Wilson | cfb46c5 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1547 | let Inst{25} = 0; |
| 1548 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1549 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1550 | def MOVCCs : AI1<0b1101, (outs GPR:$dst), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1551 | (ins GPR:$false, so_reg:$true), DPSoRegFrm, IIC_iCMOVsr, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1552 | "mov", "\t$dst, $true", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1553 | [/*(set GPR:$dst, (ARMcmov GPR:$false, so_reg:$true, imm:$cc, CCR:$ccr))*/]>, |
Bob Wilson | cfb46c5 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1554 | RegConstraint<"$false = $dst">, UnaryDP { |
Bob Wilson | cfb46c5 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1555 | let Inst{25} = 0; |
| 1556 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1557 | |
Evan Cheng | be99824 | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1558 | def MOVCCi : AI1<0b1101, (outs GPR:$dst), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1559 | (ins GPR:$false, so_imm:$true), DPFrm, IIC_iCMOVi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1560 | "mov", "\t$dst, $true", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1561 | [/*(set GPR:$dst, (ARMcmov GPR:$false, so_imm:$true, imm:$cc, CCR:$ccr))*/]>, |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1562 | RegConstraint<"$false = $dst">, UnaryDP { |
Bob Wilson | cfb46c5 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1563 | let Inst{25} = 1; |
Evan Cheng | a989293 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1564 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1565 | |
| 1566 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1567 | //===----------------------------------------------------------------------===// |
| 1568 | // TLS Instructions |
| 1569 | // |
| 1570 | |
| 1571 | // __aeabi_read_tp preserves the registers r1-r3. |
| 1572 | let isCall = 1, |
| 1573 | Defs = [R0, R12, LR, CPSR] in { |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 1574 | def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1575 | "bl\t__aeabi_read_tp", |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1576 | [(set R0, ARMthread_pointer)]>; |
| 1577 | } |
| 1578 | |
| 1579 | //===----------------------------------------------------------------------===// |
Jim Grosbach | c10915b | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 1580 | // SJLJ Exception handling intrinsics |
Jim Grosbach | 207a4ba | 2009-08-13 15:11:43 +0000 | [diff] [blame] | 1581 | // eh_sjlj_setjmp() is an instruction sequence to store the return |
Jim Grosbach | 4a9025e | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 1582 | // address and save #0 in R0 for the non-longjmp case. |
Jim Grosbach | c10915b | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 1583 | // Since by its nature we may be coming from some other function to get |
| 1584 | // here, and we're using the stack frame for the containing function to |
| 1585 | // save/restore registers, we can't keep anything live in regs across |
Jim Grosbach | 4a9025e | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 1586 | // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon |
Jim Grosbach | c10915b | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 1587 | // when we get here from a longjmp(). We force everthing out of registers |
Jim Grosbach | 4a9025e | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 1588 | // except for our own input by listing the relevant registers in Defs. By |
| 1589 | // doing so, we also cause the prologue/epilogue code to actively preserve |
| 1590 | // all of the callee-saved resgisters, which is exactly what we want. |
Jim Grosbach | c10915b | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 1591 | let Defs = |
Jim Grosbach | 3990e39 | 2009-08-13 16:59:44 +0000 | [diff] [blame] | 1592 | [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0, |
| 1593 | D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, |
Evan Cheng | 80ab2a8 | 2009-07-29 20:10:36 +0000 | [diff] [blame] | 1594 | D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30, |
Evan Cheng | 27396a6 | 2009-07-22 06:46:53 +0000 | [diff] [blame] | 1595 | D31 ] in { |
Jim Grosbach | 4a9025e | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 1596 | def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src), |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 1597 | AddrModeNone, SizeSpecial, IndexModeNone, |
| 1598 | Pseudo, NoItinerary, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1599 | "str\tsp, [$src, #+8] @ eh_setjmp begin\n\t" |
| 1600 | "add\tr12, pc, #8\n\t" |
| 1601 | "str\tr12, [$src, #+4]\n\t" |
| 1602 | "mov\tr0, #0\n\t" |
| 1603 | "add\tpc, pc, #0\n\t" |
| 1604 | "mov\tr0, #1 @ eh_setjmp end", "", |
Jim Grosbach | 4a9025e | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 1605 | [(set R0, (ARMeh_sjlj_setjmp GPR:$src))]>; |
Jim Grosbach | c10915b | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 1606 | } |
| 1607 | |
| 1608 | //===----------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1609 | // Non-Instruction Patterns |
| 1610 | // |
| 1611 | |
| 1612 | // ConstantPool, GlobalAddress, and JumpTable |
| 1613 | def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>; |
| 1614 | def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>; |
| 1615 | def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id), |
| 1616 | (LEApcrelJT tjumptable:$dst, imm:$id)>; |
| 1617 | |
| 1618 | // Large immediate handling. |
| 1619 | |
| 1620 | // Two piece so_imms. |
| 1621 | let isReMaterializable = 1 in |
David Goodwin | cfd6765 | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 1622 | def MOVi2pieces : AI1x2<(outs GPR:$dst), (ins so_imm2part:$src), |
David Goodwin | 236ccb5 | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1623 | Pseudo, IIC_iMOVi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1624 | "mov", "\t$dst, $src", |
Evan Cheng | 16c012d | 2009-09-28 09:14:39 +0000 | [diff] [blame] | 1625 | [(set GPR:$dst, so_imm2part:$src)]>, |
| 1626 | Requires<[IsARM, NoV6T2]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1627 | |
| 1628 | def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS), |
Evan Cheng | 8be2a5b | 2009-07-08 21:03:57 +0000 | [diff] [blame] | 1629 | (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)), |
| 1630 | (so_imm2part_2 imm:$RHS))>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1631 | def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS), |
Evan Cheng | 8be2a5b | 2009-07-08 21:03:57 +0000 | [diff] [blame] | 1632 | (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)), |
| 1633 | (so_imm2part_2 imm:$RHS))>; |
Jim Grosbach | 1afc8e2 | 2009-10-21 20:44:34 +0000 | [diff] [blame] | 1634 | def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS), |
| 1635 | (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)), |
| 1636 | (so_imm2part_2 imm:$RHS))>; |
Jim Grosbach | 66e70cd | 2009-11-23 20:35:53 +0000 | [diff] [blame^] | 1637 | def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS), |
| 1638 | (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)), |
| 1639 | (so_neg_imm2part_2 imm:$RHS))>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1640 | |
Evan Cheng | 16c012d | 2009-09-28 09:14:39 +0000 | [diff] [blame] | 1641 | // 32-bit immediate using movw + movt. |
Chris Lattner | e4eb734 | 2009-10-20 00:40:56 +0000 | [diff] [blame] | 1642 | // This is a single pseudo instruction, the benefit is that it can be remat'd |
| 1643 | // as a single unit instead of having to handle reg inputs. |
| 1644 | // FIXME: Remove this when we can do generalized remat. |
Evan Cheng | 16c012d | 2009-09-28 09:14:39 +0000 | [diff] [blame] | 1645 | let isReMaterializable = 1 in |
| 1646 | def MOVi32imm : AI1x2<(outs GPR:$dst), (ins i32imm:$src), Pseudo, IIC_iMOVi, |
Evan Cheng | d3f9bc4 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1647 | "movw", "\t$dst, ${src:lo16}\n\tmovt${p} $dst, ${src:hi16}", |
Evan Cheng | 16c012d | 2009-09-28 09:14:39 +0000 | [diff] [blame] | 1648 | [(set GPR:$dst, (i32 imm:$src))]>, |
| 1649 | Requires<[IsARM, HasV6T2]>; |
Anton Korobeynikov | 6092895 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1650 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1651 | // TODO: add,sub,and, 3-instr forms? |
| 1652 | |
| 1653 | |
| 1654 | // Direct calls |
Bob Wilson | 243b37c | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1655 | def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>, |
Evan Cheng | 9e73448 | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 1656 | Requires<[IsARM, IsNotDarwin]>; |
Bob Wilson | 243b37c | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1657 | def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>, |
Evan Cheng | 9e73448 | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 1658 | Requires<[IsARM, IsDarwin]>; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1659 | |
| 1660 | // zextload i1 -> zextload i8 |
| 1661 | def : ARMPat<(zextloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>; |
| 1662 | |
| 1663 | // extload -> zextload |
| 1664 | def : ARMPat<(extloadi1 addrmode2:$addr), (LDRB addrmode2:$addr)>; |
| 1665 | def : ARMPat<(extloadi8 addrmode2:$addr), (LDRB addrmode2:$addr)>; |
| 1666 | def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>; |
| 1667 | |
Evan Cheng | c41fb315 | 2008-11-05 23:22:34 +0000 | [diff] [blame] | 1668 | def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>; |
| 1669 | def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>; |
| 1670 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1671 | // smul* and smla* |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1672 | def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)), |
| 1673 | (sra (shl GPR:$b, (i32 16)), (i32 16))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1674 | (SMULBB GPR:$a, GPR:$b)>; |
| 1675 | def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b), |
| 1676 | (SMULBB GPR:$a, GPR:$b)>; |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1677 | def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)), |
| 1678 | (sra GPR:$b, (i32 16))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1679 | (SMULBT GPR:$a, GPR:$b)>; |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1680 | def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1681 | (SMULBT GPR:$a, GPR:$b)>; |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1682 | def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), |
| 1683 | (sra (shl GPR:$b, (i32 16)), (i32 16))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1684 | (SMULTB GPR:$a, GPR:$b)>; |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1685 | def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1686 | (SMULTB GPR:$a, GPR:$b)>; |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1687 | def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))), |
| 1688 | (i32 16)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1689 | (SMULWB GPR:$a, GPR:$b)>; |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1690 | def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1691 | (SMULWB GPR:$a, GPR:$b)>; |
| 1692 | |
| 1693 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1694 | (mul (sra (shl GPR:$a, (i32 16)), (i32 16)), |
| 1695 | (sra (shl GPR:$b, (i32 16)), (i32 16)))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1696 | (SMLABB GPR:$a, GPR:$b, GPR:$acc)>; |
| 1697 | def : ARMV5TEPat<(add GPR:$acc, |
| 1698 | (mul sext_16_node:$a, sext_16_node:$b)), |
| 1699 | (SMLABB GPR:$a, GPR:$b, GPR:$acc)>; |
| 1700 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1701 | (mul (sra (shl GPR:$a, (i32 16)), (i32 16)), |
| 1702 | (sra GPR:$b, (i32 16)))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1703 | (SMLABT GPR:$a, GPR:$b, GPR:$acc)>; |
| 1704 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1705 | (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1706 | (SMLABT GPR:$a, GPR:$b, GPR:$acc)>; |
| 1707 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1708 | (mul (sra GPR:$a, (i32 16)), |
| 1709 | (sra (shl GPR:$b, (i32 16)), (i32 16)))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1710 | (SMLATB GPR:$a, GPR:$b, GPR:$acc)>; |
| 1711 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1712 | (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1713 | (SMLATB GPR:$a, GPR:$b, GPR:$acc)>; |
| 1714 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1715 | (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))), |
| 1716 | (i32 16))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1717 | (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>; |
| 1718 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 74590a0 | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1719 | (sra (mul GPR:$a, sext_16_node:$b), (i32 16))), |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1720 | (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>; |
| 1721 | |
| 1722 | //===----------------------------------------------------------------------===// |
| 1723 | // Thumb Support |
| 1724 | // |
| 1725 | |
| 1726 | include "ARMInstrThumb.td" |
| 1727 | |
| 1728 | //===----------------------------------------------------------------------===// |
Anton Korobeynikov | ac869fc | 2009-06-17 18:13:58 +0000 | [diff] [blame] | 1729 | // Thumb2 Support |
| 1730 | // |
| 1731 | |
| 1732 | include "ARMInstrThumb2.td" |
| 1733 | |
| 1734 | //===----------------------------------------------------------------------===// |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1735 | // Floating Point Support |
| 1736 | // |
| 1737 | |
| 1738 | include "ARMInstrVFP.td" |
Bob Wilson | e60fee0 | 2009-06-22 23:27:02 +0000 | [diff] [blame] | 1739 | |
| 1740 | //===----------------------------------------------------------------------===// |
| 1741 | // Advanced SIMD (NEON) Support |
| 1742 | // |
| 1743 | |
| 1744 | include "ARMInstrNEON.td" |