misc.isa revision 7247
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, 667202Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 677202Sgblack@eecs.umich.edu header_output += MrsDeclare.subst(mrsCpsrIop) 687202Sgblack@eecs.umich.edu decoder_output += MrsConstructor.subst(mrsCpsrIop) 697202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(mrsCpsrIop) 707202Sgblack@eecs.umich.edu 717202Sgblack@eecs.umich.edu mrsSpsrCode = "Dest = Spsr" 727202Sgblack@eecs.umich.edu mrsSpsrIop = InstObjParams("mrs", "MrsSpsr", "MrsOp", 737202Sgblack@eecs.umich.edu { "code": mrsSpsrCode, 747202Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 757202Sgblack@eecs.umich.edu header_output += MrsDeclare.subst(mrsSpsrIop) 767202Sgblack@eecs.umich.edu decoder_output += MrsConstructor.subst(mrsSpsrIop) 777202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(mrsSpsrIop) 787202Sgblack@eecs.umich.edu 797202Sgblack@eecs.umich.edu msrCpsrRegCode = ''' 807202Sgblack@eecs.umich.edu uint32_t newCpsr = 817202Sgblack@eecs.umich.edu cpsrWriteByInstr(Cpsr | CondCodes, Op1, byteMask, false); 827202Sgblack@eecs.umich.edu Cpsr = ~CondCodesMask & newCpsr; 837202Sgblack@eecs.umich.edu CondCodes = CondCodesMask & newCpsr; 847202Sgblack@eecs.umich.edu ''' 857202Sgblack@eecs.umich.edu msrCpsrRegIop = InstObjParams("msr", "MsrCpsrReg", "MsrRegOp", 867202Sgblack@eecs.umich.edu { "code": msrCpsrRegCode, 877202Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 887202Sgblack@eecs.umich.edu header_output += MsrRegDeclare.subst(msrCpsrRegIop) 897202Sgblack@eecs.umich.edu decoder_output += MsrRegConstructor.subst(msrCpsrRegIop) 907202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(msrCpsrRegIop) 917202Sgblack@eecs.umich.edu 927202Sgblack@eecs.umich.edu msrSpsrRegCode = "Spsr = spsrWriteByInstr(Spsr, Op1, byteMask, false);" 937202Sgblack@eecs.umich.edu msrSpsrRegIop = InstObjParams("msr", "MsrSpsrReg", "MsrRegOp", 947202Sgblack@eecs.umich.edu { "code": msrSpsrRegCode, 957202Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 967202Sgblack@eecs.umich.edu header_output += MsrRegDeclare.subst(msrSpsrRegIop) 977202Sgblack@eecs.umich.edu decoder_output += MsrRegConstructor.subst(msrSpsrRegIop) 987202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(msrSpsrRegIop) 997202Sgblack@eecs.umich.edu 1007202Sgblack@eecs.umich.edu msrCpsrImmCode = ''' 1017202Sgblack@eecs.umich.edu uint32_t newCpsr = 1027202Sgblack@eecs.umich.edu cpsrWriteByInstr(Cpsr | CondCodes, imm, byteMask, false); 1037202Sgblack@eecs.umich.edu Cpsr = ~CondCodesMask & newCpsr; 1047202Sgblack@eecs.umich.edu CondCodes = CondCodesMask & newCpsr; 1057202Sgblack@eecs.umich.edu ''' 1067202Sgblack@eecs.umich.edu msrCpsrImmIop = InstObjParams("msr", "MsrCpsrImm", "MsrImmOp", 1077202Sgblack@eecs.umich.edu { "code": msrCpsrImmCode, 1087202Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1097202Sgblack@eecs.umich.edu header_output += MsrImmDeclare.subst(msrCpsrImmIop) 1107202Sgblack@eecs.umich.edu decoder_output += MsrImmConstructor.subst(msrCpsrImmIop) 1117202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(msrCpsrImmIop) 1127202Sgblack@eecs.umich.edu 1137202Sgblack@eecs.umich.edu msrSpsrImmCode = "Spsr = spsrWriteByInstr(Spsr, imm, byteMask, false);" 1147202Sgblack@eecs.umich.edu msrSpsrImmIop = InstObjParams("msr", "MsrSpsrImm", "MsrImmOp", 1157202Sgblack@eecs.umich.edu { "code": msrSpsrImmCode, 1167202Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1177202Sgblack@eecs.umich.edu header_output += MsrImmDeclare.subst(msrSpsrImmIop) 1187202Sgblack@eecs.umich.edu decoder_output += MsrImmConstructor.subst(msrSpsrImmIop) 1197202Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(msrSpsrImmIop) 1207209Sgblack@eecs.umich.edu 1217209Sgblack@eecs.umich.edu revCode = ''' 1227209Sgblack@eecs.umich.edu uint32_t val = Op1; 1237209Sgblack@eecs.umich.edu Dest = swap_byte(val); 1247209Sgblack@eecs.umich.edu ''' 1257209Sgblack@eecs.umich.edu revIop = InstObjParams("rev", "Rev", "RevOp", 1267209Sgblack@eecs.umich.edu { "code": revCode, 1277209Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1287209Sgblack@eecs.umich.edu header_output += RevOpDeclare.subst(revIop) 1297209Sgblack@eecs.umich.edu decoder_output += RevOpConstructor.subst(revIop) 1307209Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(revIop) 1317209Sgblack@eecs.umich.edu 1327209Sgblack@eecs.umich.edu rev16Code = ''' 1337209Sgblack@eecs.umich.edu uint32_t val = Op1; 1347209Sgblack@eecs.umich.edu Dest = (bits(val, 15, 8) << 0) | 1357209Sgblack@eecs.umich.edu (bits(val, 7, 0) << 8) | 1367209Sgblack@eecs.umich.edu (bits(val, 31, 24) << 16) | 1377209Sgblack@eecs.umich.edu (bits(val, 23, 16) << 24); 1387209Sgblack@eecs.umich.edu ''' 1397209Sgblack@eecs.umich.edu rev16Iop = InstObjParams("rev16", "Rev16", "RevOp", 1407209Sgblack@eecs.umich.edu { "code": rev16Code, 1417209Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1427209Sgblack@eecs.umich.edu header_output += RevOpDeclare.subst(rev16Iop) 1437209Sgblack@eecs.umich.edu decoder_output += RevOpConstructor.subst(rev16Iop) 1447209Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(rev16Iop) 1457209Sgblack@eecs.umich.edu 1467209Sgblack@eecs.umich.edu revshCode = ''' 1477209Sgblack@eecs.umich.edu uint16_t val = Op1; 1487209Sgblack@eecs.umich.edu Dest = sext<16>(swap_byte(val)); 1497209Sgblack@eecs.umich.edu ''' 1507209Sgblack@eecs.umich.edu revshIop = InstObjParams("revsh", "Revsh", "RevOp", 1517209Sgblack@eecs.umich.edu { "code": revshCode, 1527209Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1537209Sgblack@eecs.umich.edu header_output += RevOpDeclare.subst(revshIop) 1547209Sgblack@eecs.umich.edu decoder_output += RevOpConstructor.subst(revshIop) 1557209Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(revshIop) 1567226Sgblack@eecs.umich.edu 1577226Sgblack@eecs.umich.edu ssatCode = ''' 1587226Sgblack@eecs.umich.edu int32_t operand = shift_rm_imm(Op1, shiftAmt, shiftType, 0); 1597226Sgblack@eecs.umich.edu int32_t res; 1607232Sgblack@eecs.umich.edu if (satInt(res, operand, imm)) 1617226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 1627226Sgblack@eecs.umich.edu else 1637226Sgblack@eecs.umich.edu CondCodes = CondCodes; 1647226Sgblack@eecs.umich.edu Dest = res; 1657226Sgblack@eecs.umich.edu ''' 1667232Sgblack@eecs.umich.edu ssatIop = InstObjParams("ssat", "Ssat", "RegImmRegShiftOp", 1677226Sgblack@eecs.umich.edu { "code": ssatCode, 1687226Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1697232Sgblack@eecs.umich.edu header_output += RegImmRegShiftOpDeclare.subst(ssatIop) 1707232Sgblack@eecs.umich.edu decoder_output += RegImmRegShiftOpConstructor.subst(ssatIop) 1717226Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(ssatIop) 1727226Sgblack@eecs.umich.edu 1737226Sgblack@eecs.umich.edu usatCode = ''' 1747226Sgblack@eecs.umich.edu int32_t operand = shift_rm_imm(Op1, shiftAmt, shiftType, 0); 1757226Sgblack@eecs.umich.edu int32_t res; 1767232Sgblack@eecs.umich.edu if (uSatInt(res, operand, imm)) 1777226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 1787226Sgblack@eecs.umich.edu else 1797226Sgblack@eecs.umich.edu CondCodes = CondCodes; 1807226Sgblack@eecs.umich.edu Dest = res; 1817226Sgblack@eecs.umich.edu ''' 1827232Sgblack@eecs.umich.edu usatIop = InstObjParams("usat", "Usat", "RegImmRegShiftOp", 1837226Sgblack@eecs.umich.edu { "code": usatCode, 1847226Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 1857232Sgblack@eecs.umich.edu header_output += RegImmRegShiftOpDeclare.subst(usatIop) 1867232Sgblack@eecs.umich.edu decoder_output += RegImmRegShiftOpConstructor.subst(usatIop) 1877226Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(usatIop) 1887226Sgblack@eecs.umich.edu 1897226Sgblack@eecs.umich.edu ssat16Code = ''' 1907226Sgblack@eecs.umich.edu int32_t res; 1917226Sgblack@eecs.umich.edu uint32_t resTemp = 0; 1927226Sgblack@eecs.umich.edu CondCodes = CondCodes; 1937226Sgblack@eecs.umich.edu int32_t argLow = sext<16>(bits(Op1, 15, 0)); 1947226Sgblack@eecs.umich.edu int32_t argHigh = sext<16>(bits(Op1, 31, 16)); 1957232Sgblack@eecs.umich.edu if (satInt(res, argLow, imm)) 1967226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 1977226Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, res); 1987232Sgblack@eecs.umich.edu if (satInt(res, argHigh, imm)) 1997226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 2007226Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, res); 2017226Sgblack@eecs.umich.edu Dest = resTemp; 2027226Sgblack@eecs.umich.edu ''' 2037232Sgblack@eecs.umich.edu ssat16Iop = InstObjParams("ssat16", "Ssat16", "RegImmRegOp", 2047226Sgblack@eecs.umich.edu { "code": ssat16Code, 2057226Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 2067232Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(ssat16Iop) 2077232Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(ssat16Iop) 2087226Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(ssat16Iop) 2097226Sgblack@eecs.umich.edu 2107226Sgblack@eecs.umich.edu usat16Code = ''' 2117226Sgblack@eecs.umich.edu int32_t res; 2127226Sgblack@eecs.umich.edu uint32_t resTemp = 0; 2137226Sgblack@eecs.umich.edu CondCodes = CondCodes; 2147226Sgblack@eecs.umich.edu int32_t argLow = sext<16>(bits(Op1, 15, 0)); 2157226Sgblack@eecs.umich.edu int32_t argHigh = sext<16>(bits(Op1, 31, 16)); 2167232Sgblack@eecs.umich.edu if (uSatInt(res, argLow, imm)) 2177226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 2187226Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, res); 2197232Sgblack@eecs.umich.edu if (uSatInt(res, argHigh, imm)) 2207226Sgblack@eecs.umich.edu CondCodes = CondCodes | (1 << 27); 2217226Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, res); 2227226Sgblack@eecs.umich.edu Dest = resTemp; 2237226Sgblack@eecs.umich.edu ''' 2247232Sgblack@eecs.umich.edu usat16Iop = InstObjParams("usat16", "Usat16", "RegImmRegOp", 2257226Sgblack@eecs.umich.edu { "code": usat16Code, 2267226Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 2277232Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(usat16Iop) 2287232Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(usat16Iop) 2297226Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(usat16Iop) 2307234Sgblack@eecs.umich.edu 2317234Sgblack@eecs.umich.edu sxtbIop = InstObjParams("sxtb", "Sxtb", "RegImmRegOp", 2327234Sgblack@eecs.umich.edu { "code": 2337234Sgblack@eecs.umich.edu "Dest = sext<8>((uint8_t)(Op1.ud >> imm));", 2347234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 2357234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(sxtbIop) 2367234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(sxtbIop) 2377234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtbIop) 2387234Sgblack@eecs.umich.edu 2397234Sgblack@eecs.umich.edu sxtabIop = InstObjParams("sxtab", "Sxtab", "RegRegRegImmOp", 2407234Sgblack@eecs.umich.edu { "code": 2417234Sgblack@eecs.umich.edu ''' 2427234Sgblack@eecs.umich.edu Dest = sext<8>((uint8_t)(Op2.ud >> imm)) + 2437234Sgblack@eecs.umich.edu Op1; 2447234Sgblack@eecs.umich.edu ''', 2457234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 2467234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(sxtabIop) 2477234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(sxtabIop) 2487234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtabIop) 2497234Sgblack@eecs.umich.edu 2507234Sgblack@eecs.umich.edu sxtb16Code = ''' 2517234Sgblack@eecs.umich.edu uint32_t resTemp = 0; 2527234Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, sext<8>(bits(Op1, imm + 7, imm))); 2537234Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, 2547234Sgblack@eecs.umich.edu sext<8>(bits(Op1, (imm + 23) % 32, (imm + 16) % 32))); 2557234Sgblack@eecs.umich.edu Dest = resTemp; 2567234Sgblack@eecs.umich.edu ''' 2577234Sgblack@eecs.umich.edu sxtb16Iop = InstObjParams("sxtb16", "Sxtb16", "RegImmRegOp", 2587234Sgblack@eecs.umich.edu { "code": sxtb16Code, 2597234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 2607234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(sxtb16Iop) 2617234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(sxtb16Iop) 2627234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtb16Iop) 2637234Sgblack@eecs.umich.edu 2647234Sgblack@eecs.umich.edu sxtab16Code = ''' 2657234Sgblack@eecs.umich.edu uint32_t resTemp = 0; 2667234Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, sext<8>(bits(Op2, imm + 7, imm)) + 2677234Sgblack@eecs.umich.edu bits(Op1, 15, 0)); 2687234Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, 2697234Sgblack@eecs.umich.edu sext<8>(bits(Op2, (imm + 23) % 32, (imm + 16) % 32)) + 2707234Sgblack@eecs.umich.edu bits(Op1, 31, 16)); 2717234Sgblack@eecs.umich.edu Dest = resTemp; 2727234Sgblack@eecs.umich.edu ''' 2737234Sgblack@eecs.umich.edu sxtab16Iop = InstObjParams("sxtab16", "Sxtab16", "RegRegRegImmOp", 2747234Sgblack@eecs.umich.edu { "code": sxtab16Code, 2757234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 2767234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(sxtab16Iop) 2777234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(sxtab16Iop) 2787234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtab16Iop) 2797234Sgblack@eecs.umich.edu 2807234Sgblack@eecs.umich.edu sxthCode = ''' 2817234Sgblack@eecs.umich.edu uint64_t rotated = (uint32_t)Op1; 2827234Sgblack@eecs.umich.edu rotated = (rotated | (rotated << 32)) >> imm; 2837234Sgblack@eecs.umich.edu Dest = sext<16>((uint16_t)rotated); 2847234Sgblack@eecs.umich.edu ''' 2857234Sgblack@eecs.umich.edu sxthIop = InstObjParams("sxth", "Sxth", "RegImmRegOp", 2867234Sgblack@eecs.umich.edu { "code": sxthCode, 2877234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 2887234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(sxthIop) 2897234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(sxthIop) 2907234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxthIop) 2917234Sgblack@eecs.umich.edu 2927234Sgblack@eecs.umich.edu sxtahCode = ''' 2937234Sgblack@eecs.umich.edu uint64_t rotated = (uint32_t)Op2; 2947234Sgblack@eecs.umich.edu rotated = (rotated | (rotated << 32)) >> imm; 2957234Sgblack@eecs.umich.edu Dest = sext<16>((uint16_t)rotated) + Op1; 2967234Sgblack@eecs.umich.edu ''' 2977234Sgblack@eecs.umich.edu sxtahIop = InstObjParams("sxtah", "Sxtah", "RegRegRegImmOp", 2987234Sgblack@eecs.umich.edu { "code": sxtahCode, 2997234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3007234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(sxtahIop) 3017234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(sxtahIop) 3027234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(sxtahIop) 3037234Sgblack@eecs.umich.edu 3047234Sgblack@eecs.umich.edu uxtbIop = InstObjParams("uxtb", "Uxtb", "RegImmRegOp", 3057234Sgblack@eecs.umich.edu { "code": "Dest = (uint8_t)(Op1.ud >> imm);", 3067234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3077234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(uxtbIop) 3087234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(uxtbIop) 3097234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtbIop) 3107234Sgblack@eecs.umich.edu 3117234Sgblack@eecs.umich.edu uxtabIop = InstObjParams("uxtab", "Uxtab", "RegRegRegImmOp", 3127234Sgblack@eecs.umich.edu { "code": 3137234Sgblack@eecs.umich.edu "Dest = (uint8_t)(Op2.ud >> imm) + Op1;", 3147234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3157234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(uxtabIop) 3167234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(uxtabIop) 3177234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtabIop) 3187234Sgblack@eecs.umich.edu 3197234Sgblack@eecs.umich.edu uxtb16Code = ''' 3207234Sgblack@eecs.umich.edu uint32_t resTemp = 0; 3217234Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, (uint8_t)(bits(Op1, imm + 7, imm))); 3227234Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, 3237234Sgblack@eecs.umich.edu (uint8_t)(bits(Op1, (imm + 23) % 32, (imm + 16) % 32))); 3247234Sgblack@eecs.umich.edu Dest = resTemp; 3257234Sgblack@eecs.umich.edu ''' 3267234Sgblack@eecs.umich.edu uxtb16Iop = InstObjParams("uxtb16", "Uxtb16", "RegImmRegOp", 3277234Sgblack@eecs.umich.edu { "code": uxtb16Code, 3287234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3297234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(uxtb16Iop) 3307234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(uxtb16Iop) 3317234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtb16Iop) 3327234Sgblack@eecs.umich.edu 3337234Sgblack@eecs.umich.edu uxtab16Code = ''' 3347234Sgblack@eecs.umich.edu uint32_t resTemp = 0; 3357234Sgblack@eecs.umich.edu replaceBits(resTemp, 15, 0, (uint8_t)(bits(Op2, imm + 7, imm)) + 3367234Sgblack@eecs.umich.edu bits(Op1, 15, 0)); 3377234Sgblack@eecs.umich.edu replaceBits(resTemp, 31, 16, 3387234Sgblack@eecs.umich.edu (uint8_t)(bits(Op2, (imm + 23) % 32, (imm + 16) % 32)) + 3397234Sgblack@eecs.umich.edu bits(Op1, 31, 16)); 3407234Sgblack@eecs.umich.edu Dest = resTemp; 3417234Sgblack@eecs.umich.edu ''' 3427234Sgblack@eecs.umich.edu uxtab16Iop = InstObjParams("uxtab16", "Uxtab16", "RegRegRegImmOp", 3437234Sgblack@eecs.umich.edu { "code": uxtab16Code, 3447234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3457234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(uxtab16Iop) 3467234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(uxtab16Iop) 3477234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtab16Iop) 3487234Sgblack@eecs.umich.edu 3497234Sgblack@eecs.umich.edu uxthCode = ''' 3507234Sgblack@eecs.umich.edu uint64_t rotated = (uint32_t)Op1; 3517234Sgblack@eecs.umich.edu rotated = (rotated | (rotated << 32)) >> imm; 3527234Sgblack@eecs.umich.edu Dest = (uint16_t)rotated; 3537234Sgblack@eecs.umich.edu ''' 3547234Sgblack@eecs.umich.edu uxthIop = InstObjParams("uxth", "Uxth", "RegImmRegOp", 3557234Sgblack@eecs.umich.edu { "code": uxthCode, 3567234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3577234Sgblack@eecs.umich.edu header_output += RegImmRegOpDeclare.subst(uxthIop) 3587234Sgblack@eecs.umich.edu decoder_output += RegImmRegOpConstructor.subst(uxthIop) 3597234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxthIop) 3607234Sgblack@eecs.umich.edu 3617234Sgblack@eecs.umich.edu uxtahCode = ''' 3627234Sgblack@eecs.umich.edu uint64_t rotated = (uint32_t)Op2; 3637234Sgblack@eecs.umich.edu rotated = (rotated | (rotated << 32)) >> imm; 3647234Sgblack@eecs.umich.edu Dest = (uint16_t)rotated + Op1; 3657234Sgblack@eecs.umich.edu ''' 3667234Sgblack@eecs.umich.edu uxtahIop = InstObjParams("uxtah", "Uxtah", "RegRegRegImmOp", 3677234Sgblack@eecs.umich.edu { "code": uxtahCode, 3687234Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3697234Sgblack@eecs.umich.edu header_output += RegRegRegImmOpDeclare.subst(uxtahIop) 3707234Sgblack@eecs.umich.edu decoder_output += RegRegRegImmOpConstructor.subst(uxtahIop) 3717234Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(uxtahIop) 3727239Sgblack@eecs.umich.edu 3737239Sgblack@eecs.umich.edu selCode = ''' 3747239Sgblack@eecs.umich.edu uint32_t resTemp = 0; 3757239Sgblack@eecs.umich.edu for (unsigned i = 0; i < 4; i++) { 3767239Sgblack@eecs.umich.edu int low = i * 8; 3777239Sgblack@eecs.umich.edu int high = low + 7; 3787239Sgblack@eecs.umich.edu replaceBits(resTemp, high, low, 3797239Sgblack@eecs.umich.edu bits(CondCodes, 16 + i) ? 3807239Sgblack@eecs.umich.edu bits(Op1, high, low) : bits(Op2, high, low)); 3817239Sgblack@eecs.umich.edu } 3827239Sgblack@eecs.umich.edu Dest = resTemp; 3837239Sgblack@eecs.umich.edu ''' 3847239Sgblack@eecs.umich.edu selIop = InstObjParams("sel", "Sel", "RegRegRegOp", 3857239Sgblack@eecs.umich.edu { "code": selCode, 3867239Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 3877239Sgblack@eecs.umich.edu header_output += RegRegRegOpDeclare.subst(selIop) 3887239Sgblack@eecs.umich.edu decoder_output += RegRegRegOpConstructor.subst(selIop) 3897239Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(selIop) 3907242Sgblack@eecs.umich.edu 3917242Sgblack@eecs.umich.edu usad8Code = ''' 3927242Sgblack@eecs.umich.edu uint32_t resTemp = 0; 3937242Sgblack@eecs.umich.edu for (unsigned i = 0; i < 4; i++) { 3947242Sgblack@eecs.umich.edu int low = i * 8; 3957242Sgblack@eecs.umich.edu int high = low + 7; 3967242Sgblack@eecs.umich.edu int32_t diff = bits(Op1, high, low) - 3977242Sgblack@eecs.umich.edu bits(Op2, high, low); 3987242Sgblack@eecs.umich.edu resTemp += ((diff < 0) ? -diff : diff); 3997242Sgblack@eecs.umich.edu } 4007242Sgblack@eecs.umich.edu Dest = resTemp; 4017242Sgblack@eecs.umich.edu ''' 4027242Sgblack@eecs.umich.edu usad8Iop = InstObjParams("usad8", "Usad8", "RegRegRegOp", 4037242Sgblack@eecs.umich.edu { "code": usad8Code, 4047242Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 4057242Sgblack@eecs.umich.edu header_output += RegRegRegOpDeclare.subst(usad8Iop) 4067242Sgblack@eecs.umich.edu decoder_output += RegRegRegOpConstructor.subst(usad8Iop) 4077242Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(usad8Iop) 4087242Sgblack@eecs.umich.edu 4097242Sgblack@eecs.umich.edu usada8Code = ''' 4107242Sgblack@eecs.umich.edu uint32_t resTemp = 0; 4117242Sgblack@eecs.umich.edu for (unsigned i = 0; i < 4; i++) { 4127242Sgblack@eecs.umich.edu int low = i * 8; 4137242Sgblack@eecs.umich.edu int high = low + 7; 4147242Sgblack@eecs.umich.edu int32_t diff = bits(Op1, high, low) - 4157242Sgblack@eecs.umich.edu bits(Op2, high, low); 4167242Sgblack@eecs.umich.edu resTemp += ((diff < 0) ? -diff : diff); 4177242Sgblack@eecs.umich.edu } 4187242Sgblack@eecs.umich.edu Dest = Op3 + resTemp; 4197242Sgblack@eecs.umich.edu ''' 4207242Sgblack@eecs.umich.edu usada8Iop = InstObjParams("usada8", "Usada8", "RegRegRegRegOp", 4217242Sgblack@eecs.umich.edu { "code": usada8Code, 4227242Sgblack@eecs.umich.edu "predicate_test": predicateTest }, []) 4237242Sgblack@eecs.umich.edu header_output += RegRegRegRegOpDeclare.subst(usada8Iop) 4247242Sgblack@eecs.umich.edu decoder_output += RegRegRegRegOpConstructor.subst(usada8Iop) 4257242Sgblack@eecs.umich.edu exec_output += PredOpExecute.subst(usada8Iop) 4267247Sgblack@eecs.umich.edu 4277247Sgblack@eecs.umich.edu nopIop = InstObjParams("nop", "NopInst", "ArmStaticInst", "", []) 4287247Sgblack@eecs.umich.edu header_output += BasicDeclare.subst(nopIop) 4297247Sgblack@eecs.umich.edu decoder_output += BasicConstructor.subst(nopIop) 4307247Sgblack@eecs.umich.edu exec_output += BasicExecute.subst(nopIop) 4317202Sgblack@eecs.umich.edu}}; 432