misc.isa revision 7858
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 637202Sgblack@eecs.umich.edu mrsCpsrCode = "Dest = (Cpsr | CondCodes) & 0xF8FF03DF" 647202Sgblack@eecs.umich.edu mrsCpsrIop = InstObjParams("mrs", "MrsCpsr", "MrsOp", 657202Sgblack@eecs.umich.edu { "code": mrsCpsrCode, 667599Sminkyu.jeong@arm.com "predicate_test": condPredicateTest }, 677783SGiacomo.Gabrielli@arm.com ["IsSerializeBefore"]) 687202Sgblack@eecs.umich.edu header_output += MrsDeclare.subst(mrsCpsrIop) 697202Sgblack@eecs.umich.edu decoder_output += MrsConstructor.subst(mrsCpsrIop) 707202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(mrsCpsrIop) 717202Sgblack@eecs.umich.edu 727202Sgblack@eecs.umich.edu mrsSpsrCode = "Dest = Spsr" 737202Sgblack@eecs.umich.edu mrsSpsrIop = InstObjParams("mrs", "MrsSpsr", "MrsOp", 747202Sgblack@eecs.umich.edu { "code": mrsSpsrCode, 757599Sminkyu.jeong@arm.com "predicate_test": predicateTest }, 767783SGiacomo.Gabrielli@arm.com ["IsSerializeBefore"]) 777202Sgblack@eecs.umich.edu header_output += MrsDeclare.subst(mrsSpsrIop) 787202Sgblack@eecs.umich.edu decoder_output += MrsConstructor.subst(mrsSpsrIop) 797202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(mrsSpsrIop) 807202Sgblack@eecs.umich.edu 817202Sgblack@eecs.umich.edu msrCpsrRegCode = ''' 827400SAli.Saidi@ARM.com SCTLR sctlr = Sctlr; 837202Sgblack@eecs.umich.edu uint32_t newCpsr = 847400SAli.Saidi@ARM.com cpsrWriteByInstr(Cpsr | CondCodes, Op1, byteMask, false, sctlr.nmfi); 857202Sgblack@eecs.umich.edu Cpsr = ~CondCodesMask & newCpsr; 867797Sgblack@eecs.umich.edu NextThumb = ((CPSR)newCpsr).t; 877797Sgblack@eecs.umich.edu NextJazelle = ((CPSR)newCpsr).j; 887858SMatt.Horsnell@arm.com ForcedItState = ((((CPSR)Op1).it2 << 2) & 0xFC) 897858SMatt.Horsnell@arm.com | (((CPSR)Op1).it1 & 0x3); 907202Sgblack@eecs.umich.edu CondCodes = CondCodesMask & newCpsr; 917202Sgblack@eecs.umich.edu ''' 927202Sgblack@eecs.umich.edu msrCpsrRegIop = InstObjParams("msr", "MsrCpsrReg", "MsrRegOp", 937202Sgblack@eecs.umich.edu { "code": msrCpsrRegCode, 947599Sminkyu.jeong@arm.com "predicate_test": condPredicateTest }, 957599Sminkyu.jeong@arm.com ["IsSerializeAfter","IsNonSpeculative"]) 967202Sgblack@eecs.umich.edu header_output += MsrRegDeclare.subst(msrCpsrRegIop) 977202Sgblack@eecs.umich.edu decoder_output += MsrRegConstructor.subst(msrCpsrRegIop) 987202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(msrCpsrRegIop) 997202Sgblack@eecs.umich.edu 1007202Sgblack@eecs.umich.edu msrSpsrRegCode = "Spsr = spsrWriteByInstr(Spsr, Op1, byteMask, false);" 1017202Sgblack@eecs.umich.edu msrSpsrRegIop = InstObjParams("msr", "MsrSpsrReg", "MsrRegOp", 1027202Sgblack@eecs.umich.edu { "code": msrSpsrRegCode, 1037599Sminkyu.jeong@arm.com "predicate_test": predicateTest }, 1047599Sminkyu.jeong@arm.com ["IsSerializeAfter","IsNonSpeculative"]) 1057202Sgblack@eecs.umich.edu header_output += MsrRegDeclare.subst(msrSpsrRegIop) 1067202Sgblack@eecs.umich.edu decoder_output += MsrRegConstructor.subst(msrSpsrRegIop) 1077202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(msrSpsrRegIop) 1087202Sgblack@eecs.umich.edu 1097202Sgblack@eecs.umich.edu msrCpsrImmCode = ''' 1107400SAli.Saidi@ARM.com SCTLR sctlr = Sctlr; 1117202Sgblack@eecs.umich.edu uint32_t newCpsr = 1127400SAli.Saidi@ARM.com cpsrWriteByInstr(Cpsr | CondCodes, imm, byteMask, false, sctlr.nmfi); 1137202Sgblack@eecs.umich.edu Cpsr = ~CondCodesMask & newCpsr; 1147797Sgblack@eecs.umich.edu NextThumb = ((CPSR)newCpsr).t; 1157797Sgblack@eecs.umich.edu NextJazelle = ((CPSR)newCpsr).j; 1167858SMatt.Horsnell@arm.com ForcedItState = ((((CPSR)imm).it2 << 2) & 0xFC) 1177858SMatt.Horsnell@arm.com | (((CPSR)imm).it1 & 0x3); 1187202Sgblack@eecs.umich.edu CondCodes = CondCodesMask & newCpsr; 1197202Sgblack@eecs.umich.edu ''' 1207202Sgblack@eecs.umich.edu msrCpsrImmIop = InstObjParams("msr", "MsrCpsrImm", "MsrImmOp", 1217202Sgblack@eecs.umich.edu { "code": msrCpsrImmCode, 1227599Sminkyu.jeong@arm.com "predicate_test": condPredicateTest }, 1237599Sminkyu.jeong@arm.com ["IsSerializeAfter","IsNonSpeculative"]) 1247202Sgblack@eecs.umich.edu header_output += MsrImmDeclare.subst(msrCpsrImmIop) 1257202Sgblack@eecs.umich.edu decoder_output += MsrImmConstructor.subst(msrCpsrImmIop) 1267202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(msrCpsrImmIop) 1277202Sgblack@eecs.umich.edu 1287202Sgblack@eecs.umich.edu msrSpsrImmCode = "Spsr = spsrWriteByInstr(Spsr, imm, byteMask, false);" 1297202Sgblack@eecs.umich.edu msrSpsrImmIop = InstObjParams("msr", "MsrSpsrImm", "MsrImmOp", 1307202Sgblack@eecs.umich.edu { "code": msrSpsrImmCode, 1317599Sminkyu.jeong@arm.com "predicate_test": predicateTest }, 1327599Sminkyu.jeong@arm.com ["IsSerializeAfter","IsNonSpeculative"]) 1337202Sgblack@eecs.umich.edu header_output += MsrImmDeclare.subst(msrSpsrImmIop) 1347202Sgblack@eecs.umich.edu decoder_output += MsrImmConstructor.subst(msrSpsrImmIop) 1357202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(msrSpsrImmIop) 1367209Sgblack@eecs.umich.edu 1377209Sgblack@eecs.umich.edu revCode = ''' 1387209Sgblack@eecs.umich.edu uint32_t val = Op1; 1397209Sgblack@eecs.umich.edu Dest = swap_byte(val); 1407209Sgblack@eecs.umich.edu ''' 1417261Sgblack@eecs.umich.edu revIop = InstObjParams("rev", "Rev", "RegRegOp", 1427209Sgblack@eecs.umich.edu { "code": revCode, 1437209Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1447261Sgblack@eecs.umich.edu header_output += RegRegOpDeclare.subst(revIop) 1457261Sgblack@eecs.umich.edu decoder_output += RegRegOpConstructor.subst(revIop) 1467209Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(revIop) 1477209Sgblack@eecs.umich.edu 1487209Sgblack@eecs.umich.edu rev16Code = ''' 1497209Sgblack@eecs.umich.edu uint32_t val = Op1; 1507209Sgblack@eecs.umich.edu Dest = (bits(val, 15, 8) << 0) | 1517209Sgblack@eecs.umich.edu (bits(val, 7, 0) << 8) | 1527209Sgblack@eecs.umich.edu (bits(val, 31, 24) << 16) | 1537209Sgblack@eecs.umich.edu (bits(val, 23, 16) << 24); 1547209Sgblack@eecs.umich.edu ''' 1557261Sgblack@eecs.umich.edu rev16Iop = InstObjParams("rev16", "Rev16", "RegRegOp", 1567209Sgblack@eecs.umich.edu { "code": rev16Code, 1577209Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1587261Sgblack@eecs.umich.edu header_output += RegRegOpDeclare.subst(rev16Iop) 1597261Sgblack@eecs.umich.edu decoder_output += RegRegOpConstructor.subst(rev16Iop) 1607209Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(rev16Iop) 1617209Sgblack@eecs.umich.edu 1627209Sgblack@eecs.umich.edu revshCode = ''' 1637209Sgblack@eecs.umich.edu uint16_t val = Op1; 1647209Sgblack@eecs.umich.edu Dest = sext<16>(swap_byte(val)); 1657209Sgblack@eecs.umich.edu ''' 1667261Sgblack@eecs.umich.edu revshIop = InstObjParams("revsh", "Revsh", "RegRegOp", 1677209Sgblack@eecs.umich.edu { "code": revshCode, 1687209Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1697261Sgblack@eecs.umich.edu header_output += RegRegOpDeclare.subst(revshIop) 1707261Sgblack@eecs.umich.edu decoder_output += RegRegOpConstructor.subst(revshIop) 1717209Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(revshIop) 1727226Sgblack@eecs.umich.edu 1737249Sgblack@eecs.umich.edu rbitCode = ''' 1747249Sgblack@eecs.umich.edu uint8_t *opBytes = (uint8_t *)&Op1; 1757249Sgblack@eecs.umich.edu uint32_t resTemp; 1767249Sgblack@eecs.umich.edu uint8_t *destBytes = (uint8_t *)&resTemp; 1777249Sgblack@eecs.umich.edu // This reverses the bytes and bits of the input, or so says the 1787249Sgblack@eecs.umich.edu // internet. 1797249Sgblack@eecs.umich.edu for (int i = 0; i < 4; i++) { 1807249Sgblack@eecs.umich.edu uint32_t temp = opBytes[i]; 1817249Sgblack@eecs.umich.edu temp = (temp * 0x0802 & 0x22110) | (temp * 0x8020 & 0x88440); 1827249Sgblack@eecs.umich.edu destBytes[3 - i] = (temp * 0x10101) >> 16; 1837249Sgblack@eecs.umich.edu } 1847249Sgblack@eecs.umich.edu Dest = resTemp; 1857249Sgblack@eecs.umich.edu ''' 1867261Sgblack@eecs.umich.edu rbitIop = InstObjParams("rbit", "Rbit", "RegRegOp", 1877249Sgblack@eecs.umich.edu { "code": rbitCode, 1887249Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1897261Sgblack@eecs.umich.edu header_output += RegRegOpDeclare.subst(rbitIop) 1907261Sgblack@eecs.umich.edu decoder_output += RegRegOpConstructor.subst(rbitIop) 1917249Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(rbitIop) 1927249Sgblack@eecs.umich.edu 1937251Sgblack@eecs.umich.edu clzCode = ''' 1947251Sgblack@eecs.umich.edu Dest = (Op1 == 0) ? 32 : (31 - findMsbSet(Op1)); 1957251Sgblack@eecs.umich.edu ''' 1967261Sgblack@eecs.umich.edu clzIop = InstObjParams("clz", "Clz", "RegRegOp", 1977251Sgblack@eecs.umich.edu { "code": clzCode, 1987251Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1997261Sgblack@eecs.umich.edu header_output += RegRegOpDeclare.subst(clzIop) 2007261Sgblack@eecs.umich.edu decoder_output += RegRegOpConstructor.subst(clzIop) 2017251Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(clzIop) 2027251Sgblack@eecs.umich.edu 2037226Sgblack@eecs.umich.edu ssatCode = ''' 2047226Sgblack@eecs.umich.edu int32_t operand = shift_rm_imm(Op1, shiftAmt, shiftType, 0); 2057226Sgblack@eecs.umich.edu int32_t res; 2067232Sgblack@eecs.umich.edu if (satInt(res, operand, imm)) 2077226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 2087226Sgblack@eecs.umich.edu else 2097226Sgblack@eecs.umich.edu CondCodes = CondCodes; 2107226Sgblack@eecs.umich.edu Dest = res; 2117226Sgblack@eecs.umich.edu ''' 2127232Sgblack@eecs.umich.edu ssatIop = InstObjParams("ssat", "Ssat", "RegImmRegShiftOp", 2137226Sgblack@eecs.umich.edu { "code": ssatCode, 2147422Sgblack@eecs.umich.edu "predicate_test": condPredicateTest }, []) 2157232Sgblack@eecs.umich.edu header_output += RegImmRegShiftOpDeclare.subst(ssatIop) 2167232Sgblack@eecs.umich.edu decoder_output += RegImmRegShiftOpConstructor.subst(ssatIop) 2177226Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(ssatIop) 2187226Sgblack@eecs.umich.edu 2197226Sgblack@eecs.umich.edu usatCode = ''' 2207226Sgblack@eecs.umich.edu int32_t operand = shift_rm_imm(Op1, shiftAmt, shiftType, 0); 2217226Sgblack@eecs.umich.edu int32_t res; 2227232Sgblack@eecs.umich.edu if (uSatInt(res, operand, imm)) 2237226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 2247226Sgblack@eecs.umich.edu else 2257226Sgblack@eecs.umich.edu CondCodes = CondCodes; 2267226Sgblack@eecs.umich.edu Dest = res; 2277226Sgblack@eecs.umich.edu ''' 2287232Sgblack@eecs.umich.edu usatIop = InstObjParams("usat", "Usat", "RegImmRegShiftOp", 2297226Sgblack@eecs.umich.edu { "code": usatCode, 2307422Sgblack@eecs.umich.edu "predicate_test": condPredicateTest }, []) 2317232Sgblack@eecs.umich.edu header_output += RegImmRegShiftOpDeclare.subst(usatIop) 2327232Sgblack@eecs.umich.edu decoder_output += RegImmRegShiftOpConstructor.subst(usatIop) 2337226Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(usatIop) 2347226Sgblack@eecs.umich.edu 2357226Sgblack@eecs.umich.edu ssat16Code = ''' 2367226Sgblack@eecs.umich.edu int32_t res; 2377226Sgblack@eecs.umich.edu uint32_t resTemp = 0; 2387226Sgblack@eecs.umich.edu CondCodes = CondCodes; 2397226Sgblack@eecs.umich.edu int32_t argLow = sext<16>(bits(Op1, 15, 0)); 2407226Sgblack@eecs.umich.edu int32_t argHigh = sext<16>(bits(Op1, 31, 16)); 2417232Sgblack@eecs.umich.edu if (satInt(res, argLow, imm)) 2427226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 2437226Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, res); 2447232Sgblack@eecs.umich.edu if (satInt(res, argHigh, imm)) 2457226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 2467226Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, res); 2477226Sgblack@eecs.umich.edu Dest = resTemp; 2487226Sgblack@eecs.umich.edu ''' 2497232Sgblack@eecs.umich.edu ssat16Iop = InstObjParams("ssat16", "Ssat16", "RegImmRegOp", 2507226Sgblack@eecs.umich.edu { "code": ssat16Code, 2517422Sgblack@eecs.umich.edu "predicate_test": condPredicateTest }, []) 2527232Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(ssat16Iop) 2537232Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(ssat16Iop) 2547226Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(ssat16Iop) 2557226Sgblack@eecs.umich.edu 2567226Sgblack@eecs.umich.edu usat16Code = ''' 2577226Sgblack@eecs.umich.edu int32_t res; 2587226Sgblack@eecs.umich.edu uint32_t resTemp = 0; 2597226Sgblack@eecs.umich.edu CondCodes = CondCodes; 2607226Sgblack@eecs.umich.edu int32_t argLow = sext<16>(bits(Op1, 15, 0)); 2617226Sgblack@eecs.umich.edu int32_t argHigh = sext<16>(bits(Op1, 31, 16)); 2627232Sgblack@eecs.umich.edu if (uSatInt(res, argLow, imm)) 2637226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 2647226Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, res); 2657232Sgblack@eecs.umich.edu if (uSatInt(res, argHigh, imm)) 2667226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 2677226Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, res); 2687226Sgblack@eecs.umich.edu Dest = resTemp; 2697226Sgblack@eecs.umich.edu ''' 2707232Sgblack@eecs.umich.edu usat16Iop = InstObjParams("usat16", "Usat16", "RegImmRegOp", 2717226Sgblack@eecs.umich.edu { "code": usat16Code, 2727422Sgblack@eecs.umich.edu "predicate_test": condPredicateTest }, []) 2737232Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(usat16Iop) 2747232Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(usat16Iop) 2757226Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(usat16Iop) 2767234Sgblack@eecs.umich.edu 2777234Sgblack@eecs.umich.edu sxtbIop = InstObjParams("sxtb", "Sxtb", "RegImmRegOp", 2787234Sgblack@eecs.umich.edu { "code": 2797234Sgblack@eecs.umich.edu "Dest = sext<8>((uint8_t)(Op1.ud >> imm));", 2807234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 2817234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(sxtbIop) 2827234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(sxtbIop) 2837234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtbIop) 2847234Sgblack@eecs.umich.edu 2857234Sgblack@eecs.umich.edu sxtabIop = InstObjParams("sxtab", "Sxtab", "RegRegRegImmOp", 2867234Sgblack@eecs.umich.edu { "code": 2877234Sgblack@eecs.umich.edu ''' 2887234Sgblack@eecs.umich.edu Dest = sext<8>((uint8_t)(Op2.ud >> imm)) + 2897234Sgblack@eecs.umich.edu Op1; 2907234Sgblack@eecs.umich.edu ''', 2917234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 2927234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(sxtabIop) 2937234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(sxtabIop) 2947234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtabIop) 2957234Sgblack@eecs.umich.edu 2967234Sgblack@eecs.umich.edu sxtb16Code = ''' 2977234Sgblack@eecs.umich.edu uint32_t resTemp = 0; 2987234Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, sext<8>(bits(Op1, imm + 7, imm))); 2997234Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, 3007234Sgblack@eecs.umich.edu sext<8>(bits(Op1, (imm + 23) % 32, (imm + 16) % 32))); 3017234Sgblack@eecs.umich.edu Dest = resTemp; 3027234Sgblack@eecs.umich.edu ''' 3037234Sgblack@eecs.umich.edu sxtb16Iop = InstObjParams("sxtb16", "Sxtb16", "RegImmRegOp", 3047234Sgblack@eecs.umich.edu { "code": sxtb16Code, 3057234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3067234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(sxtb16Iop) 3077234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(sxtb16Iop) 3087234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtb16Iop) 3097234Sgblack@eecs.umich.edu 3107234Sgblack@eecs.umich.edu sxtab16Code = ''' 3117234Sgblack@eecs.umich.edu uint32_t resTemp = 0; 3127234Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, sext<8>(bits(Op2, imm + 7, imm)) + 3137234Sgblack@eecs.umich.edu bits(Op1, 15, 0)); 3147234Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, 3157234Sgblack@eecs.umich.edu sext<8>(bits(Op2, (imm + 23) % 32, (imm + 16) % 32)) + 3167234Sgblack@eecs.umich.edu bits(Op1, 31, 16)); 3177234Sgblack@eecs.umich.edu Dest = resTemp; 3187234Sgblack@eecs.umich.edu ''' 3197234Sgblack@eecs.umich.edu sxtab16Iop = InstObjParams("sxtab16", "Sxtab16", "RegRegRegImmOp", 3207234Sgblack@eecs.umich.edu { "code": sxtab16Code, 3217234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3227234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(sxtab16Iop) 3237234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(sxtab16Iop) 3247234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtab16Iop) 3257234Sgblack@eecs.umich.edu 3267234Sgblack@eecs.umich.edu sxthCode = ''' 3277234Sgblack@eecs.umich.edu uint64_t rotated = (uint32_t)Op1; 3287234Sgblack@eecs.umich.edu rotated = (rotated | (rotated << 32)) >> imm; 3297234Sgblack@eecs.umich.edu Dest = sext<16>((uint16_t)rotated); 3307234Sgblack@eecs.umich.edu ''' 3317234Sgblack@eecs.umich.edu sxthIop = InstObjParams("sxth", "Sxth", "RegImmRegOp", 3327234Sgblack@eecs.umich.edu { "code": sxthCode, 3337234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3347234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(sxthIop) 3357234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(sxthIop) 3367234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxthIop) 3377234Sgblack@eecs.umich.edu 3387234Sgblack@eecs.umich.edu sxtahCode = ''' 3397234Sgblack@eecs.umich.edu uint64_t rotated = (uint32_t)Op2; 3407234Sgblack@eecs.umich.edu rotated = (rotated | (rotated << 32)) >> imm; 3417234Sgblack@eecs.umich.edu Dest = sext<16>((uint16_t)rotated) + Op1; 3427234Sgblack@eecs.umich.edu ''' 3437234Sgblack@eecs.umich.edu sxtahIop = InstObjParams("sxtah", "Sxtah", "RegRegRegImmOp", 3447234Sgblack@eecs.umich.edu { "code": sxtahCode, 3457234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3467234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(sxtahIop) 3477234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(sxtahIop) 3487234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtahIop) 3497234Sgblack@eecs.umich.edu 3507234Sgblack@eecs.umich.edu uxtbIop = InstObjParams("uxtb", "Uxtb", "RegImmRegOp", 3517234Sgblack@eecs.umich.edu { "code": "Dest = (uint8_t)(Op1.ud >> imm);", 3527234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3537234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(uxtbIop) 3547234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(uxtbIop) 3557234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtbIop) 3567234Sgblack@eecs.umich.edu 3577234Sgblack@eecs.umich.edu uxtabIop = InstObjParams("uxtab", "Uxtab", "RegRegRegImmOp", 3587234Sgblack@eecs.umich.edu { "code": 3597234Sgblack@eecs.umich.edu "Dest = (uint8_t)(Op2.ud >> imm) + Op1;", 3607234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3617234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(uxtabIop) 3627234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(uxtabIop) 3637234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtabIop) 3647234Sgblack@eecs.umich.edu 3657234Sgblack@eecs.umich.edu uxtb16Code = ''' 3667234Sgblack@eecs.umich.edu uint32_t resTemp = 0; 3677234Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, (uint8_t)(bits(Op1, imm + 7, imm))); 3687234Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, 3697234Sgblack@eecs.umich.edu (uint8_t)(bits(Op1, (imm + 23) % 32, (imm + 16) % 32))); 3707234Sgblack@eecs.umich.edu Dest = resTemp; 3717234Sgblack@eecs.umich.edu ''' 3727234Sgblack@eecs.umich.edu uxtb16Iop = InstObjParams("uxtb16", "Uxtb16", "RegImmRegOp", 3737234Sgblack@eecs.umich.edu { "code": uxtb16Code, 3747234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3757234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(uxtb16Iop) 3767234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(uxtb16Iop) 3777234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtb16Iop) 3787234Sgblack@eecs.umich.edu 3797234Sgblack@eecs.umich.edu uxtab16Code = ''' 3807234Sgblack@eecs.umich.edu uint32_t resTemp = 0; 3817234Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, (uint8_t)(bits(Op2, imm + 7, imm)) + 3827234Sgblack@eecs.umich.edu bits(Op1, 15, 0)); 3837234Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, 3847234Sgblack@eecs.umich.edu (uint8_t)(bits(Op2, (imm + 23) % 32, (imm + 16) % 32)) + 3857234Sgblack@eecs.umich.edu bits(Op1, 31, 16)); 3867234Sgblack@eecs.umich.edu Dest = resTemp; 3877234Sgblack@eecs.umich.edu ''' 3887234Sgblack@eecs.umich.edu uxtab16Iop = InstObjParams("uxtab16", "Uxtab16", "RegRegRegImmOp", 3897234Sgblack@eecs.umich.edu { "code": uxtab16Code, 3907234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3917234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(uxtab16Iop) 3927234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(uxtab16Iop) 3937234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtab16Iop) 3947234Sgblack@eecs.umich.edu 3957234Sgblack@eecs.umich.edu uxthCode = ''' 3967234Sgblack@eecs.umich.edu uint64_t rotated = (uint32_t)Op1; 3977234Sgblack@eecs.umich.edu rotated = (rotated | (rotated << 32)) >> imm; 3987234Sgblack@eecs.umich.edu Dest = (uint16_t)rotated; 3997234Sgblack@eecs.umich.edu ''' 4007234Sgblack@eecs.umich.edu uxthIop = InstObjParams("uxth", "Uxth", "RegImmRegOp", 4017234Sgblack@eecs.umich.edu { "code": uxthCode, 4027234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 4037234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(uxthIop) 4047234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(uxthIop) 4057234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxthIop) 4067234Sgblack@eecs.umich.edu 4077234Sgblack@eecs.umich.edu uxtahCode = ''' 4087234Sgblack@eecs.umich.edu uint64_t rotated = (uint32_t)Op2; 4097234Sgblack@eecs.umich.edu rotated = (rotated | (rotated << 32)) >> imm; 4107234Sgblack@eecs.umich.edu Dest = (uint16_t)rotated + Op1; 4117234Sgblack@eecs.umich.edu ''' 4127234Sgblack@eecs.umich.edu uxtahIop = InstObjParams("uxtah", "Uxtah", "RegRegRegImmOp", 4137234Sgblack@eecs.umich.edu { "code": uxtahCode, 4147234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 4157234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(uxtahIop) 4167234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(uxtahIop) 4177234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtahIop) 4187239Sgblack@eecs.umich.edu 4197239Sgblack@eecs.umich.edu selCode = ''' 4207239Sgblack@eecs.umich.edu uint32_t resTemp = 0; 4217239Sgblack@eecs.umich.edu for (unsigned i = 0; i < 4; i++) { 4227239Sgblack@eecs.umich.edu int low = i * 8; 4237239Sgblack@eecs.umich.edu int high = low + 7; 4247239Sgblack@eecs.umich.edu replaceBits(resTemp, high, low, 4257239Sgblack@eecs.umich.edu bits(CondCodes, 16 + i) ? 4267239Sgblack@eecs.umich.edu bits(Op1, high, low) : bits(Op2, high, low)); 4277239Sgblack@eecs.umich.edu } 4287239Sgblack@eecs.umich.edu Dest = resTemp; 4297239Sgblack@eecs.umich.edu ''' 4307239Sgblack@eecs.umich.edu selIop = InstObjParams("sel", "Sel", "RegRegRegOp", 4317239Sgblack@eecs.umich.edu { "code": selCode, 4327422Sgblack@eecs.umich.edu "predicate_test": condPredicateTest }, []) 4337239Sgblack@eecs.umich.edu header_output += RegRegRegOpDeclare.subst(selIop) 4347239Sgblack@eecs.umich.edu decoder_output += RegRegRegOpConstructor.subst(selIop) 4357239Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(selIop) 4367242Sgblack@eecs.umich.edu 4377242Sgblack@eecs.umich.edu usad8Code = ''' 4387242Sgblack@eecs.umich.edu uint32_t resTemp = 0; 4397242Sgblack@eecs.umich.edu for (unsigned i = 0; i < 4; i++) { 4407242Sgblack@eecs.umich.edu int low = i * 8; 4417242Sgblack@eecs.umich.edu int high = low + 7; 4427242Sgblack@eecs.umich.edu int32_t diff = bits(Op1, high, low) - 4437242Sgblack@eecs.umich.edu bits(Op2, high, low); 4447242Sgblack@eecs.umich.edu resTemp += ((diff < 0) ? -diff : diff); 4457242Sgblack@eecs.umich.edu } 4467242Sgblack@eecs.umich.edu Dest = resTemp; 4477242Sgblack@eecs.umich.edu ''' 4487242Sgblack@eecs.umich.edu usad8Iop = InstObjParams("usad8", "Usad8", "RegRegRegOp", 4497242Sgblack@eecs.umich.edu { "code": usad8Code, 4507242Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 4517242Sgblack@eecs.umich.edu header_output += RegRegRegOpDeclare.subst(usad8Iop) 4527242Sgblack@eecs.umich.edu decoder_output += RegRegRegOpConstructor.subst(usad8Iop) 4537242Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(usad8Iop) 4547242Sgblack@eecs.umich.edu 4557242Sgblack@eecs.umich.edu usada8Code = ''' 4567242Sgblack@eecs.umich.edu uint32_t resTemp = 0; 4577242Sgblack@eecs.umich.edu for (unsigned i = 0; i < 4; i++) { 4587242Sgblack@eecs.umich.edu int low = i * 8; 4597242Sgblack@eecs.umich.edu int high = low + 7; 4607242Sgblack@eecs.umich.edu int32_t diff = bits(Op1, high, low) - 4617242Sgblack@eecs.umich.edu bits(Op2, high, low); 4627242Sgblack@eecs.umich.edu resTemp += ((diff < 0) ? -diff : diff); 4637242Sgblack@eecs.umich.edu } 4647242Sgblack@eecs.umich.edu Dest = Op3 + resTemp; 4657242Sgblack@eecs.umich.edu ''' 4667242Sgblack@eecs.umich.edu usada8Iop = InstObjParams("usada8", "Usada8", "RegRegRegRegOp", 4677242Sgblack@eecs.umich.edu { "code": usada8Code, 4687242Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 4697242Sgblack@eecs.umich.edu header_output += RegRegRegRegOpDeclare.subst(usada8Iop) 4707242Sgblack@eecs.umich.edu decoder_output += RegRegRegRegOpConstructor.subst(usada8Iop) 4717242Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(usada8Iop) 4727247Sgblack@eecs.umich.edu 4737797Sgblack@eecs.umich.edu bkptCode = 'return new PrefetchAbort(PC, ArmFault::DebugEvent);\n' 4747848SAli.Saidi@ARM.com bkptIop = InstObjParams("bkpt", "BkptInst", "PredOp", bkptCode) 4757410Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(bkptIop) 4767410Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(bkptIop) 4777410Sgblack@eecs.umich.edu exec_output += BasicExecute.subst(bkptIop) 4787410Sgblack@eecs.umich.edu 4797408Sgblack@eecs.umich.edu nopIop = InstObjParams("nop", "NopInst", "PredOp", \ 4807408Sgblack@eecs.umich.edu { "code" : "", "predicate_test" : predicateTest }) 4817247Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(nopIop) 4827247Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(nopIop) 4837408Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(nopIop) 4847408Sgblack@eecs.umich.edu 4857418Sgblack@eecs.umich.edu yieldIop = InstObjParams("yield", "YieldInst", "PredOp", \ 4867418Sgblack@eecs.umich.edu { "code" : "", "predicate_test" : predicateTest }) 4877418Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(yieldIop) 4887418Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(yieldIop) 4897418Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(yieldIop) 4907418Sgblack@eecs.umich.edu 4917418Sgblack@eecs.umich.edu wfeCode = ''' 4927418Sgblack@eecs.umich.edu#if FULL_SYSTEM 4937418Sgblack@eecs.umich.edu if (SevMailbox) 4947418Sgblack@eecs.umich.edu SevMailbox = 0; 4957418Sgblack@eecs.umich.edu else 4967418Sgblack@eecs.umich.edu PseudoInst::quiesce(xc->tcBase()); 4977418Sgblack@eecs.umich.edu#endif 4987418Sgblack@eecs.umich.edu ''' 4997418Sgblack@eecs.umich.edu wfeIop = InstObjParams("wfe", "WfeInst", "PredOp", \ 5007418Sgblack@eecs.umich.edu { "code" : wfeCode, "predicate_test" : predicateTest }, 5017648SAli.Saidi@ARM.com ["IsNonSpeculative", "IsQuiesce", "IsSerializeAfter"]) 5027418Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(wfeIop) 5037418Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(wfeIop) 5047418Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(wfeIop) 5057418Sgblack@eecs.umich.edu 5067418Sgblack@eecs.umich.edu wfiCode = ''' 5077418Sgblack@eecs.umich.edu#if FULL_SYSTEM 5087418Sgblack@eecs.umich.edu PseudoInst::quiesce(xc->tcBase()); 5097418Sgblack@eecs.umich.edu#endif 5107418Sgblack@eecs.umich.edu ''' 5117418Sgblack@eecs.umich.edu wfiIop = InstObjParams("wfi", "WfiInst", "PredOp", \ 5127418Sgblack@eecs.umich.edu { "code" : wfiCode, "predicate_test" : predicateTest }, 5137418Sgblack@eecs.umich.edu ["IsNonSpeculative", "IsQuiesce"]) 5147418Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(wfiIop) 5157418Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(wfiIop) 5167418Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(wfiIop) 5177418Sgblack@eecs.umich.edu 5187418Sgblack@eecs.umich.edu sevCode = ''' 5197418Sgblack@eecs.umich.edu // Need a way for O3 to not scoreboard these accesses as pipe flushes. 5207418Sgblack@eecs.umich.edu System *sys = xc->tcBase()->getSystemPtr(); 5217418Sgblack@eecs.umich.edu for (int x = 0; x < sys->numContexts(); x++) { 5227418Sgblack@eecs.umich.edu ThreadContext *oc = sys->getThreadContext(x); 5237418Sgblack@eecs.umich.edu oc->setMiscReg(MISCREG_SEV_MAILBOX, 1); 5247418Sgblack@eecs.umich.edu } 5257418Sgblack@eecs.umich.edu ''' 5267418Sgblack@eecs.umich.edu sevIop = InstObjParams("sev", "SevInst", "PredOp", \ 5277418Sgblack@eecs.umich.edu { "code" : sevCode, "predicate_test" : predicateTest }, 5287648SAli.Saidi@ARM.com ["IsNonSpeculative", "IsQuiesce", "IsSerializeAfter"]) 5297418Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(sevIop) 5307418Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(sevIop) 5317418Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sevIop) 5327418Sgblack@eecs.umich.edu 5337408Sgblack@eecs.umich.edu itIop = InstObjParams("it", "ItInst", "PredOp", \ 5347408Sgblack@eecs.umich.edu { "code" : "Itstate = machInst.newItstate;", 5357648SAli.Saidi@ARM.com "predicate_test" : predicateTest }, 5367648SAli.Saidi@ARM.com ["IsNonSpeculative", "IsSerializeAfter"]) 5377408Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(itIop) 5387408Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(itIop) 5397408Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(itIop) 5407409Sgblack@eecs.umich.edu unknownCode = ''' 5417409Sgblack@eecs.umich.edu#if FULL_SYSTEM 5427409Sgblack@eecs.umich.edu return new UndefinedInstruction; 5437409Sgblack@eecs.umich.edu#else 5447409Sgblack@eecs.umich.edu return new UndefinedInstruction(machInst, true); 5457409Sgblack@eecs.umich.edu#endif 5467409Sgblack@eecs.umich.edu ''' 5477409Sgblack@eecs.umich.edu unknownIop = InstObjParams("unknown", "Unknown", "UnknownOp", \ 5487409Sgblack@eecs.umich.edu { "code": unknownCode, 5497409Sgblack@eecs.umich.edu "predicate_test": predicateTest }) 5507409Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(unknownIop) 5517409Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(unknownIop) 5527409Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(unknownIop) 5537254Sgblack@eecs.umich.edu 5547254Sgblack@eecs.umich.edu ubfxCode = ''' 5557254Sgblack@eecs.umich.edu Dest = bits(Op1, imm2, imm1); 5567254Sgblack@eecs.umich.edu ''' 5577254Sgblack@eecs.umich.edu ubfxIop = InstObjParams("ubfx", "Ubfx", "RegRegImmImmOp", 5587254Sgblack@eecs.umich.edu { "code": ubfxCode, 5597254Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 5607254Sgblack@eecs.umich.edu header_output += RegRegImmImmOpDeclare.subst(ubfxIop) 5617254Sgblack@eecs.umich.edu decoder_output += RegRegImmImmOpConstructor.subst(ubfxIop) 5627254Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(ubfxIop) 5637254Sgblack@eecs.umich.edu 5647254Sgblack@eecs.umich.edu sbfxCode = ''' 5657254Sgblack@eecs.umich.edu int32_t resTemp = bits(Op1, imm2, imm1); 5667254Sgblack@eecs.umich.edu Dest = resTemp | -(resTemp & (1 << (imm2 - imm1))); 5677254Sgblack@eecs.umich.edu ''' 5687254Sgblack@eecs.umich.edu sbfxIop = InstObjParams("sbfx", "Sbfx", "RegRegImmImmOp", 5697254Sgblack@eecs.umich.edu { "code": sbfxCode, 5707254Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 5717254Sgblack@eecs.umich.edu header_output += RegRegImmImmOpDeclare.subst(sbfxIop) 5727254Sgblack@eecs.umich.edu decoder_output += RegRegImmImmOpConstructor.subst(sbfxIop) 5737254Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sbfxIop) 5747257Sgblack@eecs.umich.edu 5757257Sgblack@eecs.umich.edu bfcCode = ''' 5767257Sgblack@eecs.umich.edu Dest = Op1 & ~(mask(imm2 - imm1 + 1) << imm1); 5777257Sgblack@eecs.umich.edu ''' 5787257Sgblack@eecs.umich.edu bfcIop = InstObjParams("bfc", "Bfc", "RegRegImmImmOp", 5797257Sgblack@eecs.umich.edu { "code": bfcCode, 5807257Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 5817257Sgblack@eecs.umich.edu header_output += RegRegImmImmOpDeclare.subst(bfcIop) 5827257Sgblack@eecs.umich.edu decoder_output += RegRegImmImmOpConstructor.subst(bfcIop) 5837257Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(bfcIop) 5847257Sgblack@eecs.umich.edu 5857257Sgblack@eecs.umich.edu bfiCode = ''' 5867257Sgblack@eecs.umich.edu uint32_t bitMask = (mask(imm2 - imm1 + 1) << imm1); 5877257Sgblack@eecs.umich.edu Dest = ((Op1 << imm1) & bitMask) | (Dest & ~bitMask); 5887257Sgblack@eecs.umich.edu ''' 5897257Sgblack@eecs.umich.edu bfiIop = InstObjParams("bfi", "Bfi", "RegRegImmImmOp", 5907257Sgblack@eecs.umich.edu { "code": bfiCode, 5917257Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 5927257Sgblack@eecs.umich.edu header_output += RegRegImmImmOpDeclare.subst(bfiIop) 5937257Sgblack@eecs.umich.edu decoder_output += RegRegImmImmOpConstructor.subst(bfiIop) 5947257Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(bfiIop) 5957262Sgblack@eecs.umich.edu 5967347SAli.Saidi@ARM.com mrc15code = ''' 5977347SAli.Saidi@ARM.com CPSR cpsr = Cpsr; 5987347SAli.Saidi@ARM.com if (cpsr.mode == MODE_USER) 5997347SAli.Saidi@ARM.com#if FULL_SYSTEM 6007347SAli.Saidi@ARM.com return new UndefinedInstruction; 6017347SAli.Saidi@ARM.com#else 6027347SAli.Saidi@ARM.com return new UndefinedInstruction(false, mnemonic); 6037347SAli.Saidi@ARM.com#endif 6047347SAli.Saidi@ARM.com Dest = MiscOp1; 6057347SAli.Saidi@ARM.com ''' 6067347SAli.Saidi@ARM.com 6077262Sgblack@eecs.umich.edu mrc15Iop = InstObjParams("mrc", "Mrc15", "RegRegOp", 6087347SAli.Saidi@ARM.com { "code": mrc15code, 6097262Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 6107262Sgblack@eecs.umich.edu header_output += RegRegOpDeclare.subst(mrc15Iop) 6117262Sgblack@eecs.umich.edu decoder_output += RegRegOpConstructor.subst(mrc15Iop) 6127262Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(mrc15Iop) 6137262Sgblack@eecs.umich.edu 6147347SAli.Saidi@ARM.com 6157347SAli.Saidi@ARM.com mcr15code = ''' 6167347SAli.Saidi@ARM.com CPSR cpsr = Cpsr; 6177347SAli.Saidi@ARM.com if (cpsr.mode == MODE_USER) 6187347SAli.Saidi@ARM.com#if FULL_SYSTEM 6197347SAli.Saidi@ARM.com return new UndefinedInstruction; 6207347SAli.Saidi@ARM.com#else 6217347SAli.Saidi@ARM.com return new UndefinedInstruction(false, mnemonic); 6227347SAli.Saidi@ARM.com#endif 6237347SAli.Saidi@ARM.com MiscDest = Op1; 6247347SAli.Saidi@ARM.com ''' 6257262Sgblack@eecs.umich.edu mcr15Iop = InstObjParams("mcr", "Mcr15", "RegRegOp", 6267347SAli.Saidi@ARM.com { "code": mcr15code, 6277599Sminkyu.jeong@arm.com "predicate_test": predicateTest }, 6287599Sminkyu.jeong@arm.com ["IsSerializeAfter","IsNonSpeculative"]) 6297262Sgblack@eecs.umich.edu header_output += RegRegOpDeclare.subst(mcr15Iop) 6307262Sgblack@eecs.umich.edu decoder_output += RegRegOpConstructor.subst(mcr15Iop) 6317262Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(mcr15Iop) 6327283Sgblack@eecs.umich.edu 6337420Sgblack@eecs.umich.edu mrc15UserIop = InstObjParams("mrc", "Mrc15User", "RegRegOp", 6347420Sgblack@eecs.umich.edu { "code": "Dest = MiscOp1;", 6357420Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 6367420Sgblack@eecs.umich.edu header_output += RegRegOpDeclare.subst(mrc15UserIop) 6377420Sgblack@eecs.umich.edu decoder_output += RegRegOpConstructor.subst(mrc15UserIop) 6387420Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(mrc15UserIop) 6397420Sgblack@eecs.umich.edu 6407420Sgblack@eecs.umich.edu mcr15UserIop = InstObjParams("mcr", "Mcr15User", "RegRegOp", 6417420Sgblack@eecs.umich.edu { "code": "MiscDest = Op1", 6427599Sminkyu.jeong@arm.com "predicate_test": predicateTest }, 6437599Sminkyu.jeong@arm.com ["IsSerializeAfter","IsNonSpeculative"]) 6447420Sgblack@eecs.umich.edu header_output += RegRegOpDeclare.subst(mcr15UserIop) 6457420Sgblack@eecs.umich.edu decoder_output += RegRegOpConstructor.subst(mcr15UserIop) 6467420Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(mcr15UserIop) 6477420Sgblack@eecs.umich.edu 6487283Sgblack@eecs.umich.edu enterxCode = ''' 6497797Sgblack@eecs.umich.edu NextThumb = true; 6507797Sgblack@eecs.umich.edu NextJazelle = true; 6517283Sgblack@eecs.umich.edu ''' 6527283Sgblack@eecs.umich.edu enterxIop = InstObjParams("enterx", "Enterx", "PredOp", 6537283Sgblack@eecs.umich.edu { "code": enterxCode, 6547283Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 6557283Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(enterxIop) 6567283Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(enterxIop) 6577283Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(enterxIop) 6587283Sgblack@eecs.umich.edu 6597283Sgblack@eecs.umich.edu leavexCode = ''' 6607797Sgblack@eecs.umich.edu NextThumb = true; 6617797Sgblack@eecs.umich.edu NextJazelle = false; 6627283Sgblack@eecs.umich.edu ''' 6637283Sgblack@eecs.umich.edu leavexIop = InstObjParams("leavex", "Leavex", "PredOp", 6647283Sgblack@eecs.umich.edu { "code": leavexCode, 6657283Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 6667283Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(leavexIop) 6677283Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(leavexIop) 6687283Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(leavexIop) 6697307Sgblack@eecs.umich.edu 6707307Sgblack@eecs.umich.edu setendCode = ''' 6717307Sgblack@eecs.umich.edu CPSR cpsr = Cpsr; 6727307Sgblack@eecs.umich.edu cpsr.e = imm; 6737307Sgblack@eecs.umich.edu Cpsr = cpsr; 6747307Sgblack@eecs.umich.edu ''' 6757307Sgblack@eecs.umich.edu setendIop = InstObjParams("setend", "Setend", "ImmOp", 6767307Sgblack@eecs.umich.edu { "code": setendCode, 6777648SAli.Saidi@ARM.com "predicate_test": predicateTest }, 6787648SAli.Saidi@ARM.com ["IsSerializeAfter","IsNonSpeculative"]) 6797307Sgblack@eecs.umich.edu header_output += ImmOpDeclare.subst(setendIop) 6807307Sgblack@eecs.umich.edu decoder_output += ImmOpConstructor.subst(setendIop) 6817307Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(setendIop) 6827315Sgblack@eecs.umich.edu 6837603SGene.Wu@arm.com clrexCode = ''' 6847705Sgblack@eecs.umich.edu unsigned memAccessFlags = Request::CLEAR_LL | 6857705Sgblack@eecs.umich.edu ArmISA::TLB::AlignWord | Request::LLSC; 6867603SGene.Wu@arm.com fault = xc->read(0, (uint32_t&)Mem, memAccessFlags); 6877603SGene.Wu@arm.com ''' 6887603SGene.Wu@arm.com clrexIop = InstObjParams("clrex", "Clrex","PredOp", 6897603SGene.Wu@arm.com { "code": clrexCode, 6907603SGene.Wu@arm.com "predicate_test": predicateTest },[]) 6917609SGene.Wu@arm.com header_output += ClrexDeclare.subst(clrexIop) 6927603SGene.Wu@arm.com decoder_output += BasicConstructor.subst(clrexIop) 6937603SGene.Wu@arm.com exec_output += PredOpExecute.subst(clrexIop) 6947609SGene.Wu@arm.com exec_output += ClrexInitiateAcc.subst(clrexIop) 6957609SGene.Wu@arm.com exec_output += ClrexCompleteAcc.subst(clrexIop) 6967603SGene.Wu@arm.com 6977605SGene.Wu@arm.com isbCode = ''' 6987605SGene.Wu@arm.com ''' 6997605SGene.Wu@arm.com isbIop = InstObjParams("isb", "Isb", "PredOp", 7007605SGene.Wu@arm.com {"code": isbCode, 7017605SGene.Wu@arm.com "predicate_test": predicateTest}, ['IsSerializing']) 7027605SGene.Wu@arm.com header_output += BasicDeclare.subst(isbIop) 7037605SGene.Wu@arm.com decoder_output += BasicConstructor.subst(isbIop) 7047605SGene.Wu@arm.com exec_output += PredOpExecute.subst(isbIop) 7057605SGene.Wu@arm.com 7067605SGene.Wu@arm.com dsbCode = ''' 7077605SGene.Wu@arm.com ''' 7087605SGene.Wu@arm.com dsbIop = InstObjParams("dsb", "Dsb", "PredOp", 7097605SGene.Wu@arm.com {"code": dsbCode, 7107605SGene.Wu@arm.com "predicate_test": predicateTest},['IsMemBarrier']) 7117605SGene.Wu@arm.com header_output += BasicDeclare.subst(dsbIop) 7127605SGene.Wu@arm.com decoder_output += BasicConstructor.subst(dsbIop) 7137605SGene.Wu@arm.com exec_output += PredOpExecute.subst(dsbIop) 7147605SGene.Wu@arm.com 7157605SGene.Wu@arm.com dmbCode = ''' 7167605SGene.Wu@arm.com ''' 7177605SGene.Wu@arm.com dmbIop = InstObjParams("dmb", "Dmb", "PredOp", 7187605SGene.Wu@arm.com {"code": dmbCode, 7197605SGene.Wu@arm.com "predicate_test": predicateTest},['IsMemBarrier']) 7207605SGene.Wu@arm.com header_output += BasicDeclare.subst(dmbIop) 7217605SGene.Wu@arm.com decoder_output += BasicConstructor.subst(dmbIop) 7227605SGene.Wu@arm.com exec_output += PredOpExecute.subst(dmbIop) 7237605SGene.Wu@arm.com 7247613SGene.Wu@arm.com dbgCode = ''' 7257613SGene.Wu@arm.com ''' 7267613SGene.Wu@arm.com dbgIop = InstObjParams("dbg", "Dbg", "PredOp", 7277613SGene.Wu@arm.com {"code": dbgCode, 7287613SGene.Wu@arm.com "predicate_test": predicateTest}) 7297613SGene.Wu@arm.com header_output += BasicDeclare.subst(dbgIop) 7307613SGene.Wu@arm.com decoder_output += BasicConstructor.subst(dbgIop) 7317613SGene.Wu@arm.com exec_output += PredOpExecute.subst(dbgIop) 7327613SGene.Wu@arm.com 7337315Sgblack@eecs.umich.edu cpsCode = ''' 7347315Sgblack@eecs.umich.edu uint32_t mode = bits(imm, 4, 0); 7357315Sgblack@eecs.umich.edu uint32_t f = bits(imm, 5); 7367315Sgblack@eecs.umich.edu uint32_t i = bits(imm, 6); 7377315Sgblack@eecs.umich.edu uint32_t a = bits(imm, 7); 7387315Sgblack@eecs.umich.edu bool setMode = bits(imm, 8); 7397315Sgblack@eecs.umich.edu bool enable = bits(imm, 9); 7407315Sgblack@eecs.umich.edu CPSR cpsr = Cpsr; 7417400SAli.Saidi@ARM.com SCTLR sctlr = Sctlr; 7427315Sgblack@eecs.umich.edu if (cpsr.mode != MODE_USER) { 7437315Sgblack@eecs.umich.edu if (enable) { 7447315Sgblack@eecs.umich.edu if (f) cpsr.f = 0; 7457315Sgblack@eecs.umich.edu if (i) cpsr.i = 0; 7467315Sgblack@eecs.umich.edu if (a) cpsr.a = 0; 7477315Sgblack@eecs.umich.edu } else { 7487400SAli.Saidi@ARM.com if (f && !sctlr.nmfi) cpsr.f = 1; 7497315Sgblack@eecs.umich.edu if (i) cpsr.i = 1; 7507315Sgblack@eecs.umich.edu if (a) cpsr.a = 1; 7517315Sgblack@eecs.umich.edu } 7527315Sgblack@eecs.umich.edu if (setMode) { 7537315Sgblack@eecs.umich.edu cpsr.mode = mode; 7547315Sgblack@eecs.umich.edu } 7557315Sgblack@eecs.umich.edu } 7567315Sgblack@eecs.umich.edu Cpsr = cpsr; 7577315Sgblack@eecs.umich.edu ''' 7587315Sgblack@eecs.umich.edu cpsIop = InstObjParams("cps", "Cps", "ImmOp", 7597315Sgblack@eecs.umich.edu { "code": cpsCode, 7607599Sminkyu.jeong@arm.com "predicate_test": predicateTest }, 7617599Sminkyu.jeong@arm.com ["IsSerializeAfter","IsNonSpeculative"]) 7627315Sgblack@eecs.umich.edu header_output += ImmOpDeclare.subst(cpsIop) 7637315Sgblack@eecs.umich.edu decoder_output += ImmOpConstructor.subst(cpsIop) 7647315Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(cpsIop) 7657202Sgblack@eecs.umich.edu}}; 766