blob: 54b13dc21a575072f03acc59b42f7e7850e8b224 [file] [log] [blame]
Johnny Chenb68a3ee2010-04-02 22:27:38 +00001//===- ARMDisassembler.cpp - Disassembler for ARM/Thumb ISA -----*- C++ -*-===//
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// This file is part of the ARM Disassembler.
11// It contains code to implement the public interfaces of ARMDisassembler and
12// ThumbDisassembler, both of which are instances of MCDisassembler.
13//
14//===----------------------------------------------------------------------===//
15
16#define DEBUG_TYPE "arm-disassembler"
17
18#include "ARMDisassembler.h"
19#include "ARMDisassemblerCore.h"
20
Sean Callanan9899f702010-04-13 21:21:57 +000021#include "llvm/MC/EDInstInfo.h"
Johnny Chenb68a3ee2010-04-02 22:27:38 +000022#include "llvm/MC/MCInst.h"
23#include "llvm/Target/TargetRegistry.h"
24#include "llvm/Support/Debug.h"
25#include "llvm/Support/MemoryObject.h"
26#include "llvm/Support/ErrorHandling.h"
27#include "llvm/Support/raw_ostream.h"
28
Johnny Chen270159f2010-08-12 01:40:54 +000029//#define DEBUG(X) do { X; } while (0)
30
Johnny Chenb68a3ee2010-04-02 22:27:38 +000031/// ARMGenDecoderTables.inc - ARMDecoderTables.inc is tblgen'ed from
32/// ARMDecoderEmitter.cpp TableGen backend. It contains:
33///
34/// o Mappings from opcode to ARM/Thumb instruction format
35///
36/// o static uint16_t decodeInstruction(uint32_t insn) - the decoding function
37/// for an ARM instruction.
38///
39/// o static uint16_t decodeThumbInstruction(field_t insn) - the decoding
40/// function for a Thumb instruction.
41///
Oscar Fuentes38e13902010-09-28 11:48:19 +000042#include "ARMGenDecoderTables.inc"
Johnny Chenb68a3ee2010-04-02 22:27:38 +000043
Oscar Fuentes38e13902010-09-28 11:48:19 +000044#include "ARMGenEDInfo.inc"
Sean Callanan9899f702010-04-13 21:21:57 +000045
46using namespace llvm;
Johnny Chenb68a3ee2010-04-02 22:27:38 +000047
48/// showBitVector - Use the raw_ostream to log a diagnostic message describing
49/// the inidividual bits of the instruction.
50///
51static inline void showBitVector(raw_ostream &os, const uint32_t &insn) {
52 // Split the bit position markers into more than one lines to fit 80 columns.
53 os << " 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11"
54 << " 10 9 8 7 6 5 4 3 2 1 0 \n";
55 os << "---------------------------------------------------------------"
56 << "----------------------------------\n";
57 os << '|';
58 for (unsigned i = 32; i != 0; --i) {
59 if (insn >> (i - 1) & 0x01)
60 os << " 1";
61 else
62 os << " 0";
63 os << (i%4 == 1 ? '|' : ':');
64 }
65 os << '\n';
66 // Split the bit position markers into more than one lines to fit 80 columns.
67 os << "---------------------------------------------------------------"
68 << "----------------------------------\n";
69 os << '\n';
70}
71
72/// decodeARMInstruction is a decorator function which tries special cases of
73/// instruction matching before calling the auto-generated decoder function.
74static unsigned decodeARMInstruction(uint32_t &insn) {
75 if (slice(insn, 31, 28) == 15)
76 goto AutoGenedDecoder;
77
78 // Special case processing, if any, goes here....
79
80 // LLVM combines the offset mode of A8.6.197 & A8.6.198 into STRB.
81 // The insufficient encoding information of the combined instruction confuses
82 // the decoder wrt BFC/BFI. Therefore, we try to recover here.
83 // For BFC, Inst{27-21} = 0b0111110 & Inst{6-0} = 0b0011111.
84 // For BFI, Inst{27-21} = 0b0111110 & Inst{6-4} = 0b001 & Inst{3-0} =! 0b1111.
85 if (slice(insn, 27, 21) == 0x3e && slice(insn, 6, 4) == 1) {
86 if (slice(insn, 3, 0) == 15)
87 return ARM::BFC;
88 else
89 return ARM::BFI;
90 }
91
Jim Grosbach55561d12010-10-13 23:47:11 +000092 // Ditto for STRBT, which is a super-instruction for A8.6.199 Encodings
93 // A1 & A2.
Johnny Chen270159f2010-08-12 01:40:54 +000094 // As a result, the decoder fails to deocode USAT properly.
95 if (slice(insn, 27, 21) == 0x37 && slice(insn, 5, 4) == 1)
96 return ARM::USAT;
Johnny Chen18b475f2011-03-09 20:01:14 +000097 // As a result, the decoder fails to deocode UQADD16 properly.
98 if (slice(insn, 27, 20) == 0x66 && slice(insn, 7, 4) == 1)
99 return ARM::UQADD16;
Johnny Chen270159f2010-08-12 01:40:54 +0000100
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000101 // Ditto for ADDSrs, which is a super-instruction for A8.6.7 & A8.6.8.
102 // As a result, the decoder fails to decode UMULL properly.
103 if (slice(insn, 27, 21) == 0x04 && slice(insn, 7, 4) == 9) {
104 return ARM::UMULL;
105 }
106
107 // Ditto for STR_PRE, which is a super-instruction for A8.6.194 & A8.6.195.
108 // As a result, the decoder fails to decode SBFX properly.
109 if (slice(insn, 27, 21) == 0x3d && slice(insn, 6, 4) == 5)
110 return ARM::SBFX;
111
112 // And STRB_PRE, which is a super-instruction for A8.6.197 & A8.6.198.
113 // As a result, the decoder fails to decode UBFX properly.
114 if (slice(insn, 27, 21) == 0x3f && slice(insn, 6, 4) == 5)
115 return ARM::UBFX;
116
117 // Ditto for STRT, which is a super-instruction for A8.6.210 Encoding A1 & A2.
118 // As a result, the decoder fails to deocode SSAT properly.
119 if (slice(insn, 27, 21) == 0x35 && slice(insn, 5, 4) == 1)
Bob Wilsoneaf1c982010-08-11 23:10:46 +0000120 return ARM::SSAT;
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000121
122 // Ditto for RSCrs, which is a super-instruction for A8.6.146 & A8.6.147.
123 // As a result, the decoder fails to decode STRHT/LDRHT/LDRSHT/LDRSBT.
124 if (slice(insn, 27, 24) == 0) {
125 switch (slice(insn, 21, 20)) {
126 case 2:
127 switch (slice(insn, 7, 4)) {
128 case 11:
129 return ARM::STRHT;
130 default:
131 break; // fallthrough
132 }
133 break;
134 case 3:
135 switch (slice(insn, 7, 4)) {
136 case 11:
137 return ARM::LDRHT;
138 case 13:
139 return ARM::LDRSBT;
140 case 15:
141 return ARM::LDRSHT;
142 default:
143 break; // fallthrough
144 }
145 break;
146 default:
147 break; // fallthrough
148 }
149 }
150
151 // Ditto for SBCrs, which is a super-instruction for A8.6.152 & A8.6.153.
152 // As a result, the decoder fails to decode STRH_Post/LDRD_POST/STRD_POST
153 // properly.
154 if (slice(insn, 27, 25) == 0 && slice(insn, 20, 20) == 0) {
155 unsigned PW = slice(insn, 24, 24) << 1 | slice(insn, 21, 21);
156 switch (slice(insn, 7, 4)) {
157 case 11:
158 switch (PW) {
159 case 2: // Offset
160 return ARM::STRH;
161 case 3: // Pre-indexed
162 return ARM::STRH_PRE;
163 case 0: // Post-indexed
164 return ARM::STRH_POST;
165 default:
166 break; // fallthrough
167 }
168 break;
169 case 13:
170 switch (PW) {
171 case 2: // Offset
172 return ARM::LDRD;
173 case 3: // Pre-indexed
174 return ARM::LDRD_PRE;
175 case 0: // Post-indexed
176 return ARM::LDRD_POST;
177 default:
178 break; // fallthrough
179 }
180 break;
181 case 15:
182 switch (PW) {
183 case 2: // Offset
184 return ARM::STRD;
185 case 3: // Pre-indexed
186 return ARM::STRD_PRE;
187 case 0: // Post-indexed
188 return ARM::STRD_POST;
189 default:
190 break; // fallthrough
191 }
192 break;
193 default:
194 break; // fallthrough
195 }
196 }
197
198 // Ditto for SBCSSrs, which is a super-instruction for A8.6.152 & A8.6.153.
199 // As a result, the decoder fails to decode LDRH_POST/LDRSB_POST/LDRSH_POST
200 // properly.
201 if (slice(insn, 27, 25) == 0 && slice(insn, 20, 20) == 1) {
202 unsigned PW = slice(insn, 24, 24) << 1 | slice(insn, 21, 21);
203 switch (slice(insn, 7, 4)) {
204 case 11:
205 switch (PW) {
206 case 2: // Offset
207 return ARM::LDRH;
208 case 3: // Pre-indexed
209 return ARM::LDRH_PRE;
210 case 0: // Post-indexed
211 return ARM::LDRH_POST;
212 default:
213 break; // fallthrough
214 }
215 break;
216 case 13:
217 switch (PW) {
218 case 2: // Offset
219 return ARM::LDRSB;
220 case 3: // Pre-indexed
221 return ARM::LDRSB_PRE;
222 case 0: // Post-indexed
223 return ARM::LDRSB_POST;
224 default:
225 break; // fallthrough
226 }
227 break;
228 case 15:
229 switch (PW) {
230 case 2: // Offset
231 return ARM::LDRSH;
232 case 3: // Pre-indexed
233 return ARM::LDRSH_PRE;
234 case 0: // Post-indexed
235 return ARM::LDRSH_POST;
236 default:
237 break; // fallthrough
238 }
239 break;
240 default:
241 break; // fallthrough
242 }
243 }
244
245AutoGenedDecoder:
246 // Calling the auto-generated decoder function.
247 return decodeInstruction(insn);
248}
249
250// Helper function for special case handling of LDR (literal) and friends.
251// See, for example, A6.3.7 Load word: Table A6-18 Load word.
252// See A8.6.57 T3, T4 & A8.6.60 T2 and friends for why we morphed the opcode
253// before returning it.
254static unsigned T2Morph2LoadLiteral(unsigned Opcode) {
255 switch (Opcode) {
256 default:
257 return Opcode; // Return unmorphed opcode.
258
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000259 case ARM::t2LDR_POST: case ARM::t2LDR_PRE:
260 case ARM::t2LDRi12: case ARM::t2LDRi8:
Johnny Chenef37e3a2010-04-20 17:28:50 +0000261 case ARM::t2LDRs: case ARM::t2LDRT:
Owen Anderson971b83b2011-02-08 22:39:40 +0000262 return ARM::t2LDRpci;
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000263
264 case ARM::t2LDRB_POST: case ARM::t2LDRB_PRE:
265 case ARM::t2LDRBi12: case ARM::t2LDRBi8:
Johnny Chenef37e3a2010-04-20 17:28:50 +0000266 case ARM::t2LDRBs: case ARM::t2LDRBT:
Owen Anderson971b83b2011-02-08 22:39:40 +0000267 return ARM::t2LDRBpci;
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000268
269 case ARM::t2LDRH_POST: case ARM::t2LDRH_PRE:
270 case ARM::t2LDRHi12: case ARM::t2LDRHi8:
Johnny Chenef37e3a2010-04-20 17:28:50 +0000271 case ARM::t2LDRHs: case ARM::t2LDRHT:
Owen Anderson971b83b2011-02-08 22:39:40 +0000272 return ARM::t2LDRHpci;
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000273
274 case ARM::t2LDRSB_POST: case ARM::t2LDRSB_PRE:
275 case ARM::t2LDRSBi12: case ARM::t2LDRSBi8:
Johnny Chenef37e3a2010-04-20 17:28:50 +0000276 case ARM::t2LDRSBs: case ARM::t2LDRSBT:
Owen Anderson971b83b2011-02-08 22:39:40 +0000277 return ARM::t2LDRSBpci;
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000278
279 case ARM::t2LDRSH_POST: case ARM::t2LDRSH_PRE:
280 case ARM::t2LDRSHi12: case ARM::t2LDRSHi8:
Johnny Chenef37e3a2010-04-20 17:28:50 +0000281 case ARM::t2LDRSHs: case ARM::t2LDRSHT:
Owen Anderson971b83b2011-02-08 22:39:40 +0000282 return ARM::t2LDRSHpci;
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000283 }
284}
285
286/// decodeThumbSideEffect is a decorator function which can potentially twiddle
287/// the instruction or morph the returned opcode under Thumb2.
288///
289/// First it checks whether the insn is a NEON or VFP instr; if true, bit
290/// twiddling could be performed on insn to turn it into an ARM NEON/VFP
291/// equivalent instruction and decodeInstruction is called with the transformed
292/// insn.
293///
294/// Next, there is special handling for Load byte/halfword/word instruction by
295/// checking whether Rn=0b1111 and call T2Morph2LoadLiteral() on the decoded
296/// Thumb2 instruction. See comments below for further details.
297///
298/// Finally, one last check is made to see whether the insn is a NEON/VFP and
299/// decodeInstruction(insn) is invoked on the original insn.
300///
301/// Otherwise, decodeThumbInstruction is called with the original insn.
NAKAMURA Takumi186acea2010-09-08 04:48:17 +0000302static unsigned decodeThumbSideEffect(bool IsThumb2, unsigned &insn) {
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000303 if (IsThumb2) {
304 uint16_t op1 = slice(insn, 28, 27);
305 uint16_t op2 = slice(insn, 26, 20);
306
307 // A6.3 32-bit Thumb instruction encoding
308 // Table A6-9 32-bit Thumb instruction encoding
309
310 // The coprocessor instructions of interest are transformed to their ARM
311 // equivalents.
312
313 // --------- Transform Begin Marker ---------
314 if ((op1 == 1 || op1 == 3) && slice(op2, 6, 4) == 7) {
315 // A7.4 Advanced SIMD data-processing instructions
316 // U bit of Thumb corresponds to Inst{24} of ARM.
317 uint16_t U = slice(op1, 1, 1);
318
319 // Inst{28-24} of ARM = {1,0,0,1,U};
320 uint16_t bits28_24 = 9 << 1 | U;
321 DEBUG(showBitVector(errs(), insn));
322 setSlice(insn, 28, 24, bits28_24);
323 return decodeInstruction(insn);
324 }
325
326 if (op1 == 3 && slice(op2, 6, 4) == 1 && slice(op2, 0, 0) == 0) {
327 // A7.7 Advanced SIMD element or structure load/store instructions
328 // Inst{27-24} of Thumb = 0b1001
329 // Inst{27-24} of ARM = 0b0100
330 DEBUG(showBitVector(errs(), insn));
331 setSlice(insn, 27, 24, 4);
332 return decodeInstruction(insn);
333 }
334 // --------- Transform End Marker ---------
335
336 // See, for example, A6.3.7 Load word: Table A6-18 Load word.
337 // See A8.6.57 T3, T4 & A8.6.60 T2 and friends for why we morphed the opcode
338 // before returning it to our caller.
339 if (op1 == 3 && slice(op2, 6, 5) == 0 && slice(op2, 0, 0) == 1
340 && slice(insn, 19, 16) == 15)
341 return T2Morph2LoadLiteral(decodeThumbInstruction(insn));
342
343 // One last check for NEON/VFP instructions.
344 if ((op1 == 1 || op1 == 3) && slice(op2, 6, 6) == 1)
345 return decodeInstruction(insn);
346
347 // Fall through.
348 }
349
350 return decodeThumbInstruction(insn);
351}
352
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000353//
354// Public interface for the disassembler
355//
356
357bool ARMDisassembler::getInstruction(MCInst &MI,
358 uint64_t &Size,
359 const MemoryObject &Region,
360 uint64_t Address,
361 raw_ostream &os) const {
362 // The machine instruction.
363 uint32_t insn;
Johnny Chen9d563b62010-04-05 04:46:17 +0000364 uint8_t bytes[4];
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000365
366 // We want to read exactly 4 bytes of data.
Johnny Chen9d563b62010-04-05 04:46:17 +0000367 if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1)
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000368 return false;
369
Johnny Chen9d563b62010-04-05 04:46:17 +0000370 // Encoded as a small-endian 32-bit word in the stream.
371 insn = (bytes[3] << 24) |
372 (bytes[2] << 16) |
373 (bytes[1] << 8) |
374 (bytes[0] << 0);
Johnny Chen7fb053d2010-04-05 04:51:50 +0000375
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000376 unsigned Opcode = decodeARMInstruction(insn);
377 ARMFormat Format = ARMFormats[Opcode];
378 Size = 4;
379
380 DEBUG({
381 errs() << "Opcode=" << Opcode << " Name=" << ARMUtils::OpcodeName(Opcode)
382 << " Format=" << stringForARMFormat(Format) << '(' << (int)Format
383 << ")\n";
384 showBitVector(errs(), insn);
385 });
386
387 ARMBasicMCBuilder *Builder = CreateMCBuilder(Opcode, Format);
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000388 if (!Builder)
389 return false;
390
391 if (!Builder->Build(MI, insn))
392 return false;
393
394 delete Builder;
395
396 return true;
397}
398
399bool ThumbDisassembler::getInstruction(MCInst &MI,
400 uint64_t &Size,
401 const MemoryObject &Region,
402 uint64_t Address,
403 raw_ostream &os) const {
Johnny Chen9d563b62010-04-05 04:46:17 +0000404 // The Thumb instruction stream is a sequence of halhwords.
405
406 // This represents the first halfword as well as the machine instruction
407 // passed to decodeThumbInstruction(). For 16-bit Thumb instruction, the top
408 // halfword of insn is 0x00 0x00; otherwise, the first halfword is moved to
409 // the top half followed by the second halfword.
NAKAMURA Takumi186acea2010-09-08 04:48:17 +0000410 unsigned insn = 0;
Johnny Chen9d563b62010-04-05 04:46:17 +0000411 // Possible second halfword.
412 uint16_t insn1 = 0;
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000413
414 // A6.1 Thumb instruction set encoding
415 //
416 // If bits [15:11] of the halfword being decoded take any of the following
417 // values, the halfword is the first halfword of a 32-bit instruction:
418 // o 0b11101
419 // o 0b11110
420 // o 0b11111.
421 //
422 // Otherwise, the halfword is a 16-bit instruction.
423
424 // Read 2 bytes of data first.
Johnny Chen9d563b62010-04-05 04:46:17 +0000425 uint8_t bytes[2];
426 if (Region.readBytes(Address, 2, (uint8_t*)bytes, NULL) == -1)
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000427 return false;
428
Johnny Chen9d563b62010-04-05 04:46:17 +0000429 // Encoded as a small-endian 16-bit halfword in the stream.
430 insn = (bytes[1] << 8) | bytes[0];
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000431 unsigned bits15_11 = slice(insn, 15, 11);
432 bool IsThumb2 = false;
433
434 // 32-bit instructions if the bits [15:11] of the halfword matches
435 // { 0b11101 /* 0x1D */, 0b11110 /* 0x1E */, ob11111 /* 0x1F */ }.
436 if (bits15_11 == 0x1D || bits15_11 == 0x1E || bits15_11 == 0x1F) {
437 IsThumb2 = true;
Johnny Chen9d563b62010-04-05 04:46:17 +0000438 if (Region.readBytes(Address + 2, 2, (uint8_t*)bytes, NULL) == -1)
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000439 return false;
Johnny Chen9d563b62010-04-05 04:46:17 +0000440 // Encoded as a small-endian 16-bit halfword in the stream.
441 insn1 = (bytes[1] << 8) | bytes[0];
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000442 insn = (insn << 16 | insn1);
443 }
444
445 // The insn could potentially be bit-twiddled in order to be decoded as an ARM
446 // NEON/VFP opcode. In such case, the modified insn is later disassembled as
447 // an ARM NEON/VFP instruction.
448 //
449 // This is a short term solution for lack of encoding bits specified for the
450 // Thumb2 NEON/VFP instructions. The long term solution could be adding some
451 // infrastructure to have each instruction support more than one encodings.
452 // Which encoding is used would be based on which subtarget the compiler/
453 // disassembler is working with at the time. This would allow the sharing of
454 // the NEON patterns between ARM and Thumb2, as well as potential greater
455 // sharing between the regular ARM instructions and the 32-bit wide Thumb2
456 // instructions as well.
457 unsigned Opcode = decodeThumbSideEffect(IsThumb2, insn);
458
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000459 ARMFormat Format = ARMFormats[Opcode];
460 Size = IsThumb2 ? 4 : 2;
461
462 DEBUG({
463 errs() << "Opcode=" << Opcode << " Name=" << ARMUtils::OpcodeName(Opcode)
464 << " Format=" << stringForARMFormat(Format) << '(' << (int)Format
465 << ")\n";
466 showBitVector(errs(), insn);
467 });
468
469 ARMBasicMCBuilder *Builder = CreateMCBuilder(Opcode, Format);
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000470 if (!Builder)
471 return false;
472
Johnny Chenaf5b0e82010-04-16 23:02:25 +0000473 Builder->SetSession(const_cast<Session *>(&SO));
474
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000475 if (!Builder->Build(MI, insn))
476 return false;
477
478 delete Builder;
479
480 return true;
481}
482
483// A8.6.50
Johnny Chend0f3c462010-04-19 23:02:58 +0000484// Valid return values are {1, 2, 3, 4}, with 0 signifying an error condition.
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000485static unsigned short CountITSize(unsigned ITMask) {
486 // First count the trailing zeros of the IT mask.
487 unsigned TZ = CountTrailingZeros_32(ITMask);
Johnny Chend0f3c462010-04-19 23:02:58 +0000488 if (TZ > 3) {
Johnny Chen6bcf52f2010-04-20 00:15:41 +0000489 DEBUG(errs() << "Encoding error: IT Mask '0000'");
Johnny Chend0f3c462010-04-19 23:02:58 +0000490 return 0;
491 }
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000492 return (4 - TZ);
493}
494
Johnny Chend0f3c462010-04-19 23:02:58 +0000495/// Init ITState. Note that at least one bit is always 1 in mask.
496bool Session::InitIT(unsigned short bits7_0) {
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000497 ITCounter = CountITSize(slice(bits7_0, 3, 0));
Johnny Chen6bcf52f2010-04-20 00:15:41 +0000498 if (ITCounter == 0)
499 return false;
500
501 // A8.6.50 IT
502 unsigned short FirstCond = slice(bits7_0, 7, 4);
503 if (FirstCond == 0xF) {
504 DEBUG(errs() << "Encoding error: IT FirstCond '1111'");
505 return false;
506 }
507 if (FirstCond == 0xE && ITCounter != 1) {
508 DEBUG(errs() << "Encoding error: IT FirstCond '1110' && Mask != '1000'");
509 return false;
510 }
511
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000512 ITState = bits7_0;
Johnny Chen6bcf52f2010-04-20 00:15:41 +0000513
514 return true;
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000515}
516
517/// Update ITState if necessary.
518void Session::UpdateIT() {
519 assert(ITCounter);
520 --ITCounter;
521 if (ITCounter == 0)
522 ITState = 0;
523 else {
524 unsigned short NewITState4_0 = slice(ITState, 4, 0) << 1;
525 setSlice(ITState, 4, 0, NewITState4_0);
526 }
527}
528
529static MCDisassembler *createARMDisassembler(const Target &T) {
530 return new ARMDisassembler;
531}
532
533static MCDisassembler *createThumbDisassembler(const Target &T) {
534 return new ThumbDisassembler;
535}
536
Owen Anderson971b83b2011-02-08 22:39:40 +0000537extern "C" void LLVMInitializeARMDisassembler() {
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000538 // Register the disassembler.
Owen Anderson971b83b2011-02-08 22:39:40 +0000539 TargetRegistry::RegisterMCDisassembler(TheARMTarget,
Johnny Chenb68a3ee2010-04-02 22:27:38 +0000540 createARMDisassembler);
541 TargetRegistry::RegisterMCDisassembler(TheThumbTarget,
542 createThumbDisassembler);
543}
544
Sean Callanan9899f702010-04-13 21:21:57 +0000545EDInstInfo *ARMDisassembler::getEDInfo() const {
546 return instInfoARM;
547}
548
549EDInstInfo *ThumbDisassembler::getEDInfo() const {
550 return instInfoARM;
551}