| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "Dalvik.h" |
| 18 | #include "libdex/OpCode.h" |
| 19 | #include "dexdump/OpCodeNames.h" |
| 20 | |
| 21 | #include "../../CompilerInternals.h" |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 22 | #include "ArmLIR.h" |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 23 | #include <unistd.h> /* for cacheflush */ |
| 24 | |
| 25 | /* |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 26 | * opcode: ArmOpCode enum |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 27 | * skeleton: pre-designated bit-pattern for this opcode |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 28 | * k0: key to applying ds/de |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 29 | * ds: dest start bit position |
| 30 | * de: dest end bit position |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 31 | * k1: key to applying s1s/s1e |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 32 | * s1s: src1 start bit position |
| 33 | * s1e: src1 end bit position |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 34 | * k2: key to applying s2s/s2e |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 35 | * s2s: src2 start bit position |
| 36 | * s2e: src2 end bit position |
| 37 | * operands: number of operands (for sanity check purposes) |
| 38 | * name: mnemonic name |
| 39 | * fmt: for pretty-prining |
| 40 | */ |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 41 | #define ENCODING_MAP(opcode, skeleton, k0, ds, de, k1, s1s, s1e, k2, s2s, s2e, \ |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 42 | k3, k3s, k3e, operands, name, fmt, size) \ |
| 43 | {skeleton, {{k0, ds, de}, {k1, s1s, s1e}, {k2, s2s, s2e}, \ |
| 44 | {k3, k3s, k3e}}, opcode, operands, name, fmt, size} |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 45 | |
| 46 | /* Instruction dump string format keys: !pf, where "!" is the start |
| 47 | * of the key, "p" is which numeric operand to use and "f" is the |
| 48 | * print format. |
| 49 | * |
| 50 | * [p]ositions: |
| 51 | * 0 -> operands[0] (dest) |
| 52 | * 1 -> operands[1] (src1) |
| 53 | * 2 -> operands[2] (src2) |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 54 | * 3 -> operands[3] (extra) |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 55 | * |
| 56 | * [f]ormats: |
| 57 | * h -> 4-digit hex |
| 58 | * d -> decimal |
| 59 | * D -> decimal+8 (used to convert 3-bit regnum field to high reg) |
| 60 | * E -> decimal*4 |
| 61 | * F -> decimal*2 |
| 62 | * c -> branch condition (beq, bne, etc.) |
| 63 | * t -> pc-relative target |
| 64 | * u -> 1st half of bl[x] target |
| 65 | * v -> 2nd half ob bl[x] target |
| 66 | * R -> register list |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 67 | * s -> single precision floating point register |
| 68 | * S -> double precision floating point register |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 69 | * m -> Thumb2 modified immediate |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 70 | * n -> complimented Thumb2 modified immediate |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 71 | * M -> Thumb2 16-bit zero-extended immediate |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 72 | * b -> 4-digit binary |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 73 | * |
| 74 | * [!] escape. To insert "!", use "!!" |
| 75 | */ |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 76 | /* NOTE: must be kept in sync with enum ArmOpcode from ArmLIR.h */ |
| 77 | ArmEncodingMap EncodingMap[ARM_LAST] = { |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 78 | ENCODING_MAP(ARM_16BIT_DATA, 0x0000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 79 | BITBLT, 15, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 80 | IS_UNARY_OP, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 81 | "data", "0x!0h(!0d)", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 82 | ENCODING_MAP(THUMB_ADC, 0x4140, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 83 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 84 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES | USES_CCODES, |
| 85 | "adcs", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 86 | ENCODING_MAP(THUMB_ADD_RRI3, 0x1c00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 87 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| 88 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 89 | "adds", "r!0d, r!1d, #!2d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 90 | ENCODING_MAP(THUMB_ADD_RI8, 0x3000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 91 | BITBLT, 10, 8, BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| 92 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 93 | "adds", "r!0d, r!0d, #!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 94 | ENCODING_MAP(THUMB_ADD_RRR, 0x1800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 95 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| 96 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 97 | "adds", "r!0d, r!1d, r!2d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 98 | ENCODING_MAP(THUMB_ADD_RR_LH, 0x4440, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 99 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 100 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 101 | "add", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 102 | ENCODING_MAP(THUMB_ADD_RR_HL, 0x4480, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 103 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 104 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 105 | "add", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 106 | ENCODING_MAP(THUMB_ADD_RR_HH, 0x44c0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 107 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 108 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 109 | "add", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 110 | ENCODING_MAP(THUMB_ADD_PC_REL, 0xa000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 111 | BITBLT, 10, 8, BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 112 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 113 | "add", "r!0d, pc, #!1E", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 114 | ENCODING_MAP(THUMB_ADD_SP_REL, 0xa800, |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 115 | BITBLT, 10, 8, UNUSED, -1, -1, BITBLT, 7, 0, UNUSED, -1, -1, |
| 116 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 117 | "add", "r!0d, sp, #!2E", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 118 | ENCODING_MAP(THUMB_ADD_SPI7, 0xb000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 119 | BITBLT, 6, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 120 | IS_UNARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 121 | "add", "sp, #!0d*4", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 122 | ENCODING_MAP(THUMB_AND_RR, 0x4000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 123 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 124 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 125 | "ands", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 126 | ENCODING_MAP(THUMB_ASR, 0x1000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 127 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 10, 6, UNUSED, -1, -1, |
| 128 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 129 | "asrs", "r!0d, r!1d, #!2d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 130 | ENCODING_MAP(THUMB_ASRV, 0x4100, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 131 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 132 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 133 | "asrs", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 134 | ENCODING_MAP(THUMB_B_COND, 0xd000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 135 | BITBLT, 7, 0, BITBLT, 11, 8, UNUSED, -1, -1, UNUSED, -1, -1, |
| 136 | IS_BINARY_OP | IS_BRANCH | USES_CCODES, |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 137 | "b!1c", "!0t", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 138 | ENCODING_MAP(THUMB_B_UNCOND, 0xe000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 139 | BITBLT, 10, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 140 | NO_OPERAND | IS_BRANCH, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 141 | "b", "!0t", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 142 | ENCODING_MAP(THUMB_BIC, 0x4380, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 143 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 144 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 145 | "bics", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 146 | ENCODING_MAP(THUMB_BKPT, 0xbe00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 147 | BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 148 | IS_UNARY_OP | IS_BRANCH, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 149 | "bkpt", "!0d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 150 | ENCODING_MAP(THUMB_BLX_1, 0xf000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 151 | BITBLT, 10, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 152 | IS_BINARY_OP | IS_BRANCH, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 153 | "blx_1", "!0u", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 154 | ENCODING_MAP(THUMB_BLX_2, 0xe800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 155 | BITBLT, 10, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 156 | IS_BINARY_OP | IS_BRANCH, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 157 | "blx_2", "!0v", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 158 | ENCODING_MAP(THUMB_BL_1, 0xf000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 159 | BITBLT, 10, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 160 | IS_UNARY_OP | IS_BRANCH, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 161 | "bl_1", "!0u", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 162 | ENCODING_MAP(THUMB_BL_2, 0xf800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 163 | BITBLT, 10, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 164 | IS_UNARY_OP | IS_BRANCH, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 165 | "bl_2", "!0v", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 166 | ENCODING_MAP(THUMB_BLX_R, 0x4780, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 167 | BITBLT, 6, 3, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 168 | IS_UNARY_OP | IS_BRANCH, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 169 | "blx", "r!0d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 170 | ENCODING_MAP(THUMB_BX, 0x4700, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 171 | BITBLT, 6, 3, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 172 | IS_UNARY_OP | IS_BRANCH, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 173 | "bx", "r!0d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 174 | ENCODING_MAP(THUMB_CMN, 0x42c0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 175 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 176 | IS_BINARY_OP | SETS_CCODES, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 177 | "cmn", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 178 | ENCODING_MAP(THUMB_CMP_RI8, 0x2800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 179 | BITBLT, 10, 8, BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| 180 | IS_BINARY_OP | SETS_CCODES, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 181 | "cmp", "r!0d, #!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 182 | ENCODING_MAP(THUMB_CMP_RR, 0x4280, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 183 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 184 | IS_BINARY_OP | SETS_CCODES, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 185 | "cmp", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 186 | ENCODING_MAP(THUMB_CMP_LH, 0x4540, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 187 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 188 | IS_BINARY_OP | SETS_CCODES, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 189 | "cmp", "r!0d, r!1D", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 190 | ENCODING_MAP(THUMB_CMP_HL, 0x4580, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 191 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 192 | IS_BINARY_OP | SETS_CCODES, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 193 | "cmp", "r!0D, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 194 | ENCODING_MAP(THUMB_CMP_HH, 0x45c0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 195 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 196 | IS_BINARY_OP | SETS_CCODES, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 197 | "cmp", "r!0D, r!1D", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 198 | ENCODING_MAP(THUMB_EOR, 0x4040, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 199 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 200 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 201 | "eors", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 202 | ENCODING_MAP(THUMB_LDMIA, 0xc800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 203 | BITBLT, 10, 8, BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 204 | IS_BINARY_OP | CLOBBER_DEST | CLOBBER_SRC1, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 205 | "ldmia", "r!0d!!, <!1R>", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 206 | ENCODING_MAP(THUMB_LDR_RRI5, 0x6800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 207 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 10, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 208 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 209 | "ldr", "r!0d, [r!1d, #!2E]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 210 | ENCODING_MAP(THUMB_LDR_RRR, 0x5800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 211 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 212 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 213 | "ldr", "r!0d, [r!1d, r!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 214 | ENCODING_MAP(THUMB_LDR_PC_REL, 0x4800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 215 | BITBLT, 10, 8, BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 216 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 217 | "ldr", "r!0d, [pc, #!1E]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 218 | ENCODING_MAP(THUMB_LDR_SP_REL, 0x9800, |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 219 | BITBLT, 10, 8, UNUSED, -1, -1, BITBLT, 7, 0, UNUSED, -1, -1, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 220 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 221 | "ldr", "r!0d, [sp, #!2E]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 222 | ENCODING_MAP(THUMB_LDRB_RRI5, 0x7800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 223 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 10, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 224 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 225 | "ldrb", "r!0d, [r!1d, #2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 226 | ENCODING_MAP(THUMB_LDRB_RRR, 0x5c00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 227 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 228 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 229 | "ldrb", "r!0d, [r!1d, r!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 230 | ENCODING_MAP(THUMB_LDRH_RRI5, 0x8800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 231 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 10, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 232 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 233 | "ldrh", "r!0d, [r!1d, #!2F]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 234 | ENCODING_MAP(THUMB_LDRH_RRR, 0x5a00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 235 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 236 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 237 | "ldrh", "r!0d, [r!1d, r!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 238 | ENCODING_MAP(THUMB_LDRSB_RRR, 0x5600, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 239 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 240 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 241 | "ldrsb", "r!0d, [r!1d, r!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 242 | ENCODING_MAP(THUMB_LDRSH_RRR, 0x5e00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 243 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 244 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 245 | "ldrsh", "r!0d, [r!1d, r!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 246 | ENCODING_MAP(THUMB_LSL, 0x0000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 247 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 10, 6, UNUSED, -1, -1, |
| 248 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 249 | "lsls", "r!0d, r!1d, #!2d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 250 | ENCODING_MAP(THUMB_LSLV, 0x4080, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 251 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 252 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 253 | "lsls", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 254 | ENCODING_MAP(THUMB_LSR, 0x0800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 255 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 10, 6, UNUSED, -1, -1, |
| 256 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 257 | "lsrs", "r!0d, r!1d, #!2d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 258 | ENCODING_MAP(THUMB_LSRV, 0x40c0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 259 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 260 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 261 | "lsrs", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 262 | ENCODING_MAP(THUMB_MOV_IMM, 0x2000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 263 | BITBLT, 10, 8, BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| 264 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 265 | "movs", "r!0d, #!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 266 | ENCODING_MAP(THUMB_MOV_RR, 0x1c00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 267 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 268 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 269 | "movs", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 270 | ENCODING_MAP(THUMB_MOV_RR_H2H, 0x46c0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 271 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 272 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 273 | "mov", "r!0D, r!1D", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 274 | ENCODING_MAP(THUMB_MOV_RR_H2L, 0x4640, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 275 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 276 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 277 | "mov", "r!0d, r!1D", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 278 | ENCODING_MAP(THUMB_MOV_RR_L2H, 0x4680, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 279 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 280 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 281 | "mov", "r!0D, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 282 | ENCODING_MAP(THUMB_MUL, 0x4340, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 283 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 284 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 285 | "muls", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 286 | ENCODING_MAP(THUMB_MVN, 0x43c0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 287 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 288 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 289 | "mvns", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 290 | ENCODING_MAP(THUMB_NEG, 0x4240, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 291 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 292 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 293 | "negs", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 294 | ENCODING_MAP(THUMB_ORR, 0x4300, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 295 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 296 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 297 | "orrs", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 298 | ENCODING_MAP(THUMB_POP, 0xbc00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 299 | BITBLT, 8, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 300 | IS_UNARY_OP, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 301 | "pop", "<!0R>", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 302 | ENCODING_MAP(THUMB_PUSH, 0xb400, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 303 | BITBLT, 8, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 304 | IS_UNARY_OP, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 305 | "push", "<!0R>", 1), |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 306 | ENCODING_MAP(THUMB_RORV, 0x41c0, |
| 307 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 308 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 309 | "rors", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 310 | ENCODING_MAP(THUMB_SBC, 0x4180, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 311 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 312 | IS_BINARY_OP | CLOBBER_DEST | USES_CCODES | SETS_CCODES, |
| 313 | "sbcs", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 314 | ENCODING_MAP(THUMB_STMIA, 0xc000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 315 | BITBLT, 10, 8, BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 316 | IS_BINARY_OP | CLOBBER_SRC1, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 317 | "stmia", "r!0d!!, <!1R>", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 318 | ENCODING_MAP(THUMB_STR_RRI5, 0x6000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 319 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 10, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 320 | IS_TERTIARY_OP, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 321 | "str", "r!0d, [r!1d, #!2E]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 322 | ENCODING_MAP(THUMB_STR_RRR, 0x5000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 323 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 324 | IS_TERTIARY_OP, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 325 | "str", "r!0d, [r!1d, r!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 326 | ENCODING_MAP(THUMB_STR_SP_REL, 0x9000, |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 327 | BITBLT, 10, 8, UNUSED, -1, -1, BITBLT, 7, 0, UNUSED, -1, -1, |
| 328 | IS_TERTIARY_OP, |
| 329 | "str", "r!0d, [sp, #!2E]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 330 | ENCODING_MAP(THUMB_STRB_RRI5, 0x7000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 331 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 10, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 332 | IS_TERTIARY_OP, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 333 | "strb", "r!0d, [r!1d, #!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 334 | ENCODING_MAP(THUMB_STRB_RRR, 0x5400, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 335 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 336 | IS_TERTIARY_OP, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 337 | "strb", "r!0d, [r!1d, r!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 338 | ENCODING_MAP(THUMB_STRH_RRI5, 0x8000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 339 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 10, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 340 | IS_TERTIARY_OP, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 341 | "strh", "r!0d, [r!1d, #!2F]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 342 | ENCODING_MAP(THUMB_STRH_RRR, 0x5200, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 343 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 344 | IS_TERTIARY_OP, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 345 | "strh", "r!0d, [r!1d, r!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 346 | ENCODING_MAP(THUMB_SUB_RRI3, 0x1e00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 347 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| 348 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 349 | "subs", "r!0d, r!1d, #!2d]", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 350 | ENCODING_MAP(THUMB_SUB_RI8, 0x3800, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 351 | BITBLT, 10, 8, BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| 352 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 353 | "subs", "r!0d, #!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 354 | ENCODING_MAP(THUMB_SUB_RRR, 0x1a00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 355 | BITBLT, 2, 0, BITBLT, 5, 3, BITBLT, 8, 6, UNUSED, -1, -1, |
| 356 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 357 | "subs", "r!0d, r!1d, r!2d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 358 | ENCODING_MAP(THUMB_SUB_SPI7, 0xb080, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 359 | BITBLT, 6, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 360 | IS_UNARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 361 | "sub", "sp, #!0d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 362 | ENCODING_MAP(THUMB_SWI, 0xdf00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 363 | BITBLT, 7, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 364 | IS_UNARY_OP | IS_BRANCH, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 365 | "swi", "!0d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 366 | ENCODING_MAP(THUMB_TST, 0x4200, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 367 | BITBLT, 2, 0, BITBLT, 5, 3, UNUSED, -1, -1, UNUSED, -1, -1, |
| 368 | IS_UNARY_OP | SETS_CCODES, |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 369 | "tst", "r!0d, r!1d", 1), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 370 | ENCODING_MAP(THUMB2_VLDRS, 0xed900a00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 371 | SFP, 22, 12, BITBLT, 19, 16, BITBLT, 7, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 372 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 373 | "vldr", "!0s, [r!1d, #!2E]", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 374 | ENCODING_MAP(THUMB2_VLDRD, 0xed900b00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 375 | DFP, 22, 12, BITBLT, 19, 16, BITBLT, 7, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 376 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 377 | "vldr", "!0S, [r!1d, #!2E]", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 378 | ENCODING_MAP(THUMB2_VMULS, 0xee200a00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 379 | SFP, 22, 12, SFP, 7, 16, SFP, 5, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 380 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 381 | "vmuls", "!0s, !1s, !2s", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 382 | ENCODING_MAP(THUMB2_VMULD, 0xee200b00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 383 | DFP, 22, 12, DFP, 7, 16, DFP, 5, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 384 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 385 | "vmuld", "!0S, !1S, !2S", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 386 | ENCODING_MAP(THUMB2_VSTRS, 0xed800a00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 387 | SFP, 22, 12, BITBLT, 19, 16, BITBLT, 7, 0, UNUSED, -1, -1, |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 388 | IS_TERTIARY_OP, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 389 | "vstr", "!0s, [r!1d, #!2E]", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 390 | ENCODING_MAP(THUMB2_VSTRD, 0xed800b00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 391 | DFP, 22, 12, BITBLT, 19, 16, BITBLT, 7, 0, UNUSED, -1, -1, |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 392 | IS_TERTIARY_OP, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 393 | "vstr", "!0S, [r!1d, #!2E]", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 394 | ENCODING_MAP(THUMB2_VSUBS, 0xee300a40, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 395 | SFP, 22, 12, SFP, 7, 16, SFP, 5, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 396 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 397 | "vsub", "!0s, !1s, !2s", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 398 | ENCODING_MAP(THUMB2_VSUBD, 0xee300b40, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 399 | DFP, 22, 12, DFP, 7, 16, DFP, 5, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 400 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 401 | "vsub", "!0S, !1S, !2S", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 402 | ENCODING_MAP(THUMB2_VADDS, 0xee300a00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 403 | SFP, 22, 12, SFP, 7, 16, SFP, 5, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 404 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 405 | "vadd", "!0s, !1s, !2s", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 406 | ENCODING_MAP(THUMB2_VADDD, 0xee300b00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 407 | DFP, 22, 12, DFP, 7, 16, DFP, 5, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 408 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 409 | "vadd", "!0S, !1S, !2S", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 410 | ENCODING_MAP(THUMB2_VDIVS, 0xee800a00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 411 | SFP, 22, 12, SFP, 7, 16, SFP, 5, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 412 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 413 | "vdivs", "!0s, !1s, !2s", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 414 | ENCODING_MAP(THUMB2_VDIVD, 0xee800b00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 415 | DFP, 22, 12, DFP, 7, 16, DFP, 5, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 416 | IS_TERTIARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 417 | "vdivs", "!0S, !1S, !2S", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 418 | ENCODING_MAP(THUMB2_VCVTIF, 0xeeb80ac0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 419 | SFP, 22, 12, SFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 420 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 421 | "vcvt.f32", "!0s, !1s", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 422 | ENCODING_MAP(THUMB2_VCVTID, 0xeeb80bc0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 423 | DFP, 22, 12, SFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 424 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 425 | "vcvt.f64", "!0S, !1s", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 426 | ENCODING_MAP(THUMB2_VCVTFI, 0xeebd0ac0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 427 | SFP, 22, 12, SFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 428 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 429 | "vcvt.s32.f32 ", "!0s, !1s", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 430 | ENCODING_MAP(THUMB2_VCVTDI, 0xeebd0bc0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 431 | SFP, 22, 12, DFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 432 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 433 | "vcvt.s32.f64 ", "!0s, !1S", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 434 | ENCODING_MAP(THUMB2_VCVTFD, 0xeeb70ac0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 435 | DFP, 22, 12, SFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 436 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 437 | "vcvt.f64.f32 ", "!0S, !1s", 2), |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 438 | ENCODING_MAP(THUMB2_VCVTDF, 0xeeb70bc0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 439 | SFP, 22, 12, DFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 440 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 441 | "vcvt.f32.f64 ", "!0s, !1S", 2), |
| 442 | ENCODING_MAP(THUMB2_VSQRTS, 0xeeb10ac0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 443 | SFP, 22, 12, SFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 444 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 445 | "vsqrt.f32 ", "!0s, !1s", 2), |
| 446 | ENCODING_MAP(THUMB2_VSQRTD, 0xeeb10bc0, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 447 | DFP, 22, 12, DFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 448 | IS_BINARY_OP | CLOBBER_DEST, |
| Bill Buzbee | 9727c3d | 2009-08-01 11:32:36 -0700 | [diff] [blame] | 449 | "vsqrt.f64 ", "!0S, !1S", 2), |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 450 | ENCODING_MAP(THUMB2_MOV_IMM_SHIFT, 0xf04f0000, /* no setflags encoding */ |
| 451 | BITBLT, 11, 8, MODIMM, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 452 | IS_BINARY_OP | CLOBBER_DEST, |
| 453 | "mov", "r!0d, #!1m", 2), |
| 454 | ENCODING_MAP(THUMB2_MOV_IMM16, 0xf2400000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 455 | BITBLT, 11, 8, IMM16, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 456 | IS_BINARY_OP | CLOBBER_DEST, |
| 457 | "mov", "r!0d, #!1M", 2), |
| 458 | ENCODING_MAP(THUMB2_STR_RRI12, 0xf8c00000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 459 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 11, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 460 | IS_TERTIARY_OP, |
| 461 | "str", "r!0d,[r!1d, #!2d", 2), |
| 462 | ENCODING_MAP(THUMB2_LDR_RRI12, 0xf8d00000, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 463 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 11, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 464 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 465 | "ldr", "r!0d,[r!1d, #!2d", 2), |
| 466 | ENCODING_MAP(THUMB2_STR_RRI8_PREDEC, 0xf8400c00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 467 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 8, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 468 | IS_TERTIARY_OP, |
| 469 | "str", "r!0d,[r!1d, #-!2d]", 2), |
| 470 | ENCODING_MAP(THUMB2_LDR_RRI8_PREDEC, 0xf8500c00, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 471 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 8, 0, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 472 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 473 | "ldr", "r!0d,[r!1d, #-!2d]", 2), |
| 474 | ENCODING_MAP(THUMB2_CBNZ, 0xb900, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 475 | BITBLT, 2, 0, IMM6, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| 476 | IS_BINARY_OP, /* Note: does not affect flags */ |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 477 | "cbnz", "r!0d,!1t", 1), |
| 478 | ENCODING_MAP(THUMB2_CBZ, 0xb100, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 479 | BITBLT, 2, 0, IMM6, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| 480 | IS_BINARY_OP, /* Note: does not affect flags */ |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 481 | "cbz", "r!0d,!1t", 1), |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 482 | ENCODING_MAP(THUMB2_ADD_RRI12, 0xf2000000, |
| 483 | BITBLT, 11, 8, BITBLT, 19, 16, IMM12, -1, -1, UNUSED, -1, -1, |
| 484 | IS_TERTIARY_OP | CLOBBER_DEST,/* Note: doesn't affect flags */ |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 485 | "add", "r!0d,r!1d,#!2d", 2), |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 486 | ENCODING_MAP(THUMB2_MOV_RR, 0xea4f0000, /* no setflags encoding */ |
| 487 | BITBLT, 11, 8, BITBLT, 3, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 488 | IS_BINARY_OP | CLOBBER_DEST, |
| 489 | "mov", "r!0d, r!1d", 2), |
| 490 | ENCODING_MAP(THUMB2_VMOVS, 0xeeb00a40, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 491 | SFP, 22, 12, SFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 492 | IS_BINARY_OP | CLOBBER_DEST, |
| 493 | "vmov.f32 ", "!0s, !1s", 2), |
| 494 | ENCODING_MAP(THUMB2_VMOVD, 0xeeb00b40, |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 495 | DFP, 22, 12, DFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 496 | IS_BINARY_OP | CLOBBER_DEST, |
| 497 | "vmov.f64 ", "!0s, !1s", 2), |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 498 | ENCODING_MAP(THUMB2_LDMIA, 0xe8900000, |
| 499 | BITBLT, 19, 16, BITBLT, 15, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| 500 | IS_BINARY_OP | CLOBBER_DEST | CLOBBER_SRC1, |
| 501 | "ldmia", "r!0d!!, <!1R>", 2), |
| 502 | ENCODING_MAP(THUMB2_STMIA, 0xe8800000, |
| 503 | BITBLT, 19, 16, BITBLT, 15, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| 504 | IS_BINARY_OP | CLOBBER_SRC1, |
| 505 | "stmia", "r!0d!!, <!1R>", 2), |
| 506 | ENCODING_MAP(THUMB2_ADD_RRR, 0xeb100000, /* setflags encoding */ |
| 507 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, |
| 508 | IS_QUAD_OP | CLOBBER_DEST | SETS_CCODES, |
| 509 | "adds", "r!0d, r!1d, r!2d", 2), |
| 510 | ENCODING_MAP(THUMB2_SUB_RRR, 0xebb00000, /* setflags enconding */ |
| 511 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, |
| 512 | IS_QUAD_OP | CLOBBER_DEST | SETS_CCODES, |
| 513 | "subs", "r!0d, r!1d, r!2d", 2), |
| 514 | ENCODING_MAP(THUMB2_SBC_RRR, 0xeb700000, /* setflags encoding */ |
| 515 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, |
| 516 | IS_QUAD_OP | CLOBBER_DEST | USES_CCODES | SETS_CCODES, |
| 517 | "sbcs", "r!0d, r!1d, r!2d", 2), |
| 518 | ENCODING_MAP(THUMB2_CMP_RR, 0xebb00f00, |
| 519 | BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, UNUSED, -1, -1, |
| 520 | IS_TERTIARY_OP | SETS_CCODES, |
| 521 | "cmp", "r!0d, r!1d", 2), |
| 522 | ENCODING_MAP(THUMB2_SUB_RRI12, 0xf2a00000, |
| 523 | BITBLT, 11, 8, BITBLT, 19, 16, IMM12, -1, -1, UNUSED, -1, -1, |
| 524 | IS_TERTIARY_OP | CLOBBER_DEST,/* Note: doesn't affect flags */ |
| 525 | "sub", "r!0d,r!1d,#!2d", 2), |
| 526 | ENCODING_MAP(THUMB2_MVN_IMM_SHIFT, 0xf06f0000, /* no setflags encoding */ |
| 527 | BITBLT, 11, 8, MODIMM, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| 528 | IS_BINARY_OP | CLOBBER_DEST, |
| 529 | "mvn", "r!0d, #!1n", 2), |
| 530 | ENCODING_MAP(THUMB2_SEL, 0xfaa0f080, |
| 531 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, UNUSED, -1, -1, |
| 532 | IS_TERTIARY_OP | CLOBBER_DEST | USES_CCODES, |
| 533 | "sel", "r!0d, r!1d, r!2d", 2), |
| 534 | ENCODING_MAP(THUMB2_UBFX, 0xf3c00000, |
| 535 | BITBLT, 11, 8, BITBLT, 19, 16, LSB, -1, -1, BWIDTH, 4, 0, |
| 536 | IS_QUAD_OP | CLOBBER_DEST, |
| 537 | "ubfx", "r!0d, r!1d, #!2d, #!3d", 2), |
| 538 | ENCODING_MAP(THUMB2_SBFX, 0xf3400000, |
| 539 | BITBLT, 11, 8, BITBLT, 19, 16, LSB, -1, -1, BWIDTH, 4, 0, |
| 540 | IS_QUAD_OP | CLOBBER_DEST, |
| 541 | "sbfx", "r!0d, r!1d, #!2d, #!3d", 2), |
| 542 | ENCODING_MAP(THUMB2_LDR_RRR, 0xf8500000, |
| 543 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 3, 0, BITBLT, 5, 4, |
| 544 | IS_QUAD_OP | CLOBBER_DEST, |
| 545 | "ldr", "r!0d,[r!1d, r!2d, LSL #!3d]", 2), |
| 546 | ENCODING_MAP(THUMB2_LDRH_RRR, 0xf8300000, |
| 547 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 3, 0, BITBLT, 5, 4, |
| 548 | IS_QUAD_OP | CLOBBER_DEST, |
| 549 | "ldrh", "r!0d,[r!1d, r!2d, LSL #!3d]", 2), |
| 550 | ENCODING_MAP(THUMB2_LDRSH_RRR, 0xf9300000, |
| 551 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 3, 0, BITBLT, 5, 4, |
| 552 | IS_QUAD_OP | CLOBBER_DEST, |
| 553 | "ldrsh", "r!0d,[r!1d, r!2d, LSL #!3d]", 2), |
| 554 | ENCODING_MAP(THUMB2_LDRB_RRR, 0xf8100000, |
| 555 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 3, 0, BITBLT, 5, 4, |
| 556 | IS_QUAD_OP | CLOBBER_DEST, |
| 557 | "ldrb", "r!0d,[r!1d, r!2d, LSL #!3d]", 2), |
| 558 | ENCODING_MAP(THUMB2_LDRSB_RRR, 0xf9100000, |
| 559 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 3, 0, BITBLT, 5, 4, |
| 560 | IS_QUAD_OP | CLOBBER_DEST, |
| 561 | "ldrsb", "r!0d,[r!1d, r!2d, LSL #!3d]", 2), |
| 562 | ENCODING_MAP(THUMB2_STR_RRR, 0xf8400000, |
| 563 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 3, 0, BITBLT, 5, 4, |
| 564 | IS_QUAD_OP | CLOBBER_DEST, |
| 565 | "str", "r!0d,[r!1d, r!2d, LSL #!3d]", 2), |
| 566 | ENCODING_MAP(THUMB2_STRH_RRR, 0xf8200000, |
| 567 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 3, 0, BITBLT, 5, 4, |
| 568 | IS_QUAD_OP | CLOBBER_DEST, |
| 569 | "strh", "r!0d,[r!1d, r!2d, LSL #!3d]", 2), |
| 570 | ENCODING_MAP(THUMB2_STRB_RRR, 0xf8000000, |
| 571 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 3, 0, BITBLT, 5, 4, |
| 572 | IS_QUAD_OP | CLOBBER_DEST, |
| 573 | "strb", "r!0d,[r!1d, r!2d, LSL #!3d]", 2), |
| 574 | ENCODING_MAP(THUMB2_LDRH_RRI12, 0xf8b00000, |
| 575 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 11, 0, UNUSED, -1, -1, |
| 576 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 577 | "ldrh", "r!0d,[r!1d, #!2d", 2), |
| 578 | ENCODING_MAP(THUMB2_LDRSH_RRI12, 0xf9b00000, |
| 579 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 11, 0, UNUSED, -1, -1, |
| 580 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 581 | "ldrsh", "r!0d,[r!1d, #!2d", 2), |
| 582 | ENCODING_MAP(THUMB2_LDRB_RRI12, 0xf8900000, |
| 583 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 11, 0, UNUSED, -1, -1, |
| 584 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 585 | "ldrb", "r!0d,[r!1d, #!2d", 2), |
| 586 | ENCODING_MAP(THUMB2_LDRSB_RRI12, 0xf9900000, |
| 587 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 11, 0, UNUSED, -1, -1, |
| 588 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 589 | "ldrsb", "r!0d,[r!1d, #!2d", 2), |
| 590 | ENCODING_MAP(THUMB2_STRH_RRI12, 0xf8a00000, |
| 591 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 11, 0, UNUSED, -1, -1, |
| 592 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 593 | "strh", "r!0d,[r!1d, #!2d", 2), |
| 594 | ENCODING_MAP(THUMB2_STRB_RRI12, 0xf8800000, |
| 595 | BITBLT, 15, 12, BITBLT, 19, 16, BITBLT, 11, 0, UNUSED, -1, -1, |
| 596 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 597 | "strb", "r!0d,[r!1d, #!2d", 2), |
| 598 | ENCODING_MAP(THUMB2_POP, 0xe8bd0000, |
| 599 | BITBLT, 15, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| 600 | IS_UNARY_OP, |
| 601 | "pop", "<!0R>", 2), |
| 602 | ENCODING_MAP(THUMB2_PUSH, 0xe8ad0000, |
| 603 | BITBLT, 15, 0, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| 604 | IS_UNARY_OP, |
| 605 | "push", "<!0R>", 2), |
| 606 | ENCODING_MAP(THUMB2_CMP_RI8, 0xf1b00f00, |
| 607 | BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| 608 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 609 | "cmp", "r!0d, #!1m", 2), |
| 610 | ENCODING_MAP(THUMB2_ADC_RRR, 0xeb500000, /* setflags encoding */ |
| 611 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, |
| 612 | IS_QUAD_OP | CLOBBER_DEST | SETS_CCODES, |
| 613 | "acds", "r!0d, r!1d, r!2d, shift !3d", 2), |
| 614 | ENCODING_MAP(THUMB2_AND_RRR, 0xea000000, |
| 615 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, |
| 616 | IS_QUAD_OP | CLOBBER_DEST, |
| 617 | "and", "r!0d, r!1d, r!2d, shift !3d", 2), |
| 618 | ENCODING_MAP(THUMB2_BIC_RRR, 0xea200000, |
| 619 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, |
| 620 | IS_QUAD_OP | CLOBBER_DEST, |
| 621 | "bic", "r!0d, r!1d, r!2d, shift !3d", 2), |
| 622 | ENCODING_MAP(THUMB2_CMN_RR, 0xeb000000, |
| 623 | BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, UNUSED, -1, -1, |
| 624 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 625 | "cmn", "r!0d, r!1d, shift !2d", 2), |
| 626 | ENCODING_MAP(THUMB2_EOR_RRR, 0xea800000, |
| 627 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, |
| 628 | IS_QUAD_OP | CLOBBER_DEST, |
| 629 | "eor", "r!0d, r!1d, r!2d, shift !3d", 2), |
| 630 | ENCODING_MAP(THUMB2_MUL_RRR, 0xfb00f000, |
| 631 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, UNUSED, -1, -1, |
| 632 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 633 | "mul", "r!0d, r!1d, r!2d", 2), |
| 634 | ENCODING_MAP(THUMB2_MVN_RR, 0xea6f0000, |
| 635 | BITBLT, 11, 8, BITBLT, 3, 0, SHIFT, -1, -1, UNUSED, -1, -1, |
| 636 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 637 | "mvn", "r!0d, r!1d, shift !2d", 2), |
| 638 | ENCODING_MAP(THUMB2_RSUB_RRI8, 0xf1d00000, |
| 639 | BITBLT, 11, 8, BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, |
| 640 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 641 | "rsb", "r!0d,r!1d,#!2m", 2), |
| 642 | ENCODING_MAP(THUMB2_NEG_RR, 0xf1d00000, /* instance of rsub */ |
| 643 | BITBLT, 11, 8, BITBLT, 19, 16, UNUSED, -1, -1, UNUSED, -1, -1, |
| 644 | IS_BINARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 645 | "neg", "r!0d,r!1d", 2), |
| 646 | ENCODING_MAP(THUMB2_ORR_RRR, 0xea400000, |
| 647 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, |
| 648 | IS_QUAD_OP | CLOBBER_DEST, |
| 649 | "orr", "r!0d, r!1d, r!2d, shift !3d", 2), |
| 650 | ENCODING_MAP(THUMB2_TST_RR, 0xea100f00, |
| 651 | BITBLT, 19, 16, BITBLT, 3, 0, SHIFT, -1, -1, UNUSED, -1, -1, |
| 652 | IS_TERTIARY_OP | SETS_CCODES, |
| 653 | "tst", "r!0d, r!1d, shift !2d", 2), |
| 654 | ENCODING_MAP(THUMB2_LSLV_RRR, 0xfa00f000, |
| 655 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, UNUSED, -1, -1, |
| 656 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 657 | "lsl", "r!0d, r!1d, r!2d", 2), |
| 658 | ENCODING_MAP(THUMB2_LSRV_RRR, 0xfa20f000, |
| 659 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, UNUSED, -1, -1, |
| 660 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 661 | "lsr", "r!0d, r!1d, r!2d", 2), |
| 662 | ENCODING_MAP(THUMB2_ASRV_RRR, 0xfa40f000, |
| 663 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, UNUSED, -1, -1, |
| 664 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 665 | "asr", "r!0d, r!1d, r!2d", 2), |
| 666 | ENCODING_MAP(THUMB2_RORV_RRR, 0xfa60f000, |
| 667 | BITBLT, 11, 8, BITBLT, 19, 16, BITBLT, 3, 0, UNUSED, -1, -1, |
| 668 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 669 | "ror", "r!0d, r!1d, r!2d", 2), |
| 670 | ENCODING_MAP(THUMB2_LSL_RRI5, 0xea4f0000, |
| 671 | BITBLT, 11, 8, BITBLT, 3, 0, SHIFT5, -1, -1, UNUSED, -1, -1, |
| 672 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 673 | "lsl", "r!0d, r!1d, #!2d", 2), |
| 674 | ENCODING_MAP(THUMB2_LSR_RRI5, 0xea4f0010, |
| 675 | BITBLT, 11, 8, BITBLT, 3, 0, SHIFT5, -1, -1, UNUSED, -1, -1, |
| 676 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 677 | "lsr", "r!0d, r!1d, #!2d", 2), |
| 678 | ENCODING_MAP(THUMB2_ASR_RRI5, 0xea4f0020, |
| 679 | BITBLT, 11, 8, BITBLT, 3, 0, SHIFT5, -1, -1, UNUSED, -1, -1, |
| 680 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 681 | "asr", "r!0d, r!1d, #!2d", 2), |
| 682 | ENCODING_MAP(THUMB2_ROR_RRI5, 0xea4f0030, |
| 683 | BITBLT, 11, 8, BITBLT, 3, 0, SHIFT5, -1, -1, UNUSED, -1, -1, |
| 684 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 685 | "ror", "r!0d, r!1d, #!2d", 2), |
| 686 | ENCODING_MAP(THUMB2_BIC_RRI8, 0xf0200000, |
| 687 | BITBLT, 11, 8, BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, |
| 688 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 689 | "bic", "r!0d, r!1d, #!2m", 2), |
| 690 | ENCODING_MAP(THUMB2_AND_RRI8, 0xf0000000, |
| 691 | BITBLT, 11, 8, BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, |
| 692 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 693 | "and", "r!0d, r!1d, #!2m", 2), |
| 694 | ENCODING_MAP(THUMB2_ORR_RRI8, 0xf0400000, |
| 695 | BITBLT, 11, 8, BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, |
| 696 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 697 | "orr", "r!0d, r!1d, #!2m", 2), |
| 698 | ENCODING_MAP(THUMB2_EOR_RRI8, 0xf0800000, |
| 699 | BITBLT, 11, 8, BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, |
| 700 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 701 | "eor", "r!0d, r!1d, #!2m", 2), |
| 702 | ENCODING_MAP(THUMB2_ADD_RRI8, 0xf1100000, |
| 703 | BITBLT, 11, 8, BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, |
| 704 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 705 | "adds", "r!0d, r!1d, #!2m", 2), |
| 706 | ENCODING_MAP(THUMB2_ADC_RRI8, 0xf1500000, |
| 707 | BITBLT, 11, 8, BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, |
| 708 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES | USES_CCODES, |
| 709 | "adcs", "r!0d, r!1d, #!2m", 2), |
| 710 | ENCODING_MAP(THUMB2_SUB_RRI8, 0xf1b00000, |
| 711 | BITBLT, 11, 8, BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, |
| 712 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES, |
| 713 | "subs", "r!0d, r!1d, #!2m", 2), |
| 714 | ENCODING_MAP(THUMB2_SBC_RRI8, 0xf1700000, |
| 715 | BITBLT, 11, 8, BITBLT, 19, 16, MODIMM, -1, -1, UNUSED, -1, -1, |
| 716 | IS_TERTIARY_OP | CLOBBER_DEST | SETS_CCODES | USES_CCODES, |
| 717 | "sbcs", "r!0d, r!1d, #!2m", 2), |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 718 | ENCODING_MAP(THUMB2_IT, 0xbf00, |
| 719 | BITBLT, 7, 4, BITBLT, 3, 0, MODIMM, -1, -1, UNUSED, -1, -1, |
| 720 | IS_BINARY_OP | USES_CCODES, |
| 721 | "it:!1b", "!0c", 1), |
| 722 | ENCODING_MAP(THUMB2_FMSTAT, 0xeef1fa10, |
| 723 | UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, UNUSED, -1, -1, |
| 724 | NO_OPERAND | SETS_CCODES, |
| 725 | "fmstat", "", 2), |
| 726 | ENCODING_MAP(THUMB2_VCMPED, 0xeeb40bc0, |
| 727 | DFP, 22, 12, DFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| 728 | IS_BINARY_OP, |
| 729 | "vcmpe.f64", "!0S, !1S", 2), |
| 730 | ENCODING_MAP(THUMB2_VCMPES, 0xeeb40ac0, |
| 731 | SFP, 22, 12, SFP, 5, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| 732 | IS_BINARY_OP, |
| 733 | "vcmpe.f32", "!0s, !1s", 2), |
| 734 | ENCODING_MAP(THUMB2_LDR_PC_REL12, 0xf8df0000, |
| 735 | BITBLT, 15, 12, BITBLT, 11, 0, UNUSED, -1, -1, UNUSED, -1, -1, |
| 736 | IS_TERTIARY_OP | CLOBBER_DEST, |
| 737 | "ldr", "r!0d,[rpc, #!1d", 2), |
| 738 | ENCODING_MAP(THUMB2_B_COND, 0xf0008000, |
| 739 | BROFFSET, -1, -1, BITBLT, 25, 22, UNUSED, -1, -1, UNUSED, -1, -1, |
| 740 | IS_BINARY_OP | IS_BRANCH | USES_CCODES, |
| 741 | "b!1c", "!0t", 2), |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 742 | }; |
| 743 | |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 744 | |
| Ben Cheng | 6d57609 | 2009-09-01 17:01:58 -0700 | [diff] [blame^] | 745 | /* |
| 746 | * The fake NOP of moving r0 to r0 actually will incur data stalls if r0 is |
| 747 | * not ready. Since r5 (rFP) is not updated often, it is less likely to |
| 748 | * generate unnecessary stall cycles. |
| 749 | */ |
| 750 | #define PADDING_MOV_R5_R5 0x1C2D |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 751 | |
| 752 | /* Write the numbers in the literal pool to the codegen stream */ |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 753 | static void installDataContent(CompilationUnit *cUnit) |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 754 | { |
| Ben Cheng | e80cd94 | 2009-07-17 15:54:23 -0700 | [diff] [blame] | 755 | int *dataPtr = (int *) ((char *) cUnit->baseAddr + cUnit->dataOffset); |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 756 | ArmLIR *dataLIR = (ArmLIR *) cUnit->wordList; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 757 | while (dataLIR) { |
| 758 | *dataPtr++ = dataLIR->operands[0]; |
| 759 | dataLIR = NEXT_LIR(dataLIR); |
| 760 | } |
| 761 | } |
| 762 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 763 | /* Returns the size of a Jit trace description */ |
| 764 | static int jitTraceDescriptionSize(const JitTraceDescription *desc) |
| 765 | { |
| 766 | int runCount; |
| 767 | for (runCount = 0; ; runCount++) { |
| 768 | if (desc->trace[runCount].frag.runEnd) |
| 769 | break; |
| 770 | } |
| 771 | return sizeof(JitCodeDesc) + ((runCount+1) * sizeof(JitTraceRun)); |
| 772 | } |
| 773 | |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 774 | /* Return TRUE if error happens */ |
| 775 | static bool assembleInstructions(CompilationUnit *cUnit, intptr_t startAddr) |
| 776 | { |
| 777 | short *bufferAddr = (short *) cUnit->codeBuffer; |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 778 | ArmLIR *lir; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 779 | |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 780 | for (lir = (ArmLIR *) cUnit->firstLIRInsn; lir; lir = NEXT_LIR(lir)) { |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 781 | if (lir->opCode < 0) { |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 782 | if ((lir->opCode == ARM_PSEUDO_ALIGN4) && |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 783 | /* 1 means padding is needed */ |
| 784 | (lir->operands[0] == 1)) { |
| Ben Cheng | 6d57609 | 2009-09-01 17:01:58 -0700 | [diff] [blame^] | 785 | *bufferAddr++ = PADDING_MOV_R5_R5; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 786 | } |
| 787 | continue; |
| 788 | } |
| 789 | |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 790 | if (lir->isNop) { |
| 791 | continue; |
| 792 | } |
| 793 | |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 794 | if (lir->opCode == THUMB_LDR_PC_REL || |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 795 | lir->opCode == THUMB2_LDR_PC_REL12 || |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 796 | lir->opCode == THUMB_ADD_PC_REL) { |
| 797 | ArmLIR *lirTarget = (ArmLIR *) lir->generic.target; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 798 | intptr_t pc = (lir->generic.offset + 4) & ~3; |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 799 | /* |
| 800 | * Allow an offset (stored in operands[2] to be added to the |
| 801 | * PC-relative target. Useful to get to a fixed field inside a |
| 802 | * chaining cell. |
| 803 | */ |
| 804 | intptr_t target = lirTarget->generic.offset + lir->operands[2]; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 805 | int delta = target - pc; |
| 806 | if (delta & 0x3) { |
| 807 | LOGE("PC-rel distance is not multiples of 4: %d\n", delta); |
| 808 | dvmAbort(); |
| 809 | } |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 810 | if ((lir->opCode == THUMB2_LDR_PC_REL12) && (delta > 4091)) { |
| 811 | return true; |
| 812 | } else if (delta > 1020) { |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 813 | return true; |
| 814 | } |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 815 | lir->operands[1] = (lir->opCode == THUMB2_LDR_PC_REL12) ? delta : delta >> 2; |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 816 | } else if (lir->opCode == THUMB2_CBNZ || lir->opCode == THUMB2_CBZ) { |
| 817 | ArmLIR *targetLIR = (ArmLIR *) lir->generic.target; |
| 818 | intptr_t pc = lir->generic.offset + 4; |
| 819 | intptr_t target = targetLIR->generic.offset; |
| 820 | int delta = target - pc; |
| 821 | if (delta > 126 || delta < 0) { |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 822 | /* |
| 823 | * TODO: allow multiple kinds of assembler failure to allow us to |
| 824 | * change code patterns when things don't fit. |
| 825 | */ |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 826 | return true; |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 827 | } else { |
| 828 | lir->operands[1] = delta >> 1; |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 829 | } |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 830 | } else if (lir->opCode == THUMB_B_COND || |
| 831 | lir->opCode == THUMB2_B_COND) { |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 832 | ArmLIR *targetLIR = (ArmLIR *) lir->generic.target; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 833 | intptr_t pc = lir->generic.offset + 4; |
| 834 | intptr_t target = targetLIR->generic.offset; |
| 835 | int delta = target - pc; |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 836 | if ((lir->opCode == THUMB_B_COND) && (delta > 254 || delta < -256)) { |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 837 | return true; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 838 | } |
| 839 | lir->operands[0] = delta >> 1; |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 840 | } else if (lir->opCode == THUMB_B_UNCOND) { |
| 841 | ArmLIR *targetLIR = (ArmLIR *) lir->generic.target; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 842 | intptr_t pc = lir->generic.offset + 4; |
| 843 | intptr_t target = targetLIR->generic.offset; |
| 844 | int delta = target - pc; |
| 845 | if (delta > 2046 || delta < -2048) { |
| 846 | LOGE("Unconditional branch distance out of range: %d\n", delta); |
| 847 | dvmAbort(); |
| 848 | } |
| 849 | lir->operands[0] = delta >> 1; |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 850 | } else if (lir->opCode == THUMB_BLX_1) { |
| 851 | assert(NEXT_LIR(lir)->opCode == THUMB_BLX_2); |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 852 | /* curPC is Thumb */ |
| 853 | intptr_t curPC = (startAddr + lir->generic.offset + 4) & ~3; |
| 854 | intptr_t target = lir->operands[1]; |
| 855 | |
| 856 | /* Match bit[1] in target with base */ |
| 857 | if (curPC & 0x2) { |
| 858 | target |= 0x2; |
| 859 | } |
| 860 | int delta = target - curPC; |
| 861 | assert((delta >= -(1<<22)) && (delta <= ((1<<22)-2))); |
| 862 | |
| 863 | lir->operands[0] = (delta >> 12) & 0x7ff; |
| 864 | NEXT_LIR(lir)->operands[0] = (delta>> 1) & 0x7ff; |
| 865 | } |
| 866 | |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 867 | ArmEncodingMap *encoder = &EncodingMap[lir->opCode]; |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 868 | u4 bits = encoder->skeleton; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 869 | int i; |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 870 | for (i = 0; i < 4; i++) { |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 871 | u4 operand; |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 872 | u4 value; |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 873 | operand = lir->operands[i]; |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 874 | switch(encoder->fieldLoc[i].kind) { |
| 875 | case UNUSED: |
| 876 | break; |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 877 | case BROFFSET: |
| 878 | value = ((operand & 0x80000) >> 19) << 26; |
| 879 | value |= ((operand & 0x40000) >> 18) << 11; |
| 880 | value |= ((operand & 0x20000) >> 17) << 13; |
| 881 | value |= ((operand & 0x1f800) >> 11) << 16; |
| 882 | value |= (operand & 0x007ff); |
| 883 | break; |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 884 | case SHIFT5: |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 885 | value = ((operand & 0x1c) >> 2) << 12; |
| 886 | value |= (operand & 0x03) << 6; |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 887 | bits |= value; |
| 888 | break; |
| 889 | case SHIFT: |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 890 | value = ((operand & 0x70) >> 4) << 12; |
| 891 | value |= (operand & 0x0f) << 4; |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 892 | bits |= value; |
| 893 | break; |
| 894 | case BWIDTH: |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 895 | value = operand - 1; |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 896 | bits |= value; |
| 897 | break; |
| 898 | case LSB: |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 899 | value = ((operand & 0x1c) >> 2) << 12; |
| 900 | value |= (operand & 0x03) << 6; |
| Bill Buzbee | 270c1d6 | 2009-08-13 16:58:07 -0700 | [diff] [blame] | 901 | bits |= value; |
| 902 | break; |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 903 | case IMM6: |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 904 | value = ((operand & 0x20) >> 5) << 9; |
| 905 | value |= (operand & 0x1f) << 3; |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 906 | bits |= value; |
| 907 | break; |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 908 | case BITBLT: |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 909 | value = (operand << encoder->fieldLoc[i].start) & |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 910 | ((1 << (encoder->fieldLoc[i].end + 1)) - 1); |
| 911 | bits |= value; |
| 912 | break; |
| 913 | case DFP: |
| 914 | /* Snag the 1-bit slice and position it */ |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 915 | value = ((operand & 0x10) >> 4) << |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 916 | encoder->fieldLoc[i].end; |
| 917 | /* Extract and position the 4-bit slice */ |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 918 | value |= (operand & 0x0f) << |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 919 | encoder->fieldLoc[i].start; |
| 920 | bits |= value; |
| 921 | break; |
| 922 | case SFP: |
| 923 | /* Snag the 1-bit slice and position it */ |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 924 | value = (operand & 0x1) << |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 925 | encoder->fieldLoc[i].end; |
| 926 | /* Extract and position the 4-bit slice */ |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 927 | value |= ((operand & 0x1e) >> 1) << |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 928 | encoder->fieldLoc[i].start; |
| 929 | bits |= value; |
| 930 | break; |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 931 | case IMM12: |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 932 | case MODIMM: |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 933 | value = ((operand & 0x800) >> 11) << 26; |
| 934 | value |= ((operand & 0x700) >> 8) << 12; |
| 935 | value |= operand & 0x0ff; |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 936 | bits |= value; |
| 937 | break; |
| 938 | case IMM16: |
| Bill Buzbee | a4a7f07 | 2009-08-27 13:58:09 -0700 | [diff] [blame] | 939 | value = ((operand & 0x0800) >> 11) << 26; |
| 940 | value |= ((operand & 0xf000) >> 12) << 16; |
| 941 | value |= ((operand & 0x0700) >> 8) << 12; |
| 942 | value |= operand & 0x0ff; |
| Bill Buzbee | 7ea0f64 | 2009-08-10 17:06:51 -0700 | [diff] [blame] | 943 | bits |= value; |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 944 | break; |
| 945 | default: |
| 946 | assert(0); |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 947 | } |
| 948 | } |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 949 | if (encoder->size == 2) { |
| 950 | *bufferAddr++ = (bits >> 16) & 0xffff; |
| 951 | } |
| 952 | *bufferAddr++ = bits & 0xffff; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 953 | } |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 954 | return false; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | /* |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 958 | * Translation layout in the code cache. Note that the codeAddress pointer |
| 959 | * in JitTable will point directly to the code body (field codeAddress). The |
| 960 | * chain cell offset codeAddress - 2, and (if present) executionCount is at |
| 961 | * codeAddress - 6. |
| 962 | * |
| 963 | * +----------------------------+ |
| 964 | * | Execution count | -> [Optional] 4 bytes |
| 965 | * +----------------------------+ |
| 966 | * +--| Offset to chain cell counts| -> 2 bytes |
| 967 | * | +----------------------------+ |
| 968 | * | | Code body | -> Start address for translation |
| 969 | * | | | variable in 2-byte chunks |
| 970 | * | . . (JitTable's codeAddress points here) |
| 971 | * | . . |
| 972 | * | | | |
| 973 | * | +----------------------------+ |
| 974 | * | | Chaining Cells | -> 8 bytes each, must be 4 byte aligned |
| 975 | * | . . |
| 976 | * | . . |
| 977 | * | | | |
| 978 | * | +----------------------------+ |
| 979 | * +->| Chaining cell counts | -> 4 bytes, chain cell counts by type |
| 980 | * +----------------------------+ |
| 981 | * | Trace description | -> variable sized |
| 982 | * . . |
| 983 | * | | |
| 984 | * +----------------------------+ |
| 985 | * | Literal pool | -> 4-byte aligned, variable size |
| 986 | * . . |
| 987 | * . . |
| 988 | * | | |
| 989 | * +----------------------------+ |
| 990 | * |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 991 | * Go over each instruction in the list and calculate the offset from the top |
| 992 | * before sending them off to the assembler. If out-of-range branch distance is |
| 993 | * seen rearrange the instructions a bit to correct it. |
| 994 | */ |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 995 | void dvmCompilerAssembleLIR(CompilationUnit *cUnit, JitTranslationInfo *info) |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 996 | { |
| 997 | LIR *lir; |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 998 | ArmLIR *armLIR; |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 999 | int offset = 0; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1000 | int i; |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1001 | ChainCellCounts chainCellCounts; |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1002 | int descSize = jitTraceDescriptionSize(cUnit->traceDesc); |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1003 | |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 1004 | info->codeAddress = NULL; |
| 1005 | info->instructionSet = cUnit->instructionSet; |
| 1006 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1007 | /* Beginning offset needs to allow space for chain cell offset */ |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 1008 | for (armLIR = (ArmLIR *) cUnit->firstLIRInsn; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1009 | armLIR; |
| 1010 | armLIR = NEXT_LIR(armLIR)) { |
| 1011 | armLIR->generic.offset = offset; |
| Ben Cheng | e9695e5 | 2009-06-16 16:11:47 -0700 | [diff] [blame] | 1012 | if (armLIR->opCode >= 0 && !armLIR->isNop) { |
| Bill Buzbee | 9bc3df3 | 2009-07-30 10:52:29 -0700 | [diff] [blame] | 1013 | armLIR->size = EncodingMap[armLIR->opCode].size * 2; |
| 1014 | offset += armLIR->size; |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 1015 | } else if (armLIR->opCode == ARM_PSEUDO_ALIGN4) { |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1016 | if (offset & 0x2) { |
| 1017 | offset += 2; |
| 1018 | armLIR->operands[0] = 1; |
| 1019 | } else { |
| 1020 | armLIR->operands[0] = 0; |
| 1021 | } |
| 1022 | } |
| 1023 | /* Pseudo opcodes don't consume space */ |
| 1024 | } |
| 1025 | |
| 1026 | /* Const values have to be word aligned */ |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1027 | offset = (offset + 3) & ~3; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1028 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1029 | /* Add space for chain cell counts & trace description */ |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 1030 | u4 chainCellOffset = offset; |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 1031 | ArmLIR *chainCellOffsetLIR = (ArmLIR *) cUnit->chainCellOffsetLIR; |
| Bill Buzbee | 6e963e1 | 2009-06-17 16:56:19 -0700 | [diff] [blame] | 1032 | assert(chainCellOffsetLIR); |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 1033 | assert(chainCellOffset < 0x10000); |
| Bill Buzbee | 89efc3d | 2009-07-28 11:22:22 -0700 | [diff] [blame] | 1034 | assert(chainCellOffsetLIR->opCode == ARM_16BIT_DATA && |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 1035 | chainCellOffsetLIR->operands[0] == CHAIN_CELL_OFFSET_TAG); |
| 1036 | |
| Ben Cheng | e80cd94 | 2009-07-17 15:54:23 -0700 | [diff] [blame] | 1037 | /* |
| 1038 | * Replace the CHAIN_CELL_OFFSET_TAG with the real value. If trace |
| 1039 | * profiling is enabled, subtract 4 (occupied by the counter word) from |
| 1040 | * the absolute offset as the value stored in chainCellOffsetLIR is the |
| 1041 | * delta from &chainCellOffsetLIR to &ChainCellCounts. |
| 1042 | */ |
| 1043 | chainCellOffsetLIR->operands[0] = |
| 1044 | gDvmJit.profile ? (chainCellOffset - 4) : chainCellOffset; |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 1045 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1046 | offset += sizeof(chainCellCounts) + descSize; |
| 1047 | |
| 1048 | assert((offset & 0x3) == 0); /* Should still be word aligned */ |
| 1049 | |
| 1050 | /* Set up offsets for literals */ |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1051 | cUnit->dataOffset = offset; |
| 1052 | |
| 1053 | for (lir = cUnit->wordList; lir; lir = lir->next) { |
| 1054 | lir->offset = offset; |
| 1055 | offset += 4; |
| 1056 | } |
| 1057 | |
| 1058 | cUnit->totalSize = offset; |
| 1059 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1060 | if (gDvmJit.codeCacheByteUsed + cUnit->totalSize > CODE_CACHE_SIZE) { |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1061 | gDvmJit.codeCacheFull = true; |
| 1062 | cUnit->baseAddr = NULL; |
| 1063 | return; |
| 1064 | } |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1065 | |
| 1066 | /* Allocate enough space for the code block */ |
| 1067 | cUnit->codeBuffer = dvmCompilerNew(chainCellOffset, true); |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1068 | if (cUnit->codeBuffer == NULL) { |
| 1069 | LOGE("Code buffer allocation failure\n"); |
| 1070 | cUnit->baseAddr = NULL; |
| 1071 | return; |
| 1072 | } |
| 1073 | |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 1074 | bool assemblerFailure = assembleInstructions( |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1075 | cUnit, (intptr_t) gDvmJit.codeCache + gDvmJit.codeCacheByteUsed); |
| 1076 | |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 1077 | /* |
| 1078 | * Currently the only reason that can cause the assembler to fail is due to |
| 1079 | * trace length - cut it in half and retry. |
| 1080 | */ |
| 1081 | if (assemblerFailure) { |
| 1082 | cUnit->halveInstCount = true; |
| 1083 | return; |
| 1084 | } |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1085 | |
| Bill Buzbee | 6e963e1 | 2009-06-17 16:56:19 -0700 | [diff] [blame] | 1086 | |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1087 | cUnit->baseAddr = (char *) gDvmJit.codeCache + gDvmJit.codeCacheByteUsed; |
| 1088 | gDvmJit.codeCacheByteUsed += offset; |
| 1089 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1090 | /* Install the code block */ |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 1091 | memcpy((char*)cUnit->baseAddr, cUnit->codeBuffer, chainCellOffset); |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1092 | gDvmJit.numCompilations++; |
| 1093 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1094 | /* Install the chaining cell counts */ |
| 1095 | for (i=0; i< CHAINING_CELL_LAST; i++) { |
| 1096 | chainCellCounts.u.count[i] = cUnit->numChainingCells[i]; |
| 1097 | } |
| 1098 | memcpy((char*)cUnit->baseAddr + chainCellOffset, &chainCellCounts, |
| 1099 | sizeof(chainCellCounts)); |
| 1100 | |
| 1101 | /* Install the trace description */ |
| 1102 | memcpy((char*)cUnit->baseAddr + chainCellOffset + sizeof(chainCellCounts), |
| 1103 | cUnit->traceDesc, descSize); |
| 1104 | |
| 1105 | /* Write the literals directly into the code cache */ |
| 1106 | installDataContent(cUnit); |
| 1107 | |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1108 | /* Flush dcache and invalidate the icache to maintain coherence */ |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1109 | cacheflush((long)cUnit->baseAddr, |
| Ben Cheng | e80cd94 | 2009-07-17 15:54:23 -0700 | [diff] [blame] | 1110 | (long)((char *) cUnit->baseAddr + offset), 0); |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 1111 | |
| 1112 | /* Record code entry point and instruction set */ |
| 1113 | info->codeAddress = (char*)cUnit->baseAddr + cUnit->headerSize; |
| 1114 | info->instructionSet = cUnit->instructionSet; |
| 1115 | /* If applicable, mark low bit to denote thumb */ |
| 1116 | if (info->instructionSet != DALVIK_JIT_ARM) |
| 1117 | info->codeAddress = (char*)info->codeAddress + 1; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1118 | } |
| 1119 | |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1120 | static u4 assembleBXPair(int branchOffset) |
| 1121 | { |
| 1122 | u4 thumb1, thumb2; |
| 1123 | |
| 1124 | if ((branchOffset < -2048) | (branchOffset > 2046)) { |
| 1125 | thumb1 = (0xf000 | ((branchOffset>>12) & 0x7ff)); |
| 1126 | thumb2 = (0xf800 | ((branchOffset>> 1) & 0x7ff)); |
| 1127 | } else { |
| 1128 | thumb1 = (0xe000 | ((branchOffset>> 1) & 0x7ff)); |
| 1129 | thumb2 = 0x4300; /* nop -> or r0, r0 */ |
| 1130 | } |
| 1131 | |
| 1132 | return thumb2<<16 | thumb1; |
| 1133 | } |
| 1134 | |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1135 | /* |
| 1136 | * Perform translation chain operation. |
| 1137 | * For ARM, we'll use a pair of thumb instructions to generate |
| 1138 | * an unconditional chaining branch of up to 4MB in distance. |
| 1139 | * Use a BL, though we don't really need the link. The format is |
| 1140 | * 111HHooooooooooo |
| 1141 | * Where HH is 10 for the 1st inst, and 11 for the second and |
| 1142 | * the "o" field is each instruction's 11-bit contribution to the |
| 1143 | * 22-bit branch offset. |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1144 | * If the target is nearby, use a single-instruction bl. |
| 1145 | * If one or more threads is suspended, don't chain. |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1146 | */ |
| 1147 | void* dvmJitChain(void* tgtAddr, u4* branchAddr) |
| 1148 | { |
| 1149 | int baseAddr = (u4) branchAddr + 4; |
| 1150 | int branchOffset = (int) tgtAddr - baseAddr; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1151 | u4 newInst; |
| 1152 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1153 | if (gDvm.sumThreadSuspendCount == 0) { |
| 1154 | assert((branchOffset >= -(1<<22)) && (branchOffset <= ((1<<22)-2))); |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1155 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1156 | gDvmJit.translationChains++; |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1157 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1158 | COMPILER_TRACE_CHAINING( |
| 1159 | LOGD("Jit Runtime: chaining 0x%x to 0x%x\n", |
| 1160 | (int) branchAddr, (int) tgtAddr & -2)); |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1161 | |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1162 | newInst = assembleBXPair(branchOffset); |
| 1163 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1164 | *branchAddr = newInst; |
| 1165 | cacheflush((long)branchAddr, (long)branchAddr + 4, 0); |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1166 | } |
| 1167 | |
| Ben Cheng | ba4fc8b | 2009-06-01 13:00:29 -0700 | [diff] [blame] | 1168 | return tgtAddr; |
| 1169 | } |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1170 | |
| 1171 | /* |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1172 | * This method is called from the invoke templates for virtual and interface |
| 1173 | * methods to speculatively setup a chain to the callee. The templates are |
| 1174 | * written in assembly and have setup method, cell, and clazz at r0, r2, and |
| 1175 | * r3 respectively, so there is a unused argument in the list. Upon return one |
| 1176 | * of the following three results may happen: |
| 1177 | * 1) Chain is not setup because the callee is native. Reset the rechain |
| 1178 | * count to a big number so that it will take a long time before the next |
| 1179 | * rechain attempt to happen. |
| 1180 | * 2) Chain is not setup because the callee has not been created yet. Reset |
| 1181 | * the rechain count to a small number and retry in the near future. |
| 1182 | * 3) Ask all other threads to stop before patching this chaining cell. |
| 1183 | * This is required because another thread may have passed the class check |
| 1184 | * but hasn't reached the chaining cell yet to follow the chain. If we |
| 1185 | * patch the content before halting the other thread, there could be a |
| 1186 | * small window for race conditions to happen that it may follow the new |
| 1187 | * but wrong chain to invoke a different method. |
| 1188 | */ |
| 1189 | const Method *dvmJitToPatchPredictedChain(const Method *method, |
| 1190 | void *unused, |
| 1191 | PredictedChainingCell *cell, |
| 1192 | const ClassObject *clazz) |
| 1193 | { |
| Jeff Hao | 97319a8 | 2009-08-12 16:57:15 -0700 | [diff] [blame] | 1194 | #if defined(WITH_SELF_VERIFICATION) |
| 1195 | /* Disable chaining and prevent this from triggering again for a while */ |
| 1196 | cell->counter = PREDICTED_CHAIN_COUNTER_AVOID; |
| 1197 | cacheflush((long) cell, (long) (cell+1), 0); |
| 1198 | goto done; |
| 1199 | #else |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1200 | /* Don't come back here for a long time if the method is native */ |
| 1201 | if (dvmIsNativeMethod(method)) { |
| 1202 | cell->counter = PREDICTED_CHAIN_COUNTER_AVOID; |
| 1203 | cacheflush((long) cell, (long) (cell+1), 0); |
| 1204 | COMPILER_TRACE_CHAINING( |
| 1205 | LOGD("Jit Runtime: predicted chain %p to native method %s ignored", |
| 1206 | cell, method->name)); |
| 1207 | goto done; |
| 1208 | } |
| 1209 | int tgtAddr = (int) dvmJitGetCodeAddr(method->insns); |
| 1210 | |
| 1211 | /* |
| 1212 | * Compilation not made yet for the callee. Reset the counter to a small |
| 1213 | * value and come back to check soon. |
| 1214 | */ |
| 1215 | if (tgtAddr == 0) { |
| 1216 | /* |
| 1217 | * Wait for a few invocations (currently set to be 16) before trying |
| 1218 | * to setup the chain again. |
| 1219 | */ |
| 1220 | cell->counter = PREDICTED_CHAIN_COUNTER_DELAY; |
| 1221 | cacheflush((long) cell, (long) (cell+1), 0); |
| 1222 | COMPILER_TRACE_CHAINING( |
| 1223 | LOGD("Jit Runtime: predicted chain %p to method %s delayed", |
| 1224 | cell, method->name)); |
| 1225 | goto done; |
| 1226 | } |
| 1227 | |
| 1228 | /* Stop the world */ |
| 1229 | dvmSuspendAllThreads(SUSPEND_FOR_JIT); |
| 1230 | |
| 1231 | int baseAddr = (int) cell + 4; // PC is cur_addr + 4 |
| 1232 | int branchOffset = tgtAddr - baseAddr; |
| 1233 | |
| 1234 | COMPILER_TRACE_CHAINING( |
| 1235 | LOGD("Jit Runtime: predicted chain %p from %s to %s (%s) patched", |
| 1236 | cell, cell->clazz ? cell->clazz->descriptor : "NULL", |
| 1237 | clazz->descriptor, |
| 1238 | method->name)); |
| 1239 | |
| 1240 | cell->branch = assembleBXPair(branchOffset); |
| 1241 | cell->clazz = clazz; |
| 1242 | cell->method = method; |
| 1243 | cell->counter = PREDICTED_CHAIN_COUNTER_RECHAIN; |
| 1244 | |
| 1245 | cacheflush((long) cell, (long) (cell+1), 0); |
| 1246 | |
| 1247 | /* All done - resume all other threads */ |
| 1248 | dvmResumeAllThreads(SUSPEND_FOR_JIT); |
| Jeff Hao | 97319a8 | 2009-08-12 16:57:15 -0700 | [diff] [blame] | 1249 | #endif |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1250 | |
| 1251 | done: |
| 1252 | return method; |
| 1253 | } |
| 1254 | |
| 1255 | /* |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1256 | * Unchain a trace given the starting address of the translation |
| 1257 | * in the code cache. Refer to the diagram in dvmCompilerAssembleLIR. |
| 1258 | * Returns the address following the last cell unchained. Note that |
| 1259 | * the incoming codeAddr is a thumb code address, and therefore has |
| 1260 | * the low bit set. |
| 1261 | */ |
| 1262 | u4* dvmJitUnchain(void* codeAddr) |
| 1263 | { |
| 1264 | u2* pChainCellOffset = (u2*)((char*)codeAddr - 3); |
| 1265 | u2 chainCellOffset = *pChainCellOffset; |
| 1266 | ChainCellCounts *pChainCellCounts = |
| Ben Cheng | e80cd94 | 2009-07-17 15:54:23 -0700 | [diff] [blame] | 1267 | (ChainCellCounts*)((char*)codeAddr + chainCellOffset - 3); |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1268 | int cellSize; |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1269 | u4* pChainCells; |
| 1270 | u4* pStart; |
| 1271 | u4 thumb1; |
| 1272 | u4 thumb2; |
| 1273 | u4 newInst; |
| 1274 | int i,j; |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1275 | PredictedChainingCell *predChainCell; |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1276 | |
| 1277 | /* Get total count of chain cells */ |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1278 | for (i = 0, cellSize = 0; i < CHAINING_CELL_LAST; i++) { |
| 1279 | if (i != CHAINING_CELL_INVOKE_PREDICTED) { |
| 1280 | cellSize += pChainCellCounts->u.count[i] * 2; |
| 1281 | } else { |
| 1282 | cellSize += pChainCellCounts->u.count[i] * 4; |
| 1283 | } |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1284 | } |
| 1285 | |
| 1286 | /* Locate the beginning of the chain cell region */ |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1287 | pStart = pChainCells = ((u4 *) pChainCellCounts) - cellSize; |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1288 | |
| 1289 | /* The cells are sorted in order - walk through them and reset */ |
| 1290 | for (i = 0; i < CHAINING_CELL_LAST; i++) { |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1291 | int elemSize = 2; /* Most chaining cell has two words */ |
| 1292 | if (i == CHAINING_CELL_INVOKE_PREDICTED) { |
| 1293 | elemSize = 4; |
| 1294 | } |
| 1295 | |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1296 | for (j = 0; j < pChainCellCounts->u.count[i]; j++) { |
| 1297 | int targetOffset; |
| 1298 | switch(i) { |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 1299 | case CHAINING_CELL_NORMAL: |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1300 | targetOffset = offsetof(InterpState, |
| 1301 | jitToInterpEntries.dvmJitToInterpNormal); |
| 1302 | break; |
| Ben Cheng | 1efc9c5 | 2009-06-08 18:25:27 -0700 | [diff] [blame] | 1303 | case CHAINING_CELL_HOT: |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1304 | case CHAINING_CELL_INVOKE_SINGLETON: |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1305 | targetOffset = offsetof(InterpState, |
| 1306 | jitToInterpEntries.dvmJitToTraceSelect); |
| 1307 | break; |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1308 | case CHAINING_CELL_INVOKE_PREDICTED: |
| 1309 | targetOffset = 0; |
| 1310 | predChainCell = (PredictedChainingCell *) pChainCells; |
| 1311 | /* Reset the cell to the init state */ |
| 1312 | predChainCell->branch = PREDICTED_CHAIN_BX_PAIR_INIT; |
| 1313 | predChainCell->clazz = PREDICTED_CHAIN_CLAZZ_INIT; |
| 1314 | predChainCell->method = PREDICTED_CHAIN_METHOD_INIT; |
| 1315 | predChainCell->counter = PREDICTED_CHAIN_COUNTER_INIT; |
| 1316 | break; |
| Jeff Hao | 97319a8 | 2009-08-12 16:57:15 -0700 | [diff] [blame] | 1317 | #if defined(WITH_SELF_VERIFICATION) |
| 1318 | case CHAINING_CELL_BACKWARD_BRANCH: |
| 1319 | targetOffset = offsetof(InterpState, |
| 1320 | jitToInterpEntries.dvmJitToBackwardBranch); |
| 1321 | break; |
| 1322 | #endif |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1323 | default: |
| 1324 | dvmAbort(); |
| 1325 | } |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1326 | COMPILER_TRACE_CHAINING( |
| 1327 | LOGD("Jit Runtime: unchaining 0x%x", (int)pChainCells)); |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1328 | /* |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1329 | * Thumb code sequence for a chaining cell is: |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1330 | * ldr r0, rGLUE, #<word offset> |
| 1331 | * blx r0 |
| 1332 | */ |
| Ben Cheng | 38329f5 | 2009-07-07 14:19:20 -0700 | [diff] [blame] | 1333 | if (i != CHAINING_CELL_INVOKE_PREDICTED) { |
| 1334 | targetOffset = targetOffset >> 2; /* convert to word offset */ |
| 1335 | thumb1 = 0x6800 | (targetOffset << 6) | |
| 1336 | (rGLUE << 3) | (r0 << 0); |
| 1337 | thumb2 = 0x4780 | (r0 << 3); |
| 1338 | newInst = thumb2<<16 | thumb1; |
| 1339 | *pChainCells = newInst; |
| 1340 | } |
| 1341 | pChainCells += elemSize; /* Advance by a fixed number of words */ |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1342 | } |
| 1343 | } |
| 1344 | return pChainCells; |
| 1345 | } |
| 1346 | |
| 1347 | /* Unchain all translation in the cache. */ |
| 1348 | void dvmJitUnchainAll() |
| 1349 | { |
| 1350 | u4* lowAddress = NULL; |
| 1351 | u4* highAddress = NULL; |
| 1352 | unsigned int i; |
| 1353 | if (gDvmJit.pJitEntryTable != NULL) { |
| 1354 | COMPILER_TRACE_CHAINING(LOGD("Jit Runtime: unchaining all")); |
| 1355 | dvmLockMutex(&gDvmJit.tableLock); |
| Bill Buzbee | 2717622 | 2009-06-09 09:20:16 -0700 | [diff] [blame] | 1356 | for (i = 0; i < gDvmJit.jitTableSize; i++) { |
| Bill Buzbee | 46cd5b6 | 2009-06-05 15:36:06 -0700 | [diff] [blame] | 1357 | if (gDvmJit.pJitEntryTable[i].dPC && |
| 1358 | gDvmJit.pJitEntryTable[i].codeAddress) { |
| 1359 | u4* lastAddress; |
| 1360 | lastAddress = |
| 1361 | dvmJitUnchain(gDvmJit.pJitEntryTable[i].codeAddress); |
| 1362 | if (lowAddress == NULL || |
| 1363 | (u4*)gDvmJit.pJitEntryTable[i].codeAddress < lowAddress) |
| 1364 | lowAddress = lastAddress; |
| 1365 | if (lastAddress > highAddress) |
| 1366 | highAddress = lastAddress; |
| 1367 | } |
| 1368 | } |
| 1369 | cacheflush((long)lowAddress, (long)highAddress, 0); |
| 1370 | dvmUnlockMutex(&gDvmJit.tableLock); |
| 1371 | } |
| 1372 | } |
| Bill Buzbee | 716f120 | 2009-07-23 13:22:09 -0700 | [diff] [blame] | 1373 | |
| 1374 | typedef struct jitProfileAddrToLine { |
| 1375 | u4 lineNum; |
| 1376 | u4 bytecodeOffset; |
| 1377 | } jitProfileAddrToLine; |
| 1378 | |
| 1379 | |
| 1380 | /* Callback function to track the bytecode offset/line number relationiship */ |
| 1381 | static int addrToLineCb (void *cnxt, u4 bytecodeOffset, u4 lineNum) |
| 1382 | { |
| 1383 | jitProfileAddrToLine *addrToLine = (jitProfileAddrToLine *) cnxt; |
| 1384 | |
| 1385 | /* Best match so far for this offset */ |
| 1386 | if (addrToLine->bytecodeOffset >= bytecodeOffset) { |
| 1387 | addrToLine->lineNum = lineNum; |
| 1388 | } |
| 1389 | return 0; |
| 1390 | } |
| 1391 | |
| 1392 | char *getTraceBase(const JitEntry *p) |
| 1393 | { |
| 1394 | return (char*)p->codeAddress - |
| 1395 | (6 + (p->u.info.instructionSet == DALVIK_JIT_ARM ? 0 : 1)); |
| 1396 | } |
| 1397 | |
| 1398 | /* Dumps profile info for a single trace */ |
| 1399 | static int dumpTraceProfile(JitEntry *p) |
| 1400 | { |
| 1401 | ChainCellCounts* pCellCounts; |
| 1402 | char* traceBase; |
| 1403 | u4* pExecutionCount; |
| 1404 | u2* pCellOffset; |
| 1405 | JitTraceDescription *desc; |
| 1406 | const Method* method; |
| 1407 | |
| 1408 | traceBase = getTraceBase(p); |
| 1409 | |
| 1410 | if (p->codeAddress == NULL) { |
| 1411 | LOGD("TRACEPROFILE 0x%08x 0 NULL 0 0", (int)traceBase); |
| 1412 | return 0; |
| 1413 | } |
| 1414 | |
| 1415 | pExecutionCount = (u4*) (traceBase); |
| 1416 | pCellOffset = (u2*) (traceBase + 4); |
| 1417 | pCellCounts = (ChainCellCounts*) ((char *)pCellOffset + *pCellOffset); |
| 1418 | desc = (JitTraceDescription*) ((char*)pCellCounts + sizeof(*pCellCounts)); |
| 1419 | method = desc->method; |
| 1420 | char *methodDesc = dexProtoCopyMethodDescriptor(&method->prototype); |
| 1421 | jitProfileAddrToLine addrToLine = {0, desc->trace[0].frag.startOffset}; |
| 1422 | |
| 1423 | /* |
| 1424 | * We may end up decoding the debug information for the same method |
| 1425 | * multiple times, but the tradeoff is we don't need to allocate extra |
| 1426 | * space to store the addr/line mapping. Since this is a debugging feature |
| 1427 | * and done infrequently so the slower but simpler mechanism should work |
| 1428 | * just fine. |
| 1429 | */ |
| 1430 | dexDecodeDebugInfo(method->clazz->pDvmDex->pDexFile, |
| 1431 | dvmGetMethodCode(method), |
| 1432 | method->clazz->descriptor, |
| 1433 | method->prototype.protoIdx, |
| 1434 | method->accessFlags, |
| 1435 | addrToLineCb, NULL, &addrToLine); |
| 1436 | |
| 1437 | LOGD("TRACEPROFILE 0x%08x % 10d [%#x(+%d), %d] %s%s;%s", |
| 1438 | (int)traceBase, |
| 1439 | *pExecutionCount, |
| 1440 | desc->trace[0].frag.startOffset, |
| 1441 | desc->trace[0].frag.numInsts, |
| 1442 | addrToLine.lineNum, |
| 1443 | method->clazz->descriptor, method->name, methodDesc); |
| 1444 | free(methodDesc); |
| 1445 | |
| 1446 | return *pExecutionCount; |
| 1447 | } |
| 1448 | |
| 1449 | /* Handy function to retrieve the profile count */ |
| 1450 | static inline int getProfileCount(const JitEntry *entry) |
| 1451 | { |
| 1452 | if (entry->dPC == 0 || entry->codeAddress == 0) |
| 1453 | return 0; |
| 1454 | u4 *pExecutionCount = (u4 *) getTraceBase(entry); |
| 1455 | |
| 1456 | return *pExecutionCount; |
| 1457 | } |
| 1458 | |
| 1459 | |
| 1460 | /* qsort callback function */ |
| 1461 | static int sortTraceProfileCount(const void *entry1, const void *entry2) |
| 1462 | { |
| 1463 | const JitEntry *jitEntry1 = entry1; |
| 1464 | const JitEntry *jitEntry2 = entry2; |
| 1465 | |
| 1466 | int count1 = getProfileCount(jitEntry1); |
| 1467 | int count2 = getProfileCount(jitEntry2); |
| 1468 | return (count1 == count2) ? 0 : ((count1 > count2) ? -1 : 1); |
| 1469 | } |
| 1470 | |
| 1471 | /* Sort the trace profile counts and dump them */ |
| 1472 | void dvmCompilerSortAndPrintTraceProfiles() |
| 1473 | { |
| 1474 | JitEntry *sortedEntries; |
| 1475 | int numTraces = 0; |
| 1476 | unsigned long counts = 0; |
| 1477 | unsigned int i; |
| 1478 | |
| 1479 | /* Make sure that the table is not changing */ |
| 1480 | dvmLockMutex(&gDvmJit.tableLock); |
| 1481 | |
| 1482 | /* Sort the entries by descending order */ |
| 1483 | sortedEntries = malloc(sizeof(JitEntry) * gDvmJit.jitTableSize); |
| 1484 | if (sortedEntries == NULL) |
| 1485 | goto done; |
| 1486 | memcpy(sortedEntries, gDvmJit.pJitEntryTable, |
| 1487 | sizeof(JitEntry) * gDvmJit.jitTableSize); |
| 1488 | qsort(sortedEntries, gDvmJit.jitTableSize, sizeof(JitEntry), |
| 1489 | sortTraceProfileCount); |
| 1490 | |
| 1491 | /* Dump the sorted entries */ |
| 1492 | for (i=0; i < gDvmJit.jitTableSize; i++) { |
| 1493 | if (sortedEntries[i].dPC != 0) { |
| 1494 | counts += dumpTraceProfile(&sortedEntries[i]); |
| 1495 | numTraces++; |
| 1496 | } |
| 1497 | } |
| 1498 | if (numTraces == 0) |
| 1499 | numTraces = 1; |
| 1500 | LOGD("JIT: Average execution count -> %d",(int)(counts / numTraces)); |
| 1501 | |
| 1502 | free(sortedEntries); |
| 1503 | done: |
| 1504 | dvmUnlockMutex(&gDvmJit.tableLock); |
| 1505 | return; |
| 1506 | } |