fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 1 | # Copyright (C) 2011 Apple Inc. All rights reserved. |
| 2 | # |
| 3 | # Redistribution and use in source and binary forms, with or without |
| 4 | # modification, are permitted provided that the following conditions |
| 5 | # are met: |
| 6 | # 1. Redistributions of source code must retain the above copyright |
| 7 | # notice, this list of conditions and the following disclaimer. |
| 8 | # 2. Redistributions in binary form must reproduce the above copyright |
| 9 | # notice, this list of conditions and the following disclaimer in the |
| 10 | # documentation and/or other materials provided with the distribution. |
| 11 | # |
| 12 | # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 13 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 14 | # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 15 | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 16 | # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 17 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 18 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 19 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 20 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 21 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 22 | # THE POSSIBILITY OF SUCH DAMAGE. |
| 23 | |
commit-queue@webkit.org | 782c20b | 2012-07-14 00:44:47 +0000 | [diff] [blame] | 24 | require "config" |
mhahnenberg@apple.com | 6bf3748 | 2014-02-04 02:08:23 +0000 | [diff] [blame] | 25 | require "set" |
commit-queue@webkit.org | 782c20b | 2012-07-14 00:44:47 +0000 | [diff] [blame] | 26 | |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 27 | # Interesting invariant, which we take advantage of: branching instructions |
| 28 | # always begin with "b", and no non-branching instructions begin with "b". |
| 29 | # Terminal instructions are "jmp" and "ret". |
| 30 | |
| 31 | MACRO_INSTRUCTIONS = |
| 32 | [ |
msaboff@apple.com | 2935ca8 | 2014-08-12 03:20:04 +0000 | [diff] [blame] | 33 | "emit", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 34 | "addi", |
| 35 | "andi", |
| 36 | "lshifti", |
fpizlo@apple.com | 685a420 | 2012-03-11 00:33:20 +0000 | [diff] [blame] | 37 | "lshiftp", |
yuqiang.xian@intel.com | f1431ade | 2012-10-25 05:24:39 +0000 | [diff] [blame] | 38 | "lshiftq", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 39 | "muli", |
| 40 | "negi", |
fpizlo@apple.com | 685a420 | 2012-03-11 00:33:20 +0000 | [diff] [blame] | 41 | "negp", |
yuqiang.xian@intel.com | f1431ade | 2012-10-25 05:24:39 +0000 | [diff] [blame] | 42 | "negq", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 43 | "noti", |
| 44 | "ori", |
| 45 | "rshifti", |
| 46 | "urshifti", |
fpizlo@apple.com | 685a420 | 2012-03-11 00:33:20 +0000 | [diff] [blame] | 47 | "rshiftp", |
| 48 | "urshiftp", |
yuqiang.xian@intel.com | f1431ade | 2012-10-25 05:24:39 +0000 | [diff] [blame] | 49 | "rshiftq", |
| 50 | "urshiftq", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 51 | "subi", |
| 52 | "xori", |
| 53 | "loadi", |
fpizlo@apple.com | 685a420 | 2012-03-11 00:33:20 +0000 | [diff] [blame] | 54 | "loadis", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 55 | "loadb", |
| 56 | "loadbs", |
| 57 | "loadh", |
| 58 | "loadhs", |
| 59 | "storei", |
| 60 | "storeb", |
| 61 | "loadd", |
| 62 | "moved", |
| 63 | "stored", |
| 64 | "addd", |
| 65 | "divd", |
| 66 | "subd", |
| 67 | "muld", |
| 68 | "sqrtd", |
| 69 | "ci2d", |
| 70 | "fii2d", # usage: fii2d <gpr with least significant bits>, <gpr with most significant bits>, <fpr> |
| 71 | "fd2ii", # usage: fd2ii <fpr>, <gpr with least significant bits>, <gpr with most significant bits> |
yuqiang.xian@intel.com | f1431ade | 2012-10-25 05:24:39 +0000 | [diff] [blame] | 72 | "fq2d", |
| 73 | "fd2q", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 74 | "bdeq", |
| 75 | "bdneq", |
| 76 | "bdgt", |
| 77 | "bdgteq", |
| 78 | "bdlt", |
| 79 | "bdlteq", |
| 80 | "bdequn", |
| 81 | "bdnequn", |
| 82 | "bdgtun", |
| 83 | "bdgtequn", |
| 84 | "bdltun", |
| 85 | "bdltequn", |
| 86 | "btd2i", |
| 87 | "td2i", |
| 88 | "bcd2i", |
| 89 | "movdz", |
| 90 | "pop", |
| 91 | "push", |
| 92 | "move", |
yuqiang.xian@intel.com | f1431ade | 2012-10-25 05:24:39 +0000 | [diff] [blame] | 93 | "sxi2q", |
| 94 | "zxi2q", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 95 | "nop", |
| 96 | "bieq", |
| 97 | "bineq", |
| 98 | "bia", |
| 99 | "biaeq", |
| 100 | "bib", |
| 101 | "bibeq", |
| 102 | "bigt", |
| 103 | "bigteq", |
| 104 | "bilt", |
| 105 | "bilteq", |
| 106 | "bbeq", |
| 107 | "bbneq", |
| 108 | "bba", |
| 109 | "bbaeq", |
| 110 | "bbb", |
| 111 | "bbbeq", |
| 112 | "bbgt", |
| 113 | "bbgteq", |
| 114 | "bblt", |
| 115 | "bblteq", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 116 | "btis", |
| 117 | "btiz", |
| 118 | "btinz", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 119 | "btbs", |
| 120 | "btbz", |
| 121 | "btbnz", |
| 122 | "jmp", |
| 123 | "baddio", |
| 124 | "baddis", |
| 125 | "baddiz", |
| 126 | "baddinz", |
| 127 | "bsubio", |
| 128 | "bsubis", |
| 129 | "bsubiz", |
| 130 | "bsubinz", |
| 131 | "bmulio", |
| 132 | "bmulis", |
| 133 | "bmuliz", |
| 134 | "bmulinz", |
| 135 | "borio", |
| 136 | "boris", |
| 137 | "boriz", |
| 138 | "borinz", |
| 139 | "break", |
| 140 | "call", |
| 141 | "ret", |
fpizlo@apple.com | 1d21689 | 2012-04-12 00:55:44 +0000 | [diff] [blame] | 142 | "cbeq", |
| 143 | "cbneq", |
| 144 | "cba", |
| 145 | "cbaeq", |
| 146 | "cbb", |
| 147 | "cbbeq", |
| 148 | "cbgt", |
| 149 | "cbgteq", |
| 150 | "cblt", |
| 151 | "cblteq", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 152 | "cieq", |
| 153 | "cineq", |
| 154 | "cia", |
| 155 | "ciaeq", |
| 156 | "cib", |
| 157 | "cibeq", |
| 158 | "cigt", |
| 159 | "cigteq", |
| 160 | "cilt", |
| 161 | "cilteq", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 162 | "tis", |
| 163 | "tiz", |
| 164 | "tinz", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 165 | "tbs", |
| 166 | "tbz", |
| 167 | "tbnz", |
fpizlo@apple.com | 1d21689 | 2012-04-12 00:55:44 +0000 | [diff] [blame] | 168 | "tps", |
| 169 | "tpz", |
| 170 | "tpnz", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 171 | "peek", |
| 172 | "poke", |
| 173 | "bpeq", |
| 174 | "bpneq", |
| 175 | "bpa", |
| 176 | "bpaeq", |
| 177 | "bpb", |
| 178 | "bpbeq", |
| 179 | "bpgt", |
| 180 | "bpgteq", |
| 181 | "bplt", |
| 182 | "bplteq", |
| 183 | "addp", |
fpizlo@apple.com | 685a420 | 2012-03-11 00:33:20 +0000 | [diff] [blame] | 184 | "mulp", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 185 | "andp", |
| 186 | "orp", |
| 187 | "subp", |
| 188 | "xorp", |
| 189 | "loadp", |
| 190 | "cpeq", |
| 191 | "cpneq", |
| 192 | "cpa", |
| 193 | "cpaeq", |
| 194 | "cpb", |
| 195 | "cpbeq", |
| 196 | "cpgt", |
| 197 | "cpgteq", |
| 198 | "cplt", |
| 199 | "cplteq", |
| 200 | "storep", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 201 | "btps", |
| 202 | "btpz", |
| 203 | "btpnz", |
| 204 | "baddpo", |
| 205 | "baddps", |
| 206 | "baddpz", |
| 207 | "baddpnz", |
yuqiang.xian@intel.com | f1431ade | 2012-10-25 05:24:39 +0000 | [diff] [blame] | 208 | "tqs", |
| 209 | "tqz", |
| 210 | "tqnz", |
yuqiang.xian@intel.com | f1431ade | 2012-10-25 05:24:39 +0000 | [diff] [blame] | 211 | "bqeq", |
| 212 | "bqneq", |
| 213 | "bqa", |
| 214 | "bqaeq", |
| 215 | "bqb", |
| 216 | "bqbeq", |
| 217 | "bqgt", |
| 218 | "bqgteq", |
| 219 | "bqlt", |
| 220 | "bqlteq", |
| 221 | "addq", |
| 222 | "mulq", |
| 223 | "andq", |
| 224 | "orq", |
| 225 | "subq", |
| 226 | "xorq", |
| 227 | "loadq", |
| 228 | "cqeq", |
| 229 | "cqneq", |
| 230 | "cqa", |
| 231 | "cqaeq", |
| 232 | "cqb", |
| 233 | "cqbeq", |
| 234 | "cqgt", |
| 235 | "cqgteq", |
| 236 | "cqlt", |
| 237 | "cqlteq", |
| 238 | "storeq", |
| 239 | "btqs", |
| 240 | "btqz", |
| 241 | "btqnz", |
| 242 | "baddqo", |
| 243 | "baddqs", |
| 244 | "baddqz", |
| 245 | "baddqnz", |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 246 | "bo", |
| 247 | "bs", |
| 248 | "bz", |
| 249 | "bnz", |
| 250 | "leai", |
| 251 | "leap", |
fpizlo@apple.com | 3396171 | 2013-11-20 05:49:05 +0000 | [diff] [blame] | 252 | "memfence" |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 253 | ] |
| 254 | |
| 255 | X86_INSTRUCTIONS = |
| 256 | [ |
| 257 | "cdqi", |
allan.jensen@digia.com | ee0f0dc | 2013-08-15 11:28:55 +0000 | [diff] [blame] | 258 | "idivi" |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 259 | ] |
| 260 | |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 261 | ARM_INSTRUCTIONS = |
| 262 | [ |
ossy@webkit.org | 2f9d50a | 2014-04-20 13:58:25 +0000 | [diff] [blame] | 263 | "clrbp", |
| 264 | "mvlbl" |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 265 | ] |
| 266 | |
msaboff@apple.com | 6175888 | 2013-11-22 01:11:54 +0000 | [diff] [blame] | 267 | ARM64_INSTRUCTIONS = |
| 268 | [ |
commit-queue@webkit.org | 2fe25d1 | 2014-11-04 07:36:15 +0000 | [diff] [blame] | 269 | "pcrtoaddr", # Address from PC relative offset - adr instruction |
| 270 | "nopFixCortexA53Err835769" # nop on Cortex-A53 (nothing otherwise) |
msaboff@apple.com | 6175888 | 2013-11-22 01:11:54 +0000 | [diff] [blame] | 271 | ] |
| 272 | |
dbates@webkit.org | 98f0de0 | 2013-10-15 22:16:39 +0000 | [diff] [blame] | 273 | RISC_INSTRUCTIONS = |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 274 | [ |
dbates@webkit.org | 98f0de0 | 2013-10-15 22:16:39 +0000 | [diff] [blame] | 275 | "smulli", # Multiply two 32-bit words and produce a 64-bit word |
| 276 | "addis", # Add integers and set a flag. |
| 277 | "subis", # Same, but for subtraction. |
| 278 | "oris", # Same, but for bitwise or. |
| 279 | "addps" # addis but for pointers. |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 280 | ] |
| 281 | |
commit-queue@webkit.org | 99609ea | 2013-01-07 19:40:10 +0000 | [diff] [blame] | 282 | MIPS_INSTRUCTIONS = |
| 283 | [ |
commit-queue@webkit.org | 4fb3684 | 2014-09-03 21:50:46 +0000 | [diff] [blame] | 284 | "la", |
commit-queue@webkit.org | 99609ea | 2013-01-07 19:40:10 +0000 | [diff] [blame] | 285 | "movz", |
| 286 | "movn", |
| 287 | "slt", |
| 288 | "sltu", |
commit-queue@webkit.org | 4fb3684 | 2014-09-03 21:50:46 +0000 | [diff] [blame] | 289 | "pichdr" |
commit-queue@webkit.org | 99609ea | 2013-01-07 19:40:10 +0000 | [diff] [blame] | 290 | ] |
| 291 | |
commit-queue@webkit.org | 0486d5d | 2013-04-15 23:04:15 +0000 | [diff] [blame] | 292 | SH4_INSTRUCTIONS = |
| 293 | [ |
julien.brianceau@gmail.com | b05cfba | 2014-04-11 15:55:29 +0000 | [diff] [blame] | 294 | "flushcp", |
| 295 | "alignformova", |
| 296 | "mova", |
commit-queue@webkit.org | 0486d5d | 2013-04-15 23:04:15 +0000 | [diff] [blame] | 297 | "shllx", |
| 298 | "shlrx", |
| 299 | "shld", |
| 300 | "shad", |
| 301 | "bdnan", |
| 302 | "loaddReversedAndIncrementAddress", |
| 303 | "storedReversedAndDecrementAddress", |
| 304 | "ldspr", |
commit-queue@webkit.org | ea3fae7 | 2013-11-14 16:52:48 +0000 | [diff] [blame] | 305 | "stspr", |
| 306 | "setargs" |
commit-queue@webkit.org | 0486d5d | 2013-04-15 23:04:15 +0000 | [diff] [blame] | 307 | ] |
| 308 | |
commit-queue@webkit.org | e13567f | 2012-09-01 17:36:51 +0000 | [diff] [blame] | 309 | CXX_INSTRUCTIONS = |
| 310 | [ |
mhahnenberg@apple.com | 2e704ae | 2014-02-04 00:54:16 +0000 | [diff] [blame] | 311 | "cloopCrash", # no operands |
| 312 | "cloopCallJSFunction", # operands: callee |
| 313 | "cloopCallNative", # operands: callee |
| 314 | "cloopCallSlowPath", # operands: callTarget, currentFrame, currentPC |
| 315 | "cloopCallSlowPathVoid", # operands: callTarget, currentFrame, currentPC |
mark.lam@apple.com | 9cc5df7 | 2012-09-25 00:38:51 +0000 | [diff] [blame] | 316 | |
| 317 | # For debugging only: |
| 318 | # Takes no operands but simply emits whatever follows in // comments as |
| 319 | # a line of C++ code in the generated LLIntAssembly.h file. This can be |
| 320 | # used to insert instrumentation into the interpreter loop to inspect |
| 321 | # variables of interest. Do not leave these instructions in production |
| 322 | # code. |
| 323 | "cloopDo", # no operands |
commit-queue@webkit.org | e13567f | 2012-09-01 17:36:51 +0000 | [diff] [blame] | 324 | ] |
| 325 | |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 326 | INSTRUCTIONS = MACRO_INSTRUCTIONS + X86_INSTRUCTIONS + ARM_INSTRUCTIONS + ARM64_INSTRUCTIONS + RISC_INSTRUCTIONS + MIPS_INSTRUCTIONS + SH4_INSTRUCTIONS + CXX_INSTRUCTIONS |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 327 | |
mhahnenberg@apple.com | 6bf3748 | 2014-02-04 02:08:23 +0000 | [diff] [blame] | 328 | INSTRUCTION_SET = INSTRUCTIONS.to_set |
fpizlo@apple.com | 7bbcaab | 2012-02-22 05:23:19 +0000 | [diff] [blame] | 329 | |
| 330 | def isBranch(instruction) |
| 331 | instruction =~ /^b/ |
| 332 | end |
| 333 | |
| 334 | def hasFallThrough(instruction) |
| 335 | instruction != "ret" and instruction != "jmp" |
| 336 | end |
| 337 | |