mult.isa revision 7229
17160Sgblack@eecs.umich.edu// -*- mode:c++ -*-
27160Sgblack@eecs.umich.edu
37160Sgblack@eecs.umich.edu// Copyright (c) 2010 ARM Limited
47160Sgblack@eecs.umich.edu// All rights reserved
57160Sgblack@eecs.umich.edu//
67160Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall
77160Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual
87160Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating
97160Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software
107160Sgblack@eecs.umich.edu// licensed hereunder.  You may use the software subject to the license
117160Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated
127160Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software,
137160Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form.
147160Sgblack@eecs.umich.edu//
157160Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
167160Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are
177160Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright
187160Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
197160Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
207160Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
217160Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution;
227160Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its
237160Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
247160Sgblack@eecs.umich.edu// this software without specific prior written permission.
257160Sgblack@eecs.umich.edu//
267160Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
277160Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
287160Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
297160Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
307160Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
317160Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
327160Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
337160Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
347160Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
357160Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
367160Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
377160Sgblack@eecs.umich.edu//
387160Sgblack@eecs.umich.edu// Authors: Gabe Black
397160Sgblack@eecs.umich.edu
407160Sgblack@eecs.umich.edulet {{
417160Sgblack@eecs.umich.edu
427160Sgblack@eecs.umich.edu    header_output = ""
437160Sgblack@eecs.umich.edu    decoder_output = ""
447160Sgblack@eecs.umich.edu    exec_output = ""
457160Sgblack@eecs.umich.edu
467160Sgblack@eecs.umich.edu    calcQCode = '''
477196Sgblack@eecs.umich.edu        CondCodes = CondCodes | ((resTemp & 1) << 27);
487160Sgblack@eecs.umich.edu    '''
497160Sgblack@eecs.umich.edu
507160Sgblack@eecs.umich.edu    calcCcCode = '''
517160Sgblack@eecs.umich.edu        uint16_t _iz, _in;
527160Sgblack@eecs.umich.edu        _in = (resTemp >> %(negBit)d) & 1;
537160Sgblack@eecs.umich.edu        _iz = ((%(zType)s)resTemp == 0);
547160Sgblack@eecs.umich.edu
557160Sgblack@eecs.umich.edu        CondCodes =  _in << 31 | _iz << 30 | (CondCodes & 0x3FFFFFFF);
567160Sgblack@eecs.umich.edu
577160Sgblack@eecs.umich.edu        DPRINTF(Arm, "(in, iz) = (%%d, %%d)\\n", _in, _iz);
587160Sgblack@eecs.umich.edu       '''
597160Sgblack@eecs.umich.edu
607160Sgblack@eecs.umich.edu    def buildMultInst(mnem, doCc, unCc, regs, code, flagType):
617160Sgblack@eecs.umich.edu        global header_output, decoder_output, exec_output
627160Sgblack@eecs.umich.edu        cCode = carryCode[flagType]
637160Sgblack@eecs.umich.edu        vCode = overflowCode[flagType]
647160Sgblack@eecs.umich.edu        zType = "uint32_t"
657160Sgblack@eecs.umich.edu        negBit = 31
667160Sgblack@eecs.umich.edu        if flagType == "llbit":
677160Sgblack@eecs.umich.edu            zType = "uint64_t"
687160Sgblack@eecs.umich.edu            negBit = 63
697160Sgblack@eecs.umich.edu        if flagType == "overflow":
707160Sgblack@eecs.umich.edu            ccCode = calcQCode
717160Sgblack@eecs.umich.edu        else:
727160Sgblack@eecs.umich.edu            ccCode = calcCcCode % {
737160Sgblack@eecs.umich.edu                "negBit": negBit,
747160Sgblack@eecs.umich.edu                "zType": zType
757160Sgblack@eecs.umich.edu            }
767160Sgblack@eecs.umich.edu
777160Sgblack@eecs.umich.edu        if not regs in (3, 4):
787160Sgblack@eecs.umich.edu            raise Exception, "Multiplication instructions with %d " + \
797160Sgblack@eecs.umich.edu                             "registers are not implemented"
807160Sgblack@eecs.umich.edu
817160Sgblack@eecs.umich.edu        if regs == 3:
827160Sgblack@eecs.umich.edu            base = 'Mult3'
837160Sgblack@eecs.umich.edu        else:
847160Sgblack@eecs.umich.edu            base = 'Mult4'
857160Sgblack@eecs.umich.edu
867162Sgblack@eecs.umich.edu        Name = mnem.capitalize()
877160Sgblack@eecs.umich.edu
887160Sgblack@eecs.umich.edu        if unCc:
897160Sgblack@eecs.umich.edu            iop = InstObjParams(mnem, Name, base,
907160Sgblack@eecs.umich.edu                                {"code" : code,
917160Sgblack@eecs.umich.edu                                 "predicate_test": predicateTest})
927160Sgblack@eecs.umich.edu        if doCc:
937160Sgblack@eecs.umich.edu            iopCc = InstObjParams(mnem + "s", Name + "Cc", base,
947160Sgblack@eecs.umich.edu                                  {"code" : code + ccCode,
957160Sgblack@eecs.umich.edu                                   "predicate_test": predicateTest})
967160Sgblack@eecs.umich.edu
977160Sgblack@eecs.umich.edu        if regs == 3:
987160Sgblack@eecs.umich.edu            declare = Mult3Declare
997160Sgblack@eecs.umich.edu            constructor = Mult3Constructor
1007160Sgblack@eecs.umich.edu        else:
1017160Sgblack@eecs.umich.edu            declare = Mult4Declare
1027160Sgblack@eecs.umich.edu            constructor = Mult4Constructor
1037160Sgblack@eecs.umich.edu
1047160Sgblack@eecs.umich.edu        if unCc:
1057160Sgblack@eecs.umich.edu            header_output += declare.subst(iop)
1067160Sgblack@eecs.umich.edu            decoder_output += constructor.subst(iop)
1077160Sgblack@eecs.umich.edu            exec_output += PredOpExecute.subst(iop)
1087160Sgblack@eecs.umich.edu        if doCc:
1097160Sgblack@eecs.umich.edu            header_output += declare.subst(iopCc)
1107160Sgblack@eecs.umich.edu            decoder_output += constructor.subst(iopCc)
1117160Sgblack@eecs.umich.edu            exec_output += PredOpExecute.subst(iopCc)
1127160Sgblack@eecs.umich.edu
1137160Sgblack@eecs.umich.edu    def buildMult3Inst(mnem, code, flagType = "logic"):
1147160Sgblack@eecs.umich.edu        buildMultInst(mnem, True, True, 3, code, flagType)
1157160Sgblack@eecs.umich.edu
1167160Sgblack@eecs.umich.edu    def buildMult3InstCc(mnem, code, flagType = "logic"):
1177160Sgblack@eecs.umich.edu        buildMultInst(mnem, True, False, 3, code, flagType)
1187160Sgblack@eecs.umich.edu
1197160Sgblack@eecs.umich.edu    def buildMult3InstUnCc(mnem, code, flagType = "logic"):
1207160Sgblack@eecs.umich.edu        buildMultInst(mnem, False, True, 3, code, flagType)
1217160Sgblack@eecs.umich.edu
1227160Sgblack@eecs.umich.edu    def buildMult4Inst(mnem, code, flagType = "logic"):
1237160Sgblack@eecs.umich.edu        buildMultInst(mnem, True, True, 4, code, flagType)
1247160Sgblack@eecs.umich.edu
1257160Sgblack@eecs.umich.edu    def buildMult4InstCc(mnem, code, flagType = "logic"):
1267160Sgblack@eecs.umich.edu        buildMultInst(mnem, True, False, 4, code, flagType)
1277160Sgblack@eecs.umich.edu
1287160Sgblack@eecs.umich.edu    def buildMult4InstUnCc(mnem, code, flagType = "logic"):
1297160Sgblack@eecs.umich.edu        buildMultInst(mnem, False, True, 4, code, flagType)
1307160Sgblack@eecs.umich.edu
1317160Sgblack@eecs.umich.edu    buildMult4Inst    ("mla", "Reg0 = resTemp = Reg1 * Reg2 + Reg3;")
1327160Sgblack@eecs.umich.edu    buildMult4InstUnCc("mls", "Reg0 = resTemp = Reg3 - Reg1 * Reg2;")
1337160Sgblack@eecs.umich.edu    buildMult3Inst    ("mul", "Reg0 = resTemp = Reg1 * Reg2;")
1347160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smlabb", '''Reg0 = resTemp =
1357160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 15, 0)) *
1367196Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2.sw, 15, 0)) +
1377160Sgblack@eecs.umich.edu                                        Reg3.sw;
1387196Sgblack@eecs.umich.edu                                 resTemp = bits(resTemp, 32) !=
1397196Sgblack@eecs.umich.edu                                           bits(resTemp, 31);
1407160Sgblack@eecs.umich.edu                                 ''', "overflow")
1417160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smlabt", '''Reg0 = resTemp =
1427160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 15, 0)) *
1437196Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2.sw, 31, 16)) +
1447160Sgblack@eecs.umich.edu                                        Reg3.sw;
1457196Sgblack@eecs.umich.edu                                 resTemp = bits(resTemp, 32) !=
1467196Sgblack@eecs.umich.edu                                           bits(resTemp, 31);
1477160Sgblack@eecs.umich.edu                                 ''', "overflow")
1487160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smlatb", '''Reg0 = resTemp =
1497160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 31, 16)) *
1507196Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2.sw, 15, 0)) +
1517160Sgblack@eecs.umich.edu                                        Reg3.sw;
1527196Sgblack@eecs.umich.edu                                 resTemp = bits(resTemp, 32) !=
1537196Sgblack@eecs.umich.edu                                           bits(resTemp, 31);
1547160Sgblack@eecs.umich.edu                                 ''', "overflow")
1557160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smlatt", '''Reg0 = resTemp =
1567160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 31, 16)) *
1577196Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2.sw, 31, 16)) +
1587160Sgblack@eecs.umich.edu                                        Reg3.sw;
1597196Sgblack@eecs.umich.edu                                 resTemp = bits(resTemp, 32) !=
1607196Sgblack@eecs.umich.edu                                           bits(resTemp, 31);
1617160Sgblack@eecs.umich.edu                                 ''', "overflow")
1627160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smlad", '''Reg0 = resTemp =
1637160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 31, 16)) *
1647160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 31, 16)) +
1657160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 15, 0)) *
1667160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 15, 0)) +
1677160Sgblack@eecs.umich.edu                                        Reg3.sw;
1687228Sgblack@eecs.umich.edu                                    resTemp = bits(resTemp, 32) !=
1697228Sgblack@eecs.umich.edu                                              bits(resTemp, 31);
1707160Sgblack@eecs.umich.edu                                ''', "overflow")
1717160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smladx", '''Reg0 = resTemp =
1727160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg1, 31, 16)) *
1737160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 15, 0)) +
1747160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg1, 15, 0)) *
1757160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 31, 16)) +
1767160Sgblack@eecs.umich.edu                                         Reg3.sw;
1777228Sgblack@eecs.umich.edu                                    resTemp = bits(resTemp, 32) !=
1787228Sgblack@eecs.umich.edu                                              bits(resTemp, 31);
1797160Sgblack@eecs.umich.edu                                 ''', "overflow")
1807160Sgblack@eecs.umich.edu    buildMult4Inst    ("smlal", '''resTemp = sext<32>(Reg2) * sext<32>(Reg3) +
1817160Sgblack@eecs.umich.edu                                       (int64_t)((Reg1.ud << 32) | Reg0.ud);
1827160Sgblack@eecs.umich.edu                                   Reg0.ud = (uint32_t)resTemp;
1837160Sgblack@eecs.umich.edu                                   Reg1.ud = (uint32_t)(resTemp >> 32);
1847160Sgblack@eecs.umich.edu                                ''', "llbit")
1857160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smlalbb", '''resTemp = sext<16>(bits(Reg2, 15, 0)) *
1867160Sgblack@eecs.umich.edu                                               sext<16>(bits(Reg3, 15, 0)) +
1877160Sgblack@eecs.umich.edu                                               (int64_t)((Reg1.ud << 32) |
1887160Sgblack@eecs.umich.edu                                                         Reg0.ud);
1897160Sgblack@eecs.umich.edu                                     Reg0.ud = (uint32_t)resTemp;
1907160Sgblack@eecs.umich.edu                                     Reg1.ud = (uint32_t)(resTemp >> 32);
1917160Sgblack@eecs.umich.edu                                  ''')
1927160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smlalbt", '''resTemp = sext<16>(bits(Reg2, 15, 0)) *
1937160Sgblack@eecs.umich.edu                                               sext<16>(bits(Reg3, 31, 16)) +
1947160Sgblack@eecs.umich.edu                                               (int64_t)((Reg1.ud << 32) |
1957160Sgblack@eecs.umich.edu                                                         Reg0.ud);
1967160Sgblack@eecs.umich.edu                                     Reg0.ud = (uint32_t)resTemp;
1977160Sgblack@eecs.umich.edu                                     Reg1.ud = (uint32_t)(resTemp >> 32);
1987160Sgblack@eecs.umich.edu                                  ''')
1997160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smlaltb", '''resTemp = sext<16>(bits(Reg2, 31, 16)) *
2007160Sgblack@eecs.umich.edu                                               sext<16>(bits(Reg3, 15, 0)) +
2017160Sgblack@eecs.umich.edu                                               (int64_t)((Reg1.ud << 32) |
2027160Sgblack@eecs.umich.edu                                                         Reg0.ud);
2037160Sgblack@eecs.umich.edu                                     Reg0.ud = (uint32_t)resTemp;
2047160Sgblack@eecs.umich.edu                                     Reg1.ud = (uint32_t)(resTemp >> 32);
2057160Sgblack@eecs.umich.edu                                  ''')
2067160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smlaltt", '''resTemp = sext<16>(bits(Reg2, 31, 16)) *
2077160Sgblack@eecs.umich.edu                                               sext<16>(bits(Reg3, 31, 16)) +
2087160Sgblack@eecs.umich.edu                                               (int64_t)((Reg1.ud << 32) |
2097160Sgblack@eecs.umich.edu                                                         Reg0.ud);
2107160Sgblack@eecs.umich.edu                                     Reg0.ud = (uint32_t)resTemp;
2117160Sgblack@eecs.umich.edu                                     Reg1.ud = (uint32_t)(resTemp >> 32);
2127160Sgblack@eecs.umich.edu                                  ''')
2137160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smlald", '''resTemp =
2147160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 31, 16)) *
2157160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg3, 31, 16)) +
2167160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 15, 0)) *
2177160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg3, 15, 0)) +
2187160Sgblack@eecs.umich.edu                                        (int64_t)((Reg1.ud << 32) |
2197160Sgblack@eecs.umich.edu                                                  Reg0.ud);
2207160Sgblack@eecs.umich.edu                                    Reg0.ud = (uint32_t)resTemp;
2217160Sgblack@eecs.umich.edu                                    Reg1.ud = (uint32_t)(resTemp >> 32);
2227160Sgblack@eecs.umich.edu                                 ''')
2237160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smlaldx", '''resTemp =
2247160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 31, 16)) *
2257160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg3, 15, 0)) +
2267160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 15, 0)) *
2277160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg3, 31, 16)) +
2287160Sgblack@eecs.umich.edu                                         (int64_t)((Reg1.ud << 32) |
2297160Sgblack@eecs.umich.edu                                                   Reg0.ud);
2307160Sgblack@eecs.umich.edu                                     Reg0.ud = (uint32_t)resTemp;
2317160Sgblack@eecs.umich.edu                                     Reg1.ud = (uint32_t)(resTemp >> 32);
2327160Sgblack@eecs.umich.edu                                  ''')
2337160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smlawb", '''Reg0 = resTemp =
2347160Sgblack@eecs.umich.edu                                        (Reg1.sw *
2357160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 15, 0)) +
2367196Sgblack@eecs.umich.edu                                         ((int64_t)Reg3.sw << 16)) >> 16;
2377196Sgblack@eecs.umich.edu                                    resTemp = bits(resTemp, 32) !=
2387196Sgblack@eecs.umich.edu                                              bits(resTemp, 31);
2397160Sgblack@eecs.umich.edu                                 ''', "overflow")
2407160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smlawt", '''Reg0 = resTemp =
2417160Sgblack@eecs.umich.edu                                        (Reg1.sw *
2427160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 31, 16)) +
2437196Sgblack@eecs.umich.edu                                         ((int64_t)Reg3.sw << 16)) >> 16;
2447196Sgblack@eecs.umich.edu                                    resTemp = bits(resTemp, 32) !=
2457196Sgblack@eecs.umich.edu                                              bits(resTemp, 31);
2467160Sgblack@eecs.umich.edu                                 ''', "overflow")
2477160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smlsd", '''Reg0 = resTemp =
2487160Sgblack@eecs.umich.edu                                       sext<16>(bits(Reg1, 15, 0)) *
2497160Sgblack@eecs.umich.edu                                       sext<16>(bits(Reg2, 15, 0)) -
2507160Sgblack@eecs.umich.edu                                       sext<16>(bits(Reg1, 31, 16)) *
2517160Sgblack@eecs.umich.edu                                       sext<16>(bits(Reg2, 31, 16)) +
2527160Sgblack@eecs.umich.edu                                       Reg3.sw;
2537228Sgblack@eecs.umich.edu                                    resTemp = bits(resTemp, 32) !=
2547228Sgblack@eecs.umich.edu                                              bits(resTemp, 31);
2557160Sgblack@eecs.umich.edu                                ''', "overflow")
2567160Sgblack@eecs.umich.edu    buildMult4InstCc  ("smlsdx", '''Reg0 = resTemp =
2577160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 15, 0)) *
2587160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 31, 16)) -
2597160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 31, 16)) *
2607160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 15, 0)) +
2617160Sgblack@eecs.umich.edu                                        Reg3.sw;
2627228Sgblack@eecs.umich.edu                                    resTemp = bits(resTemp, 32) !=
2637228Sgblack@eecs.umich.edu                                              bits(resTemp, 31);
2647160Sgblack@eecs.umich.edu                                 ''', "overflow")
2657160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smlsld", '''resTemp =
2667160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 15, 0)) *
2677160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg3, 15, 0)) -
2687160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 31, 16)) *
2697160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg3, 31, 16)) +
2707160Sgblack@eecs.umich.edu                                        (int64_t)((Reg1.ud << 32) |
2717160Sgblack@eecs.umich.edu                                                  Reg0.ud);
2727160Sgblack@eecs.umich.edu                                    Reg0.ud = (uint32_t)resTemp;
2737160Sgblack@eecs.umich.edu                                    Reg1.ud = (uint32_t)(resTemp >> 32);
2747160Sgblack@eecs.umich.edu                                 ''')
2757160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smlsldx", '''resTemp =
2767160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 15, 0)) *
2777160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg3, 31, 16)) -
2787160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 31, 16)) *
2797160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg3, 15, 0)) +
2807160Sgblack@eecs.umich.edu                                         (int64_t)((Reg1.ud << 32) |
2817160Sgblack@eecs.umich.edu                                                   Reg0.ud);
2827160Sgblack@eecs.umich.edu                                     Reg0.ud = (uint32_t)resTemp;
2837160Sgblack@eecs.umich.edu                                     Reg1.ud = (uint32_t)(resTemp >> 32);
2847160Sgblack@eecs.umich.edu                                  ''')
2857160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smmla", '''Reg0 = resTemp =
2867160Sgblack@eecs.umich.edu                                       ((int64_t)(Reg3.ud << 32) +
2877229Sgblack@eecs.umich.edu                                        (int64_t)Reg1.sw *
2887229Sgblack@eecs.umich.edu                                        (int64_t)Reg2.sw) >> 32;
2897160Sgblack@eecs.umich.edu                                ''')
2907160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smmlar", '''Reg0 = resTemp =
2917160Sgblack@eecs.umich.edu                                        ((int64_t)(Reg3.ud << 32) +
2927229Sgblack@eecs.umich.edu                                         (int64_t)Reg1.sw *
2937229Sgblack@eecs.umich.edu                                         (int64_t)Reg2.sw +
2947160Sgblack@eecs.umich.edu                                         ULL(0x80000000)) >> 32;
2957160Sgblack@eecs.umich.edu                                 ''')
2967160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smmls", '''Reg0 = resTemp =
2977160Sgblack@eecs.umich.edu                                       ((int64_t)(Reg3.ud << 32) -
2987229Sgblack@eecs.umich.edu                                        (int64_t)Reg1.sw *
2997229Sgblack@eecs.umich.edu                                        (int64_t)Reg2.sw) >> 32;
3007160Sgblack@eecs.umich.edu                                ''')
3017160Sgblack@eecs.umich.edu    buildMult4InstUnCc("smmlsr", '''Reg0 = resTemp =
3027160Sgblack@eecs.umich.edu                                        ((int64_t)(Reg3.ud << 32) -
3037229Sgblack@eecs.umich.edu                                         (int64_t)Reg1.sw *
3047229Sgblack@eecs.umich.edu                                         (int64_t)Reg2.sw +
3057160Sgblack@eecs.umich.edu                                         ULL(0x80000000)) >> 32;
3067160Sgblack@eecs.umich.edu                                 ''')
3077160Sgblack@eecs.umich.edu    buildMult3InstUnCc("smmul", '''Reg0 = resTemp =
3087229Sgblack@eecs.umich.edu                                       ((int64_t)Reg1.sw *
3097229Sgblack@eecs.umich.edu                                        (int64_t)Reg2.sw) >> 32;
3107160Sgblack@eecs.umich.edu                                ''')
3117160Sgblack@eecs.umich.edu    buildMult3InstUnCc("smmulr", '''Reg0 = resTemp =
3127229Sgblack@eecs.umich.edu                                        ((int64_t)Reg1.sw *
3137229Sgblack@eecs.umich.edu                                         (int64_t)Reg2.sw +
3147160Sgblack@eecs.umich.edu                                         ULL(0x80000000)) >> 32;
3157160Sgblack@eecs.umich.edu                                 ''')
3167160Sgblack@eecs.umich.edu    buildMult3InstCc  ("smuad", '''Reg0 = resTemp =
3177160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 15, 0)) *
3187160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 15, 0)) +
3197160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 31, 16)) *
3207160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 31, 16));
3217228Sgblack@eecs.umich.edu                                    resTemp = bits(resTemp, 32) !=
3227228Sgblack@eecs.umich.edu                                              bits(resTemp, 31);
3237160Sgblack@eecs.umich.edu                                ''', "overflow")
3247160Sgblack@eecs.umich.edu    buildMult3InstCc  ("smuadx", '''Reg0 = resTemp =
3257160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 15, 0)) *
3267160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 31, 16)) +
3277160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 31, 16)) *
3287160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 15, 0));
3297228Sgblack@eecs.umich.edu                                    resTemp = bits(resTemp, 32) !=
3307228Sgblack@eecs.umich.edu                                              bits(resTemp, 31);
3317160Sgblack@eecs.umich.edu                                 ''', "overflow")
3327160Sgblack@eecs.umich.edu    buildMult3InstUnCc("smulbb", '''Reg0 = resTemp =
3337160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg1, 15, 0)) *
3347160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 15, 0));
3357160Sgblack@eecs.umich.edu                                 ''')
3367160Sgblack@eecs.umich.edu    buildMult3InstUnCc("smulbt", '''Reg0 = resTemp =
3377196Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg1, 15, 0)) *
3387196Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 31, 16));
3397196Sgblack@eecs.umich.edu                                 ''')
3407196Sgblack@eecs.umich.edu    buildMult3InstUnCc("smultb", '''Reg0 = resTemp =
3417160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg1, 31, 16)) *
3427160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 15, 0));
3437160Sgblack@eecs.umich.edu                                 ''')
3447160Sgblack@eecs.umich.edu    buildMult3InstUnCc("smultt", '''Reg0 = resTemp =
3457160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg1, 31, 16)) *
3467160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 31, 16));
3477160Sgblack@eecs.umich.edu                                 ''')
3487196Sgblack@eecs.umich.edu    buildMult4Inst    ("smull", '''resTemp = (int64_t)Reg2.sw *
3497196Sgblack@eecs.umich.edu                                             (int64_t)Reg3.sw;
3507160Sgblack@eecs.umich.edu                                   Reg0 = (int32_t)resTemp;
3517160Sgblack@eecs.umich.edu                                   Reg1 = (int32_t)(resTemp >> 32);
3527160Sgblack@eecs.umich.edu                                ''', "llbit")
3537160Sgblack@eecs.umich.edu    buildMult3InstUnCc("smulwb", '''Reg0 = resTemp =
3547160Sgblack@eecs.umich.edu                                        (Reg1.sw *
3557160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 15, 0))) >> 16;
3567160Sgblack@eecs.umich.edu                                 ''')
3577160Sgblack@eecs.umich.edu    buildMult3InstUnCc("smulwt", '''Reg0 = resTemp =
3587160Sgblack@eecs.umich.edu                                        (Reg1.sw *
3597160Sgblack@eecs.umich.edu                                         sext<16>(bits(Reg2, 31, 16))) >> 16;
3607160Sgblack@eecs.umich.edu                                 ''')
3617160Sgblack@eecs.umich.edu    buildMult3InstUnCc("smusd", '''Reg0 = resTemp =
3627160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 15, 0)) *
3637160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 15, 0)) -
3647160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 31, 16)) *
3657160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 31, 16));
3667160Sgblack@eecs.umich.edu                                ''')
3677160Sgblack@eecs.umich.edu    buildMult3InstUnCc("smusdx", '''Reg0 = resTemp =
3687160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 15, 0)) *
3697160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 31, 16)) -
3707160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg1, 31, 16)) *
3717160Sgblack@eecs.umich.edu                                        sext<16>(bits(Reg2, 15, 0));
3727160Sgblack@eecs.umich.edu                                 ''')
3737160Sgblack@eecs.umich.edu    buildMult4InstUnCc("umaal", '''resTemp = Reg2.ud * Reg3.ud +
3747160Sgblack@eecs.umich.edu                                             Reg0.ud + Reg1.ud;
3757160Sgblack@eecs.umich.edu                                   Reg0.ud = (uint32_t)resTemp;
3767160Sgblack@eecs.umich.edu                                   Reg1.ud = (uint32_t)(resTemp >> 32);
3777160Sgblack@eecs.umich.edu                                ''')
3787160Sgblack@eecs.umich.edu    buildMult4Inst    ("umlal", '''resTemp = Reg2.ud * Reg3.ud + Reg0.ud +
3797160Sgblack@eecs.umich.edu                                             (Reg1.ud << 32);
3807160Sgblack@eecs.umich.edu                                   Reg0.ud = (uint32_t)resTemp;
3817160Sgblack@eecs.umich.edu                                   Reg1.ud = (uint32_t)(resTemp >> 32);
3827160Sgblack@eecs.umich.edu                                ''', "llbit")
3837160Sgblack@eecs.umich.edu    buildMult4Inst    ("umull", '''resTemp = Reg2.ud * Reg3.ud;
3847160Sgblack@eecs.umich.edu                                   Reg0 = (uint32_t)resTemp;
3857160Sgblack@eecs.umich.edu                                   Reg1 = (uint32_t)(resTemp >> 32);
3867160Sgblack@eecs.umich.edu                                ''', "llbit")
3877160Sgblack@eecs.umich.edu}};
388