189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee/*
289efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * Copyright (C) 2009 The Android Open Source Project
389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee *
489efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * Licensed under the Apache License, Version 2.0 (the "License");
589efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * you may not use this file except in compliance with the License.
689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * You may obtain a copy of the License at
789efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee *
889efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee *      http://www.apache.org/licenses/LICENSE-2.0
989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee *
1089efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * Unless required by applicable law or agreed to in writing, software
1189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * distributed under the License is distributed on an "AS IS" BASIS,
1289efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * See the License for the specific language governing permissions and
1489efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * limitations under the License.
1589efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee */
1689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
1789efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#include "Dalvik.h"
1889efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#include "compiler/CompilerInternals.h"
1989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
2089efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#ifndef _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMLIR_H
2189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#define _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMLIR_H
2289efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
2389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee/*
249bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r0, r1, r2, r3 are always scratch
259bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r4 (rPC) is scratch for Jit, but most be restored when resuming interp
269bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r5 (rFP) is reserved [holds Dalvik frame pointer]
279bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r6 (rGLUE) is reserved [holds current &interpState]
289bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r7 (rINST) is scratch for Jit
299bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r8 (rIBASE) is scratch for Jit, but must be restored when resuming interp
30270c1d64a192341be842f46734054c692bac061eBill Buzbee * r9 is reserved
319bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r10 is always scratch
329bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r11 (fp) used by gcc unless -fomit-frame-pointer set [available for jit?]
339bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r12 is always scratch
349bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r13 (sp) is reserved
359bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r14 (lr) is scratch for Jit
369bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * r15 (pc) is reserved
379bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee *
38270c1d64a192341be842f46734054c692bac061eBill Buzbee * Preserved across C calls: r4, r5, r6, r7, r8, r10, r11
39270c1d64a192341be842f46734054c692bac061eBill Buzbee * Trashed across C calls: r0, r1, r2, r3, r12, r14
40270c1d64a192341be842f46734054c692bac061eBill Buzbee *
41270c1d64a192341be842f46734054c692bac061eBill Buzbee * Floating pointer registers
42270c1d64a192341be842f46734054c692bac061eBill Buzbee * s0-s31
43270c1d64a192341be842f46734054c692bac061eBill Buzbee * d0-d15, where d0={s0,s1}, d1={s2,s3}, ... , d15={s30,s31}
44270c1d64a192341be842f46734054c692bac061eBill Buzbee *
45270c1d64a192341be842f46734054c692bac061eBill Buzbee * s16-s31 (d8-d15) preserved across C calls
46270c1d64a192341be842f46734054c692bac061eBill Buzbee * s0-s15 (d0-d7) trashed across C calls
47270c1d64a192341be842f46734054c692bac061eBill Buzbee *
489bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * For Thumb code use:
49270c1d64a192341be842f46734054c692bac061eBill Buzbee *       r0, r1, r2, r3 to hold operands/results
509bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee *       r4, r7 for temps
519bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee *
529bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * For Thumb2 code use:
53270c1d64a192341be842f46734054c692bac061eBill Buzbee *       r0, r1, r2, r3, r8, r9, r10, r11, r12, r14 for operands/results
54270c1d64a192341be842f46734054c692bac061eBill Buzbee *       r4, r7 for temps
55270c1d64a192341be842f46734054c692bac061eBill Buzbee *       s16-s31/d8-d15 for operands/results
56270c1d64a192341be842f46734054c692bac061eBill Buzbee *       s0-s15/d0-d7 for temps
579bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee *
589bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee * When transitioning from code cache to interp:
599bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee *       restore rIBASE
609bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee *       restore rPC
61270c1d64a192341be842f46734054c692bac061eBill Buzbee *       restore r11?
6289efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee */
639bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee
649bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee/* Offset to distingish FP regs */
659bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee#define FP_REG_OFFSET 32
667ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee/* Offset to distinguish DP FP regs */
677ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee#define FP_DOUBLE 64
687ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee/* Reg types */
69d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REGTYPE(x) (x & (FP_REG_OFFSET | FP_DOUBLE))
707ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee#define FPREG(x) ((x & FP_REG_OFFSET) == FP_REG_OFFSET)
717ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee#define LOWREG(x) ((x & 0x7) == x)
727ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee#define DOUBLEREG(x) ((x & FP_DOUBLE) == FP_DOUBLE)
737ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee#define SINGLEREG(x) (FPREG(x) && !DOUBLEREG(x))
741465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee/*
751465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee * Note: the low register of a floating point pair is sufficient to
761465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee * create the name of a double, but require both names to be passed to
771465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee * allow for asserts to verify that the pair is consecutive if significant
781465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee * rework is done in this area.  Also, it is a good reminder in the calling
791465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee * code that reg locations always describe doubles as a pair of singles.
801465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee */
811465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee#define S2D(x,y) ((x) | FP_DOUBLE)
829bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee/* Mask to strip off fp flags */
839bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee#define FP_REG_MASK (FP_REG_OFFSET-1)
84270c1d64a192341be842f46734054c692bac061eBill Buzbee/* non-existent Dalvik register */
85270c1d64a192341be842f46734054c692bac061eBill Buzbee#define vNone   (-1)
86270c1d64a192341be842f46734054c692bac061eBill Buzbee/* non-existant physical register */
87270c1d64a192341be842f46734054c692bac061eBill Buzbee#define rNone   (-1)
889bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee
891465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee/* RegisterLocation templates return values (r0, or r0/r1) */
901465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee#define LOC_C_RETURN {kLocPhysReg, 0, 0, r0, 0, -1}
911465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee#define LOC_C_RETURN_WIDE {kLocPhysReg, 1, 0, r0, r1, -1}
921465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee/* RegisterLocation templates for interpState->retVal; */
931465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee#define LOC_DALVIK_RETURN_VAL {kLocRetval, 0, 0, 0, 0, -1}
941465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee#define LOC_DALVIK_RETURN_VAL_WIDE {kLocRetval, 1, 0, 0, 0, -1}
951465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee
961465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee /*
971465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee * Data structure tracking the mapping between a Dalvik register (pair) and a
981465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee * native register (pair). The idea is to reuse the previously loaded value
991465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee * if possible, otherwise to keep the value in a native register as long as
1001465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee * possible.
1011465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee */
1021465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbeetypedef struct RegisterInfo {
1031465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    int reg;                    // Reg number
1041465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    bool inUse;                 // Has it been allocated?
1051465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    bool pair;                  // Part of a register pair?
1061465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    int partner;                // If pair, other reg of pair
1071465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    bool live;                  // Is there an associated SSA name?
1081465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    bool dirty;                 // If live, is it dirty?
1091465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    int sReg;                   // Name of live value
1101465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    struct LIR *defStart;       // Starting inst in last def sequence
1111465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    struct LIR *defEnd;         // Ending inst in last def sequence
1121465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee} RegisterInfo;
1131465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee
1141465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbeetypedef struct RegisterPool {
1151465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    BitVector *nullCheckedRegs; // Track which registers have been null-checked
1161465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    int numCoreTemps;
1171465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    RegisterInfo *coreTemps;
1181f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    int nextCoreTemp;
1191465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    int numFPTemps;
1201465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    RegisterInfo *FPTemps;
1211f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    int nextFPTemp;
1221465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    int numCoreRegs;
1231465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    RegisterInfo *coreRegs;
1241465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    int numFPRegs;
1251465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    RegisterInfo *FPRegs;
1261465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee} RegisterPool;
1271465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee
128dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Chengtypedef enum ResourceEncodingPos {
129dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kGPReg0     = 0,
130dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegSP      = 13,
131dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegLR      = 14,
132dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegPC      = 15,
133dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kFPReg0     = 16,
134d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng    kRegEnd     = 48,
135d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng    kCCode      = kRegEnd,
136d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng    kFPStatus,
137d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng    kDalvikReg,
1381f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    kLiteral,
1391f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    kFrameRef,
1401f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    kHeapRef,
1411f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    kLitPoolRef
142dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng} ResourceEncodingPos;
143dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng
144dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define ENCODE_REG_LIST(N)      ((u8) N)
145dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define ENCODE_REG_SP           (1ULL << kRegSP)
146dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define ENCODE_REG_LR           (1ULL << kRegLR)
147dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define ENCODE_REG_PC           (1ULL << kRegPC)
148dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define ENCODE_CCODE            (1ULL << kCCode)
149dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define ENCODE_FP_STATUS        (1ULL << kFPStatus)
1501f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee
1511f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    /* Must alias */
152d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define ENCODE_DALVIK_REG       (1ULL << kDalvikReg)
1531f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee#define ENCODE_LITERAL          (1ULL << kLiteral)
1541f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee
1551f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    /* May alias */
1561f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee#define ENCODE_FRAME_REF        (1ULL << kFrameRef)
1571f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee#define ENCODE_HEAP_REF         (1ULL << kHeapRef)
1581f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee#define ENCODE_LITPOOL_REF      (1ULL << kLitPoolRef)
1591f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee
160d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define ENCODE_ALL              (~0ULL)
1611f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee#define ENCODE_MEM_DEF          (ENCODE_FRAME_REF | ENCODE_HEAP_REF)
1621f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee#define ENCODE_MEM_USE          (ENCODE_FRAME_REF | ENCODE_HEAP_REF \
1631f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee                                 | ENCODE_LITPOOL_REF)
164d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng
165d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define DECODE_ALIAS_INFO_REG(X)        (X & 0xffff)
166d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define DECODE_ALIAS_INFO_WIDE(X)       ((X & 0x80000000) ? 1 : 0)
167dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng
168270c1d64a192341be842f46734054c692bac061eBill Buzbeetypedef enum OpSize {
1691465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kWord,
1701465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kLong,
1711465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kSingle,
1721465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kDouble,
1731465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kUnsignedHalf,
1741465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kSignedHalf,
1751465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kUnsignedByte,
1761465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kSignedByte,
177270c1d64a192341be842f46734054c692bac061eBill Buzbee} OpSize;
178270c1d64a192341be842f46734054c692bac061eBill Buzbee
179270c1d64a192341be842f46734054c692bac061eBill Buzbeetypedef enum OpKind {
1801465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpMov,
1811465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpMvn,
1821465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpCmp,
1831465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpLsl,
1841465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpLsr,
1851465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpAsr,
1861465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpRor,
1871465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpNot,
1881465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpAnd,
1891465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpOr,
1901465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpXor,
1911465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpNeg,
1921465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpAdd,
1931465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpAdc,
1941465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpSub,
1951465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpSbc,
1961465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpRsub,
1971465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpMul,
1981465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpDiv,
1991465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpRem,
2001465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpBic,
2011465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpCmn,
2021465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpTst,
2031465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpBkpt,
2041465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpBlx,
2051465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpPush,
2061465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpPop,
2071465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOp2Char,
2081465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOp2Short,
2091465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOp2Byte,
2101465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpCondBr,
2111465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kOpUncondBr,
212270c1d64a192341be842f46734054c692bac061eBill Buzbee} OpKind;
2137ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee
21489efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbeetypedef enum NativeRegisterPool {
21589efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r0 = 0,
21689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r1 = 1,
21789efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r2 = 2,
21889efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r3 = 3,
21989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r4PC = 4,
22089efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    rFP = 5,
22189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    rGLUE = 6,
22289efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r7 = 7,
22389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r8 = 8,
22489efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r9 = 9,
22589efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r10 = 10,
22689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r11 = 11,
22789efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r12 = 12,
22889efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    r13 = 13,
22989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    rlr = 14,
2309bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    rpc = 15,
2319bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr0  =  0 + FP_REG_OFFSET,
2329bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr1  =  1 + FP_REG_OFFSET,
2339bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr2  =  2 + FP_REG_OFFSET,
2349bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr3  =  3 + FP_REG_OFFSET,
2359bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr4  =  4 + FP_REG_OFFSET,
2369bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr5  =  5 + FP_REG_OFFSET,
2379bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr6  =  6 + FP_REG_OFFSET,
2389bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr7  =  7 + FP_REG_OFFSET,
2399bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr8  =  8 + FP_REG_OFFSET,
2409bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr9  =  9 + FP_REG_OFFSET,
2419bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr10 = 10 + FP_REG_OFFSET,
2429bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr11 = 11 + FP_REG_OFFSET,
2439bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr12 = 12 + FP_REG_OFFSET,
2449bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr13 = 13 + FP_REG_OFFSET,
2459bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr14 = 14 + FP_REG_OFFSET,
2469bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr15 = 15 + FP_REG_OFFSET,
2479bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr16 = 16 + FP_REG_OFFSET,
2489bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr17 = 17 + FP_REG_OFFSET,
2499bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr18 = 18 + FP_REG_OFFSET,
2509bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr19 = 19 + FP_REG_OFFSET,
2519bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr20 = 20 + FP_REG_OFFSET,
2529bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr21 = 21 + FP_REG_OFFSET,
2539bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr22 = 22 + FP_REG_OFFSET,
2549bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr23 = 23 + FP_REG_OFFSET,
2559bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr24 = 24 + FP_REG_OFFSET,
2569bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr25 = 25 + FP_REG_OFFSET,
2579bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr26 = 26 + FP_REG_OFFSET,
2589bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr27 = 27 + FP_REG_OFFSET,
2599bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr28 = 28 + FP_REG_OFFSET,
2609bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr29 = 29 + FP_REG_OFFSET,
2619bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr30 = 30 + FP_REG_OFFSET,
2629bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    fr31 = 31 + FP_REG_OFFSET,
2637ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr0 = fr0 + FP_DOUBLE,
2647ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr1 = fr2 + FP_DOUBLE,
2657ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr2 = fr4 + FP_DOUBLE,
2667ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr3 = fr6 + FP_DOUBLE,
2677ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr4 = fr8 + FP_DOUBLE,
2687ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr5 = fr10 + FP_DOUBLE,
2697ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr6 = fr12 + FP_DOUBLE,
2707ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr7 = fr14 + FP_DOUBLE,
2717ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr8 = fr16 + FP_DOUBLE,
2727ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr9 = fr18 + FP_DOUBLE,
2737ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr10 = fr20 + FP_DOUBLE,
2747ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr11 = fr22 + FP_DOUBLE,
2757ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr12 = fr24 + FP_DOUBLE,
2767ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr13 = fr26 + FP_DOUBLE,
2777ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr14 = fr28 + FP_DOUBLE,
2787ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee    dr15 = fr30 + FP_DOUBLE,
27989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee} NativeRegisterPool;
28089efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
2811465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee/* Shift encodings */
2821465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbeetypedef enum ArmShiftEncodings {
2831465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmLsl = 0x0,
2841465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmLsr = 0x1,
2851465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmAsr = 0x2,
2861465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmRor = 0x3
2871465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee} ArmShiftEncodings;
2881465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee
28989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee/* Thumb condition encodings */
29089efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbeetypedef enum ArmConditionCode {
2911465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondEq = 0x0,    /* 0000 */
2921465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondNe = 0x1,    /* 0001 */
2931465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondCs = 0x2,    /* 0010 */
2941465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondCc = 0x3,    /* 0011 */
2951465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondMi = 0x4,    /* 0100 */
2961465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondPl = 0x5,    /* 0101 */
2971465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondVs = 0x6,    /* 0110 */
2981465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondVc = 0x7,    /* 0111 */
2991465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondHi = 0x8,    /* 1000 */
3001465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondLs = 0x9,    /* 1001 */
3011465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondGe = 0xa,    /* 1010 */
3021465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondLt = 0xb,    /* 1011 */
3031465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondGt = 0xc,    /* 1100 */
3041465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondLe = 0xd,    /* 1101 */
3051465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondAl = 0xe,    /* 1110 */
3061465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmCondNv = 0xf,    /* 1111 */
30789efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee} ArmConditionCode;
30889efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
30989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#define isPseudoOpCode(opCode) ((int)(opCode) < 0)
31089efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
31189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee/*
31289efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * The following enum defines the list of supported Thumb instructions by the
31389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * assembler. Their corresponding snippet positions will be defined in
31489efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * Assemble.c.
31589efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee */
31689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbeetypedef enum ArmOpCode {
317cec26f6ae3347d5ab3d60de02caca2e47151c6b2Ben Cheng    kArmChainingCellBottom = -18,
3181465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmPseudoBarrier = -17,
3191465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmPseudoExtended = -16,
3201465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmPseudoSSARep = -15,
321a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoEntryBlock = -14,
322a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoExitBlock = -13,
3231465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmPseudoTargetLabel = -12,
324a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoChainingCellBackwardBranch = -11,
325a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoChainingCellHot = -10,
326a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoChainingCellInvokePredicted = -9,
327a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoChainingCellInvokeSingleton = -8,
328a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoChainingCellNormal = -7,
329a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoDalvikByteCodeBoundary = -6,
3301465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmPseudoPseudoAlign4 = -5,
331a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoPCReconstructionCell = -4,
332a497359afa1abe4c5780c8799c6fe0edab551c2dBen Cheng    kArmPseudoPCReconstructionBlockLabel = -3,
3331465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmPseudoEHBlockLabel = -2,
3341465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmPseudoNormalBlockLabel = -1,
33589efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    /************************************************************************/
3361465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArm16BitData,       /* DATA   [0] rd[15..0] */
3371465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAdcRR,         /* adc     [0100000101] rm[5..3] rd[2..0] */
3381465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAddRRI3,       /* add(1)  [0001110] imm_3[8..6] rn[5..3] rd[2..0]*/
3391465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAddRI8,        /* add(2)  [00110] rd[10..8] imm_8[7..0] */
3401465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAddRRR,        /* add(3)  [0001100] rm[8..6] rn[5..3] rd[2..0] */
3411465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAddRRLH,       /* add(4)  [01000100] H12[01] rm[5..3] rd[2..0] */
3421465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAddRRHL,       /* add(4)  [01001000] H12[10] rm[5..3] rd[2..0] */
3431465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAddRRHH,       /* add(4)  [01001100] H12[11] rm[5..3] rd[2..0] */
3441465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAddPcRel,      /* add(5)  [10100] rd[10..8] imm_8[7..0] */
3451465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAddSpRel,      /* add(6)  [10101] rd[10..8] imm_8[7..0] */
3461465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAddSpI7,       /* add(7)  [101100000] imm_7[6..0] */
3471465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAndRR,         /* and     [0100000000] rm[5..3] rd[2..0] */
3481465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAsrRRI5,       /* asr(1)  [00010] imm_5[10..6] rm[5..3] rd[2..0] */
3491465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbAsrRR,         /* asr(2)  [0100000100] rs[5..3] rd[2..0] */
3501465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBCond,         /* b(1)    [1101] cond[11..8] offset_8[7..0] */
3511465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBUncond,       /* b(2)    [11100] offset_11[10..0] */
3521465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBicRR,         /* bic     [0100001110] rm[5..3] rd[2..0] */
3531465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBkpt,          /* bkpt    [10111110] imm_8[7..0] */
3541465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBlx1,          /* blx(1)  [111] H[10] offset_11[10..0] */
3551465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBlx2,          /* blx(1)  [111] H[01] offset_11[10..0] */
3561465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBl1,           /* blx(1)  [111] H[10] offset_11[10..0] */
3571465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBl2,           /* blx(1)  [111] H[11] offset_11[10..0] */
3581465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBlxR,          /* blx(2)  [010001111] rm[6..3] [000] */
3591465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbBx,            /* bx      [010001110] H2[6..6] rm[5..3] SBZ[000] */
3601465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbCmnRR,         /* cmn     [0100001011] rm[5..3] rd[2..0] */
3611465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbCmpRI8,        /* cmp(1)  [00101] rn[10..8] imm_8[7..0] */
3621465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbCmpRR,         /* cmp(2)  [0100001010] rm[5..3] rd[2..0] */
3631465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbCmpLH,         /* cmp(3)  [01000101] H12[01] rm[5..3] rd[2..0] */
3641465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbCmpHL,         /* cmp(3)  [01000110] H12[10] rm[5..3] rd[2..0] */
3651465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbCmpHH,         /* cmp(3)  [01000111] H12[11] rm[5..3] rd[2..0] */
3661465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbEorRR,         /* eor     [0100000001] rm[5..3] rd[2..0] */
3671465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdmia,         /* ldmia   [11001] rn[10..8] reglist [7..0] */
3681465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrRRI5,       /* ldr(1)  [01101] imm_5[10..6] rn[5..3] rd[2..0] */
3691465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrRRR,        /* ldr(2)  [0101100] rm[8..6] rn[5..3] rd[2..0] */
3701465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrPcRel,      /* ldr(3)  [01001] rd[10..8] imm_8[7..0] */
3711465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrSpRel,      /* ldr(4)  [10011] rd[10..8] imm_8[7..0] */
3721465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrbRRI5,      /* ldrb(1) [01111] imm_5[10..6] rn[5..3] rd[2..0] */
3731465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrbRRR,       /* ldrb(2) [0101110] rm[8..6] rn[5..3] rd[2..0] */
3741465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrhRRI5,      /* ldrh(1) [10001] imm_5[10..6] rn[5..3] rd[2..0] */
3751465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrhRRR,       /* ldrh(2) [0101101] rm[8..6] rn[5..3] rd[2..0] */
3761465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrsbRRR,      /* ldrsb   [0101011] rm[8..6] rn[5..3] rd[2..0] */
3771465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLdrshRRR,      /* ldrsh   [0101111] rm[8..6] rn[5..3] rd[2..0] */
3781465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLslRRI5,       /* lsl(1)  [00000] imm_5[10..6] rm[5..3] rd[2..0] */
3791465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLslRR,         /* lsl(2)  [0100000010] rs[5..3] rd[2..0] */
3801465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLsrRRI5,       /* lsr(1)  [00001] imm_5[10..6] rm[5..3] rd[2..0] */
3811465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbLsrRR,         /* lsr(2)  [0100000011] rs[5..3] rd[2..0] */
3821465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbMovImm,        /* mov(1)  [00100] rd[10..8] imm_8[7..0] */
3831465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbMovRR,         /* mov(2)  [0001110000] rn[5..3] rd[2..0] */
3841465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbMovRR_H2H,     /* mov(3)  [01000111] H12[11] rm[5..3] rd[2..0] */
3851465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbMovRR_H2L,     /* mov(3)  [01000110] H12[01] rm[5..3] rd[2..0] */
3861465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbMovRR_L2H,     /* mov(3)  [01000101] H12[10] rm[5..3] rd[2..0] */
3871465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbMul,           /* mul     [0100001101] rm[5..3] rd[2..0] */
3881465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbMvn,           /* mvn     [0100001111] rm[5..3] rd[2..0] */
3891465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbNeg,           /* neg     [0100001001] rm[5..3] rd[2..0] */
3901465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbOrr,           /* orr     [0100001100] rm[5..3] rd[2..0] */
3911465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbPop,           /* pop     [1011110] r[8..8] rl[7..0] */
3921465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbPush,          /* push    [1011010] r[8..8] rl[7..0] */
393799cdf9ef24b49a0cac0d22e1f731da01d838b4eBill Buzbee    kThumbRorRR,         /* ror     [0100000111] rs[5..3] rd[2..0] */
3941465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbSbc,           /* sbc     [0100000110] rm[5..3] rd[2..0] */
3951465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbStmia,         /* stmia   [11000] rn[10..8] reglist [7.. 0] */
3961465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbStrRRI5,       /* str(1)  [01100] imm_5[10..6] rn[5..3] rd[2..0] */
3971465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbStrRRR,        /* str(2)  [0101000] rm[8..6] rn[5..3] rd[2..0] */
3981465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbStrSpRel,      /* str(3)  [10010] rd[10..8] imm_8[7..0] */
3991465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbStrbRRI5,      /* strb(1) [01110] imm_5[10..6] rn[5..3] rd[2..0] */
4001465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbStrbRRR,       /* strb(2) [0101010] rm[8..6] rn[5..3] rd[2..0] */
4011465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbStrhRRI5,      /* strh(1) [10000] imm_5[10..6] rn[5..3] rd[2..0] */
4021465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbStrhRRR,       /* strh(2) [0101001] rm[8..6] rn[5..3] rd[2..0] */
4031465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbSubRRI3,       /* sub(1)  [0001111] imm_3[8..6] rn[5..3] rd[2..0]*/
4041465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbSubRI8,        /* sub(2)  [00111] rd[10..8] imm_8[7..0] */
4051465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbSubRRR,        /* sub(3)  [0001101] rm[8..6] rn[5..3] rd[2..0] */
4061465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbSubSpI7,       /* sub(4)  [101100001] imm_7[6..0] */
4071465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbSwi,           /* swi     [11011111] imm_8[7..0] */
4081465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumbTst,           /* tst     [0100001000] rm[5..3] rn[2..0] */
4091465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vldrs,        /* vldr low  sx [111011011001] rn[19..16] rd[15-12]
4101465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    [1010] imm_8[7..0] */
4111465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vldrd,        /* vldr low  dx [111011011001] rn[19..16] rd[15-12]
4121465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    [1011] imm_8[7..0] */
4131465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vmuls,        /* vmul vd, vn, vm [111011100010] rn[19..16]
4141465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    rd[15-12] [10100000] rm[3..0] */
4151465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vmuld,        /* vmul vd, vn, vm [111011100010] rn[19..16]
4161465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    rd[15-12] [10110000] rm[3..0] */
4171465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vstrs,        /* vstr low  sx [111011011000] rn[19..16] rd[15-12]
4181465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    [1010] imm_8[7..0] */
4191465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vstrd,        /* vstr low  dx [111011011000] rn[19..16] rd[15-12]
4201465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    [1011] imm_8[7..0] */
4211465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vsubs,        /* vsub vd, vn, vm [111011100011] rn[19..16]
4221465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    rd[15-12] [10100040] rm[3..0] */
4231465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vsubd,        /* vsub vd, vn, vm [111011100011] rn[19..16]
4241465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    rd[15-12] [10110040] rm[3..0] */
4251465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vadds,        /* vadd vd, vn, vm [111011100011] rn[19..16]
4261465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    rd[15-12] [10100000] rm[3..0] */
4271465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vaddd,        /* vadd vd, vn, vm [111011100011] rn[19..16]
4281465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    rd[15-12] [10110000] rm[3..0] */
4291465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vdivs,        /* vdiv vd, vn, vm [111011101000] rn[19..16]
4301465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    rd[15-12] [10100000] rm[3..0] */
4311465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vdivd,        /* vdiv vd, vn, vm [111011101000] rn[19..16]
4321465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    rd[15-12] [10110000] rm[3..0] */
4331465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2VcvtIF,       /* vcvt.F32 vd, vm [1110111010111000] vd[15..12]
4341465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                    [10101100] vm[3..0] */
4351465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2VcvtID,       /* vcvt.F64 vd, vm [1110111010111000] vd[15..12]
4369bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee                                       [10111100] vm[3..0] */
4371465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2VcvtFI,       /* vcvt.S32.F32 vd, vm [1110111010111101] vd[15..12]
4389bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee                                       [10101100] vm[3..0] */
4391465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2VcvtDI,       /* vcvt.S32.F32 vd, vm [1110111010111101] vd[15..12]
4409bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee                                       [10111100] vm[3..0] */
4411465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2VcvtFd,       /* vcvt.F64.F32 vd, vm [1110111010110111] vd[15..12]
4429bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee                                       [10101100] vm[3..0] */
4431465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2VcvtDF,       /* vcvt.F32.F64 vd, vm [1110111010110111] vd[15..12]
4449bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee                                       [10111100] vm[3..0] */
4451465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vsqrts,       /* vsqrt.f32 vd, vm [1110111010110001] vd[15..12]
4469727c3de12ab9daed0d92f6da2f5c0b0169e698dBill Buzbee                                       [10101100] vm[3..0] */
4471465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vsqrtd,       /* vsqrt.f64 vd, vm [1110111010110001] vd[15..12]
4489727c3de12ab9daed0d92f6da2f5c0b0169e698dBill Buzbee                                       [10111100] vm[3..0] */
4491465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2MovImmShift,  /* mov(T2) rd, #<const> [11110] i [00001001111]
4507ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       imm3 rd[11..8] imm8 */
4511465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2MovImm16,     /* mov(T3) rd, #<const> [11110] i [0010100] imm4 [0]
4527ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       imm3 rd[11..8] imm8 */
4531465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2StrRRI12,     /* str(Imm,T3) rd,[rn,#imm12] [111110001100]
4547ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       rn[19..16] rt[15..12] imm12[11..0] */
4551465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrRRI12,     /* str(Imm,T3) rd,[rn,#imm12] [111110001100]
4567ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       rn[19..16] rt[15..12] imm12[11..0] */
4571465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2StrRRI8Predec, /* str(Imm,T4) rd,[rn,#-imm8] [111110000100]
4587ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       rn[19..16] rt[15..12] [1100] imm[7..0]*/
4591465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrRRI8Predec, /* ldr(Imm,T4) rd,[rn,#-imm8] [111110000101]
4607ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       rn[19..16] rt[15..12] [1100] imm[7..0]*/
4611465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Cbnz,         /* cbnz rd,<label> [101110] i [1] imm5[7..3]
4627ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       rn[2..0] */
4631465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Cbz,          /* cbn rd,<label> [101100] i [1] imm5[7..3]
4647ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       rn[2..0] */
4651465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2AddRRI12,     /* add rd, rn, #imm12 [11110] i [100000] rn[19..16]
4667ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       [0] imm3[14..12] rd[11..8] imm8[7..0] */
4671465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2MovRR,        /* mov rd, rm [11101010010011110000] rd[11..8]
4687ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       [0000] rm[3..0] */
4691465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vmovs,        /* vmov.f32 vd, vm [111011101] D [110000]
4707ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       vd[15..12] 101001] M [0] vm[3..0] */
4711465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vmovd,        /* vmov.f64 vd, vm [111011101] D [110000]
4727ea0f64d067cd8a2213c2c04a3291335c34d9602Bill Buzbee                                       vd[15..12] 101101] M [0] vm[3..0] */
4731465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Ldmia,        /* ldmia  [111010001001[ rn[19..16] mask[15..0] */
4741465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Stmia,        /* stmia  [111010001000[ rn[19..16] mask[15..0] */
4751465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2AddRRR,       /* add [111010110000] rn[19..16] [0000] rd[11..8]
476270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
4771465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2SubRRR,       /* sub [111010111010] rn[19..16] [0000] rd[11..8]
478270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
4791465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2SbcRRR,       /* sbc [111010110110] rn[19..16] [0000] rd[11..8]
480270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
4811465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2CmpRR,        /* cmp [111010111011] rn[19..16] [0000] [1111]
482270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
4831465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2SubRRI12,     /* sub rd, rn, #imm12 [11110] i [01010] rn[19..16]
484270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       [0] imm3[14..12] rd[11..8] imm8[7..0] */
4851465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2MvnImmShift,  /* mov(T2) rd, #<const> [11110] i [00011011110]
486270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       imm3 rd[11..8] imm8 */
4871465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Sel,          /* sel rd, rn, rm [111110101010] rn[19-16] rd[11-8]
488270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rm[3-0] */
4891465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Ubfx,         /* ubfx rd,rn,#lsb,#width [111100111100] rn[19..16]
490270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       [0] imm3[14-12] rd[11-8] w[4-0] */
4911465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Sbfx,         /* ubfx rd,rn,#lsb,#width [111100110100] rn[19..16]
492270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       [0] imm3[14-12] rd[11-8] w[4-0] */
4931465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrRRR,       /* ldr rt,[rn,rm,LSL #imm] [111110000101] rn[19-16]
494270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15-12] [000000] imm[5-4] rm[3-0] */
4951465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrhRRR,      /* ldrh rt,[rn,rm,LSL #imm] [111110000101] rn[19-16]
496270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15-12] [000000] imm[5-4] rm[3-0] */
4971465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrshRRR,     /* ldrsh rt,[rn,rm,LSL #imm] [111110000101] rn[19-16]
498270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15-12] [000000] imm[5-4] rm[3-0] */
4991465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrbRRR,      /* ldrb rt,[rn,rm,LSL #imm] [111110000101] rn[19-16]
500270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15-12] [000000] imm[5-4] rm[3-0] */
5011465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrsbRRR,     /* ldrsb rt,[rn,rm,LSL #imm] [111110000101] rn[19-16]
502270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15-12] [000000] imm[5-4] rm[3-0] */
5031465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2StrRRR,       /* str rt,[rn,rm,LSL #imm] [111110000100] rn[19-16]
504270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15-12] [000000] imm[5-4] rm[3-0] */
5051465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2StrhRRR,      /* str rt,[rn,rm,LSL #imm] [111110000010] rn[19-16]
506270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15-12] [000000] imm[5-4] rm[3-0] */
5071465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2StrbRRR,      /* str rt,[rn,rm,LSL #imm] [111110000000] rn[19-16]
508270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15-12] [000000] imm[5-4] rm[3-0] */
5091465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrhRRI12,    /* ldrh rt,[rn,#imm12] [111110001011]
510270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15..12] rn[19..16] imm12[11..0] */
5111465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrshRRI12,   /* ldrsh rt,[rn,#imm12] [111110011011]
512270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15..12] rn[19..16] imm12[11..0] */
5131465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrbRRI12,    /* ldrb rt,[rn,#imm12] [111110001001]
514270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15..12] rn[19..16] imm12[11..0] */
5151465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrsbRRI12,   /* ldrsb rt,[rn,#imm12] [111110011001]
516270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15..12] rn[19..16] imm12[11..0] */
5171465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2StrhRRI12,    /* strh rt,[rn,#imm12] [111110001010]
518270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15..12] rn[19..16] imm12[11..0] */
5191465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2StrbRRI12,    /* strb rt,[rn,#imm12] [111110001000]
520270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       rt[15..12] rn[19..16] imm12[11..0] */
5211465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Pop,          /* pop     [1110100010111101] list[15-0]*/
5221465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Push,         /* push    [1110100010101101] list[15-0]*/
5231465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2CmpRI8,       /* cmp rn, #<const> [11110] i [011011] rn[19-16] [0]
524270c1d64a192341be842f46734054c692bac061eBill Buzbee                                       imm3 [1111] imm8[7..0] */
5251465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2AdcRRR,       /* adc [111010110101] rn[19..16] [0000] rd[11..8]
526270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5271465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2AndRRR,       /* and [111010100000] rn[19..16] [0000] rd[11..8]
528270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5291465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2BicRRR,       /* bic [111010100010] rn[19..16] [0000] rd[11..8]
530270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5311465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2CmnRR,        /* cmn [111010110001] rn[19..16] [0000] [1111]
532270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5331465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2EorRRR,       /* eor [111010101000] rn[19..16] [0000] rd[11..8]
534270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5351465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2MulRRR,       /* mul [111110110000] rn[19..16] [1111] rd[11..8]
536270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5371465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2MnvRR,        /* mvn [11101010011011110] rd[11-8] [0000]
538270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   rm[3..0] */
5391465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2RsubRRI8,     /* rsub [111100011100] rn[19..16] [0000] rd[11..8]
540270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   imm8[7..0] */
5411465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2NegRR,        /* actually rsub rd, rn, #0 */
5421465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2OrrRRR,       /* orr [111010100100] rn[19..16] [0000] rd[11..8]
543270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5441465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2TstRR,        /* tst [111010100001] rn[19..16] [0000] [1111]
545270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5461465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LslRRR,       /* lsl [111110100000] rn[19..16] [1111] rd[11..8]
547270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5481465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LsrRRR,       /* lsr [111110100010] rn[19..16] [1111] rd[11..8]
549270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5501465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2AsrRRR,       /* asr [111110100100] rn[19..16] [1111] rd[11..8]
551270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5521465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2RorRRR,       /* ror [111110100110] rn[19..16] [1111] rd[11..8]
553270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [0000] rm[3..0] */
5541465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LslRRI5,      /* lsl [11101010010011110] imm[14.12] rd[11..8]
555270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [00] rm[3..0] */
5561465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LsrRRI5,      /* lsr [11101010010011110] imm[14.12] rd[11..8]
557270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [01] rm[3..0] */
5581465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2AsrRRI5,      /* asr [11101010010011110] imm[14.12] rd[11..8]
559270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [10] rm[3..0] */
5601465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2RorRRI5,      /* ror [11101010010011110] imm[14.12] rd[11..8]
561270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   [11] rm[3..0] */
5621465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2BicRRI8,      /* bic [111100000010] rn[19..16] [0] imm3
563270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   rd[11..8] imm8 */
5641465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2AndRRI8,      /* bic [111100000000] rn[19..16] [0] imm3
565270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   rd[11..8] imm8 */
5661465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2OrrRRI8,      /* orr [111100000100] rn[19..16] [0] imm3
567270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   rd[11..8] imm8 */
5681465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2EorRRI8,      /* eor [111100001000] rn[19..16] [0] imm3
569270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   rd[11..8] imm8 */
5701465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2AddRRI8,      /* add [111100001000] rn[19..16] [0] imm3
571270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   rd[11..8] imm8 */
5721465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2AdcRRI8,      /* adc [111100010101] rn[19..16] [0] imm3
573270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   rd[11..8] imm8 */
5741465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2SubRRI8,      /* sub [111100011011] rn[19..16] [0] imm3
575270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   rd[11..8] imm8 */
5761465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2SbcRRI8,      /* sbc [111100010111] rn[19..16] [0] imm3
577270c1d64a192341be842f46734054c692bac061eBill Buzbee                                   rd[11..8] imm8 */
5781465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2It,           /* it [10111111] firstcond[7-4] mask[3-0] */
5791465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Fmstat,       /* fmstat [11101110111100011111101000010000] */
5801465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vcmpd,        /* vcmp [111011101] D [11011] rd[15-12] [1011]
581a4a7f0708e75eefae8cf9fff3f9e15699f7881beBill Buzbee                                   E [1] M [0] rm[3-0] */
5821465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vcmps,        /* vcmp [111011101] D [11010] rd[15-12] [1011]
583a4a7f0708e75eefae8cf9fff3f9e15699f7881beBill Buzbee                                   E [1] M [0] rm[3-0] */
5841465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2LdrPcRel12,   /* ldr rd,[pc,#imm12] [1111100011011111] rt[15-12]
5851465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  imm12[11-0] */
5861465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2BCond,        /* b<c> [1110] S cond[25-22] imm6[21-16] [10]
587a4a7f0708e75eefae8cf9fff3f9e15699f7881beBill Buzbee                                  J1 [0] J2 imm11[10..0] */
5881465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vmovd_RR,     /* vmov [111011101] D [110000] vd[15-12 [101101]
5897fb2edd2f69d11435da8dc0f1c251349238863b3Bill Buzbee                                  M [0] vm[3-0] */
5901465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vmovs_RR,     /* vmov [111011101] D [110000] vd[15-12 [101001]
5917fb2edd2f69d11435da8dc0f1c251349238863b3Bill Buzbee                                  M [0] vm[3-0] */
5921465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Fmrs,         /* vmov [111011100000] vn[19-16] rt[15-12] [1010]
5937fb2edd2f69d11435da8dc0f1c251349238863b3Bill Buzbee                                  N [0010000] */
5941465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Fmsr,         /* vmov [111011100001] vn[19-16] rt[15-12] [1010]
5957fb2edd2f69d11435da8dc0f1c251349238863b3Bill Buzbee                                  N [0010000] */
5961465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Fmrrd,        /* vmov [111011000100] rt2[19-16] rt[15-12]
5977fb2edd2f69d11435da8dc0f1c251349238863b3Bill Buzbee                                  [101100] M [1] vm[3-0] */
5981465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Fmdrr,        /* vmov [111011000101] rt2[19-16] rt[15-12]
5997fb2edd2f69d11435da8dc0f1c251349238863b3Bill Buzbee                                  [101100] M [1] vm[3-0] */
6001465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vabsd,        /* vabs.f64 [111011101] D [110000] rd[15-12]
6011465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  [1011110] M [0] vm[3-0] */
6021465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vabss,        /* vabs.f32 [111011101] D [110000] rd[15-12]
6031465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  [1010110] M [0] vm[3-0] */
6041465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vnegd,        /* vneg.f64 [111011101] D [110000] rd[15-12]
6051465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  [1011110] M [0] vm[3-0] */
6061465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vnegs,        /* vneg.f32 [111011101] D [110000] rd[15-12]
6071465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                 [1010110] M [0] vm[3-0] */
6081465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vmovs_IMM8,   /* vmov.f32 [111011101] D [11] imm4h[19-16] vd[15-12]
6091465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  [10100000] imm4l[3-0] */
6101465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Vmovd_IMM8,   /* vmov.f64 [111011101] D [11] imm4h[19-16] vd[15-12]
6111465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  [10110000] imm4l[3-0] */
6121465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Mla,          /* mla [111110110000] rn[19-16] ra[15-12] rd[7-4]
6131465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  [0000] rm[3-0] */
6141465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Umull,        /* umull [111110111010] rn[19-16], rdlo[15-12]
6151465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  rdhi[11-8] [0000] rm[3-0] */
6161465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Ldrex,        /* ldrex [111010000101] rn[19-16] rt[11-8] [1111]
6171465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  imm8[7-0] */
6181465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kThumb2Strex,        /* strex [111010000100] rn[19-16] rt[11-8] rd[11-8]
6191465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee                                  imm8[7-0] */
620d0937ef76b41a57d25c084e76aed1bb91c6dfde7Bill Buzbee    kThumb2Clrex,        /* clrex [111100111011111110000111100101111] */
621d0937ef76b41a57d25c084e76aed1bb91c6dfde7Bill Buzbee    kThumb2Bfi,          /* bfi [111100110110] rn[19-16] [0] imm3[14-12]
622d0937ef76b41a57d25c084e76aed1bb91c6dfde7Bill Buzbee                                  rd[11-8] imm2[7-6] [0] msb[4-0] */
623d0937ef76b41a57d25c084e76aed1bb91c6dfde7Bill Buzbee    kThumb2Bfc,          /* bfc [11110011011011110] [0] imm3[14-12]
624d0937ef76b41a57d25c084e76aed1bb91c6dfde7Bill Buzbee                                  rd[11-8] imm2[7-6] [0] msb[4-0] */
625ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee    kThumb2Dmb,          /* dmb [1111001110111111100011110101] option[3-0] */
6267fb2edd2f69d11435da8dc0f1c251349238863b3Bill Buzbee
6271465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kArmLast,
62889efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee} ArmOpCode;
62989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
630ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee/* DMB option encodings */
631ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbeetypedef enum ArmOpDmbOptions {
632ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee    kSY = 0xf,
633ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee    kST = 0xe,
634ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee    kISH = 0xb,
635ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee    kISHST = 0xa,
636ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee    kNSH = 0x7,
637ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee    kNSHST = 0x6
638ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee} ArmOpDmbOptions;
639ecf8f6ede2c00350a36297dd7427afff9d9cb154buzbee
64089efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee/* Bit flags describing the behavior of each native opcode */
64189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbeetypedef enum ArmOpFeatureFlags {
642dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kIsBranch = 0,
643dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegDef0,
644dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegDef1,
645dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegDefSP,
646d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng    kRegDefLR,
647dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegDefList0,
648dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegDefList1,
649dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegUse0,
650dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegUse1,
651dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegUse2,
6521465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kRegUse3,
653dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegUseSP,
654dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegUsePC,
655dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegUseList0,
656dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kRegUseList1,
657dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kNoOperand,
658dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kIsUnaryOp,
659dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kIsBinaryOp,
660dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kIsTertiaryOp,
661dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kIsQuadOp,
662dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kIsIT,
663dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kSetsCCodes,
664dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    kUsesCCodes,
6651f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    kMemLoad,
6661f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    kMemStore,
66789efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee} ArmOpFeatureFlags;
66889efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
6691f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee#define IS_LOAD         (1 << kMemLoad)
6701f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee#define IS_STORE        (1 << kMemStore)
671dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define IS_BRANCH       (1 << kIsBranch)
672dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_DEF0        (1 << kRegDef0)
673dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_DEF1        (1 << kRegDef1)
674dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_DEF_SP      (1 << kRegDefSP)
675d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REG_DEF_LR      (1 << kRegDefLR)
676dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_DEF_LIST0   (1 << kRegDefList0)
677dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_DEF_LIST1   (1 << kRegDefList1)
678dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_USE0        (1 << kRegUse0)
679dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_USE1        (1 << kRegUse1)
680dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_USE2        (1 << kRegUse2)
6811465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee#define REG_USE3        (1 << kRegUse3)
682dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_USE_SP      (1 << kRegUseSP)
683d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REG_USE_PC      (1 << kRegUsePC)
684dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_USE_LIST0   (1 << kRegUseList0)
685dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_USE_LIST1   (1 << kRegUseList1)
686dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define NO_OPERAND      (1 << kNoOperand)
687dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define IS_UNARY_OP     (1 << kIsUnaryOp)
688dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define IS_BINARY_OP    (1 << kIsBinaryOp)
689dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define IS_TERTIARY_OP  (1 << kIsTertiaryOp)
690dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define IS_QUAD_OP      (1 << kIsQuadOp)
691dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define IS_IT           (1 << kIsIT)
692dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define SETS_CCODES     (1 << kSetsCCodes)
693dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define USES_CCODES     (1 << kUsesCCodes)
694dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng
695dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng/* Common combo register usage patterns */
696dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng#define REG_USE01       (REG_USE0 | REG_USE1)
697d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REG_USE012      (REG_USE01 | REG_USE2)
698d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REG_USE12       (REG_USE1 | REG_USE2)
699d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REG_DEF0_USE0   (REG_DEF0 | REG_USE0)
700d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REG_DEF0_USE1   (REG_DEF0 | REG_USE1)
701d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REG_DEF0_USE01  (REG_DEF0 | REG_USE01)
702d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REG_DEF0_USE12  (REG_DEF0 | REG_USE12)
703d7d426a1d746f70edeaeccf77886f3ad8298e28cBen Cheng#define REG_DEF01_USE2  (REG_DEF0 | REG_DEF1 | REG_USE2)
704dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng
7059bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee/* Instruction assembly fieldLoc kind */
7069bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbeetypedef enum ArmEncodingKind {
7071465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtUnused,
7081465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtBitBlt,        /* Bit string using end/start */
7091465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtDfp,           /* Double FP reg */
7101465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtSfp,           /* Single FP reg */
7111465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtModImm,        /* Shifted 8-bit immed using [26,14..12,7..0] */
7121465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtImm16,         /* Zero-extended immed using [26,19..16,14..12,7..0] */
7131465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtImm6,          /* Encoded branch target using [9,7..3]0 */
7141465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtImm12,         /* Zero-extended immediate using [26,14..12,7..0] */
7151465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtShift,         /* Shift descriptor, [14..12,7..4] */
7161465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtLsb,           /* least significant bit using [14..12][7..6] */
7171465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtBWidth,        /* bit-field width, encoded as width-1 */
7181465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtShift5,        /* Shift count, [14..12,7..6] */
7191465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtBrOffset,      /* Signed extended [26,11,13,21-16,10-0]:0 */
7201465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee    kFmtFPImm,         /* Encoded floating point immediate */
7219bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee} ArmEncodingKind;
7229bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee
72389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee/* Struct used to define the snippet positions for each Thumb opcode */
72489efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbeetypedef struct ArmEncodingMap {
7259bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee    u4 skeleton;
72689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    struct {
7279bc3df373ae6f4f7e6e97d554884d4e0dbad5494Bill Buzbee        ArmEncodingKind kind;
7281465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee        int end;   /* end for kFmtBitBlt, 1-bit slice end for FP regs */
7291465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbee        int start; /* start for kFmtBitBlt, 4-bit slice end for FP regs */
730270c1d64a192341be842f46734054c692bac061eBill Buzbee    } fieldLoc[4];
73189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    ArmOpCode opCode;
73289efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    int flags;
73389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    char *name;
73489efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    char* fmt;
73589efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    int size;
73689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee} ArmEncodingMap;
73789efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
7381f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee/* Keys for target-specific scheduling and other optimization hints */
7391f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbeetypedef enum ArmTargetOptHints {
7401f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    kMaxHoistDistance,
7411f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee} ArmTargetOptHints;
7421f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee
7431465db5ee2d3c4c4dcc8e017a294172e858765cbBill Buzbeeextern ArmEncodingMap EncodingMap[kArmLast];
74489efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
74589efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee/*
74689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee * Each instance of this struct holds a pseudo or real LIR instruction:
747b4c05977c28c38d2f81b48d0cb15559dc3d05564Elliott Hughes * - pseudo ones (eg labels and marks) and will be discarded by the assembler.
748dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng * - real ones will be assembled into Thumb instructions.
749dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng *
750dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng * Machine resources are encoded into a 64-bit vector, where the encodings are
751dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng * as following:
752dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng * - [ 0..15]: general purpose registers including PC, SP, and LR
753dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng * - [16..47]: floating-point registers where d0 is expanded to s[01] and s0
754dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng *   starts at bit 16
755dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng * - [48]: IT block
756dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng * - [49]: integer condition code
757dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng * - [50]: floatint-point status word
75889efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee */
75989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbeetypedef struct ArmLIR {
76089efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    LIR generic;
76189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    ArmOpCode opCode;
762270c1d64a192341be842f46734054c692bac061eBill Buzbee    int operands[4];    // [0..3] = [dest, src1, src2, extra]
76389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    bool isNop;         // LIR is optimized away
7649e45c0b968d63ea38353c99252d233879c2efdafjeffhao    bool branchInsertSV;// mark for insertion of branch before this instruction,
7659e45c0b968d63ea38353c99252d233879c2efdafjeffhao                        // used to identify mem ops for self verification mode
76689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    int age;            // default is 0, set lazily by the optimizer
76789efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee    int size;           // 16-bit unit size (1 for thumb, 1 or 2 for thumb2)
7681f74863d3e0f19930818398f375ebf1cf2d78969Bill Buzbee    int aliasInfo;      // For Dalvik register access & litpool disambiguation
769dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    u8 useMask;         // Resource mask for use
770dcf3e5d43a1831a166f70cb9e0694cd4b0b356b0Ben Cheng    u8 defMask;         // Resource mask for def
77189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee} ArmLIR;
77289efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
77389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee/* Init values when a predicted chain is initially assembled */
7746999d84e2c55dc4a46a6c311b55bd5811336d9c4Ben Cheng/* E7FE is branch to self */
7756999d84e2c55dc4a46a6c311b55bd5811336d9c4Ben Cheng#define PREDICTED_CHAIN_BX_PAIR_INIT     0xe7fe
77689efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
77789efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee/* Utility macros to traverse the LIR/ArmLIR list */
77889efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#define NEXT_LIR(lir) ((ArmLIR *) lir->generic.next)
77989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#define PREV_LIR(lir) ((ArmLIR *) lir->generic.prev)
78089efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
78189efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#define NEXT_LIR_LVALUE(lir) (lir)->generic.next
78289efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#define PREV_LIR_LVALUE(lir) (lir)->generic.prev
78389efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
78489efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#define CHAIN_CELL_OFFSET_TAG   0xcdab
78589efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee
786bd0472480c6e876198fe19c4ffa22350c0ce57daBill Buzbee#define CHAIN_CELL_NORMAL_SIZE 12
787bd0472480c6e876198fe19c4ffa22350c0ce57daBill Buzbee#define CHAIN_CELL_PREDICTED_SIZE 16
788bd0472480c6e876198fe19c4ffa22350c0ce57daBill Buzbee
78989efc3d632adfa076bd622369b1ad8e4b49cf20eBill Buzbee#endif /* _DALVIK_VM_COMPILER_CODEGEN_ARM_ARMLIR_H */
790