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 | |
Evan Cheng | 4bbd5f8 | 2008-09-01 07:19:00 +0000 | [diff] [blame] | 115 | // Special cases |
| 116 | class XI<bits<4> opcod, dag oops, dag iops, AddrMode am, SizeFlagVal sz, |
| 117 | IndexMode im, Format f, string asm, string cstr, list<dag> pattern> |
| 118 | : InstARM<opcod, am, sz, im, f, cstr> { |
| 119 | let OutOperandList = oops; |
| 120 | let InOperandList = iops; |
| 121 | let AsmString = asm; |
| 122 | let Pattern = pattern; |
| 123 | list<Predicate> Predicates = [IsARM]; |
| 124 | } |
| 125 | |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 126 | class AI<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 127 | string asm, list<dag> pattern> |
| 128 | : I<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc, |
| 129 | asm,"",pattern>; |
| 130 | class AsI<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 131 | string asm, list<dag> pattern> |
| 132 | : sI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, opc, |
| 133 | asm,"",pattern>; |
Evan Cheng | 4bbd5f8 | 2008-09-01 07:19:00 +0000 | [diff] [blame] | 134 | class AXI<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 135 | list<dag> pattern> |
| 136 | : XI<opcod, oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, f, asm, |
| 137 | "", pattern>; |
| 138 | class AXIx2<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 139 | list<dag> pattern> |
| 140 | : XI<opcod, oops, iops, AddrModeNone, Size8Bytes, IndexModeNone, f, asm, |
| 141 | "", pattern>; |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 142 | |
| 143 | // addrmode1 instructions |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 144 | class AI1<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 145 | string asm, list<dag> pattern> |
| 146 | : I<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc, |
Evan Cheng | 612b79e | 2008-08-29 07:40:52 +0000 | [diff] [blame] | 147 | asm, "", pattern> { |
Evan Cheng | b7880ac | 2008-08-31 18:32:16 +0000 | [diff] [blame] | 148 | let Inst{21-24} = opcod; |
| 149 | let Inst{26-27} = 0; |
Evan Cheng | 612b79e | 2008-08-29 07:40:52 +0000 | [diff] [blame] | 150 | } |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 151 | class AsI1<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 152 | string asm, list<dag> pattern> |
| 153 | : sI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, opc, |
Evan Cheng | 612b79e | 2008-08-29 07:40:52 +0000 | [diff] [blame] | 154 | asm, "", pattern> { |
Evan Cheng | b7880ac | 2008-08-31 18:32:16 +0000 | [diff] [blame] | 155 | let Inst{20} = 1; |
| 156 | let Inst{21-24} = opcod; |
| 157 | let Inst{26-27} = 0; |
Evan Cheng | 612b79e | 2008-08-29 07:40:52 +0000 | [diff] [blame] | 158 | } |
Evan Cheng | 4bbd5f8 | 2008-09-01 07:19:00 +0000 | [diff] [blame] | 159 | class AXI1<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 160 | list<dag> pattern> |
| 161 | : XI<opcod, oops, iops, AddrMode1, Size4Bytes, IndexModeNone, f, asm, |
| 162 | "", pattern> { |
| 163 | let Inst{20} = 1; |
| 164 | let Inst{21-24} = opcod; |
| 165 | let Inst{26-27} = 0; |
| 166 | } |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 167 | class AI1x2<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 168 | string asm, list<dag> pattern> |
| 169 | : I<opcod, oops, iops, AddrMode1, Size8Bytes, IndexModeNone, f, opc, |
| 170 | asm, "", pattern>; |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 171 | |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 172 | |
| 173 | // addrmode2 loads and stores |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 174 | class AI2<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 175 | string asm, list<dag> pattern> |
| 176 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, opc, |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 177 | asm, "", pattern> { |
| 178 | let Inst{26-27} = 1; |
| 179 | } |
Evan Cheng | 4bbd5f8 | 2008-09-01 07:19:00 +0000 | [diff] [blame] | 180 | class AXI2<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 181 | list<dag> pattern> |
| 182 | : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm, |
| 183 | "", pattern>; |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 184 | |
| 185 | // loads |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 186 | class AI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 187 | string asm, list<dag> pattern> |
| 188 | : AI2<opcod, oops, iops, f, opc, asm, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 189 | let Inst{20} = 1; // L bit |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 190 | let Inst{21} = 0; // W bit |
| 191 | let Inst{22} = 0; // B bit |
| 192 | let Inst{24} = 1; // P bit |
| 193 | } |
Evan Cheng | 5d2c1cf | 2008-09-01 07:34:13 +0000 | [diff] [blame^] | 194 | class AXI2ldw<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 195 | list<dag> pattern> |
| 196 | : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm, |
| 197 | "", pattern> { |
| 198 | let Inst{20} = 1; // L bit |
| 199 | let Inst{21} = 0; // W bit |
| 200 | let Inst{22} = 0; // B bit |
| 201 | let Inst{24} = 1; // P bit |
| 202 | } |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 203 | class AI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 204 | string asm, list<dag> pattern> |
| 205 | : AI2<opcod, oops, iops, f, opc, asm, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 206 | let Inst{20} = 1; // L bit |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 207 | let Inst{21} = 0; // W bit |
| 208 | let Inst{22} = 1; // B bit |
| 209 | let Inst{24} = 1; // P bit |
| 210 | } |
Evan Cheng | 5d2c1cf | 2008-09-01 07:34:13 +0000 | [diff] [blame^] | 211 | class AXI2ldb<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 212 | list<dag> pattern> |
| 213 | : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm, |
| 214 | "", pattern> { |
| 215 | let Inst{20} = 1; // L bit |
| 216 | let Inst{21} = 0; // W bit |
| 217 | let Inst{22} = 1; // B bit |
| 218 | let Inst{24} = 1; // P bit |
| 219 | } |
Evan Cheng | 17222df | 2008-08-31 19:02:21 +0000 | [diff] [blame] | 220 | |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 221 | // stores |
| 222 | class AI2stw<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 223 | string asm, list<dag> pattern> |
| 224 | : AI2<opcod, oops, iops, f, opc, asm, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 225 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 226 | let Inst{21} = 0; // W bit |
| 227 | let Inst{22} = 0; // B bit |
| 228 | let Inst{24} = 1; // P bit |
| 229 | } |
Evan Cheng | 5d2c1cf | 2008-09-01 07:34:13 +0000 | [diff] [blame^] | 230 | class AXI2stw<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 231 | list<dag> pattern> |
| 232 | : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm, |
| 233 | "", pattern> { |
| 234 | let Inst{20} = 0; // L bit |
| 235 | let Inst{21} = 0; // W bit |
| 236 | let Inst{22} = 0; // B bit |
| 237 | let Inst{24} = 1; // P bit |
| 238 | } |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 239 | class AI2stb<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 240 | string asm, list<dag> pattern> |
| 241 | : AI2<opcod, oops, iops, f, opc, asm, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 242 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 243 | let Inst{21} = 0; // W bit |
| 244 | let Inst{22} = 1; // B bit |
| 245 | let Inst{24} = 1; // P bit |
| 246 | } |
Evan Cheng | 5d2c1cf | 2008-09-01 07:34:13 +0000 | [diff] [blame^] | 247 | class AXI2stb<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 248 | list<dag> pattern> |
| 249 | : XI<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModeNone, f, asm, |
| 250 | "", pattern> { |
| 251 | let Inst{20} = 0; // L bit |
| 252 | let Inst{21} = 0; // W bit |
| 253 | let Inst{22} = 1; // B bit |
| 254 | let Inst{24} = 1; // P bit |
| 255 | } |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 256 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 257 | // Pre-indexed loads |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 258 | 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] | 259 | string asm, string cstr, list<dag> pattern> |
| 260 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc, |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 261 | asm, cstr, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 262 | let Inst{20} = 1; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 263 | let Inst{21} = 1; // W bit |
| 264 | let Inst{22} = 0; // B bit |
| 265 | let Inst{24} = 1; // P bit |
| 266 | } |
| 267 | class AI2ldbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 268 | string asm, string cstr, list<dag> pattern> |
| 269 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc, |
| 270 | asm, cstr, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 271 | let Inst{20} = 1; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 272 | let Inst{21} = 1; // W bit |
| 273 | let Inst{22} = 1; // B bit |
| 274 | let Inst{24} = 1; // P bit |
| 275 | } |
| 276 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 277 | // Pre-indexed stores |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 278 | class AI2stwpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 279 | string asm, string cstr, list<dag> pattern> |
| 280 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc, |
| 281 | asm, cstr, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 282 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 283 | let Inst{21} = 1; // W bit |
| 284 | let Inst{22} = 0; // B bit |
| 285 | let Inst{24} = 1; // P bit |
| 286 | } |
| 287 | class AI2stbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 288 | string asm, string cstr, list<dag> pattern> |
| 289 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePre, f, opc, |
| 290 | asm, cstr, pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 291 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 292 | let Inst{21} = 1; // W bit |
| 293 | let Inst{22} = 1; // B bit |
| 294 | let Inst{24} = 1; // P bit |
| 295 | } |
| 296 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 297 | // Post-indexed loads |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 298 | 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] | 299 | string asm, string cstr, list<dag> pattern> |
| 300 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc, |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 301 | asm, cstr,pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 302 | let Inst{20} = 1; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 303 | let Inst{21} = 0; // W bit |
| 304 | let Inst{22} = 0; // B bit |
| 305 | let Inst{24} = 0; // P bit |
| 306 | } |
| 307 | class AI2ldbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 308 | string asm, string cstr, list<dag> pattern> |
| 309 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc, |
| 310 | asm, cstr,pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 311 | let Inst{20} = 1; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 312 | let Inst{21} = 0; // W bit |
| 313 | let Inst{22} = 1; // B bit |
| 314 | let Inst{24} = 0; // P bit |
| 315 | } |
| 316 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 317 | // Post-indexed stores |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 318 | class AI2stwpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 319 | string asm, string cstr, list<dag> pattern> |
| 320 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc, |
| 321 | asm, cstr,pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 322 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 323 | let Inst{21} = 0; // W bit |
| 324 | let Inst{22} = 0; // B bit |
| 325 | let Inst{24} = 0; // P bit |
| 326 | } |
| 327 | class AI2stbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 328 | string asm, string cstr, list<dag> pattern> |
| 329 | : I<opcod, oops, iops, AddrMode2, Size4Bytes, IndexModePost, f, opc, |
| 330 | asm, cstr,pattern> { |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 331 | let Inst{20} = 0; // L bit |
Evan Cheng | 9391273 | 2008-09-01 01:27:33 +0000 | [diff] [blame] | 332 | let Inst{21} = 0; // W bit |
| 333 | let Inst{22} = 1; // B bit |
| 334 | let Inst{24} = 0; // P bit |
| 335 | } |
| 336 | |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 337 | // addrmode3 instructions |
| 338 | class AI3<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 339 | string asm, list<dag> pattern> |
| 340 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 341 | asm, "", pattern>; |
Evan Cheng | 4bbd5f8 | 2008-09-01 07:19:00 +0000 | [diff] [blame] | 342 | class AXI3<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 343 | list<dag> pattern> |
| 344 | : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm, |
| 345 | "", pattern>; |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 346 | |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 347 | // loads |
| 348 | class AI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 349 | string asm, list<dag> pattern> |
| 350 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 351 | asm, "", pattern> { |
| 352 | let Inst{4} = 1; |
| 353 | let Inst{5} = 1; // H bit |
| 354 | let Inst{6} = 0; // S bit |
| 355 | let Inst{7} = 1; |
| 356 | let Inst{20} = 1; // L bit |
| 357 | let Inst{21} = 0; // W bit |
| 358 | let Inst{24} = 1; // P bit |
| 359 | } |
Evan Cheng | 5d2c1cf | 2008-09-01 07:34:13 +0000 | [diff] [blame^] | 360 | class AXI3ldh<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 361 | list<dag> pattern> |
| 362 | : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm, |
| 363 | "", pattern> { |
| 364 | let Inst{4} = 1; |
| 365 | let Inst{5} = 1; // H bit |
| 366 | let Inst{6} = 0; // S bit |
| 367 | let Inst{7} = 1; |
| 368 | let Inst{20} = 1; // L bit |
| 369 | let Inst{21} = 0; // W bit |
| 370 | let Inst{24} = 1; // P bit |
| 371 | } |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 372 | class AI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 373 | string asm, list<dag> pattern> |
| 374 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 375 | asm, "", pattern> { |
| 376 | let Inst{4} = 1; |
| 377 | let Inst{5} = 1; // H bit |
| 378 | let Inst{6} = 1; // S bit |
| 379 | let Inst{7} = 1; |
| 380 | let Inst{20} = 1; // L bit |
| 381 | let Inst{21} = 0; // W bit |
| 382 | let Inst{24} = 1; // P bit |
| 383 | } |
Evan Cheng | 5d2c1cf | 2008-09-01 07:34:13 +0000 | [diff] [blame^] | 384 | class AXI3ldsh<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 385 | list<dag> pattern> |
| 386 | : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm, |
| 387 | "", pattern> { |
| 388 | let Inst{4} = 1; |
| 389 | let Inst{5} = 1; // H bit |
| 390 | let Inst{6} = 1; // S bit |
| 391 | let Inst{7} = 1; |
| 392 | let Inst{20} = 1; // L bit |
| 393 | let Inst{21} = 0; // W bit |
| 394 | let Inst{24} = 1; // P bit |
| 395 | } |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 396 | class AI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 397 | string asm, list<dag> pattern> |
| 398 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 399 | asm, "", pattern> { |
| 400 | let Inst{4} = 1; |
| 401 | let Inst{5} = 0; // H bit |
| 402 | let Inst{6} = 1; // S bit |
| 403 | let Inst{7} = 1; |
| 404 | let Inst{20} = 1; // L bit |
| 405 | let Inst{21} = 0; // W bit |
| 406 | let Inst{24} = 1; // P bit |
| 407 | } |
Evan Cheng | 5d2c1cf | 2008-09-01 07:34:13 +0000 | [diff] [blame^] | 408 | class AXI3ldsb<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 409 | list<dag> pattern> |
| 410 | : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm, |
| 411 | "", pattern> { |
| 412 | let Inst{4} = 1; |
| 413 | let Inst{5} = 0; // H bit |
| 414 | let Inst{6} = 1; // S bit |
| 415 | let Inst{7} = 1; |
| 416 | let Inst{20} = 1; // L bit |
| 417 | let Inst{21} = 0; // W bit |
| 418 | let Inst{24} = 1; // P bit |
| 419 | } |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 420 | class AI3ldd<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 421 | string asm, list<dag> pattern> |
| 422 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 423 | asm, "", pattern> { |
| 424 | let Inst{4} = 1; |
| 425 | let Inst{5} = 0; // H bit |
| 426 | let Inst{6} = 1; // S bit |
| 427 | let Inst{7} = 1; |
| 428 | let Inst{20} = 0; // L bit |
| 429 | let Inst{21} = 0; // W bit |
| 430 | let Inst{24} = 1; // P bit |
| 431 | } |
| 432 | |
| 433 | // stores |
| 434 | class AI3sth<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 435 | string asm, list<dag> pattern> |
| 436 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 437 | asm, "", pattern> { |
| 438 | let Inst{4} = 1; |
| 439 | let Inst{5} = 1; // H bit |
| 440 | let Inst{6} = 0; // S bit |
| 441 | let Inst{7} = 1; |
| 442 | let Inst{20} = 0; // L bit |
| 443 | let Inst{21} = 0; // W bit |
| 444 | let Inst{24} = 1; // P bit |
| 445 | } |
Evan Cheng | 5d2c1cf | 2008-09-01 07:34:13 +0000 | [diff] [blame^] | 446 | class AXI3sth<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 447 | list<dag> pattern> |
| 448 | : XI<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, asm, |
| 449 | "", pattern> { |
| 450 | let Inst{4} = 1; |
| 451 | let Inst{5} = 1; // H bit |
| 452 | let Inst{6} = 0; // S bit |
| 453 | let Inst{7} = 1; |
| 454 | let Inst{20} = 0; // L bit |
| 455 | let Inst{21} = 0; // W bit |
| 456 | let Inst{24} = 1; // P bit |
| 457 | } |
Evan Cheng | 840917b | 2008-09-01 07:00:14 +0000 | [diff] [blame] | 458 | class AI3std<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 459 | string asm, list<dag> pattern> |
| 460 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModeNone, f, opc, |
| 461 | asm, "", pattern> { |
| 462 | let Inst{4} = 1; |
| 463 | let Inst{5} = 1; // H bit |
| 464 | let Inst{6} = 1; // S bit |
| 465 | let Inst{7} = 1; |
| 466 | let Inst{20} = 0; // L bit |
| 467 | let Inst{21} = 0; // W bit |
| 468 | let Inst{24} = 1; // P bit |
| 469 | } |
| 470 | |
| 471 | // Pre-indexed loads |
| 472 | class AI3ldhpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 473 | string asm, string cstr, list<dag> pattern> |
| 474 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc, |
| 475 | asm, cstr, pattern> { |
| 476 | let Inst{4} = 1; |
| 477 | let Inst{5} = 1; // H bit |
| 478 | let Inst{6} = 0; // S bit |
| 479 | let Inst{7} = 1; |
| 480 | let Inst{20} = 1; // L bit |
| 481 | let Inst{21} = 1; // W bit |
| 482 | let Inst{24} = 1; // P bit |
| 483 | } |
| 484 | class AI3ldshpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 485 | string asm, string cstr, list<dag> pattern> |
| 486 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc, |
| 487 | asm, cstr, pattern> { |
| 488 | let Inst{4} = 1; |
| 489 | let Inst{5} = 1; // H bit |
| 490 | let Inst{6} = 1; // S bit |
| 491 | let Inst{7} = 1; |
| 492 | let Inst{20} = 1; // L bit |
| 493 | let Inst{21} = 1; // W bit |
| 494 | let Inst{24} = 1; // P bit |
| 495 | } |
| 496 | class AI3ldsbpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 497 | string asm, string cstr, list<dag> pattern> |
| 498 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc, |
| 499 | asm, cstr, pattern> { |
| 500 | let Inst{4} = 1; |
| 501 | let Inst{5} = 0; // H bit |
| 502 | let Inst{6} = 1; // S bit |
| 503 | let Inst{7} = 1; |
| 504 | let Inst{20} = 1; // L bit |
| 505 | let Inst{21} = 1; // W bit |
| 506 | let Inst{24} = 1; // P bit |
| 507 | } |
| 508 | |
| 509 | // Pre-indexed stores |
| 510 | class AI3sthpr<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 511 | string asm, string cstr, list<dag> pattern> |
| 512 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePre, f, opc, |
| 513 | asm, cstr, pattern> { |
| 514 | let Inst{4} = 1; |
| 515 | let Inst{5} = 1; // H bit |
| 516 | let Inst{6} = 0; // S bit |
| 517 | let Inst{7} = 1; |
| 518 | let Inst{20} = 0; // L bit |
| 519 | let Inst{21} = 1; // W bit |
| 520 | let Inst{24} = 1; // P bit |
| 521 | } |
| 522 | |
| 523 | // Post-indexed loads |
| 524 | class AI3ldhpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 525 | string asm, string cstr, list<dag> pattern> |
| 526 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc, |
| 527 | asm, cstr,pattern> { |
| 528 | let Inst{4} = 1; |
| 529 | let Inst{5} = 1; // H bit |
| 530 | let Inst{6} = 0; // S bit |
| 531 | let Inst{7} = 1; |
| 532 | let Inst{20} = 1; // L bit |
| 533 | let Inst{21} = 1; // W bit |
| 534 | let Inst{24} = 0; // P bit |
| 535 | } |
| 536 | class AI3ldshpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 537 | string asm, string cstr, list<dag> pattern> |
| 538 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc, |
| 539 | asm, cstr,pattern> { |
| 540 | let Inst{4} = 1; |
| 541 | let Inst{5} = 1; // H bit |
| 542 | let Inst{6} = 1; // S bit |
| 543 | let Inst{7} = 1; |
| 544 | let Inst{20} = 1; // L bit |
| 545 | let Inst{21} = 1; // W bit |
| 546 | let Inst{24} = 0; // P bit |
| 547 | } |
| 548 | class AI3ldsbpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 549 | string asm, string cstr, list<dag> pattern> |
| 550 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc, |
| 551 | asm, cstr,pattern> { |
| 552 | let Inst{4} = 1; |
| 553 | let Inst{5} = 0; // H bit |
| 554 | let Inst{6} = 1; // S bit |
| 555 | let Inst{7} = 1; |
| 556 | let Inst{20} = 1; // L bit |
| 557 | let Inst{21} = 1; // W bit |
| 558 | let Inst{24} = 0; // P bit |
| 559 | } |
| 560 | |
| 561 | // Post-indexed stores |
| 562 | class AI3sthpo<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 563 | string asm, string cstr, list<dag> pattern> |
| 564 | : I<opcod, oops, iops, AddrMode3, Size4Bytes, IndexModePost, f, opc, |
| 565 | asm, cstr,pattern> { |
| 566 | let Inst{4} = 1; |
| 567 | let Inst{5} = 1; // H bit |
| 568 | let Inst{6} = 0; // S bit |
| 569 | let Inst{7} = 1; |
| 570 | let Inst{20} = 0; // L bit |
| 571 | let Inst{21} = 1; // W bit |
| 572 | let Inst{24} = 0; // P bit |
| 573 | } |
| 574 | |
| 575 | |
Evan Cheng | 0d14fc8 | 2008-09-01 01:51:14 +0000 | [diff] [blame] | 576 | // addrmode4 instructions |
| 577 | class AI4<bits<4> opcod, dag oops, dag iops, Format f, string opc, |
| 578 | string asm, list<dag> pattern> |
| 579 | : I<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, opc, |
| 580 | asm, "", pattern>; |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 581 | class AXI4<bits<4> opcod, dag oops, dag iops, Format f, string asm, |
| 582 | list<dag> pattern> |
| 583 | : XI<opcod, oops, iops, AddrMode4, Size4Bytes, IndexModeNone, f, asm, |
| 584 | "", pattern>; |
| 585 | |
Evan Cheng | 37f25d9 | 2008-08-28 23:39:26 +0000 | [diff] [blame] | 586 | |
| 587 | // BR_JT instructions |
| 588 | class JTI<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern> |
| 589 | : XI<opcod, oops, iops, AddrModeNone, SizeSpecial, IndexModeNone, BranchMisc, |
| 590 | asm, "", pattern>; |
| 591 | class JTI1<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern> |
| 592 | : XI<opcod, oops, iops, AddrMode1, SizeSpecial, IndexModeNone, BranchMisc, |
| 593 | asm, "", pattern>; |
| 594 | class JTI2<bits<4> opcod, dag oops, dag iops, string asm, list<dag> pattern> |
| 595 | : XI<opcod, oops, iops, AddrMode2, SizeSpecial, IndexModeNone, BranchMisc, |
| 596 | asm, "", pattern>; |
| 597 | |
| 598 | |
| 599 | //===----------------------------------------------------------------------===// |
| 600 | |
| 601 | // ARMPat - Same as Pat<>, but requires that the compiler be in ARM mode. |
| 602 | class ARMPat<dag pattern, dag result> : Pat<pattern, result> { |
| 603 | list<Predicate> Predicates = [IsARM]; |
| 604 | } |
| 605 | class ARMV5TEPat<dag pattern, dag result> : Pat<pattern, result> { |
| 606 | list<Predicate> Predicates = [IsARM, HasV5TE]; |
| 607 | } |
| 608 | class ARMV6Pat<dag pattern, dag result> : Pat<pattern, result> { |
| 609 | list<Predicate> Predicates = [IsARM, HasV6]; |
| 610 | } |
Evan Cheng | 1309664 | 2008-08-29 06:41:12 +0000 | [diff] [blame] | 611 | |
| 612 | //===----------------------------------------------------------------------===// |
| 613 | // |
| 614 | // Thumb Instruction Format Definitions. |
| 615 | // |
| 616 | |
| 617 | |
| 618 | // TI - Thumb instruction. |
| 619 | |
| 620 | class ThumbI<dag outs, dag ins, AddrMode am, SizeFlagVal sz, |
| 621 | string asm, string cstr, list<dag> pattern> |
| 622 | // FIXME: Set all opcodes to 0 for now. |
| 623 | : InstARM<0, am, sz, IndexModeNone, ThumbFrm, cstr> { |
| 624 | let OutOperandList = outs; |
| 625 | let InOperandList = ins; |
| 626 | let AsmString = asm; |
| 627 | let Pattern = pattern; |
| 628 | list<Predicate> Predicates = [IsThumb]; |
| 629 | } |
| 630 | |
| 631 | class TI<dag outs, dag ins, string asm, list<dag> pattern> |
| 632 | : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "", pattern>; |
| 633 | class TI1<dag outs, dag ins, string asm, list<dag> pattern> |
| 634 | : ThumbI<outs, ins, AddrModeT1, Size2Bytes, asm, "", pattern>; |
| 635 | class TI2<dag outs, dag ins, string asm, list<dag> pattern> |
| 636 | : ThumbI<outs, ins, AddrModeT2, Size2Bytes, asm, "", pattern>; |
| 637 | class TI4<dag outs, dag ins, string asm, list<dag> pattern> |
| 638 | : ThumbI<outs, ins, AddrModeT4, Size2Bytes, asm, "", pattern>; |
| 639 | class TIs<dag outs, dag ins, string asm, list<dag> pattern> |
| 640 | : ThumbI<outs, ins, AddrModeTs, Size2Bytes, asm, "", pattern>; |
| 641 | |
| 642 | // Two-address instructions |
| 643 | class TIt<dag outs, dag ins, string asm, list<dag> pattern> |
| 644 | : ThumbI<outs, ins, AddrModeNone, Size2Bytes, asm, "$lhs = $dst", pattern>; |
| 645 | |
| 646 | // BL, BLX(1) are translated by assembler into two instructions |
| 647 | class TIx2<dag outs, dag ins, string asm, list<dag> pattern> |
| 648 | : ThumbI<outs, ins, AddrModeNone, Size4Bytes, asm, "", pattern>; |
| 649 | |
| 650 | // BR_JT instructions |
| 651 | class TJTI<dag outs, dag ins, string asm, list<dag> pattern> |
| 652 | : ThumbI<outs, ins, AddrModeNone, SizeSpecial, asm, "", pattern>; |
| 653 | |
| 654 | |
| 655 | //===----------------------------------------------------------------------===// |
| 656 | |
| 657 | |
| 658 | // ThumbPat - Same as Pat<>, but requires that the compiler be in Thumb mode. |
| 659 | class ThumbPat<dag pattern, dag result> : Pat<pattern, result> { |
| 660 | list<Predicate> Predicates = [IsThumb]; |
| 661 | } |
| 662 | |
| 663 | class ThumbV5Pat<dag pattern, dag result> : Pat<pattern, result> { |
| 664 | list<Predicate> Predicates = [IsThumb, HasV5T]; |
| 665 | } |