neon.isa revision 7639
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.edudef template NeonRegRegRegOpDeclare {{
417639Sgblack@eecs.umich.edutemplate <class _Element>
427639Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s
437639Sgblack@eecs.umich.edu{
447639Sgblack@eecs.umich.edu  protected:
457639Sgblack@eecs.umich.edu    typedef _Element Element;
467639Sgblack@eecs.umich.edu  public:
477639Sgblack@eecs.umich.edu    // Constructor
487639Sgblack@eecs.umich.edu    %(class_name)s(ExtMachInst machInst,
497639Sgblack@eecs.umich.edu                   IntRegIndex _dest, IntRegIndex _op1, IntRegIndex _op2)
507639Sgblack@eecs.umich.edu        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
517639Sgblack@eecs.umich.edu                         _dest, _op1, _op2)
527639Sgblack@eecs.umich.edu    {
537639Sgblack@eecs.umich.edu        %(constructor)s;
547639Sgblack@eecs.umich.edu    }
557639Sgblack@eecs.umich.edu
567639Sgblack@eecs.umich.edu    %(BasicExecDeclare)s
577639Sgblack@eecs.umich.edu};
587639Sgblack@eecs.umich.edu}};
597639Sgblack@eecs.umich.edu
607639Sgblack@eecs.umich.edudef template NeonRegRegRegImmOpDeclare {{
617639Sgblack@eecs.umich.edutemplate <class _Element>
627639Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s
637639Sgblack@eecs.umich.edu{
647639Sgblack@eecs.umich.edu  protected:
657639Sgblack@eecs.umich.edu    typedef _Element Element;
667639Sgblack@eecs.umich.edu  public:
677639Sgblack@eecs.umich.edu    // Constructor
687639Sgblack@eecs.umich.edu    %(class_name)s(ExtMachInst machInst,
697639Sgblack@eecs.umich.edu                   IntRegIndex _dest, IntRegIndex _op1, IntRegIndex _op2,
707639Sgblack@eecs.umich.edu                   uint64_t _imm)
717639Sgblack@eecs.umich.edu        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
727639Sgblack@eecs.umich.edu                         _dest, _op1, _op2, _imm)
737639Sgblack@eecs.umich.edu    {
747639Sgblack@eecs.umich.edu        %(constructor)s;
757639Sgblack@eecs.umich.edu    }
767639Sgblack@eecs.umich.edu
777639Sgblack@eecs.umich.edu    %(BasicExecDeclare)s
787639Sgblack@eecs.umich.edu};
797639Sgblack@eecs.umich.edu}};
807639Sgblack@eecs.umich.edu
817639Sgblack@eecs.umich.edudef template NeonRegRegImmOpDeclare {{
827639Sgblack@eecs.umich.edutemplate <class _Element>
837639Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s
847639Sgblack@eecs.umich.edu{
857639Sgblack@eecs.umich.edu  protected:
867639Sgblack@eecs.umich.edu    typedef _Element Element;
877639Sgblack@eecs.umich.edu  public:
887639Sgblack@eecs.umich.edu    // Constructor
897639Sgblack@eecs.umich.edu    %(class_name)s(ExtMachInst machInst,
907639Sgblack@eecs.umich.edu                   IntRegIndex _dest, IntRegIndex _op1, uint64_t _imm)
917639Sgblack@eecs.umich.edu        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
927639Sgblack@eecs.umich.edu                         _dest, _op1, _imm)
937639Sgblack@eecs.umich.edu    {
947639Sgblack@eecs.umich.edu        %(constructor)s;
957639Sgblack@eecs.umich.edu    }
967639Sgblack@eecs.umich.edu
977639Sgblack@eecs.umich.edu    %(BasicExecDeclare)s
987639Sgblack@eecs.umich.edu};
997639Sgblack@eecs.umich.edu}};
1007639Sgblack@eecs.umich.edu
1017639Sgblack@eecs.umich.edudef template NeonRegImmOpDeclare {{
1027639Sgblack@eecs.umich.edutemplate <class _Element>
1037639Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s
1047639Sgblack@eecs.umich.edu{
1057639Sgblack@eecs.umich.edu  protected:
1067639Sgblack@eecs.umich.edu    typedef _Element Element;
1077639Sgblack@eecs.umich.edu  public:
1087639Sgblack@eecs.umich.edu    // Constructor
1097639Sgblack@eecs.umich.edu    %(class_name)s(ExtMachInst machInst, IntRegIndex _dest, uint64_t _imm)
1107639Sgblack@eecs.umich.edu        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, _dest, _imm)
1117639Sgblack@eecs.umich.edu    {
1127639Sgblack@eecs.umich.edu        %(constructor)s;
1137639Sgblack@eecs.umich.edu    }
1147639Sgblack@eecs.umich.edu
1157639Sgblack@eecs.umich.edu    %(BasicExecDeclare)s
1167639Sgblack@eecs.umich.edu};
1177639Sgblack@eecs.umich.edu}};
1187639Sgblack@eecs.umich.edu
1197639Sgblack@eecs.umich.edudef template NeonRegRegOpDeclare {{
1207639Sgblack@eecs.umich.edutemplate <class _Element>
1217639Sgblack@eecs.umich.educlass %(class_name)s : public %(base_class)s
1227639Sgblack@eecs.umich.edu{
1237639Sgblack@eecs.umich.edu  protected:
1247639Sgblack@eecs.umich.edu    typedef _Element Element;
1257639Sgblack@eecs.umich.edu  public:
1267639Sgblack@eecs.umich.edu    // Constructor
1277639Sgblack@eecs.umich.edu    %(class_name)s(ExtMachInst machInst,
1287639Sgblack@eecs.umich.edu                   IntRegIndex _dest, IntRegIndex _op1)
1297639Sgblack@eecs.umich.edu        : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s,
1307639Sgblack@eecs.umich.edu                         _dest, _op1)
1317639Sgblack@eecs.umich.edu    {
1327639Sgblack@eecs.umich.edu        %(constructor)s;
1337639Sgblack@eecs.umich.edu    }
1347639Sgblack@eecs.umich.edu
1357639Sgblack@eecs.umich.edu    %(BasicExecDeclare)s
1367639Sgblack@eecs.umich.edu};
1377639Sgblack@eecs.umich.edu}};
1387639Sgblack@eecs.umich.edu
1397639Sgblack@eecs.umich.edudef template NeonExecDeclare {{
1407639Sgblack@eecs.umich.edu    template
1417639Sgblack@eecs.umich.edu    Fault %(class_name)s<%(targs)s>::execute(
1427639Sgblack@eecs.umich.edu            %(CPU_exec_context)s *, Trace::InstRecord *) const;
1437639Sgblack@eecs.umich.edu}};
1447639Sgblack@eecs.umich.edu
1457639Sgblack@eecs.umich.edudef template NeonEqualRegExecute {{
1467639Sgblack@eecs.umich.edu    template <class Element>
1477639Sgblack@eecs.umich.edu    Fault %(class_name)s<Element>::execute(%(CPU_exec_context)s *xc,
1487639Sgblack@eecs.umich.edu            Trace::InstRecord *traceData) const
1497639Sgblack@eecs.umich.edu    {
1507639Sgblack@eecs.umich.edu        Fault fault = NoFault;
1517639Sgblack@eecs.umich.edu        %(op_decl)s;
1527639Sgblack@eecs.umich.edu        %(op_rd)s;
1537639Sgblack@eecs.umich.edu
1547639Sgblack@eecs.umich.edu        const unsigned rCount = %(r_count)d;
1557639Sgblack@eecs.umich.edu        const unsigned eCount = rCount * sizeof(FloatRegBits) / sizeof(Element);
1567639Sgblack@eecs.umich.edu
1577639Sgblack@eecs.umich.edu        union RegVect {
1587639Sgblack@eecs.umich.edu            FloatRegBits regs[rCount];
1597639Sgblack@eecs.umich.edu            Element elements[eCount];
1607639Sgblack@eecs.umich.edu        };
1617639Sgblack@eecs.umich.edu
1627639Sgblack@eecs.umich.edu        if (%(predicate_test)s)
1637639Sgblack@eecs.umich.edu        {
1647639Sgblack@eecs.umich.edu            %(code)s;
1657639Sgblack@eecs.umich.edu            if (fault == NoFault)
1667639Sgblack@eecs.umich.edu            {
1677639Sgblack@eecs.umich.edu                %(op_wb)s;
1687639Sgblack@eecs.umich.edu            }
1697639Sgblack@eecs.umich.edu        }
1707639Sgblack@eecs.umich.edu
1717639Sgblack@eecs.umich.edu        if (fault == NoFault && machInst.itstateMask != 0) {
1727639Sgblack@eecs.umich.edu            xc->setMiscReg(MISCREG_ITSTATE, machInst.newItstate);
1737639Sgblack@eecs.umich.edu        }
1747639Sgblack@eecs.umich.edu
1757639Sgblack@eecs.umich.edu        return fault;
1767639Sgblack@eecs.umich.edu    }
1777639Sgblack@eecs.umich.edu}};
1787639Sgblack@eecs.umich.edu
1797639Sgblack@eecs.umich.eduoutput header {{
1807639Sgblack@eecs.umich.edu    uint16_t nextBiggerType(uint8_t);
1817639Sgblack@eecs.umich.edu    uint32_t nextBiggerType(uint16_t);
1827639Sgblack@eecs.umich.edu    uint64_t nextBiggerType(uint32_t);
1837639Sgblack@eecs.umich.edu    int16_t nextBiggerType(int8_t);
1847639Sgblack@eecs.umich.edu    int32_t nextBiggerType(int16_t);
1857639Sgblack@eecs.umich.edu    int64_t nextBiggerType(int32_t);
1867639Sgblack@eecs.umich.edu}};
1877639Sgblack@eecs.umich.edu
1887639Sgblack@eecs.umich.edudef template NeonUnequalRegExecute {{
1897639Sgblack@eecs.umich.edu    template <class Element>
1907639Sgblack@eecs.umich.edu    Fault %(class_name)s<Element>::execute(%(CPU_exec_context)s *xc,
1917639Sgblack@eecs.umich.edu            Trace::InstRecord *traceData) const
1927639Sgblack@eecs.umich.edu    {
1937639Sgblack@eecs.umich.edu        typedef typeof(nextBiggerType((Element)0)) BigElement;
1947639Sgblack@eecs.umich.edu        Fault fault = NoFault;
1957639Sgblack@eecs.umich.edu        %(op_decl)s;
1967639Sgblack@eecs.umich.edu        %(op_rd)s;
1977639Sgblack@eecs.umich.edu
1987639Sgblack@eecs.umich.edu        const unsigned rCount = %(r_count)d;
1997639Sgblack@eecs.umich.edu        const unsigned eCount = rCount * sizeof(FloatRegBits) / sizeof(Element);
2007639Sgblack@eecs.umich.edu
2017639Sgblack@eecs.umich.edu        union RegVect {
2027639Sgblack@eecs.umich.edu            FloatRegBits regs[rCount];
2037639Sgblack@eecs.umich.edu            Element elements[eCount];
2047639Sgblack@eecs.umich.edu            BigElement bigElements[eCount / 2];
2057639Sgblack@eecs.umich.edu        };
2067639Sgblack@eecs.umich.edu
2077639Sgblack@eecs.umich.edu        union BigRegVect {
2087639Sgblack@eecs.umich.edu            FloatRegBits regs[2 * rCount];
2097639Sgblack@eecs.umich.edu            BigElement elements[eCount];
2107639Sgblack@eecs.umich.edu        };
2117639Sgblack@eecs.umich.edu
2127639Sgblack@eecs.umich.edu        if (%(predicate_test)s)
2137639Sgblack@eecs.umich.edu        {
2147639Sgblack@eecs.umich.edu            %(code)s;
2157639Sgblack@eecs.umich.edu            if (fault == NoFault)
2167639Sgblack@eecs.umich.edu            {
2177639Sgblack@eecs.umich.edu                %(op_wb)s;
2187639Sgblack@eecs.umich.edu            }
2197639Sgblack@eecs.umich.edu        }
2207639Sgblack@eecs.umich.edu
2217639Sgblack@eecs.umich.edu        if (fault == NoFault && machInst.itstateMask != 0) {
2227639Sgblack@eecs.umich.edu            xc->setMiscReg(MISCREG_ITSTATE, machInst.newItstate);
2237639Sgblack@eecs.umich.edu        }
2247639Sgblack@eecs.umich.edu
2257639Sgblack@eecs.umich.edu        return fault;
2267639Sgblack@eecs.umich.edu    }
2277639Sgblack@eecs.umich.edu}};
228