Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1 | //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===// |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +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 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 14 | //===----------------------------------------------------------------------===// |
| 15 | // ARM specific DAG Nodes. |
| 16 | // |
Rafael Espindola | 7cca7c5 | 2006-09-11 17:25:40 +0000 | [diff] [blame] | 17 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 18 | // Type profiles. |
Bill Wendling | c69107c | 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> ]>; |
Rafael Espindola | 6e8c649 | 2006-11-08 17:07:32 +0000 | [diff] [blame] | 21 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 22 | def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>; |
Rafael Espindola | 32bd5f4 | 2006-10-17 18:04:53 +0000 | [diff] [blame] | 23 | |
Chris Lattner | d10a53d | 2010-03-08 18:51:21 +0000 | [diff] [blame] | 24 | def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>; |
Rafael Espindola | 7cca7c5 | 2006-09-11 17:25:40 +0000 | [diff] [blame] | 25 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 26 | def SDT_ARMCMov : SDTypeProfile<1, 3, |
| 27 | [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>, |
| 28 | SDTCisVT<3, i32>]>; |
Rafael Espindola | 6e8c649 | 2006-11-08 17:07:32 +0000 | [diff] [blame] | 29 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 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 | 5657c01 | 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 | |
Evan Cheng | 218977b | 2010-07-13 19:27:42 +0000 | [diff] [blame] | 41 | def SDT_ARMBCC_i64 : SDTypeProfile<0, 6, |
| 42 | [SDTCisVT<0, i32>, |
| 43 | SDTCisVT<1, i32>, SDTCisVT<2, i32>, |
| 44 | SDTCisVT<3, i32>, SDTCisVT<4, i32>, |
| 45 | SDTCisVT<5, OtherVT>]>; |
| 46 | |
Bill Wendling | ac3b935 | 2010-08-29 03:02:28 +0000 | [diff] [blame] | 47 | def SDT_ARMAnd : SDTypeProfile<1, 2, |
| 48 | [SDTCisVT<0, i32>, SDTCisVT<1, i32>, |
| 49 | SDTCisVT<2, i32>]>; |
| 50 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 51 | def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>; |
| 52 | |
| 53 | def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>, |
| 54 | SDTCisPtrTy<1>, SDTCisVT<2, i32>]>; |
| 55 | |
Lauro Ramos Venancio | 64f4fa5 | 2007-04-27 13:54:47 +0000 | [diff] [blame] | 56 | def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; |
Jim Grosbach | a87ded2 | 2010-02-08 23:22:00 +0000 | [diff] [blame] | 57 | def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>, |
| 58 | SDTCisInt<2>]>; |
Jim Grosbach | 5eb1951 | 2010-05-22 01:06:18 +0000 | [diff] [blame] | 59 | def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>; |
Lauro Ramos Venancio | 64f4fa5 | 2007-04-27 13:54:47 +0000 | [diff] [blame] | 60 | |
Jim Grosbach | e4ad387 | 2010-10-19 23:27:08 +0000 | [diff] [blame] | 61 | def SDT_ARMEH_SJLJ_DispatchSetup: SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>; |
| 62 | |
Bob Wilson | f74a429 | 2010-10-30 00:54:37 +0000 | [diff] [blame] | 63 | def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>; |
Jim Grosbach | 3728e96 | 2009-12-10 00:11:09 +0000 | [diff] [blame] | 64 | |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 65 | def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>; |
| 66 | |
Jim Grosbach | 469bbdb | 2010-07-16 23:05:05 +0000 | [diff] [blame] | 67 | def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>, |
| 68 | SDTCisVT<2, i32>, SDTCisVT<3, i32>]>; |
| 69 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 70 | // Node definitions. |
| 71 | def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 72 | def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>; |
| 73 | |
Bill Wendling | c69107c | 2007-11-13 09:19:02 +0000 | [diff] [blame] | 74 | def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart, |
Bill Wendling | 6ef781f | 2008-02-27 06:33:05 +0000 | [diff] [blame] | 75 | [SDNPHasChain, SDNPOutFlag]>; |
Bill Wendling | c69107c | 2007-11-13 09:19:02 +0000 | [diff] [blame] | 76 | def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd, |
Bill Wendling | 6ef781f | 2008-02-27 06:33:05 +0000 | [diff] [blame] | 77 | [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 78 | |
| 79 | def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall, |
Chris Lattner | 60e9eac | 2010-03-19 05:33:51 +0000 | [diff] [blame] | 80 | [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag, |
| 81 | SDNPVariadic]>; |
Evan Cheng | 277f074 | 2007-06-19 21:05:09 +0000 | [diff] [blame] | 82 | def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall, |
Chris Lattner | 60e9eac | 2010-03-19 05:33:51 +0000 | [diff] [blame] | 83 | [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag, |
| 84 | SDNPVariadic]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 85 | def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall, |
Chris Lattner | 60e9eac | 2010-03-19 05:33:51 +0000 | [diff] [blame] | 86 | [SDNPHasChain, SDNPOptInFlag, SDNPOutFlag, |
| 87 | SDNPVariadic]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 88 | |
Chris Lattner | 48be23c | 2008-01-15 22:02:54 +0000 | [diff] [blame] | 89 | def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone, |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 90 | [SDNPHasChain, SDNPOptInFlag]>; |
| 91 | |
| 92 | def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov, |
| 93 | [SDNPInFlag]>; |
| 94 | def ARMcneg : SDNode<"ARMISD::CNEG", SDT_ARMCMov, |
| 95 | [SDNPInFlag]>; |
| 96 | |
| 97 | def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond, |
| 98 | [SDNPHasChain, SDNPInFlag, SDNPOutFlag]>; |
| 99 | |
| 100 | def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT, |
| 101 | [SDNPHasChain]>; |
Evan Cheng | 5657c01 | 2009-07-29 02:18:14 +0000 | [diff] [blame] | 102 | def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT, |
| 103 | [SDNPHasChain]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 104 | |
Evan Cheng | 218977b | 2010-07-13 19:27:42 +0000 | [diff] [blame] | 105 | def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64, |
| 106 | [SDNPHasChain]>; |
| 107 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 108 | def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp, |
| 109 | [SDNPOutFlag]>; |
| 110 | |
David Goodwin | c0309b4 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 111 | def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp, |
Bill Wendling | 10ce7f3 | 2010-08-29 11:31:07 +0000 | [diff] [blame] | 112 | [SDNPOutFlag, SDNPCommutative]>; |
Lauro Ramos Venancio | 9996663 | 2007-04-02 01:30:03 +0000 | [diff] [blame] | 113 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 114 | def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>; |
| 115 | |
| 116 | def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>; |
| 117 | def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutFlag]>; |
| 118 | def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInFlag ]>; |
Rafael Espindola | 32bd5f4 | 2006-10-17 18:04:53 +0000 | [diff] [blame] | 119 | |
Lauro Ramos Venancio | 64f4fa5 | 2007-04-27 13:54:47 +0000 | [diff] [blame] | 120 | def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>; |
Jim Grosbach | 23ff7cf | 2010-05-26 20:22:18 +0000 | [diff] [blame] | 121 | def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP", |
| 122 | SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>; |
Jim Grosbach | 5eb1951 | 2010-05-22 01:06:18 +0000 | [diff] [blame] | 123 | def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP", |
Jim Grosbach | e4ad387 | 2010-10-19 23:27:08 +0000 | [diff] [blame] | 124 | SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>; |
| 125 | def ARMeh_sjlj_dispatchsetup: SDNode<"ARMISD::EH_SJLJ_DISPATCHSETUP", |
| 126 | SDT_ARMEH_SJLJ_DispatchSetup, [SDNPHasChain]>; |
| 127 | |
Lauro Ramos Venancio | 64f4fa5 | 2007-04-27 13:54:47 +0000 | [diff] [blame] | 128 | |
Evan Cheng | 11db068 | 2010-08-11 06:22:01 +0000 | [diff] [blame] | 129 | def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER, |
| 130 | [SDNPHasChain]>; |
Bob Wilson | f74a429 | 2010-10-30 00:54:37 +0000 | [diff] [blame] | 131 | def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER, |
Evan Cheng | 11db068 | 2010-08-11 06:22:01 +0000 | [diff] [blame] | 132 | [SDNPHasChain]>; |
Jim Grosbach | 3728e96 | 2009-12-10 00:11:09 +0000 | [diff] [blame] | 133 | |
Evan Cheng | f609bb8 | 2010-01-19 00:44:15 +0000 | [diff] [blame] | 134 | def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>; |
| 135 | |
Jim Grosbach | a9a968d | 2010-10-22 23:48:29 +0000 | [diff] [blame] | 136 | def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET, |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 137 | [SDNPHasChain, SDNPOptInFlag, SDNPVariadic]>; |
| 138 | |
Jim Grosbach | 469bbdb | 2010-07-16 23:05:05 +0000 | [diff] [blame] | 139 | |
| 140 | def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>; |
| 141 | |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 142 | //===----------------------------------------------------------------------===// |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 143 | // ARM Instruction Predicate Definitions. |
| 144 | // |
Jim Grosbach | 833c93c | 2010-11-01 16:59:54 +0000 | [diff] [blame] | 145 | def HasV4T : Predicate<"Subtarget->hasV4TOps()">, AssemblerPredicate; |
Bill Wendling | 10ce7f3 | 2010-08-29 11:31:07 +0000 | [diff] [blame] | 146 | def NoV4T : Predicate<"!Subtarget->hasV4TOps()">; |
| 147 | def HasV5T : Predicate<"Subtarget->hasV5TOps()">; |
Jim Grosbach | 833c93c | 2010-11-01 16:59:54 +0000 | [diff] [blame] | 148 | def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">, AssemblerPredicate; |
| 149 | def HasV6 : Predicate<"Subtarget->hasV6Ops()">, AssemblerPredicate; |
| 150 | def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">, AssemblerPredicate; |
Bill Wendling | 10ce7f3 | 2010-08-29 11:31:07 +0000 | [diff] [blame] | 151 | def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">; |
Jim Grosbach | 833c93c | 2010-11-01 16:59:54 +0000 | [diff] [blame] | 152 | def HasV7 : Predicate<"Subtarget->hasV7Ops()">, AssemblerPredicate; |
Bill Wendling | 10ce7f3 | 2010-08-29 11:31:07 +0000 | [diff] [blame] | 153 | def NoVFP : Predicate<"!Subtarget->hasVFP2()">; |
Jim Grosbach | 833c93c | 2010-11-01 16:59:54 +0000 | [diff] [blame] | 154 | def HasVFP2 : Predicate<"Subtarget->hasVFP2()">, AssemblerPredicate; |
| 155 | def HasVFP3 : Predicate<"Subtarget->hasVFP3()">, AssemblerPredicate; |
| 156 | def HasNEON : Predicate<"Subtarget->hasNEON()">, AssemblerPredicate; |
| 157 | def HasDivide : Predicate<"Subtarget->hasDivide()">, AssemblerPredicate; |
| 158 | def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">, |
| 159 | AssemblerPredicate; |
| 160 | def HasDB : Predicate<"Subtarget->hasDataBarrier()">, |
| 161 | AssemblerPredicate; |
Bill Wendling | 10ce7f3 | 2010-08-29 11:31:07 +0000 | [diff] [blame] | 162 | def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">; |
David Goodwin | 42a83f2 | 2009-08-04 17:53:06 +0000 | [diff] [blame] | 163 | def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">; |
Jim Grosbach | 833c93c | 2010-11-01 16:59:54 +0000 | [diff] [blame] | 164 | def IsThumb : Predicate<"Subtarget->isThumb()">, AssemblerPredicate; |
Bill Wendling | 10ce7f3 | 2010-08-29 11:31:07 +0000 | [diff] [blame] | 165 | def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">; |
Jim Grosbach | 833c93c | 2010-11-01 16:59:54 +0000 | [diff] [blame] | 166 | def IsThumb2 : Predicate<"Subtarget->isThumb2()">, AssemblerPredicate; |
| 167 | def IsARM : Predicate<"!Subtarget->isThumb()">, AssemblerPredicate; |
Bill Wendling | 10ce7f3 | 2010-08-29 11:31:07 +0000 | [diff] [blame] | 168 | def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">; |
| 169 | def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 170 | |
Anton Korobeynikov | 5cdc3a9 | 2009-11-24 00:44:37 +0000 | [diff] [blame] | 171 | // FIXME: Eventually this will be just "hasV6T2Ops". |
Bill Wendling | 10ce7f3 | 2010-08-29 11:31:07 +0000 | [diff] [blame] | 172 | def UseMovt : Predicate<"Subtarget->useMovt()">; |
| 173 | def DontUseMovt : Predicate<"!Subtarget->useMovt()">; |
| 174 | def UseVMLx : Predicate<"Subtarget->useVMLx()">; |
Jim Grosbach | 2676737 | 2010-03-24 22:31:46 +0000 | [diff] [blame] | 175 | |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 176 | //===----------------------------------------------------------------------===// |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 177 | // ARM Flag Definitions. |
| 178 | |
| 179 | class RegConstraint<string C> { |
| 180 | string Constraints = C; |
| 181 | } |
| 182 | |
| 183 | //===----------------------------------------------------------------------===// |
| 184 | // ARM specific transformation functions and pattern fragments. |
| 185 | // |
| 186 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 187 | // so_imm_neg_XFORM - Return a so_imm value packed into the format described for |
| 188 | // so_imm_neg def below. |
| 189 | def so_imm_neg_XFORM : SDNodeXForm<imm, [{ |
Owen Anderson | 825b72b | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 190 | return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32); |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 191 | }]>; |
| 192 | |
| 193 | // so_imm_not_XFORM - Return a so_imm value packed into the format described for |
| 194 | // so_imm_not def below. |
| 195 | def so_imm_not_XFORM : SDNodeXForm<imm, [{ |
Owen Anderson | 825b72b | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 196 | return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32); |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 197 | }]>; |
| 198 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 199 | /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15]. |
| 200 | def imm1_15 : PatLeaf<(i32 imm), [{ |
Dan Gohman | f5aeb1a | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 201 | return (int32_t)N->getZExtValue() >= 1 && (int32_t)N->getZExtValue() < 16; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 202 | }]>; |
| 203 | |
| 204 | /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31]. |
| 205 | def imm16_31 : PatLeaf<(i32 imm), [{ |
Dan Gohman | f5aeb1a | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 206 | return (int32_t)N->getZExtValue() >= 16 && (int32_t)N->getZExtValue() < 32; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 207 | }]>; |
| 208 | |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 209 | def so_imm_neg : |
Dan Gohman | f5aeb1a | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 210 | PatLeaf<(imm), [{ |
| 211 | return ARM_AM::getSOImmVal(-(int)N->getZExtValue()) != -1; |
| 212 | }], so_imm_neg_XFORM>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 213 | |
Evan Cheng | a251570 | 2007-03-19 07:09:02 +0000 | [diff] [blame] | 214 | def so_imm_not : |
Dan Gohman | f5aeb1a | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 215 | PatLeaf<(imm), [{ |
| 216 | return ARM_AM::getSOImmVal(~(int)N->getZExtValue()) != -1; |
| 217 | }], so_imm_not_XFORM>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 218 | |
| 219 | // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits. |
| 220 | def sext_16_node : PatLeaf<(i32 GPR:$a), [{ |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 221 | return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 222 | }]>; |
| 223 | |
Evan Cheng | 36a0aeb | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 224 | /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield |
| 225 | /// e.g., 0xf000ffff |
| 226 | def bf_inv_mask_imm : Operand<i32>, |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 227 | PatLeaf<(imm), [{ |
Jim Grosbach | 469bbdb | 2010-07-16 23:05:05 +0000 | [diff] [blame] | 228 | return ARM::isBitFieldInvertedMask(N->getZExtValue()); |
Evan Cheng | 36a0aeb | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 229 | }] > { |
Jim Grosbach | 3fea19105 | 2010-10-21 22:03:21 +0000 | [diff] [blame] | 230 | string EncoderMethod = "getBitfieldInvertedMaskOpValue"; |
Evan Cheng | 36a0aeb | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 231 | let PrintMethod = "printBitfieldInvMaskImmOperand"; |
| 232 | } |
| 233 | |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 234 | /// Split a 32-bit immediate into two 16 bit parts. |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 235 | def hi16 : SDNodeXForm<imm, [{ |
| 236 | return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32); |
| 237 | }]>; |
| 238 | |
| 239 | def lo16AllZero : PatLeaf<(i32 imm), [{ |
| 240 | // Returns true if all low 16-bits are 0. |
| 241 | return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0; |
Anton Korobeynikov | 5cdc3a9 | 2009-11-24 00:44:37 +0000 | [diff] [blame] | 242 | }], hi16>; |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 243 | |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 244 | /// imm0_65535 predicate - True if the 32-bit immediate is in the range |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 245 | /// [0.65535]. |
| 246 | def imm0_65535 : PatLeaf<(i32 imm), [{ |
| 247 | return (uint32_t)N->getZExtValue() < 65536; |
| 248 | }]>; |
| 249 | |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 250 | class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>; |
| 251 | class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 252 | |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 253 | /// adde and sube predicates - True based on whether the carry flag output |
| 254 | /// will be needed or not. |
| 255 | def adde_dead_carry : |
| 256 | PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS), |
| 257 | [{return !N->hasAnyUseOfValue(1);}]>; |
| 258 | def sube_dead_carry : |
| 259 | PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS), |
| 260 | [{return !N->hasAnyUseOfValue(1);}]>; |
| 261 | def adde_live_carry : |
| 262 | PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS), |
| 263 | [{return N->hasAnyUseOfValue(1);}]>; |
| 264 | def sube_live_carry : |
| 265 | PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS), |
| 266 | [{return N->hasAnyUseOfValue(1);}]>; |
| 267 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 268 | //===----------------------------------------------------------------------===// |
| 269 | // Operand Definitions. |
| 270 | // |
| 271 | |
| 272 | // Branch target. |
| 273 | def brtarget : Operand<OtherVT>; |
| 274 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 275 | // A list of registers separated by comma. Used by load/store multiple. |
| 276 | def reglist : Operand<i32> { |
Jim Grosbach | 6b5252d | 2010-10-30 00:37:59 +0000 | [diff] [blame] | 277 | string EncoderMethod = "getRegisterListOpValue"; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 278 | let PrintMethod = "printRegisterList"; |
| 279 | } |
| 280 | |
| 281 | // An operand for the CONSTPOOL_ENTRY pseudo-instruction. |
| 282 | def cpinst_operand : Operand<i32> { |
| 283 | let PrintMethod = "printCPInstOperand"; |
| 284 | } |
| 285 | |
| 286 | def jtblock_operand : Operand<i32> { |
| 287 | let PrintMethod = "printJTBlockOperand"; |
| 288 | } |
Evan Cheng | 66ac531 | 2009-07-25 00:33:29 +0000 | [diff] [blame] | 289 | def jt2block_operand : Operand<i32> { |
| 290 | let PrintMethod = "printJT2BlockOperand"; |
| 291 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 292 | |
| 293 | // Local PC labels. |
| 294 | def pclabel : Operand<i32> { |
| 295 | let PrintMethod = "printPCLabel"; |
| 296 | } |
| 297 | |
Owen Anderson | 498ec20 | 2010-10-27 22:49:00 +0000 | [diff] [blame] | 298 | def neon_vcvt_imm32 : Operand<i32> { |
Jim Grosbach | 0d2d2e9 | 2010-10-29 23:19:55 +0000 | [diff] [blame] | 299 | string EncoderMethod = "getNEONVcvtImm32OpValue"; |
Owen Anderson | 498ec20 | 2010-10-27 22:49:00 +0000 | [diff] [blame] | 300 | } |
| 301 | |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 302 | // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24. |
| 303 | def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{ |
| 304 | int32_t v = (int32_t)N->getZExtValue(); |
| 305 | return v == 8 || v == 16 || v == 24; }]> { |
| 306 | string EncoderMethod = "getRotImmOpValue"; |
| 307 | } |
| 308 | |
Bob Wilson | 22f5dc7 | 2010-08-16 18:27:34 +0000 | [diff] [blame] | 309 | // shift_imm: An integer that encodes a shift amount and the type of shift |
| 310 | // (currently either asr or lsl) using the same encoding used for the |
| 311 | // immediates in so_reg operands. |
| 312 | def shift_imm : Operand<i32> { |
| 313 | let PrintMethod = "printShiftImmOperand"; |
| 314 | } |
| 315 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 316 | // shifter_operand operands: so_reg and so_imm. |
| 317 | def so_reg : Operand<i32>, // reg reg imm |
Bob Wilson | 226036e | 2010-03-20 22:13:40 +0000 | [diff] [blame] | 318 | ComplexPattern<i32, 3, "SelectShifterOperandReg", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 319 | [shl,srl,sra,rotr]> { |
Jim Grosbach | ef324d7 | 2010-10-12 23:53:58 +0000 | [diff] [blame] | 320 | string EncoderMethod = "getSORegOpValue"; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 321 | let PrintMethod = "printSORegOperand"; |
| 322 | let MIOperandInfo = (ops GPR, GPR, i32imm); |
| 323 | } |
Evan Cheng | f40deed | 2010-10-27 23:41:30 +0000 | [diff] [blame] | 324 | def shift_so_reg : Operand<i32>, // reg reg imm |
| 325 | ComplexPattern<i32, 3, "SelectShiftShifterOperandReg", |
| 326 | [shl,srl,sra,rotr]> { |
| 327 | string EncoderMethod = "getSORegOpValue"; |
| 328 | let PrintMethod = "printSORegOperand"; |
| 329 | let MIOperandInfo = (ops GPR, GPR, i32imm); |
| 330 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 331 | |
| 332 | // so_imm - Match a 32-bit shifter_operand immediate operand, which is an |
| 333 | // 8-bit immediate rotated by an arbitrary number of bits. so_imm values are |
| 334 | // represented in the imm field in the same 12-bit form that they are encoded |
| 335 | // into so_imm instructions: the 8-bit immediate is the least significant bits |
| 336 | // [bits 0-7], the 4-bit shift amount is the next 4 bits [bits 8-11]. |
Jakob Stoklund Olesen | 00d3dda | 2010-08-17 20:39:04 +0000 | [diff] [blame] | 337 | def so_imm : Operand<i32>, PatLeaf<(imm), [{ return Pred_so_imm(N); }]> { |
Jim Grosbach | 2a6a93d | 2010-10-12 23:18:08 +0000 | [diff] [blame] | 338 | string EncoderMethod = "getSOImmOpValue"; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 339 | let PrintMethod = "printSOImmOperand"; |
| 340 | } |
| 341 | |
Evan Cheng | c70d184 | 2007-03-20 08:11:30 +0000 | [diff] [blame] | 342 | // Break so_imm's up into two pieces. This handles immediates with up to 16 |
| 343 | // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to |
| 344 | // get the first/second pieces. |
| 345 | def so_imm2part : Operand<i32>, |
Dan Gohman | f5aeb1a | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 346 | PatLeaf<(imm), [{ |
| 347 | return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue()); |
| 348 | }]> { |
Evan Cheng | c70d184 | 2007-03-20 08:11:30 +0000 | [diff] [blame] | 349 | let PrintMethod = "printSOImm2PartOperand"; |
| 350 | } |
| 351 | |
| 352 | def so_imm2part_1 : SDNodeXForm<imm, [{ |
Dan Gohman | f5aeb1a | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 353 | unsigned V = ARM_AM::getSOImmTwoPartFirst((unsigned)N->getZExtValue()); |
Owen Anderson | 825b72b | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 354 | return CurDAG->getTargetConstant(V, MVT::i32); |
Evan Cheng | c70d184 | 2007-03-20 08:11:30 +0000 | [diff] [blame] | 355 | }]>; |
| 356 | |
| 357 | def so_imm2part_2 : SDNodeXForm<imm, [{ |
Dan Gohman | f5aeb1a | 2008-09-12 16:56:44 +0000 | [diff] [blame] | 358 | unsigned V = ARM_AM::getSOImmTwoPartSecond((unsigned)N->getZExtValue()); |
Owen Anderson | 825b72b | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 359 | return CurDAG->getTargetConstant(V, MVT::i32); |
Evan Cheng | c70d184 | 2007-03-20 08:11:30 +0000 | [diff] [blame] | 360 | }]>; |
| 361 | |
Jim Grosbach | 15e6ef8 | 2009-11-23 20:35:53 +0000 | [diff] [blame] | 362 | def so_neg_imm2part : Operand<i32>, PatLeaf<(imm), [{ |
| 363 | return ARM_AM::isSOImmTwoPartVal(-(int)N->getZExtValue()); |
| 364 | }]> { |
| 365 | let PrintMethod = "printSOImm2PartOperand"; |
| 366 | } |
| 367 | |
| 368 | def so_neg_imm2part_1 : SDNodeXForm<imm, [{ |
| 369 | unsigned V = ARM_AM::getSOImmTwoPartFirst(-(int)N->getZExtValue()); |
| 370 | return CurDAG->getTargetConstant(V, MVT::i32); |
| 371 | }]>; |
| 372 | |
| 373 | def so_neg_imm2part_2 : SDNodeXForm<imm, [{ |
| 374 | unsigned V = ARM_AM::getSOImmTwoPartSecond(-(int)N->getZExtValue()); |
| 375 | return CurDAG->getTargetConstant(V, MVT::i32); |
| 376 | }]>; |
| 377 | |
Sandeep Patel | 47eedaa | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 378 | /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31]. |
| 379 | def imm0_31 : Operand<i32>, PatLeaf<(imm), [{ |
| 380 | return (int32_t)N->getZExtValue() < 32; |
| 381 | }]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 382 | |
Jim Grosbach | 8abe32a | 2010-10-15 17:15:16 +0000 | [diff] [blame] | 383 | /// imm0_31_m1 - Matches and prints like imm0_31, but encodes as 'value - 1'. |
| 384 | def imm0_31_m1 : Operand<i32>, PatLeaf<(imm), [{ |
| 385 | return (int32_t)N->getZExtValue() < 32; |
| 386 | }]> { |
| 387 | string EncoderMethod = "getImmMinusOneOpValue"; |
| 388 | } |
| 389 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 390 | // Define ARM specific addressing modes. |
| 391 | |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 392 | |
| 393 | // addrmode_imm12 := reg +/- imm12 |
Jim Grosbach | 8289162 | 2010-09-29 19:03:54 +0000 | [diff] [blame] | 394 | // |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 395 | def addrmode_imm12 : Operand<i32>, |
| 396 | ComplexPattern<i32, 2, "SelectAddrModeImm12", []> { |
Jim Grosbach | ab682a2 | 2010-10-28 18:34:10 +0000 | [diff] [blame] | 397 | // 12-bit immediate operand. Note that instructions using this encode |
| 398 | // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other |
| 399 | // immediate values are as normal. |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 400 | |
| 401 | string EncoderMethod = "getAddrModeImm12OpValue"; |
| 402 | let PrintMethod = "printAddrModeImm12Operand"; |
| 403 | let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm); |
Jim Grosbach | 8289162 | 2010-09-29 19:03:54 +0000 | [diff] [blame] | 404 | } |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 405 | // ldst_so_reg := reg +/- reg shop imm |
Jim Grosbach | 8289162 | 2010-09-29 19:03:54 +0000 | [diff] [blame] | 406 | // |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 407 | def ldst_so_reg : Operand<i32>, |
| 408 | ComplexPattern<i32, 3, "SelectLdStSOReg", []> { |
| 409 | // FIXME: Simplify the printer |
Jim Grosbach | f31430f | 2010-10-27 19:55:59 +0000 | [diff] [blame] | 410 | // FIXME: Add EncoderMethod for this addressing mode |
Jim Grosbach | 8289162 | 2010-09-29 19:03:54 +0000 | [diff] [blame] | 411 | let PrintMethod = "printAddrMode2Operand"; |
| 412 | let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm); |
| 413 | } |
| 414 | |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 415 | // addrmode2 := reg +/- imm12 |
| 416 | // := reg +/- reg shop imm |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 417 | // |
| 418 | def addrmode2 : Operand<i32>, |
| 419 | ComplexPattern<i32, 3, "SelectAddrMode2", []> { |
| 420 | let PrintMethod = "printAddrMode2Operand"; |
| 421 | let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm); |
| 422 | } |
| 423 | |
| 424 | def am2offset : Operand<i32>, |
Chris Lattner | 52a261b | 2010-09-21 20:31:19 +0000 | [diff] [blame] | 425 | ComplexPattern<i32, 2, "SelectAddrMode2Offset", |
| 426 | [], [SDNPWantRoot]> { |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 427 | let PrintMethod = "printAddrMode2OffsetOperand"; |
| 428 | let MIOperandInfo = (ops GPR, i32imm); |
| 429 | } |
| 430 | |
| 431 | // addrmode3 := reg +/- reg |
| 432 | // addrmode3 := reg +/- imm8 |
| 433 | // |
| 434 | def addrmode3 : Operand<i32>, |
| 435 | ComplexPattern<i32, 3, "SelectAddrMode3", []> { |
| 436 | let PrintMethod = "printAddrMode3Operand"; |
| 437 | let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm); |
| 438 | } |
| 439 | |
| 440 | def am3offset : Operand<i32>, |
Chris Lattner | 52a261b | 2010-09-21 20:31:19 +0000 | [diff] [blame] | 441 | ComplexPattern<i32, 2, "SelectAddrMode3Offset", |
| 442 | [], [SDNPWantRoot]> { |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 443 | let PrintMethod = "printAddrMode3OffsetOperand"; |
| 444 | let MIOperandInfo = (ops GPR, i32imm); |
| 445 | } |
| 446 | |
| 447 | // addrmode4 := reg, <mode|W> |
| 448 | // |
| 449 | def addrmode4 : Operand<i32>, |
Anton Korobeynikov | baf3108 | 2009-08-08 13:35:48 +0000 | [diff] [blame] | 450 | ComplexPattern<i32, 2, "SelectAddrMode4", []> { |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 451 | let PrintMethod = "printAddrMode4Operand"; |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 452 | let MIOperandInfo = (ops GPR:$addr, i32imm); |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 453 | } |
| 454 | |
Chris Lattner | 14b9385 | 2010-10-29 00:27:31 +0000 | [diff] [blame] | 455 | def ARMMemMode5AsmOperand : AsmOperandClass { |
| 456 | let Name = "MemMode5"; |
| 457 | let SuperClasses = []; |
| 458 | } |
| 459 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 460 | // addrmode5 := reg +/- imm8*4 |
| 461 | // |
| 462 | def addrmode5 : Operand<i32>, |
| 463 | ComplexPattern<i32, 2, "SelectAddrMode5", []> { |
| 464 | let PrintMethod = "printAddrMode5Operand"; |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 465 | let MIOperandInfo = (ops GPR:$base, i32imm); |
Chris Lattner | 14b9385 | 2010-10-29 00:27:31 +0000 | [diff] [blame] | 466 | let ParserMatchClass = ARMMemMode5AsmOperand; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 467 | } |
| 468 | |
Bob Wilson | 8b024a5 | 2009-07-01 23:16:05 +0000 | [diff] [blame] | 469 | // addrmode6 := reg with optional writeback |
| 470 | // |
| 471 | def addrmode6 : Operand<i32>, |
Bob Wilson | 665814b | 2010-11-01 23:40:51 +0000 | [diff] [blame] | 472 | ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{ |
Bob Wilson | 8b024a5 | 2009-07-01 23:16:05 +0000 | [diff] [blame] | 473 | let PrintMethod = "printAddrMode6Operand"; |
Bob Wilson | 226036e | 2010-03-20 22:13:40 +0000 | [diff] [blame] | 474 | let MIOperandInfo = (ops GPR:$addr, i32imm); |
Owen Anderson | a2b50b3 | 2010-11-02 22:28:01 +0000 | [diff] [blame^] | 475 | string EncoderMethod = "getAddrMode6AddressOpValue"; |
Bob Wilson | 226036e | 2010-03-20 22:13:40 +0000 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | def am6offset : Operand<i32> { |
| 479 | let PrintMethod = "printAddrMode6OffsetOperand"; |
| 480 | let MIOperandInfo = (ops GPR); |
Owen Anderson | a2b50b3 | 2010-11-02 22:28:01 +0000 | [diff] [blame^] | 481 | string EncoderMethod = "getAddrMode6OffsetOpValue"; |
Bob Wilson | 8b024a5 | 2009-07-01 23:16:05 +0000 | [diff] [blame] | 482 | } |
| 483 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 484 | // addrmodepc := pc + reg |
| 485 | // |
| 486 | def addrmodepc : Operand<i32>, |
| 487 | ComplexPattern<i32, 2, "SelectAddrModePC", []> { |
| 488 | let PrintMethod = "printAddrModePCOperand"; |
| 489 | let MIOperandInfo = (ops GPR, i32imm); |
| 490 | } |
| 491 | |
Bob Wilson | 4f38b38 | 2009-08-21 21:58:55 +0000 | [diff] [blame] | 492 | def nohash_imm : Operand<i32> { |
| 493 | let PrintMethod = "printNoHashImmediate"; |
Anton Korobeynikov | 8e9ece7 | 2009-08-08 23:10:41 +0000 | [diff] [blame] | 494 | } |
| 495 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 496 | //===----------------------------------------------------------------------===// |
Evan Cheng | 0ff94f7 | 2007-08-07 01:37:15 +0000 | [diff] [blame] | 497 | |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 498 | include "ARMInstrFormats.td" |
Evan Cheng | 0ff94f7 | 2007-08-07 01:37:15 +0000 | [diff] [blame] | 499 | |
| 500 | //===----------------------------------------------------------------------===// |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 501 | // Multiclass helpers... |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 502 | // |
| 503 | |
Evan Cheng | 3924f78 | 2008-08-29 07:36:24 +0000 | [diff] [blame] | 504 | /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 505 | /// binop that produces a value. |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 506 | multiclass AsI1_bin_irs<bits<4> opcod, string opc, |
| 507 | InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, |
| 508 | PatFrag opnode, bit Commutable = 0> { |
Jim Grosbach | 663e339 | 2010-08-30 19:49:58 +0000 | [diff] [blame] | 509 | // The register-immediate version is re-materializable. This is useful |
| 510 | // in particular for taking the address of a local. |
| 511 | let isReMaterializable = 1 in { |
Jim Grosbach | 0de6ab3 | 2010-10-12 17:11:26 +0000 | [diff] [blame] | 512 | def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm, |
| 513 | iii, opc, "\t$Rd, $Rn, $imm", |
| 514 | [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> { |
| 515 | bits<4> Rd; |
| 516 | bits<4> Rn; |
Jim Grosbach | 2a6a93d | 2010-10-12 23:18:08 +0000 | [diff] [blame] | 517 | bits<12> imm; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 518 | let Inst{25} = 1; |
Jim Grosbach | 0de6ab3 | 2010-10-12 17:11:26 +0000 | [diff] [blame] | 519 | let Inst{19-16} = Rn; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 520 | let Inst{15-12} = Rd; |
Jim Grosbach | 2a6a93d | 2010-10-12 23:18:08 +0000 | [diff] [blame] | 521 | let Inst{11-0} = imm; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 522 | } |
Jim Grosbach | 663e339 | 2010-08-30 19:49:58 +0000 | [diff] [blame] | 523 | } |
Jim Grosbach | 6254726 | 2010-10-11 18:51:51 +0000 | [diff] [blame] | 524 | def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, |
| 525 | iir, opc, "\t$Rd, $Rn, $Rm", |
| 526 | [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> { |
Jim Grosbach | 56ac907 | 2010-10-08 21:45:55 +0000 | [diff] [blame] | 527 | bits<4> Rd; |
| 528 | bits<4> Rn; |
| 529 | bits<4> Rm; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 530 | let Inst{25} = 0; |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 531 | let isCommutable = Commutable; |
Jim Grosbach | 56ac907 | 2010-10-08 21:45:55 +0000 | [diff] [blame] | 532 | let Inst{19-16} = Rn; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 533 | let Inst{15-12} = Rd; |
| 534 | let Inst{11-4} = 0b00000000; |
| 535 | let Inst{3-0} = Rm; |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 536 | } |
Jim Grosbach | ef324d7 | 2010-10-12 23:53:58 +0000 | [diff] [blame] | 537 | def rs : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm, |
| 538 | iis, opc, "\t$Rd, $Rn, $shift", |
| 539 | [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]> { |
Jim Grosbach | 42fac8e | 2010-10-11 23:16:21 +0000 | [diff] [blame] | 540 | bits<4> Rd; |
| 541 | bits<4> Rn; |
Jim Grosbach | ef324d7 | 2010-10-12 23:53:58 +0000 | [diff] [blame] | 542 | bits<12> shift; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 543 | let Inst{25} = 0; |
Jim Grosbach | 42fac8e | 2010-10-11 23:16:21 +0000 | [diff] [blame] | 544 | let Inst{19-16} = Rn; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 545 | let Inst{15-12} = Rd; |
| 546 | let Inst{11-0} = shift; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 547 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 548 | } |
| 549 | |
Evan Cheng | 1e249e3 | 2009-06-25 20:59:23 +0000 | [diff] [blame] | 550 | /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the |
Bob Wilson | a3e8bf8 | 2009-10-06 20:18:46 +0000 | [diff] [blame] | 551 | /// instruction modifies the CPSR register. |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 552 | let Defs = [CPSR] in { |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 553 | multiclass AI1_bin_s_irs<bits<4> opcod, string opc, |
| 554 | InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, |
| 555 | PatFrag opnode, bit Commutable = 0> { |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 556 | def ri : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm, |
| 557 | iii, opc, "\t$Rd, $Rn, $imm", |
| 558 | [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> { |
| 559 | bits<4> Rd; |
| 560 | bits<4> Rn; |
| 561 | bits<12> imm; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 562 | let Inst{25} = 1; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 563 | let Inst{20} = 1; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 564 | let Inst{19-16} = Rn; |
| 565 | let Inst{15-12} = Rd; |
| 566 | let Inst{11-0} = imm; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 567 | } |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 568 | def rr : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, |
| 569 | iir, opc, "\t$Rd, $Rn, $Rm", |
| 570 | [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> { |
| 571 | bits<4> Rd; |
| 572 | bits<4> Rn; |
| 573 | bits<4> Rm; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 574 | let isCommutable = Commutable; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 575 | let Inst{25} = 0; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 576 | let Inst{20} = 1; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 577 | let Inst{19-16} = Rn; |
| 578 | let Inst{15-12} = Rd; |
| 579 | let Inst{11-4} = 0b00000000; |
| 580 | let Inst{3-0} = Rm; |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 581 | } |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 582 | def rs : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm, |
| 583 | iis, opc, "\t$Rd, $Rn, $shift", |
| 584 | [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]> { |
| 585 | bits<4> Rd; |
| 586 | bits<4> Rn; |
| 587 | bits<12> shift; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 588 | let Inst{25} = 0; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 589 | let Inst{20} = 1; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 590 | let Inst{19-16} = Rn; |
| 591 | let Inst{15-12} = Rd; |
| 592 | let Inst{11-0} = shift; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 593 | } |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 594 | } |
Evan Cheng | c85e832 | 2007-07-05 07:13:32 +0000 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test |
Evan Cheng | 13ab020 | 2007-07-10 18:08:01 +0000 | [diff] [blame] | 598 | /// patterns. Similar to AsI1_bin_irs except the instruction does not produce |
Evan Cheng | c85e832 | 2007-07-05 07:13:32 +0000 | [diff] [blame] | 599 | /// a explicit result, only implicitly set CPSR. |
Bill Wendling | 0cce3dd | 2010-08-11 00:22:27 +0000 | [diff] [blame] | 600 | let isCompare = 1, Defs = [CPSR] in { |
Evan Cheng | 5d42c56 | 2010-09-29 00:49:25 +0000 | [diff] [blame] | 601 | multiclass AI1_cmp_irs<bits<4> opcod, string opc, |
| 602 | InstrItinClass iii, InstrItinClass iir, InstrItinClass iis, |
| 603 | PatFrag opnode, bit Commutable = 0> { |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 604 | def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii, |
| 605 | opc, "\t$Rn, $imm", |
| 606 | [(opnode GPR:$Rn, so_imm:$imm)]> { |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 607 | bits<4> Rn; |
| 608 | bits<12> imm; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 609 | let Inst{25} = 1; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 610 | let Inst{20} = 1; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 611 | let Inst{19-16} = Rn; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 612 | let Inst{15-12} = 0b0000; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 613 | let Inst{11-0} = imm; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 614 | } |
| 615 | def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir, |
| 616 | opc, "\t$Rn, $Rm", |
| 617 | [(opnode GPR:$Rn, GPR:$Rm)]> { |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 618 | bits<4> Rn; |
| 619 | bits<4> Rm; |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 620 | let isCommutable = Commutable; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 621 | let Inst{25} = 0; |
Bob Wilson | 5361cd2 | 2009-10-13 17:35:30 +0000 | [diff] [blame] | 622 | let Inst{20} = 1; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 623 | let Inst{19-16} = Rn; |
| 624 | let Inst{15-12} = 0b0000; |
| 625 | let Inst{11-4} = 0b00000000; |
| 626 | let Inst{3-0} = Rm; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 627 | } |
| 628 | def rs : AI1<opcod, (outs), (ins GPR:$Rn, so_reg:$shift), DPSoRegFrm, iis, |
| 629 | opc, "\t$Rn, $shift", |
| 630 | [(opnode GPR:$Rn, so_reg:$shift)]> { |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 631 | bits<4> Rn; |
| 632 | bits<12> shift; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 633 | let Inst{25} = 0; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 634 | let Inst{20} = 1; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 635 | let Inst{19-16} = Rn; |
| 636 | let Inst{15-12} = 0b0000; |
| 637 | let Inst{11-0} = shift; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 638 | } |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 639 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 640 | } |
| 641 | |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 642 | /// AI_ext_rrot - A unary operation with two forms: one whose operand is a |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 643 | /// register and one whose operand is a register rotated by 8/16/24. |
Evan Cheng | 97f48c3 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 644 | /// FIXME: Remove the 'r' variant. Its rot_imm is zero. |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 645 | multiclass AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode> { |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 646 | def r : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm), |
| 647 | IIC_iEXTr, opc, "\t$Rd, $Rm", |
| 648 | [(set GPR:$Rd, (opnode GPR:$Rm))]>, |
Evan Cheng | 97f48c3 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 649 | Requires<[IsARM, HasV6]> { |
Jim Grosbach | 197a8df | 2010-10-15 02:29:58 +0000 | [diff] [blame] | 650 | bits<4> Rd; |
| 651 | bits<4> Rm; |
Johnny Chen | 76b39e8 | 2009-10-27 18:44:24 +0000 | [diff] [blame] | 652 | let Inst{19-16} = 0b1111; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 653 | let Inst{15-12} = Rd; |
| 654 | let Inst{11-10} = 0b00; |
| 655 | let Inst{3-0} = Rm; |
Johnny Chen | 76b39e8 | 2009-10-27 18:44:24 +0000 | [diff] [blame] | 656 | } |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 657 | def r_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm, rot_imm:$rot), |
| 658 | IIC_iEXTr, opc, "\t$Rd, $Rm, ror $rot", |
| 659 | [(set GPR:$Rd, (opnode (rotr GPR:$Rm, rot_imm:$rot)))]>, |
Evan Cheng | 97f48c3 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 660 | Requires<[IsARM, HasV6]> { |
Jim Grosbach | 197a8df | 2010-10-15 02:29:58 +0000 | [diff] [blame] | 661 | bits<4> Rd; |
| 662 | bits<4> Rm; |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 663 | bits<2> rot; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 664 | let Inst{19-16} = 0b1111; |
Jim Grosbach | 197a8df | 2010-10-15 02:29:58 +0000 | [diff] [blame] | 665 | let Inst{15-12} = Rd; |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 666 | let Inst{11-10} = rot; |
Jim Grosbach | 197a8df | 2010-10-15 02:29:58 +0000 | [diff] [blame] | 667 | let Inst{3-0} = Rm; |
Johnny Chen | 76b39e8 | 2009-10-27 18:44:24 +0000 | [diff] [blame] | 668 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 669 | } |
| 670 | |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 671 | multiclass AI_ext_rrot_np<bits<8> opcod, string opc> { |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 672 | def r : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm), |
| 673 | IIC_iEXTr, opc, "\t$Rd, $Rm", |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 674 | [/* For disassembly only; pattern left blank */]>, |
| 675 | Requires<[IsARM, HasV6]> { |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 676 | let Inst{19-16} = 0b1111; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 677 | let Inst{11-10} = 0b00; |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 678 | } |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 679 | def r_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rm, rot_imm:$rot), |
| 680 | IIC_iEXTr, opc, "\t$Rd, $Rm, ror $rot", |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 681 | [/* For disassembly only; pattern left blank */]>, |
| 682 | Requires<[IsARM, HasV6]> { |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 683 | bits<2> rot; |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 684 | let Inst{19-16} = 0b1111; |
Jim Grosbach | 28b1082 | 2010-11-02 17:59:04 +0000 | [diff] [blame] | 685 | let Inst{11-10} = rot; |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 686 | } |
| 687 | } |
| 688 | |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 689 | /// AI_exta_rrot - A binary operation with two forms: one whose operand is a |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 690 | /// register and one whose operand is a register rotated by 8/16/24. |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 691 | multiclass AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode> { |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 692 | def rr : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 693 | IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm", |
| 694 | [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>, |
Johnny Chen | 76b39e8 | 2009-10-27 18:44:24 +0000 | [diff] [blame] | 695 | Requires<[IsARM, HasV6]> { |
| 696 | let Inst{11-10} = 0b00; |
| 697 | } |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 698 | def rr_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, |
| 699 | rot_imm:$rot), |
| 700 | IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm, ror $rot", |
| 701 | [(set GPR:$Rd, (opnode GPR:$Rn, |
| 702 | (rotr GPR:$Rm, rot_imm:$rot)))]>, |
| 703 | Requires<[IsARM, HasV6]> { |
| 704 | bits<4> Rn; |
| 705 | bits<2> rot; |
| 706 | let Inst{19-16} = Rn; |
| 707 | let Inst{11-10} = rot; |
| 708 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 709 | } |
| 710 | |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 711 | // For disassembly only. |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 712 | multiclass AI_exta_rrot_np<bits<8> opcod, string opc> { |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 713 | def rr : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 714 | IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm", |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 715 | [/* For disassembly only; pattern left blank */]>, |
| 716 | Requires<[IsARM, HasV6]> { |
| 717 | let Inst{11-10} = 0b00; |
| 718 | } |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 719 | def rr_rot : AExtI<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, |
| 720 | rot_imm:$rot), |
| 721 | IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm, ror $rot", |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 722 | [/* For disassembly only; pattern left blank */]>, |
Jim Grosbach | b35ad41 | 2010-10-13 19:56:10 +0000 | [diff] [blame] | 723 | Requires<[IsARM, HasV6]> { |
| 724 | bits<4> Rn; |
| 725 | bits<2> rot; |
| 726 | let Inst{19-16} = Rn; |
| 727 | let Inst{11-10} = rot; |
| 728 | } |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 729 | } |
| 730 | |
Evan Cheng | 6267422 | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 731 | /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube. |
| 732 | let Uses = [CPSR] in { |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 733 | multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode, |
| 734 | bit Commutable = 0> { |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 735 | def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), |
| 736 | DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm", |
| 737 | [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 738 | Requires<[IsARM]> { |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 739 | bits<4> Rd; |
| 740 | bits<4> Rn; |
| 741 | bits<12> imm; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 742 | let Inst{25} = 1; |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 743 | let Inst{15-12} = Rd; |
| 744 | let Inst{19-16} = Rn; |
| 745 | let Inst{11-0} = imm; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 746 | } |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 747 | def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 748 | DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm", |
| 749 | [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 750 | Requires<[IsARM]> { |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 751 | bits<4> Rd; |
| 752 | bits<4> Rn; |
| 753 | bits<4> Rm; |
Johnny Chen | 0430152 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 754 | let Inst{11-4} = 0b00000000; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 755 | let Inst{25} = 0; |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 756 | let isCommutable = Commutable; |
| 757 | let Inst{3-0} = Rm; |
| 758 | let Inst{15-12} = Rd; |
| 759 | let Inst{19-16} = Rn; |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 760 | } |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 761 | def rs : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), |
| 762 | DPSoRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift", |
| 763 | [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 764 | Requires<[IsARM]> { |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 765 | bits<4> Rd; |
| 766 | bits<4> Rn; |
| 767 | bits<12> shift; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 768 | let Inst{25} = 0; |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 769 | let Inst{11-0} = shift; |
| 770 | let Inst{15-12} = Rd; |
| 771 | let Inst{19-16} = Rn; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 772 | } |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 773 | } |
| 774 | // Carry setting variants |
| 775 | let Defs = [CPSR] in { |
| 776 | multiclass AI1_adde_sube_s_irs<bits<4> opcod, string opc, PatFrag opnode, |
| 777 | bit Commutable = 0> { |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 778 | def Sri : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), |
| 779 | DPFrm, IIC_iALUi, !strconcat(opc, "\t$Rd, $Rn, $imm"), |
| 780 | [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 781 | Requires<[IsARM]> { |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 782 | bits<4> Rd; |
| 783 | bits<4> Rn; |
| 784 | bits<12> imm; |
| 785 | let Inst{15-12} = Rd; |
| 786 | let Inst{19-16} = Rn; |
| 787 | let Inst{11-0} = imm; |
Bob Wilson | 7e053bb | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 788 | let Inst{20} = 1; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 789 | let Inst{25} = 1; |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 790 | } |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 791 | def Srr : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 792 | DPFrm, IIC_iALUr, !strconcat(opc, "\t$Rd, $Rn, $Rm"), |
| 793 | [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 794 | Requires<[IsARM]> { |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 795 | bits<4> Rd; |
| 796 | bits<4> Rn; |
| 797 | bits<4> Rm; |
Johnny Chen | 0430152 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 798 | let Inst{11-4} = 0b00000000; |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 799 | let isCommutable = Commutable; |
| 800 | let Inst{3-0} = Rm; |
| 801 | let Inst{15-12} = Rd; |
| 802 | let Inst{19-16} = Rn; |
Bob Wilson | 7e053bb | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 803 | let Inst{20} = 1; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 804 | let Inst{25} = 0; |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 805 | } |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 806 | def Srs : AXI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), |
| 807 | DPSoRegFrm, IIC_iALUsr, !strconcat(opc, "\t$Rd, $Rn, $shift"), |
| 808 | [(set GPR:$Rd, (opnode GPR:$Rn, so_reg:$shift))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 809 | Requires<[IsARM]> { |
Jim Grosbach | 24989ec | 2010-10-13 18:00:52 +0000 | [diff] [blame] | 810 | bits<4> Rd; |
| 811 | bits<4> Rn; |
| 812 | bits<12> shift; |
| 813 | let Inst{11-0} = shift; |
| 814 | let Inst{15-12} = Rd; |
| 815 | let Inst{19-16} = Rn; |
Bob Wilson | 7e053bb | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 816 | let Inst{20} = 1; |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 817 | let Inst{25} = 0; |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 818 | } |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 819 | } |
Evan Cheng | c85e832 | 2007-07-05 07:13:32 +0000 | [diff] [blame] | 820 | } |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 821 | } |
Evan Cheng | c85e832 | 2007-07-05 07:13:32 +0000 | [diff] [blame] | 822 | |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 823 | let canFoldAsLoad = 1, isReMaterializable = 1 in { |
| 824 | multiclass AI_ldr1<bit opc22, string opc, InstrItinClass iii, |
| 825 | InstrItinClass iir, PatFrag opnode> { |
| 826 | // Note: We use the complex addrmode_imm12 rather than just an input |
| 827 | // GPR and a constrained immediate so that we can use this to match |
| 828 | // frame index references and avoid matching constant pool references. |
Jim Grosbach | 7e3383c | 2010-10-27 23:12:14 +0000 | [diff] [blame] | 829 | def i12 : AIldst1<0b010, opc22, 1, (outs GPR:$Rt), (ins addrmode_imm12:$addr), |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 830 | AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr", |
| 831 | [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> { |
| 832 | bits<4> Rt; |
| 833 | bits<17> addr; |
| 834 | let Inst{23} = addr{12}; // U (add = ('U' == 1)) |
| 835 | let Inst{19-16} = addr{16-13}; // Rn |
| 836 | let Inst{15-12} = Rt; |
| 837 | let Inst{11-0} = addr{11-0}; // imm12 |
| 838 | } |
Jim Grosbach | 7e3383c | 2010-10-27 23:12:14 +0000 | [diff] [blame] | 839 | def rs : AIldst1<0b011, opc22, 1, (outs GPR:$Rt), (ins ldst_so_reg:$shift), |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 840 | AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift", |
| 841 | [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> { |
| 842 | bits<4> Rt; |
| 843 | bits<17> shift; |
| 844 | let Inst{23} = shift{12}; // U (add = ('U' == 1)) |
| 845 | let Inst{19-16} = shift{16-13}; // Rn |
| 846 | let Inst{11-0} = shift{11-0}; |
| 847 | } |
| 848 | } |
| 849 | } |
| 850 | |
Jim Grosbach | 7e3383c | 2010-10-27 23:12:14 +0000 | [diff] [blame] | 851 | multiclass AI_str1<bit opc22, string opc, InstrItinClass iii, |
| 852 | InstrItinClass iir, PatFrag opnode> { |
| 853 | // Note: We use the complex addrmode_imm12 rather than just an input |
| 854 | // GPR and a constrained immediate so that we can use this to match |
| 855 | // frame index references and avoid matching constant pool references. |
| 856 | def i12 : AIldst1<0b010, opc22, 0, (outs), |
| 857 | (ins GPR:$Rt, addrmode_imm12:$addr), |
| 858 | AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr", |
| 859 | [(opnode GPR:$Rt, addrmode_imm12:$addr)]> { |
| 860 | bits<4> Rt; |
| 861 | bits<17> addr; |
| 862 | let Inst{23} = addr{12}; // U (add = ('U' == 1)) |
| 863 | let Inst{19-16} = addr{16-13}; // Rn |
| 864 | let Inst{15-12} = Rt; |
| 865 | let Inst{11-0} = addr{11-0}; // imm12 |
| 866 | } |
| 867 | def rs : AIldst1<0b011, opc22, 0, (outs), (ins GPR:$Rt, ldst_so_reg:$shift), |
| 868 | AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift", |
| 869 | [(opnode GPR:$Rt, ldst_so_reg:$shift)]> { |
| 870 | bits<4> Rt; |
| 871 | bits<17> shift; |
| 872 | let Inst{23} = shift{12}; // U (add = ('U' == 1)) |
| 873 | let Inst{19-16} = shift{16-13}; // Rn |
| 874 | let Inst{11-0} = shift{11-0}; |
| 875 | } |
| 876 | } |
Rafael Espindola | 15a6c3e | 2006-10-16 17:57:20 +0000 | [diff] [blame] | 877 | //===----------------------------------------------------------------------===// |
| 878 | // Instructions |
| 879 | //===----------------------------------------------------------------------===// |
| 880 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 881 | //===----------------------------------------------------------------------===// |
| 882 | // Miscellaneous Instructions. |
| 883 | // |
Rafael Espindola | 6f602de | 2006-08-24 16:13:15 +0000 | [diff] [blame] | 884 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 885 | /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in |
| 886 | /// the function. The first operand is the ID# for this instruction, the second |
| 887 | /// is the index into the MachineConstantPool that this is, the third is the |
| 888 | /// size in bytes of this constant pool entry. |
Evan Cheng | cd799b9 | 2009-06-12 20:46:18 +0000 | [diff] [blame] | 889 | let neverHasSideEffects = 1, isNotDuplicable = 1 in |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 890 | def CONSTPOOL_ENTRY : |
Evan Cheng | 64d80e3 | 2007-07-19 01:14:50 +0000 | [diff] [blame] | 891 | PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx, |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 892 | i32imm:$size), NoItinerary, "", []>; |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 893 | |
Jim Grosbach | 4642ad3 | 2010-02-22 23:10:38 +0000 | [diff] [blame] | 894 | // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE |
| 895 | // from removing one half of the matched pairs. That breaks PEI, which assumes |
| 896 | // these will always be in pairs, and asserts if it finds otherwise. Better way? |
| 897 | let Defs = [SP], Uses = [SP], hasSideEffects = 1 in { |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 898 | def ADJCALLSTACKUP : |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 899 | PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary, "", |
Chris Lattner | e563bbc | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 900 | [(ARMcallseq_end timm:$amt1, timm:$amt2)]>; |
Rafael Espindola | cdda88c | 2006-08-24 17:19:08 +0000 | [diff] [blame] | 901 | |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 902 | def ADJCALLSTACKDOWN : |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 903 | PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary, "", |
Chris Lattner | e563bbc | 2008-10-11 22:08:30 +0000 | [diff] [blame] | 904 | [(ARMcallseq_start timm:$amt)]>; |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 905 | } |
Rafael Espindola | 3c000bf | 2006-08-21 22:00:32 +0000 | [diff] [blame] | 906 | |
Johnny Chen | f4d8105 | 2010-02-12 22:53:19 +0000 | [diff] [blame] | 907 | def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "", |
Johnny Chen | 85d5a89 | 2010-02-10 18:02:25 +0000 | [diff] [blame] | 908 | [/* For disassembly only; pattern left blank */]>, |
| 909 | Requires<[IsARM, HasV6T2]> { |
| 910 | let Inst{27-16} = 0b001100100000; |
Jim Grosbach | fa7d2cb | 2010-10-13 20:30:55 +0000 | [diff] [blame] | 911 | let Inst{15-8} = 0b11110000; |
Johnny Chen | 85d5a89 | 2010-02-10 18:02:25 +0000 | [diff] [blame] | 912 | let Inst{7-0} = 0b00000000; |
| 913 | } |
| 914 | |
Johnny Chen | f4d8105 | 2010-02-12 22:53:19 +0000 | [diff] [blame] | 915 | def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "", |
| 916 | [/* For disassembly only; pattern left blank */]>, |
| 917 | Requires<[IsARM, HasV6T2]> { |
| 918 | let Inst{27-16} = 0b001100100000; |
Jim Grosbach | fa7d2cb | 2010-10-13 20:30:55 +0000 | [diff] [blame] | 919 | let Inst{15-8} = 0b11110000; |
Johnny Chen | f4d8105 | 2010-02-12 22:53:19 +0000 | [diff] [blame] | 920 | let Inst{7-0} = 0b00000001; |
| 921 | } |
| 922 | |
| 923 | def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "", |
| 924 | [/* For disassembly only; pattern left blank */]>, |
| 925 | Requires<[IsARM, HasV6T2]> { |
| 926 | let Inst{27-16} = 0b001100100000; |
Jim Grosbach | fa7d2cb | 2010-10-13 20:30:55 +0000 | [diff] [blame] | 927 | let Inst{15-8} = 0b11110000; |
Johnny Chen | f4d8105 | 2010-02-12 22:53:19 +0000 | [diff] [blame] | 928 | let Inst{7-0} = 0b00000010; |
| 929 | } |
| 930 | |
| 931 | def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "", |
| 932 | [/* For disassembly only; pattern left blank */]>, |
| 933 | Requires<[IsARM, HasV6T2]> { |
| 934 | let Inst{27-16} = 0b001100100000; |
Jim Grosbach | fa7d2cb | 2010-10-13 20:30:55 +0000 | [diff] [blame] | 935 | let Inst{15-8} = 0b11110000; |
Johnny Chen | f4d8105 | 2010-02-12 22:53:19 +0000 | [diff] [blame] | 936 | let Inst{7-0} = 0b00000011; |
| 937 | } |
| 938 | |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 939 | def SEL : AI<(outs GPR:$dst), (ins GPR:$a, GPR:$b), DPFrm, NoItinerary, "sel", |
| 940 | "\t$dst, $a, $b", |
| 941 | [/* For disassembly only; pattern left blank */]>, |
| 942 | Requires<[IsARM, HasV6]> { |
Jim Grosbach | fa7d2cb | 2010-10-13 20:30:55 +0000 | [diff] [blame] | 943 | bits<4> Rd; |
| 944 | bits<4> Rn; |
| 945 | bits<4> Rm; |
| 946 | let Inst{3-0} = Rm; |
| 947 | let Inst{15-12} = Rd; |
| 948 | let Inst{19-16} = Rn; |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 949 | let Inst{27-20} = 0b01101000; |
| 950 | let Inst{7-4} = 0b1011; |
Jim Grosbach | fa7d2cb | 2010-10-13 20:30:55 +0000 | [diff] [blame] | 951 | let Inst{11-8} = 0b1111; |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 952 | } |
| 953 | |
Johnny Chen | f4d8105 | 2010-02-12 22:53:19 +0000 | [diff] [blame] | 954 | def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "", |
| 955 | [/* For disassembly only; pattern left blank */]>, |
| 956 | Requires<[IsARM, HasV6T2]> { |
| 957 | let Inst{27-16} = 0b001100100000; |
Jim Grosbach | fa7d2cb | 2010-10-13 20:30:55 +0000 | [diff] [blame] | 958 | let Inst{15-8} = 0b11110000; |
Johnny Chen | f4d8105 | 2010-02-12 22:53:19 +0000 | [diff] [blame] | 959 | let Inst{7-0} = 0b00000100; |
| 960 | } |
| 961 | |
Johnny Chen | c6f7b27 | 2010-02-11 18:12:29 +0000 | [diff] [blame] | 962 | // The i32imm operand $val can be used by a debugger to store more information |
| 963 | // about the breakpoint. |
Johnny Chen | f4d8105 | 2010-02-12 22:53:19 +0000 | [diff] [blame] | 964 | def BKPT : AI<(outs), (ins i32imm:$val), MiscFrm, NoItinerary, "bkpt", "\t$val", |
Johnny Chen | c6f7b27 | 2010-02-11 18:12:29 +0000 | [diff] [blame] | 965 | [/* For disassembly only; pattern left blank */]>, |
| 966 | Requires<[IsARM]> { |
Jim Grosbach | fa7d2cb | 2010-10-13 20:30:55 +0000 | [diff] [blame] | 967 | bits<16> val; |
| 968 | let Inst{3-0} = val{3-0}; |
| 969 | let Inst{19-8} = val{15-4}; |
Johnny Chen | c6f7b27 | 2010-02-11 18:12:29 +0000 | [diff] [blame] | 970 | let Inst{27-20} = 0b00010010; |
| 971 | let Inst{7-4} = 0b0111; |
| 972 | } |
| 973 | |
Johnny Chen | b98e160 | 2010-02-12 18:55:33 +0000 | [diff] [blame] | 974 | // Change Processor State is a system instruction -- for disassembly only. |
| 975 | // The singleton $opt operand contains the following information: |
| 976 | // opt{4-0} = mode from Inst{4-0} |
| 977 | // opt{5} = changemode from Inst{17} |
| 978 | // opt{8-6} = AIF from Inst{8-6} |
| 979 | // opt{10-9} = imod from Inst{19-18} with 0b10 as enable and 0b11 as disable |
Jim Grosbach | 596307e | 2010-10-13 20:38:04 +0000 | [diff] [blame] | 980 | // FIXME: Integrated assembler will need these split out. |
Johnny Chen | dd0f3cf | 2010-03-10 18:59:38 +0000 | [diff] [blame] | 981 | def CPS : AXI<(outs), (ins cps_opt:$opt), MiscFrm, NoItinerary, "cps$opt", |
Johnny Chen | b98e160 | 2010-02-12 18:55:33 +0000 | [diff] [blame] | 982 | [/* For disassembly only; pattern left blank */]>, |
| 983 | Requires<[IsARM]> { |
| 984 | let Inst{31-28} = 0b1111; |
| 985 | let Inst{27-20} = 0b00010000; |
| 986 | let Inst{16} = 0; |
| 987 | let Inst{5} = 0; |
| 988 | } |
| 989 | |
Johnny Chen | b92a23f | 2010-02-21 04:42:01 +0000 | [diff] [blame] | 990 | // Preload signals the memory system of possible future data/instruction access. |
| 991 | // These are for disassembly only. |
Johnny Chen | dd0f3cf | 2010-03-10 18:59:38 +0000 | [diff] [blame] | 992 | // |
| 993 | // A8.6.117, A8.6.118. Different instructions are generated for #0 and #-0. |
| 994 | // The neg_zero operand translates -0 to -1, -1 to -2, ..., etc. |
Johnny Chen | b92a23f | 2010-02-21 04:42:01 +0000 | [diff] [blame] | 995 | multiclass APreLoad<bit data, bit read, string opc> { |
| 996 | |
Jim Grosbach | ab682a2 | 2010-10-28 18:34:10 +0000 | [diff] [blame] | 997 | def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, NoItinerary, |
| 998 | !strconcat(opc, "\t$addr"), []> { |
| 999 | bits<4> Rt; |
| 1000 | bits<17> addr; |
Johnny Chen | b92a23f | 2010-02-21 04:42:01 +0000 | [diff] [blame] | 1001 | let Inst{31-26} = 0b111101; |
| 1002 | let Inst{25} = 0; // 0 for immediate form |
| 1003 | let Inst{24} = data; |
Jim Grosbach | ab682a2 | 2010-10-28 18:34:10 +0000 | [diff] [blame] | 1004 | let Inst{23} = addr{12}; // U (add = ('U' == 1)) |
Johnny Chen | b92a23f | 2010-02-21 04:42:01 +0000 | [diff] [blame] | 1005 | let Inst{22} = read; |
| 1006 | let Inst{21-20} = 0b01; |
Jim Grosbach | ab682a2 | 2010-10-28 18:34:10 +0000 | [diff] [blame] | 1007 | let Inst{19-16} = addr{16-13}; // Rn |
| 1008 | let Inst{15-12} = Rt; |
| 1009 | let Inst{11-0} = addr{11-0}; // imm12 |
Johnny Chen | b92a23f | 2010-02-21 04:42:01 +0000 | [diff] [blame] | 1010 | } |
| 1011 | |
Jim Grosbach | ab682a2 | 2010-10-28 18:34:10 +0000 | [diff] [blame] | 1012 | def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, NoItinerary, |
| 1013 | !strconcat(opc, "\t$shift"), []> { |
| 1014 | bits<4> Rt; |
| 1015 | bits<17> shift; |
Johnny Chen | b92a23f | 2010-02-21 04:42:01 +0000 | [diff] [blame] | 1016 | let Inst{31-26} = 0b111101; |
| 1017 | let Inst{25} = 1; // 1 for register form |
| 1018 | let Inst{24} = data; |
Jim Grosbach | ab682a2 | 2010-10-28 18:34:10 +0000 | [diff] [blame] | 1019 | let Inst{23} = shift{12}; // U (add = ('U' == 1)) |
Johnny Chen | b92a23f | 2010-02-21 04:42:01 +0000 | [diff] [blame] | 1020 | let Inst{22} = read; |
| 1021 | let Inst{21-20} = 0b01; |
Jim Grosbach | ab682a2 | 2010-10-28 18:34:10 +0000 | [diff] [blame] | 1022 | let Inst{19-16} = shift{16-13}; // Rn |
| 1023 | let Inst{11-0} = shift{11-0}; |
Johnny Chen | b92a23f | 2010-02-21 04:42:01 +0000 | [diff] [blame] | 1024 | } |
| 1025 | } |
| 1026 | |
| 1027 | defm PLD : APreLoad<1, 1, "pld">; |
| 1028 | defm PLDW : APreLoad<1, 0, "pldw">; |
| 1029 | defm PLI : APreLoad<0, 1, "pli">; |
| 1030 | |
Jim Grosbach | b3af5de | 2010-10-13 21:00:04 +0000 | [diff] [blame] | 1031 | def SETEND : AXI<(outs),(ins setend_op:$end), MiscFrm, NoItinerary, |
| 1032 | "setend\t$end", |
| 1033 | [/* For disassembly only; pattern left blank */]>, |
Johnny Chen | a1e7621 | 2010-02-13 02:51:09 +0000 | [diff] [blame] | 1034 | Requires<[IsARM]> { |
Jim Grosbach | b3af5de | 2010-10-13 21:00:04 +0000 | [diff] [blame] | 1035 | bits<1> end; |
| 1036 | let Inst{31-10} = 0b1111000100000001000000; |
| 1037 | let Inst{9} = end; |
| 1038 | let Inst{8-0} = 0; |
Johnny Chen | a1e7621 | 2010-02-13 02:51:09 +0000 | [diff] [blame] | 1039 | } |
| 1040 | |
Johnny Chen | f4d8105 | 2010-02-12 22:53:19 +0000 | [diff] [blame] | 1041 | def DBG : AI<(outs), (ins i32imm:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt", |
Johnny Chen | 85d5a89 | 2010-02-10 18:02:25 +0000 | [diff] [blame] | 1042 | [/* For disassembly only; pattern left blank */]>, |
| 1043 | Requires<[IsARM, HasV7]> { |
Jim Grosbach | 6c354fd | 2010-10-13 21:32:30 +0000 | [diff] [blame] | 1044 | bits<4> opt; |
| 1045 | let Inst{27-4} = 0b001100100000111100001111; |
| 1046 | let Inst{3-0} = opt; |
Johnny Chen | 85d5a89 | 2010-02-10 18:02:25 +0000 | [diff] [blame] | 1047 | } |
| 1048 | |
Johnny Chen | ba6e033 | 2010-02-11 17:14:31 +0000 | [diff] [blame] | 1049 | // A5.4 Permanently UNDEFINED instructions. |
Evan Cheng | fb3611d | 2010-05-11 07:26:32 +0000 | [diff] [blame] | 1050 | let isBarrier = 1, isTerminator = 1 in |
Jim Grosbach | a9a968d | 2010-10-22 23:48:29 +0000 | [diff] [blame] | 1051 | def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary, |
Jim Grosbach | 2e6ae13 | 2010-09-23 18:05:37 +0000 | [diff] [blame] | 1052 | "trap", [(trap)]>, |
Johnny Chen | ba6e033 | 2010-02-11 17:14:31 +0000 | [diff] [blame] | 1053 | Requires<[IsARM]> { |
| 1054 | let Inst{27-25} = 0b011; |
| 1055 | let Inst{24-20} = 0b11111; |
| 1056 | let Inst{7-5} = 0b111; |
| 1057 | let Inst{4} = 0b1; |
| 1058 | } |
| 1059 | |
Evan Cheng | 12c3a53 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 1060 | // Address computation and loads and stores in PIC mode. |
Jim Grosbach | b4b07b9 | 2010-10-13 22:55:33 +0000 | [diff] [blame] | 1061 | // FIXME: These PIC insn patterns are pseudos, but derive from the normal insn |
| 1062 | // classes (AXI1, et.al.) and so have encoding information and such, |
| 1063 | // which is suboptimal. Once the rest of the code emitter (including |
| 1064 | // JIT) is MC-ized we should look at refactoring these into true |
Jim Grosbach | f32ecc6 | 2010-10-29 20:21:36 +0000 | [diff] [blame] | 1065 | // pseudos. As is, the encoding information ends up being ignored, |
| 1066 | // as these instructions are lowered to individual MC-insts. |
Evan Cheng | eaa91b0 | 2007-06-19 01:26:51 +0000 | [diff] [blame] | 1067 | let isNotDuplicable = 1 in { |
Evan Cheng | c072966 | 2008-10-31 19:11:09 +0000 | [diff] [blame] | 1068 | def PICADD : AXI1<0b0100, (outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p), |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 1069 | Pseudo, IIC_iALUr, "", |
Evan Cheng | 44bec52 | 2007-05-15 01:29:07 +0000 | [diff] [blame] | 1070 | [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>; |
Dale Johannesen | 86d4069 | 2007-05-21 22:14:33 +0000 | [diff] [blame] | 1071 | |
Evan Cheng | 325474e | 2008-01-07 23:56:57 +0000 | [diff] [blame] | 1072 | let AddedComplexity = 10 in { |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1073 | def PICLDR : AXI2ldw<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 1074 | Pseudo, IIC_iLoad_r, "", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1075 | [(set GPR:$dst, (load addrmodepc:$addr))]>; |
Rafael Espindola | 84b19be | 2006-07-16 01:02:57 +0000 | [diff] [blame] | 1076 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1077 | def PICLDRH : AXI3ldh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 1078 | Pseudo, IIC_iLoad_bh_r, "", |
Dale Johannesen | 86d4069 | 2007-05-21 22:14:33 +0000 | [diff] [blame] | 1079 | [(set GPR:$dst, (zextloadi16 addrmodepc:$addr))]>; |
| 1080 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1081 | def PICLDRB : AXI2ldb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 1082 | Pseudo, IIC_iLoad_bh_r, "", |
Dale Johannesen | 86d4069 | 2007-05-21 22:14:33 +0000 | [diff] [blame] | 1083 | [(set GPR:$dst, (zextloadi8 addrmodepc:$addr))]>; |
| 1084 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1085 | def PICLDRSH : AXI3ldsh<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 1086 | Pseudo, IIC_iLoad_bh_r, "", |
Dale Johannesen | 86d4069 | 2007-05-21 22:14:33 +0000 | [diff] [blame] | 1087 | [(set GPR:$dst, (sextloadi16 addrmodepc:$addr))]>; |
| 1088 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1089 | def PICLDRSB : AXI3ldsb<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p), |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 1090 | Pseudo, IIC_iLoad_bh_r, "", |
Dale Johannesen | 86d4069 | 2007-05-21 22:14:33 +0000 | [diff] [blame] | 1091 | [(set GPR:$dst, (sextloadi8 addrmodepc:$addr))]>; |
| 1092 | } |
Chris Lattner | 13c6310 | 2008-01-06 05:55:01 +0000 | [diff] [blame] | 1093 | let AddedComplexity = 10 in { |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1094 | def PICSTR : AXI2stw<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p), |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 1095 | Pseudo, IIC_iStore_r, "", |
Dale Johannesen | 86d4069 | 2007-05-21 22:14:33 +0000 | [diff] [blame] | 1096 | [(store GPR:$src, addrmodepc:$addr)]>; |
| 1097 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1098 | def PICSTRH : AXI3sth<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p), |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 1099 | Pseudo, IIC_iStore_bh_r, "", |
Dale Johannesen | 86d4069 | 2007-05-21 22:14:33 +0000 | [diff] [blame] | 1100 | [(truncstorei16 GPR:$src, addrmodepc:$addr)]>; |
| 1101 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1102 | def PICSTRB : AXI2stb<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p), |
Jim Grosbach | a3fbadf | 2010-09-30 19:53:58 +0000 | [diff] [blame] | 1103 | Pseudo, IIC_iStore_bh_r, "", |
Dale Johannesen | 86d4069 | 2007-05-21 22:14:33 +0000 | [diff] [blame] | 1104 | [(truncstorei8 GPR:$src, addrmodepc:$addr)]>; |
| 1105 | } |
Evan Cheng | 12c3a53 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 1106 | } // isNotDuplicable = 1 |
Dale Johannesen | 86d4069 | 2007-05-21 22:14:33 +0000 | [diff] [blame] | 1107 | |
Evan Cheng | e07715c | 2009-06-23 05:25:29 +0000 | [diff] [blame] | 1108 | |
| 1109 | // LEApcrel - Load a pc-relative address into a register without offending the |
| 1110 | // assembler. |
Jim Grosbach | 6c354fd | 2010-10-13 21:32:30 +0000 | [diff] [blame] | 1111 | // FIXME: These are marked as pseudos, but they're really not(?). They're just |
| 1112 | // the ADR instruction. Is this the right way to handle that? They need |
| 1113 | // encoding information regardless. |
Evan Cheng | ea420b2 | 2010-05-19 01:52:25 +0000 | [diff] [blame] | 1114 | let neverHasSideEffects = 1 in { |
Evan Cheng | 27fa722 | 2010-05-19 07:26:50 +0000 | [diff] [blame] | 1115 | let isReMaterializable = 1 in |
David Goodwin | 8b7d7ad | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 1116 | def LEApcrel : AXI1<0x0, (outs GPR:$dst), (ins i32imm:$label, pred:$p), |
David Goodwin | 5d598aa | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1117 | Pseudo, IIC_iALUi, |
Evan Cheng | 27fa722 | 2010-05-19 07:26:50 +0000 | [diff] [blame] | 1118 | "adr$p\t$dst, #$label", []>; |
Evan Cheng | e07715c | 2009-06-23 05:25:29 +0000 | [diff] [blame] | 1119 | |
Jim Grosbach | a967d11 | 2010-06-21 21:27:27 +0000 | [diff] [blame] | 1120 | } // neverHasSideEffects |
Evan Cheng | 023dd3f | 2009-06-24 23:14:45 +0000 | [diff] [blame] | 1121 | def LEApcrelJT : AXI1<0x0, (outs GPR:$dst), |
Bob Wilson | 4f38b38 | 2009-08-21 21:58:55 +0000 | [diff] [blame] | 1122 | (ins i32imm:$label, nohash_imm:$id, pred:$p), |
Evan Cheng | 27fa722 | 2010-05-19 07:26:50 +0000 | [diff] [blame] | 1123 | Pseudo, IIC_iALUi, |
| 1124 | "adr$p\t$dst, #${label}_${id}", []> { |
Evan Cheng | bc8a945 | 2009-07-07 23:40:25 +0000 | [diff] [blame] | 1125 | let Inst{25} = 1; |
| 1126 | } |
Evan Cheng | e07715c | 2009-06-23 05:25:29 +0000 | [diff] [blame] | 1127 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1128 | //===----------------------------------------------------------------------===// |
| 1129 | // Control Flow Instructions. |
| 1130 | // |
Rafael Espindola | 9e071f0 | 2006-10-02 19:30:56 +0000 | [diff] [blame] | 1131 | |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1132 | let isReturn = 1, isTerminator = 1, isBarrier = 1 in { |
| 1133 | // ARMV4T and above |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1134 | def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br, |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1135 | "bx", "\tlr", [(ARMretflag)]>, |
| 1136 | Requires<[IsARM, HasV4T]> { |
Jim Grosbach | a7dbc1e | 2010-10-13 21:48:54 +0000 | [diff] [blame] | 1137 | let Inst{27-0} = 0b0001001011111111111100011110; |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1138 | } |
| 1139 | |
| 1140 | // ARMV4 only |
Jim Grosbach | a9a968d | 2010-10-22 23:48:29 +0000 | [diff] [blame] | 1141 | def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br, |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1142 | "mov", "\tpc, lr", [(ARMretflag)]>, |
| 1143 | Requires<[IsARM, NoV4T]> { |
Jim Grosbach | a7dbc1e | 2010-10-13 21:48:54 +0000 | [diff] [blame] | 1144 | let Inst{27-0} = 0b0001101000001111000000001110; |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1145 | } |
Evan Cheng | 7fd7ca4 | 2008-09-17 07:53:38 +0000 | [diff] [blame] | 1146 | } |
Rafael Espindola | 2718519 | 2006-09-29 21:20:16 +0000 | [diff] [blame] | 1147 | |
Bob Wilson | 04ea6e5 | 2009-10-28 00:37:03 +0000 | [diff] [blame] | 1148 | // Indirect branches |
| 1149 | let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in { |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1150 | // ARMV4T and above |
Bob Wilson | 8d4de5a | 2009-10-28 18:26:41 +0000 | [diff] [blame] | 1151 | def BRIND : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst", |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1152 | [(brind GPR:$dst)]>, |
| 1153 | Requires<[IsARM, HasV4T]> { |
Jim Grosbach | 6254726 | 2010-10-11 18:51:51 +0000 | [diff] [blame] | 1154 | bits<4> dst; |
Jim Grosbach | a7dbc1e | 2010-10-13 21:48:54 +0000 | [diff] [blame] | 1155 | let Inst{31-4} = 0b1110000100101111111111110001; |
Jim Grosbach | 27e9008 | 2010-10-29 19:28:17 +0000 | [diff] [blame] | 1156 | let Inst{3-0} = dst; |
Bob Wilson | 04ea6e5 | 2009-10-28 00:37:03 +0000 | [diff] [blame] | 1157 | } |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1158 | |
| 1159 | // ARMV4 only |
| 1160 | def MOVPCRX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "mov\tpc, $dst", |
| 1161 | [(brind GPR:$dst)]>, |
| 1162 | Requires<[IsARM, NoV4T]> { |
Jim Grosbach | 6254726 | 2010-10-11 18:51:51 +0000 | [diff] [blame] | 1163 | bits<4> dst; |
Jim Grosbach | a7dbc1e | 2010-10-13 21:48:54 +0000 | [diff] [blame] | 1164 | let Inst{31-4} = 0b1110000110100000111100000000; |
Jim Grosbach | 6254726 | 2010-10-11 18:51:51 +0000 | [diff] [blame] | 1165 | let Inst{3-0} = dst; |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1166 | } |
Bob Wilson | 04ea6e5 | 2009-10-28 00:37:03 +0000 | [diff] [blame] | 1167 | } |
| 1168 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1169 | // FIXME: remove when we have a way to marking a MI with these properties. |
Evan Cheng | 12c3a53 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 1170 | // FIXME: Should pc be an implicit operand like PICADD, etc? |
Evan Cheng | 0d92f5f | 2009-10-01 08:22:27 +0000 | [diff] [blame] | 1171 | let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1, |
Chris Lattner | 39ee036 | 2010-10-31 19:10:56 +0000 | [diff] [blame] | 1172 | hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 1173 | def LDM_RET : AXI4ld<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p, |
| 1174 | reglist:$dsts, variable_ops), |
Evan Cheng | a0792de | 2010-10-06 06:27:31 +0000 | [diff] [blame] | 1175 | IndexModeUpd, LdStMulFrm, IIC_iLoad_mBr, |
Bob Wilson | ab34605 | 2010-03-16 17:46:45 +0000 | [diff] [blame] | 1176 | "ldm${addr:submode}${p}\t$addr!, $dsts", |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 1177 | "$addr.addr = $wb", []>; |
Rafael Espindola | a284584 | 2006-10-05 16:48:49 +0000 | [diff] [blame] | 1178 | |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1179 | // On non-Darwin platforms R9 is callee-saved. |
David Goodwin | 1a8f36e | 2009-08-12 18:31:53 +0000 | [diff] [blame] | 1180 | let isCall = 1, |
Evan Cheng | 756da12 | 2009-07-22 06:46:53 +0000 | [diff] [blame] | 1181 | Defs = [R0, R1, R2, R3, R12, LR, |
| 1182 | D0, D1, D2, D3, D4, D5, D6, D7, |
| 1183 | D16, D17, D18, D19, D20, D21, D22, D23, |
David Goodwin | e8d82c0 | 2009-09-03 22:12:28 +0000 | [diff] [blame] | 1184 | D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in { |
Evan Cheng | 12c3a53 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 1185 | def BL : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops), |
Jim Grosbach | 1d6111c | 2010-10-06 21:36:43 +0000 | [diff] [blame] | 1186 | IIC_Br, "bl\t$func", |
Evan Cheng | 20a2a0a | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 1187 | [(ARMcall tglobaladdr:$func)]>, |
Johnny Chen | eadeffb | 2009-10-27 20:45:15 +0000 | [diff] [blame] | 1188 | Requires<[IsARM, IsNotDarwin]> { |
| 1189 | let Inst{31-28} = 0b1110; |
Jim Grosbach | 832859d | 2010-10-13 22:09:34 +0000 | [diff] [blame] | 1190 | // FIXME: Encoding info for $func. Needs fixups bits. |
Johnny Chen | eadeffb | 2009-10-27 20:45:15 +0000 | [diff] [blame] | 1191 | } |
Evan Cheng | 277f074 | 2007-06-19 21:05:09 +0000 | [diff] [blame] | 1192 | |
Evan Cheng | 12c3a53 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 1193 | def BL_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops), |
Jim Grosbach | 1d6111c | 2010-10-06 21:36:43 +0000 | [diff] [blame] | 1194 | IIC_Br, "bl", "\t$func", |
Evan Cheng | 20a2a0a | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 1195 | [(ARMcall_pred tglobaladdr:$func)]>, |
| 1196 | Requires<[IsARM, IsNotDarwin]>; |
Evan Cheng | 277f074 | 2007-06-19 21:05:09 +0000 | [diff] [blame] | 1197 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1198 | // ARMv5T and above |
Evan Cheng | 12c3a53 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 1199 | def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm, |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1200 | IIC_Br, "blx\t$func", |
Evan Cheng | 20a2a0a | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 1201 | [(ARMcall GPR:$func)]>, |
| 1202 | Requires<[IsARM, HasV5T, IsNotDarwin]> { |
Jim Grosbach | 6254726 | 2010-10-11 18:51:51 +0000 | [diff] [blame] | 1203 | bits<4> func; |
Jim Grosbach | 832859d | 2010-10-13 22:09:34 +0000 | [diff] [blame] | 1204 | let Inst{27-4} = 0b000100101111111111110011; |
Jim Grosbach | 6254726 | 2010-10-11 18:51:51 +0000 | [diff] [blame] | 1205 | let Inst{3-0} = func; |
Evan Cheng | 7fd7ca4 | 2008-09-17 07:53:38 +0000 | [diff] [blame] | 1206 | } |
| 1207 | |
Evan Cheng | f6bc4ae | 2009-07-14 01:49:27 +0000 | [diff] [blame] | 1208 | // ARMv4T |
Bob Wilson | 1665b0a | 2010-02-16 17:24:15 +0000 | [diff] [blame] | 1209 | // Note: Restrict $func to the tGPR regclass to prevent it being in LR. |
| 1210 | def BX : ABXIx2<(outs), (ins tGPR:$func, variable_ops), |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1211 | IIC_Br, "mov\tlr, pc\n\tbx\t$func", |
Bob Wilson | 1665b0a | 2010-02-16 17:24:15 +0000 | [diff] [blame] | 1212 | [(ARMcall_nolink tGPR:$func)]>, |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1213 | Requires<[IsARM, HasV4T, IsNotDarwin]> { |
Jim Grosbach | 832859d | 2010-10-13 22:09:34 +0000 | [diff] [blame] | 1214 | bits<4> func; |
| 1215 | let Inst{27-4} = 0b000100101111111111110001; |
| 1216 | let Inst{3-0} = func; |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1217 | } |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1218 | |
| 1219 | // ARMv4 |
| 1220 | def BMOVPCRX : ABXIx2<(outs), (ins tGPR:$func, variable_ops), |
| 1221 | IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func", |
| 1222 | [(ARMcall_nolink tGPR:$func)]>, |
| 1223 | Requires<[IsARM, NoV4T, IsNotDarwin]> { |
Jim Grosbach | 832859d | 2010-10-13 22:09:34 +0000 | [diff] [blame] | 1224 | bits<4> func; |
| 1225 | let Inst{27-4} = 0b000110100000111100000000; |
| 1226 | let Inst{3-0} = func; |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1227 | } |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1228 | } |
| 1229 | |
| 1230 | // On Darwin R9 is call-clobbered. |
David Goodwin | 1a8f36e | 2009-08-12 18:31:53 +0000 | [diff] [blame] | 1231 | let isCall = 1, |
Evan Cheng | 756da12 | 2009-07-22 06:46:53 +0000 | [diff] [blame] | 1232 | Defs = [R0, R1, R2, R3, R9, R12, LR, |
| 1233 | D0, D1, D2, D3, D4, D5, D6, D7, |
| 1234 | D16, D17, D18, D19, D20, D21, D22, D23, |
David Goodwin | e8d82c0 | 2009-09-03 22:12:28 +0000 | [diff] [blame] | 1235 | D24, D25, D26, D27, D28, D29, D30, D31, CPSR, FPSCR] in { |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1236 | def BLr9 : ABXI<0b1011, (outs), (ins i32imm:$func, variable_ops), |
Jim Grosbach | 1d6111c | 2010-10-06 21:36:43 +0000 | [diff] [blame] | 1237 | IIC_Br, "bl\t$func", |
Johnny Chen | eadeffb | 2009-10-27 20:45:15 +0000 | [diff] [blame] | 1238 | [(ARMcall tglobaladdr:$func)]>, Requires<[IsARM, IsDarwin]> { |
| 1239 | let Inst{31-28} = 0b1110; |
Jim Grosbach | 832859d | 2010-10-13 22:09:34 +0000 | [diff] [blame] | 1240 | // FIXME: Encoding info for $func. Needs fixups bits. |
Johnny Chen | eadeffb | 2009-10-27 20:45:15 +0000 | [diff] [blame] | 1241 | } |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1242 | |
| 1243 | def BLr9_pred : ABI<0b1011, (outs), (ins i32imm:$func, variable_ops), |
Jim Grosbach | 1d6111c | 2010-10-06 21:36:43 +0000 | [diff] [blame] | 1244 | IIC_Br, "bl", "\t$func", |
Evan Cheng | 20a2a0a | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 1245 | [(ARMcall_pred tglobaladdr:$func)]>, |
| 1246 | Requires<[IsARM, IsDarwin]>; |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1247 | |
| 1248 | // ARMv5T and above |
| 1249 | def BLXr9 : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm, |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1250 | IIC_Br, "blx\t$func", |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1251 | [(ARMcall GPR:$func)]>, Requires<[IsARM, HasV5T, IsDarwin]> { |
Jim Grosbach | 832859d | 2010-10-13 22:09:34 +0000 | [diff] [blame] | 1252 | bits<4> func; |
| 1253 | let Inst{27-4} = 0b000100101111111111110011; |
| 1254 | let Inst{3-0} = func; |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 1255 | } |
| 1256 | |
Evan Cheng | f6bc4ae | 2009-07-14 01:49:27 +0000 | [diff] [blame] | 1257 | // ARMv4T |
Bob Wilson | 1665b0a | 2010-02-16 17:24:15 +0000 | [diff] [blame] | 1258 | // Note: Restrict $func to the tGPR regclass to prevent it being in LR. |
| 1259 | def BXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops), |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1260 | IIC_Br, "mov\tlr, pc\n\tbx\t$func", |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1261 | [(ARMcall_nolink tGPR:$func)]>, |
| 1262 | Requires<[IsARM, HasV4T, IsDarwin]> { |
Jim Grosbach | 832859d | 2010-10-13 22:09:34 +0000 | [diff] [blame] | 1263 | bits<4> func; |
| 1264 | let Inst{27-4} = 0b000100101111111111110001; |
| 1265 | let Inst{3-0} = func; |
Lauro Ramos Venancio | 64c88d7 | 2007-03-20 17:57:23 +0000 | [diff] [blame] | 1266 | } |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1267 | |
| 1268 | // ARMv4 |
| 1269 | def BMOVPCRXr9 : ABXIx2<(outs), (ins tGPR:$func, variable_ops), |
| 1270 | IIC_Br, "mov\tlr, pc\n\tmov\tpc, $func", |
| 1271 | [(ARMcall_nolink tGPR:$func)]>, |
| 1272 | Requires<[IsARM, NoV4T, IsDarwin]> { |
Jim Grosbach | 832859d | 2010-10-13 22:09:34 +0000 | [diff] [blame] | 1273 | bits<4> func; |
| 1274 | let Inst{27-4} = 0b000110100000111100000000; |
| 1275 | let Inst{3-0} = func; |
Anton Korobeynikov | ce7bf1c | 2010-03-06 19:39:36 +0000 | [diff] [blame] | 1276 | } |
Rafael Espindola | 3557463 | 2006-07-18 17:00:30 +0000 | [diff] [blame] | 1277 | } |
Rafael Espindola | dc124a2 | 2006-05-18 21:45:49 +0000 | [diff] [blame] | 1278 | |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1279 | // Tail calls. |
| 1280 | |
Jim Grosbach | 832859d | 2010-10-13 22:09:34 +0000 | [diff] [blame] | 1281 | // FIXME: These should probably be xformed into the non-TC versions of the |
| 1282 | // instructions as part of MC lowering. |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1283 | let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in { |
| 1284 | // Darwin versions. |
| 1285 | let Defs = [R0, R1, R2, R3, R9, R12, |
| 1286 | D0, D1, D2, D3, D4, D5, D6, D7, |
| 1287 | D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, |
| 1288 | D27, D28, D29, D30, D31, PC], |
| 1289 | Uses = [SP] in { |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1290 | def TCRETURNdi : AInoP<(outs), (ins i32imm:$dst, variable_ops), |
| 1291 | Pseudo, IIC_Br, |
| 1292 | "@TC_RETURN","\t$dst", []>, Requires<[IsDarwin]>; |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1293 | |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1294 | def TCRETURNri : AInoP<(outs), (ins tcGPR:$dst, variable_ops), |
| 1295 | Pseudo, IIC_Br, |
| 1296 | "@TC_RETURN","\t$dst", []>, Requires<[IsDarwin]>; |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1297 | |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1298 | def TAILJMPd : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops), |
Dale Johannesen | 7835f1f | 2010-07-08 01:18:23 +0000 | [diff] [blame] | 1299 | IIC_Br, "b\t$dst @ TAILCALL", |
| 1300 | []>, Requires<[IsDarwin]>; |
| 1301 | |
| 1302 | def TAILJMPdt: ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops), |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1303 | IIC_Br, "b.w\t$dst @ TAILCALL", |
| 1304 | []>, Requires<[IsDarwin]>; |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1305 | |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1306 | def TAILJMPr : AXI<(outs), (ins tcGPR:$dst, variable_ops), |
| 1307 | BrMiscFrm, IIC_Br, "bx\t$dst @ TAILCALL", |
| 1308 | []>, Requires<[IsDarwin]> { |
Jim Grosbach | 2d294f5 | 2010-10-14 17:24:28 +0000 | [diff] [blame] | 1309 | bits<4> dst; |
| 1310 | let Inst{31-4} = 0b1110000100101111111111110001; |
| 1311 | let Inst{3-0} = dst; |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1312 | } |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1313 | } |
| 1314 | |
| 1315 | // Non-Darwin versions (the difference is R9). |
| 1316 | let Defs = [R0, R1, R2, R3, R12, |
| 1317 | D0, D1, D2, D3, D4, D5, D6, D7, |
| 1318 | D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, |
| 1319 | D27, D28, D29, D30, D31, PC], |
| 1320 | Uses = [SP] in { |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1321 | def TCRETURNdiND : AInoP<(outs), (ins i32imm:$dst, variable_ops), |
| 1322 | Pseudo, IIC_Br, |
| 1323 | "@TC_RETURN","\t$dst", []>, Requires<[IsNotDarwin]>; |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1324 | |
Dale Johannesen | b0ccb75 | 2010-06-21 18:21:49 +0000 | [diff] [blame] | 1325 | def TCRETURNriND : AInoP<(outs), (ins tcGPR:$dst, variable_ops), |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1326 | Pseudo, IIC_Br, |
| 1327 | "@TC_RETURN","\t$dst", []>, Requires<[IsNotDarwin]>; |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1328 | |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1329 | def TAILJMPdND : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops), |
| 1330 | IIC_Br, "b\t$dst @ TAILCALL", |
| 1331 | []>, Requires<[IsARM, IsNotDarwin]>; |
Dale Johannesen | 1041680 | 2010-06-18 20:44:28 +0000 | [diff] [blame] | 1332 | |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1333 | def TAILJMPdNDt : ABXI<0b1010, (outs), (ins brtarget:$dst, variable_ops), |
| 1334 | IIC_Br, "b.w\t$dst @ TAILCALL", |
| 1335 | []>, Requires<[IsThumb, IsNotDarwin]>; |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1336 | |
Dale Johannesen | b0ccb75 | 2010-06-21 18:21:49 +0000 | [diff] [blame] | 1337 | def TAILJMPrND : AXI<(outs), (ins tcGPR:$dst, variable_ops), |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1338 | BrMiscFrm, IIC_Br, "bx\t$dst @ TAILCALL", |
| 1339 | []>, Requires<[IsNotDarwin]> { |
Jim Grosbach | 2d294f5 | 2010-10-14 17:24:28 +0000 | [diff] [blame] | 1340 | bits<4> dst; |
| 1341 | let Inst{31-4} = 0b1110000100101111111111110001; |
| 1342 | let Inst{3-0} = dst; |
Evan Cheng | 6523d2f | 2010-06-19 00:11:54 +0000 | [diff] [blame] | 1343 | } |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 1344 | } |
| 1345 | } |
| 1346 | |
David Goodwin | 1a8f36e | 2009-08-12 18:31:53 +0000 | [diff] [blame] | 1347 | let isBranch = 1, isTerminator = 1 in { |
Evan Cheng | 5ada199 | 2007-05-16 20:50:01 +0000 | [diff] [blame] | 1348 | // B is "predicable" since it can be xformed into a Bcc. |
Evan Cheng | aeafca0 | 2007-05-16 07:45:54 +0000 | [diff] [blame] | 1349 | let isBarrier = 1 in { |
Evan Cheng | 5ada199 | 2007-05-16 20:50:01 +0000 | [diff] [blame] | 1350 | let isPredicable = 1 in |
David Goodwin | 8b7d7ad | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 1351 | def B : ABXI<0b1010, (outs), (ins brtarget:$target), IIC_Br, |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1352 | "b\t$target", [(br bb:$target)]>; |
Evan Cheng | 44bec52 | 2007-05-15 01:29:07 +0000 | [diff] [blame] | 1353 | |
Owen Anderson | 20ab290 | 2007-11-12 07:39:39 +0000 | [diff] [blame] | 1354 | let isNotDuplicable = 1, isIndirectBranch = 1 in { |
Evan Cheng | 4df60f5 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 1355 | def BR_JTr : JTI<(outs), (ins GPR:$target, jtblock_operand:$jt, i32imm:$id), |
Bob Wilson | d4d188e | 2010-07-31 06:28:10 +0000 | [diff] [blame] | 1356 | IIC_Br, "mov\tpc, $target$jt", |
Evan Cheng | 4df60f5 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 1357 | [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]> { |
Johnny Chen | ec68915 | 2009-12-14 21:51:34 +0000 | [diff] [blame] | 1358 | let Inst{11-4} = 0b00000000; |
Johnny Chen | a9ea9ec | 2009-11-17 17:17:50 +0000 | [diff] [blame] | 1359 | let Inst{15-12} = 0b1111; |
Evan Cheng | 4df60f5 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 1360 | let Inst{20} = 0; // S Bit |
| 1361 | let Inst{24-21} = 0b1101; |
Evan Cheng | 0fc0ade | 2009-07-07 23:45:10 +0000 | [diff] [blame] | 1362 | let Inst{27-25} = 0b000; |
Evan Cheng | aeafca0 | 2007-05-16 07:45:54 +0000 | [diff] [blame] | 1363 | } |
Evan Cheng | 4df60f5 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 1364 | def BR_JTm : JTI<(outs), |
| 1365 | (ins addrmode2:$target, jtblock_operand:$jt, i32imm:$id), |
Bob Wilson | d4d188e | 2010-07-31 06:28:10 +0000 | [diff] [blame] | 1366 | IIC_Br, "ldr\tpc, $target$jt", |
David Goodwin | 8b7d7ad | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 1367 | [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt, |
| 1368 | imm:$id)]> { |
Johnny Chen | a9ea9ec | 2009-11-17 17:17:50 +0000 | [diff] [blame] | 1369 | let Inst{15-12} = 0b1111; |
Evan Cheng | 4df60f5 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 1370 | let Inst{20} = 1; // L bit |
| 1371 | let Inst{21} = 0; // W bit |
| 1372 | let Inst{22} = 0; // B bit |
| 1373 | let Inst{24} = 1; // P bit |
Evan Cheng | 0fc0ade | 2009-07-07 23:45:10 +0000 | [diff] [blame] | 1374 | let Inst{27-25} = 0b011; |
Evan Cheng | eaa91b0 | 2007-06-19 01:26:51 +0000 | [diff] [blame] | 1375 | } |
Evan Cheng | 4df60f5 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 1376 | def BR_JTadd : JTI<(outs), |
| 1377 | (ins GPR:$target, GPR:$idx, jtblock_operand:$jt, i32imm:$id), |
Bob Wilson | d4d188e | 2010-07-31 06:28:10 +0000 | [diff] [blame] | 1378 | IIC_Br, "add\tpc, $target, $idx$jt", |
Evan Cheng | 4df60f5 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 1379 | [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt, |
| 1380 | imm:$id)]> { |
Johnny Chen | a9ea9ec | 2009-11-17 17:17:50 +0000 | [diff] [blame] | 1381 | let Inst{15-12} = 0b1111; |
Evan Cheng | 4df60f5 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 1382 | let Inst{20} = 0; // S bit |
| 1383 | let Inst{24-21} = 0b0100; |
Evan Cheng | 0fc0ade | 2009-07-07 23:45:10 +0000 | [diff] [blame] | 1384 | let Inst{27-25} = 0b000; |
Evan Cheng | 4df60f5 | 2008-11-07 09:06:08 +0000 | [diff] [blame] | 1385 | } |
| 1386 | } // isNotDuplicable = 1, isIndirectBranch = 1 |
| 1387 | } // isBarrier = 1 |
Evan Cheng | aeafca0 | 2007-05-16 07:45:54 +0000 | [diff] [blame] | 1388 | |
Evan Cheng | c85e832 | 2007-07-05 07:13:32 +0000 | [diff] [blame] | 1389 | // FIXME: should be able to write a pattern for ARMBrcond, but can't use |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1390 | // a two-value operand where a dag node expects two operands. :( |
Evan Cheng | 12c3a53 | 2008-11-06 17:48:05 +0000 | [diff] [blame] | 1391 | def Bcc : ABI<0b1010, (outs), (ins brtarget:$target), |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1392 | IIC_Br, "b", "\t$target", |
Evan Cheng | 0ff94f7 | 2007-08-07 01:37:15 +0000 | [diff] [blame] | 1393 | [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>; |
Rafael Espindola | 1ed3af1 | 2006-08-01 18:53:10 +0000 | [diff] [blame] | 1394 | } |
Rafael Espindola | 84b19be | 2006-07-16 01:02:57 +0000 | [diff] [blame] | 1395 | |
Johnny Chen | a1e7621 | 2010-02-13 02:51:09 +0000 | [diff] [blame] | 1396 | // Branch and Exchange Jazelle -- for disassembly only |
| 1397 | def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func", |
| 1398 | [/* For disassembly only; pattern left blank */]> { |
| 1399 | let Inst{23-20} = 0b0010; |
| 1400 | //let Inst{19-8} = 0xfff; |
| 1401 | let Inst{7-4} = 0b0010; |
| 1402 | } |
| 1403 | |
Johnny Chen | 0296f3e | 2010-02-16 21:59:54 +0000 | [diff] [blame] | 1404 | // Secure Monitor Call is a system instruction -- for disassembly only |
| 1405 | def SMC : ABI<0b0001, (outs), (ins i32imm:$opt), NoItinerary, "smc", "\t$opt", |
| 1406 | [/* For disassembly only; pattern left blank */]> { |
Jim Grosbach | 06ef444 | 2010-10-13 22:38:23 +0000 | [diff] [blame] | 1407 | bits<4> opt; |
| 1408 | let Inst{23-4} = 0b01100000000000000111; |
| 1409 | let Inst{3-0} = opt; |
Johnny Chen | 0296f3e | 2010-02-16 21:59:54 +0000 | [diff] [blame] | 1410 | } |
| 1411 | |
Johnny Chen | 64dfb78 | 2010-02-16 20:04:27 +0000 | [diff] [blame] | 1412 | // Supervisor Call (Software Interrupt) -- for disassembly only |
Johnny Chen | 85d5a89 | 2010-02-10 18:02:25 +0000 | [diff] [blame] | 1413 | let isCall = 1 in { |
| 1414 | def SVC : ABI<0b1111, (outs), (ins i32imm:$svc), IIC_Br, "svc", "\t$svc", |
Jim Grosbach | 06ef444 | 2010-10-13 22:38:23 +0000 | [diff] [blame] | 1415 | [/* For disassembly only; pattern left blank */]> { |
| 1416 | bits<24> svc; |
| 1417 | let Inst{23-0} = svc; |
| 1418 | } |
Johnny Chen | 85d5a89 | 2010-02-10 18:02:25 +0000 | [diff] [blame] | 1419 | } |
| 1420 | |
Johnny Chen | fb56679 | 2010-02-17 21:39:10 +0000 | [diff] [blame] | 1421 | // Store Return State is a system instruction -- for disassembly only |
Chris Lattner | 39ee036 | 2010-10-31 19:10:56 +0000 | [diff] [blame] | 1422 | let isCodeGenOnly = 1 in { // FIXME: This should not use submode! |
Johnny Chen | 0296f3e | 2010-02-16 21:59:54 +0000 | [diff] [blame] | 1423 | def SRSW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode), |
| 1424 | NoItinerary, "srs${addr:submode}\tsp!, $mode", |
Johnny Chen | 64dfb78 | 2010-02-16 20:04:27 +0000 | [diff] [blame] | 1425 | [/* For disassembly only; pattern left blank */]> { |
| 1426 | let Inst{31-28} = 0b1111; |
| 1427 | let Inst{22-20} = 0b110; // W = 1 |
| 1428 | } |
| 1429 | |
| 1430 | def SRS : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, i32imm:$mode), |
| 1431 | NoItinerary, "srs${addr:submode}\tsp, $mode", |
| 1432 | [/* For disassembly only; pattern left blank */]> { |
| 1433 | let Inst{31-28} = 0b1111; |
| 1434 | let Inst{22-20} = 0b100; // W = 0 |
| 1435 | } |
| 1436 | |
Johnny Chen | fb56679 | 2010-02-17 21:39:10 +0000 | [diff] [blame] | 1437 | // Return From Exception is a system instruction -- for disassembly only |
| 1438 | def RFEW : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base), |
| 1439 | NoItinerary, "rfe${addr:submode}\t$base!", |
| 1440 | [/* For disassembly only; pattern left blank */]> { |
| 1441 | let Inst{31-28} = 0b1111; |
| 1442 | let Inst{22-20} = 0b011; // W = 1 |
| 1443 | } |
| 1444 | |
| 1445 | def RFE : ABXI<{1,0,0,?}, (outs), (ins addrmode4:$addr, GPR:$base), |
| 1446 | NoItinerary, "rfe${addr:submode}\t$base", |
| 1447 | [/* For disassembly only; pattern left blank */]> { |
| 1448 | let Inst{31-28} = 0b1111; |
| 1449 | let Inst{22-20} = 0b001; // W = 0 |
| 1450 | } |
Chris Lattner | 39ee036 | 2010-10-31 19:10:56 +0000 | [diff] [blame] | 1451 | } // isCodeGenOnly = 1 |
Johnny Chen | fb56679 | 2010-02-17 21:39:10 +0000 | [diff] [blame] | 1452 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1453 | //===----------------------------------------------------------------------===// |
| 1454 | // Load / store Instructions. |
| 1455 | // |
Rafael Espindola | 82c678b | 2006-10-16 17:17:22 +0000 | [diff] [blame] | 1456 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1457 | // Load |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 1458 | |
| 1459 | |
Evan Cheng | 7e2fe91 | 2010-10-28 06:47:08 +0000 | [diff] [blame] | 1460 | defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si, |
Jim Grosbach | c1d3021 | 2010-10-27 00:19:44 +0000 | [diff] [blame] | 1461 | UnOpFrag<(load node:$Src)>>; |
Evan Cheng | 7e2fe91 | 2010-10-28 06:47:08 +0000 | [diff] [blame] | 1462 | defm LDRB : AI_ldr1<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si, |
Jim Grosbach | c1d3021 | 2010-10-27 00:19:44 +0000 | [diff] [blame] | 1463 | UnOpFrag<(zextloadi8 node:$Src)>>; |
Evan Cheng | 7e2fe91 | 2010-10-28 06:47:08 +0000 | [diff] [blame] | 1464 | defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si, |
Jim Grosbach | 7e3383c | 2010-10-27 23:12:14 +0000 | [diff] [blame] | 1465 | BinOpFrag<(store node:$LHS, node:$RHS)>>; |
Evan Cheng | 7e2fe91 | 2010-10-28 06:47:08 +0000 | [diff] [blame] | 1466 | defm STRB : AI_str1<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si, |
Jim Grosbach | 7e3383c | 2010-10-27 23:12:14 +0000 | [diff] [blame] | 1467 | BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>; |
Rafael Espindola | 82c678b | 2006-10-16 17:17:22 +0000 | [diff] [blame] | 1468 | |
Evan Cheng | fa775d0 | 2007-03-19 07:20:03 +0000 | [diff] [blame] | 1469 | // Special LDR for loads from non-pc-relative constpools. |
Evan Cheng | 5fd1c9b | 2010-05-19 06:07:03 +0000 | [diff] [blame] | 1470 | let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1, |
| 1471 | isReMaterializable = 1 in |
Jim Grosbach | 7e3383c | 2010-10-27 23:12:14 +0000 | [diff] [blame] | 1472 | def LDRcp : AIldst1<0b010, 0, 1, (outs GPR:$Rt), (ins addrmode_imm12:$addr), |
Jim Grosbach | 3e55612 | 2010-10-26 22:37:02 +0000 | [diff] [blame] | 1473 | AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr", []> { |
| 1474 | bits<4> Rt; |
| 1475 | bits<17> addr; |
| 1476 | let Inst{23} = addr{12}; // U (add = ('U' == 1)) |
| 1477 | let Inst{19-16} = 0b1111; |
| 1478 | let Inst{15-12} = Rt; |
| 1479 | let Inst{11-0} = addr{11-0}; // imm12 |
| 1480 | } |
Evan Cheng | fa775d0 | 2007-03-19 07:20:03 +0000 | [diff] [blame] | 1481 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1482 | // Loads with zero extension |
David Goodwin | 5d598aa | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1483 | def LDRH : AI3ldh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm, |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1484 | IIC_iLoad_bh_r, "ldrh", "\t$dst, $addr", |
David Goodwin | 5d598aa | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1485 | [(set GPR:$dst, (zextloadi16 addrmode3:$addr))]>; |
Rafael Espindola | 82c678b | 2006-10-16 17:17:22 +0000 | [diff] [blame] | 1486 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1487 | // Loads with sign extension |
David Goodwin | 5d598aa | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1488 | def LDRSH : AI3ldsh<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm, |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1489 | IIC_iLoad_bh_r, "ldrsh", "\t$dst, $addr", |
David Goodwin | 5d598aa | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1490 | [(set GPR:$dst, (sextloadi16 addrmode3:$addr))]>; |
Rafael Espindola | 7bc59bc | 2006-05-14 22:18:28 +0000 | [diff] [blame] | 1491 | |
David Goodwin | 5d598aa | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1492 | def LDRSB : AI3ldsb<(outs GPR:$dst), (ins addrmode3:$addr), LdMiscFrm, |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1493 | IIC_iLoad_bh_r, "ldrsb", "\t$dst, $addr", |
David Goodwin | 5d598aa | 2009-08-19 18:00:44 +0000 | [diff] [blame] | 1494 | [(set GPR:$dst, (sextloadi8 addrmode3:$addr))]>; |
Rafael Espindola | c391d16 | 2006-10-23 20:34:27 +0000 | [diff] [blame] | 1495 | |
Evan Cheng | 5fd1c9b | 2010-05-19 06:07:03 +0000 | [diff] [blame] | 1496 | let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in { |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1497 | // Load doubleword |
Evan Cheng | 358dec5 | 2009-06-15 08:28:29 +0000 | [diff] [blame] | 1498 | def LDRD : AI3ldd<(outs GPR:$dst1, GPR:$dst2), (ins addrmode3:$addr), LdMiscFrm, |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1499 | IIC_iLoad_d_r, "ldrd", "\t$dst1, $addr", |
Misha Brukman | bf16f1d | 2009-08-27 14:14:21 +0000 | [diff] [blame] | 1500 | []>, Requires<[IsARM, HasV5TE]>; |
Rafael Espindola | c391d16 | 2006-10-23 20:34:27 +0000 | [diff] [blame] | 1501 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1502 | // Indexed loads |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1503 | def LDR_PRE : AI2ldwpr<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1504 | (ins addrmode2:$addr), LdFrm, IIC_iLoad_ru, |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1505 | "ldr", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Rafael Espindola | dc124a2 | 2006-05-18 21:45:49 +0000 | [diff] [blame] | 1506 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1507 | def LDR_POST : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1508 | (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoad_ru, |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1509 | "ldr", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Rafael Espindola | 450856d | 2006-12-12 00:37:38 +0000 | [diff] [blame] | 1510 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1511 | def LDRH_PRE : AI3ldhpr<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1512 | (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1513 | "ldrh", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Rafael Espindola | 4e30764 | 2006-09-08 16:59:47 +0000 | [diff] [blame] | 1514 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1515 | def LDRH_POST : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1516 | (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1517 | "ldrh", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Lauro Ramos Venancio | 301009a | 2006-12-28 13:11:14 +0000 | [diff] [blame] | 1518 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1519 | def LDRB_PRE : AI2ldbpr<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1520 | (ins addrmode2:$addr), LdFrm, IIC_iLoad_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1521 | "ldrb", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Lauro Ramos Venancio | 301009a | 2006-12-28 13:11:14 +0000 | [diff] [blame] | 1522 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1523 | def LDRB_POST : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1524 | (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoad_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1525 | "ldrb", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1526 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1527 | def LDRSH_PRE : AI3ldshpr<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1528 | (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1529 | "ldrsh", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1530 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1531 | def LDRSH_POST: AI3ldshpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1532 | (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1533 | "ldrsh", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1534 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1535 | def LDRSB_PRE : AI3ldsbpr<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1536 | (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1537 | "ldrsb", "\t$dst, $addr!", "$addr.base = $base_wb", []>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1538 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1539 | def LDRSB_POST: AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1540 | (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1541 | "ldrsb", "\t$dst, [$base], $offset", "$base = $base_wb", []>; |
Johnny Chen | 39a4bb3 | 2010-02-18 22:31:18 +0000 | [diff] [blame] | 1542 | |
| 1543 | // For disassembly only |
| 1544 | def LDRD_PRE : AI3lddpr<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1545 | (ins addrmode3:$addr), LdMiscFrm, IIC_iLoad_d_ru, |
Johnny Chen | 39a4bb3 | 2010-02-18 22:31:18 +0000 | [diff] [blame] | 1546 | "ldrd", "\t$dst1, $dst2, $addr!", "$addr.base = $base_wb", []>, |
| 1547 | Requires<[IsARM, HasV5TE]>; |
| 1548 | |
| 1549 | // For disassembly only |
| 1550 | def LDRD_POST : AI3lddpo<(outs GPR:$dst1, GPR:$dst2, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1551 | (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_d_ru, |
Johnny Chen | 39a4bb3 | 2010-02-18 22:31:18 +0000 | [diff] [blame] | 1552 | "ldrd", "\t$dst1, $dst2, [$base], $offset", "$base = $base_wb", []>, |
| 1553 | Requires<[IsARM, HasV5TE]>; |
| 1554 | |
Evan Cheng | 5fd1c9b | 2010-05-19 06:07:03 +0000 | [diff] [blame] | 1555 | } // mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1556 | |
Johnny Chen | adb561d | 2010-02-18 03:27:42 +0000 | [diff] [blame] | 1557 | // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT are for disassembly only. |
Johnny Chen | e4c7f0f | 2010-02-11 20:31:08 +0000 | [diff] [blame] | 1558 | |
| 1559 | def LDRT : AI2ldwpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1560 | (ins GPR:$base, am2offset:$offset), LdFrm, IIC_iLoad_ru, |
Johnny Chen | e4c7f0f | 2010-02-11 20:31:08 +0000 | [diff] [blame] | 1561 | "ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> { |
| 1562 | let Inst{21} = 1; // overwrite |
| 1563 | } |
| 1564 | |
| 1565 | def LDRBT : AI2ldbpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1566 | (ins GPR:$base,am2offset:$offset), LdFrm, IIC_iLoad_bh_ru, |
Johnny Chen | adb561d | 2010-02-18 03:27:42 +0000 | [diff] [blame] | 1567 | "ldrbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> { |
| 1568 | let Inst{21} = 1; // overwrite |
| 1569 | } |
| 1570 | |
| 1571 | def LDRSBT : AI3ldsbpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1572 | (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru, |
Johnny Chen | adb561d | 2010-02-18 03:27:42 +0000 | [diff] [blame] | 1573 | "ldrsbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> { |
| 1574 | let Inst{21} = 1; // overwrite |
| 1575 | } |
| 1576 | |
| 1577 | def LDRHT : AI3ldhpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1578 | (ins GPR:$base, am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru, |
Johnny Chen | adb561d | 2010-02-18 03:27:42 +0000 | [diff] [blame] | 1579 | "ldrht", "\t$dst, [$base], $offset", "$base = $base_wb", []> { |
| 1580 | let Inst{21} = 1; // overwrite |
| 1581 | } |
| 1582 | |
| 1583 | def LDRSHT : AI3ldshpo<(outs GPR:$dst, GPR:$base_wb), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1584 | (ins GPR:$base,am3offset:$offset), LdMiscFrm, IIC_iLoad_bh_ru, |
Johnny Chen | adb561d | 2010-02-18 03:27:42 +0000 | [diff] [blame] | 1585 | "ldrsht", "\t$dst, [$base], $offset", "$base = $base_wb", []> { |
Johnny Chen | e4c7f0f | 2010-02-11 20:31:08 +0000 | [diff] [blame] | 1586 | let Inst{21} = 1; // overwrite |
| 1587 | } |
| 1588 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1589 | // Store |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1590 | |
| 1591 | // Stores with truncate |
Jim Grosbach | 80dc116 | 2010-02-16 21:23:02 +0000 | [diff] [blame] | 1592 | def STRH : AI3sth<(outs), (ins GPR:$src, addrmode3:$addr), StMiscFrm, |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1593 | IIC_iStore_bh_r, "strh", "\t$src, $addr", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1594 | [(truncstorei16 GPR:$src, addrmode3:$addr)]>; |
| 1595 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1596 | // Store doubleword |
Evan Cheng | 5fd1c9b | 2010-05-19 06:07:03 +0000 | [diff] [blame] | 1597 | let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in |
David Goodwin | 8b7d7ad | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 1598 | def STRD : AI3std<(outs), (ins GPR:$src1, GPR:$src2, addrmode3:$addr), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1599 | StMiscFrm, IIC_iStore_d_r, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1600 | "strd", "\t$src1, $addr", []>, Requires<[IsARM, HasV5TE]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1601 | |
| 1602 | // Indexed stores |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1603 | def STR_PRE : AI2stwpr<(outs GPR:$base_wb), |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1604 | (ins GPR:$src, GPR:$base, am2offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1605 | StFrm, IIC_iStore_ru, |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1606 | "str", "\t$src, [$base, $offset]!", "$base = $base_wb", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1607 | [(set GPR:$base_wb, |
| 1608 | (pre_store GPR:$src, GPR:$base, am2offset:$offset))]>; |
| 1609 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1610 | def STR_POST : AI2stwpo<(outs GPR:$base_wb), |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1611 | (ins GPR:$src, GPR:$base,am2offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1612 | StFrm, IIC_iStore_ru, |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 1613 | "str", "\t$src, [$base], $offset", "$base = $base_wb", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1614 | [(set GPR:$base_wb, |
| 1615 | (post_store GPR:$src, GPR:$base, am2offset:$offset))]>; |
| 1616 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1617 | def STRH_PRE : AI3sthpr<(outs GPR:$base_wb), |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1618 | (ins GPR:$src, GPR:$base,am3offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1619 | StMiscFrm, IIC_iStore_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1620 | "strh", "\t$src, [$base, $offset]!", "$base = $base_wb", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1621 | [(set GPR:$base_wb, |
| 1622 | (pre_truncsti16 GPR:$src, GPR:$base,am3offset:$offset))]>; |
| 1623 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1624 | def STRH_POST: AI3sthpo<(outs GPR:$base_wb), |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1625 | (ins GPR:$src, GPR:$base,am3offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1626 | StMiscFrm, IIC_iStore_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1627 | "strh", "\t$src, [$base], $offset", "$base = $base_wb", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1628 | [(set GPR:$base_wb, (post_truncsti16 GPR:$src, |
| 1629 | GPR:$base, am3offset:$offset))]>; |
| 1630 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1631 | def STRB_PRE : AI2stbpr<(outs GPR:$base_wb), |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1632 | (ins GPR:$src, GPR:$base,am2offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1633 | StFrm, IIC_iStore_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1634 | "strb", "\t$src, [$base, $offset]!", "$base = $base_wb", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1635 | [(set GPR:$base_wb, (pre_truncsti8 GPR:$src, |
| 1636 | GPR:$base, am2offset:$offset))]>; |
| 1637 | |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 1638 | def STRB_POST: AI2stbpo<(outs GPR:$base_wb), |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1639 | (ins GPR:$src, GPR:$base,am2offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1640 | StFrm, IIC_iStore_bh_ru, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1641 | "strb", "\t$src, [$base], $offset", "$base = $base_wb", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1642 | [(set GPR:$base_wb, (post_truncsti8 GPR:$src, |
| 1643 | GPR:$base, am2offset:$offset))]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1644 | |
Johnny Chen | 39a4bb3 | 2010-02-18 22:31:18 +0000 | [diff] [blame] | 1645 | // For disassembly only |
| 1646 | def STRD_PRE : AI3stdpr<(outs GPR:$base_wb), |
| 1647 | (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1648 | StMiscFrm, IIC_iStore_d_ru, |
Johnny Chen | 39a4bb3 | 2010-02-18 22:31:18 +0000 | [diff] [blame] | 1649 | "strd", "\t$src1, $src2, [$base, $offset]!", |
| 1650 | "$base = $base_wb", []>; |
| 1651 | |
| 1652 | // For disassembly only |
| 1653 | def STRD_POST: AI3stdpo<(outs GPR:$base_wb), |
| 1654 | (ins GPR:$src1, GPR:$src2, GPR:$base, am3offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1655 | StMiscFrm, IIC_iStore_d_ru, |
Johnny Chen | 39a4bb3 | 2010-02-18 22:31:18 +0000 | [diff] [blame] | 1656 | "strd", "\t$src1, $src2, [$base], $offset", |
| 1657 | "$base = $base_wb", []>; |
| 1658 | |
Johnny Chen | ad4df4c | 2010-03-01 19:22:00 +0000 | [diff] [blame] | 1659 | // STRT, STRBT, and STRHT are for disassembly only. |
Johnny Chen | e4c7f0f | 2010-02-11 20:31:08 +0000 | [diff] [blame] | 1660 | |
| 1661 | def STRT : AI2stwpo<(outs GPR:$base_wb), |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1662 | (ins GPR:$src, GPR:$base,am2offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1663 | StFrm, IIC_iStore_ru, |
Johnny Chen | e4c7f0f | 2010-02-11 20:31:08 +0000 | [diff] [blame] | 1664 | "strt", "\t$src, [$base], $offset", "$base = $base_wb", |
| 1665 | [/* For disassembly only; pattern left blank */]> { |
| 1666 | let Inst{21} = 1; // overwrite |
| 1667 | } |
| 1668 | |
| 1669 | def STRBT : AI2stbpo<(outs GPR:$base_wb), |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1670 | (ins GPR:$src, GPR:$base,am2offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1671 | StFrm, IIC_iStore_bh_ru, |
Johnny Chen | e4c7f0f | 2010-02-11 20:31:08 +0000 | [diff] [blame] | 1672 | "strbt", "\t$src, [$base], $offset", "$base = $base_wb", |
| 1673 | [/* For disassembly only; pattern left blank */]> { |
| 1674 | let Inst{21} = 1; // overwrite |
| 1675 | } |
| 1676 | |
Johnny Chen | ad4df4c | 2010-03-01 19:22:00 +0000 | [diff] [blame] | 1677 | def STRHT: AI3sthpo<(outs GPR:$base_wb), |
| 1678 | (ins GPR:$src, GPR:$base,am3offset:$offset), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1679 | StMiscFrm, IIC_iStore_bh_ru, |
Johnny Chen | ad4df4c | 2010-03-01 19:22:00 +0000 | [diff] [blame] | 1680 | "strht", "\t$src, [$base], $offset", "$base = $base_wb", |
| 1681 | [/* For disassembly only; pattern left blank */]> { |
| 1682 | let Inst{21} = 1; // overwrite |
| 1683 | } |
| 1684 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1685 | //===----------------------------------------------------------------------===// |
| 1686 | // Load / store multiple Instructions. |
| 1687 | // |
| 1688 | |
Chris Lattner | 39ee036 | 2010-10-31 19:10:56 +0000 | [diff] [blame] | 1689 | let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1, |
| 1690 | isCodeGenOnly = 1 in { |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 1691 | def LDM : AXI4ld<(outs), (ins addrmode4:$addr, pred:$p, |
Bob Wilson | bffb5b3 | 2010-03-13 07:34:35 +0000 | [diff] [blame] | 1692 | reglist:$dsts, variable_ops), |
Evan Cheng | a0792de | 2010-10-06 06:27:31 +0000 | [diff] [blame] | 1693 | IndexModeNone, LdStMulFrm, IIC_iLoad_m, |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 1694 | "ldm${addr:submode}${p}\t$addr, $dsts", "", []>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1695 | |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 1696 | def LDM_UPD : AXI4ld<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p, |
| 1697 | reglist:$dsts, variable_ops), |
Evan Cheng | a0792de | 2010-10-06 06:27:31 +0000 | [diff] [blame] | 1698 | IndexModeUpd, LdStMulFrm, IIC_iLoad_mu, |
Bob Wilson | ab34605 | 2010-03-16 17:46:45 +0000 | [diff] [blame] | 1699 | "ldm${addr:submode}${p}\t$addr!, $dsts", |
Johnny Chen | e86425f | 2010-03-19 23:50:27 +0000 | [diff] [blame] | 1700 | "$addr.addr = $wb", []>; |
Evan Cheng | 5fd1c9b | 2010-05-19 06:07:03 +0000 | [diff] [blame] | 1701 | } // mayLoad, neverHasSideEffects, hasExtraDefRegAllocReq |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 1702 | |
Chris Lattner | 39ee036 | 2010-10-31 19:10:56 +0000 | [diff] [blame] | 1703 | let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1, |
| 1704 | isCodeGenOnly = 1 in { |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 1705 | def STM : AXI4st<(outs), (ins addrmode4:$addr, pred:$p, |
Bob Wilson | bffb5b3 | 2010-03-13 07:34:35 +0000 | [diff] [blame] | 1706 | reglist:$srcs, variable_ops), |
Evan Cheng | a0792de | 2010-10-06 06:27:31 +0000 | [diff] [blame] | 1707 | IndexModeNone, LdStMulFrm, IIC_iStore_m, |
Bob Wilson | 815baeb | 2010-03-13 01:08:20 +0000 | [diff] [blame] | 1708 | "stm${addr:submode}${p}\t$addr, $srcs", "", []>; |
| 1709 | |
| 1710 | def STM_UPD : AXI4st<(outs GPR:$wb), (ins addrmode4:$addr, pred:$p, |
| 1711 | reglist:$srcs, variable_ops), |
Evan Cheng | a0792de | 2010-10-06 06:27:31 +0000 | [diff] [blame] | 1712 | IndexModeUpd, LdStMulFrm, IIC_iStore_mu, |
Bob Wilson | ab34605 | 2010-03-16 17:46:45 +0000 | [diff] [blame] | 1713 | "stm${addr:submode}${p}\t$addr!, $srcs", |
Johnny Chen | e86425f | 2010-03-19 23:50:27 +0000 | [diff] [blame] | 1714 | "$addr.addr = $wb", []>; |
Evan Cheng | 5fd1c9b | 2010-05-19 06:07:03 +0000 | [diff] [blame] | 1715 | } // mayStore, neverHasSideEffects, hasExtraSrcRegAllocReq |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1716 | |
| 1717 | //===----------------------------------------------------------------------===// |
| 1718 | // Move Instructions. |
| 1719 | // |
| 1720 | |
Evan Cheng | cd799b9 | 2009-06-12 20:46:18 +0000 | [diff] [blame] | 1721 | let neverHasSideEffects = 1 in |
Jim Grosbach | f59818b | 2010-10-12 18:09:12 +0000 | [diff] [blame] | 1722 | def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr, |
| 1723 | "mov", "\t$Rd, $Rm", []>, UnaryDP { |
| 1724 | bits<4> Rd; |
| 1725 | bits<4> Rm; |
Jim Grosbach | 56ac907 | 2010-10-08 21:45:55 +0000 | [diff] [blame] | 1726 | |
Johnny Chen | 0430152 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 1727 | let Inst{11-4} = 0b00000000; |
Bob Wilson | 8e86b51 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1728 | let Inst{25} = 0; |
Jim Grosbach | f59818b | 2010-10-12 18:09:12 +0000 | [diff] [blame] | 1729 | let Inst{3-0} = Rm; |
| 1730 | let Inst{15-12} = Rd; |
Bob Wilson | 8e86b51 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1731 | } |
| 1732 | |
Dale Johannesen | 38d5f04 | 2010-06-15 22:24:08 +0000 | [diff] [blame] | 1733 | // A version for the smaller set of tail call registers. |
| 1734 | let neverHasSideEffects = 1 in |
Jim Grosbach | a9a968d | 2010-10-22 23:48:29 +0000 | [diff] [blame] | 1735 | def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm, |
Jim Grosbach | f59818b | 2010-10-12 18:09:12 +0000 | [diff] [blame] | 1736 | IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP { |
| 1737 | bits<4> Rd; |
| 1738 | bits<4> Rm; |
Jim Grosbach | 56ac907 | 2010-10-08 21:45:55 +0000 | [diff] [blame] | 1739 | |
Dale Johannesen | 38d5f04 | 2010-06-15 22:24:08 +0000 | [diff] [blame] | 1740 | let Inst{11-4} = 0b00000000; |
| 1741 | let Inst{25} = 0; |
Jim Grosbach | f59818b | 2010-10-12 18:09:12 +0000 | [diff] [blame] | 1742 | let Inst{3-0} = Rm; |
| 1743 | let Inst{15-12} = Rd; |
Dale Johannesen | 38d5f04 | 2010-06-15 22:24:08 +0000 | [diff] [blame] | 1744 | } |
| 1745 | |
Evan Cheng | f40deed | 2010-10-27 23:41:30 +0000 | [diff] [blame] | 1746 | def MOVs : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg:$src), |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1747 | DPSoRegFrm, IIC_iMOVsr, |
Evan Cheng | f40deed | 2010-10-27 23:41:30 +0000 | [diff] [blame] | 1748 | "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg:$src)]>, |
| 1749 | UnaryDP { |
Jim Grosbach | 58456c0 | 2010-10-14 23:28:31 +0000 | [diff] [blame] | 1750 | bits<4> Rd; |
Jim Grosbach | 1de588d | 2010-10-14 18:54:27 +0000 | [diff] [blame] | 1751 | bits<12> src; |
Jim Grosbach | 58456c0 | 2010-10-14 23:28:31 +0000 | [diff] [blame] | 1752 | let Inst{15-12} = Rd; |
Jim Grosbach | 1de588d | 2010-10-14 18:54:27 +0000 | [diff] [blame] | 1753 | let Inst{11-0} = src; |
Bob Wilson | 8e86b51 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 1754 | let Inst{25} = 0; |
| 1755 | } |
Evan Cheng | a251570 | 2007-03-19 07:09:02 +0000 | [diff] [blame] | 1756 | |
Evan Cheng | b3379fb | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 1757 | let isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Jim Grosbach | 2a6a93d | 2010-10-12 23:18:08 +0000 | [diff] [blame] | 1758 | def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi, |
| 1759 | "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP { |
Jim Grosbach | f59818b | 2010-10-12 18:09:12 +0000 | [diff] [blame] | 1760 | bits<4> Rd; |
Jim Grosbach | 2a6a93d | 2010-10-12 23:18:08 +0000 | [diff] [blame] | 1761 | bits<12> imm; |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1762 | let Inst{25} = 1; |
Jim Grosbach | f59818b | 2010-10-12 18:09:12 +0000 | [diff] [blame] | 1763 | let Inst{15-12} = Rd; |
| 1764 | let Inst{19-16} = 0b0000; |
Jim Grosbach | 2a6a93d | 2010-10-12 23:18:08 +0000 | [diff] [blame] | 1765 | let Inst{11-0} = imm; |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1766 | } |
| 1767 | |
| 1768 | let isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Jim Grosbach | 1de588d | 2010-10-14 18:54:27 +0000 | [diff] [blame] | 1769 | def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins i32imm:$imm), |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1770 | DPFrm, IIC_iMOVi, |
Jim Grosbach | 1de588d | 2010-10-14 18:54:27 +0000 | [diff] [blame] | 1771 | "movw", "\t$Rd, $imm", |
| 1772 | [(set GPR:$Rd, imm0_65535:$imm)]>, |
Johnny Chen | 92e63d8 | 2010-02-01 23:06:04 +0000 | [diff] [blame] | 1773 | Requires<[IsARM, HasV6T2]>, UnaryDP { |
Jim Grosbach | 1de588d | 2010-10-14 18:54:27 +0000 | [diff] [blame] | 1774 | bits<4> Rd; |
| 1775 | bits<16> imm; |
| 1776 | let Inst{15-12} = Rd; |
| 1777 | let Inst{11-0} = imm{11-0}; |
| 1778 | let Inst{19-16} = imm{15-12}; |
Bob Wilson | 5361cd2 | 2009-10-13 17:35:30 +0000 | [diff] [blame] | 1779 | let Inst{20} = 0; |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1780 | let Inst{25} = 1; |
| 1781 | } |
| 1782 | |
Jim Grosbach | 1de588d | 2010-10-14 18:54:27 +0000 | [diff] [blame] | 1783 | let Constraints = "$src = $Rd" in |
| 1784 | def MOVTi16 : AI1<0b1010, (outs GPR:$Rd), (ins GPR:$src, i32imm:$imm), |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1785 | DPFrm, IIC_iMOVi, |
Jim Grosbach | 1de588d | 2010-10-14 18:54:27 +0000 | [diff] [blame] | 1786 | "movt", "\t$Rd, $imm", |
| 1787 | [(set GPR:$Rd, |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 1788 | (or (and GPR:$src, 0xffff), |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1789 | lo16AllZero:$imm))]>, UnaryDP, |
| 1790 | Requires<[IsARM, HasV6T2]> { |
Jim Grosbach | 1de588d | 2010-10-14 18:54:27 +0000 | [diff] [blame] | 1791 | bits<4> Rd; |
| 1792 | bits<16> imm; |
| 1793 | let Inst{15-12} = Rd; |
| 1794 | let Inst{11-0} = imm{11-0}; |
| 1795 | let Inst{19-16} = imm{15-12}; |
Bob Wilson | 5361cd2 | 2009-10-13 17:35:30 +0000 | [diff] [blame] | 1796 | let Inst{20} = 0; |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 1797 | let Inst{25} = 1; |
Evan Cheng | 7995ef3 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1798 | } |
Evan Cheng | 13ab020 | 2007-07-10 18:08:01 +0000 | [diff] [blame] | 1799 | |
Evan Cheng | 2095659 | 2009-10-21 08:15:52 +0000 | [diff] [blame] | 1800 | def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>, |
| 1801 | Requires<[IsARM, HasV6T2]>; |
| 1802 | |
David Goodwin | ca01a8d | 2009-09-01 18:32:09 +0000 | [diff] [blame] | 1803 | let Uses = [CPSR] in |
Jim Grosbach | 7032f92 | 2010-10-14 22:57:13 +0000 | [diff] [blame] | 1804 | def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi, "", |
| 1805 | [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP, |
| 1806 | Requires<[IsARM]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1807 | |
| 1808 | // These aren't really mov instructions, but we have to define them this way |
| 1809 | // due to flag operands. |
| 1810 | |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1811 | let Defs = [CPSR] in { |
Jim Grosbach | 7032f92 | 2010-10-14 22:57:13 +0000 | [diff] [blame] | 1812 | def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, "", |
| 1813 | [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP, |
| 1814 | Requires<[IsARM]>; |
| 1815 | def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi, "", |
| 1816 | [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP, |
| 1817 | Requires<[IsARM]>; |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1818 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1819 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1820 | //===----------------------------------------------------------------------===// |
| 1821 | // Extend Instructions. |
| 1822 | // |
| 1823 | |
| 1824 | // Sign extenders |
| 1825 | |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 1826 | defm SXTB : AI_ext_rrot<0b01101010, |
| 1827 | "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>; |
| 1828 | defm SXTH : AI_ext_rrot<0b01101011, |
| 1829 | "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1830 | |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 1831 | defm SXTAB : AI_exta_rrot<0b01101010, |
Evan Cheng | 97f48c3 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 1832 | "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>; |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 1833 | defm SXTAH : AI_exta_rrot<0b01101011, |
Evan Cheng | 97f48c3 | 2008-11-06 22:15:19 +0000 | [diff] [blame] | 1834 | "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1835 | |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 1836 | // For disassembly only |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 1837 | defm SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">; |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 1838 | |
| 1839 | // For disassembly only |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 1840 | defm SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1841 | |
| 1842 | // Zero extenders |
| 1843 | |
| 1844 | let AddedComplexity = 16 in { |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 1845 | defm UXTB : AI_ext_rrot<0b01101110, |
| 1846 | "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>; |
| 1847 | defm UXTH : AI_ext_rrot<0b01101111, |
| 1848 | "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>; |
| 1849 | defm UXTB16 : AI_ext_rrot<0b01101100, |
| 1850 | "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1851 | |
Jim Grosbach | 542f642 | 2010-07-28 23:25:44 +0000 | [diff] [blame] | 1852 | // FIXME: This pattern incorrectly assumes the shl operator is a rotate. |
| 1853 | // The transformation should probably be done as a combiner action |
| 1854 | // instead so we can include a check for masking back in the upper |
| 1855 | // eight bits of the source into the lower eight bits of the result. |
| 1856 | //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF), |
| 1857 | // (UXTB16r_rot GPR:$Src, 24)>; |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 1858 | def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF), |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1859 | (UXTB16r_rot GPR:$Src, 8)>; |
| 1860 | |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 1861 | defm UXTAB : AI_exta_rrot<0b01101110, "uxtab", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1862 | BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>; |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 1863 | defm UXTAH : AI_exta_rrot<0b01101111, "uxtah", |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1864 | BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>; |
Rafael Espindola | 3c000bf | 2006-08-21 22:00:32 +0000 | [diff] [blame] | 1865 | } |
| 1866 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1867 | // This isn't safe in general, the add is two 16-bit units, not a 32-bit add. |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 1868 | // For disassembly only |
Evan Cheng | 576a396 | 2010-09-25 00:49:35 +0000 | [diff] [blame] | 1869 | defm UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">; |
Rafael Espindola | 817e7fd | 2006-09-11 19:24:19 +0000 | [diff] [blame] | 1870 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1871 | |
Jim Grosbach | 8abe32a | 2010-10-15 17:15:16 +0000 | [diff] [blame] | 1872 | def SBFX : I<(outs GPR:$Rd), |
| 1873 | (ins GPR:$Rn, imm0_31:$lsb, imm0_31_m1:$width), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1874 | AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi, |
Jim Grosbach | 8abe32a | 2010-10-15 17:15:16 +0000 | [diff] [blame] | 1875 | "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>, |
Sandeep Patel | 47eedaa | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 1876 | Requires<[IsARM, HasV6T2]> { |
Jim Grosbach | 8abe32a | 2010-10-15 17:15:16 +0000 | [diff] [blame] | 1877 | bits<4> Rd; |
| 1878 | bits<4> Rn; |
| 1879 | bits<5> lsb; |
| 1880 | bits<5> width; |
Sandeep Patel | 47eedaa | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 1881 | let Inst{27-21} = 0b0111101; |
| 1882 | let Inst{6-4} = 0b101; |
Jim Grosbach | 8abe32a | 2010-10-15 17:15:16 +0000 | [diff] [blame] | 1883 | let Inst{20-16} = width; |
| 1884 | let Inst{15-12} = Rd; |
| 1885 | let Inst{11-7} = lsb; |
| 1886 | let Inst{3-0} = Rn; |
Sandeep Patel | 47eedaa | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 1887 | } |
| 1888 | |
Jim Grosbach | 8abe32a | 2010-10-15 17:15:16 +0000 | [diff] [blame] | 1889 | def UBFX : I<(outs GPR:$Rd), |
| 1890 | (ins GPR:$Rn, imm0_31:$lsb, imm0_31_m1:$width), |
Evan Cheng | 0e55fd6 | 2010-09-30 01:08:25 +0000 | [diff] [blame] | 1891 | AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi, |
Jim Grosbach | 8abe32a | 2010-10-15 17:15:16 +0000 | [diff] [blame] | 1892 | "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>, |
Sandeep Patel | 47eedaa | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 1893 | Requires<[IsARM, HasV6T2]> { |
Jim Grosbach | 8abe32a | 2010-10-15 17:15:16 +0000 | [diff] [blame] | 1894 | bits<4> Rd; |
| 1895 | bits<4> Rn; |
| 1896 | bits<5> lsb; |
| 1897 | bits<5> width; |
Sandeep Patel | 47eedaa | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 1898 | let Inst{27-21} = 0b0111111; |
| 1899 | let Inst{6-4} = 0b101; |
Jim Grosbach | 8abe32a | 2010-10-15 17:15:16 +0000 | [diff] [blame] | 1900 | let Inst{20-16} = width; |
| 1901 | let Inst{15-12} = Rd; |
| 1902 | let Inst{11-7} = lsb; |
| 1903 | let Inst{3-0} = Rn; |
Sandeep Patel | 47eedaa | 2009-10-13 18:59:48 +0000 | [diff] [blame] | 1904 | } |
| 1905 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1906 | //===----------------------------------------------------------------------===// |
| 1907 | // Arithmetic Instructions. |
| 1908 | // |
| 1909 | |
Jim Grosbach | 2642196 | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1910 | defm ADD : AsI1_bin_irs<0b0100, "add", |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 1911 | IIC_iALUi, IIC_iALUr, IIC_iALUsr, |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 1912 | BinOpFrag<(add node:$LHS, node:$RHS)>, 1>; |
Jim Grosbach | 2642196 | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 1913 | defm SUB : AsI1_bin_irs<0b0010, "sub", |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 1914 | IIC_iALUi, IIC_iALUr, IIC_iALUsr, |
Evan Cheng | 7fd7ca4 | 2008-09-17 07:53:38 +0000 | [diff] [blame] | 1915 | BinOpFrag<(sub node:$LHS, node:$RHS)>>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1916 | |
Evan Cheng | c85e832 | 2007-07-05 07:13:32 +0000 | [diff] [blame] | 1917 | // ADD and SUB with 's' bit set. |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1918 | defm ADDS : AI1_bin_s_irs<0b0100, "adds", |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 1919 | IIC_iALUi, IIC_iALUr, IIC_iALUsr, |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1920 | BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>; |
| 1921 | defm SUBS : AI1_bin_s_irs<0b0010, "subs", |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 1922 | IIC_iALUi, IIC_iALUr, IIC_iALUsr, |
Evan Cheng | 1e249e3 | 2009-06-25 20:59:23 +0000 | [diff] [blame] | 1923 | BinOpFrag<(subc node:$LHS, node:$RHS)>>; |
Evan Cheng | 2c614c5 | 2007-06-06 10:17:05 +0000 | [diff] [blame] | 1924 | |
Evan Cheng | 6267422 | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1925 | defm ADC : AI1_adde_sube_irs<0b0101, "adc", |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 1926 | BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>, 1>; |
Evan Cheng | 6267422 | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 1927 | defm SBC : AI1_adde_sube_irs<0b0110, "sbc", |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 1928 | BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>>; |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1929 | defm ADCS : AI1_adde_sube_s_irs<0b0101, "adcs", |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 1930 | BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>; |
Jim Grosbach | e516549 | 2009-11-09 00:11:35 +0000 | [diff] [blame] | 1931 | defm SBCS : AI1_adde_sube_s_irs<0b0110, "sbcs", |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 1932 | BinOpFrag<(sube_live_carry node:$LHS, node:$RHS) >>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 1933 | |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 1934 | def RSBri : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm, |
| 1935 | IIC_iALUi, "rsb", "\t$Rd, $Rn, $imm", |
| 1936 | [(set GPR:$Rd, (sub so_imm:$imm, GPR:$Rn))]> { |
| 1937 | bits<4> Rd; |
| 1938 | bits<4> Rn; |
| 1939 | bits<12> imm; |
| 1940 | let Inst{25} = 1; |
| 1941 | let Inst{15-12} = Rd; |
| 1942 | let Inst{19-16} = Rn; |
| 1943 | let Inst{11-0} = imm; |
Evan Cheng | 7995ef3 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1944 | } |
Evan Cheng | 13ab020 | 2007-07-10 18:08:01 +0000 | [diff] [blame] | 1945 | |
Bob Wilson | cff7178 | 2010-08-05 18:23:43 +0000 | [diff] [blame] | 1946 | // The reg/reg form is only defined for the disassembler; for codegen it is |
| 1947 | // equivalent to SUBrr. |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 1948 | def RSBrr : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, |
| 1949 | IIC_iALUr, "rsb", "\t$Rd, $Rn, $Rm", |
Bob Wilson | 751aaf8 | 2010-08-05 19:00:21 +0000 | [diff] [blame] | 1950 | [/* For disassembly only; pattern left blank */]> { |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 1951 | bits<4> Rd; |
| 1952 | bits<4> Rn; |
| 1953 | bits<4> Rm; |
| 1954 | let Inst{11-4} = 0b00000000; |
| 1955 | let Inst{25} = 0; |
| 1956 | let Inst{3-0} = Rm; |
| 1957 | let Inst{15-12} = Rd; |
| 1958 | let Inst{19-16} = Rn; |
Bob Wilson | cff7178 | 2010-08-05 18:23:43 +0000 | [diff] [blame] | 1959 | } |
| 1960 | |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 1961 | def RSBrs : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), |
| 1962 | DPSoRegFrm, IIC_iALUsr, "rsb", "\t$Rd, $Rn, $shift", |
| 1963 | [(set GPR:$Rd, (sub so_reg:$shift, GPR:$Rn))]> { |
| 1964 | bits<4> Rd; |
| 1965 | bits<4> Rn; |
| 1966 | bits<12> shift; |
| 1967 | let Inst{25} = 0; |
| 1968 | let Inst{11-0} = shift; |
| 1969 | let Inst{15-12} = Rd; |
| 1970 | let Inst{19-16} = Rn; |
Bob Wilson | 7e053bb | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 1971 | } |
Evan Cheng | c85e832 | 2007-07-05 07:13:32 +0000 | [diff] [blame] | 1972 | |
| 1973 | // RSB with 's' bit set. |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1974 | let Defs = [CPSR] in { |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 1975 | def RSBSri : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm, |
| 1976 | IIC_iALUi, "rsbs", "\t$Rd, $Rn, $imm", |
| 1977 | [(set GPR:$Rd, (subc so_imm:$imm, GPR:$Rn))]> { |
| 1978 | bits<4> Rd; |
| 1979 | bits<4> Rn; |
| 1980 | bits<12> imm; |
| 1981 | let Inst{25} = 1; |
| 1982 | let Inst{20} = 1; |
| 1983 | let Inst{15-12} = Rd; |
| 1984 | let Inst{19-16} = Rn; |
| 1985 | let Inst{11-0} = imm; |
Evan Cheng | 7995ef3 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 1986 | } |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 1987 | def RSBSrs : AI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), |
| 1988 | DPSoRegFrm, IIC_iALUsr, "rsbs", "\t$Rd, $Rn, $shift", |
| 1989 | [(set GPR:$Rd, (subc so_reg:$shift, GPR:$Rn))]> { |
| 1990 | bits<4> Rd; |
| 1991 | bits<4> Rn; |
| 1992 | bits<12> shift; |
| 1993 | let Inst{25} = 0; |
| 1994 | let Inst{20} = 1; |
| 1995 | let Inst{11-0} = shift; |
| 1996 | let Inst{15-12} = Rd; |
| 1997 | let Inst{19-16} = Rn; |
Bob Wilson | 7e053bb | 2009-10-26 22:34:44 +0000 | [diff] [blame] | 1998 | } |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 1999 | } |
Evan Cheng | c85e832 | 2007-07-05 07:13:32 +0000 | [diff] [blame] | 2000 | |
Evan Cheng | 6267422 | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 2001 | let Uses = [CPSR] in { |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2002 | def RSCri : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), |
| 2003 | DPFrm, IIC_iALUi, "rsc", "\t$Rd, $Rn, $imm", |
| 2004 | [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 2005 | Requires<[IsARM]> { |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2006 | bits<4> Rd; |
| 2007 | bits<4> Rn; |
| 2008 | bits<12> imm; |
| 2009 | let Inst{25} = 1; |
| 2010 | let Inst{15-12} = Rd; |
| 2011 | let Inst{19-16} = Rn; |
| 2012 | let Inst{11-0} = imm; |
Evan Cheng | 7995ef3 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 2013 | } |
Bob Wilson | a1d410d | 2010-08-05 18:59:36 +0000 | [diff] [blame] | 2014 | // The reg/reg form is only defined for the disassembler; for codegen it is |
| 2015 | // equivalent to SUBrr. |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2016 | def RSCrr : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2017 | DPFrm, IIC_iALUr, "rsc", "\t$Rd, $Rn, $Rm", |
Bob Wilson | a1d410d | 2010-08-05 18:59:36 +0000 | [diff] [blame] | 2018 | [/* For disassembly only; pattern left blank */]> { |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2019 | bits<4> Rd; |
| 2020 | bits<4> Rn; |
| 2021 | bits<4> Rm; |
| 2022 | let Inst{11-4} = 0b00000000; |
| 2023 | let Inst{25} = 0; |
| 2024 | let Inst{3-0} = Rm; |
| 2025 | let Inst{15-12} = Rd; |
| 2026 | let Inst{19-16} = Rn; |
Bob Wilson | a1d410d | 2010-08-05 18:59:36 +0000 | [diff] [blame] | 2027 | } |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2028 | def RSCrs : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), |
| 2029 | DPSoRegFrm, IIC_iALUsr, "rsc", "\t$Rd, $Rn, $shift", |
| 2030 | [(set GPR:$Rd, (sube_dead_carry so_reg:$shift, GPR:$Rn))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 2031 | Requires<[IsARM]> { |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2032 | bits<4> Rd; |
| 2033 | bits<4> Rn; |
| 2034 | bits<12> shift; |
| 2035 | let Inst{25} = 0; |
| 2036 | let Inst{11-0} = shift; |
| 2037 | let Inst{15-12} = Rd; |
| 2038 | let Inst{19-16} = Rn; |
Bob Wilson | dda9583 | 2009-10-26 22:59:12 +0000 | [diff] [blame] | 2039 | } |
Evan Cheng | 6267422 | 2009-06-25 23:34:10 +0000 | [diff] [blame] | 2040 | } |
| 2041 | |
| 2042 | // FIXME: Allow these to be predicated. |
Evan Cheng | 1e249e3 | 2009-06-25 20:59:23 +0000 | [diff] [blame] | 2043 | let Defs = [CPSR], Uses = [CPSR] in { |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2044 | def RSCSri : AXI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), |
| 2045 | DPFrm, IIC_iALUi, "rscs\t$Rd, $Rn, $imm", |
| 2046 | [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 2047 | Requires<[IsARM]> { |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2048 | bits<4> Rd; |
| 2049 | bits<4> Rn; |
| 2050 | bits<12> imm; |
| 2051 | let Inst{25} = 1; |
| 2052 | let Inst{20} = 1; |
| 2053 | let Inst{15-12} = Rd; |
| 2054 | let Inst{19-16} = Rn; |
| 2055 | let Inst{11-0} = imm; |
Evan Cheng | 7995ef3 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 2056 | } |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2057 | def RSCSrs : AXI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg:$shift), |
| 2058 | DPSoRegFrm, IIC_iALUsr, "rscs\t$Rd, $Rn, $shift", |
| 2059 | [(set GPR:$Rd, (sube_dead_carry so_reg:$shift, GPR:$Rn))]>, |
Jim Grosbach | 0a145f3 | 2010-02-16 20:17:57 +0000 | [diff] [blame] | 2060 | Requires<[IsARM]> { |
Jim Grosbach | 8476088 | 2010-10-15 18:42:41 +0000 | [diff] [blame] | 2061 | bits<4> Rd; |
| 2062 | bits<4> Rn; |
| 2063 | bits<12> shift; |
| 2064 | let Inst{25} = 0; |
| 2065 | let Inst{20} = 1; |
| 2066 | let Inst{11-0} = shift; |
| 2067 | let Inst{15-12} = Rd; |
| 2068 | let Inst{19-16} = Rn; |
Bob Wilson | dda9583 | 2009-10-26 22:59:12 +0000 | [diff] [blame] | 2069 | } |
Evan Cheng | 071a279 | 2007-09-11 19:55:27 +0000 | [diff] [blame] | 2070 | } |
Evan Cheng | 2c614c5 | 2007-06-06 10:17:05 +0000 | [diff] [blame] | 2071 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2072 | // (sub X, imm) gets canonicalized to (add X, -imm). Match this form. |
Jim Grosbach | 502e0aa | 2010-07-14 17:45:16 +0000 | [diff] [blame] | 2073 | // The assume-no-carry-in form uses the negation of the input since add/sub |
| 2074 | // assume opposite meanings of the carry flag (i.e., carry == !borrow). |
| 2075 | // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory |
| 2076 | // details. |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2077 | def : ARMPat<(add GPR:$src, so_imm_neg:$imm), |
| 2078 | (SUBri GPR:$src, so_imm_neg:$imm)>; |
Jim Grosbach | 502e0aa | 2010-07-14 17:45:16 +0000 | [diff] [blame] | 2079 | def : ARMPat<(addc GPR:$src, so_imm_neg:$imm), |
| 2080 | (SUBSri GPR:$src, so_imm_neg:$imm)>; |
| 2081 | // The with-carry-in form matches bitwise not instead of the negation. |
| 2082 | // Effectively, the inverse interpretation of the carry flag already accounts |
| 2083 | // for part of the negation. |
| 2084 | def : ARMPat<(adde GPR:$src, so_imm_not:$imm), |
| 2085 | (SBCri GPR:$src, so_imm_not:$imm)>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2086 | |
| 2087 | // Note: These are implemented in C++ code, because they have to generate |
| 2088 | // ADD/SUBrs instructions, which use a complex pattern that a xform function |
| 2089 | // cannot produce. |
| 2090 | // (mul X, 2^n+1) -> (add (X << n), X) |
| 2091 | // (mul X, 2^n-1) -> (rsb X, (X << n)) |
| 2092 | |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2093 | // ARM Arithmetic Instruction -- for disassembly only |
Johnny Chen | 2faf391 | 2010-02-14 06:32:20 +0000 | [diff] [blame] | 2094 | // GPR:$dst = GPR:$a op GPR:$b |
Jim Grosbach | 5ad01c7 | 2010-10-15 19:49:46 +0000 | [diff] [blame] | 2095 | class AAI<bits<8> op27_20, bits<8> op11_4, string opc, |
Nate Begeman | 692433b | 2010-07-29 17:56:55 +0000 | [diff] [blame] | 2096 | list<dag> pattern = [/* For disassembly only; pattern left blank */]> |
Jim Grosbach | 5ad01c7 | 2010-10-15 19:49:46 +0000 | [diff] [blame] | 2097 | : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iALUr, |
| 2098 | opc, "\t$Rd, $Rn, $Rm", pattern> { |
| 2099 | bits<4> Rd; |
| 2100 | bits<4> Rn; |
| 2101 | bits<4> Rm; |
Johnny Chen | 08b85f3 | 2010-02-13 01:21:01 +0000 | [diff] [blame] | 2102 | let Inst{27-20} = op27_20; |
Jim Grosbach | 5ad01c7 | 2010-10-15 19:49:46 +0000 | [diff] [blame] | 2103 | let Inst{11-4} = op11_4; |
| 2104 | let Inst{19-16} = Rn; |
| 2105 | let Inst{15-12} = Rd; |
| 2106 | let Inst{3-0} = Rm; |
Johnny Chen | 08b85f3 | 2010-02-13 01:21:01 +0000 | [diff] [blame] | 2107 | } |
| 2108 | |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2109 | // Saturating add/subtract -- for disassembly only |
| 2110 | |
Jim Grosbach | 5ad01c7 | 2010-10-15 19:49:46 +0000 | [diff] [blame] | 2111 | def QADD : AAI<0b00010000, 0b00000101, "qadd", |
| 2112 | [(set GPR:$Rd, (int_arm_qadd GPR:$Rn, GPR:$Rm))]>; |
| 2113 | def QSUB : AAI<0b00010010, 0b00000101, "qsub", |
| 2114 | [(set GPR:$Rd, (int_arm_qsub GPR:$Rn, GPR:$Rm))]>; |
| 2115 | def QDADD : AAI<0b00010100, 0b00000101, "qdadd">; |
| 2116 | def QDSUB : AAI<0b00010110, 0b00000101, "qdsub">; |
| 2117 | |
| 2118 | def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">; |
| 2119 | def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">; |
| 2120 | def QASX : AAI<0b01100010, 0b11110011, "qasx">; |
| 2121 | def QSAX : AAI<0b01100010, 0b11110101, "qsax">; |
| 2122 | def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">; |
| 2123 | def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">; |
| 2124 | def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">; |
| 2125 | def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">; |
| 2126 | def UQASX : AAI<0b01100110, 0b11110011, "uqasx">; |
| 2127 | def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">; |
| 2128 | def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">; |
| 2129 | def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2130 | |
| 2131 | // Signed/Unsigned add/subtract -- for disassembly only |
| 2132 | |
Jim Grosbach | 5ad01c7 | 2010-10-15 19:49:46 +0000 | [diff] [blame] | 2133 | def SASX : AAI<0b01100001, 0b11110011, "sasx">; |
| 2134 | def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">; |
| 2135 | def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">; |
| 2136 | def SSAX : AAI<0b01100001, 0b11110101, "ssax">; |
| 2137 | def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">; |
| 2138 | def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">; |
| 2139 | def UASX : AAI<0b01100101, 0b11110011, "uasx">; |
| 2140 | def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">; |
| 2141 | def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">; |
| 2142 | def USAX : AAI<0b01100101, 0b11110101, "usax">; |
| 2143 | def USUB16 : AAI<0b01100101, 0b11110111, "usub16">; |
| 2144 | def USUB8 : AAI<0b01100101, 0b11111111, "usub8">; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2145 | |
| 2146 | // Signed/Unsigned halving add/subtract -- for disassembly only |
| 2147 | |
Jim Grosbach | 5ad01c7 | 2010-10-15 19:49:46 +0000 | [diff] [blame] | 2148 | def SHASX : AAI<0b01100011, 0b11110011, "shasx">; |
| 2149 | def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">; |
| 2150 | def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">; |
| 2151 | def SHSAX : AAI<0b01100011, 0b11110101, "shsax">; |
| 2152 | def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">; |
| 2153 | def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">; |
| 2154 | def UHASX : AAI<0b01100111, 0b11110011, "uhasx">; |
| 2155 | def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">; |
| 2156 | def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">; |
| 2157 | def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">; |
| 2158 | def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">; |
| 2159 | def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2160 | |
Johnny Chen | adc7733 | 2010-02-26 22:04:29 +0000 | [diff] [blame] | 2161 | // Unsigned Sum of Absolute Differences [and Accumulate] -- for disassembly only |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2162 | |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2163 | def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2164 | MulFrm /* for convenience */, NoItinerary, "usad8", |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2165 | "\t$Rd, $Rn, $Rm", []>, |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2166 | Requires<[IsARM, HasV6]> { |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2167 | bits<4> Rd; |
| 2168 | bits<4> Rn; |
| 2169 | bits<4> Rm; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2170 | let Inst{27-20} = 0b01111000; |
| 2171 | let Inst{15-12} = 0b1111; |
| 2172 | let Inst{7-4} = 0b0001; |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2173 | let Inst{19-16} = Rd; |
| 2174 | let Inst{11-8} = Rm; |
| 2175 | let Inst{3-0} = Rn; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2176 | } |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2177 | def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2178 | MulFrm /* for convenience */, NoItinerary, "usada8", |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2179 | "\t$Rd, $Rn, $Rm, $Ra", []>, |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2180 | Requires<[IsARM, HasV6]> { |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2181 | bits<4> Rd; |
| 2182 | bits<4> Rn; |
| 2183 | bits<4> Rm; |
| 2184 | bits<4> Ra; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2185 | let Inst{27-20} = 0b01111000; |
| 2186 | let Inst{7-4} = 0b0001; |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2187 | let Inst{19-16} = Rd; |
| 2188 | let Inst{15-12} = Ra; |
| 2189 | let Inst{11-8} = Rm; |
| 2190 | let Inst{3-0} = Rn; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2191 | } |
| 2192 | |
| 2193 | // Signed/Unsigned saturate -- for disassembly only |
| 2194 | |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2195 | def SSAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh), |
| 2196 | SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $a$sh", |
Bob Wilson | eaf1c98 | 2010-08-11 23:10:46 +0000 | [diff] [blame] | 2197 | [/* For disassembly only; pattern left blank */]> { |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2198 | bits<4> Rd; |
| 2199 | bits<5> sat_imm; |
| 2200 | bits<4> Rn; |
| 2201 | bits<8> sh; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2202 | let Inst{27-21} = 0b0110101; |
Bob Wilson | eaf1c98 | 2010-08-11 23:10:46 +0000 | [diff] [blame] | 2203 | let Inst{5-4} = 0b01; |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2204 | let Inst{20-16} = sat_imm; |
| 2205 | let Inst{15-12} = Rd; |
| 2206 | let Inst{11-7} = sh{7-3}; |
| 2207 | let Inst{6} = sh{0}; |
| 2208 | let Inst{3-0} = Rn; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2209 | } |
| 2210 | |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2211 | def SSAT16 : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$Rn), SatFrm, |
| 2212 | NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2213 | [/* For disassembly only; pattern left blank */]> { |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2214 | bits<4> Rd; |
| 2215 | bits<4> sat_imm; |
| 2216 | bits<4> Rn; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2217 | let Inst{27-20} = 0b01101010; |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2218 | let Inst{11-4} = 0b11110011; |
| 2219 | let Inst{15-12} = Rd; |
| 2220 | let Inst{19-16} = sat_imm; |
| 2221 | let Inst{3-0} = Rn; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2222 | } |
| 2223 | |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2224 | def USAT : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a, shift_imm:$sh), |
| 2225 | SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $a$sh", |
Bob Wilson | eaf1c98 | 2010-08-11 23:10:46 +0000 | [diff] [blame] | 2226 | [/* For disassembly only; pattern left blank */]> { |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2227 | bits<4> Rd; |
| 2228 | bits<5> sat_imm; |
| 2229 | bits<4> Rn; |
| 2230 | bits<8> sh; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2231 | let Inst{27-21} = 0b0110111; |
Bob Wilson | eaf1c98 | 2010-08-11 23:10:46 +0000 | [diff] [blame] | 2232 | let Inst{5-4} = 0b01; |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2233 | let Inst{15-12} = Rd; |
| 2234 | let Inst{11-7} = sh{7-3}; |
| 2235 | let Inst{6} = sh{0}; |
| 2236 | let Inst{20-16} = sat_imm; |
| 2237 | let Inst{3-0} = Rn; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2238 | } |
| 2239 | |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2240 | def USAT16 : AI<(outs GPR:$Rd), (ins i32imm:$sat_imm, GPR:$a), SatFrm, |
| 2241 | NoItinerary, "usat16", "\t$Rd, $sat_imm, $a", |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2242 | [/* For disassembly only; pattern left blank */]> { |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2243 | bits<4> Rd; |
| 2244 | bits<4> sat_imm; |
| 2245 | bits<4> Rn; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2246 | let Inst{27-20} = 0b01101110; |
Jim Grosbach | 70987fb | 2010-10-18 23:35:38 +0000 | [diff] [blame] | 2247 | let Inst{11-4} = 0b11110011; |
| 2248 | let Inst{15-12} = Rd; |
| 2249 | let Inst{19-16} = sat_imm; |
| 2250 | let Inst{3-0} = Rn; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2251 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2252 | |
Bob Wilson | eaf1c98 | 2010-08-11 23:10:46 +0000 | [diff] [blame] | 2253 | def : ARMV6Pat<(int_arm_ssat GPR:$a, imm:$pos), (SSAT imm:$pos, GPR:$a, 0)>; |
| 2254 | def : ARMV6Pat<(int_arm_usat GPR:$a, imm:$pos), (USAT imm:$pos, GPR:$a, 0)>; |
Nate Begeman | 0e0a20e | 2010-07-29 22:48:09 +0000 | [diff] [blame] | 2255 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2256 | //===----------------------------------------------------------------------===// |
| 2257 | // Bitwise Instructions. |
| 2258 | // |
| 2259 | |
Jim Grosbach | 2642196 | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 2260 | defm AND : AsI1_bin_irs<0b0000, "and", |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 2261 | IIC_iBITi, IIC_iBITr, IIC_iBITsr, |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 2262 | BinOpFrag<(and node:$LHS, node:$RHS)>, 1>; |
Jim Grosbach | 2642196 | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 2263 | defm ORR : AsI1_bin_irs<0b1100, "orr", |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 2264 | IIC_iBITi, IIC_iBITr, IIC_iBITsr, |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 2265 | BinOpFrag<(or node:$LHS, node:$RHS)>, 1>; |
Jim Grosbach | 2642196 | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 2266 | defm EOR : AsI1_bin_irs<0b0001, "eor", |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 2267 | IIC_iBITi, IIC_iBITr, IIC_iBITsr, |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 2268 | BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>; |
Jim Grosbach | 2642196 | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 2269 | defm BIC : AsI1_bin_irs<0b1110, "bic", |
Evan Cheng | 7e1bf30 | 2010-09-29 00:27:46 +0000 | [diff] [blame] | 2270 | IIC_iBITi, IIC_iBITr, IIC_iBITsr, |
Evan Cheng | 7fd7ca4 | 2008-09-17 07:53:38 +0000 | [diff] [blame] | 2271 | BinOpFrag<(and node:$LHS, (not node:$RHS))>>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2272 | |
Jim Grosbach | 3fea19105 | 2010-10-21 22:03:21 +0000 | [diff] [blame] | 2273 | def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm), |
David Goodwin | 2f54a2f | 2009-11-02 17:28:36 +0000 | [diff] [blame] | 2274 | AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi, |
Jim Grosbach | 3fea19105 | 2010-10-21 22:03:21 +0000 | [diff] [blame] | 2275 | "bfc", "\t$Rd, $imm", "$src = $Rd", |
| 2276 | [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>, |
Evan Cheng | 36a0aeb | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 2277 | Requires<[IsARM, HasV6T2]> { |
Jim Grosbach | 3fea19105 | 2010-10-21 22:03:21 +0000 | [diff] [blame] | 2278 | bits<4> Rd; |
| 2279 | bits<10> imm; |
Evan Cheng | 36a0aeb | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 2280 | let Inst{27-21} = 0b0111110; |
| 2281 | let Inst{6-0} = 0b0011111; |
Jim Grosbach | 3fea19105 | 2010-10-21 22:03:21 +0000 | [diff] [blame] | 2282 | let Inst{15-12} = Rd; |
| 2283 | let Inst{11-7} = imm{4-0}; // lsb |
| 2284 | let Inst{20-16} = imm{9-5}; // width |
Evan Cheng | 36a0aeb | 2009-07-06 22:23:46 +0000 | [diff] [blame] | 2285 | } |
| 2286 | |
Johnny Chen | b2503c0 | 2010-02-17 06:31:48 +0000 | [diff] [blame] | 2287 | // A8.6.18 BFI - Bitfield insert (Encoding A1) |
Jim Grosbach | 3fea19105 | 2010-10-21 22:03:21 +0000 | [diff] [blame] | 2288 | def BFI : I<(outs GPR:$Rd), (ins GPR:$src, GPR:$Rn, bf_inv_mask_imm:$imm), |
Johnny Chen | b2503c0 | 2010-02-17 06:31:48 +0000 | [diff] [blame] | 2289 | AddrMode1, Size4Bytes, IndexModeNone, DPFrm, IIC_iUNAsi, |
Jim Grosbach | 3fea19105 | 2010-10-21 22:03:21 +0000 | [diff] [blame] | 2290 | "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd", |
| 2291 | [(set GPR:$Rd, (ARMbfi GPR:$src, GPR:$Rn, |
Jim Grosbach | 469bbdb | 2010-07-16 23:05:05 +0000 | [diff] [blame] | 2292 | bf_inv_mask_imm:$imm))]>, |
Johnny Chen | b2503c0 | 2010-02-17 06:31:48 +0000 | [diff] [blame] | 2293 | Requires<[IsARM, HasV6T2]> { |
Jim Grosbach | 3fea19105 | 2010-10-21 22:03:21 +0000 | [diff] [blame] | 2294 | bits<4> Rd; |
| 2295 | bits<4> Rn; |
| 2296 | bits<10> imm; |
Johnny Chen | b2503c0 | 2010-02-17 06:31:48 +0000 | [diff] [blame] | 2297 | let Inst{27-21} = 0b0111110; |
| 2298 | let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15 |
Jim Grosbach | 3fea19105 | 2010-10-21 22:03:21 +0000 | [diff] [blame] | 2299 | let Inst{15-12} = Rd; |
| 2300 | let Inst{11-7} = imm{4-0}; // lsb |
| 2301 | let Inst{20-16} = imm{9-5}; // width |
| 2302 | let Inst{3-0} = Rn; |
Johnny Chen | b2503c0 | 2010-02-17 06:31:48 +0000 | [diff] [blame] | 2303 | } |
| 2304 | |
Jim Grosbach | 3686046 | 2010-10-21 22:19:32 +0000 | [diff] [blame] | 2305 | def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr, |
| 2306 | "mvn", "\t$Rd, $Rm", |
| 2307 | [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP { |
| 2308 | bits<4> Rd; |
| 2309 | bits<4> Rm; |
Johnny Chen | 48d5ccf | 2010-01-31 11:22:28 +0000 | [diff] [blame] | 2310 | let Inst{25} = 0; |
Jim Grosbach | 3686046 | 2010-10-21 22:19:32 +0000 | [diff] [blame] | 2311 | let Inst{19-16} = 0b0000; |
Johnny Chen | 0430152 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 2312 | let Inst{11-4} = 0b00000000; |
Jim Grosbach | 3686046 | 2010-10-21 22:19:32 +0000 | [diff] [blame] | 2313 | let Inst{15-12} = Rd; |
| 2314 | let Inst{3-0} = Rm; |
Bob Wilson | 8e86b51 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 2315 | } |
Jim Grosbach | 3686046 | 2010-10-21 22:19:32 +0000 | [diff] [blame] | 2316 | def MVNs : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg:$shift), DPSoRegFrm, |
| 2317 | IIC_iMVNsr, "mvn", "\t$Rd, $shift", |
| 2318 | [(set GPR:$Rd, (not so_reg:$shift))]>, UnaryDP { |
| 2319 | bits<4> Rd; |
| 2320 | bits<4> Rm; |
| 2321 | bits<12> shift; |
Johnny Chen | 48d5ccf | 2010-01-31 11:22:28 +0000 | [diff] [blame] | 2322 | let Inst{25} = 0; |
Jim Grosbach | 3686046 | 2010-10-21 22:19:32 +0000 | [diff] [blame] | 2323 | let Inst{19-16} = 0b0000; |
| 2324 | let Inst{15-12} = Rd; |
| 2325 | let Inst{11-0} = shift; |
Johnny Chen | 48d5ccf | 2010-01-31 11:22:28 +0000 | [diff] [blame] | 2326 | } |
Evan Cheng | b3379fb | 2009-02-05 08:42:55 +0000 | [diff] [blame] | 2327 | let isReMaterializable = 1, isAsCheapAsAMove = 1 in |
Jim Grosbach | 3686046 | 2010-10-21 22:19:32 +0000 | [diff] [blame] | 2328 | def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, |
| 2329 | IIC_iMVNi, "mvn", "\t$Rd, $imm", |
| 2330 | [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP { |
| 2331 | bits<4> Rd; |
| 2332 | bits<4> Rm; |
| 2333 | bits<12> imm; |
| 2334 | let Inst{25} = 1; |
| 2335 | let Inst{19-16} = 0b0000; |
| 2336 | let Inst{15-12} = Rd; |
| 2337 | let Inst{11-0} = imm; |
Evan Cheng | 7995ef3 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 2338 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2339 | |
| 2340 | def : ARMPat<(and GPR:$src, so_imm_not:$imm), |
| 2341 | (BICri GPR:$src, so_imm_not:$imm)>; |
| 2342 | |
| 2343 | //===----------------------------------------------------------------------===// |
| 2344 | // Multiply Instructions. |
| 2345 | // |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2346 | class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin, |
| 2347 | string opc, string asm, list<dag> pattern> |
| 2348 | : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> { |
| 2349 | bits<4> Rd; |
| 2350 | bits<4> Rm; |
| 2351 | bits<4> Rn; |
| 2352 | let Inst{19-16} = Rd; |
| 2353 | let Inst{11-8} = Rm; |
| 2354 | let Inst{3-0} = Rn; |
| 2355 | } |
| 2356 | class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin, |
| 2357 | string opc, string asm, list<dag> pattern> |
| 2358 | : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> { |
| 2359 | bits<4> RdLo; |
| 2360 | bits<4> RdHi; |
| 2361 | bits<4> Rm; |
| 2362 | bits<4> Rn; |
Jim Grosbach | 9463d0e | 2010-10-22 17:16:17 +0000 | [diff] [blame] | 2363 | let Inst{19-16} = RdHi; |
| 2364 | let Inst{15-12} = RdLo; |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2365 | let Inst{11-8} = Rm; |
| 2366 | let Inst{3-0} = Rn; |
| 2367 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2368 | |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 2369 | let isCommutable = 1 in |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2370 | def MUL : AsMul1I32<0b0000000, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2371 | IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm", |
| 2372 | [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2373 | |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2374 | def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2375 | IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra", |
| 2376 | [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]> { |
| 2377 | bits<4> Ra; |
| 2378 | let Inst{15-12} = Ra; |
| 2379 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2380 | |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2381 | def MLS : AMul1I<0b0000011, (outs GPR:$dst), (ins GPR:$a, GPR:$b, GPR:$c), |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 2382 | IIC_iMAC32, "mls", "\t$dst, $a, $b, $c", |
Evan Cheng | edcbada | 2009-07-06 22:05:45 +0000 | [diff] [blame] | 2383 | [(set GPR:$dst, (sub GPR:$c, (mul GPR:$a, GPR:$b)))]>, |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2384 | Requires<[IsARM, HasV6T2]> { |
| 2385 | bits<4> Rd; |
| 2386 | bits<4> Rm; |
| 2387 | bits<4> Rn; |
| 2388 | let Inst{19-16} = Rd; |
| 2389 | let Inst{11-8} = Rm; |
| 2390 | let Inst{3-0} = Rn; |
| 2391 | } |
Evan Cheng | edcbada | 2009-07-06 22:05:45 +0000 | [diff] [blame] | 2392 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2393 | // Extra precision multiplies with low / high results |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2394 | |
Evan Cheng | cd799b9 | 2009-06-12 20:46:18 +0000 | [diff] [blame] | 2395 | let neverHasSideEffects = 1 in { |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 2396 | let isCommutable = 1 in { |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2397 | def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi), |
| 2398 | (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64, |
| 2399 | "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2400 | |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2401 | def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi), |
| 2402 | (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64, |
| 2403 | "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>; |
Evan Cheng | 8de898a | 2009-06-26 00:19:44 +0000 | [diff] [blame] | 2404 | } |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2405 | |
| 2406 | // Multiply + accumulate |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2407 | def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi), |
| 2408 | (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64, |
| 2409 | "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2410 | |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2411 | def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi), |
| 2412 | (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64, |
| 2413 | "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2414 | |
Jim Grosbach | f50af8b | 2010-10-21 22:52:30 +0000 | [diff] [blame] | 2415 | def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi), |
| 2416 | (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64, |
| 2417 | "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>, |
| 2418 | Requires<[IsARM, HasV6]> { |
| 2419 | bits<4> RdLo; |
| 2420 | bits<4> RdHi; |
| 2421 | bits<4> Rm; |
| 2422 | bits<4> Rn; |
| 2423 | let Inst{19-16} = RdLo; |
| 2424 | let Inst{15-12} = RdHi; |
| 2425 | let Inst{11-8} = Rm; |
| 2426 | let Inst{3-0} = Rn; |
| 2427 | } |
Evan Cheng | cd799b9 | 2009-06-12 20:46:18 +0000 | [diff] [blame] | 2428 | } // neverHasSideEffects |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2429 | |
| 2430 | // Most significant word multiply |
Jim Grosbach | 9463d0e | 2010-10-22 17:16:17 +0000 | [diff] [blame] | 2431 | def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2432 | IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm", |
| 2433 | [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>, |
Evan Cheng | fbc9d41 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 2434 | Requires<[IsARM, HasV6]> { |
Evan Cheng | fbc9d41 | 2008-11-06 01:21:28 +0000 | [diff] [blame] | 2435 | let Inst{15-12} = 0b1111; |
| 2436 | } |
Evan Cheng | 13ab020 | 2007-07-10 18:08:01 +0000 | [diff] [blame] | 2437 | |
Jim Grosbach | 9463d0e | 2010-10-22 17:16:17 +0000 | [diff] [blame] | 2438 | def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2439 | IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 2440 | [/* For disassembly only; pattern left blank */]>, |
| 2441 | Requires<[IsARM, HasV6]> { |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 2442 | let Inst{15-12} = 0b1111; |
| 2443 | } |
| 2444 | |
Jim Grosbach | 9463d0e | 2010-10-22 17:16:17 +0000 | [diff] [blame] | 2445 | def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd), |
| 2446 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2447 | IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra", |
| 2448 | [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>, |
| 2449 | Requires<[IsARM, HasV6]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2450 | |
Jim Grosbach | 9463d0e | 2010-10-22 17:16:17 +0000 | [diff] [blame] | 2451 | def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd), |
| 2452 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2453 | IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 2454 | [/* For disassembly only; pattern left blank */]>, |
Jim Grosbach | 9463d0e | 2010-10-22 17:16:17 +0000 | [diff] [blame] | 2455 | Requires<[IsARM, HasV6]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2456 | |
Jim Grosbach | 9463d0e | 2010-10-22 17:16:17 +0000 | [diff] [blame] | 2457 | def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd), |
| 2458 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2459 | IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", |
| 2460 | [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>, |
| 2461 | Requires<[IsARM, HasV6]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2462 | |
Jim Grosbach | 9463d0e | 2010-10-22 17:16:17 +0000 | [diff] [blame] | 2463 | def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd), |
| 2464 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2465 | IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 2466 | [/* For disassembly only; pattern left blank */]>, |
Jim Grosbach | 9463d0e | 2010-10-22 17:16:17 +0000 | [diff] [blame] | 2467 | Requires<[IsARM, HasV6]>; |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 2468 | |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2469 | multiclass AI_smul<string opc, PatFrag opnode> { |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2470 | def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2471 | IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm", |
| 2472 | [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16), |
| 2473 | (sext_inreg GPR:$Rm, i16)))]>, |
| 2474 | Requires<[IsARM, HasV5TE]>; |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2475 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2476 | def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2477 | IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm", |
| 2478 | [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16), |
| 2479 | (sra GPR:$Rm, (i32 16))))]>, |
| 2480 | Requires<[IsARM, HasV5TE]>; |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2481 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2482 | def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2483 | IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm", |
| 2484 | [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)), |
| 2485 | (sext_inreg GPR:$Rm, i16)))]>, |
| 2486 | Requires<[IsARM, HasV5TE]>; |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2487 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2488 | def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2489 | IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm", |
| 2490 | [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)), |
| 2491 | (sra GPR:$Rm, (i32 16))))]>, |
| 2492 | Requires<[IsARM, HasV5TE]>; |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2493 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2494 | def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2495 | IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm", |
| 2496 | [(set GPR:$Rd, (sra (opnode GPR:$Rn, |
| 2497 | (sext_inreg GPR:$Rm, i16)), (i32 16)))]>, |
| 2498 | Requires<[IsARM, HasV5TE]>; |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2499 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2500 | def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2501 | IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm", |
| 2502 | [(set GPR:$Rd, (sra (opnode GPR:$Rn, |
| 2503 | (sra GPR:$Rm, (i32 16))), (i32 16)))]>, |
| 2504 | Requires<[IsARM, HasV5TE]>; |
Rafael Espindola | bec2e38 | 2006-10-16 16:33:29 +0000 | [diff] [blame] | 2505 | } |
| 2506 | |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2507 | |
| 2508 | multiclass AI_smla<string opc, PatFrag opnode> { |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2509 | def BB : AMulxyI<0b0001000, 0b00, (outs GPR:$Rd), |
| 2510 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2511 | IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra", |
| 2512 | [(set GPR:$Rd, (add GPR:$Ra, |
| 2513 | (opnode (sext_inreg GPR:$Rn, i16), |
| 2514 | (sext_inreg GPR:$Rm, i16))))]>, |
| 2515 | Requires<[IsARM, HasV5TE]>; |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2516 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2517 | def BT : AMulxyI<0b0001000, 0b10, (outs GPR:$Rd), |
| 2518 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2519 | IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra", |
| 2520 | [(set GPR:$Rd, (add GPR:$Ra, (opnode (sext_inreg GPR:$Rn, i16), |
| 2521 | (sra GPR:$Rm, (i32 16)))))]>, |
| 2522 | Requires<[IsARM, HasV5TE]>; |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2523 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2524 | def TB : AMulxyI<0b0001000, 0b01, (outs GPR:$Rd), |
| 2525 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2526 | IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra", |
| 2527 | [(set GPR:$Rd, (add GPR:$Ra, (opnode (sra GPR:$Rn, (i32 16)), |
| 2528 | (sext_inreg GPR:$Rm, i16))))]>, |
| 2529 | Requires<[IsARM, HasV5TE]>; |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2530 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2531 | def TT : AMulxyI<0b0001000, 0b11, (outs GPR:$Rd), |
| 2532 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2533 | IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra", |
| 2534 | [(set GPR:$Rd, (add GPR:$Ra, (opnode (sra GPR:$Rn, (i32 16)), |
| 2535 | (sra GPR:$Rm, (i32 16)))))]>, |
| 2536 | Requires<[IsARM, HasV5TE]>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2537 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2538 | def WB : AMulxyI<0b0001001, 0b00, (outs GPR:$Rd), |
| 2539 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2540 | IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra", |
| 2541 | [(set GPR:$Rd, (add GPR:$Ra, (sra (opnode GPR:$Rn, |
| 2542 | (sext_inreg GPR:$Rm, i16)), (i32 16))))]>, |
| 2543 | Requires<[IsARM, HasV5TE]>; |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2544 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2545 | def WT : AMulxyI<0b0001001, 0b10, (outs GPR:$Rd), |
| 2546 | (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2547 | IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra", |
| 2548 | [(set GPR:$Rd, (add GPR:$Ra, (sra (opnode GPR:$Rn, |
| 2549 | (sra GPR:$Rm, (i32 16))), (i32 16))))]>, |
| 2550 | Requires<[IsARM, HasV5TE]>; |
Rafael Espindola | 70673a1 | 2006-10-18 16:20:57 +0000 | [diff] [blame] | 2551 | } |
Rafael Espindola | 5c2aa0a | 2006-09-08 12:47:03 +0000 | [diff] [blame] | 2552 | |
Raul Herbster | 37fb5b1 | 2007-08-30 23:25:47 +0000 | [diff] [blame] | 2553 | defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>; |
| 2554 | defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>; |
Rafael Espindola | 2718519 | 2006-09-29 21:20:16 +0000 | [diff] [blame] | 2555 | |
Johnny Chen | 83498e5 | 2010-02-12 21:59:23 +0000 | [diff] [blame] | 2556 | // Halfword multiply accumulate long: SMLAL<x><y> -- for disassembly only |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2557 | def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPR:$RdLo, GPR:$RdHi), |
| 2558 | (ins GPR:$Rn, GPR:$Rm), |
| 2559 | IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", |
Johnny Chen | 83498e5 | 2010-02-12 21:59:23 +0000 | [diff] [blame] | 2560 | [/* For disassembly only; pattern left blank */]>, |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2561 | Requires<[IsARM, HasV5TE]>; |
Johnny Chen | 83498e5 | 2010-02-12 21:59:23 +0000 | [diff] [blame] | 2562 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2563 | def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPR:$RdLo, GPR:$RdHi), |
| 2564 | (ins GPR:$Rn, GPR:$Rm), |
| 2565 | IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", |
Johnny Chen | 83498e5 | 2010-02-12 21:59:23 +0000 | [diff] [blame] | 2566 | [/* For disassembly only; pattern left blank */]>, |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2567 | Requires<[IsARM, HasV5TE]>; |
Johnny Chen | 83498e5 | 2010-02-12 21:59:23 +0000 | [diff] [blame] | 2568 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2569 | def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPR:$RdLo, GPR:$RdHi), |
| 2570 | (ins GPR:$Rn, GPR:$Rm), |
| 2571 | IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", |
Johnny Chen | 83498e5 | 2010-02-12 21:59:23 +0000 | [diff] [blame] | 2572 | [/* For disassembly only; pattern left blank */]>, |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2573 | Requires<[IsARM, HasV5TE]>; |
Johnny Chen | 83498e5 | 2010-02-12 21:59:23 +0000 | [diff] [blame] | 2574 | |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2575 | def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPR:$RdLo, GPR:$RdHi), |
| 2576 | (ins GPR:$Rn, GPR:$Rm), |
| 2577 | IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", |
Johnny Chen | 83498e5 | 2010-02-12 21:59:23 +0000 | [diff] [blame] | 2578 | [/* For disassembly only; pattern left blank */]>, |
Jim Grosbach | 3870b75 | 2010-10-22 18:35:16 +0000 | [diff] [blame] | 2579 | Requires<[IsARM, HasV5TE]>; |
Johnny Chen | 83498e5 | 2010-02-12 21:59:23 +0000 | [diff] [blame] | 2580 | |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2581 | // Helper class for AI_smld -- for disassembly only |
Jim Grosbach | 385e136 | 2010-10-22 19:15:30 +0000 | [diff] [blame] | 2582 | class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops, |
| 2583 | InstrItinClass itin, string opc, string asm> |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2584 | : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> { |
Jim Grosbach | 385e136 | 2010-10-22 19:15:30 +0000 | [diff] [blame] | 2585 | bits<4> Rn; |
| 2586 | bits<4> Rm; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2587 | let Inst{4} = 1; |
| 2588 | let Inst{5} = swap; |
| 2589 | let Inst{6} = sub; |
| 2590 | let Inst{7} = 0; |
| 2591 | let Inst{21-20} = 0b00; |
| 2592 | let Inst{22} = long; |
| 2593 | let Inst{27-23} = 0b01110; |
Jim Grosbach | 385e136 | 2010-10-22 19:15:30 +0000 | [diff] [blame] | 2594 | let Inst{11-8} = Rm; |
| 2595 | let Inst{3-0} = Rn; |
| 2596 | } |
| 2597 | class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops, |
| 2598 | InstrItinClass itin, string opc, string asm> |
| 2599 | : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> { |
| 2600 | bits<4> Rd; |
| 2601 | let Inst{15-12} = 0b1111; |
| 2602 | let Inst{19-16} = Rd; |
| 2603 | } |
| 2604 | class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops, |
| 2605 | InstrItinClass itin, string opc, string asm> |
| 2606 | : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> { |
| 2607 | bits<4> Ra; |
| 2608 | let Inst{15-12} = Ra; |
| 2609 | } |
| 2610 | class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops, |
| 2611 | InstrItinClass itin, string opc, string asm> |
| 2612 | : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> { |
| 2613 | bits<4> RdLo; |
| 2614 | bits<4> RdHi; |
| 2615 | let Inst{19-16} = RdHi; |
| 2616 | let Inst{15-12} = RdLo; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2617 | } |
| 2618 | |
| 2619 | multiclass AI_smld<bit sub, string opc> { |
| 2620 | |
Jim Grosbach | 385e136 | 2010-10-22 19:15:30 +0000 | [diff] [blame] | 2621 | def D : AMulDualIa<0, sub, 0, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2622 | NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2623 | |
Jim Grosbach | 385e136 | 2010-10-22 19:15:30 +0000 | [diff] [blame] | 2624 | def DX: AMulDualIa<0, sub, 1, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra), |
| 2625 | NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2626 | |
Jim Grosbach | 385e136 | 2010-10-22 19:15:30 +0000 | [diff] [blame] | 2627 | def LD: AMulDualI64<1, sub, 0, (outs GPR:$RdLo,GPR:$RdHi), |
| 2628 | (ins GPR:$Rn, GPR:$Rm), NoItinerary, |
| 2629 | !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2630 | |
Jim Grosbach | 385e136 | 2010-10-22 19:15:30 +0000 | [diff] [blame] | 2631 | def LDX : AMulDualI64<1, sub, 1, (outs GPR:$RdLo,GPR:$RdHi), |
| 2632 | (ins GPR:$Rn, GPR:$Rm), NoItinerary, |
| 2633 | !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">; |
Johnny Chen | 667d127 | 2010-02-22 18:50:54 +0000 | [diff] [blame] | 2634 | |
| 2635 | } |
| 2636 | |
| 2637 | defm SMLA : AI_smld<0, "smla">; |
| 2638 | defm SMLS : AI_smld<1, "smls">; |
| 2639 | |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 2640 | multiclass AI_sdml<bit sub, string opc> { |
| 2641 | |
Jim Grosbach | 385e136 | 2010-10-22 19:15:30 +0000 | [diff] [blame] | 2642 | def D : AMulDualI<0, sub, 0, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2643 | NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">; |
| 2644 | def DX : AMulDualI<0, sub, 1, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), |
| 2645 | NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">; |
Johnny Chen | 2ec5e49 | 2010-02-22 21:50:40 +0000 | [diff] [blame] | 2646 | } |
| 2647 | |
| 2648 | defm SMUA : AI_sdml<0, "smua">; |
| 2649 | defm SMUS : AI_sdml<1, "smus">; |
Rafael Espindola | 42b62f3 | 2006-10-13 13:14:59 +0000 | [diff] [blame] | 2650 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2651 | //===----------------------------------------------------------------------===// |
| 2652 | // Misc. Arithmetic Instructions. |
| 2653 | // |
Rafael Espindola | 0d9fe76 | 2006-10-10 16:33:47 +0000 | [diff] [blame] | 2654 | |
Jim Grosbach | f8da5f5 | 2010-10-22 22:12:16 +0000 | [diff] [blame] | 2655 | def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm), |
| 2656 | IIC_iUNAr, "clz", "\t$Rd, $Rm", |
| 2657 | [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>; |
Rafael Espindola | 199dd67 | 2006-10-17 13:13:23 +0000 | [diff] [blame] | 2658 | |
Jim Grosbach | f8da5f5 | 2010-10-22 22:12:16 +0000 | [diff] [blame] | 2659 | def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm), |
| 2660 | IIC_iUNAr, "rbit", "\t$Rd, $Rm", |
| 2661 | [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>, |
| 2662 | Requires<[IsARM, HasV6T2]>; |
Jim Grosbach | 3482c80 | 2010-01-18 19:58:49 +0000 | [diff] [blame] | 2663 | |
Jim Grosbach | f8da5f5 | 2010-10-22 22:12:16 +0000 | [diff] [blame] | 2664 | def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm), |
| 2665 | IIC_iUNAr, "rev", "\t$Rd, $Rm", |
| 2666 | [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>; |
Rafael Espindola | 199dd67 | 2006-10-17 13:13:23 +0000 | [diff] [blame] | 2667 | |
Jim Grosbach | f8da5f5 | 2010-10-22 22:12:16 +0000 | [diff] [blame] | 2668 | def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm), |
| 2669 | IIC_iUNAr, "rev16", "\t$Rd, $Rm", |
| 2670 | [(set GPR:$Rd, |
| 2671 | (or (and (srl GPR:$Rm, (i32 8)), 0xFF), |
| 2672 | (or (and (shl GPR:$Rm, (i32 8)), 0xFF00), |
| 2673 | (or (and (srl GPR:$Rm, (i32 8)), 0xFF0000), |
| 2674 | (and (shl GPR:$Rm, (i32 8)), 0xFF000000)))))]>, |
| 2675 | Requires<[IsARM, HasV6]>; |
Rafael Espindola | 2718519 | 2006-09-29 21:20:16 +0000 | [diff] [blame] | 2676 | |
Jim Grosbach | f8da5f5 | 2010-10-22 22:12:16 +0000 | [diff] [blame] | 2677 | def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm), |
| 2678 | IIC_iUNAr, "revsh", "\t$Rd, $Rm", |
| 2679 | [(set GPR:$Rd, |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2680 | (sext_inreg |
Jim Grosbach | f8da5f5 | 2010-10-22 22:12:16 +0000 | [diff] [blame] | 2681 | (or (srl (and GPR:$Rm, 0xFF00), (i32 8)), |
| 2682 | (shl GPR:$Rm, (i32 8))), i16))]>, |
| 2683 | Requires<[IsARM, HasV6]>; |
Rafael Espindola | 2718519 | 2006-09-29 21:20:16 +0000 | [diff] [blame] | 2684 | |
Bob Wilson | f955f29 | 2010-08-17 17:23:19 +0000 | [diff] [blame] | 2685 | def lsl_shift_imm : SDNodeXForm<imm, [{ |
| 2686 | unsigned Sh = ARM_AM::getSORegOpc(ARM_AM::lsl, N->getZExtValue()); |
| 2687 | return CurDAG->getTargetConstant(Sh, MVT::i32); |
| 2688 | }]>; |
| 2689 | |
| 2690 | def lsl_amt : PatLeaf<(i32 imm), [{ |
| 2691 | return (N->getZExtValue() < 32); |
| 2692 | }], lsl_shift_imm>; |
| 2693 | |
Jim Grosbach | f8da5f5 | 2010-10-22 22:12:16 +0000 | [diff] [blame] | 2694 | def PKHBT : APKHI<0b01101000, 0, (outs GPR:$Rd), |
| 2695 | (ins GPR:$Rn, GPR:$Rm, shift_imm:$sh), |
| 2696 | IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh", |
| 2697 | [(set GPR:$Rd, (or (and GPR:$Rn, 0xFFFF), |
| 2698 | (and (shl GPR:$Rm, lsl_amt:$sh), |
| 2699 | 0xFFFF0000)))]>, |
| 2700 | Requires<[IsARM, HasV6]>; |
Rafael Espindola | 2718519 | 2006-09-29 21:20:16 +0000 | [diff] [blame] | 2701 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2702 | // Alternate cases for PKHBT where identities eliminate some nodes. |
Jim Grosbach | f8da5f5 | 2010-10-22 22:12:16 +0000 | [diff] [blame] | 2703 | def : ARMV6Pat<(or (and GPR:$Rn, 0xFFFF), (and GPR:$Rm, 0xFFFF0000)), |
| 2704 | (PKHBT GPR:$Rn, GPR:$Rm, 0)>; |
| 2705 | def : ARMV6Pat<(or (and GPR:$Rn, 0xFFFF), (shl GPR:$Rm, imm16_31:$sh)), |
| 2706 | (PKHBT GPR:$Rn, GPR:$Rm, (lsl_shift_imm imm16_31:$sh))>; |
Rafael Espindola | 9e071f0 | 2006-10-02 19:30:56 +0000 | [diff] [blame] | 2707 | |
Bob Wilson | f955f29 | 2010-08-17 17:23:19 +0000 | [diff] [blame] | 2708 | def asr_shift_imm : SDNodeXForm<imm, [{ |
| 2709 | unsigned Sh = ARM_AM::getSORegOpc(ARM_AM::asr, N->getZExtValue()); |
| 2710 | return CurDAG->getTargetConstant(Sh, MVT::i32); |
| 2711 | }]>; |
| 2712 | |
| 2713 | def asr_amt : PatLeaf<(i32 imm), [{ |
| 2714 | return (N->getZExtValue() <= 32); |
| 2715 | }], asr_shift_imm>; |
Rafael Espindola | a284584 | 2006-10-05 16:48:49 +0000 | [diff] [blame] | 2716 | |
Bob Wilson | dc66eda | 2010-08-16 22:26:55 +0000 | [diff] [blame] | 2717 | // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and |
| 2718 | // will match the pattern below. |
Jim Grosbach | f8da5f5 | 2010-10-22 22:12:16 +0000 | [diff] [blame] | 2719 | def PKHTB : APKHI<0b01101000, 1, (outs GPR:$Rd), |
| 2720 | (ins GPR:$Rn, GPR:$Rm, shift_imm:$sh), |
| 2721 | IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh", |
| 2722 | [(set GPR:$Rd, (or (and GPR:$Rn, 0xFFFF0000), |
| 2723 | (and (sra GPR:$Rm, asr_amt:$sh), |
| 2724 | 0xFFFF)))]>, |
| 2725 | Requires<[IsARM, HasV6]>; |
Rafael Espindola | 9e071f0 | 2006-10-02 19:30:56 +0000 | [diff] [blame] | 2726 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2727 | // Alternate cases for PKHTB where identities eliminate some nodes. Note that |
| 2728 | // a shift amount of 0 is *not legal* here, it is PKHBT instead. |
Bob Wilson | dc66eda | 2010-08-16 22:26:55 +0000 | [diff] [blame] | 2729 | def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, imm16_31:$sh)), |
Bob Wilson | f955f29 | 2010-08-17 17:23:19 +0000 | [diff] [blame] | 2730 | (PKHTB GPR:$src1, GPR:$src2, (asr_shift_imm imm16_31:$sh))>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2731 | def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), |
Bob Wilson | f955f29 | 2010-08-17 17:23:19 +0000 | [diff] [blame] | 2732 | (and (srl GPR:$src2, imm1_15:$sh), 0xFFFF)), |
| 2733 | (PKHTB GPR:$src1, GPR:$src2, (asr_shift_imm imm1_15:$sh))>; |
Rafael Espindola | b47e1d0 | 2006-10-10 18:55:14 +0000 | [diff] [blame] | 2734 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2735 | //===----------------------------------------------------------------------===// |
| 2736 | // Comparison Instructions... |
| 2737 | // |
Rafael Espindola | b47e1d0 | 2006-10-10 18:55:14 +0000 | [diff] [blame] | 2738 | |
Jim Grosbach | 2642196 | 2008-10-14 20:36:24 +0000 | [diff] [blame] | 2739 | defm CMP : AI1_cmp_irs<0b1010, "cmp", |
Evan Cheng | 5d42c56 | 2010-09-29 00:49:25 +0000 | [diff] [blame] | 2740 | IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, |
Evan Cheng | 0ff94f7 | 2007-08-07 01:37:15 +0000 | [diff] [blame] | 2741 | BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>; |
Bill Wendling | 6165e87 | 2010-08-26 18:33:51 +0000 | [diff] [blame] | 2742 | |
Bill Wendling | c8714bb | 2010-09-10 10:31:11 +0000 | [diff] [blame] | 2743 | // FIXME: We have to be careful when using the CMN instruction and comparison |
| 2744 | // with 0. One would expect these two pieces of code should give identical |
Bill Wendling | 6165e87 | 2010-08-26 18:33:51 +0000 | [diff] [blame] | 2745 | // results: |
| 2746 | // |
| 2747 | // rsbs r1, r1, 0 |
| 2748 | // cmp r0, r1 |
| 2749 | // mov r0, #0 |
| 2750 | // it ls |
| 2751 | // mov r0, #1 |
| 2752 | // |
| 2753 | // and: |
Jim Grosbach | a9a968d | 2010-10-22 23:48:29 +0000 | [diff] [blame] | 2754 | // |
Bill Wendling | 6165e87 | 2010-08-26 18:33:51 +0000 | [diff] [blame] | 2755 | // cmn r0, r1 |
| 2756 | // mov r0, #0 |
| 2757 | // it ls |
| 2758 | // mov r0, #1 |
| 2759 | // |
| 2760 | // However, the CMN gives the *opposite* result when r1 is 0. This is because |
| 2761 | // the carry flag is set in the CMP case but not in the CMN case. In short, the |
| 2762 | // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the |
| 2763 | // value of r0 and the carry bit (because the "carry bit" parameter to |
| 2764 | // AddWithCarry is defined as 1 in this case, the carry flag will always be set |
| 2765 | // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is |
| 2766 | // never a "carry" when this AddWithCarry is performed (because the "carry bit" |
| 2767 | // parameter to AddWithCarry is defined as 0). |
| 2768 | // |
Bill Wendling | c8714bb | 2010-09-10 10:31:11 +0000 | [diff] [blame] | 2769 | // When x is 0 and unsigned: |
Bill Wendling | 6165e87 | 2010-08-26 18:33:51 +0000 | [diff] [blame] | 2770 | // |
| 2771 | // x = 0 |
| 2772 | // ~x = 0xFFFF FFFF |
| 2773 | // ~x + 1 = 0x1 0000 0000 |
| 2774 | // (-x = 0) != (0x1 0000 0000 = ~x + 1) |
| 2775 | // |
Bill Wendling | c8714bb | 2010-09-10 10:31:11 +0000 | [diff] [blame] | 2776 | // Therefore, we should disable CMN when comparing against zero, until we can |
| 2777 | // limit when the CMN instruction is used (when we know that the RHS is not 0 or |
| 2778 | // when it's a comparison which doesn't look at the 'carry' flag). |
Bill Wendling | 6165e87 | 2010-08-26 18:33:51 +0000 | [diff] [blame] | 2779 | // |
| 2780 | // (See the ARM docs for the "AddWithCarry" pseudo-code.) |
| 2781 | // |
| 2782 | // This is related to <rdar://problem/7569620>. |
| 2783 | // |
Jim Grosbach | d5d2bae | 2010-01-22 00:08:13 +0000 | [diff] [blame] | 2784 | //defm CMN : AI1_cmp_irs<0b1011, "cmn", |
| 2785 | // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>; |
Rafael Espindola | e5bbd6d | 2006-10-07 14:24:52 +0000 | [diff] [blame] | 2786 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2787 | // Note that TST/TEQ don't set all the same flags that CMP does! |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 2788 | defm TST : AI1_cmp_irs<0b1000, "tst", |
Evan Cheng | 5d42c56 | 2010-09-29 00:49:25 +0000 | [diff] [blame] | 2789 | IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr, |
David Goodwin | c0309b4 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 2790 | BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>, 1>; |
Evan Cheng | d87293c | 2008-11-06 08:47:38 +0000 | [diff] [blame] | 2791 | defm TEQ : AI1_cmp_irs<0b1001, "teq", |
Evan Cheng | 5d42c56 | 2010-09-29 00:49:25 +0000 | [diff] [blame] | 2792 | IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr, |
David Goodwin | c0309b4 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 2793 | BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>, 1>; |
Lauro Ramos Venancio | 9996663 | 2007-04-02 01:30:03 +0000 | [diff] [blame] | 2794 | |
David Goodwin | c0309b4 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 2795 | defm CMPz : AI1_cmp_irs<0b1010, "cmp", |
Evan Cheng | 5d42c56 | 2010-09-29 00:49:25 +0000 | [diff] [blame] | 2796 | IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, |
David Goodwin | c0309b4 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 2797 | BinOpFrag<(ARMcmpZ node:$LHS, node:$RHS)>>; |
| 2798 | defm CMNz : AI1_cmp_irs<0b1011, "cmn", |
Evan Cheng | 5d42c56 | 2010-09-29 00:49:25 +0000 | [diff] [blame] | 2799 | IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, |
David Goodwin | c0309b4 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 2800 | BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>; |
Evan Cheng | 2c614c5 | 2007-06-06 10:17:05 +0000 | [diff] [blame] | 2801 | |
Jim Grosbach | d5d2bae | 2010-01-22 00:08:13 +0000 | [diff] [blame] | 2802 | //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm), |
| 2803 | // (CMNri GPR:$src, so_imm_neg:$imm)>; |
Lauro Ramos Venancio | 9996663 | 2007-04-02 01:30:03 +0000 | [diff] [blame] | 2804 | |
David Goodwin | c0309b4 | 2009-06-29 15:33:01 +0000 | [diff] [blame] | 2805 | def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm), |
Jim Grosbach | d5d2bae | 2010-01-22 00:08:13 +0000 | [diff] [blame] | 2806 | (CMNzri GPR:$src, so_imm_neg:$imm)>; |
Lauro Ramos Venancio | 9996663 | 2007-04-02 01:30:03 +0000 | [diff] [blame] | 2807 | |
Evan Cheng | 218977b | 2010-07-13 19:27:42 +0000 | [diff] [blame] | 2808 | // Pseudo i64 compares for some floating point compares. |
| 2809 | let usesCustomInserter = 1, isBranch = 1, isTerminator = 1, |
| 2810 | Defs = [CPSR] in { |
| 2811 | def BCCi64 : PseudoInst<(outs), |
Jim Grosbach | c5ed013 | 2010-08-17 18:39:16 +0000 | [diff] [blame] | 2812 | (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst), |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2813 | IIC_Br, "", |
Evan Cheng | 218977b | 2010-07-13 19:27:42 +0000 | [diff] [blame] | 2814 | [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>; |
| 2815 | |
| 2816 | def BCCZi64 : PseudoInst<(outs), |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2817 | (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br, "", |
Evan Cheng | 218977b | 2010-07-13 19:27:42 +0000 | [diff] [blame] | 2818 | [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>; |
| 2819 | } // usesCustomInserter |
| 2820 | |
Rafael Espindola | e5bbd6d | 2006-10-07 14:24:52 +0000 | [diff] [blame] | 2821 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 2822 | // Conditional moves |
Evan Cheng | c85e832 | 2007-07-05 07:13:32 +0000 | [diff] [blame] | 2823 | // FIXME: should be able to write a pattern for ARMcmov, but can't use |
Jim Grosbach | 6417171 | 2010-02-16 21:07:46 +0000 | [diff] [blame] | 2824 | // a two-value operand where a dag node expects two operands. :( |
Jim Grosbach | 3bbdcea | 2010-10-07 00:42:42 +0000 | [diff] [blame] | 2825 | // FIXME: These should all be pseudo-instructions that get expanded to |
| 2826 | // the normal MOV instructions. That would fix the dependency on |
| 2827 | // special casing them in tblgen. |
Owen Anderson | f523e47 | 2010-09-23 23:45:25 +0000 | [diff] [blame] | 2828 | let neverHasSideEffects = 1 in { |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 2829 | def MOVCCr : AI1<0b1101, (outs GPR:$Rd), (ins GPR:$false, GPR:$Rm), DPFrm, |
| 2830 | IIC_iCMOVr, "mov", "\t$Rd, $Rm", |
| 2831 | [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>, |
| 2832 | RegConstraint<"$false = $Rd">, UnaryDP { |
| 2833 | bits<4> Rd; |
| 2834 | bits<4> Rm; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 2835 | let Inst{25} = 0; |
Jim Grosbach | 27e9008 | 2010-10-29 19:28:17 +0000 | [diff] [blame] | 2836 | let Inst{20} = 0; |
Jim Grosbach | 89c898f | 2010-10-13 00:50:27 +0000 | [diff] [blame] | 2837 | let Inst{15-12} = Rd; |
Johnny Chen | 0430152 | 2009-11-07 00:54:36 +0000 | [diff] [blame] | 2838 | let Inst{11-4} = 0b00000000; |
Jim Grosbach | 27e9008 | 2010-10-29 19:28:17 +0000 | [diff] [blame] | 2839 | let Inst{3-0} = Rm; |
Bob Wilson | 8e86b51 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 2840 | } |
Rafael Espindola | 493a7fc | 2006-10-10 20:38:57 +0000 | [diff] [blame] | 2841 | |
Jim Grosbach | 27e9008 | 2010-10-29 19:28:17 +0000 | [diff] [blame] | 2842 | def MOVCCs : AI1<0b1101, (outs GPR:$Rd), |
| 2843 | (ins GPR:$false, so_reg:$shift), DPSoRegFrm, IIC_iCMOVsr, |
| 2844 | "mov", "\t$Rd, $shift", |
| 2845 | [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg:$shift, imm:$cc, CCR:$ccr))*/]>, |
| 2846 | RegConstraint<"$false = $Rd">, UnaryDP { |
| 2847 | bits<4> Rd; |
| 2848 | bits<4> Rn; |
| 2849 | bits<12> shift; |
Bob Wilson | 8e86b51 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 2850 | let Inst{25} = 0; |
Jim Grosbach | 3bbdcea | 2010-10-07 00:42:42 +0000 | [diff] [blame] | 2851 | let Inst{20} = 0; |
Jim Grosbach | 27e9008 | 2010-10-29 19:28:17 +0000 | [diff] [blame] | 2852 | let Inst{19-16} = Rn; |
| 2853 | let Inst{15-12} = Rd; |
| 2854 | let Inst{11-0} = shift; |
Jim Grosbach | 3bbdcea | 2010-10-07 00:42:42 +0000 | [diff] [blame] | 2855 | } |
| 2856 | |
Jim Grosbach | 27e9008 | 2010-10-29 19:28:17 +0000 | [diff] [blame] | 2857 | def MOVCCi16 : AI1<0b1000, (outs GPR:$Rd), (ins GPR:$false, i32imm:$imm), |
| 2858 | DPFrm, IIC_iMOVi, |
| 2859 | "movw", "\t$Rd, $imm", |
| 2860 | []>, |
| 2861 | RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>, |
| 2862 | UnaryDP { |
| 2863 | bits<4> Rd; |
| 2864 | bits<16> imm; |
Bob Wilson | 8e86b51 | 2009-10-14 19:00:24 +0000 | [diff] [blame] | 2865 | let Inst{25} = 1; |
Jim Grosbach | 27e9008 | 2010-10-29 19:28:17 +0000 | [diff] [blame] | 2866 | let Inst{20} = 0; |
| 2867 | let Inst{19-16} = imm{15-12}; |
| 2868 | let Inst{15-12} = Rd; |
| 2869 | let Inst{11-0} = imm{11-0}; |
| 2870 | } |
| 2871 | |
| 2872 | def MOVCCi : AI1<0b1101, (outs GPR:$Rd), |
| 2873 | (ins GPR:$false, so_imm:$imm), DPFrm, IIC_iCMOVi, |
| 2874 | "mov", "\t$Rd, $imm", |
| 2875 | [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>, |
| 2876 | RegConstraint<"$false = $Rd">, UnaryDP { |
| 2877 | bits<4> Rd; |
| 2878 | bits<12> imm; |
| 2879 | let Inst{25} = 1; |
| 2880 | let Inst{20} = 0; |
| 2881 | let Inst{19-16} = 0b0000; |
| 2882 | let Inst{15-12} = Rd; |
| 2883 | let Inst{11-0} = imm; |
Evan Cheng | 7995ef3 | 2009-09-09 01:47:07 +0000 | [diff] [blame] | 2884 | } |
Owen Anderson | f523e47 | 2010-09-23 23:45:25 +0000 | [diff] [blame] | 2885 | } // neverHasSideEffects |
Rafael Espindola | d9ae778 | 2006-10-07 13:46:42 +0000 | [diff] [blame] | 2886 | |
Jim Grosbach | 3728e96 | 2009-12-10 00:11:09 +0000 | [diff] [blame] | 2887 | //===----------------------------------------------------------------------===// |
| 2888 | // Atomic operations intrinsics |
| 2889 | // |
| 2890 | |
Bob Wilson | f74a429 | 2010-10-30 00:54:37 +0000 | [diff] [blame] | 2891 | def memb_opt : Operand<i32> { |
| 2892 | let PrintMethod = "printMemBOption"; |
Jim Grosbach | cbd77d2 | 2009-12-10 18:35:32 +0000 | [diff] [blame] | 2893 | } |
Jim Grosbach | 3728e96 | 2009-12-10 00:11:09 +0000 | [diff] [blame] | 2894 | |
Bob Wilson | f74a429 | 2010-10-30 00:54:37 +0000 | [diff] [blame] | 2895 | // memory barriers protect the atomic sequences |
| 2896 | let hasSideEffects = 1 in { |
| 2897 | def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary, |
| 2898 | "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>, |
| 2899 | Requires<[IsARM, HasDB]> { |
| 2900 | bits<4> opt; |
| 2901 | let Inst{31-4} = 0xf57ff05; |
| 2902 | let Inst{3-0} = opt; |
Jim Grosbach | cbd77d2 | 2009-12-10 18:35:32 +0000 | [diff] [blame] | 2903 | } |
Jim Grosbach | 7c03dbd | 2009-12-14 21:24:16 +0000 | [diff] [blame] | 2904 | |
Johnny Chen | 7def14f | 2010-08-11 23:35:12 +0000 | [diff] [blame] | 2905 | def DMB_MCR : AInoP<(outs), (ins GPR:$zero), MiscFrm, NoItinerary, |
Jim Grosbach | 7c03dbd | 2009-12-14 21:24:16 +0000 | [diff] [blame] | 2906 | "mcr", "\tp15, 0, $zero, c7, c10, 5", |
Evan Cheng | 11db068 | 2010-08-11 06:22:01 +0000 | [diff] [blame] | 2907 | [(ARMMemBarrierMCR GPR:$zero)]>, |
Jim Grosbach | 7c03dbd | 2009-12-14 21:24:16 +0000 | [diff] [blame] | 2908 | Requires<[IsARM, HasV6]> { |
Jim Grosbach | 7c03dbd | 2009-12-14 21:24:16 +0000 | [diff] [blame] | 2909 | // FIXME: add encoding |
| 2910 | } |
Jim Grosbach | 3728e96 | 2009-12-10 00:11:09 +0000 | [diff] [blame] | 2911 | } |
Rafael Espindola | 4b20fbc | 2006-10-10 12:56:00 +0000 | [diff] [blame] | 2912 | |
Bob Wilson | f74a429 | 2010-10-30 00:54:37 +0000 | [diff] [blame] | 2913 | def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary, |
| 2914 | "dsb", "\t$opt", |
| 2915 | [/* For disassembly only; pattern left blank */]>, |
| 2916 | Requires<[IsARM, HasDB]> { |
| 2917 | bits<4> opt; |
| 2918 | let Inst{31-4} = 0xf57ff04; |
| 2919 | let Inst{3-0} = opt; |
Johnny Chen | fd6037d | 2010-02-18 00:19:08 +0000 | [diff] [blame] | 2920 | } |
| 2921 | |
Johnny Chen | fd6037d | 2010-02-18 00:19:08 +0000 | [diff] [blame] | 2922 | // ISB has only full system option -- for disassembly only |
Bob Wilson | f74a429 | 2010-10-30 00:54:37 +0000 | [diff] [blame] | 2923 | def ISB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "isb", "", []>, |
| 2924 | Requires<[IsARM, HasDB]> { |
Johnny Chen | 1adc40c | 2010-08-12 20:46:17 +0000 | [diff] [blame] | 2925 | let Inst{31-4} = 0xf57ff06; |
Johnny Chen | fd6037d | 2010-02-18 00:19:08 +0000 | [diff] [blame] | 2926 | let Inst{3-0} = 0b1111; |
| 2927 | } |
| 2928 | |
Jim Grosbach | 6686910 | 2009-12-11 18:52:41 +0000 | [diff] [blame] | 2929 | let usesCustomInserter = 1 in { |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2930 | let Uses = [CPSR] in { |
| 2931 | def ATOMIC_LOAD_ADD_I8 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2932 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2933 | [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>; |
| 2934 | def ATOMIC_LOAD_SUB_I8 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2935 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2936 | [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>; |
| 2937 | def ATOMIC_LOAD_AND_I8 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2938 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2939 | [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>; |
| 2940 | def ATOMIC_LOAD_OR_I8 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2941 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2942 | [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>; |
| 2943 | def ATOMIC_LOAD_XOR_I8 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2944 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2945 | [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>; |
| 2946 | def ATOMIC_LOAD_NAND_I8 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2947 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2948 | [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>; |
| 2949 | def ATOMIC_LOAD_ADD_I16 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2950 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2951 | [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>; |
| 2952 | def ATOMIC_LOAD_SUB_I16 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2953 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2954 | [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>; |
| 2955 | def ATOMIC_LOAD_AND_I16 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2956 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2957 | [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>; |
| 2958 | def ATOMIC_LOAD_OR_I16 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2959 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2960 | [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>; |
| 2961 | def ATOMIC_LOAD_XOR_I16 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2962 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2963 | [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>; |
| 2964 | def ATOMIC_LOAD_NAND_I16 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2965 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2966 | [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>; |
| 2967 | def ATOMIC_LOAD_ADD_I32 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2968 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2969 | [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>; |
| 2970 | def ATOMIC_LOAD_SUB_I32 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2971 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2972 | [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>; |
| 2973 | def ATOMIC_LOAD_AND_I32 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2974 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2975 | [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>; |
| 2976 | def ATOMIC_LOAD_OR_I32 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2977 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2978 | [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>; |
| 2979 | def ATOMIC_LOAD_XOR_I32 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2980 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2981 | [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>; |
| 2982 | def ATOMIC_LOAD_NAND_I32 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2983 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2984 | [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>; |
| 2985 | |
| 2986 | def ATOMIC_SWAP_I8 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2987 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2988 | [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>; |
| 2989 | def ATOMIC_SWAP_I16 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2990 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2991 | [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>; |
| 2992 | def ATOMIC_SWAP_I32 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2993 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2994 | [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>; |
| 2995 | |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2996 | def ATOMIC_CMP_SWAP_I8 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 2997 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 2998 | [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>; |
| 2999 | def ATOMIC_CMP_SWAP_I16 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 3000 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 3001 | [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>; |
| 3002 | def ATOMIC_CMP_SWAP_I32 : PseudoInst< |
Jim Grosbach | adde5da | 2010-10-01 23:09:33 +0000 | [diff] [blame] | 3003 | (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary, "", |
Jim Grosbach | e801dc4 | 2009-12-12 01:40:06 +0000 | [diff] [blame] | 3004 | [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>; |
| 3005 | } |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3006 | } |
| 3007 | |
| 3008 | let mayLoad = 1 in { |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3009 | def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary, |
| 3010 | "ldrexb", "\t$Rt, [$Rn]", |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3011 | []>; |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3012 | def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary, |
| 3013 | "ldrexh", "\t$Rt, [$Rn]", |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3014 | []>; |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3015 | def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins GPR:$Rn), NoItinerary, |
| 3016 | "ldrex", "\t$Rt, [$Rn]", |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3017 | []>; |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3018 | def LDREXD : AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2), (ins GPR:$Rn), |
Jim Grosbach | d7d72d6 | 2009-12-14 17:02:55 +0000 | [diff] [blame] | 3019 | NoItinerary, |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3020 | "ldrexd", "\t$Rt, $Rt2, [$Rn]", |
Jim Grosbach | d7d72d6 | 2009-12-14 17:02:55 +0000 | [diff] [blame] | 3021 | []>; |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3022 | } |
| 3023 | |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3024 | let mayStore = 1, Constraints = "@earlyclobber $Rd" in { |
| 3025 | def STREXB : AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$src, GPR:$Rn), |
Jim Grosbach | d7d72d6 | 2009-12-14 17:02:55 +0000 | [diff] [blame] | 3026 | NoItinerary, |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3027 | "strexb", "\t$Rd, $src, [$Rn]", |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3028 | []>; |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3029 | def STREXH : AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, GPR:$Rn), |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3030 | NoItinerary, |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3031 | "strexh", "\t$Rd, $Rt, [$Rn]", |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3032 | []>; |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3033 | def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, GPR:$Rn), |
Jim Grosbach | d7d72d6 | 2009-12-14 17:02:55 +0000 | [diff] [blame] | 3034 | NoItinerary, |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3035 | "strex", "\t$Rd, $Rt, [$Rn]", |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3036 | []>; |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3037 | def STREXD : AIstrex<0b01, (outs GPR:$Rd), |
| 3038 | (ins GPR:$Rt, GPR:$Rt2, GPR:$Rn), |
Jim Grosbach | d7d72d6 | 2009-12-14 17:02:55 +0000 | [diff] [blame] | 3039 | NoItinerary, |
Jim Grosbach | 86875a2 | 2010-10-29 19:58:57 +0000 | [diff] [blame] | 3040 | "strexd", "\t$Rd, $Rt, $Rt2, [$Rn]", |
Jim Grosbach | d7d72d6 | 2009-12-14 17:02:55 +0000 | [diff] [blame] | 3041 | []>; |
Jim Grosbach | 5278eb8 | 2009-12-11 01:42:04 +0000 | [diff] [blame] | 3042 | } |
| 3043 | |
Johnny Chen | b943627 | 2010-02-17 22:37:58 +0000 | [diff] [blame] | 3044 | // Clear-Exclusive is for disassembly only. |
| 3045 | def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", |
| 3046 | [/* For disassembly only; pattern left blank */]>, |
| 3047 | Requires<[IsARM, HasV7]> { |
Jim Grosbach | f32ecc6 | 2010-10-29 20:21:36 +0000 | [diff] [blame] | 3048 | let Inst{31-0} = 0b11110101011111111111000000011111; |
Johnny Chen | b943627 | 2010-02-17 22:37:58 +0000 | [diff] [blame] | 3049 | } |
| 3050 | |
Johnny Chen | b3e1bf5 | 2010-02-12 20:48:24 +0000 | [diff] [blame] | 3051 | // SWP/SWPB are deprecated in V6/V7 and for disassembly only. |
| 3052 | let mayLoad = 1 in { |
Jim Grosbach | f32ecc6 | 2010-10-29 20:21:36 +0000 | [diff] [blame] | 3053 | def SWP : AIswp<0, (outs GPR:$Rt), (ins GPR:$Rt2, GPR:$Rn), "swp", |
| 3054 | [/* For disassembly only; pattern left blank */]>; |
| 3055 | def SWPB : AIswp<1, (outs GPR:$Rt), (ins GPR:$Rt2, GPR:$Rn), "swpb", |
| 3056 | [/* For disassembly only; pattern left blank */]>; |
Johnny Chen | b3e1bf5 | 2010-02-12 20:48:24 +0000 | [diff] [blame] | 3057 | } |
| 3058 | |
Lauro Ramos Venancio | 64f4fa5 | 2007-04-27 13:54:47 +0000 | [diff] [blame] | 3059 | //===----------------------------------------------------------------------===// |
| 3060 | // TLS Instructions |
| 3061 | // |
| 3062 | |
| 3063 | // __aeabi_read_tp preserves the registers r1-r3. |
Jim Grosbach | f32ecc6 | 2010-10-29 20:21:36 +0000 | [diff] [blame] | 3064 | // FIXME: This needs to be a pseudo of some sort so that we can get the |
| 3065 | // encoding right, complete with fixup for the aeabi_read_tp function. |
Evan Cheng | 13ab020 | 2007-07-10 18:08:01 +0000 | [diff] [blame] | 3066 | let isCall = 1, |
| 3067 | Defs = [R0, R12, LR, CPSR] in { |
David Goodwin | 8b7d7ad | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 3068 | def TPsoft : ABXI<0b1011, (outs), (ins), IIC_Br, |
Evan Cheng | 162e309 | 2009-10-26 23:45:59 +0000 | [diff] [blame] | 3069 | "bl\t__aeabi_read_tp", |
Lauro Ramos Venancio | 64f4fa5 | 2007-04-27 13:54:47 +0000 | [diff] [blame] | 3070 | [(set R0, ARMthread_pointer)]>; |
| 3071 | } |
Rafael Espindola | c01c87c | 2006-10-17 20:33:13 +0000 | [diff] [blame] | 3072 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3073 | //===----------------------------------------------------------------------===// |
Jim Grosbach | 0e0da73 | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 3074 | // SJLJ Exception handling intrinsics |
Jim Grosbach | 1add659 | 2009-08-13 15:11:43 +0000 | [diff] [blame] | 3075 | // eh_sjlj_setjmp() is an instruction sequence to store the return |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 3076 | // address and save #0 in R0 for the non-longjmp case. |
Jim Grosbach | 0e0da73 | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 3077 | // Since by its nature we may be coming from some other function to get |
| 3078 | // here, and we're using the stack frame for the containing function to |
| 3079 | // save/restore registers, we can't keep anything live in regs across |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 3080 | // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon |
Jim Grosbach | 0e0da73 | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 3081 | // when we get here from a longjmp(). We force everthing out of registers |
Jim Grosbach | f957012 | 2009-05-14 00:46:35 +0000 | [diff] [blame] | 3082 | // except for our own input by listing the relevant registers in Defs. By |
| 3083 | // doing so, we also cause the prologue/epilogue code to actively preserve |
| 3084 | // all of the callee-saved resgisters, which is exactly what we want. |
Jim Grosbach | a87ded2 | 2010-02-08 23:22:00 +0000 | [diff] [blame] | 3085 | // A constant value is passed in $val, and we use the location as a scratch. |
Jim Grosbach | f32ecc6 | 2010-10-29 20:21:36 +0000 | [diff] [blame] | 3086 | // |
| 3087 | // These are pseudo-instructions and are lowered to individual MC-insts, so |
| 3088 | // no encoding information is necessary. |
Jim Grosbach | a87ded2 | 2010-02-08 23:22:00 +0000 | [diff] [blame] | 3089 | let Defs = |
Jim Grosbach | f35d216 | 2009-08-13 16:59:44 +0000 | [diff] [blame] | 3090 | [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, D0, |
| 3091 | D1, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11, D12, D13, D14, D15, |
Evan Cheng | 0531d04 | 2009-07-29 20:10:36 +0000 | [diff] [blame] | 3092 | D16, D17, D18, D19, D20, D21, D22, D23, D24, D25, D26, D27, D28, D29, D30, |
Jim Grosbach | 5caeff5 | 2010-05-28 17:37:40 +0000 | [diff] [blame] | 3093 | D31 ], hasSideEffects = 1, isBarrier = 1 in { |
Jim Grosbach | a87ded2 | 2010-02-08 23:22:00 +0000 | [diff] [blame] | 3094 | def Int_eh_sjlj_setjmp : XI<(outs), (ins GPR:$src, GPR:$val), |
David Goodwin | 8b7d7ad | 2009-08-06 16:52:47 +0000 | [diff] [blame] | 3095 | AddrModeNone, SizeSpecial, IndexModeNone, |
Jim Grosbach | 71d933a | 2010-09-30 16:56:53 +0000 | [diff] [blame] | 3096 | Pseudo, NoItinerary, "", "", |
Bob Wilson | ec80e26 | 2010-04-09 20:41:18 +0000 | [diff] [blame] | 3097 | [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>, |
| 3098 | Requires<[IsARM, HasVFP2]>; |
| 3099 | } |
| 3100 | |
| 3101 | let Defs = |
Jim Grosbach | 5caeff5 | 2010-05-28 17:37:40 +0000 | [diff] [blame] | 3102 | [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR ], |
| 3103 | hasSideEffects = 1, isBarrier = 1 in { |
Bob Wilson | ec80e26 | 2010-04-09 20:41:18 +0000 | [diff] [blame] | 3104 | def Int_eh_sjlj_setjmp_nofp : XI<(outs), (ins GPR:$src, GPR:$val), |
| 3105 | AddrModeNone, SizeSpecial, IndexModeNone, |
Jim Grosbach | 71d933a | 2010-09-30 16:56:53 +0000 | [diff] [blame] | 3106 | Pseudo, NoItinerary, "", "", |
Bob Wilson | ec80e26 | 2010-04-09 20:41:18 +0000 | [diff] [blame] | 3107 | [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>, |
| 3108 | Requires<[IsARM, NoVFP]>; |
Jim Grosbach | 0e0da73 | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 3109 | } |
| 3110 | |
Jim Grosbach | 5eb1951 | 2010-05-22 01:06:18 +0000 | [diff] [blame] | 3111 | // FIXME: Non-Darwin version(s) |
| 3112 | let isBarrier = 1, hasSideEffects = 1, isTerminator = 1, |
| 3113 | Defs = [ R7, LR, SP ] in { |
| 3114 | def Int_eh_sjlj_longjmp : XI<(outs), (ins GPR:$src, GPR:$scratch), |
| 3115 | AddrModeNone, SizeSpecial, IndexModeNone, |
Jim Grosbach | 71d933a | 2010-09-30 16:56:53 +0000 | [diff] [blame] | 3116 | Pseudo, NoItinerary, "", "", |
Jim Grosbach | 5eb1951 | 2010-05-22 01:06:18 +0000 | [diff] [blame] | 3117 | [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>, |
| 3118 | Requires<[IsARM, IsDarwin]>; |
| 3119 | } |
| 3120 | |
Jim Grosbach | e4ad387 | 2010-10-19 23:27:08 +0000 | [diff] [blame] | 3121 | // eh.sjlj.dispatchsetup pseudo-instruction. |
Jim Grosbach | e317b13 | 2010-10-29 20:21:49 +0000 | [diff] [blame] | 3122 | // This pseudo is used for ARM, Thumb1 and Thumb2. Any differences are |
Jim Grosbach | e4ad387 | 2010-10-19 23:27:08 +0000 | [diff] [blame] | 3123 | // handled when the pseudo is expanded (which happens before any passes |
| 3124 | // that need the instruction size). |
| 3125 | let isBarrier = 1, hasSideEffects = 1 in |
| 3126 | def Int_eh_sjlj_dispatchsetup : |
| 3127 | PseudoInst<(outs), (ins GPR:$src), NoItinerary, "", |
| 3128 | [(ARMeh_sjlj_dispatchsetup GPR:$src)]>, |
| 3129 | Requires<[IsDarwin]>; |
| 3130 | |
Jim Grosbach | 0e0da73 | 2009-05-12 23:59:14 +0000 | [diff] [blame] | 3131 | //===----------------------------------------------------------------------===// |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3132 | // Non-Instruction Patterns |
| 3133 | // |
Rafael Espindola | 5aca927 | 2006-10-07 14:03:39 +0000 | [diff] [blame] | 3134 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3135 | // Large immediate handling. |
Rafael Espindola | 0505be0 | 2006-10-16 21:10:32 +0000 | [diff] [blame] | 3136 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3137 | // Two piece so_imms. |
Evan Cheng | 5be3922 | 2010-09-24 22:03:46 +0000 | [diff] [blame] | 3138 | // FIXME: Remove this when we can do generalized remat. |
Dan Gohman | d45eddd | 2007-06-26 00:48:07 +0000 | [diff] [blame] | 3139 | let isReMaterializable = 1 in |
Jim Grosbach | 8e0a3eb | 2010-10-29 21:35:25 +0000 | [diff] [blame] | 3140 | def MOVi2pieces : PseudoInst<(outs GPR:$dst), (ins so_imm2part:$src), |
| 3141 | IIC_iMOVix2, "", |
| 3142 | [(set GPR:$dst, (so_imm2part:$src))]>, |
Evan Cheng | 5adb66a | 2009-09-28 09:14:39 +0000 | [diff] [blame] | 3143 | Requires<[IsARM, NoV6T2]>; |
Rafael Espindola | f621abc | 2006-10-17 13:36:07 +0000 | [diff] [blame] | 3144 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3145 | def : ARMPat<(or GPR:$LHS, so_imm2part:$RHS), |
Evan Cheng | e7cbe41 | 2009-07-08 21:03:57 +0000 | [diff] [blame] | 3146 | (ORRri (ORRri GPR:$LHS, (so_imm2part_1 imm:$RHS)), |
| 3147 | (so_imm2part_2 imm:$RHS))>; |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3148 | def : ARMPat<(xor GPR:$LHS, so_imm2part:$RHS), |
Evan Cheng | e7cbe41 | 2009-07-08 21:03:57 +0000 | [diff] [blame] | 3149 | (EORri (EORri GPR:$LHS, (so_imm2part_1 imm:$RHS)), |
| 3150 | (so_imm2part_2 imm:$RHS))>; |
Jim Grosbach | 65b7f3a | 2009-10-21 20:44:34 +0000 | [diff] [blame] | 3151 | def : ARMPat<(add GPR:$LHS, so_imm2part:$RHS), |
| 3152 | (ADDri (ADDri GPR:$LHS, (so_imm2part_1 imm:$RHS)), |
| 3153 | (so_imm2part_2 imm:$RHS))>; |
Jim Grosbach | 15e6ef8 | 2009-11-23 20:35:53 +0000 | [diff] [blame] | 3154 | def : ARMPat<(add GPR:$LHS, so_neg_imm2part:$RHS), |
| 3155 | (SUBri (SUBri GPR:$LHS, (so_neg_imm2part_1 imm:$RHS)), |
| 3156 | (so_neg_imm2part_2 imm:$RHS))>; |
Rafael Espindola | f621abc | 2006-10-17 13:36:07 +0000 | [diff] [blame] | 3157 | |
Evan Cheng | 5adb66a | 2009-09-28 09:14:39 +0000 | [diff] [blame] | 3158 | // 32-bit immediate using movw + movt. |
Chris Lattner | 017d947 | 2009-10-20 00:40:56 +0000 | [diff] [blame] | 3159 | // This is a single pseudo instruction, the benefit is that it can be remat'd |
| 3160 | // as a single unit instead of having to handle reg inputs. |
| 3161 | // FIXME: Remove this when we can do generalized remat. |
Evan Cheng | 5adb66a | 2009-09-28 09:14:39 +0000 | [diff] [blame] | 3162 | let isReMaterializable = 1 in |
Jim Grosbach | 3c38f96 | 2010-10-06 22:01:26 +0000 | [diff] [blame] | 3163 | def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2, "", |
| 3164 | [(set GPR:$dst, (i32 imm:$src))]>, |
| 3165 | Requires<[IsARM, HasV6T2]>; |
Anton Korobeynikov | 6a2fa32 | 2009-09-27 23:52:58 +0000 | [diff] [blame] | 3166 | |
Anton Korobeynikov | 5cdc3a9 | 2009-11-24 00:44:37 +0000 | [diff] [blame] | 3167 | // ConstantPool, GlobalAddress, and JumpTable |
| 3168 | def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>, |
| 3169 | Requires<[IsARM, DontUseMovt]>; |
| 3170 | def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>; |
| 3171 | def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>, |
| 3172 | Requires<[IsARM, UseMovt]>; |
| 3173 | def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id), |
| 3174 | (LEApcrelJT tjumptable:$dst, imm:$id)>; |
| 3175 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3176 | // TODO: add,sub,and, 3-instr forms? |
Rafael Espindola | 0505be0 | 2006-10-16 21:10:32 +0000 | [diff] [blame] | 3177 | |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 3178 | // Tail calls |
Dale Johannesen | 38d5f04 | 2010-06-15 22:24:08 +0000 | [diff] [blame] | 3179 | def : ARMPat<(ARMtcret tcGPR:$dst), |
| 3180 | (TCRETURNri tcGPR:$dst)>, Requires<[IsDarwin]>; |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 3181 | |
| 3182 | def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)), |
| 3183 | (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>; |
| 3184 | |
| 3185 | def : ARMPat<(ARMtcret (i32 texternalsym:$dst)), |
| 3186 | (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>; |
| 3187 | |
Dale Johannesen | 38d5f04 | 2010-06-15 22:24:08 +0000 | [diff] [blame] | 3188 | def : ARMPat<(ARMtcret tcGPR:$dst), |
| 3189 | (TCRETURNriND tcGPR:$dst)>, Requires<[IsNotDarwin]>; |
Dale Johannesen | 51e28e6 | 2010-06-03 21:09:53 +0000 | [diff] [blame] | 3190 | |
| 3191 | def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)), |
| 3192 | (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>; |
| 3193 | |
| 3194 | def : ARMPat<(ARMtcret (i32 texternalsym:$dst)), |
| 3195 | (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>; |
Rafael Espindola | 2435786 | 2006-10-19 17:05:03 +0000 | [diff] [blame] | 3196 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3197 | // Direct calls |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 3198 | def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>, |
Evan Cheng | 20a2a0a | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 3199 | Requires<[IsARM, IsNotDarwin]>; |
Bob Wilson | 54fc124 | 2009-06-22 21:01:46 +0000 | [diff] [blame] | 3200 | def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>, |
Evan Cheng | 20a2a0a | 2009-07-29 21:26:42 +0000 | [diff] [blame] | 3201 | Requires<[IsARM, IsDarwin]>; |
Rafael Espindola | 9dca7ad | 2006-11-01 14:13:27 +0000 | [diff] [blame] | 3202 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3203 | // zextload i1 -> zextload i8 |
Jim Grosbach | c1d3021 | 2010-10-27 00:19:44 +0000 | [diff] [blame] | 3204 | def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>; |
| 3205 | def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>; |
Lauro Ramos Venancio | a8f9f4a | 2006-12-26 19:30:42 +0000 | [diff] [blame] | 3206 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3207 | // extload -> zextload |
Jim Grosbach | c1d3021 | 2010-10-27 00:19:44 +0000 | [diff] [blame] | 3208 | def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>; |
| 3209 | def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>; |
| 3210 | def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>; |
| 3211 | def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>; |
| 3212 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3213 | def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>; |
Rafael Espindola | 9dca7ad | 2006-11-01 14:13:27 +0000 | [diff] [blame] | 3214 | |
Evan Cheng | 83b5cf0 | 2008-11-05 23:22:34 +0000 | [diff] [blame] | 3215 | def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>; |
| 3216 | def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>; |
| 3217 | |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3218 | // smul* and smla* |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3219 | def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)), |
| 3220 | (sra (shl GPR:$b, (i32 16)), (i32 16))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3221 | (SMULBB GPR:$a, GPR:$b)>; |
| 3222 | def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b), |
| 3223 | (SMULBB GPR:$a, GPR:$b)>; |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3224 | def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)), |
| 3225 | (sra GPR:$b, (i32 16))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3226 | (SMULBT GPR:$a, GPR:$b)>; |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3227 | def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3228 | (SMULBT GPR:$a, GPR:$b)>; |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3229 | def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), |
| 3230 | (sra (shl GPR:$b, (i32 16)), (i32 16))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3231 | (SMULTB GPR:$a, GPR:$b)>; |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3232 | def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3233 | (SMULTB GPR:$a, GPR:$b)>; |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3234 | def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))), |
| 3235 | (i32 16)), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3236 | (SMULWB GPR:$a, GPR:$b)>; |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3237 | def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3238 | (SMULWB GPR:$a, GPR:$b)>; |
| 3239 | |
| 3240 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3241 | (mul (sra (shl GPR:$a, (i32 16)), (i32 16)), |
| 3242 | (sra (shl GPR:$b, (i32 16)), (i32 16)))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3243 | (SMLABB GPR:$a, GPR:$b, GPR:$acc)>; |
| 3244 | def : ARMV5TEPat<(add GPR:$acc, |
| 3245 | (mul sext_16_node:$a, sext_16_node:$b)), |
| 3246 | (SMLABB GPR:$a, GPR:$b, GPR:$acc)>; |
| 3247 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3248 | (mul (sra (shl GPR:$a, (i32 16)), (i32 16)), |
| 3249 | (sra GPR:$b, (i32 16)))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3250 | (SMLABT GPR:$a, GPR:$b, GPR:$acc)>; |
| 3251 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3252 | (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3253 | (SMLABT GPR:$a, GPR:$b, GPR:$acc)>; |
| 3254 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3255 | (mul (sra GPR:$a, (i32 16)), |
| 3256 | (sra (shl GPR:$b, (i32 16)), (i32 16)))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3257 | (SMLATB GPR:$a, GPR:$b, GPR:$acc)>; |
| 3258 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3259 | (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3260 | (SMLATB GPR:$a, GPR:$b, GPR:$acc)>; |
| 3261 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3262 | (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))), |
| 3263 | (i32 16))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3264 | (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>; |
| 3265 | def : ARMV5TEPat<(add GPR:$acc, |
Bob Wilson | 1c76d0e | 2009-06-22 22:08:29 +0000 | [diff] [blame] | 3266 | (sra (mul GPR:$a, sext_16_node:$b), (i32 16))), |
Evan Cheng | 34b12d2 | 2007-01-19 20:27:35 +0000 | [diff] [blame] | 3267 | (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>; |
| 3268 | |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3269 | //===----------------------------------------------------------------------===// |
| 3270 | // Thumb Support |
| 3271 | // |
| 3272 | |
| 3273 | include "ARMInstrThumb.td" |
| 3274 | |
| 3275 | //===----------------------------------------------------------------------===// |
Anton Korobeynikov | 5223711 | 2009-06-17 18:13:58 +0000 | [diff] [blame] | 3276 | // Thumb2 Support |
| 3277 | // |
| 3278 | |
| 3279 | include "ARMInstrThumb2.td" |
| 3280 | |
| 3281 | //===----------------------------------------------------------------------===// |
Evan Cheng | a8e2989 | 2007-01-19 07:51:42 +0000 | [diff] [blame] | 3282 | // Floating Point Support |
| 3283 | // |
| 3284 | |
| 3285 | include "ARMInstrVFP.td" |
Bob Wilson | 5bafff3 | 2009-06-22 23:27:02 +0000 | [diff] [blame] | 3286 | |
| 3287 | //===----------------------------------------------------------------------===// |
| 3288 | // Advanced SIMD (NEON) Support |
| 3289 | // |
| 3290 | |
| 3291 | include "ARMInstrNEON.td" |
Johnny Chen | 906d57f | 2010-02-12 01:44:23 +0000 | [diff] [blame] | 3292 | |
| 3293 | //===----------------------------------------------------------------------===// |
| 3294 | // Coprocessor Instructions. For disassembly only. |
| 3295 | // |
| 3296 | |
| 3297 | def CDP : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1, |
| 3298 | nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2), |
| 3299 | NoItinerary, "cdp", "\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2", |
| 3300 | [/* For disassembly only; pattern left blank */]> { |
| 3301 | let Inst{4} = 0; |
| 3302 | } |
| 3303 | |
| 3304 | def CDP2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1, |
| 3305 | nohash_imm:$CRd, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2), |
| 3306 | NoItinerary, "cdp2\tp$cop, $opc1, cr$CRd, cr$CRn, cr$CRm, $opc2", |
| 3307 | [/* For disassembly only; pattern left blank */]> { |
| 3308 | let Inst{31-28} = 0b1111; |
| 3309 | let Inst{4} = 0; |
| 3310 | } |
| 3311 | |
Johnny Chen | 64dfb78 | 2010-02-16 20:04:27 +0000 | [diff] [blame] | 3312 | class ACI<dag oops, dag iops, string opc, string asm> |
| 3313 | : I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, NoItinerary, |
| 3314 | opc, asm, "", [/* For disassembly only; pattern left blank */]> { |
| 3315 | let Inst{27-25} = 0b110; |
| 3316 | } |
| 3317 | |
| 3318 | multiclass LdStCop<bits<4> op31_28, bit load, string opc> { |
| 3319 | |
| 3320 | def _OFFSET : ACI<(outs), |
| 3321 | (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), |
| 3322 | opc, "\tp$cop, cr$CRd, $addr"> { |
| 3323 | let Inst{31-28} = op31_28; |
| 3324 | let Inst{24} = 1; // P = 1 |
| 3325 | let Inst{21} = 0; // W = 0 |
| 3326 | let Inst{22} = 0; // D = 0 |
| 3327 | let Inst{20} = load; |
| 3328 | } |
| 3329 | |
| 3330 | def _PRE : ACI<(outs), |
| 3331 | (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), |
| 3332 | opc, "\tp$cop, cr$CRd, $addr!"> { |
| 3333 | let Inst{31-28} = op31_28; |
| 3334 | let Inst{24} = 1; // P = 1 |
| 3335 | let Inst{21} = 1; // W = 1 |
| 3336 | let Inst{22} = 0; // D = 0 |
| 3337 | let Inst{20} = load; |
| 3338 | } |
| 3339 | |
| 3340 | def _POST : ACI<(outs), |
| 3341 | (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset), |
| 3342 | opc, "\tp$cop, cr$CRd, [$base], $offset"> { |
| 3343 | let Inst{31-28} = op31_28; |
| 3344 | let Inst{24} = 0; // P = 0 |
| 3345 | let Inst{21} = 1; // W = 1 |
| 3346 | let Inst{22} = 0; // D = 0 |
| 3347 | let Inst{20} = load; |
| 3348 | } |
| 3349 | |
| 3350 | def _OPTION : ACI<(outs), |
| 3351 | (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, i32imm:$option), |
| 3352 | opc, "\tp$cop, cr$CRd, [$base], $option"> { |
| 3353 | let Inst{31-28} = op31_28; |
| 3354 | let Inst{24} = 0; // P = 0 |
| 3355 | let Inst{23} = 1; // U = 1 |
| 3356 | let Inst{21} = 0; // W = 0 |
| 3357 | let Inst{22} = 0; // D = 0 |
| 3358 | let Inst{20} = load; |
| 3359 | } |
| 3360 | |
| 3361 | def L_OFFSET : ACI<(outs), |
| 3362 | (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), |
Johnny Chen | 2fb10f1 | 2010-04-16 19:33:23 +0000 | [diff] [blame] | 3363 | !strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr"> { |
Johnny Chen | 64dfb78 | 2010-02-16 20:04:27 +0000 | [diff] [blame] | 3364 | let Inst{31-28} = op31_28; |
| 3365 | let Inst{24} = 1; // P = 1 |
| 3366 | let Inst{21} = 0; // W = 0 |
| 3367 | let Inst{22} = 1; // D = 1 |
| 3368 | let Inst{20} = load; |
| 3369 | } |
| 3370 | |
| 3371 | def L_PRE : ACI<(outs), |
| 3372 | (ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), |
Johnny Chen | 2fb10f1 | 2010-04-16 19:33:23 +0000 | [diff] [blame] | 3373 | !strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr!"> { |
Johnny Chen | 64dfb78 | 2010-02-16 20:04:27 +0000 | [diff] [blame] | 3374 | let Inst{31-28} = op31_28; |
| 3375 | let Inst{24} = 1; // P = 1 |
| 3376 | let Inst{21} = 1; // W = 1 |
| 3377 | let Inst{22} = 1; // D = 1 |
| 3378 | let Inst{20} = load; |
| 3379 | } |
| 3380 | |
| 3381 | def L_POST : ACI<(outs), |
| 3382 | (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, am2offset:$offset), |
Johnny Chen | 2fb10f1 | 2010-04-16 19:33:23 +0000 | [diff] [blame] | 3383 | !strconcat(opc, "l"), "\tp$cop, cr$CRd, [$base], $offset"> { |
Johnny Chen | 64dfb78 | 2010-02-16 20:04:27 +0000 | [diff] [blame] | 3384 | let Inst{31-28} = op31_28; |
| 3385 | let Inst{24} = 0; // P = 0 |
| 3386 | let Inst{21} = 1; // W = 1 |
| 3387 | let Inst{22} = 1; // D = 1 |
| 3388 | let Inst{20} = load; |
| 3389 | } |
| 3390 | |
| 3391 | def L_OPTION : ACI<(outs), |
| 3392 | (ins nohash_imm:$cop, nohash_imm:$CRd, GPR:$base, nohash_imm:$option), |
Johnny Chen | 2fb10f1 | 2010-04-16 19:33:23 +0000 | [diff] [blame] | 3393 | !strconcat(opc, "l"), "\tp$cop, cr$CRd, [$base], $option"> { |
Johnny Chen | 64dfb78 | 2010-02-16 20:04:27 +0000 | [diff] [blame] | 3394 | let Inst{31-28} = op31_28; |
| 3395 | let Inst{24} = 0; // P = 0 |
| 3396 | let Inst{23} = 1; // U = 1 |
| 3397 | let Inst{21} = 0; // W = 0 |
| 3398 | let Inst{22} = 1; // D = 1 |
| 3399 | let Inst{20} = load; |
| 3400 | } |
| 3401 | } |
| 3402 | |
| 3403 | defm LDC : LdStCop<{?,?,?,?}, 1, "ldc">; |
| 3404 | defm LDC2 : LdStCop<0b1111, 1, "ldc2">; |
| 3405 | defm STC : LdStCop<{?,?,?,?}, 0, "stc">; |
| 3406 | defm STC2 : LdStCop<0b1111, 0, "stc2">; |
| 3407 | |
Johnny Chen | 906d57f | 2010-02-12 01:44:23 +0000 | [diff] [blame] | 3408 | def MCR : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1, |
| 3409 | GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2), |
| 3410 | NoItinerary, "mcr", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2", |
| 3411 | [/* For disassembly only; pattern left blank */]> { |
| 3412 | let Inst{20} = 0; |
| 3413 | let Inst{4} = 1; |
| 3414 | } |
| 3415 | |
| 3416 | def MCR2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1, |
| 3417 | GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2), |
| 3418 | NoItinerary, "mcr2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2", |
| 3419 | [/* For disassembly only; pattern left blank */]> { |
| 3420 | let Inst{31-28} = 0b1111; |
| 3421 | let Inst{20} = 0; |
| 3422 | let Inst{4} = 1; |
| 3423 | } |
| 3424 | |
| 3425 | def MRC : ABI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1, |
| 3426 | GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2), |
| 3427 | NoItinerary, "mrc", "\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2", |
| 3428 | [/* For disassembly only; pattern left blank */]> { |
| 3429 | let Inst{20} = 1; |
| 3430 | let Inst{4} = 1; |
| 3431 | } |
| 3432 | |
| 3433 | def MRC2 : ABXI<0b1110, (outs), (ins nohash_imm:$cop, i32imm:$opc1, |
| 3434 | GPR:$Rt, nohash_imm:$CRn, nohash_imm:$CRm, i32imm:$opc2), |
| 3435 | NoItinerary, "mrc2\tp$cop, $opc1, $Rt, cr$CRn, cr$CRm, $opc2", |
| 3436 | [/* For disassembly only; pattern left blank */]> { |
| 3437 | let Inst{31-28} = 0b1111; |
| 3438 | let Inst{20} = 1; |
| 3439 | let Inst{4} = 1; |
| 3440 | } |
| 3441 | |
| 3442 | def MCRR : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc, |
| 3443 | GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm), |
| 3444 | NoItinerary, "mcrr", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm", |
| 3445 | [/* For disassembly only; pattern left blank */]> { |
| 3446 | let Inst{23-20} = 0b0100; |
| 3447 | } |
| 3448 | |
| 3449 | def MCRR2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc, |
| 3450 | GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm), |
| 3451 | NoItinerary, "mcrr2\tp$cop, $opc, $Rt, $Rt2, cr$CRm", |
| 3452 | [/* For disassembly only; pattern left blank */]> { |
| 3453 | let Inst{31-28} = 0b1111; |
| 3454 | let Inst{23-20} = 0b0100; |
| 3455 | } |
| 3456 | |
| 3457 | def MRRC : ABI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc, |
| 3458 | GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm), |
| 3459 | NoItinerary, "mrrc", "\tp$cop, $opc, $Rt, $Rt2, cr$CRm", |
| 3460 | [/* For disassembly only; pattern left blank */]> { |
| 3461 | let Inst{23-20} = 0b0101; |
| 3462 | } |
| 3463 | |
| 3464 | def MRRC2 : ABXI<0b1100, (outs), (ins nohash_imm:$cop, i32imm:$opc, |
| 3465 | GPR:$Rt, GPR:$Rt2, nohash_imm:$CRm), |
| 3466 | NoItinerary, "mrrc2\tp$cop, $opc, $Rt, $Rt2, cr$CRm", |
| 3467 | [/* For disassembly only; pattern left blank */]> { |
| 3468 | let Inst{31-28} = 0b1111; |
| 3469 | let Inst{23-20} = 0b0101; |
| 3470 | } |
| 3471 | |
Johnny Chen | b98e160 | 2010-02-12 18:55:33 +0000 | [diff] [blame] | 3472 | //===----------------------------------------------------------------------===// |
| 3473 | // Move between special register and ARM core register -- for disassembly only |
| 3474 | // |
| 3475 | |
| 3476 | def MRS : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary, "mrs", "\t$dst, cpsr", |
| 3477 | [/* For disassembly only; pattern left blank */]> { |
| 3478 | let Inst{23-20} = 0b0000; |
| 3479 | let Inst{7-4} = 0b0000; |
| 3480 | } |
| 3481 | |
| 3482 | def MRSsys : ABI<0b0001,(outs GPR:$dst),(ins), NoItinerary,"mrs","\t$dst, spsr", |
| 3483 | [/* For disassembly only; pattern left blank */]> { |
| 3484 | let Inst{23-20} = 0b0100; |
| 3485 | let Inst{7-4} = 0b0000; |
| 3486 | } |
| 3487 | |
Johnny Chen | dd0f3cf | 2010-03-10 18:59:38 +0000 | [diff] [blame] | 3488 | def MSR : ABI<0b0001, (outs), (ins GPR:$src, msr_mask:$mask), NoItinerary, |
| 3489 | "msr", "\tcpsr$mask, $src", |
Johnny Chen | b98e160 | 2010-02-12 18:55:33 +0000 | [diff] [blame] | 3490 | [/* For disassembly only; pattern left blank */]> { |
| 3491 | let Inst{23-20} = 0b0010; |
| 3492 | let Inst{7-4} = 0b0000; |
| 3493 | } |
| 3494 | |
Johnny Chen | dd0f3cf | 2010-03-10 18:59:38 +0000 | [diff] [blame] | 3495 | def MSRi : ABI<0b0011, (outs), (ins so_imm:$a, msr_mask:$mask), NoItinerary, |
| 3496 | "msr", "\tcpsr$mask, $a", |
Johnny Chen | 64dfb78 | 2010-02-16 20:04:27 +0000 | [diff] [blame] | 3497 | [/* For disassembly only; pattern left blank */]> { |
| 3498 | let Inst{23-20} = 0b0010; |
| 3499 | let Inst{7-4} = 0b0000; |
| 3500 | } |
| 3501 | |
Johnny Chen | dd0f3cf | 2010-03-10 18:59:38 +0000 | [diff] [blame] | 3502 | def MSRsys : ABI<0b0001, (outs), (ins GPR:$src, msr_mask:$mask), NoItinerary, |
| 3503 | "msr", "\tspsr$mask, $src", |
Johnny Chen | 64dfb78 | 2010-02-16 20:04:27 +0000 | [diff] [blame] | 3504 | [/* For disassembly only; pattern left blank */]> { |
| 3505 | let Inst{23-20} = 0b0110; |
| 3506 | let Inst{7-4} = 0b0000; |
| 3507 | } |
| 3508 | |
Johnny Chen | dd0f3cf | 2010-03-10 18:59:38 +0000 | [diff] [blame] | 3509 | def MSRsysi : ABI<0b0011, (outs), (ins so_imm:$a, msr_mask:$mask), NoItinerary, |
| 3510 | "msr", "\tspsr$mask, $a", |
Johnny Chen | b98e160 | 2010-02-12 18:55:33 +0000 | [diff] [blame] | 3511 | [/* For disassembly only; pattern left blank */]> { |
| 3512 | let Inst{23-20} = 0b0110; |
| 3513 | let Inst{7-4} = 0b0000; |
| 3514 | } |