str.isa revision 7119
12817Sksewell@umich.edu// -*- mode:c++ -*-
22817Sksewell@umich.edu
32817Sksewell@umich.edu// Copyright (c) 2010 ARM Limited
42817Sksewell@umich.edu// All rights reserved
52817Sksewell@umich.edu//
62817Sksewell@umich.edu// The license below extends only to copyright in the software and shall
72817Sksewell@umich.edu// not be construed as granting a license to any other intellectual
82817Sksewell@umich.edu// property including but not limited to intellectual property relating
92817Sksewell@umich.edu// to a hardware implementation of the functionality of the software
102817Sksewell@umich.edu// licensed hereunder.  You may use the software subject to the license
112817Sksewell@umich.edu// terms below provided that you ensure that this notice is replicated
122817Sksewell@umich.edu// unmodified and in its entirety in all distributions of the software,
132817Sksewell@umich.edu// modified or unmodified, in source code or in binary form.
142817Sksewell@umich.edu//
152817Sksewell@umich.edu// Redistribution and use in source and binary forms, with or without
162817Sksewell@umich.edu// modification, are permitted provided that the following conditions are
172817Sksewell@umich.edu// met: redistributions of source code must retain the above copyright
182817Sksewell@umich.edu// notice, this list of conditions and the following disclaimer;
192817Sksewell@umich.edu// redistributions in binary form must reproduce the above copyright
202817Sksewell@umich.edu// notice, this list of conditions and the following disclaimer in the
212817Sksewell@umich.edu// documentation and/or other materials provided with the distribution;
222817Sksewell@umich.edu// neither the name of the copyright holders nor the names of its
232817Sksewell@umich.edu// contributors may be used to endorse or promote products derived from
242817Sksewell@umich.edu// this software without specific prior written permission.
252817Sksewell@umich.edu//
262817Sksewell@umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
272817Sksewell@umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
282817Sksewell@umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
292817Sksewell@umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
302817Sksewell@umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
312817Sksewell@umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
322817Sksewell@umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
332817Sksewell@umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
342935Sksewell@umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
352817Sksewell@umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
362817Sksewell@umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
372834Sksewell@umich.edu//
382834Sksewell@umich.edu// Authors: Gabe Black
392834Sksewell@umich.edu
402834Sksewell@umich.edulet {{
412834Sksewell@umich.edu
422834Sksewell@umich.edu    header_output = ""
432834Sksewell@umich.edu    decoder_output = ""
442817Sksewell@umich.edu    exec_output = ""
452817Sksewell@umich.edu
462817Sksewell@umich.edu    def loadImmClassName(post, add, writeback, \
472817Sksewell@umich.edu                         size=4, sign=False, user=False):
482817Sksewell@umich.edu        return memClassName("LOAD_IMM", post, add, writeback,
492817Sksewell@umich.edu                            size, sign, user)
502817Sksewell@umich.edu
512817Sksewell@umich.edu    def loadRegClassName(post, add, writeback, \
522817Sksewell@umich.edu                         size=4, sign=False, user=False):
532817Sksewell@umich.edu        return memClassName("LOAD_REG", post, add, writeback,
542817Sksewell@umich.edu                            size, sign, user)
552817Sksewell@umich.edu
562817Sksewell@umich.edu    def emitLoad(name, Name, imm, eaCode, accCode, memFlags, instFlags, base):
572817Sksewell@umich.edu        global header_output, decoder_output, exec_output
582817Sksewell@umich.edu
592817Sksewell@umich.edu        (newHeader,
602817Sksewell@umich.edu         newDecoder,
612817Sksewell@umich.edu         newExec) = newLoadStoreBase(name, Name, imm,
622817Sksewell@umich.edu                                     eaCode, accCode,
632817Sksewell@umich.edu                                     memFlags, instFlags,
642817Sksewell@umich.edu                                     base, execTemplateBase = 'Load')
652817Sksewell@umich.edu
662817Sksewell@umich.edu        header_output += newHeader
672817Sksewell@umich.edu        decoder_output += newDecoder
682817Sksewell@umich.edu        exec_output += newExec
693784Sgblack@eecs.umich.edu
706022Sgblack@eecs.umich.edu    def buildImmLoad(mnem, post, add, writeback, \
713784Sgblack@eecs.umich.edu                     size=4, sign=False, user=False):
723784Sgblack@eecs.umich.edu        name = mnem
736022Sgblack@eecs.umich.edu        Name = loadImmClassName(post, add, writeback, \
743784Sgblack@eecs.umich.edu                                size, sign, user)
752817Sksewell@umich.edu
762817Sksewell@umich.edu        if add:
772817Sksewell@umich.edu            op = " +"
782817Sksewell@umich.edu        else:
795712Shsul@eecs.umich.edu            op = " -"
802817Sksewell@umich.edu
815714Shsul@eecs.umich.edu        offset = op + " imm"
825714Shsul@eecs.umich.edu        eaCode = "EA = Base"
835714Shsul@eecs.umich.edu        if not post:
845714Shsul@eecs.umich.edu            eaCode += offset
855715Shsul@eecs.umich.edu        eaCode += ";"
865715Shsul@eecs.umich.edu
875715Shsul@eecs.umich.edu        accCode = "Dest = Mem%s;\n" % buildMemSuffix(sign, size)
885715Shsul@eecs.umich.edu        if writeback:
892817Sksewell@umich.edu            accCode += "Base = Base %s;\n" % offset
902817Sksewell@umich.edu        base = buildMemBase("MemoryNewImm", post, writeback)
912817Sksewell@umich.edu
925803Snate@binkert.org        emitLoad(name, Name, True, eaCode, accCode, [], [], base)
932817Sksewell@umich.edu
942817Sksewell@umich.edu    def buildRegLoad(mnem, post, add, writeback, \
952817Sksewell@umich.edu                     size=4, sign=False, user=False):
962817Sksewell@umich.edu        name = mnem
973548Sgblack@eecs.umich.edu        Name = loadRegClassName(post, add, writeback,
982817Sksewell@umich.edu                                size, sign, user)
992817Sksewell@umich.edu
1002817Sksewell@umich.edu        if add:
1012817Sksewell@umich.edu            op = " +"
1025499Ssaidi@eecs.umich.edu        else:
1033675Sktlim@umich.edu            op = " -"
1045497Ssaidi@eecs.umich.edu
1052817Sksewell@umich.edu        offset = op + " shift_rm_imm(Index, shiftAmt," + \
1062817Sksewell@umich.edu                      " shiftType, CondCodes<29:>)"
1072817Sksewell@umich.edu        eaCode = "EA = Base"
1082817Sksewell@umich.edu        if not post:
1092817Sksewell@umich.edu            eaCode += offset
1102817Sksewell@umich.edu        eaCode += ";"
1112817Sksewell@umich.edu
1122817Sksewell@umich.edu        accCode = "Dest = Mem%s;\n" % buildMemSuffix(sign, size)
1132817Sksewell@umich.edu        if writeback:
1142817Sksewell@umich.edu            accCode += "Base = Base %s;\n" % offset
1152817Sksewell@umich.edu        base = buildMemBase("MemoryNewReg", post, writeback)
1162817Sksewell@umich.edu
1172817Sksewell@umich.edu        emitLoad(name, Name, False, eaCode, accCode, [], [], base)
1182817Sksewell@umich.edu
1192817Sksewell@umich.edu    def buildLoads(mnem, size=4, sign=False, user=False):
1202817Sksewell@umich.edu        buildImmLoad(mnem, True, True, True, size, sign, user)
1212817Sksewell@umich.edu        buildRegLoad(mnem, True, True, True, size, sign, user)
1222817Sksewell@umich.edu        buildImmLoad(mnem, True, False, True, size, sign, user)
1235250Sksewell@umich.edu        buildRegLoad(mnem, True, False, True, size, sign, user)
1242817Sksewell@umich.edu        buildImmLoad(mnem, False, True, True, size, sign, user)
1252817Sksewell@umich.edu        buildRegLoad(mnem, False, True, True, size, sign, user)
1265250Sksewell@umich.edu        buildImmLoad(mnem, False, False, True, size, sign, user)
1272817Sksewell@umich.edu        buildRegLoad(mnem, False, False, True, size, sign, user)
1282817Sksewell@umich.edu        buildImmLoad(mnem, False, True, False, size, sign, user)
1292817Sksewell@umich.edu        buildRegLoad(mnem, False, True, False, size, sign, user)
1302817Sksewell@umich.edu        buildImmLoad(mnem, False, False, False, size, sign, user)
1312817Sksewell@umich.edu        buildRegLoad(mnem, False, False, False, size, sign, user)
1322817Sksewell@umich.edu
1332817Sksewell@umich.edu    buildLoads("ldr")
1342817Sksewell@umich.edu    buildLoads("ldrt", user=True)
1352817Sksewell@umich.edu    buildLoads("ldrb", size=1)
1362817Sksewell@umich.edu    buildLoads("ldrbt", size=1, user=True)
1372817Sksewell@umich.edu    buildLoads("ldrsb", size=1, sign=True)
1382817Sksewell@umich.edu    buildLoads("ldrsbt", size=1, sign=True, user=True)
1392817Sksewell@umich.edu    buildLoads("ldrh", size=2)
1402817Sksewell@umich.edu    buildLoads("ldrht", size=2, user=True)
1412817Sksewell@umich.edu    buildLoads("hdrsh", size=2, sign=True)
1422817Sksewell@umich.edu    buildLoads("ldrsht", size=2, sign=True, user=True)
1432817Sksewell@umich.edu}};
1442817Sksewell@umich.edu