misc.isa revision 8301
17199Sgblack@eecs.umich.edu// -*- mode:c++ -*-
27199Sgblack@eecs.umich.edu
37199Sgblack@eecs.umich.edu// Copyright (c) 2010 ARM Limited
47199Sgblack@eecs.umich.edu// All rights reserved
57199Sgblack@eecs.umich.edu//
67199Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall
77199Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual
87199Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating
97199Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software
107199Sgblack@eecs.umich.edu// licensed hereunder.  You may use the software subject to the license
117199Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated
127199Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software,
137199Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form.
147199Sgblack@eecs.umich.edu//
157199Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
167199Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are
177199Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright
187199Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
197199Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
207199Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
217199Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution;
227199Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its
237199Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
247199Sgblack@eecs.umich.edu// this software without specific prior written permission.
257199Sgblack@eecs.umich.edu//
267199Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
277199Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
287199Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
297199Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
307199Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
317199Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
327199Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
337199Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
347199Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
357199Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
367199Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
377199Sgblack@eecs.umich.edu//
387199Sgblack@eecs.umich.edu// Authors: Gabe Black
397199Sgblack@eecs.umich.edu
407199Sgblack@eecs.umich.edulet {{
417199Sgblack@eecs.umich.edu
427199Sgblack@eecs.umich.edu    svcCode = '''
437199Sgblack@eecs.umich.edu#if FULL_SYSTEM
447199Sgblack@eecs.umich.edu    fault = new SupervisorCall;
457199Sgblack@eecs.umich.edu#else
467199Sgblack@eecs.umich.edu    fault = new SupervisorCall(machInst);
477199Sgblack@eecs.umich.edu#endif
487199Sgblack@eecs.umich.edu    '''
497199Sgblack@eecs.umich.edu
507199Sgblack@eecs.umich.edu    svcIop = InstObjParams("svc", "Svc", "PredOp",
517199Sgblack@eecs.umich.edu                           { "code": svcCode,
527199Sgblack@eecs.umich.edu                             "predicate_test": predicateTest }, ["IsSyscall"])
537199Sgblack@eecs.umich.edu    header_output = BasicDeclare.subst(svcIop)
547199Sgblack@eecs.umich.edu    decoder_output = BasicConstructor.subst(svcIop)
557199Sgblack@eecs.umich.edu    exec_output = PredOpExecute.subst(svcIop)
567199Sgblack@eecs.umich.edu
577199Sgblack@eecs.umich.edu}};
587202Sgblack@eecs.umich.edu
597202Sgblack@eecs.umich.edulet {{
607202Sgblack@eecs.umich.edu
617202Sgblack@eecs.umich.edu    header_output = decoder_output = exec_output = ""
627202Sgblack@eecs.umich.edu
638301SAli.Saidi@ARM.com    mrsCpsrCode = '''
648301SAli.Saidi@ARM.com        Dest = (Cpsr | CondCodesF | CondCodesQ | CondCodesGE) & 0xF8FF03DF
658301SAli.Saidi@ARM.com    '''
668301SAli.Saidi@ARM.com
677202Sgblack@eecs.umich.edu    mrsCpsrIop = InstObjParams("mrs", "MrsCpsr", "MrsOp",
687202Sgblack@eecs.umich.edu                               { "code": mrsCpsrCode,
697599Sminkyu.jeong@arm.com                                 "predicate_test": condPredicateTest },
707783SGiacomo.Gabrielli@arm.com                               ["IsSerializeBefore"])
717202Sgblack@eecs.umich.edu    header_output += MrsDeclare.subst(mrsCpsrIop)
727202Sgblack@eecs.umich.edu    decoder_output += MrsConstructor.subst(mrsCpsrIop)
737202Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(mrsCpsrIop)
747202Sgblack@eecs.umich.edu
757202Sgblack@eecs.umich.edu    mrsSpsrCode = "Dest = Spsr"
767202Sgblack@eecs.umich.edu    mrsSpsrIop = InstObjParams("mrs", "MrsSpsr", "MrsOp",
777202Sgblack@eecs.umich.edu                               { "code": mrsSpsrCode,
787599Sminkyu.jeong@arm.com                                 "predicate_test": predicateTest },
797783SGiacomo.Gabrielli@arm.com                               ["IsSerializeBefore"])
807202Sgblack@eecs.umich.edu    header_output += MrsDeclare.subst(mrsSpsrIop)
817202Sgblack@eecs.umich.edu    decoder_output += MrsConstructor.subst(mrsSpsrIop)
827202Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(mrsSpsrIop)
837202Sgblack@eecs.umich.edu
847202Sgblack@eecs.umich.edu    msrCpsrRegCode = '''
857400SAli.Saidi@ARM.com        SCTLR sctlr = Sctlr;
867202Sgblack@eecs.umich.edu        uint32_t newCpsr =
878301SAli.Saidi@ARM.com            cpsrWriteByInstr(Cpsr | CondCodesF | CondCodesQ | CondCodesGE, Op1,
888301SAli.Saidi@ARM.com                             byteMask, false, sctlr.nmfi);
897202Sgblack@eecs.umich.edu        Cpsr = ~CondCodesMask & newCpsr;
908301SAli.Saidi@ARM.com        CondCodesF = CondCodesMaskF & newCpsr;
918301SAli.Saidi@ARM.com        CondCodesQ = CondCodesMaskQ & newCpsr;
928301SAli.Saidi@ARM.com        CondCodesGE = CondCodesMaskGE & newCpsr;
937202Sgblack@eecs.umich.edu    '''
947202Sgblack@eecs.umich.edu    msrCpsrRegIop = InstObjParams("msr", "MsrCpsrReg", "MsrRegOp",
957202Sgblack@eecs.umich.edu                                  { "code": msrCpsrRegCode,
967599Sminkyu.jeong@arm.com                                    "predicate_test": condPredicateTest },
977599Sminkyu.jeong@arm.com                                  ["IsSerializeAfter","IsNonSpeculative"])
987202Sgblack@eecs.umich.edu    header_output += MsrRegDeclare.subst(msrCpsrRegIop)
997202Sgblack@eecs.umich.edu    decoder_output += MsrRegConstructor.subst(msrCpsrRegIop)
1007202Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(msrCpsrRegIop)
1017202Sgblack@eecs.umich.edu
1027202Sgblack@eecs.umich.edu    msrSpsrRegCode = "Spsr = spsrWriteByInstr(Spsr, Op1, byteMask, false);"
1037202Sgblack@eecs.umich.edu    msrSpsrRegIop = InstObjParams("msr", "MsrSpsrReg", "MsrRegOp",
1047202Sgblack@eecs.umich.edu                                  { "code": msrSpsrRegCode,
1057599Sminkyu.jeong@arm.com                                    "predicate_test": predicateTest },
1067599Sminkyu.jeong@arm.com                                  ["IsSerializeAfter","IsNonSpeculative"])
1077202Sgblack@eecs.umich.edu    header_output += MsrRegDeclare.subst(msrSpsrRegIop)
1087202Sgblack@eecs.umich.edu    decoder_output += MsrRegConstructor.subst(msrSpsrRegIop)
1097202Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(msrSpsrRegIop)
1107202Sgblack@eecs.umich.edu
1117202Sgblack@eecs.umich.edu    msrCpsrImmCode = '''
1127400SAli.Saidi@ARM.com        SCTLR sctlr = Sctlr;
1137202Sgblack@eecs.umich.edu        uint32_t newCpsr =
1148301SAli.Saidi@ARM.com            cpsrWriteByInstr(Cpsr | CondCodesF | CondCodesQ | CondCodesGE, imm,
1158301SAli.Saidi@ARM.com                             byteMask, false, sctlr.nmfi);
1167202Sgblack@eecs.umich.edu        Cpsr = ~CondCodesMask & newCpsr;
1178301SAli.Saidi@ARM.com        CondCodesF = CondCodesMaskF & newCpsr;
1188301SAli.Saidi@ARM.com        CondCodesQ = CondCodesMaskQ & newCpsr;
1198301SAli.Saidi@ARM.com        CondCodesGE = CondCodesMaskGE & newCpsr;
1207202Sgblack@eecs.umich.edu    '''
1217202Sgblack@eecs.umich.edu    msrCpsrImmIop = InstObjParams("msr", "MsrCpsrImm", "MsrImmOp",
1227202Sgblack@eecs.umich.edu                                  { "code": msrCpsrImmCode,
1237599Sminkyu.jeong@arm.com                                    "predicate_test": condPredicateTest },
1247599Sminkyu.jeong@arm.com                                  ["IsSerializeAfter","IsNonSpeculative"])
1257202Sgblack@eecs.umich.edu    header_output += MsrImmDeclare.subst(msrCpsrImmIop)
1267202Sgblack@eecs.umich.edu    decoder_output += MsrImmConstructor.subst(msrCpsrImmIop)
1277202Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(msrCpsrImmIop)
1287202Sgblack@eecs.umich.edu
1297202Sgblack@eecs.umich.edu    msrSpsrImmCode = "Spsr = spsrWriteByInstr(Spsr, imm, byteMask, false);"
1307202Sgblack@eecs.umich.edu    msrSpsrImmIop = InstObjParams("msr", "MsrSpsrImm", "MsrImmOp",
1317202Sgblack@eecs.umich.edu                                  { "code": msrSpsrImmCode,
1327599Sminkyu.jeong@arm.com                                    "predicate_test": predicateTest },
1337599Sminkyu.jeong@arm.com                                  ["IsSerializeAfter","IsNonSpeculative"])
1347202Sgblack@eecs.umich.edu    header_output += MsrImmDeclare.subst(msrSpsrImmIop)
1357202Sgblack@eecs.umich.edu    decoder_output += MsrImmConstructor.subst(msrSpsrImmIop)
1367202Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(msrSpsrImmIop)
1377209Sgblack@eecs.umich.edu
1387209Sgblack@eecs.umich.edu    revCode = '''
1397209Sgblack@eecs.umich.edu    uint32_t val = Op1;
1407209Sgblack@eecs.umich.edu    Dest = swap_byte(val);
1417209Sgblack@eecs.umich.edu    '''
1427261Sgblack@eecs.umich.edu    revIop = InstObjParams("rev", "Rev", "RegRegOp",
1437209Sgblack@eecs.umich.edu                           { "code": revCode,
1447209Sgblack@eecs.umich.edu                             "predicate_test": predicateTest }, [])
1457261Sgblack@eecs.umich.edu    header_output += RegRegOpDeclare.subst(revIop)
1467261Sgblack@eecs.umich.edu    decoder_output += RegRegOpConstructor.subst(revIop)
1477209Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(revIop)
1487209Sgblack@eecs.umich.edu
1497209Sgblack@eecs.umich.edu    rev16Code = '''
1507209Sgblack@eecs.umich.edu    uint32_t val = Op1;
1517209Sgblack@eecs.umich.edu    Dest = (bits(val, 15, 8) << 0) |
1527209Sgblack@eecs.umich.edu           (bits(val, 7, 0) << 8) |
1537209Sgblack@eecs.umich.edu           (bits(val, 31, 24) << 16) |
1547209Sgblack@eecs.umich.edu           (bits(val, 23, 16) << 24);
1557209Sgblack@eecs.umich.edu    '''
1567261Sgblack@eecs.umich.edu    rev16Iop = InstObjParams("rev16", "Rev16", "RegRegOp",
1577209Sgblack@eecs.umich.edu                             { "code": rev16Code,
1587209Sgblack@eecs.umich.edu                               "predicate_test": predicateTest }, [])
1597261Sgblack@eecs.umich.edu    header_output += RegRegOpDeclare.subst(rev16Iop)
1607261Sgblack@eecs.umich.edu    decoder_output += RegRegOpConstructor.subst(rev16Iop)
1617209Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(rev16Iop)
1627209Sgblack@eecs.umich.edu
1637209Sgblack@eecs.umich.edu    revshCode = '''
1647209Sgblack@eecs.umich.edu    uint16_t val = Op1;
1657209Sgblack@eecs.umich.edu    Dest = sext<16>(swap_byte(val));
1667209Sgblack@eecs.umich.edu    '''
1677261Sgblack@eecs.umich.edu    revshIop = InstObjParams("revsh", "Revsh", "RegRegOp",
1687209Sgblack@eecs.umich.edu                             { "code": revshCode,
1697209Sgblack@eecs.umich.edu                               "predicate_test": predicateTest }, [])
1707261Sgblack@eecs.umich.edu    header_output += RegRegOpDeclare.subst(revshIop)
1717261Sgblack@eecs.umich.edu    decoder_output += RegRegOpConstructor.subst(revshIop)
1727209Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(revshIop)
1737226Sgblack@eecs.umich.edu
1747249Sgblack@eecs.umich.edu    rbitCode = '''
1757249Sgblack@eecs.umich.edu    uint8_t *opBytes = (uint8_t *)&Op1;
1767249Sgblack@eecs.umich.edu    uint32_t resTemp;
1777249Sgblack@eecs.umich.edu    uint8_t *destBytes = (uint8_t *)&resTemp;
1787249Sgblack@eecs.umich.edu    // This reverses the bytes and bits of the input, or so says the
1797249Sgblack@eecs.umich.edu    // internet.
1807249Sgblack@eecs.umich.edu    for (int i = 0; i < 4; i++) {
1817249Sgblack@eecs.umich.edu        uint32_t temp = opBytes[i];
1827249Sgblack@eecs.umich.edu        temp = (temp * 0x0802 & 0x22110) | (temp * 0x8020 & 0x88440);
1837249Sgblack@eecs.umich.edu        destBytes[3 - i] = (temp * 0x10101) >> 16;
1847249Sgblack@eecs.umich.edu    }
1857249Sgblack@eecs.umich.edu    Dest = resTemp;
1867249Sgblack@eecs.umich.edu    '''
1877261Sgblack@eecs.umich.edu    rbitIop = InstObjParams("rbit", "Rbit", "RegRegOp",
1887249Sgblack@eecs.umich.edu                            { "code": rbitCode,
1897249Sgblack@eecs.umich.edu                              "predicate_test": predicateTest }, [])
1907261Sgblack@eecs.umich.edu    header_output += RegRegOpDeclare.subst(rbitIop)
1917261Sgblack@eecs.umich.edu    decoder_output += RegRegOpConstructor.subst(rbitIop)
1927249Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(rbitIop)
1937249Sgblack@eecs.umich.edu
1947251Sgblack@eecs.umich.edu    clzCode = '''
1957251Sgblack@eecs.umich.edu        Dest = (Op1 == 0) ? 32 : (31 - findMsbSet(Op1));
1967251Sgblack@eecs.umich.edu    '''
1977261Sgblack@eecs.umich.edu    clzIop = InstObjParams("clz", "Clz", "RegRegOp",
1987251Sgblack@eecs.umich.edu                           { "code": clzCode,
1997251Sgblack@eecs.umich.edu                             "predicate_test": predicateTest }, [])
2007261Sgblack@eecs.umich.edu    header_output += RegRegOpDeclare.subst(clzIop)
2017261Sgblack@eecs.umich.edu    decoder_output += RegRegOpConstructor.subst(clzIop)
2027251Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(clzIop)
2037251Sgblack@eecs.umich.edu
2047226Sgblack@eecs.umich.edu    ssatCode = '''
2057226Sgblack@eecs.umich.edu        int32_t operand = shift_rm_imm(Op1, shiftAmt, shiftType, 0);
2067226Sgblack@eecs.umich.edu        int32_t res;
2077232Sgblack@eecs.umich.edu        if (satInt(res, operand, imm))
2088301SAli.Saidi@ARM.com            CondCodesQ = CondCodesQ | (1 << 27);
2097226Sgblack@eecs.umich.edu        else
2108301SAli.Saidi@ARM.com            CondCodesQ = CondCodesQ;
2117226Sgblack@eecs.umich.edu        Dest = res;
2127226Sgblack@eecs.umich.edu    '''
2137232Sgblack@eecs.umich.edu    ssatIop = InstObjParams("ssat", "Ssat", "RegImmRegShiftOp",
2147226Sgblack@eecs.umich.edu                            { "code": ssatCode,
2157422Sgblack@eecs.umich.edu                              "predicate_test": condPredicateTest }, [])
2167232Sgblack@eecs.umich.edu    header_output += RegImmRegShiftOpDeclare.subst(ssatIop)
2177232Sgblack@eecs.umich.edu    decoder_output += RegImmRegShiftOpConstructor.subst(ssatIop)
2187226Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(ssatIop)
2197226Sgblack@eecs.umich.edu
2207226Sgblack@eecs.umich.edu    usatCode = '''
2217226Sgblack@eecs.umich.edu        int32_t operand = shift_rm_imm(Op1, shiftAmt, shiftType, 0);
2227226Sgblack@eecs.umich.edu        int32_t res;
2237232Sgblack@eecs.umich.edu        if (uSatInt(res, operand, imm))
2248301SAli.Saidi@ARM.com            CondCodesQ = CondCodesQ | (1 << 27);
2257226Sgblack@eecs.umich.edu        else
2268301SAli.Saidi@ARM.com            CondCodesQ = CondCodesQ;
2277226Sgblack@eecs.umich.edu        Dest = res;
2287226Sgblack@eecs.umich.edu    '''
2297232Sgblack@eecs.umich.edu    usatIop = InstObjParams("usat", "Usat", "RegImmRegShiftOp",
2307226Sgblack@eecs.umich.edu                            { "code": usatCode,
2317422Sgblack@eecs.umich.edu                              "predicate_test": condPredicateTest }, [])
2327232Sgblack@eecs.umich.edu    header_output += RegImmRegShiftOpDeclare.subst(usatIop)
2337232Sgblack@eecs.umich.edu    decoder_output += RegImmRegShiftOpConstructor.subst(usatIop)
2347226Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(usatIop)
2357226Sgblack@eecs.umich.edu
2367226Sgblack@eecs.umich.edu    ssat16Code = '''
2377226Sgblack@eecs.umich.edu        int32_t res;
2387226Sgblack@eecs.umich.edu        uint32_t resTemp = 0;
2398301SAli.Saidi@ARM.com        CondCodesQ = CondCodesQ;
2407226Sgblack@eecs.umich.edu        int32_t argLow = sext<16>(bits(Op1, 15, 0));
2417226Sgblack@eecs.umich.edu        int32_t argHigh = sext<16>(bits(Op1, 31, 16));
2427232Sgblack@eecs.umich.edu        if (satInt(res, argLow, imm))
2438301SAli.Saidi@ARM.com            CondCodesQ = CondCodesQ | (1 << 27);
2447226Sgblack@eecs.umich.edu        replaceBits(resTemp, 15, 0, res);
2457232Sgblack@eecs.umich.edu        if (satInt(res, argHigh, imm))
2468301SAli.Saidi@ARM.com            CondCodesQ = CondCodesQ | (1 << 27);
2477226Sgblack@eecs.umich.edu        replaceBits(resTemp, 31, 16, res);
2487226Sgblack@eecs.umich.edu        Dest = resTemp;
2497226Sgblack@eecs.umich.edu    '''
2507232Sgblack@eecs.umich.edu    ssat16Iop = InstObjParams("ssat16", "Ssat16", "RegImmRegOp",
2517226Sgblack@eecs.umich.edu                              { "code": ssat16Code,
2527422Sgblack@eecs.umich.edu                                "predicate_test": condPredicateTest }, [])
2537232Sgblack@eecs.umich.edu    header_output += RegImmRegOpDeclare.subst(ssat16Iop)
2547232Sgblack@eecs.umich.edu    decoder_output += RegImmRegOpConstructor.subst(ssat16Iop)
2557226Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(ssat16Iop)
2567226Sgblack@eecs.umich.edu
2577226Sgblack@eecs.umich.edu    usat16Code = '''
2587226Sgblack@eecs.umich.edu        int32_t res;
2597226Sgblack@eecs.umich.edu        uint32_t resTemp = 0;
2608301SAli.Saidi@ARM.com        CondCodesQ = CondCodesQ;
2617226Sgblack@eecs.umich.edu        int32_t argLow = sext<16>(bits(Op1, 15, 0));
2627226Sgblack@eecs.umich.edu        int32_t argHigh = sext<16>(bits(Op1, 31, 16));
2637232Sgblack@eecs.umich.edu        if (uSatInt(res, argLow, imm))
2648301SAli.Saidi@ARM.com            CondCodesQ = CondCodesQ | (1 << 27);
2657226Sgblack@eecs.umich.edu        replaceBits(resTemp, 15, 0, res);
2667232Sgblack@eecs.umich.edu        if (uSatInt(res, argHigh, imm))
2678301SAli.Saidi@ARM.com            CondCodesQ = CondCodesQ | (1 << 27);
2687226Sgblack@eecs.umich.edu        replaceBits(resTemp, 31, 16, res);
2697226Sgblack@eecs.umich.edu        Dest = resTemp;
2707226Sgblack@eecs.umich.edu    '''
2717232Sgblack@eecs.umich.edu    usat16Iop = InstObjParams("usat16", "Usat16", "RegImmRegOp",
2727226Sgblack@eecs.umich.edu                              { "code": usat16Code,
2737422Sgblack@eecs.umich.edu                                "predicate_test": condPredicateTest }, [])
2747232Sgblack@eecs.umich.edu    header_output += RegImmRegOpDeclare.subst(usat16Iop)
2757232Sgblack@eecs.umich.edu    decoder_output += RegImmRegOpConstructor.subst(usat16Iop)
2767226Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(usat16Iop)
2777234Sgblack@eecs.umich.edu
2787234Sgblack@eecs.umich.edu    sxtbIop = InstObjParams("sxtb", "Sxtb", "RegImmRegOp",
2797234Sgblack@eecs.umich.edu                            { "code":
2807234Sgblack@eecs.umich.edu                              "Dest = sext<8>((uint8_t)(Op1.ud >> imm));",
2817234Sgblack@eecs.umich.edu                              "predicate_test": predicateTest }, [])
2827234Sgblack@eecs.umich.edu    header_output += RegImmRegOpDeclare.subst(sxtbIop)
2837234Sgblack@eecs.umich.edu    decoder_output += RegImmRegOpConstructor.subst(sxtbIop)
2847234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(sxtbIop)
2857234Sgblack@eecs.umich.edu
2867234Sgblack@eecs.umich.edu    sxtabIop = InstObjParams("sxtab", "Sxtab", "RegRegRegImmOp",
2877234Sgblack@eecs.umich.edu                             { "code":
2887234Sgblack@eecs.umich.edu                               '''
2897234Sgblack@eecs.umich.edu                                   Dest = sext<8>((uint8_t)(Op2.ud >> imm)) +
2907234Sgblack@eecs.umich.edu                                          Op1;
2917234Sgblack@eecs.umich.edu                               ''',
2927234Sgblack@eecs.umich.edu                               "predicate_test": predicateTest }, [])
2937234Sgblack@eecs.umich.edu    header_output += RegRegRegImmOpDeclare.subst(sxtabIop)
2947234Sgblack@eecs.umich.edu    decoder_output += RegRegRegImmOpConstructor.subst(sxtabIop)
2957234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(sxtabIop)
2967234Sgblack@eecs.umich.edu
2977234Sgblack@eecs.umich.edu    sxtb16Code = '''
2987234Sgblack@eecs.umich.edu    uint32_t resTemp = 0;
2997234Sgblack@eecs.umich.edu    replaceBits(resTemp, 15, 0, sext<8>(bits(Op1, imm + 7, imm)));
3007234Sgblack@eecs.umich.edu    replaceBits(resTemp, 31, 16,
3017234Sgblack@eecs.umich.edu                sext<8>(bits(Op1, (imm + 23) % 32, (imm + 16) % 32)));
3027234Sgblack@eecs.umich.edu    Dest = resTemp;
3037234Sgblack@eecs.umich.edu    '''
3047234Sgblack@eecs.umich.edu    sxtb16Iop = InstObjParams("sxtb16", "Sxtb16", "RegImmRegOp",
3057234Sgblack@eecs.umich.edu                              { "code": sxtb16Code,
3067234Sgblack@eecs.umich.edu                                "predicate_test": predicateTest }, [])
3077234Sgblack@eecs.umich.edu    header_output += RegImmRegOpDeclare.subst(sxtb16Iop)
3087234Sgblack@eecs.umich.edu    decoder_output += RegImmRegOpConstructor.subst(sxtb16Iop)
3097234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(sxtb16Iop)
3107234Sgblack@eecs.umich.edu
3117234Sgblack@eecs.umich.edu    sxtab16Code = '''
3127234Sgblack@eecs.umich.edu    uint32_t resTemp = 0;
3137234Sgblack@eecs.umich.edu    replaceBits(resTemp, 15, 0, sext<8>(bits(Op2, imm + 7, imm)) +
3147234Sgblack@eecs.umich.edu                                        bits(Op1, 15, 0));
3157234Sgblack@eecs.umich.edu    replaceBits(resTemp, 31, 16,
3167234Sgblack@eecs.umich.edu                sext<8>(bits(Op2, (imm + 23) % 32, (imm + 16) % 32)) +
3177234Sgblack@eecs.umich.edu                bits(Op1, 31, 16));
3187234Sgblack@eecs.umich.edu    Dest = resTemp;
3197234Sgblack@eecs.umich.edu    '''
3207234Sgblack@eecs.umich.edu    sxtab16Iop = InstObjParams("sxtab16", "Sxtab16", "RegRegRegImmOp",
3217234Sgblack@eecs.umich.edu                               { "code": sxtab16Code,
3227234Sgblack@eecs.umich.edu                                 "predicate_test": predicateTest }, [])
3237234Sgblack@eecs.umich.edu    header_output += RegRegRegImmOpDeclare.subst(sxtab16Iop)
3247234Sgblack@eecs.umich.edu    decoder_output += RegRegRegImmOpConstructor.subst(sxtab16Iop)
3257234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(sxtab16Iop)
3267234Sgblack@eecs.umich.edu
3277234Sgblack@eecs.umich.edu    sxthCode = '''
3287234Sgblack@eecs.umich.edu    uint64_t rotated = (uint32_t)Op1;
3297234Sgblack@eecs.umich.edu    rotated = (rotated | (rotated << 32)) >> imm;
3307234Sgblack@eecs.umich.edu    Dest = sext<16>((uint16_t)rotated);
3317234Sgblack@eecs.umich.edu    '''
3327234Sgblack@eecs.umich.edu    sxthIop = InstObjParams("sxth", "Sxth", "RegImmRegOp",
3337234Sgblack@eecs.umich.edu                              { "code": sxthCode,
3347234Sgblack@eecs.umich.edu                                "predicate_test": predicateTest }, [])
3357234Sgblack@eecs.umich.edu    header_output += RegImmRegOpDeclare.subst(sxthIop)
3367234Sgblack@eecs.umich.edu    decoder_output += RegImmRegOpConstructor.subst(sxthIop)
3377234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(sxthIop)
3387234Sgblack@eecs.umich.edu
3397234Sgblack@eecs.umich.edu    sxtahCode = '''
3407234Sgblack@eecs.umich.edu    uint64_t rotated = (uint32_t)Op2;
3417234Sgblack@eecs.umich.edu    rotated = (rotated | (rotated << 32)) >> imm;
3427234Sgblack@eecs.umich.edu    Dest = sext<16>((uint16_t)rotated) + Op1;
3437234Sgblack@eecs.umich.edu    '''
3447234Sgblack@eecs.umich.edu    sxtahIop = InstObjParams("sxtah", "Sxtah", "RegRegRegImmOp",
3457234Sgblack@eecs.umich.edu                             { "code": sxtahCode,
3467234Sgblack@eecs.umich.edu                               "predicate_test": predicateTest }, [])
3477234Sgblack@eecs.umich.edu    header_output += RegRegRegImmOpDeclare.subst(sxtahIop)
3487234Sgblack@eecs.umich.edu    decoder_output += RegRegRegImmOpConstructor.subst(sxtahIop)
3497234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(sxtahIop)
3507234Sgblack@eecs.umich.edu
3517234Sgblack@eecs.umich.edu    uxtbIop = InstObjParams("uxtb", "Uxtb", "RegImmRegOp",
3527234Sgblack@eecs.umich.edu                            { "code": "Dest = (uint8_t)(Op1.ud >> imm);",
3537234Sgblack@eecs.umich.edu                              "predicate_test": predicateTest }, [])
3547234Sgblack@eecs.umich.edu    header_output += RegImmRegOpDeclare.subst(uxtbIop)
3557234Sgblack@eecs.umich.edu    decoder_output += RegImmRegOpConstructor.subst(uxtbIop)
3567234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(uxtbIop)
3577234Sgblack@eecs.umich.edu
3587234Sgblack@eecs.umich.edu    uxtabIop = InstObjParams("uxtab", "Uxtab", "RegRegRegImmOp",
3597234Sgblack@eecs.umich.edu                             { "code":
3607234Sgblack@eecs.umich.edu                               "Dest = (uint8_t)(Op2.ud >> imm) + Op1;",
3617234Sgblack@eecs.umich.edu                               "predicate_test": predicateTest }, [])
3627234Sgblack@eecs.umich.edu    header_output += RegRegRegImmOpDeclare.subst(uxtabIop)
3637234Sgblack@eecs.umich.edu    decoder_output += RegRegRegImmOpConstructor.subst(uxtabIop)
3647234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(uxtabIop)
3657234Sgblack@eecs.umich.edu
3667234Sgblack@eecs.umich.edu    uxtb16Code = '''
3677234Sgblack@eecs.umich.edu    uint32_t resTemp = 0;
3687234Sgblack@eecs.umich.edu    replaceBits(resTemp, 15, 0, (uint8_t)(bits(Op1, imm + 7, imm)));
3697234Sgblack@eecs.umich.edu    replaceBits(resTemp, 31, 16,
3707234Sgblack@eecs.umich.edu                (uint8_t)(bits(Op1, (imm + 23) % 32, (imm + 16) % 32)));
3717234Sgblack@eecs.umich.edu    Dest = resTemp;
3727234Sgblack@eecs.umich.edu    '''
3737234Sgblack@eecs.umich.edu    uxtb16Iop = InstObjParams("uxtb16", "Uxtb16", "RegImmRegOp",
3747234Sgblack@eecs.umich.edu                              { "code": uxtb16Code,
3757234Sgblack@eecs.umich.edu                                "predicate_test": predicateTest }, [])
3767234Sgblack@eecs.umich.edu    header_output += RegImmRegOpDeclare.subst(uxtb16Iop)
3777234Sgblack@eecs.umich.edu    decoder_output += RegImmRegOpConstructor.subst(uxtb16Iop)
3787234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(uxtb16Iop)
3797234Sgblack@eecs.umich.edu
3807234Sgblack@eecs.umich.edu    uxtab16Code = '''
3817234Sgblack@eecs.umich.edu    uint32_t resTemp = 0;
3827234Sgblack@eecs.umich.edu    replaceBits(resTemp, 15, 0, (uint8_t)(bits(Op2, imm + 7, imm)) +
3837234Sgblack@eecs.umich.edu                                        bits(Op1, 15, 0));
3847234Sgblack@eecs.umich.edu    replaceBits(resTemp, 31, 16,
3857234Sgblack@eecs.umich.edu                (uint8_t)(bits(Op2, (imm + 23) % 32, (imm + 16) % 32)) +
3867234Sgblack@eecs.umich.edu                bits(Op1, 31, 16));
3877234Sgblack@eecs.umich.edu    Dest = resTemp;
3887234Sgblack@eecs.umich.edu    '''
3897234Sgblack@eecs.umich.edu    uxtab16Iop = InstObjParams("uxtab16", "Uxtab16", "RegRegRegImmOp",
3907234Sgblack@eecs.umich.edu                               { "code": uxtab16Code,
3917234Sgblack@eecs.umich.edu                                 "predicate_test": predicateTest }, [])
3927234Sgblack@eecs.umich.edu    header_output += RegRegRegImmOpDeclare.subst(uxtab16Iop)
3937234Sgblack@eecs.umich.edu    decoder_output += RegRegRegImmOpConstructor.subst(uxtab16Iop)
3947234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(uxtab16Iop)
3957234Sgblack@eecs.umich.edu
3967234Sgblack@eecs.umich.edu    uxthCode = '''
3977234Sgblack@eecs.umich.edu    uint64_t rotated = (uint32_t)Op1;
3987234Sgblack@eecs.umich.edu    rotated = (rotated | (rotated << 32)) >> imm;
3997234Sgblack@eecs.umich.edu    Dest = (uint16_t)rotated;
4007234Sgblack@eecs.umich.edu    '''
4017234Sgblack@eecs.umich.edu    uxthIop = InstObjParams("uxth", "Uxth", "RegImmRegOp",
4027234Sgblack@eecs.umich.edu                              { "code": uxthCode,
4037234Sgblack@eecs.umich.edu                                "predicate_test": predicateTest }, [])
4047234Sgblack@eecs.umich.edu    header_output += RegImmRegOpDeclare.subst(uxthIop)
4057234Sgblack@eecs.umich.edu    decoder_output += RegImmRegOpConstructor.subst(uxthIop)
4067234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(uxthIop)
4077234Sgblack@eecs.umich.edu
4087234Sgblack@eecs.umich.edu    uxtahCode = '''
4097234Sgblack@eecs.umich.edu    uint64_t rotated = (uint32_t)Op2;
4107234Sgblack@eecs.umich.edu    rotated = (rotated | (rotated << 32)) >> imm;
4117234Sgblack@eecs.umich.edu    Dest = (uint16_t)rotated + Op1;
4127234Sgblack@eecs.umich.edu    '''
4137234Sgblack@eecs.umich.edu    uxtahIop = InstObjParams("uxtah", "Uxtah", "RegRegRegImmOp",
4147234Sgblack@eecs.umich.edu                             { "code": uxtahCode,
4157234Sgblack@eecs.umich.edu                               "predicate_test": predicateTest }, [])
4167234Sgblack@eecs.umich.edu    header_output += RegRegRegImmOpDeclare.subst(uxtahIop)
4177234Sgblack@eecs.umich.edu    decoder_output += RegRegRegImmOpConstructor.subst(uxtahIop)
4187234Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(uxtahIop)
4197239Sgblack@eecs.umich.edu
4207239Sgblack@eecs.umich.edu    selCode = '''
4217239Sgblack@eecs.umich.edu        uint32_t resTemp = 0;
4227239Sgblack@eecs.umich.edu        for (unsigned i = 0; i < 4; i++) {
4237239Sgblack@eecs.umich.edu            int low = i * 8;
4247239Sgblack@eecs.umich.edu            int high = low + 7;
4257239Sgblack@eecs.umich.edu            replaceBits(resTemp, high, low,
4268301SAli.Saidi@ARM.com                        bits(CondCodesGE, 16 + i) ?
4277239Sgblack@eecs.umich.edu                            bits(Op1, high, low) : bits(Op2, high, low));
4287239Sgblack@eecs.umich.edu        }
4297239Sgblack@eecs.umich.edu        Dest = resTemp;
4307239Sgblack@eecs.umich.edu    '''
4317239Sgblack@eecs.umich.edu    selIop = InstObjParams("sel", "Sel", "RegRegRegOp",
4327239Sgblack@eecs.umich.edu                           { "code": selCode,
4337422Sgblack@eecs.umich.edu                             "predicate_test": condPredicateTest }, [])
4347239Sgblack@eecs.umich.edu    header_output += RegRegRegOpDeclare.subst(selIop)
4357239Sgblack@eecs.umich.edu    decoder_output += RegRegRegOpConstructor.subst(selIop)
4367239Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(selIop)
4377242Sgblack@eecs.umich.edu
4387242Sgblack@eecs.umich.edu    usad8Code = '''
4397242Sgblack@eecs.umich.edu        uint32_t resTemp = 0;
4407242Sgblack@eecs.umich.edu        for (unsigned i = 0; i < 4; i++) {
4417242Sgblack@eecs.umich.edu            int low = i * 8;
4427242Sgblack@eecs.umich.edu            int high = low + 7;
4437242Sgblack@eecs.umich.edu            int32_t diff = bits(Op1, high, low) -
4447242Sgblack@eecs.umich.edu                           bits(Op2, high, low);
4457242Sgblack@eecs.umich.edu            resTemp += ((diff < 0) ? -diff : diff);
4467242Sgblack@eecs.umich.edu        }
4477242Sgblack@eecs.umich.edu        Dest = resTemp;
4487242Sgblack@eecs.umich.edu    '''
4497242Sgblack@eecs.umich.edu    usad8Iop = InstObjParams("usad8", "Usad8", "RegRegRegOp",
4507242Sgblack@eecs.umich.edu                             { "code": usad8Code,
4517242Sgblack@eecs.umich.edu                               "predicate_test": predicateTest }, [])
4527242Sgblack@eecs.umich.edu    header_output += RegRegRegOpDeclare.subst(usad8Iop)
4537242Sgblack@eecs.umich.edu    decoder_output += RegRegRegOpConstructor.subst(usad8Iop)
4547242Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(usad8Iop)
4557242Sgblack@eecs.umich.edu
4567242Sgblack@eecs.umich.edu    usada8Code = '''
4577242Sgblack@eecs.umich.edu        uint32_t resTemp = 0;
4587242Sgblack@eecs.umich.edu        for (unsigned i = 0; i < 4; i++) {
4597242Sgblack@eecs.umich.edu            int low = i * 8;
4607242Sgblack@eecs.umich.edu            int high = low + 7;
4617242Sgblack@eecs.umich.edu            int32_t diff = bits(Op1, high, low) -
4627242Sgblack@eecs.umich.edu                           bits(Op2, high, low);
4637242Sgblack@eecs.umich.edu            resTemp += ((diff < 0) ? -diff : diff);
4647242Sgblack@eecs.umich.edu        }
4657242Sgblack@eecs.umich.edu        Dest = Op3 + resTemp;
4667242Sgblack@eecs.umich.edu    '''
4677242Sgblack@eecs.umich.edu    usada8Iop = InstObjParams("usada8", "Usada8", "RegRegRegRegOp",
4687242Sgblack@eecs.umich.edu                              { "code": usada8Code,
4697242Sgblack@eecs.umich.edu                                "predicate_test": predicateTest }, [])
4707242Sgblack@eecs.umich.edu    header_output += RegRegRegRegOpDeclare.subst(usada8Iop)
4717242Sgblack@eecs.umich.edu    decoder_output += RegRegRegRegOpConstructor.subst(usada8Iop)
4727242Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(usada8Iop)
4737247Sgblack@eecs.umich.edu
4747797Sgblack@eecs.umich.edu    bkptCode = 'return new PrefetchAbort(PC, ArmFault::DebugEvent);\n'
4757848SAli.Saidi@ARM.com    bkptIop = InstObjParams("bkpt", "BkptInst", "PredOp", bkptCode)
4767410Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(bkptIop)
4777410Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(bkptIop)
4787410Sgblack@eecs.umich.edu    exec_output += BasicExecute.subst(bkptIop)
4797410Sgblack@eecs.umich.edu
4807408Sgblack@eecs.umich.edu    nopIop = InstObjParams("nop", "NopInst", "PredOp", \
4818065SAli.Saidi@ARM.com            { "code" : "", "predicate_test" : predicateTest },
4828065SAli.Saidi@ARM.com            ['IsNop'])
4837247Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(nopIop)
4847247Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(nopIop)
4857408Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(nopIop)
4867408Sgblack@eecs.umich.edu
4877418Sgblack@eecs.umich.edu    yieldIop = InstObjParams("yield", "YieldInst", "PredOp", \
4887418Sgblack@eecs.umich.edu            { "code" : "", "predicate_test" : predicateTest })
4897418Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(yieldIop)
4907418Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(yieldIop)
4917418Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(yieldIop)
4927418Sgblack@eecs.umich.edu
4937418Sgblack@eecs.umich.edu    wfeCode = '''
4947418Sgblack@eecs.umich.edu#if FULL_SYSTEM
4958285SPrakash.Ramrakhyani@arm.com    if (SevMailbox == 1) {
4967418Sgblack@eecs.umich.edu        SevMailbox = 0;
4978142SAli.Saidi@ARM.com        PseudoInst::quiesceSkip(xc->tcBase());
4988285SPrakash.Ramrakhyani@arm.com    } else {
4997418Sgblack@eecs.umich.edu        PseudoInst::quiesce(xc->tcBase());
5008142SAli.Saidi@ARM.com    }
5017418Sgblack@eecs.umich.edu#endif
5027418Sgblack@eecs.umich.edu    '''
5037418Sgblack@eecs.umich.edu    wfeIop = InstObjParams("wfe", "WfeInst", "PredOp", \
5047418Sgblack@eecs.umich.edu            { "code" : wfeCode, "predicate_test" : predicateTest },
5057648SAli.Saidi@ARM.com            ["IsNonSpeculative", "IsQuiesce", "IsSerializeAfter"])
5067418Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(wfeIop)
5077418Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(wfeIop)
5088142SAli.Saidi@ARM.com    exec_output += QuiescePredOpExecute.subst(wfeIop)
5097418Sgblack@eecs.umich.edu
5107418Sgblack@eecs.umich.edu    wfiCode = '''
5117418Sgblack@eecs.umich.edu#if FULL_SYSTEM
5128285SPrakash.Ramrakhyani@arm.com    // WFI doesn't sleep if interrupts are pending (masked or not)
5138285SPrakash.Ramrakhyani@arm.com    if (xc->tcBase()->getCpuPtr()->getInterruptController()->checkRaw()) {
5148285SPrakash.Ramrakhyani@arm.com        PseudoInst::quiesceSkip(xc->tcBase());
5158285SPrakash.Ramrakhyani@arm.com    } else {
5168285SPrakash.Ramrakhyani@arm.com        PseudoInst::quiesce(xc->tcBase());
5178285SPrakash.Ramrakhyani@arm.com    }
5187418Sgblack@eecs.umich.edu#endif
5197418Sgblack@eecs.umich.edu    '''
5207418Sgblack@eecs.umich.edu    wfiIop = InstObjParams("wfi", "WfiInst", "PredOp", \
5217418Sgblack@eecs.umich.edu            { "code" : wfiCode, "predicate_test" : predicateTest },
5228142SAli.Saidi@ARM.com            ["IsNonSpeculative", "IsQuiesce", "IsSerializeAfter"])
5237418Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(wfiIop)
5247418Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(wfiIop)
5258142SAli.Saidi@ARM.com    exec_output += QuiescePredOpExecute.subst(wfiIop)
5267418Sgblack@eecs.umich.edu
5277418Sgblack@eecs.umich.edu    sevCode = '''
5287418Sgblack@eecs.umich.edu    // Need a way for O3 to not scoreboard these accesses as pipe flushes.
5298142SAli.Saidi@ARM.com    SevMailbox = 1;
5307418Sgblack@eecs.umich.edu    System *sys = xc->tcBase()->getSystemPtr();
5317418Sgblack@eecs.umich.edu    for (int x = 0; x < sys->numContexts(); x++) {
5327418Sgblack@eecs.umich.edu        ThreadContext *oc = sys->getThreadContext(x);
5338285SPrakash.Ramrakhyani@arm.com        if (oc == xc->tcBase())
5348285SPrakash.Ramrakhyani@arm.com            continue;
5358285SPrakash.Ramrakhyani@arm.com        // Only wake if they were sleeping
5368285SPrakash.Ramrakhyani@arm.com        if (oc->readMiscReg(MISCREG_SEV_MAILBOX) == 0) {
5378142SAli.Saidi@ARM.com            oc->setMiscReg(MISCREG_SEV_MAILBOX, 1);
5388285SPrakash.Ramrakhyani@arm.com            PseudoInst::wakeCPU(xc->tcBase(), x);
5398142SAli.Saidi@ARM.com        }
5407418Sgblack@eecs.umich.edu    }
5417418Sgblack@eecs.umich.edu    '''
5427418Sgblack@eecs.umich.edu    sevIop = InstObjParams("sev", "SevInst", "PredOp", \
5437418Sgblack@eecs.umich.edu            { "code" : sevCode, "predicate_test" : predicateTest },
5448142SAli.Saidi@ARM.com            ["IsNonSpeculative", "IsSquashAfter"])
5457418Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(sevIop)
5467418Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(sevIop)
5477418Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(sevIop)
5487418Sgblack@eecs.umich.edu
5497408Sgblack@eecs.umich.edu    itIop = InstObjParams("it", "ItInst", "PredOp", \
5508205SAli.Saidi@ARM.com            { "code" : ";",
5517648SAli.Saidi@ARM.com              "predicate_test" : predicateTest },
5527648SAli.Saidi@ARM.com            ["IsNonSpeculative", "IsSerializeAfter"])
5537408Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(itIop)
5547408Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(itIop)
5557408Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(itIop)
5567409Sgblack@eecs.umich.edu    unknownCode = '''
5577409Sgblack@eecs.umich.edu#if FULL_SYSTEM
5587409Sgblack@eecs.umich.edu            return new UndefinedInstruction;
5597409Sgblack@eecs.umich.edu#else
5607409Sgblack@eecs.umich.edu            return new UndefinedInstruction(machInst, true);
5617409Sgblack@eecs.umich.edu#endif
5627409Sgblack@eecs.umich.edu    '''
5637409Sgblack@eecs.umich.edu    unknownIop = InstObjParams("unknown", "Unknown", "UnknownOp", \
5647409Sgblack@eecs.umich.edu                               { "code": unknownCode,
5657409Sgblack@eecs.umich.edu                                 "predicate_test": predicateTest })
5667409Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(unknownIop)
5677409Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(unknownIop)
5687409Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(unknownIop)
5697254Sgblack@eecs.umich.edu
5707254Sgblack@eecs.umich.edu    ubfxCode = '''
5717254Sgblack@eecs.umich.edu        Dest = bits(Op1, imm2, imm1);
5727254Sgblack@eecs.umich.edu    '''
5737254Sgblack@eecs.umich.edu    ubfxIop = InstObjParams("ubfx", "Ubfx", "RegRegImmImmOp",
5747254Sgblack@eecs.umich.edu                            { "code": ubfxCode,
5757254Sgblack@eecs.umich.edu                              "predicate_test": predicateTest }, [])
5767254Sgblack@eecs.umich.edu    header_output += RegRegImmImmOpDeclare.subst(ubfxIop)
5777254Sgblack@eecs.umich.edu    decoder_output += RegRegImmImmOpConstructor.subst(ubfxIop)
5787254Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(ubfxIop)
5797254Sgblack@eecs.umich.edu
5807254Sgblack@eecs.umich.edu    sbfxCode = '''
5817254Sgblack@eecs.umich.edu        int32_t resTemp = bits(Op1, imm2, imm1);
5827254Sgblack@eecs.umich.edu        Dest = resTemp | -(resTemp & (1 << (imm2 - imm1)));
5837254Sgblack@eecs.umich.edu    '''
5847254Sgblack@eecs.umich.edu    sbfxIop = InstObjParams("sbfx", "Sbfx", "RegRegImmImmOp",
5857254Sgblack@eecs.umich.edu                            { "code": sbfxCode,
5867254Sgblack@eecs.umich.edu                              "predicate_test": predicateTest }, [])
5877254Sgblack@eecs.umich.edu    header_output += RegRegImmImmOpDeclare.subst(sbfxIop)
5887254Sgblack@eecs.umich.edu    decoder_output += RegRegImmImmOpConstructor.subst(sbfxIop)
5897254Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(sbfxIop)
5907257Sgblack@eecs.umich.edu
5917257Sgblack@eecs.umich.edu    bfcCode = '''
5927257Sgblack@eecs.umich.edu        Dest = Op1 & ~(mask(imm2 - imm1 + 1) << imm1);
5937257Sgblack@eecs.umich.edu    '''
5947257Sgblack@eecs.umich.edu    bfcIop = InstObjParams("bfc", "Bfc", "RegRegImmImmOp",
5957257Sgblack@eecs.umich.edu                           { "code": bfcCode,
5967257Sgblack@eecs.umich.edu                             "predicate_test": predicateTest }, [])
5977257Sgblack@eecs.umich.edu    header_output += RegRegImmImmOpDeclare.subst(bfcIop)
5987257Sgblack@eecs.umich.edu    decoder_output += RegRegImmImmOpConstructor.subst(bfcIop)
5997257Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(bfcIop)
6007257Sgblack@eecs.umich.edu
6017257Sgblack@eecs.umich.edu    bfiCode = '''
6027257Sgblack@eecs.umich.edu        uint32_t bitMask = (mask(imm2 - imm1 + 1) << imm1);
6037257Sgblack@eecs.umich.edu        Dest = ((Op1 << imm1) & bitMask) | (Dest & ~bitMask);
6047257Sgblack@eecs.umich.edu    '''
6057257Sgblack@eecs.umich.edu    bfiIop = InstObjParams("bfi", "Bfi", "RegRegImmImmOp",
6067257Sgblack@eecs.umich.edu                           { "code": bfiCode,
6077257Sgblack@eecs.umich.edu                             "predicate_test": predicateTest }, [])
6087257Sgblack@eecs.umich.edu    header_output += RegRegImmImmOpDeclare.subst(bfiIop)
6097257Sgblack@eecs.umich.edu    decoder_output += RegRegImmImmOpConstructor.subst(bfiIop)
6107257Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(bfiIop)
6117262Sgblack@eecs.umich.edu
6127347SAli.Saidi@ARM.com    mrc15code = '''
6137347SAli.Saidi@ARM.com    CPSR cpsr = Cpsr;
6147347SAli.Saidi@ARM.com    if (cpsr.mode == MODE_USER)
6157347SAli.Saidi@ARM.com#if FULL_SYSTEM
6167347SAli.Saidi@ARM.com        return new UndefinedInstruction;
6177347SAli.Saidi@ARM.com#else
6187347SAli.Saidi@ARM.com        return new UndefinedInstruction(false, mnemonic);
6197347SAli.Saidi@ARM.com#endif
6207347SAli.Saidi@ARM.com    Dest = MiscOp1;
6217347SAli.Saidi@ARM.com    '''
6227347SAli.Saidi@ARM.com
6237262Sgblack@eecs.umich.edu    mrc15Iop = InstObjParams("mrc", "Mrc15", "RegRegOp",
6247347SAli.Saidi@ARM.com                             { "code": mrc15code,
6257262Sgblack@eecs.umich.edu                               "predicate_test": predicateTest }, [])
6267262Sgblack@eecs.umich.edu    header_output += RegRegOpDeclare.subst(mrc15Iop)
6277262Sgblack@eecs.umich.edu    decoder_output += RegRegOpConstructor.subst(mrc15Iop)
6287262Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(mrc15Iop)
6297262Sgblack@eecs.umich.edu
6307347SAli.Saidi@ARM.com
6317347SAli.Saidi@ARM.com    mcr15code = '''
6327347SAli.Saidi@ARM.com    CPSR cpsr = Cpsr;
6337347SAli.Saidi@ARM.com    if (cpsr.mode == MODE_USER)
6347347SAli.Saidi@ARM.com#if FULL_SYSTEM
6357347SAli.Saidi@ARM.com        return new UndefinedInstruction;
6367347SAli.Saidi@ARM.com#else
6377347SAli.Saidi@ARM.com        return new UndefinedInstruction(false, mnemonic);
6387347SAli.Saidi@ARM.com#endif
6397347SAli.Saidi@ARM.com    MiscDest = Op1;
6407347SAli.Saidi@ARM.com    '''
6417262Sgblack@eecs.umich.edu    mcr15Iop = InstObjParams("mcr", "Mcr15", "RegRegOp",
6427347SAli.Saidi@ARM.com                             { "code": mcr15code,
6437599Sminkyu.jeong@arm.com                               "predicate_test": predicateTest },
6447599Sminkyu.jeong@arm.com                               ["IsSerializeAfter","IsNonSpeculative"])
6457262Sgblack@eecs.umich.edu    header_output += RegRegOpDeclare.subst(mcr15Iop)
6467262Sgblack@eecs.umich.edu    decoder_output += RegRegOpConstructor.subst(mcr15Iop)
6477262Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(mcr15Iop)
6487283Sgblack@eecs.umich.edu
6497420Sgblack@eecs.umich.edu    mrc15UserIop = InstObjParams("mrc", "Mrc15User", "RegRegOp",
6507420Sgblack@eecs.umich.edu                                 { "code": "Dest = MiscOp1;",
6517420Sgblack@eecs.umich.edu                                   "predicate_test": predicateTest }, [])
6527420Sgblack@eecs.umich.edu    header_output += RegRegOpDeclare.subst(mrc15UserIop)
6537420Sgblack@eecs.umich.edu    decoder_output += RegRegOpConstructor.subst(mrc15UserIop)
6547420Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(mrc15UserIop)
6557420Sgblack@eecs.umich.edu
6567420Sgblack@eecs.umich.edu    mcr15UserIop = InstObjParams("mcr", "Mcr15User", "RegRegOp",
6577420Sgblack@eecs.umich.edu                                 { "code": "MiscDest = Op1",
6587599Sminkyu.jeong@arm.com                                   "predicate_test": predicateTest },
6597599Sminkyu.jeong@arm.com                                   ["IsSerializeAfter","IsNonSpeculative"])
6607420Sgblack@eecs.umich.edu    header_output += RegRegOpDeclare.subst(mcr15UserIop)
6617420Sgblack@eecs.umich.edu    decoder_output += RegRegOpConstructor.subst(mcr15UserIop)
6627420Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(mcr15UserIop)
6637420Sgblack@eecs.umich.edu
6647283Sgblack@eecs.umich.edu    enterxCode = '''
6657797Sgblack@eecs.umich.edu        NextThumb = true;
6667797Sgblack@eecs.umich.edu        NextJazelle = true;
6677283Sgblack@eecs.umich.edu    '''
6687283Sgblack@eecs.umich.edu    enterxIop = InstObjParams("enterx", "Enterx", "PredOp",
6697283Sgblack@eecs.umich.edu                              { "code": enterxCode,
6707283Sgblack@eecs.umich.edu                                "predicate_test": predicateTest }, [])
6717283Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(enterxIop)
6727283Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(enterxIop)
6737283Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(enterxIop)
6747283Sgblack@eecs.umich.edu
6757283Sgblack@eecs.umich.edu    leavexCode = '''
6767797Sgblack@eecs.umich.edu        NextThumb = true;
6777797Sgblack@eecs.umich.edu        NextJazelle = false;
6787283Sgblack@eecs.umich.edu    '''
6797283Sgblack@eecs.umich.edu    leavexIop = InstObjParams("leavex", "Leavex", "PredOp",
6807283Sgblack@eecs.umich.edu                              { "code": leavexCode,
6817283Sgblack@eecs.umich.edu                                "predicate_test": predicateTest }, [])
6827283Sgblack@eecs.umich.edu    header_output += BasicDeclare.subst(leavexIop)
6837283Sgblack@eecs.umich.edu    decoder_output += BasicConstructor.subst(leavexIop)
6847283Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(leavexIop)
6857307Sgblack@eecs.umich.edu
6867307Sgblack@eecs.umich.edu    setendCode = '''
6877307Sgblack@eecs.umich.edu        CPSR cpsr = Cpsr;
6887307Sgblack@eecs.umich.edu        cpsr.e = imm;
6897307Sgblack@eecs.umich.edu        Cpsr = cpsr;
6907307Sgblack@eecs.umich.edu    '''
6917307Sgblack@eecs.umich.edu    setendIop = InstObjParams("setend", "Setend", "ImmOp",
6927307Sgblack@eecs.umich.edu                              { "code": setendCode,
6937648SAli.Saidi@ARM.com                                "predicate_test": predicateTest },
6947648SAli.Saidi@ARM.com                              ["IsSerializeAfter","IsNonSpeculative"])
6957307Sgblack@eecs.umich.edu    header_output += ImmOpDeclare.subst(setendIop)
6967307Sgblack@eecs.umich.edu    decoder_output += ImmOpConstructor.subst(setendIop)
6977307Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(setendIop)
6987315Sgblack@eecs.umich.edu
6997603SGene.Wu@arm.com    clrexCode = '''
7008209SAli.Saidi@ARM.com        LLSCLock = 0;
7017603SGene.Wu@arm.com    '''
7027603SGene.Wu@arm.com    clrexIop = InstObjParams("clrex", "Clrex","PredOp",
7037603SGene.Wu@arm.com                             { "code": clrexCode,
7047603SGene.Wu@arm.com                               "predicate_test": predicateTest },[])
7058209SAli.Saidi@ARM.com    header_output += BasicDeclare.subst(clrexIop)
7067603SGene.Wu@arm.com    decoder_output += BasicConstructor.subst(clrexIop)
7077603SGene.Wu@arm.com    exec_output += PredOpExecute.subst(clrexIop)
7087603SGene.Wu@arm.com
7097605SGene.Wu@arm.com    isbCode = '''
7108068SAli.Saidi@ARM.com        fault = new FlushPipe;
7117605SGene.Wu@arm.com    '''
7127605SGene.Wu@arm.com    isbIop = InstObjParams("isb", "Isb", "PredOp",
7137605SGene.Wu@arm.com                             {"code": isbCode,
7148068SAli.Saidi@ARM.com                               "predicate_test": predicateTest},
7158068SAli.Saidi@ARM.com                                ['IsSerializeAfter'])
7167605SGene.Wu@arm.com    header_output += BasicDeclare.subst(isbIop)
7177605SGene.Wu@arm.com    decoder_output += BasicConstructor.subst(isbIop)
7187605SGene.Wu@arm.com    exec_output += PredOpExecute.subst(isbIop)
7197605SGene.Wu@arm.com
7207605SGene.Wu@arm.com    dsbCode = '''
7218068SAli.Saidi@ARM.com        fault = new FlushPipe;
7227605SGene.Wu@arm.com    '''
7237605SGene.Wu@arm.com    dsbIop = InstObjParams("dsb", "Dsb", "PredOp",
7247605SGene.Wu@arm.com                             {"code": dsbCode,
7258068SAli.Saidi@ARM.com                               "predicate_test": predicateTest},
7268068SAli.Saidi@ARM.com                              ['IsMemBarrier', 'IsSerializeAfter'])
7277605SGene.Wu@arm.com    header_output += BasicDeclare.subst(dsbIop)
7287605SGene.Wu@arm.com    decoder_output += BasicConstructor.subst(dsbIop)
7297605SGene.Wu@arm.com    exec_output += PredOpExecute.subst(dsbIop)
7307605SGene.Wu@arm.com
7317605SGene.Wu@arm.com    dmbCode = '''
7327605SGene.Wu@arm.com    '''
7337605SGene.Wu@arm.com    dmbIop = InstObjParams("dmb", "Dmb", "PredOp",
7347605SGene.Wu@arm.com                             {"code": dmbCode,
7358068SAli.Saidi@ARM.com                               "predicate_test": predicateTest},
7368068SAli.Saidi@ARM.com                               ['IsMemBarrier'])
7377605SGene.Wu@arm.com    header_output += BasicDeclare.subst(dmbIop)
7387605SGene.Wu@arm.com    decoder_output += BasicConstructor.subst(dmbIop)
7397605SGene.Wu@arm.com    exec_output += PredOpExecute.subst(dmbIop)
7407605SGene.Wu@arm.com
7417613SGene.Wu@arm.com    dbgCode = '''
7427613SGene.Wu@arm.com    '''
7437613SGene.Wu@arm.com    dbgIop = InstObjParams("dbg", "Dbg", "PredOp",
7447613SGene.Wu@arm.com                             {"code": dbgCode,
7457613SGene.Wu@arm.com                               "predicate_test": predicateTest})
7467613SGene.Wu@arm.com    header_output += BasicDeclare.subst(dbgIop)
7477613SGene.Wu@arm.com    decoder_output += BasicConstructor.subst(dbgIop)
7487613SGene.Wu@arm.com    exec_output += PredOpExecute.subst(dbgIop)
7497613SGene.Wu@arm.com
7507315Sgblack@eecs.umich.edu    cpsCode = '''
7517315Sgblack@eecs.umich.edu    uint32_t mode = bits(imm, 4, 0);
7527315Sgblack@eecs.umich.edu    uint32_t f = bits(imm, 5);
7537315Sgblack@eecs.umich.edu    uint32_t i = bits(imm, 6);
7547315Sgblack@eecs.umich.edu    uint32_t a = bits(imm, 7);
7557315Sgblack@eecs.umich.edu    bool setMode = bits(imm, 8);
7567315Sgblack@eecs.umich.edu    bool enable = bits(imm, 9);
7577315Sgblack@eecs.umich.edu    CPSR cpsr = Cpsr;
7587400SAli.Saidi@ARM.com    SCTLR sctlr = Sctlr;
7597315Sgblack@eecs.umich.edu    if (cpsr.mode != MODE_USER) {
7607315Sgblack@eecs.umich.edu        if (enable) {
7617315Sgblack@eecs.umich.edu            if (f) cpsr.f = 0;
7627315Sgblack@eecs.umich.edu            if (i) cpsr.i = 0;
7637315Sgblack@eecs.umich.edu            if (a) cpsr.a = 0;
7647315Sgblack@eecs.umich.edu        } else {
7657400SAli.Saidi@ARM.com            if (f && !sctlr.nmfi) cpsr.f = 1;
7667315Sgblack@eecs.umich.edu            if (i) cpsr.i = 1;
7677315Sgblack@eecs.umich.edu            if (a) cpsr.a = 1;
7687315Sgblack@eecs.umich.edu        }
7697315Sgblack@eecs.umich.edu        if (setMode) {
7707315Sgblack@eecs.umich.edu            cpsr.mode = mode;
7717315Sgblack@eecs.umich.edu        }
7727315Sgblack@eecs.umich.edu    }
7737315Sgblack@eecs.umich.edu    Cpsr = cpsr;
7747315Sgblack@eecs.umich.edu    '''
7757315Sgblack@eecs.umich.edu    cpsIop = InstObjParams("cps", "Cps", "ImmOp",
7767315Sgblack@eecs.umich.edu                           { "code": cpsCode,
7777599Sminkyu.jeong@arm.com                             "predicate_test": predicateTest },
7787599Sminkyu.jeong@arm.com                           ["IsSerializeAfter","IsNonSpeculative"])
7797315Sgblack@eecs.umich.edu    header_output += ImmOpDeclare.subst(cpsIop)
7807315Sgblack@eecs.umich.edu    decoder_output += ImmOpConstructor.subst(cpsIop)
7817315Sgblack@eecs.umich.edu    exec_output += PredOpExecute.subst(cpsIop)
7827202Sgblack@eecs.umich.edu}};
783