str.isa revision 7132
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 647120Sgblack@eecs.umich.edu def emitStore(name, Name, imm, eaCode, accCode, memFlags, instFlags, base): 657119SN/A global header_output, decoder_output, exec_output 667119SN/A 677119SN/A (newHeader, 687119SN/A newDecoder, 697132Sgblack@eecs.umich.edu newExec) = loadStoreBase(name, Name, imm, 707132Sgblack@eecs.umich.edu eaCode, accCode, 717132Sgblack@eecs.umich.edu memFlags, instFlags, 727132Sgblack@eecs.umich.edu base, execTemplateBase = 'Store') 737119SN/A 747119SN/A header_output += newHeader 757119SN/A decoder_output += newDecoder 767119SN/A exec_output += newExec 777119SN/A 787120Sgblack@eecs.umich.edu def buildImmStore(mnem, post, add, writeback, \ 797120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 807119SN/A name = mnem 817120Sgblack@eecs.umich.edu Name = storeImmClassName(post, add, writeback, \ 827120Sgblack@eecs.umich.edu size, sign, user) 837119SN/A 847119SN/A if add: 857119SN/A op = " +" 867119SN/A else: 877119SN/A op = " -" 887119SN/A 897119SN/A offset = op + " imm" 907119SN/A eaCode = "EA = Base" 917119SN/A if not post: 927119SN/A eaCode += offset 937119SN/A eaCode += ";" 947119SN/A 957120Sgblack@eecs.umich.edu accCode = "Mem%s = Dest;\n" % buildMemSuffix(sign, size) 967119SN/A if writeback: 977119SN/A accCode += "Base = Base %s;\n" % offset 987132Sgblack@eecs.umich.edu base = buildMemBase("MemoryImm", post, writeback) 997119SN/A 1007120Sgblack@eecs.umich.edu emitStore(name, Name, True, eaCode, accCode, [], [], base) 1017119SN/A 1027120Sgblack@eecs.umich.edu def buildRegStore(mnem, post, add, writeback, \ 1037120Sgblack@eecs.umich.edu size=4, sign=False, user=False): 1047119SN/A name = mnem 1057120Sgblack@eecs.umich.edu Name = storeRegClassName(post, add, writeback, 1067120Sgblack@eecs.umich.edu size, sign, user) 1077119SN/A 1087119SN/A if add: 1097119SN/A op = " +" 1107119SN/A else: 1117119SN/A op = " -" 1127119SN/A 1137119SN/A offset = op + " shift_rm_imm(Index, shiftAmt," + \ 1147119SN/A " shiftType, CondCodes<29:>)" 1157119SN/A eaCode = "EA = Base" 1167119SN/A if not post: 1177119SN/A eaCode += offset 1187119SN/A eaCode += ";" 1197119SN/A 1207120Sgblack@eecs.umich.edu accCode = "Mem%s = Dest;\n" % buildMemSuffix(sign, size) 1217119SN/A if writeback: 1227119SN/A accCode += "Base = Base %s;\n" % offset 1237132Sgblack@eecs.umich.edu base = buildMemBase("MemoryReg", post, writeback) 1247119SN/A 1257120Sgblack@eecs.umich.edu emitStore(name, Name, False, eaCode, accCode, [], [], base) 1267119SN/A 1277128Sgblack@eecs.umich.edu def buildDoubleImmStore(mnem, post, add, writeback): 1287128Sgblack@eecs.umich.edu name = mnem 1297128Sgblack@eecs.umich.edu Name = storeDoubleImmClassName(post, add, writeback) 1307128Sgblack@eecs.umich.edu 1317128Sgblack@eecs.umich.edu if add: 1327128Sgblack@eecs.umich.edu op = " +" 1337128Sgblack@eecs.umich.edu else: 1347128Sgblack@eecs.umich.edu op = " -" 1357128Sgblack@eecs.umich.edu 1367128Sgblack@eecs.umich.edu offset = op + " imm" 1377128Sgblack@eecs.umich.edu eaCode = "EA = Base" 1387128Sgblack@eecs.umich.edu if not post: 1397128Sgblack@eecs.umich.edu eaCode += offset 1407128Sgblack@eecs.umich.edu eaCode += ";" 1417128Sgblack@eecs.umich.edu 1427128Sgblack@eecs.umich.edu accCode = 'Mem.ud = (Rdo.ud & mask(32)) | (Rde.ud << 32);' 1437128Sgblack@eecs.umich.edu if writeback: 1447128Sgblack@eecs.umich.edu accCode += "Base = Base %s;\n" % offset 1457132Sgblack@eecs.umich.edu base = buildMemBase("MemoryImm", post, writeback) 1467128Sgblack@eecs.umich.edu 1477128Sgblack@eecs.umich.edu emitStore(name, Name, True, eaCode, accCode, [], [], base) 1487128Sgblack@eecs.umich.edu 1497128Sgblack@eecs.umich.edu def buildDoubleRegStore(mnem, post, add, writeback): 1507128Sgblack@eecs.umich.edu name = mnem 1517128Sgblack@eecs.umich.edu Name = storeDoubleRegClassName(post, add, writeback) 1527128Sgblack@eecs.umich.edu 1537128Sgblack@eecs.umich.edu if add: 1547128Sgblack@eecs.umich.edu op = " +" 1557128Sgblack@eecs.umich.edu else: 1567128Sgblack@eecs.umich.edu op = " -" 1577128Sgblack@eecs.umich.edu 1587128Sgblack@eecs.umich.edu offset = op + " shift_rm_imm(Index, shiftAmt," + \ 1597128Sgblack@eecs.umich.edu " shiftType, CondCodes<29:>)" 1607128Sgblack@eecs.umich.edu eaCode = "EA = Base" 1617128Sgblack@eecs.umich.edu if not post: 1627128Sgblack@eecs.umich.edu eaCode += offset 1637128Sgblack@eecs.umich.edu eaCode += ";" 1647128Sgblack@eecs.umich.edu 1657128Sgblack@eecs.umich.edu accCode = 'Mem.ud = (Rdo.ud & mask(32)) | (Rde.ud << 32);' 1667128Sgblack@eecs.umich.edu if writeback: 1677128Sgblack@eecs.umich.edu accCode += "Base = Base %s;\n" % offset 1687132Sgblack@eecs.umich.edu base = buildMemBase("MemoryReg", post, writeback) 1697128Sgblack@eecs.umich.edu 1707128Sgblack@eecs.umich.edu emitStore(name, Name, False, eaCode, accCode, [], [], base) 1717128Sgblack@eecs.umich.edu 1727120Sgblack@eecs.umich.edu def buildStores(mnem, size=4, sign=False, user=False): 1737120Sgblack@eecs.umich.edu buildImmStore(mnem, True, True, True, size, sign, user) 1747120Sgblack@eecs.umich.edu buildRegStore(mnem, True, True, True, size, sign, user) 1757120Sgblack@eecs.umich.edu buildImmStore(mnem, True, False, True, size, sign, user) 1767120Sgblack@eecs.umich.edu buildRegStore(mnem, True, False, True, size, sign, user) 1777120Sgblack@eecs.umich.edu buildImmStore(mnem, False, True, True, size, sign, user) 1787120Sgblack@eecs.umich.edu buildRegStore(mnem, False, True, True, size, sign, user) 1797120Sgblack@eecs.umich.edu buildImmStore(mnem, False, False, True, size, sign, user) 1807120Sgblack@eecs.umich.edu buildRegStore(mnem, False, False, True, size, sign, user) 1817120Sgblack@eecs.umich.edu buildImmStore(mnem, False, True, False, size, sign, user) 1827120Sgblack@eecs.umich.edu buildRegStore(mnem, False, True, False, size, sign, user) 1837120Sgblack@eecs.umich.edu buildImmStore(mnem, False, False, False, size, sign, user) 1847120Sgblack@eecs.umich.edu buildRegStore(mnem, False, False, False, size, sign, user) 1857119SN/A 1867128Sgblack@eecs.umich.edu def buildDoubleStores(mnem): 1877128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, True, True, True) 1887128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, True, True, True) 1897128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, True, False, True) 1907128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, True, False, True) 1917128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, True, True) 1927128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, True, True) 1937128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, False, True) 1947128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, False, True) 1957128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, True, False) 1967128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, True, False) 1977128Sgblack@eecs.umich.edu buildDoubleImmStore(mnem, False, False, False) 1987128Sgblack@eecs.umich.edu buildDoubleRegStore(mnem, False, False, False) 1997128Sgblack@eecs.umich.edu 2007120Sgblack@eecs.umich.edu buildStores("str") 2017120Sgblack@eecs.umich.edu buildStores("strt", user=True) 2027120Sgblack@eecs.umich.edu buildStores("strb", size=1) 2037120Sgblack@eecs.umich.edu buildStores("strbt", size=1, user=True) 2047120Sgblack@eecs.umich.edu buildStores("strh", size=2) 2057120Sgblack@eecs.umich.edu buildStores("strht", size=2, user=True) 2067128Sgblack@eecs.umich.edu 2077128Sgblack@eecs.umich.edu buildDoubleStores("strd") 2087119SN/A}}; 209