str.isa revision 7294
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
967120Sgblack@eecs.umich.edu        accCode = "Mem%s = Dest;\n" % buildMemSuffix(sign, size)
977119SN/A        if writeback:
987119SN/A            accCode += "Base = Base %s;\n" % offset
997132Sgblack@eecs.umich.edu        base = buildMemBase("MemoryImm", post, writeback)
1007119SN/A
1017294Sgblack@eecs.umich.edu        emitStore(name, Name, True, eaCode, accCode, \
1027294Sgblack@eecs.umich.edu                ["ArmISA::TLB::MustBeOne", \
1037294Sgblack@eecs.umich.edu                 "ArmISA::TLB::AllowUnaligned", \
1047294Sgblack@eecs.umich.edu                 "%d" % (size - 1)], [], base)
1057119SN/A
1067120Sgblack@eecs.umich.edu    def buildRegStore(mnem, post, add, writeback, \
1077120Sgblack@eecs.umich.edu                      size=4, sign=False, user=False):
1087119SN/A        name = mnem
1097120Sgblack@eecs.umich.edu        Name = storeRegClassName(post, add, writeback,
1107120Sgblack@eecs.umich.edu                                 size, sign, user)
1117119SN/A
1127119SN/A        if add:
1137119SN/A            op = " +"
1147119SN/A        else:
1157119SN/A            op = " -"
1167119SN/A
1177119SN/A        offset = op + " shift_rm_imm(Index, shiftAmt," + \
1187119SN/A                      " shiftType, CondCodes<29:>)"
1197119SN/A        eaCode = "EA = Base"
1207119SN/A        if not post:
1217119SN/A            eaCode += offset
1227119SN/A        eaCode += ";"
1237119SN/A
1247120Sgblack@eecs.umich.edu        accCode = "Mem%s = Dest;\n" % buildMemSuffix(sign, size)
1257119SN/A        if writeback:
1267119SN/A            accCode += "Base = Base %s;\n" % offset
1277132Sgblack@eecs.umich.edu        base = buildMemBase("MemoryReg", post, writeback)
1287119SN/A
1297294Sgblack@eecs.umich.edu        emitStore(name, Name, False, eaCode, accCode, \
1307294Sgblack@eecs.umich.edu                ["ArmISA::TLB::MustBeOne", \
1317294Sgblack@eecs.umich.edu                 "ArmISA::TLB::AllowUnaligned", \
1327294Sgblack@eecs.umich.edu                 "%d" % (size - 1)], [], base)
1337119SN/A
1347128Sgblack@eecs.umich.edu    def buildDoubleImmStore(mnem, post, add, writeback):
1357128Sgblack@eecs.umich.edu        name = mnem
1367128Sgblack@eecs.umich.edu        Name = storeDoubleImmClassName(post, add, writeback)
1377128Sgblack@eecs.umich.edu
1387128Sgblack@eecs.umich.edu        if add:
1397128Sgblack@eecs.umich.edu            op = " +"
1407128Sgblack@eecs.umich.edu        else:
1417128Sgblack@eecs.umich.edu            op = " -"
1427128Sgblack@eecs.umich.edu
1437128Sgblack@eecs.umich.edu        offset = op + " imm"
1447128Sgblack@eecs.umich.edu        eaCode = "EA = Base"
1457128Sgblack@eecs.umich.edu        if not post:
1467128Sgblack@eecs.umich.edu            eaCode += offset
1477128Sgblack@eecs.umich.edu        eaCode += ";"
1487128Sgblack@eecs.umich.edu
1497279Sgblack@eecs.umich.edu        accCode = 'Mem.ud = (Dest.ud & mask(32)) | (Dest2.ud << 32);'
1507128Sgblack@eecs.umich.edu        if writeback:
1517128Sgblack@eecs.umich.edu            accCode += "Base = Base %s;\n" % offset
1527279Sgblack@eecs.umich.edu        base = buildMemBase("MemoryDImm", post, writeback)
1537128Sgblack@eecs.umich.edu
1547279Sgblack@eecs.umich.edu        emitStore(name, Name, True, eaCode, accCode, \
1557294Sgblack@eecs.umich.edu                ["ArmISA::TLB::MustBeOne",
1567294Sgblack@eecs.umich.edu                 "ArmISA::TLB::AlignWord"], [], base, double=True)
1577128Sgblack@eecs.umich.edu
1587128Sgblack@eecs.umich.edu    def buildDoubleRegStore(mnem, post, add, writeback):
1597128Sgblack@eecs.umich.edu        name = mnem
1607128Sgblack@eecs.umich.edu        Name = storeDoubleRegClassName(post, add, writeback)
1617128Sgblack@eecs.umich.edu
1627128Sgblack@eecs.umich.edu        if add:
1637128Sgblack@eecs.umich.edu            op = " +"
1647128Sgblack@eecs.umich.edu        else:
1657128Sgblack@eecs.umich.edu            op = " -"
1667128Sgblack@eecs.umich.edu
1677128Sgblack@eecs.umich.edu        offset = op + " shift_rm_imm(Index, shiftAmt," + \
1687128Sgblack@eecs.umich.edu                      " shiftType, CondCodes<29:>)"
1697128Sgblack@eecs.umich.edu        eaCode = "EA = Base"
1707128Sgblack@eecs.umich.edu        if not post:
1717128Sgblack@eecs.umich.edu            eaCode += offset
1727128Sgblack@eecs.umich.edu        eaCode += ";"
1737128Sgblack@eecs.umich.edu
1747279Sgblack@eecs.umich.edu        accCode = 'Mem.ud = (Dest.ud & mask(32)) | (Dest2.ud << 32);'
1757128Sgblack@eecs.umich.edu        if writeback:
1767128Sgblack@eecs.umich.edu            accCode += "Base = Base %s;\n" % offset
1777279Sgblack@eecs.umich.edu        base = buildMemBase("MemoryDReg", post, writeback)
1787128Sgblack@eecs.umich.edu
1797279Sgblack@eecs.umich.edu        emitStore(name, Name, False, eaCode, accCode, \
1807294Sgblack@eecs.umich.edu                ["ArmISA::TLB::MustBeOne", \
1817294Sgblack@eecs.umich.edu                 "ArmISA::TLB::AlignWord"], [], base, double=True)
1827128Sgblack@eecs.umich.edu
1837120Sgblack@eecs.umich.edu    def buildStores(mnem, size=4, sign=False, user=False):
1847120Sgblack@eecs.umich.edu        buildImmStore(mnem, True, True, True, size, sign, user)
1857120Sgblack@eecs.umich.edu        buildRegStore(mnem, True, True, True, size, sign, user)
1867120Sgblack@eecs.umich.edu        buildImmStore(mnem, True, False, True, size, sign, user)
1877120Sgblack@eecs.umich.edu        buildRegStore(mnem, True, False, True, size, sign, user)
1887120Sgblack@eecs.umich.edu        buildImmStore(mnem, False, True, True, size, sign, user)
1897120Sgblack@eecs.umich.edu        buildRegStore(mnem, False, True, True, size, sign, user)
1907120Sgblack@eecs.umich.edu        buildImmStore(mnem, False, False, True, size, sign, user)
1917120Sgblack@eecs.umich.edu        buildRegStore(mnem, False, False, True, size, sign, user)
1927120Sgblack@eecs.umich.edu        buildImmStore(mnem, False, True, False, size, sign, user)
1937120Sgblack@eecs.umich.edu        buildRegStore(mnem, False, True, False, size, sign, user)
1947120Sgblack@eecs.umich.edu        buildImmStore(mnem, False, False, False, size, sign, user)
1957120Sgblack@eecs.umich.edu        buildRegStore(mnem, False, False, False, size, sign, user)
1967119SN/A
1977128Sgblack@eecs.umich.edu    def buildDoubleStores(mnem):
1987128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, True, True, True)
1997128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, True, True, True)
2007128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, True, False, True)
2017128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, True, False, True)
2027128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, False, True, True)
2037128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, False, True, True)
2047128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, False, False, True)
2057128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, False, False, True)
2067128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, False, True, False)
2077128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, False, True, False)
2087128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, False, False, False)
2097128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, False, False, False)
2107128Sgblack@eecs.umich.edu
2117120Sgblack@eecs.umich.edu    buildStores("str")
2127120Sgblack@eecs.umich.edu    buildStores("strt", user=True)
2137120Sgblack@eecs.umich.edu    buildStores("strb", size=1)
2147120Sgblack@eecs.umich.edu    buildStores("strbt", size=1, user=True)
2157120Sgblack@eecs.umich.edu    buildStores("strh", size=2)
2167120Sgblack@eecs.umich.edu    buildStores("strht", size=2, user=True)
2177128Sgblack@eecs.umich.edu
2187128Sgblack@eecs.umich.edu    buildDoubleStores("strd")
2197119SN/A}};
220