uncond.isa revision 7435:62bdb68bb314
16019Shines@cs.fsu.edu// Copyright (c) 2010 ARM Limited
26019Shines@cs.fsu.edu// All rights reserved
310037SARM gem5 Developers//
47101Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall
57101Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual
67101Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating
77101Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software
87101Sgblack@eecs.umich.edu// licensed hereunder.  You may use the software subject to the license
97101Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated
107101Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software,
117101Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form.
127101Sgblack@eecs.umich.edu//
137101Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
147101Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are
156019Shines@cs.fsu.edu// met: redistributions of source code must retain the above copyright
166019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer;
176019Shines@cs.fsu.edu// redistributions in binary form must reproduce the above copyright
186019Shines@cs.fsu.edu// notice, this list of conditions and the following disclaimer in the
196019Shines@cs.fsu.edu// documentation and/or other materials provided with the distribution;
206019Shines@cs.fsu.edu// neither the name of the copyright holders nor the names of its
216019Shines@cs.fsu.edu// contributors may be used to endorse or promote products derived from
226019Shines@cs.fsu.edu// this software without specific prior written permission.
236019Shines@cs.fsu.edu//
246019Shines@cs.fsu.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
256019Shines@cs.fsu.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
266019Shines@cs.fsu.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
276019Shines@cs.fsu.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
286019Shines@cs.fsu.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
296019Shines@cs.fsu.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
306019Shines@cs.fsu.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
316019Shines@cs.fsu.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
326019Shines@cs.fsu.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
336019Shines@cs.fsu.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
346019Shines@cs.fsu.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
356019Shines@cs.fsu.edu//
366019Shines@cs.fsu.edu// Authors: Gabe Black
376019Shines@cs.fsu.edu
386019Shines@cs.fsu.edudef format ArmUnconditional() {{
396019Shines@cs.fsu.edu    decode_block = '''
406019Shines@cs.fsu.edu    {
416019Shines@cs.fsu.edu        const IntRegIndex rn = (IntRegIndex)(uint32_t)bits(machInst, 19, 16);
426019Shines@cs.fsu.edu        const uint32_t op1 = bits(machInst, 27, 20);
436019Shines@cs.fsu.edu        if (bits(op1, 7) == 0) {
446019Shines@cs.fsu.edu            const uint32_t op2 = bits(machInst, 7, 4);
456019Shines@cs.fsu.edu            if (op1 == 0x10) {
466019Shines@cs.fsu.edu                if (bits((uint32_t)rn, 0) == 1 && op2 == 0) {
476019Shines@cs.fsu.edu                    return new Setend(machInst, bits(machInst, 9));
486019Shines@cs.fsu.edu                } else if (bits((uint32_t)rn, 0) == 0 && bits(op2, 1) == 0) {
496268Sgblack@eecs.umich.edu                    const bool enable = bits(machInst, 19, 18) == 0x2;
506251Sgblack@eecs.umich.edu                    const uint32_t mods = bits(machInst, 4, 0) |
516269Sgblack@eecs.umich.edu                                          (bits(machInst, 8, 6) << 5) |
526269Sgblack@eecs.umich.edu                                          (bits(machInst, 17) << 8) |
536749Sgblack@eecs.umich.edu                                          ((enable ? 1 : 0) << 9);
547105Sgblack@eecs.umich.edu                    return new Cps(machInst, mods);
557161Sgblack@eecs.umich.edu                }
566251Sgblack@eecs.umich.edu            } else if (bits(op1, 6, 5) == 0x1) {
576251Sgblack@eecs.umich.edu                return decodeNeonData(machInst);
586251Sgblack@eecs.umich.edu            } else if (bits(op1, 6, 4) == 0x4) {
597105Sgblack@eecs.umich.edu                if (bits(op1, 0) == 0) {
607105Sgblack@eecs.umich.edu                    return decodeNeonMem(machInst);
617105Sgblack@eecs.umich.edu                } else if (bits(op1, 2, 0) == 1) {
627105Sgblack@eecs.umich.edu                    // Unallocated memory hint
636251Sgblack@eecs.umich.edu                    return new NopInst(machInst);
647105Sgblack@eecs.umich.edu                } else if (bits(op1, 2, 0) == 5) {
656268Sgblack@eecs.umich.edu                    const bool add = bits(machInst, 23);
666759SAli.Saidi@ARM.com                    const uint32_t imm12 = bits(machInst, 11, 0);
676251Sgblack@eecs.umich.edu                    if (add) {
687105Sgblack@eecs.umich.edu                        return new %(pli_iadd)s(machInst, INTREG_ZERO,
696251Sgblack@eecs.umich.edu                                                rn, add, imm12);
706019Shines@cs.fsu.edu                    } else {
716267Sgblack@eecs.umich.edu                        return new %(pli_isub)s(machInst, INTREG_ZERO,
726267Sgblack@eecs.umich.edu                                                rn, add, imm12);
736267Sgblack@eecs.umich.edu                    }
747101Sgblack@eecs.umich.edu                }
757101Sgblack@eecs.umich.edu            } else if (bits(op1, 6, 4) == 0x5) {
7610037SARM gem5 Developers                if (bits(op1, 1, 0) == 0x1) {
777101Sgblack@eecs.umich.edu                    const bool add = bits(machInst, 23);
786019Shines@cs.fsu.edu                    const bool pldw = bits(machInst, 22);
796251Sgblack@eecs.umich.edu                    const uint32_t imm12 = bits(machInst, 11, 0);
806251Sgblack@eecs.umich.edu                    if (pldw) {
816251Sgblack@eecs.umich.edu                        if (add) {
826251Sgblack@eecs.umich.edu                            return new %(pldw_iadd)s(machInst, INTREG_ZERO,
837121Sgblack@eecs.umich.edu                                                     rn, add, imm12);
846251Sgblack@eecs.umich.edu                        } else {
856251Sgblack@eecs.umich.edu                            return new %(pldw_isub)s(machInst, INTREG_ZERO,
866251Sgblack@eecs.umich.edu                                                     rn, add, imm12);
876019Shines@cs.fsu.edu                        }
886251Sgblack@eecs.umich.edu                    } else {
896019Shines@cs.fsu.edu                        if (add) {
906275Sgblack@eecs.umich.edu                            return new %(pld_iadd)s(machInst, INTREG_ZERO,
916275Sgblack@eecs.umich.edu                                                    rn, add, imm12);
926275Sgblack@eecs.umich.edu                        } else {
936275Sgblack@eecs.umich.edu                            return new %(pld_isub)s(machInst, INTREG_ZERO,
946275Sgblack@eecs.umich.edu                                                    rn, add, imm12);
956251Sgblack@eecs.umich.edu                        }
966019Shines@cs.fsu.edu                    }
976275Sgblack@eecs.umich.edu                } else if (op1 == 0x57) {
986019Shines@cs.fsu.edu                    switch (op2) {
996275Sgblack@eecs.umich.edu                      case 0x1:
1006019Shines@cs.fsu.edu                        return new WarnUnimplemented("clrex", machInst);
1016251Sgblack@eecs.umich.edu                      case 0x4:
1027121Sgblack@eecs.umich.edu                        return new WarnUnimplemented("dsb", machInst);
1036019Shines@cs.fsu.edu                      case 0x5:
1046251Sgblack@eecs.umich.edu                        return new WarnUnimplemented("dmb", machInst);
1056251Sgblack@eecs.umich.edu                      case 0x6:
1066019Shines@cs.fsu.edu                        return new WarnUnimplemented("isb", machInst);
1076251Sgblack@eecs.umich.edu                    }
1086019Shines@cs.fsu.edu                }
1097105Sgblack@eecs.umich.edu            } else if (bits(op2, 0) == 0) {
1106019Shines@cs.fsu.edu                switch (op1 & 0xf7) {
1117105Sgblack@eecs.umich.edu                  case 0x61:
1127105Sgblack@eecs.umich.edu                    // Unallocated memory hint
1137105Sgblack@eecs.umich.edu                    return new NopInst(machInst);
1146019Shines@cs.fsu.edu                  case 0x65:
1156019Shines@cs.fsu.edu                    {
1167105Sgblack@eecs.umich.edu                        const uint32_t imm5 = bits(machInst, 11, 7);
1177105Sgblack@eecs.umich.edu                        const uint32_t type = bits(machInst, 6, 5);
1187105Sgblack@eecs.umich.edu                        const bool add = bits(machInst, 23);
1196019Shines@cs.fsu.edu                        const IntRegIndex rm =
1206019Shines@cs.fsu.edu                            (IntRegIndex)(uint32_t)bits(machInst, 3, 0);
1216251Sgblack@eecs.umich.edu                        if (add) {
1226019Shines@cs.fsu.edu                            return new %(pli_radd)s(machInst, INTREG_ZERO, rn,
1237106Sgblack@eecs.umich.edu                                                    add, imm5, type, rm);
1247103Sgblack@eecs.umich.edu                        } else {
1257103Sgblack@eecs.umich.edu                            return new %(pli_rsub)s(machInst, INTREG_ZERO, rn,
1267103Sgblack@eecs.umich.edu                                                    add, imm5, type, rm);
1277103Sgblack@eecs.umich.edu                        }
1287103Sgblack@eecs.umich.edu                    }
1297103Sgblack@eecs.umich.edu                  case 0x71:
1307103Sgblack@eecs.umich.edu                  case 0x75:
1317103Sgblack@eecs.umich.edu                    {
1327103Sgblack@eecs.umich.edu                        const uint32_t imm5 = bits(machInst, 11, 7);
1337103Sgblack@eecs.umich.edu                        const uint32_t type = bits(machInst, 6, 5);
1347103Sgblack@eecs.umich.edu                        const bool add = bits(machInst, 23);
1357103Sgblack@eecs.umich.edu                        const bool pldw = bits(machInst, 22);
1367103Sgblack@eecs.umich.edu                        const IntRegIndex rm =
1377103Sgblack@eecs.umich.edu                            (IntRegIndex)(uint32_t)bits(machInst, 3, 0);
1387106Sgblack@eecs.umich.edu                        if (pldw) {
1397106Sgblack@eecs.umich.edu                            if (add) {
1407106Sgblack@eecs.umich.edu                                return new %(pldw_radd)s(machInst, INTREG_ZERO,
1417106Sgblack@eecs.umich.edu                                                         rn, add, imm5,
1427106Sgblack@eecs.umich.edu                                                         type, rm);
1437106Sgblack@eecs.umich.edu                            } else {
1447106Sgblack@eecs.umich.edu                                return new %(pldw_rsub)s(machInst, INTREG_ZERO,
1457106Sgblack@eecs.umich.edu                                                         rn, add, imm5,
1467106Sgblack@eecs.umich.edu                                                         type, rm);
1477106Sgblack@eecs.umich.edu                            }
1487106Sgblack@eecs.umich.edu                        } else {
1497106Sgblack@eecs.umich.edu                            if (add) {
1507113Sgblack@eecs.umich.edu                                return new %(pld_radd)s(machInst, INTREG_ZERO,
1517116Sgblack@eecs.umich.edu                                                        rn, add, imm5,
1527245Sgblack@eecs.umich.edu                                                        type, rm);
1537106Sgblack@eecs.umich.edu                            } else {
1547106Sgblack@eecs.umich.edu                                return new %(pld_rsub)s(machInst, INTREG_ZERO,
1557106Sgblack@eecs.umich.edu                                                        rn, add, imm5,
1567106Sgblack@eecs.umich.edu                                                        type, rm);
1577106Sgblack@eecs.umich.edu                            }
1587106Sgblack@eecs.umich.edu                        }
1597106Sgblack@eecs.umich.edu                    }
1607106Sgblack@eecs.umich.edu                }
1617113Sgblack@eecs.umich.edu            }
1627113Sgblack@eecs.umich.edu        } else {
1637106Sgblack@eecs.umich.edu            switch (bits(machInst, 26, 25)) {
1647106Sgblack@eecs.umich.edu              case 0x0:
1657106Sgblack@eecs.umich.edu                {
1667106Sgblack@eecs.umich.edu                    const uint32_t val = ((machInst >> 20) & 0x5);
1677106Sgblack@eecs.umich.edu                    if (val == 0x4) {
168                        const uint32_t mode = bits(machInst, 4, 0);
169                        switch (bits(machInst, 24, 21)) {
170                          case 0x2:
171                            return new %(srs)s(machInst, mode,
172                                    SrsOp::DecrementAfter, false);
173                          case 0x3:
174                            return new %(srs_w)s(machInst, mode,
175                                    SrsOp::DecrementAfter, true);
176                          case 0x6:
177                            return new %(srs_u)s(machInst, mode,
178                                    SrsOp::IncrementAfter, false);
179                          case 0x7:
180                            return new %(srs_uw)s(machInst, mode,
181                                    SrsOp::IncrementAfter, true);
182                          case 0xa:
183                            return new %(srs_p)s(machInst, mode,
184                                    SrsOp::DecrementBefore, false);
185                          case 0xb:
186                            return new %(srs_pw)s(machInst, mode,
187                                    SrsOp::DecrementBefore, true);
188                          case 0xe:
189                            return new %(srs_pu)s(machInst, mode,
190                                    SrsOp::IncrementBefore, false);
191                          case 0xf:
192                            return new %(srs_puw)s(machInst, mode,
193                                    SrsOp::IncrementBefore, true);
194                        }
195                        return new Unknown(machInst);
196                    } else if (val == 0x1) {
197                        switch (bits(machInst, 24, 21)) {
198                          case 0x0:
199                            return new %(rfe)s(machInst, rn,
200                                    RfeOp::DecrementAfter, false);
201                          case 0x1:
202                            return new %(rfe_w)s(machInst, rn,
203                                    RfeOp::DecrementAfter, true);
204                          case 0x4:
205                            return new %(rfe_u)s(machInst, rn,
206                                    RfeOp::IncrementAfter, false);
207                          case 0x5:
208                            return new %(rfe_uw)s(machInst, rn,
209                                    RfeOp::IncrementAfter, true);
210                          case 0x8:
211                            return new %(rfe_p)s(machInst, rn,
212                                    RfeOp::DecrementBefore, false);
213                          case 0x9:
214                            return new %(rfe_pw)s(machInst, rn,
215                                    RfeOp::DecrementBefore, true);
216                          case 0xc:
217                            return new %(rfe_pu)s(machInst, rn,
218                                    RfeOp::IncrementBefore, false);
219                          case 0xd:
220                            return new %(rfe_puw)s(machInst, rn,
221                                    RfeOp::IncrementBefore, true);
222                        }
223                        return new Unknown(machInst);
224                    }
225                }
226                break;
227              case 0x1:
228                {
229                    const uint32_t imm =
230                        (sext<26>(bits(machInst, 23, 0) << 2)) |
231                        (bits(machInst, 24) << 1);
232                    return new BlxImm(machInst, imm);
233                }
234              case 0x2:
235                if (bits(op1, 4, 0) != 0) {
236                    if (CPNUM == 0xa || CPNUM == 0xb) {
237                        return decodeExtensionRegLoadStore(machInst);
238                    }
239                    if (bits(op1, 0) == 1) {
240                        if (rn == INTREG_PC) {
241                            if (bits(op1, 4, 3) != 0x0) {
242                                return new WarnUnimplemented(
243                                        "ldc, ldc2 (literal)", machInst);
244                            }
245                        } else {
246                            if (op1 == 0xC3 || op1 == 0xC7) {
247                                return new WarnUnimplemented(
248                                        "ldc, ldc2 (immediate)", machInst);
249                            }
250                        }
251                        if (op1 == 0xC5) {
252                            return new WarnUnimplemented(
253                                    "mrrc, mrrc2", machInst);
254                        }
255                    } else {
256                        if (bits(op1, 4, 3) != 0 || bits(op1, 1) == 1) {
257                            return new WarnUnimplemented(
258                                    "stc, stc2", machInst);
259                        } else if (op1 == 0xC4) {
260                            return new WarnUnimplemented(
261                                    "mcrr, mcrrc", machInst);
262                        }
263                    }
264                }
265                break;
266              case 0x3:
267                if (bits(op1, 4) == 0) {
268                    if (CPNUM == 0xa || CPNUM == 0xb) {
269                        return decodeShortFpTransfer(machInst);
270                    } else if (CPNUM == 0xf) {
271                        return decodeMcrMrc15(machInst);
272                    }
273                    const bool op = bits(machInst, 4);
274                    if (op) {
275                        if (bits(op1, 0)) {
276                            return new WarnUnimplemented(
277                                    "mrc, mrc2", machInst);
278                        } else {
279                            return new WarnUnimplemented(
280                                    "mcr, mcr2", machInst);
281                        }
282                    } else {
283                        return new WarnUnimplemented("cdp, cdp2", machInst);
284                    }
285                }
286                break;
287            }
288        }
289        return new Unknown(machInst);
290    }
291    ''' % {
292        "pli_iadd" : "PLI_" + loadImmClassName(False, True, False, 1),
293        "pli_isub" : "PLI_" + loadImmClassName(False, False, False, 1),
294        "pld_iadd" : "PLD_" + loadImmClassName(False, True, False, 1),
295        "pld_isub" : "PLD_" + loadImmClassName(False, False, False, 1),
296        "pldw_iadd" : "PLDW_" + loadImmClassName(False, True, False, 1),
297        "pldw_isub" : "PLDW_" + loadImmClassName(False, False, False, 1),
298        "pli_radd" : "PLI_" + loadRegClassName(False, True, False, 1),
299        "pli_rsub" : "PLI_" + loadRegClassName(False, False, False, 1),
300        "pld_radd" : "PLD_" + loadRegClassName(False, True, False, 1),
301        "pld_rsub" : "PLD_" + loadRegClassName(False, False, False, 1),
302        "pldw_radd" : "PLDW_" + loadRegClassName(False, True, False, 1),
303        "pldw_rsub" : "PLDW_" + loadRegClassName(False, False, False, 1),
304        "rfe" : "RFE_" + loadImmClassName(True, False, False, 8),
305        "rfe_w" : "RFE_" + loadImmClassName(True, False, True, 8),
306        "rfe_u" : "RFE_" + loadImmClassName(True, True, False, 8),
307        "rfe_uw" : "RFE_" + loadImmClassName(True, True, True, 8),
308        "rfe_p" : "RFE_" + loadImmClassName(False, False, False, 8),
309        "rfe_pw" : "RFE_" + loadImmClassName(False, False, True, 8),
310        "rfe_pu" : "RFE_" + loadImmClassName(False, True, False, 8),
311        "rfe_puw" : "RFE_" + loadImmClassName(False, True, True, 8),
312        "srs" : "SRS_" + storeImmClassName(True, False, False, 8),
313        "srs_w" : "SRS_" + storeImmClassName(True, False, True, 8),
314        "srs_u" : "SRS_" + storeImmClassName(True, True, False, 8),
315        "srs_uw" : "SRS_" + storeImmClassName(True, True, True, 8),
316        "srs_p" : "SRS_" + storeImmClassName(False, False, False, 8),
317        "srs_pw" : "SRS_" + storeImmClassName(False, False, True, 8),
318        "srs_pu" : "SRS_" + storeImmClassName(False, True, False, 8),
319        "srs_puw" : "SRS_" + storeImmClassName(False, True, True, 8)
320    };
321}};
322