neon.isa revision 9557
17639Sgblack@eecs.umich.edu// -*- mode:c++ -*-
27639Sgblack@eecs.umich.edu
37639Sgblack@eecs.umich.edu// Copyright (c) 2010 ARM Limited
47639Sgblack@eecs.umich.edu// All rights reserved
57639Sgblack@eecs.umich.edu//
67639Sgblack@eecs.umich.edu// The license below extends only to copyright in the software and shall
77639Sgblack@eecs.umich.edu// not be construed as granting a license to any other intellectual
87639Sgblack@eecs.umich.edu// property including but not limited to intellectual property relating
97639Sgblack@eecs.umich.edu// to a hardware implementation of the functionality of the software
107639Sgblack@eecs.umich.edu// licensed hereunder.  You may use the software subject to the license
117639Sgblack@eecs.umich.edu// terms below provided that you ensure that this notice is replicated
127639Sgblack@eecs.umich.edu// unmodified and in its entirety in all distributions of the software,
137639Sgblack@eecs.umich.edu// modified or unmodified, in source code or in binary form.
147639Sgblack@eecs.umich.edu//
157639Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without
167639Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are
177639Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright
187639Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer;
197639Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright
207639Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the
217639Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution;
227639Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its
237639Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from
247639Sgblack@eecs.umich.edu// this software without specific prior written permission.
257639Sgblack@eecs.umich.edu//
267639Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
277639Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
287639Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
297639Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
307639Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
317639Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
327639Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
337639Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
347639Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
357639Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
367639Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
377639Sgblack@eecs.umich.edu//
387639Sgblack@eecs.umich.edu// Authors: Gabe Black
397639Sgblack@eecs.umich.edu
407639Sgblack@eecs.umich.eduoutput header {{
417639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
427639Sgblack@eecs.umich.edu    StaticInstPtr
437639Sgblack@eecs.umich.edu    decodeNeonUThreeUReg(unsigned size,
447639Sgblack@eecs.umich.edu                         ExtMachInst machInst, IntRegIndex dest,
457639Sgblack@eecs.umich.edu                         IntRegIndex op1, IntRegIndex op2)
467639Sgblack@eecs.umich.edu    {
477639Sgblack@eecs.umich.edu        switch (size) {
487639Sgblack@eecs.umich.edu          case 0:
497639Sgblack@eecs.umich.edu            return new Base<uint8_t>(machInst, dest, op1, op2);
507639Sgblack@eecs.umich.edu          case 1:
517639Sgblack@eecs.umich.edu            return new Base<uint16_t>(machInst, dest, op1, op2);
527639Sgblack@eecs.umich.edu          case 2:
537639Sgblack@eecs.umich.edu            return new Base<uint32_t>(machInst, dest, op1, op2);
547639Sgblack@eecs.umich.edu          case 3:
557639Sgblack@eecs.umich.edu            return new Base<uint64_t>(machInst, dest, op1, op2);
567639Sgblack@eecs.umich.edu          default:
577639Sgblack@eecs.umich.edu            return new Unknown(machInst);
587639Sgblack@eecs.umich.edu        }
597639Sgblack@eecs.umich.edu    }
607639Sgblack@eecs.umich.edu
617639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
627639Sgblack@eecs.umich.edu    StaticInstPtr
637639Sgblack@eecs.umich.edu    decodeNeonSThreeUReg(unsigned size,
647639Sgblack@eecs.umich.edu                         ExtMachInst machInst, IntRegIndex dest,
657639Sgblack@eecs.umich.edu                         IntRegIndex op1, IntRegIndex op2)
667639Sgblack@eecs.umich.edu    {
677639Sgblack@eecs.umich.edu        switch (size) {
687639Sgblack@eecs.umich.edu          case 0:
697639Sgblack@eecs.umich.edu            return new Base<int8_t>(machInst, dest, op1, op2);
707639Sgblack@eecs.umich.edu          case 1:
717639Sgblack@eecs.umich.edu            return new Base<int16_t>(machInst, dest, op1, op2);
727639Sgblack@eecs.umich.edu          case 2:
737639Sgblack@eecs.umich.edu            return new Base<int32_t>(machInst, dest, op1, op2);
747639Sgblack@eecs.umich.edu          case 3:
757639Sgblack@eecs.umich.edu            return new Base<int64_t>(machInst, dest, op1, op2);
767639Sgblack@eecs.umich.edu          default:
777639Sgblack@eecs.umich.edu            return new Unknown(machInst);
787639Sgblack@eecs.umich.edu        }
797639Sgblack@eecs.umich.edu    }
807639Sgblack@eecs.umich.edu
817639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
827639Sgblack@eecs.umich.edu    StaticInstPtr
837639Sgblack@eecs.umich.edu    decodeNeonUSThreeUReg(bool notSigned, unsigned size,
847639Sgblack@eecs.umich.edu                          ExtMachInst machInst, IntRegIndex dest,
857639Sgblack@eecs.umich.edu                          IntRegIndex op1, IntRegIndex op2)
867639Sgblack@eecs.umich.edu    {
877639Sgblack@eecs.umich.edu        if (notSigned) {
887639Sgblack@eecs.umich.edu            return decodeNeonUThreeUReg<Base>(size, machInst, dest, op1, op2);
897639Sgblack@eecs.umich.edu        } else {
907639Sgblack@eecs.umich.edu            return decodeNeonSThreeUReg<Base>(size, machInst, dest, op1, op2);
917639Sgblack@eecs.umich.edu        }
927639Sgblack@eecs.umich.edu    }
937639Sgblack@eecs.umich.edu
947639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
957639Sgblack@eecs.umich.edu    StaticInstPtr
967639Sgblack@eecs.umich.edu    decodeNeonUThreeUSReg(unsigned size,
977639Sgblack@eecs.umich.edu                         ExtMachInst machInst, IntRegIndex dest,
987639Sgblack@eecs.umich.edu                         IntRegIndex op1, IntRegIndex op2)
997639Sgblack@eecs.umich.edu    {
1007639Sgblack@eecs.umich.edu        switch (size) {
1017639Sgblack@eecs.umich.edu          case 0:
1027639Sgblack@eecs.umich.edu            return new Base<uint8_t>(machInst, dest, op1, op2);
1037639Sgblack@eecs.umich.edu          case 1:
1047639Sgblack@eecs.umich.edu            return new Base<uint16_t>(machInst, dest, op1, op2);
1057639Sgblack@eecs.umich.edu          case 2:
1067639Sgblack@eecs.umich.edu            return new Base<uint32_t>(machInst, dest, op1, op2);
1077639Sgblack@eecs.umich.edu          default:
1087639Sgblack@eecs.umich.edu            return new Unknown(machInst);
1097639Sgblack@eecs.umich.edu        }
1107639Sgblack@eecs.umich.edu    }
1117639Sgblack@eecs.umich.edu
1127639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
1137639Sgblack@eecs.umich.edu    StaticInstPtr
1147639Sgblack@eecs.umich.edu    decodeNeonSThreeUSReg(unsigned size,
1157639Sgblack@eecs.umich.edu                         ExtMachInst machInst, IntRegIndex dest,
1167639Sgblack@eecs.umich.edu                         IntRegIndex op1, IntRegIndex op2)
1177639Sgblack@eecs.umich.edu    {
1187639Sgblack@eecs.umich.edu        switch (size) {
1197639Sgblack@eecs.umich.edu          case 0:
1207639Sgblack@eecs.umich.edu            return new Base<int8_t>(machInst, dest, op1, op2);
1217639Sgblack@eecs.umich.edu          case 1:
1227639Sgblack@eecs.umich.edu            return new Base<int16_t>(machInst, dest, op1, op2);
1237639Sgblack@eecs.umich.edu          case 2:
1247639Sgblack@eecs.umich.edu            return new Base<int32_t>(machInst, dest, op1, op2);
1257639Sgblack@eecs.umich.edu          default:
1267639Sgblack@eecs.umich.edu            return new Unknown(machInst);
1277639Sgblack@eecs.umich.edu        }
1287639Sgblack@eecs.umich.edu    }
1297639Sgblack@eecs.umich.edu
1307639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
1317639Sgblack@eecs.umich.edu    StaticInstPtr
1327639Sgblack@eecs.umich.edu    decodeNeonUSThreeUSReg(bool notSigned, unsigned size,
1337639Sgblack@eecs.umich.edu                           ExtMachInst machInst, IntRegIndex dest,
1347639Sgblack@eecs.umich.edu                           IntRegIndex op1, IntRegIndex op2)
1357639Sgblack@eecs.umich.edu    {
1367639Sgblack@eecs.umich.edu        if (notSigned) {
1377639Sgblack@eecs.umich.edu            return decodeNeonUThreeUSReg<Base>(
1387639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
1397639Sgblack@eecs.umich.edu        } else {
1407639Sgblack@eecs.umich.edu            return decodeNeonSThreeUSReg<Base>(
1417639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
1427639Sgblack@eecs.umich.edu        }
1437639Sgblack@eecs.umich.edu    }
1447639Sgblack@eecs.umich.edu
1457639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
1467639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
1477639Sgblack@eecs.umich.edu    StaticInstPtr
1487639Sgblack@eecs.umich.edu    decodeNeonUThreeSReg(bool q, unsigned size,
1497639Sgblack@eecs.umich.edu                         ExtMachInst machInst, IntRegIndex dest,
1507639Sgblack@eecs.umich.edu                         IntRegIndex op1, IntRegIndex op2)
1517639Sgblack@eecs.umich.edu    {
1527639Sgblack@eecs.umich.edu        if (q) {
1537639Sgblack@eecs.umich.edu            return decodeNeonUThreeUSReg<BaseQ>(
1547639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
1557639Sgblack@eecs.umich.edu        } else {
1567639Sgblack@eecs.umich.edu            return decodeNeonUThreeUSReg<BaseD>(
1577639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
1587639Sgblack@eecs.umich.edu        }
1597639Sgblack@eecs.umich.edu    }
1607639Sgblack@eecs.umich.edu
1617639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
1627639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
1637639Sgblack@eecs.umich.edu    StaticInstPtr
1647639Sgblack@eecs.umich.edu    decodeNeonSThreeSReg(bool q, unsigned size,
1657639Sgblack@eecs.umich.edu                         ExtMachInst machInst, IntRegIndex dest,
1667639Sgblack@eecs.umich.edu                         IntRegIndex op1, IntRegIndex op2)
1677639Sgblack@eecs.umich.edu    {
1687639Sgblack@eecs.umich.edu        if (q) {
1697639Sgblack@eecs.umich.edu            return decodeNeonSThreeUSReg<BaseQ>(
1707639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
1717639Sgblack@eecs.umich.edu        } else {
1727639Sgblack@eecs.umich.edu            return decodeNeonSThreeUSReg<BaseD>(
1737639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
1747639Sgblack@eecs.umich.edu        }
1757639Sgblack@eecs.umich.edu    }
1767639Sgblack@eecs.umich.edu
1777639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
1787639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
1797639Sgblack@eecs.umich.edu    StaticInstPtr
1807639Sgblack@eecs.umich.edu    decodeNeonUSThreeSReg(bool q, bool notSigned, unsigned size,
1817639Sgblack@eecs.umich.edu                          ExtMachInst machInst, IntRegIndex dest,
1827639Sgblack@eecs.umich.edu                          IntRegIndex op1, IntRegIndex op2)
1837639Sgblack@eecs.umich.edu    {
1847639Sgblack@eecs.umich.edu        if (notSigned) {
1857639Sgblack@eecs.umich.edu            return decodeNeonUThreeSReg<BaseD, BaseQ>(
1867639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1, op2);
1877639Sgblack@eecs.umich.edu        } else {
1887639Sgblack@eecs.umich.edu            return decodeNeonSThreeSReg<BaseD, BaseQ>(
1897639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1, op2);
1907639Sgblack@eecs.umich.edu        }
1917639Sgblack@eecs.umich.edu    }
1927639Sgblack@eecs.umich.edu
1937639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
1947639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
1957639Sgblack@eecs.umich.edu    StaticInstPtr
1967639Sgblack@eecs.umich.edu    decodeNeonUThreeReg(bool q, unsigned size,
1977639Sgblack@eecs.umich.edu                        ExtMachInst machInst, IntRegIndex dest,
1987639Sgblack@eecs.umich.edu                        IntRegIndex op1, IntRegIndex op2)
1997639Sgblack@eecs.umich.edu    {
2007639Sgblack@eecs.umich.edu        if (q) {
2017639Sgblack@eecs.umich.edu            return decodeNeonUThreeUReg<BaseQ>(
2027639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
2037639Sgblack@eecs.umich.edu        } else {
2047639Sgblack@eecs.umich.edu            return decodeNeonUThreeUReg<BaseD>(
2057639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
2067639Sgblack@eecs.umich.edu        }
2077639Sgblack@eecs.umich.edu    }
2087639Sgblack@eecs.umich.edu
2097639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
2107639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
2117639Sgblack@eecs.umich.edu    StaticInstPtr
2127639Sgblack@eecs.umich.edu    decodeNeonSThreeReg(bool q, unsigned size,
2137639Sgblack@eecs.umich.edu                        ExtMachInst machInst, IntRegIndex dest,
2147639Sgblack@eecs.umich.edu                        IntRegIndex op1, IntRegIndex op2)
2157639Sgblack@eecs.umich.edu    {
2167639Sgblack@eecs.umich.edu        if (q) {
2177639Sgblack@eecs.umich.edu            return decodeNeonSThreeUReg<BaseQ>(
2187639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
2197639Sgblack@eecs.umich.edu        } else {
2207639Sgblack@eecs.umich.edu            return decodeNeonSThreeUReg<BaseD>(
2217639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, op2);
2227639Sgblack@eecs.umich.edu        }
2237639Sgblack@eecs.umich.edu    }
2247639Sgblack@eecs.umich.edu
2257639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
2267639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
2277639Sgblack@eecs.umich.edu    StaticInstPtr
2287639Sgblack@eecs.umich.edu    decodeNeonUSThreeReg(bool q, bool notSigned, unsigned size,
2297639Sgblack@eecs.umich.edu                         ExtMachInst machInst, IntRegIndex dest,
2307639Sgblack@eecs.umich.edu                         IntRegIndex op1, IntRegIndex op2)
2317639Sgblack@eecs.umich.edu    {
2327639Sgblack@eecs.umich.edu        if (notSigned) {
2337639Sgblack@eecs.umich.edu            return decodeNeonUThreeReg<BaseD, BaseQ>(
2347639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1, op2);
2357639Sgblack@eecs.umich.edu        } else {
2367639Sgblack@eecs.umich.edu            return decodeNeonSThreeReg<BaseD, BaseQ>(
2377639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1, op2);
2387639Sgblack@eecs.umich.edu        }
2397639Sgblack@eecs.umich.edu    }
2407639Sgblack@eecs.umich.edu
2417639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
2427639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
2437639Sgblack@eecs.umich.edu    StaticInstPtr
2447639Sgblack@eecs.umich.edu    decodeNeonUTwoShiftReg(bool q, unsigned size,
2457639Sgblack@eecs.umich.edu                           ExtMachInst machInst, IntRegIndex dest,
2467639Sgblack@eecs.umich.edu                           IntRegIndex op1, uint64_t imm)
2477639Sgblack@eecs.umich.edu    {
2487639Sgblack@eecs.umich.edu        if (q) {
2497639Sgblack@eecs.umich.edu            switch (size) {
2507639Sgblack@eecs.umich.edu              case 0:
2517639Sgblack@eecs.umich.edu                return new BaseQ<uint8_t>(machInst, dest, op1, imm);
2527639Sgblack@eecs.umich.edu              case 1:
2537639Sgblack@eecs.umich.edu                return new BaseQ<uint16_t>(machInst, dest, op1, imm);
2547639Sgblack@eecs.umich.edu              case 2:
2557639Sgblack@eecs.umich.edu                return new BaseQ<uint32_t>(machInst, dest, op1, imm);
2567639Sgblack@eecs.umich.edu              case 3:
2577639Sgblack@eecs.umich.edu                return new BaseQ<uint64_t>(machInst, dest, op1, imm);
2587639Sgblack@eecs.umich.edu              default:
2597639Sgblack@eecs.umich.edu                return new Unknown(machInst);
2607639Sgblack@eecs.umich.edu            }
2617639Sgblack@eecs.umich.edu        } else {
2627639Sgblack@eecs.umich.edu            switch (size) {
2637639Sgblack@eecs.umich.edu              case 0:
2647639Sgblack@eecs.umich.edu                return new BaseD<uint8_t>(machInst, dest, op1, imm);
2657639Sgblack@eecs.umich.edu              case 1:
2667639Sgblack@eecs.umich.edu                return new BaseD<uint16_t>(machInst, dest, op1, imm);
2677639Sgblack@eecs.umich.edu              case 2:
2687639Sgblack@eecs.umich.edu                return new BaseD<uint32_t>(machInst, dest, op1, imm);
2697639Sgblack@eecs.umich.edu              case 3:
2707639Sgblack@eecs.umich.edu                return new BaseD<uint64_t>(machInst, dest, op1, imm);
2717639Sgblack@eecs.umich.edu              default:
2727639Sgblack@eecs.umich.edu                return new Unknown(machInst);
2737639Sgblack@eecs.umich.edu            }
2747639Sgblack@eecs.umich.edu        }
2757639Sgblack@eecs.umich.edu    }
2767639Sgblack@eecs.umich.edu
2777639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
2787639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
2797639Sgblack@eecs.umich.edu    StaticInstPtr
2807639Sgblack@eecs.umich.edu    decodeNeonSTwoShiftReg(bool q, unsigned size,
2817639Sgblack@eecs.umich.edu                           ExtMachInst machInst, IntRegIndex dest,
2827639Sgblack@eecs.umich.edu                           IntRegIndex op1, uint64_t imm)
2837639Sgblack@eecs.umich.edu    {
2847639Sgblack@eecs.umich.edu        if (q) {
2857639Sgblack@eecs.umich.edu            switch (size) {
2867639Sgblack@eecs.umich.edu              case 0:
2877639Sgblack@eecs.umich.edu                return new BaseQ<int8_t>(machInst, dest, op1, imm);
2887639Sgblack@eecs.umich.edu              case 1:
2897639Sgblack@eecs.umich.edu                return new BaseQ<int16_t>(machInst, dest, op1, imm);
2907639Sgblack@eecs.umich.edu              case 2:
2917639Sgblack@eecs.umich.edu                return new BaseQ<int32_t>(machInst, dest, op1, imm);
2927639Sgblack@eecs.umich.edu              case 3:
2937639Sgblack@eecs.umich.edu                return new BaseQ<int64_t>(machInst, dest, op1, imm);
2947639Sgblack@eecs.umich.edu              default:
2957639Sgblack@eecs.umich.edu                return new Unknown(machInst);
2967639Sgblack@eecs.umich.edu            }
2977639Sgblack@eecs.umich.edu        } else {
2987639Sgblack@eecs.umich.edu            switch (size) {
2997639Sgblack@eecs.umich.edu              case 0:
3007639Sgblack@eecs.umich.edu                return new BaseD<int8_t>(machInst, dest, op1, imm);
3017639Sgblack@eecs.umich.edu              case 1:
3027639Sgblack@eecs.umich.edu                return new BaseD<int16_t>(machInst, dest, op1, imm);
3037639Sgblack@eecs.umich.edu              case 2:
3047639Sgblack@eecs.umich.edu                return new BaseD<int32_t>(machInst, dest, op1, imm);
3057639Sgblack@eecs.umich.edu              case 3:
3067639Sgblack@eecs.umich.edu                return new BaseD<int64_t>(machInst, dest, op1, imm);
3077639Sgblack@eecs.umich.edu              default:
3087639Sgblack@eecs.umich.edu                return new Unknown(machInst);
3097639Sgblack@eecs.umich.edu            }
3107639Sgblack@eecs.umich.edu        }
3117639Sgblack@eecs.umich.edu    }
3127639Sgblack@eecs.umich.edu
3137639Sgblack@eecs.umich.edu
3147639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
3157639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
3167639Sgblack@eecs.umich.edu    StaticInstPtr
3177639Sgblack@eecs.umich.edu    decodeNeonUSTwoShiftReg(bool q, bool notSigned, unsigned size,
3187639Sgblack@eecs.umich.edu                            ExtMachInst machInst, IntRegIndex dest,
3197639Sgblack@eecs.umich.edu                            IntRegIndex op1, uint64_t imm)
3207639Sgblack@eecs.umich.edu    {
3217639Sgblack@eecs.umich.edu        if (notSigned) {
3227639Sgblack@eecs.umich.edu            return decodeNeonUTwoShiftReg<BaseD, BaseQ>(
3237639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1, imm);
3247639Sgblack@eecs.umich.edu        } else {
3257639Sgblack@eecs.umich.edu            return decodeNeonSTwoShiftReg<BaseD, BaseQ>(
3267639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1, imm);
3277639Sgblack@eecs.umich.edu        }
3287639Sgblack@eecs.umich.edu    }
3297639Sgblack@eecs.umich.edu
3307639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
3317639Sgblack@eecs.umich.edu    StaticInstPtr
3327639Sgblack@eecs.umich.edu    decodeNeonUTwoShiftUSReg(unsigned size,
3337639Sgblack@eecs.umich.edu                             ExtMachInst machInst, IntRegIndex dest,
3347639Sgblack@eecs.umich.edu                             IntRegIndex op1, uint64_t imm)
3357639Sgblack@eecs.umich.edu    {
3367639Sgblack@eecs.umich.edu        switch (size) {
3377639Sgblack@eecs.umich.edu          case 0:
3387639Sgblack@eecs.umich.edu            return new Base<uint8_t>(machInst, dest, op1, imm);
3397639Sgblack@eecs.umich.edu          case 1:
3407639Sgblack@eecs.umich.edu            return new Base<uint16_t>(machInst, dest, op1, imm);
3417639Sgblack@eecs.umich.edu          case 2:
3427639Sgblack@eecs.umich.edu            return new Base<uint32_t>(machInst, dest, op1, imm);
3437639Sgblack@eecs.umich.edu          default:
3447639Sgblack@eecs.umich.edu            return new Unknown(machInst);
3457639Sgblack@eecs.umich.edu        }
3467639Sgblack@eecs.umich.edu    }
3477639Sgblack@eecs.umich.edu
3487639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
3497639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
3507639Sgblack@eecs.umich.edu    StaticInstPtr
3517639Sgblack@eecs.umich.edu    decodeNeonUTwoShiftSReg(bool q, unsigned size,
3527639Sgblack@eecs.umich.edu                            ExtMachInst machInst, IntRegIndex dest,
3537639Sgblack@eecs.umich.edu                            IntRegIndex op1, uint64_t imm)
3547639Sgblack@eecs.umich.edu    {
3557639Sgblack@eecs.umich.edu        if (q) {
3567639Sgblack@eecs.umich.edu            return decodeNeonUTwoShiftUSReg<BaseQ>(
3577639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, imm);
3587639Sgblack@eecs.umich.edu        } else {
3597639Sgblack@eecs.umich.edu            return decodeNeonUTwoShiftUSReg<BaseD>(
3607639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, imm);
3617639Sgblack@eecs.umich.edu        }
3627639Sgblack@eecs.umich.edu    }
3637639Sgblack@eecs.umich.edu
3647639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
3657639Sgblack@eecs.umich.edu    StaticInstPtr
3667639Sgblack@eecs.umich.edu    decodeNeonSTwoShiftUSReg(unsigned size,
3677639Sgblack@eecs.umich.edu                             ExtMachInst machInst, IntRegIndex dest,
3687639Sgblack@eecs.umich.edu                             IntRegIndex op1, uint64_t imm)
3697639Sgblack@eecs.umich.edu    {
3707639Sgblack@eecs.umich.edu        switch (size) {
3717639Sgblack@eecs.umich.edu          case 0:
3727639Sgblack@eecs.umich.edu            return new Base<int8_t>(machInst, dest, op1, imm);
3737639Sgblack@eecs.umich.edu          case 1:
3747639Sgblack@eecs.umich.edu            return new Base<int16_t>(machInst, dest, op1, imm);
3757639Sgblack@eecs.umich.edu          case 2:
3767639Sgblack@eecs.umich.edu            return new Base<int32_t>(machInst, dest, op1, imm);
3777639Sgblack@eecs.umich.edu          default:
3787639Sgblack@eecs.umich.edu            return new Unknown(machInst);
3797639Sgblack@eecs.umich.edu        }
3807639Sgblack@eecs.umich.edu    }
3817639Sgblack@eecs.umich.edu
3827639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
3837639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
3847639Sgblack@eecs.umich.edu    StaticInstPtr
3857639Sgblack@eecs.umich.edu    decodeNeonSTwoShiftSReg(bool q, unsigned size,
3867639Sgblack@eecs.umich.edu                            ExtMachInst machInst, IntRegIndex dest,
3877639Sgblack@eecs.umich.edu                            IntRegIndex op1, uint64_t imm)
3887639Sgblack@eecs.umich.edu    {
3897639Sgblack@eecs.umich.edu        if (q) {
3907639Sgblack@eecs.umich.edu            return decodeNeonSTwoShiftUSReg<BaseQ>(
3917639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, imm);
3927639Sgblack@eecs.umich.edu        } else {
3937639Sgblack@eecs.umich.edu            return decodeNeonSTwoShiftUSReg<BaseD>(
3947639Sgblack@eecs.umich.edu                    size, machInst, dest, op1, imm);
3957639Sgblack@eecs.umich.edu        }
3967639Sgblack@eecs.umich.edu    }
3977639Sgblack@eecs.umich.edu
3987639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
3997639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
4007639Sgblack@eecs.umich.edu    StaticInstPtr
4017639Sgblack@eecs.umich.edu    decodeNeonUSTwoShiftSReg(bool q, bool notSigned, unsigned size,
4027639Sgblack@eecs.umich.edu                             ExtMachInst machInst, IntRegIndex dest,
4037639Sgblack@eecs.umich.edu                             IntRegIndex op1, uint64_t imm)
4047639Sgblack@eecs.umich.edu    {
4057639Sgblack@eecs.umich.edu        if (notSigned) {
4067639Sgblack@eecs.umich.edu            return decodeNeonUTwoShiftSReg<BaseD, BaseQ>(
4077639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1, imm);
4087639Sgblack@eecs.umich.edu        } else {
4097639Sgblack@eecs.umich.edu            return decodeNeonSTwoShiftSReg<BaseD, BaseQ>(
4107639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1, imm);
4117639Sgblack@eecs.umich.edu        }
4127639Sgblack@eecs.umich.edu    }
4137639Sgblack@eecs.umich.edu
4147639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
4157639Sgblack@eecs.umich.edu    StaticInstPtr
4167639Sgblack@eecs.umich.edu    decodeNeonUTwoMiscUSReg(unsigned size,
4177639Sgblack@eecs.umich.edu                            ExtMachInst machInst, IntRegIndex dest,
4187639Sgblack@eecs.umich.edu                            IntRegIndex op1)
4197639Sgblack@eecs.umich.edu    {
4207639Sgblack@eecs.umich.edu        switch (size) {
4217639Sgblack@eecs.umich.edu          case 0:
4227639Sgblack@eecs.umich.edu            return new Base<uint8_t>(machInst, dest, op1);
4237639Sgblack@eecs.umich.edu          case 1:
4247639Sgblack@eecs.umich.edu            return new Base<uint16_t>(machInst, dest, op1);
4257639Sgblack@eecs.umich.edu          case 2:
4267639Sgblack@eecs.umich.edu            return new Base<uint32_t>(machInst, dest, op1);
4277639Sgblack@eecs.umich.edu          default:
4287639Sgblack@eecs.umich.edu            return new Unknown(machInst);
4297639Sgblack@eecs.umich.edu        }
4307639Sgblack@eecs.umich.edu    }
4317639Sgblack@eecs.umich.edu
4327639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
4337639Sgblack@eecs.umich.edu    StaticInstPtr
4347639Sgblack@eecs.umich.edu    decodeNeonSTwoMiscUSReg(unsigned size,
4357639Sgblack@eecs.umich.edu                            ExtMachInst machInst, IntRegIndex dest,
4367639Sgblack@eecs.umich.edu                            IntRegIndex op1)
4377639Sgblack@eecs.umich.edu    {
4387639Sgblack@eecs.umich.edu        switch (size) {
4397639Sgblack@eecs.umich.edu          case 0:
4407639Sgblack@eecs.umich.edu            return new Base<int8_t>(machInst, dest, op1);
4417639Sgblack@eecs.umich.edu          case 1:
4427639Sgblack@eecs.umich.edu            return new Base<int16_t>(machInst, dest, op1);
4437639Sgblack@eecs.umich.edu          case 2:
4447639Sgblack@eecs.umich.edu            return new Base<int32_t>(machInst, dest, op1);
4457639Sgblack@eecs.umich.edu          default:
4467639Sgblack@eecs.umich.edu            return new Unknown(machInst);
4477639Sgblack@eecs.umich.edu        }
4487639Sgblack@eecs.umich.edu    }
4497639Sgblack@eecs.umich.edu
4507639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
4517639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
4527639Sgblack@eecs.umich.edu    StaticInstPtr
4537639Sgblack@eecs.umich.edu    decodeNeonUTwoMiscSReg(bool q, unsigned size,
4547639Sgblack@eecs.umich.edu                          ExtMachInst machInst, IntRegIndex dest,
4557639Sgblack@eecs.umich.edu                          IntRegIndex op1)
4567639Sgblack@eecs.umich.edu    {
4577639Sgblack@eecs.umich.edu        if (q) {
4587639Sgblack@eecs.umich.edu            return decodeNeonUTwoMiscUSReg<BaseQ>(size, machInst, dest, op1);
4597639Sgblack@eecs.umich.edu        } else {
4607639Sgblack@eecs.umich.edu            return decodeNeonUTwoMiscUSReg<BaseD>(size, machInst, dest, op1);
4617639Sgblack@eecs.umich.edu        }
4627639Sgblack@eecs.umich.edu    }
4637639Sgblack@eecs.umich.edu
4647639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
4657639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
4667639Sgblack@eecs.umich.edu    StaticInstPtr
4677639Sgblack@eecs.umich.edu    decodeNeonSTwoMiscSReg(bool q, unsigned size,
4687639Sgblack@eecs.umich.edu                          ExtMachInst machInst, IntRegIndex dest,
4697639Sgblack@eecs.umich.edu                          IntRegIndex op1)
4707639Sgblack@eecs.umich.edu    {
4717639Sgblack@eecs.umich.edu        if (q) {
4727639Sgblack@eecs.umich.edu            return decodeNeonSTwoMiscUSReg<BaseQ>(size, machInst, dest, op1);
4737639Sgblack@eecs.umich.edu        } else {
4747639Sgblack@eecs.umich.edu            return decodeNeonSTwoMiscUSReg<BaseD>(size, machInst, dest, op1);
4757639Sgblack@eecs.umich.edu        }
4767639Sgblack@eecs.umich.edu    }
4777639Sgblack@eecs.umich.edu
4787639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
4797639Sgblack@eecs.umich.edu    StaticInstPtr
4807639Sgblack@eecs.umich.edu    decodeNeonUTwoMiscUReg(unsigned size,
4817639Sgblack@eecs.umich.edu                           ExtMachInst machInst, IntRegIndex dest,
4827639Sgblack@eecs.umich.edu                           IntRegIndex op1)
4837639Sgblack@eecs.umich.edu    {
4847639Sgblack@eecs.umich.edu        switch (size) {
4857639Sgblack@eecs.umich.edu          case 0:
4867639Sgblack@eecs.umich.edu            return new Base<uint8_t>(machInst, dest, op1);
4877639Sgblack@eecs.umich.edu          case 1:
4887639Sgblack@eecs.umich.edu            return new Base<uint16_t>(machInst, dest, op1);
4897639Sgblack@eecs.umich.edu          case 2:
4907639Sgblack@eecs.umich.edu            return new Base<uint32_t>(machInst, dest, op1);
4917639Sgblack@eecs.umich.edu          case 3:
4927639Sgblack@eecs.umich.edu            return new Base<uint64_t>(machInst, dest, op1);
4937639Sgblack@eecs.umich.edu          default:
4947639Sgblack@eecs.umich.edu            return new Unknown(machInst);
4957639Sgblack@eecs.umich.edu        }
4967639Sgblack@eecs.umich.edu    }
4977639Sgblack@eecs.umich.edu
4987639Sgblack@eecs.umich.edu    template <template <typename T> class Base>
4997639Sgblack@eecs.umich.edu    StaticInstPtr
5007639Sgblack@eecs.umich.edu    decodeNeonSTwoMiscUReg(unsigned size,
5017639Sgblack@eecs.umich.edu                            ExtMachInst machInst, IntRegIndex dest,
5027639Sgblack@eecs.umich.edu                            IntRegIndex op1)
5037639Sgblack@eecs.umich.edu    {
5047639Sgblack@eecs.umich.edu        switch (size) {
5057639Sgblack@eecs.umich.edu          case 0:
5067639Sgblack@eecs.umich.edu            return new Base<int8_t>(machInst, dest, op1);
5077639Sgblack@eecs.umich.edu          case 1:
5087639Sgblack@eecs.umich.edu            return new Base<int16_t>(machInst, dest, op1);
5097639Sgblack@eecs.umich.edu          case 2:
5107639Sgblack@eecs.umich.edu            return new Base<int32_t>(machInst, dest, op1);
5117639Sgblack@eecs.umich.edu          case 3:
5127639Sgblack@eecs.umich.edu            return new Base<int64_t>(machInst, dest, op1);
5137639Sgblack@eecs.umich.edu          default:
5147639Sgblack@eecs.umich.edu            return new Unknown(machInst);
5157639Sgblack@eecs.umich.edu        }
5167639Sgblack@eecs.umich.edu    }
5177639Sgblack@eecs.umich.edu
5187639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
5197639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
5207639Sgblack@eecs.umich.edu    StaticInstPtr
5217639Sgblack@eecs.umich.edu    decodeNeonSTwoMiscReg(bool q, unsigned size,
5227639Sgblack@eecs.umich.edu                          ExtMachInst machInst, IntRegIndex dest,
5237639Sgblack@eecs.umich.edu                          IntRegIndex op1)
5247639Sgblack@eecs.umich.edu    {
5257639Sgblack@eecs.umich.edu        if (q) {
5267639Sgblack@eecs.umich.edu            return decodeNeonSTwoMiscUReg<BaseQ>(size, machInst, dest, op1);
5277639Sgblack@eecs.umich.edu        } else {
5287639Sgblack@eecs.umich.edu            return decodeNeonSTwoMiscUReg<BaseD>(size, machInst, dest, op1);
5297639Sgblack@eecs.umich.edu        }
5307639Sgblack@eecs.umich.edu    }
5317639Sgblack@eecs.umich.edu
5327639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
5337639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
5347639Sgblack@eecs.umich.edu    StaticInstPtr
5357639Sgblack@eecs.umich.edu    decodeNeonUTwoMiscReg(bool q, unsigned size,
5367639Sgblack@eecs.umich.edu                          ExtMachInst machInst, IntRegIndex dest,
5377639Sgblack@eecs.umich.edu                          IntRegIndex op1)
5387639Sgblack@eecs.umich.edu    {
5397639Sgblack@eecs.umich.edu        if (q) {
5407639Sgblack@eecs.umich.edu            return decodeNeonUTwoMiscUReg<BaseQ>(size, machInst, dest, op1);
5417639Sgblack@eecs.umich.edu        } else {
5427639Sgblack@eecs.umich.edu            return decodeNeonUTwoMiscUReg<BaseD>(size, machInst, dest, op1);
5437639Sgblack@eecs.umich.edu        }
5447639Sgblack@eecs.umich.edu    }
5457639Sgblack@eecs.umich.edu
5467639Sgblack@eecs.umich.edu    template <template <typename T> class BaseD,
5477639Sgblack@eecs.umich.edu              template <typename T> class BaseQ>
5487639Sgblack@eecs.umich.edu    StaticInstPtr
5497639Sgblack@eecs.umich.edu    decodeNeonUSTwoMiscSReg(bool q, bool notSigned, unsigned size,
5507639Sgblack@eecs.umich.edu                            ExtMachInst machInst, IntRegIndex dest,
5517639Sgblack@eecs.umich.edu                            IntRegIndex op1)
5527639Sgblack@eecs.umich.edu    {
5537639Sgblack@eecs.umich.edu        if (notSigned) {
5547639Sgblack@eecs.umich.edu            return decodeNeonUTwoShiftSReg<BaseD, BaseQ>(
5557639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1);
5567639Sgblack@eecs.umich.edu        } else {
5577639Sgblack@eecs.umich.edu            return decodeNeonSTwoShiftSReg<BaseD, BaseQ>(
5587639Sgblack@eecs.umich.edu                    q, size, machInst, dest, op1);
5597639Sgblack@eecs.umich.edu        }
5607639Sgblack@eecs.umich.edu    }
5617639Sgblack@eecs.umich.edu
5627639Sgblack@eecs.umich.edu}};
5637639Sgblack@eecs.umich.edu
5647639Sgblack@eecs.umich.eduoutput exec {{
5657639Sgblack@eecs.umich.edu    static float
5667639Sgblack@eecs.umich.edu    vcgtFunc(float op1, float op2)
5677639Sgblack@eecs.umich.edu    {
5689517SAli.Saidi@ARM.com        if (std::isnan(op1) || std::isnan(op2))
5697639Sgblack@eecs.umich.edu            return 2.0;
5707639Sgblack@eecs.umich.edu        return (op1 > op2) ? 0.0 : 1.0;
5717639Sgblack@eecs.umich.edu    }
5727639Sgblack@eecs.umich.edu
5737639Sgblack@eecs.umich.edu    static float
5747639Sgblack@eecs.umich.edu    vcgeFunc(float op1, float op2)
5757639Sgblack@eecs.umich.edu    {
5769517SAli.Saidi@ARM.com        if (std::isnan(op1) || std::isnan(op2))
5777639Sgblack@eecs.umich.edu            return 2.0;
5787639Sgblack@eecs.umich.edu        return (op1 >= op2) ? 0.0 : 1.0;
5797639Sgblack@eecs.umich.edu    }
5807639Sgblack@eecs.umich.edu
5817639Sgblack@eecs.umich.edu    static float
5827639Sgblack@eecs.umich.edu    vceqFunc(float op1, float op2)
5837639Sgblack@eecs.umich.edu    {
5847639Sgblack@eecs.umich.edu        if (isSnan(op1) || isSnan(op2))
5857639Sgblack@eecs.umich.edu            return 2.0;
5867639Sgblack@eecs.umich.edu        return (op1 == op2) ? 0.0 : 1.0;
5877639Sgblack@eecs.umich.edu    }
5887639Sgblack@eecs.umich.edu
5897639Sgblack@eecs.umich.edu    static float
5907639Sgblack@eecs.umich.edu    vcleFunc(float op1, float op2)
5917639Sgblack@eecs.umich.edu    {
5929517SAli.Saidi@ARM.com        if (std::isnan(op1) || std::isnan(op2))
5937639Sgblack@eecs.umich.edu            return 2.0;
5947639Sgblack@eecs.umich.edu        return (op1 <= op2) ? 0.0 : 1.0;
5957639Sgblack@eecs.umich.edu    }
5967639Sgblack@eecs.umich.edu
5977639Sgblack@eecs.umich.edu    static float
5987639Sgblack@eecs.umich.edu    vcltFunc(float op1, float op2)
5997639Sgblack@eecs.umich.edu    {
6009517SAli.Saidi@ARM.com        if (std::isnan(op1) || std::isnan(op2))
6017639Sgblack@eecs.umich.edu            return 2.0;
6027639Sgblack@eecs.umich.edu        return (op1 < op2) ? 0.0 : 1.0;
6037639Sgblack@eecs.umich.edu    }
6047639Sgblack@eecs.umich.edu
6057639Sgblack@eecs.umich.edu    static float
6067639Sgblack@eecs.umich.edu    vacgtFunc(float op1, float op2)
6077639Sgblack@eecs.umich.edu    {
6089517SAli.Saidi@ARM.com        if (std::isnan(op1) || std::isnan(op2))
6097639Sgblack@eecs.umich.edu            return 2.0;
6107639Sgblack@eecs.umich.edu        return (fabsf(op1) > fabsf(op2)) ? 0.0 : 1.0;
6117639Sgblack@eecs.umich.edu    }
6127639Sgblack@eecs.umich.edu
6137639Sgblack@eecs.umich.edu    static float
6147639Sgblack@eecs.umich.edu    vacgeFunc(float op1, float op2)
6157639Sgblack@eecs.umich.edu    {
6169517SAli.Saidi@ARM.com        if (std::isnan(op1) || std::isnan(op2))
6177639Sgblack@eecs.umich.edu            return 2.0;
6187639Sgblack@eecs.umich.edu        return (fabsf(op1) >= fabsf(op2)) ? 0.0 : 1.0;
6197639Sgblack@eecs.umich.edu    }
6207639Sgblack@eecs.umich.edu}};
6217639Sgblack@eecs.umich.edu
6227639Sgblack@eecs.umich.edulet {{
6237639Sgblack@eecs.umich.edu
6247639Sgblack@eecs.umich.edu    header_output = ""
6257639Sgblack@eecs.umich.edu    exec_output = ""
6267639Sgblack@eecs.umich.edu
6277639Sgblack@eecs.umich.edu    smallUnsignedTypes = ("uint8_t", "uint16_t", "uint32_t")
6287639Sgblack@eecs.umich.edu    unsignedTypes = smallUnsignedTypes + ("uint64_t",)
6297639Sgblack@eecs.umich.edu    smallSignedTypes = ("int8_t", "int16_t", "int32_t")
6307639Sgblack@eecs.umich.edu    signedTypes = smallSignedTypes + ("int64_t",)
6317639Sgblack@eecs.umich.edu    smallTypes = smallUnsignedTypes + smallSignedTypes
6327639Sgblack@eecs.umich.edu    allTypes = unsignedTypes + signedTypes
6337639Sgblack@eecs.umich.edu
6347760SGiacomo.Gabrielli@arm.com    def threeEqualRegInst(name, Name, opClass, types, rCount, op,
6357639Sgblack@eecs.umich.edu                          readDest=False, pairwise=False):
6367639Sgblack@eecs.umich.edu        global header_output, exec_output
6377640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
6387639Sgblack@eecs.umich.edu        RegVect srcReg1, srcReg2, destReg;
6397639Sgblack@eecs.umich.edu        '''
6407639Sgblack@eecs.umich.edu        for reg in range(rCount):
6417639Sgblack@eecs.umich.edu            eWalkCode += '''
6428588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
6438588Sgblack@eecs.umich.edu                srcReg2.regs[%(reg)d] = htog(FpOp2P%(reg)d_uw);
6447639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
6457639Sgblack@eecs.umich.edu            if readDest:
6467639Sgblack@eecs.umich.edu                eWalkCode += '''
6478588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
6487639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
6497639Sgblack@eecs.umich.edu        readDestCode = ''
6507639Sgblack@eecs.umich.edu        if readDest:
6517639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
6527639Sgblack@eecs.umich.edu        if pairwise:
6537639Sgblack@eecs.umich.edu            eWalkCode += '''
6547639Sgblack@eecs.umich.edu            for (unsigned i = 0; i < eCount; i++) {
6557639Sgblack@eecs.umich.edu                Element srcElem1 = gtoh(2 * i < eCount ?
6567639Sgblack@eecs.umich.edu                                        srcReg1.elements[2 * i] :
6577639Sgblack@eecs.umich.edu                                        srcReg2.elements[2 * i - eCount]);
6587639Sgblack@eecs.umich.edu                Element srcElem2 = gtoh(2 * i < eCount ?
6597639Sgblack@eecs.umich.edu                                        srcReg1.elements[2 * i + 1] :
6607639Sgblack@eecs.umich.edu                                        srcReg2.elements[2 * i + 1 - eCount]);
6617639Sgblack@eecs.umich.edu                Element destElem;
6627639Sgblack@eecs.umich.edu                %(readDest)s
6637639Sgblack@eecs.umich.edu                %(op)s
6647639Sgblack@eecs.umich.edu                destReg.elements[i] = htog(destElem);
6657639Sgblack@eecs.umich.edu            }
6667639Sgblack@eecs.umich.edu            ''' % { "op" : op, "readDest" : readDestCode }
6677639Sgblack@eecs.umich.edu        else:
6687639Sgblack@eecs.umich.edu            eWalkCode += '''
6697639Sgblack@eecs.umich.edu            for (unsigned i = 0; i < eCount; i++) {
6707639Sgblack@eecs.umich.edu                Element srcElem1 = gtoh(srcReg1.elements[i]);
6717639Sgblack@eecs.umich.edu                Element srcElem2 = gtoh(srcReg2.elements[i]);
6727639Sgblack@eecs.umich.edu                Element destElem;
6737639Sgblack@eecs.umich.edu                %(readDest)s
6747639Sgblack@eecs.umich.edu                %(op)s
6757639Sgblack@eecs.umich.edu                destReg.elements[i] = htog(destElem);
6767639Sgblack@eecs.umich.edu            }
6777639Sgblack@eecs.umich.edu            ''' % { "op" : op, "readDest" : readDestCode }
6787639Sgblack@eecs.umich.edu        for reg in range(rCount):
6797639Sgblack@eecs.umich.edu            eWalkCode += '''
6808588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
6817639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
6827639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
6837639Sgblack@eecs.umich.edu                            "RegRegRegOp",
6847639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
6857639Sgblack@eecs.umich.edu                              "r_count": rCount,
6867760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
6877760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
6887639Sgblack@eecs.umich.edu        header_output += NeonRegRegRegOpDeclare.subst(iop)
6897639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
6907639Sgblack@eecs.umich.edu        for type in types:
6917639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
6927639Sgblack@eecs.umich.edu                          "class_name" : Name }
6937639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
6947639Sgblack@eecs.umich.edu
6957760SGiacomo.Gabrielli@arm.com    def threeEqualRegInstFp(name, Name, opClass, types, rCount, op,
6967639Sgblack@eecs.umich.edu                            readDest=False, pairwise=False, toInt=False):
6977639Sgblack@eecs.umich.edu        global header_output, exec_output
6987640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
6997639Sgblack@eecs.umich.edu        typedef FloatReg FloatVect[rCount];
7007639Sgblack@eecs.umich.edu        FloatVect srcRegs1, srcRegs2;
7017639Sgblack@eecs.umich.edu        '''
7027639Sgblack@eecs.umich.edu        if toInt:
7037639Sgblack@eecs.umich.edu            eWalkCode += 'RegVect destRegs;\n'
7047639Sgblack@eecs.umich.edu        else:
7057639Sgblack@eecs.umich.edu            eWalkCode += 'FloatVect destRegs;\n'
7067639Sgblack@eecs.umich.edu        for reg in range(rCount):
7077639Sgblack@eecs.umich.edu            eWalkCode += '''
7087639Sgblack@eecs.umich.edu                srcRegs1[%(reg)d] = FpOp1P%(reg)d;
7097639Sgblack@eecs.umich.edu                srcRegs2[%(reg)d] = FpOp2P%(reg)d;
7107639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
7117639Sgblack@eecs.umich.edu            if readDest:
7127639Sgblack@eecs.umich.edu                if toInt:
7137639Sgblack@eecs.umich.edu                    eWalkCode += '''
7147639Sgblack@eecs.umich.edu                        destRegs.regs[%(reg)d] = FpDestP%(reg)d.bits;
7157639Sgblack@eecs.umich.edu                    ''' % { "reg" : reg }
7167639Sgblack@eecs.umich.edu                else:
7177639Sgblack@eecs.umich.edu                    eWalkCode += '''
7187639Sgblack@eecs.umich.edu                        destRegs[%(reg)d] = FpDestP%(reg)d;
7197639Sgblack@eecs.umich.edu                    ''' % { "reg" : reg }
7207639Sgblack@eecs.umich.edu        readDestCode = ''
7217639Sgblack@eecs.umich.edu        if readDest:
7227639Sgblack@eecs.umich.edu            readDestCode = 'destReg = destRegs[r];'
7237639Sgblack@eecs.umich.edu        destType = 'FloatReg'
7247639Sgblack@eecs.umich.edu        writeDest = 'destRegs[r] = destReg;'
7257639Sgblack@eecs.umich.edu        if toInt:
7267639Sgblack@eecs.umich.edu            destType = 'FloatRegBits'
7277639Sgblack@eecs.umich.edu            writeDest = 'destRegs.regs[r] = destReg;'
7287639Sgblack@eecs.umich.edu        if pairwise:
7297639Sgblack@eecs.umich.edu            eWalkCode += '''
7307639Sgblack@eecs.umich.edu            for (unsigned r = 0; r < rCount; r++) {
7317639Sgblack@eecs.umich.edu                FloatReg srcReg1 = (2 * r < rCount) ?
7327639Sgblack@eecs.umich.edu                    srcRegs1[2 * r] : srcRegs2[2 * r - rCount];
7337639Sgblack@eecs.umich.edu                FloatReg srcReg2 = (2 * r < rCount) ?
7347639Sgblack@eecs.umich.edu                    srcRegs1[2 * r + 1] : srcRegs2[2 * r + 1 - rCount];
7357639Sgblack@eecs.umich.edu                %(destType)s destReg;
7367639Sgblack@eecs.umich.edu                %(readDest)s
7377639Sgblack@eecs.umich.edu                %(op)s
7387639Sgblack@eecs.umich.edu                %(writeDest)s
7397639Sgblack@eecs.umich.edu            }
7407639Sgblack@eecs.umich.edu            ''' % { "op" : op,
7417639Sgblack@eecs.umich.edu                    "readDest" : readDestCode,
7427639Sgblack@eecs.umich.edu                    "destType" : destType,
7437639Sgblack@eecs.umich.edu                    "writeDest" : writeDest }
7447639Sgblack@eecs.umich.edu        else:
7457639Sgblack@eecs.umich.edu            eWalkCode += '''
7467639Sgblack@eecs.umich.edu            for (unsigned r = 0; r < rCount; r++) {
7477639Sgblack@eecs.umich.edu                FloatReg srcReg1 = srcRegs1[r];
7487639Sgblack@eecs.umich.edu                FloatReg srcReg2 = srcRegs2[r];
7497639Sgblack@eecs.umich.edu                %(destType)s destReg;
7507639Sgblack@eecs.umich.edu                %(readDest)s
7517639Sgblack@eecs.umich.edu                %(op)s
7527639Sgblack@eecs.umich.edu                %(writeDest)s
7537639Sgblack@eecs.umich.edu            }
7547639Sgblack@eecs.umich.edu            ''' % { "op" : op,
7557639Sgblack@eecs.umich.edu                    "readDest" : readDestCode,
7567639Sgblack@eecs.umich.edu                    "destType" : destType,
7577639Sgblack@eecs.umich.edu                    "writeDest" : writeDest }
7587639Sgblack@eecs.umich.edu        for reg in range(rCount):
7597639Sgblack@eecs.umich.edu            if toInt:
7607639Sgblack@eecs.umich.edu                eWalkCode += '''
7618588Sgblack@eecs.umich.edu                FpDestP%(reg)d_uw = destRegs.regs[%(reg)d];
7627639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
7637639Sgblack@eecs.umich.edu            else:
7647639Sgblack@eecs.umich.edu                eWalkCode += '''
7657639Sgblack@eecs.umich.edu                FpDestP%(reg)d = destRegs[%(reg)d];
7667639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
7677639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
7687639Sgblack@eecs.umich.edu                            "FpRegRegRegOp",
7697639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
7707639Sgblack@eecs.umich.edu                              "r_count": rCount,
7717760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
7727760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
7737639Sgblack@eecs.umich.edu        header_output += NeonRegRegRegOpDeclare.subst(iop)
7747639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
7757639Sgblack@eecs.umich.edu        for type in types:
7767639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
7777639Sgblack@eecs.umich.edu                          "class_name" : Name }
7787639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
7797639Sgblack@eecs.umich.edu
7807760SGiacomo.Gabrielli@arm.com    def threeUnequalRegInst(name, Name, opClass, types, op,
7817639Sgblack@eecs.umich.edu                            bigSrc1, bigSrc2, bigDest, readDest):
7827639Sgblack@eecs.umich.edu        global header_output, exec_output
7837639Sgblack@eecs.umich.edu        src1Cnt = src2Cnt = destCnt = 2
7847639Sgblack@eecs.umich.edu        src1Prefix = src2Prefix = destPrefix = ''
7857639Sgblack@eecs.umich.edu        if bigSrc1:
7867639Sgblack@eecs.umich.edu            src1Cnt = 4
7877639Sgblack@eecs.umich.edu            src1Prefix = 'Big'
7887639Sgblack@eecs.umich.edu        if bigSrc2:
7897639Sgblack@eecs.umich.edu            src2Cnt = 4
7907639Sgblack@eecs.umich.edu            src2Prefix = 'Big'
7917639Sgblack@eecs.umich.edu        if bigDest:
7927639Sgblack@eecs.umich.edu            destCnt = 4
7937639Sgblack@eecs.umich.edu            destPrefix = 'Big'
7947640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
7957639Sgblack@eecs.umich.edu            %sRegVect srcReg1;
7967639Sgblack@eecs.umich.edu            %sRegVect srcReg2;
7977639Sgblack@eecs.umich.edu            %sRegVect destReg;
7987639Sgblack@eecs.umich.edu        ''' % (src1Prefix, src2Prefix, destPrefix)
7997639Sgblack@eecs.umich.edu        for reg in range(src1Cnt):
8007639Sgblack@eecs.umich.edu            eWalkCode += '''
8018588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
8027639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
8037639Sgblack@eecs.umich.edu        for reg in range(src2Cnt):
8047639Sgblack@eecs.umich.edu            eWalkCode += '''
8058588Sgblack@eecs.umich.edu                srcReg2.regs[%(reg)d] = htog(FpOp2P%(reg)d_uw);
8067639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
8077639Sgblack@eecs.umich.edu        if readDest:
8087639Sgblack@eecs.umich.edu            for reg in range(destCnt):
8097639Sgblack@eecs.umich.edu                eWalkCode += '''
8108588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
8117639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
8127639Sgblack@eecs.umich.edu        readDestCode = ''
8137639Sgblack@eecs.umich.edu        if readDest:
8147639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
8157639Sgblack@eecs.umich.edu        eWalkCode += '''
8167639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
8177639Sgblack@eecs.umich.edu            %(src1Prefix)sElement srcElem1 = gtoh(srcReg1.elements[i]);
8187639Sgblack@eecs.umich.edu            %(src1Prefix)sElement srcElem2 = gtoh(srcReg2.elements[i]);
8197639Sgblack@eecs.umich.edu            %(destPrefix)sElement destElem;
8207639Sgblack@eecs.umich.edu            %(readDest)s
8217639Sgblack@eecs.umich.edu            %(op)s
8227639Sgblack@eecs.umich.edu            destReg.elements[i] = htog(destElem);
8237639Sgblack@eecs.umich.edu        }
8247639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode,
8257639Sgblack@eecs.umich.edu                "src1Prefix" : src1Prefix, "src2Prefix" : src2Prefix,
8267639Sgblack@eecs.umich.edu                "destPrefix" : destPrefix }
8277639Sgblack@eecs.umich.edu        for reg in range(destCnt):
8287639Sgblack@eecs.umich.edu            eWalkCode += '''
8298588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
8307639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
8317639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
8327639Sgblack@eecs.umich.edu                            "RegRegRegOp",
8337639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
8347639Sgblack@eecs.umich.edu                              "r_count": 2,
8357760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
8367760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
8377639Sgblack@eecs.umich.edu        header_output += NeonRegRegRegOpDeclare.subst(iop)
8387639Sgblack@eecs.umich.edu        exec_output += NeonUnequalRegExecute.subst(iop)
8397639Sgblack@eecs.umich.edu        for type in types:
8407639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
8417639Sgblack@eecs.umich.edu                          "class_name" : Name }
8427639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
8437639Sgblack@eecs.umich.edu
8447760SGiacomo.Gabrielli@arm.com    def threeRegNarrowInst(name, Name, opClass, types, op, readDest=False):
8457760SGiacomo.Gabrielli@arm.com        threeUnequalRegInst(name, Name, opClass, types, op,
8467639Sgblack@eecs.umich.edu                            True, True, False, readDest)
8477639Sgblack@eecs.umich.edu
8487760SGiacomo.Gabrielli@arm.com    def threeRegLongInst(name, Name, opClass, types, op, readDest=False):
8497760SGiacomo.Gabrielli@arm.com        threeUnequalRegInst(name, Name, opClass, types, op,
8507639Sgblack@eecs.umich.edu                            False, False, True, readDest)
8517639Sgblack@eecs.umich.edu
8527760SGiacomo.Gabrielli@arm.com    def threeRegWideInst(name, Name, opClass, types, op, readDest=False):
8537760SGiacomo.Gabrielli@arm.com        threeUnequalRegInst(name, Name, opClass, types, op,
8547639Sgblack@eecs.umich.edu                            True, False, True, readDest)
8557639Sgblack@eecs.umich.edu
8567760SGiacomo.Gabrielli@arm.com    def twoEqualRegInst(name, Name, opClass, types, rCount, op, readDest=False):
8577639Sgblack@eecs.umich.edu        global header_output, exec_output
8587640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
8597639Sgblack@eecs.umich.edu        RegVect srcReg1, srcReg2, destReg;
8607639Sgblack@eecs.umich.edu        '''
8617639Sgblack@eecs.umich.edu        for reg in range(rCount):
8627639Sgblack@eecs.umich.edu            eWalkCode += '''
8638588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
8648588Sgblack@eecs.umich.edu                srcReg2.regs[%(reg)d] = htog(FpOp2P%(reg)d_uw);
8657639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
8667639Sgblack@eecs.umich.edu            if readDest:
8677639Sgblack@eecs.umich.edu                eWalkCode += '''
8688588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
8697639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
8707639Sgblack@eecs.umich.edu        readDestCode = ''
8717639Sgblack@eecs.umich.edu        if readDest:
8727639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
8737639Sgblack@eecs.umich.edu        eWalkCode += '''
8747853SMatt.Horsnell@ARM.com        if (imm < 0 && imm >= eCount) {
8758782Sgblack@eecs.umich.edu            if (FullSystem)
8768782Sgblack@eecs.umich.edu                fault = new UndefinedInstruction;
8778782Sgblack@eecs.umich.edu            else
8788782Sgblack@eecs.umich.edu                fault = new UndefinedInstruction(false, mnemonic);
8797853SMatt.Horsnell@ARM.com        } else {
8807853SMatt.Horsnell@ARM.com            for (unsigned i = 0; i < eCount; i++) {
8817853SMatt.Horsnell@ARM.com                Element srcElem1 = gtoh(srcReg1.elements[i]);
8827853SMatt.Horsnell@ARM.com                Element srcElem2 = gtoh(srcReg2.elements[imm]);
8837853SMatt.Horsnell@ARM.com                Element destElem;
8847853SMatt.Horsnell@ARM.com                %(readDest)s
8857853SMatt.Horsnell@ARM.com                %(op)s
8867853SMatt.Horsnell@ARM.com                destReg.elements[i] = htog(destElem);
8877853SMatt.Horsnell@ARM.com            }
8887639Sgblack@eecs.umich.edu        }
8897639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
8907639Sgblack@eecs.umich.edu        for reg in range(rCount):
8917639Sgblack@eecs.umich.edu            eWalkCode += '''
8928588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
8937639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
8947639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
8957639Sgblack@eecs.umich.edu                            "RegRegRegImmOp",
8967639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
8977639Sgblack@eecs.umich.edu                              "r_count": rCount,
8987760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
8997760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
9007639Sgblack@eecs.umich.edu        header_output += NeonRegRegRegImmOpDeclare.subst(iop)
9017639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
9027639Sgblack@eecs.umich.edu        for type in types:
9037639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
9047639Sgblack@eecs.umich.edu                          "class_name" : Name }
9057639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
9067639Sgblack@eecs.umich.edu
9077760SGiacomo.Gabrielli@arm.com    def twoRegLongInst(name, Name, opClass, types, op, readDest=False):
9087639Sgblack@eecs.umich.edu        global header_output, exec_output
9097639Sgblack@eecs.umich.edu        rCount = 2
9107640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
9117639Sgblack@eecs.umich.edu        RegVect srcReg1, srcReg2;
9127639Sgblack@eecs.umich.edu        BigRegVect destReg;
9137639Sgblack@eecs.umich.edu        '''
9147639Sgblack@eecs.umich.edu        for reg in range(rCount):
9157639Sgblack@eecs.umich.edu            eWalkCode += '''
9168588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
9178588Sgblack@eecs.umich.edu                srcReg2.regs[%(reg)d] = htog(FpOp2P%(reg)d_uw);;
9187639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
9197639Sgblack@eecs.umich.edu        if readDest:
9207639Sgblack@eecs.umich.edu            for reg in range(2 * rCount):
9217639Sgblack@eecs.umich.edu                eWalkCode += '''
9228588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
9237639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
9247639Sgblack@eecs.umich.edu        readDestCode = ''
9257639Sgblack@eecs.umich.edu        if readDest:
9267639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
9277639Sgblack@eecs.umich.edu        eWalkCode += '''
9287853SMatt.Horsnell@ARM.com        if (imm < 0 && imm >= eCount) {
9298782Sgblack@eecs.umich.edu            if (FullSystem)
9308782Sgblack@eecs.umich.edu                fault = new UndefinedInstruction;
9318782Sgblack@eecs.umich.edu            else
9328782Sgblack@eecs.umich.edu                fault = new UndefinedInstruction(false, mnemonic);
9337853SMatt.Horsnell@ARM.com        } else {
9347853SMatt.Horsnell@ARM.com            for (unsigned i = 0; i < eCount; i++) {
9357853SMatt.Horsnell@ARM.com                Element srcElem1 = gtoh(srcReg1.elements[i]);
9367853SMatt.Horsnell@ARM.com                Element srcElem2 = gtoh(srcReg2.elements[imm]);
9377853SMatt.Horsnell@ARM.com                BigElement destElem;
9387853SMatt.Horsnell@ARM.com                %(readDest)s
9397853SMatt.Horsnell@ARM.com                %(op)s
9407853SMatt.Horsnell@ARM.com                destReg.elements[i] = htog(destElem);
9417853SMatt.Horsnell@ARM.com            }
9427639Sgblack@eecs.umich.edu        }
9437639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
9447639Sgblack@eecs.umich.edu        for reg in range(2 * rCount):
9457639Sgblack@eecs.umich.edu            eWalkCode += '''
9468588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
9477639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
9487639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
9497639Sgblack@eecs.umich.edu                            "RegRegRegImmOp",
9507639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
9517639Sgblack@eecs.umich.edu                              "r_count": rCount,
9527760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
9537760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
9547639Sgblack@eecs.umich.edu        header_output += NeonRegRegRegImmOpDeclare.subst(iop)
9557639Sgblack@eecs.umich.edu        exec_output += NeonUnequalRegExecute.subst(iop)
9567639Sgblack@eecs.umich.edu        for type in types:
9577639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
9587639Sgblack@eecs.umich.edu                          "class_name" : Name }
9597639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
9607639Sgblack@eecs.umich.edu
9617760SGiacomo.Gabrielli@arm.com    def twoEqualRegInstFp(name, Name, opClass, types, rCount, op, readDest=False):
9627639Sgblack@eecs.umich.edu        global header_output, exec_output
9637640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
9647639Sgblack@eecs.umich.edu        typedef FloatReg FloatVect[rCount];
9657639Sgblack@eecs.umich.edu        FloatVect srcRegs1, srcRegs2, destRegs;
9667639Sgblack@eecs.umich.edu        '''
9677639Sgblack@eecs.umich.edu        for reg in range(rCount):
9687639Sgblack@eecs.umich.edu            eWalkCode += '''
9697639Sgblack@eecs.umich.edu                srcRegs1[%(reg)d] = FpOp1P%(reg)d;
9707639Sgblack@eecs.umich.edu                srcRegs2[%(reg)d] = FpOp2P%(reg)d;
9717639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
9727639Sgblack@eecs.umich.edu            if readDest:
9737639Sgblack@eecs.umich.edu                eWalkCode += '''
9747639Sgblack@eecs.umich.edu                    destRegs[%(reg)d] = FpDestP%(reg)d;
9757639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
9767639Sgblack@eecs.umich.edu        readDestCode = ''
9777639Sgblack@eecs.umich.edu        if readDest:
9787639Sgblack@eecs.umich.edu            readDestCode = 'destReg = destRegs[i];'
9797639Sgblack@eecs.umich.edu        eWalkCode += '''
9807853SMatt.Horsnell@ARM.com        if (imm < 0 && imm >= eCount) {
9818782Sgblack@eecs.umich.edu            if (FullSystem)
9828782Sgblack@eecs.umich.edu                fault = new UndefinedInstruction;
9838782Sgblack@eecs.umich.edu            else
9848782Sgblack@eecs.umich.edu                fault = new UndefinedInstruction(false, mnemonic);
9857853SMatt.Horsnell@ARM.com        } else {
9867853SMatt.Horsnell@ARM.com            for (unsigned i = 0; i < rCount; i++) {
9877853SMatt.Horsnell@ARM.com                FloatReg srcReg1 = srcRegs1[i];
9887853SMatt.Horsnell@ARM.com                FloatReg srcReg2 = srcRegs2[imm];
9897853SMatt.Horsnell@ARM.com                FloatReg destReg;
9907853SMatt.Horsnell@ARM.com                %(readDest)s
9917853SMatt.Horsnell@ARM.com                %(op)s
9927853SMatt.Horsnell@ARM.com                destRegs[i] = destReg;
9937853SMatt.Horsnell@ARM.com            }
9947639Sgblack@eecs.umich.edu        }
9957639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
9967639Sgblack@eecs.umich.edu        for reg in range(rCount):
9977639Sgblack@eecs.umich.edu            eWalkCode += '''
9987639Sgblack@eecs.umich.edu            FpDestP%(reg)d = destRegs[%(reg)d];
9997639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
10007639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
10017639Sgblack@eecs.umich.edu                            "FpRegRegRegImmOp",
10027639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
10037639Sgblack@eecs.umich.edu                              "r_count": rCount,
10047760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
10057760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
10067639Sgblack@eecs.umich.edu        header_output += NeonRegRegRegImmOpDeclare.subst(iop)
10077639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
10087639Sgblack@eecs.umich.edu        for type in types:
10097639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
10107639Sgblack@eecs.umich.edu                          "class_name" : Name }
10117639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
10127639Sgblack@eecs.umich.edu
10137760SGiacomo.Gabrielli@arm.com    def twoRegShiftInst(name, Name, opClass, types, rCount, op,
10147639Sgblack@eecs.umich.edu            readDest=False, toInt=False, fromInt=False):
10157639Sgblack@eecs.umich.edu        global header_output, exec_output
10167640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
10177639Sgblack@eecs.umich.edu        RegVect srcRegs1, destRegs;
10187639Sgblack@eecs.umich.edu        '''
10197639Sgblack@eecs.umich.edu        for reg in range(rCount):
10207639Sgblack@eecs.umich.edu            eWalkCode += '''
10218588Sgblack@eecs.umich.edu                srcRegs1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
10227639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
10237639Sgblack@eecs.umich.edu            if readDest:
10247639Sgblack@eecs.umich.edu                eWalkCode += '''
10258588Sgblack@eecs.umich.edu                    destRegs.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
10267639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
10277639Sgblack@eecs.umich.edu        readDestCode = ''
10287639Sgblack@eecs.umich.edu        if readDest:
10297639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destRegs.elements[i]);'
10307639Sgblack@eecs.umich.edu            if toInt:
10317639Sgblack@eecs.umich.edu                readDestCode = 'destReg = gtoh(destRegs.regs[i]);'
10327639Sgblack@eecs.umich.edu        readOpCode = 'Element srcElem1 = gtoh(srcRegs1.elements[i]);'
10337639Sgblack@eecs.umich.edu        if fromInt:
10347639Sgblack@eecs.umich.edu            readOpCode = 'FloatRegBits srcReg1 = gtoh(srcRegs1.regs[i]);'
10357639Sgblack@eecs.umich.edu        declDest = 'Element destElem;'
10367639Sgblack@eecs.umich.edu        writeDestCode = 'destRegs.elements[i] = htog(destElem);'
10377639Sgblack@eecs.umich.edu        if toInt:
10387639Sgblack@eecs.umich.edu            declDest = 'FloatRegBits destReg;'
10397639Sgblack@eecs.umich.edu            writeDestCode = 'destRegs.regs[i] = htog(destReg);'
10407639Sgblack@eecs.umich.edu        eWalkCode += '''
10417639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
10427639Sgblack@eecs.umich.edu            %(readOp)s
10437639Sgblack@eecs.umich.edu            %(declDest)s
10447639Sgblack@eecs.umich.edu            %(readDest)s
10457639Sgblack@eecs.umich.edu            %(op)s
10467639Sgblack@eecs.umich.edu            %(writeDest)s
10477639Sgblack@eecs.umich.edu        }
10487639Sgblack@eecs.umich.edu        ''' % { "readOp" : readOpCode,
10497639Sgblack@eecs.umich.edu                "declDest" : declDest,
10507639Sgblack@eecs.umich.edu                "readDest" : readDestCode,
10517639Sgblack@eecs.umich.edu                "op" : op,
10527639Sgblack@eecs.umich.edu                "writeDest" : writeDestCode }
10537639Sgblack@eecs.umich.edu        for reg in range(rCount):
10547639Sgblack@eecs.umich.edu            eWalkCode += '''
10558588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destRegs.regs[%(reg)d]);
10567639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
10577639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
10587639Sgblack@eecs.umich.edu                            "RegRegImmOp",
10597639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
10607639Sgblack@eecs.umich.edu                              "r_count": rCount,
10617760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
10627760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
10637639Sgblack@eecs.umich.edu        header_output += NeonRegRegImmOpDeclare.subst(iop)
10647639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
10657639Sgblack@eecs.umich.edu        for type in types:
10667639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
10677639Sgblack@eecs.umich.edu                          "class_name" : Name }
10687639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
10697639Sgblack@eecs.umich.edu
10707760SGiacomo.Gabrielli@arm.com    def twoRegNarrowShiftInst(name, Name, opClass, types, op, readDest=False):
10717639Sgblack@eecs.umich.edu        global header_output, exec_output
10727640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
10737639Sgblack@eecs.umich.edu        BigRegVect srcReg1;
10747639Sgblack@eecs.umich.edu        RegVect destReg;
10757639Sgblack@eecs.umich.edu        '''
10767639Sgblack@eecs.umich.edu        for reg in range(4):
10777639Sgblack@eecs.umich.edu            eWalkCode += '''
10788588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
10797639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
10807639Sgblack@eecs.umich.edu        if readDest:
10817639Sgblack@eecs.umich.edu            for reg in range(2):
10827639Sgblack@eecs.umich.edu                eWalkCode += '''
10838588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
10847639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
10857639Sgblack@eecs.umich.edu        readDestCode = ''
10867639Sgblack@eecs.umich.edu        if readDest:
10877639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
10887639Sgblack@eecs.umich.edu        eWalkCode += '''
10897639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
10907639Sgblack@eecs.umich.edu            BigElement srcElem1 = gtoh(srcReg1.elements[i]);
10917639Sgblack@eecs.umich.edu            Element destElem;
10927639Sgblack@eecs.umich.edu            %(readDest)s
10937639Sgblack@eecs.umich.edu            %(op)s
10947639Sgblack@eecs.umich.edu            destReg.elements[i] = htog(destElem);
10957639Sgblack@eecs.umich.edu        }
10967639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
10977639Sgblack@eecs.umich.edu        for reg in range(2):
10987639Sgblack@eecs.umich.edu            eWalkCode += '''
10998588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
11007639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
11017639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
11027639Sgblack@eecs.umich.edu                            "RegRegImmOp",
11037639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
11047639Sgblack@eecs.umich.edu                              "r_count": 2,
11057760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
11067760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
11077639Sgblack@eecs.umich.edu        header_output += NeonRegRegImmOpDeclare.subst(iop)
11087639Sgblack@eecs.umich.edu        exec_output += NeonUnequalRegExecute.subst(iop)
11097639Sgblack@eecs.umich.edu        for type in types:
11107639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
11117639Sgblack@eecs.umich.edu                          "class_name" : Name }
11127639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
11137639Sgblack@eecs.umich.edu
11147760SGiacomo.Gabrielli@arm.com    def twoRegLongShiftInst(name, Name, opClass, types, op, readDest=False):
11157639Sgblack@eecs.umich.edu        global header_output, exec_output
11167640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
11177639Sgblack@eecs.umich.edu        RegVect srcReg1;
11187639Sgblack@eecs.umich.edu        BigRegVect destReg;
11197639Sgblack@eecs.umich.edu        '''
11207639Sgblack@eecs.umich.edu        for reg in range(2):
11217639Sgblack@eecs.umich.edu            eWalkCode += '''
11228588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
11237639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
11247639Sgblack@eecs.umich.edu        if readDest:
11257639Sgblack@eecs.umich.edu            for reg in range(4):
11267639Sgblack@eecs.umich.edu                eWalkCode += '''
11278588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
11287639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
11297639Sgblack@eecs.umich.edu        readDestCode = ''
11307639Sgblack@eecs.umich.edu        if readDest:
11317639Sgblack@eecs.umich.edu            readDestCode = 'destReg = gtoh(destReg.elements[i]);'
11327639Sgblack@eecs.umich.edu        eWalkCode += '''
11337639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
11347639Sgblack@eecs.umich.edu            Element srcElem1 = gtoh(srcReg1.elements[i]);
11357639Sgblack@eecs.umich.edu            BigElement destElem;
11367639Sgblack@eecs.umich.edu            %(readDest)s
11377639Sgblack@eecs.umich.edu            %(op)s
11387639Sgblack@eecs.umich.edu            destReg.elements[i] = htog(destElem);
11397639Sgblack@eecs.umich.edu        }
11407639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
11417639Sgblack@eecs.umich.edu        for reg in range(4):
11427639Sgblack@eecs.umich.edu            eWalkCode += '''
11438588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
11447639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
11457639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
11467639Sgblack@eecs.umich.edu                            "RegRegImmOp",
11477639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
11487639Sgblack@eecs.umich.edu                              "r_count": 2,
11497760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
11507760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
11517639Sgblack@eecs.umich.edu        header_output += NeonRegRegImmOpDeclare.subst(iop)
11527639Sgblack@eecs.umich.edu        exec_output += NeonUnequalRegExecute.subst(iop)
11537639Sgblack@eecs.umich.edu        for type in types:
11547639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
11557639Sgblack@eecs.umich.edu                          "class_name" : Name }
11567639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
11577639Sgblack@eecs.umich.edu
11587760SGiacomo.Gabrielli@arm.com    def twoRegMiscInst(name, Name, opClass, types, rCount, op, readDest=False):
11597639Sgblack@eecs.umich.edu        global header_output, exec_output
11607640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
11617639Sgblack@eecs.umich.edu        RegVect srcReg1, destReg;
11627639Sgblack@eecs.umich.edu        '''
11637639Sgblack@eecs.umich.edu        for reg in range(rCount):
11647639Sgblack@eecs.umich.edu            eWalkCode += '''
11658588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
11667639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
11677639Sgblack@eecs.umich.edu            if readDest:
11687639Sgblack@eecs.umich.edu                eWalkCode += '''
11698588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
11707639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
11717639Sgblack@eecs.umich.edu        readDestCode = ''
11727639Sgblack@eecs.umich.edu        if readDest:
11737639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
11747639Sgblack@eecs.umich.edu        eWalkCode += '''
11757639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
11767639Sgblack@eecs.umich.edu            unsigned j = i;
11777639Sgblack@eecs.umich.edu            Element srcElem1 = gtoh(srcReg1.elements[i]);
11787639Sgblack@eecs.umich.edu            Element destElem;
11797639Sgblack@eecs.umich.edu            %(readDest)s
11807639Sgblack@eecs.umich.edu            %(op)s
11817639Sgblack@eecs.umich.edu            destReg.elements[j] = htog(destElem);
11827639Sgblack@eecs.umich.edu        }
11837639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
11847639Sgblack@eecs.umich.edu        for reg in range(rCount):
11857639Sgblack@eecs.umich.edu            eWalkCode += '''
11868588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
11877639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
11887639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
11897639Sgblack@eecs.umich.edu                            "RegRegOp",
11907639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
11917639Sgblack@eecs.umich.edu                              "r_count": rCount,
11927760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
11937760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
11947639Sgblack@eecs.umich.edu        header_output += NeonRegRegOpDeclare.subst(iop)
11957639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
11967639Sgblack@eecs.umich.edu        for type in types:
11977639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
11987639Sgblack@eecs.umich.edu                          "class_name" : Name }
11997639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
12007639Sgblack@eecs.umich.edu
12017760SGiacomo.Gabrielli@arm.com    def twoRegMiscScInst(name, Name, opClass, types, rCount, op, readDest=False):
12027639Sgblack@eecs.umich.edu        global header_output, exec_output
12037640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
12047639Sgblack@eecs.umich.edu        RegVect srcReg1, destReg;
12057639Sgblack@eecs.umich.edu        '''
12067639Sgblack@eecs.umich.edu        for reg in range(rCount):
12077639Sgblack@eecs.umich.edu            eWalkCode += '''
12088588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
12097639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
12107639Sgblack@eecs.umich.edu            if readDest:
12117639Sgblack@eecs.umich.edu                eWalkCode += '''
12128588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
12137639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
12147639Sgblack@eecs.umich.edu        readDestCode = ''
12157639Sgblack@eecs.umich.edu        if readDest:
12167639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
12177639Sgblack@eecs.umich.edu        eWalkCode += '''
12187639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
12197639Sgblack@eecs.umich.edu            Element srcElem1 = gtoh(srcReg1.elements[imm]);
12207639Sgblack@eecs.umich.edu            Element destElem;
12217639Sgblack@eecs.umich.edu            %(readDest)s
12227639Sgblack@eecs.umich.edu            %(op)s
12237639Sgblack@eecs.umich.edu            destReg.elements[i] = htog(destElem);
12247639Sgblack@eecs.umich.edu        }
12257639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
12267639Sgblack@eecs.umich.edu        for reg in range(rCount):
12277639Sgblack@eecs.umich.edu            eWalkCode += '''
12288588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
12297639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
12307639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
12317639Sgblack@eecs.umich.edu                            "RegRegImmOp",
12327639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
12337639Sgblack@eecs.umich.edu                              "r_count": rCount,
12347760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
12357760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
12367639Sgblack@eecs.umich.edu        header_output += NeonRegRegImmOpDeclare.subst(iop)
12377639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
12387639Sgblack@eecs.umich.edu        for type in types:
12397639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
12407639Sgblack@eecs.umich.edu                          "class_name" : Name }
12417639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
12427639Sgblack@eecs.umich.edu
12437760SGiacomo.Gabrielli@arm.com    def twoRegMiscScramble(name, Name, opClass, types, rCount, op, readDest=False):
12447639Sgblack@eecs.umich.edu        global header_output, exec_output
12457640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
12467639Sgblack@eecs.umich.edu        RegVect srcReg1, destReg;
12477639Sgblack@eecs.umich.edu        '''
12487639Sgblack@eecs.umich.edu        for reg in range(rCount):
12497639Sgblack@eecs.umich.edu            eWalkCode += '''
12508588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
12518588Sgblack@eecs.umich.edu                destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
12527639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
12537639Sgblack@eecs.umich.edu            if readDest:
12547639Sgblack@eecs.umich.edu                eWalkCode += '''
12557639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
12567639Sgblack@eecs.umich.edu        readDestCode = ''
12577639Sgblack@eecs.umich.edu        if readDest:
12587639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
12597639Sgblack@eecs.umich.edu        eWalkCode += op
12607639Sgblack@eecs.umich.edu        for reg in range(rCount):
12617639Sgblack@eecs.umich.edu            eWalkCode += '''
12628588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
12638588Sgblack@eecs.umich.edu            FpOp1P%(reg)d_uw = gtoh(srcReg1.regs[%(reg)d]);
12647639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
12657639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
12667639Sgblack@eecs.umich.edu                            "RegRegOp",
12677639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
12687639Sgblack@eecs.umich.edu                              "r_count": rCount,
12697760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
12707760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
12717639Sgblack@eecs.umich.edu        header_output += NeonRegRegOpDeclare.subst(iop)
12727639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
12737639Sgblack@eecs.umich.edu        for type in types:
12747639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
12757639Sgblack@eecs.umich.edu                          "class_name" : Name }
12767639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
12777639Sgblack@eecs.umich.edu
12787760SGiacomo.Gabrielli@arm.com    def twoRegMiscInstFp(name, Name, opClass, types, rCount, op,
12797639Sgblack@eecs.umich.edu            readDest=False, toInt=False):
12807639Sgblack@eecs.umich.edu        global header_output, exec_output
12817640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
12827639Sgblack@eecs.umich.edu        typedef FloatReg FloatVect[rCount];
12837639Sgblack@eecs.umich.edu        FloatVect srcRegs1;
12847639Sgblack@eecs.umich.edu        '''
12857639Sgblack@eecs.umich.edu        if toInt:
12867639Sgblack@eecs.umich.edu            eWalkCode += 'RegVect destRegs;\n'
12877639Sgblack@eecs.umich.edu        else:
12887639Sgblack@eecs.umich.edu            eWalkCode += 'FloatVect destRegs;\n'
12897639Sgblack@eecs.umich.edu        for reg in range(rCount):
12907639Sgblack@eecs.umich.edu            eWalkCode += '''
12917639Sgblack@eecs.umich.edu                srcRegs1[%(reg)d] = FpOp1P%(reg)d;
12927639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
12937639Sgblack@eecs.umich.edu            if readDest:
12947639Sgblack@eecs.umich.edu                if toInt:
12957639Sgblack@eecs.umich.edu                    eWalkCode += '''
12967639Sgblack@eecs.umich.edu                        destRegs.regs[%(reg)d] = FpDestP%(reg)d.bits;
12977639Sgblack@eecs.umich.edu                    ''' % { "reg" : reg }
12987639Sgblack@eecs.umich.edu                else:
12997639Sgblack@eecs.umich.edu                    eWalkCode += '''
13007639Sgblack@eecs.umich.edu                        destRegs[%(reg)d] = FpDestP%(reg)d;
13017639Sgblack@eecs.umich.edu                    ''' % { "reg" : reg }
13027639Sgblack@eecs.umich.edu        readDestCode = ''
13037639Sgblack@eecs.umich.edu        if readDest:
13047639Sgblack@eecs.umich.edu            readDestCode = 'destReg = destRegs[i];'
13057639Sgblack@eecs.umich.edu        destType = 'FloatReg'
13067639Sgblack@eecs.umich.edu        writeDest = 'destRegs[r] = destReg;'
13077639Sgblack@eecs.umich.edu        if toInt:
13087639Sgblack@eecs.umich.edu            destType = 'FloatRegBits'
13097639Sgblack@eecs.umich.edu            writeDest = 'destRegs.regs[r] = destReg;'
13107639Sgblack@eecs.umich.edu        eWalkCode += '''
13117639Sgblack@eecs.umich.edu        for (unsigned r = 0; r < rCount; r++) {
13127639Sgblack@eecs.umich.edu            FloatReg srcReg1 = srcRegs1[r];
13137639Sgblack@eecs.umich.edu            %(destType)s destReg;
13147639Sgblack@eecs.umich.edu            %(readDest)s
13157639Sgblack@eecs.umich.edu            %(op)s
13167639Sgblack@eecs.umich.edu            %(writeDest)s
13177639Sgblack@eecs.umich.edu        }
13187639Sgblack@eecs.umich.edu        ''' % { "op" : op,
13197639Sgblack@eecs.umich.edu                "readDest" : readDestCode,
13207639Sgblack@eecs.umich.edu                "destType" : destType,
13217639Sgblack@eecs.umich.edu                "writeDest" : writeDest }
13227639Sgblack@eecs.umich.edu        for reg in range(rCount):
13237639Sgblack@eecs.umich.edu            if toInt:
13247639Sgblack@eecs.umich.edu                eWalkCode += '''
13258588Sgblack@eecs.umich.edu                FpDestP%(reg)d_uw = destRegs.regs[%(reg)d];
13267639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
13277639Sgblack@eecs.umich.edu            else:
13287639Sgblack@eecs.umich.edu                eWalkCode += '''
13297639Sgblack@eecs.umich.edu                FpDestP%(reg)d = destRegs[%(reg)d];
13307639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
13317639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
13327639Sgblack@eecs.umich.edu                            "FpRegRegOp",
13337639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
13347639Sgblack@eecs.umich.edu                              "r_count": rCount,
13357760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
13367760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
13377639Sgblack@eecs.umich.edu        header_output += NeonRegRegOpDeclare.subst(iop)
13387639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
13397639Sgblack@eecs.umich.edu        for type in types:
13407639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
13417639Sgblack@eecs.umich.edu                          "class_name" : Name }
13427639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
13437639Sgblack@eecs.umich.edu
13447760SGiacomo.Gabrielli@arm.com    def twoRegCondenseInst(name, Name, opClass, types, rCount, op, readDest=False):
13457639Sgblack@eecs.umich.edu        global header_output, exec_output
13467640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
13477639Sgblack@eecs.umich.edu        RegVect srcRegs;
13487639Sgblack@eecs.umich.edu        BigRegVect destReg;
13497639Sgblack@eecs.umich.edu        '''
13507639Sgblack@eecs.umich.edu        for reg in range(rCount):
13517639Sgblack@eecs.umich.edu            eWalkCode += '''
13528588Sgblack@eecs.umich.edu                srcRegs.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
13537639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
13547639Sgblack@eecs.umich.edu            if readDest:
13557639Sgblack@eecs.umich.edu                eWalkCode += '''
13568588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
13577639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
13587639Sgblack@eecs.umich.edu        readDestCode = ''
13597639Sgblack@eecs.umich.edu        if readDest:
13607639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
13617639Sgblack@eecs.umich.edu        eWalkCode += '''
13627639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount / 2; i++) {
13637639Sgblack@eecs.umich.edu            Element srcElem1 = gtoh(srcRegs.elements[2 * i]);
13647639Sgblack@eecs.umich.edu            Element srcElem2 = gtoh(srcRegs.elements[2 * i + 1]);
13657639Sgblack@eecs.umich.edu            BigElement destElem;
13667639Sgblack@eecs.umich.edu            %(readDest)s
13677639Sgblack@eecs.umich.edu            %(op)s
13687639Sgblack@eecs.umich.edu            destReg.elements[i] = htog(destElem);
13697639Sgblack@eecs.umich.edu        }
13707639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
13717639Sgblack@eecs.umich.edu        for reg in range(rCount):
13727639Sgblack@eecs.umich.edu            eWalkCode += '''
13738588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
13747639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
13757639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
13767639Sgblack@eecs.umich.edu                            "RegRegOp",
13777639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
13787639Sgblack@eecs.umich.edu                              "r_count": rCount,
13797760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
13807760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
13817639Sgblack@eecs.umich.edu        header_output += NeonRegRegOpDeclare.subst(iop)
13827639Sgblack@eecs.umich.edu        exec_output += NeonUnequalRegExecute.subst(iop)
13837639Sgblack@eecs.umich.edu        for type in types:
13847639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
13857639Sgblack@eecs.umich.edu                          "class_name" : Name }
13867639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
13877639Sgblack@eecs.umich.edu
13887760SGiacomo.Gabrielli@arm.com    def twoRegNarrowMiscInst(name, Name, opClass, types, op, readDest=False):
13897639Sgblack@eecs.umich.edu        global header_output, exec_output
13907640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
13917639Sgblack@eecs.umich.edu        BigRegVect srcReg1;
13927639Sgblack@eecs.umich.edu        RegVect destReg;
13937639Sgblack@eecs.umich.edu        '''
13947639Sgblack@eecs.umich.edu        for reg in range(4):
13957639Sgblack@eecs.umich.edu            eWalkCode += '''
13968588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
13977639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
13987639Sgblack@eecs.umich.edu        if readDest:
13997639Sgblack@eecs.umich.edu            for reg in range(2):
14007639Sgblack@eecs.umich.edu                eWalkCode += '''
14018588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
14027639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
14037639Sgblack@eecs.umich.edu        readDestCode = ''
14047639Sgblack@eecs.umich.edu        if readDest:
14057639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
14067639Sgblack@eecs.umich.edu        eWalkCode += '''
14077639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
14087639Sgblack@eecs.umich.edu            BigElement srcElem1 = gtoh(srcReg1.elements[i]);
14097639Sgblack@eecs.umich.edu            Element destElem;
14107639Sgblack@eecs.umich.edu            %(readDest)s
14117639Sgblack@eecs.umich.edu            %(op)s
14127639Sgblack@eecs.umich.edu            destReg.elements[i] = htog(destElem);
14137639Sgblack@eecs.umich.edu        }
14147639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
14157639Sgblack@eecs.umich.edu        for reg in range(2):
14167639Sgblack@eecs.umich.edu            eWalkCode += '''
14178588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
14187639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
14197639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
14207639Sgblack@eecs.umich.edu                            "RegRegOp",
14217639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
14227639Sgblack@eecs.umich.edu                              "r_count": 2,
14237760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
14247760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
14257639Sgblack@eecs.umich.edu        header_output += NeonRegRegOpDeclare.subst(iop)
14267639Sgblack@eecs.umich.edu        exec_output += NeonUnequalRegExecute.subst(iop)
14277639Sgblack@eecs.umich.edu        for type in types:
14287639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
14297639Sgblack@eecs.umich.edu                          "class_name" : Name }
14307639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
14317639Sgblack@eecs.umich.edu
14327760SGiacomo.Gabrielli@arm.com    def oneRegImmInst(name, Name, opClass, types, rCount, op, readDest=False):
14337639Sgblack@eecs.umich.edu        global header_output, exec_output
14347640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
14357639Sgblack@eecs.umich.edu        RegVect destReg;
14367639Sgblack@eecs.umich.edu        '''
14377639Sgblack@eecs.umich.edu        if readDest:
14387639Sgblack@eecs.umich.edu            for reg in range(rCount):
14397639Sgblack@eecs.umich.edu                eWalkCode += '''
14408588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
14417639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
14427639Sgblack@eecs.umich.edu        readDestCode = ''
14437639Sgblack@eecs.umich.edu        if readDest:
14447639Sgblack@eecs.umich.edu            readDestCode = 'destElem = gtoh(destReg.elements[i]);'
14457639Sgblack@eecs.umich.edu        eWalkCode += '''
14467639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
14477639Sgblack@eecs.umich.edu            Element destElem;
14487639Sgblack@eecs.umich.edu            %(readDest)s
14497639Sgblack@eecs.umich.edu            %(op)s
14507639Sgblack@eecs.umich.edu            destReg.elements[i] = htog(destElem);
14517639Sgblack@eecs.umich.edu        }
14527639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
14537639Sgblack@eecs.umich.edu        for reg in range(rCount):
14547639Sgblack@eecs.umich.edu            eWalkCode += '''
14558588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
14567639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
14577639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
14587639Sgblack@eecs.umich.edu                            "RegImmOp",
14597639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
14607639Sgblack@eecs.umich.edu                              "r_count": rCount,
14617760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
14627760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
14637639Sgblack@eecs.umich.edu        header_output += NeonRegImmOpDeclare.subst(iop)
14647639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
14657639Sgblack@eecs.umich.edu        for type in types:
14667639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
14677639Sgblack@eecs.umich.edu                          "class_name" : Name }
14687639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
14697639Sgblack@eecs.umich.edu
14707760SGiacomo.Gabrielli@arm.com    def twoRegLongMiscInst(name, Name, opClass, types, op, readDest=False):
14717639Sgblack@eecs.umich.edu        global header_output, exec_output
14727640Sgblack@eecs.umich.edu        eWalkCode = simdEnabledCheckCode + '''
14737639Sgblack@eecs.umich.edu        RegVect srcReg1;
14747639Sgblack@eecs.umich.edu        BigRegVect destReg;
14757639Sgblack@eecs.umich.edu        '''
14767639Sgblack@eecs.umich.edu        for reg in range(2):
14777639Sgblack@eecs.umich.edu            eWalkCode += '''
14788588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
14797639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
14807639Sgblack@eecs.umich.edu        if readDest:
14817639Sgblack@eecs.umich.edu            for reg in range(4):
14827639Sgblack@eecs.umich.edu                eWalkCode += '''
14838588Sgblack@eecs.umich.edu                    destReg.regs[%(reg)d] = htog(FpDestP%(reg)d_uw);
14847639Sgblack@eecs.umich.edu                ''' % { "reg" : reg }
14857639Sgblack@eecs.umich.edu        readDestCode = ''
14867639Sgblack@eecs.umich.edu        if readDest:
14877639Sgblack@eecs.umich.edu            readDestCode = 'destReg = gtoh(destReg.elements[i]);'
14887639Sgblack@eecs.umich.edu        eWalkCode += '''
14897639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
14907639Sgblack@eecs.umich.edu            Element srcElem1 = gtoh(srcReg1.elements[i]);
14917639Sgblack@eecs.umich.edu            BigElement destElem;
14927639Sgblack@eecs.umich.edu            %(readDest)s
14937639Sgblack@eecs.umich.edu            %(op)s
14947639Sgblack@eecs.umich.edu            destReg.elements[i] = htog(destElem);
14957639Sgblack@eecs.umich.edu        }
14967639Sgblack@eecs.umich.edu        ''' % { "op" : op, "readDest" : readDestCode }
14977639Sgblack@eecs.umich.edu        for reg in range(4):
14987639Sgblack@eecs.umich.edu            eWalkCode += '''
14998588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
15007639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
15017639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
15027639Sgblack@eecs.umich.edu                            "RegRegOp",
15037639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
15047639Sgblack@eecs.umich.edu                              "r_count": 2,
15057760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
15067760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
15077639Sgblack@eecs.umich.edu        header_output += NeonRegRegOpDeclare.subst(iop)
15087639Sgblack@eecs.umich.edu        exec_output += NeonUnequalRegExecute.subst(iop)
15097639Sgblack@eecs.umich.edu        for type in types:
15107639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
15117639Sgblack@eecs.umich.edu                          "class_name" : Name }
15127639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
15137639Sgblack@eecs.umich.edu
15147639Sgblack@eecs.umich.edu    vhaddCode = '''
15157639Sgblack@eecs.umich.edu        Element carryBit =
15167639Sgblack@eecs.umich.edu            (((unsigned)srcElem1 & 0x1) +
15177639Sgblack@eecs.umich.edu             ((unsigned)srcElem2 & 0x1)) >> 1;
15187639Sgblack@eecs.umich.edu        // Use division instead of a shift to ensure the sign extension works
15197639Sgblack@eecs.umich.edu        // right. The compiler will figure out if it can be a shift. Mask the
15207639Sgblack@eecs.umich.edu        // inputs so they get truncated correctly.
15217639Sgblack@eecs.umich.edu        destElem = (((srcElem1 & ~(Element)1) / 2) +
15227639Sgblack@eecs.umich.edu                    ((srcElem2 & ~(Element)1) / 2)) + carryBit;
15237639Sgblack@eecs.umich.edu    '''
15247760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vhadd", "VhaddD", "SimdAddOp", allTypes, 2, vhaddCode)
15257760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vhadd", "VhaddQ", "SimdAddOp", allTypes, 4, vhaddCode)
15267639Sgblack@eecs.umich.edu
15277639Sgblack@eecs.umich.edu    vrhaddCode = '''
15287639Sgblack@eecs.umich.edu        Element carryBit =
15297639Sgblack@eecs.umich.edu            (((unsigned)srcElem1 & 0x1) +
15307639Sgblack@eecs.umich.edu             ((unsigned)srcElem2 & 0x1) + 1) >> 1;
15317639Sgblack@eecs.umich.edu        // Use division instead of a shift to ensure the sign extension works
15327639Sgblack@eecs.umich.edu        // right. The compiler will figure out if it can be a shift. Mask the
15337639Sgblack@eecs.umich.edu        // inputs so they get truncated correctly.
15347639Sgblack@eecs.umich.edu        destElem = (((srcElem1 & ~(Element)1) / 2) +
15357639Sgblack@eecs.umich.edu                    ((srcElem2 & ~(Element)1) / 2)) + carryBit;
15367639Sgblack@eecs.umich.edu    '''
15377760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vrhadd", "VrhaddD", "SimdAddOp", allTypes, 2, vrhaddCode)
15387760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vrhadd", "VrhaddQ", "SimdAddOp", allTypes, 4, vrhaddCode)
15397639Sgblack@eecs.umich.edu
15407639Sgblack@eecs.umich.edu    vhsubCode = '''
15417639Sgblack@eecs.umich.edu        Element barrowBit =
15427639Sgblack@eecs.umich.edu            (((srcElem1 & 0x1) - (srcElem2 & 0x1)) >> 1) & 0x1;
15437639Sgblack@eecs.umich.edu        // Use division instead of a shift to ensure the sign extension works
15447639Sgblack@eecs.umich.edu        // right. The compiler will figure out if it can be a shift. Mask the
15457639Sgblack@eecs.umich.edu        // inputs so they get truncated correctly.
15467639Sgblack@eecs.umich.edu        destElem = (((srcElem1 & ~(Element)1) / 2) -
15477639Sgblack@eecs.umich.edu                    ((srcElem2 & ~(Element)1) / 2)) - barrowBit;
15487639Sgblack@eecs.umich.edu    '''
15497760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vhsub", "VhsubD", "SimdAddOp", allTypes, 2, vhsubCode)
15507760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vhsub", "VhsubQ", "SimdAddOp", allTypes, 4, vhsubCode)
15517639Sgblack@eecs.umich.edu
15527639Sgblack@eecs.umich.edu    vandCode = '''
15537639Sgblack@eecs.umich.edu        destElem = srcElem1 & srcElem2;
15547639Sgblack@eecs.umich.edu    '''
15557760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vand", "VandD", "SimdAluOp", unsignedTypes, 2, vandCode)
15567760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vand", "VandQ", "SimdAluOp", unsignedTypes, 4, vandCode)
15577639Sgblack@eecs.umich.edu
15587639Sgblack@eecs.umich.edu    vbicCode = '''
15597639Sgblack@eecs.umich.edu        destElem = srcElem1 & ~srcElem2;
15607639Sgblack@eecs.umich.edu    '''
15617760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vbic", "VbicD", "SimdAluOp", unsignedTypes, 2, vbicCode)
15627760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vbic", "VbicQ", "SimdAluOp", unsignedTypes, 4, vbicCode)
15637639Sgblack@eecs.umich.edu
15647639Sgblack@eecs.umich.edu    vorrCode = '''
15657639Sgblack@eecs.umich.edu        destElem = srcElem1 | srcElem2;
15667639Sgblack@eecs.umich.edu    '''
15677760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vorr", "VorrD", "SimdAluOp", unsignedTypes, 2, vorrCode)
15687760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vorr", "VorrQ", "SimdAluOp", unsignedTypes, 4, vorrCode)
15697639Sgblack@eecs.umich.edu
15707760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmov", "VmovD", "SimdMiscOp", unsignedTypes, 2, vorrCode)
15717760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmov", "VmovQ", "SimdMiscOp", unsignedTypes, 4, vorrCode)
15727639Sgblack@eecs.umich.edu
15737639Sgblack@eecs.umich.edu    vornCode = '''
15747639Sgblack@eecs.umich.edu        destElem = srcElem1 | ~srcElem2;
15757639Sgblack@eecs.umich.edu    '''
15767760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vorn", "VornD", "SimdAluOp", unsignedTypes, 2, vornCode)
15777760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vorn", "VornQ", "SimdAluOp", unsignedTypes, 4, vornCode)
15787639Sgblack@eecs.umich.edu
15797639Sgblack@eecs.umich.edu    veorCode = '''
15807639Sgblack@eecs.umich.edu        destElem = srcElem1 ^ srcElem2;
15817639Sgblack@eecs.umich.edu    '''
15827760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("veor", "VeorD", "SimdAluOp", unsignedTypes, 2, veorCode)
15837760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("veor", "VeorQ", "SimdAluOp", unsignedTypes, 4, veorCode)
15847639Sgblack@eecs.umich.edu
15857639Sgblack@eecs.umich.edu    vbifCode = '''
15867639Sgblack@eecs.umich.edu        destElem = (destElem & srcElem2) | (srcElem1 & ~srcElem2);
15877639Sgblack@eecs.umich.edu    '''
15887760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vbif", "VbifD", "SimdAluOp", unsignedTypes, 2, vbifCode, True)
15897760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vbif", "VbifQ", "SimdAluOp", unsignedTypes, 4, vbifCode, True)
15907639Sgblack@eecs.umich.edu    vbitCode = '''
15917639Sgblack@eecs.umich.edu        destElem = (srcElem1 & srcElem2) | (destElem & ~srcElem2);
15927639Sgblack@eecs.umich.edu    '''
15937760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vbit", "VbitD", "SimdAluOp", unsignedTypes, 2, vbitCode, True)
15947760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vbit", "VbitQ", "SimdAluOp", unsignedTypes, 4, vbitCode, True)
15957639Sgblack@eecs.umich.edu    vbslCode = '''
15967639Sgblack@eecs.umich.edu        destElem = (srcElem1 & destElem) | (srcElem2 & ~destElem);
15977639Sgblack@eecs.umich.edu    '''
15987760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vbsl", "VbslD", "SimdAluOp", unsignedTypes, 2, vbslCode, True)
15997760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vbsl", "VbslQ", "SimdAluOp", unsignedTypes, 4, vbslCode, True)
16007639Sgblack@eecs.umich.edu
16017639Sgblack@eecs.umich.edu    vmaxCode = '''
16027639Sgblack@eecs.umich.edu        destElem = (srcElem1 > srcElem2) ? srcElem1 : srcElem2;
16037639Sgblack@eecs.umich.edu    '''
16047760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmax", "VmaxD", "SimdCmpOp", allTypes, 2, vmaxCode)
16057760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmax", "VmaxQ", "SimdCmpOp", allTypes, 4, vmaxCode)
16067639Sgblack@eecs.umich.edu
16077639Sgblack@eecs.umich.edu    vminCode = '''
16087639Sgblack@eecs.umich.edu        destElem = (srcElem1 < srcElem2) ? srcElem1 : srcElem2;
16097639Sgblack@eecs.umich.edu    '''
16107760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmin", "VminD", "SimdCmpOp", allTypes, 2, vminCode)
16117760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmin", "VminQ", "SimdCmpOp", allTypes, 4, vminCode)
16127639Sgblack@eecs.umich.edu
16137639Sgblack@eecs.umich.edu    vaddCode = '''
16147639Sgblack@eecs.umich.edu        destElem = srcElem1 + srcElem2;
16157639Sgblack@eecs.umich.edu    '''
16167760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vadd", "NVaddD", "SimdAddOp", unsignedTypes, 2, vaddCode)
16177760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vadd", "NVaddQ", "SimdAddOp", unsignedTypes, 4, vaddCode)
16187639Sgblack@eecs.umich.edu
16198607Sgblack@eecs.umich.edu    threeEqualRegInst("vpadd", "NVpaddD", "SimdAddOp", smallUnsignedTypes,
16207639Sgblack@eecs.umich.edu                      2, vaddCode, pairwise=True)
16217639Sgblack@eecs.umich.edu    vaddlwCode = '''
16227639Sgblack@eecs.umich.edu        destElem = (BigElement)srcElem1 + (BigElement)srcElem2;
16237639Sgblack@eecs.umich.edu    '''
16247760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vaddl", "Vaddl", "SimdAddOp", smallTypes, vaddlwCode)
16257760SGiacomo.Gabrielli@arm.com    threeRegWideInst("vaddw", "Vaddw", "SimdAddOp", smallTypes, vaddlwCode)
16267639Sgblack@eecs.umich.edu    vaddhnCode = '''
16277639Sgblack@eecs.umich.edu        destElem = ((BigElement)srcElem1 + (BigElement)srcElem2) >>
16287639Sgblack@eecs.umich.edu                   (sizeof(Element) * 8);
16297639Sgblack@eecs.umich.edu    '''
16307760SGiacomo.Gabrielli@arm.com    threeRegNarrowInst("vaddhn", "Vaddhn", "SimdAddOp", smallTypes, vaddhnCode)
16317639Sgblack@eecs.umich.edu    vraddhnCode = '''
16327639Sgblack@eecs.umich.edu        destElem = ((BigElement)srcElem1 + (BigElement)srcElem2 +
16337639Sgblack@eecs.umich.edu                    ((BigElement)1 << (sizeof(Element) * 8 - 1))) >>
16347639Sgblack@eecs.umich.edu                   (sizeof(Element) * 8);
16357639Sgblack@eecs.umich.edu    '''
16367760SGiacomo.Gabrielli@arm.com    threeRegNarrowInst("vraddhn", "Vraddhn", "SimdAddOp", smallTypes, vraddhnCode)
16377639Sgblack@eecs.umich.edu
16387639Sgblack@eecs.umich.edu    vsubCode = '''
16397639Sgblack@eecs.umich.edu        destElem = srcElem1 - srcElem2;
16407639Sgblack@eecs.umich.edu    '''
16417760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vsub", "NVsubD", "SimdAddOp", unsignedTypes, 2, vsubCode)
16427760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vsub", "NVsubQ", "SimdAddOp", unsignedTypes, 4, vsubCode)
16437639Sgblack@eecs.umich.edu    vsublwCode = '''
16447639Sgblack@eecs.umich.edu        destElem = (BigElement)srcElem1 - (BigElement)srcElem2;
16457639Sgblack@eecs.umich.edu    '''
16467760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vsubl", "Vsubl", "SimdAddOp", smallTypes, vsublwCode)
16477760SGiacomo.Gabrielli@arm.com    threeRegWideInst("vsubw", "Vsubw", "SimdAddOp", smallTypes, vsublwCode)
16487639Sgblack@eecs.umich.edu
16497639Sgblack@eecs.umich.edu    vqaddUCode = '''
16507639Sgblack@eecs.umich.edu        destElem = srcElem1 + srcElem2;
16517783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
16527639Sgblack@eecs.umich.edu        if (destElem < srcElem1 || destElem < srcElem2) {
16537639Sgblack@eecs.umich.edu            destElem = (Element)(-1);
16547639Sgblack@eecs.umich.edu            fpscr.qc = 1;
16557639Sgblack@eecs.umich.edu        }
16567783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
16577639Sgblack@eecs.umich.edu    '''
16587760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqadd", "VqaddUD", "SimdAddOp", unsignedTypes, 2, vqaddUCode)
16597760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqadd", "VqaddUQ", "SimdAddOp", unsignedTypes, 4, vqaddUCode)
16607639Sgblack@eecs.umich.edu    vsubhnCode = '''
16617639Sgblack@eecs.umich.edu        destElem = ((BigElement)srcElem1 - (BigElement)srcElem2) >>
16627639Sgblack@eecs.umich.edu                   (sizeof(Element) * 8);
16637639Sgblack@eecs.umich.edu    '''
16647760SGiacomo.Gabrielli@arm.com    threeRegNarrowInst("vsubhn", "Vsubhn", "SimdAddOp", smallTypes, vsubhnCode)
16657639Sgblack@eecs.umich.edu    vrsubhnCode = '''
16667639Sgblack@eecs.umich.edu        destElem = ((BigElement)srcElem1 - (BigElement)srcElem2 +
16677639Sgblack@eecs.umich.edu                    ((BigElement)1 << (sizeof(Element) * 8 - 1))) >>
16687639Sgblack@eecs.umich.edu                   (sizeof(Element) * 8);
16697639Sgblack@eecs.umich.edu    '''
16707760SGiacomo.Gabrielli@arm.com    threeRegNarrowInst("vrsubhn", "Vrsubhn", "SimdAddOp", smallTypes, vrsubhnCode)
16717639Sgblack@eecs.umich.edu
16727639Sgblack@eecs.umich.edu    vqaddSCode = '''
16737639Sgblack@eecs.umich.edu        destElem = srcElem1 + srcElem2;
16747783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
16757639Sgblack@eecs.umich.edu        bool negDest = (destElem < 0);
16767639Sgblack@eecs.umich.edu        bool negSrc1 = (srcElem1 < 0);
16777639Sgblack@eecs.umich.edu        bool negSrc2 = (srcElem2 < 0);
16787639Sgblack@eecs.umich.edu        if ((negDest != negSrc1) && (negSrc1 == negSrc2)) {
16797639Sgblack@eecs.umich.edu            destElem = (Element)1 << (sizeof(Element) * 8 - 1);
16807639Sgblack@eecs.umich.edu            if (negDest)
16817639Sgblack@eecs.umich.edu                destElem -= 1;
16827639Sgblack@eecs.umich.edu            fpscr.qc = 1;
16837639Sgblack@eecs.umich.edu        }
16847783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
16857639Sgblack@eecs.umich.edu    '''
16867760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqadd", "VqaddSD", "SimdAddOp", signedTypes, 2, vqaddSCode)
16877760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqadd", "VqaddSQ", "SimdAddOp", signedTypes, 4, vqaddSCode)
16887639Sgblack@eecs.umich.edu
16897639Sgblack@eecs.umich.edu    vqsubUCode = '''
16907639Sgblack@eecs.umich.edu        destElem = srcElem1 - srcElem2;
16917783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
16927639Sgblack@eecs.umich.edu        if (destElem > srcElem1) {
16937639Sgblack@eecs.umich.edu            destElem = 0;
16947639Sgblack@eecs.umich.edu            fpscr.qc = 1;
16957639Sgblack@eecs.umich.edu        }
16967783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
16977639Sgblack@eecs.umich.edu    '''
16987760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqsub", "VqsubUD", "SimdAddOp", unsignedTypes, 2, vqsubUCode)
16997760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqsub", "VqsubUQ", "SimdAddOp", unsignedTypes, 4, vqsubUCode)
17007639Sgblack@eecs.umich.edu
17017639Sgblack@eecs.umich.edu    vqsubSCode = '''
17027639Sgblack@eecs.umich.edu        destElem = srcElem1 - srcElem2;
17037783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
17047639Sgblack@eecs.umich.edu        bool negDest = (destElem < 0);
17057639Sgblack@eecs.umich.edu        bool negSrc1 = (srcElem1 < 0);
17067639Sgblack@eecs.umich.edu        bool posSrc2 = (srcElem2 >= 0);
17077639Sgblack@eecs.umich.edu        if ((negDest != negSrc1) && (negSrc1 == posSrc2)) {
17087639Sgblack@eecs.umich.edu            destElem = (Element)1 << (sizeof(Element) * 8 - 1);
17097639Sgblack@eecs.umich.edu            if (negDest)
17107639Sgblack@eecs.umich.edu                destElem -= 1;
17117639Sgblack@eecs.umich.edu            fpscr.qc = 1;
17127639Sgblack@eecs.umich.edu        }
17137783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
17147639Sgblack@eecs.umich.edu    '''
17157760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqsub", "VqsubSD", "SimdAddOp", signedTypes, 2, vqsubSCode)
17167760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqsub", "VqsubSQ", "SimdAddOp", signedTypes, 4, vqsubSCode)
17177639Sgblack@eecs.umich.edu
17187639Sgblack@eecs.umich.edu    vcgtCode = '''
17197639Sgblack@eecs.umich.edu        destElem =  (srcElem1 > srcElem2) ? (Element)(-1) : 0;
17207639Sgblack@eecs.umich.edu    '''
17217760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vcgt", "VcgtD", "SimdCmpOp", allTypes, 2, vcgtCode)
17227760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vcgt", "VcgtQ", "SimdCmpOp", allTypes, 4, vcgtCode)
17237639Sgblack@eecs.umich.edu
17247639Sgblack@eecs.umich.edu    vcgeCode = '''
17257639Sgblack@eecs.umich.edu        destElem =  (srcElem1 >= srcElem2) ? (Element)(-1) : 0;
17267639Sgblack@eecs.umich.edu    '''
17277760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vcge", "VcgeD", "SimdCmpOp", allTypes, 2, vcgeCode)
17287760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vcge", "VcgeQ", "SimdCmpOp", allTypes, 4, vcgeCode)
17297639Sgblack@eecs.umich.edu
17307639Sgblack@eecs.umich.edu    vceqCode = '''
17317639Sgblack@eecs.umich.edu        destElem =  (srcElem1 == srcElem2) ? (Element)(-1) : 0;
17327639Sgblack@eecs.umich.edu    '''
17337760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vceq", "VceqD", "SimdCmpOp", unsignedTypes, 2, vceqCode)
17347760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vceq", "VceqQ", "SimdCmpOp", unsignedTypes, 4, vceqCode)
17357639Sgblack@eecs.umich.edu
17367639Sgblack@eecs.umich.edu    vshlCode = '''
17377639Sgblack@eecs.umich.edu        int16_t shiftAmt = (int8_t)srcElem2;
17387639Sgblack@eecs.umich.edu        if (shiftAmt < 0) {
17397639Sgblack@eecs.umich.edu            shiftAmt = -shiftAmt;
17407639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
17417639Sgblack@eecs.umich.edu                shiftAmt = sizeof(Element) * 8 - 1;
17427639Sgblack@eecs.umich.edu                destElem = 0;
17437639Sgblack@eecs.umich.edu            } else {
17447639Sgblack@eecs.umich.edu                destElem = (srcElem1 >> shiftAmt);
17457639Sgblack@eecs.umich.edu            }
17467639Sgblack@eecs.umich.edu            // Make sure the right shift sign extended when it should.
17477641Sgblack@eecs.umich.edu            if (ltz(srcElem1) && !ltz(destElem)) {
17487639Sgblack@eecs.umich.edu                destElem |= -((Element)1 << (sizeof(Element) * 8 -
17497639Sgblack@eecs.umich.edu                                             1 - shiftAmt));
17507639Sgblack@eecs.umich.edu            }
17517639Sgblack@eecs.umich.edu        } else {
17527639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
17537639Sgblack@eecs.umich.edu                destElem = 0;
17547639Sgblack@eecs.umich.edu            } else {
17557639Sgblack@eecs.umich.edu                destElem = srcElem1 << shiftAmt;
17567639Sgblack@eecs.umich.edu            }
17577639Sgblack@eecs.umich.edu        }
17587639Sgblack@eecs.umich.edu    '''
17598206SWilliam.Wang@arm.com    threeEqualRegInst("vshl", "VshlD", "SimdShiftOp", allTypes, 2, vshlCode)
17608206SWilliam.Wang@arm.com    threeEqualRegInst("vshl", "VshlQ", "SimdShiftOp", allTypes, 4, vshlCode)
17617639Sgblack@eecs.umich.edu
17627639Sgblack@eecs.umich.edu    vrshlCode = '''
17637639Sgblack@eecs.umich.edu        int16_t shiftAmt = (int8_t)srcElem2;
17647639Sgblack@eecs.umich.edu        if (shiftAmt < 0) {
17657639Sgblack@eecs.umich.edu            shiftAmt = -shiftAmt;
17667639Sgblack@eecs.umich.edu            Element rBit = 0;
17677639Sgblack@eecs.umich.edu            if (shiftAmt <= sizeof(Element) * 8)
17687639Sgblack@eecs.umich.edu                rBit = bits(srcElem1, shiftAmt - 1);
17697641Sgblack@eecs.umich.edu            if (shiftAmt > sizeof(Element) * 8 && ltz(srcElem1))
17707639Sgblack@eecs.umich.edu                rBit = 1;
17717639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
17727639Sgblack@eecs.umich.edu                shiftAmt = sizeof(Element) * 8 - 1;
17737639Sgblack@eecs.umich.edu                destElem = 0;
17747639Sgblack@eecs.umich.edu            } else {
17757639Sgblack@eecs.umich.edu                destElem = (srcElem1 >> shiftAmt);
17767639Sgblack@eecs.umich.edu            }
17777639Sgblack@eecs.umich.edu            // Make sure the right shift sign extended when it should.
17787641Sgblack@eecs.umich.edu            if (ltz(srcElem1) && !ltz(destElem)) {
17797639Sgblack@eecs.umich.edu                destElem |= -((Element)1 << (sizeof(Element) * 8 -
17807639Sgblack@eecs.umich.edu                                             1 - shiftAmt));
17817639Sgblack@eecs.umich.edu            }
17827639Sgblack@eecs.umich.edu            destElem += rBit;
17837639Sgblack@eecs.umich.edu        } else if (shiftAmt > 0) {
17847639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
17857639Sgblack@eecs.umich.edu                destElem = 0;
17867639Sgblack@eecs.umich.edu            } else {
17877639Sgblack@eecs.umich.edu                destElem = srcElem1 << shiftAmt;
17887639Sgblack@eecs.umich.edu            }
17897639Sgblack@eecs.umich.edu        } else {
17907639Sgblack@eecs.umich.edu            destElem = srcElem1;
17917639Sgblack@eecs.umich.edu        }
17927639Sgblack@eecs.umich.edu    '''
17937760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vrshl", "VrshlD", "SimdAluOp", allTypes, 2, vrshlCode)
17947760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vrshl", "VrshlQ", "SimdAluOp", allTypes, 4, vrshlCode)
17957639Sgblack@eecs.umich.edu
17967639Sgblack@eecs.umich.edu    vqshlUCode = '''
17977639Sgblack@eecs.umich.edu        int16_t shiftAmt = (int8_t)srcElem2;
17987783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
17997639Sgblack@eecs.umich.edu        if (shiftAmt < 0) {
18007639Sgblack@eecs.umich.edu            shiftAmt = -shiftAmt;
18017639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
18027639Sgblack@eecs.umich.edu                shiftAmt = sizeof(Element) * 8 - 1;
18037639Sgblack@eecs.umich.edu                destElem = 0;
18047639Sgblack@eecs.umich.edu            } else {
18057639Sgblack@eecs.umich.edu                destElem = (srcElem1 >> shiftAmt);
18067639Sgblack@eecs.umich.edu            }
18077639Sgblack@eecs.umich.edu        } else if (shiftAmt > 0) {
18087639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
18097639Sgblack@eecs.umich.edu                if (srcElem1 != 0) {
18107639Sgblack@eecs.umich.edu                    destElem = mask(sizeof(Element) * 8);
18117639Sgblack@eecs.umich.edu                    fpscr.qc = 1;
18127639Sgblack@eecs.umich.edu                } else {
18137639Sgblack@eecs.umich.edu                    destElem = 0;
18147639Sgblack@eecs.umich.edu                }
18157639Sgblack@eecs.umich.edu            } else {
18167639Sgblack@eecs.umich.edu                if (bits(srcElem1, sizeof(Element) * 8 - 1,
18177639Sgblack@eecs.umich.edu                            sizeof(Element) * 8 - shiftAmt)) {
18187639Sgblack@eecs.umich.edu                    destElem = mask(sizeof(Element) * 8);
18197639Sgblack@eecs.umich.edu                    fpscr.qc = 1;
18207639Sgblack@eecs.umich.edu                } else {
18217639Sgblack@eecs.umich.edu                    destElem = srcElem1 << shiftAmt;
18227639Sgblack@eecs.umich.edu                }
18237639Sgblack@eecs.umich.edu            }
18247639Sgblack@eecs.umich.edu        } else {
18257639Sgblack@eecs.umich.edu            destElem = srcElem1;
18267639Sgblack@eecs.umich.edu        }
18277783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
18287639Sgblack@eecs.umich.edu    '''
18297760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqshl", "VqshlUD", "SimdAluOp", unsignedTypes, 2, vqshlUCode)
18307760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqshl", "VqshlUQ", "SimdAluOp", unsignedTypes, 4, vqshlUCode)
18317639Sgblack@eecs.umich.edu
18327639Sgblack@eecs.umich.edu    vqshlSCode = '''
18337639Sgblack@eecs.umich.edu        int16_t shiftAmt = (int8_t)srcElem2;
18347783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
18357639Sgblack@eecs.umich.edu        if (shiftAmt < 0) {
18367639Sgblack@eecs.umich.edu            shiftAmt = -shiftAmt;
18377639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
18387639Sgblack@eecs.umich.edu                shiftAmt = sizeof(Element) * 8 - 1;
18397639Sgblack@eecs.umich.edu                destElem = 0;
18407639Sgblack@eecs.umich.edu            } else {
18417639Sgblack@eecs.umich.edu                destElem = (srcElem1 >> shiftAmt);
18427639Sgblack@eecs.umich.edu            }
18437639Sgblack@eecs.umich.edu            // Make sure the right shift sign extended when it should.
18447639Sgblack@eecs.umich.edu            if (srcElem1 < 0 && destElem >= 0) {
18457639Sgblack@eecs.umich.edu                destElem |= -((Element)1 << (sizeof(Element) * 8 -
18467639Sgblack@eecs.umich.edu                                             1 - shiftAmt));
18477639Sgblack@eecs.umich.edu            }
18487639Sgblack@eecs.umich.edu        } else if (shiftAmt > 0) {
18497639Sgblack@eecs.umich.edu            bool sat = false;
18507639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
18517639Sgblack@eecs.umich.edu                if (srcElem1 != 0)
18527639Sgblack@eecs.umich.edu                    sat = true;
18537639Sgblack@eecs.umich.edu                else
18547639Sgblack@eecs.umich.edu                    destElem = 0;
18557639Sgblack@eecs.umich.edu            } else {
18567639Sgblack@eecs.umich.edu                if (bits(srcElem1, sizeof(Element) * 8 - 1,
18577639Sgblack@eecs.umich.edu                            sizeof(Element) * 8 - 1 - shiftAmt) !=
18587639Sgblack@eecs.umich.edu                        ((srcElem1 < 0) ? mask(shiftAmt + 1) : 0)) {
18597639Sgblack@eecs.umich.edu                    sat = true;
18607639Sgblack@eecs.umich.edu                } else {
18617639Sgblack@eecs.umich.edu                    destElem = srcElem1 << shiftAmt;
18627639Sgblack@eecs.umich.edu                }
18637639Sgblack@eecs.umich.edu            }
18647639Sgblack@eecs.umich.edu            if (sat) {
18657639Sgblack@eecs.umich.edu                fpscr.qc = 1;
18667639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8 - 1);
18677639Sgblack@eecs.umich.edu                if (srcElem1 < 0)
18687639Sgblack@eecs.umich.edu                    destElem = ~destElem;
18697639Sgblack@eecs.umich.edu            }
18707639Sgblack@eecs.umich.edu        } else {
18717639Sgblack@eecs.umich.edu            destElem = srcElem1;
18727639Sgblack@eecs.umich.edu        }
18737783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
18747639Sgblack@eecs.umich.edu    '''
18757760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqshl", "VqshlSD", "SimdCmpOp", signedTypes, 2, vqshlSCode)
18767760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqshl", "VqshlSQ", "SimdCmpOp", signedTypes, 4, vqshlSCode)
18777639Sgblack@eecs.umich.edu
18787639Sgblack@eecs.umich.edu    vqrshlUCode = '''
18797639Sgblack@eecs.umich.edu        int16_t shiftAmt = (int8_t)srcElem2;
18807783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
18817639Sgblack@eecs.umich.edu        if (shiftAmt < 0) {
18827639Sgblack@eecs.umich.edu            shiftAmt = -shiftAmt;
18837639Sgblack@eecs.umich.edu            Element rBit = 0;
18847639Sgblack@eecs.umich.edu            if (shiftAmt <= sizeof(Element) * 8)
18857639Sgblack@eecs.umich.edu                rBit = bits(srcElem1, shiftAmt - 1);
18867639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
18877639Sgblack@eecs.umich.edu                shiftAmt = sizeof(Element) * 8 - 1;
18887639Sgblack@eecs.umich.edu                destElem = 0;
18897639Sgblack@eecs.umich.edu            } else {
18907639Sgblack@eecs.umich.edu                destElem = (srcElem1 >> shiftAmt);
18917639Sgblack@eecs.umich.edu            }
18927639Sgblack@eecs.umich.edu            destElem += rBit;
18937639Sgblack@eecs.umich.edu        } else {
18947639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
18957639Sgblack@eecs.umich.edu                if (srcElem1 != 0) {
18967639Sgblack@eecs.umich.edu                    destElem = mask(sizeof(Element) * 8);
18977639Sgblack@eecs.umich.edu                    fpscr.qc = 1;
18987639Sgblack@eecs.umich.edu                } else {
18997639Sgblack@eecs.umich.edu                    destElem = 0;
19007639Sgblack@eecs.umich.edu                }
19017639Sgblack@eecs.umich.edu            } else {
19027639Sgblack@eecs.umich.edu                if (bits(srcElem1, sizeof(Element) * 8 - 1,
19037639Sgblack@eecs.umich.edu                            sizeof(Element) * 8 - shiftAmt)) {
19047639Sgblack@eecs.umich.edu                    destElem = mask(sizeof(Element) * 8);
19057639Sgblack@eecs.umich.edu                    fpscr.qc = 1;
19067639Sgblack@eecs.umich.edu                } else {
19077639Sgblack@eecs.umich.edu                    destElem = srcElem1 << shiftAmt;
19087639Sgblack@eecs.umich.edu                }
19097639Sgblack@eecs.umich.edu            }
19107639Sgblack@eecs.umich.edu        }
19117783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
19127639Sgblack@eecs.umich.edu    '''
19137760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqrshl", "VqrshlUD", "SimdCmpOp", unsignedTypes, 2, vqrshlUCode)
19147760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqrshl", "VqrshlUQ", "SimdCmpOp", unsignedTypes, 4, vqrshlUCode)
19157639Sgblack@eecs.umich.edu
19167639Sgblack@eecs.umich.edu    vqrshlSCode = '''
19177639Sgblack@eecs.umich.edu        int16_t shiftAmt = (int8_t)srcElem2;
19187783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
19197639Sgblack@eecs.umich.edu        if (shiftAmt < 0) {
19207639Sgblack@eecs.umich.edu            shiftAmt = -shiftAmt;
19217639Sgblack@eecs.umich.edu            Element rBit = 0;
19227639Sgblack@eecs.umich.edu            if (shiftAmt <= sizeof(Element) * 8)
19237639Sgblack@eecs.umich.edu                rBit = bits(srcElem1, shiftAmt - 1);
19247639Sgblack@eecs.umich.edu            if (shiftAmt > sizeof(Element) * 8 && srcElem1 < 0)
19257639Sgblack@eecs.umich.edu                rBit = 1;
19267639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
19277639Sgblack@eecs.umich.edu                shiftAmt = sizeof(Element) * 8 - 1;
19287639Sgblack@eecs.umich.edu                destElem = 0;
19297639Sgblack@eecs.umich.edu            } else {
19307639Sgblack@eecs.umich.edu                destElem = (srcElem1 >> shiftAmt);
19317639Sgblack@eecs.umich.edu            }
19327639Sgblack@eecs.umich.edu            // Make sure the right shift sign extended when it should.
19337639Sgblack@eecs.umich.edu            if (srcElem1 < 0 && destElem >= 0) {
19347639Sgblack@eecs.umich.edu                destElem |= -((Element)1 << (sizeof(Element) * 8 -
19357639Sgblack@eecs.umich.edu                                             1 - shiftAmt));
19367639Sgblack@eecs.umich.edu            }
19377639Sgblack@eecs.umich.edu            destElem += rBit;
19387639Sgblack@eecs.umich.edu        } else if (shiftAmt > 0) {
19397639Sgblack@eecs.umich.edu            bool sat = false;
19407639Sgblack@eecs.umich.edu            if (shiftAmt >= sizeof(Element) * 8) {
19417639Sgblack@eecs.umich.edu                if (srcElem1 != 0)
19427639Sgblack@eecs.umich.edu                    sat = true;
19437639Sgblack@eecs.umich.edu                else
19447639Sgblack@eecs.umich.edu                    destElem = 0;
19457639Sgblack@eecs.umich.edu            } else {
19467639Sgblack@eecs.umich.edu                if (bits(srcElem1, sizeof(Element) * 8 - 1,
19477639Sgblack@eecs.umich.edu                            sizeof(Element) * 8 - 1 - shiftAmt) !=
19487639Sgblack@eecs.umich.edu                        ((srcElem1 < 0) ? mask(shiftAmt + 1) : 0)) {
19497639Sgblack@eecs.umich.edu                    sat = true;
19507639Sgblack@eecs.umich.edu                } else {
19517639Sgblack@eecs.umich.edu                    destElem = srcElem1 << shiftAmt;
19527639Sgblack@eecs.umich.edu                }
19537639Sgblack@eecs.umich.edu            }
19547639Sgblack@eecs.umich.edu            if (sat) {
19557639Sgblack@eecs.umich.edu                fpscr.qc = 1;
19567639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8 - 1);
19577639Sgblack@eecs.umich.edu                if (srcElem1 < 0)
19587639Sgblack@eecs.umich.edu                    destElem = ~destElem;
19597639Sgblack@eecs.umich.edu            }
19607639Sgblack@eecs.umich.edu        } else {
19617639Sgblack@eecs.umich.edu            destElem = srcElem1;
19627639Sgblack@eecs.umich.edu        }
19637783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
19647639Sgblack@eecs.umich.edu    '''
19657760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqrshl", "VqrshlSD", "SimdCmpOp", signedTypes, 2, vqrshlSCode)
19667760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqrshl", "VqrshlSQ", "SimdCmpOp", signedTypes, 4, vqrshlSCode)
19677639Sgblack@eecs.umich.edu
19687639Sgblack@eecs.umich.edu    vabaCode = '''
19697639Sgblack@eecs.umich.edu        destElem += (srcElem1 > srcElem2) ? (srcElem1 - srcElem2) :
19707639Sgblack@eecs.umich.edu                                            (srcElem2 - srcElem1);
19717639Sgblack@eecs.umich.edu    '''
19727760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vaba", "VabaD", "SimdAddAccOp", allTypes, 2, vabaCode, True)
19737760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vaba", "VabaQ", "SimdAddAccOp", allTypes, 4, vabaCode, True)
19747639Sgblack@eecs.umich.edu    vabalCode = '''
19757639Sgblack@eecs.umich.edu        destElem += (srcElem1 > srcElem2) ?
19767639Sgblack@eecs.umich.edu            ((BigElement)srcElem1 - (BigElement)srcElem2) :
19777639Sgblack@eecs.umich.edu            ((BigElement)srcElem2 - (BigElement)srcElem1);
19787639Sgblack@eecs.umich.edu    '''
19797760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vabal", "Vabal", "SimdAddAccOp", smallTypes, vabalCode, True)
19807639Sgblack@eecs.umich.edu
19817639Sgblack@eecs.umich.edu    vabdCode = '''
19827639Sgblack@eecs.umich.edu        destElem = (srcElem1 > srcElem2) ? (srcElem1 - srcElem2) :
19837639Sgblack@eecs.umich.edu                                           (srcElem2 - srcElem1);
19847639Sgblack@eecs.umich.edu    '''
19857760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vabd", "VabdD", "SimdAddOp", allTypes, 2, vabdCode)
19867760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vabd", "VabdQ", "SimdAddOp", allTypes, 4, vabdCode)
19877639Sgblack@eecs.umich.edu    vabdlCode = '''
19887639Sgblack@eecs.umich.edu        destElem = (srcElem1 > srcElem2) ?
19897639Sgblack@eecs.umich.edu            ((BigElement)srcElem1 - (BigElement)srcElem2) :
19907639Sgblack@eecs.umich.edu            ((BigElement)srcElem2 - (BigElement)srcElem1);
19917639Sgblack@eecs.umich.edu    '''
19927760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vabdl", "Vabdl", "SimdAddOp", smallTypes, vabdlCode)
19937639Sgblack@eecs.umich.edu
19947639Sgblack@eecs.umich.edu    vtstCode = '''
19957639Sgblack@eecs.umich.edu        destElem = (srcElem1 & srcElem2) ? (Element)(-1) : 0;
19967639Sgblack@eecs.umich.edu    '''
19977760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vtst", "VtstD", "SimdAluOp", unsignedTypes, 2, vtstCode)
19987760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vtst", "VtstQ", "SimdAluOp", unsignedTypes, 4, vtstCode)
19997639Sgblack@eecs.umich.edu
20007639Sgblack@eecs.umich.edu    vmulCode = '''
20017639Sgblack@eecs.umich.edu        destElem = srcElem1 * srcElem2;
20027639Sgblack@eecs.umich.edu    '''
20037760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmul", "NVmulD", "SimdMultOp", allTypes, 2, vmulCode)
20047760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmul", "NVmulQ", "SimdMultOp", allTypes, 4, vmulCode)
20057639Sgblack@eecs.umich.edu    vmullCode = '''
20067639Sgblack@eecs.umich.edu        destElem = (BigElement)srcElem1 * (BigElement)srcElem2;
20077639Sgblack@eecs.umich.edu    '''
20087760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vmull", "Vmull", "SimdMultOp", smallTypes, vmullCode)
20097639Sgblack@eecs.umich.edu
20107639Sgblack@eecs.umich.edu    vmlaCode = '''
20117639Sgblack@eecs.umich.edu        destElem = destElem + srcElem1 * srcElem2;
20127639Sgblack@eecs.umich.edu    '''
20137760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmla", "NVmlaD", "SimdMultAccOp", allTypes, 2, vmlaCode, True)
20147760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmla", "NVmlaQ", "SimdMultAccOp", allTypes, 4, vmlaCode, True)
20157639Sgblack@eecs.umich.edu    vmlalCode = '''
20167639Sgblack@eecs.umich.edu        destElem = destElem + (BigElement)srcElem1 * (BigElement)srcElem2;
20177639Sgblack@eecs.umich.edu    '''
20187760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vmlal", "Vmlal", "SimdMultAccOp", smallTypes, vmlalCode, True)
20197639Sgblack@eecs.umich.edu
20207639Sgblack@eecs.umich.edu    vqdmlalCode = '''
20217783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
20227639Sgblack@eecs.umich.edu        BigElement midElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2);
20237639Sgblack@eecs.umich.edu        Element maxNeg = (Element)1 << (sizeof(Element) * 8 - 1);
20247639Sgblack@eecs.umich.edu        Element halfNeg = maxNeg / 2;
20257639Sgblack@eecs.umich.edu        if ((srcElem1 == maxNeg && srcElem2 == maxNeg) ||
20267639Sgblack@eecs.umich.edu            (srcElem1 == halfNeg && srcElem2 == maxNeg) ||
20277639Sgblack@eecs.umich.edu            (srcElem1 == maxNeg && srcElem2 == halfNeg)) {
20287639Sgblack@eecs.umich.edu            midElem = ~((BigElement)maxNeg << (sizeof(Element) * 8));
20297639Sgblack@eecs.umich.edu            fpscr.qc = 1;
20307639Sgblack@eecs.umich.edu        }
20317641Sgblack@eecs.umich.edu        bool negPreDest = ltz(destElem);
20327639Sgblack@eecs.umich.edu        destElem += midElem;
20337641Sgblack@eecs.umich.edu        bool negDest = ltz(destElem);
20347641Sgblack@eecs.umich.edu        bool negMid = ltz(midElem);
20357639Sgblack@eecs.umich.edu        if (negPreDest == negMid && negMid != negDest) {
20367639Sgblack@eecs.umich.edu            destElem = mask(sizeof(BigElement) * 8 - 1);
20377639Sgblack@eecs.umich.edu            if (negPreDest)
20387639Sgblack@eecs.umich.edu                destElem = ~destElem;
20397639Sgblack@eecs.umich.edu            fpscr.qc = 1;
20407639Sgblack@eecs.umich.edu        }
20417783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
20427639Sgblack@eecs.umich.edu    '''
20437760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vqdmlal", "Vqdmlal", "SimdMultAccOp", smallTypes, vqdmlalCode, True)
20447639Sgblack@eecs.umich.edu
20457639Sgblack@eecs.umich.edu    vqdmlslCode = '''
20467783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
20477639Sgblack@eecs.umich.edu        BigElement midElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2);
20487639Sgblack@eecs.umich.edu        Element maxNeg = (Element)1 << (sizeof(Element) * 8 - 1);
20497639Sgblack@eecs.umich.edu        Element halfNeg = maxNeg / 2;
20507639Sgblack@eecs.umich.edu        if ((srcElem1 == maxNeg && srcElem2 == maxNeg) ||
20517639Sgblack@eecs.umich.edu            (srcElem1 == halfNeg && srcElem2 == maxNeg) ||
20527639Sgblack@eecs.umich.edu            (srcElem1 == maxNeg && srcElem2 == halfNeg)) {
20537639Sgblack@eecs.umich.edu            midElem = ~((BigElement)maxNeg << (sizeof(Element) * 8));
20547639Sgblack@eecs.umich.edu            fpscr.qc = 1;
20557639Sgblack@eecs.umich.edu        }
20567641Sgblack@eecs.umich.edu        bool negPreDest = ltz(destElem);
20577639Sgblack@eecs.umich.edu        destElem -= midElem;
20587641Sgblack@eecs.umich.edu        bool negDest = ltz(destElem);
20597641Sgblack@eecs.umich.edu        bool posMid = ltz((BigElement)-midElem);
20607639Sgblack@eecs.umich.edu        if (negPreDest == posMid && posMid != negDest) {
20617639Sgblack@eecs.umich.edu            destElem = mask(sizeof(BigElement) * 8 - 1);
20627639Sgblack@eecs.umich.edu            if (negPreDest)
20637639Sgblack@eecs.umich.edu                destElem = ~destElem;
20647639Sgblack@eecs.umich.edu            fpscr.qc = 1;
20657639Sgblack@eecs.umich.edu        }
20667783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
20677639Sgblack@eecs.umich.edu    '''
20687760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vqdmlsl", "Vqdmlsl", "SimdMultAccOp", smallTypes, vqdmlslCode, True)
20697639Sgblack@eecs.umich.edu
20707639Sgblack@eecs.umich.edu    vqdmullCode = '''
20717783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
20727639Sgblack@eecs.umich.edu        destElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2);
20737639Sgblack@eecs.umich.edu        if (srcElem1 == srcElem2 &&
20747639Sgblack@eecs.umich.edu                srcElem1 == (Element)((Element)1 <<
20757639Sgblack@eecs.umich.edu                    (Element)(sizeof(Element) * 8 - 1))) {
20767639Sgblack@eecs.umich.edu            destElem = ~((BigElement)srcElem1 << (sizeof(Element) * 8));
20777639Sgblack@eecs.umich.edu            fpscr.qc = 1;
20787639Sgblack@eecs.umich.edu        }
20797783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
20807639Sgblack@eecs.umich.edu    '''
20817760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vqdmull", "Vqdmull", "SimdMultAccOp", smallTypes, vqdmullCode)
20827639Sgblack@eecs.umich.edu
20837639Sgblack@eecs.umich.edu    vmlsCode = '''
20847639Sgblack@eecs.umich.edu        destElem = destElem - srcElem1 * srcElem2;
20857639Sgblack@eecs.umich.edu    '''
20867760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmls", "NVmlsD", "SimdMultAccOp", allTypes, 2, vmlsCode, True)
20877760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmls", "NVmlsQ", "SimdMultAccOp", allTypes, 4, vmlsCode, True)
20887639Sgblack@eecs.umich.edu    vmlslCode = '''
20897639Sgblack@eecs.umich.edu        destElem = destElem - (BigElement)srcElem1 * (BigElement)srcElem2;
20907639Sgblack@eecs.umich.edu    '''
20917760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vmlsl", "Vmlsl", "SimdMultAccOp", smallTypes, vmlslCode, True)
20927639Sgblack@eecs.umich.edu
20937639Sgblack@eecs.umich.edu    vmulpCode = '''
20947639Sgblack@eecs.umich.edu        destElem = 0;
20957639Sgblack@eecs.umich.edu        for (unsigned j = 0; j < sizeof(Element) * 8; j++) {
20967639Sgblack@eecs.umich.edu            if (bits(srcElem2, j))
20977639Sgblack@eecs.umich.edu                destElem ^= srcElem1 << j;
20987639Sgblack@eecs.umich.edu        }
20997639Sgblack@eecs.umich.edu    '''
21007760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmul", "NVmulpD", "SimdMultOp", unsignedTypes, 2, vmulpCode)
21017760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vmul", "NVmulpQ", "SimdMultOp", unsignedTypes, 4, vmulpCode)
21027639Sgblack@eecs.umich.edu    vmullpCode = '''
21037639Sgblack@eecs.umich.edu        destElem = 0;
21047639Sgblack@eecs.umich.edu        for (unsigned j = 0; j < sizeof(Element) * 8; j++) {
21057639Sgblack@eecs.umich.edu            if (bits(srcElem2, j))
21067639Sgblack@eecs.umich.edu                destElem ^= (BigElement)srcElem1 << j;
21077639Sgblack@eecs.umich.edu        }
21087639Sgblack@eecs.umich.edu    '''
21097760SGiacomo.Gabrielli@arm.com    threeRegLongInst("vmull", "Vmullp", "SimdMultOp", smallUnsignedTypes, vmullpCode)
21107639Sgblack@eecs.umich.edu
21118607Sgblack@eecs.umich.edu    threeEqualRegInst("vpmax", "VpmaxD", "SimdCmpOp", smallTypes, 2, vmaxCode, pairwise=True)
21127639Sgblack@eecs.umich.edu
21138607Sgblack@eecs.umich.edu    threeEqualRegInst("vpmin", "VpminD", "SimdCmpOp", smallTypes, 2, vminCode, pairwise=True)
21147639Sgblack@eecs.umich.edu
21157639Sgblack@eecs.umich.edu    vqdmulhCode = '''
21167783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
21177639Sgblack@eecs.umich.edu        destElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2) >>
21187639Sgblack@eecs.umich.edu                   (sizeof(Element) * 8);
21197639Sgblack@eecs.umich.edu        if (srcElem1 == srcElem2 &&
21207639Sgblack@eecs.umich.edu                srcElem1 == (Element)((Element)1 <<
21217639Sgblack@eecs.umich.edu                    (sizeof(Element) * 8 - 1))) {
21227639Sgblack@eecs.umich.edu            destElem = ~srcElem1;
21237639Sgblack@eecs.umich.edu            fpscr.qc = 1;
21247639Sgblack@eecs.umich.edu        }
21257783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
21267639Sgblack@eecs.umich.edu    '''
21277760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqdmulh", "VqdmulhD", "SimdMultOp", smallSignedTypes, 2, vqdmulhCode)
21287760SGiacomo.Gabrielli@arm.com    threeEqualRegInst("vqdmulh", "VqdmulhQ", "SimdMultOp", smallSignedTypes, 4, vqdmulhCode)
21297639Sgblack@eecs.umich.edu
21307639Sgblack@eecs.umich.edu    vqrdmulhCode = '''
21317783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
21327639Sgblack@eecs.umich.edu        destElem = (2 * (int64_t)srcElem1 * (int64_t)srcElem2 +
21337639Sgblack@eecs.umich.edu                    ((int64_t)1 << (sizeof(Element) * 8 - 1))) >>
21347639Sgblack@eecs.umich.edu                   (sizeof(Element) * 8);
21357639Sgblack@eecs.umich.edu        Element maxNeg = (Element)1 << (sizeof(Element) * 8 - 1);
21367639Sgblack@eecs.umich.edu        Element halfNeg = maxNeg / 2;
21377639Sgblack@eecs.umich.edu        if ((srcElem1 == maxNeg && srcElem2 == maxNeg) ||
21387639Sgblack@eecs.umich.edu            (srcElem1 == halfNeg && srcElem2 == maxNeg) ||
21397639Sgblack@eecs.umich.edu            (srcElem1 == maxNeg && srcElem2 == halfNeg)) {
21407639Sgblack@eecs.umich.edu            if (destElem < 0) {
21417639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8 - 1);
21427639Sgblack@eecs.umich.edu            } else {
21437639Sgblack@eecs.umich.edu                destElem = (Element)1 << (sizeof(Element) * 8 - 1);
21447639Sgblack@eecs.umich.edu            }
21457639Sgblack@eecs.umich.edu            fpscr.qc = 1;
21467639Sgblack@eecs.umich.edu        }
21477783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
21487639Sgblack@eecs.umich.edu    '''
21497639Sgblack@eecs.umich.edu    threeEqualRegInst("vqrdmulh", "VqrdmulhD",
21507760SGiacomo.Gabrielli@arm.com            "SimdMultOp", smallSignedTypes, 2, vqrdmulhCode)
21517639Sgblack@eecs.umich.edu    threeEqualRegInst("vqrdmulh", "VqrdmulhQ",
21527760SGiacomo.Gabrielli@arm.com            "SimdMultOp", smallSignedTypes, 4, vqrdmulhCode)
21537639Sgblack@eecs.umich.edu
21547639Sgblack@eecs.umich.edu    vmaxfpCode = '''
21557783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
21567639Sgblack@eecs.umich.edu        bool done;
21577639Sgblack@eecs.umich.edu        destReg = processNans(fpscr, done, true, srcReg1, srcReg2);
21587639Sgblack@eecs.umich.edu        if (!done) {
21597639Sgblack@eecs.umich.edu            destReg = binaryOp(fpscr, srcReg1, srcReg2, fpMaxS,
21607639Sgblack@eecs.umich.edu                               true, true, VfpRoundNearest);
21617639Sgblack@eecs.umich.edu        } else if (flushToZero(srcReg1, srcReg2)) {
21627639Sgblack@eecs.umich.edu            fpscr.idc = 1;
21637639Sgblack@eecs.umich.edu        }
21647783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
21657639Sgblack@eecs.umich.edu    '''
21667760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmax", "VmaxDFp", "SimdFloatCmpOp", ("float",), 2, vmaxfpCode)
21677760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmax", "VmaxQFp", "SimdFloatCmpOp", ("float",), 4, vmaxfpCode)
21687639Sgblack@eecs.umich.edu
21697639Sgblack@eecs.umich.edu    vminfpCode = '''
21707783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
21717639Sgblack@eecs.umich.edu        bool done;
21727639Sgblack@eecs.umich.edu        destReg = processNans(fpscr, done, true, srcReg1, srcReg2);
21737639Sgblack@eecs.umich.edu        if (!done) {
21747639Sgblack@eecs.umich.edu            destReg = binaryOp(fpscr, srcReg1, srcReg2, fpMinS,
21757639Sgblack@eecs.umich.edu                               true, true, VfpRoundNearest);
21767639Sgblack@eecs.umich.edu        } else if (flushToZero(srcReg1, srcReg2)) {
21777639Sgblack@eecs.umich.edu            fpscr.idc = 1;
21787639Sgblack@eecs.umich.edu        }
21797783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
21807639Sgblack@eecs.umich.edu    '''
21817760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmin", "VminDFp", "SimdFloatCmpOp", ("float",), 2, vminfpCode)
21827760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmin", "VminQFp", "SimdFloatCmpOp", ("float",), 4, vminfpCode)
21837639Sgblack@eecs.umich.edu
21847760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vpmax", "VpmaxDFp", "SimdFloatCmpOp", ("float",),
21857639Sgblack@eecs.umich.edu                        2, vmaxfpCode, pairwise=True)
21867760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vpmax", "VpmaxQFp", "SimdFloatCmpOp", ("float",),
21877639Sgblack@eecs.umich.edu                        4, vmaxfpCode, pairwise=True)
21887639Sgblack@eecs.umich.edu
21897760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vpmin", "VpminDFp", "SimdFloatCmpOp", ("float",),
21907639Sgblack@eecs.umich.edu                        2, vminfpCode, pairwise=True)
21917760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vpmin", "VpminQFp", "SimdFloatCmpOp", ("float",),
21927639Sgblack@eecs.umich.edu                        4, vminfpCode, pairwise=True)
21937639Sgblack@eecs.umich.edu
21947639Sgblack@eecs.umich.edu    vaddfpCode = '''
21957783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
21967639Sgblack@eecs.umich.edu        destReg = binaryOp(fpscr, srcReg1, srcReg2, fpAddS,
21977639Sgblack@eecs.umich.edu                           true, true, VfpRoundNearest);
21987783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
21997639Sgblack@eecs.umich.edu    '''
22007760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vadd", "VaddDFp", "SimdFloatAddOp", ("float",), 2, vaddfpCode)
22017760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vadd", "VaddQFp", "SimdFloatAddOp", ("float",), 4, vaddfpCode)
22027639Sgblack@eecs.umich.edu
22037760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vpadd", "VpaddDFp", "SimdFloatAddOp", ("float",),
22047639Sgblack@eecs.umich.edu                        2, vaddfpCode, pairwise=True)
22057760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vpadd", "VpaddQFp", "SimdFloatAddOp", ("float",),
22067639Sgblack@eecs.umich.edu                        4, vaddfpCode, pairwise=True)
22077639Sgblack@eecs.umich.edu
22087639Sgblack@eecs.umich.edu    vsubfpCode = '''
22097783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
22107639Sgblack@eecs.umich.edu        destReg = binaryOp(fpscr, srcReg1, srcReg2, fpSubS,
22117639Sgblack@eecs.umich.edu                           true, true, VfpRoundNearest);
22127783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
22137639Sgblack@eecs.umich.edu    '''
22147760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vsub", "VsubDFp", "SimdFloatAddOp", ("float",), 2, vsubfpCode)
22157760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vsub", "VsubQFp", "SimdFloatAddOp", ("float",), 4, vsubfpCode)
22167639Sgblack@eecs.umich.edu
22177639Sgblack@eecs.umich.edu    vmulfpCode = '''
22187783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
22197639Sgblack@eecs.umich.edu        destReg = binaryOp(fpscr, srcReg1, srcReg2, fpMulS,
22207639Sgblack@eecs.umich.edu                           true, true, VfpRoundNearest);
22217783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
22227639Sgblack@eecs.umich.edu    '''
22237760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmul", "NVmulDFp", "SimdFloatMultOp", ("float",), 2, vmulfpCode)
22247760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmul", "NVmulQFp", "SimdFloatMultOp", ("float",), 4, vmulfpCode)
22257639Sgblack@eecs.umich.edu
22267639Sgblack@eecs.umich.edu    vmlafpCode = '''
22277783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
22287639Sgblack@eecs.umich.edu        float mid = binaryOp(fpscr, srcReg1, srcReg2, fpMulS,
22297639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
22307639Sgblack@eecs.umich.edu        destReg = binaryOp(fpscr, mid, destReg, fpAddS,
22317639Sgblack@eecs.umich.edu                           true, true, VfpRoundNearest);
22327783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
22337639Sgblack@eecs.umich.edu    '''
22347760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmla", "NVmlaDFp", "SimdFloatMultAccOp", ("float",), 2, vmlafpCode, True)
22357760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmla", "NVmlaQFp", "SimdFloatMultAccOp", ("float",), 4, vmlafpCode, True)
22367639Sgblack@eecs.umich.edu
22377639Sgblack@eecs.umich.edu    vmlsfpCode = '''
22387783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
22397639Sgblack@eecs.umich.edu        float mid = binaryOp(fpscr, srcReg1, srcReg2, fpMulS,
22407639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
22417639Sgblack@eecs.umich.edu        destReg = binaryOp(fpscr, destReg, mid, fpSubS,
22427639Sgblack@eecs.umich.edu                           true, true, VfpRoundNearest);
22437783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
22447639Sgblack@eecs.umich.edu    '''
22457760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmls", "NVmlsDFp", "SimdFloatMultAccOp", ("float",), 2, vmlsfpCode, True)
22467760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vmls", "NVmlsQFp", "SimdFloatMultAccOp", ("float",), 4, vmlsfpCode, True)
22477639Sgblack@eecs.umich.edu
22487639Sgblack@eecs.umich.edu    vcgtfpCode = '''
22497783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
22507639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, srcReg2, vcgtFunc,
22517639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
22527639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
22537639Sgblack@eecs.umich.edu        if (res == 2.0)
22547639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
22557783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
22567639Sgblack@eecs.umich.edu    '''
22577760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vcgt", "VcgtDFp", "SimdFloatCmpOp", ("float",),
22587639Sgblack@eecs.umich.edu            2, vcgtfpCode, toInt = True)
22597760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vcgt", "VcgtQFp", "SimdFloatCmpOp", ("float",),
22607639Sgblack@eecs.umich.edu            4, vcgtfpCode, toInt = True)
22617639Sgblack@eecs.umich.edu
22627639Sgblack@eecs.umich.edu    vcgefpCode = '''
22637783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
22647639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, srcReg2, vcgeFunc,
22657639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
22667639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
22677639Sgblack@eecs.umich.edu        if (res == 2.0)
22687639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
22697783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
22707639Sgblack@eecs.umich.edu    '''
22717760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vcge", "VcgeDFp", "SimdFloatCmpOp", ("float",),
22727639Sgblack@eecs.umich.edu            2, vcgefpCode, toInt = True)
22737760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vcge", "VcgeQFp", "SimdFloatCmpOp", ("float",),
22747639Sgblack@eecs.umich.edu            4, vcgefpCode, toInt = True)
22757639Sgblack@eecs.umich.edu
22767639Sgblack@eecs.umich.edu    vacgtfpCode = '''
22777783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
22787639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, srcReg2, vacgtFunc,
22797639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
22807639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
22817639Sgblack@eecs.umich.edu        if (res == 2.0)
22827639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
22837783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
22847639Sgblack@eecs.umich.edu    '''
22857760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vacgt", "VacgtDFp", "SimdFloatCmpOp", ("float",),
22867639Sgblack@eecs.umich.edu            2, vacgtfpCode, toInt = True)
22877760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vacgt", "VacgtQFp", "SimdFloatCmpOp", ("float",),
22887639Sgblack@eecs.umich.edu            4, vacgtfpCode, toInt = True)
22897639Sgblack@eecs.umich.edu
22907639Sgblack@eecs.umich.edu    vacgefpCode = '''
22917783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
22927639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, srcReg2, vacgeFunc,
22937639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
22947639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
22957639Sgblack@eecs.umich.edu        if (res == 2.0)
22967639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
22977783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
22987639Sgblack@eecs.umich.edu    '''
22997760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vacge", "VacgeDFp", "SimdFloatCmpOp", ("float",),
23007639Sgblack@eecs.umich.edu            2, vacgefpCode, toInt = True)
23017760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vacge", "VacgeQFp", "SimdFloatCmpOp", ("float",),
23027639Sgblack@eecs.umich.edu            4, vacgefpCode, toInt = True)
23037639Sgblack@eecs.umich.edu
23047639Sgblack@eecs.umich.edu    vceqfpCode = '''
23057783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
23067639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, srcReg2, vceqFunc,
23077639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
23087639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
23097639Sgblack@eecs.umich.edu        if (res == 2.0)
23107639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
23117783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
23127639Sgblack@eecs.umich.edu    '''
23137760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vceq", "VceqDFp", "SimdFloatCmpOp", ("float",),
23147639Sgblack@eecs.umich.edu            2, vceqfpCode, toInt = True)
23157760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vceq", "VceqQFp", "SimdFloatCmpOp", ("float",),
23167639Sgblack@eecs.umich.edu            4, vceqfpCode, toInt = True)
23177639Sgblack@eecs.umich.edu
23187639Sgblack@eecs.umich.edu    vrecpsCode = '''
23197783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
23207639Sgblack@eecs.umich.edu        destReg = binaryOp(fpscr, srcReg1, srcReg2, fpRecpsS,
23217639Sgblack@eecs.umich.edu                           true, true, VfpRoundNearest);
23227783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
23237639Sgblack@eecs.umich.edu    '''
23247760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vrecps", "VrecpsDFp", "SimdFloatMultAccOp", ("float",), 2, vrecpsCode)
23257760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vrecps", "VrecpsQFp", "SimdFloatMultAccOp", ("float",), 4, vrecpsCode)
23267639Sgblack@eecs.umich.edu
23277639Sgblack@eecs.umich.edu    vrsqrtsCode = '''
23287783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
23297639Sgblack@eecs.umich.edu        destReg = binaryOp(fpscr, srcReg1, srcReg2, fpRSqrtsS,
23307639Sgblack@eecs.umich.edu                           true, true, VfpRoundNearest);
23317783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
23327639Sgblack@eecs.umich.edu    '''
23337760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vrsqrts", "VrsqrtsDFp", "SimdFloatMiscOp", ("float",), 2, vrsqrtsCode)
23347760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vrsqrts", "VrsqrtsQFp", "SimdFloatMiscOp", ("float",), 4, vrsqrtsCode)
23357639Sgblack@eecs.umich.edu
23367639Sgblack@eecs.umich.edu    vabdfpCode = '''
23377783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
23387639Sgblack@eecs.umich.edu        float mid = binaryOp(fpscr, srcReg1, srcReg2, fpSubS,
23397639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
23407639Sgblack@eecs.umich.edu        destReg = fabs(mid);
23417783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
23427639Sgblack@eecs.umich.edu    '''
23437760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vabd", "VabdDFp", "SimdFloatAddOp", ("float",), 2, vabdfpCode)
23447760SGiacomo.Gabrielli@arm.com    threeEqualRegInstFp("vabd", "VabdQFp", "SimdFloatAddOp", ("float",), 4, vabdfpCode)
23457639Sgblack@eecs.umich.edu
23467760SGiacomo.Gabrielli@arm.com    twoEqualRegInst("vmla", "VmlasD", "SimdMultAccOp", unsignedTypes, 2, vmlaCode, True)
23477760SGiacomo.Gabrielli@arm.com    twoEqualRegInst("vmla", "VmlasQ", "SimdMultAccOp", unsignedTypes, 4, vmlaCode, True)
23487760SGiacomo.Gabrielli@arm.com    twoEqualRegInstFp("vmla", "VmlasDFp", "SimdFloatMultAccOp", ("float",), 2, vmlafpCode, True)
23497760SGiacomo.Gabrielli@arm.com    twoEqualRegInstFp("vmla", "VmlasQFp", "SimdFloatMultAccOp", ("float",), 4, vmlafpCode, True)
23507760SGiacomo.Gabrielli@arm.com    twoRegLongInst("vmlal", "Vmlals", "SimdMultAccOp", smallTypes, vmlalCode, True)
23517639Sgblack@eecs.umich.edu
23527760SGiacomo.Gabrielli@arm.com    twoEqualRegInst("vmls", "VmlssD", "SimdMultAccOp", allTypes, 2, vmlsCode, True)
23537760SGiacomo.Gabrielli@arm.com    twoEqualRegInst("vmls", "VmlssQ", "SimdMultAccOp", allTypes, 4, vmlsCode, True)
23547760SGiacomo.Gabrielli@arm.com    twoEqualRegInstFp("vmls", "VmlssDFp", "SimdFloatMultAccOp", ("float",), 2, vmlsfpCode, True)
23557760SGiacomo.Gabrielli@arm.com    twoEqualRegInstFp("vmls", "VmlssQFp", "SimdFloatMultAccOp", ("float",), 4, vmlsfpCode, True)
23567760SGiacomo.Gabrielli@arm.com    twoRegLongInst("vmlsl", "Vmlsls", "SimdMultAccOp", smallTypes, vmlslCode, True)
23577639Sgblack@eecs.umich.edu
23587760SGiacomo.Gabrielli@arm.com    twoEqualRegInst("vmul", "VmulsD", "SimdMultOp", allTypes, 2, vmulCode)
23597760SGiacomo.Gabrielli@arm.com    twoEqualRegInst("vmul", "VmulsQ", "SimdMultOp", allTypes, 4, vmulCode)
23607760SGiacomo.Gabrielli@arm.com    twoEqualRegInstFp("vmul", "VmulsDFp", "SimdFloatMultOp", ("float",), 2, vmulfpCode)
23617760SGiacomo.Gabrielli@arm.com    twoEqualRegInstFp("vmul", "VmulsQFp", "SimdFloatMultOp", ("float",), 4, vmulfpCode)
23627760SGiacomo.Gabrielli@arm.com    twoRegLongInst("vmull", "Vmulls", "SimdMultOp", smallTypes, vmullCode)
23637639Sgblack@eecs.umich.edu
23647760SGiacomo.Gabrielli@arm.com    twoRegLongInst("vqdmull", "Vqdmulls", "SimdMultOp", smallTypes, vqdmullCode)
23657760SGiacomo.Gabrielli@arm.com    twoRegLongInst("vqdmlal", "Vqdmlals", "SimdMultAccOp", smallTypes, vqdmlalCode, True)
23667760SGiacomo.Gabrielli@arm.com    twoRegLongInst("vqdmlsl", "Vqdmlsls", "SimdMultAccOp", smallTypes, vqdmlslCode, True)
23677760SGiacomo.Gabrielli@arm.com    twoEqualRegInst("vqdmulh", "VqdmulhsD", "SimdMultOp", smallSignedTypes, 2, vqdmulhCode)
23687760SGiacomo.Gabrielli@arm.com    twoEqualRegInst("vqdmulh", "VqdmulhsQ", "SimdMultOp", smallSignedTypes, 4, vqdmulhCode)
23697639Sgblack@eecs.umich.edu    twoEqualRegInst("vqrdmulh", "VqrdmulhsD",
23707760SGiacomo.Gabrielli@arm.com            "SimdMultOp", smallSignedTypes, 2, vqrdmulhCode)
23717639Sgblack@eecs.umich.edu    twoEqualRegInst("vqrdmulh", "VqrdmulhsQ",
23727760SGiacomo.Gabrielli@arm.com            "SimdMultOp", smallSignedTypes, 4, vqrdmulhCode)
23737639Sgblack@eecs.umich.edu
23747639Sgblack@eecs.umich.edu    vshrCode = '''
23757639Sgblack@eecs.umich.edu        if (imm >= sizeof(srcElem1) * 8) {
23767641Sgblack@eecs.umich.edu            if (ltz(srcElem1))
23777639Sgblack@eecs.umich.edu                destElem = -1;
23787639Sgblack@eecs.umich.edu            else
23797639Sgblack@eecs.umich.edu                destElem = 0;
23807639Sgblack@eecs.umich.edu        } else {
23817639Sgblack@eecs.umich.edu            destElem = srcElem1 >> imm;
23827639Sgblack@eecs.umich.edu        }
23837639Sgblack@eecs.umich.edu    '''
23847760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vshr", "NVshrD", "SimdShiftOp", allTypes, 2, vshrCode)
23857760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vshr", "NVshrQ", "SimdShiftOp", allTypes, 4, vshrCode)
23867639Sgblack@eecs.umich.edu
23877639Sgblack@eecs.umich.edu    vsraCode = '''
23887639Sgblack@eecs.umich.edu        Element mid;;
23897639Sgblack@eecs.umich.edu        if (imm >= sizeof(srcElem1) * 8) {
23907641Sgblack@eecs.umich.edu            mid = ltz(srcElem1) ? -1 : 0;
23917639Sgblack@eecs.umich.edu        } else {
23927639Sgblack@eecs.umich.edu            mid = srcElem1 >> imm;
23937641Sgblack@eecs.umich.edu            if (ltz(srcElem1) && !ltz(mid)) {
23947639Sgblack@eecs.umich.edu                mid |= -(mid & ((Element)1 <<
23957639Sgblack@eecs.umich.edu                            (sizeof(Element) * 8 - 1 - imm)));
23967639Sgblack@eecs.umich.edu            }
23977639Sgblack@eecs.umich.edu        }
23987639Sgblack@eecs.umich.edu        destElem += mid;
23997639Sgblack@eecs.umich.edu    '''
24007760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vsra", "NVsraD", "SimdShiftAccOp", allTypes, 2, vsraCode, True)
24017760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vsra", "NVsraQ", "SimdShiftAccOp", allTypes, 4, vsraCode, True)
24027639Sgblack@eecs.umich.edu
24037639Sgblack@eecs.umich.edu    vrshrCode = '''
24047639Sgblack@eecs.umich.edu        if (imm > sizeof(srcElem1) * 8) {
24057639Sgblack@eecs.umich.edu            destElem = 0;
24067639Sgblack@eecs.umich.edu        } else if (imm) {
24077639Sgblack@eecs.umich.edu            Element rBit = bits(srcElem1, imm - 1);
24087639Sgblack@eecs.umich.edu            destElem = ((srcElem1 >> (imm - 1)) >> 1) + rBit;
24097639Sgblack@eecs.umich.edu        } else {
24107639Sgblack@eecs.umich.edu            destElem = srcElem1;
24117639Sgblack@eecs.umich.edu        }
24127639Sgblack@eecs.umich.edu    '''
24137760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vrshr", "NVrshrD", "SimdShiftOp", allTypes, 2, vrshrCode)
24147760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vrshr", "NVrshrQ", "SimdShiftOp", allTypes, 4, vrshrCode)
24157639Sgblack@eecs.umich.edu
24167639Sgblack@eecs.umich.edu    vrsraCode = '''
24177639Sgblack@eecs.umich.edu        if (imm > sizeof(srcElem1) * 8) {
24187639Sgblack@eecs.umich.edu            destElem += 0;
24197639Sgblack@eecs.umich.edu        } else if (imm) {
24207639Sgblack@eecs.umich.edu            Element rBit = bits(srcElem1, imm - 1);
24217639Sgblack@eecs.umich.edu            destElem += ((srcElem1 >> (imm - 1)) >> 1) + rBit;
24227639Sgblack@eecs.umich.edu        } else {
24237639Sgblack@eecs.umich.edu            destElem += srcElem1;
24247639Sgblack@eecs.umich.edu        }
24257639Sgblack@eecs.umich.edu    '''
24267760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vrsra", "NVrsraD", "SimdShiftAccOp", allTypes, 2, vrsraCode, True)
24277760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vrsra", "NVrsraQ", "SimdShiftAccOp", allTypes, 4, vrsraCode, True)
24287639Sgblack@eecs.umich.edu
24297639Sgblack@eecs.umich.edu    vsriCode = '''
24307639Sgblack@eecs.umich.edu        if (imm >= sizeof(Element) * 8)
24317639Sgblack@eecs.umich.edu            destElem = destElem;
24327639Sgblack@eecs.umich.edu        else
24337639Sgblack@eecs.umich.edu            destElem = (srcElem1 >> imm) |
24347639Sgblack@eecs.umich.edu                (destElem & ~mask(sizeof(Element) * 8 - imm));
24357639Sgblack@eecs.umich.edu    '''
24367760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vsri", "NVsriD", "SimdShiftOp", unsignedTypes, 2, vsriCode, True)
24377760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vsri", "NVsriQ", "SimdShiftOp", unsignedTypes, 4, vsriCode, True)
24387639Sgblack@eecs.umich.edu
24397639Sgblack@eecs.umich.edu    vshlCode = '''
24407639Sgblack@eecs.umich.edu        if (imm >= sizeof(Element) * 8)
24417639Sgblack@eecs.umich.edu            destElem = (srcElem1 << (sizeof(Element) * 8 - 1)) << 1;
24427639Sgblack@eecs.umich.edu        else
24437639Sgblack@eecs.umich.edu            destElem = srcElem1 << imm;
24447639Sgblack@eecs.umich.edu    '''
24457760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vshl", "NVshlD", "SimdShiftOp", unsignedTypes, 2, vshlCode)
24467760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vshl", "NVshlQ", "SimdShiftOp", unsignedTypes, 4, vshlCode)
24477639Sgblack@eecs.umich.edu
24487639Sgblack@eecs.umich.edu    vsliCode = '''
24497639Sgblack@eecs.umich.edu        if (imm >= sizeof(Element) * 8)
24507639Sgblack@eecs.umich.edu            destElem = destElem;
24517639Sgblack@eecs.umich.edu        else
24527639Sgblack@eecs.umich.edu            destElem = (srcElem1 << imm) | (destElem & mask(imm));
24537639Sgblack@eecs.umich.edu    '''
24547760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vsli", "NVsliD", "SimdShiftOp", unsignedTypes, 2, vsliCode, True)
24557760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vsli", "NVsliQ", "SimdShiftOp", unsignedTypes, 4, vsliCode, True)
24567639Sgblack@eecs.umich.edu
24577639Sgblack@eecs.umich.edu    vqshlCode = '''
24587783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
24597639Sgblack@eecs.umich.edu        if (imm >= sizeof(Element) * 8) {
24607639Sgblack@eecs.umich.edu            if (srcElem1 != 0) {
24617639Sgblack@eecs.umich.edu                destElem = (Element)1 << (sizeof(Element) * 8 - 1);
24627639Sgblack@eecs.umich.edu                if (srcElem1 > 0)
24637639Sgblack@eecs.umich.edu                    destElem = ~destElem;
24647639Sgblack@eecs.umich.edu                fpscr.qc = 1;
24657639Sgblack@eecs.umich.edu            } else {
24667639Sgblack@eecs.umich.edu                destElem = 0;
24677639Sgblack@eecs.umich.edu            }
24687639Sgblack@eecs.umich.edu        } else if (imm) {
24697639Sgblack@eecs.umich.edu            destElem = (srcElem1 << imm);
24707639Sgblack@eecs.umich.edu            uint64_t topBits = bits((uint64_t)srcElem1,
24717639Sgblack@eecs.umich.edu                                    sizeof(Element) * 8 - 1,
24727639Sgblack@eecs.umich.edu                                    sizeof(Element) * 8 - 1 - imm);
24737639Sgblack@eecs.umich.edu            if (topBits != 0 && topBits != mask(imm + 1)) {
24747639Sgblack@eecs.umich.edu                destElem = (Element)1 << (sizeof(Element) * 8 - 1);
24757639Sgblack@eecs.umich.edu                if (srcElem1 > 0)
24767639Sgblack@eecs.umich.edu                    destElem = ~destElem;
24777639Sgblack@eecs.umich.edu                fpscr.qc = 1;
24787639Sgblack@eecs.umich.edu            }
24797639Sgblack@eecs.umich.edu        } else {
24807639Sgblack@eecs.umich.edu            destElem = srcElem1;
24817639Sgblack@eecs.umich.edu        }
24827783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
24837639Sgblack@eecs.umich.edu    '''
24847760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vqshl", "NVqshlD", "SimdShiftOp", signedTypes, 2, vqshlCode)
24857760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vqshl", "NVqshlQ", "SimdShiftOp", signedTypes, 4, vqshlCode)
24867639Sgblack@eecs.umich.edu
24877639Sgblack@eecs.umich.edu    vqshluCode = '''
24887783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
24897639Sgblack@eecs.umich.edu        if (imm >= sizeof(Element) * 8) {
24907639Sgblack@eecs.umich.edu            if (srcElem1 != 0) {
24917639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8);
24927639Sgblack@eecs.umich.edu                fpscr.qc = 1;
24937639Sgblack@eecs.umich.edu            } else {
24947639Sgblack@eecs.umich.edu                destElem = 0;
24957639Sgblack@eecs.umich.edu            }
24967639Sgblack@eecs.umich.edu        } else if (imm) {
24977639Sgblack@eecs.umich.edu            destElem = (srcElem1 << imm);
24987639Sgblack@eecs.umich.edu            uint64_t topBits = bits((uint64_t)srcElem1,
24997639Sgblack@eecs.umich.edu                                    sizeof(Element) * 8 - 1,
25007639Sgblack@eecs.umich.edu                                    sizeof(Element) * 8 - imm);
25017639Sgblack@eecs.umich.edu            if (topBits != 0) {
25027639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8);
25037639Sgblack@eecs.umich.edu                fpscr.qc = 1;
25047639Sgblack@eecs.umich.edu            }
25057639Sgblack@eecs.umich.edu        } else {
25067639Sgblack@eecs.umich.edu            destElem = srcElem1;
25077639Sgblack@eecs.umich.edu        }
25087783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
25097639Sgblack@eecs.umich.edu    '''
25107760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vqshlu", "NVqshluD", "SimdShiftOp", unsignedTypes, 2, vqshluCode)
25117760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vqshlu", "NVqshluQ", "SimdShiftOp", unsignedTypes, 4, vqshluCode)
25127639Sgblack@eecs.umich.edu
25137639Sgblack@eecs.umich.edu    vqshlusCode = '''
25147783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
25157639Sgblack@eecs.umich.edu        if (imm >= sizeof(Element) * 8) {
25167639Sgblack@eecs.umich.edu            if (srcElem1 < 0) {
25177639Sgblack@eecs.umich.edu                destElem = 0;
25187639Sgblack@eecs.umich.edu                fpscr.qc = 1;
25197639Sgblack@eecs.umich.edu            } else if (srcElem1 > 0) {
25207639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8);
25217639Sgblack@eecs.umich.edu                fpscr.qc = 1;
25227639Sgblack@eecs.umich.edu            } else {
25237639Sgblack@eecs.umich.edu                destElem = 0;
25247639Sgblack@eecs.umich.edu            }
25257639Sgblack@eecs.umich.edu        } else if (imm) {
25267639Sgblack@eecs.umich.edu            destElem = (srcElem1 << imm);
25277639Sgblack@eecs.umich.edu            uint64_t topBits = bits((uint64_t)srcElem1,
25287639Sgblack@eecs.umich.edu                                    sizeof(Element) * 8 - 1,
25297639Sgblack@eecs.umich.edu                                    sizeof(Element) * 8 - imm);
25307639Sgblack@eecs.umich.edu            if (srcElem1 < 0) {
25317639Sgblack@eecs.umich.edu                destElem = 0;
25327639Sgblack@eecs.umich.edu                fpscr.qc = 1;
25337639Sgblack@eecs.umich.edu            } else if (topBits != 0) {
25347639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8);
25357639Sgblack@eecs.umich.edu                fpscr.qc = 1;
25367639Sgblack@eecs.umich.edu            }
25377639Sgblack@eecs.umich.edu        } else {
25387639Sgblack@eecs.umich.edu            if (srcElem1 < 0) {
25397639Sgblack@eecs.umich.edu                fpscr.qc = 1;
25407639Sgblack@eecs.umich.edu                destElem = 0;
25417639Sgblack@eecs.umich.edu            } else {
25427639Sgblack@eecs.umich.edu                destElem = srcElem1;
25437639Sgblack@eecs.umich.edu            }
25447639Sgblack@eecs.umich.edu        }
25457783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
25467639Sgblack@eecs.umich.edu    '''
25477760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vqshlus", "NVqshlusD", "SimdShiftOp", signedTypes, 2, vqshlusCode)
25487760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vqshlus", "NVqshlusQ", "SimdShiftOp", signedTypes, 4, vqshlusCode)
25497639Sgblack@eecs.umich.edu
25507639Sgblack@eecs.umich.edu    vshrnCode = '''
25517639Sgblack@eecs.umich.edu        if (imm >= sizeof(srcElem1) * 8) {
25527639Sgblack@eecs.umich.edu            destElem = 0;
25537639Sgblack@eecs.umich.edu        } else {
25547639Sgblack@eecs.umich.edu            destElem = srcElem1 >> imm;
25557639Sgblack@eecs.umich.edu        }
25567639Sgblack@eecs.umich.edu    '''
25577760SGiacomo.Gabrielli@arm.com    twoRegNarrowShiftInst("vshrn", "NVshrn", "SimdShiftOp", smallUnsignedTypes, vshrnCode)
25587639Sgblack@eecs.umich.edu
25597639Sgblack@eecs.umich.edu    vrshrnCode = '''
25607639Sgblack@eecs.umich.edu        if (imm > sizeof(srcElem1) * 8) {
25617639Sgblack@eecs.umich.edu            destElem = 0;
25627639Sgblack@eecs.umich.edu        } else if (imm) {
25637639Sgblack@eecs.umich.edu            Element rBit = bits(srcElem1, imm - 1);
25647639Sgblack@eecs.umich.edu            destElem = ((srcElem1 >> (imm - 1)) >> 1) + rBit;
25657639Sgblack@eecs.umich.edu        } else {
25667639Sgblack@eecs.umich.edu            destElem = srcElem1;
25677639Sgblack@eecs.umich.edu        }
25687639Sgblack@eecs.umich.edu    '''
25697760SGiacomo.Gabrielli@arm.com    twoRegNarrowShiftInst("vrshrn", "NVrshrn", "SimdShiftOp", smallUnsignedTypes, vrshrnCode)
25707639Sgblack@eecs.umich.edu
25717639Sgblack@eecs.umich.edu    vqshrnCode = '''
25727783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
25737639Sgblack@eecs.umich.edu        if (imm > sizeof(srcElem1) * 8) {
25747639Sgblack@eecs.umich.edu            if (srcElem1 != 0 && srcElem1 != -1)
25757639Sgblack@eecs.umich.edu                fpscr.qc = 1;
25767639Sgblack@eecs.umich.edu            destElem = 0;
25777639Sgblack@eecs.umich.edu        } else if (imm) {
25787639Sgblack@eecs.umich.edu            BigElement mid = ((srcElem1 >> (imm - 1)) >> 1);
25797639Sgblack@eecs.umich.edu            mid |= -(mid & ((BigElement)1 <<
25807639Sgblack@eecs.umich.edu                        (sizeof(BigElement) * 8 - 1 - imm)));
25817639Sgblack@eecs.umich.edu            if (mid != (Element)mid) {
25827639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8 - 1);
25837639Sgblack@eecs.umich.edu                if (srcElem1 < 0)
25847639Sgblack@eecs.umich.edu                    destElem = ~destElem;
25857639Sgblack@eecs.umich.edu                fpscr.qc = 1;
25867639Sgblack@eecs.umich.edu            } else {
25877639Sgblack@eecs.umich.edu                destElem = mid;
25887639Sgblack@eecs.umich.edu            }
25897639Sgblack@eecs.umich.edu        } else {
25907639Sgblack@eecs.umich.edu            destElem = srcElem1;
25917639Sgblack@eecs.umich.edu        }
25927783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
25937639Sgblack@eecs.umich.edu    '''
25947760SGiacomo.Gabrielli@arm.com    twoRegNarrowShiftInst("vqshrn", "NVqshrn", "SimdShiftOp", smallSignedTypes, vqshrnCode)
25957639Sgblack@eecs.umich.edu
25967639Sgblack@eecs.umich.edu    vqshrunCode = '''
25977783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
25987639Sgblack@eecs.umich.edu        if (imm > sizeof(srcElem1) * 8) {
25997639Sgblack@eecs.umich.edu            if (srcElem1 != 0)
26007639Sgblack@eecs.umich.edu                fpscr.qc = 1;
26017639Sgblack@eecs.umich.edu            destElem = 0;
26027639Sgblack@eecs.umich.edu        } else if (imm) {
26037639Sgblack@eecs.umich.edu            BigElement mid = ((srcElem1 >> (imm - 1)) >> 1);
26047639Sgblack@eecs.umich.edu            if (mid != (Element)mid) {
26057639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8);
26067639Sgblack@eecs.umich.edu                fpscr.qc = 1;
26077639Sgblack@eecs.umich.edu            } else {
26087639Sgblack@eecs.umich.edu                destElem = mid;
26097639Sgblack@eecs.umich.edu            }
26107639Sgblack@eecs.umich.edu        } else {
26117639Sgblack@eecs.umich.edu            destElem = srcElem1;
26127639Sgblack@eecs.umich.edu        }
26137783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
26147639Sgblack@eecs.umich.edu    '''
26157639Sgblack@eecs.umich.edu    twoRegNarrowShiftInst("vqshrun", "NVqshrun",
26167760SGiacomo.Gabrielli@arm.com                          "SimdShiftOp", smallUnsignedTypes, vqshrunCode)
26177639Sgblack@eecs.umich.edu
26187639Sgblack@eecs.umich.edu    vqshrunsCode = '''
26197783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
26207639Sgblack@eecs.umich.edu        if (imm > sizeof(srcElem1) * 8) {
26217639Sgblack@eecs.umich.edu            if (srcElem1 != 0)
26227639Sgblack@eecs.umich.edu                fpscr.qc = 1;
26237639Sgblack@eecs.umich.edu            destElem = 0;
26247639Sgblack@eecs.umich.edu        } else if (imm) {
26257639Sgblack@eecs.umich.edu            BigElement mid = ((srcElem1 >> (imm - 1)) >> 1);
26267639Sgblack@eecs.umich.edu            if (bits(mid, sizeof(BigElement) * 8 - 1,
26277639Sgblack@eecs.umich.edu                          sizeof(Element) * 8) != 0) {
26287639Sgblack@eecs.umich.edu                if (srcElem1 < 0) {
26297639Sgblack@eecs.umich.edu                    destElem = 0;
26307639Sgblack@eecs.umich.edu                } else {
26317639Sgblack@eecs.umich.edu                    destElem = mask(sizeof(Element) * 8);
26327639Sgblack@eecs.umich.edu                }
26337639Sgblack@eecs.umich.edu                fpscr.qc = 1;
26347639Sgblack@eecs.umich.edu            } else {
26357639Sgblack@eecs.umich.edu                destElem = mid;
26367639Sgblack@eecs.umich.edu            }
26377639Sgblack@eecs.umich.edu        } else {
26387639Sgblack@eecs.umich.edu            destElem = srcElem1;
26397639Sgblack@eecs.umich.edu        }
26407783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
26417639Sgblack@eecs.umich.edu    '''
26427639Sgblack@eecs.umich.edu    twoRegNarrowShiftInst("vqshrun", "NVqshruns",
26437760SGiacomo.Gabrielli@arm.com                          "SimdShiftOp", smallSignedTypes, vqshrunsCode)
26447639Sgblack@eecs.umich.edu
26457639Sgblack@eecs.umich.edu    vqrshrnCode = '''
26467783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
26477639Sgblack@eecs.umich.edu        if (imm > sizeof(srcElem1) * 8) {
26487639Sgblack@eecs.umich.edu            if (srcElem1 != 0 && srcElem1 != -1)
26497639Sgblack@eecs.umich.edu                fpscr.qc = 1;
26507639Sgblack@eecs.umich.edu            destElem = 0;
26517639Sgblack@eecs.umich.edu        } else if (imm) {
26527639Sgblack@eecs.umich.edu            BigElement mid = (srcElem1 >> (imm - 1));
26537639Sgblack@eecs.umich.edu            uint64_t rBit = mid & 0x1;
26547639Sgblack@eecs.umich.edu            mid >>= 1;
26557639Sgblack@eecs.umich.edu            mid |= -(mid & ((BigElement)1 <<
26567639Sgblack@eecs.umich.edu                        (sizeof(BigElement) * 8 - 1 - imm)));
26577639Sgblack@eecs.umich.edu            mid += rBit;
26587639Sgblack@eecs.umich.edu            if (mid != (Element)mid) {
26597639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8 - 1);
26607639Sgblack@eecs.umich.edu                if (srcElem1 < 0)
26617639Sgblack@eecs.umich.edu                    destElem = ~destElem;
26627639Sgblack@eecs.umich.edu                fpscr.qc = 1;
26637639Sgblack@eecs.umich.edu            } else {
26647639Sgblack@eecs.umich.edu                destElem = mid;
26657639Sgblack@eecs.umich.edu            }
26667639Sgblack@eecs.umich.edu        } else {
26677639Sgblack@eecs.umich.edu            if (srcElem1 != (Element)srcElem1) {
26687639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8 - 1);
26697639Sgblack@eecs.umich.edu                if (srcElem1 < 0)
26707639Sgblack@eecs.umich.edu                    destElem = ~destElem;
26717639Sgblack@eecs.umich.edu                fpscr.qc = 1;
26727639Sgblack@eecs.umich.edu            } else {
26737639Sgblack@eecs.umich.edu                destElem = srcElem1;
26747639Sgblack@eecs.umich.edu            }
26757639Sgblack@eecs.umich.edu        }
26767783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
26777639Sgblack@eecs.umich.edu    '''
26787639Sgblack@eecs.umich.edu    twoRegNarrowShiftInst("vqrshrn", "NVqrshrn",
26797760SGiacomo.Gabrielli@arm.com                          "SimdShiftOp", smallSignedTypes, vqrshrnCode)
26807639Sgblack@eecs.umich.edu
26817639Sgblack@eecs.umich.edu    vqrshrunCode = '''
26827783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
26837639Sgblack@eecs.umich.edu        if (imm > sizeof(srcElem1) * 8) {
26847639Sgblack@eecs.umich.edu            if (srcElem1 != 0)
26857639Sgblack@eecs.umich.edu                fpscr.qc = 1;
26867639Sgblack@eecs.umich.edu            destElem = 0;
26877639Sgblack@eecs.umich.edu        } else if (imm) {
26887639Sgblack@eecs.umich.edu            BigElement mid = (srcElem1 >> (imm - 1));
26897639Sgblack@eecs.umich.edu            uint64_t rBit = mid & 0x1;
26907639Sgblack@eecs.umich.edu            mid >>= 1;
26917639Sgblack@eecs.umich.edu            mid += rBit;
26927639Sgblack@eecs.umich.edu            if (mid != (Element)mid) {
26937639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8);
26947639Sgblack@eecs.umich.edu                fpscr.qc = 1;
26957639Sgblack@eecs.umich.edu            } else {
26967639Sgblack@eecs.umich.edu                destElem = mid;
26977639Sgblack@eecs.umich.edu            }
26987639Sgblack@eecs.umich.edu        } else {
26997639Sgblack@eecs.umich.edu            if (srcElem1 != (Element)srcElem1) {
27007639Sgblack@eecs.umich.edu                destElem = mask(sizeof(Element) * 8 - 1);
27017639Sgblack@eecs.umich.edu                fpscr.qc = 1;
27027639Sgblack@eecs.umich.edu            } else {
27037639Sgblack@eecs.umich.edu                destElem = srcElem1;
27047639Sgblack@eecs.umich.edu            }
27057639Sgblack@eecs.umich.edu        }
27067783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
27077639Sgblack@eecs.umich.edu    '''
27087639Sgblack@eecs.umich.edu    twoRegNarrowShiftInst("vqrshrun", "NVqrshrun",
27097760SGiacomo.Gabrielli@arm.com                          "SimdShiftOp", smallUnsignedTypes, vqrshrunCode)
27107639Sgblack@eecs.umich.edu
27117639Sgblack@eecs.umich.edu    vqrshrunsCode = '''
27127783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
27137639Sgblack@eecs.umich.edu        if (imm > sizeof(srcElem1) * 8) {
27147639Sgblack@eecs.umich.edu            if (srcElem1 != 0)
27157639Sgblack@eecs.umich.edu                fpscr.qc = 1;
27167639Sgblack@eecs.umich.edu            destElem = 0;
27177639Sgblack@eecs.umich.edu        } else if (imm) {
27187639Sgblack@eecs.umich.edu            BigElement mid = (srcElem1 >> (imm - 1));
27197639Sgblack@eecs.umich.edu            uint64_t rBit = mid & 0x1;
27207639Sgblack@eecs.umich.edu            mid >>= 1;
27217639Sgblack@eecs.umich.edu            mid |= -(mid & ((BigElement)1 <<
27227639Sgblack@eecs.umich.edu                            (sizeof(BigElement) * 8 - 1 - imm)));
27237639Sgblack@eecs.umich.edu            mid += rBit;
27247639Sgblack@eecs.umich.edu            if (bits(mid, sizeof(BigElement) * 8 - 1,
27257639Sgblack@eecs.umich.edu                          sizeof(Element) * 8) != 0) {
27267639Sgblack@eecs.umich.edu                if (srcElem1 < 0) {
27277639Sgblack@eecs.umich.edu                    destElem = 0;
27287639Sgblack@eecs.umich.edu                } else {
27297639Sgblack@eecs.umich.edu                    destElem = mask(sizeof(Element) * 8);
27307639Sgblack@eecs.umich.edu                }
27317639Sgblack@eecs.umich.edu                fpscr.qc = 1;
27327639Sgblack@eecs.umich.edu            } else {
27337639Sgblack@eecs.umich.edu                destElem = mid;
27347639Sgblack@eecs.umich.edu            }
27357639Sgblack@eecs.umich.edu        } else {
27367639Sgblack@eecs.umich.edu            if (srcElem1 < 0) {
27377639Sgblack@eecs.umich.edu                fpscr.qc = 1;
27387639Sgblack@eecs.umich.edu                destElem = 0;
27397639Sgblack@eecs.umich.edu            } else {
27407639Sgblack@eecs.umich.edu                destElem = srcElem1;
27417639Sgblack@eecs.umich.edu            }
27427639Sgblack@eecs.umich.edu        }
27437783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
27447639Sgblack@eecs.umich.edu    '''
27457639Sgblack@eecs.umich.edu    twoRegNarrowShiftInst("vqrshrun", "NVqrshruns",
27467760SGiacomo.Gabrielli@arm.com                          "SimdShiftOp", smallSignedTypes, vqrshrunsCode)
27477639Sgblack@eecs.umich.edu
27487639Sgblack@eecs.umich.edu    vshllCode = '''
27497639Sgblack@eecs.umich.edu        if (imm >= sizeof(destElem) * 8) {
27507639Sgblack@eecs.umich.edu            destElem = 0;
27517639Sgblack@eecs.umich.edu        } else {
27527639Sgblack@eecs.umich.edu            destElem = (BigElement)srcElem1 << imm;
27537639Sgblack@eecs.umich.edu        }
27547639Sgblack@eecs.umich.edu    '''
27557760SGiacomo.Gabrielli@arm.com    twoRegLongShiftInst("vshll", "NVshll", "SimdShiftOp", smallTypes, vshllCode)
27567639Sgblack@eecs.umich.edu
27577639Sgblack@eecs.umich.edu    vmovlCode = '''
27587639Sgblack@eecs.umich.edu        destElem = srcElem1;
27597639Sgblack@eecs.umich.edu    '''
27607760SGiacomo.Gabrielli@arm.com    twoRegLongShiftInst("vmovl", "NVmovl", "SimdMiscOp", smallTypes, vmovlCode)
27617639Sgblack@eecs.umich.edu
27627639Sgblack@eecs.umich.edu    vcvt2ufxCode = '''
27637783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
27647639Sgblack@eecs.umich.edu        if (flushToZero(srcElem1))
27657639Sgblack@eecs.umich.edu            fpscr.idc = 1;
27667639Sgblack@eecs.umich.edu        VfpSavedState state = prepFpState(VfpRoundNearest);
27677639Sgblack@eecs.umich.edu        __asm__ __volatile__("" : "=m" (srcElem1) : "m" (srcElem1));
27687639Sgblack@eecs.umich.edu        destReg = vfpFpSToFixed(srcElem1, false, false, imm);
27697639Sgblack@eecs.umich.edu        __asm__ __volatile__("" :: "m" (destReg));
27707639Sgblack@eecs.umich.edu        finishVfp(fpscr, state, true);
27717783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
27727639Sgblack@eecs.umich.edu    '''
27737760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vcvt", "NVcvt2ufxD", "SimdCvtOp", ("float",),
27747639Sgblack@eecs.umich.edu            2, vcvt2ufxCode, toInt = True)
27757760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vcvt", "NVcvt2ufxQ", "SimdCvtOp", ("float",),
27767639Sgblack@eecs.umich.edu            4, vcvt2ufxCode, toInt = True)
27777639Sgblack@eecs.umich.edu
27787639Sgblack@eecs.umich.edu    vcvt2sfxCode = '''
27797783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
27807639Sgblack@eecs.umich.edu        if (flushToZero(srcElem1))
27817639Sgblack@eecs.umich.edu            fpscr.idc = 1;
27827639Sgblack@eecs.umich.edu        VfpSavedState state = prepFpState(VfpRoundNearest);
27837639Sgblack@eecs.umich.edu        __asm__ __volatile__("" : "=m" (srcElem1) : "m" (srcElem1));
27847639Sgblack@eecs.umich.edu        destReg = vfpFpSToFixed(srcElem1, true, false, imm);
27857639Sgblack@eecs.umich.edu        __asm__ __volatile__("" :: "m" (destReg));
27867639Sgblack@eecs.umich.edu        finishVfp(fpscr, state, true);
27877783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
27887639Sgblack@eecs.umich.edu    '''
27897760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vcvt", "NVcvt2sfxD", "SimdCvtOp", ("float",),
27907639Sgblack@eecs.umich.edu            2, vcvt2sfxCode, toInt = True)
27917760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vcvt", "NVcvt2sfxQ", "SimdCvtOp", ("float",),
27927639Sgblack@eecs.umich.edu            4, vcvt2sfxCode, toInt = True)
27937639Sgblack@eecs.umich.edu
27947639Sgblack@eecs.umich.edu    vcvtu2fpCode = '''
27957783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
27967639Sgblack@eecs.umich.edu        VfpSavedState state = prepFpState(VfpRoundNearest);
27977639Sgblack@eecs.umich.edu        __asm__ __volatile__("" : "=m" (srcReg1) : "m" (srcReg1));
27987639Sgblack@eecs.umich.edu        destElem = vfpUFixedToFpS(true, true, srcReg1, false, imm);
27997639Sgblack@eecs.umich.edu        __asm__ __volatile__("" :: "m" (destElem));
28007639Sgblack@eecs.umich.edu        finishVfp(fpscr, state, true);
28017783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
28027639Sgblack@eecs.umich.edu    '''
28037760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vcvt", "NVcvtu2fpD", "SimdCvtOp", ("float",),
28047639Sgblack@eecs.umich.edu            2, vcvtu2fpCode, fromInt = True)
28057760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vcvt", "NVcvtu2fpQ", "SimdCvtOp", ("float",),
28067639Sgblack@eecs.umich.edu            4, vcvtu2fpCode, fromInt = True)
28077639Sgblack@eecs.umich.edu
28087639Sgblack@eecs.umich.edu    vcvts2fpCode = '''
28097783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
28107639Sgblack@eecs.umich.edu        VfpSavedState state = prepFpState(VfpRoundNearest);
28117639Sgblack@eecs.umich.edu        __asm__ __volatile__("" : "=m" (srcReg1) : "m" (srcReg1));
28127639Sgblack@eecs.umich.edu        destElem = vfpSFixedToFpS(true, true, srcReg1, false, imm);
28137639Sgblack@eecs.umich.edu        __asm__ __volatile__("" :: "m" (destElem));
28147639Sgblack@eecs.umich.edu        finishVfp(fpscr, state, true);
28157783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
28167639Sgblack@eecs.umich.edu    '''
28177760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vcvt", "NVcvts2fpD", "SimdCvtOp", ("float",),
28187639Sgblack@eecs.umich.edu            2, vcvts2fpCode, fromInt = True)
28197760SGiacomo.Gabrielli@arm.com    twoRegShiftInst("vcvt", "NVcvts2fpQ", "SimdCvtOp", ("float",),
28207639Sgblack@eecs.umich.edu            4, vcvts2fpCode, fromInt = True)
28217639Sgblack@eecs.umich.edu
28227639Sgblack@eecs.umich.edu    vcvts2hCode = '''
28239557Sandreas.hansson@arm.com        destElem = 0;
28247783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
28257639Sgblack@eecs.umich.edu        float srcFp1 = bitsToFp(srcElem1, (float)0.0);
28267639Sgblack@eecs.umich.edu        if (flushToZero(srcFp1))
28277639Sgblack@eecs.umich.edu            fpscr.idc = 1;
28287639Sgblack@eecs.umich.edu        VfpSavedState state = prepFpState(VfpRoundNearest);
28297639Sgblack@eecs.umich.edu        __asm__ __volatile__("" : "=m" (srcFp1), "=m" (destElem)
28307639Sgblack@eecs.umich.edu                                : "m" (srcFp1), "m" (destElem));
28317639Sgblack@eecs.umich.edu        destElem = vcvtFpSFpH(fpscr, true, true, VfpRoundNearest,
28327639Sgblack@eecs.umich.edu                              fpscr.ahp, srcFp1);
28337639Sgblack@eecs.umich.edu        __asm__ __volatile__("" :: "m" (destElem));
28347639Sgblack@eecs.umich.edu        finishVfp(fpscr, state, true);
28357783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
28367639Sgblack@eecs.umich.edu    '''
28377760SGiacomo.Gabrielli@arm.com    twoRegNarrowMiscInst("vcvt", "NVcvts2h", "SimdCvtOp", ("uint16_t",), vcvts2hCode)
28387639Sgblack@eecs.umich.edu
28397639Sgblack@eecs.umich.edu    vcvth2sCode = '''
28409557Sandreas.hansson@arm.com        destElem = 0;
28417783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
28427639Sgblack@eecs.umich.edu        VfpSavedState state = prepFpState(VfpRoundNearest);
28437639Sgblack@eecs.umich.edu        __asm__ __volatile__("" : "=m" (srcElem1), "=m" (destElem)
28447639Sgblack@eecs.umich.edu                                : "m" (srcElem1), "m" (destElem));
28457639Sgblack@eecs.umich.edu        destElem = fpToBits(vcvtFpHFpS(fpscr, true, fpscr.ahp, srcElem1));
28467639Sgblack@eecs.umich.edu        __asm__ __volatile__("" :: "m" (destElem));
28477639Sgblack@eecs.umich.edu        finishVfp(fpscr, state, true);
28487783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
28497639Sgblack@eecs.umich.edu    '''
28507760SGiacomo.Gabrielli@arm.com    twoRegLongMiscInst("vcvt", "NVcvth2s", "SimdCvtOp", ("uint16_t",), vcvth2sCode)
28517639Sgblack@eecs.umich.edu
28527639Sgblack@eecs.umich.edu    vrsqrteCode = '''
28537639Sgblack@eecs.umich.edu        destElem = unsignedRSqrtEstimate(srcElem1);
28547639Sgblack@eecs.umich.edu    '''
28557760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vrsqrte", "NVrsqrteD", "SimdSqrtOp", ("uint32_t",), 2, vrsqrteCode)
28567760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vrsqrte", "NVrsqrteQ", "SimdSqrtOp", ("uint32_t",), 4, vrsqrteCode)
28577639Sgblack@eecs.umich.edu
28587639Sgblack@eecs.umich.edu    vrsqrtefpCode = '''
28597783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
28607639Sgblack@eecs.umich.edu        if (flushToZero(srcReg1))
28617639Sgblack@eecs.umich.edu            fpscr.idc = 1;
28627639Sgblack@eecs.umich.edu        destReg = fprSqrtEstimate(fpscr, srcReg1);
28637783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
28647639Sgblack@eecs.umich.edu    '''
28657760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vrsqrte", "NVrsqrteDFp", "SimdFloatSqrtOp", ("float",), 2, vrsqrtefpCode)
28667760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vrsqrte", "NVrsqrteQFp", "SimdFloatSqrtOp", ("float",), 4, vrsqrtefpCode)
28677639Sgblack@eecs.umich.edu
28687639Sgblack@eecs.umich.edu    vrecpeCode = '''
28697639Sgblack@eecs.umich.edu        destElem = unsignedRecipEstimate(srcElem1);
28707639Sgblack@eecs.umich.edu    '''
28717760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vrecpe", "NVrecpeD", "SimdMultAccOp", ("uint32_t",), 2, vrecpeCode)
28727760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vrecpe", "NVrecpeQ", "SimdMultAccOp", ("uint32_t",), 4, vrecpeCode)
28737639Sgblack@eecs.umich.edu
28747639Sgblack@eecs.umich.edu    vrecpefpCode = '''
28757783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
28767639Sgblack@eecs.umich.edu        if (flushToZero(srcReg1))
28777639Sgblack@eecs.umich.edu            fpscr.idc = 1;
28787639Sgblack@eecs.umich.edu        destReg = fpRecipEstimate(fpscr, srcReg1);
28797783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
28807639Sgblack@eecs.umich.edu    '''
28817760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vrecpe", "NVrecpeDFp", "SimdFloatMultAccOp", ("float",), 2, vrecpefpCode)
28827760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vrecpe", "NVrecpeQFp", "SimdFloatMultAccOp", ("float",), 4, vrecpefpCode)
28837639Sgblack@eecs.umich.edu
28847639Sgblack@eecs.umich.edu    vrev16Code = '''
28857639Sgblack@eecs.umich.edu        destElem = srcElem1;
28867639Sgblack@eecs.umich.edu        unsigned groupSize = ((1 << 1) / sizeof(Element));
28877639Sgblack@eecs.umich.edu        unsigned reverseMask = (groupSize - 1);
28887639Sgblack@eecs.umich.edu        j = i ^ reverseMask;
28897639Sgblack@eecs.umich.edu    '''
28907760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vrev16", "NVrev16D", "SimdAluOp", ("uint8_t",), 2, vrev16Code)
28917760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vrev16", "NVrev16Q", "SimdAluOp", ("uint8_t",), 4, vrev16Code)
28927639Sgblack@eecs.umich.edu    vrev32Code = '''
28937639Sgblack@eecs.umich.edu        destElem = srcElem1;
28947639Sgblack@eecs.umich.edu        unsigned groupSize = ((1 << 2) / sizeof(Element));
28957639Sgblack@eecs.umich.edu        unsigned reverseMask = (groupSize - 1);
28967639Sgblack@eecs.umich.edu        j = i ^ reverseMask;
28977639Sgblack@eecs.umich.edu    '''
28987639Sgblack@eecs.umich.edu    twoRegMiscInst("vrev32", "NVrev32D",
28997760SGiacomo.Gabrielli@arm.com            "SimdAluOp", ("uint8_t", "uint16_t"), 2, vrev32Code)
29007639Sgblack@eecs.umich.edu    twoRegMiscInst("vrev32", "NVrev32Q",
29017760SGiacomo.Gabrielli@arm.com            "SimdAluOp", ("uint8_t", "uint16_t"), 4, vrev32Code)
29027639Sgblack@eecs.umich.edu    vrev64Code = '''
29037639Sgblack@eecs.umich.edu        destElem = srcElem1;
29047639Sgblack@eecs.umich.edu        unsigned groupSize = ((1 << 3) / sizeof(Element));
29057639Sgblack@eecs.umich.edu        unsigned reverseMask = (groupSize - 1);
29067639Sgblack@eecs.umich.edu        j = i ^ reverseMask;
29077639Sgblack@eecs.umich.edu    '''
29087760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vrev64", "NVrev64D", "SimdAluOp", smallUnsignedTypes, 2, vrev64Code)
29097760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vrev64", "NVrev64Q", "SimdAluOp", smallUnsignedTypes, 4, vrev64Code)
29107639Sgblack@eecs.umich.edu
29117639Sgblack@eecs.umich.edu    vpaddlCode = '''
29127639Sgblack@eecs.umich.edu        destElem = (BigElement)srcElem1 + (BigElement)srcElem2;
29137639Sgblack@eecs.umich.edu    '''
29147760SGiacomo.Gabrielli@arm.com    twoRegCondenseInst("vpaddl", "NVpaddlD", "SimdAddOp", smallTypes, 2, vpaddlCode)
29157760SGiacomo.Gabrielli@arm.com    twoRegCondenseInst("vpaddl", "NVpaddlQ", "SimdAddOp", smallTypes, 4, vpaddlCode)
29167639Sgblack@eecs.umich.edu
29177639Sgblack@eecs.umich.edu    vpadalCode = '''
29187639Sgblack@eecs.umich.edu        destElem += (BigElement)srcElem1 + (BigElement)srcElem2;
29197639Sgblack@eecs.umich.edu    '''
29207760SGiacomo.Gabrielli@arm.com    twoRegCondenseInst("vpadal", "NVpadalD", "SimdAddAccOp", smallTypes, 2, vpadalCode, True)
29217760SGiacomo.Gabrielli@arm.com    twoRegCondenseInst("vpadal", "NVpadalQ", "SimdAddAccOp", smallTypes, 4, vpadalCode, True)
29227639Sgblack@eecs.umich.edu
29237639Sgblack@eecs.umich.edu    vclsCode = '''
29247639Sgblack@eecs.umich.edu        unsigned count = 0;
29257639Sgblack@eecs.umich.edu        if (srcElem1 < 0) {
29267639Sgblack@eecs.umich.edu            srcElem1 <<= 1;
29277639Sgblack@eecs.umich.edu            while (srcElem1 < 0 && count < sizeof(Element) * 8 - 1) {
29287639Sgblack@eecs.umich.edu                count++;
29297639Sgblack@eecs.umich.edu                srcElem1 <<= 1;
29307639Sgblack@eecs.umich.edu            }
29317639Sgblack@eecs.umich.edu        } else {
29327639Sgblack@eecs.umich.edu            srcElem1 <<= 1;
29337639Sgblack@eecs.umich.edu            while (srcElem1 >= 0 && count < sizeof(Element) * 8 - 1) {
29347639Sgblack@eecs.umich.edu                count++;
29357639Sgblack@eecs.umich.edu                srcElem1 <<= 1;
29367639Sgblack@eecs.umich.edu            }
29377639Sgblack@eecs.umich.edu        }
29387639Sgblack@eecs.umich.edu        destElem = count;
29397639Sgblack@eecs.umich.edu    '''
29407760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcls", "NVclsD", "SimdAluOp", signedTypes, 2, vclsCode)
29417760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcls", "NVclsQ", "SimdAluOp", signedTypes, 4, vclsCode)
29427639Sgblack@eecs.umich.edu
29437639Sgblack@eecs.umich.edu    vclzCode = '''
29447639Sgblack@eecs.umich.edu        unsigned count = 0;
29457639Sgblack@eecs.umich.edu        while (srcElem1 >= 0 && count < sizeof(Element) * 8) {
29467639Sgblack@eecs.umich.edu            count++;
29477639Sgblack@eecs.umich.edu            srcElem1 <<= 1;
29487639Sgblack@eecs.umich.edu        }
29497639Sgblack@eecs.umich.edu        destElem = count;
29507639Sgblack@eecs.umich.edu    '''
29517760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vclz", "NVclzD", "SimdAluOp", signedTypes, 2, vclzCode)
29527760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vclz", "NVclzQ", "SimdAluOp", signedTypes, 4, vclzCode)
29537639Sgblack@eecs.umich.edu
29547639Sgblack@eecs.umich.edu    vcntCode = '''
29557639Sgblack@eecs.umich.edu        unsigned count = 0;
29567639Sgblack@eecs.umich.edu        while (srcElem1 && count < sizeof(Element) * 8) {
29577639Sgblack@eecs.umich.edu            count += srcElem1 & 0x1;
29587639Sgblack@eecs.umich.edu            srcElem1 >>= 1;
29597639Sgblack@eecs.umich.edu        }
29607639Sgblack@eecs.umich.edu        destElem = count;
29617639Sgblack@eecs.umich.edu    '''
29627760SGiacomo.Gabrielli@arm.com
29637760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcnt", "NVcntD", "SimdAluOp", unsignedTypes, 2, vcntCode)
29647760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcnt", "NVcntQ", "SimdAluOp", unsignedTypes, 4, vcntCode)
29657639Sgblack@eecs.umich.edu
29667639Sgblack@eecs.umich.edu    vmvnCode = '''
29677639Sgblack@eecs.umich.edu        destElem = ~srcElem1;
29687639Sgblack@eecs.umich.edu    '''
29697760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vmvn", "NVmvnD", "SimdAluOp", ("uint64_t",), 2, vmvnCode)
29707760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vmvn", "NVmvnQ", "SimdAluOp", ("uint64_t",), 4, vmvnCode)
29717639Sgblack@eecs.umich.edu
29727639Sgblack@eecs.umich.edu    vqabsCode = '''
29737783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
29747639Sgblack@eecs.umich.edu        if (srcElem1 == (Element)((Element)1 << (sizeof(Element) * 8 - 1))) {
29757639Sgblack@eecs.umich.edu            fpscr.qc = 1;
29767639Sgblack@eecs.umich.edu            destElem = ~srcElem1;
29777639Sgblack@eecs.umich.edu        } else if (srcElem1 < 0) {
29787639Sgblack@eecs.umich.edu            destElem = -srcElem1;
29797639Sgblack@eecs.umich.edu        } else {
29807639Sgblack@eecs.umich.edu            destElem = srcElem1;
29817639Sgblack@eecs.umich.edu        }
29827783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
29837639Sgblack@eecs.umich.edu    '''
29847760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vqabs", "NVqabsD", "SimdAluOp", signedTypes, 2, vqabsCode)
29857760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vqabs", "NVqabsQ", "SimdAluOp", signedTypes, 4, vqabsCode)
29867639Sgblack@eecs.umich.edu
29877639Sgblack@eecs.umich.edu    vqnegCode = '''
29887783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrQc;
29897639Sgblack@eecs.umich.edu        if (srcElem1 == (Element)((Element)1 << (sizeof(Element) * 8 - 1))) {
29907639Sgblack@eecs.umich.edu            fpscr.qc = 1;
29917639Sgblack@eecs.umich.edu            destElem = ~srcElem1;
29927639Sgblack@eecs.umich.edu        } else {
29937639Sgblack@eecs.umich.edu            destElem = -srcElem1;
29947639Sgblack@eecs.umich.edu        }
29957783SGiacomo.Gabrielli@arm.com        FpscrQc = fpscr;
29967639Sgblack@eecs.umich.edu    '''
29977760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vqneg", "NVqnegD", "SimdAluOp", signedTypes, 2, vqnegCode)
29987760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vqneg", "NVqnegQ", "SimdAluOp", signedTypes, 4, vqnegCode)
29997639Sgblack@eecs.umich.edu
30007639Sgblack@eecs.umich.edu    vabsCode = '''
30017639Sgblack@eecs.umich.edu        if (srcElem1 < 0) {
30027639Sgblack@eecs.umich.edu            destElem = -srcElem1;
30037639Sgblack@eecs.umich.edu        } else {
30047639Sgblack@eecs.umich.edu            destElem = srcElem1;
30057639Sgblack@eecs.umich.edu        }
30067639Sgblack@eecs.umich.edu    '''
30077760SGiacomo.Gabrielli@arm.com
30087760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vabs", "NVabsD", "SimdAluOp", signedTypes, 2, vabsCode)
30097760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vabs", "NVabsQ", "SimdAluOp", signedTypes, 4, vabsCode)
30107639Sgblack@eecs.umich.edu    vabsfpCode = '''
30117639Sgblack@eecs.umich.edu        union
30127639Sgblack@eecs.umich.edu        {
30137639Sgblack@eecs.umich.edu            uint32_t i;
30147639Sgblack@eecs.umich.edu            float f;
30157639Sgblack@eecs.umich.edu        } cStruct;
30167639Sgblack@eecs.umich.edu        cStruct.f = srcReg1;
30177639Sgblack@eecs.umich.edu        cStruct.i &= mask(sizeof(Element) * 8 - 1);
30187639Sgblack@eecs.umich.edu        destReg = cStruct.f;
30197639Sgblack@eecs.umich.edu    '''
30207760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vabs", "NVabsDFp", "SimdFloatAluOp", ("float",), 2, vabsfpCode)
30217760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vabs", "NVabsQFp", "SimdFloatAluOp", ("float",), 4, vabsfpCode)
30227639Sgblack@eecs.umich.edu
30237639Sgblack@eecs.umich.edu    vnegCode = '''
30247639Sgblack@eecs.umich.edu        destElem = -srcElem1;
30257639Sgblack@eecs.umich.edu    '''
30267760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vneg", "NVnegD", "SimdAluOp", signedTypes, 2, vnegCode)
30277760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vneg", "NVnegQ", "SimdAluOp", signedTypes, 4, vnegCode)
30287639Sgblack@eecs.umich.edu    vnegfpCode = '''
30297639Sgblack@eecs.umich.edu        destReg = -srcReg1;
30307639Sgblack@eecs.umich.edu    '''
30317760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vneg", "NVnegDFp", "SimdFloatAluOp", ("float",), 2, vnegfpCode)
30327760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vneg", "NVnegQFp", "SimdFloatAluOp", ("float",), 4, vnegfpCode)
30337639Sgblack@eecs.umich.edu
30347639Sgblack@eecs.umich.edu    vcgtCode = 'destElem = (srcElem1 > 0) ? mask(sizeof(Element) * 8) : 0;'
30357760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcgt", "NVcgtD", "SimdCmpOp", signedTypes, 2, vcgtCode)
30367760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcgt", "NVcgtQ", "SimdCmpOp", signedTypes, 4, vcgtCode)
30377639Sgblack@eecs.umich.edu    vcgtfpCode = '''
30387783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
30397639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, (FloatReg)0.0, vcgtFunc,
30407639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
30417639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
30427639Sgblack@eecs.umich.edu        if (res == 2.0)
30437639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
30447783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
30457639Sgblack@eecs.umich.edu    '''
30467760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vcgt", "NVcgtDFp", "SimdFloatCmpOp", ("float",),
30477639Sgblack@eecs.umich.edu            2, vcgtfpCode, toInt = True)
30487760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vcgt", "NVcgtQFp", "SimdFloatCmpOp", ("float",),
30497639Sgblack@eecs.umich.edu            4, vcgtfpCode, toInt = True)
30507639Sgblack@eecs.umich.edu
30517639Sgblack@eecs.umich.edu    vcgeCode = 'destElem = (srcElem1 >= 0) ? mask(sizeof(Element) * 8) : 0;'
30527760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcge", "NVcgeD", "SimdCmpOp", signedTypes, 2, vcgeCode)
30537760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcge", "NVcgeQ", "SimdCmpOp", signedTypes, 4, vcgeCode)
30547639Sgblack@eecs.umich.edu    vcgefpCode = '''
30557783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
30567639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, (FloatReg)0.0, vcgeFunc,
30577639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
30587639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
30597639Sgblack@eecs.umich.edu        if (res == 2.0)
30607639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
30617783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
30627639Sgblack@eecs.umich.edu    '''
30637760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vcge", "NVcgeDFp", "SimdFloatCmpOp", ("float",),
30647639Sgblack@eecs.umich.edu            2, vcgefpCode, toInt = True)
30657760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vcge", "NVcgeQFp", "SimdFloatCmpOp", ("float",),
30667639Sgblack@eecs.umich.edu            4, vcgefpCode, toInt = True)
30677639Sgblack@eecs.umich.edu
30687639Sgblack@eecs.umich.edu    vceqCode = 'destElem = (srcElem1 == 0) ? mask(sizeof(Element) * 8) : 0;'
30697760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vceq", "NVceqD", "SimdCmpOp", signedTypes, 2, vceqCode)
30707760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vceq", "NVceqQ", "SimdCmpOp", signedTypes, 4, vceqCode)
30717639Sgblack@eecs.umich.edu    vceqfpCode = '''
30727783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
30737639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, (FloatReg)0.0, vceqFunc,
30747639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
30757639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
30767639Sgblack@eecs.umich.edu        if (res == 2.0)
30777639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
30787783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
30797639Sgblack@eecs.umich.edu    '''
30807760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vceq", "NVceqDFp", "SimdFloatCmpOp", ("float",),
30817639Sgblack@eecs.umich.edu            2, vceqfpCode, toInt = True)
30827760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vceq", "NVceqQFp", "SimdFloatCmpOp", ("float",),
30837639Sgblack@eecs.umich.edu            4, vceqfpCode, toInt = True)
30847639Sgblack@eecs.umich.edu
30857639Sgblack@eecs.umich.edu    vcleCode = 'destElem = (srcElem1 <= 0) ? mask(sizeof(Element) * 8) : 0;'
30867760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcle", "NVcleD", "SimdCmpOp", signedTypes, 2, vcleCode)
30877760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vcle", "NVcleQ", "SimdCmpOp", signedTypes, 4, vcleCode)
30887639Sgblack@eecs.umich.edu    vclefpCode = '''
30897783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
30907639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, (FloatReg)0.0, vcleFunc,
30917639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
30927639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
30937639Sgblack@eecs.umich.edu        if (res == 2.0)
30947639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
30957783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
30967639Sgblack@eecs.umich.edu    '''
30977760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vcle", "NVcleDFp", "SimdFloatCmpOp", ("float",),
30987639Sgblack@eecs.umich.edu            2, vclefpCode, toInt = True)
30997760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vcle", "NVcleQFp", "SimdFloatCmpOp", ("float",),
31007639Sgblack@eecs.umich.edu            4, vclefpCode, toInt = True)
31017639Sgblack@eecs.umich.edu
31027639Sgblack@eecs.umich.edu    vcltCode = 'destElem = (srcElem1 < 0) ? mask(sizeof(Element) * 8) : 0;'
31037760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vclt", "NVcltD", "SimdCmpOp", signedTypes, 2, vcltCode)
31047760SGiacomo.Gabrielli@arm.com    twoRegMiscInst("vclt", "NVcltQ", "SimdCmpOp", signedTypes, 4, vcltCode)
31057639Sgblack@eecs.umich.edu    vcltfpCode = '''
31067783SGiacomo.Gabrielli@arm.com        FPSCR fpscr = (FPSCR) FpscrExc;
31077639Sgblack@eecs.umich.edu        float res = binaryOp(fpscr, srcReg1, (FloatReg)0.0, vcltFunc,
31087639Sgblack@eecs.umich.edu                             true, true, VfpRoundNearest);
31097639Sgblack@eecs.umich.edu        destReg = (res == 0) ? -1 : 0;
31107639Sgblack@eecs.umich.edu        if (res == 2.0)
31117639Sgblack@eecs.umich.edu            fpscr.ioc = 1;
31127783SGiacomo.Gabrielli@arm.com        FpscrExc = fpscr;
31137639Sgblack@eecs.umich.edu    '''
31147760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vclt", "NVcltDFp", "SimdFloatCmpOp", ("float",),
31157639Sgblack@eecs.umich.edu            2, vcltfpCode, toInt = True)
31167760SGiacomo.Gabrielli@arm.com    twoRegMiscInstFp("vclt", "NVcltQFp", "SimdFloatCmpOp", ("float",),
31177639Sgblack@eecs.umich.edu            4, vcltfpCode, toInt = True)
31187639Sgblack@eecs.umich.edu
31197639Sgblack@eecs.umich.edu    vswpCode = '''
31207639Sgblack@eecs.umich.edu        FloatRegBits mid;
31217639Sgblack@eecs.umich.edu        for (unsigned r = 0; r < rCount; r++) {
31227639Sgblack@eecs.umich.edu            mid = srcReg1.regs[r];
31237639Sgblack@eecs.umich.edu            srcReg1.regs[r] = destReg.regs[r];
31247639Sgblack@eecs.umich.edu            destReg.regs[r] = mid;
31257639Sgblack@eecs.umich.edu        }
31267639Sgblack@eecs.umich.edu    '''
31277760SGiacomo.Gabrielli@arm.com    twoRegMiscScramble("vswp", "NVswpD", "SimdAluOp", ("uint64_t",), 2, vswpCode)
31287760SGiacomo.Gabrielli@arm.com    twoRegMiscScramble("vswp", "NVswpQ", "SimdAluOp", ("uint64_t",), 4, vswpCode)
31297639Sgblack@eecs.umich.edu
31307639Sgblack@eecs.umich.edu    vtrnCode = '''
31317639Sgblack@eecs.umich.edu        Element mid;
31327639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i += 2) {
31337639Sgblack@eecs.umich.edu            mid = srcReg1.elements[i];
31347639Sgblack@eecs.umich.edu            srcReg1.elements[i] = destReg.elements[i + 1];
31357639Sgblack@eecs.umich.edu            destReg.elements[i + 1] = mid;
31367639Sgblack@eecs.umich.edu        }
31377639Sgblack@eecs.umich.edu    '''
31388607Sgblack@eecs.umich.edu    twoRegMiscScramble("vtrn", "NVtrnD", "SimdAluOp",
31398607Sgblack@eecs.umich.edu            smallUnsignedTypes, 2, vtrnCode)
31408607Sgblack@eecs.umich.edu    twoRegMiscScramble("vtrn", "NVtrnQ", "SimdAluOp",
31418607Sgblack@eecs.umich.edu            smallUnsignedTypes, 4, vtrnCode)
31427639Sgblack@eecs.umich.edu
31437639Sgblack@eecs.umich.edu    vuzpCode = '''
31447639Sgblack@eecs.umich.edu        Element mid[eCount];
31457639Sgblack@eecs.umich.edu        memcpy(&mid, &srcReg1, sizeof(srcReg1));
31467639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount / 2; i++) {
31477639Sgblack@eecs.umich.edu            srcReg1.elements[i] = destReg.elements[2 * i + 1];
31487639Sgblack@eecs.umich.edu            srcReg1.elements[eCount / 2 + i] = mid[2 * i + 1];
31497639Sgblack@eecs.umich.edu            destReg.elements[i] = destReg.elements[2 * i];
31507639Sgblack@eecs.umich.edu        }
31517639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount / 2; i++) {
31527639Sgblack@eecs.umich.edu            destReg.elements[eCount / 2 + i] = mid[2 * i];
31537639Sgblack@eecs.umich.edu        }
31547639Sgblack@eecs.umich.edu    '''
31557760SGiacomo.Gabrielli@arm.com    twoRegMiscScramble("vuzp", "NVuzpD", "SimdAluOp", unsignedTypes, 2, vuzpCode)
31567760SGiacomo.Gabrielli@arm.com    twoRegMiscScramble("vuzp", "NVuzpQ", "SimdAluOp", unsignedTypes, 4, vuzpCode)
31577639Sgblack@eecs.umich.edu
31587639Sgblack@eecs.umich.edu    vzipCode = '''
31597639Sgblack@eecs.umich.edu        Element mid[eCount];
31607639Sgblack@eecs.umich.edu        memcpy(&mid, &destReg, sizeof(destReg));
31617639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount / 2; i++) {
31627639Sgblack@eecs.umich.edu            destReg.elements[2 * i] = mid[i];
31637639Sgblack@eecs.umich.edu            destReg.elements[2 * i + 1] = srcReg1.elements[i];
31647639Sgblack@eecs.umich.edu        }
31657639Sgblack@eecs.umich.edu        for (int i = 0; i < eCount / 2; i++) {
31667639Sgblack@eecs.umich.edu            srcReg1.elements[2 * i] = mid[eCount / 2 + i];
31677639Sgblack@eecs.umich.edu            srcReg1.elements[2 * i + 1] = srcReg1.elements[eCount / 2 + i];
31687639Sgblack@eecs.umich.edu        }
31697639Sgblack@eecs.umich.edu    '''
31707760SGiacomo.Gabrielli@arm.com    twoRegMiscScramble("vzip", "NVzipD", "SimdAluOp", unsignedTypes, 2, vzipCode)
31717760SGiacomo.Gabrielli@arm.com    twoRegMiscScramble("vzip", "NVzipQ", "SimdAluOp", unsignedTypes, 4, vzipCode)
31727639Sgblack@eecs.umich.edu
31737639Sgblack@eecs.umich.edu    vmovnCode = 'destElem = srcElem1;'
31747760SGiacomo.Gabrielli@arm.com    twoRegNarrowMiscInst("vmovn", "NVmovn", "SimdMiscOp", smallUnsignedTypes, vmovnCode)
31757639Sgblack@eecs.umich.edu
31767639Sgblack@eecs.umich.edu    vdupCode = 'destElem = srcElem1;'
31777760SGiacomo.Gabrielli@arm.com    twoRegMiscScInst("vdup", "NVdupD", "SimdAluOp", smallUnsignedTypes, 2, vdupCode)
31787760SGiacomo.Gabrielli@arm.com    twoRegMiscScInst("vdup", "NVdupQ", "SimdAluOp", smallUnsignedTypes, 4, vdupCode)
31797639Sgblack@eecs.umich.edu
31807760SGiacomo.Gabrielli@arm.com    def vdupGprInst(name, Name, opClass, types, rCount):
31817639Sgblack@eecs.umich.edu        global header_output, exec_output
31827639Sgblack@eecs.umich.edu        eWalkCode = '''
31837639Sgblack@eecs.umich.edu        RegVect destReg;
31847639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
31857639Sgblack@eecs.umich.edu            destReg.elements[i] = htog((Element)Op1);
31867639Sgblack@eecs.umich.edu        }
31877639Sgblack@eecs.umich.edu        '''
31887639Sgblack@eecs.umich.edu        for reg in range(rCount):
31897639Sgblack@eecs.umich.edu            eWalkCode += '''
31908588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
31917639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
31927639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
31937639Sgblack@eecs.umich.edu                            "RegRegOp",
31947639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
31957639Sgblack@eecs.umich.edu                              "r_count": rCount,
31967760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
31977760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
31987639Sgblack@eecs.umich.edu        header_output += NeonRegRegOpDeclare.subst(iop)
31997639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
32007639Sgblack@eecs.umich.edu        for type in types:
32017639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
32027639Sgblack@eecs.umich.edu                          "class_name" : Name }
32037639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
32048206SWilliam.Wang@arm.com    vdupGprInst("vdup", "NVdupDGpr", "SimdMiscOp", smallUnsignedTypes, 2)
32058206SWilliam.Wang@arm.com    vdupGprInst("vdup", "NVdupQGpr", "SimdMiscOp", smallUnsignedTypes, 4)
32067639Sgblack@eecs.umich.edu
32077639Sgblack@eecs.umich.edu    vmovCode = 'destElem = imm;'
32087760SGiacomo.Gabrielli@arm.com    oneRegImmInst("vmov", "NVmoviD", "SimdMiscOp", ("uint64_t",), 2, vmovCode)
32097760SGiacomo.Gabrielli@arm.com    oneRegImmInst("vmov", "NVmoviQ", "SimdMiscOp", ("uint64_t",), 4, vmovCode)
32107639Sgblack@eecs.umich.edu
32117639Sgblack@eecs.umich.edu    vorrCode = 'destElem |= imm;'
32127760SGiacomo.Gabrielli@arm.com    oneRegImmInst("vorr", "NVorriD", "SimdAluOp", ("uint64_t",), 2, vorrCode, True)
32137760SGiacomo.Gabrielli@arm.com    oneRegImmInst("vorr", "NVorriQ", "SimdAluOp", ("uint64_t",), 4, vorrCode, True)
32147639Sgblack@eecs.umich.edu
32157639Sgblack@eecs.umich.edu    vmvnCode = 'destElem = ~imm;'
32167760SGiacomo.Gabrielli@arm.com    oneRegImmInst("vmvn", "NVmvniD", "SimdAluOp", ("uint64_t",), 2, vmvnCode)
32177760SGiacomo.Gabrielli@arm.com    oneRegImmInst("vmvn", "NVmvniQ", "SimdAluOp", ("uint64_t",), 4, vmvnCode)
32187639Sgblack@eecs.umich.edu
32197639Sgblack@eecs.umich.edu    vbicCode = 'destElem &= ~imm;'
32207760SGiacomo.Gabrielli@arm.com    oneRegImmInst("vbic", "NVbiciD", "SimdAluOp", ("uint64_t",), 2, vbicCode, True)
32217760SGiacomo.Gabrielli@arm.com    oneRegImmInst("vbic", "NVbiciQ", "SimdAluOp", ("uint64_t",), 4, vbicCode, True)
32227639Sgblack@eecs.umich.edu
32237639Sgblack@eecs.umich.edu    vqmovnCode = '''
32247783SGiacomo.Gabrielli@arm.com    FPSCR fpscr = (FPSCR) FpscrQc;
32257639Sgblack@eecs.umich.edu    destElem = srcElem1;
32267639Sgblack@eecs.umich.edu    if ((BigElement)destElem != srcElem1) {
32277639Sgblack@eecs.umich.edu        fpscr.qc = 1;
32287639Sgblack@eecs.umich.edu        destElem = mask(sizeof(Element) * 8 - 1);
32297639Sgblack@eecs.umich.edu        if (srcElem1 < 0)
32307639Sgblack@eecs.umich.edu            destElem = ~destElem;
32317639Sgblack@eecs.umich.edu    }
32327783SGiacomo.Gabrielli@arm.com    FpscrQc = fpscr;
32337639Sgblack@eecs.umich.edu    '''
32347760SGiacomo.Gabrielli@arm.com    twoRegNarrowMiscInst("vqmovn", "NVqmovn", "SimdMiscOp", smallSignedTypes, vqmovnCode)
32357639Sgblack@eecs.umich.edu
32367639Sgblack@eecs.umich.edu    vqmovunCode = '''
32377783SGiacomo.Gabrielli@arm.com    FPSCR fpscr = (FPSCR) FpscrQc;
32387639Sgblack@eecs.umich.edu    destElem = srcElem1;
32397639Sgblack@eecs.umich.edu    if ((BigElement)destElem != srcElem1) {
32407639Sgblack@eecs.umich.edu        fpscr.qc = 1;
32417639Sgblack@eecs.umich.edu        destElem = mask(sizeof(Element) * 8);
32427639Sgblack@eecs.umich.edu    }
32437783SGiacomo.Gabrielli@arm.com    FpscrQc = fpscr;
32447639Sgblack@eecs.umich.edu    '''
32457639Sgblack@eecs.umich.edu    twoRegNarrowMiscInst("vqmovun", "NVqmovun",
32467760SGiacomo.Gabrielli@arm.com            "SimdMiscOp", smallUnsignedTypes, vqmovunCode)
32477639Sgblack@eecs.umich.edu
32487639Sgblack@eecs.umich.edu    vqmovunsCode = '''
32497783SGiacomo.Gabrielli@arm.com    FPSCR fpscr = (FPSCR) FpscrQc;
32507639Sgblack@eecs.umich.edu    destElem = srcElem1;
32517639Sgblack@eecs.umich.edu    if (srcElem1 < 0 ||
32527639Sgblack@eecs.umich.edu            ((BigElement)destElem & mask(sizeof(Element) * 8)) != srcElem1) {
32537639Sgblack@eecs.umich.edu        fpscr.qc = 1;
32547639Sgblack@eecs.umich.edu        destElem = mask(sizeof(Element) * 8);
32557639Sgblack@eecs.umich.edu        if (srcElem1 < 0)
32567639Sgblack@eecs.umich.edu            destElem = ~destElem;
32577639Sgblack@eecs.umich.edu    }
32587783SGiacomo.Gabrielli@arm.com    FpscrQc = fpscr;
32597639Sgblack@eecs.umich.edu    '''
32607639Sgblack@eecs.umich.edu    twoRegNarrowMiscInst("vqmovun", "NVqmovuns",
32617760SGiacomo.Gabrielli@arm.com            "SimdMiscOp", smallSignedTypes, vqmovunsCode)
32627639Sgblack@eecs.umich.edu
32637760SGiacomo.Gabrielli@arm.com    def buildVext(name, Name, opClass, types, rCount, op):
32647639Sgblack@eecs.umich.edu        global header_output, exec_output
32657639Sgblack@eecs.umich.edu        eWalkCode = '''
32667639Sgblack@eecs.umich.edu        RegVect srcReg1, srcReg2, destReg;
32677639Sgblack@eecs.umich.edu        '''
32687639Sgblack@eecs.umich.edu        for reg in range(rCount):
32697644Sali.saidi@arm.com            eWalkCode += simdEnabledCheckCode + '''
32708588Sgblack@eecs.umich.edu                srcReg1.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);
32718588Sgblack@eecs.umich.edu                srcReg2.regs[%(reg)d] = htog(FpOp2P%(reg)d_uw);
32727639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
32737639Sgblack@eecs.umich.edu        eWalkCode += op
32747639Sgblack@eecs.umich.edu        for reg in range(rCount):
32757639Sgblack@eecs.umich.edu            eWalkCode += '''
32768588Sgblack@eecs.umich.edu            FpDestP%(reg)d_uw = gtoh(destReg.regs[%(reg)d]);
32777639Sgblack@eecs.umich.edu            ''' % { "reg" : reg }
32787639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
32797639Sgblack@eecs.umich.edu                            "RegRegRegImmOp",
32807639Sgblack@eecs.umich.edu                            { "code": eWalkCode,
32817639Sgblack@eecs.umich.edu                              "r_count": rCount,
32827760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
32837760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
32847639Sgblack@eecs.umich.edu        header_output += NeonRegRegRegImmOpDeclare.subst(iop)
32857639Sgblack@eecs.umich.edu        exec_output += NeonEqualRegExecute.subst(iop)
32867639Sgblack@eecs.umich.edu        for type in types:
32877639Sgblack@eecs.umich.edu            substDict = { "targs" : type,
32887639Sgblack@eecs.umich.edu                          "class_name" : Name }
32897639Sgblack@eecs.umich.edu            exec_output += NeonExecDeclare.subst(substDict)
32907639Sgblack@eecs.umich.edu
32917639Sgblack@eecs.umich.edu    vextCode = '''
32927639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < eCount; i++) {
32937639Sgblack@eecs.umich.edu            unsigned index = i + imm;
32947639Sgblack@eecs.umich.edu            if (index < eCount) {
32957639Sgblack@eecs.umich.edu                destReg.elements[i] = srcReg1.elements[index];
32967639Sgblack@eecs.umich.edu            } else {
32977639Sgblack@eecs.umich.edu                index -= eCount;
32988782Sgblack@eecs.umich.edu                if (index >= eCount) {
32998782Sgblack@eecs.umich.edu                    if (FullSystem)
33008782Sgblack@eecs.umich.edu                        fault = new UndefinedInstruction;
33018782Sgblack@eecs.umich.edu                    else
33028782Sgblack@eecs.umich.edu                        fault = new UndefinedInstruction(false, mnemonic);
33038782Sgblack@eecs.umich.edu                } else {
33047853SMatt.Horsnell@ARM.com                    destReg.elements[i] = srcReg2.elements[index];
33058782Sgblack@eecs.umich.edu                }
33067639Sgblack@eecs.umich.edu            }
33077639Sgblack@eecs.umich.edu        }
33087639Sgblack@eecs.umich.edu    '''
33098206SWilliam.Wang@arm.com    buildVext("vext", "NVextD", "SimdMiscOp", ("uint8_t",), 2, vextCode)
33108206SWilliam.Wang@arm.com    buildVext("vext", "NVextQ", "SimdMiscOp", ("uint8_t",), 4, vextCode)
33117639Sgblack@eecs.umich.edu
33127760SGiacomo.Gabrielli@arm.com    def buildVtbxl(name, Name, opClass, length, isVtbl):
33137639Sgblack@eecs.umich.edu        global header_output, decoder_output, exec_output
33147639Sgblack@eecs.umich.edu        code = '''
33157639Sgblack@eecs.umich.edu            union
33167639Sgblack@eecs.umich.edu            {
33177639Sgblack@eecs.umich.edu                uint8_t bytes[32];
33187639Sgblack@eecs.umich.edu                FloatRegBits regs[8];
33197639Sgblack@eecs.umich.edu            } table;
33207639Sgblack@eecs.umich.edu
33217639Sgblack@eecs.umich.edu            union
33227639Sgblack@eecs.umich.edu            {
33237639Sgblack@eecs.umich.edu                uint8_t bytes[8];
33247639Sgblack@eecs.umich.edu                FloatRegBits regs[2];
33257639Sgblack@eecs.umich.edu            } destReg, srcReg2;
33267639Sgblack@eecs.umich.edu
33277639Sgblack@eecs.umich.edu            const unsigned length = %(length)d;
33287639Sgblack@eecs.umich.edu            const bool isVtbl = %(isVtbl)s;
33297639Sgblack@eecs.umich.edu
33308588Sgblack@eecs.umich.edu            srcReg2.regs[0] = htog(FpOp2P0_uw);
33318588Sgblack@eecs.umich.edu            srcReg2.regs[1] = htog(FpOp2P1_uw);
33327639Sgblack@eecs.umich.edu
33338588Sgblack@eecs.umich.edu            destReg.regs[0] = htog(FpDestP0_uw);
33348588Sgblack@eecs.umich.edu            destReg.regs[1] = htog(FpDestP1_uw);
33357639Sgblack@eecs.umich.edu        ''' % { "length" : length, "isVtbl" : isVtbl }
33367639Sgblack@eecs.umich.edu        for reg in range(8):
33377639Sgblack@eecs.umich.edu            if reg < length * 2:
33388588Sgblack@eecs.umich.edu                code += 'table.regs[%(reg)d] = htog(FpOp1P%(reg)d_uw);\n' % \
33397639Sgblack@eecs.umich.edu                        { "reg" : reg }
33407639Sgblack@eecs.umich.edu            else:
33417639Sgblack@eecs.umich.edu                code += 'table.regs[%(reg)d] = 0;\n' % { "reg" : reg }
33427639Sgblack@eecs.umich.edu        code += '''
33437639Sgblack@eecs.umich.edu        for (unsigned i = 0; i < sizeof(destReg); i++) {
33447639Sgblack@eecs.umich.edu            uint8_t index = srcReg2.bytes[i];
33457639Sgblack@eecs.umich.edu            if (index < 8 * length) {
33467639Sgblack@eecs.umich.edu                destReg.bytes[i] = table.bytes[index];
33477639Sgblack@eecs.umich.edu            } else {
33487639Sgblack@eecs.umich.edu                if (isVtbl)
33497639Sgblack@eecs.umich.edu                    destReg.bytes[i] = 0;
33507639Sgblack@eecs.umich.edu                // else destReg.bytes[i] unchanged
33517639Sgblack@eecs.umich.edu            }
33527639Sgblack@eecs.umich.edu        }
33537639Sgblack@eecs.umich.edu
33548588Sgblack@eecs.umich.edu        FpDestP0_uw = gtoh(destReg.regs[0]);
33558588Sgblack@eecs.umich.edu        FpDestP1_uw = gtoh(destReg.regs[1]);
33567639Sgblack@eecs.umich.edu        '''
33577639Sgblack@eecs.umich.edu        iop = InstObjParams(name, Name,
33587639Sgblack@eecs.umich.edu                            "RegRegRegOp",
33597639Sgblack@eecs.umich.edu                            { "code": code,
33607760SGiacomo.Gabrielli@arm.com                              "predicate_test": predicateTest,
33617760SGiacomo.Gabrielli@arm.com                              "op_class": opClass }, [])
33627639Sgblack@eecs.umich.edu        header_output += RegRegRegOpDeclare.subst(iop)
33637639Sgblack@eecs.umich.edu        decoder_output += RegRegRegOpConstructor.subst(iop)
33647639Sgblack@eecs.umich.edu        exec_output += PredOpExecute.subst(iop)
33657639Sgblack@eecs.umich.edu
33668206SWilliam.Wang@arm.com    buildVtbxl("vtbl", "NVtbl1", "SimdMiscOp", 1, "true")
33678206SWilliam.Wang@arm.com    buildVtbxl("vtbl", "NVtbl2", "SimdMiscOp", 2, "true")
33688206SWilliam.Wang@arm.com    buildVtbxl("vtbl", "NVtbl3", "SimdMiscOp", 3, "true")
33698206SWilliam.Wang@arm.com    buildVtbxl("vtbl", "NVtbl4", "SimdMiscOp", 4, "true")
33707639Sgblack@eecs.umich.edu
33718206SWilliam.Wang@arm.com    buildVtbxl("vtbx", "NVtbx1", "SimdMiscOp", 1, "false")
33728206SWilliam.Wang@arm.com    buildVtbxl("vtbx", "NVtbx2", "SimdMiscOp", 2, "false")
33738206SWilliam.Wang@arm.com    buildVtbxl("vtbx", "NVtbx3", "SimdMiscOp", 3, "false")
33748206SWilliam.Wang@arm.com    buildVtbxl("vtbx", "NVtbx4", "SimdMiscOp", 4, "false")
33757639Sgblack@eecs.umich.edu}};
3376