str.isa revision 7296
17119SN/A// -*- mode:c++ -*- 27119SN/A 37119SN/A// Copyright (c) 2010 ARM Limited 47119SN/A// All rights reserved 57119SN/A// 67119SN/A// The license below extends only to copyright in the software and shall 77119SN/A// not be construed as granting a license to any other intellectual 87119SN/A// property including but not limited to intellectual property relating 97119SN/A// to a hardware implementation of the functionality of the software 107119SN/A// licensed hereunder. You may use the software subject to the license 117119SN/A// terms below provided that you ensure that this notice is replicated 127119SN/A// unmodified and in its entirety in all distributions of the software, 137119SN/A// modified or unmodified, in source code or in binary form. 147119SN/A// 157119SN/A// Redistribution and use in source and binary forms, with or without 167119SN/A// modification, are permitted provided that the following conditions are 177119SN/A// met: redistributions of source code must retain the above copyright 187119SN/A// notice, this list of conditions and the following disclaimer; 197119SN/A// redistributions in binary form must reproduce the above copyright 207119SN/A// notice, this list of conditions and the following disclaimer in the 217119SN/A// documentation and/or other materials provided with the distribution; 227119SN/A// neither the name of the copyright holders nor the names of its 237119SN/A// contributors may be used to endorse or promote products derived from 247119SN/A// this software without specific prior written permission. 257119SN/A// 267119SN/A// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 277119SN/A// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 287119SN/A// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 297119SN/A// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 307119SN/A// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 317119SN/A// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 327119SN/A// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 337119SN/A// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 347119SN/A// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 357119SN/A// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 367119SN/A// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 377119SN/A// 387119SN/A// Authors: Gabe Black 397119SN/A 407119SN/Alet {{ 417119SN/A 427119SN/A header_output = "" 437119SN/A decoder_output = "" 447119SN/A exec_output = "" 457119SN/A 467120Sgblack@eecs.umich.edu def storeImmClassName(post, add, writeback, \ 477120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 487120Sgblack@eecs.umich.edu return memClassName("STORE_IMM", post, add, writeback, 497119SN/A size, sign, user) 507119SN/A 517120Sgblack@eecs.umich.edu def storeRegClassName(post, add, writeback, \ 527120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 537120Sgblack@eecs.umich.edu return memClassName("STORE_REG", post, add, writeback, 547119SN/A size, sign, user) 557119SN/A 567128Sgblack@eecs.umich.edu def storeDoubleImmClassName(post, add, writeback): 577128Sgblack@eecs.umich.edu return memClassName("STORE_IMMD", post, add, writeback, 587128Sgblack@eecs.umich.edu 4, False, False) 597128Sgblack@eecs.umich.edu 607128Sgblack@eecs.umich.edu def storeDoubleRegClassName(post, add, writeback): 617128Sgblack@eecs.umich.edu return memClassName("STORE_REGD", post, add, writeback, 627128Sgblack@eecs.umich.edu 4, False, False) 637128Sgblack@eecs.umich.edu 647279Sgblack@eecs.umich.edu def emitStore(name, Name, imm, eaCode, accCode, \ 657279Sgblack@eecs.umich.edu memFlags, instFlags, base, double=False): 667119SN/A global header_output, decoder_output, exec_output 677119SN/A 687119SN/A (newHeader, 697119SN/A newDecoder, 707132Sgblack@eecs.umich.edu newExec) = loadStoreBase(name, Name, imm, 717132Sgblack@eecs.umich.edu eaCode, accCode, 727279Sgblack@eecs.umich.edu memFlags, instFlags, double, 737132Sgblack@eecs.umich.edu base, execTemplateBase = 'Store') 747119SN/A 757119SN/A header_output += newHeader 767119SN/A decoder_output += newDecoder 777119SN/A exec_output += newExec 787119SN/A 797120Sgblack@eecs.umich.edu def buildImmStore(mnem, post, add, writeback, \ 807120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 817119SN/A name = mnem 827120Sgblack@eecs.umich.edu Name = storeImmClassName(post, add, writeback, \ 837120Sgblack@eecs.umich.edu size, sign, user) 847119SN/A 857119SN/A if add: 867119SN/A op = " +" 877119SN/A else: 887119SN/A op = " -" 897119SN/A 907119SN/A offset = op + " imm" 917119SN/A eaCode = "EA = Base" 927119SN/A if not post: 937119SN/A eaCode += offset 947119SN/A eaCode += ";" 957119SN/A 967296Sgblack@eecs.umich.edu accCode = "Mem%(suffix)s = cSwap(Dest%(suffix)s, ((CPSR)Cpsr).e);" % \ 977296Sgblack@eecs.umich.edu { "suffix" : buildMemSuffix(sign, size) } 987119SN/A if writeback: 997119SN/A accCode += "Base = Base %s;\n" % offset 1007132Sgblack@eecs.umich.edu base = buildMemBase("MemoryImm", post, writeback) 1017119SN/A 1027294Sgblack@eecs.umich.edu emitStore(name, Name, True, eaCode, accCode, \ 1037294Sgblack@eecs.umich.edu ["ArmISA::TLB::MustBeOne", \ 1047294Sgblack@eecs.umich.edu "ArmISA::TLB::AllowUnaligned", \ 1057294Sgblack@eecs.umich.edu "%d" % (size - 1)], [], base) 1067119SN/A 1077120Sgblack@eecs.umich.edu def buildRegStore(mnem, post, add, writeback, \ 1087120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 1097119SN/A name = mnem 1107120Sgblack@eecs.umich.edu Name = storeRegClassName(post, add, writeback, 1117120Sgblack@eecs.umich.edu size, sign, user) 1127119SN/A 1137119SN/A if add: 1147119SN/A op = " +" 1157119SN/A else: 1167119SN/A op = " -" 1177119SN/A 1187119SN/A offset = op + " shift_rm_imm(Index, shiftAmt," + \ 1197119SN/A " shiftType, CondCodes<29:>)" 1207119SN/A eaCode = "EA = Base" 1217119SN/A if not post: 1227119SN/A eaCode += offset 1237119SN/A eaCode += ";" 1247119SN/A 1257296Sgblack@eecs.umich.edu accCode = "Mem%(suffix)s = cSwap(Dest%(suffix)s, ((CPSR)Cpsr).e);" % \ 1267296Sgblack@eecs.umich.edu { "suffix" : buildMemSuffix(sign, size) } 1277119SN/A if writeback: 1287119SN/A accCode += "Base = Base %s;\n" % offset 1297132Sgblack@eecs.umich.edu base = buildMemBase("MemoryReg", post, writeback) 1307119SN/A 1317294Sgblack@eecs.umich.edu emitStore(name, Name, False, eaCode, accCode, \ 1327294Sgblack@eecs.umich.edu ["ArmISA::TLB::MustBeOne", \ 1337294Sgblack@eecs.umich.edu "ArmISA::TLB::AllowUnaligned", \ 1347294Sgblack@eecs.umich.edu "%d" % (size - 1)], [], base) 1357119SN/A 1367128Sgblack@eecs.umich.edu def buildDoubleImmStore(mnem, post, add, writeback): 1377128Sgblack@eecs.umich.edu name = mnem 1387128Sgblack@eecs.umich.edu Name = storeDoubleImmClassName(post, add, writeback) 1397128Sgblack@eecs.umich.edu 1407128Sgblack@eecs.umich.edu if add: 1417128Sgblack@eecs.umich.edu op = " +" 1427128Sgblack@eecs.umich.edu else: 1437128Sgblack@eecs.umich.edu op = " -" 1447128Sgblack@eecs.umich.edu 1457128Sgblack@eecs.umich.edu offset = op + " imm" 1467128Sgblack@eecs.umich.edu eaCode = "EA = Base" 1477128Sgblack@eecs.umich.edu if not post: 1487128Sgblack@eecs.umich.edu eaCode += offset 1497128Sgblack@eecs.umich.edu eaCode += ";" 1507128Sgblack@eecs.umich.edu 1517296Sgblack@eecs.umich.edu accCode = ''' 1527296Sgblack@eecs.umich.edu CPSR cpsr = Cpsr; 1537296Sgblack@eecs.umich.edu Mem.ud = (uint64_t)cSwap(Dest.uw, cpsr.e) | 1547296Sgblack@eecs.umich.edu ((uint64_t)cSwap(Dest2.uw, cpsr.e) << 32); 1557296Sgblack@eecs.umich.edu ''' 1567128Sgblack@eecs.umich.edu if writeback: 1577128Sgblack@eecs.umich.edu accCode += "Base = Base %s;\n" % offset 1587279Sgblack@eecs.umich.edu base = buildMemBase("MemoryDImm", post, writeback) 1597128Sgblack@eecs.umich.edu 1607279Sgblack@eecs.umich.edu emitStore(name, Name, True, eaCode, accCode, \ 1617294Sgblack@eecs.umich.edu ["ArmISA::TLB::MustBeOne", 1627294Sgblack@eecs.umich.edu "ArmISA::TLB::AlignWord"], [], base, double=True) 1637128Sgblack@eecs.umich.edu 1647128Sgblack@eecs.umich.edu def buildDoubleRegStore(mnem, post, add, writeback): 1657128Sgblack@eecs.umich.edu name = mnem 1667128Sgblack@eecs.umich.edu Name = storeDoubleRegClassName(post, add, writeback) 1677128Sgblack@eecs.umich.edu 1687128Sgblack@eecs.umich.edu if add: 1697128Sgblack@eecs.umich.edu op = " +" 1707128Sgblack@eecs.umich.edu else: 1717128Sgblack@eecs.umich.edu op = " -" 1727128Sgblack@eecs.umich.edu 1737128Sgblack@eecs.umich.edu offset = op + " shift_rm_imm(Index, shiftAmt," + \ 1747128Sgblack@eecs.umich.edu " shiftType, CondCodes<29:>)" 1757128Sgblack@eecs.umich.edu eaCode = "EA = Base" 1767128Sgblack@eecs.umich.edu if not post: 1777128Sgblack@eecs.umich.edu eaCode += offset 1787128Sgblack@eecs.umich.edu eaCode += ";" 1797128Sgblack@eecs.umich.edu 1807296Sgblack@eecs.umich.edu accCode = ''' 1817296Sgblack@eecs.umich.edu CPSR cpsr = Cpsr; 1827296Sgblack@eecs.umich.edu Mem.ud = (uint64_t)cSwap(Dest.uw, cpsr.e) | 1837296Sgblack@eecs.umich.edu ((uint64_t)cSwap(Dest2.uw, cpsr.e) << 32); 1847296Sgblack@eecs.umich.edu ''' 1857128Sgblack@eecs.umich.edu if writeback: 1867128Sgblack@eecs.umich.edu accCode += "Base = Base %s;\n" % offset 1877279Sgblack@eecs.umich.edu base = buildMemBase("MemoryDReg", post, writeback) 1887128Sgblack@eecs.umich.edu 1897279Sgblack@eecs.umich.edu emitStore(name, Name, False, eaCode, accCode, \ 1907294Sgblack@eecs.umich.edu ["ArmISA::TLB::MustBeOne", \ 1917294Sgblack@eecs.umich.edu "ArmISA::TLB::AlignWord"], [], base, double=True) 1927128Sgblack@eecs.umich.edu 1937120Sgblack@eecs.umich.edu def buildStores(mnem, size=4, sign=False, user=False): 1947120Sgblack@eecs.umich.edu buildImmStore(mnem, True, True, True, size, sign, user) 1957120Sgblack@eecs.umich.edu buildRegStore(mnem, True, True, True, size, sign, user) 1967120Sgblack@eecs.umich.edu buildImmStore(mnem, True, False, True, size, sign, user) 1977120Sgblack@eecs.umich.edu buildRegStore(mnem, True, False, True, size, sign, user) 1987120Sgblack@eecs.umich.edu buildImmStore(mnem, False, True, True, size, sign, user) 1997120Sgblack@eecs.umich.edu buildRegStore(mnem, False, True, True, size, sign, user) 2007120Sgblack@eecs.umich.edu buildImmStore(mnem, False, False, True, size, sign, user) 2017120Sgblack@eecs.umich.edu buildRegStore(mnem, False, False, True, size, sign, user) 2027120Sgblack@eecs.umich.edu buildImmStore(mnem, False, True, False, size, sign, user) 2037120Sgblack@eecs.umich.edu buildRegStore(mnem, False, True, False, size, sign, user) 2047120Sgblack@eecs.umich.edu buildImmStore(mnem, False, False, False, size, sign, user) 2057120Sgblack@eecs.umich.edu buildRegStore(mnem, False, False, False, size, sign, user) 2067119SN/A 2077128Sgblack@eecs.umich.edu def buildDoubleStores(mnem): 2087128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, True, True, True) 2097128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, True, True, True) 2107128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, True, False, True) 2117128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, True, False, True) 2127128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, True, True) 2137128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, True, True) 2147128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, False, True) 2157128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, False, True) 2167128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, True, False) 2177128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, True, False) 2187128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, False, False) 2197128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, False, False) 2207128Sgblack@eecs.umich.edu 2217120Sgblack@eecs.umich.edu buildStores("str") 2227120Sgblack@eecs.umich.edu buildStores("strt", user=True) 2237120Sgblack@eecs.umich.edu buildStores("strb", size=1) 2247120Sgblack@eecs.umich.edu buildStores("strbt", size=1, user=True) 2257120Sgblack@eecs.umich.edu buildStores("strh", size=2) 2267120Sgblack@eecs.umich.edu buildStores("strht", size=2, user=True) 2277128Sgblack@eecs.umich.edu 2287128Sgblack@eecs.umich.edu buildDoubleStores("strd") 2297119SN/A}}; 230