Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 1 | //===- ARMInstrFormats.td - ARM Instruction Formats --*- tablegen -*---------=// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | //===----------------------------------------------------------------------===// |
| 11 | // |
| 12 | // ARM Instruction Format Definitions. |
| 13 | // |
| 14 | |
| 15 | // Format specifies the encoding used by the instruction. This is part of the |
| 16 | // ad-hoc solution used to emit machine instruction encodings by our machine |
| 17 | // code emitter. |
| 18 | class Format<bits<5> val> { |
| 19 | bits<5> Value = val; |
| 20 | } |
| 21 | |
| 22 | def Pseudo : Format<1>; |
| 23 | def MulFrm : Format<2>; |
| 24 | def MulSMLAW : Format<3>; |
| 25 | def MulSMULW : Format<4>; |
| 26 | def MulSMLA : Format<5>; |
| 27 | def MulSMUL : Format<6>; |
| 28 | def Branch : Format<7>; |
| 29 | def BranchMisc : Format<8>; |
| 30 | |
| 31 | def DPRdIm : Format<9>; |
| 32 | def DPRdReg : Format<10>; |
| 33 | def DPRdSoReg : Format<11>; |
| 34 | def DPRdMisc : Format<12>; |
| 35 | def DPRnIm : Format<13>; |
| 36 | def DPRnReg : Format<14>; |
| 37 | def DPRnSoReg : Format<15>; |
| 38 | def DPRIm : Format<16>; |
| 39 | def DPRReg : Format<17>; |
| 40 | def DPRSoReg : Format<18>; |
| 41 | def DPRImS : Format<19>; |
| 42 | def DPRRegS : Format<20>; |
| 43 | def DPRSoRegS : Format<21>; |
| 44 | |
| 45 | def LdFrm : Format<22>; |
| 46 | def StFrm : Format<23>; |
| 47 | |
| 48 | def ArithMisc : Format<24>; |
| 49 | def ThumbFrm : Format<25>; |
| 50 | def VFPFrm : Format<26>; |
| 51 | |
| 52 | |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 53 | //===----------------------------------------------------------------------===// |
| 54 | |
| 55 | // ARM Instruction templates. |
| 56 | // |
| 57 | |
| 58 | class InstARM<bits<4> opcod, AddrMode am, SizeFlagVal sz, IndexMode im, |
| 59 | Format f, string cstr> |
| 60 | : Instruction { |
Evan Cheng | 612b79e | 2008-08-29 07:40:52 +0000 | [diff] [blame] | 61 | field bits<32> Inst; |
| 62 | |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 63 | let Namespace = "ARM"; |
| 64 | |
| 65 | bits<4> Opcode = opcod; |
| 66 | AddrMode AM = am; |
| 67 | bits<4> AddrModeBits = AM.Value; |
| 68 | |
| 69 | SizeFlagVal SZ = sz; |
| 70 | bits<3> SizeFlag = SZ.Value; |
| 71 | |
| 72 | IndexMode IM = im; |
| 73 | bits<2> IndexModeBits = IM.Value; |
| 74 | |
| 75 | Format F = f; |
| 76 | bits<5> Form = F.Value; |
| 77 | |
| 78 | let Constraints = cstr; |
| 79 | } |
| 80 | |
| 81 | class PseudoInst<dag oops, dag iops, string asm, list<dag> pattern> |
| 82 | : InstARM<0, AddrModeNone, SizeSpecial, IndexModeNone, Pseudo, ""> { |
| 83 | let OutOperandList = oops; |
| 84 | let InOperandList = iops; |
| 85 | let AsmString = asm; |
| 86 | let Pattern = pattern; |
| 87 | } |
| 88 | |
| 89 | // Almost all ARM instructions are predicable. |
| 90 | class I<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz, |
| 91 | IndexMode im, Format f, string opc, string asm, string cstr, |
| 92 | list<dag> pattern> |
| 93 | : InstARM<opcod, am, sz, im, f, cstr> { |
| 94 | let OutOperandList = oops; |
| 95 | let InOperandList = !con(iops, (ops pred:$p)); |
| 96 | let AsmString = !strconcat(opc, !strconcat("${p}", asm)); |
| 97 | let Pattern = pattern; |
| 98 | list<Predicate> Predicates = [IsARM]; |
| 99 | } |
| 100 | |
| 101 | // Same as I except it can optionally modify CPSR. Note it's modeled as |
| 102 | // an input operand since by default it's a zero register. It will |
| 103 | // become an implicit def once it's "flipped". |
| 104 | class sI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz, |
| 105 | IndexMode im, Format f, string opc, string asm, string cstr, |
| 106 | list<dag> pattern> |
| 107 | : InstARM<opcod, am, sz, im, f, cstr> { |
| 108 | let OutOperandList = oops; |
| 109 | let InOperandList = !con(iops, (ops pred:$p, cc_out:$s)); |
| 110 | let AsmString = !strconcat(opc, !strconcat("${p}${s}", asm)); |
| 111 | let Pattern = pattern; |
| 112 | list<Predicate> Predicates = [IsARM]; |
| 113 | } |
| 114 | |
| 115 | class AI<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 116 | string asm, list<dag> pattern> |
| 117 | : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc, |
| 118 | asm,"",pattern>; |
| 119 | class AsI<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 120 | string asm, list<dag> pattern> |
| 121 | : sI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc, |
| 122 | asm,"",pattern>; |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 123 | |
| 124 | // addrmode1 instructions |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 125 | class AI1<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 126 | string asm, list<dag> pattern> |
| 127 | : I<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc, |
Evan Cheng | 612b79e | 2008-08-29 07:40:52 +0000 | [diff] [blame] | 128 | asm, "", pattern> { |
Evan Cheng | b7880ac | 2008-08-31 18:32:16 +0000 | [diff] [blame] | 129 | let Inst{21-24} = opcod; |
| 130 | let Inst{26-27} = 0; |
Evan Cheng | 612b79e | 2008-08-29 07:40:52 +0000 | [diff] [blame] | 131 | } |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 132 | class AsI1<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 133 | string asm, list<dag> pattern> |
| 134 | : sI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc, |
Evan Cheng | 612b79e | 2008-08-29 07:40:52 +0000 | [diff] [blame] | 135 | asm, "", pattern> { |
Evan Cheng | b7880ac | 2008-08-31 18:32:16 +0000 | [diff] [blame] | 136 | let Inst{20} = 1; |
| 137 | let Inst{21-24} = opcod; |
| 138 | let Inst{26-27} = 0; |
Evan Cheng | 612b79e | 2008-08-29 07:40:52 +0000 | [diff] [blame] | 139 | } |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 140 | class AI1x2<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 141 | string asm, list<dag> pattern> |
| 142 | : I<opcod, oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, opc, |
| 143 | asm, "", pattern>; |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 144 | |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 145 | |
| 146 | // addrmode2 loads and stores |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 147 | class AI2<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 148 | string asm, list<dag> pattern> |
| 149 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc, |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 150 | asm, "", pattern> { |
| 151 | let Inst{26-27} = 1; |
| 152 | } |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 153 | |
| 154 | // loads |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 155 | class AI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 156 | string asm, list<dag> pattern> |
| 157 | : AI2<opcod, oops, iops, f, opc, asm, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 158 | let Inst{20} = 1; // L bit |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 159 | let Inst{21} = 0; // W bit |
| 160 | let Inst{22} = 0; // B bit |
| 161 | let Inst{24} = 1; // P bit |
| 162 | } |
| 163 | class AI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 164 | string asm, list<dag> pattern> |
| 165 | : AI2<opcod, oops, iops, f, opc, asm, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 166 | let Inst{20} = 1; // L bit |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 167 | let Inst{21} = 0; // W bit |
| 168 | let Inst{22} = 1; // B bit |
| 169 | let Inst{24} = 1; // P bit |
| 170 | } |
| 171 | |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 172 | // stores |
| 173 | class AI2stw<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 174 | string asm, list<dag> pattern> |
| 175 | : AI2<opcod, oops, iops, f, opc, asm, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 176 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 177 | let Inst{21} = 0; // W bit |
| 178 | let Inst{22} = 0; // B bit |
| 179 | let Inst{24} = 1; // P bit |
| 180 | } |
| 181 | class AI2stb<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 182 | string asm, list<dag> pattern> |
| 183 | : AI2<opcod, oops, iops, f, opc, asm, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 184 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 185 | let Inst{21} = 0; // W bit |
| 186 | let Inst{22} = 1; // B bit |
| 187 | let Inst{24} = 1; // P bit |
| 188 | } |
| 189 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 190 | // Pre-indexed loads |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 191 | class AI2ldwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 192 | string asm, string cstr, list<dag> pattern> |
| 193 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc, |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 194 | asm, cstr, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 195 | let Inst{20} = 1; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 196 | let Inst{21} = 1; // W bit |
| 197 | let Inst{22} = 0; // B bit |
| 198 | let Inst{24} = 1; // P bit |
| 199 | } |
| 200 | class AI2ldbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 201 | string asm, string cstr, list<dag> pattern> |
| 202 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc, |
| 203 | asm, cstr, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 204 | let Inst{20} = 1; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 205 | let Inst{21} = 1; // W bit |
| 206 | let Inst{22} = 1; // B bit |
| 207 | let Inst{24} = 1; // P bit |
| 208 | } |
| 209 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 210 | // Pre-indexed stores |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 211 | class AI2stwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 212 | string asm, string cstr, list<dag> pattern> |
| 213 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc, |
| 214 | asm, cstr, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 215 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 216 | let Inst{21} = 1; // W bit |
| 217 | let Inst{22} = 0; // B bit |
| 218 | let Inst{24} = 1; // P bit |
| 219 | } |
| 220 | class AI2stbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 221 | string asm, string cstr, list<dag> pattern> |
| 222 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc, |
| 223 | asm, cstr, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 224 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 225 | let Inst{21} = 1; // W bit |
| 226 | let Inst{22} = 1; // B bit |
| 227 | let Inst{24} = 1; // P bit |
| 228 | } |
| 229 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 230 | // Post-indexed loads |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 231 | class AI2ldwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 232 | string asm, string cstr, list<dag> pattern> |
| 233 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc, |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 234 | asm, cstr,pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 235 | let Inst{20} = 1; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 236 | let Inst{21} = 0; // W bit |
| 237 | let Inst{22} = 0; // B bit |
| 238 | let Inst{24} = 0; // P bit |
| 239 | } |
| 240 | class AI2ldbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 241 | string asm, string cstr, list<dag> pattern> |
| 242 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc, |
| 243 | asm, cstr,pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 244 | let Inst{20} = 1; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 245 | let Inst{21} = 0; // W bit |
| 246 | let Inst{22} = 1; // B bit |
| 247 | let Inst{24} = 0; // P bit |
| 248 | } |
| 249 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 250 | // Post-indexed stores |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 251 | class AI2stwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 252 | string asm, string cstr, list<dag> pattern> |
| 253 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc, |
| 254 | asm, cstr,pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 255 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 256 | let Inst{21} = 0; // W bit |
| 257 | let Inst{22} = 0; // B bit |
| 258 | let Inst{24} = 0; // P bit |
| 259 | } |
| 260 | class AI2stbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 261 | string asm, string cstr, list<dag> pattern> |
| 262 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc, |
| 263 | asm, cstr,pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 264 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 265 | let Inst{21} = 0; // W bit |
| 266 | let Inst{22} = 1; // B bit |
| 267 | let Inst{24} = 0; // P bit |
| 268 | } |
| 269 | |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 270 | // addrmode3 instructions |
| 271 | class AI3<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 272 | string asm, list<dag> pattern> |
| 273 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 274 | asm, "", pattern>; |
| 275 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame^] | 276 | // loads |
| 277 | class AI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 278 | string asm, list<dag> pattern> |
| 279 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 280 | asm, "", pattern> { |
| 281 | let Inst{4} = 1; |
| 282 | let Inst{5} = 1; // H bit |
| 283 | let Inst{6} = 0; // S bit |
| 284 | let Inst{7} = 1; |
| 285 | let Inst{20} = 1; // L bit |
| 286 | let Inst{21} = 0; // W bit |
| 287 | let Inst{24} = 1; // P bit |
| 288 | } |
| 289 | class AI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 290 | string asm, list<dag> pattern> |
| 291 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 292 | asm, "", pattern> { |
| 293 | let Inst{4} = 1; |
| 294 | let Inst{5} = 1; // H bit |
| 295 | let Inst{6} = 1; // S bit |
| 296 | let Inst{7} = 1; |
| 297 | let Inst{20} = 1; // L bit |
| 298 | let Inst{21} = 0; // W bit |
| 299 | let Inst{24} = 1; // P bit |
| 300 | } |
| 301 | class AI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 302 | string asm, list<dag> pattern> |
| 303 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 304 | asm, "", pattern> { |
| 305 | let Inst{4} = 1; |
| 306 | let Inst{5} = 0; // H bit |
| 307 | let Inst{6} = 1; // S bit |
| 308 | let Inst{7} = 1; |
| 309 | let Inst{20} = 1; // L bit |
| 310 | let Inst{21} = 0; // W bit |
| 311 | let Inst{24} = 1; // P bit |
| 312 | } |
| 313 | class AI3ldd<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 314 | string asm, list<dag> pattern> |
| 315 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 316 | asm, "", pattern> { |
| 317 | let Inst{4} = 1; |
| 318 | let Inst{5} = 0; // H bit |
| 319 | let Inst{6} = 1; // S bit |
| 320 | let Inst{7} = 1; |
| 321 | let Inst{20} = 0; // L bit |
| 322 | let Inst{21} = 0; // W bit |
| 323 | let Inst{24} = 1; // P bit |
| 324 | } |
| 325 | |
| 326 | // stores |
| 327 | class AI3sth<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 328 | string asm, list<dag> pattern> |
| 329 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 330 | asm, "", pattern> { |
| 331 | let Inst{4} = 1; |
| 332 | let Inst{5} = 1; // H bit |
| 333 | let Inst{6} = 0; // S bit |
| 334 | let Inst{7} = 1; |
| 335 | let Inst{20} = 0; // L bit |
| 336 | let Inst{21} = 0; // W bit |
| 337 | let Inst{24} = 1; // P bit |
| 338 | } |
| 339 | class AI3std<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 340 | string asm, list<dag> pattern> |
| 341 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 342 | asm, "", pattern> { |
| 343 | let Inst{4} = 1; |
| 344 | let Inst{5} = 1; // H bit |
| 345 | let Inst{6} = 1; // S bit |
| 346 | let Inst{7} = 1; |
| 347 | let Inst{20} = 0; // L bit |
| 348 | let Inst{21} = 0; // W bit |
| 349 | let Inst{24} = 1; // P bit |
| 350 | } |
| 351 | |
| 352 | // Pre-indexed loads |
| 353 | class AI3ldhpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 354 | string asm, string cstr, list<dag> pattern> |
| 355 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc, |
| 356 | asm, cstr, pattern> { |
| 357 | let Inst{4} = 1; |
| 358 | let Inst{5} = 1; // H bit |
| 359 | let Inst{6} = 0; // S bit |
| 360 | let Inst{7} = 1; |
| 361 | let Inst{20} = 1; // L bit |
| 362 | let Inst{21} = 1; // W bit |
| 363 | let Inst{24} = 1; // P bit |
| 364 | } |
| 365 | class AI3ldshpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 366 | string asm, string cstr, list<dag> pattern> |
| 367 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc, |
| 368 | asm, cstr, pattern> { |
| 369 | let Inst{4} = 1; |
| 370 | let Inst{5} = 1; // H bit |
| 371 | let Inst{6} = 1; // S bit |
| 372 | let Inst{7} = 1; |
| 373 | let Inst{20} = 1; // L bit |
| 374 | let Inst{21} = 1; // W bit |
| 375 | let Inst{24} = 1; // P bit |
| 376 | } |
| 377 | class AI3ldsbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 378 | string asm, string cstr, list<dag> pattern> |
| 379 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc, |
| 380 | asm, cstr, pattern> { |
| 381 | let Inst{4} = 1; |
| 382 | let Inst{5} = 0; // H bit |
| 383 | let Inst{6} = 1; // S bit |
| 384 | let Inst{7} = 1; |
| 385 | let Inst{20} = 1; // L bit |
| 386 | let Inst{21} = 1; // W bit |
| 387 | let Inst{24} = 1; // P bit |
| 388 | } |
| 389 | |
| 390 | // Pre-indexed stores |
| 391 | class AI3sthpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 392 | string asm, string cstr, list<dag> pattern> |
| 393 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc, |
| 394 | asm, cstr, pattern> { |
| 395 | let Inst{4} = 1; |
| 396 | let Inst{5} = 1; // H bit |
| 397 | let Inst{6} = 0; // S bit |
| 398 | let Inst{7} = 1; |
| 399 | let Inst{20} = 0; // L bit |
| 400 | let Inst{21} = 1; // W bit |
| 401 | let Inst{24} = 1; // P bit |
| 402 | } |
| 403 | |
| 404 | // Post-indexed loads |
| 405 | class AI3ldhpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 406 | string asm, string cstr, list<dag> pattern> |
| 407 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc, |
| 408 | asm, cstr,pattern> { |
| 409 | let Inst{4} = 1; |
| 410 | let Inst{5} = 1; // H bit |
| 411 | let Inst{6} = 0; // S bit |
| 412 | let Inst{7} = 1; |
| 413 | let Inst{20} = 1; // L bit |
| 414 | let Inst{21} = 1; // W bit |
| 415 | let Inst{24} = 0; // P bit |
| 416 | } |
| 417 | class AI3ldshpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 418 | string asm, string cstr, list<dag> pattern> |
| 419 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc, |
| 420 | asm, cstr,pattern> { |
| 421 | let Inst{4} = 1; |
| 422 | let Inst{5} = 1; // H bit |
| 423 | let Inst{6} = 1; // S bit |
| 424 | let Inst{7} = 1; |
| 425 | let Inst{20} = 1; // L bit |
| 426 | let Inst{21} = 1; // W bit |
| 427 | let Inst{24} = 0; // P bit |
| 428 | } |
| 429 | class AI3ldsbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 430 | string asm, string cstr, list<dag> pattern> |
| 431 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc, |
| 432 | asm, cstr,pattern> { |
| 433 | let Inst{4} = 1; |
| 434 | let Inst{5} = 0; // H bit |
| 435 | let Inst{6} = 1; // S bit |
| 436 | let Inst{7} = 1; |
| 437 | let Inst{20} = 1; // L bit |
| 438 | let Inst{21} = 1; // W bit |
| 439 | let Inst{24} = 0; // P bit |
| 440 | } |
| 441 | |
| 442 | // Post-indexed stores |
| 443 | class AI3sthpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 444 | string asm, string cstr, list<dag> pattern> |
| 445 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc, |
| 446 | asm, cstr,pattern> { |
| 447 | let Inst{4} = 1; |
| 448 | let Inst{5} = 1; // H bit |
| 449 | let Inst{6} = 0; // S bit |
| 450 | let Inst{7} = 1; |
| 451 | let Inst{20} = 0; // L bit |
| 452 | let Inst{21} = 1; // W bit |
| 453 | let Inst{24} = 0; // P bit |
| 454 | } |
| 455 | |
| 456 | |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 457 | // addrmode4 instructions |
| 458 | class AI4<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 459 | string asm, list<dag> pattern> |
| 460 | : I<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc, |
| 461 | asm, "", pattern>; |
| 462 | |
| 463 | |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 464 | |
| 465 | // Special cases. |
| 466 | class XI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz, |
| 467 | IndexMode im, Format f, string asm, string cstr, list<dag> pattern> |
| 468 | : InstARM<opcod, am, sz, im, f, cstr> { |
| 469 | let OutOperandList = oops; |
| 470 | let InOperandList = iops; |
| 471 | let AsmString = asm; |
| 472 | let Pattern = pattern; |
| 473 | list<Predicate> Predicates = [IsARM]; |
| 474 | } |
| 475 | |
| 476 | class AXI<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 477 | list<dag> pattern> |
| 478 | : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm, |
| 479 | "", pattern>; |
| 480 | class AXI1<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 481 | list<dag> pattern> |
| 482 | : XI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, asm, |
| 483 | "", pattern>; |
| 484 | class AXI2<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 485 | list<dag> pattern> |
| 486 | : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm, |
| 487 | "", pattern>; |
| 488 | class AXI3<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 489 | list<dag> pattern> |
| 490 | : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm, |
| 491 | "", pattern>; |
| 492 | class AXI4<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 493 | list<dag> pattern> |
| 494 | : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm, |
| 495 | "", pattern>; |
| 496 | |
| 497 | class AXIx2<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 498 | list<dag> pattern> |
| 499 | : XI<opcod, oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, f, asm, |
| 500 | "", pattern>; |
| 501 | |
| 502 | // BR_JT instructions |
| 503 | class JTI<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern> |
| 504 | : XI<opcod, oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BranchMisc, |
| 505 | asm, "", pattern>; |
| 506 | class JTI1<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern> |
| 507 | : XI<opcod, oops, iops, AddrMode1, SizeSpecial, IndexModeNone, BranchMisc, |
| 508 | asm, "", pattern>; |
| 509 | class JTI2<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern> |
| 510 | : XI<opcod, oops, iops, AddrMode2, SizeSpecial, IndexModeNone, BranchMisc, |
| 511 | asm, "", pattern>; |
| 512 | |
| 513 | |
| 514 | //===----------------------------------------------------------------------===// |
| 515 | |
| 516 | // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode. |
| 517 | class ARMPat<dag pattern, dag result> : Pat<pattern, result> { |
| 518 | list<Predicate> Predicates = [IsARM]; |
| 519 | } |
| 520 | class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> { |
| 521 | list<Predicate> Predicates = [IsARM, HasV5TE]; |
| 522 | } |
| 523 | class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> { |
| 524 | list<Predicate> Predicates = [IsARM, HasV6]; |
| 525 | } |
Evan Cheng | 1309664 | 2008-08-29 06:41:12 +0000 | [diff] [blame] | 526 | |
| 527 | //===----------------------------------------------------------------------===// |
| 528 | // |
| 529 | // Thumb Instruction Format Definitions. |
| 530 | // |
| 531 | |
| 532 | |
| 533 | // TI - Thumb instruction. |
| 534 | |
| 535 | class ThumbI<dag outs, dag ins, AddrMode am, SizeFlagVal sz, |
| 536 | string asm, string cstr, list<dag> pattern> |
| 537 | // FIXME: Set all opcodes to 0 for now. |
| 538 | : InstARM<0, am, sz, IndexModeNone, ThumbFrm, cstr> { |
| 539 | let OutOperandList = outs; |
| 540 | let InOperandList = ins; |
| 541 | let AsmString = asm; |
| 542 | let Pattern = pattern; |
| 543 | list<Predicate> Predicates = [IsThumb]; |
| 544 | } |
| 545 | |
| 546 | class TI<dag outs, dag ins, string asm, list<dag> pattern> |
| 547 | : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "", pattern>; |
| 548 | class TI1<dag outs, dag ins, string asm, list<dag> pattern> |
| 549 | : ThumbI<outs, ins, AddrModeT1, Size2Bytes, asm, "", pattern>; |
| 550 | class TI2<dag outs, dag ins, string asm, list<dag> pattern> |
| 551 | : ThumbI<outs, ins, AddrModeT2, Size2Bytes, asm, "", pattern>; |
| 552 | class TI4<dag outs, dag ins, string asm, list<dag> pattern> |
| 553 | : ThumbI<outs, ins, AddrModeT4, Size2Bytes, asm, "", pattern>; |
| 554 | class TIs<dag outs, dag ins, string asm, list<dag> pattern> |
| 555 | : ThumbI<outs, ins, AddrModeTs, Size2Bytes, asm, "", pattern>; |
| 556 | |
| 557 | // Two-address instructions |
| 558 | class TIt<dag outs, dag ins, string asm, list<dag> pattern> |
| 559 | : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "$lhs = $dst", pattern>; |
| 560 | |
| 561 | // BL, BLX(1) are translated by assembler into two instructions |
| 562 | class TIx2<dag outs, dag ins, string asm, list<dag> pattern> |
| 563 | : ThumbI<outs, ins, AddrModeNone, Size4Bytes, asm, "", pattern>; |
| 564 | |
| 565 | // BR_JT instructions |
| 566 | class TJTI<dag outs, dag ins, string asm, list<dag> pattern> |
| 567 | : ThumbI<outs, ins, AddrModeNone, SizeSpecial, asm, "", pattern>; |
| 568 | |
| 569 | |
| 570 | //===----------------------------------------------------------------------===// |
| 571 | |
| 572 | |
| 573 | // ThumbPat - Same as Pat<>, but requires that the compiler be in Thumb mode. |
| 574 | class ThumbPat<dag pattern, dag result> : Pat<pattern, result> { |
| 575 | list<Predicate> Predicates = [IsThumb]; |
| 576 | } |
| 577 | |
| 578 | class ThumbV5Pat<dag pattern, dag result> : Pat<pattern, result> { |
| 579 | list<Predicate> Predicates = [IsThumb, HasV5T]; |
| 580 | } |