str.isa revision 7279
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
1017120Sgblack@eecs.umich.edu        emitStore(name, Name, True, eaCode, accCode, [], [], base)
1027119SN/A
1037120Sgblack@eecs.umich.edu    def buildRegStore(mnem, post, add, writeback, \
1047120Sgblack@eecs.umich.edu                      size=4, sign=False, user=False):
1057119SN/A        name = mnem
1067120Sgblack@eecs.umich.edu        Name = storeRegClassName(post, add, writeback,
1077120Sgblack@eecs.umich.edu                                 size, sign, user)
1087119SN/A
1097119SN/A        if add:
1107119SN/A            op = " +"
1117119SN/A        else:
1127119SN/A            op = " -"
1137119SN/A
1147119SN/A        offset = op + " shift_rm_imm(Index, shiftAmt," + \
1157119SN/A                      " shiftType, CondCodes<29:>)"
1167119SN/A        eaCode = "EA = Base"
1177119SN/A        if not post:
1187119SN/A            eaCode += offset
1197119SN/A        eaCode += ";"
1207119SN/A
1217120Sgblack@eecs.umich.edu        accCode = "Mem%s = Dest;\n" % buildMemSuffix(sign, size)
1227119SN/A        if writeback:
1237119SN/A            accCode += "Base = Base %s;\n" % offset
1247132Sgblack@eecs.umich.edu        base = buildMemBase("MemoryReg", post, writeback)
1257119SN/A
1267120Sgblack@eecs.umich.edu        emitStore(name, Name, False, eaCode, accCode, [], [], base)
1277119SN/A
1287128Sgblack@eecs.umich.edu    def buildDoubleImmStore(mnem, post, add, writeback):
1297128Sgblack@eecs.umich.edu        name = mnem
1307128Sgblack@eecs.umich.edu        Name = storeDoubleImmClassName(post, add, writeback)
1317128Sgblack@eecs.umich.edu
1327128Sgblack@eecs.umich.edu        if add:
1337128Sgblack@eecs.umich.edu            op = " +"
1347128Sgblack@eecs.umich.edu        else:
1357128Sgblack@eecs.umich.edu            op = " -"
1367128Sgblack@eecs.umich.edu
1377128Sgblack@eecs.umich.edu        offset = op + " imm"
1387128Sgblack@eecs.umich.edu        eaCode = "EA = Base"
1397128Sgblack@eecs.umich.edu        if not post:
1407128Sgblack@eecs.umich.edu            eaCode += offset
1417128Sgblack@eecs.umich.edu        eaCode += ";"
1427128Sgblack@eecs.umich.edu
1437279Sgblack@eecs.umich.edu        accCode = 'Mem.ud = (Dest.ud & mask(32)) | (Dest2.ud << 32);'
1447128Sgblack@eecs.umich.edu        if writeback:
1457128Sgblack@eecs.umich.edu            accCode += "Base = Base %s;\n" % offset
1467279Sgblack@eecs.umich.edu        base = buildMemBase("MemoryDImm", post, writeback)
1477128Sgblack@eecs.umich.edu
1487279Sgblack@eecs.umich.edu        emitStore(name, Name, True, eaCode, accCode, \
1497279Sgblack@eecs.umich.edu                  [], [], base, double=True)
1507128Sgblack@eecs.umich.edu
1517128Sgblack@eecs.umich.edu    def buildDoubleRegStore(mnem, post, add, writeback):
1527128Sgblack@eecs.umich.edu        name = mnem
1537128Sgblack@eecs.umich.edu        Name = storeDoubleRegClassName(post, add, writeback)
1547128Sgblack@eecs.umich.edu
1557128Sgblack@eecs.umich.edu        if add:
1567128Sgblack@eecs.umich.edu            op = " +"
1577128Sgblack@eecs.umich.edu        else:
1587128Sgblack@eecs.umich.edu            op = " -"
1597128Sgblack@eecs.umich.edu
1607128Sgblack@eecs.umich.edu        offset = op + " shift_rm_imm(Index, shiftAmt," + \
1617128Sgblack@eecs.umich.edu                      " shiftType, CondCodes<29:>)"
1627128Sgblack@eecs.umich.edu        eaCode = "EA = Base"
1637128Sgblack@eecs.umich.edu        if not post:
1647128Sgblack@eecs.umich.edu            eaCode += offset
1657128Sgblack@eecs.umich.edu        eaCode += ";"
1667128Sgblack@eecs.umich.edu
1677279Sgblack@eecs.umich.edu        accCode = 'Mem.ud = (Dest.ud & mask(32)) | (Dest2.ud << 32);'
1687128Sgblack@eecs.umich.edu        if writeback:
1697128Sgblack@eecs.umich.edu            accCode += "Base = Base %s;\n" % offset
1707279Sgblack@eecs.umich.edu        base = buildMemBase("MemoryDReg", post, writeback)
1717128Sgblack@eecs.umich.edu
1727279Sgblack@eecs.umich.edu        emitStore(name, Name, False, eaCode, accCode, \
1737279Sgblack@eecs.umich.edu                  [], [], base, double=True)
1747128Sgblack@eecs.umich.edu
1757120Sgblack@eecs.umich.edu    def buildStores(mnem, size=4, sign=False, user=False):
1767120Sgblack@eecs.umich.edu        buildImmStore(mnem, True, True, True, size, sign, user)
1777120Sgblack@eecs.umich.edu        buildRegStore(mnem, True, True, True, size, sign, user)
1787120Sgblack@eecs.umich.edu        buildImmStore(mnem, True, False, True, size, sign, user)
1797120Sgblack@eecs.umich.edu        buildRegStore(mnem, True, False, True, size, sign, user)
1807120Sgblack@eecs.umich.edu        buildImmStore(mnem, False, True, True, size, sign, user)
1817120Sgblack@eecs.umich.edu        buildRegStore(mnem, False, True, True, size, sign, user)
1827120Sgblack@eecs.umich.edu        buildImmStore(mnem, False, False, True, size, sign, user)
1837120Sgblack@eecs.umich.edu        buildRegStore(mnem, False, False, True, size, sign, user)
1847120Sgblack@eecs.umich.edu        buildImmStore(mnem, False, True, False, size, sign, user)
1857120Sgblack@eecs.umich.edu        buildRegStore(mnem, False, True, False, size, sign, user)
1867120Sgblack@eecs.umich.edu        buildImmStore(mnem, False, False, False, size, sign, user)
1877120Sgblack@eecs.umich.edu        buildRegStore(mnem, False, False, False, size, sign, user)
1887119SN/A
1897128Sgblack@eecs.umich.edu    def buildDoubleStores(mnem):
1907128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, True, True, True)
1917128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, True, True, True)
1927128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, True, False, True)
1937128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, True, False, True)
1947128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, False, True, True)
1957128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, False, True, True)
1967128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, False, False, True)
1977128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, False, False, True)
1987128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, False, True, False)
1997128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, False, True, False)
2007128Sgblack@eecs.umich.edu        buildDoubleImmStore(mnem, False, False, False)
2017128Sgblack@eecs.umich.edu        buildDoubleRegStore(mnem, False, False, False)
2027128Sgblack@eecs.umich.edu
2037120Sgblack@eecs.umich.edu    buildStores("str")
2047120Sgblack@eecs.umich.edu    buildStores("strt", user=True)
2057120Sgblack@eecs.umich.edu    buildStores("strb", size=1)
2067120Sgblack@eecs.umich.edu    buildStores("strbt", size=1, user=True)
2077120Sgblack@eecs.umich.edu    buildStores("strh", size=2)
2087120Sgblack@eecs.umich.edu    buildStores("strht", size=2, user=True)
2097128Sgblack@eecs.umich.edu
2107128Sgblack@eecs.umich.edu    buildDoubleStores("strd")
2117119SN/A}};
212