str.isa revision 7303
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 647303Sgblack@eecs.umich.edu def emitStore(name, Name, imm, eaCode, accCode, postAccCode, \ 657303Sgblack@eecs.umich.edu memFlags, instFlags, base, double=False, strex=False, 667303Sgblack@eecs.umich.edu execTemplateBase = 'Store'): 677119SN/A global header_output, decoder_output, exec_output 687119SN/A 697119SN/A (newHeader, 707119SN/A newDecoder, 717132Sgblack@eecs.umich.edu newExec) = loadStoreBase(name, Name, imm, 727303Sgblack@eecs.umich.edu eaCode, accCode, postAccCode, 737303Sgblack@eecs.umich.edu memFlags, instFlags, double, strex, 747303Sgblack@eecs.umich.edu base, execTemplateBase = execTemplateBase) 757119SN/A 767119SN/A header_output += newHeader 777119SN/A decoder_output += newDecoder 787119SN/A exec_output += newExec 797119SN/A 807120Sgblack@eecs.umich.edu def buildImmStore(mnem, post, add, writeback, \ 817303Sgblack@eecs.umich.edu size=4, sign=False, user=False, strex=False): 827119SN/A name = mnem 837120Sgblack@eecs.umich.edu Name = storeImmClassName(post, add, writeback, \ 847120Sgblack@eecs.umich.edu size, sign, user) 857119SN/A 867119SN/A if add: 877119SN/A op = " +" 887119SN/A else: 897119SN/A op = " -" 907119SN/A 917119SN/A offset = op + " imm" 927119SN/A eaCode = "EA = Base" 937119SN/A if not post: 947119SN/A eaCode += offset 957119SN/A eaCode += ";" 967119SN/A 977296Sgblack@eecs.umich.edu accCode = "Mem%(suffix)s = cSwap(Dest%(suffix)s, ((CPSR)Cpsr).e);" % \ 987296Sgblack@eecs.umich.edu { "suffix" : buildMemSuffix(sign, size) } 997119SN/A if writeback: 1007119SN/A accCode += "Base = Base %s;\n" % offset 1017119SN/A 1027303Sgblack@eecs.umich.edu memFlags = ["ArmISA::TLB::MustBeOne", "%d" % (size - 1)] 1037303Sgblack@eecs.umich.edu if strex: 1047303Sgblack@eecs.umich.edu memFlags.append("Request::LLSC") 1057303Sgblack@eecs.umich.edu Name = "%s_%s" % (mnem.upper(), Name) 1067303Sgblack@eecs.umich.edu base = buildMemBase("MemoryExImm", post, writeback) 1077303Sgblack@eecs.umich.edu postAccCode = "Result = !writeResult;" 1087303Sgblack@eecs.umich.edu execTemplateBase = 'StoreEx' 1097303Sgblack@eecs.umich.edu else: 1107303Sgblack@eecs.umich.edu memFlags.append("ArmISA::TLB::AllowUnaligned") 1117303Sgblack@eecs.umich.edu base = buildMemBase("MemoryImm", post, writeback) 1127303Sgblack@eecs.umich.edu postAccCode = "" 1137303Sgblack@eecs.umich.edu execTemplateBase = 'Store' 1147303Sgblack@eecs.umich.edu 1157303Sgblack@eecs.umich.edu emitStore(name, Name, True, eaCode, accCode, postAccCode, \ 1167303Sgblack@eecs.umich.edu memFlags, [], base, strex=strex, 1177303Sgblack@eecs.umich.edu execTemplateBase = execTemplateBase) 1187119SN/A 1197120Sgblack@eecs.umich.edu def buildRegStore(mnem, post, add, writeback, \ 1207303Sgblack@eecs.umich.edu size=4, sign=False, user=False, strex=False): 1217119SN/A name = mnem 1227120Sgblack@eecs.umich.edu Name = storeRegClassName(post, add, writeback, 1237120Sgblack@eecs.umich.edu size, sign, user) 1247119SN/A 1257119SN/A if add: 1267119SN/A op = " +" 1277119SN/A else: 1287119SN/A op = " -" 1297119SN/A 1307119SN/A offset = op + " shift_rm_imm(Index, shiftAmt," + \ 1317119SN/A " shiftType, CondCodes<29:>)" 1327119SN/A eaCode = "EA = Base" 1337119SN/A if not post: 1347119SN/A eaCode += offset 1357119SN/A eaCode += ";" 1367119SN/A 1377296Sgblack@eecs.umich.edu accCode = "Mem%(suffix)s = cSwap(Dest%(suffix)s, ((CPSR)Cpsr).e);" % \ 1387296Sgblack@eecs.umich.edu { "suffix" : buildMemSuffix(sign, size) } 1397119SN/A if writeback: 1407119SN/A accCode += "Base = Base %s;\n" % offset 1417132Sgblack@eecs.umich.edu base = buildMemBase("MemoryReg", post, writeback) 1427119SN/A 1437303Sgblack@eecs.umich.edu emitStore(name, Name, False, eaCode, accCode, "",\ 1447294Sgblack@eecs.umich.edu ["ArmISA::TLB::MustBeOne", \ 1457294Sgblack@eecs.umich.edu "ArmISA::TLB::AllowUnaligned", \ 1467294Sgblack@eecs.umich.edu "%d" % (size - 1)], [], base) 1477119SN/A 1487303Sgblack@eecs.umich.edu def buildDoubleImmStore(mnem, post, add, writeback, strex=False): 1497128Sgblack@eecs.umich.edu name = mnem 1507128Sgblack@eecs.umich.edu Name = storeDoubleImmClassName(post, add, writeback) 1517128Sgblack@eecs.umich.edu 1527128Sgblack@eecs.umich.edu if add: 1537128Sgblack@eecs.umich.edu op = " +" 1547128Sgblack@eecs.umich.edu else: 1557128Sgblack@eecs.umich.edu op = " -" 1567128Sgblack@eecs.umich.edu 1577128Sgblack@eecs.umich.edu offset = op + " imm" 1587128Sgblack@eecs.umich.edu eaCode = "EA = Base" 1597128Sgblack@eecs.umich.edu if not post: 1607128Sgblack@eecs.umich.edu eaCode += offset 1617128Sgblack@eecs.umich.edu eaCode += ";" 1627128Sgblack@eecs.umich.edu 1637296Sgblack@eecs.umich.edu accCode = ''' 1647296Sgblack@eecs.umich.edu CPSR cpsr = Cpsr; 1657296Sgblack@eecs.umich.edu Mem.ud = (uint64_t)cSwap(Dest.uw, cpsr.e) | 1667296Sgblack@eecs.umich.edu ((uint64_t)cSwap(Dest2.uw, cpsr.e) << 32); 1677296Sgblack@eecs.umich.edu ''' 1687128Sgblack@eecs.umich.edu if writeback: 1697128Sgblack@eecs.umich.edu accCode += "Base = Base %s;\n" % offset 1707128Sgblack@eecs.umich.edu 1717303Sgblack@eecs.umich.edu memFlags = ["ArmISA::TLB::MustBeOne", 1727303Sgblack@eecs.umich.edu "ArmISA::TLB::AlignWord"] 1737303Sgblack@eecs.umich.edu if strex: 1747303Sgblack@eecs.umich.edu memFlags.append("Request::LLSC") 1757303Sgblack@eecs.umich.edu Name = "%s_%s" % (mnem.upper(), Name) 1767303Sgblack@eecs.umich.edu base = buildMemBase("MemoryExDImm", post, writeback) 1777303Sgblack@eecs.umich.edu postAccCode = "Result = !writeResult;" 1787303Sgblack@eecs.umich.edu else: 1797303Sgblack@eecs.umich.edu base = buildMemBase("MemoryDImm", post, writeback) 1807303Sgblack@eecs.umich.edu postAccCode = "" 1817303Sgblack@eecs.umich.edu 1827303Sgblack@eecs.umich.edu emitStore(name, Name, True, eaCode, accCode, postAccCode, \ 1837303Sgblack@eecs.umich.edu memFlags, [], base, double=True, strex=strex) 1847128Sgblack@eecs.umich.edu 1857128Sgblack@eecs.umich.edu def buildDoubleRegStore(mnem, post, add, writeback): 1867128Sgblack@eecs.umich.edu name = mnem 1877128Sgblack@eecs.umich.edu Name = storeDoubleRegClassName(post, add, writeback) 1887128Sgblack@eecs.umich.edu 1897128Sgblack@eecs.umich.edu if add: 1907128Sgblack@eecs.umich.edu op = " +" 1917128Sgblack@eecs.umich.edu else: 1927128Sgblack@eecs.umich.edu op = " -" 1937128Sgblack@eecs.umich.edu 1947128Sgblack@eecs.umich.edu offset = op + " shift_rm_imm(Index, shiftAmt," + \ 1957128Sgblack@eecs.umich.edu " shiftType, CondCodes<29:>)" 1967128Sgblack@eecs.umich.edu eaCode = "EA = Base" 1977128Sgblack@eecs.umich.edu if not post: 1987128Sgblack@eecs.umich.edu eaCode += offset 1997128Sgblack@eecs.umich.edu eaCode += ";" 2007128Sgblack@eecs.umich.edu 2017296Sgblack@eecs.umich.edu accCode = ''' 2027296Sgblack@eecs.umich.edu CPSR cpsr = Cpsr; 2037296Sgblack@eecs.umich.edu Mem.ud = (uint64_t)cSwap(Dest.uw, cpsr.e) | 2047296Sgblack@eecs.umich.edu ((uint64_t)cSwap(Dest2.uw, cpsr.e) << 32); 2057296Sgblack@eecs.umich.edu ''' 2067128Sgblack@eecs.umich.edu if writeback: 2077128Sgblack@eecs.umich.edu accCode += "Base = Base %s;\n" % offset 2087279Sgblack@eecs.umich.edu base = buildMemBase("MemoryDReg", post, writeback) 2097128Sgblack@eecs.umich.edu 2107303Sgblack@eecs.umich.edu memFlags = ["ArmISA::TLB::MustBeOne", 2117303Sgblack@eecs.umich.edu "ArmISA::TLB::AlignWord"] 2127303Sgblack@eecs.umich.edu 2137303Sgblack@eecs.umich.edu emitStore(name, Name, False, eaCode, accCode, "", \ 2147303Sgblack@eecs.umich.edu memFlags, [], base, double=True) 2157128Sgblack@eecs.umich.edu 2167120Sgblack@eecs.umich.edu def buildStores(mnem, size=4, sign=False, user=False): 2177120Sgblack@eecs.umich.edu buildImmStore(mnem, True, True, True, size, sign, user) 2187120Sgblack@eecs.umich.edu buildRegStore(mnem, True, True, True, size, sign, user) 2197120Sgblack@eecs.umich.edu buildImmStore(mnem, True, False, True, size, sign, user) 2207120Sgblack@eecs.umich.edu buildRegStore(mnem, True, False, True, size, sign, user) 2217120Sgblack@eecs.umich.edu buildImmStore(mnem, False, True, True, size, sign, user) 2227120Sgblack@eecs.umich.edu buildRegStore(mnem, False, True, True, size, sign, user) 2237120Sgblack@eecs.umich.edu buildImmStore(mnem, False, False, True, size, sign, user) 2247120Sgblack@eecs.umich.edu buildRegStore(mnem, False, False, True, size, sign, user) 2257120Sgblack@eecs.umich.edu buildImmStore(mnem, False, True, False, size, sign, user) 2267120Sgblack@eecs.umich.edu buildRegStore(mnem, False, True, False, size, sign, user) 2277120Sgblack@eecs.umich.edu buildImmStore(mnem, False, False, False, size, sign, user) 2287120Sgblack@eecs.umich.edu buildRegStore(mnem, False, False, False, size, sign, user) 2297119SN/A 2307128Sgblack@eecs.umich.edu def buildDoubleStores(mnem): 2317128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, True, True, True) 2327128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, True, True, True) 2337128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, True, False, True) 2347128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, True, False, True) 2357128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, True, True) 2367128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, True, True) 2377128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, False, True) 2387128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, False, True) 2397128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, True, False) 2407128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, True, False) 2417128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, False, False) 2427128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, False, False) 2437128Sgblack@eecs.umich.edu 2447120Sgblack@eecs.umich.edu buildStores("str") 2457120Sgblack@eecs.umich.edu buildStores("strt", user=True) 2467120Sgblack@eecs.umich.edu buildStores("strb", size=1) 2477120Sgblack@eecs.umich.edu buildStores("strbt", size=1, user=True) 2487120Sgblack@eecs.umich.edu buildStores("strh", size=2) 2497120Sgblack@eecs.umich.edu buildStores("strht", size=2, user=True) 2507128Sgblack@eecs.umich.edu 2517128Sgblack@eecs.umich.edu buildDoubleStores("strd") 2527303Sgblack@eecs.umich.edu 2537303Sgblack@eecs.umich.edu buildImmStore("strex", False, True, False, size=4, strex=True) 2547303Sgblack@eecs.umich.edu buildImmStore("strexh", False, True, False, size=2, strex=True) 2557303Sgblack@eecs.umich.edu buildImmStore("strexb", False, True, False, size=1, strex=True) 2567303Sgblack@eecs.umich.edu buildDoubleImmStore("strexd", False, True, False, strex=True) 2577119SN/A}}; 258